Irrlicht 3D Engine
IGUIContextMenu.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4 
5 #ifndef __I_GUI_CONTEXT_MENU_H_INCLUDED__
6 #define __I_GUI_CONTEXT_MENU_H_INCLUDED__
7 
8 #include "IGUIElement.h"
9 
10 namespace irr
11 {
12 namespace gui
13 {
17  {
20 
23 
26 
27  // note to implementors - this is planned as bitset, so continue with 4 if you need to add further flags.
28  };
29 
31 
36  {
37  public:
38 
40  IGUIContextMenu(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
41  : IGUIElement(EGUIET_CONTEXT_MENU, environment, parent, id, rectangle) {}
42 
44  virtual void setCloseHandling(ECONTEXT_MENU_CLOSE onClose) = 0;
45 
47  virtual ECONTEXT_MENU_CLOSE getCloseHandling() const = 0;
48 
50  virtual u32 getItemCount() const = 0;
51 
53 
64  virtual u32 addItem(const wchar_t* text, s32 commandId=-1, bool enabled=true,
65  bool hasSubMenu=false, bool checked=false, bool autoChecking=false) = 0;
66 
68 
81  virtual u32 insertItem(u32 idx, const wchar_t* text, s32 commandId=-1, bool enabled=true,
82  bool hasSubMenu=false, bool checked=false, bool autoChecking=false) = 0;
83 
85 
89  virtual s32 findItemWithCommandId(s32 commandId, u32 idxStartSearch=0) const = 0;
90 
92  virtual void addSeparator() = 0;
93 
95 
96  virtual const wchar_t* getItemText(u32 idx) const = 0;
97 
99 
101  virtual void setItemText(u32 idx, const wchar_t* text) = 0;
102 
104 
105  virtual bool isItemEnabled(u32 idx) const = 0;
106 
108 
110  virtual void setItemEnabled(u32 idx, bool enabled) = 0;
111 
113 
115  virtual void setItemChecked(u32 idx, bool enabled) = 0;
116 
118 
119  virtual bool isItemChecked(u32 idx) const = 0;
120 
122 
123  virtual void removeItem(u32 idx) = 0;
124 
126  virtual void removeAllItems() = 0;
127 
129 
130  virtual s32 getSelectedItem() const = 0;
131 
133 
134  virtual s32 getItemCommandId(u32 idx) const = 0;
135 
137 
140  virtual void setItemCommandId(u32 idx, s32 id) = 0;
141 
143 
146  virtual IGUIContextMenu* getSubMenu(u32 idx) const = 0;
147 
149  virtual void setItemAutoChecking(u32 idx, bool autoChecking) = 0;
150 
152  virtual bool getItemAutoChecking(u32 idx) const = 0;
153 
155  virtual void setEventParent(IGUIElement *parent) = 0;
156  };
157 
158 } // end namespace gui
159 } // end namespace irr
160 
161 #endif
162 
irr::gui::IGUIContextMenu::isItemEnabled
virtual bool isItemEnabled(u32 idx) const =0
Check if a menu item is enabled.
irr::gui::IGUIContextMenu::findItemWithCommandId
virtual s32 findItemWithCommandId(s32 commandId, u32 idxStartSearch=0) const =0
Find an item by it's CommandID.
irr::gui::IGUIContextMenu::getItemCommandId
virtual s32 getItemCommandId(u32 idx) const =0
Get the command id of a menu item.
irr::gui::IGUIContextMenu::getItemAutoChecking
virtual bool getItemAutoChecking(u32 idx) const =0
does the element change the checked status on clicking
irr::gui::ECONTEXT_MENU_CLOSE
ECONTEXT_MENU_CLOSE
Definition: IGUIContextMenu.h:16
irr::gui::IGUIContextMenu::setEventParent
virtual void setEventParent(IGUIElement *parent)=0
When an eventparent is set it receives events instead of the usual parent element.
irr::gui::IGUIContextMenu::removeAllItems
virtual void removeAllItems()=0
Removes all menu items.
irr::gui::IGUIContextMenu::addSeparator
virtual void addSeparator()=0
Adds a separator item to the menu.
irr::gui::ECMC_REMOVE
@ ECMC_REMOVE
remove the gui element
Definition: IGUIContextMenu.h:22
irr::gui::IGUIContextMenu::getCloseHandling
virtual ECONTEXT_MENU_CLOSE getCloseHandling() const =0
get current behavior when the menu will be closed
irr::gui::IGUIContextMenu::setItemChecked
virtual void setItemChecked(u32 idx, bool enabled)=0
Sets if the menu item should be checked.
irr::gui::IGUIContextMenu::addItem
virtual u32 addItem(const wchar_t *text, s32 commandId=-1, bool enabled=true, bool hasSubMenu=false, bool checked=false, bool autoChecking=false)=0
Adds a menu item.
irr::gui::IGUIContextMenu::setItemEnabled
virtual void setItemEnabled(u32 idx, bool enabled)=0
Sets if the menu item should be enabled.
irr::s32
signed int s32
32 bit signed variable.
Definition: irrTypes.h:66
irr::gui::ECMC_IGNORE
@ ECMC_IGNORE
do nothing - menu stays open
Definition: IGUIContextMenu.h:19
irr::gui::IGUIContextMenu::insertItem
virtual u32 insertItem(u32 idx, const wchar_t *text, s32 commandId=-1, bool enabled=true, bool hasSubMenu=false, bool checked=false, bool autoChecking=false)=0
Insert a menu item at specified position.
irr::gui::IGUIContextMenu::setCloseHandling
virtual void setCloseHandling(ECONTEXT_MENU_CLOSE onClose)=0
set behavior when menus are closed
irr::gui::IGUIContextMenu::getItemText
virtual const wchar_t * getItemText(u32 idx) const =0
Get text of the menu item.
irr::gui::IGUIContextMenu::IGUIContextMenu
IGUIContextMenu(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect< s32 > rectangle)
constructor
Definition: IGUIContextMenu.h:40
irr::gui::IGUIContextMenu
GUI Context menu interface.
Definition: IGUIContextMenu.h:35
irr::gui::IGUIContextMenu::setItemAutoChecking
virtual void setItemAutoChecking(u32 idx, bool autoChecking)=0
should the element change the checked status on clicking
irr::gui::IGUIContextMenu::getItemCount
virtual u32 getItemCount() const =0
Get amount of menu items.
IGUIElement.h
irr::gui::IGUIContextMenu::getSelectedItem
virtual s32 getSelectedItem() const =0
Get the selected item in the menu.
irr::gui::IGUIContextMenu::removeItem
virtual void removeItem(u32 idx)=0
Removes a menu item.
irr::gui::IGUIContextMenu::setItemText
virtual void setItemText(u32 idx, const wchar_t *text)=0
Sets text of the menu item.
irr
Everything in the Irrlicht Engine can be found in this namespace.
Definition: aabbox3d.h:12
irr::core::rect< s32 >
irr::u32
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:58
irr::gui::IGUIContextMenu::getSubMenu
virtual IGUIContextMenu * getSubMenu(u32 idx) const =0
Get a pointer to the submenu of an item.
irr::gui::ECMC_HIDE
@ ECMC_HIDE
call setVisible(false)
Definition: IGUIContextMenu.h:25
irr::gui::IGUIEnvironment
GUI Environment. Used as factory and manager of all other GUI elements.
Definition: IGUIEnvironment.h:70
irr::gui::IGUIContextMenu::isItemChecked
virtual bool isItemChecked(u32 idx) const =0
Check if a menu item is checked.
irr::gui::IGUIContextMenu::setItemCommandId
virtual void setItemCommandId(u32 idx, s32 id)=0
Sets the command id of a menu item.
irr::gui::IGUIElement
Base class of all GUI elements.
Definition: IGUIElement.h:25
irr::gui::EGUIET_CONTEXT_MENU
@ EGUIET_CONTEXT_MENU
A context menu (IGUIContextMenu)
Definition: EGUIElementTypes.h:29