1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GtkColorChooser.html
27  * outPack = gtk
28  * outFile = ColorChooserT
29  * strct   = GtkColorChooser
30  * realStrct=
31  * ctorStrct=
32  * clss    = ColorChooserT
33  * interf  = ColorChooserIF
34  * class Code: Yes
35  * interface Code: Yes
36  * template for:
37  * 	- TStruct
38  * extend  = 
39  * implements:
40  * prefixes:
41  * 	- gtk_color_chooser_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * 	- gtk_color_chooser_add_palette
46  * omit signals:
47  * imports:
48  * 	- gdk.RGBA
49  * structWrap:
50  * 	- GdkRGBA* -> RGBA
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gtk.ColorChooserT;
57 
58 public  import gtkc.gtktypes;
59 
60 public import gtkc.gtk;
61 public import glib.ConstructionException;
62 public import gobject.ObjectG;
63 
64 public import gobject.Signals;
65 public  import gtkc.gdktypes;
66 public import gdk.RGBA;
67 
68 
69 
70 /**
71  * GtkColorChooser is an interface that is implemented by widgets
72  * for choosing colors. Depending on the situation, colors may be
73  * allowed to have alpha (translucency).
74  *
75  * In GTK+, the main widgets that implement this interface are
76  * GtkColorChooserWidget, GtkColorChooserDialog and GtkColorButton.
77  */
78 public template ColorChooserT(TStruct)
79 {
80 	
81 	/** the main Gtk struct */
82 	protected GtkColorChooser* gtkColorChooser;
83 	
84 	
85 	/** Get the main Gtk struct */
86 	public GtkColorChooser* getColorChooserTStruct()
87 	{
88 		return cast(GtkColorChooser*)getStruct();
89 	}
90 	
91 	
92 	/**
93 	 * Adds a palette to the color chooser. If orientation is horizontal,
94 	 * the colors are grouped in rows, with colorsPerPine colors
95 	 * in each row. If horizontal is false, the colors are grouped
96 	 * in columns instead.
97 	 *
98 	 * The default color palette of ColorChooserWidget has
99 	 * 27 colors, organized in columns of 3 colors. The default gray
100 	 * palette has 9 grays in a single row.
101 	 *
102 	 * The layout of the color chooser widget works best when the
103 	 * palettes have 9-10 columns.
104 	 *
105 	 * Calling this function for the first time has the
106 	 * side effect of removing the default color and gray palettes
107 	 * from the color chooser.
108 	 *
109 	 * If colors is null, removes all previously added palettes.
110 	 *
111 	 * Params:
112 	 *     orientation   = Orientation.HORIZONTAL if the palette should
113 	 *                     be displayed in rows, Orientation.VERTICAL for columns
114 	 *     colorsPerLine = the number of colors to show in each row/column
115 	 *     colors        = the colors of the palette, or null.
116 	 * Since 3.4
117 	 */
118 	public void addPalette(GtkOrientation orientation, int colorsPerLine, RGBA[] colors)
119 	{
120 		GdkRGBA*[] cColors = new GdkRGBA*[colors.length];
121 		
122 		foreach( i, color; colors )
123 		{
124 			cColors[i] = color.getRGBAStruct();
125 		}
126 		
127 		// void gtk_color_chooser_add_palette (GtkColorChooser *chooser,  GtkOrientation orientation,  gint colors_per_line,  gint n_colors,  GdkRGBA *colors);
128 		gtk_color_chooser_add_palette(getColorChooserTStruct(), orientation, colorsPerLine, cast(int) colors.length, cColors[0]);
129 	}
130 	
131 	/**
132 	 */
133 	int[string] connectedSignals;
134 	
135 	void delegate(RGBA, ColorChooserIF)[] _onColorActivatedListeners;
136 	@property void delegate(RGBA, ColorChooserIF)[] onColorActivatedListeners()
137 	{
138 		return  _onColorActivatedListeners;
139 	}
140 	/**
141 	 * Emitted when a color is activated from the color chooser.
142 	 * This usually happens when the user clicks a color swatch,
143 	 * or a color is selected and the user presses one of the keys
144 	 * Space, Shift+Space, Return or Enter.
145 	 * Since 3.4
146 	 * See Also
147 	 * GtkColorChooserDialog, GtkColorChooserWidget, GtkColorButton
148 	 */
149 	void addOnColorActivated(void delegate(RGBA, ColorChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
150 	{
151 		if ( !("color-activated" in connectedSignals) )
152 		{
153 			Signals.connectData(
154 			getStruct(),
155 			"color-activated",
156 			cast(GCallback)&callBackColorActivated,
157 			cast(void*)cast(ColorChooserIF)this,
158 			null,
159 			connectFlags);
160 			connectedSignals["color-activated"] = 1;
161 		}
162 		_onColorActivatedListeners ~= dlg;
163 	}
164 	extern(C) static void callBackColorActivated(GtkColorChooser* chooserStruct, GdkRGBA* color, ColorChooserIF _colorChooserIF)
165 	{
166 		foreach ( void delegate(RGBA, ColorChooserIF) dlg ; _colorChooserIF.onColorActivatedListeners )
167 		{
168 			dlg(ObjectG.getDObject!(RGBA)(color), _colorChooserIF);
169 		}
170 	}
171 	
172 	
173 	/**
174 	 * Gets the currently-selected color.
175 	 * Params:
176 	 * color = a GdkRGBA to fill in with the current color. [out]
177 	 * Since 3.4
178 	 */
179 	public void getRgba(RGBA color)
180 	{
181 		// void gtk_color_chooser_get_rgba (GtkColorChooser *chooser,  GdkRGBA *color);
182 		gtk_color_chooser_get_rgba(getColorChooserTStruct(), (color is null) ? null : color.getRGBAStruct());
183 	}
184 	
185 	/**
186 	 * Sets the color.
187 	 * Params:
188 	 * color = the new color
189 	 * Since 3.4
190 	 */
191 	public void setRgba(RGBA color)
192 	{
193 		// void gtk_color_chooser_set_rgba (GtkColorChooser *chooser,  const GdkRGBA *color);
194 		gtk_color_chooser_set_rgba(getColorChooserTStruct(), (color is null) ? null : color.getRGBAStruct());
195 	}
196 	
197 	/**
198 	 * Returns whether the color chooser shows the alpha channel.
199 	 * Returns: TRUE if the color chooser uses the alpha channel, FALSE if not Since 3.4
200 	 */
201 	public int getUseAlpha()
202 	{
203 		// gboolean gtk_color_chooser_get_use_alpha (GtkColorChooser *chooser);
204 		return gtk_color_chooser_get_use_alpha(getColorChooserTStruct());
205 	}
206 	
207 	/**
208 	 * Sets whether or not the color chooser should use the alpha channel.
209 	 * Params:
210 	 * useAlpha = TRUE if color chooser should use alpha channel, FALSE if not
211 	 * Since 3.4
212 	 */
213 	public void setUseAlpha(int useAlpha)
214 	{
215 		// void gtk_color_chooser_set_use_alpha (GtkColorChooser *chooser,  gboolean use_alpha);
216 		gtk_color_chooser_set_use_alpha(getColorChooserTStruct(), useAlpha);
217 	}
218 }