MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Mezzanine::UI::TextLine Class Referenceabstract

This represents a single line of text to be rendered by a TextLayer. More...

#include <textline.h>

+ Inheritance diagram for Mezzanine::UI::TextLine:
+ Collaboration diagram for Mezzanine::UI::TextLine:

Public Types

typedef std::list< Character * > CharacterContainer
 Basic container type for Character storage by this class.
 
typedef
CharacterContainer::iterator 
CharacterIterator
 Iterator type for Character instances stored by this class.
 
typedef std::pair
< CharacterIterator,
CharacterIterator
CharacterIteratorPair
 An std::pair storing two CharacterIterators, usually for expressing a range.
 
typedef
CharacterContainer::const_iterator 
ConstCharacterIterator
 Const Iterator type for Character instances stored by this class.
 
typedef std::pair< Character
*, Vector2
OffsetResultPair
 An std::pair storing a Character and it's offset position (relative to the parent layer).
 
typedef
CharacterContainer::reverse_iterator 
ReverseCharacterIterator
 Reverse Iterator type for Character instances stored by this class.
 
typedef
CharacterContainer::const_reverse_iterator 
ReverseConstCharacterIterator
 Const Reverse Iterator type for Character instances stored by this class.
 

Public Member Functions

 TextLine (TextLayer *ParentLayer)
 Class constructor. More...
 
virtual ~TextLine ()
 Class destructor.
 
Boolean AppendCharacter (Character *ToAdd)
 Adds a Character to the end of this TextLine. More...
 
Boolean AppendCharacters (CharacterContainer &ToAdd)
 Adds a series of Characters to the end of this TextLine. More...
 
Boolean AppendCharacters (CharacterIteratorPair Pair)
 Adds a series of Characters to the end of this TextLine. More...
 
virtual Boolean AppendCharacters (CharacterIterator First, CharacterIterator Last)=0
 Adds a series of Characters to the end of this TextLine. More...
 
CharacterIterator AppendFittingCharacters (CharacterContainer &ToAdd)
 Adds as many Characters in a range as will fit to this TextLine. More...
 
CharacterIterator AppendFittingCharacters (CharacterIteratorPair Pair)
 Adds as many Characters in a range as will fit to this TextLine. More...
 
virtual CharacterIterator AppendFittingCharacters (CharacterIterator First, CharacterIterator Last)=0
 Adds as many Characters in a range as will fit to this TextLine. More...
 
CharacterIterator BeginCharacter ()
 Gets an iterator to the first Character. More...
 
ConstCharacterIterator BeginCharacter () const
 Gets a const iterator to the first Character. More...
 
CharacterIterator EndCharacter ()
 Gets an iterator to one passed the last Character. More...
 
ConstCharacterIterator EndCharacter () const
 Gets an iterator to one passed the last Character. More...
 
UI::LinearAlignment GetAlignment () const
 Gets the current alignment for the text in this line of text. More...
 
OffsetResultPair GetCharacterAndCursorPositionAtOffset (const Real &Offset) const
 Gets the character at the provided offset as well as the nearest valid position the cursor can take. More...
 
CharacterGetCharacterAtIndex (const UInt32 &Index)
 Gets the character in this textline at the specified index. More...
 
CharacterGetCharacterAtOffset (const Real &Offset)
 Gets the character in this textline at the specified offset. More...
 
Real GetClosestCursorPosition (const Real &Offset)
 Gets the closest valid cursor position to the offset provided. More...
 
Real GetCurrentLength () const
 Calculates the current length of this text line. More...
 
virtual Real GetCursorStartPosition () const =0
 Gets the offset position of the cursor based on the text order of the layer this text line belongs to. More...
 
virtual CharacterIterator GetFirstCharacter ()=0
 Gets the first character in this TextLine. More...
 
Integer GetIndexAtOffset (const Real &Offset) const
 Gets the index of the character at the provided offset. More...
 
virtual CharacterIterator GetLastCharacter ()=0
 Gets the last character in this TextLine. More...
 
