MyGUI 3.5.3
MyGUI_ComboBox.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_COMBO_BOX_H_
8#define MYGUI_COMBO_BOX_H_
9
10#include "MyGUI_Prerequest.h"
11#include "MyGUI_EditBox.h"
12#include "MyGUI_ListBox.h"
13#include "MyGUI_Any.h"
14#include "MyGUI_EventPair.h"
16#include "MyGUI_FlowDirection.h"
17#include "MyGUI_IItem.h"
19
20namespace MyGUI
21{
22
24
28 class MYGUI_EXPORT ComboBox : public EditBox, public IItemContainer, public MemberObsolete<ComboBox>
29 {
30 MYGUI_RTTI_DERIVED(ComboBox)
31
32 public:
33 //------------------------------------------------------------------------------//
34
36 size_t getItemCount() const;
37
39 void insertItemAt(size_t _index, const UString& _item, Any _data = Any::Null);
40
42 void addItem(const UString& _name, Any _data = Any::Null);
43
45 void removeItemAt(size_t _index);
46
48 void removeAllItems();
49
50
52 size_t findItemIndexWith(const UString& _name);
53
54
55 //------------------------------------------------------------------------------//
56
58 size_t getIndexSelected() const;
59
61 void setIndexSelected(size_t _index);
62
64 void clearIndexSelected();
65
66
67 //------------------------------------------------------------------------------//
68
70 void setItemDataAt(size_t _index, Any _data);
71
73 void clearItemDataAt(size_t _index);
74
76 template<typename ValueType>
77 ValueType* getItemDataAt(size_t _index, bool _throw = true)
78 {
79 return mList->getItemDataAt<ValueType>(_index, _throw);
80 }
81
82
83 //------------------------------------------------------------------------------//
84
86 void setItemNameAt(size_t _index, const UString& _name);
87
89 const UString& getItemNameAt(size_t _index) const;
90
91
92 //------------------------------------------------------------------------------//
93
95 void beginToItemAt(size_t _index);
96
98 void beginToItemFirst();
99
101 void beginToItemLast();
102
104 void beginToItemSelected();
105
106
107 //------------------------------------------------------------------------------------//
108
110 void setComboModeDrop(bool _drop);
112 bool getComboModeDrop() const;
113
115 void setSmoothShow(bool _value);
117 bool getSmoothShow() const;
118
122 void setItemHeight(int _height);
124 int getItemHeight() const;
125
127 void setMaxListLength(int _value);
129 int getMaxListLength() const;
130
131 // RENAME
133 void setFlowDirection(FlowDirection _value);
135 FlowDirection getFlowDirection() const;
136
137 /*events:*/
145
152
153 /*internal:*/
154 // IItemContainer impl
155 size_t _getItemCount() const override;
156 void _addItem(const MyGUI::UString& _name) override;
157 void _removeItemAt(size_t _index) override;
158 void _setItemNameAt(size_t _index, const UString& _name) override;
159 const UString& _getItemNameAt(size_t _index) const override;
160
161 void _resetContainer(bool _update) override;
162
163 protected:
164 void initialiseOverride() override;
165 void shutdownOverride() override;
166
167 void onKeyButtonPressed(KeyCode _key, Char _char) override;
168
169 void setPropertyOverride(std::string_view _key, std::string_view _value) override;
170
171 private:
172 void notifyButtonPressed(Widget* _sender, int _left, int _top, MouseButton _id);
173 void notifyListLostFocus(Widget* _sender, MyGUI::Widget* _new);
174 void notifyListSelectAccept(ListBox* _widget, size_t _position);
175 void notifyListMouseItemActivate(ListBox* _widget, size_t _position);
176 void notifyListChangePosition(ListBox* _widget, size_t _position);
177 void notifyMouseWheel(Widget* _sender, int _rel);
178 void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id);
179 void notifyEditTextChange(EditBox* _sender);
180 void notifyToolTip(Widget* _sender, const ToolTipInfo& _info);
181 void notifyChangeCoord(Widget* _sender);
182
183 void showList();
184 void hideList();
185
186 void actionWidgetHide(Widget* _widget, ControllerItem* _controller);
187
188 ControllerFadeAlpha* createControllerFadeAlpha(float _alpha, float _coef, bool _enable);
189 IntCoord calculateListPosition();
190
191 private:
192 Button* mButton{nullptr};
193 ListBox* mList{nullptr};
194
195 bool mListShow{false};
196 int mMaxListLength{-1};
197 size_t mItemIndex{ITEM_NONE};
198 bool mModeDrop{false};
199 bool mDropMouse{false};
200 bool mShowSmooth{false};
201
202 FlowDirection mFlowDirection{FlowDirection::TopToBottom};
203 };
204
205} // namespace MyGUI
206
207#endif // MYGUI_COMBO_BOX_H_
#define MYGUI_EXPORT
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition MyGUI_RTTI.h:67
unsigned int Char
Definition MyGUI_Types.h:49
constexpr size_t ITEM_NONE
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:35
delegates::MultiDelegate< ComboBox *, size_t > EventHandle_ComboBoxPtrSizeT