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