MyGUI
3.2.0
|
00001 00006 /* 00007 This file is part of MyGUI. 00008 00009 MyGUI is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU Lesser General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 MyGUI is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License 00020 along with MyGUI. If not, see <http://www.gnu.org/licenses/>. 00021 */ 00022 #ifndef __MYGUI_COMBO_BOX_H__ 00023 #define __MYGUI_COMBO_BOX_H__ 00024 00025 #include "MyGUI_Prerequest.h" 00026 #include "MyGUI_EditBox.h" 00027 #include "MyGUI_ListBox.h" 00028 #include "MyGUI_Any.h" 00029 #include "MyGUI_EventPair.h" 00030 #include "MyGUI_ControllerFadeAlpha.h" 00031 #include "MyGUI_FlowDirection.h" 00032 #include "MyGUI_IItem.h" 00033 #include "MyGUI_IItemContainer.h" 00034 00035 namespace MyGUI 00036 { 00037 00038 typedef delegates::CMultiDelegate2<ComboBox*, size_t> EventHandle_ComboBoxPtrSizeT; 00039 00040 class MYGUI_EXPORT ComboBox : 00041 public EditBox, 00042 public IItemContainer, 00043 public MemberObsolete<ComboBox> 00044 { 00045 MYGUI_RTTI_DERIVED( ComboBox ) 00046 00047 public: 00048 ComboBox(); 00049 00050 //------------------------------------------------------------------------------// 00051 // манипуляции айтемами 00052 00054 size_t getItemCount() const; 00055 00057 void insertItemAt(size_t _index, const UString& _name, Any _data = Any::Null); 00058 00060 void addItem(const UString& _name, Any _data = Any::Null); 00061 00063 void removeItemAt(size_t _index); 00064 00066 void removeAllItems(); 00067 00068 00070 size_t findItemIndexWith(const UString& _name); 00071 00072 00073 //------------------------------------------------------------------------------// 00074 // манипуляции выделениями 00075 00077 size_t getIndexSelected() const; 00078 00080 void setIndexSelected(size_t _index); 00081 00083 void clearIndexSelected(); 00084 00085 00086 //------------------------------------------------------------------------------// 00087 // манипуляции данными 00088 00090 void setItemDataAt(size_t _index, Any _data); 00091 00093 void clearItemDataAt(size_t _index); 00094 00096 template <typename ValueType> 00097 ValueType* getItemDataAt(size_t _index, bool _throw = true) 00098 { 00099 return mList->getItemDataAt<ValueType>(_index, _throw); 00100 } 00101 00102 00103 //------------------------------------------------------------------------------// 00104 // манипуляции отображением 00105 00107 void setItemNameAt(size_t _index, const UString& _name); 00108 00110 const UString& getItemNameAt(size_t _index); 00111 00112 00113 //------------------------------------------------------------------------------// 00114 // манипуляции выдимостью 00115 00117 void beginToItemAt(size_t _index); 00118 00120 void beginToItemFirst(); 00121 00123 void beginToItemLast(); 00124 00126 void beginToItemSelected(); 00127 00128 00129 //------------------------------------------------------------------------------------// 00130 // методы для управления отображением 00131 00133 void setComboModeDrop(bool _value); 00135 bool getComboModeDrop() const; 00136 00138 void setSmoothShow(bool _value); 00140 bool getSmoothShow() const; 00141 00143 void setMaxListLength(int _value); 00145 int getMaxListLength() const; 00146 00147 // RENAME 00149 void setFlowDirection(FlowDirection _value); 00151 FlowDirection getFlowDirection() const; 00152 00153 /*events:*/ 00160 EventPair<EventHandle_WidgetVoid, EventHandle_ComboBoxPtrSizeT> 00161 eventComboAccept; 00162 00168 EventPair<EventHandle_WidgetSizeT, EventHandle_ComboBoxPtrSizeT> 00169 eventComboChangePosition; 00170 00171 /*internal:*/ 00172 // IItemContainer impl 00173 virtual size_t _getItemCount(); 00174 virtual void _addItem(const MyGUI::UString& _name); 00175 virtual void _removeItemAt(size_t _index); 00176 virtual void _setItemNameAt(size_t _index, const UString& _name); 00177 virtual const UString& _getItemNameAt(size_t _index); 00178 00179 virtual void _resetContainer(bool _update); 00180 00181 protected: 00182 virtual void initialiseOverride(); 00183 virtual void shutdownOverride(); 00184 00185 virtual void onKeyButtonPressed(KeyCode _key, Char _char); 00186 00187 virtual void setPropertyOverride(const std::string& _key, const std::string& _value); 00188 00189 private: 00190 void notifyButtonPressed(Widget* _sender, int _left, int _top, MouseButton _id); 00191 void notifyListLostFocus(Widget* _sender, MyGUI::Widget* _new); 00192 void notifyListSelectAccept(ListBox* _widget, size_t _position); 00193 void notifyListMouseItemActivate(ListBox* _widget, size_t _position); 00194 void notifyListChangePosition(ListBox* _widget, size_t _position); 00195 void notifyMouseWheel(Widget* _sender, int _rel); 00196 void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id); 00197 void notifyEditTextChange(EditBox* _sender); 00198 void notifyToolTip(Widget* _sender, const ToolTipInfo& _info); 00199 00200 void showList(); 00201 void hideList(); 00202 00203 void actionWidgetHide(Widget* _widget); 00204 00205 ControllerFadeAlpha* createControllerFadeAlpha(float _alpha, float _coef, bool _enable); 00206 IntCoord calculateListPosition(); 00207 00208 private: 00209 Button* mButton; 00210 ListBox* mList; 00211 00212 bool mListShow; 00213 int mMaxListLength; 00214 size_t mItemIndex; 00215 bool mModeDrop; 00216 bool mDropMouse; 00217 bool mShowSmooth; 00218 00219 FlowDirection mFlowDirection; 00220 }; 00221 00222 } // namespace MyGUI 00223 00224 #endif // __MYGUI_COMBO_BOX_H__