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.WidgetClass;
26 
27 private import glib.Bytes;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gobject.ParamSpec;
31 private import gtkc.gtk;
32 public  import gtkc.gtktypes;
33 
34 
35 /** */
36 public class WidgetClass
37 {
38 	/** the main Gtk struct */
39 	protected GtkWidgetClass* gtkWidgetClass;
40 	protected bool ownedRef;
41 
42 	/** Get the main Gtk struct */
43 	public GtkWidgetClass* getWidgetClassStruct()
44 	{
45 		return gtkWidgetClass;
46 	}
47 
48 	/** the main Gtk struct as a void* */
49 	protected void* getStruct()
50 	{
51 		return cast(void*)gtkWidgetClass;
52 	}
53 
54 	/**
55 	 * Sets our main struct and passes it to the parent class.
56 	 */
57 	public this (GtkWidgetClass* gtkWidgetClass, bool ownedRef = false)
58 	{
59 		this.gtkWidgetClass = gtkWidgetClass;
60 		this.ownedRef = ownedRef;
61 	}
62 
63 
64 	/**
65 	 * Declares a @callback_symbol to handle @callback_name from the template XML
66 	 * defined for @widget_type. See gtk_builder_add_callback_symbol().
67 	 *
68 	 * Note that this must be called from a composite widget classes class
69 	 * initializer after calling gtk_widget_class_set_template().
70 	 *
71 	 * Params:
72 	 *     callbackName = The name of the callback as expected in the template XML
73 	 *     callbackSymbol = The callback symbol
74 	 *
75 	 * Since: 3.10
76 	 */
77 	public void bindTemplateCallbackFull(string callbackName, GCallback callbackSymbol)
78 	{
79 		gtk_widget_class_bind_template_callback_full(gtkWidgetClass, Str.toStringz(callbackName), callbackSymbol);
80 	}
81 
82 	/**
83 	 * Automatically assign an object declared in the class template XML to be set to a location
84 	 * on a freshly built instance’s private data, or alternatively accessible via gtk_widget_get_template_child().
85 	 *
86 	 * The struct can point either into the public instance, then you should use G_STRUCT_OFFSET(WidgetType, member)
87 	 * for @struct_offset,  or in the private struct, then you should use G_PRIVATE_OFFSET(WidgetType, member).
88 	 *
89 	 * An explicit strong reference will be held automatically for the duration of your
90 	 * instance’s life cycle, it will be released automatically when #GObjectClass.dispose() runs
91 	 * on your instance and if a @struct_offset that is != 0 is specified, then the automatic location
92 	 * in your instance public or private data will be set to %NULL. You can however access an automated child
93 	 * pointer the first time your classes #GObjectClass.dispose() runs, or alternatively in
94 	 * #GtkWidgetClass.destroy().
95 	 *
96 	 * If @internal_child is specified, #GtkBuildableIface.get_internal_child() will be automatically
97 	 * implemented by the #GtkWidget class so there is no need to implement it manually.
98 	 *
99 	 * The wrapper macros gtk_widget_class_bind_template_child(), gtk_widget_class_bind_template_child_internal(),
100 	 * gtk_widget_class_bind_template_child_private() and gtk_widget_class_bind_template_child_internal_private()
101 	 * might be more convenient to use.
102 	 *
103 	 * Note that this must be called from a composite widget classes class
104 	 * initializer after calling gtk_widget_class_set_template().
105 	 *
106 	 * Params:
107 	 *     name = The “id” of the child defined in the template XML
108 	 *     internalChild = Whether the child should be accessible as an “internal-child”
109 	 *         when this class is used in GtkBuilder XML
110 	 *     structOffset = The structure offset into the composite widget’s instance public or private structure
111 	 *         where the automated child pointer should be set, or 0 to not assign the pointer.
112 	 *
113 	 * Since: 3.10
114 	 */
115 	public void bindTemplateChildFull(string name, bool internalChild, ptrdiff_t structOffset)
116 	{
117 		gtk_widget_class_bind_template_child_full(gtkWidgetClass, Str.toStringz(name), internalChild, structOffset);
118 	}
119 
120 	/**
121 	 * Finds a style property of a widget class by name.
122 	 *
123 	 * Params:
124 	 *     propertyName = the name of the style property to find
125 	 *
126 	 * Return: the #GParamSpec of the style property or
127 	 *     %NULL if @class has no style property with that name.
128 	 *
129 	 * Since: 2.2
130 	 */
131 	public ParamSpec findStyleProperty(string propertyName)
132 	{
133 		auto p = gtk_widget_class_find_style_property(gtkWidgetClass, Str.toStringz(propertyName));
134 		
135 		if(p is null)
136 		{
137 			return null;
138 		}
139 		
140 		return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p);
141 	}
142 
143 	/**
144 	 * Gets the name used by this class for matching in CSS code. See
145 	 * gtk_widget_class_set_css_name() for details.
146 	 *
147 	 * Return: the CSS name of the given class
148 	 *
149 	 * Since: 3.20
150 	 */
151 	public string getCssName()
152 	{
153 		return Str.toString(gtk_widget_class_get_css_name(gtkWidgetClass));
154 	}
155 
156 	/**
157 	 * Installs a style property on a widget class. The parser for the
158 	 * style property is determined by the value type of @pspec.
159 	 *
160 	 * Params:
161 	 *     pspec = the #GParamSpec for the property
162 	 */
163 	public void installStyleProperty(ParamSpec pspec)
164 	{
165 		gtk_widget_class_install_style_property(gtkWidgetClass, (pspec is null) ? null : pspec.getParamSpecStruct());
166 	}
167 
168 	/**
169 	 * Installs a style property on a widget class.
170 	 *
171 	 * Params:
172 	 *     pspec = the #GParamSpec for the style property
173 	 *     parser = the parser for the style property
174 	 */
175 	public void installStylePropertyParser(ParamSpec pspec, GtkRcPropertyParser parser)
176 	{
177 		gtk_widget_class_install_style_property_parser(gtkWidgetClass, (pspec is null) ? null : pspec.getParamSpecStruct(), parser);
178 	}
179 
180 	/**
181 	 * Returns all style properties of a widget class.
182 	 *
183 	 * Return: a
184 	 *     newly allocated array of #GParamSpec*. The array must be
185 	 *     freed with g_free().
186 	 *
187 	 * Since: 2.2
188 	 */
189 	public ParamSpec[] listStyleProperties()
190 	{
191 		uint nProperties;
192 		
193 		auto p = gtk_widget_class_list_style_properties(gtkWidgetClass, &nProperties);
194 		
195 		if(p is null)
196 		{
197 			return null;
198 		}
199 		
200 		ParamSpec[] arr = new ParamSpec[nProperties];
201 		for(int i = 0; i < nProperties; i++)
202 		{
203 			arr[i] = ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p[i]);
204 		}
205 		
206 		return arr;
207 	}
208 
209 	/**
210 	 * Sets the default #AtkRole to be set on accessibles created for
211 	 * widgets of @widget_class. Accessibles may decide to not honor this
212 	 * setting if their role reporting is more refined. Calls to
213 	 * gtk_widget_class_set_accessible_type() will reset this value.
214 	 *
215 	 * In cases where you want more fine-grained control over the role of
216 	 * accessibles created for @widget_class, you should provide your own
217 	 * accessible type and use gtk_widget_class_set_accessible_type()
218 	 * instead.
219 	 *
220 	 * If @role is #ATK_ROLE_INVALID, the default role will not be changed
221 	 * and the accessible’s default role will be used instead.
222 	 *
223 	 * This function should only be called from class init functions of widgets.
224 	 *
225 	 * Params:
226 	 *     role = The role to use for accessibles created for @widget_class
227 	 *
228 	 * Since: 3.2
229 	 */
230 	public void setAccessibleRole(AtkRole role)
231 	{
232 		gtk_widget_class_set_accessible_role(gtkWidgetClass, role);
233 	}
234 
235 	/**
236 	 * Sets the type to be used for creating accessibles for widgets of
237 	 * @widget_class. The given @type must be a subtype of the type used for
238 	 * accessibles of the parent class.
239 	 *
240 	 * This function should only be called from class init functions of widgets.
241 	 *
242 	 * Params:
243 	 *     type = The object type that implements the accessible for @widget_class
244 	 *
245 	 * Since: 3.2
246 	 */
247 	public void setAccessibleType(GType type)
248 	{
249 		gtk_widget_class_set_accessible_type(gtkWidgetClass, type);
250 	}
251 
252 	/**
253 	 * For use in language bindings, this will override the default #GtkBuilderConnectFunc to be
254 	 * used when parsing GtkBuilder XML from this class’s template data.
255 	 *
256 	 * Note that this must be called from a composite widget classes class
257 	 * initializer after calling gtk_widget_class_set_template().
258 	 *
259 	 * Params:
260 	 *     connectFunc = The #GtkBuilderConnectFunc to use when connecting signals in the class template
261 	 *     connectData = The data to pass to @connect_func
262 	 *     connectDataDestroy = The #GDestroyNotify to free @connect_data, this will only be used at
263 	 *         class finalization time, when no classes of type @widget_type are in use anymore.
264 	 *
265 	 * Since: 3.10
266 	 */
267 	public void setConnectFunc(GtkBuilderConnectFunc connectFunc, void* connectData, GDestroyNotify connectDataDestroy)
268 	{
269 		gtk_widget_class_set_connect_func(gtkWidgetClass, connectFunc, connectData, connectDataDestroy);
270 	}
271 
272 	/**
273 	 * Sets the name to be used for CSS matching of widgets.
274 	 *
275 	 * If this function is not called for a given class, the name
276 	 * of the parent class is used.
277 	 *
278 	 * Params:
279 	 *     name = name to use
280 	 *
281 	 * Since: 3.20
282 	 */
283 	public void setCssName(string name)
284 	{
285 		gtk_widget_class_set_css_name(gtkWidgetClass, Str.toStringz(name));
286 	}
287 
288 	/**
289 	 * This should be called at class initialization time to specify
290 	 * the GtkBuilder XML to be used to extend a widget.
291 	 *
292 	 * For convenience, gtk_widget_class_set_template_from_resource() is also provided.
293 	 *
294 	 * Note that any class that installs templates must call gtk_widget_init_template()
295 	 * in the widget’s instance initializer.
296 	 *
297 	 * Params:
298 	 *     templateBytes = A #GBytes holding the #GtkBuilder XML
299 	 *
300 	 * Since: 3.10
301 	 */
302 	public void setTemplate(Bytes templateBytes)
303 	{
304 		gtk_widget_class_set_template(gtkWidgetClass, (templateBytes is null) ? null : templateBytes.getBytesStruct());
305 	}
306 
307 	/**
308 	 * A convenience function to call gtk_widget_class_set_template().
309 	 *
310 	 * Note that any class that installs templates must call gtk_widget_init_template()
311 	 * in the widget’s instance initializer.
312 	 *
313 	 * Params:
314 	 *     resourceName = The name of the resource to load the template from
315 	 *
316 	 * Since: 3.10
317 	 */
318 	public void setTemplateFromResource(string resourceName)
319 	{
320 		gtk_widget_class_set_template_from_resource(gtkWidgetClass, Str.toStringz(resourceName));
321 	}
322 }