author | KUDr |
Sat, 03 Mar 2007 16:11:18 +0000 | |
branch | cpp_gui |
changeset 6282 | c5b92f2d924f |
parent 6279 | c75b2c7222ff |
child 6283 | 7072ee68c676 |
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) |
7054c910251d
(svn r8932) [cpp_gui] -Fix(r8931): forward enum declaration doesn't work for g++
KUDr
parents:
6264
diff
changeset
|
25 |
}; |
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 |
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
|
28 |
|
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
29 |
enum Anchors { |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
30 |
PIN_NONE = 0x00, |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
31 |
PIN_LEFT = 0x01, |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
32 |
PIN_TOP = 0x02, |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
33 |
PIN_RIGHT = 0x04, |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
34 |
PIN_BOTTOM = 0x08, |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
35 |
}; |
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 |
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
|
38 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
39 |
namespace gui { |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
40 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
41 |
struct Widget; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
42 |
typedef CCountedPtr<Widget> WidgetPtr; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
43 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
44 |
struct CompositeWidget; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
45 |
typedef CCountedPtr<CompositeWidget> CompositeWidgetPtr; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
46 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
47 |
typedef int32 WidgetId; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
48 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
49 |
struct Widget : public SimpleCountedObject { |
6269
3b3bd4fe0736
(svn r8947) [cpp_gui] -Codechange: proprietary smart pointer adapter replaced by generic one
KUDr
parents:
6265
diff
changeset
|
50 |
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
|
51 |
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
|
52 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
uint16 m_data; ///< The String/Image or special code (list-matrices) of a widget |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
57 |
byte m_display_flags; ///< Resize direction, alignment, etc. during resizing, see @ResizeFlags |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
58 |
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
|
59 |
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
|
60 |
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
|
61 |
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
|
62 |
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
|
63 |
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
|
64 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
65 |
Widget() |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
66 |
: m_container(NULL), m_id(0), m_rect(), m_data(0), m_display_flags(0), m_color(0) |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
67 |
, 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
|
68 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
69 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
70 |
Widget(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
71 |
: m_container(container) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
72 |
, m_id(id) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
73 |
, m_rect(rect) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
74 |
, m_data(0) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
75 |
, m_display_flags(display_flags) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
76 |
, m_color(color) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
77 |
, m_is_closing(false) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
78 |
, m_dont_clip(false) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
79 |
, m_tooltips(tooltips) |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
80 |
, 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 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
83 |
int16 Left() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
84 |
int16 Top() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
85 |
int16 Right() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
86 |
int16 Bottom() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
87 |
int16 Width() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
88 |
int16 Height() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
89 |
const Point16& TopLeft() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
90 |
const Point16& BottomRight() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
91 |
Point16 Size() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
92 |
Point16 CenterPt() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
93 |
const Rect16& GetRect() const; |
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 |
void SetLeft(int16 val); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
96 |
void SetTop(int16 val); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
97 |
void SetRight(int16 val); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
98 |
void SetBottom(int16 val); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
99 |
void SetWidth(int16 val); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
100 |
void SetHeight(int16 val); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
101 |
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
|
102 |
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
|
103 |
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
|
104 |
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
|
105 |
|
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
106 |
void SetAnchors(Anchors a); |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
107 |
|
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
108 |
WidgetId GetId() const; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
109 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
110 |
void AddHandler(EventHandlerDelegate *d); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
111 |
void CallHandlers(EventBase &e); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
112 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
113 |
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
|
114 |
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
|
115 |
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
|
116 |
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
|
117 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
118 |
virtual BaseWindow* GetWindow(); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
119 |
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
|
120 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
121 |
virtual void Close(); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
122 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
123 |
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
|
124 |
|
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 |
* 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
|
127 |
* 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
|
128 |
*/ |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
129 |
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
|
130 |
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
|
131 |
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
|
132 |
virtual void OnKeyPress(EvtKeyPress &ev) {}; |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
133 |
virtual void OnLeftButtonDown(EvtLeftButtonDown &ev) {}; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
134 |
virtual void OnLeftClick(EvtLeftClick &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
135 |
virtual void OnRightButtonDown(EvtRightButtonDown &ev); |
6271
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
136 |
virtual void OnMouseOver(EvtMouseOver &ev) {}; |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
137 |
virtual void OnResize(EvtResize &ev) {}; |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
138 |
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
|
139 |
|
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 |
* 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
|
142 |
*/ |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
143 |
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
|
144 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
145 |
/** |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
146 |
* @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
|
147 |
* 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
|
148 |
* 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
|
149 |
* 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
|
150 |
* like: |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
151 |
* 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
|
152 |
* { |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
153 |
* ... |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
154 |
* } |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
155 |
* 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
|
156 |
* call: |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
157 |
* 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
|
158 |
* 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
|
159 |
*/ |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
160 |
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
|
161 |
{ |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
162 |
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
|
163 |
AddHandler(new Delegate(handler)); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
164 |
} |
6271
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
165 |
|
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
166 |
/** 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
|
167 |
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
|
168 |
{ |
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
169 |
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
|
170 |
return ticket; |
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
171 |
} |
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
172 |
|
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
173 |
}; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
174 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
175 |
struct CompositeWidget : public Widget { |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
176 |
typedef Widget super; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
177 |
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
|
178 |
typedef Widgets::iterator WidgetIterator; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
179 |
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
|
180 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
181 |
protected: |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
182 |
Widgets m_widgets; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
183 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
184 |
public: |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
185 |
CompositeWidget() |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
186 |
: Widget() |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
187 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
188 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
189 |
CompositeWidget(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
190 |
: Widget(container, id, display_flags, color, rect, tooltips) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
191 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
192 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
193 |
void AddWidget(Widget *wd); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
194 |
Widget* GetWidget(WidgetId id); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
195 |
Widget* RemoveWidget(WidgetId id); |
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 |
/*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
|
198 |
|
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
|
199 |
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
|
200 |
virtual void Close(); |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
201 |
|
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
202 |
/*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
|
203 |
/*virtual*/ void OnPaint(EvtPaint &ev); |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
204 |
/*virtual*/ void OnLeftButtonDown(EvtLeftButtonDown &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
205 |
/*virtual*/ void OnRightButtonDown(EvtRightButtonDown &ev); |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
206 |
/*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
|
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 |
struct Button : public Widget { |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
210 |
typedef Widget super; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
211 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
212 |
protected: |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
213 |
bool m_pushed; |
6271
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
214 |
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
|
215 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
216 |
public: |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
217 |
Button() |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
218 |
: Widget() |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
219 |
, m_pushed(false) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
220 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
221 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
222 |
Button(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
223 |
: Widget(container, id, display_flags, color, rect, tooltips) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
224 |
, m_pushed(false) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
225 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
226 |
|
6271
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
227 |
void OnCapturePressed(EvtMouseOver &e); |
0ad100a98853
(svn r8958) [cpp_gui] -Add: Widget can now capture specified gui events
KUDr
parents:
6269
diff
changeset
|
228 |
|
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
229 |
/*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
|
230 |
|
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
231 |
/*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
|
232 |
}; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
233 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
234 |
struct TextButton : public Button { |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
235 |
typedef Button super; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
236 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
237 |
protected: |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
238 |
StringID m_text; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
239 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
240 |
public: |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
241 |
TextButton() |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
242 |
: Button() |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
243 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
244 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
245 |
TextButton(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips, StringID text) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
246 |
: Button(container, id, display_flags, color, rect, tooltips) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
247 |
, m_text(text) |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
248 |
{} |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
249 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
250 |
/*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
|
251 |
}; |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
252 |
|
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
253 |
struct CloseBox : public Button { |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
254 |
typedef Button super; |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
255 |
|
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
256 |
static const int16 DEFAULT_WIDTH = 11; |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
257 |
static const int16 DEFAULT_HEIGHT = 14; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
258 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
259 |
public: |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
260 |
CloseBox() |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
261 |
: Button() |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
262 |
{} |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
263 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
264 |
CloseBox(CompositeWidget *container) |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
265 |
: Button(container, -102, 0, container->m_color, Rect16(), 0) |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
266 |
{} |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
267 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
268 |
/*virtual*/ void OnCreate(EvtCreate &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
269 |
/*virtual*/ void OnPaint(EvtPaint &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
270 |
/*virtual*/ void OnLeftClick(EvtLeftClick &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
271 |
}; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
272 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
273 |
struct Caption : public Widget { |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
274 |
typedef Widget super; |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
275 |
|
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
276 |
protected: |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
277 |
StringID m_text; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
278 |
byte m_text_color; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
279 |
Point16 m_moving_offset; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
280 |
CaptureTicket m_ticket_moving; |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
281 |
|
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
282 |
public: |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
283 |
Caption() |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
284 |
: Widget() |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
285 |
, m_text(0) |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
286 |
, m_text_color(0xFF) |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
287 |
{} |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
288 |
|
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
289 |
Caption(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 rect, byte text_color, StringID tooltips, StringID text) |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
290 |
: Widget(container, id, display_flags, color, rect, tooltips) |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
291 |
, m_text(text) |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
292 |
, m_text_color(text_color) |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
293 |
{} |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
294 |
|
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
295 |
/*virtual*/ void DrawBackground(EvtPaint &ev); |
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 |
/*virtual*/ void OnCreate(EvtCreate &ev); |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
298 |
/*virtual*/ void OnPaint(EvtPaint &ev); |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
299 |
/*virtual*/ void OnLeftButtonDown(EvtLeftButtonDown &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
300 |
void OnCaptureMoving(EvtMouseOver &e); |
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
301 |
}; |
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
302 |
|
6273 | 303 |
struct CaptionBar : public CompositeWidget { |
304 |
typedef CompositeWidget super; |
|
305 |
||
306 |
static const int16 DEFAULT_HEIGHT = 14; |
|
307 |
||
308 |
protected: |
|
6275
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
309 |
StringID m_text; |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
310 |
byte m_text_color; |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
311 |
Point16 m_moving_offset; |
bd57b30a8b81
(svn r8983) [cpp_gui] -Add: moving window by dragging CaptionBar
KUDr
parents:
6273
diff
changeset
|
312 |
CaptureTicket m_ticket_moving; |
6273 | 313 |
|
314 |
public: |
|
315 |
CaptionBar() |
|
316 |
: CompositeWidget() |
|
317 |
, m_text(0) |
|
318 |
, m_text_color(0xFF) |
|
319 |
{} |
|
320 |
||
321 |
CaptionBar(CompositeWidget *container, WidgetId id, byte display_flags, byte color, byte text_color, StringID tooltips, StringID text) |
|
322 |
: CompositeWidget(container, id, display_flags, color, Rect16(0, 0, container->Width() - 1, DEFAULT_HEIGHT - 1), tooltips) |
|
323 |
, m_text(text) |
|
324 |
, m_text_color(text_color) |
|
325 |
{} |
|
326 |
||
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
|
327 |
/*virtual*/ void CreateWidgets(); |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
328 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
329 |
/*virtual*/ void OnCreate(EvtCreate &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
330 |
}; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
331 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
332 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
333 |
struct ResizeBox : public Widget { |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
334 |
typedef Widget super; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
335 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
336 |
static const int16 DEFAULT_WIDTH = 11; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
337 |
static const int16 DEFAULT_HEIGHT = 11; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
338 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
339 |
protected: |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
340 |
Point16 m_sizing_offset; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
341 |
CaptureTicket m_ticket_sizing; |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
342 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
343 |
public: |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
344 |
ResizeBox() |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
345 |
: Widget() |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
346 |
{} |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
347 |
|
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
348 |
ResizeBox(CompositeWidget *container) |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
349 |
: Widget(container, -101, 0, container->m_color, Rect16(), 0) |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
350 |
{} |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
351 |
|
6273 | 352 |
/*virtual*/ void DrawBackground(EvtPaint &ev); |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
353 |
void OnCaptureSizing(EvtMouseOver &e); |
6273 | 354 |
|
6278
c09f5e53af9b
(svn r8986) [cpp_gui] -Add: resizing window by dragging ResizeBox
KUDr
parents:
6277
diff
changeset
|
355 |
/*virtual*/ void OnCreate(EvtCreate &ev); |
6273 | 356 |
/*virtual*/ void OnPaint(EvtPaint &ev); |
6282
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
357 |
/*virtual*/ void OnLeftButtonDown(EvtLeftButtonDown &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
358 |
/*virtual*/ void OnResizeParent(EvtResizeParent &ev); |
c5b92f2d924f
(svn r8996) [cpp_gui] -Add: CloseBox added into CaptionBar
KUDr
parents:
6279
diff
changeset
|
359 |
|
6273 | 360 |
}; |
361 |
||
6264
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
362 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
363 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
364 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
365 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
366 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
367 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
368 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
369 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
370 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
371 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
372 |
}; // namespace gui |
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
373 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
374 |
|
9fc3b5467396
(svn r8931) [cpp_gui] -Add: first OO widget type (TextButton) added only with basic functionality
KUDr
parents:
diff
changeset
|
375 |
#endif /* WIDGET_H */ |