Crazy Eddie's GUI System  0.8.7
StaticText.h
1 /***********************************************************************
2  created: Tue Jul 5 2005
3  author: Paul D Turner <paul@cegui.org.uk>
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2006 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 _FalStaticText_h_
28 #define _FalStaticText_h_
29 
30 #include "CEGUI/WindowRendererSets/Core/Module.h"
31 #include "CEGUI/WindowRendererSets/Core/Static.h"
32 #include "CEGUI/falagard/Enums.h"
33 #include "CEGUI/ColourRect.h"
34 #include <vector>
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 {
70  class COREWRSET_API FalagardStaticText : public FalagardStatic
71  {
72  public:
73  static const String TypeName;
74 
75  /*************************************************************************
76  Child Widget name constants
77  *************************************************************************/
78  static const String VertScrollbarName;
79  static const String HorzScrollbarName;
80 
81  /************************************************************************
82  Constructor / Destructor
83  *************************************************************************/
88  FalagardStaticText(const String& type);
89 
92 
93  /************************************************************************
94  Scrolled text implementation
95  *************************************************************************/
100  ColourRect getTextColours(void) const {return d_textCols;}
101 
106  HorizontalTextFormatting getHorizontalFormatting(void) const {return d_horzFormatting;}
107 
112  VerticalTextFormatting getVerticalFormatting(void) const {return d_vertFormatting;}
113 
118  void setTextColours(const ColourRect& colours);
119 
124  void setVerticalFormatting(VerticalTextFormatting v_fmt);
125 
130  void setHorizontalFormatting(HorizontalTextFormatting h_fmt);
131 
136  bool isVerticalScrollbarEnabled(void) const {return d_enableVertScrollbar;}
137 
142  bool isHorizontalScrollbarEnabled(void) const {return d_enableHorzScrollbar;}
143 
148  void setVerticalScrollbarEnabled(bool setting);
149 
154  void setHorizontalScrollbarEnabled(bool setting);
155 
157  float getHorizontalTextExtent() const;
158 
160  float getVerticalTextExtent() const;
161 
162  // overridden from base class
163  bool handleFontRenderSizeChange(const Font* const font);
164  void render(void);
165 
179  float getHorizontalScrollPosition() const;
180 
193  float getVerticalScrollPosition() const;
194 
200  float getUnitIntervalHorizontalScrollPosition() const;
201 
207  float getUnitIntervalVerticalScrollPosition() const;
208 
224  void setHorizontalScrollPosition(float position);
225 
240  void setVerticalScrollPosition(float position);
241 
247  void setUnitIntervalHorizontalScrollPosition(float position);
248 
254  void setUnitIntervalVerticalScrollPosition(float position);
255 
264  void invalidateFormatting();
265 
266  protected:
275  void updateFormatting() const;
276 
278  void updateFormatting(const Sizef&) const;
279 
280  // overridden from FalagardStatic base class
281  void onLookNFeelAssigned();
282  void onLookNFeelUnassigned();
283 
284  // text field with scrollbars methods
285  void renderScrolledText(void);
286 
287  void configureScrollbars() const;
288 
290  void configureScrollbars(void);
291 
292  Scrollbar* getVertScrollbar() const;
293  Scrollbar* getHorzScrollbar() const;
294  Rectf getTextRenderArea() const;
295  Sizef getDocumentSize() const;
296 
298  Sizef getDocumentSize(const Rectf& renderArea) const;
299 
300  void setupStringFormatter() const;
301 
302  // overridden event handlers
303  bool onTextChanged(const EventArgs& e);
304  bool onSized(const EventArgs& e);
305  bool onFontChanged(const EventArgs& e);
306  bool onMouseWheel(const EventArgs& e);
307 
308  // event subscribers
309  bool handleScrollbarChange(const EventArgs& e);
310 
311  // implementation data
319 
322 
323  typedef std::vector<Event::Connection> ConnectionList;
324  ConnectionList d_connections;
325 
331  mutable bool d_formatValid;
332 
333  private:
334  Scrollbar* getVertScrollbarWithoutUpdate() const;
335  Scrollbar* getHorzScrollbarWithoutUpdate() const;
336  Rectf getTextRenderAreaWithoutUpdate() const;
337  Sizef getDocumentSizeWithoutUpdate() const;
338  };
339 
340 } // End of CEGUI namespace section
341 
342 #if defined(_MSC_VER)
343 # pragma warning(pop)
344 #endif
345 
346 #endif // end of guard _FalStaticText_h_
bool d_enableVertScrollbar
true if vertical scroll bar is enabled.
Definition: StaticText.h:317
bool d_enableHorzScrollbar
true if horizontal scroll bar is enabled.
Definition: StaticText.h:318
ColourRect d_textCols
Colours used when rendering the text.
Definition: StaticText.h:316
HorizontalTextFormatting d_horzFormatting
Horizontal formatting to be applied to the text.
Definition: StaticText.h:313
VerticalTextFormatting d_vertFormatting
Vertical formatting to be applied to the text.
Definition: StaticText.h:315
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:49
Base scroll bar class.
Definition: widgets/Scrollbar.h:89
Class that holds details of colours for the four corners of a rectangle.
Definition: ColourRect.h:43
HorizontalTextFormatting getHorizontalFormatting(void) const
Return the current horizontal formatting option set for this widget.
Definition: StaticText.h:106
HorizontalTextFormatting
Enumeration of possible values to indicate the horizontal formatting to be used for a text component...
Definition: Enums.h:95
static const String HorzScrollbarName
Widget name for the horizontal scrollbar component.
Definition: StaticText.h:79
Root of a class hierarchy that wrap RenderedString objects and render them with additional formatting...
Definition: FormattedRenderedString.h:40
bool isVerticalScrollbarEnabled(void) const
Return whether the vertical scroll bar is set to be shown if needed.
Definition: StaticText.h:136
VerticalTextFormatting getVerticalFormatting(void) const
Return the current vertical formatting option set for this widget.
Definition: StaticText.h:112
ColourRect getTextColours(void) const
Return a ColourRect object containing the colours used when rendering this widget.
Definition: StaticText.h:100
bool isHorizontalScrollbarEnabled(void) const
Return whether the horizontal scroll bar is set to be shown if needed.
Definition: StaticText.h:142
Class that encapsulates a typeface.
Definition: Font.h:58
FormattedRenderedString * d_formattedRenderedString
Class that renders RenderedString with some formatting.
Definition: StaticText.h:321
VerticalTextFormatting
Enumeration of possible values to indicate the vertical formatting to be used for a text component...
Definition: Enums.h:84
Static class for the FalagardBase module.
Definition: Static.h:56
StaticText class for the FalagardBase module.
Definition: StaticText.h:70
bool d_formatValid
True when string formatting and scrollbars visibility are up to date.
Definition: StaticText.h:331
static const String VertScrollbarName
Widget name for the vertical scrollbar component.
Definition: StaticText.h:78
static const String TypeName
type name for this widget.
Definition: StaticText.h:73
String class used within the GUI system.
Definition: String.h:62