#include <PopupMenu.h>
Data Structures | |
struct | MenuItem |
Public Types | |
typedef bool(* | SensitivityTest )(void) |
Public Member Functions | |
PopupMenu (GtkWidget *widget=NULL) | |
~PopupMenu () | |
void | addItem (GtkWidget *widget, GFunc callback, gpointer userData, SensitivityTest test=_alwaysVisible) |
void | show () |
Private Types | |
typedef std::list< MenuItem > | MenuItemList |
Static Private Member Functions | |
static bool | _alwaysVisible () |
static void | _onActivate (GtkMenuItem *item, MenuItem *menuItem) |
static gboolean | _onClick (GtkWidget *w, GdkEventButton *e, PopupMenu *self) |
Private Attributes | |
GtkWidget * | _menu |
MenuItemList | _menuItems |
A free pop-up menu populated with items and displayed on demand. Useful for right-click context menus.
Definition at line 15 of file PopupMenu.h.
typedef std::list<MenuItem> gtkutil::PopupMenu::MenuItemList [private] |
Definition at line 41 of file PopupMenu.h.
typedef bool(* gtkutil::PopupMenu::SensitivityTest)(void) |
Definition at line 19 of file PopupMenu.h.
gtkutil::PopupMenu::PopupMenu | ( | GtkWidget * | widget = NULL |
) |
Default constructor.
widget | Optional widget for which this menu should be a right-click popup menu. If not set to NULL, the PopupMenu will connect to the button-release-event on this widget and automatically display itself when a right-click is detected. |
gtkutil::PopupMenu::~PopupMenu | ( | ) | [inline] |
static bool gtkutil::PopupMenu::_alwaysVisible | ( | ) | [inline, static, private] |
Definition at line 51 of file PopupMenu.h.
static void gtkutil::PopupMenu::_onActivate | ( | GtkMenuItem * | item, | |
MenuItem * | menuItem | |||
) | [inline, static, private] |
Definition at line 59 of file PopupMenu.h.
References gtkutil::PopupMenu::MenuItem::callback, gtkutil::PopupMenu::MenuItem::userData, and gtkutil::PopupMenu::MenuItem::widget.
static gboolean gtkutil::PopupMenu::_onClick | ( | GtkWidget * | w, | |
GdkEventButton * | e, | |||
PopupMenu * | self | |||
) | [static, private] |
void gtkutil::PopupMenu::addItem | ( | GtkWidget * | widget, | |
GFunc | callback, | |||
gpointer | userData, | |||
SensitivityTest | test = _alwaysVisible | |||
) |
Add an item to this menu using a widget and callback function.
widget | The GtkWidget containing the displayed menu elements (i.e. icon and text). | |
callback | A callback function to be invoked when this menu item is activated. | |
userData | pointer to user data | |
test | SensitivityTest function object to determine whether this menu item is currently visible. |
void gtkutil::PopupMenu::show | ( | ) |
Show this menu. Each menu item's SensitivityTest will be invoked to determine whether it should be enabled or not, then the menu will be displayed.
GtkWidget* gtkutil::PopupMenu::_menu [private] |
Definition at line 24 of file PopupMenu.h.
Referenced by ~PopupMenu().
MenuItemList gtkutil::PopupMenu::_menuItems [private] |
Definition at line 42 of file PopupMenu.h.