Files
@ r9951:8026cba2423a
Branch filter:
Location: cpp/openttd-patchpack/source/src/widgets/dropdown_type.h - annotation
r9951:8026cba2423a
2.7 KiB
text/x-c
(svn r14106) -Fix(r14104): A string too much been commited
r8284:d769847bf11d r8284:d769847bf11d r9111:983de9c5a848 r9111:983de9c5a848 r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8290:b32f411ab7cc r8290:b32f411ab7cc r9859:8c15dba58099 r9859:8c15dba58099 r9859:8c15dba58099 r9868:7ffba1f0658a r9859:8c15dba58099 r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8290:b32f411ab7cc r8293:5e18781db363 r8284:d769847bf11d r9859:8c15dba58099 r9868:7ffba1f0658a r9859:8c15dba58099 r9859:8c15dba58099 r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8290:b32f411ab7cc r8293:5e18781db363 r8285:e82ce65cfaa6 r9859:8c15dba58099 r9859:8c15dba58099 r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8284:d769847bf11d r8877:00e39d55d291 r9868:7ffba1f0658a r9868:7ffba1f0658a r9869:49fc50b6a2ef r9869:49fc50b6a2ef r8284:d769847bf11d r9869:49fc50b6a2ef r8284:d769847bf11d r8284:d769847bf11d | /* $Id$ */
/** @file dropdown_type.h Types related to the drop down widget. */
#ifndef WIDGETS_DROPDOWN_TYPE_H
#define WIDGETS_DROPDOWN_TYPE_H
#include "../window_type.h"
#include <list>
/**
* Base list item class from which others are derived. If placed in a list it
* will appear as a horizontal line in the menu.
*/
class DropDownListItem {
public:
int result; ///< Result code to return to window on selection
bool masked; ///< Masked and unselectable item
DropDownListItem(int result, bool masked) : result(result), masked(masked) {}
virtual ~DropDownListItem() {}
virtual bool Selectable() const { return false; }
virtual uint Height(uint width) const { return 10; }
virtual uint Width() const { return 0; }
virtual void Draw(int x, int y, uint width, uint height, bool sel, int bg_colour) const;
};
/**
* Common string list item.
*/
class DropDownListStringItem : public DropDownListItem {
public:
StringID string; ///< String ID of item
DropDownListStringItem(StringID string, int result, bool masked) : DropDownListItem(result, masked), string(string) {}
virtual ~DropDownListStringItem() {}
virtual bool Selectable() const { return true; }
virtual uint Width() const;
virtual void Draw(int x, int y, uint width, uint height, bool sel, int bg_colour) const;
virtual StringID String() const { return this->string; }
};
/**
* String list item with parameters.
*/
class DropDownListParamStringItem : public DropDownListStringItem {
public:
uint64 decode_params[10]; ///< Parameters of the string
DropDownListParamStringItem(StringID string, int result, bool masked) : DropDownListStringItem(string, result, masked) {}
virtual ~DropDownListParamStringItem() {}
virtual StringID String() const;
virtual void SetParam(uint index, uint64 value) { decode_params[index] = value; }
};
/**
* A drop down list is a collection of drop down list items.
*/
typedef std::list<DropDownListItem *> DropDownList;
/**
* Show a drop down list.
* @param w Parent window for the list.
* @param list Prepopulated DropDownList. Will be deleted when the list is
* closed.
* @param selected The initially selected list item.
* @param button The widget within the parent window that is used to determine
* the list's location.
* @param width Override the width determined by the selected widget.
* If UINT_MAX then the width is determined by the widest item
* in the list.
* @param instant_close Set to true if releasing mouse button should close the
* list regardless of where the cursor is.
*/
void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, uint width = 0, bool instant_close = false);
#endif /* WIDGETS_DROPDOWN_TYPE_H */
|