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.CellArea; 26 27 private import cairo.Context; 28 private import gdk.Event; 29 private import glib.ListG; 30 private import glib.Str; 31 private import gobject.ObjectG; 32 private import gobject.Signals; 33 private import gobject.Value; 34 private import gtk.BuildableIF; 35 private import gtk.BuildableT; 36 private import gtk.CellAreaContext; 37 private import gtk.CellEditable; 38 private import gtk.CellEditableIF; 39 private import gtk.CellLayoutIF; 40 private import gtk.CellLayoutT; 41 private import gtk.CellRenderer; 42 private import gtk.TreeIter; 43 private import gtk.TreeModel; 44 private import gtk.TreeModelIF; 45 private import gtk.Widget; 46 private import gtkc.gtk; 47 public import gtkc.gtktypes; 48 private import std.algorithm; 49 50 51 /** 52 * The #GtkCellArea is an abstract class for #GtkCellLayout widgets 53 * (also referred to as "layouting widgets") to interface with an 54 * arbitrary number of #GtkCellRenderers and interact with the user 55 * for a given #GtkTreeModel row. 56 * 57 * The cell area handles events, focus navigation, drawing and 58 * size requests and allocations for a given row of data. 59 * 60 * Usually users dont have to interact with the #GtkCellArea directly 61 * unless they are implementing a cell-layouting widget themselves. 62 * 63 * # Requesting area sizes 64 * 65 * As outlined in 66 * [GtkWidget’s geometry management section][geometry-management], 67 * GTK+ uses a height-for-width 68 * geometry management system to compute the sizes of widgets and user 69 * interfaces. #GtkCellArea uses the same semantics to calculate the 70 * size of an area for an arbitrary number of #GtkTreeModel rows. 71 * 72 * When requesting the size of a cell area one needs to calculate 73 * the size for a handful of rows, and this will be done differently by 74 * different layouting widgets. For instance a #GtkTreeViewColumn 75 * always lines up the areas from top to bottom while a #GtkIconView 76 * on the other hand might enforce that all areas received the same 77 * width and wrap the areas around, requesting height for more cell 78 * areas when allocated less width. 79 * 80 * It’s also important for areas to maintain some cell 81 * alignments with areas rendered for adjacent rows (cells can 82 * appear “columnized” inside an area even when the size of 83 * cells are different in each row). For this reason the #GtkCellArea 84 * uses a #GtkCellAreaContext object to store the alignments 85 * and sizes along the way (as well as the overall largest minimum 86 * and natural size for all the rows which have been calculated 87 * with the said context). 88 * 89 * The #GtkCellAreaContext is an opaque object specific to the 90 * #GtkCellArea which created it (see gtk_cell_area_create_context()). 91 * The owning cell-layouting widget can create as many contexts as 92 * it wishes to calculate sizes of rows which should receive the 93 * same size in at least one orientation (horizontally or vertically), 94 * However, it’s important that the same #GtkCellAreaContext which 95 * was used to request the sizes for a given #GtkTreeModel row be 96 * used when rendering or processing events for that row. 97 * 98 * In order to request the width of all the rows at the root level 99 * of a #GtkTreeModel one would do the following: 100 * 101 * |[<!-- language="C" --> 102 * GtkTreeIter iter; 103 * gint minimum_width; 104 * gint natural_width; 105 * 106 * valid = gtk_tree_model_get_iter_first (model, &iter); 107 * while (valid) 108 * { 109 * gtk_cell_area_apply_attributes (area, model, &iter, FALSE, FALSE); 110 * gtk_cell_area_get_preferred_width (area, context, widget, NULL, NULL); 111 * 112 * valid = gtk_tree_model_iter_next (model, &iter); 113 * } 114 * gtk_cell_area_context_get_preferred_width (context, &minimum_width, &natural_width); 115 * ]| 116 * 117 * Note that in this example it’s not important to observe the 118 * returned minimum and natural width of the area for each row 119 * unless the cell-layouting object is actually interested in the 120 * widths of individual rows. The overall width is however stored 121 * in the accompanying #GtkCellAreaContext object and can be consulted 122 * at any time. 123 * 124 * This can be useful since #GtkCellLayout widgets usually have to 125 * support requesting and rendering rows in treemodels with an 126 * exceedingly large amount of rows. The #GtkCellLayout widget in 127 * that case would calculate the required width of the rows in an 128 * idle or timeout source (see g_timeout_add()) and when the widget 129 * is requested its actual width in #GtkWidgetClass.get_preferred_width() 130 * it can simply consult the width accumulated so far in the 131 * #GtkCellAreaContext object. 132 * 133 * A simple example where rows are rendered from top to bottom and 134 * take up the full width of the layouting widget would look like: 135 * 136 * |[<!-- language="C" --> 137 * static void 138 * foo_get_preferred_width (GtkWidget *widget, 139 * gint *minimum_size, 140 * gint *natural_size) 141 * { 142 * Foo *foo = FOO (widget); 143 * FooPrivate *priv = foo->priv; 144 * 145 * foo_ensure_at_least_one_handfull_of_rows_have_been_requested (foo); 146 * 147 * gtk_cell_area_context_get_preferred_width (priv->context, minimum_size, natural_size); 148 * } 149 * ]| 150 * 151 * In the above example the Foo widget has to make sure that some 152 * row sizes have been calculated (the amount of rows that Foo judged 153 * was appropriate to request space for in a single timeout iteration) 154 * before simply returning the amount of space required by the area via 155 * the #GtkCellAreaContext. 156 * 157 * Requesting the height for width (or width for height) of an area is 158 * a similar task except in this case the #GtkCellAreaContext does not 159 * store the data (actually, it does not know how much space the layouting 160 * widget plans to allocate it for every row. It’s up to the layouting 161 * widget to render each row of data with the appropriate height and 162 * width which was requested by the #GtkCellArea). 163 * 164 * In order to request the height for width of all the rows at the 165 * root level of a #GtkTreeModel one would do the following: 166 * 167 * |[<!-- language="C" --> 168 * GtkTreeIter iter; 169 * gint minimum_height; 170 * gint natural_height; 171 * gint full_minimum_height = 0; 172 * gint full_natural_height = 0; 173 * 174 * valid = gtk_tree_model_get_iter_first (model, &iter); 175 * while (valid) 176 * { 177 * gtk_cell_area_apply_attributes (area, model, &iter, FALSE, FALSE); 178 * gtk_cell_area_get_preferred_height_for_width (area, context, widget, 179 * width, &minimum_height, &natural_height); 180 * 181 * if (width_is_for_allocation) 182 * cache_row_height (&iter, minimum_height, natural_height); 183 * 184 * full_minimum_height += minimum_height; 185 * full_natural_height += natural_height; 186 * 187 * valid = gtk_tree_model_iter_next (model, &iter); 188 * } 189 * ]| 190 * 191 * Note that in the above example we would need to cache the heights 192 * returned for each row so that we would know what sizes to render the 193 * areas for each row. However we would only want to really cache the 194 * heights if the request is intended for the layouting widgets real 195 * allocation. 196 * 197 * In some cases the layouting widget is requested the height for an 198 * arbitrary for_width, this is a special case for layouting widgets 199 * who need to request size for tens of thousands of rows. For this 200 * case it’s only important that the layouting widget calculate 201 * one reasonably sized chunk of rows and return that height 202 * synchronously. The reasoning here is that any layouting widget is 203 * at least capable of synchronously calculating enough height to fill 204 * the screen height (or scrolled window height) in response to a single 205 * call to #GtkWidgetClass.get_preferred_height_for_width(). Returning 206 * a perfect height for width that is larger than the screen area is 207 * inconsequential since after the layouting receives an allocation 208 * from a scrolled window it simply continues to drive the scrollbar 209 * values while more and more height is required for the row heights 210 * that are calculated in the background. 211 * 212 * # Rendering Areas 213 * 214 * Once area sizes have been aquired at least for the rows in the 215 * visible area of the layouting widget they can be rendered at 216 * #GtkWidgetClass.draw() time. 217 * 218 * A crude example of how to render all the rows at the root level 219 * runs as follows: 220 * 221 * |[<!-- language="C" --> 222 * GtkAllocation allocation; 223 * GdkRectangle cell_area = { 0, }; 224 * GtkTreeIter iter; 225 * gint minimum_width; 226 * gint natural_width; 227 * 228 * gtk_widget_get_allocation (widget, &allocation); 229 * cell_area.width = allocation.width; 230 * 231 * valid = gtk_tree_model_get_iter_first (model, &iter); 232 * while (valid) 233 * { 234 * cell_area.height = get_cached_height_for_row (&iter); 235 * 236 * gtk_cell_area_apply_attributes (area, model, &iter, FALSE, FALSE); 237 * gtk_cell_area_render (area, context, widget, cr, 238 * &cell_area, &cell_area, state_flags, FALSE); 239 * 240 * cell_area.y += cell_area.height; 241 * 242 * valid = gtk_tree_model_iter_next (model, &iter); 243 * } 244 * ]| 245 * 246 * Note that the cached height in this example really depends on how 247 * the layouting widget works. The layouting widget might decide to 248 * give every row its minimum or natural height or, if the model content 249 * is expected to fit inside the layouting widget without scrolling, it 250 * would make sense to calculate the allocation for each row at 251 * #GtkWidget::size-allocate time using gtk_distribute_natural_allocation(). 252 * 253 * # Handling Events and Driving Keyboard Focus 254 * 255 * Passing events to the area is as simple as handling events on any 256 * normal widget and then passing them to the gtk_cell_area_event() 257 * API as they come in. Usually #GtkCellArea is only interested in 258 * button events, however some customized derived areas can be implemented 259 * who are interested in handling other events. Handling an event can 260 * trigger the #GtkCellArea::focus-changed signal to fire; as well as 261 * #GtkCellArea::add-editable in the case that an editable cell was 262 * clicked and needs to start editing. You can call 263 * gtk_cell_area_stop_editing() at any time to cancel any cell editing 264 * that is currently in progress. 265 * 266 * The #GtkCellArea drives keyboard focus from cell to cell in a way 267 * similar to #GtkWidget. For layouting widgets that support giving 268 * focus to cells it’s important to remember to pass %GTK_CELL_RENDERER_FOCUSED 269 * to the area functions for the row that has focus and to tell the 270 * area to paint the focus at render time. 271 * 272 * Layouting widgets that accept focus on cells should implement the 273 * #GtkWidgetClass.focus() virtual method. The layouting widget is always 274 * responsible for knowing where #GtkTreeModel rows are rendered inside 275 * the widget, so at #GtkWidgetClass.focus() time the layouting widget 276 * should use the #GtkCellArea methods to navigate focus inside the area 277 * and then observe the GtkDirectionType to pass the focus to adjacent 278 * rows and areas. 279 * 280 * A basic example of how the #GtkWidgetClass.focus() virtual method 281 * should be implemented: 282 * 283 * |[<!-- language="C" --> 284 * static gboolean 285 * foo_focus (GtkWidget *widget, 286 * GtkDirectionType direction) 287 * { 288 * Foo *foo = FOO (widget); 289 * FooPrivate *priv = foo->priv; 290 * gint focus_row; 291 * gboolean have_focus = FALSE; 292 * 293 * focus_row = priv->focus_row; 294 * 295 * if (!gtk_widget_has_focus (widget)) 296 * gtk_widget_grab_focus (widget); 297 * 298 * valid = gtk_tree_model_iter_nth_child (priv->model, &iter, NULL, priv->focus_row); 299 * while (valid) 300 * { 301 * gtk_cell_area_apply_attributes (priv->area, priv->model, &iter, FALSE, FALSE); 302 * 303 * if (gtk_cell_area_focus (priv->area, direction)) 304 * { 305 * priv->focus_row = focus_row; 306 * have_focus = TRUE; 307 * break; 308 * } 309 * else 310 * { 311 * if (direction == GTK_DIR_RIGHT || 312 * direction == GTK_DIR_LEFT) 313 * break; 314 * else if (direction == GTK_DIR_UP || 315 * direction == GTK_DIR_TAB_BACKWARD) 316 * { 317 * if (focus_row == 0) 318 * break; 319 * else 320 * { 321 * focus_row--; 322 * valid = gtk_tree_model_iter_nth_child (priv->model, &iter, NULL, focus_row); 323 * } 324 * } 325 * else 326 * { 327 * if (focus_row == last_row) 328 * break; 329 * else 330 * { 331 * focus_row++; 332 * valid = gtk_tree_model_iter_next (priv->model, &iter); 333 * } 334 * } 335 * } 336 * } 337 * return have_focus; 338 * } 339 * ]| 340 * 341 * Note that the layouting widget is responsible for matching the 342 * GtkDirectionType values to the way it lays out its cells. 343 * 344 * # Cell Properties 345 * 346 * The #GtkCellArea introduces cell properties for #GtkCellRenderers 347 * in very much the same way that #GtkContainer introduces 348 * [child properties][child-properties] 349 * for #GtkWidgets. This provides some general interfaces for defining 350 * the relationship cell areas have with their cells. For instance in a 351 * #GtkCellAreaBox a cell might “expand” and receive extra space when 352 * the area is allocated more than its full natural request, or a cell 353 * might be configured to “align” with adjacent rows which were requested 354 * and rendered with the same #GtkCellAreaContext. 355 * 356 * Use gtk_cell_area_class_install_cell_property() to install cell 357 * properties for a cell area class and gtk_cell_area_class_find_cell_property() 358 * or gtk_cell_area_class_list_cell_properties() to get information about 359 * existing cell properties. 360 * 361 * To set the value of a cell property, use gtk_cell_area_cell_set_property(), 362 * gtk_cell_area_cell_set() or gtk_cell_area_cell_set_valist(). To obtain 363 * the value of a cell property, use gtk_cell_area_cell_get_property(), 364 * gtk_cell_area_cell_get() or gtk_cell_area_cell_get_valist(). 365 */ 366 public class CellArea : ObjectG, BuildableIF, CellLayoutIF 367 { 368 /** the main Gtk struct */ 369 protected GtkCellArea* gtkCellArea; 370 371 /** Get the main Gtk struct */ 372 public GtkCellArea* getCellAreaStruct(bool transferOwnership = false) 373 { 374 if (transferOwnership) 375 ownedRef = false; 376 return gtkCellArea; 377 } 378 379 /** the main Gtk struct as a void* */ 380 protected override void* getStruct() 381 { 382 return cast(void*)gtkCellArea; 383 } 384 385 protected override void setStruct(GObject* obj) 386 { 387 gtkCellArea = cast(GtkCellArea*)obj; 388 super.setStruct(obj); 389 } 390 391 /** 392 * Sets our main struct and passes it to the parent class. 393 */ 394 public this (GtkCellArea* gtkCellArea, bool ownedRef = false) 395 { 396 this.gtkCellArea = gtkCellArea; 397 super(cast(GObject*)gtkCellArea, ownedRef); 398 } 399 400 // add the Buildable capabilities 401 mixin BuildableT!(GtkCellArea); 402 403 // add the CellLayout capabilities 404 mixin CellLayoutT!(GtkCellArea); 405 406 407 /** */ 408 public static GType getType() 409 { 410 return gtk_cell_area_get_type(); 411 } 412 413 /** 414 * Activates @area, usually by activating the currently focused 415 * cell, however some subclasses which embed widgets in the area 416 * can also activate a widget if it currently has the focus. 417 * 418 * Params: 419 * context = the #GtkCellAreaContext in context with the current row data 420 * widget = the #GtkWidget that @area is rendering on 421 * cellArea = the size and location of @area relative to @widget’s allocation 422 * flags = the #GtkCellRendererState flags for @area for this row of data. 423 * editOnly = if %TRUE then only cell renderers that are %GTK_CELL_RENDERER_MODE_EDITABLE 424 * will be activated. 425 * 426 * Returns: Whether @area was successfully activated. 427 * 428 * Since: 3.0 429 */ 430 public bool activate(CellAreaContext context, Widget widget, GdkRectangle* cellArea, GtkCellRendererState flags, bool editOnly) 431 { 432 return gtk_cell_area_activate(gtkCellArea, (context is null) ? null : context.getCellAreaContextStruct(), (widget is null) ? null : widget.getWidgetStruct(), cellArea, flags, editOnly) != 0; 433 } 434 435 /** 436 * This is used by #GtkCellArea subclasses when handling events 437 * to activate cells, the base #GtkCellArea class activates cells 438 * for keyboard events for free in its own GtkCellArea->activate() 439 * implementation. 440 * 441 * Params: 442 * widget = the #GtkWidget that @area is rendering onto 443 * renderer = the #GtkCellRenderer in @area to activate 444 * event = the #GdkEvent for which cell activation should occur 445 * cellArea = the #GdkRectangle in @widget relative coordinates 446 * of @renderer for the current row. 447 * flags = the #GtkCellRendererState for @renderer 448 * 449 * Returns: whether cell activation was successful 450 * 451 * Since: 3.0 452 */ 453 public bool activateCell(Widget widget, CellRenderer renderer, Event event, GdkRectangle* cellArea, GtkCellRendererState flags) 454 { 455 return gtk_cell_area_activate_cell(gtkCellArea, (widget is null) ? null : widget.getWidgetStruct(), (renderer is null) ? null : renderer.getCellRendererStruct(), (event is null) ? null : event.getEventStruct(), cellArea, flags) != 0; 456 } 457 458 /** 459 * Adds @renderer to @area with the default child cell properties. 460 * 461 * Params: 462 * renderer = the #GtkCellRenderer to add to @area 463 * 464 * Since: 3.0 465 */ 466 public void add(CellRenderer renderer) 467 { 468 gtk_cell_area_add(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct()); 469 } 470 471 /** 472 * Adds @sibling to @renderer’s focusable area, focus will be drawn 473 * around @renderer and all of its siblings if @renderer can 474 * focus for a given row. 475 * 476 * Events handled by focus siblings can also activate the given 477 * focusable @renderer. 478 * 479 * Params: 480 * renderer = the #GtkCellRenderer expected to have focus 481 * sibling = the #GtkCellRenderer to add to @renderer’s focus area 482 * 483 * Since: 3.0 484 */ 485 public void addFocusSibling(CellRenderer renderer, CellRenderer sibling) 486 { 487 gtk_cell_area_add_focus_sibling(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct(), (sibling is null) ? null : sibling.getCellRendererStruct()); 488 } 489 490 /** 491 * Applies any connected attributes to the renderers in 492 * @area by pulling the values from @tree_model. 493 * 494 * Params: 495 * treeModel = the #GtkTreeModel to pull values from 496 * iter = the #GtkTreeIter in @tree_model to apply values for 497 * isExpander = whether @iter has children 498 * isExpanded = whether @iter is expanded in the view and 499 * children are visible 500 * 501 * Since: 3.0 502 */ 503 public void applyAttributes(TreeModelIF treeModel, TreeIter iter, bool isExpander, bool isExpanded) 504 { 505 gtk_cell_area_apply_attributes(gtkCellArea, (treeModel is null) ? null : treeModel.getTreeModelStruct(), (iter is null) ? null : iter.getTreeIterStruct(), isExpander, isExpanded); 506 } 507 508 /** 509 * Connects an @attribute to apply values from @column for the 510 * #GtkTreeModel in use. 511 * 512 * Params: 513 * renderer = the #GtkCellRenderer to connect an attribute for 514 * attribute = the attribute name 515 * column = the #GtkTreeModel column to fetch attribute values from 516 * 517 * Since: 3.0 518 */ 519 public void attributeConnect(CellRenderer renderer, string attribute, int column) 520 { 521 gtk_cell_area_attribute_connect(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct(), Str.toStringz(attribute), column); 522 } 523 524 /** 525 * Disconnects @attribute for the @renderer in @area so that 526 * attribute will no longer be updated with values from the 527 * model. 528 * 529 * Params: 530 * renderer = the #GtkCellRenderer to disconnect an attribute for 531 * attribute = the attribute name 532 * 533 * Since: 3.0 534 */ 535 public void attributeDisconnect(CellRenderer renderer, string attribute) 536 { 537 gtk_cell_area_attribute_disconnect(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct(), Str.toStringz(attribute)); 538 } 539 540 /** 541 * Returns the model column that an attribute has been mapped to, 542 * or -1 if the attribute is not mapped. 543 * 544 * Params: 545 * renderer = a #GtkCellRenderer 546 * attribute = an attribute on the renderer 547 * 548 * Returns: the model column, or -1 549 * 550 * Since: 3.14 551 */ 552 public int attributeGetColumn(CellRenderer renderer, string attribute) 553 { 554 return gtk_cell_area_attribute_get_column(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct(), Str.toStringz(attribute)); 555 } 556 557 /** 558 * Gets the value of a cell property for @renderer in @area. 559 * 560 * Params: 561 * renderer = a #GtkCellRenderer inside @area 562 * propertyName = the name of the property to get 563 * value = a location to return the value 564 * 565 * Since: 3.0 566 */ 567 public void cellGetProperty(CellRenderer renderer, string propertyName, Value value) 568 { 569 gtk_cell_area_cell_get_property(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct(), Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct()); 570 } 571 572 /** 573 * Gets the values of one or more cell properties for @renderer in @area. 574 * 575 * Params: 576 * renderer = a #GtkCellRenderer inside @area 577 * firstPropertyName = the name of the first property to get 578 * varArgs = return location for the first property, followed 579 * optionally by more name/return location pairs, followed by %NULL 580 * 581 * Since: 3.0 582 */ 583 public void cellGetValist(CellRenderer renderer, string firstPropertyName, void* varArgs) 584 { 585 gtk_cell_area_cell_get_valist(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct(), Str.toStringz(firstPropertyName), varArgs); 586 } 587 588 /** 589 * Sets a cell property for @renderer in @area. 590 * 591 * Params: 592 * renderer = a #GtkCellRenderer inside @area 593 * propertyName = the name of the cell property to set 594 * value = the value to set the cell property to 595 * 596 * Since: 3.0 597 */ 598 public void cellSetProperty(CellRenderer renderer, string propertyName, Value value) 599 { 600 gtk_cell_area_cell_set_property(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct(), Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct()); 601 } 602 603 /** 604 * Sets one or more cell properties for @renderer in @area. 605 * 606 * Params: 607 * renderer = a #GtkCellRenderer which inside @area 608 * firstPropertyName = the name of the first cell property to set 609 * varArgs = a %NULL-terminated list of property names and values, starting 610 * with @first_prop_name 611 * 612 * Since: 3.0 613 */ 614 public void cellSetValist(CellRenderer renderer, string firstPropertyName, void* varArgs) 615 { 616 gtk_cell_area_cell_set_valist(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct(), Str.toStringz(firstPropertyName), varArgs); 617 } 618 619 /** 620 * This is sometimes needed for cases where rows need to share 621 * alignments in one orientation but may be separately grouped 622 * in the opposing orientation. 623 * 624 * For instance, #GtkIconView creates all icons (rows) to have 625 * the same width and the cells theirin to have the same 626 * horizontal alignments. However each row of icons may have 627 * a separate collective height. #GtkIconView uses this to 628 * request the heights of each row based on a context which 629 * was already used to request all the row widths that are 630 * to be displayed. 631 * 632 * Params: 633 * context = the #GtkCellAreaContext to copy 634 * 635 * Returns: a newly created #GtkCellAreaContext copy of @context. 636 * 637 * Since: 3.0 638 */ 639 public CellAreaContext copyContext(CellAreaContext context) 640 { 641 auto p = gtk_cell_area_copy_context(gtkCellArea, (context is null) ? null : context.getCellAreaContextStruct()); 642 643 if(p is null) 644 { 645 return null; 646 } 647 648 return ObjectG.getDObject!(CellAreaContext)(cast(GtkCellAreaContext*) p, true); 649 } 650 651 /** 652 * Creates a #GtkCellAreaContext to be used with @area for 653 * all purposes. #GtkCellAreaContext stores geometry information 654 * for rows for which it was operated on, it is important to use 655 * the same context for the same row of data at all times (i.e. 656 * one should render and handle events with the same #GtkCellAreaContext 657 * which was used to request the size of those rows of data). 658 * 659 * Returns: a newly created #GtkCellAreaContext which can be used with @area. 660 * 661 * Since: 3.0 662 */ 663 public CellAreaContext createContext() 664 { 665 auto p = gtk_cell_area_create_context(gtkCellArea); 666 667 if(p is null) 668 { 669 return null; 670 } 671 672 return ObjectG.getDObject!(CellAreaContext)(cast(GtkCellAreaContext*) p, true); 673 } 674 675 /** 676 * Delegates event handling to a #GtkCellArea. 677 * 678 * Params: 679 * context = the #GtkCellAreaContext for this row of data. 680 * widget = the #GtkWidget that @area is rendering to 681 * event = the #GdkEvent to handle 682 * cellArea = the @widget relative coordinates for @area 683 * flags = the #GtkCellRendererState for @area in this row. 684 * 685 * Returns: %TRUE if the event was handled by @area. 686 * 687 * Since: 3.0 688 */ 689 public int event(CellAreaContext context, Widget widget, Event event, GdkRectangle* cellArea, GtkCellRendererState flags) 690 { 691 return gtk_cell_area_event(gtkCellArea, (context is null) ? null : context.getCellAreaContextStruct(), (widget is null) ? null : widget.getWidgetStruct(), (event is null) ? null : event.getEventStruct(), cellArea, flags); 692 } 693 694 /** 695 * This should be called by the @area’s owning layout widget 696 * when focus is to be passed to @area, or moved within @area 697 * for a given @direction and row data. 698 * 699 * Implementing #GtkCellArea classes should implement this 700 * method to receive and navigate focus in its own way particular 701 * to how it lays out cells. 702 * 703 * Params: 704 * direction = the #GtkDirectionType 705 * 706 * Returns: %TRUE if focus remains inside @area as a result of this call. 707 * 708 * Since: 3.0 709 */ 710 public bool focus(GtkDirectionType direction) 711 { 712 return gtk_cell_area_focus(gtkCellArea, direction) != 0; 713 } 714 715 /** 716 * Calls @callback for every #GtkCellRenderer in @area. 717 * 718 * Params: 719 * callback = the #GtkCellCallback to call 720 * callbackData = user provided data pointer 721 * 722 * Since: 3.0 723 */ 724 public void foreac(GtkCellCallback callback, void* callbackData) 725 { 726 gtk_cell_area_foreach(gtkCellArea, callback, callbackData); 727 } 728 729 /** 730 * Calls @callback for every #GtkCellRenderer in @area with the 731 * allocated rectangle inside @cell_area. 732 * 733 * Params: 734 * context = the #GtkCellAreaContext for this row of data. 735 * widget = the #GtkWidget that @area is rendering to 736 * cellArea = the @widget relative coordinates and size for @area 737 * backgroundArea = the @widget relative coordinates of the background area 738 * callback = the #GtkCellAllocCallback to call 739 * callbackData = user provided data pointer 740 * 741 * Since: 3.0 742 */ 743 public void foreachAlloc(CellAreaContext context, Widget widget, GdkRectangle* cellArea, GdkRectangle* backgroundArea, GtkCellAllocCallback callback, void* callbackData) 744 { 745 gtk_cell_area_foreach_alloc(gtkCellArea, (context is null) ? null : context.getCellAreaContextStruct(), (widget is null) ? null : widget.getWidgetStruct(), cellArea, backgroundArea, callback, callbackData); 746 } 747 748 /** 749 * Derives the allocation of @renderer inside @area if @area 750 * were to be renderered in @cell_area. 751 * 752 * Params: 753 * context = the #GtkCellAreaContext used to hold sizes for @area. 754 * widget = the #GtkWidget that @area is rendering on 755 * renderer = the #GtkCellRenderer to get the allocation for 756 * cellArea = the whole allocated area for @area in @widget 757 * for this row 758 * allocation = where to store the allocation for @renderer 759 * 760 * Since: 3.0 761 */ 762 public void getCellAllocation(CellAreaContext context, Widget widget, CellRenderer renderer, GdkRectangle* cellArea, out GdkRectangle allocation) 763 { 764 gtk_cell_area_get_cell_allocation(gtkCellArea, (context is null) ? null : context.getCellAreaContextStruct(), (widget is null) ? null : widget.getWidgetStruct(), (renderer is null) ? null : renderer.getCellRendererStruct(), cellArea, &allocation); 765 } 766 767 /** 768 * Gets the #GtkCellRenderer at @x and @y coordinates inside @area and optionally 769 * returns the full cell allocation for it inside @cell_area. 770 * 771 * Params: 772 * context = the #GtkCellAreaContext used to hold sizes for @area. 773 * widget = the #GtkWidget that @area is rendering on 774 * cellArea = the whole allocated area for @area in @widget 775 * for this row 776 * x = the x position 777 * y = the y position 778 * allocArea = where to store the inner allocated area of the 779 * returned cell renderer, or %NULL. 780 * 781 * Returns: the #GtkCellRenderer at @x and @y. 782 * 783 * Since: 3.0 784 */ 785 public CellRenderer getCellAtPosition(CellAreaContext context, Widget widget, GdkRectangle* cellArea, int x, int y, out GdkRectangle allocArea) 786 { 787 auto p = gtk_cell_area_get_cell_at_position(gtkCellArea, (context is null) ? null : context.getCellAreaContextStruct(), (widget is null) ? null : widget.getWidgetStruct(), cellArea, x, y, &allocArea); 788 789 if(p is null) 790 { 791 return null; 792 } 793 794 return ObjectG.getDObject!(CellRenderer)(cast(GtkCellRenderer*) p); 795 } 796 797 /** 798 * Gets the current #GtkTreePath string for the currently 799 * applied #GtkTreeIter, this is implicitly updated when 800 * gtk_cell_area_apply_attributes() is called and can be 801 * used to interact with renderers from #GtkCellArea 802 * subclasses. 803 * 804 * Returns: The current #GtkTreePath string for the current 805 * attributes applied to @area. This string belongs to the area and 806 * should not be freed. 807 * 808 * Since: 3.0 809 */ 810 public string getCurrentPathString() 811 { 812 return Str.toString(gtk_cell_area_get_current_path_string(gtkCellArea)); 813 } 814 815 /** 816 * Gets the #GtkCellEditable widget currently used 817 * to edit the currently edited cell. 818 * 819 * Returns: The currently active #GtkCellEditable widget 820 * 821 * Since: 3.0 822 */ 823 public CellEditableIF getEditWidget() 824 { 825 auto p = gtk_cell_area_get_edit_widget(gtkCellArea); 826 827 if(p is null) 828 { 829 return null; 830 } 831 832 return ObjectG.getDObject!(CellEditable, CellEditableIF)(cast(GtkCellEditable*) p); 833 } 834 835 /** 836 * Gets the #GtkCellRenderer in @area that is currently 837 * being edited. 838 * 839 * Returns: The currently edited #GtkCellRenderer 840 * 841 * Since: 3.0 842 */ 843 public CellRenderer getEditedCell() 844 { 845 auto p = gtk_cell_area_get_edited_cell(gtkCellArea); 846 847 if(p is null) 848 { 849 return null; 850 } 851 852 return ObjectG.getDObject!(CellRenderer)(cast(GtkCellRenderer*) p); 853 } 854 855 /** 856 * Retrieves the currently focused cell for @area 857 * 858 * Returns: the currently focused cell in @area. 859 * 860 * Since: 3.0 861 */ 862 public CellRenderer getFocusCell() 863 { 864 auto p = gtk_cell_area_get_focus_cell(gtkCellArea); 865 866 if(p is null) 867 { 868 return null; 869 } 870 871 return ObjectG.getDObject!(CellRenderer)(cast(GtkCellRenderer*) p); 872 } 873 874 /** 875 * Gets the #GtkCellRenderer which is expected to be focusable 876 * for which @renderer is, or may be a sibling. 877 * 878 * This is handy for #GtkCellArea subclasses when handling events, 879 * after determining the renderer at the event location it can 880 * then chose to activate the focus cell for which the event 881 * cell may have been a sibling. 882 * 883 * Params: 884 * renderer = the #GtkCellRenderer 885 * 886 * Returns: the #GtkCellRenderer for which @renderer 887 * is a sibling, or %NULL. 888 * 889 * Since: 3.0 890 */ 891 public CellRenderer getFocusFromSibling(CellRenderer renderer) 892 { 893 auto p = gtk_cell_area_get_focus_from_sibling(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct()); 894 895 if(p is null) 896 { 897 return null; 898 } 899 900 return ObjectG.getDObject!(CellRenderer)(cast(GtkCellRenderer*) p); 901 } 902 903 /** 904 * Gets the focus sibling cell renderers for @renderer. 905 * 906 * Params: 907 * renderer = the #GtkCellRenderer expected to have focus 908 * 909 * Returns: A #GList of #GtkCellRenderers. 910 * The returned list is internal and should not be freed. 911 * 912 * Since: 3.0 913 */ 914 public ListG getFocusSiblings(CellRenderer renderer) 915 { 916 auto p = gtk_cell_area_get_focus_siblings(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct()); 917 918 if(p is null) 919 { 920 return null; 921 } 922 923 return new ListG(cast(GList*) p); 924 } 925 926 /** 927 * Retrieves a cell area’s initial minimum and natural height. 928 * 929 * @area will store some geometrical information in @context along the way; 930 * when requesting sizes over an arbitrary number of rows, it’s not important 931 * to check the @minimum_height and @natural_height of this call but rather to 932 * consult gtk_cell_area_context_get_preferred_height() after a series of 933 * requests. 934 * 935 * Params: 936 * context = the #GtkCellAreaContext to perform this request with 937 * widget = the #GtkWidget where @area will be rendering 938 * minimumHeight = location to store the minimum height, or %NULL 939 * naturalHeight = location to store the natural height, or %NULL 940 * 941 * Since: 3.0 942 */ 943 public void getPreferredHeight(CellAreaContext context, Widget widget, out int minimumHeight, out int naturalHeight) 944 { 945 gtk_cell_area_get_preferred_height(gtkCellArea, (context is null) ? null : context.getCellAreaContextStruct(), (widget is null) ? null : widget.getWidgetStruct(), &minimumHeight, &naturalHeight); 946 } 947 948 /** 949 * Retrieves a cell area’s minimum and natural height if it would be given 950 * the specified @width. 951 * 952 * @area stores some geometrical information in @context along the way 953 * while calling gtk_cell_area_get_preferred_width(). It’s important to 954 * perform a series of gtk_cell_area_get_preferred_width() requests with 955 * @context first and then call gtk_cell_area_get_preferred_height_for_width() 956 * on each cell area individually to get the height for width of each 957 * fully requested row. 958 * 959 * If at some point, the width of a single row changes, it should be 960 * requested with gtk_cell_area_get_preferred_width() again and then 961 * the full width of the requested rows checked again with 962 * gtk_cell_area_context_get_preferred_width(). 963 * 964 * Params: 965 * context = the #GtkCellAreaContext which has already been requested for widths. 966 * widget = the #GtkWidget where @area will be rendering 967 * width = the width for which to check the height of this area 968 * minimumHeight = location to store the minimum height, or %NULL 969 * naturalHeight = location to store the natural height, or %NULL 970 * 971 * Since: 3.0 972 */ 973 public void getPreferredHeightForWidth(CellAreaContext context, Widget widget, int width, out int minimumHeight, out int naturalHeight) 974 { 975 gtk_cell_area_get_preferred_height_for_width(gtkCellArea, (context is null) ? null : context.getCellAreaContextStruct(), (widget is null) ? null : widget.getWidgetStruct(), width, &minimumHeight, &naturalHeight); 976 } 977 978 /** 979 * Retrieves a cell area’s initial minimum and natural width. 980 * 981 * @area will store some geometrical information in @context along the way; 982 * when requesting sizes over an arbitrary number of rows, it’s not important 983 * to check the @minimum_width and @natural_width of this call but rather to 984 * consult gtk_cell_area_context_get_preferred_width() after a series of 985 * requests. 986 * 987 * Params: 988 * context = the #GtkCellAreaContext to perform this request with 989 * widget = the #GtkWidget where @area will be rendering 990 * minimumWidth = location to store the minimum width, or %NULL 991 * naturalWidth = location to store the natural width, or %NULL 992 * 993 * Since: 3.0 994 */ 995 public void getPreferredWidth(CellAreaContext context, Widget widget, out int minimumWidth, out int naturalWidth) 996 { 997 gtk_cell_area_get_preferred_width(gtkCellArea, (context is null) ? null : context.getCellAreaContextStruct(), (widget is null) ? null : widget.getWidgetStruct(), &minimumWidth, &naturalWidth); 998 } 999 1000 /** 1001 * Retrieves a cell area’s minimum and natural width if it would be given 1002 * the specified @height. 1003 * 1004 * @area stores some geometrical information in @context along the way 1005 * while calling gtk_cell_area_get_preferred_height(). It’s important to 1006 * perform a series of gtk_cell_area_get_preferred_height() requests with 1007 * @context first and then call gtk_cell_area_get_preferred_width_for_height() 1008 * on each cell area individually to get the height for width of each 1009 * fully requested row. 1010 * 1011 * If at some point, the height of a single row changes, it should be 1012 * requested with gtk_cell_area_get_preferred_height() again and then 1013 * the full height of the requested rows checked again with 1014 * gtk_cell_area_context_get_preferred_height(). 1015 * 1016 * Params: 1017 * context = the #GtkCellAreaContext which has already been requested for widths. 1018 * widget = the #GtkWidget where @area will be rendering 1019 * height = the height for which to check the width of this area 1020 * minimumWidth = location to store the minimum width, or %NULL 1021 * naturalWidth = location to store the natural width, or %NULL 1022 * 1023 * Since: 3.0 1024 */ 1025 public void getPreferredWidthForHeight(CellAreaContext context, Widget widget, int height, out int minimumWidth, out int naturalWidth) 1026 { 1027 gtk_cell_area_get_preferred_width_for_height(gtkCellArea, (context is null) ? null : context.getCellAreaContextStruct(), (widget is null) ? null : widget.getWidgetStruct(), height, &minimumWidth, &naturalWidth); 1028 } 1029 1030 /** 1031 * Gets whether the area prefers a height-for-width layout 1032 * or a width-for-height layout. 1033 * 1034 * Returns: The #GtkSizeRequestMode preferred by @area. 1035 * 1036 * Since: 3.0 1037 */ 1038 public GtkSizeRequestMode getRequestMode() 1039 { 1040 return gtk_cell_area_get_request_mode(gtkCellArea); 1041 } 1042 1043 /** 1044 * Checks if @area contains @renderer. 1045 * 1046 * Params: 1047 * renderer = the #GtkCellRenderer to check 1048 * 1049 * Returns: %TRUE if @renderer is in the @area. 1050 * 1051 * Since: 3.0 1052 */ 1053 public bool hasRenderer(CellRenderer renderer) 1054 { 1055 return gtk_cell_area_has_renderer(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct()) != 0; 1056 } 1057 1058 /** 1059 * This is a convenience function for #GtkCellArea implementations 1060 * to get the inner area where a given #GtkCellRenderer will be 1061 * rendered. It removes any padding previously added by gtk_cell_area_request_renderer(). 1062 * 1063 * Params: 1064 * widget = the #GtkWidget that @area is rendering onto 1065 * cellArea = the @widget relative coordinates where one of @area’s cells 1066 * is to be placed 1067 * innerArea = the return location for the inner cell area 1068 * 1069 * Since: 3.0 1070 */ 1071 public void innerCellArea(Widget widget, GdkRectangle* cellArea, out GdkRectangle innerArea) 1072 { 1073 gtk_cell_area_inner_cell_area(gtkCellArea, (widget is null) ? null : widget.getWidgetStruct(), cellArea, &innerArea); 1074 } 1075 1076 /** 1077 * Returns whether the area can do anything when activated, 1078 * after applying new attributes to @area. 1079 * 1080 * Returns: whether @area can do anything when activated. 1081 * 1082 * Since: 3.0 1083 */ 1084 public bool isActivatable() 1085 { 1086 return gtk_cell_area_is_activatable(gtkCellArea) != 0; 1087 } 1088 1089 /** 1090 * Returns whether @sibling is one of @renderer’s focus siblings 1091 * (see gtk_cell_area_add_focus_sibling()). 1092 * 1093 * Params: 1094 * renderer = the #GtkCellRenderer expected to have focus 1095 * sibling = the #GtkCellRenderer to check against @renderer’s sibling list 1096 * 1097 * Returns: %TRUE if @sibling is a focus sibling of @renderer 1098 * 1099 * Since: 3.0 1100 */ 1101 public bool isFocusSibling(CellRenderer renderer, CellRenderer sibling) 1102 { 1103 return gtk_cell_area_is_focus_sibling(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct(), (sibling is null) ? null : sibling.getCellRendererStruct()) != 0; 1104 } 1105 1106 /** 1107 * Removes @renderer from @area. 1108 * 1109 * Params: 1110 * renderer = the #GtkCellRenderer to remove from @area 1111 * 1112 * Since: 3.0 1113 */ 1114 public void remove(CellRenderer renderer) 1115 { 1116 gtk_cell_area_remove(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct()); 1117 } 1118 1119 /** 1120 * Removes @sibling from @renderer’s focus sibling list 1121 * (see gtk_cell_area_add_focus_sibling()). 1122 * 1123 * Params: 1124 * renderer = the #GtkCellRenderer expected to have focus 1125 * sibling = the #GtkCellRenderer to remove from @renderer’s focus area 1126 * 1127 * Since: 3.0 1128 */ 1129 public void removeFocusSibling(CellRenderer renderer, CellRenderer sibling) 1130 { 1131 gtk_cell_area_remove_focus_sibling(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct(), (sibling is null) ? null : sibling.getCellRendererStruct()); 1132 } 1133 1134 /** 1135 * Renders @area’s cells according to @area’s layout onto @widget at 1136 * the given coordinates. 1137 * 1138 * Params: 1139 * context = the #GtkCellAreaContext for this row of data. 1140 * widget = the #GtkWidget that @area is rendering to 1141 * cr = the #cairo_t to render with 1142 * backgroundArea = the @widget relative coordinates for @area’s background 1143 * cellArea = the @widget relative coordinates for @area 1144 * flags = the #GtkCellRendererState for @area in this row. 1145 * paintFocus = whether @area should paint focus on focused cells for focused rows or not. 1146 * 1147 * Since: 3.0 1148 */ 1149 public void render(CellAreaContext context, Widget widget, Context cr, GdkRectangle* backgroundArea, GdkRectangle* cellArea, GtkCellRendererState flags, bool paintFocus) 1150 { 1151 gtk_cell_area_render(gtkCellArea, (context is null) ? null : context.getCellAreaContextStruct(), (widget is null) ? null : widget.getWidgetStruct(), (cr is null) ? null : cr.getContextStruct(), backgroundArea, cellArea, flags, paintFocus); 1152 } 1153 1154 /** 1155 * This is a convenience function for #GtkCellArea implementations 1156 * to request size for cell renderers. It’s important to use this 1157 * function to request size and then use gtk_cell_area_inner_cell_area() 1158 * at render and event time since this function will add padding 1159 * around the cell for focus painting. 1160 * 1161 * Params: 1162 * renderer = the #GtkCellRenderer to request size for 1163 * orientation = the #GtkOrientation in which to request size 1164 * widget = the #GtkWidget that @area is rendering onto 1165 * forSize = the allocation contextual size to request for, or -1 if 1166 * the base request for the orientation is to be returned. 1167 * minimumSize = location to store the minimum size, or %NULL 1168 * naturalSize = location to store the natural size, or %NULL 1169 * 1170 * Since: 3.0 1171 */ 1172 public void requestRenderer(CellRenderer renderer, GtkOrientation orientation, Widget widget, int forSize, out int minimumSize, out int naturalSize) 1173 { 1174 gtk_cell_area_request_renderer(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct(), orientation, (widget is null) ? null : widget.getWidgetStruct(), forSize, &minimumSize, &naturalSize); 1175 } 1176 1177 /** 1178 * Explicitly sets the currently focused cell to @renderer. 1179 * 1180 * This is generally called by implementations of 1181 * #GtkCellAreaClass.focus() or #GtkCellAreaClass.event(), 1182 * however it can also be used to implement functions such 1183 * as gtk_tree_view_set_cursor_on_cell(). 1184 * 1185 * Params: 1186 * renderer = the #GtkCellRenderer to give focus to 1187 * 1188 * Since: 3.0 1189 */ 1190 public void setFocusCell(CellRenderer renderer) 1191 { 1192 gtk_cell_area_set_focus_cell(gtkCellArea, (renderer is null) ? null : renderer.getCellRendererStruct()); 1193 } 1194 1195 /** 1196 * Explicitly stops the editing of the currently edited cell. 1197 * 1198 * If @canceled is %TRUE, the currently edited cell renderer 1199 * will emit the ::editing-canceled signal, otherwise the 1200 * the ::editing-done signal will be emitted on the current 1201 * edit widget. 1202 * 1203 * See gtk_cell_area_get_edited_cell() and gtk_cell_area_get_edit_widget(). 1204 * 1205 * Params: 1206 * canceled = whether editing was canceled. 1207 * 1208 * Since: 3.0 1209 */ 1210 public void stopEditing(bool canceled) 1211 { 1212 gtk_cell_area_stop_editing(gtkCellArea, canceled); 1213 } 1214 1215 protected class OnAddEditableDelegateWrapper 1216 { 1217 static OnAddEditableDelegateWrapper[] listeners; 1218 void delegate(CellRenderer, CellEditableIF, GdkRectangle*, string, CellArea) dlg; 1219 gulong handlerId; 1220 1221 this(void delegate(CellRenderer, CellEditableIF, GdkRectangle*, string, CellArea) dlg) 1222 { 1223 this.dlg = dlg; 1224 this.listeners ~= this; 1225 } 1226 1227 void remove(OnAddEditableDelegateWrapper source) 1228 { 1229 foreach(index, wrapper; listeners) 1230 { 1231 if (wrapper.handlerId == source.handlerId) 1232 { 1233 listeners[index] = null; 1234 listeners = std.algorithm.remove(listeners, index); 1235 break; 1236 } 1237 } 1238 } 1239 } 1240 1241 /** 1242 * Indicates that editing has started on @renderer and that @editable 1243 * should be added to the owning cell-layouting widget at @cell_area. 1244 * 1245 * Params: 1246 * renderer = the #GtkCellRenderer that started the edited 1247 * editable = the #GtkCellEditable widget to add 1248 * cellArea = the #GtkWidget relative #GdkRectangle coordinates 1249 * where @editable should be added 1250 * path = the #GtkTreePath string this edit was initiated for 1251 * 1252 * Since: 3.0 1253 */ 1254 gulong addOnAddEditable(void delegate(CellRenderer, CellEditableIF, GdkRectangle*, string, CellArea) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1255 { 1256 auto wrapper = new OnAddEditableDelegateWrapper(dlg); 1257 wrapper.handlerId = Signals.connectData( 1258 this, 1259 "add-editable", 1260 cast(GCallback)&callBackAddEditable, 1261 cast(void*)wrapper, 1262 cast(GClosureNotify)&callBackAddEditableDestroy, 1263 connectFlags); 1264 return wrapper.handlerId; 1265 } 1266 1267 extern(C) static void callBackAddEditable(GtkCellArea* cellareaStruct, GtkCellRenderer* renderer, GtkCellEditable* editable, GdkRectangle* cellArea, char* path, OnAddEditableDelegateWrapper wrapper) 1268 { 1269 wrapper.dlg(ObjectG.getDObject!(CellRenderer)(renderer), ObjectG.getDObject!(CellEditable, CellEditableIF)(editable), cellArea, Str.toString(path), wrapper.outer); 1270 } 1271 1272 extern(C) static void callBackAddEditableDestroy(OnAddEditableDelegateWrapper wrapper, GClosure* closure) 1273 { 1274 wrapper.remove(wrapper); 1275 } 1276 1277 protected class OnApplyAttributesDelegateWrapper 1278 { 1279 static OnApplyAttributesDelegateWrapper[] listeners; 1280 void delegate(TreeModelIF, TreeIter, bool, bool, CellArea) dlg; 1281 gulong handlerId; 1282 1283 this(void delegate(TreeModelIF, TreeIter, bool, bool, CellArea) dlg) 1284 { 1285 this.dlg = dlg; 1286 this.listeners ~= this; 1287 } 1288 1289 void remove(OnApplyAttributesDelegateWrapper source) 1290 { 1291 foreach(index, wrapper; listeners) 1292 { 1293 if (wrapper.handlerId == source.handlerId) 1294 { 1295 listeners[index] = null; 1296 listeners = std.algorithm.remove(listeners, index); 1297 break; 1298 } 1299 } 1300 } 1301 } 1302 1303 /** 1304 * This signal is emitted whenever applying attributes to @area from @model 1305 * 1306 * Params: 1307 * model = the #GtkTreeModel to apply the attributes from 1308 * iter = the #GtkTreeIter indicating which row to apply the attributes of 1309 * isExpander = whether the view shows children for this row 1310 * isExpanded = whether the view is currently showing the children of this row 1311 * 1312 * Since: 3.0 1313 */ 1314 gulong addOnApplyAttributes(void delegate(TreeModelIF, TreeIter, bool, bool, CellArea) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1315 { 1316 auto wrapper = new OnApplyAttributesDelegateWrapper(dlg); 1317 wrapper.handlerId = Signals.connectData( 1318 this, 1319 "apply-attributes", 1320 cast(GCallback)&callBackApplyAttributes, 1321 cast(void*)wrapper, 1322 cast(GClosureNotify)&callBackApplyAttributesDestroy, 1323 connectFlags); 1324 return wrapper.handlerId; 1325 } 1326 1327 extern(C) static void callBackApplyAttributes(GtkCellArea* cellareaStruct, GtkTreeModel* model, GtkTreeIter* iter, bool isExpander, bool isExpanded, OnApplyAttributesDelegateWrapper wrapper) 1328 { 1329 wrapper.dlg(ObjectG.getDObject!(TreeModel, TreeModelIF)(model), ObjectG.getDObject!(TreeIter)(iter), isExpander, isExpanded, wrapper.outer); 1330 } 1331 1332 extern(C) static void callBackApplyAttributesDestroy(OnApplyAttributesDelegateWrapper wrapper, GClosure* closure) 1333 { 1334 wrapper.remove(wrapper); 1335 } 1336 1337 protected class OnFocusChangedDelegateWrapper 1338 { 1339 static OnFocusChangedDelegateWrapper[] listeners; 1340 void delegate(CellRenderer, string, CellArea) dlg; 1341 gulong handlerId; 1342 1343 this(void delegate(CellRenderer, string, CellArea) dlg) 1344 { 1345 this.dlg = dlg; 1346 this.listeners ~= this; 1347 } 1348 1349 void remove(OnFocusChangedDelegateWrapper source) 1350 { 1351 foreach(index, wrapper; listeners) 1352 { 1353 if (wrapper.handlerId == source.handlerId) 1354 { 1355 listeners[index] = null; 1356 listeners = std.algorithm.remove(listeners, index); 1357 break; 1358 } 1359 } 1360 } 1361 } 1362 1363 /** 1364 * Indicates that focus changed on this @area. This signal 1365 * is emitted either as a result of focus handling or event 1366 * handling. 1367 * 1368 * It's possible that the signal is emitted even if the 1369 * currently focused renderer did not change, this is 1370 * because focus may change to the same renderer in the 1371 * same cell area for a different row of data. 1372 * 1373 * Params: 1374 * renderer = the #GtkCellRenderer that has focus 1375 * path = the current #GtkTreePath string set for @area 1376 * 1377 * Since: 3.0 1378 */ 1379 gulong addOnFocusChanged(void delegate(CellRenderer, string, CellArea) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1380 { 1381 auto wrapper = new OnFocusChangedDelegateWrapper(dlg); 1382 wrapper.handlerId = Signals.connectData( 1383 this, 1384 "focus-changed", 1385 cast(GCallback)&callBackFocusChanged, 1386 cast(void*)wrapper, 1387 cast(GClosureNotify)&callBackFocusChangedDestroy, 1388 connectFlags); 1389 return wrapper.handlerId; 1390 } 1391 1392 extern(C) static void callBackFocusChanged(GtkCellArea* cellareaStruct, GtkCellRenderer* renderer, char* path, OnFocusChangedDelegateWrapper wrapper) 1393 { 1394 wrapper.dlg(ObjectG.getDObject!(CellRenderer)(renderer), Str.toString(path), wrapper.outer); 1395 } 1396 1397 extern(C) static void callBackFocusChangedDestroy(OnFocusChangedDelegateWrapper wrapper, GClosure* closure) 1398 { 1399 wrapper.remove(wrapper); 1400 } 1401 1402 protected class OnRemoveEditableDelegateWrapper 1403 { 1404 static OnRemoveEditableDelegateWrapper[] listeners; 1405 void delegate(CellRenderer, CellEditableIF, CellArea) dlg; 1406 gulong handlerId; 1407 1408 this(void delegate(CellRenderer, CellEditableIF, CellArea) dlg) 1409 { 1410 this.dlg = dlg; 1411 this.listeners ~= this; 1412 } 1413 1414 void remove(OnRemoveEditableDelegateWrapper source) 1415 { 1416 foreach(index, wrapper; listeners) 1417 { 1418 if (wrapper.handlerId == source.handlerId) 1419 { 1420 listeners[index] = null; 1421 listeners = std.algorithm.remove(listeners, index); 1422 break; 1423 } 1424 } 1425 } 1426 } 1427 1428 /** 1429 * Indicates that editing finished on @renderer and that @editable 1430 * should be removed from the owning cell-layouting widget. 1431 * 1432 * Params: 1433 * renderer = the #GtkCellRenderer that finished editeding 1434 * editable = the #GtkCellEditable widget to remove 1435 * 1436 * Since: 3.0 1437 */ 1438 gulong addOnRemoveEditable(void delegate(CellRenderer, CellEditableIF, CellArea) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1439 { 1440 auto wrapper = new OnRemoveEditableDelegateWrapper(dlg); 1441 wrapper.handlerId = Signals.connectData( 1442 this, 1443 "remove-editable", 1444 cast(GCallback)&callBackRemoveEditable, 1445 cast(void*)wrapper, 1446 cast(GClosureNotify)&callBackRemoveEditableDestroy, 1447 connectFlags); 1448 return wrapper.handlerId; 1449 } 1450 1451 extern(C) static void callBackRemoveEditable(GtkCellArea* cellareaStruct, GtkCellRenderer* renderer, GtkCellEditable* editable, OnRemoveEditableDelegateWrapper wrapper) 1452 { 1453 wrapper.dlg(ObjectG.getDObject!(CellRenderer)(renderer), ObjectG.getDObject!(CellEditable, CellEditableIF)(editable), wrapper.outer); 1454 } 1455 1456 extern(C) static void callBackRemoveEditableDestroy(OnRemoveEditableDelegateWrapper wrapper, GClosure* closure) 1457 { 1458 wrapper.remove(wrapper); 1459 } 1460 }