Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_Menu Class Reference

A class for representing a platforms menu object. More...

Inheritance diagram for CP_Menu:

CP_Menu_Imp CP_M_RefCounted CP_NoCopy List of all members.

Public Member Functions

Constructor / Destructor
 CP_Menu ()
 Constructor.
 CP_Menu (SInt16 inMenuID, const CP_String &inMenuTitle, bool inPopup=false)
 CP_Menu (const CP_String &inMenuTitle)
 CP_Menu (SInt16 inMenuID, const CP_String &inMenuTitle, OSMenu inOSMenu)
 CP_Menu (OSMenu innMenu)
virtual ~CP_Menu () throw ()
 Destructor.
Commands
virtual CP_CommandNo GetCommandNo (SInt16 inMenuItemIndex)
Getters
OSMenu GetOSMenu ()
SInt16 GetMenuItemCount ()
CP_String GetTitle () const
SInt16 GetID ()
CP_CommandNo GetCommand (SInt16 inItemIndex)
SInt16 GetCommandItemIndex (const CP_CommandNo inCommand)
CP_String GetItemText (SInt16 inItemIndex)
Items
void AppendItem (const CP_String &inItemText, CP_CommandNo inCommand)
void DeleteItem (UInt16 inItemIndex)
Setters
void SetTitle (const CP_String &inTitle)
void SetItemMark (CP_CommandNo inCommand, SInt16 inItemMark, bool inHasMark)
void SetItemMark (SInt16 inIndex, SInt16 inItemMark, bool inHasMark)
Commands
virtual CP_CommandNo GetCommandNo (SInt16 inMenuItemIndex)
Getters
OSMenu GetOSMenu ()
SInt16 GetMenuItemCount ()
CP_String GetTitle () const
SInt16 GetID ()
CP_CommandNo GetCommand (SInt16 inItemIndex)
SInt16 GetCommandItemIndex (const CP_CommandNo inCommand)
CP_String GetItemText (SInt16 inItemIndex)
Items
void AppendItem (const CP_String &inItemText, CP_CommandNo inCommand)
void DeleteItem (UInt16 inItemIndex)
Setters
void SetTitle (const CP_String &inTitle)
void SetItemMark (CP_CommandNo inCommand, SInt16 inItemMark, bool inHasMark)
void SetItemMark (SInt16 inIndex, SInt16 inItemMark, bool inHasMark)

Protected Member Functions

OSMenu
void LoadOSMenu (SInt16 inMenuID, bool inPopup=false)
OSMenu
void LoadOSMenu (SInt16 inMenuID, bool inPopup=false)

Protected Attributes

SInt16 fMenuID
OSMenu fOSMenu
CP_MenuImp_List fSubMenus

Detailed Description

This class is implemented for each of the supported platforms through a CP_Menu_Imp class.

The menu class is also reference counted in case the menu is used in more than one place, and the underlying OS shares a copy of the native menu.


Constructor & Destructor Documentation

CPLAT_Begin_Namespace_CPLAT CP_Menu::CP_Menu  ) 
 

Constructor. This creates an empty menu. You will need to do the actual creation of the underlying OSMenu before being able to use this object.

CP_Menu::CP_Menu SInt16  inMenuID,
const CP_String inMenuTitle,
bool  inPopup = false
 

Constructor. This version creates the underlying OSMenu from the passed in menu resource id.

Parameters:
inMenuID Resource id of the menu.
inMenuTitle Title of the menu.

CP_Menu::CP_Menu const CP_String inMenuTitle  ) 
 

CP_Menu::CP_Menu SInt16  inMenuID,
const CP_String inMenuTitle,
OSMenu  inOSMenu
 

Constructor. This version creates the underlying OSMenu from the passed in menu resource id.

Parameters:
inMenuID Resource id of the menu.
inMenuTitle Title of the menu.
inOSMenu OSMenu for this menu.

CP_Menu::CP_Menu OSMenu  innMenu  ) 
 

CP_Menu::~CP_Menu  )  throw () [virtual]
 

Destructor.


Member Function Documentation

CP_CommandNo CP_Menu_Imp::GetCommandNo SInt16  inMenuItemIndex  )  [virtual, inherited]
 

Returns the CP_CommandNo associated with the menu item at the passed in 1 based index.

Parameters:
inMenuItemIndex 1 based index of the menu item to return the command for.
Exceptions:
OSErr 
Returns:
CP_CommandNo The command associated with the menu item.

OSMenu CP_Menu_Imp::GetOSMenu  )  [inherited]
 

Return the MacOS platform menu reference.

Exceptions:
none 
Returns:
OSMenu MacOS menu reference.

SInt16 CP_Menu_Imp::GetMenuItemCount  )  [inherited]
 

