Main Index : Reference :

MenuPlugin


Description

A menu plugin class.

Definition

class MenuPlugin : BasePlugin
{
public:
  MenuPlugin();
  
  [string] GetName() = 0;
  [string] GetHelp() = 0;
  
  [BaseBitmap] GetIcon();
  [bool] GetIconState();
  
  [int] GetState();
  
  [bool] Execute([BaseDocument] doc, [BaseObject] op) = 0;

  [bool] RestoreLayout([int] secret);
}

Explanation

A class to derive menu plugins from.

Members

GetName()

[string] GetName() = 0;

Should return the menu entry for the plugin. Must be overloaded in derived classes.

GetHelp()

[string] GetHelp() = 0;

Should return a help text for the menu entry. This is shown in the command manager and bubble help. Must be overloaded in derived classes.


GetIcon()

[BaseBitmap] GetIcon();

Overload this function and return a bitmap to show an icon in the menu and in the command manager.

GetIconState()

[bool] GetIconState();

Overload this function to control the enabled/disabled state of the icon.


GetState()

[int] GetState();

Overload this function to control the enabled/disabled and checkmark state of the menu entry. Possible return values are combinations of the following flags:

Flag Explanation
0 Disabled and not checked
CMD_ENABLED Enabled
CMD_CHECKED Checked


Execute()

[bool] Execute([BaseDocument] doc, [BaseObject] op) = 0;

Called when the plugin is chosen. Must be overloaded in derived classes.


RestoreLayout( secret )

[bool] RestoreLayout([int] secret);

If one's menu plugin brings up an asynchronous dialog, one should overload this functions. It will be called when C4D needs to open the dialog again, for example if it has been added to the users layout and the program has been restarted. The overloaded function should look like this:

MyMenuPlugin::RestoreLayout(secret)
{
  // 'd' is the member variable that 
  // holds the dialog object.
  
  if (!d) d = new(MyAsyncDialog);
  d->RestoreLayout(secret);
}