Crazy Eddie's GUI System  0.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
TextComponent.h
1 /***********************************************************************
2  filename: CEGUITextComponent.h
3  created: Sun Jun 19 2005
4  author: Paul D Turner <paul@cegui.org.uk>
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIFalTextComponent_h_
29 #define _CEGUIFalTextComponent_h_
30 
31 #include "./ComponentBase.h"
32 #include "../RenderedString.h"
33 #include "../RefCounted.h"
34 #include "../FormattedRenderedString.h"
35 #include "CEGUI/falagard/FormattingSetting.h"
36 
37 #if defined(_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
49  class CEGUIEXPORT TextComponent : public FalagardComponentBase
50  {
51  public:
52  TextComponent();
53  ~TextComponent();
54  TextComponent(const TextComponent& obj);
55  TextComponent& operator=(const TextComponent& other);
56 
69  const String& getText() const;
70 
71  /*
72  \brief
73  Return a copy of the actual text string that will be used when
74  rendering this TextComponent.
75  */
76  String getEffectiveText(const Window& wnd) const;
77 
90  const String& getTextVisual() const;
91 
92  /*
93  \brief
94  Return a copy of the actual text - with visual ordering - that
95  will be used when rendering this TextComponent.
96  */
97  String getEffectiveVisualText(const Window& wnd) const;
98 
112  void setText(const String& text);
113 
130  const String& getFont() const;
131 
132  /*
133  \brief
134  Return a copy of the name of the font that will actually be used
135  when rendering this TextComponent.
136  */
137  String getEffectiveFont(const Window& wnd) const;
138 
152  void setFont(const String& font);
153 
161  VerticalTextFormatting getVerticalFormatting(const Window& wnd) const;
162 
173  void setVerticalFormatting(VerticalTextFormatting fmt);
174 
182  HorizontalTextFormatting getHorizontalFormatting(const Window& wnd) const;
183 
194  void setHorizontalFormatting(HorizontalTextFormatting fmt);
195 
201  void setHorizontalFormattingPropertySource(const String& property_name);
202 
208  void setVerticalFormattingPropertySource(const String& property_name);
209 
221  void writeXMLToStream(XMLSerializer& xml_stream) const;
222 
231  bool isTextFetchedFromProperty() const;
232 
241  const String& getTextPropertySource() const;
242 
254  void setTextPropertySource(const String& property);
255 
264  bool isFontFetchedFromProperty() const;
265 
274  const String& getFontPropertySource() const;
275 
287  void setFontPropertySource(const String& property);
288 
290  float getHorizontalTextExtent(const Window& window) const;
291 
293  float getVerticalTextExtent(const Window& window) const;
294 
295  // overridden from ComponentBase.
296  bool handleFontRenderSizeChange(Window& window, const Font* font) const;
297 
298  protected:
299  // implemets abstract from base
300  void render_impl(Window& srcWindow, Rectf& destRect, const CEGUI::ColourRect* modColours, const Rectf* clipper, bool clipToDisplay) const;
302  void setupStringFormatter(const Window& window,
303  const RenderedString& rendered_string) const;
305  const Font* getFontObject(const Window& window) const;
306 
307  private:
309  String d_textLogical;
311  BidiVisualMapping* d_bidiVisualMapping;
313  mutable bool d_bidiDataValid;
315  mutable RenderedString d_renderedString;
317  mutable RefCounted<FormattedRenderedString> d_formattedRenderedString;
319  mutable HorizontalTextFormatting d_lastHorzFormatting;
320 
321  String d_font;
322 
326  String d_textPropertyName;
327  String d_fontPropertyName;
328  };
329 
330 } // End of CEGUI namespace section
331 
332 #if defined(_MSC_VER)
333 # pragma warning(pop)
334 #endif
335 
336 #endif // end of guard _CEGUIFalTextComponent_h_