Real GetLeftMostCursorPosition () const
 Gets the offset position of the left-most part of this TextLine. More...
 
Real GetLineHeight () const
 Gets the size of this TextLine on the Y axis. More...
 
virtual CharacterIterator GetNextCharacter (CharacterIterator Current)=0
 Gets an iterator to the next Character. More...
 
UInt32 GetNumCharacters () const
 Gets the number of characters in this TextLine. More...
 
Real GetOffsetAtIndex (const Integer &Index) const
 Gets the Offset position of the character at the specified index. More...
 
Real GetPositionOffset () const
 Gets the offset on the Y axis from the parent layer. More...
 
Real GetRightMostCursorPosition () const
 Gets the offset position of the right-most part of this TextLine. More...
 
void RemoveAllCharacters ()
 Removes all characters from this TextLine.
 
virtual void RemoveFirstCharacter ()=0
 Removes the character at the start of this TextLine.
 
virtual void RemoveLastCharacter ()=0
 Removes the character at the end of this TextLine.
 
void SetAlignment (const UI::LinearAlignment Align)
 Aligns the text of the caption. More...
 
void SetPositionOffset (const Real &Offset)
 Sets the offset on the Y axis from the parent layer. More...
 

Protected Member Functions

virtual void AppendToBack (Character *ToAppend)=0
 Adds a character such that it becomes the last in the sequence. More...
 
virtual void AppendToBack (CharacterIterator First, CharacterIterator Last)=0
 Adds a series of characters to the end of this line. More...
 
Real GetMaxWidth () const
 Gets the maximum width this text line can be. More...
 
virtual CharacterGetSecondFromLastCharacter () const =0
 Gets the character before the last character. More...
 
virtual void RecalculateOffsets ()=0
 Recalculates the offset for every character in this line. More...
 

Protected Attributes

UI::LinearAlignment Alignment
 The alignment of the text on the X axis in this line. More...
 
CharacterContainer Characters
 Vector containing all the characters belonging to this TextLine. More...
 
Real CurrLength
 The current length of this TextLine. More...
 
TextLayerParent
 The parent layer this text line belongs to. More...
 
Real PositionOffset
 The offset in pixels from the parent layer on the Y axis. More...
 
Real TallestHeight
 The size of the largest glyph on the Y axis. More...
 

Detailed Description

This represents a single line of text to be rendered by a TextLayer.

While many of the utilities of the TextLine class are exposed in public interfaces, it is important to note that this class as a whole is not intended to be used directly by game programmers. These interfaces are available for those that need that level of control but it should be noted that manual manipulation of this class may disrupt the behaviors of not only this class but it's parent layer as well. Query methods are, of course, safe from this.

Definition at line 59 of file textline.h.

Constructor & Destructor Documentation

Mezzanine::UI::TextLine::TextLine ( TextLayer ParentLayer)

Class constructor.

Parameters
ParentLayerThe TextLayer that this TextLine belongs to.

Definition at line 57 of file textline.cpp.

Member Function Documentation

Boolean Mezzanine::UI::TextLine::AppendCharacter ( Character ToAdd)

Adds a Character to the end of this TextLine.

Parameters
ToAddThe Character to be added.
Returns
Returns true if the character was successfully added, false otherwise.

Definition at line 231 of file textline.cpp.

Boolean Mezzanine::UI::TextLine::AppendCharacters ( TextLine::CharacterContainer ToAdd)

Adds a series of Characters to the end of this TextLine.

Parameters
ToAddA container storing all Characters to attempt to add.
Returns
Returns true if all characters were successfully added, false otherwise.

Definition at line 248 of file textline.cpp.

Boolean Mezzanine::UI::TextLine::AppendCharacters ( TextLine::CharacterIteratorPair  Pair)

Adds a series of Characters to the end of this TextLine.

Parameters
PairAn std::pair containing iterators to both the first and last Characters in a sequence to attempt to append.
Returns
Returns true if all characters were successfully added, false otherwise.

Definition at line 251 of file textline.cpp.

