eb05362005-11-05Henrik Grubbström (Grubba) /* -*- C -*- */
1a05542005-07-28Martin Nilsson class GTK2.TreeView; inherit GTK2.Container; //! Properties: //! int enable-search //! GTK2.TreeViewColumn expander-column require gtk24; //! int fixed-height-mode endrequire; //! GTK2.Adjustment hadjustment //! int headers-clickable //! int headers-visible require gtk26; //! int hover-expand //! int hover-selection endrequire;
c37a152007-10-14Lance Dillon require gtk212; //! int level-indentation endrequire;
1a05542005-07-28Martin Nilsson //! GTK2.TreeModel model //! int reorderable //! int rules-hint //! int search-column
c37a152007-10-14Lance Dillon require gtk212; //! int show-expanders endrequire;
1a05542005-07-28Martin Nilsson //! GTK2.Adjustment vadjustment //! <p> //! Style properties: //! int allow-rules //! GDK2.Color even-row-color //! int expander-size //! int horizontal-separator //! int indent-expanders //! GDK2.Color odd-row-color //! int vertical-separator signal columns_changed; signal cursor_changed; signal expand_collapse_cursor_row; signal move_cursor; signal row_activated; signal row_collapsed; signal row_expanded; signal select_all; signal select_cursor_parent; signal select_cursor_row; signal set_scroll_adjustments; signal start_interactive_search; signal test_collapse_row; signal test_expand_row; signal toggle_cursor_row; signal unselect_all;
3d76632005-11-03Lance Dillon void create(GTK2.TreeModel|mapping(string:mixed)|void model_or_props)
1a05542005-07-28Martin Nilsson //! Create a new W(TreeView), with or without a default model. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_not_inited(); pgtk2_verify_setup();
1a05542005-07-28Martin Nilsson  if (args) {
017b572011-10-28Henrik Grubbström (Grubba)  if (TYPEOF(Pike_sp[-args]) == PIKE_T_OBJECT) {
3d76632005-11-03Lance Dillon  struct object *o1; GtkTreeModel *gtm; GtkWidget *gt;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%o",&o1);
3d76632005-11-03Lance Dillon  gtm=GTK_TREE_MODEL(get_gobject(o1)); if (gtm) { gt=gtk_tree_view_new_with_model(gtm); } else { gt=gtk_tree_view_new(); } THIS->obj=G_OBJECT(gt);
1a05542005-07-28Martin Nilsson  } else {
3d76632005-11-03Lance Dillon  INIT_WITH_PROPS(GTK_TYPE_TREE_VIEW);
1a05542005-07-28Martin Nilsson  }
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  } else {
3d76632005-11-03Lance Dillon  GtkWidget *gt; gt=gtk_tree_view_new(); THIS->obj=G_OBJECT(gt);
1a05542005-07-28Martin Nilsson  }
ba9e802006-02-27Martin Stjernholm  pgtk2__init_this_object();
1a05542005-07-28Martin Nilsson }
c37a152007-10-14Lance Dillon require gtk212; int get_level_indentation(); //! Returns the amount, in pixels, of extra indentation for child levels int get_show_expanders(); //! Returns whether or not expanders are drawn void set_show_expanders(int show); //! Sets whether to draw and enable expanders and indent child rows. endrequire;
f284492006-08-03Lance Dillon +GTK2.TreeModel get_model();
1a05542005-07-28Martin Nilsson //! Returns the model this TreeView is based on.
d0dfbd2014-10-19Chris Angelico +GTK2.TreeView set_model(GTK2.TreeModel model)
1a05542005-07-28Martin Nilsson //! Sets the model. If this TreeView already has a model set, it will remove //! it before setting the new model.
d0dfbd2014-10-19Chris Angelico { pgtk2_verify_inited(); if (args) { struct object *o1;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%o",&o1);
d0dfbd2014-10-19Chris Angelico  gtk_tree_view_set_model(GTK_TREE_VIEW(THIS->obj), GTK_TREE_MODEL(get_gobject(o1))); } else { gtk_tree_view_set_model(GTK_TREE_VIEW(THIS->obj),NULL); } RETURN_THIS(); }
1a05542005-07-28Martin Nilsson 
f284492006-08-03Lance Dillon +GTK2.TreeSelection get_selection();
1a05542005-07-28Martin Nilsson //! Gets the W(TreeSelection) associated with this TreeView.
f284492006-08-03Lance Dillon +GTK2.Adjustment get_hadjustment();
1a05542005-07-28Martin Nilsson //! Gets the W(Adjustment) currently being used for the horizontal aspect. void set_hadjustment(GTK2.Adjustment hadj); //! Sets the W(Adjustment) for the current horizontal aspect.
f284492006-08-03Lance Dillon +GTK2.Adjustment get_vadjustment();
1a05542005-07-28Martin Nilsson //! Gets the W(Adjustment) currently being used for the vertical aspect. void set_vadjustment(GTK2.Adjustment vadj); //! Sets the W(Adjustment) for the current vertical aspect. int get_headers_visible(); //! Returns true if the headers are visible. void set_headers_visible(int headers_visible); //! Sets the visibility state of the headers. void columns_autosize(); //! Resizes all columns to their optimal width. Only works after the treeview //! has been realized.
f284492006-08-03Lance Dillon require gtk210; int get_headers_clickable(); //! Returns whether all header columns are clickable. endrequire;
1a05542005-07-28Martin Nilsson void set_headers_clickable(int setting); //! Allow the column title buttons to be clicked. void set_rules_hint(int setting); //! This function tells GTK2+ that the user interface for your application //! requires users to read across tree rows and associate cells with one //! another. By default, GTK2+ will then render the tree with alternating row //! colors. Do not use it just because you prefer the appearance of the //! ruled tree; that's a question for the theme. Some themes will draw tree //! rows in alternating colors even when rules are turned off, and users who //! prefer that appearance all the time can choose those themes. You should //! call this function only as a semantic hint to the theme engine that your //! tree makes alternating colors usefull from a functional standpoint //! (since it has lots of columns, generally). int get_rules_hint(); //! Gets the setting set by set_rules_hint(). void append_column(GTK2.TreeViewColumn column); //! Appends column to the list of columns. If this tree view has //! "fixed_height" mode enabled, then column must have its "sizing" property //! set to be GTK2.TREE_VIEW_COLUMN_FIXED. int remove_column(GTK2.TreeViewColumn column); //! Removes column. int insert_column(GTK2.TreeViewColumn column, int position); //! This inserts the column at position. If position is -1, then the column //! is inserted at the end. If this tree view has "fixed_height" mode //! enabled, then column must have its "sizing property set to //! GTK2.TREE_VIEW_COLUMN_FIXED. GTK2.TreeViewColumn get_column(int n); //! Gets the W(TreeViewColumn) at the given position. array(GTK2.TreeViewColumn) get_columns() //! Returns an array of all the W(TreeViewColumn)'s current in the view. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited(); pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  { GList *gl,*g2; int i=0; gl=g2=gtk_tree_view_get_columns(GTK_TREE_VIEW(THIS->obj)); while (g2) { push_gobject(GTK_TREE_VIEW_COLUMN(g2->data)); g_object_ref(GTK_TREE_VIEW_COLUMN(g2->data)); i++; g2=g_list_next(g2); } f_aggregate(i); g_list_free(gl); } } void move_column_after(GTK2.TreeViewColumn column, ?GTK2.TreeViewColumn base); //! Moves column to be after base. If base is omitted, then column is //! placed in the first position. void set_expander_column(?GTK2.TreeViewColumn column); //! Sets the column to draw the expander arrow at. It must be in the view. //! If column is omitted, then the expander arrow is always at the first //! visible column.
f284492006-08-03Lance Dillon +GTK2.TreeViewColumn get_expander_column();
1a05542005-07-28Martin Nilsson //! Returns the column that is the current expander column. This column has //! the expander arrow drawn next to it. void scroll_to_point(int x, int y); //! Scrolls the tree view such that the top-left corner of the visible area //! is x,y, where x and y are specified in tree window coordinates. The view //! must be realized before this function is called. If it isn't, you //! probably want to be using scroll_to_cell(). //! <p> //! If either x or y are -1, then that direction isn't scrolled.
3e0ef52016-10-24Chris Angelico void scroll_to_cell(GTK2.TreePath path, ?GTK2.TreeViewColumn column,
1a05542005-07-28Martin Nilsson  ?float row_align, ?float col_align) //! Moves the alignments of the view to the position specified by column and //! path. If column is 0, then no horizontal scrolling occurs. Likewise, if //! path is 0, no vertical scrolling occurs. At a minimum, one of column or //! path needs to be non-zero. row_align determines where the row is placed, //! and col_align determines where column is placed. Both are expected to be //! between 0.0 and 1.0. 0.0 means left/top alignment, 1.0 means right/bottom //! alignment, 0.5 means center. //! <p> //! If row_align exists, then col_align must exist, otherwise neither will be //! used. If neither are used, the tree does the minimum amount of work to //! scroll the cell onto the screen. This means that the cell will be scrolled //! to the edge closest to its current position. If the cell is currently //! visible on the screen, nothing is done. //! <p> //! This function only works if the model is set, and path is a valid row on //! the model. If the model changes before the view is realized, the centered //! path will be modifed to reflect this change. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  {
3e0ef52016-10-24Chris Angelico  struct object *o1,*o2=0;
cac4202005-12-17Marcus Comstedt  FLOAT_TYPE row_align=0,col_align=0;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%o.%O%f%f",&o1,&o2,
3d76632005-11-03Lance Dillon  &row_align,&col_align); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(THIS->obj),
67ad922011-11-21Lance Dillon  (GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program),
3e0ef52016-10-24Chris Angelico  o2 ? GTK_TREE_VIEW_COLUMN(get_gobject(o2)) : 0,
1a05542005-07-28Martin Nilsson  1,row_align,col_align); } RETURN_THIS(); } void set_cursor(GTK2.TreePath path, ?GTK2.TreeViewColumn focus_column, ?int start_editing) //! Sets the current keyboard focus to be at path, and selects it. This is //! useful when you want to focus the user's attention on a particular row. //! If focus_column is present, then focus is given to the column specified by //! it. Additionally, if focus_column is specified, and start_editing is //! true, then editing should be started in the specified cell. This function //! is often followed by grab_focus() in order to give keyboard focus to the //! widget. Please note that editing can only happen when the widget is //! realized. {
4a7cc12005-12-28Martin Nilsson  struct object *o1,*o2=NULL; INT_TYPE ed=0;
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
4a7cc12005-12-28Martin Nilsson 
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%o.%o%i",&o1,&o2,&ed);
4a7cc12005-12-28Martin Nilsson  gtk_tree_view_set_cursor(GTK_TREE_VIEW(THIS->obj),
67ad922011-11-21Lance Dillon  (GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program),
4a7cc12005-12-28Martin Nilsson  GTK_TREE_VIEW_COLUMN(get_gobject(o2)),ed);
1a05542005-07-28Martin Nilsson  RETURN_THIS(); } require gtk22; void set_cursor_on_cell(GTK2.TreePath path, ?GTK2.TreeViewColumn focus_column, ?int start_editing, ?GTK2.CellRenderer focus_cell) //! Sets the current keyboard focus to be at path, and selects it. This is //! useful when you want to focus the user's attention on a particular row. //! If focus_column is present, then focus is given to the column specified by //! it. If focus_column and focus_cell are present, and focus_column contains //! 2 or more editable or activatable cells, then focus is given to the cell //! specified by focus_cell. Additionally, if focus_column is specified, and //! start_editing is true, then editing should be started in the specified //! cell. This function is often followed by grab_focus() in order to give //! keyboard focus to the widget. Please note that editing can only happen //! when the widget is realized. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { struct object *o1,*o2=NULL,*o3=NULL;
cac4202005-12-17Marcus Comstedt  INT_TYPE ed=0;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%o.%o%i%o",&o1,&o2,&ed,&o3);
1a05542005-07-28Martin Nilsson  gtk_tree_view_set_cursor_on_cell(GTK_TREE_VIEW(THIS->obj),
67ad922011-11-21Lance Dillon  (GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program),
1a05542005-07-28Martin Nilsson  GTK_TREE_VIEW_COLUMN(get_gobject(o2)), GTK_CELL_RENDERER(get_gobject(o3)),ed); } RETURN_THIS(); } endrequire; mapping(string:object) get_cursor() //! Returns the current path and focus column. If the cursor isn't currently //! set, then "path" will be 0. If no column currently has focus, then //! "focus_column" will be 0. //! Returns ([ "path": GTK2.TreePath, "column": GTK2.TreeViewColumn ]); {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited(); pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  { GtkTreePath *path; GtkTreeViewColumn *col; gtk_tree_view_get_cursor(GTK_TREE_VIEW(THIS->obj),&path,&col);
f439a12008-04-11Per Hedbor  ref_push_string(_STR("path"));push_pgdk2object((GtkTreePath *)path,pgtk2_tree_path_program,1);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("column")); push_gobject(col);
1a05542005-07-28Martin Nilsson  f_aggregate_mapping(4); } } void row_activated(GTK2.TreePath path, GTK2.TreeViewColumn column) //! Activates the cell determined by path and column. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { struct object *o1,*o2;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%o%o",&o1,&o2);
1a05542005-07-28Martin Nilsson  gtk_tree_view_row_activated(GTK_TREE_VIEW(THIS->obj),
67ad922011-11-21Lance Dillon  (GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program),
1a05542005-07-28Martin Nilsson  GTK_TREE_VIEW_COLUMN(get_gobject(o2))); } RETURN_THIS(); } void expand_all(); //! Recursively expands all nodes. void collapse_all(); //! Recursively collapses all visible, expanded nodes. require gtk22; void expand_to_path(GTK2.TreePath path) //! Expands the row at path. This will also expand all parent rows of path as //! necessary. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { struct object *o1;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%o",&o1);
1a05542005-07-28Martin Nilsson  gtk_tree_view_expand_to_path(GTK_TREE_VIEW(THIS->obj),
67ad922011-11-21Lance Dillon  (GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program));
1a05542005-07-28Martin Nilsson  } RETURN_THIS(); } endrequire; int expand_row(GTK2.TreePath path, int open_all) //! Opens the row so its children are visible. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { struct object *o1;
cac4202005-12-17Marcus Comstedt  INT_TYPE op;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%o%i",&o1,&op);
1a05542005-07-28Martin Nilsson  gtk_tree_view_expand_row(GTK_TREE_VIEW(THIS->obj),
67ad922011-11-21Lance Dillon  (GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program),op);
1a05542005-07-28Martin Nilsson  } RETURN_THIS(); } int collapse_row(GTK2.TreePath path) //! Collapses a row (hides its child rows, if they exist). {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { struct object *o1;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%o",&o1);
1a05542005-07-28Martin Nilsson  gtk_tree_view_collapse_row(GTK_TREE_VIEW(THIS->obj),
67ad922011-11-21Lance Dillon  (GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program));
1a05542005-07-28Martin Nilsson  } RETURN_THIS(); } int row_expanded(GTK2.TreePath path) //! Returns true if the node pointed to by path is expanded. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { struct object *o1;
3d76632005-11-03Lance Dillon  int res;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%o",&o1);
3d76632005-11-03Lance Dillon  res=gtk_tree_view_row_expanded(GTK_TREE_VIEW(THIS->obj),
67ad922011-11-21Lance Dillon  (GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program));
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
3d76632005-11-03Lance Dillon  PGTK_PUSH_INT(res);
1a05542005-07-28Martin Nilsson  } } void set_reorderable(int reorderable); //! This function is a convenience function to allow you to reorder models. //! If reorderable is true, then the user can reorder the model by dragging //! and dropping rows. The developer can listen to these changes by connecting //! to the model's "row-inserted" and "row-deleted" signals. //! <p> //! This function does not give you any degree of control over the order -- //! any reordering is allowed. If more control is needed, you should probably //! handle drag and drop manually. int get_reorderable(); //! Retrieves whether the user can reorder the tree via drag-and-drop. mapping get_path_at_pos(int x, int y) //! Finds the path at the point (x,y) relative to widget coordinates. That //! is, x and y are relative to an events coordinates. x and y must come from //! an event on the view only where event->window==get_bin(). It is primarily //! for things like popup menus. Returns GTK2.TreePath, GTK2.TreeViewColumn, //! and cell_x and cell_y, which are the coordinates relative to the cell //! background (i.e. the background_area passed to GTK2.CellRenderer->render()). //! This function is only meaningful if the widget is realized. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  {
cac4202005-12-17Marcus Comstedt  INT_TYPE x,y;
1a05542005-07-28Martin Nilsson  GtkTreePath *path; GtkTreeViewColumn *col; gint cell_x,cell_y; int res;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%i%i",&x,&y);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  res=gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(THIS->obj), x,y,&path,&col,&cell_x,&cell_y);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("path"));
1a05542005-07-28Martin Nilsson  if (res)
f439a12008-04-11Per Hedbor  push_pgdk2object(path,pgtk2_tree_path_program,1);
1a05542005-07-28Martin Nilsson  else push_int(0);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("column"));
1a05542005-07-28Martin Nilsson  if (res) push_gobject(col); else push_int(0);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("cell_x"));
1a05542005-07-28Martin Nilsson  push_int(res?cell_x:0);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("cell_y"));
1a05542005-07-28Martin Nilsson  push_int(res?cell_y:0); f_aggregate_mapping(8); } }
f284492006-08-03Lance Dillon +GDK2.Rectangle get_cell_area(?GTK2.TreePath path, ?GTK2.TreeViewColumn column)
1a05542005-07-28Martin Nilsson //! Fills the bounding rectangle in tree window coordinates for the cell at //! the row specified by path and the column specified by column. If path is //! omitted or 0, or points to a path not currently displayed, the y and //! height fields of the rectangle will be 0. If column is omitted, the x and //! width fields will be o. The sum of all cell rects does not cover the //! entire tree; there are extra pixels in between rows, for example. The //! returned rectangle is equivalent to the cell_area passed to //! GTK2.CellRenderer->render(). This function is only valid if the view is //! realized. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  {
4a7cc12005-12-28Martin Nilsson  struct object *o1,*o2=NULL;
1a05542005-07-28Martin Nilsson  GdkRectangle *rect;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%o.%o",&o1,&o2);
1a05542005-07-28Martin Nilsson  rect=(GdkRectangle *)g_malloc(sizeof(GdkRectangle)); if (rect==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("get_cell_area",sizeof(GdkRectangle)); gtk_tree_view_get_cell_area(GTK_TREE_VIEW(THIS->obj),
67ad922011-11-21Lance Dillon  (GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program),
1a05542005-07-28Martin Nilsson  GTK_TREE_VIEW_COLUMN(get_gobject(o2)),
3d76632005-11-03Lance Dillon  rect);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
2edd4f2008-01-30Per Hedbor  push_gdkobject(rect,rectangle,1);
1a05542005-07-28Martin Nilsson  } }
f284492006-08-03Lance Dillon +GDK2.Rectangle get_background_area(?GTK2.TreePath path,
1a05542005-07-28Martin Nilsson  ?GTK2.TreeViewColumn column) //! Similar to get_cell_area(). The returned rectangle is equivalent to the //! background_area passed to GTK2.CellRenderer->render(). These background //! area tiles to cover the entire tree window (except for the area used for //! header buttons). Contrast with get_cell_area(), which returns only the //! cell itself, excluding surrounding borders and the tree expander area. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  {
4a7cc12005-12-28Martin Nilsson  struct object *o1,*o2=NULL;
1a05542005-07-28Martin Nilsson  GdkRectangle *rect;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%o.%o",&o1,&o2);
1a05542005-07-28Martin Nilsson  rect=(GdkRectangle *)g_malloc(sizeof(GdkRectangle)); if (rect==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("get_background_area",sizeof(GdkRectangle)); gtk_tree_view_get_background_area(GTK_TREE_VIEW(THIS->obj),
67ad922011-11-21Lance Dillon  (GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program),
1a05542005-07-28Martin Nilsson  GTK_TREE_VIEW_COLUMN(get_gobject(o2)),
3d76632005-11-03Lance Dillon  rect);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
2edd4f2008-01-30Per Hedbor  push_gdkobject(rect,rectangle,1);
1a05542005-07-28Martin Nilsson  } }
f284492006-08-03Lance Dillon +GDK2.Rectangle get_visible_rect()
1a05542005-07-28Martin Nilsson //! Returns a GDK2.Rectangle with the currently-visible region of the buffer, //! in tree coordinates. Conver to widget coordinates with //! tree_to_widget_coords(). Tree coordinates start at 0,0 for row 0 of the //! tree, and cover the entire scrollable area of the tree. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited(); pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  { GdkRectangle *gr;
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  gr=g_malloc(sizeof(GdkRectangle)); if (gr==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("get_visible_rect",sizeof(GdkRectangle)); gtk_tree_view_get_visible_rect(GTK_TREE_VIEW(THIS->obj),gr);
2edd4f2008-01-30Per Hedbor  push_gdkobject(gr,rectangle,1);
1a05542005-07-28Martin Nilsson  } }
3d76632005-11-03Lance Dillon require gtk28; array get_visible_range() //! Returns the first and last visible path. Note that there may be invisible //! paths in between. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited(); pgtk2_pop_n_elems(args);
3d76632005-11-03Lance Dillon  { GtkTreePath *s,*e; int res; res=gtk_tree_view_get_visible_range(GTK_TREE_VIEW(THIS->obj),&s,&e); if (res) {
f439a12008-04-11Per Hedbor  push_pgdk2object(s,pgtk2_tree_path_program,1); push_pgdk2object(e,pgtk2_tree_path_program,1);
3d76632005-11-03Lance Dillon  f_aggregate(2); } else ref_push_array(&empty_array); } } endrequire;
f284492006-08-03Lance Dillon +GDK2.Window get_bin_window();
1a05542005-07-28Martin Nilsson //! Returns the window that this view renders to. This is used primarily to //! compare to event->window to confirm that the event on this view is on the //! right window.
c37a152007-10-14Lance Dillon not gtk212;
1a05542005-07-28Martin Nilsson mapping widget_to_tree_coords(int wx, int wy) //! converts widget coordinates to coordinates for the tree window (the full //! scrollable area of the tree). {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { gint tx,ty;
cac4202005-12-17Marcus Comstedt  INT_TYPE wx,wy;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%i%i",&wx,&wy);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  gtk_tree_view_widget_to_tree_coords(GTK_TREE_VIEW(THIS->obj),wx,wy,&tx,&ty);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("x")); push_int(tx); ref_push_string(_STR("y")); push_int(ty);
1a05542005-07-28Martin Nilsson  f_aggregate_mapping(4); } } mapping tree_to_widget_coords(int tx, int ty) //! Converts tree coordinates (coordinates in full scrollable area of the tree) //! to widget coordinates. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { gint wx,wy;
cac4202005-12-17Marcus Comstedt  INT_TYPE tx,ty;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%i%i",&tx,&ty);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  gtk_tree_view_tree_to_widget_coords(GTK_TREE_VIEW(THIS->obj),tx,ty,&wx,&wy);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("x")); push_int(wx); ref_push_string(_STR("y")); push_int(wy);
1a05542005-07-28Martin Nilsson  f_aggregate_mapping(4); } }
c37a152007-10-14Lance Dillon endnot; require gtk212; mapping convert_bin_window_to_tree_coords(int bx, int by)
7caac22014-09-05Chris Angelico //! Convert bin_window coordinates to tree coordinates.
c37a152007-10-14Lance Dillon { pgtk2_verify_inited(); { gint tx,ty; INT_TYPE bx,by;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%i%i",&bx,&by);
c37a152007-10-14Lance Dillon  pgtk2_pop_n_elems(args); gtk_tree_view_convert_bin_window_to_tree_coords(GTK_TREE_VIEW(THIS->obj), bx,by,&tx,&ty); ref_push_string(_STR("x")); push_int(tx); ref_push_string(_STR("y")); push_int(ty); f_aggregate_mapping(4); } } mapping convert_bin_window_to_widget_coords(int bx, int by)
7caac22014-09-05Chris Angelico //! Convert bin_window coordinates to widget coordinates.
c37a152007-10-14Lance Dillon { pgtk2_verify_inited(); { gint wx,wy; INT_TYPE bx,by;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%i%i",&bx,&by);
c37a152007-10-14Lance Dillon  pgtk2_pop_n_elems(args); gtk_tree_view_convert_bin_window_to_widget_coords(GTK_TREE_VIEW(THIS->obj), bx,by,&wx,&wy); ref_push_string(_STR("x")); push_int(wx); ref_push_string(_STR("y")); push_int(wy); f_aggregate_mapping(4); } } mapping convert_tree_to_bin_window_coords(int tx, int ty)
7caac22014-09-05Chris Angelico //! Converts tree coordinates (coordinates in full scrollable area of the tree) to //! bin_window coordinates.
c37a152007-10-14Lance Dillon { pgtk2_verify_inited(); { gint bx,by; INT_TYPE tx,ty;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%i%i",&tx,&ty);
c37a152007-10-14Lance Dillon  pgtk2_pop_n_elems(args); gtk_tree_view_convert_tree_to_bin_window_coords(GTK_TREE_VIEW(THIS->obj), tx,ty,&bx,&by); ref_push_string(_STR("x")); push_int(bx); ref_push_string(_STR("y")); push_int(by); f_aggregate_mapping(4); } } mapping convert_tree_to_widget_coords(int tx, int ty)
7caac22014-09-05Chris Angelico //! Convert tree coordinates to widget coordinates.
c37a152007-10-14Lance Dillon { pgtk2_verify_inited(); { gint wx,wy; INT_TYPE tx,ty;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%i%i",&tx,&ty);
c37a152007-10-14Lance Dillon  pgtk2_pop_n_elems(args);
418e9c2009-11-13Per Hedbor  gtk_tree_view_convert_tree_to_widget_coords(GTK_TREE_VIEW(THIS->obj),
c37a152007-10-14Lance Dillon  tx,ty,&wx,&wy); ref_push_string(_STR("x")); push_int(wx); ref_push_string(_STR("y")); push_int(wy); f_aggregate_mapping(4); } } mapping convert_widget_to_bin_window_coords(int wx, int wy)
7caac22014-09-05Chris Angelico //! Convert widget coordinates to bin_window coordinates.
c37a152007-10-14Lance Dillon { pgtk2_verify_inited(); { gint bx,by; INT_TYPE wx,wy;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%i%i",&wx,&wy);
c37a152007-10-14Lance Dillon  pgtk2_pop_n_elems(args); gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(THIS->obj), wx,wy,&bx,&by); ref_push_string(_STR("x")); push_int(bx); ref_push_string(_STR("y")); push_int(by); f_aggregate_mapping(4); } } mapping convert_widget_to_tree_coords(int wx, int wy)
7caac22014-09-05Chris Angelico //! Convert widget coordinates to tree coordinates.
c37a152007-10-14Lance Dillon { pgtk2_verify_inited(); { gint tx,ty; INT_TYPE wx,wy;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%i%i",&wx,&wy);
c37a152007-10-14Lance Dillon  pgtk2_pop_n_elems(args); gtk_tree_view_convert_widget_to_tree_coords(GTK_TREE_VIEW(THIS->obj), wx,wy,&tx,&ty); ref_push_string(_STR("x")); push_int(tx); ref_push_string(_STR("y")); push_int(ty); f_aggregate_mapping(4); } } endrequire;
1a05542005-07-28Martin Nilsson 
a905d32016-11-05Chris Angelico %{ /* Borrow code from gtkwidget.pre */ int _decode_targets(struct array *targ, GtkTargetEntry *drag_targets);
704b752016-11-05Chris Angelico  /* Simplify the code by allowing the same form of cast */ #define GTK_TREE_PATH(object) ((GtkTreePath *)object)
a905d32016-11-05Chris Angelico %}
1a05542005-07-28Martin Nilsson  void enable_model_drag_source(int start_button_mask,
a905d32016-11-05Chris Angelico  array(array) targets, int actions)
1a05542005-07-28Martin Nilsson //! Turns the view into a drag source for automatic DND.
a905d32016-11-05Chris Angelico //! See also: @[drag_source_set] { pgtk2_verify_inited(); { INT_TYPE btn, act; struct array *targ;
d627d42016-12-14Chris Angelico  GtkTargetEntry drag_targets[10];
a905d32016-11-05Chris Angelico 
96f5f42018-08-05Martin Nilsson  get_all_args(NULL, args, "%d%a%d", &btn, &targ, &act);
d627d42016-12-14Chris Angelico  if (targ->size > 10 || _decode_targets(targ, drag_targets))
a905d32016-11-05Chris Angelico  SIMPLE_ARG_TYPE_ERROR("enable_model_drag_source", 2, "array(array(string|int))"); gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(THIS->obj), btn, drag_targets, targ->size, act); } RETURN_THIS(); }
1a05542005-07-28Martin Nilsson 
a905d32016-11-05Chris Angelico void enable_model_drag_dest(array(array) targets, int actions) //! Turns the view into a drop destination for automatic DND. //! See also: @[drag_dest_set], @[drag_source_set] { pgtk2_verify_inited(); { INT_TYPE flags, act; struct array *targ;
d627d42016-12-14Chris Angelico  GtkTargetEntry drag_targets[10];
a905d32016-11-05Chris Angelico 
96f5f42018-08-05Martin Nilsson  get_all_args(NULL, args, "%a%d", &targ, &act);
d627d42016-12-14Chris Angelico  if (targ->size > 10 || _decode_targets(targ, drag_targets))
a905d32016-11-05Chris Angelico  SIMPLE_ARG_TYPE_ERROR("enable_model_drag_dest", 2, "array(array(string|int))"); gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(THIS->obj), drag_targets, targ->size, act); } RETURN_THIS(); }
1a05542005-07-28Martin Nilsson void unset_rows_drag_source(); //! Undoes the effect of enable_model_drag_source(). void unset_rows_drag_dest();
7328212016-10-30Chris Angelico //! Undoes the effect of enable_model_drag_dest().
1a05542005-07-28Martin Nilsson  void set_drag_dest_row(GTK2.TreePath path, int pos);
704b752016-11-05Chris Angelico //! Sets the row that is highlighted for feedback. pos is one of the four //! constants GTK2.TREE_VIEW_DROP_[INTO_OR_]{BEFORE,AFTER}.
1a05542005-07-28Martin Nilsson 
704b752016-11-05Chris Angelico mapping(string:mixed) get_drag_dest_row()
1a05542005-07-28Martin Nilsson //! Gets information about the row that is highlighted for feedback.
704b752016-11-05Chris Angelico //! Returns ([ "path": GTK2.TreePath, "pos": int ]); //! pos will be one of GTK2.TREE_VIEW_DROP_[INTO_OR_]{BEFORE,AFTER}. { pgtk2_verify_inited(); pgtk2_pop_n_elems(args); { GtkTreePath *path; GtkTreeViewDropPosition pos; gtk_tree_view_get_drag_dest_row(GTK_TREE_VIEW(THIS->obj),&path,&pos); ref_push_string(_STR("path"));push_pgdk2object((GtkTreePath *)path,pgtk2_tree_path_program,1); ref_push_string(_STR("pos")); push_int(pos); f_aggregate_mapping(4); } }
1a05542005-07-28Martin Nilsson 
704b752016-11-05Chris Angelico mapping(string:mixed) get_dest_row_at_pos(int drag_x, int drag_y) //! Determines the destination row for a given position. //! Returns ([ "path": GTK2.TreePath, "pos": int ]) if there is such //! a row, or 0 if not. //! pos will be one of GTK2.TREE_VIEW_DROP_[INTO_OR_]{BEFORE,AFTER}. { pgtk2_verify_inited(); { GtkTreePath *path; INT_TYPE drag_x, drag_y; GtkTreeViewDropPosition pos;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL, args, "%d%d", &drag_x, &drag_y);
704b752016-11-05Chris Angelico  if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(THIS->obj), drag_x, drag_y, &path, &pos)) { ref_push_string(_STR("path"));push_pgdk2object((GtkTreePath *)path,pgtk2_tree_path_program,1); ref_push_string(_STR("pos")); push_int(pos); f_aggregate_mapping(4); } else { push_int(0); } } }
1a05542005-07-28Martin Nilsson 
f284492006-08-03Lance Dillon +GDK2.Pixmap create_row_drag_icon(GTK2.TreePath path);
1a05542005-07-28Martin Nilsson //! Creates a GDK2.Pixmap representation of the row at path. This image is //! used for a drag icon. void set_enable_search(int enable_search); //! If enable_search is set, then the user can type in text to search through //! the tree interactively (this is sometimes called "typeahead find"). //! <p> //! Note that even if this is false, the user can still initiate a search //! using the "start-interactive-search" key binding. int get_enable_search(); //! Returns whether or not the tree allows to start interactive searching by //! typing in text. int get_search_column(); //! Gets the column searched on by the interactive search code. void set_search_column(int column); //! Sets column as the column where the interactive search code should search //! in. //! <p> //! If the sort column is set, users can use the "start-interactive-search" //! key binding to bring up search popup. The enable-search property controls //! whether simply typing text will also start an interactive search. //! <p> //! Note that column refers to a column of the model.
f284492006-08-03Lance Dillon require gtk210; +GTK2.Entry get_search_entry(); //! Returns the GTK2.Entry which is currently in use as interactive search //! entry. In case the built-in entry is being used, 0 will be returned. void set_search_entry(?GTK2.Entry entry); //! Sets the entry which the interactive search code will use. This is useful //! when you want to provide a search entry in your interface at all times //! at a fixed position. Passing 0 will make the interactive search code //! use the built-in popup entry again.
1a05542005-07-28Martin Nilsson require gtk26; int get_fixed_height_mode(); //! Returns whether fixed height mode is turned on. void set_fixed_height_mode(int enable); //! Enables or disables the fixed height mode. Fixed height mode speeds up //! W(TreeView) by assuming that all rows have the same height. Only enable //! this option if all rows are the same height and all columns are of type //! GTK2.TREE_VIEW_COLUMN_FIXED. int get_hover_selection(); //! Returns whether hover selection mode is turned on. void set_hover_selection(int hover); //! Enables or disables the hover selection mode. Hover selection makes the //! selected row follow the pointer. Currently, this works only for the //! selection modes GTK2.SELECTION_SINGLE and GTK2.SELECTION_BROWSE. int get_hover_expand(); //! Returns whether hover expansion mode is turned on. void set_hover_expand(int expand); //! Enables or disables the hover expansion mode. Hover expansion makes rows //! expand or collapse if the pointer moves over them.
f272812015-10-25Chris Angelico void set_row_separator_func(function(GTK2.TreeModel, GTK2.TreeIter, mixed : int) f, mixed user_data )
f284492006-08-03Lance Dillon //! Sets the row separator function, which is used to determine whether a //! row should be drawn as a separator. If the row separator function is 0 //! no separators are drawn. This is the default value. { pgtk2_verify_inited(); { struct svalue *sv1,*sv2; struct signal_data *sd;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%*%*",&sv1,&sv2);
f284492006-08-03Lance Dillon  sd=(struct signal_data *)g_malloc(sizeof(struct signal_data)); if (sd==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("set_row_separator_func",sizeof(struct signal_data) ); assign_svalue_no_free(&sd->cb,sv1); assign_svalue_no_free(&sd->args,sv2);
2feed02007-10-15Lance Dillon  gtk_tree_view_set_row_separator_func(GTK_TREE_VIEW(THIS->obj),
f284492006-08-03Lance Dillon  (GtkTreeViewRowSeparatorFunc)pgtk2_tree_view_row_separator_func, sd,(GtkDestroyNotify)pgtk2_free_signal_data); } RETURN_THIS(); }
1a05542005-07-28Martin Nilsson  array get_selected() //! Shortcut to GTK2.TreeView->get_selection() and //! GTK2.TreeSelection()->get_selected(). {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited(); pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  { GtkTreeSelection *sel; GtkTreeIter *iter; GtkTreeModel *model; iter=(GtkTreeIter *)g_malloc(sizeof(GtkTreeIter)); if (iter==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("get_selected",sizeof(GtkTreeIter)); sel=gtk_tree_view_get_selection(GTK_TREE_VIEW(THIS->obj)); if (gtk_tree_selection_get_selected(sel,&model,iter)) {
2fa8a62008-04-11Per Hedbor  push_pgdk2object(iter,pgtk2_tree_iter_program,1);
1a05542005-07-28Martin Nilsson  push_gobject(model);
3d76632005-11-03Lance Dillon  f_aggregate(2);
2fa8a62008-04-11Per Hedbor  } else {
1a05542005-07-28Martin Nilsson  push_int(0);
2fa8a62008-04-11Per Hedbor  g_free(iter); }
1a05542005-07-28Martin Nilsson  } }
f284492006-08-03Lance Dillon endrequire; require gtk210; int get_rubber_banding(); //! Returns whether rubber banding is turned on. If the selection mode is //! GTK2.SELECTION_MULTIPLE, rubber banding will allow the user to select //! multiple rows by dragging the mouse. void set_rubber_banding(int enable); //! Enables or disables rubber banding. int get_enable_tree_lines(); //! Returns whether or not tree lines are drawn. void set_enable_tree_lines(int enabled); //! Sets whether to draw lines interconnecting the expanders. This does not //! have any visible effects for lists. int get_grid_lines(); //! Returns which grid lines are enabled. void set_grid_lines(int grid_lines); //! Sets which grid lines to draw. endrequire;