LMenu is a PowerPlant class that is used for managing a Mac OS menu. This class maintains a mapping between Menu items and Command numbers.
Methods :
The methods in this class are:
Data Members:
The data members in this class are:
Operation:
To learn more about effectively using the LMenu class, refer to The PowerPlant Book for a lengthy discussion on the topic.
Source Files:
Purpose:
The constructors create objects from the passed-in parameters.
Access:
Prototypes:
LMenu();
LMenu( ResIDT inMENUid);
LMenu( SInt16 inMENUid,Str255 inTitle );Parameters:
The parameters for these constructors are:
Purpose:
The destructor destroys the LMenu object.
Access:
Prototype:
~LMenu();
Purpose:
Return the command number for a particular Menu item.
Access:
Prototype:
CommandT CommandFromIndex( SInt16 inIndex ) const;Parameters:
The parameter for this method is:
Return:
Purpose:
Access:
Prototype:
Boolean FindNextCommand( SInt16 &ioIndex,Parameters:
CommandT &outCommand ) const;
The parameters for this method are:
Return:
Returns true if the command is found.
Purpose:
Access:
Prototype:
MenuHandle GetMacMenuH() const;Parameters:
Return:
Purpose:
Access:
Prototype:
ResIDT GetMenuID() const;Parameters:
Return:
Purpose:
Access:
Prototype:
LMenu* GetNextMenu() const;Parameters:
Return:
A pointer to the LMenu object.
Purpose:
Return the Menu item index number for a particular command number Return 0 if the command number is not used for this Men
Access:
Prototype:
SInt16 IndexFromCommand(Parameters:
CommandT inCommand ) const;
The parameter for this method is:
Return:
Purpose:
Insert an item with the specified text and command number afterparticular item.
Access:
Prototype:
void InsertCommand( ConstStringPtr inItemText,Parameters:
CommandT inCommand,
SInt16 inAfterItem );
The parameters for this method are:
Return:
Remarks:
This function does not support adding multiple menu items using
"Return" or "Semicolon" characters within inItemText.
Purpose:
Retrieves the value of mIsInstalled.
Access:
Prototype:
Boolean IsInstalled() const;Parameters:
Return:
The value of mIsInstalled.
Purpose:
Retrieves the value of mUsed.
Access:
Prototype:
Boolean IsUsed() const;Parameters:
Return:
The value of mUsed.
Purpose:
Return whether an item at the specified position is enabled.
Access:
Prototype:
Boolean ItemIsEnabled( SInt16 inIndex ) const;Parameters:
The parameter for this method is:
Return:
Returns true if enabled, else false.
Purpose:
Get command numbers from the 'Mcmd' resource. A 'Mcmd" resource with the same ID as the 'MENU' resource contains a list of command numbers. The format of a
'Mcmd' resource is:
Prototype:
void ReadCommandNumbers();Parameters:
Return:
Purpose:
Remove the Menu item with the specified command.
Access:
Prototype:
void RemoveCommand( CommandT inCommand );Parameters:
The parameter for this method is:
Return:
Purpose:
Remove the Menu item at the specified position.
Access:
Prototype:
void RemoveItem( SInt16 inItemToRemove );Parameters:
The parameter for this method is:
Return:
Purpose:
Set the command number for a Menu item.
Access:
Prototype:
void SetCommand(Parameters:
SInt16 inIndex,
CommandT inCommand );
The parameters for this method are:
Return:
Purpose:
Sets the value of the mIsInstalled data member.
Access:
Prototype:
void SetInstalled(Boolean inInstalled);Parameters:
The parameter for this method is:
Return:
Purpose:
Access:
Prototype:
void SetNextMenu( LMenu *inMenu );Parameters:
The parameter for this method is:
Return:
Purpose:
This method sets the value of the mUsed data member.
Access:
Prototype:
void SetUsed( Boolean inUsed );Parameters:
The parameter for this method is:
Return:
Purpose:
Retrieve the synthetic command number for a particular Menu item.
A synthetic command number has the MENU id in the high 16 bits
and the item number in the low 16 bits, and the resulting 32-bit
number is negated (to distinguish it from regular command numbers).
The synthetic command number is the negative of the value that
would be returned by the Toolbox trap MenuSelect() for the menu item.
Access:
Prototype:
CommandT SyntheticCommandFromIndex(Parameters:
SInt16 inIndex ) const;
The parameter for this method is:
Return:
The command for the Menu item.
Purpose:
Access:
Prototype:
LMenu *mNextMenu;
Purpose:
Access:
Prototype:
MenuHandle mMacMenuH;
Purpose:
Access:
Prototype:
ResIDT mMENUid;
Purpose:
Access:
Prototype:
Purpose:
Access:
Prototype:
CommandT **mCommandNums;
Purpose:
Storage for detecting installation.
Access:
Prototype:
Boolean mIsInstalled;
Purpose:
Indicates whether used or not.
Access:
Prototype:
Boolean mUsed;