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