author | truebrain |
Fri, 18 Jul 2008 10:15:16 +0000 | |
branch | noai |
changeset 11168 | 3842648184cd |
parent 10776 | 07203fc29812 |
permissions | -rw-r--r-- |
9723 | 1 |
/* $Id$ */ |
2 |
||
3 |
/** @file window_gui.h Functions, definitions and such used only by the GUI. */ |
|
4 |
||
5 |
#ifndef WINDOW_GUI_H |
|
6 |
#define WINDOW_GUI_H |
|
7 |
||
8 |
#include "core/bitmath_func.hpp" |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
9 |
#include "core/geometry_type.hpp" |
9723 | 10 |
#include "vehicle_type.h" |
11 |
#include "viewport_type.h" |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
12 |
#include "player_type.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
13 |
#include "strings_type.h" |
10181
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
14 |
#include "core/alloc_type.hpp" |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
15 |
#include "window_type.h" |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
16 |
#include "tile_type.h" |
9723 | 17 |
|
18 |
/** |
|
19 |
* The maximum number of windows that can be opened. |
|
20 |
*/ |
|
21 |
static const int MAX_NUMBER_OF_WINDOWS = 25; |
|
22 |
||
23 |
/* How the resize system works: |
|
24 |
First, you need to add a WWT_RESIZEBOX to the widgets, and you need |
|
25 |
to add the flag WDF_RESIZABLE to the window. Now the window is ready |
|
26 |
to resize itself. |
|
27 |
As you may have noticed, all widgets have a RESIZE_XXX in their line. |
|
28 |
This lines controls how the widgets behave on resize. RESIZE_NONE means |
|
29 |
it doesn't do anything. Any other option let's one of the borders |
|
30 |
move with the changed width/height. So if a widget has |
|
31 |
RESIZE_RIGHT, and the window is made 5 pixels wider by the user, |
|
32 |
the right of the window will also be made 5 pixels wider. |
|
33 |
Now, what if you want to clamp a widget to the bottom? Give it the flag |
|
34 |
RESIZE_TB. This is RESIZE_TOP + RESIZE_BOTTOM. Now if the window gets |
|
35 |
5 pixels bigger, both the top and bottom gets 5 bigger, so the whole |
|
36 |
widgets moves downwards without resizing, and appears to be clamped |
|
37 |
to the bottom. Nice aint it? |
|
38 |
You should know one more thing about this system. Most windows can't |
|
39 |
handle an increase of 1 pixel. So there is a step function, which |
|
40 |
let the windowsize only be changed by X pixels. You configure this |
|
41 |
after making the window, like this: |
|
42 |
w->resize.step_height = 10; |
|
43 |
Now the window will only change in height in steps of 10. |
|
44 |
You can also give a minimum width and height. The default value is |
|
45 |
the default height/width of the window itself. You can change this |
|
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
10181
diff
changeset
|
46 |
AFTER window - creation, with: |
9723 | 47 |
w->resize.width or w->resize.height. |
48 |
That was all.. good luck, and enjoy :) -- TrueLight */ |
|
49 |
||
50 |
enum ResizeFlag { |
|
51 |
RESIZE_NONE = 0, ///< no resize required |
|
52 |
||
53 |
RESIZE_LEFT = 1, ///< left resize flag |
|
54 |
RESIZE_RIGHT = 2, ///< rigth resize flag |
|
55 |
RESIZE_TOP = 4, ///< top resize flag |
|
56 |
RESIZE_BOTTOM = 8, ///< bottom resize flag |
|
57 |
||
58 |
RESIZE_LR = RESIZE_LEFT | RESIZE_RIGHT, ///< combination of left and right resize flags |
|
59 |
RESIZE_RB = RESIZE_RIGHT | RESIZE_BOTTOM, ///< combination of right and bottom resize flags |
|
60 |
RESIZE_TB = RESIZE_TOP | RESIZE_BOTTOM, ///< combination of top and bottom resize flags |
|
61 |
RESIZE_LRB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_BOTTOM, ///< combination of left, right and bottom resize flags |
|
62 |
RESIZE_LRTB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, ///< combination of all resize flags |
|
63 |
RESIZE_RTB = RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, ///< combination of right, top and bottom resize flag |
|
64 |
||
65 |
/* The following flags are used by the system to specify what is disabled, hidden, or clicked |
|
66 |
* They are used in the same place as the above RESIZE_x flags, Widget visual_flags. |
|
67 |
* These states are used in exceptions. If nothing is specified, they will indicate |
|
68 |
* Enabled, visible or unclicked widgets*/ |
|
69 |
WIDG_DISABLED = 4, ///< widget is greyed out, not available |
|
70 |
WIDG_HIDDEN = 5, ///< widget is made invisible |
|
71 |
WIDG_LOWERED = 6, ///< widget is paint lowered, a pressed button in fact |
|
72 |
}; |
|
73 |
||
74 |
enum { |
|
75 |
WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions |
|
76 |
}; |
|
77 |
||
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
78 |
/** |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
79 |
* Window widget data structure |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
80 |
*/ |
9723 | 81 |
struct Widget { |
82 |
byte type; ///< Widget type, see WindowWidgetTypes |
|
83 |
byte display_flags; ///< Resize direction, alignment, etc. during resizing, see ResizeFlags |
|
84 |
byte color; ///< Widget colour, see docs/ottd-colourtext-palette.png |
|
85 |
int16 left, right, top, bottom; ///< The position offsets inside the window |
|
86 |
uint16 data; ///< The String/Image or special code (list-matrixes) of a widget |
|
87 |
StringID tooltips; ///< Tooltips that are shown when rightclicking on a widget |
|
88 |
}; |
|
89 |
||
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
90 |
/** |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
91 |
* Flags to describe the look of the frame |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
92 |
*/ |
9723 | 93 |
enum FrameFlags { |
94 |
FR_NONE = 0, |
|
95 |
FR_TRANSPARENT = 1 << 0, ///< Makes the background transparent if set |
|
96 |
FR_BORDERONLY = 1 << 4, ///< Draw border only, no background |
|
97 |
FR_LOWERED = 1 << 5, ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed) |
|
98 |
FR_DARKENED = 1 << 6, ///< If set the background is darker, allows for lowered frames with normal background color when used with FR_LOWERED (ie. dropdown boxes) |
|
99 |
}; |
|
100 |
||
101 |
DECLARE_ENUM_AS_BIT_SET(FrameFlags); |
|
102 |
||
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
103 |
/* wiget.cpp */ |
9723 | 104 |
void DrawFrameRect(int left, int top, int right, int bottom, int color, FrameFlags flags); |
105 |
||
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
106 |
/** |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
107 |
* High level window description |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
108 |
*/ |
9723 | 109 |
struct WindowDesc { |
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
110 |
int16 left; ///< Prefered x position of left edge of the window, @see WindowDefaultPosition() |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
111 |
int16 top; ///< Prefered y position of the top of the window, @see WindowDefaultPosition() |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
112 |
int16 minimum_width; ///< Minimal width of the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
113 |
int16 minimum_height; ///< Minimal height of the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
114 |
int16 default_width; ///< Prefered initial width of the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
115 |
int16 default_height; ///< Prefered initial height of the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
116 |
WindowClass cls; ///< Class of the window, @see WindowClass |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
117 |
WindowClass parent_cls; ///< Class of the parent window, @see WindowClass |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
118 |
uint32 flags; ///< Flags, @see WindowDefaultFlags |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
119 |
const Widget *widgets; ///< List of widgets with their position and size for the window |
9723 | 120 |
}; |
121 |
||
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
122 |
/** |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
123 |
* Window default widget/window handling flags |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
124 |
*/ |
9723 | 125 |
enum WindowDefaultFlag { |
126 |
WDF_STD_TOOLTIPS = 1 << 0, ///< use standard routine when displaying tooltips |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
127 |
WDF_DEF_WIDGET = 1 << 1, ///< Default widget control for some widgets in the on click event, @see DispatchLeftClickEvent() |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
128 |
WDF_STD_BTN = 1 << 2, ///< Default handling for close and titlebar widgets (widget no 0 and 1) |
9723 | 129 |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
130 |
WDF_UNCLICK_BUTTONS = 1 << 4, ///< Unclick buttons when the window event times out |
9723 | 131 |
WDF_STICKY_BUTTON = 1 << 5, ///< Set window to sticky mode; they are not closed unless closed with 'X' (widget 2) |
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
132 |
WDF_RESIZABLE = 1 << 6, ///< Window can be resized |
9723 | 133 |
WDF_MODAL = 1 << 7, ///< The window is a modal child of some other window, meaning the parent is 'inactive' |
134 |
}; |
|
135 |
||
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
136 |
/** |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
137 |
* Special values for 'left' and 'top' to cause a specific placement |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
138 |
*/ |
9723 | 139 |
enum WindowDefaultPosition { |
140 |
WDP_AUTO = -1, ///< Find a place automatically |
|
141 |
WDP_CENTER = -2, ///< Center the window (left/right or top/bottom) |
|
142 |
WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar |
|
143 |
WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar |
|
144 |
}; |
|
145 |
||
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
146 |
/** |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
147 |
* Scrollbar data structure |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
148 |
*/ |
9723 | 149 |
struct Scrollbar { |
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
150 |
uint16 count; ///< Number of elements in the list |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
151 |
uint16 cap; ///< Number of visible elements of the scroll bar |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
152 |
uint16 pos; |
9723 | 153 |
}; |
154 |
||
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
155 |
/** |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
156 |
* Data structure for resizing a window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
157 |
*/ |
9723 | 158 |
struct ResizeInfo { |
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
159 |
uint width; ///< Minimum allowed width of the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
160 |
uint height; ///< Minimum allowed height of the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
161 |
uint step_width; ///< Step-size of width resize changes |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
162 |
uint step_height; ///< Step-size of height resize changes |
9723 | 163 |
}; |
164 |
||
10645 | 165 |
enum SortButtonState { |
166 |
SBS_OFF, |
|
167 |
SBS_DOWN, |
|
168 |
SBS_UP, |
|
169 |
}; |
|
170 |
||
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
171 |
/** |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
172 |
* Data structure for a window viewport |
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
173 |
*/ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
174 |
struct ViewportData : ViewPort { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
175 |
VehicleID follow_vehicle; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
176 |
int32 scrollpos_x; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
177 |
int32 scrollpos_y; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
178 |
int32 dest_scrollpos_x; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
179 |
int32 dest_scrollpos_y; |
9723 | 180 |
}; |
181 |
||
10645 | 182 |
/** |
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
183 |
* Data structure for an opened window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
184 |
*/ |
10181
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
185 |
struct Window : ZeroedMemoryAllocator { |
10645 | 186 |
enum EventState { |
187 |
ES_HANDLED, |
|
188 |
ES_NOT_HANDLED, |
|
189 |
}; |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
190 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
191 |
protected: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
192 |
void Initialize(int x, int y, int min_width, int min_height, |
10645 | 193 |
WindowClass cls, const Widget *widget, int window_number); |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
194 |
void FindWindowPlacementAndResize(int def_width, int def_height); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
195 |
void FindWindowPlacementAndResize(const WindowDesc *desc); |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
196 |
|
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
197 |
public: |
10645 | 198 |
Window(int x, int y, int width, int height, WindowClass cls, const Widget *widget); |
199 |
Window(const WindowDesc *desc, WindowNumber number = 0); |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
200 |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
201 |
virtual ~Window(); |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
202 |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
203 |
uint16 flags4; ///< Window flags, @see WindowFlags |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
204 |
WindowClass window_class; ///< Window class |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
205 |
WindowNumber window_number; ///< Window number within the window class |
9723 | 206 |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
207 |
int left; ///< x position of left edge of the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
208 |
int top; ///< y position of top edge of the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
209 |
int width; ///< width of the window (number of pixels to the right in x direction) |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
210 |
int height; ///< Height of the window (number of pixels down in y direction) |
9723 | 211 |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
212 |
Scrollbar hscroll; ///< Horizontal scroll bar |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
213 |
Scrollbar vscroll; ///< First vertical scroll bar |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
214 |
Scrollbar vscroll2; ///< Second vertical scroll bar |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
215 |
ResizeInfo resize; ///< Resize information |
9723 | 216 |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
217 |
byte caption_color; ///< Background color of the window caption, contains PlayerID |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
218 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
219 |
ViewportData *viewport; ///< Pointer to viewport data, if present |
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
220 |
Widget *widget; ///< Widgets of the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
221 |
uint widget_count; ///< Number of widgets of the window |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
222 |
uint32 desc_flags; ///< Window/widgets default flags setting, @see WindowDefaultFlag |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
223 |
|
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
224 |
Window *parent; ///< Parent window |
9723 | 225 |
|
226 |
void HandleButtonClick(byte widget); |
|
227 |
||
228 |
void SetWidgetDisabledState(byte widget_index, bool disab_stat); |
|
229 |
void DisableWidget(byte widget_index); |
|
230 |
void EnableWidget(byte widget_index); |
|
231 |
bool IsWidgetDisabled(byte widget_index) const; |
|
232 |
void SetWidgetHiddenState(byte widget_index, bool hidden_stat); |
|
233 |
void HideWidget(byte widget_index); |
|
234 |
void ShowWidget(byte widget_index); |
|
235 |
bool IsWidgetHidden(byte widget_index) const; |
|
236 |
void SetWidgetLoweredState(byte widget_index, bool lowered_stat); |
|
237 |
void ToggleWidgetLoweredState(byte widget_index); |
|
238 |
void LowerWidget(byte widget_index); |
|
239 |
void RaiseWidget(byte widget_index); |
|
240 |
bool IsWidgetLowered(byte widget_index) const; |
|
241 |
||
242 |
void RaiseButtons(); |
|
243 |
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets, ...); |
|
244 |
void CDECL SetWidgetsHiddenState(bool hidden_stat, int widgets, ...); |
|
245 |
void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets, ...); |
|
246 |
void InvalidateWidget(byte widget_index) const; |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
247 |
|
10645 | 248 |
void DrawWidgets() const; |
249 |
void DrawViewport() const; |
|
250 |
void DrawSortButtonState(int widget, SortButtonState state) const; |
|
251 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
252 |
void SetDirty() const; |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
253 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
254 |
/*** Event handling ***/ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
255 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
256 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
257 |
* This window is currently being repainted. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
258 |
*/ |
10645 | 259 |
virtual void OnPaint() {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
260 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
261 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
262 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
263 |
* A key has been pressed. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
264 |
* @param key the Unicode value of the key. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
265 |
* @param keycode the untranslated key code including shift state. |
10645 | 266 |
* @return ES_HANDLED if the key press has been handled and no other |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
267 |
* window should receive the event. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
268 |
*/ |
10645 | 269 |
virtual EventState OnKeyPress(uint16 key, uint16 keycode) { return ES_NOT_HANDLED; } |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
270 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
271 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
272 |
* The state of the control key has changed |
10645 | 273 |
* @return ES_HANDLED if the change has been handled and no other |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
274 |
* window should receive the event. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
275 |
*/ |
10645 | 276 |
virtual EventState OnCTRLStateChange() { return ES_NOT_HANDLED; } |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
277 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
278 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
279 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
280 |
* A click with the left mouse button has been made on the window. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
281 |
* @param pt the point inside the window that has been clicked. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
282 |
* @param widget the clicked widget. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
283 |
*/ |
10645 | 284 |
virtual void OnClick(Point pt, int widget) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
285 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
286 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
287 |
* A double click with the left mouse button has been made on the window. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
288 |
* @param pt the point inside the window that has been clicked. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
289 |
* @param widget the clicked widget. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
290 |
*/ |
10645 | 291 |
virtual void OnDoubleClick(Point pt, int widget) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
292 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
293 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
294 |
* A click with the right mouse button has been made on the window. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
295 |
* @param pt the point inside the window that has been clicked. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
296 |
* @param widget the clicked widget. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
297 |
*/ |
10645 | 298 |
virtual void OnRightClick(Point pt, int widget) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
299 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
300 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
301 |
* A dragged 'object' has been released. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
302 |
* @param pt the point inside the window where the release took place. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
303 |
* @param widget the widget where the release took place. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
304 |
*/ |
10645 | 305 |
virtual void OnDragDrop(Point pt, int widget) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
306 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
307 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
308 |
* Handle the request for (viewport) scrolling. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
309 |
* @param delta the amount the viewport must be scrolled. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
310 |
*/ |
10645 | 311 |
virtual void OnScroll(Point delta) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
312 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
313 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
314 |
* The mouse is currently moving over the window or has just moved outside |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
315 |
* of the window. In the latter case pt is (-1, -1). |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
316 |
* @param pt the point inside the window that the mouse hovers over. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
317 |
* @param widget the widget the mouse hovers over. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
318 |
*/ |
10645 | 319 |
virtual void OnMouseOver(Point pt, int widget) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
320 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
321 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
322 |
* The mouse wheel has been turned. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
323 |
* @param wheel the amount of movement of the mouse wheel. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
324 |
*/ |
10645 | 325 |
virtual void OnMouseWheel(int wheel) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
326 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
327 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
328 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
329 |
* Called for every mouse loop run, which is at least once per (game) tick. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
330 |
*/ |
10645 | 331 |
virtual void OnMouseLoop() {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
332 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
333 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
334 |
* Called once per (game) tick. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
335 |
*/ |
10645 | 336 |
virtual void OnTick() {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
337 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
338 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
339 |
* Called once every 100 (game) ticks. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
340 |
*/ |
10645 | 341 |
virtual void OnHundredthTick() {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
342 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
343 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
344 |
* Called when this window's timeout has been reached. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
345 |
*/ |
10645 | 346 |
virtual void OnTimeout() {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
347 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
348 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
349 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
350 |
* Called when the window got resized. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
351 |
* @param new_size the new size of the window. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
352 |
* @param delta the amount of which the window size changed. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
353 |
*/ |
10645 | 354 |
virtual void OnResize(Point new_size, Point delta) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
355 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
356 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
357 |
* A dropdown option associated to this window has been selected. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
358 |
* @param widget the widget (button) that the dropdown is associated with. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
359 |
* @param index the element in the dropdown that is selected. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
360 |
*/ |
10645 | 361 |
virtual void OnDropdownSelect(int widget, int index) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
362 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
363 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
364 |
* The query window opened from this window has closed. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
365 |
* @param str the new value of the string or NULL if the window |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
366 |
* was cancelled. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
367 |
*/ |
10645 | 368 |
virtual void OnQueryTextFinished(char *str) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
369 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
370 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
371 |
* Some data on this window has become invalid. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
372 |
* @param data information about the changed data. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
373 |
*/ |
10645 | 374 |
virtual void OnInvalidateData(int data = 0) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
375 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
376 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
377 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
378 |
* The user clicked some place on the map when a tile highlight mode |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
379 |
* has been set. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
380 |
* @param pt the exact point on the map that has been clicked. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
381 |
* @param tile the tile on the map that has been clicked. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
382 |
*/ |
10645 | 383 |
virtual void OnPlaceObject(Point pt, TileIndex tile) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
384 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
385 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
386 |
* The user cancelled a tile highlight mode that has been set. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
387 |
*/ |
10645 | 388 |
virtual void OnPlaceObjectAbort() {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
389 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
390 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
391 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
392 |
* The user is dragging over the map when the tile highlight mode |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
393 |
* has been set. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
394 |
* @param select_method the method of selection (allowed directions) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
395 |
* @param select_proc what will be created when the drag is over. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
396 |
* @param pt the exact point on the map where the mouse is. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
397 |
*/ |
10645 | 398 |
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
399 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
400 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
401 |
* The user has dragged over the map when the tile highlight mode |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
402 |
* has been set. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
403 |
* @param select_method the method of selection (allowed directions) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
404 |
* @param select_proc what should be created. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
405 |
* @param pt the exact point on the map where the mouse was released. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
406 |
* @param start_tile the begin tile of the drag. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
407 |
* @param end_tile the end tile of the drag. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
408 |
*/ |
10645 | 409 |
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
410 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
411 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
412 |
* The user moves over the map when a tile highlight mode has been set |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
413 |
* when the special mouse mode has been set to 'PRESIZE' mode. An |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
414 |
* example of this is the tile highlight for dock building. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
415 |
* @param pt the exact point on the map where the mouse is. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
416 |
* @param tile the tile on the map where the mouse is. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
417 |
*/ |
10645 | 418 |
virtual void OnPlacePresize(Point pt, TileIndex tile) {} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
419 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
420 |
/*** End of the event handling ***/ |
9723 | 421 |
}; |
422 |
||
10645 | 423 |
/** |
424 |
* Data structure for a window opened from a toolbar |
|
425 |
*/ |
|
426 |
class PickerWindowBase : public Window { |
|
9723 | 427 |
|
10645 | 428 |
public: |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
429 |
PickerWindowBase(const WindowDesc *desc, Window *parent) : Window(desc) |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
430 |
{ |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
431 |
this->parent = parent; |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
432 |
}; |
9723 | 433 |
|
10645 | 434 |
virtual ~PickerWindowBase(); |
9723 | 435 |
}; |
436 |
||
437 |
/****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/ |
|
438 |
enum WindowWidgetBehaviours { |
|
439 |
WWB_PUSHBUTTON = 1 << 5, |
|
440 |
||
441 |
WWB_MASK = 0xE0, |
|
442 |
}; |
|
443 |
||
444 |
||
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
445 |
/** |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
446 |
* Window widget types |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
447 |
*/ |
9723 | 448 |
enum WindowWidgetTypes { |
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
449 |
WWT_EMPTY, ///< Empty widget, place holder to reserve space in widget array |
9723 | 450 |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
451 |
WWT_PANEL, ///< Simple depressed panel |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
452 |
WWT_INSET, ///< Pressed (inset) panel, most commonly used as combo box _text_ area |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
453 |
WWT_IMGBTN, ///< Button with image |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
454 |
WWT_IMGBTN_2, ///< Button with diff image when clicked |
9723 | 455 |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
456 |
WWT_TEXTBTN, ///< Button with text |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
457 |
WWT_TEXTBTN_2, ///< Button with diff text when clicked |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
458 |
WWT_LABEL, ///< Centered label |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
459 |
WWT_TEXT, ///< Pure simple text |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
460 |
WWT_MATRIX, ///< List of items underneath each other |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
461 |
WWT_SCROLLBAR, ///< Vertical scrollbar |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
462 |
WWT_FRAME, ///< Frame |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
463 |
WWT_CAPTION, ///< Window caption (window title between closebox and stickybox) |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
464 |
|
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
465 |
WWT_HSCROLLBAR, ///< Horizontal scrollbar |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
466 |
WWT_STICKYBOX, ///< Sticky box (normally at top-right of a window) |
9723 | 467 |
WWT_SCROLL2BAR, ///< 2nd vertical scrollbar |
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
468 |
WWT_RESIZEBOX, ///< Resize box (normally at bottom-right of a window) |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
469 |
WWT_CLOSEBOX, ///< Close box (at top-left of a window) |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
470 |
WWT_DROPDOWN, ///< Raised drop down list (regular) |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
471 |
WWT_DROPDOWNIN, ///< Inset drop down list (used on game options only) |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
472 |
WWT_EDITBOX, ///< a textbox for typing (don't forget to call ShowOnScreenKeyboard() when clicked) |
9723 | 473 |
WWT_LAST, ///< Last Item. use WIDGETS_END to fill up padding!! |
474 |
||
475 |
WWT_MASK = 0x1F, |
|
476 |
||
477 |
WWT_PUSHBTN = WWT_PANEL | WWB_PUSHBUTTON, |
|
478 |
WWT_PUSHTXTBTN = WWT_TEXTBTN | WWB_PUSHBUTTON, |
|
479 |
WWT_PUSHIMGBTN = WWT_IMGBTN | WWB_PUSHBUTTON, |
|
480 |
}; |
|
481 |
||
482 |
#define WIDGETS_END WWT_LAST, RESIZE_NONE, 0, 0, 0, 0, 0, 0, STR_NULL |
|
483 |
||
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
484 |
/** |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
485 |
* Window flags |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
486 |
*/ |
9723 | 487 |
enum WindowFlags { |
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
488 |
WF_TIMEOUT_SHL = 0, ///< Window timeout counter shift |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
489 |
WF_TIMEOUT_MASK = 7, ///< Window timeout counter bit mask (3 bits), @see WF_TIMEOUT_SHL |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
490 |
WF_DRAGGING = 1 << 3, ///< Window is being dragged |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
491 |
WF_SCROLL_UP = 1 << 4, ///< Upper scroll button has been pressed, @see ScrollbarClickHandler() |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
492 |
WF_SCROLL_DOWN = 1 << 5, ///< Lower scroll button has been pressed, @see ScrollbarClickHandler() |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
493 |
WF_SCROLL_MIDDLE = 1 << 6, ///< Scrollbar scrolling, @see ScrollbarClickHandler() |
9723 | 494 |
WF_HSCROLL = 1 << 7, |
495 |
WF_SIZING = 1 << 8, |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
496 |
WF_STICKY = 1 << 9, ///< Window is made sticky by user |
9723 | 497 |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9837
diff
changeset
|
498 |
WF_DISABLE_VP_SCROLL = 1 << 10, ///< Window does not do autoscroll, @see HandleAutoscroll() |
9723 | 499 |
|
500 |
WF_WHITE_BORDER_ONE = 1 << 11, |
|
501 |
WF_WHITE_BORDER_MASK = 1 << 12 | WF_WHITE_BORDER_ONE, |
|
502 |
WF_SCROLL2 = 1 << 13, |
|
503 |
}; |
|
504 |
||
505 |
Window *BringWindowToFrontById(WindowClass cls, WindowNumber number); |
|
506 |
Window *FindWindowFromPt(int x, int y); |
|
507 |
||
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
508 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
509 |
* Open a new window. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
510 |
* @param *desc The pointer to the WindowDesc to be created |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
511 |
* @param window_number the window number of the new window |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
512 |
* @param data arbitrary data that is send with the WE_CREATE message |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
513 |
* @return see Window pointer of the newly created window |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
514 |
*/ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
515 |
template <typename Wcls> |
10645 | 516 |
Wcls *AllocateWindowDescFront(const WindowDesc *desc, int window_number) |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
517 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
518 |
if (BringWindowToFrontById(desc->cls, window_number)) return NULL; |
10645 | 519 |
return new Wcls(desc, window_number); |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
520 |
} |
9723 | 521 |
|
522 |
void RelocateAllWindows(int neww, int newh); |
|
523 |
||
524 |
/* misc_gui.cpp */ |
|
525 |
void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[]); |
|
526 |
static inline void GuiShowTooltips(StringID str) |
|
527 |
{ |
|
528 |
GuiShowTooltipsWithArgs(str, 0, NULL); |
|
529 |
} |
|
530 |
||
531 |
/* widget.cpp */ |
|
532 |
int GetWidgetFromPos(const Window *w, int x, int y); |
|
533 |
||
534 |
/* window.cpp */ |
|
535 |
extern Window *_z_windows[]; |
|
536 |
extern Window **_last_z_window; |
|
537 |
#define FOR_ALL_WINDOWS(wz) for (wz = _z_windows; wz != _last_z_window; wz++) |
|
538 |
||
10776 | 539 |
/** |
540 |
* In certain windows you navigate with the arrow keys. Do not scroll the |
|
541 |
* gameview when here. Bitencoded variable that only allows scrolling if all |
|
542 |
* elements are zero |
|
543 |
*/ |
|
544 |
enum { |
|
545 |
SCROLL_CON = 0, |
|
546 |
SCROLL_EDIT = 1, |
|
547 |
SCROLL_SAVE = 2, |
|
548 |
SCROLL_CHAT = 4, |
|
549 |
}; |
|
550 |
||
551 |
/** Disable scrolling of the main viewport when an input-window is active. */ |
|
552 |
extern byte _no_scroll; |
|
553 |
||
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
554 |
extern Point _cursorpos_drag_start; |
9723 | 555 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
556 |
extern int _scrollbar_start_pos; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
557 |
extern int _scrollbar_size; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
558 |
extern byte _scroller_click_timeout; |
9723 | 559 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
560 |
extern bool _scrolling_scrollbar; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
561 |
extern bool _scrolling_viewport; |
9723 | 562 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
563 |
extern byte _special_mouse_mode; |
9723 | 564 |
enum SpecialMouseMode { |
565 |
WSM_NONE = 0, |
|
566 |
WSM_DRAGDROP = 1, |
|
567 |
WSM_SIZING = 2, |
|
568 |
WSM_PRESIZE = 3, |
|
569 |
}; |
|
570 |
||
10294 | 571 |
Window *GetCallbackWnd(); |
572 |
Window **FindWindowZPosition(const Window *w); |
|
573 |
||
9723 | 574 |
void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y); |
575 |
||
576 |
void ResizeButtons(Window *w, byte left, byte right); |
|
577 |
||
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
578 |
void ResizeWindowForWidget(Window *w, int widget, int delta_x, int delta_y); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
579 |
|
10776 | 580 |
void SetVScrollCount(Window *w, int num); |
581 |
void SetVScroll2Count(Window *w, int num); |
|
582 |
void SetHScrollCount(Window *w, int num); |
|
583 |
||
9723 | 584 |
|
585 |
/** |
|
586 |
* Sets the enabled/disabled status of a widget. |
|
587 |
* By default, widgets are enabled. |
|
588 |
* On certain conditions, they have to be disabled. |
|
589 |
* @param widget_index : index of this widget in the window |
|
590 |
* @param disab_stat : status to use ie: disabled = true, enabled = false |
|
591 |
*/ |
|
592 |
inline void Window::SetWidgetDisabledState(byte widget_index, bool disab_stat) |
|
593 |
{ |
|
594 |
assert(widget_index < this->widget_count); |
|
595 |
SB(this->widget[widget_index].display_flags, WIDG_DISABLED, 1, !!disab_stat); |
|
596 |
} |
|
597 |
||
598 |
/** |
|
599 |
* Sets a widget to disabled. |
|
600 |
* @param widget_index : index of this widget in the window |
|
601 |
*/ |
|
602 |
inline void Window::DisableWidget(byte widget_index) |
|
603 |
{ |
|
604 |
SetWidgetDisabledState(widget_index, true); |
|
605 |
} |
|
606 |
||
607 |
/** |
|
608 |
* Sets a widget to Enabled. |
|
609 |
* @param widget_index : index of this widget in the window |
|
610 |
*/ |
|
611 |
inline void Window::EnableWidget(byte widget_index) |
|
612 |
{ |
|
613 |
SetWidgetDisabledState(widget_index, false); |
|
614 |
} |
|
615 |
||
616 |
/** |
|
617 |
* Gets the enabled/disabled status of a widget. |
|
618 |
* @param widget_index : index of this widget in the window |
|
619 |
* @return status of the widget ie: disabled = true, enabled = false |
|
620 |
*/ |
|
621 |
inline bool Window::IsWidgetDisabled(byte widget_index) const |
|
622 |
{ |
|
623 |
assert(widget_index < this->widget_count); |
|
624 |
return HasBit(this->widget[widget_index].display_flags, WIDG_DISABLED); |
|
625 |
} |
|
626 |
||
627 |
/** |
|
628 |
* Sets the hidden/shown status of a widget. |
|
629 |
* By default, widgets are visible. |
|
630 |
* On certain conditions, they have to be hidden. |
|
631 |
* @param widget_index index of this widget in the window |
|
632 |
* @param hidden_stat status to use ie. hidden = true, visible = false |
|
633 |
*/ |
|
634 |
inline void Window::SetWidgetHiddenState(byte widget_index, bool hidden_stat) |
|
635 |
{ |
|
636 |
assert(widget_index < this->widget_count); |
|
637 |
SB(this->widget[widget_index].display_flags, WIDG_HIDDEN, 1, !!hidden_stat); |
|
638 |
} |
|
639 |
||
640 |
/** |
|
641 |
* Sets a widget hidden. |
|
642 |
* @param widget_index : index of this widget in the window |
|
643 |
*/ |
|
644 |
inline void Window::HideWidget(byte widget_index) |
|
645 |
{ |
|
646 |
SetWidgetHiddenState(widget_index, true); |
|
647 |
} |
|
648 |
||
649 |
/** |
|
650 |
* Sets a widget visible. |
|
651 |
* @param widget_index : index of this widget in the window |
|
652 |
*/ |
|
653 |
inline void Window::ShowWidget(byte widget_index) |
|
654 |
{ |
|
655 |
SetWidgetHiddenState(widget_index, false); |
|
656 |
} |
|
657 |
||
658 |
/** |
|
659 |
* Gets the visibility of a widget. |
|
660 |
* @param widget_index : index of this widget in the window |
|
661 |
* @return status of the widget ie: hidden = true, visible = false |
|
662 |
*/ |
|
663 |
inline bool Window::IsWidgetHidden(byte widget_index) const |
|
664 |
{ |
|
665 |
assert(widget_index < this->widget_count); |
|
666 |
return HasBit(this->widget[widget_index].display_flags, WIDG_HIDDEN); |
|
667 |
} |
|
668 |
||
669 |
/** |
|
670 |
* Sets the lowered/raised status of a widget. |
|
671 |
* @param widget_index : index of this widget in the window |
|
672 |
* @param lowered_stat : status to use ie: lowered = true, raised = false |
|
673 |
*/ |
|
674 |
inline void Window::SetWidgetLoweredState(byte widget_index, bool lowered_stat) |
|
675 |
{ |
|
676 |
assert(widget_index < this->widget_count); |
|
677 |
SB(this->widget[widget_index].display_flags, WIDG_LOWERED, 1, !!lowered_stat); |
|
678 |
} |
|
679 |
||
680 |
/** |
|
681 |
* Invert the lowered/raised status of a widget. |
|
682 |
* @param widget_index : index of this widget in the window |
|
683 |
*/ |
|
684 |
inline void Window::ToggleWidgetLoweredState(byte widget_index) |
|
685 |
{ |
|
686 |
assert(widget_index < this->widget_count); |
|
687 |
ToggleBit(this->widget[widget_index].display_flags, WIDG_LOWERED); |
|
688 |
} |
|
689 |
||
690 |
/** |
|
691 |
* Marks a widget as lowered. |
|
692 |
* @param widget_index : index of this widget in the window |
|
693 |
*/ |
|
694 |
inline void Window::LowerWidget(byte widget_index) |
|
695 |
{ |
|
696 |
SetWidgetLoweredState(widget_index, true); |
|
697 |
} |
|
698 |
||
699 |
/** |
|
700 |
* Marks a widget as raised. |
|
701 |
* @param widget_index : index of this widget in the window |
|
702 |
*/ |
|
703 |
inline void Window::RaiseWidget(byte widget_index) |
|
704 |
{ |
|
705 |
SetWidgetLoweredState(widget_index, false); |
|
706 |
} |
|
707 |
||
708 |
/** |
|
709 |
* Gets the lowered state of a widget. |
|
710 |
* @param widget_index : index of this widget in the window |
|
711 |
* @return status of the widget ie: lowered = true, raised= false |
|
712 |
*/ |
|
713 |
inline bool Window::IsWidgetLowered(byte widget_index) const |
|
714 |
{ |
|
715 |
assert(widget_index < this->widget_count); |
|
716 |
return HasBit(this->widget[widget_index].display_flags, WIDG_LOWERED); |
|
717 |
} |
|
718 |
||
719 |
#endif /* WINDOW_GUI_H */ |