41 #ifndef _uitextlayer_cpp
42 #define _uitextlayer_cpp
44 #include "UI/textlayer.h"
45 #include "UI/textline.h"
46 #include "UI/textcursor.h"
47 #include "UI/texttoken.h"
48 #include "UI/defaultmarkupparser.h"
49 #include "UI/widget.h"
50 #include "UI/screen.h"
52 #include "UI/uimanager.h"
54 #include "stringtool.h"
63 ManualCharScaling(1.0,1.0),
73 AutoCharScalingMode(
TextLayer::SM_NoAutoScaling),
75 VerticalAlign(UI::LA_TopLeft),
96 ManualCharScaling(1.0,1.0),
104 AutoCharScaling(0.0),
106 AutoCharScalingMode(
TextLayer::SM_NoAutoScaling),
108 VerticalAlign(UI::LA_TopLeft),
109 ScalingChanged(false)
130 ManualCharScaling(1.0,1.0),
138 AutoCharScaling(LineHeight),
140 AutoCharScalingMode(
TextLayer::SM_ScreenRelative),
142 VerticalAlign(UI::LA_TopLeft),
143 ScalingChanged(false)
190 Vector2 TopLeft, TopRight, BottomLeft, BottomRight;
203 CurrLine = (*LineIt);
215 CurrChar = (*CharIt);
239 PushVertex(BottomLeft.
X, BottomLeft.
Y, WhitePixelCoords, HighlightColour, CharAtlas);
240 PushVertex(TopRight.
X, TopRight.
Y, WhitePixelCoords, HighlightColour, CharAtlas);
241 PushVertex(TopLeft.
X, TopLeft.
Y, WhitePixelCoords, HighlightColour, CharAtlas);
244 PushVertex(BottomLeft.
X, BottomLeft.
Y, WhitePixelCoords, HighlightColour, CharAtlas);
245 PushVertex(BottomRight.
X, BottomRight.
Y, WhitePixelCoords, HighlightColour, CharAtlas);
246 PushVertex(TopRight.
X, TopRight.
Y, WhitePixelCoords, HighlightColour, CharAtlas);
271 BottomRight.
SetValues( TopRight.
X , BottomLeft.
Y );
292 if( TotalHeight < ActDims.
Size.
Y )
296 case UI::LA_TopLeft:
break;
297 case UI::LA_BottomRight: CursorY = ActDims.
Size.
Y - TotalHeight;
break;
298 case UI::LA_Center: CursorY = (ActDims.
Size.
Y * 0.5) - (TotalHeight * 0.5);
break;
304 CursorY += (*TLIt)->GetLineHeight();
305 (*TLIt)->SetPositionOffset(CursorY);
314 if( Parser != NULL ) {
347 Ret += (*TextIt)->GetLineHeight();
360 default:
return 0;
break;
389 ExceptionStream <<
"Attempting to set text on a TextLayer without a default font set. Layer owned by renderable \"" <<
Parent->
GetName() <<
"\".";
528 (*ToHighlight)->SetHighlighted(
true);
541 while( StartIterator != EndIterator )
543 (*StartIterator)->SetHighlighted(
true);
569 while( StartIterator != EndIterator )
571 (*StartIterator)->SetHighlighted(
false);
621 return ( this->
Cursor != NULL );
646 if( Offset < (*LineIt)->GetPositionOffset() - (*LineIt)->GetLineHeight() )
649 while( LineIt != this->
TextLines.end() && Offset < (*LineIt)->GetPositionOffset() )
655 if( LineIt == (--this->
TextLines.end()) && Offset > (*LineIt)->GetPositionOffset() )
678 (*TLIt)->RemoveAllCharacters();
737 while( LineIt != this->
TextLines.end() && Offset.
Y > (*LineIt)->GetPositionOffset() )
745 if( Offset.
X < (*LineIt)->GetLeftMostCursorPosition() ||
746 Offset.
X > (*LineIt)->GetRightMostCursorPosition() )
753 while( CharIt != (*LineIt)->EndCharacter() && Offset.
X > (*CharIt)->GetLengthOffset() + (*CharIt)->GetCharacterSize().X )
760 if( CharIt == (*LineIt)->EndCharacter() )
return NULL;
761 else return (*CharIt);
766 if( 0 > Index || Index >= this->
Characters.size() ) {
782 if( 0 > Index || Index >= this->
Characters.size() ) {
967 if( !PropertiesNode.
Empty() ) {
969 CurrAttrib = PropertiesNode.
GetAttribute(
"HighlightStart");
970 if( !CurrAttrib.
Empty() )
973 CurrAttrib = PropertiesNode.
GetAttribute(
"HighlightEnd");
974 if( !CurrAttrib.
Empty() )
977 CurrAttrib = PropertiesNode.
GetAttribute(
"AutoCharScaling");
978 if( !CurrAttrib.
Empty() )
981 CurrAttrib = PropertiesNode.
GetAttribute(
"AutoCharScalingMode");
982 if( !CurrAttrib.
Empty() )
985 CurrAttrib = PropertiesNode.
GetAttribute(
"HorizontalOrder");
986 if( !CurrAttrib.
Empty() )
989 CurrAttrib = PropertiesNode.
GetAttribute(
"VerticalAlign");
990 if( !CurrAttrib.
Empty() )
993 CurrAttrib = PropertiesNode.
GetAttribute(
"ScalingChanged");
994 if( !CurrAttrib.
Empty() )
998 if( !DefaultCharTraitsNode.
Empty() )
1002 if( !ActiveHLColourNode.
Empty() )
1006 if( !InactiveHLColourNode.
Empty() )
1010 if( !CharScalingNode.
Empty() )
1023 if( !CursorNode.
Empty() ) {
1036 if( !TextNode.
Empty() ) {
1039 if( !CurrAttrib.
Empty() )
1053 {
return "TextLayer"; }