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