[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

 

LMenuBar



Description:

LMenuBar is a PowerPlant class that is used for managing the menu bar.

Methods :

The methods in this class are:

 

LMenuBar()  
~LMenuBar()  
CouldBeKeyCommand()  
FetchMenu()  
FindCommand()  
FindKeyCommand()  
FindMenuItem()  
FindNextCommand()  
FindNextMenu()  
GetCurrentMenuBar()  
InstallMenu()  
MenuCommandSelection()  
RemoveMenu()  
 

Data Members:

The data members in this class are:

 

sMenuBar  
mMenuListHead  

Operation:

For detailed information on how to use this class, refer to The PowerPlant Book.

Source files:

(Support Classes)

LMenuBar.h

LMenuBar.cp

LMenuBar()

Purpose:

The constructor creates the menu bar.

Access:

Public

Prototype:

LMenuBar( ResIDT inMBARid );
Parameters:

This constructor has the following parameter:

 

ResIDT  
inMBARid  
The resource ID of the menu bar.  

~LMenuBar()

Purpose:

The destructor destroys the object.

Access:

Virtual, Public

Prototype:

virtual ~LMenuBar();

CouldBeKeyCommand()

Purpose:

Return whether the keystoke could be a key equivalent for a menu command. Overrid this to implement keyboard equivalents that use modifier keys other than just the Command key.

Access:

Virtual, Public

Prototype:

virtual Boolean CouldBeKeyCommand(
const EventRecord &inKeyEvent ) const;
Parameters:

This method has the following parameter:

 

const   EventRecord&  
inKeyEvent  
The event for the key down.  

Return:

This function returns true if the command key is down.

FetchMenu()

Purpose:

Return the Menu object for the specified MENU resource ID Returns nil if there is no such Menu object

Access:

Public

Prototype:

LMenu *FetchMenu( ResIDT inMENUid ) const;
Parameters:

This method has the following parameter:

 

ResIDT  
inMENUid  
The menu resource ID.  

Return:

A pointer to an LMenu.

FindCommand()

Purpose:

Retrieve the Command number corresponding to a Menu (ID, item) pair.

Access:

Public

Prototype:

CommandT FindCommand( ResIDT inMENUid,
SInt16 inItem ) const;
Parameters:

This method has the following parameters:

 

ResIDT  
inMENUid  
The menu resource ID.  
SInt16  
inItem  
The menu item.  

Return:

Returns the command number.

FindKeyCommand()

Purpose:

Return the Command number corresponding to a keystroke. Call this function when CouldBeKeyCommand() is true. You should override this to implement keyboard equivalents that use modifier keys other than just the Command key.

Access:

Virtual, Public

Prototype:

virtual CommandT FindKeyCommand(
const EventRecord &inKeyEvent,
SInt32 &outMenuChoice ) const;
Parameters:

 

const   EventRecord &  
inKeyEvent  
The key down event.  
SInt32&  
outMenuChoice  
The menu choice.  

Return:

The command number. Returns cmd_Nothing if the keystroke is not a menu equivalent

Remarks:

This function calls the Toolbox routine MenuKey to find the associated menu item, if any. Override this function (as well as CouldBeKeyCommand) to implement key equivalents that use other modifier keys, such as Option, Shift, or Control.

FindMenuItem()

Purpose:

Passes back the MENU id, MenuHandle, and item number corresponding to a Command number.

If the Command is not associated with any item in the MenuBar, outMENUid is 0, outMenuHandle is nil, and outItem is 0.

Access:

Public

Prototype:

void FindMenuItem(
CommandT inCommand,
ResIDT &outMENUid,
MenuHandle &outMenuHandle,
SInt16 &outItem);
Parameters:

This method has the following parameter:

 

ResIDT  
outMENUid  
The menu resource ID.  
SInt16  
outItem  
The menu item.  
CommandT  
inCommand  
The command.  
MenuHandle  
outMenuHandle  
A handle to the menu.  

Return:

None

Remarks:

None

FindNextCommand()

Purpose:

Find the next command.

Access:

Public

Prototype:

Boolean FindNextCommand(
SInt16 &ioIndex,
MenuHandle &ioMenuHandle,
LMenu* &ioMenu,
CommandT &outCommand );
Parameters:

This method has the following parameters:

 

LMenu*  
ioMenu  
The menu pointer.  
SInt16&  
ioIndex  
The index.  
CommandT&  
outCommand  
The command.  
MenuHandle&  
ioMenuHandle  
A handle to the menu.  

Return:

Return true if the command is found, else return false.

FindNextMenu()

Purpose:

Find the next menu in the menu bar.

Access:

Public

Prototype:

Boolean FindNextMenu( LMenu* &ioMenu ) const;
Parameters:

This method has the following parameter:

 

LMenu*&  
ioMenu  
The menu pointer.  

Return:

Return true if a menu was found, else return false.

GetCurrentMenuBar()

Purpose:

Retrieve the menu bar.

Access:

Static, Public

Prototype:

static LMenuBar* GetCurrentMenuBar();
Parameters:

None

Return:

The pointer to the menu bar.

InstallMenu()

Purpose:

Install a Menu object in the MenuBar

Access:

Public

Prototype:

void InstallMenu(
LMenu *inMenuToInstall,
ResIDT ioMenuHandle );
Parameters:

This method has the following parameters:

 

LMenu*  
inMenuToInstall  
The menu to install in the menu bar.  
ResIDT  
ioMenuHandle  
The resource ID for the menu.  

Return:

None

MenuCommandSelection()

Purpose:

Handle menu selection with the Mouse and return the command number for the item chosen. Override this method to implement alternative menu selection behavior.

Access:

Virtual, Public

Prototype:

virtual CommandT MenuCommandSelection(
const EventRecord &inMouseEvent,
SInt32 &outMenuChoice ) const;
Parameters:

This method has the following parameters:

 

const   EventRecord&  
inMouseEvent  
The mouse event information.  
SInt32&  
outMenuChoice  
The menu choice.  

Return:

The command number.

RemoveMenu()

Purpose:

Remove a Menu object from the menu bar.

Access:

Public

Prototype:

void RemoveMenu( LMenu *inMenuToRemove );
Parameters:

This method has the following parameters:

 

LMenu*  
inMenuToRemove  
The menu to remove.  

Return:

None

sMenuBar

Purpose:

Storage for the menu bar pointer.

Access:

Protected

Prototype:

static LMenuBar *sMenuBar;

mMenuListHead

Purpose:

The menu list head.

Access:

Protected

Prototype:

LMenu *mMenuListHead;

[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: July 21, 2000