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.TreeView; 26 27 private import gdk.ContentFormats; 28 private import gdk.PaintableIF; 29 private import glib.ConstructionException; 30 private import glib.ListG; 31 private import glib.MemorySlice; 32 private import glib.Str; 33 private import gobject.ObjectG; 34 private import gobject.Signals; 35 private import gtk.CellRenderer; 36 private import gtk.EditableIF; 37 private import gtk.ScrollableIF; 38 private import gtk.ScrollableT; 39 private import gtk.Tooltip; 40 private import gtk.TreeIter; 41 private import gtk.TreeModelIF; 42 private import gtk.TreePath; 43 private import gtk.TreeSelection; 44 private import gtk.TreeViewColumn; 45 private import gtk.Widget; 46 private import gtk.c.functions; 47 public import gtk.c.types; 48 private import std.algorithm; 49 50 51 /** 52 * A widget for displaying both trees and lists 53 * 54 * Widget that displays any object that implements the [iface@Gtk.TreeModel] interface. 55 * 56 * Please refer to the [tree widget conceptual overview](section-tree-widget.html) 57 * for an overview of all the objects and data types related to the tree 58 * widget and how they work together. 59 * 60 * ## Coordinate systems in GtkTreeView API 61 * 62 * Several different coordinate systems are exposed in the `GtkTreeView` API. 63 * These are: 64 * 65 * ![](tree-view-coordinates.png) 66 * 67 * - Widget coordinates: Coordinates relative to the widget (usually `widget->window`). 68 * 69 * - Bin window coordinates: Coordinates relative to the window that GtkTreeView renders to. 70 * 71 * - Tree coordinates: Coordinates relative to the entire scrollable area of GtkTreeView. These 72 * coordinates start at (0, 0) for row 0 of the tree. 73 * 74 * Several functions are available for converting between the different 75 * coordinate systems. The most common translations are between widget and bin 76 * window coordinates and between bin window and tree coordinates. For the 77 * former you can use [method@Gtk.TreeView.convert_widget_to_bin_window_coords] 78 * (and vice versa), for the latter [method@Gtk.TreeView.convert_bin_window_to_tree_coords] 79 * (and vice versa). 80 * 81 * ## `GtkTreeView` as `GtkBuildable` 82 * 83 * The `GtkTreeView` implementation of the `GtkBuildable` interface accepts 84 * [class@Gtk.TreeViewColumn] objects as `<child>` elements and exposes the 85 * internal [class@Gtk.TreeSelection] in UI definitions. 86 * 87 * An example of a UI definition fragment with `GtkTreeView`: 88 * 89 * ```xml 90 * <object class="GtkTreeView" id="treeview"> 91 * <property name="model">liststore1</property> 92 * <child> 93 * <object class="GtkTreeViewColumn" id="test-column"> 94 * <property name="title">Test</property> 95 * <child> 96 * <object class="GtkCellRendererText" id="test-renderer"/> 97 * <attributes> 98 * <attribute name="text">1</attribute> 99 * </attributes> 100 * </child> 101 * </object> 102 * </child> 103 * <child internal-child="selection"> 104 * <object class="GtkTreeSelection" id="selection"> 105 * <signal name="changed" handler="on_treeview_selection_changed"/> 106 * </object> 107 * </child> 108 * </object> 109 * ``` 110 * 111 * ## CSS nodes 112 * 113 * ``` 114 * treeview.view 115 * ├── header 116 * │ ├── button 117 * │ │ ╰── [sort-indicator] 118 * ┊ ┊ 119 * │ ╰── button 120 * │ ╰── [sort-indicator] 121 * │ 122 * ├── [rubberband] 123 * ╰── [dndtarget] 124 * ``` 125 * 126 * `GtkTreeView` has a main CSS node with name `treeview` and style class `.view`. 127 * It has a subnode with name `header`, which is the parent for all the column 128 * header widgets' CSS nodes. 129 * 130 * Each column header consists of a `button`, which among other content, has a 131 * child with name `sort-indicator`, which carries the `.ascending` or `.descending` 132 * style classes when the column header should show a sort indicator. The CSS 133 * is expected to provide a suitable image using the `-gtk-icon-source` property. 134 * 135 * For rubberband selection, a subnode with name `rubberband` is used. 136 * 137 * For the drop target location during DND, a subnode with name `dndtarget` is used. 138 */ 139 public class TreeView : Widget, ScrollableIF 140 { 141 /** the main Gtk struct */ 142 protected GtkTreeView* gtkTreeView; 143 144 /** Get the main Gtk struct */ 145 public GtkTreeView* getTreeViewStruct(bool transferOwnership = false) 146 { 147 if (transferOwnership) 148 ownedRef = false; 149 return gtkTreeView; 150 } 151 152 /** the main Gtk struct as a void* */ 153 protected override void* getStruct() 154 { 155 return cast(void*)gtkTreeView; 156 } 157 158 /** 159 * Sets our main struct and passes it to the parent class. 160 */ 161 public this (GtkTreeView* gtkTreeView, bool ownedRef = false) 162 { 163 this.gtkTreeView = gtkTreeView; 164 super(cast(GtkWidget*)gtkTreeView, ownedRef); 165 } 166 167 // add the Scrollable capabilities 168 mixin ScrollableT!(GtkTreeView); 169 170 171 /** */ 172 public static GType getType() 173 { 174 return gtk_tree_view_get_type(); 175 } 176 177 /** 178 * Creates a new #GtkTreeView widget. 179 * 180 * Returns: A newly created #GtkTreeView widget. 181 * 182 * Throws: ConstructionException GTK+ fails to create the object. 183 */ 184 public this() 185 { 186 auto __p = gtk_tree_view_new(); 187 188 if(__p is null) 189 { 190 throw new ConstructionException("null returned by new"); 191 } 192 193 this(cast(GtkTreeView*) __p); 194 } 195 196 /** 197 * Creates a new #GtkTreeView widget with the model initialized to @model. 198 * 199 * Params: 200 * model = the model. 201 * 202 * Returns: A newly created #GtkTreeView widget. 203 * 204 * Throws: ConstructionException GTK+ fails to create the object. 205 */ 206 public this(TreeModelIF model) 207 { 208 auto __p = gtk_tree_view_new_with_model((model is null) ? null : model.getTreeModelStruct()); 209 210 if(__p is null) 211 { 212 throw new ConstructionException("null returned by new_with_model"); 213 } 214 215 this(cast(GtkTreeView*) __p); 216 } 217 218 /** 219 * Appends @column to the list of columns. If @tree_view has “fixed_height” 220 * mode enabled, then @column must have its “sizing” property set to be 221 * GTK_TREE_VIEW_COLUMN_FIXED. 222 * 223 * Params: 224 * column = The #GtkTreeViewColumn to add. 225 * 226 * Returns: The number of columns in @tree_view after appending. 227 */ 228 public int appendColumn(TreeViewColumn column) 229 { 230 return gtk_tree_view_append_column(gtkTreeView, (column is null) ? null : column.getTreeViewColumnStruct()); 231 } 232 233 /** 234 * Recursively collapses all visible, expanded nodes in @tree_view. 235 */ 236 public void collapseAll() 237 { 238 gtk_tree_view_collapse_all(gtkTreeView); 239 } 240 241 /** 242 * Collapses a row (hides its child rows, if they exist). 243 * 244 * Params: 245 * path = path to a row in the @tree_view 246 * 247 * Returns: %TRUE if the row was collapsed. 248 */ 249 public bool collapseRow(TreePath path) 250 { 251 return gtk_tree_view_collapse_row(gtkTreeView, (path is null) ? null : path.getTreePathStruct()) != 0; 252 } 253 254 /** 255 * Resizes all columns to their optimal width. Only works after the 256 * treeview has been realized. 257 */ 258 public void columnsAutosize() 259 { 260 gtk_tree_view_columns_autosize(gtkTreeView); 261 } 262 263 /** 264 * Converts bin_window coordinates to coordinates for the 265 * tree (the full scrollable area of the tree). 266 * 267 * Params: 268 * bx = X coordinate relative to bin_window 269 * by = Y coordinate relative to bin_window 270 * tx = return location for tree X coordinate 271 * ty = return location for tree Y coordinate 272 */ 273 public void convertBinWindowToTreeCoords(int bx, int by, out int tx, out int ty) 274 { 275 gtk_tree_view_convert_bin_window_to_tree_coords(gtkTreeView, bx, by, &tx, &ty); 276 } 277 278 /** 279 * Converts bin_window coordinates to widget relative coordinates. 280 * 281 * Params: 282 * bx = bin_window X coordinate 283 * by = bin_window Y coordinate 284 * wx = return location for widget X coordinate 285 * wy = return location for widget Y coordinate 286 */ 287 public void convertBinWindowToWidgetCoords(int bx, int by, out int wx, out int wy) 288 { 289 gtk_tree_view_convert_bin_window_to_widget_coords(gtkTreeView, bx, by, &wx, &wy); 290 } 291 292 /** 293 * Converts tree coordinates (coordinates in full scrollable area of the tree) 294 * to bin_window coordinates. 295 * 296 * Params: 297 * tx = tree X coordinate 298 * ty = tree Y coordinate 299 * bx = return location for X coordinate relative to bin_window 300 * by = return location for Y coordinate relative to bin_window 301 */ 302 public void convertTreeToBinWindowCoords(int tx, int ty, out int bx, out int by) 303 { 304 gtk_tree_view_convert_tree_to_bin_window_coords(gtkTreeView, tx, ty, &bx, &by); 305 } 306 307 /** 308 * Converts tree coordinates (coordinates in full scrollable area of the tree) 309 * to widget coordinates. 310 * 311 * Params: 312 * tx = X coordinate relative to the tree 313 * ty = Y coordinate relative to the tree 314 * wx = return location for widget X coordinate 315 * wy = return location for widget Y coordinate 316 */ 317 public void convertTreeToWidgetCoords(int tx, int ty, out int wx, out int wy) 318 { 319 gtk_tree_view_convert_tree_to_widget_coords(gtkTreeView, tx, ty, &wx, &wy); 320 } 321 322 /** 323 * Converts widget coordinates to coordinates for the bin_window. 324 * 325 * Params: 326 * wx = X coordinate relative to the widget 327 * wy = Y coordinate relative to the widget 328 * bx = return location for bin_window X coordinate 329 * by = return location for bin_window Y coordinate 330 */ 331 public void convertWidgetToBinWindowCoords(int wx, int wy, out int bx, out int by) 332 { 333 gtk_tree_view_convert_widget_to_bin_window_coords(gtkTreeView, wx, wy, &bx, &by); 334 } 335 336 /** 337 * Converts widget coordinates to coordinates for the 338 * tree (the full scrollable area of the tree). 339 * 340 * Params: 341 * wx = X coordinate relative to the widget 342 * wy = Y coordinate relative to the widget 343 * tx = return location for tree X coordinate 344 * ty = return location for tree Y coordinate 345 */ 346 public void convertWidgetToTreeCoords(int wx, int wy, out int tx, out int ty) 347 { 348 gtk_tree_view_convert_widget_to_tree_coords(gtkTreeView, wx, wy, &tx, &ty); 349 } 350 351 /** 352 * Creates a #cairo_surface_t representation of the row at @path. 353 * This image is used for a drag icon. 354 * 355 * Params: 356 * path = a #GtkTreePath in @tree_view 357 * 358 * Returns: a newly-allocated surface of the drag icon. 359 */ 360 public PaintableIF createRowDragIcon(TreePath path) 361 { 362 auto __p = gtk_tree_view_create_row_drag_icon(gtkTreeView, (path is null) ? null : path.getTreePathStruct()); 363 364 if(__p is null) 365 { 366 return null; 367 } 368 369 return ObjectG.getDObject!(PaintableIF)(cast(GdkPaintable*) __p, true); 370 } 371 372 /** 373 * Turns @tree_view into a drop destination for automatic DND. Calling 374 * this method sets #GtkTreeView:reorderable to %FALSE. 375 * 376 * Params: 377 * formats = the target formats that the drag will support 378 * actions = the bitmask of possible actions for a drag from this 379 * widget 380 */ 381 public void enableModelDragDest(ContentFormats formats, GdkDragAction actions) 382 { 383 gtk_tree_view_enable_model_drag_dest(gtkTreeView, (formats is null) ? null : formats.getContentFormatsStruct(), actions); 384 } 385 386 /** 387 * Turns @tree_view into a drag source for automatic DND. Calling this 388 * method sets #GtkTreeView:reorderable to %FALSE. 389 * 390 * Params: 391 * startButtonMask = Mask of allowed buttons to start drag 392 * formats = the target formats that the drag will support 393 * actions = the bitmask of possible actions for a drag from this 394 * widget 395 */ 396 public void enableModelDragSource(GdkModifierType startButtonMask, ContentFormats formats, GdkDragAction actions) 397 { 398 gtk_tree_view_enable_model_drag_source(gtkTreeView, startButtonMask, (formats is null) ? null : formats.getContentFormatsStruct(), actions); 399 } 400 401 /** 402 * Recursively expands all nodes in the @tree_view. 403 */ 404 public void expandAll() 405 { 406 gtk_tree_view_expand_all(gtkTreeView); 407 } 408 409 /** 410 * Opens the row so its children are visible. 411 * 412 * Params: 413 * path = path to a row 414 * openAll = whether to recursively expand, or just expand immediate children 415 * 416 * Returns: %TRUE if the row existed and had children 417 */ 418 public bool expandRow(TreePath path, bool openAll) 419 { 420 return gtk_tree_view_expand_row(gtkTreeView, (path is null) ? null : path.getTreePathStruct(), openAll) != 0; 421 } 422 423 /** 424 * Expands the row at @path. This will also expand all parent rows of 425 * @path as necessary. 426 * 427 * Params: 428 * path = path to a row. 429 */ 430 public void expandToPath(TreePath path) 431 { 432 gtk_tree_view_expand_to_path(gtkTreeView, (path is null) ? null : path.getTreePathStruct()); 433 } 434 435 /** 436 * Gets the setting set by gtk_tree_view_set_activate_on_single_click(). 437 * 438 * Returns: %TRUE if row-activated will be emitted on a single click 439 */ 440 public bool getActivateOnSingleClick() 441 { 442 return gtk_tree_view_get_activate_on_single_click(gtkTreeView) != 0; 443 } 444 445 /** 446 * Fills the bounding rectangle in bin_window coordinates for the cell at the 447 * row specified by @path and the column specified by @column. If @path is 448 * %NULL, or points to a node not found in the tree, the @y and @height fields of 449 * the rectangle will be filled with 0. If @column is %NULL, the @x and @width 450 * fields will be filled with 0. The returned rectangle is equivalent to the 451 * @background_area passed to gtk_cell_renderer_render(). These background 452 * areas tile to cover the entire bin window. Contrast with the @cell_area, 453 * returned by gtk_tree_view_get_cell_area(), which returns only the cell 454 * itself, excluding surrounding borders and the tree expander area. 455 * 456 * Params: 457 * path = a #GtkTreePath for the row, or %NULL to get only horizontal coordinates 458 * column = a #GtkTreeViewColumn for the column, or %NULL to get only vertical coordinates 459 * rect = rectangle to fill with cell background rect 460 */ 461 public void getBackgroundArea(TreePath path, TreeViewColumn column, out GdkRectangle rect) 462 { 463 gtk_tree_view_get_background_area(gtkTreeView, (path is null) ? null : path.getTreePathStruct(), (column is null) ? null : column.getTreeViewColumnStruct(), &rect); 464 } 465 466 /** 467 * Fills the bounding rectangle in bin_window coordinates for the cell at the 468 * row specified by @path and the column specified by @column. If @path is 469 * %NULL, or points to a path not currently displayed, the @y and @height fields 470 * of the rectangle will be filled with 0. If @column is %NULL, the @x and @width 471 * fields will be filled with 0. The sum of all cell rects does not cover the 472 * entire tree; there are extra pixels in between rows, for example. The 473 * returned rectangle is equivalent to the @cell_area passed to 474 * gtk_cell_renderer_render(). This function is only valid if @tree_view is 475 * realized. 476 * 477 * Params: 478 * path = a #GtkTreePath for the row, or %NULL to get only horizontal coordinates 479 * column = a #GtkTreeViewColumn for the column, or %NULL to get only vertical coordinates 480 * rect = rectangle to fill with cell rect 481 */ 482 public void getCellArea(TreePath path, TreeViewColumn column, out GdkRectangle rect) 483 { 484 gtk_tree_view_get_cell_area(gtkTreeView, (path is null) ? null : path.getTreePathStruct(), (column is null) ? null : column.getTreeViewColumnStruct(), &rect); 485 } 486 487 /** 488 * Gets the #GtkTreeViewColumn at the given position in the #tree_view. 489 * 490 * Params: 491 * n = The position of the column, counting from 0. 492 * 493 * Returns: The #GtkTreeViewColumn, or %NULL if the 494 * position is outside the range of columns. 495 */ 496 public TreeViewColumn getColumn(int n) 497 { 498 auto __p = gtk_tree_view_get_column(gtkTreeView, n); 499 500 if(__p is null) 501 { 502 return null; 503 } 504 505 return ObjectG.getDObject!(TreeViewColumn)(cast(GtkTreeViewColumn*) __p); 506 } 507 508 /** 509 * Returns a #GList of all the #GtkTreeViewColumn s currently in @tree_view. 510 * The returned list must be freed with g_list_free (). 511 * 512 * Returns: A list of #GtkTreeViewColumn s 513 */ 514 public ListG getColumns() 515 { 516 auto __p = gtk_tree_view_get_columns(gtkTreeView); 517 518 if(__p is null) 519 { 520 return null; 521 } 522 523 return new ListG(cast(GList*) __p); 524 } 525 526 /** 527 * Fills in @path and @focus_column with the current path and focus column. If 528 * the cursor isn’t currently set, then *@path will be %NULL. If no column 529 * currently has focus, then *@focus_column will be %NULL. 530 * 531 * The returned #GtkTreePath must be freed with gtk_tree_path_free() when 532 * you are done with it. 533 * 534 * Params: 535 * path = A pointer to be 536 * filled with the current cursor path, or %NULL 537 * focusColumn = A 538 * pointer to be filled with the current focus column, or %NULL 539 */ 540 public void getCursor(out TreePath path, out TreeViewColumn focusColumn) 541 { 542 GtkTreePath* outpath = null; 543 GtkTreeViewColumn* outfocusColumn = null; 544 545 gtk_tree_view_get_cursor(gtkTreeView, &outpath, &outfocusColumn); 546 547 path = ObjectG.getDObject!(TreePath)(outpath); 548 focusColumn = ObjectG.getDObject!(TreeViewColumn)(outfocusColumn); 549 } 550 551 /** 552 * Determines the destination row for a given position. @drag_x and 553 * @drag_y are expected to be in widget coordinates. This function is only 554 * meaningful if @tree_view is realized. Therefore this function will always 555 * return %FALSE if @tree_view is not realized or does not have a model. 556 * 557 * Params: 558 * dragX = the position to determine the destination row for 559 * dragY = the position to determine the destination row for 560 * path = Return location for the path of 561 * the highlighted row, or %NULL. 562 * pos = Return location for the drop position, or 563 * %NULL 564 * 565 * Returns: whether there is a row at the given position, %TRUE if this 566 * is indeed the case. 567 */ 568 public bool getDestRowAtPos(int dragX, int dragY, out TreePath path, out GtkTreeViewDropPosition pos) 569 { 570 GtkTreePath* outpath = null; 571 572 auto __p = gtk_tree_view_get_dest_row_at_pos(gtkTreeView, dragX, dragY, &outpath, &pos) != 0; 573 574 path = ObjectG.getDObject!(TreePath)(outpath); 575 576 return __p; 577 } 578 579 /** 580 * Gets information about the row that is highlighted for feedback. 581 * 582 * Params: 583 * path = Return location for the path of the highlighted row, or %NULL. 584 * pos = Return location for the drop position, or %NULL 585 */ 586 public void getDragDestRow(out TreePath path, out GtkTreeViewDropPosition pos) 587 { 588 GtkTreePath* outpath = null; 589 590 gtk_tree_view_get_drag_dest_row(gtkTreeView, &outpath, &pos); 591 592 path = ObjectG.getDObject!(TreePath)(outpath); 593 } 594 595 /** 596 * Returns whether or not the tree allows to start interactive searching 597 * by typing in text. 598 * 599 * Returns: whether or not to let the user search interactively 600 */ 601 public bool getEnableSearch() 602 { 603 return gtk_tree_view_get_enable_search(gtkTreeView) != 0; 604 } 605 606 /** 607 * Returns whether or not tree lines are drawn in @tree_view. 608 * 609 * Returns: %TRUE if tree lines are drawn in @tree_view, %FALSE 610 * otherwise. 611 */ 612 public bool getEnableTreeLines() 613 { 614 return gtk_tree_view_get_enable_tree_lines(gtkTreeView) != 0; 615 } 616 617 /** 618 * Returns the column that is the current expander column, 619 * or %NULL if none has been set. 620 * This column has the expander arrow drawn next to it. 621 * 622 * Returns: The expander column. 623 */ 624 public TreeViewColumn getExpanderColumn() 625 { 626 auto __p = gtk_tree_view_get_expander_column(gtkTreeView); 627 628 if(__p is null) 629 { 630 return null; 631 } 632 633 return ObjectG.getDObject!(TreeViewColumn)(cast(GtkTreeViewColumn*) __p); 634 } 635 636 /** 637 * Returns whether fixed height mode is turned on for @tree_view. 638 * 639 * Returns: %TRUE if @tree_view is in fixed height mode 640 */ 641 public bool getFixedHeightMode() 642 { 643 return gtk_tree_view_get_fixed_height_mode(gtkTreeView) != 0; 644 } 645 646 /** 647 * Returns which grid lines are enabled in @tree_view. 648 * 649 * Returns: a #GtkTreeViewGridLines value indicating which grid lines 650 * are enabled. 651 */ 652 public GtkTreeViewGridLines getGridLines() 653 { 654 return gtk_tree_view_get_grid_lines(gtkTreeView); 655 } 656 657 /** 658 * Returns whether all header columns are clickable. 659 * 660 * Returns: %TRUE if all header columns are clickable, otherwise %FALSE 661 */ 662 public bool getHeadersClickable() 663 { 664 return gtk_tree_view_get_headers_clickable(gtkTreeView) != 0; 665 } 666 667 /** 668 * Returns %TRUE if the headers on the @tree_view are visible. 669 * 670 * Returns: Whether the headers are visible or not. 671 */ 672 public bool getHeadersVisible() 673 { 674 return gtk_tree_view_get_headers_visible(gtkTreeView) != 0; 675 } 676 677 /** 678 * Returns whether hover expansion mode is turned on for @tree_view. 679 * 680 * Returns: %TRUE if @tree_view is in hover expansion mode 681 */ 682 public bool getHoverExpand() 683 { 684 return gtk_tree_view_get_hover_expand(gtkTreeView) != 0; 685 } 686 687 /** 688 * Returns whether hover selection mode is turned on for @tree_view. 689 * 690 * Returns: %TRUE if @tree_view is in hover selection mode 691 */ 692 public bool getHoverSelection() 693 { 694 return gtk_tree_view_get_hover_selection(gtkTreeView) != 0; 695 } 696 697 /** 698 * Returns the amount, in pixels, of extra indentation for child levels 699 * in @tree_view. 700 * 701 * Returns: the amount of extra indentation for child levels in 702 * @tree_view. A return value of 0 means that this feature is disabled. 703 */ 704 public int getLevelIndentation() 705 { 706 return gtk_tree_view_get_level_indentation(gtkTreeView); 707 } 708 709 /** 710 * Returns the model the #GtkTreeView is based on. Returns %NULL if the 711 * model is unset. 712 * 713 * Returns: A #GtkTreeModel, or %NULL if 714 * none is currently being used. 715 */ 716 public TreeModelIF getModel() 717 { 718 auto __p = gtk_tree_view_get_model(gtkTreeView); 719 720 if(__p is null) 721 { 722 return null; 723 } 724 725 return ObjectG.getDObject!(TreeModelIF)(cast(GtkTreeModel*) __p); 726 } 727 728 /** 729 * Queries the number of columns in the given @tree_view. 730 * 731 * Returns: The number of columns in the @tree_view 732 */ 733 public uint getNColumns() 734 { 735 return gtk_tree_view_get_n_columns(gtkTreeView); 736 } 737 738 /** 739 * Finds the path at the point (@x, @y), relative to bin_window coordinates. 740 * That is, @x and @y are relative to an events coordinates. Widget-relative 741 * coordinates must be converted using 742 * gtk_tree_view_convert_widget_to_bin_window_coords(). It is primarily for 743 * things like popup menus. If @path is non-%NULL, then it will be filled 744 * with the #GtkTreePath at that point. This path should be freed with 745 * gtk_tree_path_free(). If @column is non-%NULL, then it will be filled 746 * with the column at that point. @cell_x and @cell_y return the coordinates 747 * relative to the cell background (i.e. the @background_area passed to 748 * gtk_cell_renderer_render()). This function is only meaningful if 749 * @tree_view is realized. Therefore this function will always return %FALSE 750 * if @tree_view is not realized or does not have a model. 751 * 752 * For converting widget coordinates (eg. the ones you get from 753 * GtkWidget::query-tooltip), please see 754 * gtk_tree_view_convert_widget_to_bin_window_coords(). 755 * 756 * Params: 757 * x = The x position to be identified (relative to bin_window). 758 * y = The y position to be identified (relative to bin_window). 759 * path = A pointer to a #GtkTreePath 760 * pointer to be filled in, or %NULL 761 * column = A pointer to 762 * a #GtkTreeViewColumn pointer to be filled in, or %NULL 763 * cellX = A pointer where the X coordinate 764 * relative to the cell can be placed, or %NULL 765 * cellY = A pointer where the Y coordinate 766 * relative to the cell can be placed, or %NULL 767 * 768 * Returns: %TRUE if a row exists at that coordinate. 769 */ 770 public bool getPathAtPos(int x, int y, out TreePath path, out TreeViewColumn column, out int cellX, out int cellY) 771 { 772 GtkTreePath* outpath = null; 773 GtkTreeViewColumn* outcolumn = null; 774 775 auto __p = gtk_tree_view_get_path_at_pos(gtkTreeView, x, y, &outpath, &outcolumn, &cellX, &cellY) != 0; 776 777 path = ObjectG.getDObject!(TreePath)(outpath); 778 column = ObjectG.getDObject!(TreeViewColumn)(outcolumn); 779 780 return __p; 781 } 782 783 /** 784 * Retrieves whether the user can reorder the tree via drag-and-drop. See 785 * gtk_tree_view_set_reorderable(). 786 * 787 * Returns: %TRUE if the tree can be reordered. 788 */ 789 public bool getReorderable() 790 { 791 return gtk_tree_view_get_reorderable(gtkTreeView) != 0; 792 } 793 794 /** 795 * Returns the current row separator function. 796 * 797 * Returns: the current row separator function. 798 */ 799 public GtkTreeViewRowSeparatorFunc getRowSeparatorFunc() 800 { 801 return gtk_tree_view_get_row_separator_func(gtkTreeView); 802 } 803 804 /** 805 * Returns whether rubber banding is turned on for @tree_view. If the 806 * selection mode is #GTK_SELECTION_MULTIPLE, rubber banding will allow the 807 * user to select multiple rows by dragging the mouse. 808 * 809 * Returns: %TRUE if rubber banding in @tree_view is enabled. 810 */ 811 public bool getRubberBanding() 812 { 813 return gtk_tree_view_get_rubber_banding(gtkTreeView) != 0; 814 } 815 816 /** 817 * Gets the column searched on by the interactive search code. 818 * 819 * Returns: the column the interactive search code searches in. 820 */ 821 public int getSearchColumn() 822 { 823 return gtk_tree_view_get_search_column(gtkTreeView); 824 } 825 826 /** 827 * Returns the #GtkEntry which is currently in use as interactive search 828 * entry for @tree_view. In case the built-in entry is being used, %NULL 829 * will be returned. 830 * 831 * Returns: the entry currently in use as search entry. 832 */ 833 public EditableIF getSearchEntry() 834 { 835 auto __p = gtk_tree_view_get_search_entry(gtkTreeView); 836 837 if(__p is null) 838 { 839 return null; 840 } 841 842 return ObjectG.getDObject!(EditableIF)(cast(GtkEditable*) __p); 843 } 844 845 /** 846 * Returns the compare function currently in use. 847 * 848 * Returns: the currently used compare function for the search code. 849 */ 850 public GtkTreeViewSearchEqualFunc getSearchEqualFunc() 851 { 852 return gtk_tree_view_get_search_equal_func(gtkTreeView); 853 } 854 855 /** 856 * Gets the #GtkTreeSelection associated with @tree_view. 857 * 858 * Returns: A #GtkTreeSelection object. 859 */ 860 public TreeSelection getSelection() 861 { 862 auto __p = gtk_tree_view_get_selection(gtkTreeView); 863 864 if(__p is null) 865 { 866 return null; 867 } 868 869 return ObjectG.getDObject!(TreeSelection)(cast(GtkTreeSelection*) __p); 870 } 871 872 /** 873 * Returns whether or not expanders are drawn in @tree_view. 874 * 875 * Returns: %TRUE if expanders are drawn in @tree_view, %FALSE 876 * otherwise. 877 */ 878 public bool getShowExpanders() 879 { 880 return gtk_tree_view_get_show_expanders(gtkTreeView) != 0; 881 } 882 883 /** 884 * Returns the column of @tree_view’s model which is being used for 885 * displaying tooltips on @tree_view’s rows. 886 * 887 * Returns: the index of the tooltip column that is currently being 888 * used, or -1 if this is disabled. 889 */ 890 public int getTooltipColumn() 891 { 892 return gtk_tree_view_get_tooltip_column(gtkTreeView); 893 } 894 895 /** 896 * This function is supposed to be used in a #GtkWidget::query-tooltip 897 * signal handler for #GtkTreeView. The @x, @y and @keyboard_tip values 898 * which are received in the signal handler, should be passed to this 899 * function without modification. 900 * 901 * The return value indicates whether there is a tree view row at the given 902 * coordinates (%TRUE) or not (%FALSE) for mouse tooltips. For keyboard 903 * tooltips the row returned will be the cursor row. When %TRUE, then any of 904 * @model, @path and @iter which have been provided will be set to point to 905 * that row and the corresponding model. @x and @y will always be converted 906 * to be relative to @tree_view’s bin_window if @keyboard_tooltip is %FALSE. 907 * 908 * Params: 909 * x = the x coordinate (relative to widget coordinates) 910 * y = the y coordinate (relative to widget coordinates) 911 * keyboardTip = whether this is a keyboard tooltip or not 912 * model = a pointer to 913 * receive a #GtkTreeModel or %NULL 914 * path = a pointer to receive a #GtkTreePath or %NULL 915 * iter = a pointer to receive a #GtkTreeIter or %NULL 916 * 917 * Returns: whether or not the given tooltip context points to a row. 918 */ 919 public bool getTooltipContext(int x, int y, bool keyboardTip, out TreeModelIF model, out TreePath path, out TreeIter iter) 920 { 921 GtkTreeModel* outmodel = null; 922 GtkTreePath* outpath = null; 923 GtkTreeIter* outiter = sliceNew!GtkTreeIter(); 924 925 auto __p = gtk_tree_view_get_tooltip_context(gtkTreeView, x, y, keyboardTip, &outmodel, &outpath, outiter) != 0; 926 927 model = ObjectG.getDObject!(TreeModelIF)(outmodel); 928 path = ObjectG.getDObject!(TreePath)(outpath); 929 iter = ObjectG.getDObject!(TreeIter)(outiter, true); 930 931 return __p; 932 } 933 934 /** 935 * Sets @start_path and @end_path to be the first and last visible path. 936 * Note that there may be invisible paths in between. 937 * 938 * The paths should be freed with gtk_tree_path_free() after use. 939 * 940 * Params: 941 * startPath = Return location for start of region, 942 * or %NULL. 943 * endPath = Return location for end of region, or %NULL. 944 * 945 * Returns: %TRUE, if valid paths were placed in @start_path and @end_path. 946 */ 947 public bool getVisibleRange(out TreePath startPath, out TreePath endPath) 948 { 949 GtkTreePath* outstartPath = null; 950 GtkTreePath* outendPath = null; 951 952 auto __p = gtk_tree_view_get_visible_range(gtkTreeView, &outstartPath, &outendPath) != 0; 953 954 startPath = ObjectG.getDObject!(TreePath)(outstartPath); 955 endPath = ObjectG.getDObject!(TreePath)(outendPath); 956 957 return __p; 958 } 959 960 /** 961 * Fills @visible_rect with the currently-visible region of the 962 * buffer, in tree coordinates. Convert to bin_window coordinates with 963 * gtk_tree_view_convert_tree_to_bin_window_coords(). 964 * Tree coordinates start at 0,0 for row 0 of the tree, and cover the entire 965 * scrollable area of the tree. 966 * 967 * Params: 968 * visibleRect = rectangle to fill 969 */ 970 public void getVisibleRect(out GdkRectangle visibleRect) 971 { 972 gtk_tree_view_get_visible_rect(gtkTreeView, &visibleRect); 973 } 974 975 /** 976 * This inserts the @column into the @tree_view at @position. If @position is 977 * -1, then the column is inserted at the end. If @tree_view has 978 * “fixed_height” mode enabled, then @column must have its “sizing” property 979 * set to be GTK_TREE_VIEW_COLUMN_FIXED. 980 * 981 * Params: 982 * column = The #GtkTreeViewColumn to be inserted. 983 * position = The position to insert @column in. 984 * 985 * Returns: The number of columns in @tree_view after insertion. 986 */ 987 public int insertColumn(TreeViewColumn column, int position) 988 { 989 return gtk_tree_view_insert_column(gtkTreeView, (column is null) ? null : column.getTreeViewColumnStruct(), position); 990 } 991 992 /** 993 * Convenience function that inserts a new column into the #GtkTreeView 994 * with the given cell renderer and a #GtkTreeCellDataFunc to set cell renderer 995 * attributes (normally using data from the model). See also 996 * gtk_tree_view_column_set_cell_data_func(), gtk_tree_view_column_pack_start(). 997 * If @tree_view has “fixed_height” mode enabled, then the new column will have its 998 * “sizing” property set to be GTK_TREE_VIEW_COLUMN_FIXED. 999 * 1000 * Params: 1001 * position = Position to insert, -1 for append 1002 * title = column title 1003 * cell = cell renderer for column 1004 * func = function to set attributes of cell renderer 1005 * data = data for @func 1006 * dnotify = destroy notifier for @data 1007 * 1008 * Returns: number of columns in the tree view post-insert 1009 */ 1010 public int insertColumnWithDataFunc(int position, string title, CellRenderer cell, GtkTreeCellDataFunc func, void* data, GDestroyNotify dnotify) 1011 { 1012 return gtk_tree_view_insert_column_with_data_func(gtkTreeView, position, Str.toStringz(title), (cell is null) ? null : cell.getCellRendererStruct(), func, data, dnotify); 1013 } 1014 1015 /** 1016 * Determine whether the point (@x, @y) in @tree_view is blank, that is no 1017 * cell content nor an expander arrow is drawn at the location. If so, the 1018 * location can be considered as the background. You might wish to take 1019 * special action on clicks on the background, such as clearing a current 1020 * selection, having a custom context menu or starting rubber banding. 1021 * 1022 * The @x and @y coordinate that are provided must be relative to bin_window 1023 * coordinates. Widget-relative coordinates must be converted using 1024 * gtk_tree_view_convert_widget_to_bin_window_coords(). 1025 * 1026 * For converting widget coordinates (eg. the ones you get from 1027 * GtkWidget::query-tooltip), please see 1028 * gtk_tree_view_convert_widget_to_bin_window_coords(). 1029 * 1030 * The @path, @column, @cell_x and @cell_y arguments will be filled in 1031 * likewise as for gtk_tree_view_get_path_at_pos(). Please see 1032 * gtk_tree_view_get_path_at_pos() for more information. 1033 * 1034 * Params: 1035 * x = The x position to be identified (relative to bin_window) 1036 * y = The y position to be identified (relative to bin_window) 1037 * path = A pointer to a #GtkTreePath pointer to 1038 * be filled in, or %NULL 1039 * column = A pointer to a 1040 * #GtkTreeViewColumn pointer to be filled in, or %NULL 1041 * cellX = A pointer where the X coordinate relative to the 1042 * cell can be placed, or %NULL 1043 * cellY = A pointer where the Y coordinate relative to the 1044 * cell can be placed, or %NULL 1045 * 1046 * Returns: %TRUE if the area at the given coordinates is blank, 1047 * %FALSE otherwise. 1048 */ 1049 public bool isBlankAtPos(int x, int y, out TreePath path, out TreeViewColumn column, out int cellX, out int cellY) 1050 { 1051 GtkTreePath* outpath = null; 1052 GtkTreeViewColumn* outcolumn = null; 1053 1054 auto __p = gtk_tree_view_is_blank_at_pos(gtkTreeView, x, y, &outpath, &outcolumn, &cellX, &cellY) != 0; 1055 1056 path = ObjectG.getDObject!(TreePath)(outpath); 1057 column = ObjectG.getDObject!(TreeViewColumn)(outcolumn); 1058 1059 return __p; 1060 } 1061 1062 /** 1063 * Returns whether a rubber banding operation is currently being done 1064 * in @tree_view. 1065 * 1066 * Returns: %TRUE if a rubber banding operation is currently being 1067 * done in @tree_view. 1068 */ 1069 public bool isRubberBandingActive() 1070 { 1071 return gtk_tree_view_is_rubber_banding_active(gtkTreeView) != 0; 1072 } 1073 1074 /** 1075 * Calls @func on all expanded rows. 1076 * 1077 * Params: 1078 * func = A function to be called 1079 * data = User data to be passed to the function. 1080 */ 1081 public void mapExpandedRows(GtkTreeViewMappingFunc func, void* data) 1082 { 1083 gtk_tree_view_map_expanded_rows(gtkTreeView, func, data); 1084 } 1085 1086 /** 1087 * Moves @column to be after to @base_column. If @base_column is %NULL, then 1088 * @column is placed in the first position. 1089 * 1090 * Params: 1091 * column = The #GtkTreeViewColumn to be moved. 1092 * baseColumn = The #GtkTreeViewColumn to be moved relative to, or %NULL. 1093 */ 1094 public void moveColumnAfter(TreeViewColumn column, TreeViewColumn baseColumn) 1095 { 1096 gtk_tree_view_move_column_after(gtkTreeView, (column is null) ? null : column.getTreeViewColumnStruct(), (baseColumn is null) ? null : baseColumn.getTreeViewColumnStruct()); 1097 } 1098 1099 /** 1100 * Removes @column from @tree_view. 1101 * 1102 * Params: 1103 * column = The #GtkTreeViewColumn to remove. 1104 * 1105 * Returns: The number of columns in @tree_view after removing. 1106 */ 1107 public int removeColumn(TreeViewColumn column) 1108 { 1109 return gtk_tree_view_remove_column(gtkTreeView, (column is null) ? null : column.getTreeViewColumnStruct()); 1110 } 1111 1112 /** 1113 * Activates the cell determined by @path and @column. 1114 * 1115 * Params: 1116 * path = The #GtkTreePath to be activated. 1117 * column = The #GtkTreeViewColumn to be activated. 1118 */ 1119 public void rowActivated(TreePath path, TreeViewColumn column) 1120 { 1121 gtk_tree_view_row_activated(gtkTreeView, (path is null) ? null : path.getTreePathStruct(), (column is null) ? null : column.getTreeViewColumnStruct()); 1122 } 1123 1124 /** 1125 * Returns %TRUE if the node pointed to by @path is expanded in @tree_view. 1126 * 1127 * Params: 1128 * path = A #GtkTreePath to test expansion state. 1129 * 1130 * Returns: %TRUE if #path is expanded. 1131 */ 1132 public bool rowExpanded(TreePath path) 1133 { 1134 return gtk_tree_view_row_expanded(gtkTreeView, (path is null) ? null : path.getTreePathStruct()) != 0; 1135 } 1136 1137 /** 1138 * Moves the alignments of @tree_view to the position specified by @column and 1139 * @path. If @column is %NULL, then no horizontal scrolling occurs. Likewise, 1140 * if @path is %NULL no vertical scrolling occurs. At a minimum, one of @column 1141 * or @path need to be non-%NULL. @row_align determines where the row is 1142 * placed, and @col_align determines where @column is placed. Both are expected 1143 * to be between 0.0 and 1.0. 0.0 means left/top alignment, 1.0 means 1144 * right/bottom alignment, 0.5 means center. 1145 * 1146 * If @use_align is %FALSE, then the alignment arguments are ignored, and the 1147 * tree does the minimum amount of work to scroll the cell onto the screen. 1148 * This means that the cell will be scrolled to the edge closest to its current 1149 * position. If the cell is currently visible on the screen, nothing is done. 1150 * 1151 * This function only works if the model is set, and @path is a valid row on the 1152 * model. If the model changes before the @tree_view is realized, the centered 1153 * path will be modified to reflect this change. 1154 * 1155 * Params: 1156 * path = The path of the row to move to, or %NULL. 1157 * column = The #GtkTreeViewColumn to move horizontally to, or %NULL. 1158 * useAlign = whether to use alignment arguments, or %FALSE. 1159 * rowAlign = The vertical alignment of the row specified by @path. 1160 * colAlign = The horizontal alignment of the column specified by @column. 1161 */ 1162 public void scrollToCell(TreePath path, TreeViewColumn column, bool useAlign, float rowAlign, float colAlign) 1163 { 1164 gtk_tree_view_scroll_to_cell(gtkTreeView, (path is null) ? null : path.getTreePathStruct(), (column is null) ? null : column.getTreeViewColumnStruct(), useAlign, rowAlign, colAlign); 1165 } 1166 1167 /** 1168 * Scrolls the tree view such that the top-left corner of the visible 1169 * area is @tree_x, @tree_y, where @tree_x and @tree_y are specified 1170 * in tree coordinates. The @tree_view must be realized before 1171 * this function is called. If it isn't, you probably want to be 1172 * using gtk_tree_view_scroll_to_cell(). 1173 * 1174 * If either @tree_x or @tree_y are -1, then that direction isn’t scrolled. 1175 * 1176 * Params: 1177 * treeX = X coordinate of new top-left pixel of visible area, or -1 1178 * treeY = Y coordinate of new top-left pixel of visible area, or -1 1179 */ 1180 public void scrollToPoint(int treeX, int treeY) 1181 { 1182 gtk_tree_view_scroll_to_point(gtkTreeView, treeX, treeY); 1183 } 1184 1185 /** 1186 * Cause the #GtkTreeView::row-activated signal to be emitted 1187 * on a single click instead of a double click. 1188 * 1189 * Params: 1190 * single = %TRUE to emit row-activated on a single click 1191 */ 1192 public void setActivateOnSingleClick(bool single) 1193 { 1194 gtk_tree_view_set_activate_on_single_click(gtkTreeView, single); 1195 } 1196 1197 /** 1198 * Sets a user function for determining where a column may be dropped when 1199 * dragged. This function is called on every column pair in turn at the 1200 * beginning of a column drag to determine where a drop can take place. The 1201 * arguments passed to @func are: the @tree_view, the #GtkTreeViewColumn being 1202 * dragged, the two #GtkTreeViewColumn s determining the drop spot, and 1203 * @user_data. If either of the #GtkTreeViewColumn arguments for the drop spot 1204 * are %NULL, then they indicate an edge. If @func is set to be %NULL, then 1205 * @tree_view reverts to the default behavior of allowing all columns to be 1206 * dropped everywhere. 1207 * 1208 * Params: 1209 * func = A function to determine which columns are reorderable, or %NULL. 1210 * userData = User data to be passed to @func, or %NULL 1211 * destroy = Destroy notifier for @user_data, or %NULL 1212 */ 1213 public void setColumnDragFunction(GtkTreeViewColumnDropFunc func, void* userData, GDestroyNotify destroy) 1214 { 1215 gtk_tree_view_set_column_drag_function(gtkTreeView, func, userData, destroy); 1216 } 1217 1218 /** 1219 * Sets the current keyboard focus to be at @path, and selects it. This is 1220 * useful when you want to focus the user’s attention on a particular row. If 1221 * @focus_column is not %NULL, then focus is given to the column specified by 1222 * it. Additionally, if @focus_column is specified, and @start_editing is 1223 * %TRUE, then editing should be started in the specified cell. 1224 * This function is often followed by @gtk_widget_grab_focus (@tree_view) 1225 * in order to give keyboard focus to the widget. Please note that editing 1226 * can only happen when the widget is realized. 1227 * 1228 * If @path is invalid for @model, the current cursor (if any) will be unset 1229 * and the function will return without failing. 1230 * 1231 * Params: 1232 * path = A #GtkTreePath 1233 * focusColumn = A #GtkTreeViewColumn, or %NULL 1234 * startEditing = %TRUE if the specified cell should start being edited. 1235 */ 1236 public void setCursor(TreePath path, TreeViewColumn focusColumn, bool startEditing) 1237 { 1238 gtk_tree_view_set_cursor(gtkTreeView, (path is null) ? null : path.getTreePathStruct(), (focusColumn is null) ? null : focusColumn.getTreeViewColumnStruct(), startEditing); 1239 } 1240 1241 /** 1242 * Sets the current keyboard focus to be at @path, and selects it. This is 1243 * useful when you want to focus the user’s attention on a particular row. If 1244 * @focus_column is not %NULL, then focus is given to the column specified by 1245 * it. If @focus_column and @focus_cell are not %NULL, and @focus_column 1246 * contains 2 or more editable or activatable cells, then focus is given to 1247 * the cell specified by @focus_cell. Additionally, if @focus_column is 1248 * specified, and @start_editing is %TRUE, then editing should be started in 1249 * the specified cell. This function is often followed by 1250 * @gtk_widget_grab_focus (@tree_view) in order to give keyboard focus to the 1251 * widget. Please note that editing can only happen when the widget is 1252 * realized. 1253 * 1254 * If @path is invalid for @model, the current cursor (if any) will be unset 1255 * and the function will return without failing. 1256 * 1257 * Params: 1258 * path = A #GtkTreePath 1259 * focusColumn = A #GtkTreeViewColumn, or %NULL 1260 * focusCell = A #GtkCellRenderer, or %NULL 1261 * startEditing = %TRUE if the specified cell should start being edited. 1262 */ 1263 public void setCursorOnCell(TreePath path, TreeViewColumn focusColumn, CellRenderer focusCell, bool startEditing) 1264 { 1265 gtk_tree_view_set_cursor_on_cell(gtkTreeView, (path is null) ? null : path.getTreePathStruct(), (focusColumn is null) ? null : focusColumn.getTreeViewColumnStruct(), (focusCell is null) ? null : focusCell.getCellRendererStruct(), startEditing); 1266 } 1267 1268 /** 1269 * Sets the row that is highlighted for feedback. 1270 * If @path is %NULL, an existing highlight is removed. 1271 * 1272 * Params: 1273 * path = The path of the row to highlight, or %NULL 1274 * pos = Specifies whether to drop before, after or into the row 1275 */ 1276 public void setDragDestRow(TreePath path, GtkTreeViewDropPosition pos) 1277 { 1278 gtk_tree_view_set_drag_dest_row(gtkTreeView, (path is null) ? null : path.getTreePathStruct(), pos); 1279 } 1280 1281 /** 1282 * If @enable_search is set, then the user can type in text to search through 1283 * the tree interactively (this is sometimes called "typeahead find"). 1284 * 1285 * Note that even if this is %FALSE, the user can still initiate a search 1286 * using the “start-interactive-search” key binding. 1287 * 1288 * Params: 1289 * enableSearch = %TRUE, if the user can search interactively 1290 */ 1291 public void setEnableSearch(bool enableSearch) 1292 { 1293 gtk_tree_view_set_enable_search(gtkTreeView, enableSearch); 1294 } 1295 1296 /** 1297 * Sets whether to draw lines interconnecting the expanders in @tree_view. 1298 * This does not have any visible effects for lists. 1299 * 1300 * Params: 1301 * enabled = %TRUE to enable tree line drawing, %FALSE otherwise. 1302 */ 1303 public void setEnableTreeLines(bool enabled) 1304 { 1305 gtk_tree_view_set_enable_tree_lines(gtkTreeView, enabled); 1306 } 1307 1308 /** 1309 * Sets the column to draw the expander arrow at. It must be in @tree_view. 1310 * If @column is %NULL, then the expander arrow is always at the first 1311 * visible column. 1312 * 1313 * If you do not want expander arrow to appear in your tree, set the 1314 * expander column to a hidden column. 1315 * 1316 * Params: 1317 * column = %NULL, or the column to draw the expander arrow at. 1318 */ 1319 public void setExpanderColumn(TreeViewColumn column) 1320 { 1321 gtk_tree_view_set_expander_column(gtkTreeView, (column is null) ? null : column.getTreeViewColumnStruct()); 1322 } 1323 1324 /** 1325 * Enables or disables the fixed height mode of @tree_view. 1326 * Fixed height mode speeds up #GtkTreeView by assuming that all 1327 * rows have the same height. 1328 * Only enable this option if all rows are the same height and all 1329 * columns are of type %GTK_TREE_VIEW_COLUMN_FIXED. 1330 * 1331 * Params: 1332 * enable = %TRUE to enable fixed height mode 1333 */ 1334 public void setFixedHeightMode(bool enable) 1335 { 1336 gtk_tree_view_set_fixed_height_mode(gtkTreeView, enable); 1337 } 1338 1339 /** 1340 * Sets which grid lines to draw in @tree_view. 1341 * 1342 * Params: 1343 * gridLines = a #GtkTreeViewGridLines value indicating which grid lines to 1344 * enable. 1345 */ 1346 public void setGridLines(GtkTreeViewGridLines gridLines) 1347 { 1348 gtk_tree_view_set_grid_lines(gtkTreeView, gridLines); 1349 } 1350 1351 /** 1352 * Allow the column title buttons to be clicked. 1353 * 1354 * Params: 1355 * setting = %TRUE if the columns are clickable. 1356 */ 1357 public void setHeadersClickable(bool setting) 1358 { 1359 gtk_tree_view_set_headers_clickable(gtkTreeView, setting); 1360 } 1361 1362 /** 1363 * Sets the visibility state of the headers. 1364 * 1365 * Params: 1366 * headersVisible = %TRUE if the headers are visible 1367 */ 1368 public void setHeadersVisible(bool headersVisible) 1369 { 1370 gtk_tree_view_set_headers_visible(gtkTreeView, headersVisible); 1371 } 1372 1373 /** 1374 * Enables or disables the hover expansion mode of @tree_view. 1375 * Hover expansion makes rows expand or collapse if the pointer 1376 * moves over them. 1377 * 1378 * Params: 1379 * expand = %TRUE to enable hover selection mode 1380 */ 1381 public void setHoverExpand(bool expand) 1382 { 1383 gtk_tree_view_set_hover_expand(gtkTreeView, expand); 1384 } 1385 1386 /** 1387 * Enables or disables the hover selection mode of @tree_view. 1388 * Hover selection makes the selected row follow the pointer. 1389 * Currently, this works only for the selection modes 1390 * %GTK_SELECTION_SINGLE and %GTK_SELECTION_BROWSE. 1391 * 1392 * Params: 1393 * hover = %TRUE to enable hover selection mode 1394 */ 1395 public void setHoverSelection(bool hover) 1396 { 1397 gtk_tree_view_set_hover_selection(gtkTreeView, hover); 1398 } 1399 1400 /** 1401 * Sets the amount of extra indentation for child levels to use in @tree_view 1402 * in addition to the default indentation. The value should be specified in 1403 * pixels, a value of 0 disables this feature and in this case only the default 1404 * indentation will be used. 1405 * This does not have any visible effects for lists. 1406 * 1407 * Params: 1408 * indentation = the amount, in pixels, of extra indentation in @tree_view. 1409 */ 1410 public void setLevelIndentation(int indentation) 1411 { 1412 gtk_tree_view_set_level_indentation(gtkTreeView, indentation); 1413 } 1414 1415 /** 1416 * Sets the model for a #GtkTreeView. If the @tree_view already has a model 1417 * set, it will remove it before setting the new model. If @model is %NULL, 1418 * then it will unset the old model. 1419 * 1420 * Params: 1421 * model = The model. 1422 */ 1423 public void setModel(TreeModelIF model) 1424 { 1425 gtk_tree_view_set_model(gtkTreeView, (model is null) ? null : model.getTreeModelStruct()); 1426 } 1427 1428 /** 1429 * This function is a convenience function to allow you to reorder 1430 * models that support the #GtkTreeDragSourceIface and the 1431 * #GtkTreeDragDestIface. Both #GtkTreeStore and #GtkListStore support 1432 * these. If @reorderable is %TRUE, then the user can reorder the 1433 * model by dragging and dropping rows. The developer can listen to 1434 * these changes by connecting to the model’s #GtkTreeModel::row-inserted 1435 * and #GtkTreeModel::row-deleted signals. The reordering is implemented 1436 * by setting up the tree view as a drag source and destination. 1437 * Therefore, drag and drop can not be used in a reorderable view for any 1438 * other purpose. 1439 * 1440 * This function does not give you any degree of control over the order -- any 1441 * reordering is allowed. If more control is needed, you should probably 1442 * handle drag and drop manually. 1443 * 1444 * Params: 1445 * reorderable = %TRUE, if the tree can be reordered. 1446 */ 1447 public void setReorderable(bool reorderable) 1448 { 1449 gtk_tree_view_set_reorderable(gtkTreeView, reorderable); 1450 } 1451 1452 /** 1453 * Sets the row separator function, which is used to determine 1454 * whether a row should be drawn as a separator. If the row separator 1455 * function is %NULL, no separators are drawn. This is the default value. 1456 * 1457 * Params: 1458 * func = a #GtkTreeViewRowSeparatorFunc 1459 * data = user data to pass to @func, or %NULL 1460 * destroy = destroy notifier for @data, or %NULL 1461 */ 1462 public void setRowSeparatorFunc(GtkTreeViewRowSeparatorFunc func, void* data, GDestroyNotify destroy) 1463 { 1464 gtk_tree_view_set_row_separator_func(gtkTreeView, func, data, destroy); 1465 } 1466 1467 /** 1468 * Enables or disables rubber banding in @tree_view. If the selection mode 1469 * is #GTK_SELECTION_MULTIPLE, rubber banding will allow the user to select 1470 * multiple rows by dragging the mouse. 1471 * 1472 * Params: 1473 * enable = %TRUE to enable rubber banding 1474 */ 1475 public void setRubberBanding(bool enable) 1476 { 1477 gtk_tree_view_set_rubber_banding(gtkTreeView, enable); 1478 } 1479 1480 /** 1481 * Sets @column as the column where the interactive search code should 1482 * search in for the current model. 1483 * 1484 * If the search column is set, users can use the “start-interactive-search” 1485 * key binding to bring up search popup. The enable-search property controls 1486 * whether simply typing text will also start an interactive search. 1487 * 1488 * Note that @column refers to a column of the current model. The search 1489 * column is reset to -1 when the model is changed. 1490 * 1491 * Params: 1492 * column = the column of the model to search in, or -1 to disable searching 1493 */ 1494 public void setSearchColumn(int column) 1495 { 1496 gtk_tree_view_set_search_column(gtkTreeView, column); 1497 } 1498 1499 /** 1500 * Sets the entry which the interactive search code will use for this 1501 * @tree_view. This is useful when you want to provide a search entry 1502 * in our interface at all time at a fixed position. Passing %NULL for 1503 * @entry will make the interactive search code use the built-in popup 1504 * entry again. 1505 * 1506 * Params: 1507 * entry = the entry the interactive search code of @tree_view should use or %NULL 1508 */ 1509 public void setSearchEntry(EditableIF entry) 1510 { 1511 gtk_tree_view_set_search_entry(gtkTreeView, (entry is null) ? null : entry.getEditableStruct()); 1512 } 1513 1514 /** 1515 * Sets the compare function for the interactive search capabilities; note 1516 * that somewhat like strcmp() returning 0 for equality 1517 * #GtkTreeViewSearchEqualFunc returns %FALSE on matches. 1518 * 1519 * Params: 1520 * searchEqualFunc = the compare function to use during the search 1521 * searchUserData = user data to pass to @search_equal_func, or %NULL 1522 * searchDestroy = Destroy notifier for @search_user_data, or %NULL 1523 */ 1524 public void setSearchEqualFunc(GtkTreeViewSearchEqualFunc searchEqualFunc, void* searchUserData, GDestroyNotify searchDestroy) 1525 { 1526 gtk_tree_view_set_search_equal_func(gtkTreeView, searchEqualFunc, searchUserData, searchDestroy); 1527 } 1528 1529 /** 1530 * Sets whether to draw and enable expanders and indent child rows in 1531 * @tree_view. When disabled there will be no expanders visible in trees 1532 * and there will be no way to expand and collapse rows by default. Also 1533 * note that hiding the expanders will disable the default indentation. You 1534 * can set a custom indentation in this case using 1535 * gtk_tree_view_set_level_indentation(). 1536 * This does not have any visible effects for lists. 1537 * 1538 * Params: 1539 * enabled = %TRUE to enable expander drawing, %FALSE otherwise. 1540 */ 1541 public void setShowExpanders(bool enabled) 1542 { 1543 gtk_tree_view_set_show_expanders(gtkTreeView, enabled); 1544 } 1545 1546 /** 1547 * Sets the tip area of @tooltip to the area @path, @column and @cell have 1548 * in common. For example if @path is %NULL and @column is set, the tip 1549 * area will be set to the full area covered by @column. See also 1550 * gtk_tooltip_set_tip_area(). 1551 * 1552 * Note that if @path is not specified and @cell is set and part of a column 1553 * containing the expander, the tooltip might not show and hide at the correct 1554 * position. In such cases @path must be set to the current node under the 1555 * mouse cursor for this function to operate correctly. 1556 * 1557 * See also gtk_tree_view_set_tooltip_column() for a simpler alternative. 1558 * 1559 * Params: 1560 * tooltip = a #GtkTooltip 1561 * path = a #GtkTreePath or %NULL 1562 * column = a #GtkTreeViewColumn or %NULL 1563 * cell = a #GtkCellRenderer or %NULL 1564 */ 1565 public void setTooltipCell(Tooltip tooltip, TreePath path, TreeViewColumn column, CellRenderer cell) 1566 { 1567 gtk_tree_view_set_tooltip_cell(gtkTreeView, (tooltip is null) ? null : tooltip.getTooltipStruct(), (path is null) ? null : path.getTreePathStruct(), (column is null) ? null : column.getTreeViewColumnStruct(), (cell is null) ? null : cell.getCellRendererStruct()); 1568 } 1569 1570 /** 1571 * If you only plan to have simple (text-only) tooltips on full rows, you 1572 * can use this function to have #GtkTreeView handle these automatically 1573 * for you. @column should be set to the column in @tree_view’s model 1574 * containing the tooltip texts, or -1 to disable this feature. 1575 * 1576 * When enabled, #GtkWidget:has-tooltip will be set to %TRUE and 1577 * @tree_view will connect a #GtkWidget::query-tooltip signal handler. 1578 * 1579 * Note that the signal handler sets the text with gtk_tooltip_set_markup(), 1580 * so &, <, etc have to be escaped in the text. 1581 * 1582 * Params: 1583 * column = an integer, which is a valid column number for @tree_view’s model 1584 */ 1585 public void setTooltipColumn(int column) 1586 { 1587 gtk_tree_view_set_tooltip_column(gtkTreeView, column); 1588 } 1589 1590 /** 1591 * Sets the tip area of @tooltip to be the area covered by the row at @path. 1592 * See also gtk_tree_view_set_tooltip_column() for a simpler alternative. 1593 * See also gtk_tooltip_set_tip_area(). 1594 * 1595 * Params: 1596 * tooltip = a #GtkTooltip 1597 * path = a #GtkTreePath 1598 */ 1599 public void setTooltipRow(Tooltip tooltip, TreePath path) 1600 { 1601 gtk_tree_view_set_tooltip_row(gtkTreeView, (tooltip is null) ? null : tooltip.getTooltipStruct(), (path is null) ? null : path.getTreePathStruct()); 1602 } 1603 1604 /** 1605 * Undoes the effect of 1606 * gtk_tree_view_enable_model_drag_dest(). Calling this method sets 1607 * #GtkTreeView:reorderable to %FALSE. 1608 */ 1609 public void unsetRowsDragDest() 1610 { 1611 gtk_tree_view_unset_rows_drag_dest(gtkTreeView); 1612 } 1613 1614 /** 1615 * Undoes the effect of 1616 * gtk_tree_view_enable_model_drag_source(). Calling this method sets 1617 * #GtkTreeView:reorderable to %FALSE. 1618 */ 1619 public void unsetRowsDragSource() 1620 { 1621 gtk_tree_view_unset_rows_drag_source(gtkTreeView); 1622 } 1623 1624 /** 1625 * The number of columns of the treeview has changed. 1626 */ 1627 gulong addOnColumnsChanged(void delegate(TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1628 { 1629 return Signals.connect(this, "columns-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1630 } 1631 1632 /** 1633 * The position of the cursor (focused cell) has changed. 1634 */ 1635 gulong addOnCursorChanged(void delegate(TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1636 { 1637 return Signals.connect(this, "cursor-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1638 } 1639 1640 /** */ 1641 gulong addOnExpandCollapseCursorRow(bool delegate(bool, bool, bool, TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1642 { 1643 return Signals.connect(this, "expand-collapse-cursor-row", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1644 } 1645 1646 /** 1647 * The #GtkTreeView::move-cursor signal is a [keybinding 1648 * signal][GtkSignalAction] which gets emitted when the user 1649 * presses one of the cursor keys. 1650 * 1651 * Applications should not connect to it, but may emit it with 1652 * g_signal_emit_by_name() if they need to control the cursor 1653 * programmatically. In contrast to gtk_tree_view_set_cursor() and 1654 * gtk_tree_view_set_cursor_on_cell() when moving horizontally 1655 * #GtkTreeView::move-cursor does not reset the current selection. 1656 * 1657 * Params: 1658 * step = the granularity of the move, as a #GtkMovementStep. 1659 * %GTK_MOVEMENT_LOGICAL_POSITIONS, %GTK_MOVEMENT_VISUAL_POSITIONS, 1660 * %GTK_MOVEMENT_DISPLAY_LINES, %GTK_MOVEMENT_PAGES and 1661 * %GTK_MOVEMENT_BUFFER_ENDS are supported. 1662 * %GTK_MOVEMENT_LOGICAL_POSITIONS and %GTK_MOVEMENT_VISUAL_POSITIONS 1663 * are treated identically. 1664 * direction = the direction to move: +1 to move forwards; -1 to move 1665 * backwards. The resulting movement is undefined for all other values. 1666 * extend = whether to extend the selection 1667 * modify = whether to modify the selection 1668 * 1669 * Returns: %TRUE if @step is supported, %FALSE otherwise. 1670 */ 1671 gulong addOnMoveCursor(bool delegate(GtkMovementStep, int, bool, bool, TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1672 { 1673 return Signals.connect(this, "move-cursor", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1674 } 1675 1676 /** 1677 * The "row-activated" signal is emitted when the method 1678 * gtk_tree_view_row_activated() is called, when the user double 1679 * clicks a treeview row with the "activate-on-single-click" 1680 * property set to %FALSE, or when the user single clicks a row when 1681 * the "activate-on-single-click" property set to %TRUE. It is also 1682 * emitted when a non-editable row is selected and one of the keys: 1683 * Space, Shift+Space, Return or Enter is pressed. 1684 * 1685 * For selection handling refer to the 1686 * [tree widget conceptual overview][TreeWidget] 1687 * as well as #GtkTreeSelection. 1688 * 1689 * Params: 1690 * path = the #GtkTreePath for the activated row 1691 * column = the #GtkTreeViewColumn in which the activation occurred 1692 */ 1693 gulong addOnRowActivated(void delegate(TreePath, TreeViewColumn, TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1694 { 1695 return Signals.connect(this, "row-activated", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1696 } 1697 1698 /** 1699 * The given row has been collapsed (child nodes are hidden). 1700 * 1701 * Params: 1702 * iter = the tree iter of the collapsed row 1703 * path = a tree path that points to the row 1704 */ 1705 gulong addOnRowCollapsed(void delegate(TreeIter, TreePath, TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1706 { 1707 return Signals.connect(this, "row-collapsed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1708 } 1709 1710 /** 1711 * The given row has been expanded (child nodes are shown). 1712 * 1713 * Params: 1714 * iter = the tree iter of the expanded row 1715 * path = a tree path that points to the row 1716 */ 1717 gulong addOnRowExpanded(void delegate(TreeIter, TreePath, TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1718 { 1719 return Signals.connect(this, "row-expanded", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1720 } 1721 1722 /** */ 1723 gulong addOnSelectAll(bool delegate(TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1724 { 1725 return Signals.connect(this, "select-all", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1726 } 1727 1728 /** */ 1729 gulong addOnSelectCursorParent(bool delegate(TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1730 { 1731 return Signals.connect(this, "select-cursor-parent", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1732 } 1733 1734 /** */ 1735 gulong addOnSelectCursorRow(bool delegate(bool, TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1736 { 1737 return Signals.connect(this, "select-cursor-row", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1738 } 1739 1740 /** */ 1741 gulong addOnStartInteractiveSearch(bool delegate(TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1742 { 1743 return Signals.connect(this, "start-interactive-search", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1744 } 1745 1746 /** 1747 * The given row is about to be collapsed (hide its children nodes). Use this 1748 * signal if you need to control the collapsibility of individual rows. 1749 * 1750 * Params: 1751 * iter = the tree iter of the row to collapse 1752 * path = a tree path that points to the row 1753 * 1754 * Returns: %FALSE to allow collapsing, %TRUE to reject 1755 */ 1756 gulong addOnTestCollapseRow(bool delegate(TreeIter, TreePath, TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1757 { 1758 return Signals.connect(this, "test-collapse-row", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1759 } 1760 1761 /** 1762 * The given row is about to be expanded (show its children nodes). Use this 1763 * signal if you need to control the expandability of individual rows. 1764 * 1765 * Params: 1766 * iter = the tree iter of the row to expand 1767 * path = a tree path that points to the row 1768 * 1769 * Returns: %FALSE to allow expansion, %TRUE to reject 1770 */ 1771 gulong addOnTestExpandRow(bool delegate(TreeIter, TreePath, TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1772 { 1773 return Signals.connect(this, "test-expand-row", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1774 } 1775 1776 /** */ 1777 gulong addOnToggleCursorRow(bool delegate(TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1778 { 1779 return Signals.connect(this, "toggle-cursor-row", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1780 } 1781 1782 /** */ 1783 gulong addOnUnselectAll(bool delegate(TreeView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1784 { 1785 return Signals.connect(this, "unselect-all", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1786 } 1787 }