Class IMenuItem

3DS Max Plug-In SDK

Class IMenuItem

See Also: Class IMenuElement, Class IMenuGlobalContext, Class IMenuLocalContext, Class ActionItem, Class IMenu, Class MaxIcon , Class IQuadMenuSettings

class IMenuItem : public IMenuElement, public FPMixinInterface

Description:

This class is available in release 4.0 and later only.

This abstract class represents an interface for a menu item. Methods that are marked as internal should not be used.

Methods:

public:

Prototype:

virtual void SetIMenuLocalContext(IMenuLocalContext* pIMenuLocalContext) = 0;

Remarks:

This method is used internally.

This method allows you to set a new (local) context for the menu, invalidating the menu’s cache.

Parameters:

IMenuLocalContext* pIMenuLocalContext

A pointer to the new local context object you wish to set.

Prototype:

virtual ActionMode GetActionMode() const = 0;

Remarks:

This method returns the current action mode. When item selection instigates an action item, calls functions, or displays a submenu the action mode changes to indicate the exact state the system is in.

Return Value:

Either of the following; AM_INACTIVE, AM_SEPARATOR, AM_ITEM, AM_FN, AM_SUBMENU, AM_ITEM_SUBMENU

Prototype:

virtual bool ExecuteAction() const = 0;

Remarks:

This method will execute the current action.

Return Value:

TRUE if the action was executed successfully, otherwise FALSE.

Prototype:

virtual void ActAsSeparator() = 0;

Remarks:

This method allows you to make the item act as an item seperator.

Prototype:

virtual bool IsSeparator() const = 0;

Remarks:

This method determines if the item is acting as a seperator (TRUE) or not (FALSE).

Prototype:

virtual void SetActionItem(ActionItem* pActionItem) = 0;

Remarks:

This method allows you to set the current action item. Note that GetActionItem() returns NULL if the ActionMode is not AM_ITEM.

Parameters:

ActionItem* pActionItem

The action item you wish to set.

Prototype:

virtual ActionItem* GetActionItem() const = 0;

Remarks:

This method returns a pointer to the current action item, or NULL if the ActionMode is not AM_ITEM.

Prototype:

virtual void SetActionFn(ActionFn actionFn) = 0;

Remarks:

This method allows you to set the current action function. Note that GetActionFn() returns NULL if the ActionMode is not AM_FN. A

lso note: typedef void (* ActionFn)(void);

Parameters:

ActionFn actionFn

The action function you wish to set.

Prototype:

virtual const ActionFn GetActionFn() const = 0;

Remarks:

This method returns the current action function, or NULL if the ActionMode is not AM_FN.

Note: typedef void (* ActionFn)(void);

Prototype:

virtual void SetSubMenu(IMenu* menu) = 0;

Remarks:

This method allows you to set the submenu. Note that GetSubMenu() returns NULL if the ActionMode is not AM_SUBMENU.

Parameters:

IMenu* menu

The submenu you wish to set.

Prototype:

virtual IMenu* GetSubMenu() = 0;

Remarks:

This method returns a pointer to the submenu, or NULL if the ActionMode is not AM_SUBMENU.

Prototype:

virtual void SetPreDisplayCB(PreDisplayCB preDisplayCB) = 0;

Remarks:

This method allows you to set the pre-display callback.

Note: typedef void (* PreDisplayCB)(IMenuItem& menuItem);

Parameters:

PreDisplayCB preDisplayCB

The callback to set.

Prototype:

virtual const PreDisplayCB GetPreDisplayCB() const = 0;

Remarks:

This method returns the pre-display callback.

Prototype:

virtual void Display(bool leftToRight) = 0;

Remarks:

This method is used internally.

Prototype:

virtual TCHAR GetAccelerator() = 0;

Remarks:

This method is used internally.

This method returns the item’s accelerator, or 0 if none is assigned.

Prototype:

virtual void SetIcon(MaxIcon* pMaxIcon) = 0;

Remarks:

This method allows you to set the item’s icon.

Parameters:

MaxIcon* pMaxIcon

A pointer to a MaxIcon to set.

Prototype:

virtual const MaxIcon* GetIcon() const = 0;

Remarks:

This method returns a pointer to the item’s icon.

Prototype:

virtual void SetChecked(bool checked) = 0;

Remarks:

This method allows you to set the checked state of the item.

Parameters:

bool checked

TRUE to check the item, FALSE to uncheck the item.

Prototype:

virtual bool GetChecked() = 0;

Remarks:

This method returns TRUE if the item is checked or FALSE if it is unchecked.

Prototype:

virtual void SetHighlighted(bool highlighted) = 0;

Remarks:

This method allows you to set the highlighted state of the item.

Parameters:

bool highlighted

TRUE to highlight the item, FALSE if you do not want to highlight the item.

Prototype:

virtual bool GetHighlighted() const = 0;

Remarks:

This method returns TRUE if the item is highlighted, otherwise FALSE.

Prototype:

virtual void SetUseCustomTitle(bool useCustomTitle) = 0;

Remarks:

This method allows you to tell the item it should use a custom title, which is set through SetTitle().

Parameters:

bool useCustomTitle

TRUE to use a custom title, FALSE to use the default.

Prototype:

virtual bool GetUseCustomTitle() const = 0;

Remarks:

This method returns TRUE if the item is using a custom title or FALSE if it’s using a default.

Prototype:

virtual void SetDisplayFlat(bool displayFlat) = 0;

Remarks:

This method allows you to set whether the submenu-item should be displayed ‘flat’.

Parameters:

bool displayFlat

TRUE to set to flat, otherwise FALSE.

Prototype:

virtual bool GetDisplayFlat() const = 0;

Remarks:

This method returns TRUE if the submenu-item should be displayed ‘flat’, otherwise FALSE.

Prototype:

virtual void PostMenuInteraction() = 0;

Remarks:

This method is used internally.

This method is called after the user/menu interaction is done after which it will clear the caches for ActionItem handler values.

The following functions are not part of the class but are available for use.

Function:

IMenuItem * GetIMenuItem();

Remarks:

This method will return a pointer to the IMenuItem.

Prototype:

void ReleaseIMenuItem(IMenuItem *);

Remarks:

This method will release the specified IMenuItem.

Parameters:

IMenuItem *

A pointer to the IMenuItem you wish to release.