Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

PG_PopupMenu Class Reference

Inheritance diagram for PG_PopupMenu:

Inheritance graph
[legend]
Collaboration diagram for PG_PopupMenu:

Collaboration graph
[legend]
List of all members.

Detailed Description

A stand-alone or attached popup menu.

Author:
Marek Habersack

A popup menu that can be attached to a menu bar or used stand-alone. In the first case, the widget sizes itself so that only the caption is visible, the menu items remain hidden until menu is activated. In the latter case menu sizes itself to encompass all of its items unless the menu size would exceed the space between the menu origin and the edge of the screen. In such case, menu displays a "scroller" button at the bottom.

Todo:
implement the scroller code (menu scrolling when it exceeds the screen height/width - a kind of specialized widgetlist). Should display a scroller icon at the bottom/top of the popup menu - a'la w2k.

keyboard handling (accelerators, ESC/ENTER & arrows)

Examples:

paratest.cpp.


Public Member Functions

 PG_PopupMenu (PG_Widget *parent, int x, int y, char *caption, char *style="PopupMenu")
 ~PG_PopupMenu ()
PG_PopupMenuaddSeparator ()
bool SetMenuItemSlot (int id, MenuItem::MenuItemSlot slot, PG_Pointer clientdata=NULL)
int maxItemWidth () const
void disableItem (int dd)
void enableItem (int id)
void trackMenu (int x=-1, int y=-1)
 Modal popup menu will be shown - i.e.

Add a new menu item to this menu
Constructs a new menu item using the provided parameters and then adds the item to this menu.

PG_PopupMenuaddMenuItem (char *caption, int ID, MenuItem::MenuItemSlot, PG_Pointer data=NULL, MenuItem::MI_FLAGS flags=MenuItem::MIF_NONE)
 Adds a menu item whose handler (if any) is set to be a stand-alone function.

PG_PopupMenuaddMenuItem (char *caption, int ID, MenuItem::MI_FLAGS flags=MenuItem::MIF_NONE)
PG_PopupMenuaddMenuItem (char *caption, PG_PopupMenu *sub, MenuItem::MI_FLAGS flags=MenuItem::MIF_SUBMENU)

Public Attributes

SignalSelectMenuItem sigSelectMenuItem

Protected Types

typedef list< MenuItem
* >::iterator 
MII

Protected Member Functions

void eventBlit (SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst)
 overridable eventhandler to blit the widget contents to the screen

void eventMouseEnter ()
 eventhandler for mouse movements.

void eventMouseLeave ()
 eventhandler for mouse movements.

bool eventMouseMotion (const SDL_MouseMotionEvent *motion)
 Overridable Eventhandler for a SDL_MouseMotionEvent message.

bool eventMouseButtonDown (const SDL_MouseButtonEvent *button)
 Overridable Eventhandler for a SDL_MouseButtonEvent message.

bool eventMouseButtonUp (const SDL_MouseButtonEvent *button)
 Overridable Eventhandler for a SDL_MouseButtonEvent message.

bool eventKeyDown (const SDL_KeyboardEvent *key)
 Overridable Eventhandler for a SDL_KeyboardEvent message.

void eventMoveWidget (int x, int y)
 Callback for the MoveWidget event.

void eventShow ()
 overridable eventhandler called whenever the widget gets shown.

void eventHide ()
 overridable eventhandler called whenever the widget gets hidden.

void LoadThemeStyle (const char *widgettype)
 Load a specific themestyle.

void LoadThemeStyle (const char *widgettype, const char *objectname)
 Load a style from the theme definition.

virtual bool getCaptionHeight (PG_Rect &rect, bool constructing=false)
virtual void recalcRect ()
virtual void handleClick (int x, int y)
virtual void enslave (PG_PopupMenu *master)
virtual void liberate ()

Protected Attributes

list< MenuItem * > items
string myCaption
 the menu items collection

PG_Color captionActiveColor
 menu caption

