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