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 CP_NoCopy CP_NoCopy List of all members.

Public Member Functions

virtual CP_CommandNo GetCommandNo (SInt16 inMenuItemIndex)
OSMenu GetOSMenu ()
OSMenu GetMenuItems ()
SInt16 GetID ()
UInt16 GetMenuItemCount ()
CP_String GetItemText (SInt16 inMenuItemIndex)
void AppendItem (const CP_String &inMenuItem, CP_CommandNo inCommand=CP_CMD_NoCommand)
void AppendItem (const CP_String &inItemText, CP_CommandNo inCommand)
void AppendSeparator ()
void DeleteItem (UInt16 inItemIndex)
void DeleteItem (UInt16 inItemIndex)
CP_MenuItems_ArrayGetMenuItemsArray ()
void UpdateCommandStatus (CP_M_CommandHandler *inCommandHandler)
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)
virtual ~CP_Menu () throw ()
 Destructor.
Constructor / Destructor
 CP_Menu (OSMenu innMenu)
 Constructor.
Commands
virtual CP_CommandNo GetCommandNo (SInt16 inMenuItemIndex)
Getters
OSMenu GetOSMenu ()
SInt16 GetID ()
SInt16 GetMenuItemCount ()
CP_String GetItemText (SInt16 inItemIndex)
CP_String GetTitle () const
CP_CommandNo GetCommand (SInt16 inItemIndex)
SInt16 GetCommandItemIndex (const CP_CommandNo inCommand)
Getters
OSMenu GetOSMenu ()
SInt16 GetID ()
SInt16 GetMenuItemCount ()
CP_String GetItemText (SInt16 inItemIndex)
CP_String GetTitle () const
CP_CommandNo GetCommand (SInt16 inItemIndex)
SInt16 GetCommandItemIndex (const CP_CommandNo inCommand)
Items
void AppendItem (const CP_String &inItemText, CP_CommandNo inCommand)
void DeleteItem (UInt16 inItemIndex)
Setters
void SetTitle (const CP_String &inTitle)
Setters
void SetTitle (const CP_String &inTitle)
void SetItemMark (CP_CommandNo inCommand, SInt16 inItemMark, bool inHasMark)
void SetItemMark (SInt16 inIndex, SInt16 inItemMark, bool inHasMark)
Setters
void SetTitle (const CP_String &inTitle)
Setters
void SetTitle (const CP_String &inTitle)
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)
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)
Setters
void SetTitle (const CP_String &inTitle)

Protected Member Functions

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

Protected Attributes

SInt16 fMenuID
OSMenu fOSMenu
CP_CommandsNo_ArrayfCommands
CP_CommandsNo_ArrayfCommands
OSMenu fMenuItems
CP_MenuItems_ArrayfMenuItemStructs_Linux
CP_MenuImp_List fSubMenus
CP_String fMenuTitle

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  )  throw () [virtual]
 

Destructor.

CP_Menu::CP_Menu OSMenu  innMenu  ) 
 


Member Function Documentation

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

Return the CP_COMMAND for the passed in inMenuItem. If the inMenuItem does not correspond to an item in this menu, CP_CMD_NoCommand is returned.

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

OSMenu CP_Menu_Imp::GetOSMenu  )  [inherited]
 

Return the MacOS platform menu reference.

Returns:
OSMenu MacOS menu reference.

OSMenu CP_Menu_Imp::GetOSMenu  )  [inherited]
 

Return the MacOS platform menu reference.

Exceptions:
none 
Returns:
OSMenu MacOS menu reference.

OSMenu CP_Menu_Imp::GetOSMenu  )  [inherited]
 

Return the Windows platform menu reference.

Returns:
OSMenu Windows menu reference.

OSMenu CP_Menu_Imp::GetMenuItems  )  [inherited]
 

SInt16 CP_Menu_Imp::GetID  )  [inherited]
 

Return the ID of this menu.

Exceptions:
none 
Returns:
SInt16 ID of this menu.

SInt16 CP_Menu_Imp::GetID  )  [inherited]
 

Return the ID of this menu.

Exceptions:
none 
Returns:
SInt16 ID of this menu.

SInt16 CP_Menu_Imp::GetID  )  [inherited]
 

Return the ID of this menu.

Exceptions:
none 
Returns:
SInt16 ID of this menu.

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.

Returns:
SInt16 Number of menu items.

SInt16 CP_Menu_Imp::GetMenuItemCount  )  [inherited]
 

SInt16 CP_Menu_Imp::GetMenuItemCount  )  [inherited]
 

CP_String CP_Menu_Imp::GetItemText SInt16  inMenuItemIndex  )  [inherited]
 

CP_String CP_Menu_Imp::GetItemText SInt16  inItemIndex  )  [inherited]
 

CP_String CP_Menu_Imp::GetItemText SInt16  inItemIndex  )  [inherited]
 

void CP_Menu_Imp::AppendItem const CP_String inItemText,
CP_CommandNo  inCommand = CP_CMD_NoCommand
[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::AppendItem const CP_String inItemText,
CP_CommandNo  inCommand
[inherited]
 

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

void CP_Menu_Imp::AppendSeparator  )  [inherited]
 

void CP_Menu_Imp::DeleteItem UInt16  inItemIndex  )  [inherited]
 

Delets 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.
Returns:
void

void CP_Menu_Imp::DeleteItem UInt16  inItemIndex  )  [inherited]
 

void CP_Menu_Imp::DeleteItem UInt16  inItemIndex  )  [inherited]
 

CP_MenuItems_Array* CP_Menu_Imp::GetMenuItemsArray  )  [inherited]
 

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::SetTitle const CP_String inTitle  )  [inherited]
 

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

void CP_Menu_Imp::LoadOSMenu SInt16  inMenuID,
bool  inPopup
[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.
Returns:
void

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

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

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.

CP_String CP_Menu_Imp::GetTitle  )  const [inherited]
 

CP_CommandNo CP_Menu_Imp::GetCommand SInt16  inItemIndex  )  [inherited]
 

CP_CommandNo CP_Menu_Imp::GetCommand SInt16  inItemIndex  )  [inherited]
 

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

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

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::UpdateCommandStatus CP_M_CommandHandler inCommandHandler  )  [inherited]
 

Update the status of all of the commands in this menu.

Exceptions:
none 
Returns:
void

void CP_Menu_Imp::LoadAsPopup SInt16  inMenuID  )  [protected, inherited]
 

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_CommandsNo_Array* CP_Menu_Imp::fCommands [protected, inherited]
 

MacOS menu reference.

CP_CommandsNo_Array* CP_Menu_Imp::fCommands [protected, inherited]
 

Windows menu reference.

OSMenu CP_Menu_Imp::fMenuItems [protected, inherited]
 

Table of commands for each menu item.

CP_MenuItems_Array* CP_Menu_Imp::fMenuItemStructs_Linux [protected, inherited]
 

List of structures we maintain about each item in the menu, used to map between CPLAT information for a menu, and the GtkWidget

CP_MenuImp_List CP_Menu_Imp::fSubMenus [protected, inherited]
 

MacOS menu reference.

CP_String CP_Menu_Imp::fMenuTitle [protected, inherited]
 

Table of commands for each menu item.


The documentation for this class was generated from the following files:
Generated on Sat Sep 17 20:01:52 2005 for CPLAT by  doxygen 1.4.0