MyGUI 3.2.0

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

- File List
- Globals

MyGUI_ComboBox.h
Go to the documentation of this file.
1
6 /*
7 This file is part of MyGUI.
8
9 MyGUI is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 MyGUI is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_COMBO_BOX_H__
23 #define __MYGUI_COMBO_BOX_H__
24
25 #include "MyGUI_Prerequest.h"
26 #include "MyGUI_EditBox.h"
27 #include "MyGUI_ListBox.h"
28 #include "MyGUI_Any.h"
29 #include "MyGUI_EventPair.h"
30 #include "MyGUI_ControllerFadeAlpha.h"
31 #include "MyGUI_FlowDirection.h"
32 #include "MyGUI_IItem.h"
33 #include "MyGUI_IItemContainer.h"
34
35 namespace MyGUI
36 {
37
38 typedef delegates::CMultiDelegate2<ComboBox*, size_t> EventHandle_ComboBoxPtrSizeT;
39
40 class MYGUI_EXPORT ComboBox :
41 public EditBox,
42 public IItemContainer,
43 public MemberObsolete<ComboBox>
44 {
45 MYGUI_RTTI_DERIVED( ComboBox )
46
47 public:
48 ComboBox();
49
50 //------------------------------------------------------------------------------//
51 // манипуляции айтемами
52
54 size_t getItemCount() const;
55
57 void insertItemAt(size_t _index, const UString& _name, Any _data = Any::Null);
58
60 void addItem(const UString& _name, Any _data = Any::Null);
61
63 void removeItemAt(size_t _index);
64
66 void removeAllItems();
67
68
70 size_t findItemIndexWith(const UString& _name);
71
72
73 //------------------------------------------------------------------------------//
74 // манипуляции выделениями
75
77 size_t getIndexSelected() const;
78
80 void setIndexSelected(size_t _index);
81
83 void clearIndexSelected();
84
85
86 //------------------------------------------------------------------------------//
87 // манипуляции данными
88
90 void setItemDataAt(size_t _index, Any _data);
91
93 void clearItemDataAt(size_t _index);
94
96 template <typename ValueType>
97 ValueType* getItemDataAt(size_t _index, bool _throw = true)
98 {
99 return mList->getItemDataAt<ValueType>(_index, _throw);
100 }
101
102
103 //------------------------------------------------------------------------------//
104 // манипуляции отображением
105
107 void setItemNameAt(size_t _index, const UString& _name);
108
110 const UString& getItemNameAt(size_t _index);
111
112
113 //------------------------------------------------------------------------------//
114 // манипуляции выдимостью
115
117 void beginToItemAt(size_t _index);
118
120 void beginToItemFirst();
121
123 void beginToItemLast();
124
126 void beginToItemSelected();
127
128
129 //------------------------------------------------------------------------------------//
130 // методы для управления отображением
131
133 void setComboModeDrop(bool _value);
135 bool getComboModeDrop() const;
136
138 void setSmoothShow(bool _value);
140 bool getSmoothShow() const;
141
143 void setMaxListLength(int _value);
145 int getMaxListLength() const;
146
147 // RENAME
149 void setFlowDirection(FlowDirection _value);
151 FlowDirection getFlowDirection() const;
152
153 /*events:*/
160 EventPair<EventHandle_WidgetVoid, EventHandle_ComboBoxPtrSizeT>
161 eventComboAccept;
162
168 EventPair<EventHandle_WidgetSizeT, EventHandle_ComboBoxPtrSizeT>
169 eventComboChangePosition;
170
171 /*internal:*/
172 // IItemContainer impl
173 virtual size_t _getItemCount();
174 virtual void _addItem(const MyGUI::UString& _name);
175 virtual void _removeItemAt(size_t _index);
176 virtual void _setItemNameAt(size_t _index, const UString& _name);
177 virtual const UString& _getItemNameAt(size_t _index);
178
179 virtual void _resetContainer(bool _update);
180
181 protected:
182 virtual void initialiseOverride();
183 virtual void shutdownOverride();
184
185 virtual void onKeyButtonPressed(KeyCode _key, Char _char);
186
187 virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
188
189 private:
190 void notifyButtonPressed(Widget* _sender, int _left, int _top, MouseButton _id);
191 void notifyListLostFocus(Widget* _sender, MyGUI::Widget* _new);
192 void notifyListSelectAccept(ListBox* _widget, size_t _position);
193 void notifyListMouseItemActivate(ListBox* _widget, size_t _position);
194 void notifyListChangePosition(ListBox* _widget, size_t _position);
195 void notifyMouseWheel(Widget* _sender, int _rel);
196 void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id);
197 void notifyEditTextChange(EditBox* _sender);
198 void notifyToolTip(Widget* _sender, const ToolTipInfo& _info);
199
200 void showList();
201 void hideList();
202
203 void actionWidgetHide(Widget* _widget);
204
205 ControllerFadeAlpha* createControllerFadeAlpha(float _alpha, float _coef, bool _enable);
206 IntCoord calculateListPosition();
207
208 private:
209 Button* mButton;
210 ListBox* mList;
211
212 bool mListShow;
213 int mMaxListLength;
214 size_t mItemIndex;
215 bool mModeDrop;
216 bool mDropMouse;
217 bool mShowSmooth;
218
219 FlowDirection mFlowDirection;
220 };
221
222 } // namespace MyGUI
223
224 #endif // __MYGUI_COMBO_BOX_H__
MyGUI::types::TCoord< int >
MyGUI::Widget
Definition: MyGUI_Widget.h:41
MyGUI::ComboBox
Definition: MyGUI_ComboBox.h:40
MyGUI_IItemContainer.h
MyGUI_Prerequest.h
MyGUI_IItem.h
MyGUI::KeyCode
Definition: MyGUI_KeyCode.h:30
MyGUI_FlowDirection.h
MyGUI::ToolTipInfo
Definition: MyGUI_WidgetToolTip.h:32
MyGUI::Any
Definition: MyGUI_Any.h:81
MyGUI_ListBox.h
MyGUI::ListBox
Definition: MyGUI_ListBox.h:37
MyGUI::IItemContainer
Definition: MyGUI_IItemContainer.h:33
MyGUI::MouseButton
Definition: MyGUI_MouseButton.h:30
MyGUI::Button
Definition: MyGUI_Button.h:31
MyGUI::EditBox
Definition: MyGUI_EditBox.h:37
MyGUI::ComboBox::eventComboAccept
EventPair< EventHandle_WidgetVoid, EventHandle_ComboBoxPtrSizeT > eventComboAccept
Definition: MyGUI_ComboBox.h:161
MyGUI::FlowDirection
Definition: MyGUI_FlowDirection.h:31
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition: MyGUI_RTTI.h:88
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:120
MyGUI::EventPair
Definition: MyGUI_EventPair.h:31
MyGUI::Char
unsigned int Char
Definition: MyGUI_Types.h:66
MyGUI_ControllerFadeAlpha.h
MyGUI_Any.h
MyGUI::delegates::CMultiDelegate2
Definition: MyGUI_Delegate.h:239
MyGUI::ControllerFadeAlpha
Definition: MyGUI_ControllerFadeAlpha.h:33
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition: MyGUI_UString.h:169
MyGUI::MemberObsolete
Definition: MyGUI_DeprecatedTypes.h:28
MyGUI::ComboBox::eventComboChangePosition
EventPair< EventHandle_WidgetSizeT, EventHandle_ComboBoxPtrSizeT > eventComboChangePosition
Definition: MyGUI_ComboBox.h:169
MyGUI_EventPair.h
MyGUI::ComboBox::getItemDataAt
ValueType * getItemDataAt(size_t _index, bool _throw=true)
Get item data from specified position.
Definition: MyGUI_ComboBox.h:97
MyGUI::action::actionWidgetHide
void actionWidgetHide(Widget *_widget)
Definition: MyGUI_ActionController.cpp:34
MyGUI_EditBox.h
MyGUI::EventHandle_ComboBoxPtrSizeT
delegates::CMultiDelegate2< ComboBox *, size_t > EventHandle_ComboBoxPtrSizeT
Definition: MyGUI_ComboBox.h:38