You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

432 lines
22 KiB

  1. /* gtktreeview.h
  2. * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Library General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Library General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public
  15. * License along with this library; if not, write to the
  16. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17. * Boston, MA 02111-1307, USA.
  18. */
  19. #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
  20. #error "Only <gtk/gtk.h> can be included directly."
  21. #endif
  22. #ifndef __GTK_TREE_VIEW_H__
  23. #define __GTK_TREE_VIEW_H__
  24. #include <gtk/gtkcontainer.h>
  25. #include <gtk/gtktreemodel.h>
  26. #include <gtk/gtktreeviewcolumn.h>
  27. #include <gtk/gtkdnd.h>
  28. #include <gtk/gtkentry.h>
  29. G_BEGIN_DECLS
  30. typedef enum
  31. {
  32. /* drop before/after this row */
  33. GTK_TREE_VIEW_DROP_BEFORE,
  34. GTK_TREE_VIEW_DROP_AFTER,
  35. /* drop as a child of this row (with fallback to before or after
  36. * if into is not possible)
  37. */
  38. GTK_TREE_VIEW_DROP_INTO_OR_BEFORE,
  39. GTK_TREE_VIEW_DROP_INTO_OR_AFTER
  40. } GtkTreeViewDropPosition;
  41. #define GTK_TYPE_TREE_VIEW (gtk_tree_view_get_type ())
  42. #define GTK_TREE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TREE_VIEW, GtkTreeView))
  43. #define GTK_TREE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TREE_VIEW, GtkTreeViewClass))
  44. #define GTK_IS_TREE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TREE_VIEW))
  45. #define GTK_IS_TREE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TREE_VIEW))
  46. #define GTK_TREE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TREE_VIEW, GtkTreeViewClass))
  47. typedef struct _GtkTreeView GtkTreeView;
  48. typedef struct _GtkTreeViewClass GtkTreeViewClass;
  49. typedef struct _GtkTreeViewPrivate GtkTreeViewPrivate;
  50. typedef struct _GtkTreeSelection GtkTreeSelection;
  51. typedef struct _GtkTreeSelectionClass GtkTreeSelectionClass;
  52. struct _GtkTreeView
  53. {
  54. GtkContainer parent;
  55. GtkTreeViewPrivate *GSEAL (priv);
  56. };
  57. struct _GtkTreeViewClass
  58. {
  59. GtkContainerClass parent_class;
  60. void (* set_scroll_adjustments) (GtkTreeView *tree_view,
  61. GtkAdjustment *hadjustment,
  62. GtkAdjustment *vadjustment);
  63. void (* row_activated) (GtkTreeView *tree_view,
  64. GtkTreePath *path,
  65. GtkTreeViewColumn *column);
  66. gboolean (* test_expand_row) (GtkTreeView *tree_view,
  67. GtkTreeIter *iter,
  68. GtkTreePath *path);
  69. gboolean (* test_collapse_row) (GtkTreeView *tree_view,
  70. GtkTreeIter *iter,
  71. GtkTreePath *path);
  72. void (* row_expanded) (GtkTreeView *tree_view,
  73. GtkTreeIter *iter,
  74. GtkTreePath *path);
  75. void (* row_collapsed) (GtkTreeView *tree_view,
  76. GtkTreeIter *iter,
  77. GtkTreePath *path);
  78. void (* columns_changed) (GtkTreeView *tree_view);
  79. void (* cursor_changed) (GtkTreeView *tree_view);
  80. /* Key Binding signals */
  81. gboolean (* move_cursor) (GtkTreeView *tree_view,
  82. GtkMovementStep step,
  83. gint count);
  84. gboolean (* select_all) (GtkTreeView *tree_view);
  85. gboolean (* unselect_all) (GtkTreeView *tree_view);
  86. gboolean (* select_cursor_row) (GtkTreeView *tree_view,
  87. gboolean start_editing);
  88. gboolean (* toggle_cursor_row) (GtkTreeView *tree_view);
  89. gboolean (* expand_collapse_cursor_row) (GtkTreeView *tree_view,
  90. gboolean logical,
  91. gboolean expand,
  92. gboolean open_all);
  93. gboolean (* select_cursor_parent) (GtkTreeView *tree_view);
  94. gboolean (* start_interactive_search) (GtkTreeView *tree_view);
  95. /* Padding for future expansion */
  96. void (*_gtk_reserved0) (void);
  97. void (*_gtk_reserved1) (void);
  98. void (*_gtk_reserved2) (void);
  99. void (*_gtk_reserved3) (void);
  100. void (*_gtk_reserved4) (void);
  101. };
  102. typedef gboolean (* GtkTreeViewColumnDropFunc) (GtkTreeView *tree_view,
  103. GtkTreeViewColumn *column,
  104. GtkTreeViewColumn *prev_column,
  105. GtkTreeViewColumn *next_column,
  106. gpointer data);
  107. typedef void (* GtkTreeViewMappingFunc) (GtkTreeView *tree_view,
  108. GtkTreePath *path,
  109. gpointer user_data);
  110. typedef gboolean (*GtkTreeViewSearchEqualFunc) (GtkTreeModel *model,
  111. gint column,
  112. const gchar *key,
  113. GtkTreeIter *iter,
  114. gpointer search_data);
  115. typedef gboolean (*GtkTreeViewRowSeparatorFunc) (GtkTreeModel *model,
  116. GtkTreeIter *iter,
  117. gpointer data);
  118. typedef void (*GtkTreeViewSearchPositionFunc) (GtkTreeView *tree_view,
  119. GtkWidget *search_dialog,
  120. gpointer user_data);
  121. /* Creators */
  122. GType gtk_tree_view_get_type (void) G_GNUC_CONST;
  123. GtkWidget *gtk_tree_view_new (void);
  124. GtkWidget *gtk_tree_view_new_with_model (GtkTreeModel *model);
  125. /* Accessors */
  126. GtkTreeModel *gtk_tree_view_get_model (GtkTreeView *tree_view);
  127. void gtk_tree_view_set_model (GtkTreeView *tree_view,
  128. GtkTreeModel *model);
  129. GtkTreeSelection *gtk_tree_view_get_selection (GtkTreeView *tree_view);
  130. GtkAdjustment *gtk_tree_view_get_hadjustment (GtkTreeView *tree_view);
  131. void gtk_tree_view_set_hadjustment (GtkTreeView *tree_view,
  132. GtkAdjustment *adjustment);
  133. GtkAdjustment *gtk_tree_view_get_vadjustment (GtkTreeView *tree_view);
  134. void gtk_tree_view_set_vadjustment (GtkTreeView *tree_view,
  135. GtkAdjustment *adjustment);
  136. gboolean gtk_tree_view_get_headers_visible (GtkTreeView *tree_view);
  137. void gtk_tree_view_set_headers_visible (GtkTreeView *tree_view,
  138. gboolean headers_visible);
  139. void gtk_tree_view_columns_autosize (GtkTreeView *tree_view);
  140. gboolean gtk_tree_view_get_headers_clickable (GtkTreeView *tree_view);
  141. void gtk_tree_view_set_headers_clickable (GtkTreeView *tree_view,
  142. gboolean setting);
  143. void gtk_tree_view_set_rules_hint (GtkTreeView *tree_view,
  144. gboolean setting);
  145. gboolean gtk_tree_view_get_rules_hint (GtkTreeView *tree_view);
  146. /* Column funtions */
  147. gint gtk_tree_view_append_column (GtkTreeView *tree_view,
  148. GtkTreeViewColumn *column);
  149. gint gtk_tree_view_remove_column (GtkTreeView *tree_view,
  150. GtkTreeViewColumn *column);
  151. gint gtk_tree_view_insert_column (GtkTreeView *tree_view,
  152. GtkTreeViewColumn *column,
  153. gint position);
  154. gint gtk_tree_view_insert_column_with_attributes (GtkTreeView *tree_view,
  155. gint position,
  156. const gchar *title,
  157. GtkCellRenderer *cell,
  158. ...) G_GNUC_NULL_TERMINATED;
  159. gint gtk_tree_view_insert_column_with_data_func (GtkTreeView *tree_view,
  160. gint position,
  161. const gchar *title,
  162. GtkCellRenderer *cell,
  163. GtkTreeCellDataFunc func,
  164. gpointer data,
  165. GDestroyNotify dnotify);
  166. GtkTreeViewColumn *gtk_tree_view_get_column (GtkTreeView *tree_view,
  167. gint n);
  168. GList *gtk_tree_view_get_columns (GtkTreeView *tree_view);
  169. void gtk_tree_view_move_column_after (GtkTreeView *tree_view,
  170. GtkTreeViewColumn *column,
  171. GtkTreeViewColumn *base_column);
  172. void gtk_tree_view_set_expander_column (GtkTreeView *tree_view,
  173. GtkTreeViewColumn *column);
  174. GtkTreeViewColumn *gtk_tree_view_get_expander_column (GtkTreeView *tree_view);
  175. void gtk_tree_view_set_column_drag_function (GtkTreeView *tree_view,
  176. GtkTreeViewColumnDropFunc func,
  177. gpointer user_data,
  178. GDestroyNotify destroy);
  179. /* Actions */
  180. void gtk_tree_view_scroll_to_point (GtkTreeView *tree_view,
  181. gint tree_x,
  182. gint tree_y);
  183. void gtk_tree_view_scroll_to_cell (GtkTreeView *tree_view,
  184. GtkTreePath *path,
  185. GtkTreeViewColumn *column,
  186. gboolean use_align,
  187. gfloat row_align,
  188. gfloat col_align);
  189. void gtk_tree_view_row_activated (GtkTreeView *tree_view,
  190. GtkTreePath *path,
  191. GtkTreeViewColumn *column);
  192. void gtk_tree_view_expand_all (GtkTreeView *tree_view);
  193. void gtk_tree_view_collapse_all (GtkTreeView *tree_view);
  194. void gtk_tree_view_expand_to_path (GtkTreeView *tree_view,
  195. GtkTreePath *path);
  196. gboolean gtk_tree_view_expand_row (GtkTreeView *tree_view,
  197. GtkTreePath *path,
  198. gboolean open_all);
  199. gboolean gtk_tree_view_collapse_row (GtkTreeView *tree_view,
  200. GtkTreePath *path);
  201. void gtk_tree_view_map_expanded_rows (GtkTreeView *tree_view,
  202. GtkTreeViewMappingFunc func,
  203. gpointer data);
  204. gboolean gtk_tree_view_row_expanded (GtkTreeView *tree_view,
  205. GtkTreePath *path);
  206. void gtk_tree_view_set_reorderable (GtkTreeView *tree_view,
  207. gboolean reorderable);
  208. gboolean gtk_tree_view_get_reorderable (GtkTreeView *tree_view);
  209. void gtk_tree_view_set_cursor (GtkTreeView *tree_view,
  210. GtkTreePath *path,
  211. GtkTreeViewColumn *focus_column,
  212. gboolean start_editing);
  213. void gtk_tree_view_set_cursor_on_cell (GtkTreeView *tree_view,
  214. GtkTreePath *path,
  215. GtkTreeViewColumn *focus_column,
  216. GtkCellRenderer *focus_cell,
  217. gboolean start_editing);
  218. void gtk_tree_view_get_cursor (GtkTreeView *tree_view,
  219. GtkTreePath **path,
  220. GtkTreeViewColumn **focus_column);
  221. /* Layout information */
  222. GdkWindow *gtk_tree_view_get_bin_window (GtkTreeView *tree_view);
  223. gboolean gtk_tree_view_get_path_at_pos (GtkTreeView *tree_view,
  224. gint x,
  225. gint y,
  226. GtkTreePath **path,
  227. GtkTreeViewColumn **column,
  228. gint *cell_x,
  229. gint *cell_y);
  230. void gtk_tree_view_get_cell_area (GtkTreeView *tree_view,
  231. GtkTreePath *path,
  232. GtkTreeViewColumn *column,
  233. GdkRectangle *rect);
  234. void gtk_tree_view_get_background_area (GtkTreeView *tree_view,
  235. GtkTreePath *path,
  236. GtkTreeViewColumn *column,
  237. GdkRectangle *rect);
  238. void gtk_tree_view_get_visible_rect (GtkTreeView *tree_view,
  239. GdkRectangle *visible_rect);
  240. #ifndef GTK_DISABLE_DEPRECATED
  241. void gtk_tree_view_widget_to_tree_coords (GtkTreeView *tree_view,
  242. gint wx,
  243. gint wy,
  244. gint *tx,
  245. gint *ty);
  246. void gtk_tree_view_tree_to_widget_coords (GtkTreeView *tree_view,
  247. gint tx,
  248. gint ty,
  249. gint *wx,
  250. gint *wy);
  251. #endif /* !GTK_DISABLE_DEPRECATED */
  252. gboolean gtk_tree_view_get_visible_range (GtkTreeView *tree_view,
  253. GtkTreePath **start_path,
  254. GtkTreePath **end_path);
  255. /* Drag-and-Drop support */
  256. void gtk_tree_view_enable_model_drag_source (GtkTreeView *tree_view,
  257. GdkModifierType start_button_mask,
  258. const GtkTargetEntry *targets,
  259. gint n_targets,
  260. GdkDragAction actions);
  261. void gtk_tree_view_enable_model_drag_dest (GtkTreeView *tree_view,
  262. const GtkTargetEntry *targets,
  263. gint n_targets,
  264. GdkDragAction actions);
  265. void gtk_tree_view_unset_rows_drag_source (GtkTreeView *tree_view);
  266. void gtk_tree_view_unset_rows_drag_dest (GtkTreeView *tree_view);
  267. /* These are useful to implement your own custom stuff. */
  268. void gtk_tree_view_set_drag_dest_row (GtkTreeView *tree_view,
  269. GtkTreePath *path,
  270. GtkTreeViewDropPosition pos);
  271. void gtk_tree_view_get_drag_dest_row (GtkTreeView *tree_view,
  272. GtkTreePath **path,
  273. GtkTreeViewDropPosition *pos);
  274. gboolean gtk_tree_view_get_dest_row_at_pos (GtkTreeView *tree_view,
  275. gint drag_x,
  276. gint drag_y,
  277. GtkTreePath **path,
  278. GtkTreeViewDropPosition *pos);
  279. GdkPixmap *gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
  280. GtkTreePath *path);
  281. /* Interactive search */
  282. void gtk_tree_view_set_enable_search (GtkTreeView *tree_view,
  283. gboolean enable_search);
  284. gboolean gtk_tree_view_get_enable_search (GtkTreeView *tree_view);
  285. gint gtk_tree_view_get_search_column (GtkTreeView *tree_view);
  286. void gtk_tree_view_set_search_column (GtkTreeView *tree_view,
  287. gint column);
  288. GtkTreeViewSearchEqualFunc gtk_tree_view_get_search_equal_func (GtkTreeView *tree_view);
  289. void gtk_tree_view_set_search_equal_func (GtkTreeView *tree_view,
  290. GtkTreeViewSearchEqualFunc search_equal_func,
  291. gpointer search_user_data,
  292. GDestroyNotify search_destroy);
  293. GtkEntry *gtk_tree_view_get_search_entry (GtkTreeView *tree_view);
  294. void gtk_tree_view_set_search_entry (GtkTreeView *tree_view,
  295. GtkEntry *entry);
  296. GtkTreeViewSearchPositionFunc gtk_tree_view_get_search_position_func (GtkTreeView *tree_view);
  297. void gtk_tree_view_set_search_position_func (GtkTreeView *tree_view,
  298. GtkTreeViewSearchPositionFunc func,
  299. gpointer data,
  300. GDestroyNotify destroy);
  301. /* Convert between the different coordinate systems */
  302. void gtk_tree_view_convert_widget_to_tree_coords (GtkTreeView *tree_view,
  303. gint wx,
  304. gint wy,
  305. gint *tx,
  306. gint *ty);
  307. void gtk_tree_view_convert_tree_to_widget_coords (GtkTreeView *tree_view,
  308. gint tx,
  309. gint ty,
  310. gint *wx,
  311. gint *wy);
  312. void gtk_tree_view_convert_widget_to_bin_window_coords (GtkTreeView *tree_view,
  313. gint wx,
  314. gint wy,
  315. gint *bx,
  316. gint *by);
  317. void gtk_tree_view_convert_bin_window_to_widget_coords (GtkTreeView *tree_view,
  318. gint bx,
  319. gint by,
  320. gint *wx,
  321. gint *wy);
  322. void gtk_tree_view_convert_tree_to_bin_window_coords (GtkTreeView *tree_view,
  323. gint tx,
  324. gint ty,
  325. gint *bx,
  326. gint *by);
  327. void gtk_tree_view_convert_bin_window_to_tree_coords (GtkTreeView *tree_view,
  328. gint bx,
  329. gint by,
  330. gint *tx,
  331. gint *ty);
  332. /* This function should really never be used. It is just for use by ATK.
  333. */
  334. typedef void (* GtkTreeDestroyCountFunc) (GtkTreeView *tree_view,
  335. GtkTreePath *path,
  336. gint children,
  337. gpointer user_data);
  338. void gtk_tree_view_set_destroy_count_func (GtkTreeView *tree_view,
  339. GtkTreeDestroyCountFunc func,
  340. gpointer data,
  341. GDestroyNotify destroy);
  342. void gtk_tree_view_set_fixed_height_mode (GtkTreeView *tree_view,
  343. gboolean enable);
  344. gboolean gtk_tree_view_get_fixed_height_mode (GtkTreeView *tree_view);
  345. void gtk_tree_view_set_hover_selection (GtkTreeView *tree_view,
  346. gboolean hover);
  347. gboolean gtk_tree_view_get_hover_selection (GtkTreeView *tree_view);
  348. void gtk_tree_view_set_hover_expand (GtkTreeView *tree_view,
  349. gboolean expand);
  350. gboolean gtk_tree_view_get_hover_expand (GtkTreeView *tree_view);
  351. void gtk_tree_view_set_rubber_banding (GtkTreeView *tree_view,
  352. gboolean enable);
  353. gboolean gtk_tree_view_get_rubber_banding (GtkTreeView *tree_view);
  354. gboolean gtk_tree_view_is_rubber_banding_active (GtkTreeView *tree_view);
  355. GtkTreeViewRowSeparatorFunc gtk_tree_view_get_row_separator_func (GtkTreeView *tree_view);
  356. void gtk_tree_view_set_row_separator_func (GtkTreeView *tree_view,
  357. GtkTreeViewRowSeparatorFunc func,
  358. gpointer data,
  359. GDestroyNotify destroy);
  360. GtkTreeViewGridLines gtk_tree_view_get_grid_lines (GtkTreeView *tree_view);
  361. void gtk_tree_view_set_grid_lines (GtkTreeView *tree_view,
  362. GtkTreeViewGridLines grid_lines);
  363. gboolean gtk_tree_view_get_enable_tree_lines (GtkTreeView *tree_view);
  364. void gtk_tree_view_set_enable_tree_lines (GtkTreeView *tree_view,
  365. gboolean enabled);
  366. void gtk_tree_view_set_show_expanders (GtkTreeView *tree_view,
  367. gboolean enabled);
  368. gboolean gtk_tree_view_get_show_expanders (GtkTreeView *tree_view);
  369. void gtk_tree_view_set_level_indentation (GtkTreeView *tree_view,
  370. gint indentation);
  371. gint gtk_tree_view_get_level_indentation (GtkTreeView *tree_view);
  372. /* Convenience functions for setting tooltips */
  373. void gtk_tree_view_set_tooltip_row (GtkTreeView *tree_view,
  374. GtkTooltip *tooltip,
  375. GtkTreePath *path);
  376. void gtk_tree_view_set_tooltip_cell (GtkTreeView *tree_view,
  377. GtkTooltip *tooltip,
  378. GtkTreePath *path,
  379. GtkTreeViewColumn *column,
  380. GtkCellRenderer *cell);
  381. gboolean gtk_tree_view_get_tooltip_context(GtkTreeView *tree_view,
  382. gint *x,
  383. gint *y,
  384. gboolean keyboard_tip,
  385. GtkTreeModel **model,
  386. GtkTreePath **path,
  387. GtkTreeIter *iter);
  388. void gtk_tree_view_set_tooltip_column (GtkTreeView *tree_view,
  389. gint column);
  390. gint gtk_tree_view_get_tooltip_column (GtkTreeView *tree_view);
  391. G_END_DECLS
  392. #endif /* __GTK_TREE_VIEW_H__ */