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