| 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/button.h> |
| 18 |
#ifndef GTKMM_DISABLE_DEPRECATED |
| 19 |
#include <gdkmm/color.h> |
| 20 |
#endif |
| 21 |
#include <gdkmm/rgba.h> |
| 22 |
_DEFS(gtkmm,gtk) |
| 23 |
_PINCLUDE(gtkmm/private/button_p.h) |
| 24 |
|
| 25 |
#m4 _PUSH(SECTION_CC_PRE_INCLUDES) |
| 26 |
#undef GTK_DISABLE_DEPRECATED |
| 27 |
#define GDK_DISABLE_DEPRECATION_WARNINGS 1 |
| 28 |
#m4 _POP() |
| 29 |
|
| 30 |
namespace Gtk |
| 31 |
{ |
| 32 |
|
| 33 |
//TODO: Derive from (and implement) ColorChooser when we can break ABI. |
| 34 |
|
| 35 |
/** A button to launch a color selection dialog. |
| 36 |
* |
| 37 |
* The GtkColorButton is a button which displays the currently selected color an allows to |
| 38 |
* open a color selection dialog to change the color. It is suitable widget for selecting a |
| 39 |
* color in a preference dialog. |
| 40 |
* |
| 41 |
* The ColorButton widget looks like this: |
| 42 |
* @image html colorbutton1.png |
| 43 |
* |
| 44 |
* @ingroup Widgets |
| 45 |
*/ |
| 46 |
class GTKMM_API ColorButton : public Button |
| 47 |
//TODO: When we can break ABI: public ColorChooser |
| 48 |
{ |
| 49 |
_CLASS_GTKOBJECT(ColorButton, GtkColorButton, GTK_COLOR_BUTTON, Gtk::Button, GtkButton, , , GTKMM_API) |
| 50 |
//TODO: When we can break ABI: _IMPLEMENTS_INTERFACE(ColorChooser) |
| 51 |
public: |
| 52 |
|
| 53 |
/** Creates a new color button. |
| 54 |
* |
| 55 |
* This creates a widget in the form of a small button containing a swatch representing |
| 56 |
* the current selected color. When the button is clicked, a color-selection dialog will |
| 57 |
* open, allowing the user to select a color. The swatch will be updated to reflect the |
| 58 |
* new color when the user finishes. |
| 59 |
* |
| 60 |
* @newin{2,4} |
| 61 |
*/ |
| 62 |
_CTOR_DEFAULT() |
| 63 |
_IGNORE(gtk_color_button_new) |
| 64 |
|
| 65 |
// _WRAP_CTOR does not take a 'deprecated' parameter. |
| 66 |
// _WRAP_CTOR(ColorButton(const Gdk::Color& color), gtk_color_button_new_with_color) |
| 67 |
#ifndef GTKMM_DISABLE_DEPRECATED |
| 68 |
/** Creates a new color button with a predefined color. |
| 69 |
* |
| 70 |
* Same as Gtk::ColorButton::ColorButton(). Additionally takes a Gdk::Color and |
| 71 |
* initializes the button with this color. Equivalent to calling set_color(@a color) |
| 72 |
* after the default constructor. |
| 73 |
* |
| 74 |
* @param color A Gdk::Color to set the current color with. |
| 75 |
* |
| 76 |
* @newin{2,4} |
| 77 |
* @deprecated "Use the constructor that takes a Gdk::RGBA instead." |
| 78 |
*/ |
| 79 |
explicit ColorButton(const Gdk::Color& color); |
| 80 |
_IGNORE(gtk_color_button_new_with_color) |
| 81 |
#endif //GTKMM_DISABLE_DEPRECATED |
| 82 |
|
| 83 |
/** Creates a new color button with a predefined color. |
| 84 |
* |
| 85 |
* Same as Gtk::ColorButton::ColorButton(). Additionally takes a Gdk::RGBA and |
| 86 |
* initializes the button with this color. Equivalent to calling set_rgba(@a color) |
| 87 |
* after the default constructor. |
| 88 |
* |
| 89 |
* @param rgba A Gdk::RGBA to set the current color with. |
| 90 |
* |
| 91 |
* @newin{3,0} |
| 92 |
*/ |
| 93 |
_WRAP_CTOR(ColorButton(const Gdk::RGBA& rgba), gtk_color_button_new_with_rgba) |
| 94 |
|
| 95 |
//TODO: When we can implement interface ColorChooser: deprecated "Use Gtk::ColorChooser::set_rgba() instead." |
| 96 |
_WRAP_METHOD(void set_color(const Gdk::Color& color), gtk_color_button_set_color, deprecated "Use set_rgba() instead.") |
| 97 |
//TODO: When we can implement interface ColorChooser: deprecated "Use Gtk::ColorChooser::set_rgba() instead." |
| 98 |
_WRAP_METHOD(void set_alpha(guint16 alpha), gtk_color_button_set_alpha, deprecated "Use set_rgba() instead.") |
| 99 |
//TODO: When we can implement interface ColorChooser: deprecated "Use Gtk::ColorChooser::set_rgba() instead." |
| 100 |
_WRAP_METHOD(void set_rgba(const Gdk::RGBA& rgba), gtk_color_button_set_rgba) |
| 101 |
|
| 102 |
#ifndef GTKMM_DISABLE_DEPRECATED |
| 103 |
|
| 104 |
//TODO: When we can implement interface ColorChooser: deprecated Use Gtk::ColorChooser::get_rgba() instead. |
| 105 |
/** Returns a copy of the the current color. |
| 106 |
* |
| 107 |
* Changes to the return value will have no effect on the Gtk::ColorButton. |
| 108 |
* |
| 109 |
* @return A Gdk::Color representing the current internal color of the Gtk::ColorButton. |
| 110 |
* |
| 111 |
* @newin{2,4} |
| 112 |
* @deprecated Use get_rgba() instead. |
| 113 |
*/ |
| 114 |
Gdk::Color get_color() const; |
| 115 |
_IGNORE(gtk_color_button_get_color) |
| 116 |
|
| 117 |
#endif //GTKMM_DISABLE_DEPRECATED |
| 118 |
|
| 119 |
//TODO: When we can implement interface ColorChooser: deprecated Use Gtk::ColorChooser::get_rgba() instead. |
| 120 |
/** Returns a copy of the the current color. |
| 121 |
* |
| 122 |
* Changes to the return value will have no effect on the Gtk::ColorButton. |
| 123 |
* |
| 124 |
* @return A Gdk::RGBA representing the current internal color of the Gtk::ColorButton. |
| 125 |
* |
| 126 |
* @newin{3,0} |
| 127 |
*/ |
| 128 |
Gdk::RGBA get_rgba() const; |
| 129 |
_IGNORE(gtk_color_button_get_rgba) |
| 130 |
|
| 131 |
//TODO: When we can implement interface ColorChooser: deprecated "Use Gtk::ColorChooser::get_rgba() instead." |
| 132 |
_WRAP_METHOD(guint16 get_alpha() const, gtk_color_button_get_alpha, deprecated "Use get_rgba() instead.") |
| 133 |
//TODO: When we can implement interface ColorChooser: deprecated "Use Gtk::ColorChooser::set_use_alpha() instead." |
| 134 |
_WRAP_METHOD(void set_use_alpha(bool use_alpha = true), gtk_color_button_set_use_alpha) |
| 135 |
//TODO: When we can implement interface ColorChooser: deprecated "Use Gtk::ColorChooser::get_use_alpha() instead." |
| 136 |
_WRAP_METHOD(bool get_use_alpha() const, gtk_color_button_get_use_alpha) |
| 137 |
_WRAP_METHOD(void set_title(const Glib::ustring& title), gtk_color_button_set_title) |
| 138 |
_WRAP_METHOD(Glib::ustring get_title() const, gtk_color_button_get_title) |
| 139 |
|
| 140 |
_WRAP_PROPERTY("use-alpha", bool) |
| 141 |
_WRAP_PROPERTY("title", Glib::ustring) |
| 142 |
_WRAP_PROPERTY("color", Gdk::Color, deprecated "Use property_rgba() instead.") |
| 143 |
_WRAP_PROPERTY("rgba", Gdk::RGBA) |
| 144 |
_WRAP_PROPERTY("alpha", guint16) //Todo: Remove this when we remove the "color" property too. |
| 145 |
_WRAP_PROPERTY("show-editor", bool) |
| 146 |
|
| 147 |
_WRAP_SIGNAL(void color_set(), "color-set") |
| 148 |
}; |
| 149 |
|
| 150 |
} // namespace Gtk |