widget.c
author peter1138
Fri, 03 Nov 2006 23:29:24 +0000
changeset 5017 3df5ce293696
parent 4940 d021a1285a5f
child 5041 674e5e1b4ad4
permissions -rw-r--r--
(svn r7058) -Codechange: Truncate text in window captions
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
	Point pt;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
	int height, count, pos, cap;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
	top += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
	bottom -= 9;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    20
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
	height = (bottom - top);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    23
	pos = sb->pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
	count = sb->count;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
	cap = sb->cap;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
2026
567e3bc9af72 (svn r2535) Tabs
tron
parents: 2021
diff changeset
    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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
	if (cap > count) cap = count;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
    30
	if (count != 0) bottom -= (count - pos - cap) * height / count;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
	pt.x = top;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
	pt.y = bottom - 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
	return pt;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
/*****************************************************
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
 * Special handling for the scrollbar widget type.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
 * Handles the special scrolling buttons and other
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
 * scrolling.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
 * Parameters:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
 *   w   - Window.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
 *   wi  - Pointer to the scrollbar widget.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
 *   x   - The X coordinate of the mouse click.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
 *   y   - The Y coordinate of the mouse click.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
 */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
	int mi, ma, pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
	Scrollbar *sb;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    53
	switch (wi->type) {
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    54
		case WWT_SCROLLBAR: {
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    55
			// vertical scroller
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    56
			w->flags4 &= ~WF_HSCROLL;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    57
			w->flags4 &= ~WF_SCROLL2;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    58
			mi = wi->top;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    59
			ma = wi->bottom;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    60
			pos = y;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    61
			sb = &w->vscroll;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    62
			break;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    63
		}
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    64
		case WWT_SCROLL2BAR: {
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    65
			// 2nd vertical scroller
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    66
			w->flags4 &= ~WF_HSCROLL;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    67
			w->flags4 |= WF_SCROLL2;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    68
			mi = wi->top;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    69
			ma = wi->bottom;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    70
			pos = y;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    71
			sb = &w->vscroll2;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    72
			break;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    73
		}
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    74
		case  WWT_HSCROLLBAR: {
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    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
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    77
			w->flags4 |= WF_HSCROLL;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    78
			mi = wi->left;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    79
			ma = wi->right;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    80
			pos = x;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    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
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
	if (pos <= mi+9) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
		// Pressing the upper button?
2597
b806dafa9be6 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    88
		w->flags4 |= WF_SCROLL_UP;
b806dafa9be6 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    89
		if (_scroller_click_timeout == 0) {
b806dafa9be6 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    90
			_scroller_click_timeout = 6;
b806dafa9be6 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    91
			if (sb->pos != 0) sb->pos--;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
		}
2597
b806dafa9be6 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    93
		_left_button_clicked = false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	} else if (pos >= ma-10) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
		// Pressing the lower button?
2597
b806dafa9be6 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    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
b806dafa9be6 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    98
		if (_scroller_click_timeout == 0) {
b806dafa9be6 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    99
			_scroller_click_timeout = 6;
b806dafa9be6 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
   100
			if ((byte)(sb->pos + sb->cap) < sb->count)
b806dafa9be6 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
   101
				sb->pos++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
		}
2597
b806dafa9be6 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
   103
		_left_button_clicked = false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
	} else {
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   105
		//
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
		Point pt = HandleScrollbarHittest(sb, mi, ma);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
		if (pos < pt.x) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
			sb->pos = max(sb->pos - sb->cap, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
		} else if (pos > pt.y) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
				max(sb->count - sb->cap, 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
			);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
			_scrollbar_start_pos = pt.x - mi - 9;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
			_scrollbar_size = ma - mi - 23;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
			w->flags4 |= WF_SCROLL_MIDDLE;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
			_scrolling_scrollbar = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
			_cursorpos_drag_start = _cursor.pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
	SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
	const Widget *wi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
	int index, found_index = -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
	// Go through the widgets and check if we find the widget that the coordinate is
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   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
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   141
		if (wi->type == WWT_EMPTY || wi->type == WWT_FRAME) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   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 &&
4749
65a49cfc922d (svn r6661) Feature: Windows are not restricted to 32 widget items anymore.
belugas
parents: 4719
diff changeset
   144
				!IsWidgetHidden(wi)) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   145
			found_index = index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
	return found_index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
	Rect r;
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4634
diff changeset
   190
	int i = 0;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   191
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
	wi = w->widget;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
	do {
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4634
diff changeset
   195
		bool clicked = IsWindowWidgetLowered((Window*)w, i);
1657
af84fedacc6d (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   196
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
		if (dpi->left > (r.right=/*w->left + */wi->right) ||
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   198
				dpi->left + dpi->width <= (r.left=wi->left/* + w->left*/) ||
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
				dpi->top > (r.bottom=/*w->top +*/ wi->bottom) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
				dpi->top + dpi->height <= (r.top = /*w->top +*/ wi->top) ||
4749
65a49cfc922d (svn r6661) Feature: Windows are not restricted to 32 widget items anymore.
belugas
parents: 4719
diff changeset
   201
				IsWidgetHidden(wi)) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   202
			continue;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   203
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
1657
af84fedacc6d (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   205
		switch (wi->type & WWT_MASK) {
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4749
diff changeset
   206
		case WWT_IMGBTN:
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4749
diff changeset
   207
		case WWT_IMGBTN_2: {
4547
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4444
diff changeset
   208
			int img = wi->data;
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4749
diff changeset
   209
			assert(img != 0);
1938
70baf462aff1 (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   210
			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4749
diff changeset
   212
			/* show different image when clicked for WWT_IMGBTN_2 */
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4749
diff changeset
   213
			if ((wi->type & WWT_MASK) == WWT_IMGBTN_2 && clicked) img++;
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4749
diff changeset
   214
			DrawSprite(img, r.left + 1 + clicked, r.top + 1 + clicked);
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4749
diff changeset
   215
			goto draw_default;
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4749
diff changeset
   216
		}
1657
af84fedacc6d (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   217
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4749
diff changeset
   218
		case WWT_PANEL: {
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4749
diff changeset
   219
			assert(wi->data == 0);
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4749
diff changeset
   220
			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
			goto draw_default;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
4939
bef7c24a6027 (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4938
diff changeset
   224
		case WWT_TEXTBTN:
bef7c24a6027 (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4938
diff changeset
   225
		case WWT_TEXTBTN_2: {
1938
70baf462aff1 (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   226
			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
		/* fall through */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
4345
1da147230c79 (svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents: 3762
diff changeset
   230
		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
   231
			StringID str = wi->data;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
4939
bef7c24a6027 (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4938
diff changeset
   233
			if ((wi->type & WWT_MASK) == WWT_TEXTBTN_2 && clicked) str++;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   234
1657
af84fedacc6d (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   235
			DrawStringCentered(((r.left + r.right + 1) >> 1) + clicked, ((r.top + r.bottom + 1) >> 1) - 5 + clicked, 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
   236
			goto draw_default;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
4939
bef7c24a6027 (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4938
diff changeset
   239
		case WWT_INSET: {
4547
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4444
diff changeset
   240
			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
   241
			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_LOWERED | FR_DARKENED);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
4547
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4444
diff changeset
   243
			if (str != STR_NULL) DrawStringTruncated(r.left + 2, r.top + 1, str, 0, r.right - r.left - 10);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
			goto draw_default;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
		case WWT_MATRIX: {
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   248
			int c, d, ctr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
			int x, amt1, amt2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
			int color;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   251
1938
70baf462aff1 (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   252
			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
   253
4547
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4444
diff changeset
   254
			c = GB(wi->data, 0, 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
			amt1 = (wi->right - wi->left + 1) / c;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
4547
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4444
diff changeset
   257
			d = GB(wi->data, 8, 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
			amt2 = (wi->bottom - wi->top + 1) / d;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4438
diff changeset
   260
			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
   261
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
			x = r.left;
2801
b9062d829629 (svn r3349) Fix off-by-one error in drawing matrix widget, from r3181.
peter1138
parents: 2757
diff changeset
   263
			for (ctr = c; ctr > 1; ctr--) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
				x += amt1;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   265
				GfxFillRect(x, r.top + 1, x, r.bottom - 1, color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
			x = r.top;
2801
b9062d829629 (svn r3349) Fix off-by-one error in drawing matrix widget, from r3181.
peter1138
parents: 2757
diff changeset
   269
			for (ctr = d; ctr > 1; ctr--) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
				x += amt2;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   271
				GfxFillRect(r.left + 1, x, r.right - 1, x, color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4438
diff changeset
   274
			color = _colour_gradient[wi->color&0xF][4];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   276
			x = r.left - 1;
2801
b9062d829629 (svn r3349) Fix off-by-one error in drawing matrix widget, from r3181.
peter1138
parents: 2757
diff changeset
   277
			for (ctr = c; ctr > 1; ctr--) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
				x += amt1;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   279
				GfxFillRect(x, r.top + 1, x, r.bottom - 1, color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   282
			x = r.top - 1;
2801
b9062d829629 (svn r3349) Fix off-by-one error in drawing matrix widget, from r3181.
peter1138
parents: 2757
diff changeset
   283
			for (ctr = d; ctr > 1; ctr--) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
				x += amt2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
				GfxFillRect(r.left+1, x, r.right-1, x, color);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   288
			goto draw_default;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
		// vertical scrollbar
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
		case WWT_SCROLLBAR: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
			Point pt;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
			int c1,c2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
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
   296
			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
   297
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
			// draw up/down buttons
4940
d021a1285a5f (svn r6927) -Codechange: No need to explicitly cast a boolean to a boolean and move draw_default
Darkvater
parents: 4939
diff changeset
   299
			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
   300
			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
   301
			DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, 0x10);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
4940
d021a1285a5f (svn r6927) -Codechange: No need to explicitly cast a boolean to a boolean and move draw_default
Darkvater
parents: 4939
diff changeset
   303
			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
   304
			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
   305
			DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4438
diff changeset
   307
			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
   308
			c2 = _colour_gradient[wi->color&0xF][7];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
			// draw "shaded" background
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
			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
   312
			GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | PALETTE_MODIFIER_GREYOUT);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
			// draw shaded lines
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
			GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
			GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
			GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
			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
   319
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
			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
   321
			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
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   322
			break;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   323
		}
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   324
		case WWT_SCROLL2BAR: {
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   325
			Point pt;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   326
			int c1,c2;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   327
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
   328
			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
   329
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   330
			// draw up/down buttons
4940
d021a1285a5f (svn r6927) -Codechange: No need to explicitly cast a boolean to a boolean and move draw_default
Darkvater
parents: 4939
diff changeset
   331
			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
   332
			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
   333
			DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, 0x10);
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   334
4940
d021a1285a5f (svn r6927) -Codechange: No need to explicitly cast a boolean to a boolean and move draw_default
Darkvater
parents: 4939
diff changeset
   335
			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
   336
			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
   337
			DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10);
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   338
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4438
diff changeset
   339
			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
   340
			c2 = _colour_gradient[wi->color&0xF][7];
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   341
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   342
			// draw "shaded" background
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   343
			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
   344
			GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | PALETTE_MODIFIER_GREYOUT);
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   345
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   346
			// draw shaded lines
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   347
			GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   348
			GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   349
			GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   350
			GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   351
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   352
			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
   353
			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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
		// horizontal scrollbar
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
		case WWT_HSCROLLBAR: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
			Point pt;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
			int c1,c2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
894
8b59c639837d (svn r1380) -Fix: missed widget fixes; thanks Jango and TestMan57
darkvater
parents: 893
diff changeset
   362
			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
   363
4940
d021a1285a5f (svn r6927) -Codechange: No need to explicitly cast a boolean to a boolean and move draw_default
Darkvater
parents: 4939
diff changeset
   364
			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
   365
			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
   366
			DrawSprite(SPR_ARROW_LEFT, r.left + 1 + clicked, r.top + 1 + clicked);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
4940
d021a1285a5f (svn r6927) -Codechange: No need to explicitly cast a boolean to a boolean and move draw_default
Darkvater
parents: 4939
diff changeset
   368
			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
   369
			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
   370
			DrawSprite(SPR_ARROW_RIGHT, r.right - 8 + clicked, r.top + 1 + clicked);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4438
diff changeset
   372
			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
   373
			c2 = _colour_gradient[wi->color&0xF][7];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
			// draw "shaded" background
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
			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
   377
			GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c1 | PALETTE_MODIFIER_GREYOUT);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
			// draw shaded lines
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
			GfxFillRect(r.left+10, r.top+2, r.right-10, r.top+2, c1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
			GfxFillRect(r.left+10, r.top+3, r.right-10, r.top+3, c2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
			GfxFillRect(r.left+10, r.top+7, r.right-10, r.top+7, c1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
			GfxFillRect(r.left+10, r.top+8, r.right-10, r.top+8, c2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
			// draw actual scrollbar
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
			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
   387
			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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   389
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   390
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
		case WWT_FRAME: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
			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
   394
			int x2 = r.left; // by default the left side is the left side of the widget
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
4547
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4444
diff changeset
   396
			if (wi->data != 0) x2 = DrawString(r.left + 6, r.top, wi->data, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4438
diff changeset
   398
			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
   399
			c2 = _colour_gradient[wi->color][7];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
			//Line from upper left corner to start of text
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
			GfxFillRect(r.left, r.top+4, r.left+4,r.top+4, c1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
			GfxFillRect(r.left+1, r.top+5, r.left+4,r.top+5, c2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
			// Line from end of text to upper right corner
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
			GfxFillRect(x2, r.top+4, r.right-1,r.top+4,c1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   407
			GfxFillRect(x2, r.top+5, r.right-2,r.top+5,c2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
			// Line from upper left corner to bottom left corner
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
			GfxFillRect(r.left, r.top+5, r.left, r.bottom-1, c1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
			GfxFillRect(r.left+1, r.top+6, r.left+1, r.bottom-2, c2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
			//Line from upper right corner to bottom right corner
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
			GfxFillRect(r.right-1, r.top+5, r.right-1, r.bottom-2, c1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
			GfxFillRect(r.right, r.top+4, r.right, r.bottom-1, c2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
			GfxFillRect(r.left+1, r.bottom-1, r.right-1, r.bottom-1, c1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   418
			GfxFillRect(r.left, r.bottom, r.right, r.bottom, c2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
2064
e6a2b42d0b15 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2026
diff changeset
   420
			goto draw_default;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
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
   423
		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
   424
			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
   425
a969970a5245 (svn r3247) - Fix: "[ 1335580 ] sticky windows not sticky anymore"
peter1138
parents: 2683
diff changeset
   426
			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
   427
			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
   428
			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
   429
			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
   430
		}
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   431
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   432
		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
   433
			assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
915
d845fe7cf6f2 (svn r1402) Trim trailing whitespace
tron
parents: 894
diff changeset
   434
1657
af84fedacc6d (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   435
			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
   436
			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
   437
			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
   438
			break;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   439
		}
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   440
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
   441
		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
   442
			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
   443
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
			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
   445
			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
   446
			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
   447
		}
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
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
		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
   450
			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
   451
			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
   452
			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
   453
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
			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
   455
				GfxFillRect(r.left+2, r.top+2, r.right-2, r.bottom-2, _colour_gradient[_player_colors[w->caption_color]][4]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   457
5017
3df5ce293696 (svn r7058) -Codechange: Truncate text in window captions
peter1138
parents: 4940
diff changeset
   458
			DrawStringCenteredTruncated(r.left + 2, r.right - 2, r.top+2, wi->data, 0x84);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   459
draw_default:;
4749
65a49cfc922d (svn r6661) Feature: Windows are not restricted to 32 widget items anymore.
belugas
parents: 4719
diff changeset
   460
			if (IsWidgetDisabled(wi)) {
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4438
diff changeset
   461
				GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _colour_gradient[wi->color&0xF][2] | PALETTE_MODIFIER_GREYOUT);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   463
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
		}
4749
65a49cfc922d (svn r6661) Feature: Windows are not restricted to 32 widget items anymore.
belugas
parents: 4719
diff changeset
   465
	} while (i++, (++wi)->type != WWT_LAST);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   466
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
	if (w->flags4 & WF_WHITE_BORDER_MASK) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
		//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
   470
		DrawFrameRect(0, 0, w->width-1, w->height-1, 0xF, FR_BORDERONLY);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
}
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
   474
883
9bfde7bab1f9 (svn r1368) -Fix: Disabled dropdown menu options are gray again (instead of blue)
truelight
parents: 876
diff changeset
   475
static const Widget _dropdown_menu_widgets[] = {
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4749
diff changeset
   476
{      WWT_PANEL,   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
   477
{   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
   478
};
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
   479
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
   480
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
   481
{
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
   482
	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
   483
	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
   484
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
	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
   486
		return -1;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   487
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
   488
	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
   489
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
	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
   491
		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
   492
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
	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
   494
	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
   495
		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
   496
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
   497
	// 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
   498
	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
   499
		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
   500
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
   501
	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
   502
}
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
1095
b59632d9df1b (svn r1596) Add some more statics
tron
parents: 915
diff changeset
   504
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
   505
{
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
   506
	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
   507
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2801
diff changeset
   508
	switch (e->event) {
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   509
		case WE_PAINT: {
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   510
			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
   511
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   512
			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
   513
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   514
			x = 1;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   515
			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
   516
			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
   517
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
			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
   519
				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
   520
					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
   521
					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
   522
				}
4573
92032cec7021 (svn r6423) -Codechange: Replace two magic numbers by appropriate enum/define value
belugas
parents: 4547
diff changeset
   523
				if (WP(w,dropdown_d).items[i] != STR_NULL) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   524
					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
   525
					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
   526
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
   527
					if (HASBIT(WP(w,dropdown_d).disabled_state, i)) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   528
						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
   529
							PALETTE_MODIFIER_GREYOUT | _colour_gradient[_dropdown_menu_widgets[0].color][5]
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   530
						);
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   531
					}
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
   532
				} else {
4444
8d40844e6755 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4438
diff changeset
   533
					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
   534
					int c2 = _colour_gradient[_dropdown_menu_widgets[0].color][7];
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   535
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   536
					GfxFillRect(x + 1, y + 3, x + w->width - 5, y + 3, c1);
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   537
					GfxFillRect(x + 1, y + 4, x + w->width - 5, y + 4, c2);
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   538
				}
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
   539
				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
   540
				sel--;
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   541
			}
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   542
		} break;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   543
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   544
		case WE_CLICK: {
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   545
			item = GetDropdownItem(w);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   546
			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
   547
				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
   548
				WP(w,dropdown_d).selected_index = item;
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   549
				SetWindowDirty(w);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   550
			}
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   551
		} break;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   552
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   553
		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
   554
			Window *w2 = FindWindowById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   555
			if (w2 == NULL) {
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   556
				DeleteWindow(w);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   557
				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
   558
			}
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
   559
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
   560
			if (WP(w,dropdown_d).click_delay != 0 && --WP(w,dropdown_d).click_delay == 0) {
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   561
				WindowEvent e;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   562
				e.event = WE_DROPDOWN_SELECT;
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4573
diff changeset
   563
				e.we.dropdown.button = WP(w,dropdown_d).parent_button;
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4573
diff changeset
   564
				e.we.dropdown.index  = WP(w,dropdown_d).selected_index;
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   565
				w2->wndproc(w2, &e);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   566
				DeleteWindow(w);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   567
				return;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   568
			}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   569
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
   570
			if (WP(w,dropdown_d).drag_mode) {
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   571
				item = GetDropdownItem(w);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   572
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   573
				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
   574
					WP(w,dropdown_d).drag_mode = false;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   575
					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
   576
					WP(w,dropdown_d).click_delay = 2;
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   577
				} else {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   578
					if (item < 0) return;
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   579
				}
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   580
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
   581
				WP(w,dropdown_d).selected_index = item;
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   582
				SetWindowDirty(w);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   583
			}
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   584
		} break;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   585
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   586
		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
   587
			Window *w2 = FindWindowById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   588
			if (w2 != NULL) {
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4634
diff changeset
   589
				RaiseWindowWidget(w2, WP(w,dropdown_d).parent_button);
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
   590
				InvalidateWidget(w2, WP(w,dropdown_d).parent_button);
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   591
			}
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   592
		} 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
   593
	}
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
   594
}
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
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
   596
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
   597
{
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
   598
	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
   599
	WindowClass cls;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   600
	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
   601
	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
   602
	Window *w2;
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4634
diff changeset
   603
	bool is_dropdown_menu_shown = IsWindowWidgetLowered(w, button);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   604
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
   605
	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
   606
	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
   607
	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
   608
	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
   609
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4634
diff changeset
   610
	if (is_dropdown_menu_shown) 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
   611
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4634
diff changeset
   612
	LowerWindowWidget(w, button);
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
	InvalidateWidget(w, button);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   615
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   616
	for (i = 0; strings[i] != INVALID_STRING_ID; i++) {}
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   617
	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
   618
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
   619
	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
   620
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
   621
	if (hidden_mask != 0) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   622
		uint j;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   623
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
   624
		for (j = 0; strings[j] != INVALID_STRING_ID; j++) {
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2636
diff changeset
   625
			if (HASBIT(hidden_mask, j)) i--;
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   626
		}
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   627
	}
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   628
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
   629
	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
   630
		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
   631
		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
   632
		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
   633
		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
   634
		DropdownMenuWndProc,
4573
92032cec7021 (svn r6423) -Codechange: Replace two magic numbers by appropriate enum/define value
belugas
parents: 4547
diff changeset
   635
		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
   636
		_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
   637
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   638
	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
   639
	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
   640
	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
   641
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
   642
	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
   643
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
   644
	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
   645
	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
   646
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
   647
	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
   648
	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
   649
	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
   650
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).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
   652
	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
   653
	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
   654
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).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
   656
	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
   657
}