| 1 |
/* Copyright (C) 2007 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 <vector> |
| 20 |
|
| 21 |
#include <gtkmm/button.h> |
| 22 |
#include <gtkmm/adjustment.h> |
| 23 |
#include <gtkmm/orientable.h> |
| 24 |
#include <gtkmm/enums.h> |
| 25 |
_DEFS(gtkmm,gtk) |
| 26 |
_PINCLUDE(gtkmm/private/button_p.h) |
| 27 |
|
| 28 |
namespace Gtk |
| 29 |
{ |
| 30 |
|
| 31 |
/** A button which pops up a scale widget. |
| 32 |
* |
| 33 |
* This kind of widget is commonly used for volume controls in multimedia |
| 34 |
* applications, and there is a Gtk::VolumeButton subclass that is tailored |
| 35 |
* for this use case. |
| 36 |
* |
| 37 |
* @ingroup Widgets |
| 38 |
* @newin{2,12} |
| 39 |
*/ |
| 40 |
class GTKMM_API ScaleButton |
| 41 |
: public Button, |
| 42 |
public Orientable |
| 43 |
{ |
| 44 |
_CLASS_GTKOBJECT(ScaleButton, GtkScaleButton, GTK_SCALE_BUTTON, Gtk::Button, GtkButton, , , GTKMM_API) |
| 45 |
_IMPLEMENTS_INTERFACE(Orientable) |
| 46 |
|
| 47 |
public: |
| 48 |
//We custom-implement the constructor because gtk_scale_button_new() does more than just call g_object_new(). |
| 49 |
/** Creates a GtkScaleButton, with a range between min and max , with a stepping of step. |
| 50 |
* |
| 51 |
* @param size A stock icon size. |
| 52 |
* @param min The minimum value of the scale (usually 0). |
| 53 |
* @param max The maximum value of the scale (usually 100). |
| 54 |
* @param step The stepping of value when a scroll-wheel event, or up/down arrow event occurs (usually 2). |
| 55 |
* @param icons A vector of icon names. |
| 56 |
*/ |
| 57 |
explicit ScaleButton(IconSize size, double min, double max, double step, const std::vector<Glib::ustring>& icons); |
| 58 |
_IGNORE(gtk_scale_button_new) |
| 59 |
|
| 60 |
//We add the constructor without icons because the C functions allows that to be NULL. |
| 61 |
/** Creates a GtkScaleButton, with a range between min and max , with a stepping of step. |
| 62 |
* |
| 63 |
* @param size A stock icon size. |
| 64 |
* @param min The minimum value of the scale (usually 0). |
| 65 |
* @param max The maximum value of the scale (usually 100). |
| 66 |
* @param step The stepping of value when a scroll-wheel event, or up/down arrow event occurs (usually 2). |
| 67 |
* |
| 68 |
* @newin{3,16} |
| 69 |
*/ |
| 70 |
explicit ScaleButton(IconSize size, double min, double max, double step); |
| 71 |
|
| 72 |
#m4 _CONVERSION(`const std::vector<Glib::ustring>&',`const gchar**',`Glib::ArrayHandler<Glib::ustring>::vector_to_array($3).data ()') |
| 73 |
_WRAP_METHOD(void set_icons(const std::vector<Glib::ustring>& icons), gtk_scale_button_set_icons) |
| 74 |
_WRAP_METHOD(double get_value() const, gtk_scale_button_get_value) |
| 75 |
_WRAP_METHOD(void set_value(double value), gtk_scale_button_set_value) |
| 76 |
|
| 77 |
_WRAP_METHOD(Glib::RefPtr<Adjustment> get_adjustment(), gtk_scale_button_get_adjustment, refreturn) |
| 78 |
_WRAP_METHOD(Glib::RefPtr<const Adjustment> get_adjustment() const, gtk_scale_button_get_adjustment, refreturn, constversion) |
| 79 |
|
| 80 |
_WRAP_METHOD(void set_adjustment(const Glib::RefPtr<Adjustment>& adjustment), gtk_scale_button_set_adjustment) |
| 81 |
|
| 82 |
//TODO: Change the Widget* return type to Gtk::Button: https://bugzilla.gnome.org/show_bug.cgi?id=539944 |
| 83 |
_WRAP_METHOD(Widget* get_plus_button(), gtk_scale_button_get_plus_button) |
| 84 |
_WRAP_METHOD(const Widget* get_plus_button() const, gtk_scale_button_get_plus_button, constversion) |
| 85 |
|
| 86 |
//TODO: Change the Widget* return type to Gtk::Button: https://bugzilla.gnome.org/show_bug.cgi?id=539944 |
| 87 |
_WRAP_METHOD(Widget* get_minus_button(), gtk_scale_button_get_minus_button) |
| 88 |
_WRAP_METHOD(const Widget* get_minus_button() const, gtk_scale_button_get_minus_button, constversion) |
| 89 |
|
| 90 |
//TODO: Use a more specific return type? |
| 91 |
_WRAP_METHOD(Gtk::Widget* get_popup(), gtk_scale_button_get_popup) |
| 92 |
_WRAP_METHOD(const Gtk::Widget* get_popup() const, gtk_scale_button_get_popup) |
| 93 |
|
| 94 |
_WRAP_SIGNAL(void value_changed(double value), "value_changed") |
| 95 |
|
| 96 |
//Ignore key-binding signals: |
| 97 |
_IGNORE_SIGNAL("popup") |
| 98 |
_IGNORE_SIGNAL("popdown") |
| 99 |
|
| 100 |
_WRAP_PROPERTY("value", double) |
| 101 |
_WRAP_PROPERTY("size", IconSize) |
| 102 |
_WRAP_PROPERTY("adjustment", Adjustment*) |
| 103 |
_WRAP_PROPERTY("icons", std::vector<Glib::ustring>) |
| 104 |
}; |
| 105 |
|
| 106 |
} // namespace Gtk |