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 <list>
00017
00022 class DropDownListItem {
00023 public:
00024 int result;
00025 bool masked;
00026
00027 DropDownListItem(int result, bool masked) : result(result), masked(masked) {}
00028 virtual ~DropDownListItem() {}
00029
00030 virtual bool Selectable() const { return false; }
00031 virtual uint Height(uint width) const { return FONT_HEIGHT_NORMAL; }
00032 virtual uint Width() const { return 0; }
00033 virtual void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const;
00034 };
00035
00039 class DropDownListStringItem : public DropDownListItem {
00040 public:
00041 StringID string;
00042
00043 DropDownListStringItem(StringID string, int result, bool masked) : DropDownListItem(result, masked), string(string) {}
00044 virtual ~DropDownListStringItem() {}
00045
00046 virtual bool Selectable() const { return true; }
00047 virtual uint Width() const;
00048 virtual void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const;
00049 virtual StringID String() const { return this->string; }
00050 };
00051
00055 class DropDownListParamStringItem : public DropDownListStringItem {
00056 public:
00057 uint64 decode_params[10];
00058
00059 DropDownListParamStringItem(StringID string, int result, bool masked) : DropDownListStringItem(string, result, masked) {}
00060 virtual ~DropDownListParamStringItem() {}
00061
00062 virtual StringID String() const;
00063 virtual void SetParam(uint index, uint64 value) { decode_params[index] = value; }
00064 };
00065
00069 class DropDownListCharStringItem : public DropDownListItem {
00070 public:
00071 const char *string;
00072
00073 DropDownListCharStringItem(const char *string, int result, bool masked) : DropDownListItem(result, masked), string(string) {}
00074 virtual ~DropDownListCharStringItem() {}
00075
00076 virtual bool Selectable() const { return true; }
00077 virtual uint Width() const;
00078 virtual void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const;
00079 };
00080
00084 typedef std::list<DropDownListItem *> DropDownList;
00085
00099 void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, uint width = 0, bool auto_width = false, bool instant_close = false);
00100
00101 #endif