MyGUI  3.2.0
MyGUI_MenuItem.h
Go to the documentation of this file.
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_MENU_ITEM_H__
00023 #define __MYGUI_MENU_ITEM_H__
00024 
00025 #include "MyGUI_Prerequest.h"
00026 #include "MyGUI_Button.h"
00027 #include "MyGUI_MenuControl.h"
00028 #include "MyGUI_IItem.h"
00029 
00030 namespace MyGUI
00031 {
00032 
00033     class MYGUI_EXPORT MenuItem :
00034         public Button,
00035         public IItem,
00036         public MemberObsolete<MenuItem>
00037     {
00038         MYGUI_RTTI_DERIVED( MenuItem )
00039 
00040     public:
00041         MenuItem();
00042 
00044         virtual void setCaption(const UString& _value);
00045 
00047         void setItemName(const UString& _value);
00049         const UString& getItemName();
00050 
00052         void setItemData(Any _value);
00053 
00055         template <typename ValueType>
00056         ValueType* getItemData(bool _throw = true)
00057         {
00058             return mOwner->getItemData<ValueType>(this, _throw);
00059         }
00060 
00062         void removeItem();
00063 
00065         void setItemId(const std::string& _value);
00067         const std::string& getItemId();
00068 
00070         size_t getItemIndex();
00071 
00073         MenuControl* createItemChild();
00074 
00076         template <typename Type>
00077         Type* createItemChildT()
00078         {
00079             return mOwner->createItemChildT<Type>(this);
00080         }
00081 
00083         void setItemType(MenuItemType _value);
00085         MenuItemType getItemType();
00086 
00088         void setItemChildVisible(bool _value);
00089 
00091         MenuControl* getMenuCtrlParent();
00092 
00094         MenuControl* getItemChild();
00095 
00096         bool getItemChecked() const;
00097         void setItemChecked(bool _value);
00098 
00099     /*internal:*/
00100         virtual IItemContainer* _getItemContainer();
00101         IntSize _getContentSize();
00102 
00103     protected:
00104         virtual void initialiseOverride();
00105         virtual void shutdownOverride();
00106 
00107         virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
00108 
00109         virtual void onWidgetCreated(Widget* _widget);
00110 
00111     private:
00112         void updateCheck();
00113 
00114     private:
00115         MenuControl* mOwner;
00116         IntSize mMinSize;
00117         Widget* mCheck;
00118         bool mCheckValue;
00119     };
00120 
00121 } // namespace MyGUI
00122 
00123 #endif // __MYGUI_MENU_ITEM_H__