Returns the number of menu items in this menu. If this is an Apple menu, then 1 is returned for the count.

Exceptions:
none 
Returns:
UInt16 Number of menu items.

CP_String CP_Menu_Imp::GetTitle  )  const [inherited]
 

Returns the menu title as a CP_String.

Exceptions:
none 
Returns:
CP_String const The menu title.

SInt16 CP_Menu_Imp::GetID  )  [inherited]
 

Return the ID of this menu.

Exceptions:
none 
Returns:
SInt16 ID of this menu.

CP_CommandNo CP_Menu_Imp::GetCommand SInt16  inItemIndex  )  [inherited]
 

SInt16 CP_Menu_Imp::GetCommandItemIndex const CP_CommandNo  inCommand  )  [inherited]
 

CP_String CP_Menu_Imp::GetItemText SInt16  inItemIndex  )  [inherited]
 

void CP_Menu_Imp::AppendItem const CP_String inItemText,
CP_CommandNo  inCommand
[inherited]
 

Appends the passed in item to this menu.

Parameters:
inItemText The text of the item being appended.
inCommand The command of the item being appended.
Exceptions:
OSErr 
Returns:
void

void CP_Menu_Imp::DeleteItem UInt16  inItemIndex  )  [inherited]
 

Deletes the menu item with the passed in inItemIndex which is 1 based, and should be between 1 and the number of items in this menu.

Parameters:
inItemIndex The 1 based index of the item to delete.
Exceptions:
none 
Returns:
void

void CP_Menu_Imp::SetTitle const CP_String inTitle  )  [inherited]
 

Sets the menu title from the passed in string.

Parameters:
inTitle The title of the menu.
Exceptions:
OSErr 
Returns:
void

void CP_Menu_Imp::SetItemMark CP_CommandNo  inCommand,
SInt16  inItemMark,
bool  inHasMark
[inherited]
 

Sets/remove the menu items mark to the passed in inItemMark.

Parameters:
inCommand The CP_CommandNo of the item being set.
inItemMark The character to use as the menu item mark.
inHasMark Flag to indicate if we are setting or removing the mark.
Exceptions:
OSErr 
Returns:
void

void CP_Menu_Imp::SetItemMark SInt16  inIndex,
SInt16  inItemMark,
bool  inHasMark
[inherited]
 

Sets/remove the menu items mark to the passed in inItemMark.

Parameters:
inIndex Index of the menu item being set.
inItemMark The character to use as the menu item mark.
inHasMark Flag to indicate if we are setting or removing the mark.
Exceptions:
OSErr 
Returns:
void

void CP_Menu_Imp::LoadOSMenu SInt16  inMenuID,
bool  inPopup = false
[protected, inherited]
 

Loads the MacOS menu reference with the passed in resource id. If no menu can be found a CP_ThrowIfResFail exception is thrown.

Under MacOSX if this is a menu with the id of kCP_FileMenuID a check will be made if there is a Quit item at the end of the menu, and if so it and its separator line (if any) will be removed from this menu.

Under MacOSX the edit menu is also checked for a preference item, and it will be removed like the above file menus quit item.

Parameters:
inMenuID Resource id of the menu to load.
inPopup Flag to indicate if this is a popup menu.
Exceptions:
CP_ThrowIfResFail If the menu could not be loaded.
Returns:
void

UInt32 CP_M_RefCounted::AddReference  )  const [inherited]
 

Add a reference to our object, returning the new reference count.

Exceptions:
none 
Returns:
UInt32 const Returns the new reference count.

UInt32 CP_M_RefCounted::RemoveReference  )  const [inherited]
 

Remove a reference to our object, returning the new reference count. If the count is 0, then this object is also deleted, and 0 is returned.

Exceptions:
none 
Returns:
UInt32 const Returns the new reference count.

void CP_M_RefCounted::Autorelease  )  const [inherited]
 

Add the object to the topmost auto-release pool. This will ensure that the object is eventually released.

See also:
CP_AutoReleasePool
Exceptions:
none 
Returns:
void

UInt32 CP_M_RefCounted::GetRefCount  )  const [inherited]
 

Returns the current ref count.

Exceptions:
none 
Returns:
UInt32 The current referencce count.


Member Data Documentation

SInt16 CP_Menu_Imp::fMenuID [protected, inherited]
 

OSMenu CP_Menu_Imp::fOSMenu [protected, inherited]
 

Menu id of this menu.

CP_MenuImp_List CP_Menu_Imp::fSubMenus [protected, inherited]
 

MacOS menu reference.


The documentation for this class was generated from the following files:
Generated on Tue Sep 20 20:21:53 2005 for CPLAT_MacOS by  doxygen 1.4.0