PopupMenu Class Reference

#include <popupMenu.h>

Inheritance diagram for PopupMenu:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 PopupMenu ()
virtual ~PopupMenu ()
void createPlatformPopupMenuData ()
void deletePlatformPopupMenuData ()
 DECLARE_CONOBJECT (PopupMenu)
virtual bool onAdd ()
 Called when the object is added to the sim.
virtual void onRemove ()
 Called when the object is removed from the sim.
void createPlatformMenu ()
 Creates the platform specific menu object, a peer to this object.
void setBarTitle (const char *val)
StringTableEntry getBarTitle () const
S32 insertItem (S32 pos, const char *title, const char *accelerator)
 pass NULL for title to insert a separator returns the menu item's ID, or -1 on failure.
S32 insertSubMenu (S32 pos, const char *title, PopupMenu *submenu)
 pass NULL for title to insert a separator returns the menu item's ID, or -1 on failure.
void removeItem (S32 itemPos)
 remove the menu item at itemPos if the item has a submenu, it is removed from the mSubmenus list.
void enableItem (S32 pos, bool enable)
 implemented on a per-platform basis.
void checkItem (S32 pos, bool checked)
 implemented on a per-platform basis.
void checkRadioItem (S32 firstPos, S32 lastPos, S32 checkPos)
 All items at positions firstPos through lastPos are unchecked, and the item at checkPos is checked.
bool isItemChecked (S32 pos)
void attachToMenuBar (GuiCanvas *owner, S32 pos, const char *title)
 Places this menu in the menu bar of the application's main window.
void removeFromMenuBar ()
 Removes this menu from the menu bar.
void onAttachToMenuBar (GuiCanvas *canvas, S32 pos, const char *title)
 Called when the menu has been attached to the menu bar.
void onRemoveFromMenuBar (GuiCanvas *canvas)
 Called when the menu has been removed from the menu bar.
S32 getPosOnMenuBar ()
 Returns the position index of this menu on the bar.
bool isAttachedToMenuBar ()
 Returns true if this menu is attached to the menu bar.
void showPopup (GuiCanvas *owner, S32 x=-1, S32 y=-1)
 Displays this menu as a popup menu and blocks until the user has selected an item.
bool canHandleID (U32 iD)
 Returns true iff this menu contains an item that matches iD.
bool handleSelect (U32 command, const char *text=NULL)
 A menu item in this menu has been selected by id.
void onMenuSelect ()
virtual bool onMessageReceived (StringTableEntry queue, const char *event, const char *data)
 Callback for when messages are received.
virtual bool onMessageObjectReceived (StringTableEntry queue, Message *msg)
 Callback for when message objects are received.

Static Public Member Functions

static void initPersistFields ()
 Register dynamic fields in a subclass of ConsoleObject.

Protected Attributes

PlatformPopupMenuDatamData
SimSetmSubmenus
SimObjectPtr< GuiCanvasmCanvas
StringTableEntry mBarTitle
bool mIsPopup

Private Types

typedef SimObject Parent

Private Member Functions

void attachToMenuBar (GuiCanvas *owner, S32 pos)
 Used by MenuBar to attach the menu to the menu bar. Do not use anywhere else.

Friends

class MenuBar

Member Typedef Documentation

typedef SimObject PopupMenu::Parent [private]

Reimplemented from SimObject.


Constructor & Destructor Documentation

PopupMenu::PopupMenu (  ) 

virtual PopupMenu::~PopupMenu (  )  [virtual]


Member Function Documentation

void PopupMenu::attachToMenuBar ( GuiCanvas owner,
S32  pos 
) [private]

Used by MenuBar to attach the menu to the menu bar. Do not use anywhere else.

void PopupMenu::createPlatformPopupMenuData (  ) 

void PopupMenu::deletePlatformPopupMenuData (  ) 

PopupMenu::DECLARE_CONOBJECT ( PopupMenu   ) 

static void PopupMenu::initPersistFields (  )  [static]

Register dynamic fields in a subclass of ConsoleObject.

See also:
addField(), addFieldV(), addDeprecatedField(), addGroup(), endGroup()

Reimplemented from SimObject.

virtual bool PopupMenu::onAdd (  )  [virtual]

Called when the object is added to the sim.

Reimplemented from SimObject.

virtual void PopupMenu::onRemove (  )  [virtual]

Called when the object is removed from the sim.

Reimplemented from SimObject.

