Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
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.
 
 MenuButton (Gtk::StockID const &stock_id)
 Creates a new Button containing the image and text from a stock item.
 
 MenuButton (cuString &label, bool mnemonic=false)
 Creates a simple Push Button with label.
 
Gtk::Menu & get_menu ()
 Gets the menu which will be displayed when the button is clicked on.
 
void append (uString &slug, uString &title, sigc::slot< void > &callback, bool toggle=false)
 Append a Menu Item to the Menu.
 
void append (CStr slug, CStr title, sigc::slot< void > &callback, bool toggle=false)
 Append a Menu Item to the Menu.
 
void appendSeparator ()
 Append a Gtk::SeparatorMenuItem to the Menu.
 
Gtk::Widget * get (uString slug)
 Get an object from the Menu.
 
void popup ()
 Pops up the menu.
 

Protected Member Functions

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

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.
 

Private Attributes

Gtk::HBox hBox_
 holds the layout of an image, caption and arrow.
 
Gtk::Image image_
 can optionally display an icon.
 
Gtk::Label caption_
 caption text label to show on the button.
 
Gtk::Arrow arrow_
 arrow widget to be displayed to indicate a drop-down menu
 
Gtk::Menu menu_
 internal menu object which is the popup menu of this widget.
 
Glib::RefPtr< Gtk::UIManager > uimanager_
 
Glib::RefPtr< Gtk::ActionGroup > actions_
 

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()
Create an empty button.
const uString cuString
Definition gtk-base.hpp:93
ctor directly instead.

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

References MenuButton::setupButton().

+ Here is the call graph for this function:

◆ MenuButton() [2/3]

MenuButton ( Gtk::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.
Deprecated:
Stock-IDs will be removed with GTK-4

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

References MenuButton::caption_, MenuButton::hBox_, MenuButton::image_, and MenuButton::setupButton().

+ Here is the call graph for this function:

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

References MenuButton::setupButton().

+ Here is the call graph for this function:

Member Function Documentation

◆ get_menu()

Gtk::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 84 of file menu-button.cpp.

References POPUP_SLUG, and MenuButton::uimanager_.

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

+ 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 95 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:

◆ append() [2/2]

void append ( CStr  slug,
CStr  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 117 of file menu-button.cpp.

References _, and MenuButton::append().

+ Here is the call graph for this function:

◆ appendSeparator()

void appendSeparator ( )

Append a Gtk::SeparatorMenuItem to the Menu.

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

References POPUP_SLUG, and MenuButton::uimanager_.

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

References POPUP_PATH, and MenuButton::uimanager_.

Referenced by WrappedStandardExeBuilder::invokeOriginalBuilder().

+ Here is the caller graph for this function:

◆ popup()

void popup ( )

Pops up the menu.

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

◆ setupButton()

void setupButton ( )
protected

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

Definition at line 148 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(), MenuButton::MenuButton(), and MenuButton::MenuButton().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_pressed()

void on_pressed ( )
protected

An event handler for when the button is pressed.

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

References MenuButton::popup().

+ Here is the call graph for this function:

◆ on_menu_deactivated()

void on_menu_deactivated ( )
protected

An event handler for when the menu is closed.

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

Referenced by MenuButton::setupButton().

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

Referenced by MenuButton::popup().

+ Here is the caller graph for this function:

Member Data Documentation

◆ hBox_

Gtk::HBox hBox_
private

holds the layout of an image, caption and arrow.

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

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

◆ image_

Gtk::Image image_
private

can optionally display an icon.

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

Referenced by MenuButton::MenuButton().

◆ caption_

Gtk::Label caption_
private

caption text label to show on the button.

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

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

◆ arrow_

Gtk::Arrow arrow_
private

arrow widget to be displayed to indicate a drop-down menu

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

Referenced by MenuButton::setupButton().

◆ menu_

Gtk::Menu menu_
private

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

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

◆ uimanager_

Glib::RefPtr<Gtk::UIManager> uimanager_
private

◆ actions_

Glib::RefPtr<Gtk::ActionGroup> actions_
private

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