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.CellLayoutT; 26 27 public import glib.ListG; 28 public import glib.Str; 29 public import gobject.ObjectG; 30 public import gtk.CellArea; 31 public import gtk.CellRenderer; 32 public import gtkc.gtk; 33 public import gtkc.gtktypes; 34 35 36 /** 37 * #GtkCellLayout is an interface to be implemented by all objects which 38 * want to provide a #GtkTreeViewColumn like API for packing cells, 39 * setting attributes and data funcs. 40 * 41 * One of the notable features provided by implementations of 42 * GtkCellLayout are attributes. Attributes let you set the properties 43 * in flexible ways. They can just be set to constant values like regular 44 * properties. But they can also be mapped to a column of the underlying 45 * tree model with gtk_cell_layout_set_attributes(), which means that the value 46 * of the attribute can change from cell to cell as they are rendered by 47 * the cell renderer. Finally, it is possible to specify a function with 48 * gtk_cell_layout_set_cell_data_func() that is called to determine the 49 * value of the attribute for each cell that is rendered. 50 * 51 * # GtkCellLayouts as GtkBuildable 52 * 53 * Implementations of GtkCellLayout which also implement the GtkBuildable 54 * interface (#GtkCellView, #GtkIconView, #GtkComboBox, 55 * #GtkEntryCompletion, #GtkTreeViewColumn) accept GtkCellRenderer objects 56 * as <child> elements in UI definitions. They support a custom <attributes> 57 * element for their children, which can contain multiple <attribute> 58 * elements. Each <attribute> element has a name attribute which specifies 59 * a property of the cell renderer; the content of the element is the 60 * attribute value. 61 * 62 * This is an example of a UI definition fragment specifying attributes: 63 * |[ 64 * <object class="GtkCellView"> 65 * <child> 66 * <object class="GtkCellRendererText"/> 67 * <attributes> 68 * <attribute name="text">0</attribute> 69 * </attributes> 70 * </child>" 71 * </object> 72 * ]| 73 * 74 * Furthermore for implementations of GtkCellLayout that use a #GtkCellArea 75 * to lay out cells (all GtkCellLayouts in GTK+ use a GtkCellArea) 76 * [cell properties][cell-properties] can also be defined in the format by 77 * specifying the custom <cell-packing> attribute which can contain multiple 78 * <property> elements defined in the normal way. 79 * 80 * Here is a UI definition fragment specifying cell properties: 81 * 82 * |[ 83 * <object class="GtkTreeViewColumn"> 84 * <child> 85 * <object class="GtkCellRendererText"/> 86 * <cell-packing> 87 * <property name="align">True</property> 88 * <property name="expand">False</property> 89 * </cell-packing> 90 * </child>" 91 * </object> 92 * ]| 93 * 94 * # Subclassing GtkCellLayout implementations 95 * 96 * When subclassing a widget that implements #GtkCellLayout like 97 * #GtkIconView or #GtkComboBox, there are some considerations related 98 * to the fact that these widgets internally use a #GtkCellArea. 99 * The cell area is exposed as a construct-only property by these 100 * widgets. This means that it is possible to e.g. do 101 * 102 * |[<!-- language="C" --> 103 * combo = g_object_new (GTK_TYPE_COMBO_BOX, "cell-area", my_cell_area, NULL); 104 * ]| 105 * 106 * to use a custom cell area with a combo box. But construct properties 107 * are only initialized after instance init() 108 * functions have run, which means that using functions which rely on 109 * the existence of the cell area in your subclass’ init() function will 110 * cause the default cell area to be instantiated. In this case, a provided 111 * construct property value will be ignored (with a warning, to alert 112 * you to the problem). 113 * 114 * |[<!-- language="C" --> 115 * static void 116 * my_combo_box_init (MyComboBox *b) 117 * { 118 * GtkCellRenderer *cell; 119 * 120 * cell = gtk_cell_renderer_pixbuf_new (); 121 * // The following call causes the default cell area for combo boxes, 122 * // a GtkCellAreaBox, to be instantiated 123 * gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (b), cell, FALSE); 124 * ... 125 * } 126 * 127 * GtkWidget * 128 * my_combo_box_new (GtkCellArea *area) 129 * { 130 * // This call is going to cause a warning about area being ignored 131 * return g_object_new (MY_TYPE_COMBO_BOX, "cell-area", area, NULL); 132 * } 133 * ]| 134 * 135 * If supporting alternative cell areas with your derived widget is 136 * not important, then this does not have to concern you. If you want 137 * to support alternative cell areas, you can do so by moving the 138 * problematic calls out of init() and into a constructor() 139 * for your class. 140 */ 141 public template CellLayoutT(TStruct) 142 { 143 /** Get the main Gtk struct */ 144 public GtkCellLayout* getCellLayoutStruct(bool transferOwnership = false) 145 { 146 if (transferOwnership) 147 ownedRef = false; 148 return cast(GtkCellLayout*)getStruct(); 149 } 150 151 152 /** 153 * Adds an attribute mapping to the list in @cell_layout. 154 * 155 * The @column is the column of the model to get a value from, and the 156 * @attribute is the parameter on @cell to be set from the value. So for 157 * example if column 2 of the model contains strings, you could have the 158 * “text” attribute of a #GtkCellRendererText get its values from column 2. 159 * 160 * Params: 161 * cell = a #GtkCellRenderer 162 * attribute = an attribute on the renderer 163 * column = the column position on the model to get the attribute from 164 * 165 * Since: 2.4 166 */ 167 public void addAttribute(CellRenderer cell, string attribute, int column) 168 { 169 gtk_cell_layout_add_attribute(getCellLayoutStruct(), (cell is null) ? null : cell.getCellRendererStruct(), Str.toStringz(attribute), column); 170 } 171 172 /** 173 * Unsets all the mappings on all renderers on @cell_layout and 174 * removes all renderers from @cell_layout. 175 * 176 * Since: 2.4 177 */ 178 public void clear() 179 { 180 gtk_cell_layout_clear(getCellLayoutStruct()); 181 } 182 183 /** 184 * Clears all existing attributes previously set with 185 * gtk_cell_layout_set_attributes(). 186 * 187 * Params: 188 * cell = a #GtkCellRenderer to clear the attribute mapping on 189 * 190 * Since: 2.4 191 */ 192 public void clearAttributes(CellRenderer cell) 193 { 194 gtk_cell_layout_clear_attributes(getCellLayoutStruct(), (cell is null) ? null : cell.getCellRendererStruct()); 195 } 196 197 /** 198 * Returns the underlying #GtkCellArea which might be @cell_layout 199 * if called on a #GtkCellArea or might be %NULL if no #GtkCellArea 200 * is used by @cell_layout. 201 * 202 * Returns: the cell area used by @cell_layout, 203 * or %NULL in case no cell area is used. 204 * 205 * Since: 3.0 206 */ 207 public CellArea getArea() 208 { 209 auto p = gtk_cell_layout_get_area(getCellLayoutStruct()); 210 211 if(p is null) 212 { 213 return null; 214 } 215 216 return ObjectG.getDObject!(CellArea)(cast(GtkCellArea*) p); 217 } 218 219 /** 220 * Returns the cell renderers which have been added to @cell_layout. 221 * 222 * Returns: a list of cell renderers. The list, but not the renderers has 223 * been newly allocated and should be freed with g_list_free() 224 * when no longer needed. 225 * 226 * Since: 2.12 227 */ 228 public ListG getCells() 229 { 230 auto p = gtk_cell_layout_get_cells(getCellLayoutStruct()); 231 232 if(p is null) 233 { 234 return null; 235 } 236 237 return new ListG(cast(GList*) p); 238 } 239 240 /** 241 * Adds the @cell to the end of @cell_layout. If @expand is %FALSE, then the 242 * @cell is allocated no more space than it needs. Any unused space is 243 * divided evenly between cells for which @expand is %TRUE. 244 * 245 * Note that reusing the same cell renderer is not supported. 246 * 247 * Params: 248 * cell = a #GtkCellRenderer 249 * expand = %TRUE if @cell is to be given extra space allocated to @cell_layout 250 * 251 * Since: 2.4 252 */ 253 public void packEnd(CellRenderer cell, bool expand) 254 { 255 gtk_cell_layout_pack_end(getCellLayoutStruct(), (cell is null) ? null : cell.getCellRendererStruct(), expand); 256 } 257 258 /** 259 * Packs the @cell into the beginning of @cell_layout. If @expand is %FALSE, 260 * then the @cell is allocated no more space than it needs. Any unused space 261 * is divided evenly between cells for which @expand is %TRUE. 262 * 263 * Note that reusing the same cell renderer is not supported. 264 * 265 * Params: 266 * cell = a #GtkCellRenderer 267 * expand = %TRUE if @cell is to be given extra space allocated to @cell_layout 268 * 269 * Since: 2.4 270 */ 271 public void packStart(CellRenderer cell, bool expand) 272 { 273 gtk_cell_layout_pack_start(getCellLayoutStruct(), (cell is null) ? null : cell.getCellRendererStruct(), expand); 274 } 275 276 /** 277 * Re-inserts @cell at @position. 278 * 279 * Note that @cell has already to be packed into @cell_layout 280 * for this to function properly. 281 * 282 * Params: 283 * cell = a #GtkCellRenderer to reorder 284 * position = new position to insert @cell at 285 * 286 * Since: 2.4 287 */ 288 public void reorder(CellRenderer cell, int position) 289 { 290 gtk_cell_layout_reorder(getCellLayoutStruct(), (cell is null) ? null : cell.getCellRendererStruct(), position); 291 } 292 293 /** 294 * Sets the #GtkCellLayoutDataFunc to use for @cell_layout. 295 * 296 * This function is used instead of the standard attributes mapping 297 * for setting the column value, and should set the value of @cell_layout’s 298 * cell renderer(s) as appropriate. 299 * 300 * @func may be %NULL to remove a previously set function. 301 * 302 * Params: 303 * cell = a #GtkCellRenderer 304 * func = the #GtkCellLayoutDataFunc to use, or %NULL 305 * funcData = user data for @func 306 * destroy = destroy notify for @func_data 307 * 308 * Since: 2.4 309 */ 310 public void setCellDataFunc(CellRenderer cell, GtkCellLayoutDataFunc func, void* funcData, GDestroyNotify destroy) 311 { 312 gtk_cell_layout_set_cell_data_func(getCellLayoutStruct(), (cell is null) ? null : cell.getCellRendererStruct(), func, funcData, destroy); 313 } 314 }