source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreTextAreaOverlayElement.h @ 1812

Revision 1812, 8.7 KB checked in by gumbau, 18 years ago (diff)
Line 
1/*-------------------------------------------------------------------------
2This source file is a part of OGRE
3(Object-oriented Graphics Rendering Engine)
4
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This library is free software; you can redistribute it and/or modify it
11under the terms of the GNU Lesser General Public License (LGPL) as
12published by the Free Software Foundation; either version 2.1 of the
13License, or (at your option) any later version.
14
15This library is distributed in the hope that it will be useful, but
16WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
18License for more details.
19
20You should have received a copy of the GNU Lesser General Public License
21along with this library; if not, write to the Free Software Foundation,
22Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA or go to
23http://www.gnu.org/copyleft/lesser.txt
24-------------------------------------------------------------------------*/
25
26#ifndef _TextAreaOverlayElement_H__
27#define _TextAreaOverlayElement_H__
28
29#include "OgreOverlayElement.h"
30#include "OgreFont.h"
31
32namespace Ogre
33{
34    /** This class implements an overlay element which contains simple unformatted text.
35    */
36    class _OgreExport TextAreaOverlayElement : public OverlayElement
37    {
38    public:
39        enum Alignment
40        {
41            Left,
42            Right,
43            Center
44        };
45
46    public:
47        /** Constructor. */
48        TextAreaOverlayElement(const String& name);
49        virtual ~TextAreaOverlayElement();
50
51        virtual void initialise(void);
52        void setCaption( const String& caption );
53        const String& getCaption() const;
54
55        void setCharHeight( Real height );
56        Real getCharHeight() const;
57
58        void setSpaceWidth( Real width );
59        Real getSpaceWidth() const;
60
61        void setFontName( const String& font );
62        const String& getFontName() const;
63
64        /** See OverlayElement. */
65        virtual const String& getTypeName(void) const;
66        /** See Renderable. */
67        void getRenderOperation(RenderOperation& op);
68        /** Overridden from OverlayElement */
69        void setMaterialName(const String& matName);
70
71        /** Sets the colour of the text.
72        @remarks
73            This method establishes a constant colour for
74            the entire text. Also see setColourBottom and
75            setColourTop which allow you to set a colour gradient.
76        */
77        void setColour(const ColourValue& col);
78
79        /** Gets the colour of the text. */
80        const ColourValue& getColour(void) const;
81        /** Sets the colour of the bottom of the letters.
82        @remarks
83            By setting a separate top and bottom colour, you
84            can create a text area which has a graduated colour
85            effect to it.
86        */
87        void setColourBottom(const ColourValue& col);
88        /** Gets the colour of the bottom of the letters. */
89        const ColourValue& getColourBottom(void) const;
90        /** Sets the colour of the top of the letters.
91        @remarks
92            By setting a separate top and bottom colour, you
93            can create a text area which has a graduated colour
94            effect to it.
95        */
96        void setColourTop(const ColourValue& col);
97        /** Gets the colour of the top of the letters. */
98        const ColourValue& getColourTop(void) const;
99
100        inline void setAlignment( Alignment a )
101        {
102            mAlignment = a;
103                        mGeomPositionsOutOfDate = true;
104        }
105        inline Alignment getAlignment() const
106        {
107            return mAlignment;
108        }
109
110        /** Overridden from OverlayElement */
111        void setMetricsMode(GuiMetricsMode gmm);
112
113        /** Overridden from OverlayElement */
114        void _update(void);
115
116        //-----------------------------------------------------------------------------------------
117        /** Command object for setting the caption.
118                @see ParamCommand
119        */
120        class _OgrePrivate CmdCaption : public ParamCommand
121        {
122        public:
123            String doGet( const void* target ) const;
124            void doSet( void* target, const String& val );
125        };
126        //-----------------------------------------------------------------------------------------
127        /** Command object for setting the char height.
128                @see ParamCommand
129        */
130        class _OgrePrivate CmdCharHeight : public ParamCommand
131        {
132        public:
133            String doGet( const void* target ) const;
134            void doSet( void* target, const String& val );
135        };
136        //-----------------------------------------------------------------------------------------
137        /** Command object for setting the width of a space.
138                @see ParamCommand
139        */
140        class _OgrePrivate CmdSpaceWidth : public ParamCommand
141        {
142        public:
143            String doGet( const void* target ) const;
144            void doSet( void* target, const String& val );
145        };
146        //-----------------------------------------------------------------------------------------
147        /** Command object for setting the caption.
148                @see ParamCommand
149        */
150        class _OgrePrivate CmdFontName : public ParamCommand
151        {
152        public:
153            String doGet( const void* target ) const;
154            void doSet( void* target, const String& val );
155        };
156        //-----------------------------------------------------------------------------------------
157        /** Command object for setting the top colour.
158                @see ParamCommand
159        */
160        class _OgrePrivate CmdColourTop : public ParamCommand
161        {
162        public:
163            String doGet( const void* target ) const;
164            void doSet( void* target, const String& val );
165        };
166        //-----------------------------------------------------------------------------------------
167        /** Command object for setting the bottom colour.
168                @see ParamCommand
169        */
170        class _OgrePrivate CmdColourBottom : public ParamCommand
171        {
172        public:
173            String doGet( const void* target ) const;
174            void doSet( void* target, const String& val );
175        };
176        //-----------------------------------------------------------------------------------------
177        /** Command object for setting the constant colour.
178                @see ParamCommand
179        */
180        class _OgrePrivate CmdColour : public ParamCommand
181        {
182        public:
183            String doGet( const void* target ) const;
184            void doSet( void* target, const String& val );
185        };
186        //-----------------------------------------------------------------------------------------
187        /** Command object for setting the alignment.
188                @see ParamCommand
189        */
190        class _OgrePrivate CmdAlignment : public ParamCommand
191        {
192        public:
193            String doGet( const void* target ) const;
194            void doSet( void* target, const String& val );
195        };
196
197    protected:
198        /// The text alignment
199        Alignment mAlignment;
200
201        /// Flag indicating if this panel should be visual or just group things
202        bool mTransparent;
203
204        /// Render operation
205        RenderOperation mRenderOp;
206
207        /// Method for setting up base parameters for this class
208        void addBaseParameters(void);
209
210        static String msTypeName;
211
212        // Command objects
213        static CmdCharHeight msCmdCharHeight;
214        static CmdSpaceWidth msCmdSpaceWidth;
215        static CmdFontName msCmdFontName;
216        static CmdColour msCmdColour;
217        static CmdColourTop msCmdColourTop;
218        static CmdColourBottom msCmdColourBottom;
219        static CmdAlignment msCmdAlignment;
220
221
222        FontPtr mpFont;
223        Real mCharHeight;
224        ushort mPixelCharHeight;
225        Real mSpaceWidth;
226        ushort mPixelSpaceWidth;
227        size_t mAllocSize;
228                Real mViewportAspectCoef;
229
230        /// Colours to use for the vertices
231        ColourValue mColourBottom;
232        ColourValue mColourTop;
233        bool mColoursChanged;
234
235
236        /// Internal method to allocate memory, only reallocates when necessary
237        void checkMemoryAllocation( size_t numChars );
238        /// Inherited function
239        virtual void updatePositionGeometry();
240                /// Inherited function
241                virtual void updateTextureGeometry();
242        /// Updates vertex colours
243        virtual void updateColours(void);
244    };
245}
246
247#endif
248
Note: See TracBrowser for help on using the repository browser.