Lumiera  0.pre.03
»edit your freedom«
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) Lumiera.org
5  2008, Joel Holdsworth <joel@airwebreathe.org.uk>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
31 #ifndef STAGE_WIDGET_MENU_BUTTON_H
32 #define STAGE_WIDGET_MENU_BUTTON_H
33 
34 #include "stage/gtk-base.hpp"
35 
36 
37 
38 namespace stage {
39 namespace widget {
40 
41  using namespace Gtk;
42 
46  class MenuButton
47  : public ToggleButton
48  {
49  public:
58  MenuButton();
59 
64  MenuButton (StockID const& stock_id);
65 
72  MenuButton (cuString& label, bool mnemonic=false);
73 
79  Menu& get_menu();
80 
88  void append (uString& slug, uString& title, sigc::slot<void>& callback, bool toggle=false);
89 
90 
98  void append (const char *slug, const char* title, sigc::slot<void>& callback, bool toggle=false);
99 
100 
102  void appendSeparator();
103 
104 
113  Gtk::Widget* get (uString slug);
114 
115 
117  void popup();
118 
119 
120  protected:
124  void setupButton();
125 
129  void on_pressed();
130 
134  void on_menu_deactivated();
135 
136 
137  private:
145  void on_menu_position (int& x, int& y, bool& push_in);
146 
147  private:
149  HBox hBox;
150 
152  Image image;
153 
155  Label caption;
156 
161  Arrow arrow;
162 
166  Menu menu;
167 
168  Glib::RefPtr<UIManager> uimanager;
169  Glib::RefPtr<ActionGroup> actions;
170 
171  };
172 
173 
174 }}// stage::widget
175 #endif /*STAGE_WIDGET_MENU_BUTTON_H*/
Image image
The image that will optionally display an icon.
Label caption
caption text label to show on the button.
Menu menu
The internal menu object which is the popup menu of this widget.
Arrow arrow
The arrow widget that will be displayed to hint the user that this button is a drop-down.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
A set of basic GTK includes for the UI.
HBox hBox
hBox for the layout of an image, caption and arrow.
A button that displays a menu when clicked on.
Definition: menu-button.hpp:46