author | darkvater |
Tue, 05 Apr 2005 21:03:30 +0000 | |
changeset 1648 | 747061dca705 |
parent 1570 | c470380facb9 |
child 1938 | 21bd6ef5f85e |
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 |
||
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
64 |
/* XXX - outside "byte event" so you can set event directly without going into |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
65 |
* the union elements at first. Because of this every first element of the union |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
66 |
* MUST BE 'byte event'. Whoever did this must get shot! Scheduled for immediate |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
67 |
* rewrite after 0.4.0 */ |
0 | 68 |
union WindowEvent { |
69 |
byte event; |
|
70 |
struct { |
|
71 |
byte event; |
|
72 |
Point pt; |
|
73 |
int widget; |
|
74 |
} click; |
|
75 |
||
76 |
struct { |
|
77 |
byte event; |
|
78 |
Point pt; |
|
79 |
uint tile; |
|
80 |
uint starttile; |
|
81 |
int userdata; |
|
82 |
} place; |
|
83 |
||
84 |
struct { |
|
85 |
byte event; |
|
86 |
Point pt; |
|
87 |
int widget; |
|
88 |
} dragdrop; |
|
89 |
||
90 |
struct { |
|
91 |
byte event; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
92 |
Point size; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
93 |
Point diff; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
94 |
} sizing; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
95 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
96 |
struct { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
97 |
byte event; |
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1178
diff
changeset
|
98 |
char *str; |
0 | 99 |
} edittext; |
100 |
||
101 |
struct { |
|
102 |
byte event; |
|
103 |
Point pt; |
|
104 |
} popupmenu; |
|
105 |
||
106 |
struct { |
|
107 |
byte event; |
|
108 |
int button; |
|
109 |
int index; |
|
110 |
} dropdown; |
|
111 |
||
112 |
struct { |
|
113 |
byte event; |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
114 |
Point pt; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
115 |
int widget; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
116 |
} mouseover; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
117 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
118 |
struct { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
119 |
byte event; |
0 | 120 |
bool cont; // continue the search? (default true) |
121 |
byte ascii; // 8-bit ASCII-value of the key |
|
122 |
uint16 keycode;// untranslated key (including shift-state) |
|
123 |
} keypress; |
|
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
124 |
|
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
125 |
struct { |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
126 |
byte event; |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
127 |
uint msg; // message to be sent |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
128 |
uint wparam; // additional message-specific information |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
129 |
uint lparam; // additional message-specific information |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
130 |
} message; |
0 | 131 |
}; |
132 |
||
133 |
enum WindowKeyCodes { |
|
134 |
WKC_SHIFT = 0x8000, |
|
135 |
WKC_CTRL = 0x4000, |
|
136 |
WKC_ALT = 0x2000, |
|
137 |
WKC_META = 0x1000, |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
138 |
|
0 | 139 |
// Special ones |
140 |
WKC_NONE = 0, |
|
141 |
WKC_ESC=1, |
|
142 |
WKC_BACKSPACE = 2, |
|
143 |
WKC_INSERT = 3, |
|
144 |
WKC_DELETE = 4, |
|
145 |
||
146 |
WKC_PAGEUP = 5, |
|
147 |
WKC_PAGEDOWN = 6, |
|
148 |
WKC_END = 7, |
|
149 |
WKC_HOME = 8, |
|
150 |
||
151 |
// Arrow keys |
|
152 |
WKC_LEFT = 9, |
|
153 |
WKC_UP = 10, |
|
154 |
WKC_RIGHT = 11, |
|
155 |
WKC_DOWN = 12, |
|
156 |
||
157 |
// Return & tab |
|
158 |
WKC_RETURN = 13, |
|
159 |
WKC_TAB = 14, |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
160 |
|
0 | 161 |
// Numerical keyboard |
162 |
WKC_NUM_0 = 16, |
|
163 |
WKC_NUM_1 = 17, |
|
164 |
WKC_NUM_2 = 18, |
|
165 |
WKC_NUM_3 = 19, |
|
166 |
WKC_NUM_4 = 20, |
|
167 |
WKC_NUM_5 = 21, |
|
168 |
WKC_NUM_6 = 22, |
|
169 |
WKC_NUM_7 = 23, |
|
170 |
WKC_NUM_8 = 24, |
|
171 |
WKC_NUM_9 = 25, |
|
172 |
WKC_NUM_DIV = 26, |
|
173 |
WKC_NUM_MUL = 27, |
|
174 |
WKC_NUM_MINUS = 28, |
|
175 |
WKC_NUM_PLUS = 29, |
|
176 |
WKC_NUM_ENTER = 30, |
|
177 |
WKC_NUM_DECIMAL = 31, |
|
178 |
||
179 |
// Space |
|
180 |
WKC_SPACE = 32, |
|
181 |
||
182 |
// Function keys |
|
183 |
WKC_F1 = 33, |
|
184 |
WKC_F2 = 34, |
|
185 |
WKC_F3 = 35, |
|
186 |
WKC_F4 = 36, |
|
187 |
WKC_F5 = 37, |
|
188 |
WKC_F6 = 38, |
|
189 |
WKC_F7 = 39, |
|
190 |
WKC_F8 = 40, |
|
191 |
WKC_F9 = 41, |
|
192 |
WKC_F10 = 42, |
|
193 |
WKC_F11 = 43, |
|
194 |
WKC_F12 = 44, |
|
195 |
||
129
df1a60bc0d70
(svn r130) Change: hotkey for console is Backquote (the key left to '1', regardless of keyboard layout
dominik
parents:
116
diff
changeset
|
196 |
// 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
|
197 |
// 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
|
198 |
// 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
|
199 |
WKC_BACKQUOTE = 45, |
424
4c7808af7526
(svn r623) -Feature: [ 1066504 ] Pause key pauses the game
tron
parents:
380
diff
changeset
|
200 |
WKC_PAUSE = 46, |
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
201 |
|
0 | 202 |
// 0-9 are mapped to 48-57 |
203 |
// A-Z are mapped to 65-90 |
|
204 |
// 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
|
205 |
|
0 | 206 |
|
207 |
//WKC_UNKNOWN = 0xFF, |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
208 |
|
0 | 209 |
}; |
210 |
||
211 |
typedef struct WindowDesc { |
|
212 |
int16 left, top, width, height; |
|
213 |
byte cls; |
|
214 |
byte parent_cls; |
|
215 |
uint32 flags; |
|
216 |
const Widget *widgets; |
|
217 |
WindowProc *proc; |
|
218 |
} WindowDesc; |
|
219 |
||
220 |
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
|
221 |
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
|
222 |
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
|
223 |
WDF_STD_BTN = 4, /* default handling for close and drag widgets (widget no 0 and 1) */ |
0 | 224 |
WDF_RESTORE_DPARAM = 8, /* when drawing widgets, restore the dparam so all widgets recieve the same set of them */ |
225 |
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
|
226 |
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
|
227 |
WDF_RESIZABLE =64, /* A window can be resized */ |
0 | 228 |
}; |
229 |
||
230 |
/* can be used as x or y coordinates to cause a specific placement */ |
|
231 |
enum { |
|
232 |
WDP_AUTO = -1, |
|
233 |
WDP_CENTER = -2, |
|
234 |
}; |
|
235 |
||
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
236 |
typedef struct Textbuf { |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
237 |
char *buf; /* buffer in which text is saved */ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
238 |
uint16 maxlength, maxwidth; /* the maximum size of the buffer. Maxwidth specifies screensize in pixels */ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
239 |
uint16 length, width; /* the current size of the buffer. Width specifies screensize in pixels */ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
240 |
bool caret; /* is the caret ("_") visible or not */ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
241 |
uint16 caretpos; /* the current position of the caret in the buffer */ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
242 |
uint16 caretxoffs; /* the current position of the caret in pixels */ |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
243 |
} Textbuf; |
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
244 |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
245 |
typedef struct { |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
246 |
StringID caption; |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
247 |
WindowClass wnd_class; |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
248 |
WindowNumber wnd_num; |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1386
diff
changeset
|
249 |
Textbuf text; |
1386
aa5a172a8431
(svn r1890) Begin to clean up the edit box: Remove one global variable and split the combined edit/original buffer into two
tron
parents:
1323
diff
changeset
|
250 |
const char* orig; |
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
251 |
} querystr_d; |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
252 |
|
0 | 253 |
#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
|
254 |
// 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
|
255 |
// because 64-bit systems use 64-bit pointers, it is bigger on a 64-bit system |
826 | 256 |
// 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
|
257 |
// instead of a hardcoded number. |
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
258 |
// 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
|
259 |
#define WINDOW_CUSTOM_SIZE sizeof(querystr_d) |
0 | 260 |
|
261 |
typedef struct { |
|
62
2bdd81b8adcc
(svn r63) Fix: [ 1009385 ] Too many save games prevented loading
dominik
parents:
0
diff
changeset
|
262 |
uint16 count, cap, pos; |
0 | 263 |
} Scrollbar; |
264 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
265 |
typedef struct { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
266 |
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
|
267 |
uint height; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
268 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
269 |
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
|
270 |
uint step_height; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
271 |
} ResizeInfo; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
272 |
|
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
273 |
typedef struct { |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
274 |
int msg; |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
275 |
int wparam; |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
276 |
int lparam; |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
277 |
} Message; |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
278 |
|
0 | 279 |
struct Window { |
280 |
uint16 flags4; |
|
281 |
WindowClass window_class; |
|
282 |
WindowNumber window_number; |
|
283 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
284 |
int left, top; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
285 |
int width, height; |
0 | 286 |
|
842 | 287 |
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
|
288 |
ResizeInfo resize; |
0 | 289 |
|
290 |
byte caption_color; |
|
291 |
||
292 |
uint32 click_state, disabled_state, hidden_state; |
|
293 |
WindowProc *wndproc; |
|
294 |
ViewPort *viewport; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
295 |
const Widget *original_widget; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
296 |
Widget *widget; |
0 | 297 |
//const WindowDesc *desc; |
298 |
uint32 desc_flags; |
|
299 |
||
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
300 |
Message message; |
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
301 |
byte custom[WINDOW_CUSTOM_SIZE]; |
0 | 302 |
}; |
303 |
||
304 |
typedef struct { |
|
305 |
byte item_count; /* follow_vehicle */ |
|
306 |
byte sel_index; /* scrollpos_x */ |
|
307 |
byte main_button; /* scrollpos_y */ |
|
308 |
byte action_id; |
|
309 |
StringID string_id; /* unk30 */ |
|
310 |
uint16 checked_items; /* unk32 */ |
|
311 |
} menu_d; |
|
1004 | 312 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(menu_d)); |
0 | 313 |
|
314 |
typedef struct { |
|
315 |
int16 data_1, data_2, data_3; |
|
316 |
int16 data_4, data_5; |
|
317 |
bool close; /* scrollpos_y */ |
|
318 |
byte byte_1; |
|
319 |
} def_d; |
|
1004 | 320 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(def_d)); |
0 | 321 |
|
322 |
typedef struct { |
|
323 |
void *data; |
|
324 |
} void_d; |
|
1004 | 325 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(void_d)); |
0 | 326 |
|
327 |
typedef struct { |
|
328 |
uint16 base; /* follow_vehicle */ |
|
329 |
uint16 count;/* scrollpos_x */ |
|
330 |
} tree_d; |
|
1004 | 331 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tree_d)); |
0 | 332 |
|
333 |
typedef struct { |
|
334 |
byte refresh_counter; /* follow_vehicle */ |
|
335 |
} plstations_d; |
|
1004 | 336 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(plstations_d)); |
0 | 337 |
|
338 |
typedef struct { |
|
339 |
StringID string_id; |
|
340 |
} tooltips_d; |
|
1004 | 341 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d)); |
0 | 342 |
|
343 |
typedef struct { |
|
344 |
byte railtype; |
|
345 |
byte sel_index; |
|
346 |
int16 sel_engine; |
|
347 |
int16 rename_engine; |
|
348 |
} buildtrain_d; |
|
1004 | 349 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildtrain_d)); |
0 | 350 |
|
351 |
typedef struct { |
|
842 | 352 |
byte vehicletype; |
353 |
byte sel_index[2]; |
|
354 |
int16 sel_engine[2]; |
|
355 |
uint16 count[2]; |
|
356 |
} replaceveh_d; |
|
1004 | 357 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d)); |
842 | 358 |
|
359 |
typedef struct { |
|
0 | 360 |
VehicleID sel; |
361 |
} traindepot_d; |
|
1004 | 362 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(traindepot_d)); |
0 | 363 |
|
364 |
typedef struct { |
|
365 |
int sel; |
|
366 |
} order_d; |
|
1004 | 367 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d)); |
0 | 368 |
|
369 |
typedef struct { |
|
370 |
byte tab; |
|
371 |
} traindetails_d; |
|
1004 | 372 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(traindetails_d)); |
0 | 373 |
|
374 |
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
|
375 |
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
|
376 |
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
|
377 |
int32 subscroll; |
0 | 378 |
} smallmap_d; |
1004 | 379 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(traindetails_d)); |
0 | 380 |
|
381 |
typedef struct { |
|
382 |
uint32 face; |
|
383 |
byte gender; |
|
384 |
} facesel_d; |
|
1004 | 385 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(facesel_d)); |
0 | 386 |
|
387 |
typedef struct { |
|
388 |
int sel; |
|
389 |
byte cargo; |
|
390 |
} refit_d; |
|
1004 | 391 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d)); |
0 | 392 |
|
393 |
typedef struct { |
|
394 |
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
|
395 |
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
|
396 |
int32 scrollpos_y; |
0 | 397 |
} vp_d; |
1004 | 398 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d) + 3 * sizeof(byte)); // + 3 * byte is a hack from Miham |
399 |
||
400 |
// vp2_d is the same as vp_d, except for the data_# values.. |
|
401 |
typedef struct { |
|
402 |
uint16 follow_vehicle; |
|
403 |
int32 scrollpos_x; |
|
404 |
int32 scrollpos_y; |
|
405 |
byte data_1; |
|
406 |
byte data_2; |
|
407 |
byte data_3; |
|
408 |
} vp2_d; |
|
409 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp2_d)); |
|
0 | 410 |
|
411 |
typedef struct { |
|
412 |
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
|
413 |
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
|
414 |
int32 scrollpos_y; |
0 | 415 |
NewsItem *ni; |
416 |
} news_d; |
|
1004 | 417 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d)); |
0 | 418 |
|
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
849
diff
changeset
|
419 |
typedef struct { |
998
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
420 |
uint32 background_img; |
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
421 |
int8 rank; |
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
422 |
} highscore_d; |
1004 | 423 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(highscore_d)); |
998
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
424 |
|
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
425 |
typedef struct { |
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
426 |
int height; |
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
427 |
uint16 counter; |
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
983
diff
changeset
|
428 |
} scroller_d; |
1004 | 429 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(scroller_d)); |
859
46839573bed8
(svn r1340) -Feature: scrolling credits list...finally! Hope nobody gets offended if I forgot them.
darkvater
parents:
849
diff
changeset
|
430 |
|
588 | 431 |
typedef enum VehicleListFlags { |
432 |
VL_DESC = 0x01, |
|
433 |
VL_RESORT = 0x02, |
|
434 |
VL_REBUILD = 0x04 |
|
435 |
} VehicleListFlags; |
|
436 |
||
437 |
typedef struct vehiclelist_d { |
|
438 |
SortStruct *sort_list; |
|
439 |
uint16 list_length; |
|
440 |
byte sort_type; |
|
441 |
VehicleListFlags flags; |
|
442 |
uint16 resort_timer; |
|
443 |
} vehiclelist_d; |
|
1004 | 444 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d)); |
588 | 445 |
|
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
446 |
typedef struct message_d { |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
447 |
int msg; |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
448 |
int wparam; |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
449 |
int lparam; |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
450 |
} message_d; |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
451 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(message_d)); |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
452 |
|
0 | 453 |
enum WindowEvents { |
454 |
WE_CLICK = 0, |
|
455 |
WE_PAINT = 1, |
|
456 |
WE_MOUSELOOP = 2, |
|
457 |
WE_TICK = 3, |
|
458 |
WE_4 = 4, |
|
459 |
WE_TIMEOUT = 5, |
|
460 |
WE_PLACE_OBJ = 6, |
|
461 |
WE_ABORT_PLACE_OBJ = 7, |
|
462 |
WE_DESTROY = 8, |
|
463 |
WE_ON_EDIT_TEXT = 9, |
|
464 |
WE_POPUPMENU_SELECT = 10, |
|
465 |
WE_POPUPMENU_OVER = 11, |
|
466 |
WE_DRAGDROP = 12, |
|
467 |
WE_PLACE_DRAG = 13, |
|
468 |
WE_PLACE_MOUSEUP = 14, |
|
469 |
WE_PLACE_PRESIZE = 15, |
|
470 |
WE_DROPDOWN_SELECT = 16, |
|
471 |
WE_RCLICK = 17, |
|
472 |
WE_KEYPRESS = 18, |
|
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
68
diff
changeset
|
473 |
WE_CREATE = 19, |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
474 |
WE_MOUSEOVER = 20, |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
424
diff
changeset
|
475 |
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
|
476 |
WE_RESIZE = 22, |
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
477 |
WE_MESSAGE = 23 |
0 | 478 |
}; |
479 |
||
480 |
||
481 |
/****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/ |
|
482 |
enum WindowWidgetBehaviours { |
|
483 |
WWB_PUSHBUTTON = 1 << 5, |
|
484 |
WWB_NODISBUTTON = 2 << 5, |
|
485 |
}; |
|
486 |
||
487 |
||
488 |
enum WindowWidgetTypes { |
|
489 |
WWT_EMPTY = 0, |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
490 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
491 |
WWT_IMGBTN = 1, /* button with image */ |
0 | 492 |
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
|
493 |
WWT_PANEL_2 = 2, /* button with diff image when clicked */ |
0 | 494 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
495 |
WWT_TEXTBTN = 3, /* button with text */ |
0 | 496 |
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
|
497 |
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
|
498 |
WWT_5 = 5, /* label */ |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
499 |
WWT_6 = 6, /* combo box text area */ |
0 | 500 |
WWT_MATRIX = 7, |
501 |
WWT_SCROLLBAR = 8, |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
502 |
WWT_FRAME = 9, /* frame */ |
0 | 503 |
WWT_CAPTION = 10, |
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
504 |
|
0 | 505 |
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
|
506 |
WWT_STICKYBOX = 12, |
842 | 507 |
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
|
508 |
WWT_RESIZEBOX = 14, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
509 |
WWT_LAST = 15, /* Last Item. use WIDGETS_END to fill up padding!! */ |
0 | 510 |
|
511 |
WWT_MASK = 31, |
|
512 |
||
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
513 |
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
|
514 |
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
|
515 |
WWT_NODISTXTBTN = WWT_TEXTBTN | WWB_NODISBUTTON, |
0 | 516 |
}; |
517 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
518 |
#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
|
519 |
|
0 | 520 |
enum WindowFlags { |
521 |
WF_TIMEOUT_SHL = 0, |
|
522 |
WF_TIMEOUT_MASK = 7, |
|
523 |
WF_DRAGGING = 1 << 3, |
|
524 |
WF_SCROLL_UP = 1 << 4, |
|
525 |
WF_SCROLL_DOWN = 1 << 5, |
|
526 |
WF_SCROLL_MIDDLE = 1 << 6, |
|
527 |
WF_HSCROLL = 1 << 7, |
|
528 |
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
|
529 |
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
|
530 |
|
0 | 531 |
WF_DISABLE_VP_SCROLL = 1 << 10, |
532 |
||
533 |
WF_WHITE_BORDER_ONE = 1 << 11, |
|
534 |
WF_WHITE_BORDER_MASK = 3 << 11, |
|
842 | 535 |
WF_SCROLL2 = 1 << 13, |
0 | 536 |
}; |
537 |
||
538 |
||
539 |
void DispatchLeftClickEvent(Window *w, int x, int y); |
|
540 |
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
|
541 |
void DispatchMouseWheelEvent(Window *w, uint widget, int wheel); |
0 | 542 |
|
543 |
/* window.c */ |
|
544 |
void DrawOverlappedWindow(Window *w, int left, int top, int right, int bottom); |
|
545 |
void CallWindowEventNP(Window *w, int event); |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
546 |
void CallWindowTickEvent(void); |
0 | 547 |
void SetWindowDirty(Window *w); |
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
548 |
void SendWindowMessageW(Window *w, uint msg, uint wparam, uint lparam); |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1570
diff
changeset
|
549 |
void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, uint msg, uint wparam, uint lparam); |
0 | 550 |
|
551 |
Window *FindWindowById(WindowClass cls, WindowNumber number); |
|
552 |
void DeleteWindow(Window *w); |
|
553 |
Window *BringWindowToFrontById(WindowClass cls, WindowNumber number); |
|
554 |
Window *BringWindowToFront(Window *w); |
|
555 |
Window *StartWindowDrag(Window *w); |
|
556 |
Window *StartWindowSizing(Window *w); |
|
557 |
Window *FindWindowFromPt(int x, int y); |
|
558 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
859
diff
changeset
|
559 |
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
|
560 |
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
|
561 |
/* 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
|
562 |
void MakeWindowWidgetDefault(Window *w); |
0 | 563 |
Window *AllocateWindow( |
564 |
int x, |
|
565 |
int y, |
|
566 |
int width, |
|
567 |
int height, |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
568 |
WindowProc *proc, |
0 | 569 |
WindowClass cls, |
570 |
const Widget *widget); |
|
571 |
||
572 |
Window *AllocateWindowDesc(const WindowDesc *desc); |
|
573 |
Window *AllocateWindowDescFront(const WindowDesc *desc, int value); |
|
574 |
||
575 |
Window *AllocateWindowAutoPlace( |
|
576 |
int width, |
|
577 |
int height, |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
578 |
WindowProc *proc, |
0 | 579 |
WindowClass cls, |
580 |
const Widget *widget); |
|
581 |
||
582 |
Window *AllocateWindowAutoPlace2( |
|
583 |
WindowClass exist_class, |
|
584 |
WindowNumber exist_num, |
|
585 |
int width, |
|
586 |
int height, |
|
158
b1a821f84250
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
truelight
parents:
129
diff
changeset
|
587 |
WindowProc *proc, |
0 | 588 |
WindowClass cls, |
589 |
const Widget *widget); |
|
590 |
||
591 |
void DrawWindowViewport(Window *w); |
|
592 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
593 |
void InitWindowSystem(void); |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1390
diff
changeset
|
594 |
void UnInitWindowSystem(void); |
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1390
diff
changeset
|
595 |
void ResetWindowSystem(void); |
0 | 596 |
int GetMenuItemIndex(Window *w, int x, int y); |
1570
c470380facb9
(svn r2074) MouseLoop -> InputLoop(), factor out a real mouse-specific MouseLoop from the new InitLoop() (more in the spirit of HandleKeypress()).
pasky
parents:
1474
diff
changeset
|
597 |
void InputLoop(void); |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
598 |
void UpdateWindows(void); |
0 | 599 |
void InvalidateWidget(Window *w, byte widget_index); |
600 |
||
601 |
void GuiShowTooltips(uint16 string_id); |
|
602 |
||
603 |
void UnclickWindowButtons(Window *w); |
|
604 |
void UnclickSomeWindowButtons(Window *w, uint32 mask); |
|
605 |
void RelocateAllWindows(int neww, int newh); |
|
380 | 606 |
int PositionMainToolbar(Window *w); |
0 | 607 |
|
608 |
/* widget.c */ |
|
609 |
int GetWidgetFromPos(Window *w, int x, int y); |
|
610 |
void DrawWindowWidgets(Window *w); |
|
842 | 611 |
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, bool remove_filtered_strings); |
0 | 612 |
|
613 |
void HandleButtonClick(Window *w, byte widget); |
|
614 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
615 |
Window *GetCallbackWnd(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
616 |
void DeleteNonVitalWindows(void); |
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
|
617 |
void DeleteAllNonVitalWindows(void); |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
618 |
void HideVitalWindows(void); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
982
diff
changeset
|
619 |
void ShowVitalWindows(void); |
0 | 620 |
|
621 |
/* 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
|
622 |
VARDEF Window _windows[25]; |
0 | 623 |
VARDEF Window *_last_window; |
624 |
||
625 |
VARDEF Point _cursorpos_drag_start; |
|
626 |
||
627 |
VARDEF bool _left_button_down; |
|
628 |
VARDEF bool _left_button_clicked; |
|
629 |
||
630 |
VARDEF bool _right_button_down; |
|
631 |
VARDEF bool _right_button_clicked; |
|
632 |
||
633 |
VARDEF int _alloc_wnd_parent_num; |
|
634 |
||
635 |
VARDEF int _scrollbar_start_pos; |
|
636 |
VARDEF int _scrollbar_size; |
|
637 |
VARDEF bool _demo_mode; |
|
638 |
VARDEF byte _scroller_click_timeout; |
|
639 |
||
640 |
VARDEF bool _dragging_window; |
|
641 |
VARDEF bool _scrolling_scrollbar; |
|
642 |
VARDEF bool _scrolling_viewport; |
|
643 |
VARDEF bool _popup_menu_active; |
|
644 |
//VARDEF bool _dragdrop_active; |
|
645 |
||
646 |
VARDEF Point _fix_mouse_at; |
|
647 |
||
648 |
VARDEF byte _special_mouse_mode; |
|
649 |
enum SpecialMouseMode { |
|
650 |
WSM_NONE = 0, |
|
651 |
WSM_DRAGDROP = 1, |
|
652 |
WSM_SIZING = 2, |
|
653 |
WSM_PRESIZE = 3, |
|
654 |
}; |
|
655 |
||
656 |
void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y); |
|
657 |
||
658 |
#endif /* WINDOW_H */ |