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 
67 public import gdk.RGBA;
68 
69 
70 
71 
72 /**
73  * GtkColorChooser is an interface that is implemented by widgets
74  * for choosing colors. Depending on the situation, colors may be
75  * allowed to have alpha (translucency).
76  *
77  * In GTK+, the main widgets that implement this interface are
78  * GtkColorChooserWidget, GtkColorChooserDialog and GtkColorButton.
79  */
80 public template ColorChooserT(TStruct)
81 {
82 	
83 	/** the main Gtk struct */
84 	protected GtkColorChooser* gtkColorChooser;
85 	
86 	
87 	public GtkColorChooser* getColorChooserTStruct()
88 	{
89 		return cast(GtkColorChooser*)getStruct();
90 	}
91 	
92 	
93 	/**
94 	 * Adds a palette to the color chooser. If orientation is horizontal,
95 	 * the colors are grouped in rows, with colorsPerPine colors
96 	 * in each row. If horizontal is false, the colors are grouped
97 	 * in columns instead.
98 	 *
99 	 * The default color palette of ColorChooserWidget has
100 	 * 27 colors, organized in columns of 3 colors. The default gray
101 	 * palette has 9 grays in a single row.
102 	 *
103 	 * The layout of the color chooser widget works best when the
104 	 * palettes have 9-10 columns.
105 	 *
106 	 * Calling this function for the first time has the
107 	 * side effect of removing the default color and gray palettes
108 	 * from the color chooser.
109 	 *
110 	 * If colors is null, removes all previously added palettes.
111 	 *
112 	 * Params:
113 	 *     orientation   = Orientation.HORIZONTAL if the palette should
114 	 *                     be displayed in rows, Orientation.VERTICAL for columns
115 	 *     colorsPerLine = the number of colors to show in each row/column
116 	 *     colors        = the colors of the palette, or null.
117 	 * Since 3.4
118 	 */
119 	public void addPalette(GtkOrientation orientation, int colorsPerLine, RGBA[] colors)
120 	{
121 		GdkRGBA*[] cColors = new GdkRGBA*[colors.length];
122 		
123 		foreach( i, color; colors )
124 		{
125 			cColors[i] = color.getRGBAStruct();
126 		}
127 		
128 		// void gtk_color_chooser_add_palette (GtkColorChooser *chooser,  GtkOrientation orientation,  gint colors_per_line,  gint n_colors,  GdkRGBA *colors);
129 		gtk_color_chooser_add_palette(getColorChooserTStruct(), orientation, colorsPerLine, cast(int) colors.length, cColors[0]);
130 	}
131 	
132 	/**
133 	 */
134 	int[string] connectedSignals;
135 	
136 	void delegate(RGBA, ColorChooserIF)[] _onColorActivatedListeners;
137 	@property void delegate(RGBA, ColorChooserIF)[] onColorActivatedListeners()
138 	{
139 		return  _onColorActivatedListeners;
140 	}
141 	/**
142 	 * Emitted when a color is activated from the color chooser.
143 	 * This usually happens when the user clicks a color swatch,
144 	 * or a color is selected and the user presses one of the keys
145 	 * Space, Shift+Space, Return or Enter.
146 	 * Since 3.4
147 	 * See Also
148 	 * GtkColorChooserDialog, GtkColorChooserWidget, GtkColorButton
149 	 */
150 	void addOnColorActivated(void delegate(RGBA, ColorChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
151 	{
152 		if ( !("color-activated" in connectedSignals) )
153 		{
154 			Signals.connectData(
155 			getStruct(),
156 			"color-activated",
157 			cast(GCallback)&callBackColorActivated,
158 			cast(void*)cast(ColorChooserIF)this,
159 			null,
160 			connectFlags);
161 			connectedSignals["color-activated"] = 1;
162 		}
163 		_onColorActivatedListeners ~= dlg;
164 	}
165 	extern(C) static void callBackColorActivated(GtkColorChooser* chooserStruct, GdkRGBA* color, ColorChooserIF _colorChooserIF)
166 	{
167 		foreach ( void delegate(RGBA, ColorChooserIF) dlg ; _colorChooserIF.onColorActivatedListeners )
168 		{
169 			dlg(ObjectG.getDObject!(RGBA)(color), _colorChooserIF);
170 		}
171 	}
172 	
173 	
174 	/**
175 	 * Gets the currently-selected color.
176 	 * Params:
177 	 * color = a GdkRGBA to fill in with the current color. [out]
178 	 * Since 3.4
179 	 */
180 	public void getRgba(RGBA color)
181 	{
182 		// void gtk_color_chooser_get_rgba (GtkColorChooser *chooser,  GdkRGBA *color);
183 		gtk_color_chooser_get_rgba(getColorChooserTStruct(), (color is null) ? null : color.getRGBAStruct());
184 	}
185 	
186 	/**
187 	 * Sets the color.
188 	 * Params:
189 	 * color = the new color
190 	 * Since 3.4
191 	 */
192 	public void setRgba(RGBA color)
193 	{
194 		// void gtk_color_chooser_set_rgba (GtkColorChooser *chooser,  const GdkRGBA *color);
195 		gtk_color_chooser_set_rgba(getColorChooserTStruct(), (color is null) ? null : color.getRGBAStruct());
196 	}
197 	
198 	/**
199 	 * Returns whether the color chooser shows the alpha channel.
200 	 * Returns: TRUE if the color chooser uses the alpha channel, FALSE if not Since 3.4
201 	 */
202 	public int getUseAlpha()
203 	{
204 		// gboolean gtk_color_chooser_get_use_alpha (GtkColorChooser *chooser);
205 		return gtk_color_chooser_get_use_alpha(getColorChooserTStruct());
206 	}
207 	
208 	/**
209 	 * Sets whether or not the color chooser should use the alpha channel.
210 	 * Params:
211 	 * useAlpha = TRUE if color chooser should use alpha channel, FALSE if not
212 	 * Since 3.4
213 	 */
214 	public void setUseAlpha(int useAlpha)
215 	{
216 		// void gtk_color_chooser_set_use_alpha (GtkColorChooser *chooser,  gboolean use_alpha);
217 		gtk_color_chooser_set_use_alpha(getColorChooserTStruct(), useAlpha);
218 	}
219 }