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  * prefixes:
41  * 	- gtk_cell_view_
42  * 	- gtk_
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.Pixbuf
52  * 	- gtk.TreeModel
53  * 	- gtk.TreeModelIF
54  * 	- gtk.TreePath
55  * 	- gdk.Color
56  * 	- glib.ListG
57  * 	- gtk.CellLayoutIF
58  * 	- gtk.CellLayoutT
59  * structWrap:
60  * 	- GList* -> ListG
61  * 	- GdkColor* -> Color
62  * 	- GdkPixbuf* -> Pixbuf
63  * 	- GtkTreeModel* -> TreeModelIF
64  * 	- GtkTreePath* -> TreePath
65  * module aliases:
66  * local aliases:
67  * overrides:
68  */
69 
70 module gtk.CellView;
71 
72 public  import gtkc.gtktypes;
73 
74 private import gtkc.gtk;
75 private import glib.ConstructionException;
76 private import gobject.ObjectG;
77 
78 
79 private import glib.Str;
80 private import gdk.Pixbuf;
81 private import gtk.TreeModel;
82 private import gtk.TreeModelIF;
83 private import gtk.TreePath;
84 private import gdk.Color;
85 private import glib.ListG;
86 private import gtk.CellLayoutIF;
87 private import gtk.CellLayoutT;
88 
89 
90 
91 private import gtk.Widget;
92 
93 /**
94  * Description
95  * A GtkCellView displays a single row of a GtkTreeModel, using
96  * cell renderers just like GtkTreeView. GtkCellView doesn't support
97  * some of the more complex features of GtkTreeView, like cell editing
98  * and drag and drop.
99  */
100 public class CellView : Widget, CellLayoutIF
101 {
102 	
103 	/** the main Gtk struct */
104 	protected GtkCellView* gtkCellView;
105 	
106 	
107 	public GtkCellView* getCellViewStruct()
108 	{
109 		return gtkCellView;
110 	}
111 	
112 	
113 	/** the main Gtk struct as a void* */
114 	protected override void* getStruct()
115 	{
116 		return cast(void*)gtkCellView;
117 	}
118 	
119 	/**
120 	 * Sets our main struct and passes it to the parent class
121 	 */
122 	public this (GtkCellView* gtkCellView)
123 	{
124 		super(cast(GtkWidget*)gtkCellView);
125 		this.gtkCellView = gtkCellView;
126 	}
127 	
128 	protected override void setStruct(GObject* obj)
129 	{
130 		super.setStruct(obj);
131 		gtkCellView = cast(GtkCellView*)obj;
132 	}
133 	
134 	// add the CellLayout capabilities
135 	mixin CellLayoutT!(GtkCellView);
136 	
137 	/**
138 	 * Creates a new GtkCellView widget, adds a GtkCellRendererText
139 	 * to it, and makes its show text.
140 	 * If markup is true the text can be marked up with the Pango text
141 	 * markup language.
142 	 * Since 2.6
143 	 * Params:
144 	 *  text = the text to display in the cell view
145 	 * Returns:
146 	 *  A newly created GtkCellView widget.
147 	 * Throws: ConstructionException GTK+ fails to create the object.
148 	 */
149 	public this (string text, bool markup=true)
150 	{
151 		GtkCellView* p;
152 		
153 		if ( markup )
154 		{
155 			// GtkWidget* gtk_cell_view_new_with_markup (const gchar *markup);
156 			p = cast(GtkCellView*)gtk_cell_view_new_with_markup(Str.toStringz(text));
157 		}
158 		else
159 		{
160 			// GtkWidget* gtk_cell_view_new_with_text (const gchar *text);
161 			p = cast(GtkCellView*)gtk_cell_view_new_with_text(Str.toStringz(text));
162 		}
163 		
164 		if(p is null)
165 		{
166 			throw new ConstructionException("null returned by gtk_cell_view_new_with_");
167 		}
168 		
169 		this(p);
170 	}
171 	
172 	/**
173 	 */
174 	
175 	/**
176 	 * Creates a new GtkCellView widget.
177 	 * Since 2.6
178 	 * Throws: ConstructionException GTK+ fails to create the object.
179 	 */
180 	public this ()
181 	{
182 		// GtkWidget * gtk_cell_view_new (void);
183 		auto p = gtk_cell_view_new();
184 		if(p is null)
185 		{
186 			throw new ConstructionException("null returned by gtk_cell_view_new()");
187 		}
188 		this(cast(GtkCellView*) p);
189 	}
190 	
191 	/**
192 	 * Creates a new GtkCellView widget, adds a GtkCellRendererPixbuf
193 	 * to it, and makes its show pixbuf.
194 	 * Since 2.6
195 	 * Params:
196 	 * pixbuf = the image to display in the cell view
197 	 * Throws: ConstructionException GTK+ fails to create the object.
198 	 */
199 	public this (Pixbuf pixbuf)
200 	{
201 		// GtkWidget * gtk_cell_view_new_with_pixbuf (GdkPixbuf *pixbuf);
202 		auto p = gtk_cell_view_new_with_pixbuf((pixbuf is null) ? null : pixbuf.getPixbufStruct());
203 		if(p is null)
204 		{
205 			throw new ConstructionException("null returned by gtk_cell_view_new_with_pixbuf((pixbuf is null) ? null : pixbuf.getPixbufStruct())");
206 		}
207 		this(cast(GtkCellView*) p);
208 	}
209 	
210 	/**
211 	 * Sets the model for cell_view. If cell_view already has a model
212 	 * set, it will remove it before setting the new model. If model is
213 	 * NULL, then it will unset the old model.
214 	 * Since 2.6
215 	 * Params:
216 	 * model = a GtkTreeModel. [allow-none]
217 	 */
218 	public void setModel(TreeModelIF model)
219 	{
220 		// void gtk_cell_view_set_model (GtkCellView *cell_view,  GtkTreeModel *model);
221 		gtk_cell_view_set_model(gtkCellView, (model is null) ? null : model.getTreeModelTStruct());
222 	}
223 	
224 	/**
225 	 * Returns the model for cell_view. If no model is used NULL is
226 	 * returned.
227 	 * Since 2.16
228 	 * Returns: a GtkTreeModel used or NULL. [transfer none]
229 	 */
230 	public TreeModelIF getModel()
231 	{
232 		// GtkTreeModel * gtk_cell_view_get_model (GtkCellView *cell_view);
233 		auto p = gtk_cell_view_get_model(gtkCellView);
234 		
235 		if(p is null)
236 		{
237 			return null;
238 		}
239 		
240 		return ObjectG.getDObject!(TreeModel, TreeModelIF)(cast(GtkTreeModel*) p);
241 	}
242 	
243 	/**
244 	 * Sets the row of the model that is currently displayed
245 	 * by the GtkCellView. If the path is unset, then the
246 	 * contents of the cellview "stick" at their last value;
247 	 * this is not normally a desired result, but may be
248 	 * a needed intermediate state if say, the model for
249 	 * the GtkCellView becomes temporarily empty.
250 	 * Since 2.6
251 	 * Params:
252 	 * path = a GtkTreePath or NULL to unset. [allow-none]
253 	 */
254 	public void setDisplayedRow(TreePath path)
255 	{
256 		// void gtk_cell_view_set_displayed_row (GtkCellView *cell_view,  GtkTreePath *path);
257 		gtk_cell_view_set_displayed_row(gtkCellView, (path is null) ? null : path.getTreePathStruct());
258 	}
259 	
260 	/**
261 	 * Returns a GtkTreePath referring to the currently
262 	 * displayed row. If no row is currently displayed,
263 	 * NULL is returned.
264 	 * Since 2.6
265 	 * Returns: the currently displayed row or NULL
266 	 */
267 	public TreePath getDisplayedRow()
268 	{
269 		// GtkTreePath * gtk_cell_view_get_displayed_row (GtkCellView *cell_view);
270 		auto p = gtk_cell_view_get_displayed_row(gtkCellView);
271 		
272 		if(p is null)
273 		{
274 			return null;
275 		}
276 		
277 		return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p);
278 	}
279 	
280 	/**
281 	 * Sets requisition to the size needed by cell_view to display
282 	 * the model row pointed to by path.
283 	 * Since 2.6
284 	 * Params:
285 	 * path = a GtkTreePath
286 	 * requisition = return location for the size. [out]
287 	 * Returns: TRUE
288 	 */
289 	public int getSizeOfRow(TreePath path, out GtkRequisition requisition)
290 	{
291 		// gboolean gtk_cell_view_get_size_of_row (GtkCellView *cell_view,  GtkTreePath *path,  GtkRequisition *requisition);
292 		return gtk_cell_view_get_size_of_row(gtkCellView, (path is null) ? null : path.getTreePathStruct(), &requisition);
293 	}
294 	
295 	/**
296 	 * Sets the background color of view.
297 	 * Since 2.6
298 	 * Params:
299 	 * color = the new background color
300 	 */
301 	public void setBackgroundColor(Color color)
302 	{
303 		// void gtk_cell_view_set_background_color (GtkCellView *cell_view,  const GdkColor *color);
304 		gtk_cell_view_set_background_color(gtkCellView, (color is null) ? null : color.getColorStruct());
305 	}
306 	
307 	/**
308 	 * Warning
309 	 * gtk_cell_view_get_cell_renderers has been deprecated since version 2.18 and should not be used in newly-written code. use gtk_cell_layout_get_cells() instead.
310 	 * Returns the cell renderers which have been added to cell_view.
311 	 * Since 2.6
312 	 * 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.
313 	 */
314 	public ListG getCellRenderers()
315 	{
316 		// GList * gtk_cell_view_get_cell_renderers (GtkCellView *cell_view);
317 		auto p = gtk_cell_view_get_cell_renderers(gtkCellView);
318 		
319 		if(p is null)
320 		{
321 			return null;
322 		}
323 		
324 		return ObjectG.getDObject!(ListG)(cast(GList*) p);
325 	}
326 }