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  = GtkCellView.html
27  * outPack = gtk
28  * outFile = CellView
29  * strct   = GtkCellView
30  * realStrct=
31  * ctorStrct=
32  * clss    = CellView
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- CellLayoutIF
40  * 	- OrientableIF
41  * prefixes:
42  * 	- gtk_cell_view_
43  * omit structs:
44  * omit prefixes:
45  * omit code:
46  * 	- gtk_cell_view_new_with_text
47  * 	- gtk_cell_view_new_with_markup
48  * omit signals:
49  * imports:
50  * 	- glib.Str
51  * 	- gdk.Color
52  * 	- gdk.RGBA
53  * 	- gdk.Pixbuf
54  * 	- gtk.CellArea
55  * 	- gtk.CellAreaContext
56  * 	- gtk.TreeModel
57  * 	- gtk.TreeModelIF
58  * 	- gtk.TreePath
59  * 	- gtk.CellLayoutIF
60  * 	- gtk.CellLayoutT
61  * 	- gtk.OrientableIF
62  * 	- gtk.OrientableT
63  * structWrap:
64  * 	- GdkColor* -> Color
65  * 	- GdkPixbuf* -> Pixbuf
66  * 	- GdkRGBA* -> RGBA
67  * 	- GtkCellArea* -> CellArea
68  * 	- GtkCellAreaContext* -> CellAreaContext
69  * 	- GtkTreeModel* -> TreeModelIF
70  * 	- GtkTreePath* -> TreePath
71  * module aliases:
72  * local aliases:
73  * overrides:
74  */
75 
76 module gtk.CellView;
77 
78 public  import gtkc.gtktypes;
79 
80 private import gtkc.gtk;
81 private import glib.ConstructionException;
82 private import gobject.ObjectG;
83 
84 
85 private import glib.Str;
86 private import gdk.Color;
87 private import gdk.RGBA;
88 private import gdk.Pixbuf;
89 private import gtk.CellArea;
90 private import gtk.CellAreaContext;
91 private import gtk.TreeModel;
92 private import gtk.TreeModelIF;
93 private import gtk.TreePath;
94 private import gtk.CellLayoutIF;
95 private import gtk.CellLayoutT;
96 private import gtk.OrientableIF;
97 private import gtk.OrientableT;
98 
99 
100 
101 private import gtk.Widget;
102 
103 /**
104  * A GtkCellView displays a single row of a GtkTreeModel using a GtkCellArea
105  * and GtkCellAreaContext. A GtkCellAreaContext can be provided to the
106  * GtkCellView at construction time in order to keep the cellview in context
107  * of a group of cell views, this ensures that the renderers displayed will
108  * be properly aligned with eachother (like the aligned cells in the menus
109  * of GtkComboBox).
110  *
111  * GtkCellView is GtkOrientable in order to decide in which orientation
112  * the underlying GtkCellAreaContext should be allocated. Taking the GtkComboBox
113  * menu as an example, cellviews should be oriented horizontally if the menus are
114  * listed top-to-bottom and thus all share the same width but may have separate
115  * individual heights (left-to-right menus should be allocated vertically since
116  * they all share the same height but may have variable widths).
117  */
118 public class CellView : Widget, CellLayoutIF, OrientableIF
119 {
120 	
121 	/** the main Gtk struct */
122 	protected GtkCellView* gtkCellView;
123 	
124 	
125 	public GtkCellView* getCellViewStruct()
126 	{
127 		return gtkCellView;
128 	}
129 	
130 	
131 	/** the main Gtk struct as a void* */
132 	protected override void* getStruct()
133 	{
134 		return cast(void*)gtkCellView;
135 	}
136 	
137 	/**
138 	 * Sets our main struct and passes it to the parent class
139 	 */
140 	public this (GtkCellView* gtkCellView)
141 	{
142 		super(cast(GtkWidget*)gtkCellView);
143 		this.gtkCellView = gtkCellView;
144 	}
145 	
146 	protected override void setStruct(GObject* obj)
147 	{
148 		super.setStruct(obj);
149 		gtkCellView = cast(GtkCellView*)obj;
150 	}
151 	
152 	// add the CellLayout capabilities
153 	mixin CellLayoutT!(GtkCellView);
154 	
155 	// add the Orientable capabilities
156 	mixin OrientableT!(GtkCellView);
157 	
158 	/**
159 	 * Creates a new GtkCellView widget, adds a GtkCellRendererText
160 	 * to it, and makes its show text.
161 	 * If markup is true the text can be marked up with the Pango text
162 	 * markup language.
163 	 * Since 2.6
164 	 * Params:
165 	 *  text = the text to display in the cell view
166 	 * Returns:
167 	 *  A newly created GtkCellView widget.
168 	 * Throws: ConstructionException GTK+ fails to create the object.
169 	 */
170 	public this (string text, bool markup=true)
171 	{
172 		GtkCellView* p;
173 		
174 		if ( markup )
175 		{
176 			// GtkWidget* gtk_cell_view_new_with_markup (const gchar *markup);
177 			p = cast(GtkCellView*)gtk_cell_view_new_with_markup(Str.toStringz(text));
178 		}
179 		else
180 		{
181 			// GtkWidget* gtk_cell_view_new_with_text (const gchar *text);
182 			p = cast(GtkCellView*)gtk_cell_view_new_with_text(Str.toStringz(text));
183 		}
184 		
185 		if(p is null)
186 		{
187 			throw new ConstructionException("null returned by gtk_cell_view_new_with_");
188 		}
189 		
190 		this(p);
191 	}
192 	
193 	/**
194 	 */
195 	
196 	/**
197 	 * Creates a new GtkCellView widget.
198 	 * Since 2.6
199 	 * Throws: ConstructionException GTK+ fails to create the object.
200 	 */
201 	public this ()
202 	{
203 		// GtkWidget * gtk_cell_view_new (void);
204 		auto p = gtk_cell_view_new();
205 		if(p is null)
206 		{
207 			throw new ConstructionException("null returned by gtk_cell_view_new()");
208 		}
209 		this(cast(GtkCellView*) p);
210 	}
211 	
212 	/**
213 	 * Creates a new GtkCellView widget with a specific GtkCellArea
214 	 * to layout cells and a specific GtkCellAreaContext.
215 	 * Specifying the same context for a handfull of cells lets
216 	 * the underlying area synchronize the geometry for those cells,
217 	 * in this way alignments with cellviews for other rows are
218 	 * possible.
219 	 * Since 2.6
220 	 * Params:
221 	 * area = the GtkCellArea to layout cells
222 	 * context = the GtkCellAreaContext in which to calculate cell geometry
223 	 * Throws: ConstructionException GTK+ fails to create the object.
224 	 */
225 	public this (CellArea area, CellAreaContext context)
226 	{
227 		// GtkWidget * gtk_cell_view_new_with_context (GtkCellArea *area,  GtkCellAreaContext *context);
228 		auto p = gtk_cell_view_new_with_context((area is null) ? null : area.getCellAreaStruct(), (context is null) ? null : context.getCellAreaContextStruct());
229 		if(p is null)
230 		{
231 			throw new ConstructionException("null returned by gtk_cell_view_new_with_context((area is null) ? null : area.getCellAreaStruct(), (context is null) ? null : context.getCellAreaContextStruct())");
232 		}
233 		this(cast(GtkCellView*) p);
234 	}
235 	
236 	/**
237 	 * Creates a new GtkCellView widget, adds a GtkCellRendererPixbuf
238 	 * to it, and makes it show pixbuf.
239 	 * Since 2.6
240 	 * Params:
241 	 * pixbuf = the image to display in the cell view
242 	 * Throws: ConstructionException GTK+ fails to create the object.
243 	 */
244 	public this (Pixbuf pixbuf)
245 	{
246 		// GtkWidget * gtk_cell_view_new_with_pixbuf (GdkPixbuf *pixbuf);
247 		auto p = gtk_cell_view_new_with_pixbuf((pixbuf is null) ? null : pixbuf.getPixbufStruct());
248 		if(p is null)
249 		{
250 			throw new ConstructionException("null returned by gtk_cell_view_new_with_pixbuf((pixbuf is null) ? null : pixbuf.getPixbufStruct())");
251 		}
252 		this(cast(GtkCellView*) p);
253 	}
254 	
255 	/**
256 	 * Sets the model for cell_view. If cell_view already has a model
257 	 * set, it will remove it before setting the new model. If model is
258 	 * NULL, then it will unset the old model.
259 	 * Since 2.6
260 	 * Params:
261 	 * model = a GtkTreeModel. [allow-none]
262 	 */
263 	public void setModel(TreeModelIF model)
264 	{
265 		// void gtk_cell_view_set_model (GtkCellView *cell_view,  GtkTreeModel *model);
266 		gtk_cell_view_set_model(gtkCellView, (model is null) ? null : model.getTreeModelTStruct());
267 	}
268 	
269 	/**
270 	 * Returns the model for cell_view. If no model is used NULL is
271 	 * returned.
272 	 * Since 2.16
273 	 * Returns: a GtkTreeModel used or NULL. [transfer none]
274 	 */
275 	public TreeModelIF getModel()
276 	{
277 		// GtkTreeModel * gtk_cell_view_get_model (GtkCellView *cell_view);
278 		auto p = gtk_cell_view_get_model(gtkCellView);
279 		
280 		if(p is null)
281 		{
282 			return null;
283 		}
284 		
285 		return ObjectG.getDObject!(TreeModel, TreeModelIF)(cast(GtkTreeModel*) p);
286 	}
287 	
288 	/**
289 	 * Sets the row of the model that is currently displayed
290 	 * by the GtkCellView. If the path is unset, then the
291 	 * contents of the cellview "stick" at their last value;
292 	 * this is not normally a desired result, but may be
293 	 * a needed intermediate state if say, the model for
294 	 * the GtkCellView becomes temporarily empty.
295 	 * Since 2.6
296 	 * Params:
297 	 * path = a GtkTreePath or NULL to unset. [allow-none]
298 	 */
299 	public void setDisplayedRow(TreePath path)
300 	{
301 		// void gtk_cell_view_set_displayed_row (GtkCellView *cell_view,  GtkTreePath *path);
302 		gtk_cell_view_set_displayed_row(gtkCellView, (path is null) ? null : path.getTreePathStruct());
303 	}
304 	
305 	/**
306 	 * Returns a GtkTreePath referring to the currently
307 	 * displayed row. If no row is currently displayed,
308 	 * NULL is returned.
309 	 * Since 2.6
310 	 * Returns: the currently displayed row or NULL
311 	 */
312 	public TreePath getDisplayedRow()
313 	{
314 		// GtkTreePath * gtk_cell_view_get_displayed_row (GtkCellView *cell_view);
315 		auto p = gtk_cell_view_get_displayed_row(gtkCellView);
316 		
317 		if(p is null)
318 		{
319 			return null;
320 		}
321 		
322 		return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p);
323 	}
324 	
325 	/**
326 	 * Warning
327 	 * gtk_cell_view_get_size_of_row has been deprecated since version 3.0 and should not be used in newly-written code. Combo box formerly used this to calculate the
328 	 * sizes for cellviews, now you can achieve this by either using
329 	 * the "fit-model" property or by setting the currently
330 	 * displayed row of the GtkCellView and using gtk_widget_get_preferred_size().
331 	 * Sets requisition to the size needed by cell_view to display
332 	 * the model row pointed to by path.
333 	 * Since 2.6
334 	 * Params:
335 	 * path = a GtkTreePath
336 	 * requisition = return location for the size. [out]
337 	 * Returns: TRUE
338 	 */
339 	public int getSizeOfRow(TreePath path, out GtkRequisition requisition)
340 	{
341 		// gboolean gtk_cell_view_get_size_of_row (GtkCellView *cell_view,  GtkTreePath *path,  GtkRequisition *requisition);
342 		return gtk_cell_view_get_size_of_row(gtkCellView, (path is null) ? null : path.getTreePathStruct(), &requisition);
343 	}
344 	
345 	/**
346 	 * Warning
347 	 * gtk_cell_view_set_background_color has been deprecated since version 3.4 and should not be used in newly-written code. Use gtk_cell_view_set_background_rgba() instead.
348 	 * Sets the background color of view.
349 	 * Since 2.6
350 	 * Params:
351 	 * color = the new background color
352 	 */
353 	public void setBackgroundColor(Color color)
354 	{
355 		// void gtk_cell_view_set_background_color (GtkCellView *cell_view,  const GdkColor *color);
356 		gtk_cell_view_set_background_color(gtkCellView, (color is null) ? null : color.getColorStruct());
357 	}
358 	
359 	/**
360 	 * Sets the background color of cell_view.
361 	 * Params:
362 	 * rgba = the new background color
363 	 * Since 3.0
364 	 */
365 	public void setBackgroundRgba(RGBA rgba)
366 	{
367 		// void gtk_cell_view_set_background_rgba (GtkCellView *cell_view,  const GdkRGBA *rgba);
368 		gtk_cell_view_set_background_rgba(gtkCellView, (rgba is null) ? null : rgba.getRGBAStruct());
369 	}
370 	
371 	/**
372 	 * Sets whether cell_view should draw all of its
373 	 * cells in a sensitive state, this is used by GtkComboBox menus
374 	 * to ensure that rows with insensitive cells that contain
375 	 * children appear sensitive in the parent menu item.
376 	 * Params:
377 	 * drawSensitive = whether to draw all cells in a sensitive state.
378 	 * Since 3.0
379 	 */
380 	public void setDrawSensitive(int drawSensitive)
381 	{
382 		// void gtk_cell_view_set_draw_sensitive (GtkCellView *cell_view,  gboolean draw_sensitive);
383 		gtk_cell_view_set_draw_sensitive(gtkCellView, drawSensitive);
384 	}
385 	
386 	/**
387 	 * Gets whether cell_view is configured to draw all of its
388 	 * cells in a sensitive state.
389 	 * Returns: whether cell_view draws all of its cells in a sensitive state Since 3.0
390 	 */
391 	public int getDrawSensitive()
392 	{
393 		// gboolean gtk_cell_view_get_draw_sensitive (GtkCellView *cell_view);
394 		return gtk_cell_view_get_draw_sensitive(gtkCellView);
395 	}
396 	
397 	/**
398 	 * Sets whether cell_view should request space to fit the entire GtkTreeModel.
399 	 * This is used by GtkComboBox to ensure that the cell view displayed on
400 	 * the combo box's button always gets enough space and does not resize
401 	 * when selection changes.
402 	 * Params:
403 	 * fitModel = whether cell_view should request space for the whole model.
404 	 * Since 3.0
405 	 */
406 	public void setFitModel(int fitModel)
407 	{
408 		// void gtk_cell_view_set_fit_model (GtkCellView *cell_view,  gboolean fit_model);
409 		gtk_cell_view_set_fit_model(gtkCellView, fitModel);
410 	}
411 	
412 	/**
413 	 * Gets whether cell_view is configured to request space
414 	 * to fit the entire GtkTreeModel.
415 	 * Returns: whether cell_view requests space to fit the entire GtkTreeModel. Since 3.0
416 	 */
417 	public int getFitModel()
418 	{
419 		// gboolean gtk_cell_view_get_fit_model (GtkCellView *cell_view);
420 		return gtk_cell_view_get_fit_model(gtkCellView);
421 	}
422 }