1 | /************************************************************************
|
---|
2 | filename: CEGUITextItem.h
|
---|
3 | created: 31/3/2005
|
---|
4 | author: Tomas Lindquist Olsen (based on code by Paul D Turner)
|
---|
5 |
|
---|
6 | purpose: Interface to base class for TextItem widget
|
---|
7 | *************************************************************************/
|
---|
8 | /*************************************************************************
|
---|
9 | Crazy Eddie's GUI System (http://www.cegui.org.uk)
|
---|
10 | Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
|
---|
11 |
|
---|
12 | This library is free software; you can redistribute it and/or
|
---|
13 | modify it under the terms of the GNU Lesser General Public
|
---|
14 | License as published by the Free Software Foundation; either
|
---|
15 | version 2.1 of the License, or (at your option) any later version.
|
---|
16 |
|
---|
17 | This library is distributed in the hope that it will be useful,
|
---|
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | Lesser General Public License for more details.
|
---|
21 |
|
---|
22 | You should have received a copy of the GNU Lesser General Public
|
---|
23 | License along with this library; if not, write to the Free Software
|
---|
24 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
25 | *************************************************************************/
|
---|
26 | #ifndef _CEGUITextItem_h_
|
---|
27 | #define _CEGUITextItem_h_
|
---|
28 |
|
---|
29 | #include "CEGUIBase.h"
|
---|
30 | #include "CEGUIWindow.h"
|
---|
31 | #include "elements/CEGUIItemEntry.h"
|
---|
32 | #include "elements/CEGUITextItemProperties.h"
|
---|
33 | #include "CEGUIFont.h"
|
---|
34 |
|
---|
35 |
|
---|
36 | #if defined(_MSC_VER)
|
---|
37 | # pragma warning(push)
|
---|
38 | # pragma warning(disable : 4251)
|
---|
39 | #endif
|
---|
40 |
|
---|
41 |
|
---|
42 | // Start of CEGUI namespace section
|
---|
43 | namespace CEGUI
|
---|
44 | {
|
---|
45 |
|
---|
46 | /*!
|
---|
47 | \brief
|
---|
48 | Base class for all the TextItem widgets.
|
---|
49 | */
|
---|
50 | class CEGUIEXPORT TextItem : public ItemEntry
|
---|
51 | {
|
---|
52 | public:
|
---|
53 | /*************************************************************************
|
---|
54 | Constants
|
---|
55 | *************************************************************************/
|
---|
56 | static const colour DefaultTextColour; //!< Default colour used when rendering text.
|
---|
57 |
|
---|
58 |
|
---|
59 | /*************************************************************************
|
---|
60 | Accessors
|
---|
61 | *************************************************************************/
|
---|
62 | /*!
|
---|
63 | \brief
|
---|
64 | Return the TextFormatting currently used for rendering the text.
|
---|
65 |
|
---|
66 | \return
|
---|
67 | TextFormatting value describing the currently used text formatting option.
|
---|
68 | */
|
---|
69 | TextFormatting getTextFormatting() const {return d_textFormatting;}
|
---|
70 |
|
---|
71 |
|
---|
72 | /*!
|
---|
73 | \brief
|
---|
74 | get the offset that is used to shift of the text in the x-direction
|
---|
75 | this is useful if the button-images are not symmetrical and the
|
---|
76 | text shouldn't be completely centered
|
---|
77 |
|
---|
78 | \return
|
---|
79 | the offset in pixels
|
---|
80 | */
|
---|
81 | float getTextXOffset(void) const {return d_textXOffset;}
|
---|
82 |
|
---|
83 |
|
---|
84 | /*!
|
---|
85 | \brief
|
---|
86 | Get the current text colour of the item.
|
---|
87 |
|
---|
88 | \return
|
---|
89 | The current text colour.
|
---|
90 | */
|
---|
91 | colour getTextColour(void) const {return d_textColour;}
|
---|
92 |
|
---|
93 |
|
---|
94 | /*************************************************************************
|
---|
95 | Manipulators
|
---|
96 | *************************************************************************/
|
---|
97 | /*!
|
---|
98 | \brief
|
---|
99 | Set the TextFormatting to be used when rendering the text.
|
---|
100 | */
|
---|
101 | void setTextFormatting(TextFormatting format) {d_textFormatting=format;}
|
---|
102 |
|
---|
103 |
|
---|
104 | /*!
|
---|
105 | \brief
|
---|
106 | Set the current text colour of the item.
|
---|
107 |
|
---|
108 | \param col
|
---|
109 | The colour to set as the current text colour.
|
---|
110 | */
|
---|
111 | void setTextColour(const colour& col) {d_textColour=col;}
|
---|
112 |
|
---|
113 |
|
---|
114 | /*!
|
---|
115 | \brief
|
---|
116 | Set the offset to use for a shift of the text in the x-direction
|
---|
117 | this is useful if the button-images are not symmetrical and the
|
---|
118 | text shouldn't be completely centered
|
---|
119 |
|
---|
120 | \param offset
|
---|
121 | The offset to use - in pixels.
|
---|
122 |
|
---|
123 | \return
|
---|
124 | Nothing.
|
---|
125 | */
|
---|
126 | void setTextXOffset(float offset) {d_textXOffset=offset;}
|
---|
127 |
|
---|
128 |
|
---|
129 | /*************************************************************************
|
---|
130 | Pure functions from ItemEntry
|
---|
131 | *************************************************************************/
|
---|
132 | /*!
|
---|
133 | \brief
|
---|
134 | Return the "optimal" size for the item
|
---|
135 |
|
---|
136 | \return
|
---|
137 | Size describing the size in pixel that this TextItem's content requires
|
---|
138 | for non-clipped rendering
|
---|
139 | */
|
---|
140 | virtual Size getItemPixelSize(void);
|
---|
141 |
|
---|
142 |
|
---|
143 | /*************************************************************************
|
---|
144 | Construction and Destruction
|
---|
145 | *************************************************************************/
|
---|
146 | /*!
|
---|
147 | \brief
|
---|
148 | Constructor for TextItem objects
|
---|
149 | */
|
---|
150 | TextItem(const String& type, const String& name);
|
---|
151 |
|
---|
152 |
|
---|
153 | /*!
|
---|
154 | \brief
|
---|
155 | Destructor for TextItem objects
|
---|
156 | */
|
---|
157 | virtual ~TextItem(void);
|
---|
158 |
|
---|
159 |
|
---|
160 | protected:
|
---|
161 | /*************************************************************************
|
---|
162 | Abstract Implementation Functions (must be provided by derived class)
|
---|
163 | *************************************************************************/
|
---|
164 |
|
---|
165 | /*************************************************************************
|
---|
166 | Overridden event handlers
|
---|
167 | *************************************************************************/
|
---|
168 | /*!
|
---|
169 | \brief
|
---|
170 | Handler called when the window's text is changed.
|
---|
171 |
|
---|
172 | \param e
|
---|
173 | WindowEventArgs object whose 'window' pointer field is set to the window that triggered the event. For this
|
---|
174 | event the trigger window is always 'this'.
|
---|
175 | */
|
---|
176 | virtual void onTextChanged(WindowEventArgs& e);
|
---|
177 |
|
---|
178 |
|
---|
179 | /*************************************************************************
|
---|
180 | Implementation Functions
|
---|
181 | *************************************************************************/
|
---|
182 | /*!
|
---|
183 | \brief
|
---|
184 | Perform the actual rendering for this Window.
|
---|
185 |
|
---|
186 | \param z
|
---|
187 | float value specifying the base Z co-ordinate that should be used when rendering
|
---|
188 |
|
---|
189 | \return
|
---|
190 | Nothing
|
---|
191 | */
|
---|
192 | virtual void drawSelf(float z);
|
---|
193 |
|
---|
194 |
|
---|
195 | /*!
|
---|
196 | \brief
|
---|
197 | Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
|
---|
198 |
|
---|
199 | \param class_name
|
---|
200 | The class name that is to be checked.
|
---|
201 |
|
---|
202 | \return
|
---|
203 | true if this window was inherited from \a class_name. false if not.
|
---|
204 | */
|
---|
205 | virtual bool testClassName_impl(const String& class_name) const
|
---|
206 | {
|
---|
207 | if (class_name==(const utf8*)"TextItem") return true;
|
---|
208 | return ItemEntry::testClassName_impl(class_name);
|
---|
209 | }
|
---|
210 |
|
---|
211 |
|
---|
212 | /*************************************************************************
|
---|
213 | Implementation Rendering Functions
|
---|
214 | *************************************************************************/
|
---|
215 |
|
---|
216 | /*************************************************************************
|
---|
217 | Implementation Data
|
---|
218 | *************************************************************************/
|
---|
219 | colour d_textColour; //!< the current text colour
|
---|
220 | TextFormatting d_textFormatting; //!< the current text formatting
|
---|
221 |
|
---|
222 | //text-offset
|
---|
223 | float d_textXOffset; //!< offset applied to the x co-ordinate of the text rendered.
|
---|
224 |
|
---|
225 |
|
---|
226 | private:
|
---|
227 | /*************************************************************************
|
---|
228 | Static Properties for this class
|
---|
229 | *************************************************************************/
|
---|
230 | static TextItemProperties::TextColour d_textColourProperty;
|
---|
231 | static TextItemProperties::TextFormatting d_textFormattingProperty;
|
---|
232 | static TextItemProperties::TextXOffset d_textXOffsetProperty;
|
---|
233 |
|
---|
234 | /*************************************************************************
|
---|
235 | Private methods
|
---|
236 | *************************************************************************/
|
---|
237 | void addTextItemProperties(void);
|
---|
238 | };
|
---|
239 |
|
---|
240 | } // End of CEGUI namespace section
|
---|
241 |
|
---|
242 |
|
---|
243 | #if defined(_MSC_VER)
|
---|
244 | # pragma warning(pop)
|
---|
245 | #endif
|
---|
246 |
|
---|
247 |
|
---|
248 | #endif // end of guard _CEGUITextItem_h_
|
---|