author | belugas |
Fri, 08 Sep 2006 03:59:38 +0000 | |
changeset 4573 | 92032cec7021 |
parent 4547 | d37c2d172ad4 |
child 4634 | 07699ac2bf37 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1657
diff
changeset
|
4 |
#include "openttd.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2154
diff
changeset
|
5 |
#include "functions.h" |
2154
f86c59e73a16
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2064
diff
changeset
|
6 |
#include "player.h" |
1363
775a7ee52369
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1177
diff
changeset
|
7 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
193
diff
changeset
|
8 |
#include "table/strings.h" |
0 | 9 |
#include "window.h" |
10 |
#include "gfx.h" |
|
11 |
#include "viewport.h" |
|
12 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2406
diff
changeset
|
13 |
static Point HandleScrollbarHittest(const Scrollbar *sb, int top, int bottom) |
0 | 14 |
{ |
15 |
Point pt; |
|
16 |
int height, count, pos, cap; |
|
17 |
||
18 |
top += 10; |
|
19 |
bottom -= 9; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
20 |
|
0 | 21 |
height = (bottom - top); |
22 |
||
23 |
pos = sb->pos; |
|
24 |
count = sb->count; |
|
25 |
cap = sb->cap; |
|
26 |
||
2026 | 27 |
if (count != 0) top += height * pos / count; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
28 |
|
0 | 29 |
if (cap > count) cap = count; |
2639 | 30 |
if (count != 0) bottom -= (count - pos - cap) * height / count; |
0 | 31 |
|
32 |
pt.x = top; |
|
33 |
pt.y = bottom - 1; |
|
34 |
return pt; |
|
35 |
} |
|
36 |
||
37 |
/***************************************************** |
|
38 |
* Special handling for the scrollbar widget type. |
|
39 |
* Handles the special scrolling buttons and other |
|
40 |
* scrolling. |
|
41 |
* Parameters: |
|
42 |
* w - Window. |
|
43 |
* wi - Pointer to the scrollbar widget. |
|
44 |
* x - The X coordinate of the mouse click. |
|
45 |
* y - The Y coordinate of the mouse click. |
|
46 |
*/ |
|
47 |
||
48 |
void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y) |
|
49 |
{ |
|
50 |
int mi, ma, pos; |
|
51 |
Scrollbar *sb; |
|
52 |
||
842 | 53 |
switch (wi->type) { |
54 |
case WWT_SCROLLBAR: { |
|
55 |
// vertical scroller |
|
56 |
w->flags4 &= ~WF_HSCROLL; |
|
57 |
w->flags4 &= ~WF_SCROLL2; |
|
58 |
mi = wi->top; |
|
59 |
ma = wi->bottom; |
|
60 |
pos = y; |
|
61 |
sb = &w->vscroll; |
|
62 |
break; |
|
63 |
} |
|
64 |
case WWT_SCROLL2BAR: { |
|
65 |
// 2nd vertical scroller |
|
66 |
w->flags4 &= ~WF_HSCROLL; |
|
67 |
w->flags4 |= WF_SCROLL2; |
|
68 |
mi = wi->top; |
|
69 |
ma = wi->bottom; |
|
70 |
pos = y; |
|
71 |
sb = &w->vscroll2; |
|
72 |
break; |
|
73 |
} |
|
74 |
case WWT_HSCROLLBAR: { |
|
75 |
// horizontal scroller |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
76 |
w->flags4 &= ~WF_SCROLL2; |
842 | 77 |
w->flags4 |= WF_HSCROLL; |
78 |
mi = wi->left; |
|
79 |
ma = wi->right; |
|
80 |
pos = x; |
|
81 |
sb = &w->hscroll; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
82 |
break; |
842 | 83 |
} |
845
4960e265d25b
(svn r1326) fixed compiler warnings in vehicle_gui.c and widget.c
bjarni
parents:
842
diff
changeset
|
84 |
default: return; //this should never happen |
0 | 85 |
} |
86 |
if (pos <= mi+9) { |
|
87 |
// Pressing the upper button? |
|
2597 | 88 |
w->flags4 |= WF_SCROLL_UP; |
89 |
if (_scroller_click_timeout == 0) { |
|
90 |
_scroller_click_timeout = 6; |
|
91 |
if (sb->pos != 0) sb->pos--; |
|
0 | 92 |
} |
2597 | 93 |
_left_button_clicked = false; |
0 | 94 |
} else if (pos >= ma-10) { |
95 |
// Pressing the lower button? |
|
2597 | 96 |
w->flags4 |= WF_SCROLL_DOWN; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
97 |
|
2597 | 98 |
if (_scroller_click_timeout == 0) { |
99 |
_scroller_click_timeout = 6; |
|
100 |
if ((byte)(sb->pos + sb->cap) < sb->count) |
|
101 |
sb->pos++; |
|
0 | 102 |
} |
2597 | 103 |
_left_button_clicked = false; |
0 | 104 |
} else { |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
105 |
// |
0 | 106 |
Point pt = HandleScrollbarHittest(sb, mi, ma); |
107 |
||
108 |
if (pos < pt.x) { |
|
109 |
sb->pos = max(sb->pos - sb->cap, 0); |
|
110 |
} else if (pos > pt.y) { |
|
111 |
sb->pos = min( |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
112 |
sb->pos + sb->cap, |
0 | 113 |
max(sb->count - sb->cap, 0) |
114 |
); |
|
115 |
} else { |
|
116 |
_scrollbar_start_pos = pt.x - mi - 9; |
|
117 |
_scrollbar_size = ma - mi - 23; |
|
118 |
w->flags4 |= WF_SCROLL_MIDDLE; |
|
119 |
_scrolling_scrollbar = true; |
|
120 |
_cursorpos_drag_start = _cursor.pos; |
|
121 |
} |
|
122 |
} |
|
123 |
||
124 |
SetWindowDirty(w); |
|
125 |
} |
|
126 |
||
2021
3a8c59ea3fbe
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
127 |
/** Returns the index for the widget located at the given position |
3a8c59ea3fbe
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
128 |
* relative to the window. It includes all widget-corner pixels as well. |
3a8c59ea3fbe
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
129 |
* @param *w Window to look inside |
3a8c59ea3fbe
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
130 |
* @param x,y Window client coordinates |
3a8c59ea3fbe
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
131 |
* @return A widget index, or -1 if no widget was found. |
0 | 132 |
*/ |
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2406
diff
changeset
|
133 |
int GetWidgetFromPos(const Window *w, int x, int y) |
0 | 134 |
{ |
135 |
const Widget *wi; |
|
136 |
int index, found_index = -1; |
|
137 |
||
138 |
// Go through the widgets and check if we find the widget that the coordinate is |
|
139 |
// inside. |
|
2021
3a8c59ea3fbe
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
140 |
for (index = 0,wi = w->widget; wi->type != WWT_LAST; index++, wi++) { |
2639 | 141 |
if (wi->type == WWT_EMPTY || wi->type == WWT_FRAME) continue; |
0 | 142 |
|
2021
3a8c59ea3fbe
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
143 |
if (x >= wi->left && x <= wi->right && y >= wi->top && y <= wi->bottom && |
3a8c59ea3fbe
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
144 |
!HASBIT(w->hidden_state,index)) { |
2639 | 145 |
found_index = index; |
0 | 146 |
} |
147 |
} |
|
148 |
||
149 |
return found_index; |
|
150 |
} |
|
151 |
||
152 |
||
4437
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
153 |
void DrawFrameRect(int left, int top, int right, int bottom, int ctab, FrameFlags flags) |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
154 |
{ |
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
155 |
uint dark = _colour_gradient[ctab][3]; |
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
156 |
uint medium_dark = _colour_gradient[ctab][5]; |
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
157 |
uint medium_light = _colour_gradient[ctab][6]; |
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
158 |
uint light = _colour_gradient[ctab][7]; |
4437
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
159 |
|
4438
c8b86504b83c
(svn r6210) Remove FR_NOBORDER, because it is exclusivly used in conjunction with FR_TRANSPARENT
tron
parents:
4437
diff
changeset
|
160 |
if (flags & FR_TRANSPARENT) { |
c8b86504b83c
(svn r6210) Remove FR_NOBORDER, because it is exclusivly used in conjunction with FR_TRANSPARENT
tron
parents:
4437
diff
changeset
|
161 |
GfxFillRect(left, top, right, bottom, 0x322 | USE_COLORTABLE); |
4437
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
162 |
} else { |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
163 |
uint interior; |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
164 |
|
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
165 |
if (flags & FR_LOWERED) { |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
166 |
GfxFillRect(left, top, left, bottom, dark); |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
167 |
GfxFillRect(left + 1, top, right, top, dark); |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
168 |
GfxFillRect(right, top + 1, right, bottom - 1, light); |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
169 |
GfxFillRect(left + 1, bottom, right, bottom, light); |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
170 |
interior = (flags & FR_DARKENED ? medium_dark : medium_light); |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
171 |
} else { |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
172 |
GfxFillRect(left, top, left, bottom - 1, light); |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
173 |
GfxFillRect(left + 1, top, right - 1, top, light); |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
174 |
GfxFillRect(right, top, right, bottom - 1, dark); |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
175 |
GfxFillRect(left, bottom, right, bottom, dark); |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
176 |
interior = medium_dark; |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
177 |
} |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
178 |
if (!(flags & FR_BORDERONLY)) { |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
179 |
GfxFillRect(left + 1, top + 1, right - 1, bottom - 1, interior); |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
180 |
} |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
181 |
} |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
182 |
} |
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
183 |
|
49e79e135539
(svn r6209) Move DrawFrameRect() out of gfx.[ch], because it uses data (_color_list) which the renderer shouldn't have know about
tron
parents:
4345
diff
changeset
|
184 |
|
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2406
diff
changeset
|
185 |
void DrawWindowWidgets(const Window *w) |
0 | 186 |
{ |
187 |
const Widget *wi; |
|
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2448
diff
changeset
|
188 |
const DrawPixelInfo* dpi = _cur_dpi; |
0 | 189 |
Rect r; |
190 |
uint32 cur_click, cur_disabled, cur_hidden; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
191 |
|
0 | 192 |
wi = w->widget; |
193 |
||
194 |
cur_click = w->click_state; |
|
195 |
cur_disabled = w->disabled_state; |
|
196 |
cur_hidden = w->hidden_state; |
|
197 |
||
198 |
do { |
|
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
199 |
bool clicked = (cur_click & 1); |
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
200 |
|
0 | 201 |
if (dpi->left > (r.right=/*w->left + */wi->right) || |
2639 | 202 |
dpi->left + dpi->width <= (r.left=wi->left/* + w->left*/) || |
0 | 203 |
dpi->top > (r.bottom=/*w->top +*/ wi->bottom) || |
204 |
dpi->top + dpi->height <= (r.top = /*w->top +*/ wi->top) || |
|
2639 | 205 |
cur_hidden & 1) { |
206 |
continue; |
|
207 |
} |
|
0 | 208 |
|
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
209 |
switch (wi->type & WWT_MASK) { |
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
210 |
case WWT_PANEL: /* WWT_IMGBTN */ |
0 | 211 |
case WWT_PANEL_2: { |
4547
d37c2d172ad4
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4444
diff
changeset
|
212 |
int img = wi->data; |
0 | 213 |
|
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
214 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
0 | 215 |
|
2639 | 216 |
if (img != 0) { // has an image |
217 |
// show diff image when clicked |
|
218 |
if ((wi->type & WWT_MASK) == WWT_PANEL_2 && clicked) img++; |
|
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
219 |
|
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
220 |
DrawSprite(img, r.left + 1 + clicked, r.top + 1 + clicked); |
0 | 221 |
} |
222 |
goto draw_default; |
|
223 |
} |
|
224 |
||
2757
d1ccb6600be3
(svn r3302) - Fix: split drawing of text buttons and the closebox, so the closebox symbol can be centred.
peter1138
parents:
2703
diff
changeset
|
225 |
case WWT_TEXTBTN: /* WWT_TEXTBTN */ |
0 | 226 |
case WWT_4: { |
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
227 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
0 | 228 |
} |
229 |
/* fall through */ |
|
230 |
||
4345
1da147230c79
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
3762
diff
changeset
|
231 |
case WWT_LABEL: { |
4547
d37c2d172ad4
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4444
diff
changeset
|
232 |
StringID str = wi->data; |
0 | 233 |
|
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
234 |
if ((wi->type&WWT_MASK) == WWT_4 && clicked) str++; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
235 |
|
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
236 |
DrawStringCentered(((r.left + r.right + 1) >> 1) + clicked, ((r.top + r.bottom + 1) >> 1) - 5 + clicked, str, 0); |
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
237 |
//DrawStringCentered((r.left + r.right+1)>>1, ((r.top+r.bottom + 1)>>1) - 5, str, 0); |
2064
e6a2b42d0b15
(svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents:
2026
diff
changeset
|
238 |
goto draw_default; |
0 | 239 |
} |
240 |
||
241 |
case WWT_6: { |
|
4547
d37c2d172ad4
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4444
diff
changeset
|
242 |
StringID str = wi->data; |
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
243 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_LOWERED | FR_DARKENED); |
0 | 244 |
|
4547
d37c2d172ad4
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4444
diff
changeset
|
245 |
if (str != STR_NULL) DrawStringTruncated(r.left + 2, r.top + 1, str, 0, r.right - r.left - 10); |
0 | 246 |
goto draw_default; |
247 |
} |
|
248 |
||
249 |
case WWT_MATRIX: { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
250 |
int c, d, ctr; |
0 | 251 |
int x, amt1, amt2; |
252 |
int color; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
253 |
|
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
254 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
255 |
|
4547
d37c2d172ad4
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4444
diff
changeset
|
256 |
c = GB(wi->data, 0, 8); |
0 | 257 |
amt1 = (wi->right - wi->left + 1) / c; |
258 |
||
4547
d37c2d172ad4
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4444
diff
changeset
|
259 |
d = GB(wi->data, 8, 8); |
0 | 260 |
amt2 = (wi->bottom - wi->top + 1) / d; |
261 |
||
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
262 |
color = _colour_gradient[wi->color & 0xF][6]; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
263 |
|
0 | 264 |
x = r.left; |
2801
b9062d829629
(svn r3349) Fix off-by-one error in drawing matrix widget, from r3181.
peter1138
parents:
2757
diff
changeset
|
265 |
for (ctr = c; ctr > 1; ctr--) { |
0 | 266 |
x += amt1; |
2639 | 267 |
GfxFillRect(x, r.top + 1, x, r.bottom - 1, color); |
0 | 268 |
} |
269 |
||
270 |
x = r.top; |
|
2801
b9062d829629
(svn r3349) Fix off-by-one error in drawing matrix widget, from r3181.
peter1138
parents:
2757
diff
changeset
|
271 |
for (ctr = d; ctr > 1; ctr--) { |
0 | 272 |
x += amt2; |
2639 | 273 |
GfxFillRect(r.left + 1, x, r.right - 1, x, color); |
0 | 274 |
} |
275 |
||
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
276 |
color = _colour_gradient[wi->color&0xF][4]; |
0 | 277 |
|
2639 | 278 |
x = r.left - 1; |
2801
b9062d829629
(svn r3349) Fix off-by-one error in drawing matrix widget, from r3181.
peter1138
parents:
2757
diff
changeset
|
279 |
for (ctr = c; ctr > 1; ctr--) { |
0 | 280 |
x += amt1; |
2639 | 281 |
GfxFillRect(x, r.top + 1, x, r.bottom - 1, color); |
0 | 282 |
} |
283 |
||
2639 | 284 |
x = r.top - 1; |
2801
b9062d829629
(svn r3349) Fix off-by-one error in drawing matrix widget, from r3181.
peter1138
parents:
2757
diff
changeset
|
285 |
for (ctr = d; ctr > 1; ctr--) { |
0 | 286 |
x += amt2; |
287 |
GfxFillRect(r.left+1, x, r.right-1, x, color); |
|
288 |
} |
|
289 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
290 |
goto draw_default; |
0 | 291 |
} |
292 |
||
293 |
// vertical scrollbar |
|
294 |
case WWT_SCROLLBAR: { |
|
295 |
Point pt; |
|
296 |
int c1,c2; |
|
297 |
||
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
298 |
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
299 |
|
0 | 300 |
// draw up/down buttons |
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
301 |
clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP); |
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
302 |
DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : 0); |
2406
8c873205483a
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2218
diff
changeset
|
303 |
DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, 0x10); |
0 | 304 |
|
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
305 |
clicked = !!(((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN)); |
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
306 |
DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
2406
8c873205483a
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2218
diff
changeset
|
307 |
DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10); |
0 | 308 |
|
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
309 |
c1 = _colour_gradient[wi->color&0xF][3]; |
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
310 |
c2 = _colour_gradient[wi->color&0xF][7]; |
0 | 311 |
|
312 |
// draw "shaded" background |
|
313 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2); |
|
2218
2132596a35c0
(svn r2736) -Codechange: De-mystified GfxDrawFillRect a bit, and used enums from table/sprites.h. You can now change the number of bits used for sprites and switches in the SpriteSetup enum and the rest should work automagically. Can be used to increase the number of active sprites to 2^19 in case there are no colortables (recolor sprites) in any newgrf. We should possibly move the the colortables to an own list, but how to detect them in a newgrf.
celestar
parents:
2186
diff
changeset
|
314 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | PALETTE_MODIFIER_GREYOUT); |
0 | 315 |
|
316 |
// draw shaded lines |
|
317 |
GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1); |
|
318 |
GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2); |
|
319 |
GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1); |
|
320 |
GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
321 |
|
0 | 322 |
pt = HandleScrollbarHittest(&w->vscroll, r.top, r.bottom); |
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
323 |
DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_MIDDLE ? FR_LOWERED : 0); |
842 | 324 |
break; |
325 |
} |
|
326 |
case WWT_SCROLL2BAR: { |
|
327 |
Point pt; |
|
328 |
int c1,c2; |
|
329 |
||
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
330 |
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
331 |
|
842 | 332 |
// draw up/down buttons |
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
333 |
clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2)); |
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
334 |
DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : 0); |
2406
8c873205483a
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2218
diff
changeset
|
335 |
DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, 0x10); |
842 | 336 |
|
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
337 |
clicked = !!((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2)); |
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
338 |
DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
2406
8c873205483a
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2218
diff
changeset
|
339 |
DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10); |
842 | 340 |
|
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
341 |
c1 = _colour_gradient[wi->color&0xF][3]; |
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
342 |
c2 = _colour_gradient[wi->color&0xF][7]; |
842 | 343 |
|
344 |
// draw "shaded" background |
|
345 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2); |
|
2218
2132596a35c0
(svn r2736) -Codechange: De-mystified GfxDrawFillRect a bit, and used enums from table/sprites.h. You can now change the number of bits used for sprites and switches in the SpriteSetup enum and the rest should work automagically. Can be used to increase the number of active sprites to 2^19 in case there are no colortables (recolor sprites) in any newgrf. We should possibly move the the colortables to an own list, but how to detect them in a newgrf.
celestar
parents:
2186
diff
changeset
|
346 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | PALETTE_MODIFIER_GREYOUT); |
842 | 347 |
|
348 |
// draw shaded lines |
|
349 |
GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1); |
|
350 |
GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2); |
|
351 |
GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1); |
|
352 |
GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2); |
|
353 |
||
354 |
pt = HandleScrollbarHittest(&w->vscroll2, r.top, r.bottom); |
|
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
355 |
DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_MIDDLE | WF_SCROLL2) ? FR_LOWERED : 0); |
0 | 356 |
break; |
357 |
} |
|
358 |
||
359 |
// horizontal scrollbar |
|
360 |
case WWT_HSCROLLBAR: { |
|
361 |
Point pt; |
|
362 |
int c1,c2; |
|
363 |
||
894
8b59c639837d
(svn r1380) -Fix: missed widget fixes; thanks Jango and TestMan57
darkvater
parents:
893
diff
changeset
|
364 |
assert(r.bottom - r.top == 11); // XXX - to ensure the same sizes are used everywhere! |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
365 |
|
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
366 |
clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL)); |
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
367 |
DrawFrameRect(r.left, r.top, r.left + 9, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
368 |
DrawSprite(SPR_ARROW_LEFT, r.left + 1 + clicked, r.top + 1 + clicked); |
0 | 369 |
|
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
370 |
clicked = !!((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL)); |
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
371 |
DrawFrameRect(r.right-9, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
372 |
DrawSprite(SPR_ARROW_RIGHT, r.right - 8 + clicked, r.top + 1 + clicked); |
0 | 373 |
|
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
374 |
c1 = _colour_gradient[wi->color&0xF][3]; |
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
375 |
c2 = _colour_gradient[wi->color&0xF][7]; |
0 | 376 |
|
377 |
// draw "shaded" background |
|
378 |
GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c2); |
|
2218
2132596a35c0
(svn r2736) -Codechange: De-mystified GfxDrawFillRect a bit, and used enums from table/sprites.h. You can now change the number of bits used for sprites and switches in the SpriteSetup enum and the rest should work automagically. Can be used to increase the number of active sprites to 2^19 in case there are no colortables (recolor sprites) in any newgrf. We should possibly move the the colortables to an own list, but how to detect them in a newgrf.
celestar
parents:
2186
diff
changeset
|
379 |
GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c1 | PALETTE_MODIFIER_GREYOUT); |
0 | 380 |
|
381 |
// draw shaded lines |
|
382 |
GfxFillRect(r.left+10, r.top+2, r.right-10, r.top+2, c1); |
|
383 |
GfxFillRect(r.left+10, r.top+3, r.right-10, r.top+3, c2); |
|
384 |
GfxFillRect(r.left+10, r.top+7, r.right-10, r.top+7, c1); |
|
385 |
GfxFillRect(r.left+10, r.top+8, r.right-10, r.top+8, c2); |
|
386 |
||
387 |
// draw actual scrollbar |
|
388 |
pt = HandleScrollbarHittest(&w->hscroll, r.left, r.right); |
|
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
389 |
DrawFrameRect(pt.x, r.top, pt.y, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL)) == (WF_SCROLL_MIDDLE | WF_HSCROLL) ? FR_LOWERED : 0); |
0 | 390 |
|
391 |
break; |
|
392 |
} |
|
393 |
||
394 |
case WWT_FRAME: { |
|
395 |
int c1,c2; |
|
860
fad6642f6217
(svn r1341) -Fix: fix WWT_FRAME drawing when there is no text there (STR_NULL)
darkvater
parents:
845
diff
changeset
|
396 |
int x2 = r.left; // by default the left side is the left side of the widget |
0 | 397 |
|
4547
d37c2d172ad4
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4444
diff
changeset
|
398 |
if (wi->data != 0) x2 = DrawString(r.left + 6, r.top, wi->data, 0); |
0 | 399 |
|
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
400 |
c1 = _colour_gradient[wi->color][3]; |
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
401 |
c2 = _colour_gradient[wi->color][7]; |
0 | 402 |
|
403 |
//Line from upper left corner to start of text |
|
404 |
GfxFillRect(r.left, r.top+4, r.left+4,r.top+4, c1); |
|
405 |
GfxFillRect(r.left+1, r.top+5, r.left+4,r.top+5, c2); |
|
406 |
||
407 |
// Line from end of text to upper right corner |
|
408 |
GfxFillRect(x2, r.top+4, r.right-1,r.top+4,c1); |
|
409 |
GfxFillRect(x2, r.top+5, r.right-2,r.top+5,c2); |
|
410 |
||
411 |
// Line from upper left corner to bottom left corner |
|
412 |
GfxFillRect(r.left, r.top+5, r.left, r.bottom-1, c1); |
|
413 |
GfxFillRect(r.left+1, r.top+6, r.left+1, r.bottom-2, c2); |
|
414 |
||
415 |
//Line from upper right corner to bottom right corner |
|
416 |
GfxFillRect(r.right-1, r.top+5, r.right-1, r.bottom-2, c1); |
|
417 |
GfxFillRect(r.right, r.top+4, r.right, r.bottom-1, c2); |
|
418 |
||
419 |
GfxFillRect(r.left+1, r.bottom-1, r.right-1, r.bottom-1, c1); |
|
420 |
GfxFillRect(r.left, r.bottom, r.right, r.bottom, c2); |
|
421 |
||
2064
e6a2b42d0b15
(svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents:
2026
diff
changeset
|
422 |
goto draw_default; |
0 | 423 |
} |
424 |
||
682
74c70f645d95
(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:
674
diff
changeset
|
425 |
case WWT_STICKYBOX: { |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
426 |
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
2703
a969970a5245
(svn r3247) - Fix: "[ 1335580 ] sticky windows not sticky anymore"
peter1138
parents:
2683
diff
changeset
|
427 |
|
a969970a5245
(svn r3247) - Fix: "[ 1335580 ] sticky windows not sticky anymore"
peter1138
parents:
2683
diff
changeset
|
428 |
clicked = !!(w->flags4 & WF_STICKY); |
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
429 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
430 |
DrawSprite((clicked) ? SPR_PIN_UP : SPR_PIN_DOWN, r.left + 2 + clicked, r.top + 3 + clicked); |
682
74c70f645d95
(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:
674
diff
changeset
|
431 |
break; |
74c70f645d95
(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:
674
diff
changeset
|
432 |
} |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
433 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
434 |
case WWT_RESIZEBOX: { |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
435 |
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
915 | 436 |
|
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
437 |
clicked = !!(w->flags4 & WF_SIZING); |
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
438 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
1657
af84fedacc6d
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
439 |
DrawSprite(SPR_WINDOW_RESIZE, r.left + 3 + clicked, r.top + 3 + clicked); |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
440 |
break; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
441 |
} |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
442 |
|
2757
d1ccb6600be3
(svn r3302) - Fix: split drawing of text buttons and the closebox, so the closebox symbol can be centred.
peter1138
parents:
2703
diff
changeset
|
443 |
case WWT_CLOSEBOX: { |
d1ccb6600be3
(svn r3302) - Fix: split drawing of text buttons and the closebox, so the closebox symbol can be centred.
peter1138
parents:
2703
diff
changeset
|
444 |
assert(r.right - r.left == 10); // ensure the same sizes are used everywhere |
d1ccb6600be3
(svn r3302) - Fix: split drawing of text buttons and the closebox, so the closebox symbol can be centred.
peter1138
parents:
2703
diff
changeset
|
445 |
|
d1ccb6600be3
(svn r3302) - Fix: split drawing of text buttons and the closebox, so the closebox symbol can be centred.
peter1138
parents:
2703
diff
changeset
|
446 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0); |
d1ccb6600be3
(svn r3302) - Fix: split drawing of text buttons and the closebox, so the closebox symbol can be centred.
peter1138
parents:
2703
diff
changeset
|
447 |
DrawString(r.left + 2, r.top + 2, STR_00C5, 0); |
d1ccb6600be3
(svn r3302) - Fix: split drawing of text buttons and the closebox, so the closebox symbol can be centred.
peter1138
parents:
2703
diff
changeset
|
448 |
break; |
d1ccb6600be3
(svn r3302) - Fix: split drawing of text buttons and the closebox, so the closebox symbol can be centred.
peter1138
parents:
2703
diff
changeset
|
449 |
} |
d1ccb6600be3
(svn r3302) - Fix: split drawing of text buttons and the closebox, so the closebox symbol can be centred.
peter1138
parents:
2703
diff
changeset
|
450 |
|
0 | 451 |
case WWT_CAPTION: { |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
452 |
assert(r.bottom - r.top == 13); // XXX - to ensure the same sizes are used everywhere! |
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
453 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_BORDERONLY); |
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
454 |
DrawFrameRect(r.left+1, r.top+1, r.right-1, r.bottom-1, wi->color, (w->caption_color == 0xFF) ? FR_LOWERED | FR_DARKENED : FR_LOWERED | FR_DARKENED | FR_BORDERONLY); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
455 |
|
0 | 456 |
if (w->caption_color != 0xFF) { |
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
457 |
GfxFillRect(r.left+2, r.top+2, r.right-2, r.bottom-2, _colour_gradient[_player_colors[w->caption_color]][4]); |
0 | 458 |
} |
459 |
||
4547
d37c2d172ad4
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4444
diff
changeset
|
460 |
DrawStringCentered( (r.left+r.right+1)>>1, r.top+2, wi->data, 0x84); |
0 | 461 |
draw_default:; |
462 |
if (cur_disabled & 1) { |
|
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
463 |
GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _colour_gradient[wi->color&0xF][2] | PALETTE_MODIFIER_GREYOUT); |
0 | 464 |
} |
465 |
} |
|
466 |
} |
|
467 |
} while (cur_click>>=1, cur_disabled>>=1, cur_hidden >>= 1, (++wi)->type != WWT_LAST); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
468 |
|
0 | 469 |
|
470 |
if (w->flags4 & WF_WHITE_BORDER_MASK) { |
|
471 |
//DrawFrameRect(w->left, w->top, w->left + w->width-1, w->top+w->height-1, 0xF, 0x10); |
|
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
472 |
DrawFrameRect(0, 0, w->width-1, w->height-1, 0xF, FR_BORDERONLY); |
0 | 473 |
} |
474 |
||
475 |
} |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
476 |
|
883
9bfde7bab1f9
(svn r1368) -Fix: Disabled dropdown menu options are gray again (instead of blue)
truelight
parents:
876
diff
changeset
|
477 |
static const Widget _dropdown_menu_widgets[] = { |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
478 |
{ WWT_IMGBTN, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
479 |
{ WIDGETS_END}, |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
480 |
}; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
481 |
|
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2406
diff
changeset
|
482 |
static int GetDropdownItem(const Window *w) |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
483 |
{ |
2448
1a07657c9f9a
(svn r2974) -Fix: Drag and drop selection on drop down boxes didn't select correct item when some items were hidden.
peter1138
parents:
2436
diff
changeset
|
484 |
byte item, counter; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
485 |
int y; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
486 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
487 |
if (GetWidgetFromPos(w, _cursor.pos.x - w->left, _cursor.pos.y - w->top) < 0) |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
488 |
return -1; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
489 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
490 |
y = _cursor.pos.y - w->top - 2; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
491 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
492 |
if (y < 0) |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
493 |
return - 1; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
494 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
495 |
item = y / 10; |
2683
ca9645a21734
(svn r3225) - Fix for "[ 1359165 ] Autoreplace problem with r3171 and later" -- Move the disabled/hidden bits to custom data in window struct.
peter1138
parents:
2642
diff
changeset
|
496 |
if (item >= WP(w,dropdown_d).num_items || (HASBIT(WP(w,dropdown_d).disabled_state, item) && !HASBIT(WP(w,dropdown_d).hidden_state, item)) || WP(w,dropdown_d).items[item] == 0) |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
497 |
return - 1; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
498 |
|
2448
1a07657c9f9a
(svn r2974) -Fix: Drag and drop selection on drop down boxes didn't select correct item when some items were hidden.
peter1138
parents:
2436
diff
changeset
|
499 |
// Skip hidden items -- +1 for each hidden item before the clicked item. |
1a07657c9f9a
(svn r2974) -Fix: Drag and drop selection on drop down boxes didn't select correct item when some items were hidden.
peter1138
parents:
2436
diff
changeset
|
500 |
for (counter = 0; item >= counter; ++counter) |
2683
ca9645a21734
(svn r3225) - Fix for "[ 1359165 ] Autoreplace problem with r3171 and later" -- Move the disabled/hidden bits to custom data in window struct.
peter1138
parents:
2642
diff
changeset
|
501 |
if (HASBIT(WP(w,dropdown_d).hidden_state, counter)) item++; |
2448
1a07657c9f9a
(svn r2974) -Fix: Drag and drop selection on drop down boxes didn't select correct item when some items were hidden.
peter1138
parents:
2436
diff
changeset
|
502 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
503 |
return item; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
504 |
} |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
505 |
|
1095 | 506 |
static void DropdownMenuWndProc(Window *w, WindowEvent *e) |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
507 |
{ |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
508 |
int item; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
509 |
|
2952 | 510 |
switch (e->event) { |
842 | 511 |
case WE_PAINT: { |
512 |
int x,y,i,sel; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
513 |
|
842 | 514 |
DrawWindowWidgets(w); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
515 |
|
842 | 516 |
x = 1; |
517 |
y = 2; |
|
2636
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
518 |
sel = WP(w,dropdown_d).selected_index; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
519 |
|
2636
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
520 |
for (i = 0; WP(w,dropdown_d).items[i] != INVALID_STRING_ID; i++) { |
2683
ca9645a21734
(svn r3225) - Fix for "[ 1359165 ] Autoreplace problem with r3171 and later" -- Move the disabled/hidden bits to custom data in window struct.
peter1138
parents:
2642
diff
changeset
|
521 |
if (HASBIT(WP(w,dropdown_d).hidden_state, i)) { |
1177
9a250d8f0794
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
522 |
sel--; |
9a250d8f0794
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
523 |
continue; |
9a250d8f0794
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
524 |
} |
4573
92032cec7021
(svn r6423) -Codechange: Replace two magic numbers by appropriate enum/define value
belugas
parents:
4547
diff
changeset
|
525 |
if (WP(w,dropdown_d).items[i] != STR_NULL) { |
2639 | 526 |
if (sel == 0) GfxFillRect(x + 1, y, x + w->width - 4, y + 9, 0); |
3762
91f23249d987
(svn r4753) - Truncate text in dropdown lists to stop text overflowing.
peter1138
parents:
2952
diff
changeset
|
527 |
DrawStringTruncated(x + 2, y, WP(w,dropdown_d).items[i], sel == 0 ? 12 : 16, w->width - 4); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
528 |
|
2683
ca9645a21734
(svn r3225) - Fix for "[ 1359165 ] Autoreplace problem with r3171 and later" -- Move the disabled/hidden bits to custom data in window struct.
peter1138
parents:
2642
diff
changeset
|
529 |
if (HASBIT(WP(w,dropdown_d).disabled_state, i)) { |
2639 | 530 |
GfxFillRect(x, y, x + w->width - 3, y + 9, |
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
531 |
PALETTE_MODIFIER_GREYOUT | _colour_gradient[_dropdown_menu_widgets[0].color][5] |
2639 | 532 |
); |
842 | 533 |
} |
1177
9a250d8f0794
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
534 |
} else { |
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
535 |
int c1 = _colour_gradient[_dropdown_menu_widgets[0].color][3]; |
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4438
diff
changeset
|
536 |
int c2 = _colour_gradient[_dropdown_menu_widgets[0].color][7]; |
2639 | 537 |
|
538 |
GfxFillRect(x + 1, y + 3, x + w->width - 5, y + 3, c1); |
|
539 |
GfxFillRect(x + 1, y + 4, x + w->width - 5, y + 4, c2); |
|
842 | 540 |
} |
1177
9a250d8f0794
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
541 |
y += 10; |
9a250d8f0794
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
542 |
sel--; |
842 | 543 |
} |
544 |
} break; |
|
545 |
||
546 |
case WE_CLICK: { |
|
547 |
item = GetDropdownItem(w); |
|
548 |
if (item >= 0) { |
|
2636
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
549 |
WP(w,dropdown_d).click_delay = 4; |
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
550 |
WP(w,dropdown_d).selected_index = item; |
842 | 551 |
SetWindowDirty(w); |
552 |
} |
|
553 |
} break; |
|
554 |
||
555 |
case WE_MOUSELOOP: { |
|
2636
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
556 |
Window *w2 = FindWindowById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num); |
842 | 557 |
if (w2 == NULL) { |
558 |
DeleteWindow(w); |
|
559 |
return; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
560 |
} |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
561 |
|
2636
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
562 |
if (WP(w,dropdown_d).click_delay != 0 && --WP(w,dropdown_d).click_delay == 0) { |
842 | 563 |
WindowEvent e; |
564 |
e.event = WE_DROPDOWN_SELECT; |
|
2636
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
565 |
e.dropdown.button = WP(w,dropdown_d).parent_button; |
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
566 |
e.dropdown.index = WP(w,dropdown_d).selected_index; |
842 | 567 |
w2->wndproc(w2, &e); |
568 |
DeleteWindow(w); |
|
569 |
return; |
|
570 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
571 |
|
2636
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
572 |
if (WP(w,dropdown_d).drag_mode) { |
842 | 573 |
item = GetDropdownItem(w); |
574 |
||
575 |
if (!_left_button_clicked) { |
|
2636
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
576 |
WP(w,dropdown_d).drag_mode = false; |
2639 | 577 |
if (item < 0) return; |
2636
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
578 |
WP(w,dropdown_d).click_delay = 2; |
842 | 579 |
} else { |
2639 | 580 |
if (item < 0) return; |
842 | 581 |
} |
582 |
||
2636
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
583 |
WP(w,dropdown_d).selected_index = item; |
842 | 584 |
SetWindowDirty(w); |
585 |
} |
|
586 |
} break; |
|
587 |
||
588 |
case WE_DESTROY: { |
|
2636
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
589 |
Window *w2 = FindWindowById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num); |
842 | 590 |
if (w2 != NULL) { |
2636
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
591 |
CLRBIT(w2->click_state, WP(w,dropdown_d).parent_button); |
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
592 |
InvalidateWidget(w2, WP(w,dropdown_d).parent_button); |
842 | 593 |
} |
594 |
} break; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
595 |
} |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
596 |
} |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
597 |
|
2448
1a07657c9f9a
(svn r2974) -Fix: Drag and drop selection on drop down boxes didn't select correct item when some items were hidden.
peter1138
parents:
2436
diff
changeset
|
598 |
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask) |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
599 |
{ |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
600 |
WindowNumber num; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
601 |
WindowClass cls; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
602 |
int i; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
603 |
const Widget *wi; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
604 |
Window *w2; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
605 |
uint32 old_click_state = w->click_state; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
606 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
607 |
cls = w->window_class; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
608 |
num = w->window_number; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
609 |
DeleteWindowById(WC_DROPDOWN_MENU, 0); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
610 |
w = FindWindowById(cls, num); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
611 |
|
2639 | 612 |
if (HASBIT(old_click_state, button)) return; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
613 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
614 |
SETBIT(w->click_state, button); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
615 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
616 |
InvalidateWidget(w, button); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
617 |
|
2639 | 618 |
for (i = 0; strings[i] != INVALID_STRING_ID; i++) {} |
619 |
if (i == 0) return; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
620 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
621 |
wi = &w->widget[button]; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
622 |
|
2448
1a07657c9f9a
(svn r2974) -Fix: Drag and drop selection on drop down boxes didn't select correct item when some items were hidden.
peter1138
parents:
2436
diff
changeset
|
623 |
if (hidden_mask != 0) { |
2639 | 624 |
uint j; |
625 |
||
2636
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
626 |
for (j = 0; strings[j] != INVALID_STRING_ID; j++) { |
2639 | 627 |
if (HASBIT(hidden_mask, j)) i--; |
842 | 628 |
} |
629 |
} |
|
630 |
||
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
631 |
w2 = AllocateWindow( |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
632 |
w->left + wi[-1].left + 1, |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
633 |
w->top + wi->bottom + 2, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
634 |
wi->right - wi[-1].left + 1, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
635 |
i * 10 + 4, |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
636 |
DropdownMenuWndProc, |
4573
92032cec7021
(svn r6423) -Codechange: Replace two magic numbers by appropriate enum/define value
belugas
parents:
4547
diff
changeset
|
637 |
WC_DROPDOWN_MENU, |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
638 |
_dropdown_menu_widgets); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
639 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
640 |
w2->widget[0].color = wi->color; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
641 |
w2->widget[0].right = wi->right - wi[-1].left; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
642 |
w2->widget[0].bottom = i * 10 + 3; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
643 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
644 |
w2->flags4 &= ~WF_WHITE_BORDER_MASK; |
2629
78f87f273407
(svn r3171) - Codechange: remove static _dropdown_disabled/_dropdown_hidden variables, as a window already contains this information.
peter1138
parents:
2597
diff
changeset
|
645 |
|
2683
ca9645a21734
(svn r3225) - Fix for "[ 1359165 ] Autoreplace problem with r3171 and later" -- Move the disabled/hidden bits to custom data in window struct.
peter1138
parents:
2642
diff
changeset
|
646 |
WP(w2,dropdown_d).disabled_state = disabled_mask; |
ca9645a21734
(svn r3225) - Fix for "[ 1359165 ] Autoreplace problem with r3171 and later" -- Move the disabled/hidden bits to custom data in window struct.
peter1138
parents:
2642
diff
changeset
|
647 |
WP(w2,dropdown_d).hidden_state = hidden_mask; |
2636
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
648 |
|
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
649 |
WP(w2,dropdown_d).parent_wnd_class = w->window_class; |
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
650 |
WP(w2,dropdown_d).parent_wnd_num = w->window_number; |
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
651 |
WP(w2,dropdown_d).parent_button = button; |
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
652 |
|
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
653 |
WP(w2,dropdown_d).num_items = i; |
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
654 |
WP(w2,dropdown_d).selected_index = selected; |
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
655 |
WP(w2,dropdown_d).items = strings; |
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
656 |
|
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
657 |
WP(w2,dropdown_d).click_delay = 0; |
bdff7da76aa2
(svn r3178) - Codechange: move static _dropdown_* vars into the window custom data, giving var1 and var2 more meaningful names.
peter1138
parents:
2629
diff
changeset
|
658 |
WP(w2,dropdown_d).drag_mode = true; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
659 |
} |