1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
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 program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #include "OgreStableHeaders.h"
|
---|
26 | #include "OgreOverlayElementCommands.h"
|
---|
27 | #include "OgreOverlayElement.h"
|
---|
28 | #include "OgreStringConverter.h"
|
---|
29 |
|
---|
30 |
|
---|
31 | namespace Ogre {
|
---|
32 |
|
---|
33 | namespace OverlayElementCommands {
|
---|
34 |
|
---|
35 | //-----------------------------------------------------------------------
|
---|
36 | String CmdLeft::doGet(const void* target) const
|
---|
37 | {
|
---|
38 | return StringConverter::toString(
|
---|
39 | static_cast<const OverlayElement*>(target)->getLeft() );
|
---|
40 | }
|
---|
41 | void CmdLeft::doSet(void* target, const String& val)
|
---|
42 | {
|
---|
43 | static_cast<OverlayElement*>(target)->setLeft(StringConverter::parseReal(val));
|
---|
44 | }
|
---|
45 | //-----------------------------------------------------------------------
|
---|
46 | String CmdTop::doGet(const void* target) const
|
---|
47 | {
|
---|
48 | return StringConverter::toString(
|
---|
49 | static_cast<const OverlayElement*>(target)->getTop() );
|
---|
50 | }
|
---|
51 | void CmdTop::doSet(void* target, const String& val)
|
---|
52 | {
|
---|
53 | static_cast<OverlayElement*>(target)->setTop(StringConverter::parseReal(val));
|
---|
54 | }
|
---|
55 | //-----------------------------------------------------------------------
|
---|
56 | String CmdWidth::doGet(const void* target) const
|
---|
57 | {
|
---|
58 | return StringConverter::toString(
|
---|
59 | static_cast<const OverlayElement*>(target)->getWidth() );
|
---|
60 | }
|
---|
61 | void CmdWidth::doSet(void* target, const String& val)
|
---|
62 | {
|
---|
63 | static_cast<OverlayElement*>(target)->setWidth(StringConverter::parseReal(val));
|
---|
64 | }
|
---|
65 | //-----------------------------------------------------------------------
|
---|
66 | String CmdHeight::doGet(const void* target) const
|
---|
67 | {
|
---|
68 | return StringConverter::toString(
|
---|
69 | static_cast<const OverlayElement*>(target)->getHeight() );
|
---|
70 | }
|
---|
71 | void CmdHeight::doSet(void* target, const String& val)
|
---|
72 | {
|
---|
73 | static_cast<OverlayElement*>(target)->setHeight(StringConverter::parseReal(val));
|
---|
74 | }
|
---|
75 | //-----------------------------------------------------------------------
|
---|
76 | String CmdMaterial::doGet(const void* target) const
|
---|
77 | {
|
---|
78 | return static_cast<const OverlayElement*>(target)->getMaterialName();
|
---|
79 | }
|
---|
80 | void CmdMaterial::doSet(void* target, const String& val)
|
---|
81 | {
|
---|
82 | if (val != "")
|
---|
83 | {
|
---|
84 | static_cast<OverlayElement*>(target)->setMaterialName(val);
|
---|
85 | }
|
---|
86 | }
|
---|
87 | //-----------------------------------------------------------------------
|
---|
88 | //-----------------------------------------------------------------------
|
---|
89 | String CmdCaption::doGet(const void* target) const
|
---|
90 | {
|
---|
91 | return static_cast<const OverlayElement*>(target)->getCaption();
|
---|
92 | }
|
---|
93 | void CmdCaption::doSet(void* target, const String& val)
|
---|
94 | {
|
---|
95 | static_cast<OverlayElement*>(target)->setCaption(val);
|
---|
96 | }
|
---|
97 | //-----------------------------------------------------------------------
|
---|
98 | //-----------------------------------------------------------------------
|
---|
99 | //-----------------------------------------------------------------------
|
---|
100 | String CmdMetricsMode::doGet(const void* target) const
|
---|
101 | {
|
---|
102 | GuiMetricsMode gmm =
|
---|
103 | static_cast<const OverlayElement*>(target)->getMetricsMode();
|
---|
104 |
|
---|
105 | switch (gmm)
|
---|
106 | {
|
---|
107 | case GMM_PIXELS :
|
---|
108 | return "pixels";
|
---|
109 |
|
---|
110 | case GMM_RELATIVE_ASPECT_ADJUSTED :
|
---|
111 | return "relative_aspect_adjusted";
|
---|
112 |
|
---|
113 | default :
|
---|
114 | return "relative";
|
---|
115 | }
|
---|
116 | }
|
---|
117 | void CmdMetricsMode::doSet(void* target, const String& val)
|
---|
118 | {
|
---|
119 | if (val == "pixels")
|
---|
120 | {
|
---|
121 | static_cast<OverlayElement*>(target)->setMetricsMode(GMM_PIXELS);
|
---|
122 | }
|
---|
123 | else if (val == "relative_aspect_adjusted")
|
---|
124 | {
|
---|
125 | static_cast<OverlayElement*>(target)->setMetricsMode(GMM_RELATIVE_ASPECT_ADJUSTED);
|
---|
126 | }
|
---|
127 | else
|
---|
128 | {
|
---|
129 | static_cast<OverlayElement*>(target)->setMetricsMode(GMM_RELATIVE);
|
---|
130 | }
|
---|
131 | }
|
---|
132 | //-----------------------------------------------------------------------
|
---|
133 | //-----------------------------------------------------------------------
|
---|
134 | //-----------------------------------------------------------------------
|
---|
135 | String CmdHorizontalAlign::doGet(const void* target) const
|
---|
136 | {
|
---|
137 | GuiHorizontalAlignment gha =
|
---|
138 | static_cast<const OverlayElement*>(target)->getHorizontalAlignment();
|
---|
139 | switch(gha)
|
---|
140 | {
|
---|
141 | case GHA_LEFT:
|
---|
142 | return "left";
|
---|
143 | case GHA_RIGHT:
|
---|
144 | return "right";
|
---|
145 | case GHA_CENTER:
|
---|
146 | return "center";
|
---|
147 | }
|
---|
148 | // To keep compiler happy
|
---|
149 | return "center";
|
---|
150 | }
|
---|
151 | void CmdHorizontalAlign::doSet(void* target, const String& val)
|
---|
152 | {
|
---|
153 | if (val == "left")
|
---|
154 | {
|
---|
155 | static_cast<OverlayElement*>(target)->setHorizontalAlignment(GHA_LEFT);
|
---|
156 | }
|
---|
157 | else if (val == "right")
|
---|
158 | {
|
---|
159 | static_cast<OverlayElement*>(target)->setHorizontalAlignment(GHA_RIGHT);
|
---|
160 | }
|
---|
161 | else
|
---|
162 | {
|
---|
163 | static_cast<OverlayElement*>(target)->setHorizontalAlignment(GHA_CENTER);
|
---|
164 | }
|
---|
165 | }
|
---|
166 | //-----------------------------------------------------------------------
|
---|
167 | //-----------------------------------------------------------------------
|
---|
168 | //-----------------------------------------------------------------------
|
---|
169 | String CmdVerticalAlign::doGet(const void* target) const
|
---|
170 | {
|
---|
171 | GuiVerticalAlignment gva =
|
---|
172 | static_cast<const OverlayElement*>(target)->getVerticalAlignment();
|
---|
173 | switch(gva)
|
---|
174 | {
|
---|
175 | case GVA_TOP:
|
---|
176 | return "top";
|
---|
177 | case GVA_BOTTOM:
|
---|
178 | return "bottom";
|
---|
179 | case GVA_CENTER:
|
---|
180 | return "center";
|
---|
181 | }
|
---|
182 | // To keep compiler happy
|
---|
183 | return "center";
|
---|
184 | }
|
---|
185 | void CmdVerticalAlign::doSet(void* target, const String& val)
|
---|
186 | {
|
---|
187 | if (val == "top")
|
---|
188 | {
|
---|
189 | static_cast<OverlayElement*>(target)->setVerticalAlignment(GVA_TOP);
|
---|
190 | }
|
---|
191 | else if (val == "bottom")
|
---|
192 | {
|
---|
193 | static_cast<OverlayElement*>(target)->setVerticalAlignment(GVA_BOTTOM);
|
---|
194 | }
|
---|
195 | else
|
---|
196 | {
|
---|
197 | static_cast<OverlayElement*>(target)->setVerticalAlignment(GVA_CENTER);
|
---|
198 | }
|
---|
199 | }
|
---|
200 | //-----------------------------------------------------------------------
|
---|
201 | //-----------------------------------------------------------------------
|
---|
202 | //-----------------------------------------------------------------------
|
---|
203 | //-----------------------------------------------------------------------
|
---|
204 | String CmdVisible::doGet(const void* target) const
|
---|
205 | {
|
---|
206 | bool visible =
|
---|
207 | static_cast<const OverlayElement*>(target)->isVisible();
|
---|
208 | switch(visible)
|
---|
209 | {
|
---|
210 | case true:
|
---|
211 | return "true";
|
---|
212 | case false:
|
---|
213 | return "false";
|
---|
214 | }
|
---|
215 | // To keep compiler happy
|
---|
216 | return "true";
|
---|
217 | }
|
---|
218 | void CmdVisible::doSet(void* target, const String& val)
|
---|
219 | {
|
---|
220 | if (val == "true")
|
---|
221 | {
|
---|
222 | static_cast<OverlayElement*>(target)->show();
|
---|
223 | }
|
---|
224 | else if (val == "false")
|
---|
225 | {
|
---|
226 | static_cast<OverlayElement*>(target)->hide();
|
---|
227 | }
|
---|
228 | }
|
---|
229 | //-----------------------------------------------------------------------
|
---|
230 | }
|
---|
231 | }
|
---|
232 |
|
---|