| 1 |
/* Copyright (C) 2012 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 |
#include <gtkmm/togglebutton.h> |
| 18 |
#include <gtkmm/menu.h> |
| 19 |
#include <gtkmm/popover.h> |
| 20 |
#include <giomm/menumodel.h> |
| 21 |
_DEFS(gtkmm,gtk) |
| 22 |
_PINCLUDE(gtkmm/private/togglebutton_p.h) |
| 23 |
|
| 24 |
namespace Gtk |
| 25 |
{ |
| 26 |
|
| 27 |
/** A widget that shows a menu when clicked on. |
| 28 |
* |
| 29 |
* This menu can be provided either as a Gtk::Menu, or an abstract Gio::MenuModel. |
| 30 |
* |
| 31 |
* This widget can hold any valid child widget. That is, it can hold |
| 32 |
* almost any other standard Gtk::Widget. The most commonly used child is the |
| 33 |
* provided Gtk::Arrow. |
| 34 |
* |
| 35 |
* @ingroup Widgets |
| 36 |
* @newin{3,6} |
| 37 |
*/ |
| 38 |
class GTKMM_API MenuButton : public ToggleButton |
| 39 |
{ |
| 40 |
_CLASS_GTKOBJECT(MenuButton, GtkMenuButton, GTK_MENU_BUTTON, Gtk::ToggleButton, GtkToggleButton, , , GTKMM_API) |
| 41 |
public: |
| 42 |
|
| 43 |
_CTOR_DEFAULT |
| 44 |
|
| 45 |
|
| 46 |
_WRAP_METHOD(void set_menu(Menu& menu), gtk_menu_button_set_popup, deprecated "Use set_popup() instead.") |
| 47 |
|
| 48 |
_DEPRECATE_IFDEF_START |
| 49 |
/** Disables the button. |
| 50 |
* |
| 51 |
* @deprecated Use unset_popup() instead. |
| 52 |
*/ |
| 53 |
void unset_menu(); |
| 54 |
_DEPRECATE_IFDEF_END |
| 55 |
|
| 56 |
_WRAP_METHOD(Menu* get_menu(), gtk_menu_button_get_popup, deprecated "Use get_popup() instead.") |
| 57 |
_WRAP_METHOD(const Menu* get_menu() const, gtk_menu_button_get_popup, constversion, deprecated "Use get_popup() instead.") |
| 58 |
|
| 59 |
_WRAP_METHOD(void set_popup(Menu& menu), gtk_menu_button_set_popup) |
| 60 |
|
| 61 |
/** Disables the button. |
| 62 |
*/ |
| 63 |
void unset_popup(); |
| 64 |
|
| 65 |
_WRAP_METHOD(Menu* get_popup(), gtk_menu_button_get_popup) |
| 66 |
_WRAP_METHOD(const Menu* get_popup() const, gtk_menu_button_get_popup, constversion) |
| 67 |
|
| 68 |
_WRAP_METHOD(void set_popover(Popover& popover), gtk_menu_button_set_popover) |
| 69 |
|
| 70 |
/** Disables the button. |
| 71 |
*/ |
| 72 |
void unset_popover(); |
| 73 |
|
| 74 |
_WRAP_METHOD(Popover* get_popover(), gtk_menu_button_get_popover) |
| 75 |
_WRAP_METHOD(const Popover* get_popover() const, gtk_menu_button_get_popover, constversion) |
| 76 |
|
| 77 |
_WRAP_METHOD(void set_use_popover(bool use_popover = true), gtk_menu_button_set_use_popover) |
| 78 |
_WRAP_METHOD(bool get_use_popover(), gtk_menu_button_get_use_popover) |
| 79 |
|
| 80 |
_WRAP_METHOD(void set_direction(ArrowType direction), gtk_menu_button_set_direction) |
| 81 |
_WRAP_METHOD(ArrowType get_direction() const, gtk_menu_button_get_direction) |
| 82 |
|
| 83 |
_WRAP_METHOD(void set_menu_model(const Glib::RefPtr<const Gio::MenuModel>& menu_model), gtk_menu_button_set_menu_model) |
| 84 |
|
| 85 |
/** Disables the button. |
| 86 |
*/ |
| 87 |
void unset_menu_model(); |
| 88 |
|
| 89 |
_WRAP_METHOD(Glib::RefPtr<Gio::MenuModel> get_menu_model(), gtk_menu_button_get_menu_model, refreturn) |
| 90 |
_WRAP_METHOD(Glib::RefPtr<const Gio::MenuModel> get_menu_model() const, gtk_menu_button_get_menu_model, refreturn, constversion) |
| 91 |
|
| 92 |
|
| 93 |
_WRAP_METHOD(void set_align_widget(Widget& align_widget), gtk_menu_button_set_align_widget) |
| 94 |
_WRAP_METHOD(Widget* get_align_widget(), gtk_menu_button_get_align_widget) |
| 95 |
_WRAP_METHOD(const Widget* get_align_widget() const, gtk_menu_button_get_align_widget) |
| 96 |
|
| 97 |
#ifndef GTKMM_DISABLE_DEPRECATED |
| 98 |
// _WRAP_PROPERTY("menu", Menu*, deprecated "Use popup instead.") |
| 99 |
// The GtkMenuButton::menu property does not exist in gtk+ 3.7.0 and later. Must hand-code to avoid an API/ABI break. |
| 100 |
/** The dropdown menu. |
| 101 |
* @deprecated Use popup instead. |
| 102 |
* |
| 103 |
* You rarely need to use properties because there are get_ and set_ methods for almost all of them. |
| 104 |
* @return A PropertyProxy that allows you to get or set the value of the property, |
| 105 |
* or receive notification when the value of the property changes. |
| 106 |
*/ |
| 107 |
Glib::PropertyProxy< Menu* > property_menu() ; |
| 108 |
|
| 109 |
/** The dropdown menu. |
| 110 |
* @deprecated Use popup instead. |
| 111 |
* |
| 112 |
* You rarely need to use properties because there are get_ and set_ methods for almost all of them. |
| 113 |
* @return A PropertyProxy_ReadOnly that allows you to get the value of the property, |
| 114 |
* or receive notification when the value of the property changes. |
| 115 |
*/ |
| 116 |
Glib::PropertyProxy_ReadOnly< Menu* > property_menu() const; |
| 117 |
#endif // GTKMM_DISABLE_DEPRECATED |
| 118 |
|
| 119 |
_WRAP_PROPERTY("popup", Menu*) |
| 120 |
_WRAP_PROPERTY("menu-model", Glib::RefPtr<Gio::MenuModel>) |
| 121 |
_WRAP_PROPERTY("align-widget", Widget*) |
| 122 |
_WRAP_PROPERTY("direction", ArrowType) |
| 123 |
_WRAP_PROPERTY("use-popover", bool) |
| 124 |
_WRAP_PROPERTY("popover", Popover*) |
| 125 |
|
| 126 |
}; |
| 127 |
|
| 128 |
} /* namespace Gtk */ |