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