Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
menu-button.hpp
Go to the documentation of this file.
1/*
2 MENU-BUTTON.hpp - button widget to invoke a menu
3
4 Copyright (C)
5 2008, Joel Holdsworth <joel@airwebreathe.org.uk>
6 2012, Michael R. Fisher <mfisher31@gmail.com>
7
8  **Lumiera** is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by the
10  Free Software Foundation; either version 2 of the License, or (at your
11  option) any later version. See the file COPYING for further details.
12
13*/
14
15
23#ifndef STAGE_WIDGET_MENU_BUTTON_H
24#define STAGE_WIDGET_MENU_BUTTON_H
25
26#include "stage/gtk-base.hpp"
27
28
29
30namespace stage {
31namespace widget {
32
33
38 : public Gtk::ToggleButton
39 {
40 Gtk::HBox hBox_;
41 Gtk::Image image_;
42 Gtk::Label caption_;
43 Gtk::Arrow arrow_;
44 Gtk::Menu menu_;
45
46 Glib::RefPtr<Gtk::UIManager> uimanager_;
47 Glib::RefPtr<Gtk::ActionGroup> actions_;
48
49 public:
58 MenuButton();
59
65 MenuButton (Gtk::StockID const& stock_id);
66
73 MenuButton (cuString& label, bool mnemonic=false);
74
80 Gtk::Menu& get_menu();
81
89 void append (uString& slug, uString& title, sigc::slot<void>& callback, bool toggle=false);
90
91
99 void append (CStr slug, CStr title, sigc::slot<void>& callback, bool toggle=false);
100
101
103 void appendSeparator();
104
105
114 Gtk::Widget* get (uString slug);
115
116
118 void popup();
119
120
121 protected:
125 void setupButton();
126
130 void on_pressed();
131
135 void on_menu_deactivated();
136
137
138 private:
146 void on_menu_position (int& x, int& y, bool& push_in);
147 };
148
149
150}}// stage::widget
151#endif /*STAGE_WIDGET_MENU_BUTTON_H*/
A button that displays a menu when clicked on.
void setupButton()
An internal method which sets up the button at create time.
Gtk::Label caption_
caption text label to show on the button.
MenuButton()
Create an empty button.
void on_menu_position(int &x, int &y, bool &push_in)
callback function used to determine the correct position for the popup menu.
void on_menu_deactivated()
An event handler for when the menu is closed.
Glib::RefPtr< Gtk::UIManager > uimanager_
Glib::RefPtr< Gtk::ActionGroup > actions_
Gtk::Arrow arrow_
arrow widget to be displayed to indicate a drop-down menu
Gtk::Widget * get(uString slug)
Get an object from the Menu.
void append(uString &slug, uString &title, sigc::slot< void > &callback, bool toggle=false)
Append a Menu Item to the Menu.
Gtk::Menu menu_
internal menu object which is the popup menu of this widget.
Gtk::HBox hBox_
holds the layout of an image, caption and arrow.
Gtk::Menu & get_menu()
Gets the menu which will be displayed when the button is clicked on.
Gtk::Image image_
can optionally display an icon.
void popup()
Pops up the menu.
void appendSeparator()
Append a Gtk::SeparatorMenuItem to the Menu.
void on_pressed()
An event handler for when the button is pressed.
const char * CStr
Definition error.hpp:42
A set of basic GTK includes for the UI.
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
const uString cuString
Definition gtk-base.hpp:93
Glib::ustring uString
Definition gtk-base.hpp:92