MyGUI: MyGUI_ComboBox.h Source File

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"
15#include "MyGUI_ControllerFadeAlpha.h"
16#include "MyGUI_FlowDirection.h"
17#include "MyGUI_IItem.h"
18#include "MyGUI_IItemContainer.h"
19
20namespace MyGUI
21{
22
23 using EventHandle_ComboBoxPtrSizeT = delegates::MultiDelegate<ComboBox*, size_t>;
24
28 class MYGUI_EXPORT ComboBox : public EditBox, public IItemContainer, public MemberObsolete<ComboBox>
29 {
30 MYGUI_RTTI_DERIVED(ComboBox)
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:*/
143 EventPairAddParameter<EventHandle_WidgetVoid, EventHandle_ComboBoxPtrSizeT> eventComboAccept;
144
150 EventPair<EventHandle_WidgetSizeT, EventHandle_ComboBoxPtrSizeT> eventComboChangePosition;
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_
MyGUI_Any.h
MyGUI_ControllerFadeAlpha.h
MyGUI_EditBox.h
MyGUI_EventPair.h
MyGUI_FlowDirection.h
MyGUI_IItem.h
MyGUI_IItemContainer.h
MyGUI_ListBox.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition MyGUI_RTTI.h:69
MyGUI::Any
Definition MyGUI_Any.h:56
MyGUI::Any::Null
static const Any Null
Definition MyGUI_Any.h:58
MyGUI::Button
widget description should be here.
Definition MyGUI_Button.h:20
MyGUI::ComboBox
widget description should be here.
Definition MyGUI_ComboBox.h:29
MyGUI::ComboBox::addItem
void addItem(const UString &_name, Any _data=Any::Null)
Add an item to the end of a array.
Definition MyGUI_ComboBox.cpp:470
MyGUI::ComboBox::eventComboAccept
EventPairAddParameter< EventHandle_WidgetVoid, EventHandle_ComboBoxPtrSizeT > eventComboAccept
Definition MyGUI_ComboBox.h:143
MyGUI::ComboBox::findItemIndexWith
size_t findItemIndexWith(const UString &_name)
Search item, returns the position of the first occurrence in array or ITEM_NONE if item not found.
Definition MyGUI_ComboBox.cpp:372
MyGUI::ComboBox::_setItemNameAt
void _setItemNameAt(size_t _index, const UString &_name) override
Definition MyGUI_ComboBox.cpp:569
MyGUI::ComboBox::clearIndexSelected
void clearIndexSelected()
Clear item selection.
Definition MyGUI_ComboBox.cpp:480
MyGUI::ComboBox::setIndexSelected
void setIndexSelected(size_t _index)
Select specified _index.
Definition MyGUI_ComboBox.cpp:306
MyGUI::ComboBox::removeAllItems
void removeAllItems()
Remove all items.
Definition MyGUI_ComboBox.cpp:348
MyGUI::ComboBox::_addItem
void _addItem(const MyGUI::UString &_name) override
Definition MyGUI_ComboBox.cpp:559
MyGUI::ComboBox::onKeyButtonPressed
void onKeyButtonPressed(KeyCode _key, Char _char) override
Definition MyGUI_ComboBox.cpp:147
MyGUI::ComboBox::_getItemNameAt
const UString & _getItemNameAt(size_t _index) const override
Definition MyGUI_ComboBox.cpp:574
MyGUI::ComboBox::_removeItemAt
void _removeItemAt(size_t _index) override
Definition MyGUI_ComboBox.cpp:564
MyGUI::ComboBox::shutdownOverride
void shutdownOverride() override
Definition MyGUI_ComboBox.cpp:82
MyGUI::ComboBox::insertItemAt
void insertItemAt(size_t _index, const UString &_item, Any _data=Any::Null)
Insert an item into a array at a specified position.
Definition MyGUI_ComboBox.cpp:334
MyGUI::ComboBox::getIndexSelected
size_t getIndexSelected() const
Get index of selected item (ITEM_NONE if none selected).
Definition MyGUI_ComboBox.cpp:475
MyGUI::ComboBox::initialiseOverride
void initialiseOverride() override
Definition MyGUI_ComboBox.cpp:26
MyGUI::ComboBox::eventComboChangePosition
EventPair< EventHandle_WidgetSizeT, EventHandle_ComboBoxPtrSizeT > eventComboChangePosition
Definition MyGUI_ComboBox.h:150
MyGUI::ComboBox::setItemDataAt
void setItemDataAt(size_t _index, Any _data)
Replace an item data at a specified position.
Definition MyGUI_ComboBox.cpp:327
MyGUI::ComboBox::_getItemCount
size_t _getItemCount() const override
Definition MyGUI_ComboBox.cpp:554
MyGUI::ComboBox::removeItemAt
void removeItemAt(size_t _index)
Remove item at a specified position.
Definition MyGUI_ComboBox.cpp:341
MyGUI::ComboBox::clearItemDataAt
void clearItemDataAt(size_t _index)
Clear an item data at a specified position.
Definition MyGUI_ComboBox.cpp:485
MyGUI::ComboBox::_resetContainer
void _resetContainer(bool _update) override
Definition MyGUI_ComboBox.cpp:579
MyGUI::ComboBox::getItemCount
size_t getItemCount() const
Get number of items.
Definition MyGUI_ComboBox.cpp:465
MyGUI::ComboBox::setPropertyOverride
void setPropertyOverride(std::string_view _key, std::string_view _value) override
Definition MyGUI_ComboBox.cpp:434
MyGUI::ComboBox::getItemDataAt
ValueType * getItemDataAt(size_t _index, bool _throw=true)
Get item data from specified position.
Definition MyGUI_ComboBox.h:80
MyGUI::ControllerFadeAlpha
Definition MyGUI_ControllerFadeAlpha.h:19
MyGUI::ControllerItem
Definition MyGUI_ControllerItem.h:26
MyGUI::EditBox::EditBox
EditBox()
Definition MyGUI_EditBox.cpp:63
MyGUI::EventPairAddParameter
Definition MyGUI_EventPair.h:176
MyGUI::EventPair
Definition MyGUI_EventPair.h:99
MyGUI::IItemContainer
Definition MyGUI_IItemContainer.h:19
MyGUI::ListBox
widget description should be here.
Definition MyGUI_ListBox.h:28
MyGUI::MemberObsolete
Definition MyGUI_DeprecatedTypes.h:14
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition MyGUI_UString.h:144
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:40
MyGUI::delegates::MultiDelegate
Definition MyGUI_Delegate.h:190
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::Char
unsigned int Char
Definition MyGUI_Types.h:50
MyGUI::ITEM_NONE
constexpr size_t ITEM_NONE
Definition MyGUI_Macros.h:19
MyGUI::IntCoord
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:36
MyGUI::EventHandle_ComboBoxPtrSizeT
delegates::MultiDelegate< ComboBox *, size_t > EventHandle_ComboBoxPtrSizeT
Definition MyGUI_ComboBox.h:23
MyGUI::FlowDirection
Definition MyGUI_FlowDirection.h:19
MyGUI::KeyCode
Definition MyGUI_KeyCode.h:16
MyGUI::MouseButton
Definition MyGUI_MouseButton.h:16
MyGUI::ToolTipInfo
Definition MyGUI_WidgetToolTip.h:18