PG_Color captionInactiveColor
PG_Color miNormalColor
PG_Color miSelectedColor
PG_Color miDisabledColor
PG_Color sepNormalColor
PG_Color sepShadowColor
int xPadding
int yPadding


Member Typedef Documentation

typedef list<MenuItem*>::iterator PG_PopupMenu::MII [protected]
 


Constructor & Destructor Documentation

PG_PopupMenu::PG_PopupMenu PG_Widget parent,
int  x,
int  y,
char *  caption,
char *  style = "PopupMenu"
 

PG_PopupMenu::~PG_PopupMenu  ) 
 


Member Function Documentation

PG_PopupMenu& PG_PopupMenu::addMenuItem char *  caption,
PG_PopupMenu sub,
MenuItem::MI_FLAGS  flags = MenuItem::MIF_SUBMENU
 

PG_PopupMenu& PG_PopupMenu::addMenuItem char *  caption,
int  ID,
MenuItem::MI_FLAGS  flags = MenuItem::MIF_NONE
 

PG_PopupMenu& PG_PopupMenu::addMenuItem char *  caption,
int  ID,
MenuItem::MenuItemSlot  ,
PG_Pointer  data = NULL,
MenuItem::MI_FLAGS  flags = MenuItem::MIF_NONE
 

Adds a menu item whose handler (if any) is set to be a stand-alone function.

Parameters:
caption the item caption
ID the item identifier
data application-specific data associated with the menu item action.
flags menu item flags
Examples:
paratest.cpp.

PG_PopupMenu& PG_PopupMenu::addSeparator  ) 
 

Returns:
a reference to this menu

void PG_PopupMenu::disableItem int  dd  ) 
 

Examples:
paratest.cpp.

void PG_PopupMenu::enableItem int  id  ) 
 

virtual void PG_PopupMenu::enslave PG_PopupMenu master  )  [protected, virtual]
 

void PG_PopupMenu::eventBlit SDL_Surface *  surface,
const PG_Rect src,
const PG_Rect dst
[protected, virtual]
 

overridable eventhandler to blit the widget contents to the screen

Parameters:
surface pointer to SDL_Surface to be blitted
src source rectangle (client coordinates)
dst destination rectangle (screen coordinates) Override this eventhandler to perform custom blitting behaviour (without drawing onto the widget surface).

Reimplemented from PG_ThemeWidget.

void PG_PopupMenu::eventHide  )  [protected, virtual]
 

overridable eventhandler called whenever the widget gets hidden.

Reimplemented from PG_Widget.

bool PG_PopupMenu::eventKeyDown const SDL_KeyboardEvent *  key  )  [protected, virtual]
 

Overridable Eventhandler for a SDL_KeyboardEvent message.

This handler is called when a key changed it's state from unpressed to pressed. The default implementation returns 'false' which indicates that this message is not processed by this object.

Parameters:
key SDL_KeyboardEvent message
Returns:
Notifies the message pump if this message is processed by this object or it should be routed to the next message receiver.

Reimplemented from PG_MessageObject.

bool PG_PopupMenu::eventMouseButtonDown const SDL_MouseButtonEvent *  button  )  [protected, virtual]
 

Overridable Eventhandler for a SDL_MouseButtonEvent message.

This handler is called when a mouse button is pressed. The default implementation returns 'false' which indicates that this message is not processed by this object.

Parameters:
button SDL_MouseButtonEvent message
Returns:
Notifies the message pump if this message is processed by this object or it should be routed to the next message receiver.

Reimplemented from PG_MessageObject.

bool PG_PopupMenu::eventMouseButtonUp const SDL_MouseButtonEvent *  button  )  [protected, virtual]
 

Overridable Eventhandler for a SDL_MouseButtonEvent message.

This handler is called when a mouse button is released. The default implementation returns 'false' which indicates that this message is not processed by this object.

Parameters:
button SDL_MouseButtonEvent message
Returns:
Notifies the message pump if this message is processed by this object or it should be routed to the next message receiver.

Reimplemented from PG_MessageObject.

