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