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