author | glx |
Fri, 13 Jun 2008 15:43:39 +0000 | |
branch | noai |
changeset 10955 | 56b381e5253f |
parent 10455 | 22c441f5adf9 |
permissions | -rw-r--r-- |
9724 | 1 |
/* $Id$ */ |
2 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10181
diff
changeset
|
3 |
/** @file dropdown_type.h Types related to the drop down widget. */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10181
diff
changeset
|
4 |
|
9724 | 5 |
#ifndef WIDGETS_DROPDOWN_TYPE_H |
6 |
#define WIDGETS_DROPDOWN_TYPE_H |
|
7 |
||
8 |
#include "../window_type.h" |
|
9 |
#include <list> |
|
10 |
||
11 |
/** |
|
12 |
* Base list item class from which others are derived. If placed in a list it |
|
13 |
* will appear as a horizontal line in the menu. |
|
14 |
*/ |
|
15 |
class DropDownListItem { |
|
16 |
public: |
|
17 |
int result; ///< Result code to return to window on selection |
|
18 |
bool masked; ///< Masked and unselectable item |
|
19 |
||
20 |
DropDownListItem(int result, bool masked) : result(result), masked(masked) {} |
|
21 |
virtual ~DropDownListItem() {} |
|
22 |
virtual StringID String() const; |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9724
diff
changeset
|
23 |
virtual uint Height(uint width) const; |
10181
54df587fef5d
(svn r12712) [NoAI] -Sync with trunk r12672:12711.
rubidium
parents:
10142
diff
changeset
|
24 |
virtual void Draw(int x, int y, uint width, uint height, bool sel) const; |
9724 | 25 |
}; |
26 |
||
27 |
/** |
|
28 |
* Common string list item. |
|
29 |
*/ |
|
30 |
class DropDownListStringItem : public DropDownListItem { |
|
31 |
public: |
|
32 |
StringID string; ///< String ID of item |
|
33 |
||
34 |
DropDownListStringItem(StringID string, int result, bool masked) : DropDownListItem(result, masked), string(string) {} |
|
35 |
virtual ~DropDownListStringItem() {} |
|
36 |
||
37 |
StringID String() const; |
|
38 |
}; |
|
39 |
||
40 |
/** |
|
41 |
* String list item with parameters. |
|
42 |
*/ |
|
43 |
class DropDownListParamStringItem : public DropDownListStringItem { |
|
44 |
public: |
|
45 |
uint64 decode_params[10]; ///< Parameters of the string |
|
46 |
||
47 |
DropDownListParamStringItem(StringID string, int result, bool masked) : DropDownListStringItem(string, result, masked) {} |
|
48 |
virtual ~DropDownListParamStringItem() {} |
|
49 |
||
50 |
StringID String() const; |
|
51 |
void SetParam(uint index, uint64 value) { decode_params[index] = value; } |
|
52 |
}; |
|
53 |
||
54 |
/** |
|
55 |
* A drop down list is a collection of drop down list items. |
|
56 |
*/ |
|
57 |
typedef std::list<DropDownListItem *> DropDownList; |
|
58 |
||
59 |
/** |
|
60 |
* Show a drop down list. |
|
61 |
* @param w Parent window for the list. |
|
62 |
* @param list Prepopulated DropDownList. Will be deleted when the list is |
|
63 |
* closed. |
|
64 |
* @param selected The initially selected list item. |
|
65 |
* @param button The widget within the parent window that is used to determine |
|
66 |
* the list's location. |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9724
diff
changeset
|
67 |
* @param width Override the width determined by the selected widget. |
9724 | 68 |
*/ |
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9724
diff
changeset
|
69 |
void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, uint width = 0); |
9724 | 70 |
|
71 |
#endif /* WIDGETS_DROPDOWN_TYPE_H */ |