Crazy Eddies GUI System  0.7.1
FalStaticText.h
1 /***********************************************************************
2  filename: FalStaticText.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 "FalModule.h"
32 #include "FalStatic.h"
33 #include "FalStaticTextProperties.h"
34 #include "../../falagard/CEGUIFalEnums.h"
35 #include "../../CEGUIColourRect.h"
36 #include <vector>
37 
38 #if defined(_MSC_VER)
39 # pragma warning(push)
40 # pragma warning(disable : 4251)
41 #endif
42 
43 // Start of CEGUI namespace section
44 namespace CEGUI
45 {
72  class FALAGARDBASE_API FalagardStaticText : public FalagardStatic
73  {
74  public:
75  static const utf8 TypeName[];
76 
77  /*************************************************************************
78  Child Widget name suffix constants
79  *************************************************************************/
82 
83  /************************************************************************
84  Constructor / Destructor
85  *************************************************************************/
90  FalagardStaticText(const String& type);
91 
94 
95  /************************************************************************
96  Scrolled text implementation
97  *************************************************************************/
102  ColourRect getTextColours(void) const {return d_textCols;}
103 
108  HorizontalTextFormatting getHorizontalFormatting(void) const {return d_horzFormatting;}
109 
114  VerticalTextFormatting getVerticalFormatting(void) const {return d_vertFormatting;}
115 
120  void setTextColours(const ColourRect& colours);
121 
126  void setVerticalFormatting(VerticalTextFormatting v_fmt);
127 
132  void setHorizontalFormatting(HorizontalTextFormatting h_fmt);
133 
138  bool isVerticalScrollbarEnabled(void) const {return d_enableVertScrollbar;}
139 
144  bool isHorizontalScrollbarEnabled(void) const {return d_enableHorzScrollbar;}
145 
150  void setVerticalScrollbarEnabled(bool setting);
151 
156  void setHorizontalScrollbarEnabled(bool setting);
157 
159  float getHorizontalTextExtent() const;
160 
162  float getVerticalTextExtent() const;
163 
164  void render(void);
165 
166  protected:
168  void updateFormatting() const;
170  void updateFormatting(const Size& sz) const;
171 
172  // overridden from FalagardStatic base class
173  void onLookNFeelAssigned();
174  void onLookNFeelUnassigned();
175 
176  // text field with scrollbars methods
177  void renderScrolledText(void);
178  void configureScrollbars(void);
179  Scrollbar* getVertScrollbar(void) const;
180  Scrollbar* getHorzScrollbar(void) const;
181  Rect getTextRenderArea(void) const;
182  Size getDocumentSize(const Rect& renderArea) const;
183  void setupStringFormatter() const;
184 
185  // overridden event handlers
186  bool onTextChanged(const EventArgs& e);
187  bool onSized(const EventArgs& e);
188  bool onFontChanged(const EventArgs& e);
189  bool onMouseWheel(const EventArgs& e);
190 
191  // event subscribers
192  bool handleScrollbarChange(const EventArgs& e);
193 
194  // properties
195  static FalagardStaticTextProperties::TextColours d_textColoursProperty;
196  static FalagardStaticTextProperties::VertFormatting d_vertFormattingProperty;
197  static FalagardStaticTextProperties::HorzFormatting d_horzFormattingProperty;
198  static FalagardStaticTextProperties::VertScrollbar d_vertScrollbarProperty;
199  static FalagardStaticTextProperties::HorzScrollbar d_horzScrollbarProperty;
200  static FalagardStaticTextProperties::HorzExtent d_horzExtentProperty;
201  static FalagardStaticTextProperties::VertExtent d_vertExtentProperty;
202 
203  // implementation data
211 
214 
215  typedef std::vector<Event::Connection> ConnectionList;
216  ConnectionList d_connections;
217 
219  mutable bool d_formatValid;
220  };
221 
222 } // End of CEGUI namespace section
223 
224 #if defined(_MSC_VER)
225 # pragma warning(pop)
226 #endif
227 
228 #endif // end of guard _FalStaticText_h_