MyGUI: MyGUI_ComboBox.h Source File

MyGUI 3.4.2

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

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 typedef delegates::CMultiDelegate2<ComboBox*, size_t> EventHandle_ComboBoxPtrSizeT;
24
28 class MYGUI_EXPORT ComboBox :
29 public EditBox,
30 public IItemContainer,
31 public MemberObsolete<ComboBox>
32 {
33 MYGUI_RTTI_DERIVED( ComboBox )
34
35 public:
36 ComboBox();
37
38 //------------------------------------------------------------------------------//
39 // манипуляции айтемами
40
42 size_t getItemCount() const;
43
45 void insertItemAt(size_t _index, const UString& _name, Any _data = Any::Null);
46
48 void addItem(const UString& _name, Any _data = Any::Null);
49
51 void removeItemAt(size_t _index);
52
54 void removeAllItems();
55
56
58 size_t findItemIndexWith(const UString& _name);
59
60
61 //------------------------------------------------------------------------------//
62 // манипуляции выделениями
63
65 size_t getIndexSelected() const;
66
68 void setIndexSelected(size_t _index);
69
71 void clearIndexSelected();
72
73
74 //------------------------------------------------------------------------------//
75 // манипуляции данными
76
78 void setItemDataAt(size_t _index, Any _data);
79
81 void clearItemDataAt(size_t _index);
82
84 template <typename ValueType>
85 ValueType* getItemDataAt(size_t _index, bool _throw = true)
86 {
87 return mList->getItemDataAt<ValueType>(_index, _throw);
88 }
89
90
91 //------------------------------------------------------------------------------//
92 // манипуляции отображением
93
95 void setItemNameAt(size_t _index, const UString& _name);
96
98 const UString& getItemNameAt(size_t _index) const;
99
100
101 //------------------------------------------------------------------------------//
102 // манипуляции выдимостью
103
105 void beginToItemAt(size_t _index);
106
108 void beginToItemFirst();
109
111 void beginToItemLast();
112
114 void beginToItemSelected();
115
116
117 //------------------------------------------------------------------------------------//
118 // методы для управления отображением
119
121 void setComboModeDrop(bool _value);
123 bool getComboModeDrop() const;
124
126 void setSmoothShow(bool _value);
128 bool getSmoothShow() const;
129
131 void setMaxListLength(int _value);
133 int getMaxListLength() const;
134
135 // RENAME
137 void setFlowDirection(FlowDirection _value);
139 FlowDirection getFlowDirection() const;
140
141 /*events:*/
148 EventPair<EventHandle_WidgetVoid, EventHandle_ComboBoxPtrSizeT> eventComboAccept;
149
155 EventPair<EventHandle_WidgetSizeT, EventHandle_ComboBoxPtrSizeT> eventComboChangePosition;
156
157 /*internal:*/
158 // IItemContainer impl
159 size_t _getItemCount() const override;
160 void _addItem(const MyGUI::UString& _name) override;
161 void _removeItemAt(size_t _index) override;
162 void _setItemNameAt(size_t _index, const UString& _name) override;
163 const UString& _getItemNameAt(size_t _index) const override;
164
165 void _resetContainer(bool _update) override;
166
167 protected:
168 void initialiseOverride() override;
169 void shutdownOverride() override;
170
171 void onKeyButtonPressed(KeyCode _key, Char _char) override;
172
173 void setPropertyOverride(const std::string& _key, const std::string& _value) override;
174
175 private:
176 void notifyButtonPressed(Widget* _sender, int _left, int _top, MouseButton _id);
177 void notifyListLostFocus(Widget* _sender, MyGUI::Widget* _new);
178 void notifyListSelectAccept(ListBox* _widget, size_t _position);
179 void notifyListMouseItemActivate(ListBox* _widget, size_t _position);
180 void notifyListChangePosition(ListBox* _widget, size_t _position);
181 void notifyMouseWheel(Widget* _sender, int _rel);
182 void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id);
183 void notifyEditTextChange(EditBox* _sender);
184 void notifyToolTip(Widget* _sender, const ToolTipInfo& _info);
185
186 void showList();
187 void hideList();
188
189 void actionWidgetHide(Widget* _widget, ControllerItem* _controller);
190
191 ControllerFadeAlpha* createControllerFadeAlpha(float _alpha, float _coef, bool _enable);
192 IntCoord calculateListPosition();
193
194 private:
195 Button* mButton;
196 ListBox* mList;
197
198 bool mListShow;
199 int mMaxListLength;
200 size_t mItemIndex;
201 bool mModeDrop;
202 bool mDropMouse;
203 bool mShowSmooth;
204
205 FlowDirection mFlowDirection;
206 };
207
208} // namespace MyGUI
209
210#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:48
MyGUI::Any
Definition MyGUI_Any.h:56
MyGUI::Button
widget description should be here.
Definition MyGUI_Button.h:22
MyGUI::ComboBox
widget description should be here.
Definition MyGUI_ComboBox.h:32
MyGUI::ComboBox::eventComboAccept
EventPair< EventHandle_WidgetVoid, EventHandle_ComboBoxPtrSizeT > eventComboAccept
Definition MyGUI_ComboBox.h:148
MyGUI::ComboBox::eventComboChangePosition
EventPair< EventHandle_WidgetSizeT, EventHandle_ComboBoxPtrSizeT > eventComboChangePosition
Definition MyGUI_ComboBox.h:155
MyGUI::ComboBox::getItemDataAt
ValueType * getItemDataAt(size_t _index, bool _throw=true)
Get item data from specified position.
Definition MyGUI_ComboBox.h:85
MyGUI::ControllerFadeAlpha
Definition MyGUI_ControllerFadeAlpha.h:20
MyGUI::ControllerItem
Definition MyGUI_ControllerItem.h:27
MyGUI::EditBox
widget description should be here.
Definition MyGUI_EditBox.h:29
MyGUI::EventPair
Definition MyGUI_EventPair.h:17
MyGUI::IItemContainer
Definition MyGUI_IItemContainer.h:19
MyGUI::ListBox
widget description should be here.
Definition MyGUI_ListBox.h:31
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:145
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:37
MyGUI::delegates::MultiDelegate
Definition MyGUI_Delegate.h:200
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::Char
unsigned int Char
Definition MyGUI_Types.h:50
MyGUI::EventHandle_ComboBoxPtrSizeT
delegates::CMultiDelegate2< 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
MyGUI::types::TCoord< int >