2007-05-20 11:03:49 -07:00
|
|
|
// Copyright (C) 2002-2007 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#ifndef __I_GUI_CONTEXT_MENU_H_INCLUDED__
|
|
|
|
#define __I_GUI_CONTEXT_MENU_H_INCLUDED__
|
|
|
|
|
|
|
|
#include "IGUIElement.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace gui
|
|
|
|
{
|
|
|
|
|
|
|
|
//! GUI Context menu interface.
|
|
|
|
class IGUIContextMenu : public IGUIElement
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
IGUIContextMenu(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
|
|
|
|
: IGUIElement(EGUIET_CONTEXT_MENU, environment, parent, id, rectangle) {}
|
|
|
|
|
|
|
|
//! destructor
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual ~IGUIContextMenu() {};
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Get amount of menu items
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual u32 getItemCount() const = 0;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Adds a menu item.
|
|
|
|
/** \param text: Text of menu item. Set this to 0 to create
|
|
|
|
an separator instead of a real item, which is the same like
|
|
|
|
calling addSeparator();
|
|
|
|
\param commandId: Command id of menu item, a simple id you may
|
|
|
|
set to whatever you want.
|
|
|
|
\param enabled: Specifies if the menu item should be enabled.
|
|
|
|
\param hasSubMenu: Set this to true if there should be a submenu
|
|
|
|
at this item. You can acess this submenu via getSubMenu().
|
|
|
|
\param checked: Specifies if the menu item should be initially checked.
|
|
|
|
\return Returns the index of the new item */
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual u32 addItem(const wchar_t* text, s32 commandId=-1, bool enabled=true,
|
2007-05-20 11:03:49 -07:00
|
|
|
bool hasSubMenu=false,
|
|
|
|
bool checked=false
|
|
|
|
) = 0;
|
|
|
|
|
|
|
|
//! Adds a separator item to the menu
|
|
|
|
virtual void addSeparator() = 0;
|
|
|
|
|
|
|
|
//! Get text of the menu item.
|
|
|
|
/** \param idx: Zero based index of the menu item */
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual const wchar_t* getItemText(u32 idx) const = 0;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Sets text of the menu item.
|
|
|
|
/** \param idx: Zero based index of the menu item
|
|
|
|
\param text: New text of the item. */
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual void setItemText(u32 idx, const wchar_t* text) = 0;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Check if a menu item is enabled
|
|
|
|
/** \param idx: Zero based index of the menu item */
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual bool isItemEnabled(u32 idx) const = 0;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Sets if the menu item should be enabled.
|
|
|
|
/** \param idx: Zero based index of the menu item
|
|
|
|
\param enabled: True if it is enabled, otherwise false. */
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual void setItemEnabled(u32 idx, bool enabled) = 0;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Sets if the menu item should be checked.
|
|
|
|
/** \param idx: Zero based index of the menu item
|
|
|
|
\param enabled: True if it is enabled, otherwise false. */
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual void setItemChecked(u32 idx, bool enabled) = 0;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2007-05-26 13:44:25 -07:00
|
|
|
//! Check if a menu item is checked
|
|
|
|
/** \param idx: Zero based index of the menu item */
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual bool isItemChecked(u32 idx) const = 0;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Removes a menu item
|
|
|
|
/** \param idx: Zero based index of the menu item */
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual void removeItem(u32 idx) = 0;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Removes all menu items
|
|
|
|
virtual void removeAllItems() = 0;
|
|
|
|
|
|
|
|
//! Get the selected item in the menu
|
|
|
|
/** \return Index of the selected item, -1 if none selected. */
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual s32 getSelectedItem() const = 0;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Get the command id of a menu item
|
|
|
|
/** \param idx: Zero based index of the menu item */
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual s32 getItemCommandId(u32 idx) const = 0;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Sets the command id of a menu item
|
|
|
|
/** \param idx: Zero based index of the menu item
|
|
|
|
\param id: Command id of menu item, a simple id you may
|
|
|
|
set to whatever you want. */
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual void setItemCommandId(u32 idx, s32 id) = 0;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Get a pointer to the submenu of an item.
|
|
|
|
/** 0 is returned if there is no submenu
|
|
|
|
\param idx: Zero based index of the menu item
|
|
|
|
\return Returns a pointer to the submenu of an item. */
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual IGUIContextMenu* getSubMenu(u32 idx) const = 0;
|
2007-05-20 11:03:49 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace gui
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|