Debian Codegraph @

gtk/src/colorchooser.hg

raw
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 <glibmm/interface.h>
18 #include <gtkmm/enums.h> //For Orientation.
19 #include <gdkmm/rgba.h>
20
21 _DEFS(gtkmm,gtk)
22 _PINCLUDE(glibmm/private/interface_p.h)
23
24 #ifndef DOXYGEN_SHOULD_SKIP_THIS
25 extern "C"
26 {
27 typedef struct _GtkColorChooserInterface GtkColorChooserInterface;
28 }
29 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
30
31 namespace Gtk
32 {
33
34 /** This interface can be implemented by widgets which allow the user to choose
35 * a color. Depending on the situation, colors may be
36 * allowed to have alpha (translucency).
37 * The main widgets that implement this interface are ColorChooserWidget, ColorChooserDialog
38 * and ColorChooserButton.
39 *
40 * @newin{3,4}
41 */
42 class GTKMM_API ColorChooser : public Glib::Interface
43 {
44 _CLASS_INTERFACE(ColorChooser, GtkColorChooser, GTK_COLOR_CHOOSER, GtkColorChooserInterface, , , GTKMM_API)
45
46 public:
47 /** Gets the currently selected color.
48 * @return The currently selected color.
49 * @newin{3,4}
50 */
51 Gdk::RGBA get_rgba() const;
52 _IGNORE(gtk_color_chooser_get_rgba)
53
54 _WRAP_METHOD(void set_rgba(const Gdk::RGBA& color), gtk_color_chooser_set_rgba)
55 _WRAP_METHOD(bool get_use_alpha() const, gtk_color_chooser_get_use_alpha)
56 _WRAP_METHOD(void set_use_alpha(bool use_alpha = true), gtk_color_chooser_set_use_alpha)
57
58 /** Adds a palette to the color chooser. If @a orientation is horizontal,
59 * the colors are grouped in rows, with @a colors_per_line colors
60 * in each row. If @a orientation is vertical, the colors are grouped
61 * in columns instead.
62 *
63 * The default color palette of ColorChooserWidget has
64 * 27 colors, organized in columns of 3 colors. The default gray
65 * palette has 9 grays in a single row.
66 *
67 * The layout of the color chooser widget works best when the
68 * palettes have 9-10 columns.
69 *
70 * Calling this function for the first time has the
71 * side effect of removing the default color and gray palettes
72 * from the color chooser.
73 *
74 * @param orientation ORIENTATION_HORIZONTAL if the palette should be displayed in rows, or ORIENTATION_VERTICAL for columns
75 * @param colors_per_line The number of colors to show in each row/column.
76 * @param colors The colors of the palette.
77 *
78 * @newin{3,4}
79 */
80 void add_palette(Orientation orientation, int colors_per_line, const std::vector<Gdk::RGBA>& colors);
81 _IGNORE(gtk_color_chooser_add_palette)
82
83 #m4 _CONVERSION(`const GdkRGBA*',`const Gdk::RGBA&',`Glib::wrap(const_cast<GdkRGBA*>($3), true)')
84 //#m4 _CONVERSION(`const Gdk::RGBA&',`const GdkRGBA*',`const_cast<GdkRGBA*>(($3).gobj())')
85 _WRAP_SIGNAL(void color_activated(const Gdk::RGBA& color), "color-activated")
86
87 _WRAP_PROPERTY("rgba", Gdk::RGBA)
88 _WRAP_PROPERTY("use-alpha", bool)
89 };
90
91 } // namespace Gtk