MyGUI  3.0.3
MyGUI_MenuItem.h
Go to the documentation of this file.
00001 
00007 /*
00008     This file is part of MyGUI.
00009 
00010     MyGUI is free software: you can redistribute it and/or modify
00011     it under the terms of the GNU Lesser General Public License as published by
00012     the Free Software Foundation, either version 3 of the License, or
00013     (at your option) any later version.
00014 
00015     MyGUI is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU Lesser General Public License for more details.
00019 
00020     You should have received a copy of the GNU Lesser General Public License
00021     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00022 */
00023 #ifndef __MYGUI_MENU_ITEM_H__
00024 #define __MYGUI_MENU_ITEM_H__
00025 
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_Button.h"
00028 #include "MyGUI_MenuCtrl.h"
00029 
00030 namespace MyGUI
00031 {
00032 
00033     class MYGUI_EXPORT MenuItem :
00034         public Button
00035     {
00036         MYGUI_RTTI_DERIVED( MenuItem )
00037 
00038     public:
00039         MenuItem();
00040 
00042         virtual void setCaption(const UString& _value);
00043 
00045         void setItemName(const UString& _value);
00047         const UString& getItemName();
00048 
00050         void setItemData(Any _value);
00051 
00053         template <typename ValueType>
00054         ValueType* getItemData(bool _throw = true)
00055         {
00056             return mOwner->getItemData<ValueType>(this, _throw);
00057         }
00058 
00060         void removeItem();
00061 
00063         void setItemId(const std::string& _value);
00065         const std::string& getItemId();
00066 
00068         size_t getItemIndex();
00069 
00071         MenuCtrl* createItemChild();
00072 
00074         template <typename Type>
00075         Type * createItemChildT()
00076         {
00077             return mOwner->createItemChildT<Type>(this);
00078         }
00079 
00081         void setItemType(MenuItemType _value);
00083         MenuItemType getItemType();
00084 
00086         void setItemChildVisible(bool _value);
00087 
00089         MenuCtrl* getMenuCtrlParent() { return mOwner; }
00090 
00092         MenuCtrl* getItemChild();
00093 
00095         virtual void setProperty(const std::string& _key, const std::string& _value);
00096 
00097 
00098     /*internal:*/
00099         virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
00100 
00101     /*obsolete:*/
00102 #ifndef MYGUI_DONT_USE_OBSOLETE
00103 
00104         MYGUI_OBSOLETE("use : void setItemChildVisible(bool _visible)")
00105         void showItemChild() { setItemChildVisible(true); }
00106         MYGUI_OBSOLETE("use : void setItemChildVisible(bool _visible)")
00107         void hideItemChild() { setItemChildVisible(false); }
00108 
00109 #endif // MYGUI_DONT_USE_OBSOLETE
00110 
00111     protected:
00112         virtual ~MenuItem();
00113 
00114         virtual Widget* baseCreateWidget(WidgetStyle _style, const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name);
00115 
00116         virtual void baseChangeWidgetSkin(ResourceSkin* _info);
00117         void initialiseWidgetSkin(ResourceSkin* _info);
00118         void shutdownWidgetSkin();
00119 
00120     private:
00121         virtual void onMouseButtonPressed(int _left, int _top, MouseButton _id);
00122         virtual void onMouseButtonReleased(int _left, int _top, MouseButton _id);
00123 
00124     private:
00125         MenuCtrl* mOwner;
00126 
00127     };
00128 
00129 } // namespace MyGUI
00130 
00131 #endif // __MYGUI_MENU_ITEM_H__