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 = gtk3-GtkSymbolicColor.html 27 * outPack = gtk 28 * outFile = SymbolicColor 29 * strct = GtkSymbolicColor 30 * realStrct= 31 * ctorStrct= 32 * clss = SymbolicColor 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_symbolic_color_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * - gtk_symbolic_color_new_shade 45 * - gtk_symbolic_color_new_alpha 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * - gdk.RGBA 50 * - gtk.StyleProperties 51 * - gtkc.Loader 52 * - gtkc.paths 53 * structWrap: 54 * - GdkRGBA* -> RGBA 55 * - GtkStyleProperties* -> StyleProperties 56 * - GtkSymbolicColor* -> SymbolicColor 57 * module aliases: 58 * local aliases: 59 * overrides: 60 * - toString 61 */ 62 63 module gtk.SymbolicColor; 64 65 public import gtkc.gtktypes; 66 67 private import gtkc.gtk; 68 private import glib.ConstructionException; 69 private import gobject.ObjectG; 70 71 private import glib.Str; 72 private import gdk.RGBA; 73 private import gtk.StyleProperties; 74 private import gtkc.Loader; 75 private import gtkc.paths; 76 77 78 79 /** 80 * GtkSymbolicColor is a boxed type that represents a symbolic color. 81 * It is the result of parsing a 82 * color expression. 83 * To obtain the color represented by a GtkSymbolicColor, it has to 84 * be resolved with gtk_symbolic_color_resolve(), which replaces all 85 * symbolic color references by the colors they refer to (in a given 86 * context) and evaluates mix, shade and other expressions, resulting 87 * in a GdkRGBA value. 88 * 89 * It is not normally necessary to deal directly with GtkSymbolicColors, 90 * since they are mostly used behind the scenes by GtkStyleContext and 91 * GtkCssProvider. 92 * 93 * GtkSymbolicColor is deprecated. Symbolic colors are considered an 94 * implementation detail of GTK+. 95 */ 96 public class SymbolicColor 97 { 98 99 /** the main Gtk struct */ 100 protected GtkSymbolicColor* gtkSymbolicColor; 101 102 103 /** Get the main Gtk struct */ 104 public GtkSymbolicColor* getSymbolicColorStruct() 105 { 106 return gtkSymbolicColor; 107 } 108 109 110 /** the main Gtk struct as a void* */ 111 protected void* getStruct() 112 { 113 return cast(void*)gtkSymbolicColor; 114 } 115 116 /** 117 * Sets our main struct and passes it to the parent class 118 */ 119 public this (GtkSymbolicColor* gtkSymbolicColor) 120 { 121 this.gtkSymbolicColor = gtkSymbolicColor; 122 } 123 124 ~this () 125 { 126 if ( Linker.isLoaded(LIBRARY.GTK) && gtkSymbolicColor !is null ) 127 { 128 gtk_symbolic_color_unref(gtkSymbolicColor); 129 } 130 } 131 132 /** 133 * Creates a symbolic color defined as a shade of another color. 134 * A factor > 1.0 would resolve to a brighter or more transparent color, 135 * while < 1.0 would resolve to a darker or more opaque color. 136 * 137 * Params: 138 * color = another GtkSymbolicColor. 139 * factor = shading factor to apply to color. 140 * useAlpha = if true change the relative alpha value of the color, 141 * otherwise change the shade. 142 * 143 * Throws: ConstructionException GTK+ fails to create the object. 144 */ 145 public this (SymbolicColor color, double factor, bool useAlpha = true) 146 { 147 GtkSymbolicColor* p; 148 149 if ( useAlpha ) 150 { 151 p = gtk_symbolic_color_new_alpha((color is null) ? null : color.getSymbolicColorStruct(), factor); 152 } 153 else 154 { 155 p = gtk_symbolic_color_new_shade((color is null) ? null : color.getSymbolicColorStruct(), factor); 156 } 157 158 if(p is null) 159 { 160 throw new ConstructionException("null returned by gtk_symbolic_color_new_shade((color is null) ? null : color.getSymbolicColorStruct(), factor)"); 161 } 162 163 this(cast(GtkSymbolicColor*) p); 164 } 165 166 /** 167 */ 168 169 /** 170 * Warning 171 * gtk_symbolic_color_new_literal has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated. 172 * Creates a symbolic color pointing to a literal color. 173 * Params: 174 * color = a GdkRGBA 175 * Throws: ConstructionException GTK+ fails to create the object. 176 */ 177 public this (RGBA color) 178 { 179 // GtkSymbolicColor * gtk_symbolic_color_new_literal (const GdkRGBA *color); 180 auto p = gtk_symbolic_color_new_literal((color is null) ? null : color.getRGBAStruct()); 181 if(p is null) 182 { 183 throw new ConstructionException("null returned by gtk_symbolic_color_new_literal((color is null) ? null : color.getRGBAStruct())"); 184 } 185 this(cast(GtkSymbolicColor*) p); 186 } 187 188 /** 189 * Warning 190 * gtk_symbolic_color_new_name has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated. 191 * Creates a symbolic color pointing to an unresolved named 192 * color. See gtk_style_context_lookup_color() and 193 * gtk_style_properties_lookup_color(). 194 * Params: 195 * name = color name 196 * Throws: ConstructionException GTK+ fails to create the object. 197 */ 198 public this (string name) 199 { 200 // GtkSymbolicColor * gtk_symbolic_color_new_name (const gchar *name); 201 auto p = gtk_symbolic_color_new_name(Str.toStringz(name)); 202 if(p is null) 203 { 204 throw new ConstructionException("null returned by gtk_symbolic_color_new_name(Str.toStringz(name))"); 205 } 206 this(cast(GtkSymbolicColor*) p); 207 } 208 209 /** 210 * Warning 211 * gtk_symbolic_color_new_mix has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated. 212 * Creates a symbolic color defined as a mix of another 213 * two colors. a mix factor of 0 would resolve to color1, 214 * while a factor of 1 would resolve to color2. 215 * Params: 216 * color1 = color to mix 217 * color2 = another color to mix 218 * factor = mix factor 219 * Throws: ConstructionException GTK+ fails to create the object. 220 */ 221 public this (SymbolicColor color1, SymbolicColor color2, double factor) 222 { 223 // GtkSymbolicColor * gtk_symbolic_color_new_mix (GtkSymbolicColor *color1, GtkSymbolicColor *color2, gdouble factor); 224 auto p = gtk_symbolic_color_new_mix((color1 is null) ? null : color1.getSymbolicColorStruct(), (color2 is null) ? null : color2.getSymbolicColorStruct(), factor); 225 if(p is null) 226 { 227 throw new ConstructionException("null returned by gtk_symbolic_color_new_mix((color1 is null) ? null : color1.getSymbolicColorStruct(), (color2 is null) ? null : color2.getSymbolicColorStruct(), factor)"); 228 } 229 this(cast(GtkSymbolicColor*) p); 230 } 231 232 /** 233 * Warning 234 * gtk_symbolic_color_new_win32 has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated. 235 * Creates a symbolic color based on the current win32 236 * theme. 237 * Note that while this call is available on all platforms 238 * the actual value returned is not reliable on non-win32 239 * platforms. 240 * Params: 241 * themeClass = The theme class to pull color from 242 * id = The color id 243 * Throws: ConstructionException GTK+ fails to create the object. 244 */ 245 public this (string themeClass, int id) 246 { 247 // GtkSymbolicColor * gtk_symbolic_color_new_win32 (const gchar *theme_class, gint id); 248 auto p = gtk_symbolic_color_new_win32(Str.toStringz(themeClass), id); 249 if(p is null) 250 { 251 throw new ConstructionException("null returned by gtk_symbolic_color_new_win32(Str.toStringz(themeClass), id)"); 252 } 253 this(cast(GtkSymbolicColor*) p); 254 } 255 256 /** 257 * Warning 258 * gtk_symbolic_color_ref has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated. 259 * Increases the reference count of color 260 * Returns: the same color Since 3.0 261 */ 262 public SymbolicColor doref() 263 { 264 // GtkSymbolicColor * gtk_symbolic_color_ref (GtkSymbolicColor *color); 265 auto p = gtk_symbolic_color_ref(gtkSymbolicColor); 266 267 if(p is null) 268 { 269 return null; 270 } 271 272 return ObjectG.getDObject!(SymbolicColor)(cast(GtkSymbolicColor*) p); 273 } 274 275 /** 276 * Warning 277 * gtk_symbolic_color_unref has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated. 278 * Decreases the reference count of color, freeing its memory if the 279 * reference count reaches 0. 280 */ 281 public void unref() 282 { 283 // void gtk_symbolic_color_unref (GtkSymbolicColor *color); 284 gtk_symbolic_color_unref(gtkSymbolicColor); 285 } 286 287 /** 288 * Warning 289 * gtk_symbolic_color_resolve has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated. 290 * If color is resolvable, resolved_color will be filled in 291 * with the resolved color, and TRUE will be returned. Generally, 292 * if color can't be resolved, it is due to it being defined on 293 * top of a named color that doesn't exist in props. 294 * When props is NULL, resolving of named colors will fail, so if 295 * your color is or references such a color, this function will 296 * return FALSE. 297 * Params: 298 * props = GtkStyleProperties to use when resolving 299 * named colors, or NULL. [allow-none] 300 * resolvedColor = return location for the resolved color. [out] 301 * Returns: TRUE if the color has been resolved Since 3.0 302 */ 303 public int resolve(StyleProperties props, RGBA resolvedColor) 304 { 305 // gboolean gtk_symbolic_color_resolve (GtkSymbolicColor *color, GtkStyleProperties *props, GdkRGBA *resolved_color); 306 return gtk_symbolic_color_resolve(gtkSymbolicColor, (props is null) ? null : props.getStylePropertiesStruct(), (resolvedColor is null) ? null : resolvedColor.getRGBAStruct()); 307 } 308 309 /** 310 * Warning 311 * gtk_symbolic_color_to_string has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated. 312 * Converts the given color to a string representation. This is useful 313 * both for debugging and for serialization of strings. The format of 314 * the string may change between different versions of GTK, but it is 315 * guaranteed that the GTK css parser is able to read the string and 316 * create the same symbolic color from it. 317 * Returns: a new string representing color 318 */ 319 public override string toString() 320 { 321 // char * gtk_symbolic_color_to_string (GtkSymbolicColor *color); 322 return Str.toString(gtk_symbolic_color_to_string(gtkSymbolicColor)); 323 } 324 }