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