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 = GtkHSV.html 27 * outPack = gtk 28 * outFile = HSV 29 * strct = GtkHSV 30 * realStrct= 31 * ctorStrct= 32 * clss = HSV 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_hsv_ 41 * - gtk_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * structWrap: 48 * module aliases: 49 * local aliases: 50 * overrides: 51 */ 52 53 module gtk.HSV; 54 55 public import gtkc.gtktypes; 56 57 private import gtkc.gtk; 58 private import glib.ConstructionException; 59 private import gobject.ObjectG; 60 61 private import gobject.Signals; 62 public import gtkc.gdktypes; 63 64 65 private import gtk.Widget; 66 67 /** 68 * GtkHSV is the 'color wheel' part of a complete color selector widget. 69 * It allows to select a color by determining its HSV components in an 70 * intuitive way. Moving the selection around the outer ring changes the hue, 71 * and moving the selection point inside the inner triangle changes value and 72 * saturation. 73 * 74 * GtkHSV has been deprecated together with GtkColorSelection, where 75 * it was used. 76 */ 77 public class HSV : Widget 78 { 79 80 /** the main Gtk struct */ 81 protected GtkHSV* gtkHSV; 82 83 84 /** Get the main Gtk struct */ 85 public GtkHSV* getHSVStruct() 86 { 87 return gtkHSV; 88 } 89 90 91 /** the main Gtk struct as a void* */ 92 protected override void* getStruct() 93 { 94 return cast(void*)gtkHSV; 95 } 96 97 /** 98 * Sets our main struct and passes it to the parent class 99 */ 100 public this (GtkHSV* gtkHSV) 101 { 102 super(cast(GtkWidget*)gtkHSV); 103 this.gtkHSV = gtkHSV; 104 } 105 106 protected override void setStruct(GObject* obj) 107 { 108 super.setStruct(obj); 109 gtkHSV = cast(GtkHSV*)obj; 110 } 111 112 /** 113 */ 114 int[string] connectedSignals; 115 116 void delegate(HSV)[] onChangedListeners; 117 /** 118 */ 119 void addOnChanged(void delegate(HSV) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 120 { 121 if ( !("changed" in connectedSignals) ) 122 { 123 Signals.connectData( 124 getStruct(), 125 "changed", 126 cast(GCallback)&callBackChanged, 127 cast(void*)this, 128 null, 129 connectFlags); 130 connectedSignals["changed"] = 1; 131 } 132 onChangedListeners ~= dlg; 133 } 134 extern(C) static void callBackChanged(GtkHSV* hsvStruct, HSV _hSV) 135 { 136 foreach ( void delegate(HSV) dlg ; _hSV.onChangedListeners ) 137 { 138 dlg(_hSV); 139 } 140 } 141 142 void delegate(GtkDirectionType, HSV)[] onMoveListeners; 143 /** 144 * See Also 145 * GtkColorSelection, GtkColorSelectionDialog 146 */ 147 void addOnMove(void delegate(GtkDirectionType, HSV) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 148 { 149 if ( !("move" in connectedSignals) ) 150 { 151 Signals.connectData( 152 getStruct(), 153 "move", 154 cast(GCallback)&callBackMove, 155 cast(void*)this, 156 null, 157 connectFlags); 158 connectedSignals["move"] = 1; 159 } 160 onMoveListeners ~= dlg; 161 } 162 extern(C) static void callBackMove(GtkHSV* hsvStruct, GtkDirectionType arg1, HSV _hSV) 163 { 164 foreach ( void delegate(GtkDirectionType, HSV) dlg ; _hSV.onMoveListeners ) 165 { 166 dlg(arg1, _hSV); 167 } 168 } 169 170 171 /** 172 * Creates a new HSV color selector. 173 * Since 2.14 174 * Throws: ConstructionException GTK+ fails to create the object. 175 */ 176 public this () 177 { 178 // GtkWidget * gtk_hsv_new (void); 179 auto p = gtk_hsv_new(); 180 if(p is null) 181 { 182 throw new ConstructionException("null returned by gtk_hsv_new()"); 183 } 184 this(cast(GtkHSV*) p); 185 } 186 187 /** 188 * Sets the current color in an HSV color selector. 189 * Color component values must be in the [0.0, 1.0] range. 190 * Since 2.14 191 * Params: 192 * h = Hue 193 * s = Saturation 194 * v = Value 195 */ 196 public void setColor(double h, double s, double v) 197 { 198 // void gtk_hsv_set_color (GtkHSV *hsv, double h, double s, double v); 199 gtk_hsv_set_color(gtkHSV, h, s, v); 200 } 201 202 /** 203 * Queries the current color in an HSV color selector. 204 * Returned values will be in the [0.0, 1.0] range. 205 * Since 2.14 206 * Params: 207 * h = Return value for the hue. [out] 208 * s = Return value for the saturation. [out] 209 * v = Return value for the value. [out] 210 */ 211 public void getColor(out double h, out double s, out double v) 212 { 213 // void gtk_hsv_get_color (GtkHSV *hsv, gdouble *h, gdouble *s, gdouble *v); 214 gtk_hsv_get_color(gtkHSV, &h, &s, &v); 215 } 216 217 /** 218 * Sets the size and ring width of an HSV color selector. 219 * Since 2.14 220 * Params: 221 * size = Diameter for the hue ring 222 * ringWidth = Width of the hue ring 223 */ 224 public void setMetrics(int size, int ringWidth) 225 { 226 // void gtk_hsv_set_metrics (GtkHSV *hsv, gint size, gint ring_width); 227 gtk_hsv_set_metrics(gtkHSV, size, ringWidth); 228 } 229 230 /** 231 * Queries the size and ring width of an HSV color selector. 232 * Since 2.14 233 * Params: 234 * size = Return value for the diameter of the hue ring. [out] 235 * ringWidth = Return value for the width of the hue ring. [out] 236 */ 237 public void getMetrics(out int size, out int ringWidth) 238 { 239 // void gtk_hsv_get_metrics (GtkHSV *hsv, gint *size, gint *ring_width); 240 gtk_hsv_get_metrics(gtkHSV, &size, &ringWidth); 241 } 242 243 /** 244 * An HSV color selector can be said to be adjusting if multiple rapid 245 * changes are being made to its value, for example, when the user is 246 * adjusting the value with the mouse. This function queries whether 247 * the HSV color selector is being adjusted or not. 248 * Since 2.14 249 * Returns: TRUE if clients can ignore changes to the color value, since they may be transitory, or FALSE if they should consider the color value status to be final. 250 */ 251 public int isAdjusting() 252 { 253 // gboolean gtk_hsv_is_adjusting (GtkHSV *hsv); 254 return gtk_hsv_is_adjusting(gtkHSV); 255 } 256 257 /** 258 * Converts a color from HSV space to RGB. 259 * Input values must be in the [0.0, 1.0] range; 260 * output values will be in the same range. 261 * Since 2.14 262 * Params: 263 * h = Hue 264 * s = Saturation 265 * v = Value 266 * r = Return value for the red component. [out] 267 * g = Return value for the green component. [out] 268 * b = Return value for the blue component. [out] 269 */ 270 public static void toRgb(double h, double s, double v, out double r, out double g, out double b) 271 { 272 // void gtk_hsv_to_rgb (gdouble h, gdouble s, gdouble v, gdouble *r, gdouble *g, gdouble *b); 273 gtk_hsv_to_rgb(h, s, v, &r, &g, &b); 274 } 275 276 /** 277 * Converts a color from RGB space to HSV. 278 * Input values must be in the [0.0, 1.0] range; 279 * output values will be in the same range. 280 * Since 2.14 281 * Signal Details 282 * The "changed" signal 283 * void user_function (GtkHSV *hsv, 284 * gpointer user_data) : Run First 285 * Params: 286 * r = Red 287 * g = Green 288 * b = Blue 289 * h = Return value for the hue component. [out] 290 * s = Return value for the saturation component. [out] 291 * v = Return value for the value component. [out] 292 */ 293 public static void rgbToHsv(double r, double g, double b, out double h, out double s, out double v) 294 { 295 // void gtk_rgb_to_hsv (gdouble r, gdouble g, gdouble b, gdouble *h, gdouble *s, gdouble *v); 296 gtk_rgb_to_hsv(r, g, b, &h, &s, &v); 297 } 298 }