MyGUI: MyGUI_MenuItem.h Source File

MyGUI 3.4.3

MyGUI_MenuItem.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_MENU_ITEM_H_
8#define MYGUI_MENU_ITEM_H_
9
10#include "MyGUI_Prerequest.h"
11#include "MyGUI_Button.h"
12#include "MyGUI_MenuControl.h"
13#include "MyGUI_IItem.h"
14
15namespace MyGUI
16{
17
21 class MYGUI_EXPORT MenuItem : public Button, public IItem, public MemberObsolete<MenuItem>
22 {
23 MYGUI_RTTI_DERIVED(MenuItem)
24
25 public:
27 void setCaption(const UString& _value) override;
28
30 void setFontName(std::string_view _value) override;
31
33 void setFontHeight(int _value) override;
34
36 void setItemName(const UString& _value);
38 const UString& getItemName() const;
39
41 void setItemData(Any _data);
42
44 template<typename ValueType>
45 ValueType* getItemData(bool _throw = true)
46 {
47 return mOwner->getItemData<ValueType>(this, _throw);
48 }
49
51 void removeItem();
52
54 void setItemId(std::string_view _id);
56 const std::string& getItemId() const;
57
59 size_t getItemIndex() const;
60
62 MenuControl* createItemChild();
63
65 template<typename Type>
66 Type* createItemChildT()
67 {
68 return mOwner->createItemChildT<Type>(this);
69 }
70
72 void setItemType(MenuItemType _type);
74 MenuItemType getItemType() const;
75
77 void setItemChildVisible(bool _visible);
78
80 MenuControl* getMenuCtrlParent() const;
81
83 MenuControl* getItemChild() const;
84
85 bool getItemChecked() const;
86 void setItemChecked(bool _value);
87
88 /*internal:*/
89 IItemContainer* _getItemContainer() const override;
90 IntSize _getContentSize() const;
91
92 protected:
93 void initialiseOverride() override;
94 void shutdownOverride() override;
95
96 void setPropertyOverride(std::string_view _key, std::string_view _value) override;
97
98 void onWidgetCreated(Widget* _widget) override;
99
100 private:
101 void updateCheck();
102
103 private:
104 MenuControl* mOwner{nullptr};
105 IntSize mMinSize{10, 10};
106 Widget* mCheck{nullptr};
107 bool mCheckValue{false};
108 };
109
110} // namespace MyGUI
111
112#endif // MYGUI_MENU_ITEM_H_
MyGUI_Button.h
MyGUI_IItem.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition MyGUI_RTTI.h:69
MyGUI::Any
Definition MyGUI_Any.h:56
MyGUI::Button
widget description should be here.
Definition MyGUI_Button.h:20
MyGUI::IItemContainer
Definition MyGUI_IItemContainer.h:19
MyGUI::IItem
Definition MyGUI_IItem.h:18
MyGUI::MemberObsolete
Definition MyGUI_DeprecatedTypes.h:14
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition MyGUI_UString.h:144
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:40
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::IntSize
types::TSize< int > IntSize
Definition MyGUI_Types.h:30