Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IGUITextOwner.h
Go to the documentation of this file.
1 /* Copyright (C) 2009 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /*
19 GUI Object Base - Text Owner
20 
21 --Overview--
22 
23  Interface class that enhance the IGUIObject with
24  cached CGUIStrings. This class is not at all needed,
25  and many controls that will use CGUIStrings might
26  not use this, but does help for regular usage such
27  as a text-box, a button, a radio button etc.
28 
29 --More info--
30 
31  Check GUI.h
32 
33 */
34 
35 #ifndef INCLUDED_IGUITEXTOWNER
36 #define INCLUDED_IGUITEXTOWNER
37 
38 //--------------------------------------------------------
39 // Includes / Compiler directives
40 //--------------------------------------------------------
41 #include "GUI.h"
42 
43 //--------------------------------------------------------
44 // Macros
45 //--------------------------------------------------------
46 
47 //--------------------------------------------------------
48 // Types
49 //--------------------------------------------------------
50 
51 //--------------------------------------------------------
52 // Declarations
53 //--------------------------------------------------------
54 
55 /**
56  * Framework for handling Output text.
57  *
58  * @see IGUIObject
59  */
60 class IGUITextOwner : virtual public IGUIObject
61 {
62 public:
63  IGUITextOwner();
64  virtual ~IGUITextOwner();
65 
66  /**
67  * Adds a text object.
68  */
69  void AddText(SGUIText * text);
70 
71  /**
72  * @see IGUIObject#HandleMessage()
73  */
74  virtual void HandleMessage(SGUIMessage &Message);
75 
76  /**
77  * @see IGUIObject#UpdateCachedSize()
78  */
79  virtual void UpdateCachedSize();
80 
81  /**
82  * Draws the Text.
83  *
84  * @param index Index value of text. Mostly this will be 0
85  * @param color
86  * @param pos Position
87  * @param z Z value
88  * @param clipping Clipping rectangle, don't even add a parameter
89  * to get no clipping.
90  */
91  virtual void DrawText(int index, const CColor& color, const CPos& pos, float z, const CRect& clipping = CRect());
92 
93  /**
94  * Test if mouse position is over an icon
95  */
96  virtual bool MouseOverIcon();
97 
98 protected:
99 
100  /**
101  * Setup texts. Functions that sets up all texts when changes have been made.
102  */
103  virtual void SetupText()=0;
104 
105  /**
106  * Whether the cached text is currently valid (if not then SetupText will be called by Draw)
107  */
109 
110  /**
111  * Texts that are generated and ready to be rendered.
112  */
113  std::vector<SGUIText*> m_GeneratedTexts;
114 
115  /**
116  * Calculate the position for the text, based on the alignment.
117  */
118  void CalculateTextPosition(CRect &ObjSize, CPos &TextPos, SGUIText &Text);
119 };
120 
121 #endif
virtual void SetupText()=0
Setup texts.
virtual ~IGUITextOwner()
virtual void UpdateCachedSize()
Definition: Overlay.h:34
virtual bool MouseOverIcon()
Test if mouse position is over an icon.
Base settings, all objects possess these settings in their m_BaseSettings Instructions can be found i...
Definition: IGUIObject.h:140
void CalculateTextPosition(CRect &ObjSize, CPos &TextPos, SGUIText &Text)
Calculate the position for the text, based on the alignment.
Framework for handling Output text.
Definition: IGUITextOwner.h:60
virtual void HandleMessage(SGUIMessage &Message)
Made to represent screen positions and delta values.
Definition: Overlay.h:167
virtual void DrawText(int index, const CColor &color, const CPos &pos, float z, const CRect &clipping=CRect())
Draws the Text.
std::vector< SGUIText * > m_GeneratedTexts
Texts that are generated and ready to be rendered.
Message send to IGUIObject::HandleMessage() in order to give life to Objects manually with a derived ...
Definition: GUIbase.h:106
void AddText(SGUIText *text)
Adds a text object.
bool m_GeneratedTextsValid
Whether the cached text is currently valid (if not then SetupText will be called by Draw) ...
An SGUIText object is a parsed string, divided into text-rendering components.
Definition: GUItext.h:62
Rectangle class used for screen rectangles.
Definition: Overlay.h:71