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