MyGUI  3.2.0
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"
31 #include "MyGUI_FlowDirection.h"
32 #include "MyGUI_IItem.h"
33 #include "MyGUI_IItemContainer.h"
34 
35 namespace MyGUI
36 {
37 
39 
41  public EditBox,
42  public IItemContainer,
43  public MemberObsolete<ComboBox>
44  {
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:*/
162 
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__