MyGUI 3.4.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 {
31
32 public:
33 //------------------------------------------------------------------------------//
34 // манипуляции айтемами
35
37 size_t getItemCount() const;
38
40 void insertItemAt(size_t _index, const UString& _item, Any _data = Any::Null);
41
43 void addItem(const UString& _name, Any _data = Any::Null);
44
46 void removeItemAt(size_t _index);
47
49 void removeAllItems();
50
51
53 size_t findItemIndexWith(const UString& _name);
54
55
56 //------------------------------------------------------------------------------//
57 // манипуляции выделениями
58
60 size_t getIndexSelected() const;
61
63 void setIndexSelected(size_t _index);
64
66 void clearIndexSelected();
67
68
69 //------------------------------------------------------------------------------//
70 // манипуляции данными
71
73 void setItemDataAt(size_t _index, Any _data);
74
76 void clearItemDataAt(size_t _index);
77
79 template<typename ValueType>
80 ValueType* getItemDataAt(size_t _index, bool _throw = true)
81 {
82 return mList->getItemDataAt<ValueType>(_index, _throw);
83 }
84
85
86 //------------------------------------------------------------------------------//
87 // манипуляции отображением
88
90 void setItemNameAt(size_t _index, const UString& _name);
91
93 const UString& getItemNameAt(size_t _index) const;
94
95
96 //------------------------------------------------------------------------------//
97 // манипуляции выдимостью
98
100 void beginToItemAt(size_t _index);
101
103 void beginToItemFirst();
104
106 void beginToItemLast();
107
109 void beginToItemSelected();
110
111
112 //------------------------------------------------------------------------------------//
113 // методы для управления отображением
114
116 void setComboModeDrop(bool _drop);
118 bool getComboModeDrop() const;
119
121 void setSmoothShow(bool _value);
123 bool getSmoothShow() const;
124
126 void setMaxListLength(int _value);
128 int getMaxListLength() const;
129
130 // RENAME
132 void setFlowDirection(FlowDirection _value);
134 FlowDirection getFlowDirection() const;
135
136 /*events:*/
144
151
152 /*internal:*/
153 // IItemContainer impl
154 size_t _getItemCount() const override;
155 void _addItem(const MyGUI::UString& _name) override;
156 void _removeItemAt(size_t _index) override;
157 void _setItemNameAt(size_t _index, const UString& _name) override;
158 const UString& _getItemNameAt(size_t _index) const override;
159
160 void _resetContainer(bool _update) override;
161
162 protected:
163 void initialiseOverride() override;
164 void shutdownOverride() override;
165
166 void onKeyButtonPressed(KeyCode _key, Char _char) override;
167
168 void setPropertyOverride(std::string_view _key, std::string_view _value) override;
169
170 private:
171 void notifyButtonPressed(Widget* _sender, int _left, int _top, MouseButton _id);
172 void notifyListLostFocus(Widget* _sender, MyGUI::Widget* _new);
173 void notifyListSelectAccept(ListBox* _widget, size_t _position);
174 void notifyListMouseItemActivate(ListBox* _widget, size_t _position);
175 void notifyListChangePosition(ListBox* _widget, size_t _position);
176 void notifyMouseWheel(Widget* _sender, int _rel);
177 void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id);
178 void notifyEditTextChange(EditBox* _sender);
179 void notifyToolTip(Widget* _sender, const ToolTipInfo& _info);
180
181 void showList();
182 void hideList();
183
184 void actionWidgetHide(Widget* _widget, ControllerItem* _controller);
185
186 ControllerFadeAlpha* createControllerFadeAlpha(float _alpha, float _coef, bool _enable);
187 IntCoord calculateListPosition();
188
189 private:
190 Button* mButton{nullptr};
191 ListBox* mList{nullptr};
192
193 bool mListShow{false};
194 int mMaxListLength{-1};
195 size_t mItemIndex{ITEM_NONE};
196 bool mModeDrop{false};
197 bool mDropMouse{false};
198 bool mShowSmooth{false};
199
200 FlowDirection mFlowDirection{FlowDirection::TopToBottom};
201 };
202
203} // namespace MyGUI
204
205#endif // MYGUI_COMBO_BOX_H_
#define MYGUI_EXPORT
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition MyGUI_RTTI.h:69
widget description should be here.
widget description should be here.
EventPairAddParameter< EventHandle_WidgetVoid, EventHandle_ComboBoxPtrSizeT > eventComboAccept
EventPair< EventHandle_WidgetSizeT, EventHandle_ComboBoxPtrSizeT > eventComboChangePosition
ValueType * getItemDataAt(size_t _index, bool _throw=true)
Get item data from specified position.
widget description should be here.
widget description should be here.
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
widget description should be here.
unsigned int Char
Definition MyGUI_Types.h:50
constexpr size_t ITEM_NONE