| 1 |
/* Copyright (C) 2003 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/toggletoolbutton.h> |
| 18 |
#include <gtkmm/radiobuttongroup.h> |
| 19 |
_DEFS(gtkmm,gtk) |
| 20 |
_PINCLUDE(gtkmm/private/toggletoolbutton_p.h) |
| 21 |
|
| 22 |
|
| 23 |
namespace Gtk |
| 24 |
{ |
| 25 |
|
| 26 |
/** A toolbar item that contains a radio button. |
| 27 |
* |
| 28 |
* A %Gtk::RadioToolButton is a Gtk::ToolItem that contains a radio button, that is, |
| 29 |
* a button that is part of a group of toggle buttons where only one button can be |
| 30 |
* active at a time. |
| 31 |
* |
| 32 |
* @ingroup Widgets |
| 33 |
*/ |
| 34 |
class GTKMM_API RadioToolButton : public ToggleToolButton |
| 35 |
{ |
| 36 |
_CLASS_GTKOBJECT(RadioToolButton, GtkRadioToolButton, GTK_RADIO_TOOL_BUTTON, Gtk::ToggleToolButton, GtkToggleToolButton, , , GTKMM_API) |
| 37 |
public: |
| 38 |
using Group = RadioButtonGroup; |
| 39 |
|
| 40 |
/** Creates a new Gtk::RadioToolButton and a new group. |
| 41 |
* |
| 42 |
* The RadioToolButton will have an empty label and will reside in a newly created group. |
| 43 |
* Use get_group() to retrieve this group and pass it to other radio buttons to assign |
| 44 |
* them to this group, or use join_group(). |
| 45 |
* |
| 46 |
* @newin{2,4} |
| 47 |
*/ |
| 48 |
_CTOR_DEFAULT() |
| 49 |
|
| 50 |
/** Creates a new Gtk::RadioToolButton and a new group. |
| 51 |
* |
| 52 |
* The RadioToolButton will have the label @a label. |
| 53 |
* |
| 54 |
* @param label The string used to display the label for this RadioToolButton. |
| 55 |
* |
| 56 |
* @newin{3,22} |
| 57 |
*/ |
| 58 |
explicit RadioToolButton(const Glib::ustring& label); |
| 59 |
|
| 60 |
/** Creates a new Gtk::RadioToolButton in an existing group. |
| 61 |
* |
| 62 |
* The RadioToolButton will have the label @a label and will be put into the Group |
| 63 |
* @a group. |
| 64 |
* |
| 65 |
* @param group The existing group which will be used for this RadioToolButton. |
| 66 |
* @param label The string used to display the label for this RadioToolButton. |
| 67 |
* |
| 68 |
* @newin{2,4} |
| 69 |
*/ |
| 70 |
explicit RadioToolButton(Group& group, const Glib::ustring& label = Glib::ustring()); |
| 71 |
_IGNORE(gtk_radio_tool_button_new) |
| 72 |
|
| 73 |
#ifndef GTKMM_DISABLE_DEPRECATED |
| 74 |
/** Creates a new Gtk::RadioToolButton in an existing group. |
| 75 |
* |
| 76 |
* The RadioToolButton will be created according to the StockID properties and put into |
| 77 |
* the Group @a group. |
| 78 |
* |
| 79 |
* @param group The existing group which will be used for this RadioToolButton. |
| 80 |
* @param stock_id The StockID which determines the look of the RadioToolButton. |
| 81 |
* |
| 82 |
* @newin{2,4} |
| 83 |
* @deprecated Use one of the other constructors instead. |
| 84 |
*/ |
| 85 |
RadioToolButton(Group& group, const Gtk::StockID& stock_id); |
| 86 |
_IGNORE(gtk_radio_tool_button_new_from_stock) |
| 87 |
#endif // GTKMM_DISABLE_DEPRECATED |
| 88 |
|
| 89 |
//This would look too much like a copy constructor: |
| 90 |
//_WRAP_CTOR(RadioToolButton(RadioToolButton& group), gtk_radio_tool_button_new_from_widget) |
| 91 |
//People should use second.join_group(first) instead. |
| 92 |
_IGNORE(gtk_radio_tool_button_new_with_stock_from_widget, gtk_radio_tool_button_new_from_widget) |
| 93 |
|
| 94 |
//This does not correspond to any gtk_radio_tool_button_*_new() function, |
| 95 |
//but it should work (it just sets properties), and it makes this class consistent with the |
| 96 |
//other ToolButton classes. |
| 97 |
|
| 98 |
/** Creates a new Gtk::RadioToolButton with an image and a new group. |
| 99 |
* |
| 100 |
* The RadioToolButton will have the label @a label and an image widget @a icon_widget. |
| 101 |
* |
| 102 |
* @param icon_widget The widget placed as the RadioToolButton's icon. |
| 103 |
* @param label The string used to display the label for this RadioToolButton. |
| 104 |
* |
| 105 |
* @newin{2,4} |
| 106 |
*/ |
| 107 |
explicit RadioToolButton(Widget& icon_widget, const Glib::ustring& label = Glib::ustring()); |
| 108 |
|
| 109 |
|
| 110 |
_WRAP_METHOD(Group get_group(), gtk_radio_tool_button_get_group) |
| 111 |
|
| 112 |
/** Adds the radio tool button to @a group, removing it from the group it belonged to before. |
| 113 |
* You can obtain a suitable group from another radio tool button by using get_group(). |
| 114 |
* |
| 115 |
* @newin{2,4} |
| 116 |
* |
| 117 |
* @param group An existing radio button group. |
| 118 |
*/ |
| 119 |
void set_group(Group& group); |
| 120 |
|
| 121 |
/** Removes the radio tool button from the group. |
| 122 |
* |
| 123 |
* @newin{3,10} |
| 124 |
*/ |
| 125 |
void reset_group(); |
| 126 |
_IGNORE(gtk_radio_tool_button_set_group) |
| 127 |
|
| 128 |
/** Joins a Gtk::RadioToolButton object to the group of another Gtk::RadioToolButton object. |
| 129 |
* |
| 130 |
* @newin{3,22} |
| 131 |
* |
| 132 |
* @param group_source A radio tool button object whose group we are joining. |
| 133 |
*/ |
| 134 |
void join_group(RadioToolButton& group_source); |
| 135 |
|
| 136 |
/// Note that %property_group() corresponds to join_group(), rather than to get_group() and set_group(). |
| 137 |
_WRAP_PROPERTY("group", RadioToolButton*, newin "3,22") |
| 138 |
}; |
| 139 |
|
| 140 |
} // namespace Gtk |