OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
box.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_WIDGETS_BOX_H
2 #define OPENMW_WIDGETS_BOX_H
3 
4 #include <MyGUI_Widget.h>
5 #include <MyGUI_TextBox.h>
6 #include <MyGUI_EditBox.h>
7 #include <MyGUI_ListBox.h>
8 #include <MyGUI_Button.h>
9 
10 #include "fontwrapper.hpp"
11 
12 namespace Gui
13 {
14  class Button : public FontWrapper<MyGUI::Button>
15  {
16  MYGUI_RTTI_DERIVED( Button )
17  };
18 
19  class TextBox : public FontWrapper<MyGUI::TextBox>
20  {
21  MYGUI_RTTI_DERIVED( TextBox )
22  };
23 
24  class EditBox : public FontWrapper<MyGUI::EditBox>
25  {
26  MYGUI_RTTI_DERIVED( EditBox )
27  };
28 
30  {
31  public:
32  AutoSizedWidget() : mExpandDirection(MyGUI::Align::Right) {}
33 
34  virtual MyGUI::IntSize getRequestedSize() = 0;
35 
36  protected:
37  void notifySizeChange(MyGUI::Widget* w);
38 
39  MyGUI::Align mExpandDirection;
40  };
41 
42  class AutoSizedTextBox : public AutoSizedWidget, public TextBox
43  {
44  MYGUI_RTTI_DERIVED( AutoSizedTextBox )
45 
46  public:
47  virtual MyGUI::IntSize getRequestedSize();
48  virtual void setCaption(const MyGUI::UString& _value);
49 
50  protected:
51  virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
52  std::string mFontSize;
53  };
54 
55  class AutoSizedEditBox : public AutoSizedWidget, public EditBox
56  {
57  MYGUI_RTTI_DERIVED( AutoSizedEditBox )
58 
59  public:
60 
61  virtual MyGUI::IntSize getRequestedSize();
62  virtual void setCaption(const MyGUI::UString& _value);
63 
64  virtual void initialiseOverride();
65 
66  protected:
67  virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
68  std::string mFontSize;
69  };
70 
71  class AutoSizedButton : public AutoSizedWidget, public Button
72  {
73  MYGUI_RTTI_DERIVED( AutoSizedButton )
74 
75  public:
76  virtual MyGUI::IntSize getRequestedSize();
77  virtual void setCaption(const MyGUI::UString& _value);
78 
79  protected:
80  virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
81  std::string mFontSize;
82  };
83 
88  class Box : public AutoSizedWidget
89  {
90  public:
91  Box();
92 
94 
95  protected:
96  virtual void align() = 0;
97 
98  virtual bool _setPropertyImpl(const std::string& _key, const std::string& _value);
99 
100  int mSpacing; // how much space to put between elements
101 
102  int mPadding; // outer padding
103 
104  bool mAutoResize; // auto resize the box so that it exactly fits all elements
105  };
106 
107  class Spacer : public AutoSizedWidget, public MyGUI::Widget
108  {
109  MYGUI_RTTI_DERIVED( Spacer )
110  public:
111  Spacer();
112 
113  virtual MyGUI::IntSize getRequestedSize() { return MyGUI::IntSize(0,0); }
114  };
115 
116  class HBox : public Box, public MyGUI::Widget
117  {
118  MYGUI_RTTI_DERIVED( HBox )
119 
120  public:
121  virtual void setSize (const MyGUI::IntSize &_value);
122  virtual void setCoord (const MyGUI::IntCoord &_value);
123 
124  protected:
125  virtual void initialiseOverride();
126 
127  virtual void align();
128  virtual MyGUI::IntSize getRequestedSize();
129 
130  virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
131 
132  virtual void onWidgetCreated(MyGUI::Widget* _widget);
133  };
134 
135  class VBox : public Box, public MyGUI::Widget
136  {
137  MYGUI_RTTI_DERIVED( VBox)
138 
139  public:
140  virtual void setSize (const MyGUI::IntSize &_value);
141  virtual void setCoord (const MyGUI::IntCoord &_value);
142 
143  protected:
144  virtual void initialiseOverride();
145 
146  virtual void align();
147  virtual MyGUI::IntSize getRequestedSize();
148 
149  virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
150 
151  virtual void onWidgetCreated(MyGUI::Widget* _widget);
152  };
153 
154 }
155 
156 #endif
A container widget that automatically sizes its children.
Definition: box.hpp:88
Spacer()
Definition: box.cpp:448
virtual void initialiseOverride()
Definition: box.cpp:245
virtual void onWidgetCreated(MyGUI::Widget *_widget)
Definition: box.cpp:443
virtual MyGUI::IntSize getRequestedSize()
Definition: box.cpp:408
int mSpacing
Definition: box.hpp:100
virtual MyGUI::IntSize getRequestedSize()
Definition: box.cpp:258
Definition: box.hpp:29
virtual void setCaption(const MyGUI::UString &_value)
Definition: box.cpp:98
virtual void setCaption(const MyGUI::UString &_value)
Definition: box.cpp:62
virtual bool _setPropertyImpl(const std::string &_key, const std::string &_value)
Definition: box.cpp:128
virtual void setCoord(const MyGUI::IntCoord &_value)
Definition: box.cpp:394
virtual void onWidgetCreated(MyGUI::Widget *_widget)
Definition: box.cpp:253
virtual void setSize(const MyGUI::IntSize &_value)
Definition: box.cpp:233
virtual void initialiseOverride()
Definition: box.cpp:69
Box()
Definition: box.cpp:116
Definition: box.hpp:107
Definition: box.hpp:116
virtual void setCoord(const MyGUI::IntCoord &_value)
Definition: box.cpp:239
virtual void initialiseOverride()
Definition: box.cpp:400
Definition: fontwrapper.hpp:11
virtual MyGUI::IntSize getRequestedSize()=0
Definition: box.hpp:14
virtual void setPropertyOverride(const std::string &_key, const std::string &_value)
Definition: box.cpp:382
Definition: box.hpp:71
void notifyChildrenSizeChanged()
Definition: box.cpp:123
Definition: box.hpp:19
bool mAutoResize
Definition: box.hpp:104
virtual void setCaption(const MyGUI::UString &_value)
Definition: box.cpp:36
virtual void setPropertyOverride(const std::string &_key, const std::string &_value)
Definition: box.cpp:227
Definition: box.hpp:42
std::string mFontSize
Definition: box.hpp:68
virtual MyGUI::IntSize getRequestedSize()
Definition: box.hpp:113
virtual void setPropertyOverride(const std::string &_key, const std::string &_value)
Definition: box.cpp:76
virtual void setPropertyOverride(const std::string &_key, const std::string &_value)
Definition: box.cpp:105
std::string mFontSize
Definition: box.hpp:52
virtual void setPropertyOverride(const std::string &_key, const std::string &_value)
Definition: box.cpp:43
virtual MyGUI::IntSize getRequestedSize()
Definition: box.cpp:88
int mPadding
Definition: box.hpp:102
void notifySizeChange(MyGUI::Widget *w)
Definition: box.cpp:6
virtual void setSize(const MyGUI::IntSize &_value)
Definition: box.cpp:388
Definition: box.hpp:135
MyGUI::Align mExpandDirection
Definition: box.hpp:39
virtual void align()
Definition: box.cpp:142
std::string mFontSize
Definition: box.hpp:81
Definition: box.hpp:55
virtual MyGUI::IntSize getRequestedSize()
Definition: box.cpp:55
virtual void align()
Definition: box.cpp:296
virtual void align()=0
Definition: box.hpp:24
virtual MyGUI::IntSize getRequestedSize()
Definition: box.cpp:31
AutoSizedWidget()
Definition: box.hpp:32