virtual Boolean Mezzanine::UI::TextLine::AppendCharacters ( CharacterIterator  First,
CharacterIterator  Last 
)
pure virtual

Adds a series of Characters to the end of this TextLine.

Parameters
FirstIterator to the first Character in the series to be added.
LastIterator to one passed the last Character in the series to be added.
Returns
Returns true if all characters were successfully added, false otherwise.

Implemented in Mezzanine::UI::RightToLeftTextLine, and Mezzanine::UI::LeftToRightTextLine.

TextLine::CharacterIterator Mezzanine::UI::TextLine::AppendFittingCharacters ( TextLine::CharacterContainer ToAdd)

Adds as many Characters in a range as will fit to this TextLine.

Parameters
ToAddA container storing all Characters to attempt to add.
Returns
Returns a CharacterIterator to the first character that was not added in the range. This can be the left-most non-added Character when added to Left-To-Right TextLines, or the right-most non-added Character in Right-To-Left TextLines.

Definition at line 254 of file textline.cpp.

TextLine::CharacterIterator Mezzanine::UI::TextLine::AppendFittingCharacters ( TextLine::CharacterIteratorPair  Pair)

Adds as many Characters in a range as will fit to this TextLine.

Parameters
PairAn std::pair containing iterators to both the first and last Characters in a sequence to attempt to append.
Returns
Returns a CharacterIterator to the first character that was not added in the range. This can be the left-most non-added Character when added to Left-To-Right TextLines, or the right-most non-added Character in Right-To-Left TextLines.

Definition at line 257 of file textline.cpp.

virtual CharacterIterator Mezzanine::UI::TextLine::AppendFittingCharacters ( CharacterIterator  First,
CharacterIterator  Last 
)
pure virtual

Adds as many Characters in a range as will fit to this TextLine.

Parameters
FirstIterator to the first Character in the series to be added.
LastIterator to one passed the last Character in the series to be added.
Returns
Returns a CharacterIterator to the first character that was not added in the range. This can be the left-most non-added Character when added to Left-To-Right TextLines, or the right-most non-added Character in Right-To-Left TextLines.

Implemented in Mezzanine::UI::RightToLeftTextLine, and Mezzanine::UI::LeftToRightTextLine.

virtual void Mezzanine::UI::TextLine::AppendToBack ( Character ToAppend)
protectedpure virtual

Adds a character such that it becomes the last in the sequence.

Implemented in Mezzanine::UI::RightToLeftTextLine, and Mezzanine::UI::LeftToRightTextLine.

virtual void Mezzanine::UI::TextLine::AppendToBack ( CharacterIterator  First,
CharacterIterator  Last 
)
protectedpure virtual

Adds a series of characters to the end of this line.

Implemented in Mezzanine::UI::RightToLeftTextLine, and Mezzanine::UI::LeftToRightTextLine.

TextLine::CharacterIterator Mezzanine::UI::TextLine::BeginCharacter ( )

Gets an iterator to the first Character.

Returns
Returns an iterator to the first Character being stored by this TextLine.

Definition at line 312 of file textline.cpp.

TextLine::ConstCharacterIterator Mezzanine::UI::TextLine::BeginCharacter ( ) const

Gets a const iterator to the first Character.

Returns
Returns a const iterator to the first Character being stored by this TextLine.

Definition at line 318 of file textline.cpp.

TextLine::CharacterIterator Mezzanine::UI::TextLine::EndCharacter ( )

Gets an iterator to one passed the last Character.

Returns
Returns an iterator to one passed the last Character being stored by this TextLine.

Definition at line 315 of file textline.cpp.

TextLine::ConstCharacterIterator Mezzanine::UI::TextLine::EndCharacter ( ) const

Gets an iterator to one passed the last Character.

Returns
Returns an iterator to one passed the last Character being stored by this TextLine.

Definition at line 321 of file textline.cpp.

UI::LinearAlignment Mezzanine::UI::TextLine::GetAlignment ( ) const

Gets the current alignment for the text in this line of text.

Returns
Returns a TextAlignment value representing the alignment the text in this line will have.

Definition at line 79 of file textline.cpp.

