author | peter1138 |
Sun, 03 Aug 2008 17:35:08 +0000 | |
changeset 9834 | 7474149531c1 |
parent 9111 | 48ce04029fe4 |
child 9859 | 28606a486c52 |
permissions | -rw-r--r-- |
8284
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
1 |
/* $Id$ */ |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
2 |
|
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8907
diff
changeset
|
3 |
/** @file dropdown_type.h Types related to the drop down widget. */ |
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8907
diff
changeset
|
4 |
|
8284
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
5 |
#ifndef WIDGETS_DROPDOWN_TYPE_H |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
6 |
#define WIDGETS_DROPDOWN_TYPE_H |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
7 |
|
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
8 |
#include "../window_type.h" |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
9 |
#include <list> |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
10 |
|
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
11 |
/** |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
12 |
* Base list item class from which others are derived. If placed in a list it |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
13 |
* will appear as a horizontal line in the menu. |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
14 |
*/ |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
15 |
class DropDownListItem { |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
16 |
public: |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
17 |
int result; ///< Result code to return to window on selection |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
18 |
bool masked; ///< Masked and unselectable item |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
19 |
|
8290
ff0b2196d09b
(svn r11854) -Fix (r11848): Nightly build farm showed up more compiler warnings... c++ is fun
peter1138
parents:
8285
diff
changeset
|
20 |
DropDownListItem(int result, bool masked) : result(result), masked(masked) {} |
ff0b2196d09b
(svn r11854) -Fix (r11848): Nightly build farm showed up more compiler warnings... c++ is fun
peter1138
parents:
8285
diff
changeset
|
21 |
virtual ~DropDownListItem() {} |
8284
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
22 |
virtual StringID String() const; |
8905
609b1121b3b3
(svn r12672) -Codechange: Add support for variably-sized drop down list items.
peter1138
parents:
8877
diff
changeset
|
23 |
virtual uint Height(uint width) const; |
8907
c6949b09d3b3
(svn r12675) -Codechange: Add support for custom drawing of drop down list items.
peter1138
parents:
8905
diff
changeset
|
24 |
virtual void Draw(int x, int y, uint width, uint height, bool sel) const; |
8284
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
25 |
}; |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
26 |
|
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
27 |
/** |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
28 |
* Common string list item. |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
29 |
*/ |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
30 |
class DropDownListStringItem : public DropDownListItem { |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
31 |
public: |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
32 |
StringID string; ///< String ID of item |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
33 |
|
8290
ff0b2196d09b
(svn r11854) -Fix (r11848): Nightly build farm showed up more compiler warnings... c++ is fun
peter1138
parents:
8285
diff
changeset
|
34 |
DropDownListStringItem(StringID string, int result, bool masked) : DropDownListItem(result, masked), string(string) {} |
8293 | 35 |
virtual ~DropDownListStringItem() {} |
8284
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
36 |
|
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
37 |
StringID String() const; |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
38 |
}; |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
39 |
|
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
40 |
/** |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
41 |
* String list item with parameters. |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
42 |
*/ |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
43 |
class DropDownListParamStringItem : public DropDownListStringItem { |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
44 |
public: |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
45 |
uint64 decode_params[10]; ///< Parameters of the string |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
46 |
|
8290
ff0b2196d09b
(svn r11854) -Fix (r11848): Nightly build farm showed up more compiler warnings... c++ is fun
peter1138
parents:
8285
diff
changeset
|
47 |
DropDownListParamStringItem(StringID string, int result, bool masked) : DropDownListStringItem(string, result, masked) {} |
8293 | 48 |
virtual ~DropDownListParamStringItem() {} |
8285
0a7bd8284319
(svn r11849) -Fix (r11848): Incomplete(?) class broke MSVC/mingw compilation
peter1138
parents:
8284
diff
changeset
|
49 |
|
8284
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
50 |
StringID String() const; |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
51 |
void SetParam(uint index, uint64 value) { decode_params[index] = value; } |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
52 |
}; |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
53 |
|
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
54 |
/** |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
55 |
* A drop down list is a collection of drop down list items. |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
56 |
*/ |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
57 |
typedef std::list<DropDownListItem *> DropDownList; |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
58 |
|
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
59 |
/** |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
60 |
* Show a drop down list. |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
61 |
* @param w Parent window for the list. |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
62 |
* @param list Prepopulated DropDownList. Will be deleted when the list is |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
63 |
* closed. |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
64 |
* @param selected The initially selected list item. |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
65 |
* @param button The widget within the parent window that is used to determine |
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
66 |
* the list's location. |
8877
f09f03b0dc64
(svn r12644) -Codechange: rework the order gui a little to prepare it for some future changes.
rubidium
parents:
8293
diff
changeset
|
67 |
* @param width Override the width determined by the selected widget. |
8284
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
68 |
*/ |
8877
f09f03b0dc64
(svn r12644) -Codechange: rework the order gui a little to prepare it for some future changes.
rubidium
parents:
8293
diff
changeset
|
69 |
void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, uint width = 0); |
8284
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
70 |
|
ebdc5ba08874
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
diff
changeset
|
71 |
#endif /* WIDGETS_DROPDOWN_TYPE_H */ |