Crazy Eddie's GUI System  0.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
StaticText.h
1 /***********************************************************************
2  filename: StaticText.h
3  created: Tue Jul 5 2005
4  author: Paul D Turner <paul@cegui.org.uk>
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2006 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 _FalStaticText_h_
29 #define _FalStaticText_h_
30 
31 #include "CEGUI/WindowRendererSets/Core/Module.h"
32 #include "CEGUI/WindowRendererSets/Core/Static.h"
33 #include "CEGUI/falagard/Enums.h"
34 #include "CEGUI/ColourRect.h"
35 #include <vector>
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 {
71  class COREWRSET_API FalagardStaticText : public FalagardStatic
72  {
73  public:
74  static const String TypeName;
75 
76  /*************************************************************************
77  Child Widget name constants
78  *************************************************************************/
79  static const String VertScrollbarName;
80  static const String HorzScrollbarName;
81 
82  /************************************************************************
83  Constructor / Destructor
84  *************************************************************************/
89  FalagardStaticText(const String& type);
90 
93 
94  /************************************************************************
95  Scrolled text implementation
96  *************************************************************************/
101  ColourRect getTextColours(void) const {return d_textCols;}
102 
107  HorizontalTextFormatting getHorizontalFormatting(void) const {return d_horzFormatting;}
108 
113  VerticalTextFormatting getVerticalFormatting(void) const {return d_vertFormatting;}
114 
119  void setTextColours(const ColourRect& colours);
120 
125  void setVerticalFormatting(VerticalTextFormatting v_fmt);
126 
131  void setHorizontalFormatting(HorizontalTextFormatting h_fmt);
132 
137  bool isVerticalScrollbarEnabled(void) const {return d_enableVertScrollbar;}
138 
143  bool isHorizontalScrollbarEnabled(void) const {return d_enableHorzScrollbar;}
144 
149  void setVerticalScrollbarEnabled(bool setting);
150 
155  void setHorizontalScrollbarEnabled(bool setting);
156 
158  float getHorizontalTextExtent() const;
159 
161  float getVerticalTextExtent() const;
162 
163  // overridden from base class
164  bool handleFontRenderSizeChange(const Font* const font);
165  void render(void);
166 
167  protected:
169  void updateFormatting() const;
171  void updateFormatting(const Sizef& sz) const;
172 
173  // overridden from FalagardStatic base class
174  void onLookNFeelAssigned();
175  void onLookNFeelUnassigned();
176 
177  // text field with scrollbars methods
178  void renderScrolledText(void);
179  void configureScrollbars(void);
180  Scrollbar* getVertScrollbar(void) const;
181  Scrollbar* getHorzScrollbar(void) const;
182  Rectf getTextRenderArea(void) const;
183  Sizef getDocumentSize(const Rectf& renderArea) const;
184  void setupStringFormatter() const;
185 
186  // overridden event handlers
187  bool onTextChanged(const EventArgs& e);
188  bool onSized(const EventArgs& e);
189  bool onFontChanged(const EventArgs& e);
190  bool onMouseWheel(const EventArgs& e);
191 
192  // event subscribers
193  bool handleScrollbarChange(const EventArgs& e);
194 
195  // implementation data
203 
206 
207  typedef std::vector<Event::Connection> ConnectionList;
208  ConnectionList d_connections;
209 
211  mutable bool d_formatValid;
212  };
213 
214 } // End of CEGUI namespace section
215 
216 #if defined(_MSC_VER)
217 # pragma warning(pop)
218 #endif
219 
220 #endif // end of guard _FalStaticText_h_