MyGUI  3.2.1
MyGUI_ComboBox.h
Go to the documentation of this file.
00001 /*
00002  * This source file is part of MyGUI. For the latest info, see http://mygui.info/
00003  * Distributed under the MIT License
00004  * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
00005  */
00006 
00007 #ifndef __MYGUI_COMBO_BOX_H__
00008 #define __MYGUI_COMBO_BOX_H__
00009 
00010 #include "MyGUI_Prerequest.h"
00011 #include "MyGUI_EditBox.h"
00012 #include "MyGUI_ListBox.h"
00013 #include "MyGUI_Any.h"
00014 #include "MyGUI_EventPair.h"
00015 #include "MyGUI_ControllerFadeAlpha.h"
00016 #include "MyGUI_FlowDirection.h"
00017 #include "MyGUI_IItem.h"
00018 #include "MyGUI_IItemContainer.h"
00019 
00020 namespace MyGUI
00021 {
00022 
00023     typedef delegates::CMultiDelegate2<ComboBox*, size_t> EventHandle_ComboBoxPtrSizeT;
00024 
00028     class MYGUI_EXPORT ComboBox :
00029         public EditBox,
00030         public IItemContainer,
00031         public MemberObsolete<ComboBox>
00032     {
00033         MYGUI_RTTI_DERIVED( ComboBox )
00034 
00035     public:
00036         ComboBox();
00037 
00038         //------------------------------------------------------------------------------//
00039         // манипуляции айтемами
00040 
00042         size_t getItemCount() const;
00043 
00045         void insertItemAt(size_t _index, const UString& _name, Any _data = Any::Null);
00046 
00048         void addItem(const UString& _name, Any _data = Any::Null);
00049 
00051         void removeItemAt(size_t _index);
00052 
00054         void removeAllItems();
00055 
00056 
00058         size_t findItemIndexWith(const UString& _name);
00059 
00060 
00061         //------------------------------------------------------------------------------//
00062         // манипуляции выделениями
00063 
00065         size_t getIndexSelected() const;
00066 
00068         void setIndexSelected(size_t _index);
00069 
00071         void clearIndexSelected();
00072 
00073 
00074         //------------------------------------------------------------------------------//
00075         // манипуляции данными
00076 
00078         void setItemDataAt(size_t _index, Any _data);
00079 
00081         void clearItemDataAt(size_t _index);
00082 
00084         template <typename ValueType>
00085         ValueType* getItemDataAt(size_t _index, bool _throw = true)
00086         {
00087             return mList->getItemDataAt<ValueType>(_index, _throw);
00088         }
00089 
00090 
00091         //------------------------------------------------------------------------------//
00092         // манипуляции отображением
00093 
00095         void setItemNameAt(size_t _index, const UString& _name);
00096 
00098         const UString& getItemNameAt(size_t _index);
00099 
00100 
00101         //------------------------------------------------------------------------------//
00102         // манипуляции выдимостью
00103 
00105         void beginToItemAt(size_t _index);
00106 
00108         void beginToItemFirst();
00109 
00111         void beginToItemLast();
00112 
00114         void beginToItemSelected();
00115 
00116 
00117         //------------------------------------------------------------------------------------//
00118         // методы для управления отображением
00119 
00121         void setComboModeDrop(bool _value);
00123         bool getComboModeDrop() const;
00124 
00126         void setSmoothShow(bool _value);
00128         bool getSmoothShow() const;
00129 
00131         void setMaxListLength(int _value);
00133         int getMaxListLength() const;
00134 
00135         // RENAME
00137         void setFlowDirection(FlowDirection _value);
00139         FlowDirection getFlowDirection() const;
00140 
00141         /*events:*/
00148         EventPair<EventHandle_WidgetVoid, EventHandle_ComboBoxPtrSizeT> eventComboAccept;
00149 
00155         EventPair<EventHandle_WidgetSizeT, EventHandle_ComboBoxPtrSizeT> eventComboChangePosition;
00156 
00157         /*internal:*/
00158         // IItemContainer impl
00159         virtual size_t _getItemCount();
00160         virtual void _addItem(const MyGUI::UString& _name);
00161         virtual void _removeItemAt(size_t _index);
00162         virtual void _setItemNameAt(size_t _index, const UString& _name);
00163         virtual const UString& _getItemNameAt(size_t _index);
00164 
00165         virtual void _resetContainer(bool _update);
00166 
00167     protected:
00168         virtual void initialiseOverride();
00169         virtual void shutdownOverride();
00170 
00171         virtual void onKeyButtonPressed(KeyCode _key, Char _char);
00172 
00173         virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
00174 
00175     private:
00176         void notifyButtonPressed(Widget* _sender, int _left, int _top, MouseButton _id);
00177         void notifyListLostFocus(Widget* _sender, MyGUI::Widget* _new);
00178         void notifyListSelectAccept(ListBox* _widget, size_t _position);
00179         void notifyListMouseItemActivate(ListBox* _widget, size_t _position);
00180         void notifyListChangePosition(ListBox* _widget, size_t _position);
00181         void notifyMouseWheel(Widget* _sender, int _rel);
00182         void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id);
00183         void notifyEditTextChange(EditBox* _sender);
00184         void notifyToolTip(Widget* _sender, const ToolTipInfo& _info);
00185 
00186         void showList();
00187         void hideList();
00188 
00189         void actionWidgetHide(Widget* _widget, ControllerItem* _controller);
00190 
00191         ControllerFadeAlpha* createControllerFadeAlpha(float _alpha, float _coef, bool _enable);
00192         IntCoord calculateListPosition();
00193 
00194     private:
00195         Button* mButton;
00196         ListBox* mList;
00197 
00198         bool mListShow;
00199         int mMaxListLength;
00200         size_t mItemIndex;
00201         bool mModeDrop;
00202         bool mDropMouse;
00203         bool mShowSmooth;
00204 
00205         FlowDirection mFlowDirection;
00206     };
00207 
00208 } // namespace MyGUI
00209 
00210 #endif // __MYGUI_COMBO_BOX_H__