1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include "interfaces_manager.h"
38 extern UTextContext
*TextContext
;
42 //-----------------------------------------------
45 //-----------------------------------------------
52 //-----------------------------------------------
55 //-----------------------------------------------
56 CText::CText(uint id
, float x
, float y
, float x_pixel
, float y_pixel
, const ucstring
&text
, const CPen
&pen
)
57 : CControl(id
, x
, y
, x_pixel
, y_pixel
, 0.f
, 0.f
, 0.f
, 0.f
), CPen(pen
)
62 //-----------------------------------------------
65 //-----------------------------------------------
66 CText::CText(uint id
, float x
, float y
, float x_pixel
, float y_pixel
, const ucstring
&text
, uint32 fontSize
, CRGBA color
, bool shadow
)
67 : CControl(id
, x
, y
, x_pixel
, y_pixel
, 0.f
, 0.f
, 0.f
, 0.f
), CPen(fontSize
, color
, shadow
)
72 //-----------------------------------------------
74 // Initialize the button (1 function called for all constructors -> easier).
75 //-----------------------------------------------
76 void CText::init(const ucstring
&text
)
85 //-----------------------------------------------
88 //-----------------------------------------------
91 // If the control is hide -> return
95 /* TextContext->setShaded(_Shadow);
96 */ TextContext
->setHotSpot(_TextHotSpot
);
97 /* TextContext->setColor(_Color);
98 TextContext->setFontSize(_FontSize);
99 */ //TextContext->printAt(_X_Display, _Y_Display, _Text);
100 TextContext
->printAt(_X_Display
, _Y_Display
, _Index
);
106 //-----------------------------------------------
108 //-----------------------------------------------
109 ucstring
CText::text()
113 //-----------------------------------------------
115 //-----------------------------------------------
116 void CText::text(ucstring txt
)
121 // get the current text context param
122 shadow
= TextContext
->getShaded();
123 fontSize
= TextContext
->getFontSize();
127 TextContext
->setShaded(_Shadow
);
128 TextContext
->setColor(_Color
);
129 TextContext
->setFontSize(_FontSize
);
131 TextContext
->erase( _Index
);
133 _Index
= TextContext
->textPush( _Text
);
134 _Info
= TextContext
->getStringInfo( _Index
);
136 // restore old values
137 TextContext
->setShaded(shadow
);
138 TextContext
->setFontSize(fontSize
);
142 //-----------------------------------------------
143 // calculateDisplay :
144 // Calculate the Display X, Y, Width, Height.
145 //-----------------------------------------------
146 void CText::calculateDisplay()
149 CInterfMngr::getWindowSize(w
, h
);
151 // Calculate the HotSpot.
154 _X_Display
= _X_Ref
+ _X
*_W_Ref
+ _X_Pixel
/w
;
155 _Y_Display
= _Y_Ref
+ _Y
*_H_Ref
+ _Y_Pixel
/h
;
157 // Calculate the display Width and Height.
158 _W_Display
= _Info
.StringWidth
/ w
;
159 _H_Display
= _Info
.StringHeight
/ h
;
161 _W_Pixel
= _Info
.StringWidth
;
162 _H_Pixel
= _Info
.StringHeight
;
163 }// calculateDisplay //
165 //-----------------------------------------------
167 // Calculate the display position of the control in relation to the position of the control (Hot Spot).
168 //-----------------------------------------------
169 void CText::calculateHS()
174 _TextHotSpot
= UTextContext::BottomRight
;
177 _TextHotSpot
= UTextContext::MiddleBottom
;
180 _TextHotSpot
= UTextContext::BottomLeft
;
184 _TextHotSpot
= UTextContext::MiddleRight
;
187 _TextHotSpot
= UTextContext::MiddleMiddle
;
190 _TextHotSpot
= UTextContext::MiddleLeft
;
194 _TextHotSpot
= UTextContext::TopRight
;
197 _TextHotSpot
= UTextContext::MiddleTop
;
200 _TextHotSpot
= UTextContext::TopLeft
;
206 //-----------------------------------------------
208 // Set the font size.
209 //-----------------------------------------------
210 void CText::fontSize(uint32 fs
)
216 //-----------------------------------------------
218 // Set the pen color.
219 //-----------------------------------------------
220 void CText::color(CRGBA color
)
226 //-----------------------------------------------
228 // Set the shadow state.
229 //-----------------------------------------------
230 void CText::shadow(bool s
)