TextLine::OffsetResultPair Mezzanine::UI::TextLine::GetCharacterAndCursorPositionAtOffset ( const Real Offset) const

Gets the character at the provided offset as well as the nearest valid position the cursor can take.

Parameters
OffsetThe offset from the left side of this TextLine to use when finding the result.
Returns
Returns a OffsetResultPair with the "first" member containing a pointer to the character at the offset, or NULL if there isn't one and the "second" member containing the closest valid position the cursor can be placed at in the form of an offset from this TextLines left edge.

Definition at line 84 of file textline.cpp.

Character * Mezzanine::UI::TextLine::GetCharacterAtIndex ( const UInt32 Index)

Gets the character in this textline at the specified index.

Parameters
IndexThe index of the character to retrieve.
Returns
Returns a pointer to the character at the requested index, or NULL if out of bounds.

Definition at line 260 of file textline.cpp.

Character * Mezzanine::UI::TextLine::GetCharacterAtOffset ( const Real Offset)

Gets the character in this textline at the specified offset.

Parameters
OffsetThe offset from the parent position to use when checking characters.
Returns
Returns a pointer to the character at the requested offset, or NULL of none exists.

Definition at line 276 of file textline.cpp.

Real Mezzanine::UI::TextLine::GetClosestCursorPosition ( const Real Offset)

Gets the closest valid cursor position to the offset provided.

Parameters
OffsetThe offset from the left side of the TextLine.
Returns
Returns a Real containing the closest valid offset to the one provided.

Definition at line 187 of file textline.cpp.

Real Mezzanine::UI::TextLine::GetCurrentLength ( ) const

Calculates the current length of this text line.

Note
This method will return the length of the non-clipped characters.
Returns
Returns a Real representing the current length of this text line.

Definition at line 222 of file textline.cpp.

virtual Real Mezzanine::UI::TextLine::GetCursorStartPosition ( ) const
pure virtual

Gets the offset position of the cursor based on the text order of the layer this text line belongs to.

Returns
Returns the left most cursor position if text is ordered left to right, and vice versa.

Implemented in Mezzanine::UI::RightToLeftTextLine, and Mezzanine::UI::LeftToRightTextLine.

virtual CharacterIterator Mezzanine::UI::TextLine::GetFirstCharacter ( )
pure virtual

Gets the first character in this TextLine.

Note
The first character is based on the order in which the characters are read. If the characters are meant to be read left-to-right then this will be the left most character. If the characters are meant to be read right-to-left, this will be the right most character.
Returns
Returns an iterator to the first character in this TextLine.

Implemented in Mezzanine::UI::RightToLeftTextLine, and Mezzanine::UI::LeftToRightTextLine.

Integer Mezzanine::UI::TextLine::GetIndexAtOffset ( const Real Offset) const

Gets the index of the character at the provided offset.

Note
The index returned is only among the characters in this line and is not indicative of the overall index among all characters in the parent layer.
Parameters
OffsetThe offset from the left side of this TextLine to use when finding the result.
Returns
Returns an Integer representing the index of the character at the given offset.

Definition at line 122 of file textline.cpp.

virtual CharacterIterator Mezzanine::UI::TextLine::GetLastCharacter ( )
pure virtual

Gets the last character in this TextLine.

Note
The last character is based on the order in which the characters are read. If the characters are meant to be read left-to-right then this will be the right most character. If the characters are meant to be read right-to-left, this will be the left most character.
Returns
Returns an iterator to the last character in this TextLine.

Implemented in Mezzanine::UI::RightToLeftTextLine, and Mezzanine::UI::LeftToRightTextLine.

Real Mezzanine::UI::TextLine::GetLeftMostCursorPosition ( ) const

Gets the offset position of the left-most part of this TextLine.

Returns
Returns the left-most offset from the left side of this TextLine where the cursor can be placed.

Definition at line 165 of file textline.cpp.

Real Mezzanine::UI::TextLine::GetLineHeight ( ) const

Gets the size of this TextLine on the Y axis.

