Photon microGUI widgets library 0.6.0
ComboBox.h
1#ifndef PHWIDGETS_COMBO_BOX_H
2#define PHWIDGETS_COMBO_BOX_H
3
4#include <photon/PtComboBox.h>
5
6#include "./Compound.h"
7#include "./Text.h"
8//#include "./List.h"
9
10
11namespace PhWidgets
12{
14
23 {
25
34 {
35 DropDown = 1,
37 DropDownList = 2,
39 Simple = 0
41 };
42 };
43
50
75 class ComboBox:
76 public Compound
77 {
78 public:
79
81 struct ThisArgs
82 {
85 {
87
97 {
98 button_width = Pt_ARG_CBOX_BUTTON_WIDTH,
99 max_visible_count = Pt_ARG_CBOX_MAX_VISIBLE_COUNT,
101 selected_item = Pt_ARG_CBOX_SEL_ITEM
102 };
103 };
104
107 {
109
119 {
121
128 text_fill_color = Pt_ARG_CBOX_TEXT_FILL_COLOR
129 };
130
132
142 {
143 cbox_flags = Pt_ARG_CBOX_FLAGS
144 };
145 };
146 };
147
150 {
152 struct Callback
153 {
155
164 {
165 list_activate = Pt_CB_CBOX_ACTIVATE,
166 list_close = Pt_CB_CBOX_CLOSE
167 };
168 };
169 };
170
173 {
175
183 {
184 AltDown = Pt_COMBOBOX_ALT_DOWN,
185 MaxWidth = Pt_COMBOBOX_MAX_WIDTH,
186 IsOpened = Pt_COMBOBOX_OPEN,
187 StaticList = Pt_COMBOBOX_STATIC,
189 ListAbove = Pt_COMBOBOX_TOP
193 };
194 };
195
196 private:
197 struct ArgUnsignedShortBase:
198 public ArgumentsEx<Compound::ArgUnsignedShort>,
199 public ThisArgs::ArgUnsignedShort
200 {
201 typedef ThisArgs::ArgUnsignedShort::eArgUnsignedShort eArgUnsignedShort;
202 };
203 public:
206 public ArgumentsEx<Text::ArgUnsignedShort>,
207 //public ArgumentsEx<List::ArgUnsignedShort>
208 public ArgumentsEx<ArgUnsignedShortBase>
209 {
211 };
212
215 public ArgumentsEx<Compound::ArgUnsignedLong>,
216 //public ArgumentsEx<List::ArgUnsignedLong>,
218 {
221 };
222 private:
223 struct CallbackBase:
224 public ArgumentsEx<Compound::Callback>,
226 {
227 typedef ThisCallbacks::Callback::eCallback eCallback;
228 };
229 public:
231 struct Callback:
232 public ArgumentsEx<Text::Callback>,
233 //public ArgumentsEx<List::Callback>,
234 public ArgumentsEx<CallbackBase>
235 {
237 };
238
240 struct Arguments:
241 public ArgUnsignedShort,
242 public ArgUnsignedLong,
243 public Compound::Arguments,
244 //public List::Arguments,
245 public Text::Arguments
246 { };
247
249 struct Callbacks:
250 public Callback,
251 //public List::Callbacks,
252 public Text::Callbacks
253 { };
254
256 struct Flags:
257 public ThisFlags,
258 public Compound::Flags
259 //public List::Flags
260 { };
261
262 protected:
263 typedef ResourceFrom<Compound::WidgetResourcesSingleton>::
264 //And<List::WidgetResourcesSingleton>::
265 And<Text::WidgetResourcesSingleton>::
266 Define::Scalar<ThisArgs::ArgUnsignedShort::eArgUnsignedShort, unsigned short>::
267 Define::Color<ThisArgs::ArgUnsignedLong::eArgUnsignedLong, unsigned long>:: // that's right - color of unsigned long
268 Define::Flag<ThisArgs::ArgUnsignedLong::eArgUnsignedLongFlag, unsigned long>::
269
270 Define::Link<ThisCallbacks::Callback::eCallback, PtCallback_t*>::
271
272 resource_type WidgetResourcesSingleton;
273
274 virtual void check();
275
276 //for properties:
277
278 PhWidgets::ComboBoxStyle::eComboBoxStyle getDropDownStyle() const;
279 void setDropDownStyle(PhWidgets::ComboBoxStyle::eComboBoxStyle);
280
281 bool getDroppedDown() const;
282 void setDroppedDown(bool);
283
284 public:
286
290 WidgetResourcesSingleton resource;
291
293
297 explicit ComboBox(int abn);
298
300
304 explicit ComboBox(PtWidget_t *wdg);
305
307
311 ComboBox(const ComboBox &other);
312
314
319
321
331 void AddItem(std::string item, unsigned int pos = 0);
332
334
337 void Clear();
338
340
346 void RemoveItem(std::string item);
347
349
355 void RemoveItemAt(unsigned int pos);
356
358
365 void ReplaceItem(std::string item, unsigned int pos);
366
369
370
372
382 property<PhWidgets::ComboBoxStyle::eComboBoxStyle>::
383 bind<ComboBox, &ComboBox::getDropDownStyle, &ComboBox::setDropDownStyle> DropDownStyle;
384
386
393 property<bool>::
394 bind<ComboBox, &ComboBox::getDroppedDown, &ComboBox::setDroppedDown> DroppedDown;
395
397
398 };
399
400} // namespace PhWidgets
401
402cppbitmasks::bitmask<unsigned short, PhWidgets::ComboBox::Flags::eComboBoxFlags> operator|(const PhWidgets::ComboBox::Flags::eComboBoxFlags &flag1, const PhWidgets::ComboBox::Flags::eComboBoxFlags &flag2);
403cppbitmasks::bitmask<unsigned short, PhWidgets::ComboBox::Flags::eComboBoxFlags> operator&(const PhWidgets::ComboBox::Flags::eComboBoxFlags &flag1, const PhWidgets::ComboBox::Flags::eComboBoxFlags &flag2);
404cppbitmasks::bitmask<unsigned short, PhWidgets::ComboBox::Flags::eComboBoxFlags> operator^(const PhWidgets::ComboBox::Flags::eComboBoxFlags &flag1, const PhWidgets::ComboBox::Flags::eComboBoxFlags &flag2);
405
406#endif // PHWIDGETS_COMBO_BOX_H
A text field with a list of choices.
Definition: ComboBox.h:77
WidgetResourcesSingleton resource
Resources of the ComboBox.
Definition: ComboBox.h:290
ComboBox(PtWidget_t *wdg)
(constructor)
void RemoveItemAt(unsigned int pos)
Remove specific item from a list at specified position.
ComboBox(const ComboBox &other)
(copy constructor)
ComboBox(int abn)
(constructor)
void RemoveItem(std::string item)
Remove specific item from a list.
ComboBox & operator=(const ComboBox &other)
Assigns value in ComboBox widget.
void AddItem(std::string item, unsigned int pos=0)
Adds an item to the drop-down list of items.
property< bool >::bind< ComboBox, &ComboBox::getDroppedDown, &ComboBox::setDroppedDown > DroppedDown
Gets or sets a value indicating whether the combo box is displaying its drop-down portion.
Definition: ComboBox.h:394
void Clear()
Deletes all of the items from the drop-down list.
void ReplaceItem(std::string item, unsigned int pos)
Replaces an item in the drop-down list of items.
property< PhWidgets::ComboBoxStyle::eComboBoxStyle >::bind< ComboBox, &ComboBox::getDropDownStyle, &ComboBox::setDropDownStyle > DropDownStyle
Gets or sets a value specifying the style of the combo box.
Definition: ComboBox.h:383
Superclass for all compound widgets.
Definition: Compound.h:25
The main namespace for all widgets.
Definition: Basic.h:11
Contains resource IDs for arguments of type unsigned long.
Definition: ComboBox.h:218
Contains resource IDs for arguments of type unsigned short.
Definition: ComboBox.h:209
Contains resource IDs for all ComboBox arguments.
Definition: ComboBox.h:246
Contains resource IDs for callbacks of type PtCallback_t.
Definition: ComboBox.h:235
Contains resource IDs for all ComboBox callbacks.
Definition: ComboBox.h:253
Contains flags for all ComboBox resources.
Definition: ComboBox.h:260
Contains resource IDs for ComboBox arguments of type unsigned long.
Definition: ComboBox.h:107
eArgUnsignedLong
Resource IDs for ComboBox arguments of type unsigned long.
Definition: ComboBox.h:119
@ text_fill_color
The fill color of the text area.
Definition: ComboBox.h:128
eArgUnsignedLongFlag
Resource IDs for ComboBox flags of type unsigned long.
Definition: ComboBox.h:142
@ cbox_flags
Flags of ComboBox widget.
Definition: ComboBox.h:143
Contains resource IDs for ComboBox arguments of type unsigned short.
Definition: ComboBox.h:85
eArgUnsignedShort
Resource IDs for ComboBox arguments of type unsigned short.
Definition: ComboBox.h:97
@ selected_item
An index into List::Arguments::items that indicates which list item is currently selected.
Definition: ComboBox.h:101
@ button_width
The width of the drop button, in pixels. Default is 13.
Definition: ComboBox.h:98
@ max_visible_count
Definition: ComboBox.h:99
Contains resource IDs for ComboBox arguments.
Definition: ComboBox.h:82
Contains resource IDs for ComboBox callbacks of type PtCallback_t.
Definition: ComboBox.h:153
eCallback
Resource IDs for ComboBox arguments of type PtCallback_t.
Definition: ComboBox.h:164
@ list_activate
A list of PtCallback_t structures that define the callbacks that the widget invokes when the list is ...
Definition: ComboBox.h:165
@ list_close
A list of PtCallback_t structures that define the callbacks that are invoked when you close the combo...
Definition: ComboBox.h:166
Contains resource IDs for ComboBox callbacks.
Definition: ComboBox.h:150
Contains flags for ComboBox resources.
Definition: ComboBox.h:173
eComboBoxFlags
ComboBox flags for ComboBox resource ComboBox::Arguments::cbox_flags.
Definition: ComboBox.h:183
@ StaticList
Definition: ComboBox.h:187
@ AltDown
Enable the Alt-↓ keychord, which displays the list and highlights the item corresponding to the curre...
Definition: ComboBox.h:184
@ ListAbove
Definition: ComboBox.h:189
@ IsOpened
(read-only) If this bit is set, the list is currently open.
Definition: ComboBox.h:186
@ MaxWidth
Make the combo box size itself to fit the longest list item.
Definition: ComboBox.h:185
Specifies the ComboBox style.
Definition: ComboBox.h:23
eComboBoxStyle
Possible ComboBox style.
Definition: ComboBox.h:34
@ DropDownList
Definition: ComboBox.h:37
@ Simple
Definition: ComboBox.h:39
@ DropDown
Definition: ComboBox.h:35
Contains resource IDs for all Compound arguments.
Definition: Compound.h:31
Contains resource IDs for all Text arguments.
Definition: Text.h:86
Contains resource IDs for all Text callbacks.
Definition: Text.h:92