dropdown_type.h

Go to the documentation of this file.
00001 /* $Id: dropdown_type.h 15387 2009-02-07 00:37:35Z peter1138 $ */
00002 
00005 #ifndef WIDGETS_DROPDOWN_TYPE_H
00006 #define WIDGETS_DROPDOWN_TYPE_H
00007 
00008 #include "../window_type.h"
00009 #include <list>
00010 
00015 class DropDownListItem {
00016 public:
00017   int result;  
00018   bool masked; 
00019 
00020   DropDownListItem(int result, bool masked) : result(result), masked(masked) {}
00021   virtual ~DropDownListItem() {}
00022 
00023   virtual bool Selectable() const { return false; }
00024   virtual uint Height(uint width) const { return 10; }
00025   virtual uint Width() const { return 0; }
00026   virtual void Draw(int x, int y, uint width, uint height, bool sel, int bg_colour) const;
00027 };
00028 
00032 class DropDownListStringItem : public DropDownListItem {
00033 public:
00034   StringID string; 
00035 
00036   DropDownListStringItem(StringID string, int result, bool masked) : DropDownListItem(result, masked), string(string) {}
00037   virtual ~DropDownListStringItem() {}
00038 
00039   virtual bool Selectable() const { return true; }
00040   virtual uint Width() const;
00041   virtual void Draw(int x, int y, uint width, uint height, bool sel, int bg_colour) const;
00042   virtual StringID String() const { return this->string; }
00043 };
00044 
00048 class DropDownListParamStringItem : public DropDownListStringItem {
00049 public:
00050   uint64 decode_params[10]; 
00051 
00052   DropDownListParamStringItem(StringID string, int result, bool masked) : DropDownListStringItem(string, result, masked) {}
00053   virtual ~DropDownListParamStringItem() {}
00054 
00055   virtual StringID String() const;
00056   virtual void SetParam(uint index, uint64 value) { decode_params[index] = value; }
00057 };
00058 
00062 class DropDownListCharStringItem : public DropDownListItem {
00063 public:
00064   const char *string;
00065 
00066   DropDownListCharStringItem(const char *string, int result, bool masked) : DropDownListItem(result, masked), string(string) {}
00067   virtual ~DropDownListCharStringItem() {}
00068 
00069   virtual bool Selectable() const { return true; }
00070   virtual uint Width() const;
00071   virtual void Draw(int x, int y, uint width, uint height, bool sel, int bg_colour) const;
00072 };
00073 
00077 typedef std::list<DropDownListItem *> DropDownList;
00078 
00092 void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, uint width = 0, bool auto_width = false, bool instant_close = false);
00093 
00094 #endif /* WIDGETS_DROPDOWN_TYPE_H */

Generated on Tue Jul 21 18:48:29 2009 for OpenTTD by  doxygen 1.5.6