41 #ifndef _uitextcursor_cpp
42 #define _uitextcursor_cpp
44 #include "UI/textcursor.h"
45 #include "UI/textline.h"
46 #include "UI/character.h"
47 #include "MathTools/mathtools.h"
48 #include "stringtool.h"
99 if( ResultPair.first ) {
113 if( (*Last)->GetNumCharacters() > 0 ) {
114 Ret.
Size.
Y = (*Last)->GetLineHeight();
115 Ret.
Size.
X = MathTools::Floor( Ret.
Size.
Y * 0.1 ) + 1.0;
116 Ret.
Position.
Y = (*Last)->GetPositionOffset();
117 Ret.
Position.
X = (*Last)->GetOffsetAtIndex(-1);
120 Ret.
Size.
X = MathTools::Floor( Ret.
Size.
Y * 0.1 ) + 1.0;
121 Ret.
Position.
Y = ( (*Last)->GetPositionOffset() + ( Ret.
Size.
Y * 0.5 ) );
122 Ret.
Position.
X = (*Last)->GetOffsetAtIndex(-1);
130 IndexCount += (*LineIt)->GetNumCharacters();
134 if( (*LineIt)->GetNumCharacters() > 0 ) {
135 Ret.
Size.
Y = (*LineIt)->GetLineHeight();
136 Ret.
Size.
X = MathTools::Floor( Ret.
Size.
Y * 0.1 ) + 1.0;
137 Ret.
Position.
Y = (*LineIt)->GetPositionOffset();
141 Ret.
Size.
X = MathTools::Floor( Ret.
Size.
Y * 0.1 ) + 1.0;
142 Ret.
Position.
Y = ( (*LineIt)->GetPositionOffset() + ( Ret.
Size.
Y * 0.5 ) );
258 if( !SelfRoot.
Empty() ) {
261 if( !CurrAttrib.
Empty() )
265 if( !CurrAttrib.
Empty() )
269 if( !CursorColourNode.
Empty() )
280 {
return "TextCursor"; }
virtual Integer InsertCharacterAtIndex(const Integer Index, const UInt32 GlyphID)
Creates a character from a Glyph ID and inserts it into the layer at the specified index...
std::pair< Boole, Vector2 > CharOffsetPair
An std::pair type used as a return for index-offset conversions.
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
virtual TextLineIterator BeginTextLine()
Gets an iterator to the first TextLine.
A light-weight handle for manipulating attributes in DOM tree.
Boole Visibility
Stores the cursors current visibility state.
virtual TextLineIterator EndTextLine()
Gets an iterator to one passed the last TextLine.
Integer IndexPosition
The index of the character this TextCursor is to the left of.
bool Boole
Generally acts a single bit, true or false.
virtual ~TextCursor()
Class destructor.
Vector2 Size
Vector2 representing the width and height of the rect.
virtual void InsertCharacterAtCursor(const UInt32 GlyphID)
Creates a character from a Glyph ID and inserts it at the cursor position.
virtual void ProtoSerialize(XML::Node &ParentNode) const
Convert this class to an XML::Node ready for serialization.
Thrown when the requested identity could not be found.
virtual void MoveCursorLeft()
Decrements this cursors index position, moving it to the left.
Node GetFirstChild() const
Get the first child Node of this Node.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
int Integer
A datatype used to represent any integer close to.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
const Char8 * AsString(const Char8 *def="") const
Attempts to convert the value of the attribute to a String and returns the results.
virtual void MoveCursorRight()
Increments this cursors index position, moving it to the right.
This class represents a box shaped area on the screen.
static ColourValue Black()
Creates a ColourValue representing the colour Black.
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
virtual void _MarkDirty()
Marks this renderable as well as all parent objects as dirty.
bool Empty() const
Is this storing anything at all?
TextLineContainer::iterator TextLineIterator
Iterator type for TextLine instances stored by this class.
ColourValue CursorColour
The colour to be given to the TextCursor.
TextCursor(TextLayer *Creator)
Class constructor.
std::pair< Boole, Integer > CharIndexPair
An std::pair type used as a return for index-offset conversions.
char Char8
A datatype to represent one character.
virtual void SetColour(const ColourValue &Colour)
Sets the colour that the Text Cursor should be rendered as.
virtual Rect GetCursorRect() const
Gets a rect representing this cursors dimentions.
bool SetValue(const Char8 *rhs)
Set the value of this.
virtual Integer RemoveCharacterAtIndex(const Integer Index)
Removes a character from the layer at the specified index.
Whole AsWhole(Whole def=0) const
Attempts to convert the value of the attribute to a Whole and returns the results.
Real Y
Coordinate on the Y vector.
virtual void RemoveLeftCharacter()
Removes the character to the left (and decrements the index position) of this cursor.
virtual CharIndexPair GetIndexAtOffset(const Vector2 &Offset)
Gets the index of the character at the specified offset position.
A light-weight handle for manipulating nodes in DOM tree.
Real X
Coordinate on the X vector.
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
uint32_t UInt32
An 32-bit unsigned integer.
This is used to represent a point on a 2 dimentional area, such as a screen.
bool Empty() const
Is this storing anything at all?
virtual Integer GetCursorIndex() const
Gets the index position of this cursor.
virtual Real GetDesiredLineHeight() const
Gets the height in pixels this layer is configured to render it's text.
virtual Boole GetVisible() const
Gets the visibility of this cursor.
virtual void SetOffsetPosition(const Vector2 &Offset)
Sets the offset position of this cursor to the nearest appropriate point.
virtual CharOffsetPair GetOffsetAtIndex(const Integer Index)
Gets the offset position of the character at the provided index.
virtual Integer InsertCharactersAtIndex(const Integer Index, const Char8 *Characters, const UInt32 BufSize)
Creates a series of characters from a UTF-8 encoded string to be inserted into this layer...
virtual void InsertCharactersAtCursor(const Char8 *Characters, const UInt32 BufSize)
Creates a series of characters from a UTF-8 encoded string to be inserted at the cursor position...
virtual Whole GetNumCharacters() const
Gets the number of characters being rendered by this TextLayer.
virtual TextLayer::CharOffsetPair GetOffsetPosition() const
Gets the current offset position of this cursor.
virtual void RemoveRightCharacter()
Removes the character to the right of this cursor.
void ProtoDeSerialize(const XML::Node &OneNode)
Take the data stored in an XML and overwrite this instance of this object with it.
virtual void SetCursorIndex(const Integer &Index)
Sets the index position of this cursor.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
virtual void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
void ProtoSerialize(XML::Node &CurrentRoot) const
Convert this class to an XML::Node ready for serialization.
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
Vector2 Position
Vector2 representing the top-left position of the rect.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
TextLayer * Layer
The layer this TextCursor belongs to.
virtual const ColourValue & GetColour() const
Gets the colour that the Text Cursor will be rendered as.
std::string String
A datatype used to a series of characters.
virtual void SetVisible(Boole Visible)
Sets the visibility of this cursor.
This is a base class for render layers that render text.
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.