29 #ifndef _GG_TextControl_h_
30 #define _GG_TextControl_h_
36 #include <boost/lexical_cast.hpp>
72 TextControl(
X x,
Y y,
X w,
Y h,
const std::string& str,
const boost::shared_ptr<Font>& font,
80 TextControl(
X x,
Y y,
const std::string& str,
const boost::shared_ptr<Font>& font,
86 virtual Pt MinUsableSize()
const;
89 const std::string& Text()
const;
97 Clr TextColor()
const;
101 bool ClipText()
const;
110 bool SetMinSize()
const;
125 template <
class T>
void operator>>(T& t)
const;
139 template <
class T> T GetValue()
const;
143 operator const std::string&()
const;
150 Pt TextUpperLeft()
const;
154 Pt TextLowerRight()
const;
158 virtual void Render();
164 virtual void SetText(
const std::string& str);
166 virtual void SizeMove(
const Pt& ul,
const Pt& lr);
172 void SetTextColor(
Clr color);
176 virtual void SetColor(
Clr c);
179 void ClipText(
bool b);
183 void SetMinSize(
bool b);
195 void operator+=(
const std::string& s);
196 void operator+=(
char c);
202 void Insert(
CPSize pos,
char c);
205 void Insert(
CPSize pos,
const std::string& s);
214 void Insert(std::size_t line,
CPSize pos,
char c);
217 void Insert(std::size_t line,
CPSize pos,
const std::string& s);
221 void Erase(std::size_t line,
CPSize pos,
CPSize num = CP1);
231 const std::vector<Font::LineData>& GetLineData()
const;
234 const boost::shared_ptr<Font>& GetFont()
const;
238 bool FitToText()
const;
242 void ValidateFormat();
243 void AdjustMinimumSize();
244 void RecomputeTextBounds();
251 std::vector<boost::shared_ptr<Font::TextElement> >
253 std::vector<Font::LineData> m_line_data;
255 boost::shared_ptr<Font> m_font;
268 t = boost::lexical_cast<T>(m_text);
269 }
catch (boost::bad_lexical_cast) {
276 {
return boost::lexical_cast<T, std::string>(m_text); }
280 { SetText(boost::lexical_cast<std::string>(t)); }