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.Texture;
28 private import glib.ConstructionException;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gtk.CellArea;
32 private import gtk.CellAreaContext;
33 private import gtk.CellLayoutIF;
34 private import gtk.CellLayoutT;
35 private import gtk.OrientableIF;
36 private import gtk.OrientableT;
37 private import gtk.TreeModelIF;
38 private import gtk.TreePath;
39 private import gtk.Widget;
40 private import gtk.c.functions;
41 public  import gtk.c.types;
42 
43 
44 /**
45  * A widget displaying a single row of a GtkTreeModel
46  * 
47  * A #GtkCellView displays a single row of a #GtkTreeModel using a #GtkCellArea
48  * and #GtkCellAreaContext. A #GtkCellAreaContext can be provided to the
49  * #GtkCellView at construction time in order to keep the cellview in context
50  * of a group of cell views, this ensures that the renderers displayed will
51  * be properly aligned with each other (like the aligned cells in the menus
52  * of #GtkComboBox).
53  * 
54  * #GtkCellView is #GtkOrientable in order to decide in which orientation
55  * the underlying #GtkCellAreaContext should be allocated. Taking the #GtkComboBox
56  * menu as an example, cellviews should be oriented horizontally if the menus are
57  * listed top-to-bottom and thus all share the same width but may have separate
58  * individual heights (left-to-right menus should be allocated vertically since
59  * they all share the same height but may have variable widths).
60  * 
61  * # CSS nodes
62  * 
63  * GtkCellView has a single CSS node with name cellview.
64  */
65 public class CellView : Widget, CellLayoutIF, OrientableIF
66 {
67 	/** the main Gtk struct */
68 	protected GtkCellView* gtkCellView;
69 
70 	/** Get the main Gtk struct */
71 	public GtkCellView* getCellViewStruct(bool transferOwnership = false)
72 	{
73 		if (transferOwnership)
74 			ownedRef = false;
75 		return gtkCellView;
76 	}
77 
78 	/** the main Gtk struct as a void* */
79 	protected override void* getStruct()
80 	{
81 		return cast(void*)gtkCellView;
82 	}
83 
84 	/**
85 	 * Sets our main struct and passes it to the parent class.
86 	 */
87 	public this (GtkCellView* gtkCellView, bool ownedRef = false)
88 	{
89 		this.gtkCellView = gtkCellView;
90 		super(cast(GtkWidget*)gtkCellView, ownedRef);
91 	}
92 
93 	// add the CellLayout capabilities
94 	mixin CellLayoutT!(GtkCellView);
95 
96 	// add the Orientable capabilities
97 	mixin OrientableT!(GtkCellView);
98 
99 
100 	/** */
101 	public static GType getType()
102 	{
103 		return gtk_cell_view_get_type();
104 	}
105 
106 	/**
107 	 * Creates a new #GtkCellView widget.
108 	 *
109 	 * Returns: A newly created #GtkCellView widget.
110 	 *
111 	 * Throws: ConstructionException GTK+ fails to create the object.
112 	 */
113 	public this()
114 	{
115 		auto __p = gtk_cell_view_new();
116 
117 		if(__p is null)
118 		{
119 			throw new ConstructionException("null returned by new");
120 		}
121 
122 		this(cast(GtkCellView*) __p);
123 	}
124 
125 	/**
126 	 * Creates a new #GtkCellView widget with a specific #GtkCellArea
127 	 * to layout cells and a specific #GtkCellAreaContext.
128 	 *
129 	 * Specifying the same context for a handful of cells lets
130 	 * the underlying area synchronize the geometry for those cells,
131 	 * in this way alignments with cellviews for other rows are
132 	 * possible.
133 	 *
134 	 * Params:
135 	 *     area = the #GtkCellArea to layout cells
136 	 *     context = the #GtkCellAreaContext in which to calculate cell geometry
137 	 *
138 	 * Returns: A newly created #GtkCellView widget.
139 	 *
140 	 * Throws: ConstructionException GTK+ fails to create the object.
141 	 */
142 	public this(CellArea area, CellAreaContext context)
143 	{
144 		auto __p = gtk_cell_view_new_with_context((area is null) ? null : area.getCellAreaStruct(), (context is null) ? null : context.getCellAreaContextStruct());
145 
146 		if(__p is null)
147 		{
148 			throw new ConstructionException("null returned by new_with_context");
149 		}
150 
151 		this(cast(GtkCellView*) __p);
152 	}
153 
154 	/**
155 	 * Creates a new #GtkCellView widget, adds a #GtkCellRendererText
156 	 * to it, and makes it show @markup. The text can be
157 	 * marked up with the [Pango text markup language][PangoMarkupFormat].
158 	 *
159 	 * Params:
160 	 *     markup = the text to display in the cell view
161 	 *
162 	 * Returns: A newly created #GtkCellView widget.
163 	 *
164 	 * Throws: ConstructionException GTK+ fails to create the object.
165 	 */
166 	public this(string markup)
167 	{
168 		auto __p = gtk_cell_view_new_with_markup(Str.toStringz(markup));
169 
170 		if(__p is null)
171 		{
172 			throw new ConstructionException("null returned by new_with_markup");
173 		}
174 
175 		this(cast(GtkCellView*) __p);
176 	}
177 
178 	/**
179 	 * Creates a new #GtkCellView widget, adds a #GtkCellRendererPixbuf
180 	 * to it, and makes it show @texture.
181 	 *
182 	 * Params:
183 	 *     texture = the image to display in the cell view
184 	 *
185 	 * Returns: A newly created #GtkCellView widget.
186 	 *
187 	 * Throws: ConstructionException GTK+ fails to create the object.
188 	 */
189 	public this(Texture texture)
190 	{
191 		auto __p = gtk_cell_view_new_with_texture((texture is null) ? null : texture.getTextureStruct());
192 
193 		if(__p is null)
194 		{
195 			throw new ConstructionException("null returned by new_with_texture");
196 		}
197 
198 		this(cast(GtkCellView*) __p);
199 	}
200 
201 	/**
202 	 * Returns a #GtkTreePath referring to the currently
203 	 * displayed row. If no row is currently displayed,
204 	 * %NULL is returned.
205 	 *
206 	 * Returns: the currently displayed row or %NULL
207 	 */
208 	public TreePath getDisplayedRow()
209 	{
210 		auto __p = gtk_cell_view_get_displayed_row(gtkCellView);
211 
212 		if(__p is null)
213 		{
214 			return null;
215 		}
216 
217 		return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) __p, true);
218 	}
219 
220 	/**
221 	 * Gets whether @cell_view is configured to draw all of its
222 	 * cells in a sensitive state.
223 	 *
224 	 * Returns: whether @cell_view draws all of its
225 	 *     cells in a sensitive state
226 	 */
227 	public bool getDrawSensitive()
228 	{
229 		return gtk_cell_view_get_draw_sensitive(gtkCellView) != 0;
230 	}
231 
232 	/**
233 	 * Gets whether @cell_view is configured to request space
234 	 * to fit the entire #GtkTreeModel.
235 	 *
236 	 * Returns: whether @cell_view requests space to fit
237 	 *     the entire #GtkTreeModel.
238 	 */
239 	public bool getFitModel()
240 	{
241 		return gtk_cell_view_get_fit_model(gtkCellView) != 0;
242 	}
243 
244 	/**
245 	 * Returns the model for @cell_view. If no model is used %NULL is
246 	 * returned.
247 	 *
248 	 * Returns: a #GtkTreeModel used or %NULL
249 	 */
250 	public TreeModelIF getModel()
251 	{
252 		auto __p = gtk_cell_view_get_model(gtkCellView);
253 
254 		if(__p is null)
255 		{
256 			return null;
257 		}
258 
259 		return ObjectG.getDObject!(TreeModelIF)(cast(GtkTreeModel*) __p);
260 	}
261 
262 	/**
263 	 * Sets the row of the model that is currently displayed
264 	 * by the #GtkCellView. If the path is unset, then the
265 	 * contents of the cellview “stick” at their last value;
266 	 * this is not normally a desired result, but may be
267 	 * a needed intermediate state if say, the model for
268 	 * the #GtkCellView becomes temporarily empty.
269 	 *
270 	 * Params:
271 	 *     path = a #GtkTreePath or %NULL to unset.
272 	 */
273 	public void setDisplayedRow(TreePath path)
274 	{
275 		gtk_cell_view_set_displayed_row(gtkCellView, (path is null) ? null : path.getTreePathStruct());
276 	}
277 
278 	/**
279 	 * Sets whether @cell_view should draw all of its
280 	 * cells in a sensitive state, this is used by #GtkComboBox menus
281 	 * to ensure that rows with insensitive cells that contain
282 	 * children appear sensitive in the parent menu item.
283 	 *
284 	 * Params:
285 	 *     drawSensitive = whether to draw all cells in a sensitive state.
286 	 */
287 	public void setDrawSensitive(bool drawSensitive)
288 	{
289 		gtk_cell_view_set_draw_sensitive(gtkCellView, drawSensitive);
290 	}
291 
292 	/**
293 	 * Sets whether @cell_view should request space to fit the entire #GtkTreeModel.
294 	 *
295 	 * This is used by #GtkComboBox to ensure that the cell view displayed on
296 	 * the combo box’s button always gets enough space and does not resize
297 	 * when selection changes.
298 	 *
299 	 * Params:
300 	 *     fitModel = whether @cell_view should request space for the whole model.
301 	 */
302 	public void setFitModel(bool fitModel)
303 	{
304 		gtk_cell_view_set_fit_model(gtkCellView, fitModel);
305 	}
306 
307 	/**
308 	 * Sets the model for @cell_view.  If @cell_view already has a model
309 	 * set, it will remove it before setting the new model.  If @model is
310 	 * %NULL, then it will unset the old model.
311 	 *
312 	 * Params:
313 	 *     model = a #GtkTreeModel
314 	 */
315 	public void setModel(TreeModelIF model)
316 	{
317 		gtk_cell_view_set_model(gtkCellView, (model is null) ? null : model.getTreeModelStruct());
318 	}
319 }