Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / gtkmm2 / gtk / src / colorbutton.hg
1 /* $Id: colorbutton.hg,v 1.5 2005/11/30 14:10:49 murrayc Exp $ */
2
3 /* colorbutton.h
4  *
5  * Copyright (C) 2003 The gtkmm Development Team
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the Free
19  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21
22 #include <gtkmm/button.h>
23 #include <gdkmm/color.h>
24 _DEFS(gtkmm,gtk)
25 _PINCLUDE(gtkmm/private/button_p.h)
26
27
28 namespace Gtk
29 {
30
31 /** A button to launch a color selection dialog.
32  *
33  * The GtkColorButton is a button which displays the currently selected color an allows to
34  * open a color selection dialog to change the color. It is suitable widget for selecting a
35  * color in a preference dialog.
36  *
37  * @ingroup Widgets
38  */
39 class ColorButton : public Button
40 {
41   _CLASS_GTKOBJECT(ColorButton, GtkColorButton, GTK_COLOR_BUTTON, Gtk::Button, GtkButton)
42 public:
43
44   /** Creates a new color button.
45    * 
46    * This creates a widget in the form of a small button containing a swatch representing
47    * the current selected color. When the button is clicked, a color-selection dialog will
48    * open, allowing the user to select a color. The swatch will be updated to reflect the
49    * new color when the user finishes.
50    *
51    * @newin2p4
52    */
53   _CTOR_DEFAULT()
54   _IGNORE(gtk_color_button_new)
55   
56   /** Creates a new color button with a predefined color.
57    * 
58    * Same as Gtk::ColorButton::ColorButton(). Additionally takes a Gdk::Color and
59    * initializes the button with this color. Equivalent to calling set_color(@a color)
60    * after the default constructor.
61    *
62    * @param color A Gdk::Color to set the current color with.
63    *
64    * @newin2p4
65    */
66   _WRAP_CTOR(ColorButton(const Gdk::Color& color), gtk_color_button_new_with_color)
67
68   _WRAP_METHOD(void set_color(const Gdk::Color& color), gtk_color_button_set_color)
69   _WRAP_METHOD(void set_alpha(guint16 alpha), gtk_color_button_set_alpha)
70   
71   /** Returns a copy of the the current color.
72    * 
73    * Changes to the return value will have no effect on the Gtk::ColorButton.
74    *
75    * @return A Gdk::Color representing the current internal color of the Gtk::ColorButton.
76    *
77    * @newin2p4
78    */
79   Gdk::Color get_color() const;
80   _IGNORE(gtk_color_button_get_color)
81   
82   _WRAP_METHOD(guint16 get_alpha() const, gtk_color_button_get_alpha)
83   _WRAP_METHOD(void set_use_alpha(bool use_alpha = true), gtk_color_button_set_use_alpha)
84   _WRAP_METHOD(bool get_use_alpha() const, gtk_color_button_get_use_alpha)
85   _WRAP_METHOD(void set_title(const Glib::ustring& title), gtk_color_button_set_title)
86   _WRAP_METHOD(Glib::ustring get_title() const, gtk_color_button_get_title)
87
88   _WRAP_PROPERTY("use-alpha", bool)
89   _WRAP_PROPERTY("title", Glib::ustring)
90   _WRAP_PROPERTY("color", Gdk::Color)
91   _WRAP_PROPERTY("alpha", guint16)
92
93   /** The color_set signal is emitted when the user selects a color. When handling this signal,
94    * use get_color() and get_alpha() to find out which color 
95    * was just selected.
96    */
97   _WRAP_SIGNAL(void color_set(), "color-set")                    
98 };
99
100
101 } // namespace Gtk
102