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 = GtkCellRenderer.html 27 * outPack = gtk 28 * outFile = CellRenderer 29 * strct = GtkCellRenderer 30 * realStrct= 31 * ctorStrct= 32 * clss = CellRenderer 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_cell_renderer_ 41 * - gtk_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gtk.Widget 49 * - gdk.Rectangle 50 * - gdk.Window 51 * - gdk.Event 52 * - gtk.CellEditable 53 * - gtk.CellEditableIF 54 * structWrap: 55 * - GdkEvent* -> Event 56 * - GdkRectangle* -> Rectangle 57 * - GdkWindow* -> Window 58 * - GtkCellEditable* -> CellEditableIF 59 * - GtkWidget* -> Widget 60 * module aliases: 61 * local aliases: 62 * overrides: 63 */ 64 65 module gtk.CellRenderer; 66 67 public import gtkc.gtktypes; 68 69 private import gtkc.gtk; 70 private import glib.ConstructionException; 71 private import gobject.ObjectG; 72 73 private import gobject.Signals; 74 public import gtkc.gdktypes; 75 76 private import glib.Str; 77 private import gtk.Widget; 78 private import gdk.Rectangle; 79 private import gdk.Window; 80 private import gdk.Event; 81 private import gtk.CellEditable; 82 private import gtk.CellEditableIF; 83 84 85 86 private import gtk.ObjectGtk; 87 88 /** 89 * Description 90 * The GtkCellRenderer is a base class of a set of objects used for 91 * rendering a cell to a GdkDrawable. These objects are used primarily by 92 * the GtkTreeView widget, though they aren't tied to them in any 93 * specific way. It is worth noting that GtkCellRenderer is not a 94 * GtkWidget and cannot be treated as such. 95 * The primary use of a GtkCellRenderer is for drawing a certain graphical 96 * elements on a GdkDrawable. Typically, one cell renderer is used to 97 * draw many cells on the screen. To this extent, it isn't expected that a 98 * CellRenderer keep any permanent state around. Instead, any state is set 99 * just prior to use using GObjects property system. Then, the 100 * cell is measured using gtk_cell_renderer_get_size(). Finally, the cell 101 * is rendered in the correct location using gtk_cell_renderer_render(). 102 * There are a number of rules that must be followed when writing a new 103 * GtkCellRenderer. First and formost, it's important that a certain set 104 * of properties will always yield a cell renderer of the same size, 105 * barring a GtkStyle change. The GtkCellRenderer also has a number of 106 * generic properties that are expected to be honored by all children. 107 * Beyond merely rendering a cell, cell renderers can optionally 108 * provide active user interface elements. A cell renderer can be 109 * activatable like GtkCellRendererToggle, 110 * which toggles when it gets activated by a mouse click, or it can be 111 * editable like GtkCellRendererText, which 112 * allows the user to edit the text using a GtkEntry. 113 * To make a cell renderer activatable or editable, you have to 114 * implement the activate or start_editing virtual functions, 115 * respectively. 116 */ 117 public class CellRenderer : ObjectGtk 118 { 119 120 /** the main Gtk struct */ 121 protected GtkCellRenderer* gtkCellRenderer; 122 123 124 public GtkCellRenderer* getCellRendererStruct() 125 { 126 return gtkCellRenderer; 127 } 128 129 130 /** the main Gtk struct as a void* */ 131 protected override void* getStruct() 132 { 133 return cast(void*)gtkCellRenderer; 134 } 135 136 /** 137 * Sets our main struct and passes it to the parent class 138 */ 139 public this (GtkCellRenderer* gtkCellRenderer) 140 { 141 super(cast(GtkObject*)gtkCellRenderer); 142 this.gtkCellRenderer = gtkCellRenderer; 143 } 144 145 protected override void setStruct(GObject* obj) 146 { 147 super.setStruct(obj); 148 gtkCellRenderer = cast(GtkCellRenderer*)obj; 149 } 150 151 /** 152 */ 153 int[string] connectedSignals; 154 155 void delegate(CellRenderer)[] onEditingCanceledListeners; 156 /** 157 * This signal gets emitted when the user cancels the process of editing a 158 * cell. For example, an editable cell renderer could be written to cancel 159 * editing when the user presses Escape. 160 * See also: gtk_cell_renderer_stop_editing(). 161 * Since 2.4 162 */ 163 void addOnEditingCanceled(void delegate(CellRenderer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 164 { 165 if ( !("editing-canceled" in connectedSignals) ) 166 { 167 Signals.connectData( 168 getStruct(), 169 "editing-canceled", 170 cast(GCallback)&callBackEditingCanceled, 171 cast(void*)this, 172 null, 173 connectFlags); 174 connectedSignals["editing-canceled"] = 1; 175 } 176 onEditingCanceledListeners ~= dlg; 177 } 178 extern(C) static void callBackEditingCanceled(GtkCellRenderer* rendererStruct, CellRenderer _cellRenderer) 179 { 180 foreach ( void delegate(CellRenderer) dlg ; _cellRenderer.onEditingCanceledListeners ) 181 { 182 dlg(_cellRenderer); 183 } 184 } 185 186 void delegate(CellEditableIF, string, CellRenderer)[] onEditingStartedListeners; 187 /** 188 * This signal gets emitted when a cell starts to be edited. 189 * The intended use of this signal is to do special setup 190 * on editable, e.g. adding a GtkEntryCompletion or setting 191 * up additional columns in a GtkComboBox. 192 * Note that GTK+ doesn't guarantee that cell renderers will 193 * continue to use the same kind of widget for editing in future 194 * releases, therefore you should check the type of editable 195 * $(DDOC_COMMENT example) 196 * Since 2.6 197 * See Also 198 * GtkCellRendererText,GtkCellRendererPixbuf,GtkCellRendererToggle 199 */ 200 void addOnEditingStarted(void delegate(CellEditableIF, string, CellRenderer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 201 { 202 if ( !("editing-started" in connectedSignals) ) 203 { 204 Signals.connectData( 205 getStruct(), 206 "editing-started", 207 cast(GCallback)&callBackEditingStarted, 208 cast(void*)this, 209 null, 210 connectFlags); 211 connectedSignals["editing-started"] = 1; 212 } 213 onEditingStartedListeners ~= dlg; 214 } 215 extern(C) static void callBackEditingStarted(GtkCellRenderer* rendererStruct, GtkCellEditable* editable, gchar* path, CellRenderer _cellRenderer) 216 { 217 foreach ( void delegate(CellEditableIF, string, CellRenderer) dlg ; _cellRenderer.onEditingStartedListeners ) 218 { 219 dlg(ObjectG.getDObject!(CellEditable, CellEditableIF)(editable), Str.toString(path), _cellRenderer); 220 } 221 } 222 223 224 /** 225 * Obtains the width and height needed to render the cell. Used by view 226 * widgets to determine the appropriate size for the cell_area passed to 227 * gtk_cell_renderer_render(). If cell_area is not NULL, fills in the 228 * x and y offsets (if set) of the cell relative to this location. 229 * Please note that the values set in width and height, as well as those 230 * in x_offset and y_offset are inclusive of the xpad and ypad properties. 231 * Params: 232 * cell = a GtkCellRenderer 233 * widget = the widget the renderer is rendering to 234 * cellArea = The area a cell will be allocated, or NULL. [allow-none] 235 * xOffset = location to return x offset of cell relative to cell_area, or NULL. [out][allow-none] 236 * yOffset = location to return y offset of cell relative to cell_area, or NULL. [out][allow-none] 237 * width = location to return width needed to render a cell, or NULL. [out][allow-none] 238 * height = location to return height needed to render a cell, or NULL. [out][allow-none] 239 */ 240 public void getSize(Widget widget, Rectangle cellArea, out int xOffset, out int yOffset, out int width, out int height) 241 { 242 // void gtk_cell_renderer_get_size (GtkCellRenderer *cell, GtkWidget *widget, const GdkRectangle *cell_area, gint *x_offset, gint *y_offset, gint *width, gint *height); 243 gtk_cell_renderer_get_size(gtkCellRenderer, (widget is null) ? null : widget.getWidgetStruct(), (cellArea is null) ? null : cellArea.getRectangleStruct(), &xOffset, &yOffset, &width, &height); 244 } 245 246 /** 247 * Invokes the virtual render function of the GtkCellRenderer. The three 248 * passed-in rectangles are areas of window. Most renderers will draw within 249 * cell_area; the xalign, yalign, xpad, and ypad fields of the GtkCellRenderer 250 * should be honored with respect to cell_area. background_area includes the 251 * blank space around the cell, and also the area containing the tree expander; 252 * so the background_area rectangles for all cells tile to cover the entire 253 * window. expose_area is a clip rectangle. 254 * Params: 255 * cell = a GtkCellRenderer 256 * window = a GdkDrawable to draw to 257 * widget = the widget owning window 258 * backgroundArea = entire cell area (including tree expanders and maybe 259 * padding on the sides) 260 * cellArea = area normally rendered by a cell renderer 261 * exposeArea = area that actually needs updating 262 * flags = flags that affect rendering 263 */ 264 public void render(Window window, Widget widget, Rectangle backgroundArea, Rectangle cellArea, Rectangle exposeArea, GtkCellRendererState flags) 265 { 266 // void gtk_cell_renderer_render (GtkCellRenderer *cell, GdkWindow *window, GtkWidget *widget, const GdkRectangle *background_area, const GdkRectangle *cell_area, const GdkRectangle *expose_area, GtkCellRendererState flags); 267 gtk_cell_renderer_render(gtkCellRenderer, (window is null) ? null : window.getWindowStruct(), (widget is null) ? null : widget.getWidgetStruct(), (backgroundArea is null) ? null : backgroundArea.getRectangleStruct(), (cellArea is null) ? null : cellArea.getRectangleStruct(), (exposeArea is null) ? null : exposeArea.getRectangleStruct(), flags); 268 } 269 270 /** 271 * Passes an activate event to the cell renderer for possible processing. 272 * Some cell renderers may use events; for example, GtkCellRendererToggle 273 * toggles when it gets a mouse click. 274 * Params: 275 * cell = a GtkCellRenderer 276 * event = a GdkEvent 277 * widget = widget that received the event 278 * path = widget-dependent string representation of the event location; 279 * e.g. for GtkTreeView, a string representation of GtkTreePath 280 * backgroundArea = background area as passed to gtk_cell_renderer_render() 281 * cellArea = cell area as passed to gtk_cell_renderer_render() 282 * flags = render flags 283 * Returns: TRUE if the event was consumed/handled 284 */ 285 public int activate(Event event, Widget widget, string path, Rectangle backgroundArea, Rectangle cellArea, GtkCellRendererState flags) 286 { 287 // gboolean gtk_cell_renderer_activate (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, const GdkRectangle *background_area, const GdkRectangle *cell_area, GtkCellRendererState flags); 288 return gtk_cell_renderer_activate(gtkCellRenderer, (event is null) ? null : event.getEventStruct(), (widget is null) ? null : widget.getWidgetStruct(), Str.toStringz(path), (backgroundArea is null) ? null : backgroundArea.getRectangleStruct(), (cellArea is null) ? null : cellArea.getRectangleStruct(), flags); 289 } 290 291 /** 292 * Passes an activate event to the cell renderer for possible processing. 293 * Params: 294 * cell = a GtkCellRenderer 295 * event = a GdkEvent 296 * widget = widget that received the event 297 * path = widget-dependent string representation of the event location; 298 * e.g. for GtkTreeView, a string representation of GtkTreePath 299 * backgroundArea = background area as passed to gtk_cell_renderer_render() 300 * cellArea = cell area as passed to gtk_cell_renderer_render() 301 * flags = render flags 302 * Returns: A new GtkCellEditable, or NULL. [transfer none] 303 */ 304 public CellEditableIF startEditing(Event event, Widget widget, string path, Rectangle backgroundArea, Rectangle cellArea, GtkCellRendererState flags) 305 { 306 // GtkCellEditable * gtk_cell_renderer_start_editing (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, const GdkRectangle *background_area, const GdkRectangle *cell_area, GtkCellRendererState flags); 307 auto p = gtk_cell_renderer_start_editing(gtkCellRenderer, (event is null) ? null : event.getEventStruct(), (widget is null) ? null : widget.getWidgetStruct(), Str.toStringz(path), (backgroundArea is null) ? null : backgroundArea.getRectangleStruct(), (cellArea is null) ? null : cellArea.getRectangleStruct(), flags); 308 309 if(p is null) 310 { 311 return null; 312 } 313 314 return ObjectG.getDObject!(CellEditable, CellEditableIF)(cast(GtkCellEditable*) p); 315 } 316 317 /** 318 * Warning 319 * gtk_cell_renderer_editing_canceled has been deprecated since version 2.6 and should not be used in newly-written code. Use gtk_cell_renderer_stop_editing() instead 320 * Causes the cell renderer to emit the "editing-canceled" 321 * signal. 322 * This function is for use only by implementations of cell renderers that 323 * need to notify the client program that an editing process was canceled 324 * and the changes were not committed. 325 * Since 2.4 326 */ 327 public void editingCanceled() 328 { 329 // void gtk_cell_renderer_editing_canceled (GtkCellRenderer *cell); 330 gtk_cell_renderer_editing_canceled(gtkCellRenderer); 331 } 332 333 /** 334 * Informs the cell renderer that the editing is stopped. 335 * If canceled is TRUE, the cell renderer will emit the 336 * "editing-canceled" signal. 337 * This function should be called by cell renderer implementations 338 * in response to the "editing-done" signal of 339 * GtkCellEditable. 340 * Since 2.6 341 * Params: 342 * canceled = TRUE if the editing has been canceled 343 */ 344 public void stopEditing(int canceled) 345 { 346 // void gtk_cell_renderer_stop_editing (GtkCellRenderer *cell, gboolean canceled); 347 gtk_cell_renderer_stop_editing(gtkCellRenderer, canceled); 348 } 349 350 /** 351 * Fills in width and height with the appropriate size of cell. 352 * Params: 353 * width = location to fill in with the fixed width of the cell, or NULL. [out][allow-none] 354 * height = location to fill in with the fixed height of the cell, or NULL. [out][allow-none] 355 */ 356 public void getFixedSize(out int width, out int height) 357 { 358 // void gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell, gint *width, gint *height); 359 gtk_cell_renderer_get_fixed_size(gtkCellRenderer, &width, &height); 360 } 361 362 /** 363 * Sets the renderer size to be explicit, independent of the properties set. 364 * Params: 365 * width = the width of the cell renderer, or -1 366 * height = the height of the cell renderer, or -1 367 */ 368 public void setFixedSize(int width, int height) 369 { 370 // void gtk_cell_renderer_set_fixed_size (GtkCellRenderer *cell, gint width, gint height); 371 gtk_cell_renderer_set_fixed_size(gtkCellRenderer, width, height); 372 } 373 374 /** 375 * Returns the cell renderer's visibility. 376 * Since 2.18 377 * Returns: TRUE if the cell renderer is visible 378 */ 379 public int getVisible() 380 { 381 // gboolean gtk_cell_renderer_get_visible (GtkCellRenderer *cell); 382 return gtk_cell_renderer_get_visible(gtkCellRenderer); 383 } 384 385 /** 386 * Sets the cell renderer's visibility. 387 * Since 2.18 388 * Params: 389 * visible = the visibility of the cell 390 */ 391 public void setVisible(int visible) 392 { 393 // void gtk_cell_renderer_set_visible (GtkCellRenderer *cell, gboolean visible); 394 gtk_cell_renderer_set_visible(gtkCellRenderer, visible); 395 } 396 397 /** 398 * Returns the cell renderer's sensitivity. 399 * Since 2.18 400 * Returns: TRUE if the cell renderer is sensitive 401 */ 402 public int getSensitive() 403 { 404 // gboolean gtk_cell_renderer_get_sensitive (GtkCellRenderer *cell); 405 return gtk_cell_renderer_get_sensitive(gtkCellRenderer); 406 } 407 408 /** 409 * Sets the cell renderer's sensitivity. 410 * Since 2.18 411 * Params: 412 * sensitive = the sensitivity of the cell 413 */ 414 public void setSensitive(int sensitive) 415 { 416 // void gtk_cell_renderer_set_sensitive (GtkCellRenderer *cell, gboolean sensitive); 417 gtk_cell_renderer_set_sensitive(gtkCellRenderer, sensitive); 418 } 419 420 /** 421 * Fills in xalign and yalign with the appropriate values of cell. 422 * Since 2.18 423 * Params: 424 * xalign = location to fill in with the x alignment of the cell, or NULL. [out][allow-none] 425 * yalign = location to fill in with the y alignment of the cell, or NULL. [out][allow-none] 426 */ 427 public void getAlignment(out float xalign, out float yalign) 428 { 429 // void gtk_cell_renderer_get_alignment (GtkCellRenderer *cell, gfloat *xalign, gfloat *yalign); 430 gtk_cell_renderer_get_alignment(gtkCellRenderer, &xalign, &yalign); 431 } 432 433 /** 434 * Sets the renderer's alignment within its available space. 435 * Since 2.18 436 * Params: 437 * xalign = the x alignment of the cell renderer 438 * yalign = the y alignment of the cell renderer 439 */ 440 public void setAlignment(float xalign, float yalign) 441 { 442 // void gtk_cell_renderer_set_alignment (GtkCellRenderer *cell, gfloat xalign, gfloat yalign); 443 gtk_cell_renderer_set_alignment(gtkCellRenderer, xalign, yalign); 444 } 445 446 /** 447 * Fills in xpad and ypad with the appropriate values of cell. 448 * Since 2.18 449 * Params: 450 * xpad = location to fill in with the x padding of the cell, or NULL. [out][allow-none] 451 * ypad = location to fill in with the y padding of the cell, or NULL. [out][allow-none] 452 */ 453 public void getPadding(out int xpad, out int ypad) 454 { 455 // void gtk_cell_renderer_get_padding (GtkCellRenderer *cell, gint *xpad, gint *ypad); 456 gtk_cell_renderer_get_padding(gtkCellRenderer, &xpad, &ypad); 457 } 458 459 /** 460 * Sets the renderer's padding. 461 * Since 2.18 462 * Params: 463 * xpad = the x padding of the cell renderer 464 * ypad = the y padding of the cell renderer 465 */ 466 public void setPadding(int xpad, int ypad) 467 { 468 // void gtk_cell_renderer_set_padding (GtkCellRenderer *cell, gint xpad, gint ypad); 469 gtk_cell_renderer_set_padding(gtkCellRenderer, xpad, ypad); 470 } 471 }