MyGUI  3.0.1
MyGUI_MenuItem.h
Go to the documentation of this file.
1 
7 /*
8  This file is part of MyGUI.
9 
10  MyGUI is free software: you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  MyGUI is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
22 */
23 #ifndef __MYGUI_MENU_ITEM_H__
24 #define __MYGUI_MENU_ITEM_H__
25 
26 #include "MyGUI_Prerequest.h"
27 #include "MyGUI_Button.h"
28 #include "MyGUI_MenuCtrl.h"
29 
30 namespace MyGUI
31 {
32 
34  public Button
35  {
37 
38  public:
39  MenuItem();
40 
42  virtual void setCaption(const UString& _value);
43 
45  void setItemName(const UString& _value);
47  const UString& getItemName();
48 
50  void setItemData(Any _value);
51 
53  template <typename ValueType>
54  ValueType* getItemData(bool _throw = true)
55  {
56  return mOwner->getItemData<ValueType>(this, _throw);
57  }
58 
60  void removeItem();
61 
63  void setItemId(const std::string& _value);
65  const std::string& getItemId();
66 
68  size_t getItemIndex();
69 
71  MenuCtrl* createItemChild();
72 
74  template <typename Type>
75  Type * createItemChildT()
76  {
77  return mOwner->createItemChildT<Type>(this);
78  }
79 
81  void setItemType(MenuItemType _value);
83  MenuItemType getItemType();
84 
86  void setItemChildVisible(bool _value);
87 
89  MenuCtrl* getMenuCtrlParent() { return mOwner; }
90 
92  MenuCtrl* getItemChild();
93 
95  virtual void setProperty(const std::string& _key, const std::string& _value);
96 
97 
98  /*internal:*/
99  virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
100 
101  /*obsolete:*/
102 #ifndef MYGUI_DONT_USE_OBSOLETE
103 
104  MYGUI_OBSOLETE("use : void setItemChildVisible(bool _visible)")
105  void showItemChild() { setItemChildVisible(true); }
106  MYGUI_OBSOLETE("use : void setItemChildVisible(bool _visible)")
107  void hideItemChild() { setItemChildVisible(false); }
108 
109 #endif // MYGUI_DONT_USE_OBSOLETE
110 
111  protected:
112  virtual ~MenuItem();
113 
114  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);
115 
116  virtual void baseChangeWidgetSkin(ResourceSkin* _info);
117  void initialiseWidgetSkin(ResourceSkin* _info);
118  void shutdownWidgetSkin();
119 
120  private:
121  virtual void onMouseButtonPressed(int _left, int _top, MouseButton _id);
122  virtual void onMouseButtonReleased(int _left, int _top, MouseButton _id);
123 
124  private:
125  MenuCtrl* mOwner;
126 
127  };
128 
129 } // namespace MyGUI
130 
131 #endif // __MYGUI_MENU_ITEM_H__