widget.c
author peter1138
Sat, 12 Nov 2005 11:10:12 +0000
changeset 2629 842a290af2fb
parent 2597 68ffedae1eb5
child 2636 e2bfdc3e82b6
permissions -rw-r--r--
(svn r3171) - Codechange: remove static _dropdown_disabled/_dropdown_hidden variables, as a window already contains this information.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (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
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1657
diff changeset
     4
#include "openttd.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2154
diff changeset
     5
#include "functions.h"
2154
63a6b880b4c0 (svn r2664) Remove depedency on player.h from variables.h
tron
parents: 2064
diff changeset
     6
#include "player.h"
1363
01d3de5d8039 (svn r1867) Include tables/sprites.h only in files which need it
tron
parents: 1177
diff changeset
     7
#include "table/sprites.h"
507
8aa8100b0b22 (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
177cb6a8339f (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
02dfa0aa2c2f (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;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
	if (count != 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
		bottom -= (count - pos - cap) * height / count;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
	pt.x = top;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
	pt.y = bottom - 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
	return pt;
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
/*****************************************************
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
 * Special handling for the scrollbar widget type.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
 * Handles the special scrolling buttons and other
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
 * scrolling.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
 * Parameters:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
 *   w   - Window.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
 *   wi  - Pointer to the scrollbar widget.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
 *   x   - The X coordinate of the mouse click.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
 *   y   - The Y coordinate of the mouse click.
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
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
    50
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
	int mi, ma, pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
	Scrollbar *sb;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    54
	switch (wi->type) {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    55
		case WWT_SCROLLBAR: {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    56
			// vertical scroller
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    57
			w->flags4 &= ~WF_HSCROLL;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    58
			w->flags4 &= ~WF_SCROLL2;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    59
			mi = wi->top;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    60
			ma = wi->bottom;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    61
			pos = y;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    62
			sb = &w->vscroll;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    63
			break;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    64
		}
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    65
		case WWT_SCROLL2BAR: {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    66
			// 2nd vertical scroller
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    67
			w->flags4 &= ~WF_HSCROLL;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    68
			w->flags4 |= WF_SCROLL2;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    69
			mi = wi->top;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    70
			ma = wi->bottom;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    71
			pos = y;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    72
			sb = &w->vscroll2;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    73
			break;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    74
		}
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    75
		case  WWT_HSCROLLBAR: {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    76
			// horizontal scroller
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
    77
			w->flags4 &= ~WF_SCROLL2;
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    78
			w->flags4 |= WF_HSCROLL;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    79
			mi = wi->left;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    80
			ma = wi->right;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    81
			pos = x;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    82
			sb = &w->hscroll;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
    83
			break;
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
    84
		}
845
0c66e26fecb2 (svn r1326) fixed compiler warnings in vehicle_gui.c and widget.c
bjarni
parents: 842
diff changeset
    85
		default: return; //this should never happen
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
	if (pos <= mi+9) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
		// Pressing the upper button?
2597
68ffedae1eb5 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    89
		w->flags4 |= WF_SCROLL_UP;
68ffedae1eb5 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    90
		if (_scroller_click_timeout == 0) {
68ffedae1eb5 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    91
			_scroller_click_timeout = 6;
68ffedae1eb5 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    92
			if (sb->pos != 0) sb->pos--;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
		}
2597
68ffedae1eb5 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    94
		_left_button_clicked = false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	} else if (pos >= ma-10) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
		// Pressing the lower button?
2597
68ffedae1eb5 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    97
		w->flags4 |= WF_SCROLL_DOWN;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    98
2597
68ffedae1eb5 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
    99
		if (_scroller_click_timeout == 0) {
68ffedae1eb5 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
   100
			_scroller_click_timeout = 6;
68ffedae1eb5 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
   101
			if ((byte)(sb->pos + sb->cap) < sb->count)
68ffedae1eb5 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
   102
				sb->pos++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
		}
2597
68ffedae1eb5 (svn r3134) Forgot to commit one file in r3133
tron
parents: 2548
diff changeset
   104
		_left_button_clicked = false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
	} else {
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   106
		//
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
		Point pt = HandleScrollbarHittest(sb, mi, ma);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
		if (pos < pt.x) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
			sb->pos = max(sb->pos - sb->cap, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
		} else if (pos > pt.y) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
			sb->pos = min(
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   113
				sb->pos + sb->cap,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
				max(sb->count - sb->cap, 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
			);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
			_scrollbar_start_pos = pt.x - mi - 9;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
			_scrollbar_size = ma - mi - 23;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
			w->flags4 |= WF_SCROLL_MIDDLE;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
			_scrolling_scrollbar = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
			_cursorpos_drag_start = _cursor.pos;
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
	SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
2021
3be628c59488 (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
/** Returns the index for the widget located at the given position
3be628c59488 (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
 * relative to the window. It includes all widget-corner pixels as well.
3be628c59488 (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 *w Window to look inside
3be628c59488 (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
 * @param  x,y Window client coordinates
3be628c59488 (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
   132
 * @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
   133
 */
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2406
diff changeset
   134
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
   135
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
	const Widget *wi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
	int index, found_index = -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
	// 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
   140
	// inside.
2021
3be628c59488 (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
   141
	for (index = 0,wi = w->widget; wi->type != WWT_LAST; index++, wi++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
		if (wi->type == WWT_EMPTY || wi->type == WWT_FRAME)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
			continue;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
2021
3be628c59488 (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
   145
		if (x >= wi->left && x <= wi->right && y >= wi->top &&  y <= wi->bottom &&
3be628c59488 (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
   146
				!HASBIT(w->hidden_state,index)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
				found_index = index;
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
	}
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
	return found_index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2406
diff changeset
   155
void DrawWindowWidgets(const Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
	const Widget *wi;
2548
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2448
diff changeset
   158
	const DrawPixelInfo* dpi = _cur_dpi;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
	Rect r;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
	uint32 cur_click, cur_disabled, cur_hidden;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   161
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
	wi = w->widget;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
	cur_click = w->click_state;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
	cur_disabled = w->disabled_state;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
	cur_hidden = w->hidden_state;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
	do {
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   169
		bool clicked = (cur_click & 1);
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   170
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
		if (dpi->left > (r.right=/*w->left + */wi->right) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
		    dpi->left + dpi->width <= (r.left=wi->left/* + w->left*/) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
				dpi->top > (r.bottom=/*w->top +*/ wi->bottom) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
				dpi->top + dpi->height <= (r.top = /*w->top +*/ wi->top) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
				(cur_hidden&1))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
					continue;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   178
		switch (wi->type & WWT_MASK) {
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   179
		case WWT_PANEL: /* WWT_IMGBTN */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
		case WWT_PANEL_2: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
			int img;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   183
			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
   184
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   185
			if ((img = wi->unkA) != 0) { // has an image
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   186
				if ((wi->type & WWT_MASK) == WWT_PANEL_2 && clicked) img++; // show diff image when clicked
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   187
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   188
				DrawSprite(img, r.left + 1 + clicked, r.top + 1 + clicked);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
			goto draw_default;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   193
		case WWT_CLOSEBOX: /* WWT_TEXTBTN */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
		case WWT_4: {
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   195
			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
   196
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
		/* fall through */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
		case WWT_5: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
			StringID str = wi->unkA;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   202
			if ((wi->type&WWT_MASK) == WWT_4 && clicked) str++;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   203
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   204
			DrawStringCentered(((r.left + r.right + 1) >> 1) + clicked, ((r.top + r.bottom + 1) >> 1) - 5 + clicked, str, 0);
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   205
			//DrawStringCentered((r.left + r.right+1)>>1, ((r.top+r.bottom + 1)>>1) - 5, str, 0);
2064
c889fcc76398 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2026
diff changeset
   206
			goto draw_default;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
		case WWT_6: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
			StringID str;
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   211
			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
   212
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
			if ((str = wi->unkA) != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
				DrawString(r.left+2, r.top+1, str, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
			goto draw_default;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
		case WWT_MATRIX: {
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   220
			int c, d, ctr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
			int x, amt1, amt2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
			int color;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   223
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   224
			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
   225
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
			c = (wi->unkA&0xFF);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
			amt1 = (wi->right - wi->left + 1) / c;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
			d = (wi->unkA >> 8);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
			amt2 = (wi->bottom - wi->top + 1) / d;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
			color = _color_list[wi->color&0xF].window_color_bgb;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   233
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
			x = r.left;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
			for(ctr=c; --ctr; ) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
				x += amt1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
				GfxFillRect(x, r.top+1, x, r.bottom-1, color);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
			x = r.top;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
			for(ctr=d; --ctr; ) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
				x += amt2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
				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
   244
			}
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
			color = _color_list[wi->color&0xF].window_color_1b;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
			x = r.left-1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
			for(ctr=c; --ctr; ) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
				x += amt1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
				GfxFillRect(x, r.top+1, x, r.bottom-1, color);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
			x = r.top-1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
			for(ctr=d; --ctr; ) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
				x += amt2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
				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
   258
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   260
			goto draw_default;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
		// vertical scrollbar
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
		case WWT_SCROLLBAR: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
			Point pt;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
			int c1,c2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
893
d9e69e5060ba (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
   268
			assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
d9e69e5060ba (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
   269
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
			// draw up/down buttons
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   271
			clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP);
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   272
			DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : 0);
2406
be5cfb8cd20d (svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents: 2218
diff changeset
   273
			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
   274
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   275
			clicked = !!(((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN));
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   276
			DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0);
2406
be5cfb8cd20d (svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents: 2218
diff changeset
   277
			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
   278
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
			c1 = _color_list[wi->color&0xF].window_color_1a;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
			c2 = _color_list[wi->color&0xF].window_color_2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
			// draw "shaded" background
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
			GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2);
2218
abd47ef7d902 (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
   284
			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
   285
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
			// draw shaded lines
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
			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
   288
			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
   289
			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
   290
			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
   291
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
			pt = HandleScrollbarHittest(&w->vscroll, r.top, r.bottom);
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   293
			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
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   294
			break;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   295
		}
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   296
		case WWT_SCROLL2BAR: {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   297
			Point pt;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   298
			int c1,c2;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   299
893
d9e69e5060ba (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
   300
			assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
d9e69e5060ba (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
   301
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   302
			// draw up/down buttons
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   303
			clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2));
1938
21bd6ef5f85e (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.top, r.right, r.top + 9, wi->color,  (clicked) ? FR_LOWERED : 0);
2406
be5cfb8cd20d (svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents: 2218
diff changeset
   305
			DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, 0x10);
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   306
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   307
			clicked = !!((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2));
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   308
			DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color,  (clicked) ? FR_LOWERED : 0);
2406
be5cfb8cd20d (svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents: 2218
diff changeset
   309
			DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10);
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   310
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   311
			c1 = _color_list[wi->color&0xF].window_color_1a;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   312
			c2 = _color_list[wi->color&0xF].window_color_2;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   313
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   314
			// draw "shaded" background
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   315
			GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2);
2218
abd47ef7d902 (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
   316
			GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | PALETTE_MODIFIER_GREYOUT);
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   317
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   318
			// draw shaded lines
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   319
			GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   320
			GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   321
			GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   322
			GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   323
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   324
			pt = HandleScrollbarHittest(&w->vscroll2, r.top, r.bottom);
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   325
			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
   326
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
		// horizontal scrollbar
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
		case WWT_HSCROLLBAR: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
			Point pt;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
			int c1,c2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
894
ab8a5f7ea3db (svn r1380) -Fix: missed widget fixes; thanks Jango and TestMan57
darkvater
parents: 893
diff changeset
   334
			assert(r.bottom - r.top == 11); // XXX - to ensure the same sizes are used everywhere!
893
d9e69e5060ba (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
   335
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   336
			clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL));
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   337
			DrawFrameRect(r.left, r.top, r.left + 9, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0);
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   338
			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
   339
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   340
			clicked = !!((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL));
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   341
			DrawFrameRect(r.right-9, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0);
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   342
			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
   343
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
			c1 = _color_list[wi->color&0xF].window_color_1a;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
			c2 = _color_list[wi->color&0xF].window_color_2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
			// draw "shaded" background
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
			GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c2);
2218
abd47ef7d902 (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
   349
			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
   350
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
			// draw shaded lines
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
			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
   353
			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
   354
			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
   355
			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
   356
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
			// draw actual scrollbar
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
			pt = HandleScrollbarHittest(&w->hscroll, r.left, r.right);
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   359
			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
   360
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
		case WWT_FRAME: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
			int c1,c2;
860
d756b3e0e171 (svn r1341) -Fix: fix WWT_FRAME drawing when there is no text there (STR_NULL)
darkvater
parents: 845
diff changeset
   366
			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
   367
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
			if (wi->unkA != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
				x2 = DrawString(r.left+6, r.top, wi->unkA, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
			c1 = _color_list[wi->color].window_color_1a;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
			c2 = _color_list[wi->color].window_color_2;
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
			//Line from upper left corner to start of text
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
			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
   377
			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
   378
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
			// Line from end of text to upper right corner
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
			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
   381
			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
   382
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
			// Line from upper left corner to bottom left corner
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
			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
   385
			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
   386
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
			//Line from upper right corner to bottom right corner
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
			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
   389
			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
   390
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
			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
   392
			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
   393
2064
c889fcc76398 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2026
diff changeset
   394
			goto draw_default;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
682
7f5de4abac85 (svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents: 674
diff changeset
   397
		case WWT_STICKYBOX: {
893
d9e69e5060ba (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
   398
			assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   399
			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0);
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   400
			DrawSprite((clicked) ? SPR_PIN_UP : SPR_PIN_DOWN, r.left + 2 + clicked, r.top + 3 + clicked);
682
7f5de4abac85 (svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents: 674
diff changeset
   401
			break;
7f5de4abac85 (svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents: 674
diff changeset
   402
		}
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   403
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   404
		case WWT_RESIZEBOX: {
893
d9e69e5060ba (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
   405
			assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
915
013cb2d74800 (svn r1402) Trim trailing whitespace
tron
parents: 894
diff changeset
   406
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   407
			clicked = !!(w->flags4 & WF_SIZING);
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   408
			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0);
1657
eb57fee328fb (svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents: 1363
diff changeset
   409
			DrawSprite(SPR_WINDOW_RESIZE, r.left + 3 + clicked, r.top + 3 + clicked);
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   410
			break;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   411
		}
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   412
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
		case WWT_CAPTION: {
893
d9e69e5060ba (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
   414
			assert(r.bottom - r.top == 13); // XXX - to ensure the same sizes are used everywhere!
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   415
			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_BORDERONLY);
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   416
			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
   417
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   418
			if (w->caption_color != 0xFF) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
				GfxFillRect(r.left+2, r.top+2, r.right-2, r.bottom-2, _color_list[_player_colors[w->caption_color]].window_color_1b);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   420
			}
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
			DrawStringCentered( (r.left+r.right+1)>>1, r.top+2, wi->unkA, 0x84);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
draw_default:;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
			if (cur_disabled & 1) {
2218
abd47ef7d902 (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
   425
				GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _color_list[wi->color&0xF].unk2 | PALETTE_MODIFIER_GREYOUT);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   426
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   428
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
	} while (cur_click>>=1, cur_disabled>>=1, cur_hidden >>= 1, (++wi)->type != WWT_LAST);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   430
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
	if (w->flags4 & WF_WHITE_BORDER_MASK) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   433
		//DrawFrameRect(w->left, w->top, w->left + w->width-1, w->top+w->height-1, 0xF, 0x10);
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   434
		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
   435
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   436
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   437
}
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
   438
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
   439
static uint _dropdown_item_count;
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
   440
static const StringID *_dropdown_items;
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
   441
static int _dropdown_selindex;
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
   442
static byte _dropdown_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
   443
static WindowClass _dropdown_windowclass;
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
   444
static WindowNumber _dropdown_windownum;
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
   445
static byte _dropdown_var1;
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
   446
static byte _dropdown_var2;
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
   447
883
0c54c6fc1790 (svn r1368) -Fix: Disabled dropdown menu options are gray again (instead of blue)
truelight
parents: 876
diff changeset
   448
static const Widget _dropdown_menu_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   449
{     WWT_IMGBTN,   RESIZE_NONE,     0,     0, 0,     0, 0, 0x0, STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 164
diff changeset
   450
{   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
   451
};
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
   452
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2406
diff changeset
   453
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
   454
{
2448
0a34e90cb31f (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
   455
	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
   456
	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
   457
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
   458
	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
   459
		return -1;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   460
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
   461
	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
   462
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
   463
	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
   464
		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
   465
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
   466
	item = y / 10;
2629
842a290af2fb (svn r3171) - Codechange: remove static _dropdown_disabled/_dropdown_hidden variables, as a window already contains this information.
peter1138
parents: 2597
diff changeset
   467
	if (item >= _dropdown_item_count || (HASBIT(w->disabled_state, item) && !HASBIT(w->hidden_state, item)) || _dropdown_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
   468
		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
   469
2448
0a34e90cb31f (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
   470
	// Skip hidden items -- +1 for each hidden item before the clicked item.
0a34e90cb31f (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
   471
	for (counter = 0; item >= counter; ++counter)
2629
842a290af2fb (svn r3171) - Codechange: remove static _dropdown_disabled/_dropdown_hidden variables, as a window already contains this information.
peter1138
parents: 2597
diff changeset
   472
		if (HASBIT(w->hidden_state, counter)) item++;
2448
0a34e90cb31f (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
   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
	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
   475
}
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 0
diff changeset
   476
1095
90220990fd7c (svn r1596) Add some more statics
tron
parents: 915
diff changeset
   477
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
   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
	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
   480
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 0
diff changeset
   481
	switch(e->event) {
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   482
		case WE_PAINT: {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   483
			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
   484
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   485
			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
   486
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   487
			x = 1;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   488
			y = 2;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   489
			sel    = _dropdown_selindex;
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 0
diff changeset
   490
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   491
			for(i=0; _dropdown_items[i] != INVALID_STRING_ID; i++) {
2629
842a290af2fb (svn r3171) - Codechange: remove static _dropdown_disabled/_dropdown_hidden variables, as a window already contains this information.
peter1138
parents: 2597
diff changeset
   492
				if (HASBIT(w->hidden_state, i)) {
1177
6adbf59f59a3 (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
   493
					sel--;
6adbf59f59a3 (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
   494
					continue;
6adbf59f59a3 (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
   495
				}
6adbf59f59a3 (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
   496
				if (_dropdown_items[i] != 0) {
6adbf59f59a3 (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
   497
					if (sel == 0) {
6adbf59f59a3 (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
   498
						GfxFillRect(x+1, y, x+w->width-4, y + 9, 0);
6adbf59f59a3 (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
   499
					}
6adbf59f59a3 (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
   500
					DrawString(x+2, y, _dropdown_items[i], sel==0 ? 12 : 16);
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
2629
842a290af2fb (svn r3171) - Codechange: remove static _dropdown_disabled/_dropdown_hidden variables, as a window already contains this information.
peter1138
parents: 2597
diff changeset
   502
					if (HASBIT(w->disabled_state, i)) {
2218
abd47ef7d902 (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
   503
						GfxFillRect(x, y, x+w->width-3, y + 9, PALETTE_MODIFIER_GREYOUT |
1177
6adbf59f59a3 (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
   504
									_color_list[_dropdown_menu_widgets[0].color].window_color_bga);
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   505
					}
1177
6adbf59f59a3 (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
   506
				} else {
6adbf59f59a3 (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
   507
					int color_1 = _color_list[_dropdown_menu_widgets[0].color].window_color_1a;
6adbf59f59a3 (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
   508
					int color_2 = _color_list[_dropdown_menu_widgets[0].color].window_color_2;
6adbf59f59a3 (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
   509
					GfxFillRect(x+1, y+3, x+w->width-5, y+3, color_1);
6adbf59f59a3 (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
   510
					GfxFillRect(x+1, y+4, x+w->width-5, y+4, color_2);
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   511
				}
1177
6adbf59f59a3 (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
   512
				y += 10;
6adbf59f59a3 (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
   513
				sel--;
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   514
			}
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   515
		} break;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   516
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   517
		case WE_CLICK: {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   518
			item = GetDropdownItem(w);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   519
			if (item >= 0) {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   520
				_dropdown_var1 = 4;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   521
				_dropdown_selindex = item;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   522
				SetWindowDirty(w);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   523
			}
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   524
		} break;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   525
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   526
		case WE_MOUSELOOP: {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   527
			Window *w2 = FindWindowById(_dropdown_windowclass, _dropdown_windownum);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   528
			if (w2 == NULL) {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   529
				DeleteWindow(w);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   530
				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
   531
			}
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
   532
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   533
			if (_dropdown_var1 != 0 && --_dropdown_var1 == 0) {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   534
				WindowEvent e;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   535
				e.event = WE_DROPDOWN_SELECT;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   536
				e.dropdown.button = _dropdown_button;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   537
				e.dropdown.index = _dropdown_selindex;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   538
				w2->wndproc(w2, &e);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   539
				DeleteWindow(w);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   540
				return;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   541
			}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   542
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   543
			if (_dropdown_var2 != 0) {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   544
				item = GetDropdownItem(w);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   545
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   546
				if (!_left_button_clicked) {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   547
					_dropdown_var2 = 0;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   548
					if (item < 0)
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   549
						return;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   550
					_dropdown_var1 = 2;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   551
				} else {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   552
					if (item < 0)
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   553
						return;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   554
				}
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   555
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   556
				_dropdown_selindex = item;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   557
				SetWindowDirty(w);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   558
			}
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   559
		} break;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   560
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   561
		case WE_DESTROY: {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   562
			Window *w2 = FindWindowById(_dropdown_windowclass, _dropdown_windownum);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   563
			if (w2 != NULL) {
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   564
				CLRBIT(w2->click_state, _dropdown_button);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   565
				InvalidateWidget(w2, _dropdown_button);
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   566
			}
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   567
		} 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
   568
	}
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
   569
}
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
   570
2448
0a34e90cb31f (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
   571
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
   572
{
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
   573
	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
   574
	WindowClass cls;
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   575
	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
   576
	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
   577
	Window *w2;
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 0
diff changeset
   578
	uint32 old_click_state = w->click_state;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   579
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
   580
	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
   581
	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
   582
	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
   583
	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
   584
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
   585
	if (HASBIT(old_click_state, button))
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 0
diff changeset
   586
		return;
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
   587
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
   588
	SETBIT(w->click_state, button);
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 0
diff changeset
   589
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
   590
	InvalidateWidget(w, button);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   591
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
   592
	for(i=0;strings[i] != INVALID_STRING_ID;i++);
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
	if (i == 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
   594
		return;
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 0
diff changeset
   595
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 0
diff changeset
   596
	_dropdown_items = strings;
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
	_dropdown_selindex = selected;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   598
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 0
diff changeset
   599
	_dropdown_windowclass = 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
   600
	_dropdown_windownum = 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
   601
	_dropdown_button = button;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   602
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 0
diff changeset
   603
	_dropdown_var1 = 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
   604
	_dropdown_var2 = 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
   605
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
	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
   607
2448
0a34e90cb31f (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
   608
	if (hidden_mask != 0) {
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   609
		int j;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   610
		for(j=0; _dropdown_items[j] != INVALID_STRING_ID; j++) {
2448
0a34e90cb31f (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
   611
			if (HASBIT(hidden_mask, j)) {
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   612
				i--;
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   613
			}
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   614
		}
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   615
	}
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 682
diff changeset
   616
2448
0a34e90cb31f (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
   617
	_dropdown_item_count = i;
0a34e90cb31f (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
   618
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
   619
	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
   620
		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
   621
		w->top + wi->bottom + 2,
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   622
		wi->right - wi[-1].left + 1,
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   623
		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
   624
		DropdownMenuWndProc,
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
   625
		0x3F,
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
   626
		_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
   627
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   628
	w2->widget[0].color = wi->color;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   629
	w2->widget[0].right = wi->right - wi[-1].left;
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 860
diff changeset
   630
	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
   631
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 0
diff changeset
   632
	w2->flags4 &= ~WF_WHITE_BORDER_MASK;
2629
842a290af2fb (svn r3171) - Codechange: remove static _dropdown_disabled/_dropdown_hidden variables, as a window already contains this information.
peter1138
parents: 2597
diff changeset
   633
842a290af2fb (svn r3171) - Codechange: remove static _dropdown_disabled/_dropdown_hidden variables, as a window already contains this information.
peter1138
parents: 2597
diff changeset
   634
	w2->disabled_state = disabled_mask;
842a290af2fb (svn r3171) - Codechange: remove static _dropdown_disabled/_dropdown_hidden variables, as a window already contains this information.
peter1138
parents: 2597
diff changeset
   635
	w2->hidden_state = 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
   636
}