src/widgets/dropdown_type.h
changeset 8780 6f3f3ec6c69a
child 8781 e03f519901c1
equal deleted inserted replaced
8779:efb41d093a39 8780:6f3f3ec6c69a
       
     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 	virtual StringID String() const;
       
    19 };
       
    20 
       
    21 /**
       
    22  * Common string list item.
       
    23  */
       
    24 class DropDownListStringItem : public DropDownListItem {
       
    25 public:
       
    26 	StringID string; ///< String ID of item
       
    27 
       
    28 	DropDownListStringItem(StringID string, uint result, bool masked)
       
    29 	{
       
    30 		this->string = string;
       
    31 		this->result = result;
       
    32 		this->masked = masked;
       
    33 	}
       
    34 
       
    35 	StringID String() const;
       
    36 };
       
    37 
       
    38 /**
       
    39  * String list item with parameters.
       
    40  */
       
    41 class DropDownListParamStringItem : public DropDownListStringItem {
       
    42 public:
       
    43 	uint64 decode_params[10]; ///< Parameters of the string
       
    44 
       
    45 	StringID String() const;
       
    46 	void SetParam(uint index, uint64 value) { decode_params[index] = value; }
       
    47 };
       
    48 
       
    49 /**
       
    50  * A drop down list is a collection of drop down list items.
       
    51  */
       
    52 typedef std::list<DropDownListItem *> DropDownList;
       
    53 
       
    54 /**
       
    55  * Show a drop down list.
       
    56  * @param w        Parent window for the list.
       
    57  * @param list     Prepopulated DropDownList. Will be deleted when the list is
       
    58  *                 closed.
       
    59  * @param selected The initially selected list item.
       
    60  * @param button   The widget within the parent window that is used to determine
       
    61  *                 the list's location.
       
    62  */
       
    63 void ShowDropDownList(Window *w, DropDownList *list, int selected, int button);
       
    64 
       
    65 #endif /* WIDGETS_DROPDOWN_TYPE_H */