author | darkvater |
Tue, 11 Jan 2005 00:24:27 +0000 | |
changeset 982 | be834034b331 |
parent 869 | f211ac238c8e |
child 983 | 1be852dcdd4c |
permissions | -rw-r--r-- |
0 | 1 |
#ifndef WINDOW_H |
2 |
#define WINDOW_H |
|
3 |
||
588 | 4 |
#include "vehicle_gui.h" |
5 |
||
0 | 6 |
typedef union WindowEvent WindowEvent; |
7 |
||
8 |
//typedef void WindowProc(Window *w, int event, int wparam, long lparam); |
|
9 |
||
10 |
typedef void WindowProc(Window *w, WindowEvent *e); |
|
11 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
12 |
/* How the resize system works: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
13 |
First, you need to add a WWT_RESIZEBOX to the widgets, and you need |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
14 |
to add the flag WDF_RESIZABLE to the window. Now the window is ready |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
15 |
to resize itself. |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
16 |
As you may have noticed, all widgets have a RESIZE_XXX in their line. |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
17 |
This lines controls how the widgets behave on resize. RESIZE_NONE means |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
18 |
it doesn't do anything. Any other option let's one of the borders |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
19 |
move with the changed width/height. So if a widget has |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
20 |
RESIZE_RIGHT, and the window is made 5 pixels wider by the user, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
21 |
the right of the window will also be made 5 pixels wider. |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
22 |
Now, what if you want to clamp a widget to the bottom? Give it the flag |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
23 |
RESIZE_TB. This is RESIZE_TOP + RESIZE_BOTTOM. Now if the window gets |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
24 |
5 pixels bigger, both the top and bottom gets 5 bigger, so the whole |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
25 |
widgets moves downwards without resizing, and appears to be clamped |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
26 |
to the bottom. Nice aint it? |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
27 |
You should know one more thing about this system. Most windows can't |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
28 |
handle an increase of 1 pixel. So there is a step function, which |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
29 |
let the windowsize only be changed by X pixels. You configure this |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
30 |
after making the window, like this: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
31 |
w->resize.step_height = 10; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
32 |
Now the window will only change in height in steps of 10. |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
33 |
You can also give a minimum width and height. The default value is |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
34 |
the default height/width of the window itself. You can change this |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
35 |
AFTER window-creation, with: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
36 |
w->resize.width or w->resize.height. |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
37 |
That was all.. good luck, and enjoy :) -- TrueLight */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
38 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
39 |
enum { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
40 |
RESIZE_NONE = 0, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
41 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
42 |
RESIZE_LEFT = 1, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
43 |
RESIZE_RIGHT = 2, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
44 |
RESIZE_TOP = 4, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
45 |
RESIZE_BOTTOM = 8, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
46 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
47 |
RESIZE_LR = RESIZE_LEFT | RESIZE_RIGHT, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
48 |
RESIZE_RB = RESIZE_RIGHT | RESIZE_BOTTOM, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
49 |
RESIZE_TB = RESIZE_TOP | RESIZE_BOTTOM, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
50 |
RESIZE_LRB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_BOTTOM, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
51 |
RESIZE_LRTB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
52 |
RESIZE_RTB = RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
53 |
}; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
54 |
|
0 | 55 |
typedef struct Widget { |
56 |
byte type; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
57 |
byte resize_flag; |
0 | 58 |
byte color; |
59 |
uint16 left, right, top, bottom; |
|
60 |
uint16 unkA; |
|
61 |
uint16 tooltips; |
|
62 |
} Widget; |
|
63 |
||
64 |
union WindowEvent { |
|
65 |
byte event; |
|
66 |
struct { |
|
67 |
byte event; |
|
68 |
Point pt; |
|
69 |
int widget; |
|
70 |
} click; |
|
71 |
||
72 |
struct { |
|
73 |
byte event; |
|
74 |
Point pt; |
|
75 |
uint tile; |
|
76 |
uint starttile; |
|
77 |
int userdata; |
|
78 |
} place; |
|
79 |
||
80 |
struct { |
|
81 |
byte event; |
|
82 |
Point pt; |
|
83 |
int widget; |
|
84 |
} dragdrop; |
|
85 |
||
86 |
struct { |
|
87 |
byte event; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
88 |
Point size; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
89 |
Point diff; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
90 |
} sizing; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
91 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
92 |
struct { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
93 |
byte event; |
0 | 94 |
byte *str; |
95 |
} edittext; |
|
96 |
||
97 |
struct { |
|
98 |
byte event; |
|
99 |
Point pt; |
|
100 |
} popupmenu; |
|
101 |
||
102 |
struct { |
|
103 |
byte event; |
|
104 |
int button; |
|
105 |
int index; |
|
106 |
} dropdown; |
|
107 |
||
108 |
struct { |
|
109 |
byte event; |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
110 |
Point pt; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
111 |
int widget; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
112 |
} mouseover; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
113 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
114 |
struct { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
115 |
byte event; |
0 | 116 |
bool cont; // continue the search? (default true) |
117 |
byte ascii; // 8-bit ASCII-value of the key |
|
118 |
uint16 keycode;// untranslated key (including shift-state) |
|
119 |
} keypress; |
|
120 |
}; |
|
121 |
||
122 |
enum WindowKeyCodes { |
|
123 |
WKC_SHIFT = 0x8000, |
|
124 |
WKC_CTRL = 0x4000, |
|
125 |
WKC_ALT = 0x2000, |
|
126 |
WKC_META = 0x1000, |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
127 |
|
0 | 128 |
// Special ones |
129 |
WKC_NONE = 0, |
|
130 |
WKC_ESC=1, |
|
131 |
WKC_BACKSPACE = 2, |
|
132 |
WKC_INSERT = 3, |
|
133 |
WKC_DELETE = 4, |
|
134 |
||
135 |
WKC_PAGEUP = 5, |
|
136 |
WKC_PAGEDOWN = 6, |
|
137 |
WKC_END = 7, |
|
138 |
WKC_HOME = 8, |
|
139 |
||
140 |
// Arrow keys |
|
141 |
WKC_LEFT = 9, |
|
142 |
WKC_UP = 10, |
|
143 |
WKC_RIGHT = 11, |
|
144 |
WKC_DOWN = 12, |
|
145 |
||
146 |
// Return & tab |
|
147 |
WKC_RETURN = 13, |
|
148 |
WKC_TAB = 14, |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
149 |
|
0 | 150 |
// Numerical keyboard |
151 |
WKC_NUM_0 = 16, |
|
152 |
WKC_NUM_1 = 17, |
|
153 |
WKC_NUM_2 = 18, |
|
154 |
WKC_NUM_3 = 19, |
|
155 |
WKC_NUM_4 = 20, |
|
156 |
WKC_NUM_5 = 21, |
|
157 |
WKC_NUM_6 = 22, |
|
158 |
WKC_NUM_7 = 23, |
|
159 |
WKC_NUM_8 = 24, |
|
160 |
WKC_NUM_9 = 25, |
|
161 |
WKC_NUM_DIV = 26, |
|
162 |
WKC_NUM_MUL = 27, |
|
163 |
WKC_NUM_MINUS = 28, |
|
164 |
WKC_NUM_PLUS = 29, |
|
165 |
WKC_NUM_ENTER = 30, |
|
166 |
WKC_NUM_DECIMAL = 31, |
|
167 |
||
168 |
// Space |
|
169 |
WKC_SPACE = 32, |
|
170 |
||
171 |
// Function keys |
|
172 |
WKC_F1 = 33, |
|
173 |
WKC_F2 = 34, |
|
174 |
WKC_F3 = 35, |
|
175 |
WKC_F4 = 36, |
|
176 |
WKC_F5 = 37, |
|
177 |
WKC_F6 = 38, |
|
178 |
WKC_F7 = 39, |
|
179 |
WKC_F8 = 40, |
|
180 |
WKC_F9 = 41, |
|
181 |
WKC_F10 = 42, |
|
182 |
WKC_F11 = 43, |
|
183 |
WKC_F12 = 44, |
|
184 |
||
129
df1a60bc0d70
(svn r130) Change: hotkey for console is Backquote (the key left to '1', regardless of keyboard layout
dominik
parents:
116
diff
changeset
|
185 |
// backquote is the key left of "1" |
df1a60bc0d70
(svn r130) Change: hotkey for console is Backquote (the key left to '1', regardless of keyboard layout
dominik
parents:
116
diff
changeset
|
186 |
// we only store this key here, no matter what character is really mapped to it |
df1a60bc0d70
(svn r130) Change: hotkey for console is Backquote (the key left to '1', regardless of keyboard layout
dominik
parents:
116
diff
changeset
|
187 |
// on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °) |
df1a60bc0d70
(svn r130) Change: hotkey for console is Backquote (the key left to '1', regardless of keyboard layout
dominik
parents:
116
diff
changeset
|
188 |
WKC_BACKQUOTE = 45, |
424
4c7808af7526
(svn r623) -Feature: [ 1066504 ] Pause key pauses the game
tron
parents:
380
diff
changeset
|
189 |
WKC_PAUSE = 46, |
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
190 |
|
0 | 191 |
// 0-9 are mapped to 48-57 |
192 |
// A-Z are mapped to 65-90 |
|
193 |
// a-z are mapped to 97-122 |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
194 |
|
0 | 195 |
|
196 |
//WKC_UNKNOWN = 0xFF, |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
197 |
|
0 | 198 |
}; |
199 |
||
200 |
typedef struct WindowDesc { |
|
201 |
int16 left, top, width, height; |
|
202 |
byte cls; |
|
203 |
byte parent_cls; |
|
204 |
uint32 flags; |
|
205 |
const Widget *widgets; |
|
206 |
WindowProc *proc; |
|
207 |
} WindowDesc; |
|
208 |
||
209 |
enum { |
|
682
7f5de4abac85
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
588
diff
changeset
|
210 |
WDF_STD_TOOLTIPS = 1, /* use standard routine when displaying tooltips */ |
7f5de4abac85
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
588
diff
changeset
|
211 |
WDF_DEF_WIDGET = 2, /* default widget control for some widgets in the on click event */ |
7f5de4abac85
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
588
diff
changeset
|
212 |
WDF_STD_BTN = 4, /* default handling for close and drag widgets (widget no 0 and 1) */ |
0 | 213 |
WDF_RESTORE_DPARAM = 8, /* when drawing widgets, restore the dparam so all widgets recieve the same set of them */ |
214 |
WDF_UNCLICK_BUTTONS=16, /* Unclick buttons when the window event times out */ |
|
682
7f5de4abac85
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
588
diff
changeset
|
215 |
WDF_STICKY_BUTTON =32, /* Set window to sticky mode; they are not closed unless closed with 'X' (widget 2) */ |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
216 |
WDF_RESIZABLE =64, /* A window can be resized */ |
0 | 217 |
}; |
218 |
||
219 |
/* can be used as x or y coordinates to cause a specific placement */ |
|
220 |
enum { |
|
221 |
WDP_AUTO = -1, |
|
222 |
WDP_CENTER = -2, |
|
223 |
}; |
|
224 |
||
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
225 |
typedef struct { |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
226 |
StringID caption; |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
227 |
bool caret; |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
228 |
WindowClass wnd_class; |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
229 |
WindowNumber wnd_num; |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
230 |
uint16 maxlen, maxwidth; |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
231 |
byte *buf; |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
232 |
} querystr_d; |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
233 |
|
0 | 234 |
#define WP(ptr,str) (*(str*)(ptr)->custom) |
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
235 |
// querystr_d is the bigest struct that comes in w->custom |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
236 |
// because 64-bit systems use 64-bit pointers, it is bigger on a 64-bit system |
826 | 237 |
// than on a 32-bit system. Therefore, the size is calculated from querystr_d |
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
238 |
// instead of a hardcoded number. |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
239 |
// if any struct becomes bigger the querystr_d, it should be replaced. |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
240 |
#define WINDOW_CUSTOM_SIZE sizeof(querystr_d) |
0 | 241 |
|
242 |
typedef struct { |
|
62
2bdd81b8adcc
(svn r63) Fix: [ 1009385 ] Too many save games prevented loading
dominik
parents:
0
diff
changeset
|
243 |
uint16 count, cap, pos; |
0 | 244 |
} Scrollbar; |
245 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
246 |
typedef struct { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
247 |
uint width; /* Minimum width and height */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
248 |
uint height; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
249 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
250 |
uint step_width; /* In how big steps the width and height go */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
251 |
uint step_height; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
252 |
} ResizeInfo; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
253 |
|
0 | 254 |
struct Window { |
255 |
uint16 flags4; |
|
256 |
WindowClass window_class; |
|
257 |
WindowNumber window_number; |
|
258 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
259 |
int left, top; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
260 |
int width, height; |
0 | 261 |
|
842 | 262 |
Scrollbar hscroll, vscroll, vscroll2; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
263 |
ResizeInfo resize; |
0 | 264 |
|
265 |
byte caption_color; |
|
266 |
||
267 |
uint32 click_state, disabled_state, hidden_state; |
|
268 |
WindowProc *wndproc; |
|
269 |
ViewPort *viewport; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
270 |
const Widget *original_widget; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
271 |
Widget *widget; |
0 | 272 |
//const WindowDesc *desc; |
273 |
uint32 desc_flags; |
|
274 |
||
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
275 |
byte custom[WINDOW_CUSTOM_SIZE]; |
0 | 276 |
}; |
277 |
||
278 |
typedef struct { |
|
279 |
byte item_count; /* follow_vehicle */ |
|
280 |
byte sel_index; /* scrollpos_x */ |
|
281 |
byte main_button; /* scrollpos_y */ |
|
282 |
byte action_id; |
|
283 |
StringID string_id; /* unk30 */ |
|
284 |
uint16 checked_items; /* unk32 */ |
|
285 |
} menu_d; |
|
286 |
||
287 |
typedef struct { |
|
288 |
int16 data_1, data_2, data_3; |
|
289 |
int16 data_4, data_5; |
|
290 |
bool close; /* scrollpos_y */ |
|
291 |
byte byte_1; |
|
292 |
} def_d; |
|
293 |
||
294 |
typedef struct { |
|
295 |
void *data; |
|
296 |
} void_d; |
|
297 |
||
298 |
typedef struct { |
|
299 |
uint16 base; /* follow_vehicle */ |
|
300 |
uint16 count;/* scrollpos_x */ |
|
301 |
} tree_d; |
|
302 |
||
303 |
typedef struct { |
|
304 |
byte refresh_counter; /* follow_vehicle */ |
|
305 |
} plstations_d; |
|
306 |
||
307 |
typedef struct { |
|
308 |
StringID string_id; |
|
309 |
} tooltips_d; |
|
310 |
||
311 |
typedef struct { |
|
312 |
byte railtype; |
|
313 |
byte sel_index; |
|
314 |
int16 sel_engine; |
|
315 |
int16 rename_engine; |
|
316 |
} buildtrain_d; |
|
317 |
||
318 |
typedef struct { |
|
842 | 319 |
byte railtype; |
320 |
byte vehicletype; |
|
321 |
byte sel_index[2]; |
|
322 |
int16 sel_engine[2]; |
|
323 |
uint16 count[2]; |
|
324 |
} replaceveh_d; |
|
325 |
||
326 |
typedef struct { |
|
0 | 327 |
VehicleID sel; |
328 |
} traindepot_d; |
|
329 |
||
330 |
typedef struct { |
|
331 |
int sel; |
|
332 |
} order_d; |
|
333 |
||
334 |
typedef struct { |
|
335 |
byte tab; |
|
336 |
} traindetails_d; |
|
337 |
||
338 |
typedef struct { |
|
849
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
842
diff
changeset
|
339 |
int32 scroll_x; |
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
842
diff
changeset
|
340 |
int32 scroll_y; |
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
842
diff
changeset
|
341 |
int32 subscroll; |
0 | 342 |
} smallmap_d; |
343 |
||
344 |
typedef struct { |
|
345 |
uint32 face; |
|
346 |
byte gender; |
|
347 |
} facesel_d; |
|
348 |
||
349 |
typedef struct { |
|
350 |
int sel; |
|
351 |
byte cargo; |
|
352 |
} refit_d; |
|
353 |
||
354 |
typedef struct { |
|
355 |
uint16 follow_vehicle; |
|
849
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
842
diff
changeset
|
356 |
int32 scrollpos_x; |
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
842
diff
changeset
|
357 |
int32 scrollpos_y; |
0 | 358 |
} vp_d; |
359 |
||
360 |
typedef struct { |
|
361 |
uint16 follow_vehicle; |
|
849
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
842
diff
changeset
|
362 |
int32 scrollpos_x; |
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
842
diff
changeset
|
363 |
int32 scrollpos_y; |
0 | 364 |
NewsItem *ni; |
365 |
} news_d; |
|
366 |
||
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
849
diff
changeset
|
367 |
typedef struct { |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
849
diff
changeset
|
368 |
int i; |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
849
diff
changeset
|
369 |
int j; |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
849
diff
changeset
|
370 |
} general_d; |
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
849
diff
changeset
|
371 |
|
588 | 372 |
typedef enum VehicleListFlags { |
373 |
VL_DESC = 0x01, |
|
374 |
VL_RESORT = 0x02, |
|
375 |
VL_REBUILD = 0x04 |
|
376 |
} VehicleListFlags; |
|
377 |
||
378 |
typedef struct vehiclelist_d { |
|
379 |
SortStruct *sort_list; |
|
380 |
uint16 list_length; |
|
381 |
byte sort_type; |
|
382 |
VehicleListFlags flags; |
|
383 |
uint16 resort_timer; |
|
384 |
} vehiclelist_d; |
|
385 |
assert_compile(sizeof(vehiclelist_d) <= WINDOW_CUSTOM_SIZE); |
|
386 |
||
0 | 387 |
enum WindowEvents { |
388 |
WE_CLICK = 0, |
|
389 |
WE_PAINT = 1, |
|
390 |
WE_MOUSELOOP = 2, |
|
391 |
WE_TICK = 3, |
|
392 |
WE_4 = 4, |
|
393 |
WE_TIMEOUT = 5, |
|
394 |
WE_PLACE_OBJ = 6, |
|
395 |
WE_ABORT_PLACE_OBJ = 7, |
|
396 |
WE_DESTROY = 8, |
|
397 |
WE_ON_EDIT_TEXT = 9, |
|
398 |
WE_POPUPMENU_SELECT = 10, |
|
399 |
WE_POPUPMENU_OVER = 11, |
|
400 |
WE_DRAGDROP = 12, |
|
401 |
WE_PLACE_DRAG = 13, |
|
402 |
WE_PLACE_MOUSEUP = 14, |
|
403 |
WE_PLACE_PRESIZE = 15, |
|
404 |
WE_DROPDOWN_SELECT = 16, |
|
405 |
WE_RCLICK = 17, |
|
406 |
WE_KEYPRESS = 18, |
|
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
68
diff
changeset
|
407 |
WE_CREATE = 19, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
408 |
WE_MOUSEOVER = 20, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
409 |
WE_ON_EDIT_TEXT_CANCEL = 21, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
410 |
WE_RESIZE = 22, |
0 | 411 |
}; |
412 |
||
413 |
||
414 |
/****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/ |
|
415 |
enum WindowWidgetBehaviours { |
|
416 |
WWB_PUSHBUTTON = 1 << 5, |
|
417 |
WWB_NODISBUTTON = 2 << 5, |
|
418 |
}; |
|
419 |
||
420 |
||
421 |
enum WindowWidgetTypes { |
|
422 |
WWT_EMPTY = 0, |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
423 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
424 |
WWT_IMGBTN = 1, /* button with image */ |
0 | 425 |
WWT_PANEL = WWT_IMGBTN, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
426 |
WWT_PANEL_2 = 2, /* button with diff image when clicked */ |
0 | 427 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
428 |
WWT_TEXTBTN = 3, /* button with text */ |
0 | 429 |
WWT_CLOSEBOX = WWT_TEXTBTN, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
430 |
WWT_4 = 4, /* button with diff text when clicked */ |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
431 |
WWT_5 = 5, /* label */ |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
432 |
WWT_6 = 6, /* combo box text area */ |
0 | 433 |
WWT_MATRIX = 7, |
434 |
WWT_SCROLLBAR = 8, |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
435 |
WWT_FRAME = 9, /* frame */ |
0 | 436 |
WWT_CAPTION = 10, |
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
437 |
|
0 | 438 |
WWT_HSCROLLBAR = 11, |
682
7f5de4abac85
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
588
diff
changeset
|
439 |
WWT_STICKYBOX = 12, |
842 | 440 |
WWT_SCROLL2BAR = 13, /* 2nd vertical scrollbar*/ |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
441 |
WWT_RESIZEBOX = 14, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
442 |
WWT_LAST = 15, /* Last Item. use WIDGETS_END to fill up padding!! */ |
0 | 443 |
|
444 |
WWT_MASK = 31, |
|
445 |
||
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
446 |
WWT_PUSHTXTBTN = WWT_TEXTBTN | WWB_PUSHBUTTON, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
447 |
WWT_PUSHIMGBTN = WWT_IMGBTN | WWB_PUSHBUTTON, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
448 |
WWT_NODISTXTBTN = WWT_TEXTBTN | WWB_NODISBUTTON, |
0 | 449 |
}; |
450 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
451 |
#define WIDGETS_END WWT_LAST, RESIZE_NONE, 0, 0, 0, 0, 0, 0, STR_NULL |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
452 |
|
0 | 453 |
enum WindowFlags { |
454 |
WF_TIMEOUT_SHL = 0, |
|
455 |
WF_TIMEOUT_MASK = 7, |
|
456 |
WF_DRAGGING = 1 << 3, |
|
457 |
WF_SCROLL_UP = 1 << 4, |
|
458 |
WF_SCROLL_DOWN = 1 << 5, |
|
459 |
WF_SCROLL_MIDDLE = 1 << 6, |
|
460 |
WF_HSCROLL = 1 << 7, |
|
461 |
WF_SIZING = 1 << 8, |
|
682
7f5de4abac85
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
588
diff
changeset
|
462 |
WF_STICKY = 1 << 9, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
463 |
|
0 | 464 |
WF_DISABLE_VP_SCROLL = 1 << 10, |
465 |
||
466 |
WF_WHITE_BORDER_ONE = 1 << 11, |
|
467 |
WF_WHITE_BORDER_MASK = 3 << 11, |
|
842 | 468 |
WF_SCROLL2 = 1 << 13, |
0 | 469 |
}; |
470 |
||
471 |
||
472 |
void DispatchLeftClickEvent(Window *w, int x, int y); |
|
473 |
void DispatchRightClickEvent(Window *w, int x, int y); |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
869
diff
changeset
|
474 |
void DispatchMouseWheelEvent(Window *w, uint widget, int wheel); |
0 | 475 |
|
476 |
/* window.c */ |
|
477 |
void DrawOverlappedWindow(Window *w, int left, int top, int right, int bottom); |
|
478 |
void CallWindowEventNP(Window *w, int event); |
|
479 |
void CallWindowTickEvent(); |
|
480 |
void DrawDirtyBlocks(); |
|
481 |
void SetDirtyBlocks(int left, int top, int right, int bottom); |
|
482 |
void SetWindowDirty(Window *w); |
|
483 |
||
484 |
Window *FindWindowById(WindowClass cls, WindowNumber number); |
|
485 |
void DeleteWindow(Window *w); |
|
486 |
Window *BringWindowToFrontById(WindowClass cls, WindowNumber number); |
|
487 |
Window *BringWindowToFront(Window *w); |
|
488 |
Window *StartWindowDrag(Window *w); |
|
489 |
Window *StartWindowSizing(Window *w); |
|
490 |
Window *FindWindowFromPt(int x, int y); |
|
491 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
492 |
bool IsWindowOfPrototype(Window *w, const Widget *widget); |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
493 |
void AssignWidgetToWindow(Window *w, const Widget *widget); |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
494 |
/* Use this function to save the current widget to be the global default */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
495 |
void MakeWindowWidgetDefault(Window *w); |
0 | 496 |
Window *AllocateWindow( |
497 |
int x, |
|
498 |
int y, |
|
499 |
int width, |
|
500 |
int height, |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
501 |
WindowProc *proc, |
0 | 502 |
WindowClass cls, |
503 |
const Widget *widget); |
|
504 |
||
505 |
Window *AllocateWindowDesc(const WindowDesc *desc); |
|
506 |
Window *AllocateWindowDescFront(const WindowDesc *desc, int value); |
|
507 |
||
508 |
Window *AllocateWindowAutoPlace( |
|
509 |
int width, |
|
510 |
int height, |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
511 |
WindowProc *proc, |
0 | 512 |
WindowClass cls, |
513 |
const Widget *widget); |
|
514 |
||
515 |
Window *AllocateWindowAutoPlace2( |
|
516 |
WindowClass exist_class, |
|
517 |
WindowNumber exist_num, |
|
518 |
int width, |
|
519 |
int height, |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
520 |
WindowProc *proc, |
0 | 521 |
WindowClass cls, |
522 |
const Widget *widget); |
|
523 |
||
524 |
void DrawWindowViewport(Window *w); |
|
525 |
||
526 |
void InitWindowSystem(); |
|
527 |
int GetMenuItemIndex(Window *w, int x, int y); |
|
528 |
void MouseLoop(); |
|
529 |
void UpdateWindows(); |
|
530 |
void InvalidateWidget(Window *w, byte widget_index); |
|
531 |
||
532 |
void GuiShowTooltips(uint16 string_id); |
|
533 |
||
534 |
void UnclickWindowButtons(Window *w); |
|
535 |
void UnclickSomeWindowButtons(Window *w, uint32 mask); |
|
536 |
void RelocateAllWindows(int neww, int newh); |
|
380 | 537 |
int PositionMainToolbar(Window *w); |
0 | 538 |
|
539 |
/* widget.c */ |
|
540 |
int GetWidgetFromPos(Window *w, int x, int y); |
|
541 |
void DrawWindowWidgets(Window *w); |
|
842 | 542 |
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, bool remove_filtered_strings); |
0 | 543 |
|
544 |
void HandleButtonClick(Window *w, byte widget); |
|
545 |
||
546 |
Window *GetCallbackWnd(); |
|
547 |
void DeleteNonVitalWindows(); |
|
763
8ff348acf75e
(svn r1225) -Feature: SHIFT+DEL now deletes all non-vital windows (only status bar and main bar remain)
darkvater
parents:
682
diff
changeset
|
548 |
void DeleteAllNonVitalWindows(void); |
0 | 549 |
|
550 |
/* window.c */ |
|
682
7f5de4abac85
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
588
diff
changeset
|
551 |
VARDEF Window _windows[25]; |
0 | 552 |
VARDEF Window *_last_window; |
553 |
||
554 |
VARDEF Point _cursorpos_drag_start; |
|
555 |
||
556 |
VARDEF bool _left_button_down; |
|
557 |
VARDEF bool _left_button_clicked; |
|
558 |
||
559 |
VARDEF bool _right_button_down; |
|
560 |
VARDEF bool _right_button_clicked; |
|
561 |
||
562 |
VARDEF int _alloc_wnd_parent_num; |
|
563 |
||
564 |
VARDEF int _scrollbar_start_pos; |
|
565 |
VARDEF int _scrollbar_size; |
|
566 |
VARDEF bool _demo_mode; |
|
567 |
VARDEF byte _scroller_click_timeout; |
|
568 |
||
569 |
VARDEF bool _dragging_window; |
|
570 |
VARDEF bool _scrolling_scrollbar; |
|
571 |
VARDEF bool _scrolling_viewport; |
|
572 |
VARDEF bool _popup_menu_active; |
|
573 |
//VARDEF bool _dragdrop_active; |
|
574 |
||
575 |
VARDEF Point _fix_mouse_at; |
|
576 |
||
577 |
VARDEF byte _special_mouse_mode; |
|
578 |
enum SpecialMouseMode { |
|
579 |
WSM_NONE = 0, |
|
580 |
WSM_DRAGDROP = 1, |
|
581 |
WSM_SIZING = 2, |
|
582 |
WSM_PRESIZE = 3, |
|
583 |
}; |
|
584 |
||
585 |
void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y); |
|
586 |
||
587 |
#endif /* WINDOW_H */ |