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