dropdown_type.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef WIDGETS_DROPDOWN_TYPE_H
00013 #define WIDGETS_DROPDOWN_TYPE_H
00014
00015 #include "../window_type.h"
00016 #include "../gfx_func.h"
00017 #include "table/strings.h"
00018 #include <list>
00019
00024 class DropDownListItem {
00025 public:
00026 int result;
00027 bool masked;
00028
00029 DropDownListItem(int result, bool masked) : result(result), masked(masked) {}
00030 virtual ~DropDownListItem() {}
00031
00032 virtual bool Selectable() const { return false; }
00033 virtual uint Height(uint width) const { return FONT_HEIGHT_NORMAL; }
00034 virtual uint Width() const { return 0; }
00035 virtual void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const;
00036 };
00037
00041 class DropDownListStringItem : public DropDownListItem {
00042 public:
00043 StringID string;
00044
00045 DropDownListStringItem(StringID string, int result, bool masked) : DropDownListItem(result, masked), string(string) {}
00046 virtual ~DropDownListStringItem() {}
00047
00048 virtual bool Selectable() const { return true; }
00049 virtual uint Width() const;
00050 virtual void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const;
00051 virtual StringID String() const { return this->string; }
00052
00053 static bool NatSortFunc(const DropDownListItem *first, const DropDownListItem *second);
00054 };
00055
00059 class DropDownListParamStringItem : public DropDownListStringItem {
00060 public:
00061 uint64 decode_params[10];
00062
00063 DropDownListParamStringItem(StringID string, int result, bool masked) : DropDownListStringItem(string, result, masked) {}
00064 virtual ~DropDownListParamStringItem() {}
00065
00066 virtual StringID String() const;
00067 virtual void SetParam(uint index, uint64 value) { decode_params[index] = value; }
00068 };
00069
00073 class DropDownListCharStringItem : public DropDownListStringItem {
00074 public:
00075 const char *raw_string;
00076
00077 DropDownListCharStringItem(const char *raw_string, int result, bool masked) : DropDownListStringItem(STR_JUST_RAW_STRING, result, masked), raw_string(raw_string) {}
00078 virtual ~DropDownListCharStringItem() {}
00079
00080 virtual StringID String() const;
00081 };
00082
00086 typedef std::list<DropDownListItem *> DropDownList;
00087
00101 void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, uint width = 0, bool auto_width = false, bool instant_close = false);
00102
00103 #endif