peter1138@8780: /* $Id$ */ peter1138@8780: rubidium@10429: /** @file dropdown_type.h Types related to the drop down widget. */ rubidium@10429: peter1138@8780: #ifndef WIDGETS_DROPDOWN_TYPE_H peter1138@8780: #define WIDGETS_DROPDOWN_TYPE_H peter1138@8780: peter1138@8780: #include "../window_type.h" peter1138@8780: #include peter1138@8780: peter1138@8780: /** peter1138@8780: * Base list item class from which others are derived. If placed in a list it peter1138@8780: * will appear as a horizontal line in the menu. peter1138@8780: */ peter1138@8780: class DropDownListItem { peter1138@8780: public: peter1138@8780: int result; ///< Result code to return to window on selection peter1138@8780: bool masked; ///< Masked and unselectable item peter1138@8780: peter1138@8786: DropDownListItem(int result, bool masked) : result(result), masked(masked) {} peter1138@8786: virtual ~DropDownListItem() {} peter1138@8780: virtual StringID String() const; peter1138@10141: virtual uint Height(uint width) const; peter1138@10144: virtual void Draw(int x, int y, uint width, uint height, bool sel) const; peter1138@8780: }; peter1138@8780: peter1138@8780: /** peter1138@8780: * Common string list item. peter1138@8780: */ peter1138@8780: class DropDownListStringItem : public DropDownListItem { peter1138@8780: public: peter1138@8780: StringID string; ///< String ID of item peter1138@8780: peter1138@8786: DropDownListStringItem(StringID string, int result, bool masked) : DropDownListItem(result, masked), string(string) {} rubidium@8789: virtual ~DropDownListStringItem() {} peter1138@8780: peter1138@8780: StringID String() const; peter1138@8780: }; peter1138@8780: peter1138@8780: /** peter1138@8780: * String list item with parameters. peter1138@8780: */ peter1138@8780: class DropDownListParamStringItem : public DropDownListStringItem { peter1138@8780: public: peter1138@8780: uint64 decode_params[10]; ///< Parameters of the string peter1138@8780: peter1138@8786: DropDownListParamStringItem(StringID string, int result, bool masked) : DropDownListStringItem(string, result, masked) {} rubidium@8789: virtual ~DropDownListParamStringItem() {} peter1138@8781: peter1138@8780: StringID String() const; peter1138@8780: void SetParam(uint index, uint64 value) { decode_params[index] = value; } peter1138@8780: }; peter1138@8780: peter1138@8780: /** peter1138@8780: * A drop down list is a collection of drop down list items. peter1138@8780: */ peter1138@8780: typedef std::list DropDownList; peter1138@8780: peter1138@8780: /** peter1138@8780: * Show a drop down list. peter1138@8780: * @param w Parent window for the list. peter1138@8780: * @param list Prepopulated DropDownList. Will be deleted when the list is peter1138@8780: * closed. peter1138@8780: * @param selected The initially selected list item. peter1138@8780: * @param button The widget within the parent window that is used to determine peter1138@8780: * the list's location. rubidium@10113: * @param width Override the width determined by the selected widget. peter1138@8780: */ rubidium@10113: void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, uint width = 0); peter1138@8780: peter1138@8780: #endif /* WIDGETS_DROPDOWN_TYPE_H */