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.ContainerClass;
26 
27 private import glib.Str;
28 private import gobject.ObjectG;
29 private import gobject.ParamSpec;
30 private import gtkc.gtk;
31 public  import gtkc.gtktypes;
32 
33 
34 /**
35  * Base class for containers.
36  */
37 public class ContainerClass
38 {
39 	/** the main Gtk struct */
40 	protected GtkContainerClass* gtkContainerClass;
41 	protected bool ownedRef;
42 
43 	/** Get the main Gtk struct */
44 	public GtkContainerClass* getContainerClassStruct()
45 	{
46 		return gtkContainerClass;
47 	}
48 
49 	/** the main Gtk struct as a void* */
50 	protected void* getStruct()
51 	{
52 		return cast(void*)gtkContainerClass;
53 	}
54 
55 	/**
56 	 * Sets our main struct and passes it to the parent class.
57 	 */
58 	public this (GtkContainerClass* gtkContainerClass, bool ownedRef = false)
59 	{
60 		this.gtkContainerClass = gtkContainerClass;
61 		this.ownedRef = ownedRef;
62 	}
63 
64 
65 	/**
66 	 * Finds a child property of a container class by name.
67 	 *
68 	 * Params:
69 	 *     propertyName = the name of the child property to find
70 	 *
71 	 * Return: the #GParamSpec of the child
72 	 *     property or %NULL if @class has no child property with that
73 	 *     name.
74 	 */
75 	public ParamSpec findChildProperty(string propertyName)
76 	{
77 		auto p = gtk_container_class_find_child_property(cast(GObjectClass*)gtkContainerClass, Str.toStringz(propertyName));
78 		
79 		if(p is null)
80 		{
81 			return null;
82 		}
83 		
84 		return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p);
85 	}
86 
87 	/**
88 	 * Modifies a subclass of #GtkContainerClass to automatically add and
89 	 * remove the border-width setting on GtkContainer.  This allows the
90 	 * subclass to ignore the border width in its size request and
91 	 * allocate methods. The intent is for a subclass to invoke this
92 	 * in its class_init function.
93 	 *
94 	 * gtk_container_class_handle_border_width() is necessary because it
95 	 * would break API too badly to make this behavior the default. So
96 	 * subclasses must “opt in” to the parent class handling border_width
97 	 * for them.
98 	 */
99 	public void handleBorderWidth()
100 	{
101 		gtk_container_class_handle_border_width(gtkContainerClass);
102 	}
103 
104 	/**
105 	 * Installs child properties on a container class.
106 	 *
107 	 * Params:
108 	 *     nPspecs = the length of the #GParamSpec array
109 	 *     pspecs = the #GParamSpec array defining the new
110 	 *         child properties
111 	 *
112 	 * Since: 3.18
113 	 */
114 	public void installChildProperties(ParamSpec[] pspecs)
115 	{
116 		GParamSpec*[] pspecsArray = new GParamSpec*[pspecs.length];
117 		for ( int i = 0; i < pspecs.length; i++ )
118 		{
119 			pspecsArray[i] = pspecs[i].getParamSpecStruct();
120 		}
121 		
122 		gtk_container_class_install_child_properties(gtkContainerClass, cast(uint)pspecs.length, pspecsArray.ptr);
123 	}
124 
125 	/**
126 	 * Installs a child property on a container class.
127 	 *
128 	 * Params:
129 	 *     propertyId = the id for the property
130 	 *     pspec = the #GParamSpec for the property
131 	 */
132 	public void installChildProperty(uint propertyId, ParamSpec pspec)
133 	{
134 		gtk_container_class_install_child_property(gtkContainerClass, propertyId, (pspec is null) ? null : pspec.getParamSpecStruct());
135 	}
136 
137 	/**
138 	 * Returns all child properties of a container class.
139 	 *
140 	 * Return: a newly allocated %NULL-terminated array of #GParamSpec*.
141 	 *     The array must be freed with g_free().
142 	 */
143 	public ParamSpec[] listChildProperties()
144 	{
145 		uint nProperties;
146 		
147 		auto p = gtk_container_class_list_child_properties(cast(GObjectClass*)gtkContainerClass, &nProperties);
148 		
149 		if(p is null)
150 		{
151 			return null;
152 		}
153 		
154 		ParamSpec[] arr = new ParamSpec[nProperties];
155 		for(int i = 0; i < nProperties; i++)
156 		{
157 			arr[i] = ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p[i]);
158 		}
159 		
160 		return arr;
161 	}
162 }