Returns
Returns a Real representing the height of this TextLine.

Definition at line 225 of file textline.cpp.

Real Mezzanine::UI::TextLine::GetMaxWidth ( ) const
protected

Gets the maximum width this text line can be.

Definition at line 67 of file textline.cpp.

virtual CharacterIterator Mezzanine::UI::TextLine::GetNextCharacter ( CharacterIterator  Current)
pure virtual

Gets an iterator to the next Character.

Parameters
CurrentAn iterator to a valid Character.
Returns
Returns an iterator to the next Character in the sequence.

Implemented in Mezzanine::UI::RightToLeftTextLine, and Mezzanine::UI::LeftToRightTextLine.

UInt32 Mezzanine::UI::TextLine::GetNumCharacters ( ) const

Gets the number of characters in this TextLine.

Returns
Returns a UInt32 containing the number of characters in this TextLine.

Definition at line 298 of file textline.cpp.

Real Mezzanine::UI::TextLine::GetOffsetAtIndex ( const Integer Index) const

Gets the Offset position of the character at the specified index.

Note
The index provided is only among the characters in this line and is not indicative of the overall index among all characters in the parent layer.
Parameters
IndexThe index of the character in this line to get the offset of.
Returns
Returns a Real representing the distance in pixels the character at the provided index is from the left side of the TextLine.

Definition at line 145 of file textline.cpp.

Real Mezzanine::UI::TextLine::GetPositionOffset ( ) const

Gets the offset on the Y axis from the parent layer.

Returns
Returns a Real representing the offset in pixels from the parent layer.

Definition at line 219 of file textline.cpp.

Real Mezzanine::UI::TextLine::GetRightMostCursorPosition ( ) const

Gets the offset position of the right-most part of this TextLine.

Returns
Returns the right-most offset from the right side of this TextLine where the cursor can be placed.

Definition at line 176 of file textline.cpp.

virtual Character* Mezzanine::UI::TextLine::GetSecondFromLastCharacter ( ) const
protectedpure virtual

Gets the character before the last character.

Implemented in Mezzanine::UI::RightToLeftTextLine, and Mezzanine::UI::LeftToRightTextLine.

virtual void Mezzanine::UI::TextLine::RecalculateOffsets ( )
protectedpure virtual

Recalculates the offset for every character in this line.

Implemented in Mezzanine::UI::RightToLeftTextLine, and Mezzanine::UI::LeftToRightTextLine.

void Mezzanine::UI::TextLine::SetAlignment ( const UI::LinearAlignment  Align)

Aligns the text of the caption.

Default value for this is UI::Txt_Middle.

Parameters
AlignThe enum value representing the horizontal alignment to be set.

Definition at line 73 of file textline.cpp.

void Mezzanine::UI::TextLine::SetPositionOffset ( const Real Offset)

Sets the offset on the Y axis from the parent layer.

Warning
Adjusting this value manually can create visual artifacts. Only call this manually if you know what you are doing.
Parameters
OffsetThe offset in pixels from the top of the parent layer to be this TextLines position.

Definition at line 216 of file textline.cpp.

Member Data Documentation

UI::LinearAlignment Mezzanine::UI::TextLine::Alignment
protected

The alignment of the text on the X axis in this line.

Definition at line 94 of file textline.h.

CharacterContainer Mezzanine::UI::TextLine::Characters
protected

Vector containing all the characters belonging to this TextLine.

Definition at line 79 of file textline.h.

Real Mezzanine::UI::TextLine::CurrLength
protected

The current length of this TextLine.

Definition at line 85 of file textline.h.

TextLayer* Mezzanine::UI::TextLine::Parent
protected

The parent layer this text line belongs to.

Definition at line 82 of file textline.h.

Real Mezzanine::UI::TextLine::PositionOffset
protected

The offset in pixels from the parent layer on the Y axis.

Definition at line 91 of file textline.h.

Real Mezzanine::UI::TextLine::TallestHeight
protected

The size of the largest glyph on the Y axis.

Definition at line 88 of file textline.h.


The documentation for this class was generated from the following files: