class LM_Menu

The LM_Menu class represents a list of commands. A menu by itself does not appear in the user interface - it must be attached to an LM_PopupMenu widget in order to be placed in a dialog box or toolbar. To create a new menu, you would use the following function:


LM_Menu LM.GUI.Menu(title)

Creates a new LM_Menu object that can then be added to a dialog or toolbar.

Return value (LM_Menu): the newly-created menu
title (string): the menu's title

Member Functions

void AddItem(label, shortcut, msg)

Adds a new command to the bottom of the menu.

Return value: none
label (string): the item's text label
shortcut (char): a shortcut key used to trigger the menu command
msg (int): the message value to send when the command is selected by the user

void AddItemAlphabetically(label, shortcut, msg)

Adds a new command alphabetically to the menu.

Return value: none
label (string): the item's text label
shortcut (char): a shortcut key used to trigger the menu command
msg (int): the message value to send when the command is selected by the user

int CountItems()

Returns the number of commands in the menu.

Return value (int): the number of commands in the menu

void RemoveAllItems()

Removes all commands from a menu, leaving the menu empty.

Return value: none

void SetEnabled(msg, enabled)

Enables or disables a menu command.

Return value: none
msg (int): the message value of the desired command
enabled (bool): true to enable the command, false to disable it

bool IsEnabled(msg)

Checks the enabled status of a menu command.

Return value (bool): true if enabled, false if disabled
msg (int): the message value of the desired command

void SetChecked(msg, checked)

Attaches a checkmark to a menu command.

Return value: none
msg (int): the message value of the desired command
checked (bool): true to add a checkmark, false to remove a checkmark

void SetCheckedLabel(label, checked)

Attaches a checkmark to a menu command.

Return value: none
label (string): the text label of the matching menu command
checked (bool): true to add a checkmark, false to remove a checkmark

bool IsChecked(msg)

Tests whether a menu command is checked.

Return value (bool): true if check, false otherwise
msg (int): the message value of the desired command

void UncheckAll()

Un-checks all commands in the menu.

Return value: none

int FirstChecked()

Returns the id of the first checked command in the menu (starting at 0 for the first item).

Return value (int): the id of the first checked command in the menu

int FirstCheckedMsg()

Returns the message value of the first checked command in the menu.

Return value (int): the message value of the first checked command in the menu

string FirstCheckedLabel()

Returns the text label of the first checked command in the menu.

Return value (string): the text label of the first checked command in the menu

string ItemLabel(msg)

Returns the text label of a command in the menu.

Return value (string): the text label of a command in the menu
msg (int): the message value of the desired command
class LM_Menu : public LM_Layer {
  void AddItem(const char *label, char shortcut, int32 msg);
  void AddItemAlphabetically(const char *label, char shortcut, int32 msg);
  int32 CountItems();
  void RemoveAllItems();
 
  void SetEnabled(int32 msg, bool enabled);
  bool IsEnabled(int32 msg);
  void SetChecked(int32 msg, bool checked);
  void SetChecked @ SetCheckedLabel(const char *label, bool checked);
  bool IsChecked(int32 msg);
  void UncheckAll();
  int32 FirstChecked();
  int32 FirstCheckedMsg();
  const char *FirstCheckedLabel();
  const char *ItemLabel(int32 msg);
};