40 #ifndef _uimultilinetextlayer_cpp
41 #define _uimultilinetextlayer_cpp
43 #include "UI/multilinetextlayer.h"
44 #include "UI/uimanager.h"
45 #include "UI/textline.h"
46 #include "UI/character.h"
76 Boole NewLineDetected =
false;
84 if( (*Start)->IsWhiteSpace() ) {
86 while( End != CharEnd )
88 if( (*End)->IsNewLine() ) {
89 NewLineDetected =
true;
92 }
else if( !(*End)->IsWhiteSpace() ) {
101 if( Result != End || NewLineDetected ) {
110 NewLineDetected =
false;
113 while( End != CharEnd )
115 if( (*End)->IsWhiteSpace() )
136 }
while( Start != CharEnd );
147 if( (*End)->IsWhiteSpace() ) {
149 while( Start != CharEnd )
151 if( (*Start)->IsNewLine() ) {
152 NewLineDetected =
true;
155 }
else if( !(*Start)->IsWhiteSpace() ) {
162 AppendPair.first = Start;
163 AppendPair.second = End;
169 if( Result != Start || NewLineDetected ) {
177 NewLineDetected =
false;
180 while( Start != CharEnd )
182 if( (*Start)->IsWhiteSpace() )
188 AppendPair.first = Start;
189 AppendPair.second = End;
207 }
while( CharEnd != CharEnd );
221 if( Offset.
Y < (*LineIt)->GetPositionOffset() - (*LineIt)->GetLineHeight() )
225 while( LineIt !=
TextLines.end() && Offset.
Y < (*LineIt)->GetPositionOffset() )
227 IndexCount +=
static_cast<Integer>( (*LineIt)->GetNumCharacters() );
232 if( LineIt == (--
TextLines.end()) && Offset.
Y > (*LineIt)->GetPositionOffset() )
235 Ret.second = IndexCount + (*LineIt)->GetIndexAtOffset(Offset.
X);
243 if( Index < 0 || static_cast<Whole>( Index ) >= this->
Characters.size() ) {
245 Ret.second.Y = (*Last)->GetPositionOffset();
246 Ret.second.X = (*Last)->GetOffsetAtIndex(-1);
252 while( LineIt != this->
TextLines.end() && IndexCount +
static_cast<Integer>( (*LineIt)->GetNumCharacters() ) < Index )
254 IndexCount += (*LineIt)->GetNumCharacters();
257 Ret.second.Y = (*LineIt)->GetPositionOffset();
258 Ret.second.X = (*LineIt)->GetOffsetAtIndex( Index - IndexCount );
300 return "MultiLineTextLayer";
Characters/New Lines originate from the left, and advance to the right.
std::pair< Boole, Vector2 > CharOffsetPair
An std::pair type used as a return for index-offset conversions.
MultiLineTextLayer(QuadRenderable *ParentRenderable)
No-Font constructor.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
virtual ~MultiLineTextLayer()
Class destructor.
bool Boole
Generally acts a single bit, true or false.
CharacterContainer Characters
Container with all this layers Characters.
virtual UI::RenderLayerType GetLayerType() const
Gets the type of render layer this is.
int Integer
A datatype used to represent any integer close to.
TextLineContainer::iterator TextLineIterator
Iterator type for TextLine instances stored by this class.
This represents a single line of text to be rendered by a TextLayer.
CharacterIterator AppendFittingCharacters(CharacterContainer &ToAdd, const Real MaxWidth)
Adds as many Characters in a range as will fit to this TextLine.
Value representing a MultiLineTextLayer.
std::pair< Boole, Integer > CharIndexPair
An std::pair type used as a return for index-offset conversions.
float Real
A Datatype used to represent a real floating point number.
Characters/New Lines originate from the right, and advance to the left.
virtual String GetDerivedSerializableName() const
Gets the most derived serializable name of this Renderable.
virtual CharIndexPair GetIndexAtOffsetImpl(const Vector2 &Offset)
Gets the index of the character at the specified offset position.
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
Real Y
Coordinate on the Y vector.
virtual TextLine * CreateTextLine()
Creates a new TextLine.
A light-weight handle for manipulating nodes in DOM tree.
Real X
Coordinate on the X vector.
uint32_t UInt32
An 32-bit unsigned integer.
This is used to represent a point on a 2 dimentional area, such as a screen.
This file describes and implements a reference counted pointer that is NOT threadsafe.
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
virtual TextLine * GetOrCreateTextLine(const UInt32 Index)
Gets the TextLine at the requested index, or creates one if it doesn't exist.
virtual void PopulateTextLinesImpl(const Real MaxWidth)
Clears and then places characters belonging to this layer in the appropriate text lines...
RenderLayerType
This enum describes the type of RenderLayer this is for use in casting.
The bulk of the engine components go in this namspace.
Boole AppendCharacters(CharacterContainer &ToAdd, const Real MaxWidth)
Adds a series of Characters to the end of this TextLine.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
TextLineContainer TextLines
Container with all this layers TextLines.
virtual CharOffsetPair GetOffsetAtIndexImpl(const Integer Index)
Gets the position of the character at the specified index.
This represents a nestable quad for an object in a GUI layout.
std::pair< CharacterIterator, CharacterIterator > CharacterIteratorPair
An std::pair type storing two character iterators, usually used to express a range.
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
UI::TextOrdering HorizontalOrder
The order text will have in TextLines.
std::string String
A datatype used to a series of characters.
This is a base class for render layers that render text.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
CharacterContainer::iterator CharacterIterator
Iterator type for Character instances stored by this class.