00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00030 #ifndef _GG_DropDownList_h_
00031 #define _GG_DropDownList_h_
00032
00033 #include <GG/ListBox.h>
00034
00035
00036 namespace GG {
00037
00050 class GG_API DropDownList : public Control
00051 {
00052 public:
00054 typedef ListBox::Row Row;
00055
00057 typedef boost::signal<void (int)> SelChangedSignalType;
00058
00059
00061 typedef SelChangedSignalType::slot_type SelChangedSlotType;
00062
00063
00065
00066 DropDownList(int x, int y, int w, int h, int drop_ht, Clr color, Flags<WndFlag> flags = CLICKABLE);
00067
00068 ~DropDownList();
00069
00070
00072 const Row* CurrentItem() const;
00073 int CurrentItemIndex() const;
00074
00075 bool Empty() const;
00076 const Row& GetItem(int n) const;
00077 bool Selected(int n) const;
00078 Clr InteriorColor() const;
00079
00080 int DropHeight() const;
00081
00083 Flags<ListBoxStyle> Style() const;
00084
00085 int NumRows() const;
00086 int NumCols() const;
00087
00090 int SortCol() const;
00091
00092 int ColWidth(int n) const;
00093 Alignment ColAlignment(int n) const;
00094 Alignment RowAlignment(int n) const;
00095
00096 virtual Pt ClientUpperLeft() const;
00097 virtual Pt ClientLowerRight() const;
00098
00099 mutable SelChangedSignalType SelChangedSignal;
00100
00101
00103 virtual void Render();
00104 virtual void LClick(const Pt& pt, Flags<ModKey> mod_keys);
00105 virtual void KeyPress(Key key, Flags<ModKey> mod_keys);
00106
00107 virtual void SizeMove(const Pt& ul, const Pt& lr);
00108
00109 virtual void SetColor(Clr c);
00110
00111 int Insert(Row* row, int at = -1);
00112 Row* Erase(int idx);
00113 void Clear();
00114 Row& GetRow(int n);
00115
00116 void Select(int row);
00117
00118 void SetInteriorColor(Clr c);
00119 void SetDropHeight(int h);
00120
00122 void SetStyle(Flags<ListBoxStyle> s);
00123
00124 void SetNumCols(int n);
00125 void SetSortCol(int n);
00126 void SetColWidth(int n, int w);
00127
00130 void LockColWidths();
00131
00133 void UnLockColWidths();
00134
00135 void SetColAlignment(int n, Alignment align);
00136 void SetRowAlignment(int n, Alignment align);
00137
00138 virtual void DefineAttributes(WndEditor* editor);
00140
00141 protected:
00143 DropDownList();
00144
00145
00147 ListBox* LB();
00148
00149
00150 private:
00151 int m_current_item_idx;
00152 ListBox* m_LB;
00153
00154 friend class boost::serialization::access;
00155 template <class Archive>
00156 void serialize(Archive& ar, const unsigned int version);
00157 };
00158
00159 }
00160
00161
00162 template <class Archive>
00163 void GG::DropDownList::serialize(Archive& ar, const unsigned int version)
00164 {
00165 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Control)
00166 & BOOST_SERIALIZATION_NVP(m_current_item_idx)
00167 & BOOST_SERIALIZATION_NVP(m_LB);
00168 }
00169
00170 #endif // _GG_DropDownList_h_