MyGUI 3.2.2

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
20 namespace 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);
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 virtual size_t _getItemCount();
160 virtual void _addItem(const MyGUI::UString& _name);
161 virtual void _removeItemAt(size_t _index);
162 virtual void _setItemNameAt(size_t _index, const UString& _name);
163 virtual const UString& _getItemNameAt(size_t _index);
164
165 virtual void _resetContainer(bool _update);
166
167 protected:
168 virtual void initialiseOverride();
169 virtual void shutdownOverride();
170
171 virtual void onKeyButtonPressed(KeyCode _key, Char _char);
172
173 virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
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::types::TCoord< int >
MyGUI::Widget
Widget properties. Widget_skin_childs Skin childs. Widget widget description should be here...
Definition: MyGUI_Widget.h:29
MyGUI::ComboBox
ComboBox properties. ComboBox_skin_childs Skin childs. ComboBox widget description should be here...
Definition: MyGUI_ComboBox.h:28
MyGUI_IItemContainer.h
MyGUI_Prerequest.h
MyGUI_IItem.h
MyGUI::KeyCode
Definition: MyGUI_KeyCode.h:15
MyGUI_FlowDirection.h
MyGUI::ToolTipInfo
Definition: MyGUI_WidgetToolTip.h:17
MyGUI::action::actionWidgetHide
void actionWidgetHide(Widget *_widget, ControllerItem *_controller)
Definition: MyGUI_ActionController.cpp:18
MyGUI::Any
Definition: MyGUI_Any.h:63
MyGUI_ListBox.h
MyGUI::ListBox
ListBox properties. ListBox_skin_childs Skin childs. ListBox widget description should be here...
Definition: MyGUI_ListBox.h:27
MyGUI::IItemContainer
Definition: MyGUI_IItemContainer.h:18
MyGUI::MouseButton
Definition: MyGUI_MouseButton.h:15
MyGUI::Button
Button properties. Button_skin_childs Skin childs. Button widget description should be here...
Definition: MyGUI_Button.h:19
MyGUI::EditBox
EditBox properties. EditBox_skin_childs Skin childs. EditBox widget description should be here...
Definition: MyGUI_EditBox.h:25
MyGUI::ComboBox::eventComboAccept
EventPair< EventHandle_WidgetVoid, EventHandle_ComboBoxPtrSizeT > eventComboAccept
Definition: MyGUI_ComboBox.h:148
MyGUI::FlowDirection
Definition: MyGUI_FlowDirection.h:16
MyGUI
Definition: MyGUI_ActionController.h:14
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition: MyGUI_RTTI.h:65
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:103
MyGUI::EventPair
Definition: MyGUI_EventPair.h:16
MyGUI::Char
unsigned int Char
Definition: MyGUI_Types.h:51
MyGUI_ControllerFadeAlpha.h
MyGUI_Any.h
MyGUI::delegates::CMultiDelegate2
Definition: MyGUI_Delegate.h:203
MyGUI::ControllerFadeAlpha
Definition: MyGUI_ControllerFadeAlpha.h:18
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition: MyGUI_UString.h:168
MyGUI::ControllerItem
Definition: MyGUI_ControllerItem.h:25
MyGUI::MemberObsolete
Definition: MyGUI_DeprecatedTypes.h:13
MyGUI::ComboBox::eventComboChangePosition
EventPair< EventHandle_WidgetSizeT, EventHandle_ComboBoxPtrSizeT > eventComboChangePosition
Definition: MyGUI_ComboBox.h:155
MyGUI_EventPair.h
MyGUI::ComboBox::getItemDataAt
ValueType * getItemDataAt(size_t _index, bool _throw=true)
Get item data from specified position.
Definition: MyGUI_ComboBox.h:85
MyGUI_EditBox.h
MyGUI::EventHandle_ComboBoxPtrSizeT
delegates::CMultiDelegate2< ComboBox *, size_t > EventHandle_ComboBoxPtrSizeT
Definition: MyGUI_ComboBox.h:23
MyGUI::Any::Null
static AnyEmpty Null
Definition: MyGUI_Any.h:67