Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MenuButton Class Reference

#include "gui/widget/menu-button.hpp"

Description

A button that displays a menu when clicked on.

Definition at line 44 of file menu-button.hpp.

Public Member Functions

 MenuButton ()
 Create an empty button. More...
 
 MenuButton (StockID const &stock_id)
 Creates a new Button containing the image and text from a stock item. More...
 
 MenuButton (cuString &label, bool mnemonic=false)
 Creates a simple Push Button with label. More...
 
void append (uString &slug, uString &title, sigc::slot< void > &callback, bool toggle=false)
 Append a Menu Item to the Menu. More...
 
void append (const char *slug, const char *title, sigc::slot< void > &callback, bool toggle=false)
 Append a Menu Item to the Menu. More...
 
void appendSeparator ()
 Append a Gtk::SeparatorMenuItem to the Menu. More...
 
Gtk::Widget * get (uString slug)
 Get an object from the Menu. More...
 
Menu & get_menu ()
 Gets the menu which will be displayed when the button is clicked on. More...
 
void popup ()
 Pops up the menu. More...
 

Protected Member Functions

void on_menu_deactivated ()
 An event handler for when the menu is closed. More...
 
void on_pressed ()
 An event handler for when the button is pressed. More...
 
void setupButton ()
 An internal method which sets up the button at create time. More...
 

Private Member Functions

void on_menu_position (int &x, int &y, bool &push_in)
 callback function used to determine the correct position for the popup menu. More...
 

Private Attributes

Glib::RefPtr< ActionGroup > actions
 
Arrow arrow
 The arrow widget that will be displayed to hint the user that this button is a drop-down. More...
 
Label caption
 caption text label to show on the button. More...
 
HBox hBox
 hBox for the layout of an image, caption and arrow. More...
 
Image image
 The image that will optionally display an icon. More...
 
Menu menu
 The internal menu object which is the popup menu of this widget. More...
 
Glib::RefPtr< UIManager > uimanager
 

Constructor & Destructor Documentation

Create an empty button.

Remarks
With an empty button, you can Button::add() a widget such as a Pixmap or Box. If you just wish to add a Label, you may want to use the ctor directly instead.

Definition at line 51 of file menu-button.cpp.

References MenuButton::setupButton().

+ Here is the call graph for this function:

MenuButton ( StockID const &  stock_id)

Creates a new Button containing the image and text from a stock item.

Remarks
Stock IDs have identifiers like Stock::OK and Stock::APPLY.

Definition at line 61 of file menu-button.cpp.

References MenuButton::caption, MenuButton::hBox, MenuButton::image, and MenuButton::setupButton().

+ Here is the call graph for this function:

MenuButton ( cuString label,
bool  mnemonic = false 
)

Creates a simple Push Button with label.

Remarks
Create a button with the given label inside. You won't be able to add a widget in this button since it already has a Label in it

Definition at line 75 of file menu-button.cpp.

References MenuButton::setupButton().

+ Here is the call graph for this function:

Member Function Documentation

Menu & get_menu ( )

Gets the menu which will be displayed when the button is clicked on.

Returns
Returns a reference to the menu that will be clicked on. This reference can be used to populate the menu with items.

Definition at line 96 of file menu-button.cpp.

References POPUP_SLUG, and MenuButton::uimanager.

Referenced by MenuButton::popup(), MenuButton::setupButton(), and Track::Track().

+ Here is the caller graph for this function:

void append ( uString slug,
uString title,
sigc::slot< void > &  callback,
bool  toggle = false 
)

Append a Menu Item to the Menu.

Parameters
slugUnique identifier in the UI Manager
titleThe title of the item
callbackThe signal handler when clicked
toggle

Definition at line 108 of file menu-button.cpp.

References MenuButton::actions, POPUP_SLUG, and MenuButton::uimanager.

Referenced by MenuButton::append(), and PanelBar::setupPanelButton().

+ Here is the caller graph for this function:

void append ( const char *  slug,
const char *  title,
sigc::slot< void > &  callback,
bool  toggle = false 
)

Append a Menu Item to the Menu.

Parameters
slugUnique identifier in the UI Manager
titleThe title of the item
callbackThe signal handler when clicked
toggle

Definition at line 125 of file menu-button.cpp.

References _, and MenuButton::append().

+ Here is the call graph for this function:

void appendSeparator ( )

Append a Gtk::SeparatorMenuItem to the Menu.

Definition at line 135 of file menu-button.cpp.

References POPUP_SLUG, and MenuButton::uimanager.

Gtk::Widget * get ( uString  slug)

Get an object from the Menu.

Parameters
slugThe slug that created the object
Returns
Widget* Returns a valid Gtk::Widget or NULL if not found
Remarks
Typically you'll 'get' a MenuItem of sorts. Use MenuButton::get_menu() to get the menu as a whole

Definition at line 86 of file menu-button.cpp.

References POPUP_PATH, and MenuButton::uimanager.

Referenced by WrappedStandardExeBuilder::invokeOriginalBuilder().

+ Here is the caller graph for this function:

void popup ( )

Pops up the menu.

Definition at line 146 of file menu-button.cpp.

References MenuButton::get_menu(), and MenuButton::on_menu_position().

Referenced by MenuButton::on_pressed().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void setupButton ( )
protected

An internal method which sets up the button at create time.

Definition at line 155 of file menu-button.cpp.

References MenuButton::actions, MenuButton::arrow, MenuButton::caption, MenuButton::get_menu(), MenuButton::hBox, MenuButton::on_menu_deactivated(), POPUP_SLUG, and MenuButton::uimanager.

Referenced by MenuButton::MenuButton().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void on_pressed ( )
protected

An event handler for when the button is pressed.

Definition at line 181 of file menu-button.cpp.

References MenuButton::popup().

+ Here is the call graph for this function:

void on_menu_deactivated ( )
protected

An event handler for when the menu is closed.

Definition at line 188 of file menu-button.cpp.

Referenced by MenuButton::setupButton().

+ Here is the caller graph for this function:

void on_menu_position ( int &  x,
int &  y,
bool &  push_in 
)
private

callback function used to determine the correct position for the popup menu.

Parameters
xThe x-coordinate to display the menu in root window coordinates.
yThe y-coordinate to display the menu in root window coordinates.
push_inThis value is set to true if the menu should be pushed in if it collides with the edge of the screen.

Definition at line 195 of file menu-button.cpp.

Referenced by MenuButton::popup().

+ Here is the caller graph for this function:

Member Data Documentation

HBox hBox
private

hBox for the layout of an image, caption and arrow.

Definition at line 147 of file menu-button.hpp.

Referenced by MenuButton::MenuButton(), and MenuButton::setupButton().

Image image
private

The image that will optionally display an icon.

Definition at line 150 of file menu-button.hpp.

Referenced by MenuButton::MenuButton().

Label caption
private

caption text label to show on the button.

Definition at line 153 of file menu-button.hpp.

Referenced by MenuButton::MenuButton(), and MenuButton::setupButton().

Arrow arrow
private

The arrow widget that will be displayed to hint the user that this button is a drop-down.

Definition at line 159 of file menu-button.hpp.

Referenced by MenuButton::setupButton().

Menu menu
private

The internal menu object which is the popup menu of this widget.

Definition at line 164 of file menu-button.hpp.

Glib::RefPtr<UIManager> uimanager
private
Glib::RefPtr<ActionGroup> actions
private

Definition at line 167 of file menu-button.hpp.

Referenced by MenuButton::append(), and MenuButton::setupButton().

+ Inheritance diagram for MenuButton:
+ Collaboration diagram for MenuButton:

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