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 = GtkColorSelection.html 27 * outPack = gtk 28 * outFile = ColorSelection 29 * strct = GtkColorSelection 30 * realStrct= 31 * ctorStrct= 32 * clss = ColorSelection 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_color_selection_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - gdk.Color 48 * - gdk.RGBA 49 * structWrap: 50 * - GdkColor* -> Color 51 * - GdkRGBA* -> RGBA 52 * module aliases: 53 * local aliases: 54 * overrides: 55 */ 56 57 module gtk.ColorSelection; 58 59 public import gtkc.gtktypes; 60 61 private import gtkc.gtk; 62 private import glib.ConstructionException; 63 private import gobject.ObjectG; 64 65 private import gobject.Signals; 66 public import gtkc.gdktypes; 67 private import glib.Str; 68 private import gdk.Color; 69 private import gdk.RGBA; 70 71 72 private import gtk.Box; 73 74 /** 75 * The GtkColorSelection is a widget that is used to select 76 * a color. It consists of a color wheel and number of sliders 77 * and entry boxes for color parameters such as hue, saturation, 78 * value, red, green, blue, and opacity. It is found on the standard 79 * color selection dialog box GtkColorSelectionDialog. 80 */ 81 public class ColorSelection : Box 82 { 83 84 /** the main Gtk struct */ 85 protected GtkColorSelection* gtkColorSelection; 86 87 88 /** Get the main Gtk struct */ 89 public GtkColorSelection* getColorSelectionStruct() 90 { 91 return gtkColorSelection; 92 } 93 94 95 /** the main Gtk struct as a void* */ 96 protected override void* getStruct() 97 { 98 return cast(void*)gtkColorSelection; 99 } 100 101 /** 102 * Sets our main struct and passes it to the parent class 103 */ 104 public this (GtkColorSelection* gtkColorSelection) 105 { 106 super(cast(GtkBox*)gtkColorSelection); 107 this.gtkColorSelection = gtkColorSelection; 108 } 109 110 protected override void setStruct(GObject* obj) 111 { 112 super.setStruct(obj); 113 gtkColorSelection = cast(GtkColorSelection*)obj; 114 } 115 116 /** 117 */ 118 int[string] connectedSignals; 119 120 void delegate(ColorSelection)[] onColorChangedListeners; 121 /** 122 * This signal is emitted when the color changes in the GtkColorSelection 123 * according to its update policy. 124 */ 125 void addOnColorChanged(void delegate(ColorSelection) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 126 { 127 if ( !("color-changed" in connectedSignals) ) 128 { 129 Signals.connectData( 130 getStruct(), 131 "color-changed", 132 cast(GCallback)&callBackColorChanged, 133 cast(void*)this, 134 null, 135 connectFlags); 136 connectedSignals["color-changed"] = 1; 137 } 138 onColorChangedListeners ~= dlg; 139 } 140 extern(C) static void callBackColorChanged(GtkColorSelection* colorselectionStruct, ColorSelection _colorSelection) 141 { 142 foreach ( void delegate(ColorSelection) dlg ; _colorSelection.onColorChangedListeners ) 143 { 144 dlg(_colorSelection); 145 } 146 } 147 148 149 /** 150 * Creates a new GtkColorSelection. 151 * Throws: ConstructionException GTK+ fails to create the object. 152 */ 153 public this () 154 { 155 // GtkWidget * gtk_color_selection_new (void); 156 auto p = gtk_color_selection_new(); 157 if(p is null) 158 { 159 throw new ConstructionException("null returned by gtk_color_selection_new()"); 160 } 161 this(cast(GtkColorSelection*) p); 162 } 163 164 /** 165 * Sets the colorsel to use or not use opacity. 166 * Params: 167 * hasOpacity = TRUE if colorsel can set the opacity, FALSE otherwise 168 */ 169 public void setHasOpacityControl(int hasOpacity) 170 { 171 // void gtk_color_selection_set_has_opacity_control (GtkColorSelection *colorsel, gboolean has_opacity); 172 gtk_color_selection_set_has_opacity_control(gtkColorSelection, hasOpacity); 173 } 174 175 /** 176 * Determines whether the colorsel has an opacity control. 177 * Returns: TRUE if the colorsel has an opacity control, FALSE if it does't 178 */ 179 public int getHasOpacityControl() 180 { 181 // gboolean gtk_color_selection_get_has_opacity_control (GtkColorSelection *colorsel); 182 return gtk_color_selection_get_has_opacity_control(gtkColorSelection); 183 } 184 185 /** 186 * Shows and hides the palette based upon the value of has_palette. 187 * Params: 188 * hasPalette = TRUE if palette is to be visible, FALSE otherwise 189 */ 190 public void setHasPalette(int hasPalette) 191 { 192 // void gtk_color_selection_set_has_palette (GtkColorSelection *colorsel, gboolean has_palette); 193 gtk_color_selection_set_has_palette(gtkColorSelection, hasPalette); 194 } 195 196 /** 197 * Determines whether the color selector has a color palette. 198 * Returns: TRUE if the selector has a palette, FALSE if it hasn't 199 */ 200 public int getHasPalette() 201 { 202 // gboolean gtk_color_selection_get_has_palette (GtkColorSelection *colorsel); 203 return gtk_color_selection_get_has_palette(gtkColorSelection); 204 } 205 206 /** 207 * Returns the current alpha value. 208 * Returns: an integer between 0 and 65535 209 */ 210 public ushort getCurrentAlpha() 211 { 212 // guint16 gtk_color_selection_get_current_alpha (GtkColorSelection *colorsel); 213 return gtk_color_selection_get_current_alpha(gtkColorSelection); 214 } 215 216 /** 217 * Sets the current opacity to be alpha. 218 * The first time this is called, it will also set 219 * the original opacity to be alpha too. 220 * Params: 221 * alpha = an integer between 0 and 65535 222 */ 223 public void setCurrentAlpha(ushort alpha) 224 { 225 // void gtk_color_selection_set_current_alpha (GtkColorSelection *colorsel, guint16 alpha); 226 gtk_color_selection_set_current_alpha(gtkColorSelection, alpha); 227 } 228 229 /** 230 * Warning 231 * gtk_color_selection_get_current_color has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_color_selection_get_current_rgba() instead. 232 * Sets color to be the current color in the GtkColorSelection widget. 233 * Params: 234 * color = a GdkColor to fill in with the current color. [out] 235 */ 236 public void getCurrentColor(Color color) 237 { 238 // void gtk_color_selection_get_current_color (GtkColorSelection *colorsel, GdkColor *color); 239 gtk_color_selection_get_current_color(gtkColorSelection, (color is null) ? null : color.getColorStruct()); 240 } 241 242 /** 243 * Warning 244 * gtk_color_selection_set_current_color has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_color_selection_set_current_rgba() instead. 245 * Sets the current color to be color. 246 * The first time this is called, it will also set 247 * the original color to be color too. 248 * Params: 249 * color = a GdkColor to set the current color with 250 */ 251 public void setCurrentColor(Color color) 252 { 253 // void gtk_color_selection_set_current_color (GtkColorSelection *colorsel, const GdkColor *color); 254 gtk_color_selection_set_current_color(gtkColorSelection, (color is null) ? null : color.getColorStruct()); 255 } 256 257 /** 258 * Returns the previous alpha value. 259 * Returns: an integer between 0 and 65535 260 */ 261 public ushort getPreviousAlpha() 262 { 263 // guint16 gtk_color_selection_get_previous_alpha (GtkColorSelection *colorsel); 264 return gtk_color_selection_get_previous_alpha(gtkColorSelection); 265 } 266 267 /** 268 * Sets the 'previous' alpha to be alpha. 269 * This function should be called with some hesitations, 270 * as it might seem confusing to have that alpha change. 271 * Params: 272 * alpha = an integer between 0 and 65535 273 */ 274 public void setPreviousAlpha(ushort alpha) 275 { 276 // void gtk_color_selection_set_previous_alpha (GtkColorSelection *colorsel, guint16 alpha); 277 gtk_color_selection_set_previous_alpha(gtkColorSelection, alpha); 278 } 279 280 /** 281 * Warning 282 * gtk_color_selection_get_previous_color has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_color_selection_get_previous_rgba() instead. 283 * Fills color in with the original color value. 284 * Params: 285 * color = a GdkColor to fill in with the original color value. [out] 286 */ 287 public void getPreviousColor(Color color) 288 { 289 // void gtk_color_selection_get_previous_color (GtkColorSelection *colorsel, GdkColor *color); 290 gtk_color_selection_get_previous_color(gtkColorSelection, (color is null) ? null : color.getColorStruct()); 291 } 292 293 /** 294 * Warning 295 * gtk_color_selection_set_previous_color has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_color_selection_set_previous_rgba() instead. 296 * Sets the 'previous' color to be color. 297 * This function should be called with some hesitations, 298 * as it might seem confusing to have that color change. 299 * Calling gtk_color_selection_set_current_color() will also 300 * set this color the first time it is called. 301 * Params: 302 * color = a GdkColor to set the previous color with 303 */ 304 public void setPreviousColor(Color color) 305 { 306 // void gtk_color_selection_set_previous_color (GtkColorSelection *colorsel, const GdkColor *color); 307 gtk_color_selection_set_previous_color(gtkColorSelection, (color is null) ? null : color.getColorStruct()); 308 } 309 310 /** 311 * Sets rgba to be the current color in the GtkColorSelection widget. 312 * Params: 313 * rgba = a GdkRGBA to fill in with the current color. [out] 314 * Since 3.0 315 */ 316 public void getCurrentRgba(RGBA rgba) 317 { 318 // void gtk_color_selection_get_current_rgba (GtkColorSelection *colorsel, GdkRGBA *rgba); 319 gtk_color_selection_get_current_rgba(gtkColorSelection, (rgba is null) ? null : rgba.getRGBAStruct()); 320 } 321 322 /** 323 * Sets the current color to be rgba. 324 * The first time this is called, it will also set 325 * the original color to be rgba too. 326 * Params: 327 * rgba = A GdkRGBA to set the current color with 328 * Since 3.0 329 */ 330 public void setCurrentRgba(RGBA rgba) 331 { 332 // void gtk_color_selection_set_current_rgba (GtkColorSelection *colorsel, const GdkRGBA *rgba); 333 gtk_color_selection_set_current_rgba(gtkColorSelection, (rgba is null) ? null : rgba.getRGBAStruct()); 334 } 335 336 /** 337 * Fills rgba in with the original color value. 338 * Params: 339 * rgba = a GdkRGBA to fill in with the original color value. [out] 340 * Since 3.0 341 */ 342 public void getPreviousRgba(RGBA rgba) 343 { 344 // void gtk_color_selection_get_previous_rgba (GtkColorSelection *colorsel, GdkRGBA *rgba); 345 gtk_color_selection_get_previous_rgba(gtkColorSelection, (rgba is null) ? null : rgba.getRGBAStruct()); 346 } 347 348 /** 349 * Sets the 'previous' color to be rgba. 350 * This function should be called with some hesitations, 351 * as it might seem confusing to have that color change. 352 * Calling gtk_color_selection_set_current_rgba() will also 353 * set this color the first time it is called. 354 * Params: 355 * rgba = a GdkRGBA to set the previous color with 356 * Since 3.0 357 */ 358 public void setPreviousRgba(RGBA rgba) 359 { 360 // void gtk_color_selection_set_previous_rgba (GtkColorSelection *colorsel, const GdkRGBA *rgba); 361 gtk_color_selection_set_previous_rgba(gtkColorSelection, (rgba is null) ? null : rgba.getRGBAStruct()); 362 } 363 364 /** 365 * Gets the current state of the colorsel. 366 * Returns: TRUE if the user is currently dragging a color around, and FALSE if the selection has stopped 367 */ 368 public int isAdjusting() 369 { 370 // gboolean gtk_color_selection_is_adjusting (GtkColorSelection *colorsel); 371 return gtk_color_selection_is_adjusting(gtkColorSelection); 372 } 373 374 /** 375 * Parses a color palette string; the string is a colon-separated 376 * list of color names readable by gdk_color_parse(). 377 * Params: 378 * str = a string encoding a color palette 379 * colors = return location for 380 * allocated array of GdkColor. [out][array length=n_colors] 381 * Returns: TRUE if a palette was successfully parsed 382 */ 383 public static int paletteFromString(string str, out GdkColor[] colors) 384 { 385 // gboolean gtk_color_selection_palette_from_string (const gchar *str, GdkColor **colors, gint *n_colors); 386 GdkColor* outcolors = null; 387 int nColors; 388 389 auto p = gtk_color_selection_palette_from_string(Str.toStringz(str), &outcolors, &nColors); 390 391 colors = outcolors[0 .. nColors]; 392 return p; 393 } 394 395 /** 396 * Encodes a palette as a string, useful for persistent storage. 397 * Params: 398 * colors = an array of colors. [array length=n_colors] 399 * Returns: allocated string encoding the palette 400 */ 401 public static string paletteToString(GdkColor[] colors) 402 { 403 // gchar * gtk_color_selection_palette_to_string (const GdkColor *colors, gint n_colors); 404 return Str.toString(gtk_color_selection_palette_to_string(colors.ptr, cast(int) colors.length)); 405 } 406 407 /** 408 * Installs a global function to be called whenever the user 409 * tries to modify the palette in a color selection. 410 * This function should save the new palette contents, and update 411 * the "gtk-color-palette" GtkSettings property so all 412 * GtkColorSelection widgets will be modified. 413 * Since 2.2 414 * Params: 415 * func = a function to call when the custom palette needs saving 416 * Returns: the previous change palette hook (that was replaced) 417 */ 418 public static GtkColorSelectionChangePaletteWithScreenFunc setChangePaletteWithScreenHook(GtkColorSelectionChangePaletteWithScreenFunc func) 419 { 420 // GtkColorSelectionChangePaletteWithScreenFunc gtk_color_selection_set_change_palette_with_screen_hook (GtkColorSelectionChangePaletteWithScreenFunc func); 421 return gtk_color_selection_set_change_palette_with_screen_hook(func); 422 } 423 }