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