void PopupMenu::createPlatformMenu (  ) 

Creates the platform specific menu object, a peer to this object.

The platform menu *must* exist before calling any method that manipulates menu items or displays the menu. implementd on a per-platform basis.

void PopupMenu::setBarTitle ( const char *  val  )  [inline]

StringTableEntry PopupMenu::getBarTitle (  )  const [inline]

S32 PopupMenu::insertItem ( S32  pos,
const char *  title,
const char *  accelerator 
)

pass NULL for title to insert a separator returns the menu item's ID, or -1 on failure.

implementd on a per-platform basis. TODO: factor out common code

S32 PopupMenu::insertSubMenu ( S32  pos,
const char *  title,
PopupMenu submenu 
)

pass NULL for title to insert a separator returns the menu item's ID, or -1 on failure.

adds the submenu to the mSubmenus vector. implemented on a per-platform basis. TODO: factor out common code

void PopupMenu::removeItem ( S32  itemPos  ) 

remove the menu item at itemPos if the item has a submenu, it is removed from the mSubmenus list.

implemented on a per-platform basis. TODO: factor out common code

void PopupMenu::enableItem ( S32  pos,
bool  enable 
)

implemented on a per-platform basis.

void PopupMenu::checkItem ( S32  pos,
bool  checked 
)

implemented on a per-platform basis.

void PopupMenu::checkRadioItem ( S32  firstPos,
S32  lastPos,
S32  checkPos 
)

All items at positions firstPos through lastPos are unchecked, and the item at checkPos is checked.

implemented on a per-platform basis.

bool PopupMenu::isItemChecked ( S32  pos  ) 

void PopupMenu::attachToMenuBar ( GuiCanvas owner,
S32  pos,
const char *  title 
)

Places this menu in the menu bar of the application's main window.

Parameters:
owner The GuiCanvas that owns the PlatformWindow that this call is associated with
pos The relative position at which to place the menu.
title The name of the menu

void PopupMenu::removeFromMenuBar (  ) 

Removes this menu from the menu bar.

void PopupMenu::onAttachToMenuBar ( GuiCanvas canvas,
S32  pos,
const char *  title 
)

Called when the menu has been attached to the menu bar.

void PopupMenu::onRemoveFromMenuBar ( GuiCanvas canvas  ) 

Called when the menu has been removed from the menu bar.

S32 PopupMenu::getPosOnMenuBar (  ) 

Returns the position index of this menu on the bar.

bool PopupMenu::isAttachedToMenuBar (  )  [inline]

Returns true if this menu is attached to the menu bar.

void PopupMenu::showPopup ( GuiCanvas owner,
S32  x = -1,
S32  y = -1 
)

Displays this menu as a popup menu and blocks until the user has selected an item.

Parameters:
canvas the owner to show this popup associated with
x window local x coordinate at which to display the popup menu
y window local y coordinate at which to display the popup menu implemented on a per-platform basis.

bool PopupMenu::canHandleID ( U32  iD  ) 

Returns true iff this menu contains an item that matches iD.

implemented on a per-platform basis. TODO: factor out common code

bool PopupMenu::handleSelect ( U32  command,
const char *  text = NULL 
)

A menu item in this menu has been selected by id.

Submenus are given a chance to respond to the command first. If no submenu can handle the command id, this menu handles it. The script callback this::onSelectItem( position, text) is called. If text is null, then the text arg passed to script is the text of the selected menu item. implemented on a per-platform basis. TODO: factor out common code

void PopupMenu::onMenuSelect (  ) 

virtual bool PopupMenu::onMessageReceived ( StringTableEntry  queue,
const char *  event,
const char *  data 
) [virtual]

Callback for when messages are received.

Parameters:
queue The name of the queue the message was dispatched to
msg The type of message
data The data for the message
Returns:
false to prevent other listeners receiving this message, true otherwise
See also:
onMessageObjectReceived()

Implements Dispatcher::IMessageListener.

virtual bool PopupMenu::onMessageObjectReceived ( StringTableEntry  queue,
Message msg 
) [virtual]

Callback for when message objects are received.

Parameters:
queue The name of the queue the message was dispatched to
msg The message object
Returns:
false to prevent other listeners receiving this message, true otherwise
See also:
onMessageReceived()

Implements Dispatcher::IMessageListener.


Friends And Related Function Documentation

friend class MenuBar [friend]


Member Data Documentation