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