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.StyleProperties; 26 27 private import glib.ConstructionException; 28 private import glib.MemorySlice; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gobject.ParamSpec; 32 private import gobject.Value; 33 private import gtk.StyleProviderIF; 34 private import gtk.StyleProviderT; 35 private import gtk.SymbolicColor; 36 private import gtk.c.functions; 37 public import gtk.c.types; 38 public import gtkc.gtktypes; 39 40 41 /** 42 * GtkStyleProperties provides the storage for style information 43 * that is used by #GtkStyleContext and other #GtkStyleProvider 44 * implementations. 45 * 46 * Before style properties can be stored in GtkStyleProperties, they 47 * must be registered with gtk_style_properties_register_property(). 48 * 49 * Unless you are writing a #GtkStyleProvider implementation, you 50 * are unlikely to use this API directly, as gtk_style_context_get() 51 * and its variants are the preferred way to access styling information 52 * from widget implementations and theming engine implementations 53 * should use the APIs provided by #GtkThemingEngine instead. 54 * 55 * #GtkStyleProperties has been deprecated in GTK 3.16. The CSS 56 * machinery does not use it anymore and all users of this object 57 * have been deprecated. 58 */ 59 public class StyleProperties : ObjectG, StyleProviderIF 60 { 61 /** the main Gtk struct */ 62 protected GtkStyleProperties* gtkStyleProperties; 63 64 /** Get the main Gtk struct */ 65 public GtkStyleProperties* getStylePropertiesStruct(bool transferOwnership = false) 66 { 67 if (transferOwnership) 68 ownedRef = false; 69 return gtkStyleProperties; 70 } 71 72 /** the main Gtk struct as a void* */ 73 protected override void* getStruct() 74 { 75 return cast(void*)gtkStyleProperties; 76 } 77 78 protected override void setStruct(GObject* obj) 79 { 80 gtkStyleProperties = cast(GtkStyleProperties*)obj; 81 super.setStruct(obj); 82 } 83 84 /** 85 * Sets our main struct and passes it to the parent class. 86 */ 87 public this (GtkStyleProperties* gtkStyleProperties, bool ownedRef = false) 88 { 89 this.gtkStyleProperties = gtkStyleProperties; 90 super(cast(GObject*)gtkStyleProperties, ownedRef); 91 } 92 93 // add the StyleProvider capabilities 94 mixin StyleProviderT!(GtkStyleProperties); 95 96 97 /** */ 98 public static GType getType() 99 { 100 return gtk_style_properties_get_type(); 101 } 102 103 /** 104 * Returns a newly created #GtkStyleProperties 105 * 106 * Deprecated: #GtkStyleProperties are deprecated. 107 * 108 * Returns: a new #GtkStyleProperties 109 * 110 * Throws: ConstructionException GTK+ fails to create the object. 111 */ 112 public this() 113 { 114 auto p = gtk_style_properties_new(); 115 116 if(p is null) 117 { 118 throw new ConstructionException("null returned by new"); 119 } 120 121 this(cast(GtkStyleProperties*) p, true); 122 } 123 124 /** 125 * Returns %TRUE if a property has been registered, if @pspec or 126 * @parse_func are not %NULL, the #GParamSpec and parsing function 127 * will be respectively returned. 128 * 129 * Deprecated: This code could only look up custom properties and 130 * those are deprecated. 131 * 132 * Params: 133 * propertyName = property name to look up 134 * parseFunc = return location for the parse function 135 * pspec = return location for the #GParamSpec 136 * 137 * Returns: %TRUE if the property is registered, %FALSE otherwise 138 * 139 * Since: 3.0 140 */ 141 public static bool lookupProperty(string propertyName, out GtkStylePropertyParser parseFunc, out ParamSpec pspec) 142 { 143 GParamSpec* outpspec = null; 144 145 auto p = gtk_style_properties_lookup_property(Str.toStringz(propertyName), &parseFunc, &outpspec) != 0; 146 147 pspec = ObjectG.getDObject!(ParamSpec)(outpspec); 148 149 return p; 150 } 151 152 /** 153 * Registers a property so it can be used in the CSS file format. 154 * This function is the low-level equivalent of 155 * gtk_theming_engine_register_property(), if you are implementing 156 * a theming engine, you want to use that function instead. 157 * 158 * Deprecated: Code should use the default properties provided by CSS. 159 * 160 * Params: 161 * parseFunc = parsing function to use, or %NULL 162 * pspec = the #GParamSpec for the new property 163 * 164 * Since: 3.0 165 */ 166 public static void registerProperty(GtkStylePropertyParser parseFunc, ParamSpec pspec) 167 { 168 gtk_style_properties_register_property(parseFunc, (pspec is null) ? null : pspec.getParamSpecStruct()); 169 } 170 171 /** 172 * Clears all style information from @props. 173 * 174 * Deprecated: #GtkStyleProperties are deprecated. 175 */ 176 public void clear() 177 { 178 gtk_style_properties_clear(gtkStyleProperties); 179 } 180 181 /** 182 * Gets a style property from @props for the given state. When done with @value, 183 * g_value_unset() needs to be called to free any allocated memory. 184 * 185 * Deprecated: #GtkStyleProperties are deprecated. 186 * 187 * Params: 188 * property = style property name 189 * state = state to retrieve the property value for 190 * value = return location for the style property value. 191 * 192 * Returns: %TRUE if the property exists in @props, %FALSE otherwise 193 * 194 * Since: 3.0 195 */ 196 public bool getStyleProperty(string property, GtkStateFlags state, out Value value) 197 { 198 GValue* outvalue = sliceNew!GValue(); 199 200 auto p = gtk_style_properties_get_property(gtkStyleProperties, Str.toStringz(property), state, outvalue) != 0; 201 202 value = ObjectG.getDObject!(Value)(outvalue, true); 203 204 return p; 205 } 206 207 /** 208 * Retrieves several style property values from @props for a given state. 209 * 210 * Deprecated: #GtkStyleProperties are deprecated. 211 * 212 * Params: 213 * state = state to retrieve the property values for 214 * args = va_list of property name/return location pairs, followed by %NULL 215 * 216 * Since: 3.0 217 */ 218 public void getStyleValist(GtkStateFlags state, void* args) 219 { 220 gtk_style_properties_get_valist(gtkStyleProperties, state, args); 221 } 222 223 /** 224 * Returns the symbolic color that is mapped 225 * to @name. 226 * 227 * Deprecated: #GtkSymbolicColor is deprecated. 228 * 229 * Params: 230 * name = color name to lookup 231 * 232 * Returns: The mapped color 233 * 234 * Since: 3.0 235 */ 236 public SymbolicColor lookupColor(string name) 237 { 238 auto p = gtk_style_properties_lookup_color(gtkStyleProperties, Str.toStringz(name)); 239 240 if(p is null) 241 { 242 return null; 243 } 244 245 return ObjectG.getDObject!(SymbolicColor)(cast(GtkSymbolicColor*) p); 246 } 247 248 /** 249 * Maps @color so it can be referenced by @name. See 250 * gtk_style_properties_lookup_color() 251 * 252 * Deprecated: #GtkSymbolicColor is deprecated. 253 * 254 * Params: 255 * name = color name 256 * color = #GtkSymbolicColor to map @name to 257 * 258 * Since: 3.0 259 */ 260 public void mapColor(string name, SymbolicColor color) 261 { 262 gtk_style_properties_map_color(gtkStyleProperties, Str.toStringz(name), (color is null) ? null : color.getSymbolicColorStruct()); 263 } 264 265 /** 266 * Merges into @props all the style information contained 267 * in @props_to_merge. If @replace is %TRUE, the values 268 * will be overwritten, if it is %FALSE, the older values 269 * will prevail. 270 * 271 * Deprecated: #GtkStyleProperties are deprecated. 272 * 273 * Params: 274 * propsToMerge = a second #GtkStyleProperties 275 * replace = whether to replace values or not 276 * 277 * Since: 3.0 278 */ 279 public void merge(StyleProperties propsToMerge, bool replace) 280 { 281 gtk_style_properties_merge(gtkStyleProperties, (propsToMerge is null) ? null : propsToMerge.getStylePropertiesStruct(), replace); 282 } 283 284 /** 285 * Sets a styling property in @props. 286 * 287 * Deprecated: #GtkStyleProperties are deprecated. 288 * 289 * Params: 290 * property = styling property to set 291 * state = state to set the value for 292 * value = new value for the property 293 * 294 * Since: 3.0 295 */ 296 public void setStyleProperty(string property, GtkStateFlags state, Value value) 297 { 298 gtk_style_properties_set_property(gtkStyleProperties, Str.toStringz(property), state, (value is null) ? null : value.getValueStruct()); 299 } 300 301 /** 302 * Sets several style properties on @props. 303 * 304 * Deprecated: #GtkStyleProperties are deprecated. 305 * 306 * Params: 307 * state = state to set the values for 308 * args = va_list of property name/value pairs, followed by %NULL 309 * 310 * Since: 3.0 311 */ 312 public void setStyleValist(GtkStateFlags state, void* args) 313 { 314 gtk_style_properties_set_valist(gtkStyleProperties, state, args); 315 } 316 317 /** 318 * Unsets a style property in @props. 319 * 320 * Deprecated: #GtkStyleProperties are deprecated. 321 * 322 * Params: 323 * property = property to unset 324 * state = state to unset 325 * 326 * Since: 3.0 327 */ 328 public void unsetProperty(string property, GtkStateFlags state) 329 { 330 gtk_style_properties_unset_property(gtkStyleProperties, Str.toStringz(property), state); 331 } 332 }