void PG_PopupMenu::eventMouseEnter  )  [protected, virtual]
 

eventhandler for mouse movements.

This overrideable handler is called everytime the mouse cursor is entering the widget area.

Reimplemented from PG_Widget.

void PG_PopupMenu::eventMouseLeave  )  [protected, virtual]
 

eventhandler for mouse movements.

This overrideable handler is called everytime the mouse cursor is leaving the widget area.

Reimplemented from PG_Widget.

bool PG_PopupMenu::eventMouseMotion const SDL_MouseMotionEvent *  motion  )  [protected, virtual]
 

Overridable Eventhandler for a SDL_MouseMotionEvent message.

This handler is called when mouse movement is detected. The default implementation returns 'false' which indicates that this message is not processed by this object.

Parameters:
motion SDL_MouseMotionEvent message
Returns:
Notifies the message pump if this message is processed by this object or it should be routed to the next message receiver.

Reimplemented from PG_MessageObject.

void PG_PopupMenu::eventMoveWidget int  x,
int  y
[protected, virtual]
 

Callback for the MoveWidget event.

Parameters:
x new x position
y new y position This virtual function can be used to implement custom behavior for MoveWidget events.

Reimplemented from PG_Widget.

void PG_PopupMenu::eventShow  )  [protected, virtual]
 

overridable eventhandler called whenever the widget gets shown.

Reimplemented from PG_Widget.

virtual bool PG_PopupMenu::getCaptionHeight PG_Rect rect,
bool  constructing = false
[protected, virtual]
 

virtual void PG_PopupMenu::handleClick int  x,
int  y
[protected, virtual]
 

virtual void PG_PopupMenu::liberate  )  [protected, virtual]
 

void PG_PopupMenu::LoadThemeStyle const char *  widgettype,
const char *  objectname
[protected, virtual]
 

Load a style from the theme definition.

Parameters:
widgettype name of the widgettype
objectname name of the object
Loads the defined style of a given widgettype and objectname.

Reimplemented from PG_ThemeWidget.

void PG_PopupMenu::LoadThemeStyle const char *  widgettype  )  [protected]
 

Load a specific themestyle.

Parameters:
widgettype name of widget type to load

Reimplemented from PG_ThemeWidget.

int PG_PopupMenu::maxItemWidth  )  const [inline]
 

virtual void PG_PopupMenu::recalcRect  )  [protected, virtual]
 

bool PG_PopupMenu::SetMenuItemSlot int  id,
MenuItem::MenuItemSlot  slot,
PG_Pointer  clientdata = NULL
 

void PG_PopupMenu::trackMenu int  x = -1,
int  y = -1
 

Modal popup menu will be shown - i.e.

all mouse/keyboard events will be captured by the menu and until the user selects any menu item (or cancels the menu by pressing ESC) no other widget will be accessible. If

 x @endcoce and @code y 
are absent, menu is popped up at its current position.

Parameters:
x xpos where the menu should pop up
y ypos where the menu should pop up
Examples:
paratest.cpp.


Member Data Documentation

PG_Color PG_PopupMenu::captionActiveColor [protected]
 

menu caption

PG_Color PG_PopupMenu::captionInactiveColor [protected]
 

list<MenuItem*> PG_PopupMenu::items [protected]
 

PG_Color PG_PopupMenu::miDisabledColor [protected]
 

PG_Color PG_PopupMenu::miNormalColor [protected]
 

PG_Color PG_PopupMenu::miSelectedColor [protected]
 

string PG_PopupMenu::myCaption [protected]
 

the menu items collection

PG_Color PG_PopupMenu::sepNormalColor [protected]
 

PG_Color PG_PopupMenu::sepShadowColor [protected]
 

SignalSelectMenuItem PG_PopupMenu::sigSelectMenuItem
 

Examples:
paratest.cpp.

int PG_PopupMenu::xPadding [protected]
 

int PG_PopupMenu::yPadding [protected]
 



The ParaGUI Project - Alexander Pipelka