2 // Copyright (C) 2008 by Martin Moracek
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Provides collection of basic widgets.
27 #include <boost/signals/connection.hpp>
33 #include "plaintext.h"
40 class AbstractStatic
: virtual public Widget
{
42 AbstractStatic(Gui
& g
, Widget
* p
);
44 void OnMouseEnter(void) {}
45 void OnMouseExit(void) {}
48 class AbstractButton
: virtual public Widget
{
51 boost::signal
<void (void)> clicked
;
54 AbstractButton(Gui
& g
, Widget
* p
);
56 void OnMouseEnter(void);
57 void OnMouseExit(void);
61 class OnButtonPressed
;
62 class OnButtonReleased
;
65 boost::signals::connection buttonCon1
;
66 boost::signals::connection buttonCon2
;
69 class AbstractEdit
: virtual public Widget
{
71 AbstractEdit(Gui
& g
, Widget
* p
);
73 void OnMouseEnter(void);
77 class OnButtonPressed
;
81 boost::signals::connection buttonCon
;
82 boost::signals::connection keyCon
;
85 virtual void InsertCharacter(wchar_t chr
) = 0;
89 * Static text widget (without frame-like parent)
91 class StaticText
: public Widget
{
93 static Widget
* CreateWidget(Gui
& gui
, Widget
* parent
);
99 StaticText(Gui
& g
, Widget
* p
);
101 void OnMouseEnter(void) {}
102 void OnMouseExit(void) {}
103 void OnGuiResize(const Vector2f
& scale
);
106 void LoadFromXml(TiXmlElement
& root
);
109 class StaticRichText
: public Widget
{
111 static Widget
* CreateWidget(Gui
& gui
, Widget
* parent
);
117 StaticRichText(Gui
& g
, Widget
* p
);
119 void OnMouseEnter(void) {}
120 void OnMouseExit(void) {}
121 void OnGuiResize(const Vector2f
& scale
);
124 void LoadFromXml(TiXmlElement
& root
);
128 * Parent class for most pixmap based widgets
130 class PixmapWidget
: virtual public Widget
, private boost::noncopyable
{
132 PixmapWidget(Pixmap
* pix
) : pixmap_(pix
) {}
135 void OnGuiResize(const Vector2f
& scale
);
137 void SetSize(const Vector2f
& sz
);
144 void SetState(uint u
, WidgetState w
);
150 class Frame
: public AbstractStatic
, public PixmapWidget
{
152 static Widget
* CreateWidget(Gui
& gui
, Widget
* parent
);
155 Frame(Gui
& g
, Widget
* p
);
157 void LoadFromXml(TiXmlElement
& root
);
160 class FrameRaised
: public Frame
{
162 static Widget
* CreateWidget(Gui
& gui
, Widget
* parent
);
165 FrameRaised(Gui
& g
, Widget
* p
) : Frame(g
, p
) {}
167 void LoadFromXml(TiXmlElement
& root
);
170 class FrameSunken
: public Frame
{
172 static Widget
* CreateWidget(Gui
& gui
, Widget
* parent
);
175 FrameSunken(Gui
& g
, Widget
* p
) : Frame(g
, p
) {}
177 void LoadFromXml(TiXmlElement
& root
);
180 // class StaticLine : public Pixmap2x1L {
182 // StaticLine(Gui & g, Widget * p);
183 // StaticLine(Gui & g, Widget * p, Mesh & pm);
185 // void LoadFromXml(TiXmlElement & root);
188 class PushButton
: public AbstractButton
, public PixmapWidget
{
190 static Widget
* CreateWidget(Gui
& gui
, Widget
* parent
);
193 PushButton(Gui
& g
, Widget
* p
);
195 void OnGuiResize(const Vector2f
& scale
);
197 const std::wstring
GetCaption(void) const {return caption_
.GetText();}
198 void SetCaption(const std::string
& text
) {caption_
.SetText(text
);}
200 void SetSize(const Vector2f
& sz
);
202 void LoadFromXml(TiXmlElement
& root
);
211 // class EditBox : public Pixmap3x1 {
213 // EditBox(Gui & g, Widget * p);
214 // EditBox(Gui & g, Widget * p, Mesh & pm);
216 // void LoadFromXml(TiXmlElement & root);
219 // class CheckBox : public Pixmap1x1 {
221 // CheckBox(Gui & g, Widget * p);
222 // CheckBox(Gui & g, Widget * p, Mesh & pm);
224 // void LoadFromXml(TiXmlElement & root);
227 // class RadioButton : public Pixmap1x1 {
229 // RadioButton(Gui & g, Widget * p);
230 // RadioButton(Gui & g, Widget * p, Mesh & pm);
232 // void LoadFromXml(TiXmlElement & root);
235 // class DropDownList : public Pixmap3x1 {
237 // DropDownList(Gui & g, Widget * p);
238 // DropDownList(Gui & g, Widget * p, Mesh & pm);
240 // void LoadFromXml(TiXmlElement & root);
243 // class ListBox : public Widget {
246 // class TabWidget : public Widget {
249 // class Window : public Widget {
252 // class RenderView : public Widget {