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 module gtk.ColorChooserT; 26 27 public import gdk.RGBA; 28 public import glib.MemorySlice; 29 public import gobject.ObjectG; 30 public import gobject.Signals; 31 public import gtk.c.functions; 32 public import gtk.c.types; 33 public import gtkc.gtktypes; 34 public import std.algorithm; 35 36 37 /** 38 * #GtkColorChooser is an interface that is implemented by widgets 39 * for choosing colors. Depending on the situation, colors may be 40 * allowed to have alpha (translucency). 41 * 42 * In GTK+, the main widgets that implement this interface are 43 * #GtkColorChooserWidget, #GtkColorChooserDialog and #GtkColorButton. 44 * 45 * Since: 3.4 46 */ 47 public template ColorChooserT(TStruct) 48 { 49 /** Get the main Gtk struct */ 50 public GtkColorChooser* getColorChooserStruct(bool transferOwnership = false) 51 { 52 if (transferOwnership) 53 ownedRef = false; 54 return cast(GtkColorChooser*)getStruct(); 55 } 56 57 58 /** 59 * Adds a palette to the color chooser. If @orientation is horizontal, 60 * the colors are grouped in rows, with @colors_per_line colors 61 * in each row. If @horizontal is %FALSE, the colors are grouped 62 * in columns instead. 63 * 64 * The default color palette of #GtkColorChooserWidget has 65 * 27 colors, organized in columns of 3 colors. The default gray 66 * palette has 9 grays in a single row. 67 * 68 * The layout of the color chooser widget works best when the 69 * palettes have 9-10 columns. 70 * 71 * Calling this function for the first time has the 72 * side effect of removing the default color and gray palettes 73 * from the color chooser. 74 * 75 * If @colors is %NULL, removes all previously added palettes. 76 * 77 * Params: 78 * orientation = %GTK_ORIENTATION_HORIZONTAL if the palette should 79 * be displayed in rows, %GTK_ORIENTATION_VERTICAL for columns 80 * colorsPerLine = the number of colors to show in each row/column 81 * colors = the colors of the palette, or %NULL 82 * 83 * Since: 3.4 84 */ 85 public void addPalette(GtkOrientation orientation, int colorsPerLine, RGBA[] colors) 86 { 87 GdkRGBA[] colorsArray = new GdkRGBA[colors.length]; 88 for ( int i = 0; i < colors.length; i++ ) 89 { 90 colorsArray[i] = *(colors[i].getRGBAStruct()); 91 } 92 93 gtk_color_chooser_add_palette(getColorChooserStruct(), orientation, colorsPerLine, cast(int)colors.length, colorsArray.ptr); 94 } 95 96 /** 97 * Gets the currently-selected color. 98 * 99 * Params: 100 * color = a #GdkRGBA to fill in with the current color 101 * 102 * Since: 3.4 103 */ 104 public void getRgba(out RGBA color) 105 { 106 GdkRGBA* outcolor = sliceNew!GdkRGBA(); 107 108 gtk_color_chooser_get_rgba(getColorChooserStruct(), outcolor); 109 110 color = ObjectG.getDObject!(RGBA)(outcolor, true); 111 } 112 113 /** 114 * Returns whether the color chooser shows the alpha channel. 115 * 116 * Returns: %TRUE if the color chooser uses the alpha channel, 117 * %FALSE if not 118 * 119 * Since: 3.4 120 */ 121 public bool getUseAlpha() 122 { 123 return gtk_color_chooser_get_use_alpha(getColorChooserStruct()) != 0; 124 } 125 126 /** 127 * Sets the color. 128 * 129 * Params: 130 * color = the new color 131 * 132 * Since: 3.4 133 */ 134 public void setRgba(RGBA color) 135 { 136 gtk_color_chooser_set_rgba(getColorChooserStruct(), (color is null) ? null : color.getRGBAStruct()); 137 } 138 139 /** 140 * Sets whether or not the color chooser should use the alpha channel. 141 * 142 * Params: 143 * useAlpha = %TRUE if color chooser should use alpha channel, %FALSE if not 144 * 145 * Since: 3.4 146 */ 147 public void setUseAlpha(bool useAlpha) 148 { 149 gtk_color_chooser_set_use_alpha(getColorChooserStruct(), useAlpha); 150 } 151 152 /** 153 * Emitted when a color is activated from the color chooser. 154 * This usually happens when the user clicks a color swatch, 155 * or a color is selected and the user presses one of the keys 156 * Space, Shift+Space, Return or Enter. 157 * 158 * Params: 159 * color = the color 160 * 161 * Since: 3.4 162 */ 163 gulong addOnColorActivated(void delegate(RGBA, ColorChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 164 { 165 return Signals.connect(this, "color-activated", dlg, connectFlags ^ ConnectFlags.SWAPPED); 166 } 167 }