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 00105 switch (gmm) 00106 { 00107 case GMM_PIXELS : 00108 return "pixels"; 00109 00110 case GMM_RELATIVE_ASPECT_ADJUSTED : 00111 return "relative_aspect_adjusted"; 00112 00113 default : 00114 return "relative"; 00115 } 00116 } 00117 void CmdMetricsMode::doSet(void* target, const String& val) 00118 { 00119 if (val == "pixels") 00120 { 00121 static_cast<GuiElement*>(target)->setMetricsMode(GMM_PIXELS); 00122 } 00123 else if (val == "relative_aspect_adjusted") 00124 { 00125 static_cast<GuiElement*>(target)->setMetricsMode(GMM_RELATIVE_ASPECT_ADJUSTED); 00126 } 00127 else 00128 { 00129 static_cast<GuiElement*>(target)->setMetricsMode(GMM_RELATIVE); 00130 } 00131 } 00132 //----------------------------------------------------------------------- 00133 //----------------------------------------------------------------------- 00134 //----------------------------------------------------------------------- 00135 String CmdHorizontalAlign::doGet(const void* target) const 00136 { 00137 GuiHorizontalAlignment gha = 00138 static_cast<const GuiElement*>(target)->getHorizontalAlignment(); 00139 switch(gha) 00140 { 00141 case GHA_LEFT: 00142 return "left"; 00143 case GHA_RIGHT: 00144 return "right"; 00145 case GHA_CENTER: 00146 return "center"; 00147 } 00148 // To keep compiler happy 00149 return "center"; 00150 } 00151 void CmdHorizontalAlign::doSet(void* target, const String& val) 00152 { 00153 if (val == "left") 00154 { 00155 static_cast<GuiElement*>(target)->setHorizontalAlignment(GHA_LEFT); 00156 } 00157 else if (val == "right") 00158 { 00159 static_cast<GuiElement*>(target)->setHorizontalAlignment(GHA_RIGHT); 00160 } 00161 else 00162 { 00163 static_cast<GuiElement*>(target)->setHorizontalAlignment(GHA_CENTER); 00164 } 00165 } 00166 //----------------------------------------------------------------------- 00167 //----------------------------------------------------------------------- 00168 //----------------------------------------------------------------------- 00169 String CmdVerticalAlign::doGet(const void* target) const 00170 { 00171 GuiVerticalAlignment gva = 00172 static_cast<const GuiElement*>(target)->getVerticalAlignment(); 00173 switch(gva) 00174 { 00175 case GVA_TOP: 00176 return "top"; 00177 case GVA_BOTTOM: 00178 return "bottom"; 00179 case GVA_CENTER: 00180 return "center"; 00181 } 00182 // To keep compiler happy 00183 return "center"; 00184 } 00185 void CmdVerticalAlign::doSet(void* target, const String& val) 00186 { 00187 if (val == "top") 00188 { 00189 static_cast<GuiElement*>(target)->setVerticalAlignment(GVA_TOP); 00190 } 00191 else if (val == "bottom") 00192 { 00193 static_cast<GuiElement*>(target)->setVerticalAlignment(GVA_BOTTOM); 00194 } 00195 else 00196 { 00197 static_cast<GuiElement*>(target)->setVerticalAlignment(GVA_CENTER); 00198 } 00199 } 00200 //----------------------------------------------------------------------- 00201 //----------------------------------------------------------------------- 00202 //----------------------------------------------------------------------- 00203 //----------------------------------------------------------------------- 00204 String CmdVisible::doGet(const void* target) const 00205 { 00206 bool visible = 00207 static_cast<const GuiElement*>(target)->isVisible(); 00208 switch(visible) 00209 { 00210 case true: 00211 return "true"; 00212 case false: 00213 return "false"; 00214 } 00215 // To keep compiler happy 00216 return "true"; 00217 } 00218 void CmdVisible::doSet(void* target, const String& val) 00219 { 00220 if (val == "true") 00221 { 00222 static_cast<GuiElement*>(target)->show(); 00223 } 00224 else if (val == "false") 00225 { 00226 static_cast<GuiElement*>(target)->hide(); 00227 } 00228 } 00229 //----------------------------------------------------------------------- 00230 } 00231 } 00232
Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:15 2004