|
1 /* $Id$ */ |
|
2 |
|
3 #ifndef WIDGETS_DROPDOWN_TYPE_H |
|
4 #define WIDGETS_DROPDOWN_TYPE_H |
|
5 |
|
6 #include "../window_type.h" |
|
7 #include <list> |
|
8 |
|
9 /** |
|
10 * Base list item class from which others are derived. If placed in a list it |
|
11 * will appear as a horizontal line in the menu. |
|
12 */ |
|
13 class DropDownListItem { |
|
14 public: |
|
15 int result; ///< Result code to return to window on selection |
|
16 bool masked; ///< Masked and unselectable item |
|
17 |
|
18 DropDownListItem(int result, bool masked) : result(result), masked(masked) {} |
|
19 virtual ~DropDownListItem() {} |
|
20 virtual StringID String() const; |
|
21 }; |
|
22 |
|
23 /** |
|
24 * Common string list item. |
|
25 */ |
|
26 class DropDownListStringItem : public DropDownListItem { |
|
27 public: |
|
28 StringID string; ///< String ID of item |
|
29 |
|
30 DropDownListStringItem(StringID string, int result, bool masked) : DropDownListItem(result, masked), string(string) {} |
|
31 virtual ~DropDownListStringItem() {} |
|
32 |
|
33 StringID String() const; |
|
34 }; |
|
35 |
|
36 /** |
|
37 * String list item with parameters. |
|
38 */ |
|
39 class DropDownListParamStringItem : public DropDownListStringItem { |
|
40 public: |
|
41 uint64 decode_params[10]; ///< Parameters of the string |
|
42 |
|
43 DropDownListParamStringItem(StringID string, int result, bool masked) : DropDownListStringItem(string, result, masked) {} |
|
44 virtual ~DropDownListParamStringItem() {} |
|
45 |
|
46 StringID String() const; |
|
47 void SetParam(uint index, uint64 value) { decode_params[index] = value; } |
|
48 }; |
|
49 |
|
50 /** |
|
51 * A drop down list is a collection of drop down list items. |
|
52 */ |
|
53 typedef std::list<DropDownListItem *> DropDownList; |
|
54 |
|
55 /** |
|
56 * Show a drop down list. |
|
57 * @param w Parent window for the list. |
|
58 * @param list Prepopulated DropDownList. Will be deleted when the list is |
|
59 * closed. |
|
60 * @param selected The initially selected list item. |
|
61 * @param button The widget within the parent window that is used to determine |
|
62 * the list's location. |
|
63 */ |
|
64 void ShowDropDownList(Window *w, DropDownList *list, int selected, int button); |
|
65 |
|
66 #endif /* WIDGETS_DROPDOWN_TYPE_H */ |