author | richk |
Wed, 16 Apr 2008 22:16:04 +0000 | |
branch | NewGRF_ports |
changeset 10210 | a2131f7a315d |
parent 10200 | aba3af04cdbd |
child 10724 | 68a692eacf22 |
permissions | -rw-r--r-- |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
1 |
/* $Id$ */ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
2 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
3 |
#ifndef WIDGETS_DROPDOWN_TYPE_H |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
4 |
#define WIDGETS_DROPDOWN_TYPE_H |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
5 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
6 |
#include "../window_type.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
7 |
#include <list> |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
8 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
9 |
/** |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
10 |
* Base list item class from which others are derived. If placed in a list it |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
11 |
* will appear as a horizontal line in the menu. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
12 |
*/ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
13 |
class DropDownListItem { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
14 |
public: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
15 |
int result; ///< Result code to return to window on selection |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
16 |
bool masked; ///< Masked and unselectable item |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
17 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
18 |
DropDownListItem(int result, bool masked) : result(result), masked(masked) {} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
19 |
virtual ~DropDownListItem() {} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
20 |
virtual StringID String() const; |
10200
aba3af04cdbd
(svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents:
10184
diff
changeset
|
21 |
virtual uint Height(uint width) const; |
10210
a2131f7a315d
(svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents:
10200
diff
changeset
|
22 |
virtual void Draw(int x, int y, uint width, uint height, bool sel) const; |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
23 |
}; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
24 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
25 |
/** |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
26 |
* Common string list item. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
27 |
*/ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
28 |
class DropDownListStringItem : public DropDownListItem { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
29 |
public: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
30 |
StringID string; ///< String ID of item |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
31 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
32 |
DropDownListStringItem(StringID string, int result, bool masked) : DropDownListItem(result, masked), string(string) {} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
33 |
virtual ~DropDownListStringItem() {} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
34 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
35 |
StringID String() const; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
36 |
}; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
37 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
38 |
/** |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
39 |
* String list item with parameters. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
40 |
*/ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
41 |
class DropDownListParamStringItem : public DropDownListStringItem { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
42 |
public: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
43 |
uint64 decode_params[10]; ///< Parameters of the string |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
44 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
45 |
DropDownListParamStringItem(StringID string, int result, bool masked) : DropDownListStringItem(string, result, masked) {} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
46 |
virtual ~DropDownListParamStringItem() {} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
47 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
48 |
StringID String() const; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
49 |
void SetParam(uint index, uint64 value) { decode_params[index] = value; } |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
50 |
}; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
51 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
52 |
/** |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
53 |
* A drop down list is a collection of drop down list items. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
54 |
*/ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
55 |
typedef std::list<DropDownListItem *> DropDownList; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
56 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
57 |
/** |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
58 |
* Show a drop down list. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
59 |
* @param w Parent window for the list. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
60 |
* @param list Prepopulated DropDownList. Will be deleted when the list is |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
61 |
* closed. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
62 |
* @param selected The initially selected list item. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
63 |
* @param button The widget within the parent window that is used to determine |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
64 |
* the list's location. |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6872
diff
changeset
|
65 |
* @param width Override the width determined by the selected widget. |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
66 |
*/ |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6872
diff
changeset
|
67 |
void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, uint width = 0); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
68 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
diff
changeset
|
69 |
#endif /* WIDGETS_DROPDOWN_TYPE_H */ |