Simple Graphics Library  0.9.5
SGL API
Classes | Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
sgl::PopupMenu Class Reference

#include <sgl.h>

Classes

struct  MenuItem
 

Public Member Functions

 PopupMenu ()
 
virtual ~PopupMenu ()
 
virtual void add_menu_item (const std::string &item, MenuItemFunction func)
 
virtual void replace_menu_item (const std::string &old_name, const std::string &new_name, MenuItemFunction func)
 
virtual void remove_menu_item (const std::string &item)
 
virtual void execute_handler (int n)
 
virtual void activate ()
 

Static Protected Member Functions

static void process_menu_events (int option)
 

Protected Attributes

int index
 
std::vector< MenuItemitems
 

Detailed Description

Implements a popup menu. Each popup menu must be associated with a particular window.

Constructor & Destructor Documentation

◆ PopupMenu()

sgl::PopupMenu::PopupMenu ( )

Intializes an empty popup menu.

◆ ~PopupMenu()

sgl::PopupMenu::~PopupMenu ( )
virtual

Destroys a popup menu

Member Function Documentation

◆ activate()

void sgl::PopupMenu::activate ( )
virtual

Make this popup menu the active popup for its window.

Returns
nothing

◆ add_menu_item()

void sgl::PopupMenu::add_menu_item ( const std::string &  item,
MenuItemFunction  func 
)
virtual

Specifies which method to call for a given menu item. Clients ordinarily will use the add_menu_item macro so a messy type cast is no necessary.

Parameters
itema string listed for the menu choice
funca method to call when the user selects the given menu item
Returns
nothing

◆ execute_handler()

void sgl::PopupMenu::execute_handler ( int  n)
virtual

Invokes the proper handler when the user selects an item in a popup menu. Client ordinarily do not call this method directly, nor do they override it.

Parameters
nan index into the table of handlers maintained by this popup menu
Returns
nothing

◆ process_menu_events()

void sgl::PopupMenu::process_menu_events ( int  option)
staticprotected

Calls the proper handler for the user's selection

◆ remove_menu_item()

void sgl::PopupMenu::remove_menu_item ( const std::string &  item)
virtual

Removes a menu item and its associated handler. The current menu item name is supplied.

Parameters
itema string listed for the current menu choice
Returns
nothing

◆ replace_menu_item()

void sgl::PopupMenu::replace_menu_item ( const std::string &  old_name,
const std::string &  new_name,
MenuItemFunction  func 
)
virtual

Replaces one menu item and its associated handler with another. The current menu item name is supplied along with the new menu item name and the new handler.

Parameters
old_namea string listed for the current menu choice
new_namea string listed for the replacement menu choice
functhe replacement handler for this menu item
Returns
nothing

Member Data Documentation

◆ index

int sgl::PopupMenu::index
protected

The window associated with this popup menu

◆ items

std::vector<MenuItem> sgl::PopupMenu::items
protected

Collection of menu items


The documentation for this class was generated from the following files: