Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreTextAreaGuiElement.cpp

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002 This source file is a part of OGRE
00003 (Object-oriented Graphics Rendering Engine)
00004 
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright © 2000-2002 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This library is free software; you can redistribute it and/or modify it
00011 under the terms of the GNU Lesser General Public License (LGPL) as 
00012 published by the Free Software Foundation; either version 2.1 of the 
00013 License, or (at your option) any later version.
00014 
00015 This library is distributed in the hope that it will be useful, but 
00016 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
00017 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
00018 License for more details.
00019 
00020 You should have received a copy of the GNU Lesser General Public License 
00021 along with this library; if not, write to the Free Software Foundation, 
00022 Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA or go to
00023 http://www.gnu.org/copyleft/lesser.txt
00024 -------------------------------------------------------------------------*/
00025 
00026 #include "OgreTextAreaGuiElement.h"
00027 #include "OgreRoot.h"
00028 #include "OgreLogManager.h"
00029 #include "OgreOverlayManager.h"
00030 #include "OgreHardwareBufferManager.h"
00031 #include "OgreHardwareVertexBuffer.h"
00032 #include "OgreException.h"
00033 
00034 namespace Ogre {
00035 
00036 #define DEFAULT_INITIAL_CHARS 12
00037     //---------------------------------------------------------------------
00038     String TextAreaGuiElement::msTypeName = "TextArea";
00039     TextAreaGuiElement::CmdCharHeight TextAreaGuiElement::msCmdCharHeight;
00040     TextAreaGuiElement::CmdSpaceWidth TextAreaGuiElement::msCmdSpaceWidth;
00041     TextAreaGuiElement::CmdFontName TextAreaGuiElement::msCmdFontName;
00042     TextAreaGuiElement::CmdColour TextAreaGuiElement::msCmdColour;
00043     TextAreaGuiElement::CmdColourBottom TextAreaGuiElement::msCmdColourBottom;
00044     TextAreaGuiElement::CmdColourTop TextAreaGuiElement::msCmdColourTop;
00045     TextAreaGuiElement::CmdAlignment TextAreaGuiElement::msCmdAlignment;
00046     //---------------------------------------------------------------------
00047     #define POS_TEX_BINDING 0
00048     #define COLOUR_BINDING 1
00049     //---------------------------------------------------------------------
00050     TextAreaGuiElement::TextAreaGuiElement(const String& name)
00051         : GuiElement(name)
00052     {
00053         mTransparent = false;
00054         mAlignment = Left;
00055         mpFont = 0;
00056 
00057         mColourTop = ColourValue::White;
00058         mColourBottom = ColourValue::White;
00059         mColoursChanged = true;
00060 
00061         mAllocSize = 0;
00062 
00063         mCharHeight = 0.02;
00064         mPixelCharHeight = 12;
00065         mSpaceWidth = 0;
00066         mPixelSpaceWidth = 0;
00067         mViewportAspectCoef = 1;
00068 
00069         if (createParamDictionary("TextAreaGuiElement"))
00070         {
00071             addBaseParameters();
00072         }
00073     }
00074 
00075     void TextAreaGuiElement::initialise(void)
00076     {
00077         // Set up the render op
00078         // Combine positions and texture coords since they tend to change together
00079         // since character sizes are different
00080         mRenderOp.vertexData = new VertexData();
00081         VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
00082         size_t offset = 0;
00083         // Positions
00084         decl->addElement(POS_TEX_BINDING, offset, VET_FLOAT3, VES_POSITION);
00085         offset += VertexElement::getTypeSize(VET_FLOAT3);
00086         // Texcoords
00087         decl->addElement(POS_TEX_BINDING, offset, VET_FLOAT2, VES_TEXTURE_COORDINATES, 0);
00088         offset += VertexElement::getTypeSize(VET_FLOAT2);
00089         // Colours - store these in a separate buffer because they change less often
00090         decl->addElement(COLOUR_BINDING, 0, VET_COLOUR, VES_DIFFUSE);
00091 
00092         mRenderOp.operationType = RenderOperation::OT_TRIANGLE_LIST;
00093         mRenderOp.useIndexes = false;
00094         mRenderOp.vertexData->vertexStart = 0;
00095         // Vertex buffer will be created in checkMemoryAllocation
00096 
00097         checkMemoryAllocation( DEFAULT_INITIAL_CHARS );
00098 
00099     }
00100 
00101     void TextAreaGuiElement::checkMemoryAllocation( size_t numChars )
00102     {
00103         if( mAllocSize < numChars)
00104         {
00105             // Create and bind new buffers
00106             // Note that old buffers will be deleted automatically through reference counting
00107             
00108             // 6 verts per char since we're doing tri lists without indexes
00109             // Allocate space for positions & texture coords
00110             VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
00111             VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;
00112 
00113             mRenderOp.vertexData->vertexCount = numChars * 6;
00114 
00115             // Create dynamic since text tends to change alot
00116             // positions & texcoords
00117             HardwareVertexBufferSharedPtr vbuf = 
00118                 HardwareBufferManager::getSingleton().
00119                     createVertexBuffer(
00120                         decl->getVertexSize(POS_TEX_BINDING), 
00121                         mRenderOp.vertexData->vertexCount,
00122                         HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
00123             bind->setBinding(POS_TEX_BINDING, vbuf);
00124 
00125             // colours
00126             vbuf = HardwareBufferManager::getSingleton().
00127                     createVertexBuffer(
00128                         decl->getVertexSize(COLOUR_BINDING), 
00129                         mRenderOp.vertexData->vertexCount,
00130                         HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
00131             bind->setBinding(COLOUR_BINDING, vbuf);
00132 
00133             mAllocSize = numChars;
00134             mColoursChanged = true; // force colour buffer regeneration
00135         }
00136 
00137     }
00138 
00139     void TextAreaGuiElement::updateGeometry()
00140     {
00141         Real *pVert;
00142 
00143         if (!mpFont)
00144         {
00145             // not initialised yet, probably due to the order of creation in a template
00146             return;
00147         }
00148 
00149         size_t charlen = mCaption.size();
00150         checkMemoryAllocation( charlen );
00151 
00152         mRenderOp.vertexData->vertexCount = charlen * 6;
00153         // Get position / texcoord buffer
00154         HardwareVertexBufferSharedPtr vbuf = 
00155             mRenderOp.vertexData->vertexBufferBinding->getBuffer(POS_TEX_BINDING);
00156         pVert = static_cast<Real*>(
00157             vbuf->lock(HardwareBuffer::HBL_DISCARD) );
00158 
00159         float largestWidth = 0;
00160         float left = _getDerivedLeft() * 2.0 - 1.0;
00161         float top = -( (_getDerivedTop() * 2.0 ) - 1.0 );
00162 
00163         // Derive space with from a capital A
00164         if (mSpaceWidth == 0)
00165         {
00166             mSpaceWidth = mpFont->getGlyphAspectRatio( 'A' ) * mCharHeight * 2.0 * mViewportAspectCoef;
00167         }
00168 
00169         // Use iterator
00170         String::iterator i, iend;
00171         iend = mCaption.end();
00172         bool newLine = true;
00173         for( i = mCaption.begin(); i != iend; ++i )
00174         {
00175             if( newLine )
00176             {
00177                 Real len = 0.0f;
00178                 for( String::iterator j = i; j != iend && *j != '\n'; j++ )
00179                 {
00180                     if (*j == ' ')
00181                     {
00182                         len += mSpaceWidth;
00183                     }
00184                     else 
00185                     {
00186                         len += mpFont->getGlyphAspectRatio( *j ) * mCharHeight * 2.0 * mViewportAspectCoef;
00187                     }
00188                 }
00189 
00190                 if( mAlignment == Right )
00191                     left -= len;
00192                 else if( mAlignment == Center )
00193                     left -= len * 0.5;
00194                 
00195                 newLine = false;
00196             }
00197 
00198             if( *i == '\n' )
00199             {
00200                 left = _getDerivedLeft() * 2.0 - 1.0;
00201                 top -= mCharHeight * 2.0;
00202                 newLine = true;
00203                 // Also reduce tri count
00204                 mRenderOp.vertexData->vertexCount -= 6;
00205                 continue;
00206             }
00207 
00208             if ( *i == ' ')
00209             {
00210                 // Just leave a gap, no tris
00211                 left += mSpaceWidth;
00212                 // Also reduce tri count
00213                 mRenderOp.vertexData->vertexCount -= 6;
00214                 continue;
00215             }
00216 
00217             Real horiz_height = mpFont->getGlyphAspectRatio( *i ) * mViewportAspectCoef ;
00218             Real u1, u2, v1, v2; 
00219             mpFont->getGlyphTexCoords( *i, u1, v1, u2, v2 );
00220 
00221             // each vert is (x, y, z, u, v)
00222             //-------------------------------------------------------------------------------------
00223             // First tri
00224             //
00225             // Upper left
00226             *pVert++ = left;
00227             *pVert++ = top;
00228             *pVert++ = -1.0;
00229             *pVert++ = u1;
00230             *pVert++ = v1;
00231 
00232             top -= mCharHeight * 2.0;
00233 
00234             // Bottom left
00235             *pVert++ = left;
00236             *pVert++ = top;
00237             *pVert++ = -1.0;
00238             *pVert++ = u1;
00239             *pVert++ = v2;
00240 
00241             top += mCharHeight * 2.0;
00242             left += horiz_height * mCharHeight * 2.0;
00243 
00244             // Top right
00245             *pVert++ = left;
00246             *pVert++ = top;
00247             *pVert++ = -1.0;
00248             *pVert++ = u2;
00249             *pVert++ = v1;
00250             //-------------------------------------------------------------------------------------
00251 
00252             //-------------------------------------------------------------------------------------
00253             // Second tri
00254             //
00255             // Top right (again)
00256             *pVert++ = left;
00257             *pVert++ = top;
00258             *pVert++ = -1.0;
00259             *pVert++ = u2;
00260             *pVert++ = v1;
00261 
00262             top -= mCharHeight * 2.0;
00263             left -= horiz_height  * mCharHeight * 2.0;
00264 
00265             // Bottom left (again)
00266             *pVert++ = left;
00267             *pVert++ = top;
00268             *pVert++ = -1.0;
00269             *pVert++ = u1;
00270             *pVert++ = v2;
00271 
00272             left += horiz_height  * mCharHeight * 2.0;
00273 
00274             // Bottom right
00275             *pVert++ = left;
00276             *pVert++ = top;
00277             *pVert++ = -1.0;
00278             *pVert++ = u2;
00279             *pVert++ = v2;
00280             //-------------------------------------------------------------------------------------
00281 
00282             // Go back up with top
00283             top += mCharHeight * 2.0;
00284 
00285             float currentWidth = (left + 1)/2 - _getDerivedLeft();
00286             if (currentWidth > largestWidth)
00287             {
00288                 largestWidth = currentWidth;
00289 
00290             }
00291         }
00292         // Unlock vertex buffer
00293         vbuf->unlock();
00294 
00295         if (mMetricsMode == GMM_PIXELS)
00296         {
00297             // Derive parametric version of dimensions
00298             Real vpWidth;
00299             vpWidth = (Real) (OverlayManager::getSingleton().getViewportWidth());
00300 
00301             largestWidth *= vpWidth;
00302         };
00303 
00304         if (getWidth() < largestWidth)
00305             setWidth(largestWidth);
00306         updateColours();
00307 
00308     }
00309 
00310     void TextAreaGuiElement::updatePositionGeometry()
00311     {
00312         updateGeometry();
00313     }
00314 
00315     void TextAreaGuiElement::setCaption( const String& caption )
00316     {
00317         mCaption = caption;
00318         updateGeometry();
00319 
00320     }
00321     const String& TextAreaGuiElement::getCaption() const
00322     {
00323         return mCaption;
00324     }
00325 
00326     void TextAreaGuiElement::setFontName( const String& font )
00327     {
00328         mpFont = (Font*)FontManager::getSingleton().getByName( font );
00329         if (!mpFont)
00330             Except( Exception::ERR_ITEM_NOT_FOUND, "Could not find font " + font,
00331                 "TextAreaGuiElement::setFontName" );
00332         mpFont->load();
00333         mpMaterial = mpFont->getMaterial();
00334         mpMaterial->setDepthCheckEnabled(false);
00335         mpMaterial->setLightingEnabled(false);
00336 
00337         updateGeometry();
00338     }
00339     const String& TextAreaGuiElement::getFontName() const
00340     {
00341         return mpFont->getName();
00342     }
00343 
00344     void TextAreaGuiElement::setCharHeight( Real height )
00345     {
00346         if (mMetricsMode != GMM_RELATIVE)
00347         {
00348             mPixelCharHeight = height;
00349         }
00350         else
00351         {
00352             mCharHeight = height;
00353         }
00354         mGeomPositionsOutOfDate = true;
00355     }
00356     Real TextAreaGuiElement::getCharHeight() const
00357     {
00358         if (mMetricsMode == GMM_PIXELS)
00359         {
00360             return mPixelCharHeight;
00361         }
00362         else
00363         {
00364             return mCharHeight;
00365         }
00366     }
00367 
00368     void TextAreaGuiElement::setSpaceWidth( Real width )
00369     {
00370         if (mMetricsMode != GMM_RELATIVE)
00371         {
00372             mPixelSpaceWidth = width;
00373         }
00374         else
00375         {
00376             mSpaceWidth = width;
00377         }
00378 
00379         mGeomPositionsOutOfDate = true;
00380     }
00381     Real TextAreaGuiElement::getSpaceWidth() const
00382     {
00383         if (mMetricsMode == GMM_PIXELS)
00384         {
00385             return mPixelSpaceWidth;
00386         }
00387         else
00388         {
00389             return mSpaceWidth;
00390         }
00391     }
00392 
00393     //---------------------------------------------------------------------
00394     TextAreaGuiElement::~TextAreaGuiElement()
00395     {
00396         delete mRenderOp.vertexData;
00397     }
00398     //---------------------------------------------------------------------
00399     const String& TextAreaGuiElement::getTypeName(void) const
00400     {
00401         return msTypeName;
00402     }
00403     //---------------------------------------------------------------------
00404     void TextAreaGuiElement::getRenderOperation(RenderOperation& op)
00405     {
00406         op = mRenderOp;
00407     }
00408     //---------------------------------------------------------------------
00409     void TextAreaGuiElement::setMaterialName(const String& matName)
00410     {
00411         GuiElement::setMaterialName(matName);
00412         updateGeometry();
00413     }
00414     //---------------------------------------------------------------------
00415     void TextAreaGuiElement::addBaseParameters(void)
00416     {
00417         GuiElement::addBaseParameters();
00418         ParamDictionary* dict = getParamDictionary();
00419 
00420         dict->addParameter(ParameterDef("char_height", 
00421             "Sets the height of the characters in relation to the screen."
00422             , PT_REAL),
00423             &msCmdCharHeight);
00424 
00425         dict->addParameter(ParameterDef("space_width", 
00426             "Sets the width of a space in relation to the screen."
00427             , PT_REAL),
00428             &msCmdSpaceWidth);
00429 
00430         dict->addParameter(ParameterDef("font_name", 
00431             "Sets the name of the font to use."
00432             , PT_STRING),
00433             &msCmdFontName);
00434 
00435         dict->addParameter(ParameterDef("colour", 
00436             "Sets the colour of the font (a solid colour)."
00437             , PT_STRING),
00438             &msCmdColour);
00439 
00440         dict->addParameter(ParameterDef("colour_bottom", 
00441             "Sets the colour of the font at the bottom (a gradient colour)."
00442             , PT_STRING),
00443             &msCmdColourBottom);
00444 
00445         dict->addParameter(ParameterDef("colour_top", 
00446             "Sets the colour of the font at the top (a gradient colour)."
00447             , PT_STRING),
00448             &msCmdColourTop);
00449 
00450         dict->addParameter(ParameterDef("alignment", 
00451             "Sets the alignment of the text: 'left', 'center' or 'right'."
00452             , PT_STRING),
00453             &msCmdAlignment);
00454     }
00455     //---------------------------------------------------------------------
00456     void TextAreaGuiElement::setColour(const ColourValue& col)
00457     {
00458         mColourBottom = mColourTop = col;
00459         mColoursChanged = true;
00460         updateColours();
00461     }
00462     //---------------------------------------------------------------------
00463     const ColourValue& TextAreaGuiElement::getColour(void) const
00464     {
00465         // Either one
00466         return mColourTop;
00467     }
00468     //---------------------------------------------------------------------
00469     void TextAreaGuiElement::setColourBottom(const ColourValue& col)
00470     {
00471         mColourBottom = col;
00472         mColoursChanged = true;
00473         updateColours();
00474     }
00475     //---------------------------------------------------------------------
00476     const ColourValue& TextAreaGuiElement::getColourBottom(void) const
00477     {
00478         return mColourBottom;
00479     }
00480     //---------------------------------------------------------------------
00481     void TextAreaGuiElement::setColourTop(const ColourValue& col)
00482     {
00483         mColourTop = col;
00484         mColoursChanged = true;
00485         updateColours();
00486     }
00487     //---------------------------------------------------------------------
00488     const ColourValue& TextAreaGuiElement::getColourTop(void) const
00489     {
00490         return mColourTop;
00491     }
00492     //---------------------------------------------------------------------
00493     void TextAreaGuiElement::updateColours(void)
00494     {
00495         if (!mColoursChanged) return; // do nothing if colours haven't changed
00496 
00497         // Convert to system-specific
00498         RGBA topColour, bottomColour;
00499         Root::getSingleton().convertColourValue(mColourTop, &topColour);
00500         Root::getSingleton().convertColourValue(mColourBottom, &bottomColour);
00501 
00502         HardwareVertexBufferSharedPtr vbuf = 
00503             mRenderOp.vertexData->vertexBufferBinding->getBuffer(COLOUR_BINDING);
00504 
00505         RGBA* pDest = static_cast<RGBA*>(
00506             vbuf->lock(HardwareBuffer::HBL_DISCARD) );
00507 
00508         for (size_t i = 0; i < mAllocSize; ++i)
00509         {
00510             // First tri (top, bottom, top)
00511             *pDest++ = topColour;
00512             *pDest++ = bottomColour;
00513             *pDest++ = topColour;
00514             // Second tri (top, bottom, bottom)
00515             *pDest++ = topColour;
00516             *pDest++ = bottomColour;
00517             *pDest++ = bottomColour;
00518         }
00519         vbuf->unlock();
00520 
00521         mColoursChanged = false;
00522 
00523     }
00524     //-----------------------------------------------------------------------
00525     void TextAreaGuiElement::setMetricsMode(GuiMetricsMode gmm)
00526     {
00527         Real vpWidth, vpHeight;
00528 
00529         vpWidth = (Real) (OverlayManager::getSingleton().getViewportWidth());
00530         vpHeight = (Real) (OverlayManager::getSingleton().getViewportHeight());
00531         mViewportAspectCoef = vpHeight/vpWidth;
00532 
00533         GuiElement::setMetricsMode(gmm);
00534         if (gmm != GMM_RELATIVE)
00535         {
00536             // Set pixel variables based on viewport multipliers
00537             mPixelCharHeight = mCharHeight * vpHeight;
00538             mPixelSpaceWidth = mSpaceWidth * vpHeight;
00539         }
00540     }
00541 
00542     //-----------------------------------------------------------------------
00543     void TextAreaGuiElement::_update(void)
00544     {
00545         Real vpWidth, vpHeight;
00546 
00547         vpWidth = (Real) (OverlayManager::getSingleton().getViewportWidth());
00548         vpHeight = (Real) (OverlayManager::getSingleton().getViewportHeight());
00549         mViewportAspectCoef = vpHeight/vpWidth;
00550         
00551         if (mMetricsMode != GMM_RELATIVE && 
00552             (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate))
00553         {
00554             // Recalc character size
00555 
00556             mCharHeight = (Real) mPixelCharHeight / vpHeight;
00557             mSpaceWidth = (Real) mPixelSpaceWidth / vpHeight;
00558             mGeomPositionsOutOfDate = true;
00559         }
00560         GuiElement::_update();
00561     }
00562     //---------------------------------------------------------------------------------------------
00563     // Char height command object
00564     //
00565     String TextAreaGuiElement::CmdCharHeight::doGet( const void* target ) const
00566     {
00567         return StringConverter::toString( 
00568             static_cast< const TextAreaGuiElement* >( target )->getCharHeight() );
00569     }
00570     void TextAreaGuiElement::CmdCharHeight::doSet( void* target, const String& val )
00571     {
00572         static_cast< TextAreaGuiElement* >( target )->setCharHeight( 
00573             StringConverter::parseReal( val ) );
00574     }
00575     //---------------------------------------------------------------------------------------------
00576     // Space width command object
00577     //
00578     String TextAreaGuiElement::CmdSpaceWidth::doGet( const void* target ) const
00579     {
00580         return StringConverter::toString( 
00581             static_cast< const TextAreaGuiElement* >( target )->getSpaceWidth() );
00582     }
00583     void TextAreaGuiElement::CmdSpaceWidth::doSet( void* target, const String& val )
00584     {
00585         static_cast< TextAreaGuiElement* >( target )->setSpaceWidth( 
00586             StringConverter::parseReal( val ) );
00587     }
00588     //---------------------------------------------------------------------------------------------
00589 
00590     //---------------------------------------------------------------------------------------------
00591     // Font name command object
00592     //
00593     String TextAreaGuiElement::CmdFontName::doGet( const void* target ) const
00594     {
00595         return static_cast< const TextAreaGuiElement* >( target )->getFontName();
00596     }
00597     void TextAreaGuiElement::CmdFontName::doSet( void* target, const String& val )
00598     {
00599         static_cast< TextAreaGuiElement* >( target )->setFontName( val );
00600     }
00601     //---------------------------------------------------------------------------------------------
00602     //---------------------------------------------------------------------------------------------
00603     // Colour command object
00604     //
00605     String TextAreaGuiElement::CmdColour::doGet( const void* target ) const
00606     {
00607         return StringConverter::toString (
00608             static_cast< const TextAreaGuiElement* >( target )->getColour());
00609     }
00610     void TextAreaGuiElement::CmdColour::doSet( void* target, const String& val )
00611     {
00612         static_cast< TextAreaGuiElement* >( target )->setColour( 
00613             StringConverter::parseColourValue(val) );
00614     }
00615     //---------------------------------------------------------------------------------------------
00616     //---------------------------------------------------------------------------------------------
00617     //---------------------------------------------------------------------------------------------
00618     // Top colour command object
00619     //
00620     String TextAreaGuiElement::CmdColourTop::doGet( const void* target ) const
00621     {
00622         return StringConverter::toString (
00623             static_cast< const TextAreaGuiElement* >( target )->getColourTop());
00624     }
00625     void TextAreaGuiElement::CmdColourTop::doSet( void* target, const String& val )
00626     {
00627         static_cast< TextAreaGuiElement* >( target )->setColourTop( 
00628             StringConverter::parseColourValue(val) );
00629     }
00630     //---------------------------------------------------------------------------------------------
00631     //---------------------------------------------------------------------------------------------
00632     //---------------------------------------------------------------------------------------------
00633     // Bottom colour command object
00634     //
00635     String TextAreaGuiElement::CmdColourBottom::doGet( const void* target ) const
00636     {
00637         return StringConverter::toString (
00638             static_cast< const TextAreaGuiElement* >( target )->getColourBottom());
00639     }
00640     void TextAreaGuiElement::CmdColourBottom::doSet( void* target, const String& val )
00641     {
00642         static_cast< TextAreaGuiElement* >( target )->setColourBottom( 
00643             StringConverter::parseColourValue(val) );
00644     }
00645     //---------------------------------------------------------------------------------------------
00646     //---------------------------------------------------------------------------------------------
00647     //---------------------------------------------------------------------------------------------
00648     // Alignment command object
00649     //
00650     String TextAreaGuiElement::CmdAlignment::doGet( const void* target ) const
00651     {
00652         Alignment align = static_cast< const TextAreaGuiElement* >( target )->getAlignment();
00653         switch (align)
00654         {
00655             case Left:
00656                 return "left";
00657             case Center:
00658                 return "center";
00659             case Right:
00660                 return "right";
00661                 
00662         }
00663         // To keep compiler happy
00664         return "left";
00665     }
00666     void TextAreaGuiElement::CmdAlignment::doSet( void* target, const String& val )
00667     {
00668         if (val == "center")
00669         {
00670             static_cast< TextAreaGuiElement* >( target )->setAlignment(Center);
00671         }
00672         else if (val == "right")
00673         {
00674             static_cast< TextAreaGuiElement* >( target )->setAlignment(Right);
00675         }
00676         else
00677         {
00678             static_cast< TextAreaGuiElement* >( target )->setAlignment(Left);
00679         }
00680     }
00681     //---------------------------------------------------------------------------------------------
00682 }

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:49 2004