xoreos  0.0.5
gui.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/graphics/windowman.h"
26 
29 
30 namespace Engines {
31 
32 namespace KotOR2 {
33 
34 GUI::GUI(::Engines::Console *console) : Engines::KotOR::GUI(console) {
35 }
36 
37 void GUI::initWidget(Widget &widget) {
38  KotORJadeWidget &kotorWidget = static_cast<KotORJadeWidget &>(widget);
39 
40  float wWidth = WindowMan.getWindowWidth();
41  float wHeight = WindowMan.getWindowHeight();
42 
43  if (widget.getTag() == "TGuiPanel") {
44  kotorWidget.setWidth(wWidth);
45  kotorWidget.setHeight(wHeight);
46  } else {
47  float x, y, z;
48  kotorWidget.getPosition(x, y, z);
49 
50  x *= ((wWidth / 2.0f) / 400.0f);
51  y *= ((wHeight / 2.0f) / 300.0f);
52 
53  kotorWidget.setPosition(x, y, z);
54 
55  float w, h;
56  w = kotorWidget.getWidth();
57  h = kotorWidget.getHeight();
58 
59  w *= (wWidth / 800.0f);
60  h *= (wHeight / 600.0f);
61 
62  kotorWidget.setWidth(w);
63  kotorWidget.setHeight(h);
64  }
65 }
66 
67 } // End of namespace KotOR2
68 
69 } // End of namespace Engines
virtual void setHeight(float height)
Set the height of the widget.
virtual void getPosition(float &x, float &y, float &z) const
Get the widget&#39;s position.
Definition: widget.cpp:140
The global window manager.
A KotOR2 GUI.
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
Common base for Star Wars: Knights of the Old Republic and Jade Empire widgets.
GUI(::Engines::Console *console)
Definition: gui.cpp:34
#define WindowMan
Shortcut for accessing the window manager.
Definition: windowman.h:137
A widget in a GUI.
Definition: widget.h:40
virtual void initWidget(Widget &widget)
Definition: gui.cpp:37
float getWidth() const
Get the widget&#39;s width.
virtual void setWidth(float width)
Set the width of the widget.
virtual void setPosition(float x, float y, float z)
Set the widget&#39;s position.
float getHeight() const
Get the widget&#39;s height.