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