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 public static GType getType() 139 { 140 return gtk_cell_view_get_type(); 141 } 142 143 /** 144 * Creates a new #GtkCellView widget. 145 * 146 * Return: A newly created #GtkCellView widget. 147 * 148 * Since: 2.6 149 * 150 * Throws: ConstructionException GTK+ fails to create the object. 151 */ 152 public this() 153 { 154 auto p = gtk_cell_view_new(); 155 156 if(p is null) 157 { 158 throw new ConstructionException("null returned by new"); 159 } 160 161 this(cast(GtkCellView*) p); 162 } 163 164 /** 165 * Creates a new #GtkCellView widget with a specific #GtkCellArea 166 * to layout cells and a specific #GtkCellAreaContext. 167 * 168 * Specifying the same context for a handfull of cells lets 169 * the underlying area synchronize the geometry for those cells, 170 * in this way alignments with cellviews for other rows are 171 * possible. 172 * 173 * Params: 174 * area = the #GtkCellArea to layout cells 175 * context = the #GtkCellAreaContext in which to calculate cell geometry 176 * 177 * Return: A newly created #GtkCellView widget. 178 * 179 * Since: 2.6 180 * 181 * Throws: ConstructionException GTK+ fails to create the object. 182 */ 183 public this(CellArea area, CellAreaContext context) 184 { 185 auto p = gtk_cell_view_new_with_context((area is null) ? null : area.getCellAreaStruct(), (context is null) ? null : context.getCellAreaContextStruct()); 186 187 if(p is null) 188 { 189 throw new ConstructionException("null returned by new_with_context"); 190 } 191 192 this(cast(GtkCellView*) p); 193 } 194 195 /** 196 * Creates a new #GtkCellView widget, adds a #GtkCellRendererPixbuf 197 * to it, and makes it show @pixbuf. 198 * 199 * Params: 200 * pixbuf = the image to display in the cell view 201 * 202 * Return: A newly created #GtkCellView widget. 203 * 204 * Since: 2.6 205 * 206 * Throws: ConstructionException GTK+ fails to create the object. 207 */ 208 public this(Pixbuf pixbuf) 209 { 210 auto p = gtk_cell_view_new_with_pixbuf((pixbuf is null) ? null : pixbuf.getPixbufStruct()); 211 212 if(p is null) 213 { 214 throw new ConstructionException("null returned by new_with_pixbuf"); 215 } 216 217 this(cast(GtkCellView*) p); 218 } 219 220 /** 221 * Returns a #GtkTreePath referring to the currently 222 * displayed row. If no row is currently displayed, 223 * %NULL is returned. 224 * 225 * Return: the currently displayed row or %NULL 226 * 227 * Since: 2.6 228 */ 229 public TreePath getDisplayedRow() 230 { 231 auto p = gtk_cell_view_get_displayed_row(gtkCellView); 232 233 if(p is null) 234 { 235 return null; 236 } 237 238 return ObjectG.getDObject!(TreePath)(cast(GtkTreePath*) p); 239 } 240 241 /** 242 * Gets whether @cell_view is configured to draw all of its 243 * cells in a sensitive state. 244 * 245 * Return: whether @cell_view draws all of its 246 * cells in a sensitive state 247 * 248 * Since: 3.0 249 */ 250 public bool getDrawSensitive() 251 { 252 return gtk_cell_view_get_draw_sensitive(gtkCellView) != 0; 253 } 254 255 /** 256 * Gets whether @cell_view is configured to request space 257 * to fit the entire #GtkTreeModel. 258 * 259 * Return: whether @cell_view requests space to fit 260 * the entire #GtkTreeModel. 261 * 262 * Since: 3.0 263 */ 264 public bool getFitModel() 265 { 266 return gtk_cell_view_get_fit_model(gtkCellView) != 0; 267 } 268 269 /** 270 * Returns the model for @cell_view. If no model is used %NULL is 271 * returned. 272 * 273 * Return: a #GtkTreeModel used or %NULL 274 * 275 * Since: 2.16 276 */ 277 public TreeModelIF getModel() 278 { 279 auto p = gtk_cell_view_get_model(gtkCellView); 280 281 if(p is null) 282 { 283 return null; 284 } 285 286 return ObjectG.getDObject!(TreeModel, TreeModelIF)(cast(GtkTreeModel*) p); 287 } 288 289 /** 290 * Sets @requisition to the size needed by @cell_view to display 291 * the model row pointed to by @path. 292 * 293 * Deprecated: Combo box formerly used this to calculate the 294 * sizes for cellviews, now you can achieve this by either using 295 * the #GtkCellView:fit-model property or by setting the currently 296 * displayed row of the #GtkCellView and using gtk_widget_get_preferred_size(). 297 * 298 * Params: 299 * path = a #GtkTreePath 300 * requisition = return location for the size 301 * 302 * Return: %TRUE 303 * 304 * Since: 2.6 305 */ 306 public bool getSizeOfRow(TreePath path, out Requisition requisition) 307 { 308 GtkRequisition* outrequisition = new GtkRequisition; 309 310 auto p = gtk_cell_view_get_size_of_row(gtkCellView, (path is null) ? null : path.getTreePathStruct(), outrequisition) != 0; 311 312 requisition = ObjectG.getDObject!(Requisition)(outrequisition); 313 314 return p; 315 } 316 317 /** 318 * Sets the background color of @view. 319 * 320 * Deprecated: Use gtk_cell_view_set_background_rgba() instead. 321 * 322 * Params: 323 * color = the new background color 324 * 325 * Since: 2.6 326 */ 327 public void setBackgroundColor(Color color) 328 { 329 gtk_cell_view_set_background_color(gtkCellView, (color is null) ? null : color.getColorStruct()); 330 } 331 332 /** 333 * Sets the background color of @cell_view. 334 * 335 * Params: 336 * rgba = the new background color 337 * 338 * Since: 3.0 339 */ 340 public void setBackgroundRgba(RGBA rgba) 341 { 342 gtk_cell_view_set_background_rgba(gtkCellView, (rgba is null) ? null : rgba.getRGBAStruct()); 343 } 344 345 /** 346 * Sets the row of the model that is currently displayed 347 * by the #GtkCellView. If the path is unset, then the 348 * contents of the cellview “stick” at their last value; 349 * this is not normally a desired result, but may be 350 * a needed intermediate state if say, the model for 351 * the #GtkCellView becomes temporarily empty. 352 * 353 * Params: 354 * path = a #GtkTreePath or %NULL to unset. 355 * 356 * Since: 2.6 357 */ 358 public void setDisplayedRow(TreePath path) 359 { 360 gtk_cell_view_set_displayed_row(gtkCellView, (path is null) ? null : path.getTreePathStruct()); 361 } 362 363 /** 364 * Sets whether @cell_view should draw all of its 365 * cells in a sensitive state, this is used by #GtkComboBox menus 366 * to ensure that rows with insensitive cells that contain 367 * children appear sensitive in the parent menu item. 368 * 369 * Params: 370 * drawSensitive = whether to draw all cells in a sensitive state. 371 * 372 * Since: 3.0 373 */ 374 public void setDrawSensitive(bool drawSensitive) 375 { 376 gtk_cell_view_set_draw_sensitive(gtkCellView, drawSensitive); 377 } 378 379 /** 380 * Sets whether @cell_view should request space to fit the entire #GtkTreeModel. 381 * 382 * This is used by #GtkComboBox to ensure that the cell view displayed on 383 * the combo box’s button always gets enough space and does not resize 384 * when selection changes. 385 * 386 * Params: 387 * fitModel = whether @cell_view should request space for the whole model. 388 * 389 * Since: 3.0 390 */ 391 public void setFitModel(bool fitModel) 392 { 393 gtk_cell_view_set_fit_model(gtkCellView, fitModel); 394 } 395 396 /** 397 * Sets the model for @cell_view. If @cell_view already has a model 398 * set, it will remove it before setting the new model. If @model is 399 * %NULL, then it will unset the old model. 400 * 401 * Params: 402 * model = a #GtkTreeModel 403 * 404 * Since: 2.6 405 */ 406 public void setModel(TreeModelIF model) 407 { 408 gtk_cell_view_set_model(gtkCellView, (model is null) ? null : model.getTreeModelStruct()); 409 } 410 }