author | KUDr |
Sun, 04 Mar 2007 12:53:05 +0000 | |
branch | cpp_gui |
changeset 6287 | e59240e63a90 |
parent 6286 | 6e8eec87fa9d |
child 6289 | be3d8bd9fb02 |
permissions | -rw-r--r-- |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
1 |
/* $Id$ */ |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
2 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
3 |
#ifndef WIDGET_H |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
4 |
#define WIDGET_H |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
5 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
6 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
7 |
#include <list> |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
8 |
#include <map> |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
9 |
#include "../macros.h" |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
10 |
#include "../string.h" |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
11 |
#include "../order.h" |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
12 |
#include "../rail.h" |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
13 |
#include "../airport.h" |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
14 |
#include "../misc/rect.hpp" |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
15 |
#include "../misc/countedptr.hpp" |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
16 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
17 |
#include "window_event_base.h" |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
18 |
|
6265
7054c910251d
(svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents:
6264
diff
changeset
|
19 |
enum FrameFlags { |
7054c910251d
(svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents:
6264
diff
changeset
|
20 |
FR_NONE = 0x00, |
7054c910251d
(svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents:
6264
diff
changeset
|
21 |
FR_TRANSPARENT = 0x01, ///< Makes the background transparent if set |
7054c910251d
(svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents:
6264
diff
changeset
|
22 |
FR_BORDERONLY = 0x10, ///< Draw border only, no background |
7054c910251d
(svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents:
6264
diff
changeset
|
23 |
FR_LOWERED = 0x20, ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed) |
7054c910251d
(svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents:
6264
diff
changeset
|
24 |
FR_DARKENED = 0x40, ///< If set the background is darker, allows for lowered frames with normal background color when used with FR_LOWERED (ie. dropdown boxes) |
6286 | 25 |
FR_BG_ONLY = 0x80, ///< If set only the background is drawn without any frame (labels and such) |
6265
7054c910251d
(svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents:
6264
diff
changeset
|
26 |
}; |
7054c910251d
(svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents:
6264
diff
changeset
|
27 |
|
7054c910251d
(svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents:
6264
diff
changeset
|
28 |
DECLARE_ENUM_AS_BIT_SET(FrameFlags); |
7054c910251d
(svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents:
6264
diff
changeset
|
29 |
|
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
30 |
enum Anchors { |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
31 |
PIN_NONE = 0x00, |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
32 |
PIN_LEFT = 0x01, |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
33 |
PIN_TOP = 0x02, |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
34 |
PIN_RIGHT = 0x04, |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
35 |
PIN_BOTTOM = 0x08, |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
36 |
}; |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
37 |
|
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
38 |
DECLARE_ENUM_AS_BIT_SET(Anchors); |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
39 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
40 |
namespace gui { |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
41 |
|
6283
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
42 |
enum FeatureFlags { |
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
43 |
FF_NONE = 0, |
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
44 |
FF_NO_CAPTION_BAR = (1 << 0), |
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
45 |
FF_NO_CLOSE_BOX = (1 << 1), |
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
46 |
FF_NO_STICKY_BOX = (1 << 2), |
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
47 |
FF_NO_RESIZE_BOX = (1 << 3), |
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
48 |
FF_UNMOVABLE = (1 << 4), |
6286 | 49 |
FF_TRANSPARENT = (1 << 5), |
6283
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
50 |
}; |
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
51 |
|
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
52 |
DECLARE_ENUM_AS_BIT_SET(FeatureFlags); |
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
53 |
|
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
54 |
struct Widget; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
55 |
typedef CCountedPtr<Widget> WidgetPtr; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
56 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
57 |
struct CompositeWidget; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
58 |
typedef CCountedPtr<CompositeWidget> CompositeWidgetPtr; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
59 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
60 |
typedef int32 WidgetId; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
61 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
62 |
struct Widget : public SimpleCountedObject { |
6269
3b3bd4fe0736
(svn r8947) [cpp_gui] -Codechange: proprietary smart pointer adapter replaced by generic one
KUDr
parents:
6265
diff
changeset
|
63 |
typedef AdaptT<EventHandlerDelegatePtr> Handler; |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
64 |
typedef std::list<Handler> Handlers; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
65 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
66 |
CompositeWidget *m_container; ///< widget container (can be any panel or window) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
67 |
WidgetId m_id; ///< Widget id in its container |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
68 |
Rect16 m_rect; ///< The position offsets relative to the container |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
69 |
uint16 m_data; ///< The String/Image or special code (list-matrices) of a widget |
6283
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
70 |
FeatureFlags m_feature_flags; ///< @see FeatureFlags |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
71 |
byte m_color; ///< Widget color, see docs/ottd-colourtext-palette.png |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
72 |
bool m_is_closing : 1; ///< Widget was logically destroyed |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
73 |
bool m_dont_clip : 1; ///< should not be clipped by parent (container) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
74 |
StringID m_tooltips; ///< Tooltips that are shown when right clicking on a widget |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
75 |
Anchors m_anchors; ///< Resize/move when container resizes? |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
76 |
Handlers m_handlers; ///< dynamically registered event handlers |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
77 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
78 |
Widget() |
6283
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
79 |
: m_container(NULL), m_id(0), m_rect(), m_data(0), m_feature_flags(FF_NONE), m_color(0) |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
80 |
, m_is_closing(false), m_tooltips(0), m_anchors(PIN_NONE) |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
81 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
82 |
|
6283
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
83 |
Widget(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 &rect, StringID tooltips) |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
84 |
: m_container(container) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
85 |
, m_id(id) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
86 |
, m_rect(rect) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
87 |
, m_data(0) |
6283
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
88 |
, m_feature_flags(feature_flags) |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
89 |
, m_color(color) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
90 |
, m_is_closing(false) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
91 |
, m_dont_clip(false) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
92 |
, m_tooltips(tooltips) |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
93 |
, m_anchors(PIN_NONE) |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
94 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
95 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
96 |
int16 Left() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
97 |
int16 Top() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
98 |
int16 Right() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
99 |
int16 Bottom() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
100 |
int16 Width() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
101 |
int16 Height() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
102 |
const Point16& TopLeft() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
103 |
const Point16& BottomRight() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
104 |
Point16 Size() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
105 |
Point16 CenterPt() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
106 |
const Rect16& GetRect() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
107 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
108 |
void SetLeft(int16 val); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
109 |
void SetTop(int16 val); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
110 |
void SetRight(int16 val); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
111 |
void SetBottom(int16 val); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
112 |
void SetWidth(int16 val); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
113 |
void SetHeight(int16 val); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
114 |
void SetTopLeft(const Point16 &pt); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
115 |
void SetBottomRight(const Point16 &pt); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
116 |
void SetSize(const Point16 &pt); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
117 |
void SetRect(const Rect16 &rect); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
118 |
|
6286 | 119 |
byte GetColor() const; |
120 |
void SetColor(byte val); |
|
121 |
||
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
122 |
void SetAnchors(Anchors a); |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
123 |
|
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
124 |
WidgetId GetId() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
125 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
126 |
void AddHandler(EventHandlerDelegate *d); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
127 |
void CallHandlers(EventBase &e); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
128 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
129 |
void Invalidate() {}; ///< now we redraw gui all the time, so no processing is needed here |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
130 |
static /*static*/ void FillRect(const Rect16 &rc, int color); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
131 |
static void DrawFrameRect(int left, int top, int right, int bottom, int ctab, FrameFlags flags); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
132 |
void DrawFrameRect(int ctab, FrameFlags flags); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
133 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
134 |
virtual BaseWindow* GetWindow(); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
135 |
virtual Widget* WidgetFromPt(const Point16 &pt); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
136 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
137 |
virtual void Close(); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
138 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
139 |
virtual void DrawBackground(EvtPaint &ev); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
140 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
141 |
/** |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
142 |
* OnCreate() handler called when window gets created. Override this method in your |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
143 |
* Window subclass and place widgets into your window from there. |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
144 |
*/ |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
145 |
virtual void OnCreate(EvtCreate &ev) {}; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
146 |
virtual void OnDestroy(EvtDestroy &ev) {}; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
147 |
virtual void OnPaint(EvtPaint &ev) = 0; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
148 |
virtual void OnKeyPress(EvtKeyPress &ev) {}; |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
149 |
virtual void OnLeftButtonDown(EvtLeftButtonDown &ev) {}; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
150 |
virtual void OnLeftClick(EvtLeftClick &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
151 |
virtual void OnRightButtonDown(EvtRightButtonDown &ev); |
6271
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
152 |
virtual void OnMouseOver(EvtMouseOver &ev) {}; |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
153 |
virtual void OnResize(EvtResize &ev) {}; |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
154 |
virtual void OnResizeParent(EvtResizeParent &ev); |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
155 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
156 |
/** |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
157 |
* Dispatch event by its type calling appropriate OnCreate(), OnDestroy(), etc. |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
158 |
*/ |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
159 |
virtual void DispatchEvent(EventBase &ev); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
160 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
161 |
/** |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
162 |
* @function AddReflectHandlerT Registers reflected event handler. Use it from |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
163 |
* BaseWindow subclasses (Window implementations) to register custom event handler. |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
164 |
* For example if you are implementing 'MyWindow' class and want to handle OnLeftClick() |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
165 |
* event for your button 'MyButton', define your handler method inside 'MyWindow' class |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
166 |
* like: |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
167 |
* void MyWindow::MyButtonClickHandler(gui::EvtLeftClick &e) |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
168 |
* { |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
169 |
* ... |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
170 |
* } |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
171 |
* then from inside OnCreate() handler, create your button 'my_button' and |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
172 |
* call: |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
173 |
* my_button->AddReflectHandlerT(&MyWindow::MyButtonClickHandler); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
174 |
* and your MyButtonClickHandler will be called on every click on my_button. |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
175 |
*/ |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
176 |
template <class Twnd_cls, EventCode Tevt_code> void AddReflectHandlerT(void (Twnd_cls::*handler)(gui::EventT<Tevt_code>&)) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
177 |
{ |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
178 |
typedef ReflectHandlerDelegateT<Twnd_cls, Tevt_code> Delegate; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
179 |
AddHandler(new Delegate(handler)); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
180 |
} |
6271
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
181 |
|
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
182 |
/** add capture handler using default delegate type (CaptureHandlerDelegateT<>) */ |
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
183 |
template <class Twd_cls, EventCode Tevt_code> CaptureTicket CaptureEventsT(Twd_cls *wd, void (Twd_cls::*handler)(EventT<Tevt_code>&)) |
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
184 |
{ |
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
185 |
CaptureTicket ticket = EventCaptureStack::AddHandler(new CaptureHandlerDelegateT<Twd_cls, Tevt_code>(wd, handler)); |
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
186 |
return ticket; |
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
187 |
} |
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
188 |
|
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
189 |
}; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
190 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
191 |
struct CompositeWidget : public Widget { |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
192 |
typedef Widget super; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
193 |
typedef std::map<WidgetId, WidgetPtr> Widgets; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
194 |
typedef Widgets::iterator WidgetIterator; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
195 |
typedef Widgets::reverse_iterator WidgetReverseIterator; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
196 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
197 |
protected: |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
198 |
Widgets m_widgets; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
199 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
200 |
public: |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
201 |
CompositeWidget() |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
202 |
: Widget() |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
203 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
204 |
|
6283
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
205 |
CompositeWidget(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 &rect, StringID tooltips) |
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
206 |
: Widget(container, id, feature_flags, color, rect, tooltips) |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
207 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
208 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
209 |
void AddWidget(Widget *wd); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
210 |
Widget* GetWidget(WidgetId id); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
211 |
Widget* RemoveWidget(WidgetId id); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
212 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
213 |
/*virtual*/ Widget* WidgetFromPt(const Point16 &pt); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
214 |
|
6283
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
215 |
virtual void CreateNcWidgets() {}; |
6279
c75b2c7222ff
(svn r8991) [cpp_gui] -Codechange: composite widgets (incl. windows) now must implement CreateWidgets() method which is called from the default OnCreate() implementation
KUDr
parents:
6278
diff
changeset
|
216 |
virtual void CreateWidgets() = 0; |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
217 |
virtual void Close(); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
218 |
|
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
219 |
/*virtual*/ void OnCreate(EvtCreate &ev); |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
220 |
/*virtual*/ void OnPaint(EvtPaint &ev); |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
221 |
/*virtual*/ void OnLeftButtonDown(EvtLeftButtonDown &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
222 |
/*virtual*/ void OnRightButtonDown(EvtRightButtonDown &ev); |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
223 |
/*virtual*/ void OnResize(EvtResize &ev); |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
224 |
}; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
225 |
|
6286 | 226 |
struct Label : public Widget { |
227 |
typedef Widget super; |
|
228 |
||
229 |
protected: |
|
230 |
StringID m_text; |
|
231 |
||
232 |
public: |
|
233 |
Label() |
|
234 |
: Widget() |
|
235 |
{} |
|
236 |
||
237 |
Label(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, const Rect16 &rect, StringID text, StringID tooltip = 0, int color = COLOUR_NONE) |
|
238 |
: Widget(container, id, feature_flags, (byte)color, rect, tooltip) |
|
239 |
, m_text(text) |
|
240 |
{ |
|
241 |
/* make the label transparent (no background) if color not provided */ |
|
242 |
if (color == COLOUR_NONE) m_feature_flags |= FF_TRANSPARENT; |
|
243 |
} |
|
244 |
||
245 |
/*virtual*/ void DrawBackground(EvtPaint &ev); |
|
246 |
||
247 |
/*virtual*/ void OnPaint(EvtPaint &ev); |
|
248 |
}; |
|
249 |
||
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
250 |
struct Button : public Widget { |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
251 |
typedef Widget super; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
252 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
253 |
protected: |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
254 |
bool m_pushed; |
6271
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
255 |
CaptureTicket m_ticket_pressed; |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
256 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
257 |
public: |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
258 |
Button() |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
259 |
: Widget() |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
260 |
, m_pushed(false) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
261 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
262 |
|
6283
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
263 |
Button(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 &rect, StringID tooltips) |
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
264 |
: Widget(container, id, feature_flags, color, rect, tooltips) |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
265 |
, m_pushed(false) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
266 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
267 |
|
6271
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
268 |
void OnCapturePressed(EvtMouseOver &e); |
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
269 |
|
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
270 |
/*virtual*/ void DrawBackground(EvtPaint &ev); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
271 |
|
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
272 |
/*virtual*/ void OnLeftButtonDown(EvtLeftButtonDown &ev); |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
273 |
}; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
274 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
275 |
struct TextButton : public Button { |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
276 |
typedef Button super; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
277 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
278 |
protected: |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
279 |
StringID m_text; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
280 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
281 |
public: |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
282 |
TextButton() |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
283 |
: Button() |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
284 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
285 |
|
6283
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
286 |
TextButton(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 &rect, StringID tooltips, StringID text) |
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
287 |
: Button(container, id, feature_flags, color, rect, tooltips) |
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
288 |
, m_text(text) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
289 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
290 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
291 |
/*virtual*/ void OnPaint(EvtPaint &ev); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
292 |
}; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
293 |
|
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
294 |
struct CloseBox : public Button { |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
295 |
typedef Button super; |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
296 |
|
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
297 |
static const int16 DEFAULT_WIDTH = 11; |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
298 |
static const int16 DEFAULT_HEIGHT = 14; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
299 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
300 |
public: |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
301 |
CloseBox() |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
302 |
: Button() |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
303 |
{} |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
304 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
305 |
CloseBox(CompositeWidget *container) |
6283
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
306 |
: Button(container, -102, FF_NONE, container->m_color, Rect16(), 0) |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
307 |
{} |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
308 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
309 |
/*virtual*/ void OnCreate(EvtCreate &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
310 |
/*virtual*/ void OnPaint(EvtPaint &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
311 |
/*virtual*/ void OnLeftClick(EvtLeftClick &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
312 |
}; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
313 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
314 |
struct Caption : public Widget { |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
315 |
typedef Widget super; |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
316 |
|
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
317 |
protected: |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
318 |
Point16 m_moving_offset; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
319 |
CaptureTicket m_ticket_moving; |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
320 |
|
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
321 |
public: |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
322 |
Caption() |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
323 |
: Widget() |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
324 |
{} |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
325 |
|
6283
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
326 |
Caption(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color, const Rect16 rect, byte text_color, StringID tooltips, StringID text) |
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
327 |
: Widget(container, id, feature_flags, color, rect, tooltips) |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
328 |
{} |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
329 |
|
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
330 |
/*virtual*/ void DrawBackground(EvtPaint &ev); |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
331 |
|
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
332 |
/*virtual*/ void OnPaint(EvtPaint &ev); |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
333 |
/*virtual*/ void OnLeftButtonDown(EvtLeftButtonDown &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
334 |
void OnCaptureMoving(EvtMouseOver &e); |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
335 |
}; |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
336 |
|
6273 | 337 |
struct CaptionBar : public CompositeWidget { |
338 |
typedef CompositeWidget super; |
|
339 |
||
340 |
static const int16 DEFAULT_HEIGHT = 14; |
|
341 |
||
342 |
public: |
|
343 |
CaptionBar() |
|
344 |
: CompositeWidget() |
|
345 |
{} |
|
346 |
||
6283
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
347 |
CaptionBar(CompositeWidget *container, WidgetId id, FeatureFlags feature_flags, byte color) |
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
348 |
: CompositeWidget(container, id, feature_flags, color, Rect16(0, 0, container->Right(), DEFAULT_HEIGHT - 1), 0) |
6273 | 349 |
{} |
350 |
||
6279
c75b2c7222ff
(svn r8991) [cpp_gui] -Codechange: composite widgets (incl. windows) now must implement CreateWidgets() method which is called from the default OnCreate() implementation
KUDr
parents:
6278
diff
changeset
|
351 |
/*virtual*/ void CreateWidgets(); |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
352 |
}; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
353 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
354 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
355 |
struct ResizeBox : public Widget { |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
356 |
typedef Widget super; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
357 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
358 |
static const int16 DEFAULT_WIDTH = 11; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
359 |
static const int16 DEFAULT_HEIGHT = 11; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
360 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
361 |
protected: |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
362 |
Point16 m_sizing_offset; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
363 |
CaptureTicket m_ticket_sizing; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
364 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
365 |
public: |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
366 |
ResizeBox() |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
367 |
: Widget() |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
368 |
{} |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
369 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
370 |
ResizeBox(CompositeWidget *container) |
6283
7072ee68c676
(svn r8997) [cpp_gui] -Codechange: common window features are now controlled by FeatureFlags enum.
KUDr
parents:
6282
diff
changeset
|
371 |
: Widget(container, -101, FF_NONE, container->m_color, Rect16(), 0) |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
372 |
{} |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
373 |
|
6273 | 374 |
/*virtual*/ void DrawBackground(EvtPaint &ev); |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
375 |
void OnCaptureSizing(EvtMouseOver &e); |
6273 | 376 |
|
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
377 |
/*virtual*/ void OnCreate(EvtCreate &ev); |
6273 | 378 |
/*virtual*/ void OnPaint(EvtPaint &ev); |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
379 |
/*virtual*/ void OnLeftButtonDown(EvtLeftButtonDown &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
380 |
/*virtual*/ void OnResizeParent(EvtResizeParent &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
381 |
|
6273 | 382 |
}; |
383 |
||
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
384 |
}; // namespace gui |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
385 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
386 |
#endif /* WIDGET_H */ |