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