Debian Codegraph @

gtk/src/menuitem.hg

raw
1 /* Copyright (C) 1998-2002 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 _CONFIGINCLUDE(gtkmmconfig.h)
18
19 #include <gtkmm/bin.h>
20 #include <gtkmm/accelkey.h>
21 #include <gtkmm/accellabel.h>
22 #include <gtkmm/activatable.h>
23 _DEFS(gtkmm,gtk)
24 _PINCLUDE(gtkmm/private/bin_p.h)
25
26 namespace Gtk
27 {
28
29 //TODO: Derive from (and implement) Actionable when we can break ABI.
30
31 class GTKMM_API Menu;
32 namespace Menu_Helpers { class GTKMM_API Element; }
33
34 /** Child item for menus.
35 * Handle highlighting, alignment, events and submenus.
36 * As it derives from Gtk::Bin it can hold any valid child widget, although only a few are really useful.
37 * @ingroup Widgets
38 * @ingroup Menus
39 */
40 class GTKMM_API MenuItem
41 : public Bin,
42 public Activatable
43 {
44 _CLASS_GTKOBJECT(MenuItem,GtkMenuItem,GTK_MENU_ITEM,Gtk::Bin,GtkBin,,,GTKMM_API)
45 _IMPLEMENTS_INTERFACE(Activatable)
46 public:
47 /// Create an empty menu item
48 _CTOR_DEFAULT
49
50 /// Create a menu item with widget
51 explicit MenuItem(Widget& widget);
52
53 /// Create a menu item with label
54 explicit MenuItem(const Glib::ustring& label, bool mnemonic = false);
55
56 _WRAP_METHOD(void set_submenu(Menu& submenu), gtk_menu_item_set_submenu)
57
58 /** Remove the menu item's sub-menu.
59 * @newin{2,22}
60 */
61 void unset_submenu();
62
63 _WRAP_METHOD(Menu* get_submenu(), gtk_menu_item_get_submenu)
64 _WRAP_METHOD(const Menu* get_submenu() const, gtk_menu_item_get_submenu, constversion)
65 bool has_submenu() const;
66 _WRAP_METHOD(void select(), gtk_menu_item_select)
67 _WRAP_METHOD(void deselect(), gtk_menu_item_deselect)
68 _WRAP_METHOD(void activate(), gtk_menu_item_activate)
69 _WRAP_METHOD(void toggle_size_request(int& requisition), gtk_menu_item_toggle_size_request)
70 _WRAP_METHOD(void toggle_size_allocate(int allocation), gtk_menu_item_toggle_size_allocate)
71
72 _WRAP_METHOD(void set_right_justified(bool right_justified = true), gtk_menu_item_set_right_justified, deprecated "If you insist on using it, use Widget::set_hexpand() and Widget::set_halign().")
73 _WRAP_METHOD(bool get_right_justified() const, gtk_menu_item_get_right_justified, deprecated "See set_right_justified().")
74
75 _WRAP_METHOD(void set_accel_path(const Glib::ustring& accel_path), gtk_menu_item_set_accel_path)
76 void unset_accel_path();
77 _WRAP_METHOD(Glib::ustring get_accel_path() const, gtk_menu_item_get_accel_path)
78 _WRAP_METHOD(void set_label(const Glib::ustring& label), gtk_menu_item_set_label)
79 _WRAP_METHOD(Glib::ustring get_label() const, gtk_menu_item_get_label)
80 _WRAP_METHOD(void set_use_underline(bool setting = true), gtk_menu_item_set_use_underline)
81 _WRAP_METHOD(bool get_use_underline() const, gtk_menu_item_get_use_underline)
82
83 _WRAP_METHOD(void set_reserve_indicator(bool reserve = true), gtk_menu_item_set_reserve_indicator)
84 _WRAP_METHOD(bool get_reserve_indicator() const, gtk_menu_item_get_reserve_indicator)
85
86 _WRAP_SIGNAL(void activate(), "activate")
87 _WRAP_SIGNAL(void activate_item(), "activate_item")
88 _WRAP_SIGNAL(void toggle_size_request(int* requisition), "toggle_size_request")
89 _WRAP_SIGNAL(void toggle_size_allocate(int allocation), "toggle_size_allocate")
90
91 //TODO: Remove no_default_handler when we can break ABI
92 _WRAP_SIGNAL(void select(), "select", no_default_handler)
93 _WRAP_SIGNAL(void deselect(), "deselect", no_default_handler)
94
95 void accelerate(Window& window);
96
97 //TODO: Deprecate the C property once GTK+ 3.5 has begun. It seems to have been forgotten.
98 _WRAP_PROPERTY("right-justified", bool, deprecated "See set_right_justified.")
99
100 _WRAP_PROPERTY("submenu", Gtk::Menu*)
101 _WRAP_PROPERTY("accel-path", Glib::ustring)
102 _WRAP_PROPERTY("label", Glib::ustring)
103 _WRAP_PROPERTY("use-underline", bool)
104
105 protected:
106 void add_accel_label(const Glib::ustring& label, bool mnemonic = true);
107 void set_accel_key(const AccelKey& accel_key);
108
109 private:
110 friend class Menu_Helpers::Element;
111
112 //This data is set by MenuElem, and will be used in on_realize(), in the call to add_accelerator().
113 AccelKey accel_key_;
114 };
115
116 } // namespace Gtk