xoreos  0.0.5
widget.h
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 #ifndef ENGINES_AURORA_WIDGET_H
26 #define ENGINES_AURORA_WIDGET_H
27 
28 #include <list>
29 
30 #include <boost/noncopyable.hpp>
31 
32 #include "src/common/types.h"
33 #include "src/common/ustring.h"
34 
35 namespace Engines {
36 
37 class GUI;
38 
40 class Widget : boost::noncopyable {
41 public:
42  Widget(GUI &gui, const Common::UString &tag);
43  virtual ~Widget();
44 
45  const Common::UString &getTag() const;
46 
48  virtual void setTag(const Common::UString &tag);
49 
50  bool isActive () const;
51  bool isVisible () const;
52  bool isDisabled () const;
53  bool isInvisible() const;
54 
55  virtual void show();
56  virtual void hide();
57 
58  Widget *getParent();
59  const Widget *getParent() const;
60 
62  Widget *getChild(const Common::UString &childTag);
63 
65  virtual void setPosition(float x, float y, float z);
66 
68  virtual void movePosition(float x, float y, float z);
69 
71  virtual void getPosition(float &x, float &y, float &z) const;
72 
73  virtual float getWidth () const;
74  virtual float getHeight() const;
75 
76  virtual void setDisabled(bool disabled);
77  virtual void setInvisible(bool invisible);
78 
79  virtual void enter();
80  virtual void leave();
81 
83  virtual void mouseMove(uint8 state, float x, float y);
85  virtual void mouseDown(uint8 state, float x, float y);
87  virtual void mouseUp(uint8 state, float x, float y);
89  virtual void mouseWheel(uint8 state, int x, int y);
90 
92  virtual void mouseDblClick(uint8 state, float x, float y);
93 
95  virtual void subActive(Widget &widget);
96 
97  void remove();
98 
99  virtual void addSub(Widget &widget);
100  virtual void addChild(Widget &widget);
101  virtual void addGroupMember(Widget &widget);
102 
103  virtual void removeSub(Widget &widget);
104  virtual void removeChild(Widget &widget);
105  virtual void removeGroupMember(Widget &widget);
106 
107 protected:
109 
111 
114 
115  std::list<Widget *> _subWidgets;
116  std::list<Widget *> _children;
117  std::list<Widget *> _groupMembers;
118 
120  virtual void signalGroupMemberActive();
121 
122  void setActive(bool active);
123  void raiseCallbackActive(Widget &widget);
124 
125 private:
126  bool _active;
127  bool _visible;
128  bool _disabled;
129  bool _invisible;
130 
131  float _x;
132  float _y;
133  float _z;
134 
137  float _lastClickX;
138  float _lastClickY;
139 
140  friend class GUI;
141 };
142 
143 } // End of namespace Engines
144 
145 #endif // ENGINES_AURORA_WIDGET_H
virtual void mouseDblClick(uint8 state, float x, float y)
A mouse button was double-clicked on the widget.
Definition: widget.cpp:200
uint8 _lastClickButton
Definition: widget.h:135
float _y
The widget Y position.
Definition: widget.h:132
virtual void setInvisible(bool invisible)
Make the widget invisible.
Definition: widget.cpp:168
Widget * _owner
The widget&#39;s owner, if any.
Definition: widget.h:113
virtual void setTag(const Common::UString &tag)
Set the widget&#39;s tag.
Definition: widget.cpp:49
A class holding an UTF-8 string.
Definition: ustring.h:48
float _lastClickX
Definition: widget.h:137
bool isActive() const
Was the widget activated?
Definition: widget.cpp:55
uint8_t uint8
Definition: types.h:200
virtual void subActive(Widget &widget)
A sub-widget was activated.
Definition: widget.cpp:203
virtual void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: widget.cpp:119
virtual void enter()
The mouse entered the widget.
Definition: widget.cpp:182
void setActive(bool active)
The widget&#39;s active state.
Definition: widget.cpp:268
virtual void setDisabled(bool disabled)
Disable/Enable the widget.
Definition: widget.cpp:154
virtual float getWidth() const
Get the widget&#39;s width.
Definition: widget.cpp:146
virtual void addGroupMember(Widget &widget)
Add a fellow group member to the widget.
Definition: widget.cpp:222
virtual void getPosition(float &x, float &y, float &z) const
Get the widget&#39;s position.
Definition: widget.cpp:140
virtual void mouseUp(uint8 state, float x, float y)
A mouse button was released on the widget.
Definition: widget.cpp:194
bool isVisible() const
Is the widget visible?
Definition: widget.cpp:59
Widget(GUI &gui, const Common::UString &tag)
Definition: widget.cpp:34
bool _visible
Is the widget visible?
Definition: widget.h:127
virtual void signalGroupMemberActive()
A fellow group member signaled that it is now active.
Definition: widget.cpp:264
GUI * _gui
The GUI the widget belongs to.
Definition: widget.h:108
virtual float getHeight() const
Get the widget&#39;s height.
Definition: widget.cpp:150
A GUI.
Definition: gui.h:43
bool isInvisible() const
Is the widget invisible (never visible)?
Definition: widget.cpp:67
virtual void mouseDown(uint8 state, float x, float y)
A mouse button was pressed on the widget.
Definition: widget.cpp:191
void raiseCallbackActive(Widget &widget)
Definition: widget.cpp:281
Common::UString _tag
The widget&#39;s tag.
Definition: widget.h:110
virtual ~Widget()
Definition: widget.cpp:42
Widget * getParent()
Definition: widget.cpp:102
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
bool _active
Was the widget activated?
Definition: widget.h:126
float _lastClickY
Definition: widget.h:138
Low-level type definitions to handle fixed width types portably.
virtual void movePosition(float x, float y, float z)
Move the widget, relative to its current position.
Definition: widget.cpp:136
virtual void addChild(Widget &widget)
Add a child to the widget.
Definition: widget.cpp:215
virtual void removeChild(Widget &widget)
Remove a child from the widget.
Definition: widget.cpp:238
bool _disabled
Is the widget disabled?
Definition: widget.h:128
Unicode string handling.
virtual void hide()
Hide the widget.
Definition: widget.cpp:90
virtual void leave()
The mouse left the widget.
Definition: widget.cpp:185
virtual void mouseWheel(uint8 state, int x, int y)
A mouse wheel was used on the widget.
Definition: widget.cpp:197
virtual void removeGroupMember(Widget &widget)
Remove fellow group member from the widget.
Definition: widget.cpp:249
virtual void removeSub(Widget &widget)
Remove a sub-widget from the widget.
Definition: widget.cpp:227
A widget in a GUI.
Definition: widget.h:40
virtual void show()
Show the widget.
Definition: widget.cpp:71
Widget * getChild(const Common::UString &childTag)
Get the widget&#39;s child by tag.
Definition: widget.cpp:110
bool _invisible
Is the widget invisible (never visible)?
Definition: widget.h:129
uint32_t uint32
Definition: types.h:204
float _z
The widget Z position.
Definition: widget.h:133
bool isDisabled() const
Is the widget disabled?
Definition: widget.cpp:63
std::list< Widget * > _groupMembers
The widget&#39;s fellow group members.
Definition: widget.h:117
uint32 _lastClickTime
Definition: widget.h:136
Widget * _parent
The widget&#39;s parent, if any.
Definition: widget.h:112
virtual void addSub(Widget &widget)
Add a sub-widget to the widget.
Definition: widget.cpp:206
std::list< Widget * > _subWidgets
The widget&#39;s sub-widgets.
Definition: widget.h:115
virtual void mouseMove(uint8 state, float x, float y)
The mouse was moved over the widget.
Definition: widget.cpp:188
std::list< Widget * > _children
The widget&#39;s children.
Definition: widget.h:116
float _x
The widget X position.
Definition: widget.h:131