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

OgreGuiElementCommands.cpp

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE 
00004     (Object-oriented Graphics Rendering Engine)
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 program is free software; you can redistribute it and/or modify it under 
00011 the terms of the GNU Lesser General Public License as published by the Free Software 
00012 Foundation; either version 2 of the License, or (at your option) any later 
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT 
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with 
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #include "OgreStableHeaders.h"
00026 #include "OgreGuiElementCommands.h"
00027 #include "OgreGuiElement.h"
00028 #include "OgreStringConverter.h"
00029 
00030 
00031 namespace Ogre {
00032 
00033     namespace GuiElementCommands {
00034 
00035         //-----------------------------------------------------------------------
00036         String CmdLeft::doGet(const void* target) const
00037         {
00038             return StringConverter::toString(
00039                 static_cast<const GuiElement*>(target)->getLeft() );
00040         }
00041         void CmdLeft::doSet(void* target, const String& val)
00042         {
00043             static_cast<GuiElement*>(target)->setLeft(StringConverter::parseReal(val));
00044         }
00045         //-----------------------------------------------------------------------
00046         String CmdTop::doGet(const void* target) const
00047         {
00048             return StringConverter::toString(
00049                 static_cast<const GuiElement*>(target)->getTop() );
00050         }
00051         void CmdTop::doSet(void* target, const String& val)
00052         {
00053             static_cast<GuiElement*>(target)->setTop(StringConverter::parseReal(val));
00054         }
00055         //-----------------------------------------------------------------------
00056         String CmdWidth::doGet(const void* target) const
00057         {
00058             return StringConverter::toString(
00059                 static_cast<const GuiElement*>(target)->getWidth() );
00060         }
00061         void CmdWidth::doSet(void* target, const String& val)
00062         {
00063             static_cast<GuiElement*>(target)->setWidth(StringConverter::parseReal(val));
00064         }
00065         //-----------------------------------------------------------------------
00066         String CmdHeight::doGet(const void* target) const
00067         {
00068             return StringConverter::toString(
00069                 static_cast<const GuiElement*>(target)->getHeight() );
00070         }
00071         void CmdHeight::doSet(void* target, const String& val)
00072         {
00073             static_cast<GuiElement*>(target)->setHeight(StringConverter::parseReal(val));
00074         }
00075         //-----------------------------------------------------------------------
00076         String CmdMaterial::doGet(const void* target) const
00077         {
00078             return static_cast<const GuiElement*>(target)->getMaterialName();
00079         }
00080         void CmdMaterial::doSet(void* target, const String& val)
00081         {
00082             if (val != "")
00083             {
00084                 static_cast<GuiElement*>(target)->setMaterialName(val);
00085             }
00086         }
00087         //-----------------------------------------------------------------------
00088         //-----------------------------------------------------------------------
00089         String CmdCaption::doGet(const void* target) const
00090         {
00091             return static_cast<const GuiElement*>(target)->getCaption();
00092         }
00093         void CmdCaption::doSet(void* target, const String& val)
00094         {
00095             static_cast<GuiElement*>(target)->setCaption(val);
00096         }
00097         //-----------------------------------------------------------------------
00098         //-----------------------------------------------------------------------
00099         //-----------------------------------------------------------------------
00100         String CmdMetricsMode::doGet(const void* target) const
00101         {
00102             GuiMetricsMode gmm = 
00103                 static_cast<const GuiElement*>(target)->getMetricsMode();
00104             if (gmm == GMM_PIXELS)
00105             {
00106                 return "pixels";
00107             }
00108             else
00109             {
00110                 return "relative";
00111             }
00112         }
00113         void CmdMetricsMode::doSet(void* target, const String& val)
00114         {
00115             if (val == "pixels")
00116             {
00117                 static_cast<GuiElement*>(target)->setMetricsMode(GMM_PIXELS);
00118             }
00119             else
00120             {
00121                 static_cast<GuiElement*>(target)->setMetricsMode(GMM_RELATIVE);
00122             }
00123         }
00124         //-----------------------------------------------------------------------
00125         //-----------------------------------------------------------------------
00126         //-----------------------------------------------------------------------
00127         String CmdHorizontalAlign::doGet(const void* target) const
00128         {
00129             GuiHorizontalAlignment gha = 
00130                 static_cast<const GuiElement*>(target)->getHorizontalAlignment();
00131             switch(gha)
00132             {
00133             case GHA_LEFT:
00134                 return "left";
00135             case GHA_RIGHT:
00136                 return "right";
00137             case GHA_CENTER:
00138                 return "center";
00139             }
00140             // To keep compiler happy
00141             return "center";
00142         }
00143         void CmdHorizontalAlign::doSet(void* target, const String& val)
00144         {
00145             if (val == "left")
00146             {
00147                 static_cast<GuiElement*>(target)->setHorizontalAlignment(GHA_LEFT);
00148             }
00149             else if (val == "right")
00150             {
00151                 static_cast<GuiElement*>(target)->setHorizontalAlignment(GHA_RIGHT);
00152             }
00153             else
00154             {
00155                 static_cast<GuiElement*>(target)->setHorizontalAlignment(GHA_CENTER);
00156             }
00157         }
00158         //-----------------------------------------------------------------------
00159         //-----------------------------------------------------------------------
00160         //-----------------------------------------------------------------------
00161         String CmdVerticalAlign::doGet(const void* target) const
00162         {
00163             GuiVerticalAlignment gva = 
00164                 static_cast<const GuiElement*>(target)->getVerticalAlignment();
00165             switch(gva)
00166             {
00167             case GVA_TOP:
00168                 return "top";
00169             case GVA_BOTTOM:
00170                 return "bottom";
00171             case GVA_CENTER:
00172                 return "center";
00173             }
00174             // To keep compiler happy
00175             return "center";
00176         }
00177         void CmdVerticalAlign::doSet(void* target, const String& val)
00178         {
00179             if (val == "top")
00180             {
00181                 static_cast<GuiElement*>(target)->setVerticalAlignment(GVA_TOP);
00182             }
00183             else if (val == "bottom")
00184             {
00185                 static_cast<GuiElement*>(target)->setVerticalAlignment(GVA_BOTTOM);
00186             }
00187             else
00188             {
00189                 static_cast<GuiElement*>(target)->setVerticalAlignment(GVA_CENTER);
00190             }
00191         }
00192         //-----------------------------------------------------------------------
00193         //-----------------------------------------------------------------------
00194         //-----------------------------------------------------------------------
00195         //-----------------------------------------------------------------------
00196         String CmdVisible::doGet(const void* target) const
00197         {
00198             bool visible = 
00199                 static_cast<const GuiElement*>(target)->isVisible();
00200             switch(visible)
00201             {
00202             case true:
00203                 return "true";
00204             case false:
00205                 return "false";
00206             }
00207             // To keep compiler happy
00208             return "true";
00209         }
00210         void CmdVisible::doSet(void* target, const String& val)
00211         {
00212             if (val == "true")
00213             {
00214                 static_cast<GuiElement*>(target)->show();
00215             }
00216             else if (val == "false")
00217             {
00218                 static_cast<GuiElement*>(target)->hide();
00219             }
00220         }
00221         //-----------------------------------------------------------------------
00222     }
00223 }
00224 

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:13 2004