GG: DropDownList.h Source File

GG

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

DropDownList.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /* GG is a GUI for SDL and OpenGL.
3 Copyright (C) 2003-2008 T. Zachary Laine
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License
7 as published by the Free Software Foundation; either version 2.1
8 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA
19
20 If you do not wish to comply with the terms of the LGPL please
21 contact the author as other terms are available for a fee.
22
23 Zach Laine
24 whatwasthataddress@gmail.com */
25
31 #ifndef _GG_DropDownList_h_
32 #define _GG_DropDownList_h_
33
34 #include <GG/ListBox.h>
35
36
37 namespace GG {
38
52 class GG_API DropDownList : public Control
53 {
54 public:
56 typedef ListBox::Row Row;
57
58 typedef ListBox::iterator iterator;
59 typedef ListBox::const_iterator const_iterator;
60 typedef ListBox::reverse_iterator reverse_iterator;
61 typedef ListBox::const_reverse_iterator const_reverse_iterator;
62
64 typedef boost::signal<void (iterator)> SelChangedSignalType;
65
66
68
69 DropDownList(X x, Y y, X w, Y h, Y drop_ht, Clr color, Flags<WndFlag> flags = INTERACTIVE);
70
71 ~DropDownList();
72
73
75 iterator CurrentItem() const;
76 std::size_t CurrentItemIndex() const;
77
78 std::size_t IteratorToIndex(iterator it) const;
79 iterator IndexToIterator(std::size_t n) const;
80
81 bool Empty() const;
82 const_iterator begin() const;
83 const_iterator end() const;
84 const_reverse_iterator
85 rbegin() const;
86 const_reverse_iterator
87 rend() const;
88 const Row& GetRow(std::size_t n) const;
89 bool Selected(iterator it) const;
90 bool Selected(std::size_t n) const;
91 Clr InteriorColor() const;
92
93 Y DropHeight() const;
94
96 Flags<ListBoxStyle> Style() const;
97
98 std::size_t NumRows() const;
99 std::size_t NumCols() const;
100
104 std::size_t SortCol() const;
105
106 X ColWidth(std::size_t n) const;
107 Alignment ColAlignment(std::size_t n) const;
108 Alignment RowAlignment(iterator it) const;
109
110 virtual Pt ClientUpperLeft() const;
111 virtual Pt ClientLowerRight() const;
112
113 mutable SelChangedSignalType SelChangedSignal;
114
115
117 virtual void Render();
118
119 virtual void SizeMove(const Pt& ul, const Pt& lr);
120
121 virtual void SetColor(Clr c);
122
127 iterator Insert(Row* row, iterator it);
128
133 iterator Insert(Row* row);
134
135 Row* Erase(iterator it);
136 void Clear();
137 iterator begin();
138 iterator end();
139 reverse_iterator
140 rbegin();
141 reverse_iterator
142 rend();
143 Row& GetRow(std::size_t n);
144
145 void Select(iterator it);
146 void Select(std::size_t n);
147
148 void SetInteriorColor(Clr c);
149 void SetDropHeight(Y h);
150
152 void SetStyle(Flags<ListBoxStyle> s);
153
154 void SetNumCols(std::size_t n);
155 void SetSortCol(std::size_t n);
156 void SetColWidth(std::size_t n, X w);
157
162 void LockColWidths();
163
166 void UnLockColWidths();
167
168 void SetColAlignment(std::size_t n, Alignment align);
169 void SetRowAlignment(iterator it, Alignment align);
170
171
172 protected:
174 DropDownList();
175
176
178 virtual void LClick(const Pt& pt, Flags<ModKey> mod_keys);
179 virtual void KeyPress(Key key, boost::uint32_t key_code_point, Flags<ModKey> mod_keys);
180
181 ListBox* LB();
182
183
184 private:
185 void SelectImpl(iterator it, bool signal);
186
187 iterator m_current_item;
188 ListBox* m_LB;
189 };
190
191 } // namespace GG
192
193 #endif