Lumiera  0.pre.03
»edit your freedom«
MenuButton Class Reference

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

Description

A button that displays a menu when clicked on.

Definition at line 37 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.
 
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.
 
void on_pressed ()
 An event handler for when the button is pressed.
 
void setupButton ()
 An internal method which sets up the button at create time.
 

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.
 
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.
 
Glib::RefPtr< UIManager > uimanager
 

Constructor & Destructor Documentation

◆ MenuButton() [1/3]

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
MenuButton(cuString& label)
ctor directly instead.

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

◆ MenuButton() [2/3]

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 52 of file menu-button.cpp.

◆ MenuButton() [3/3]

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 66 of file menu-button.cpp.

Member Function Documentation

◆ get_menu()

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 87 of file menu-button.cpp.

Referenced by MenuButton::popup().

+ Here is the caller graph for this function:

◆ append() [1/2]

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 99 of file menu-button.cpp.

◆ append() [2/2]

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 116 of file menu-button.cpp.

◆ get()

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 77 of file menu-button.cpp.

Referenced by WrappedStandardExeBuilder::__call__().

+ Here is the caller graph for this function:

◆ popup()

void popup ( )

Pops up the menu.

Definition at line 137 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:

◆ on_menu_position()

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 186 of file menu-button.cpp.

Referenced by MenuButton::popup().

+ Here is the caller graph for this function:

Member Data Documentation

◆ hBox

HBox hBox
private

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

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

◆ image

Image image
private

The image that will optionally display an icon.

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

◆ caption

Label caption
private

caption text label to show on the button.

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

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

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