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.
 
 
 
 
 
 

446 lines
16 KiB

  1. /* GTK - The GIMP Toolkit
  2. * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball, Josh MacDonald
  3. * Copyright (C) 1997-1998 Jay Painter <jpaint@serv.net><jpaint@gimp.org>
  4. *
  5. * GtkCTree widget for GTK+
  6. * Copyright (C) 1998 Lars Hamann and Stefan Jeske
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the
  20. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21. * Boston, MA 02111-1307, USA.
  22. */
  23. /*
  24. * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
  25. * file for a list of people on the GTK+ Team. See the ChangeLog
  26. * files for a list of changes. These files are distributed with
  27. * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  28. */
  29. #if !defined (GTK_DISABLE_DEPRECATED) || defined (__GTK_CLIST_C__) || defined (__GTK_CTREE_C__)
  30. #ifndef __GTK_CTREE_H__
  31. #define __GTK_CTREE_H__
  32. #include <gtk/gtkclist.h>
  33. G_BEGIN_DECLS
  34. #define GTK_TYPE_CTREE (gtk_ctree_get_type ())
  35. #define GTK_CTREE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CTREE, GtkCTree))
  36. #define GTK_CTREE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CTREE, GtkCTreeClass))
  37. #define GTK_IS_CTREE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CTREE))
  38. #define GTK_IS_CTREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CTREE))
  39. #define GTK_CTREE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CTREE, GtkCTreeClass))
  40. #define GTK_CTREE_ROW(_node_) ((GtkCTreeRow *)(((GList *)(_node_))->data))
  41. #define GTK_CTREE_NODE(_node_) ((GtkCTreeNode *)((_node_)))
  42. #define GTK_CTREE_NODE_NEXT(_nnode_) ((GtkCTreeNode *)(((GList *)(_nnode_))->next))
  43. #define GTK_CTREE_NODE_PREV(_pnode_) ((GtkCTreeNode *)(((GList *)(_pnode_))->prev))
  44. #define GTK_CTREE_FUNC(_func_) ((GtkCTreeFunc)(_func_))
  45. #define GTK_TYPE_CTREE_NODE (gtk_ctree_node_get_type ())
  46. typedef enum
  47. {
  48. GTK_CTREE_POS_BEFORE,
  49. GTK_CTREE_POS_AS_CHILD,
  50. GTK_CTREE_POS_AFTER
  51. } GtkCTreePos;
  52. typedef enum
  53. {
  54. GTK_CTREE_LINES_NONE,
  55. GTK_CTREE_LINES_SOLID,
  56. GTK_CTREE_LINES_DOTTED,
  57. GTK_CTREE_LINES_TABBED
  58. } GtkCTreeLineStyle;
  59. typedef enum
  60. {
  61. GTK_CTREE_EXPANDER_NONE,
  62. GTK_CTREE_EXPANDER_SQUARE,
  63. GTK_CTREE_EXPANDER_TRIANGLE,
  64. GTK_CTREE_EXPANDER_CIRCULAR
  65. } GtkCTreeExpanderStyle;
  66. typedef enum
  67. {
  68. GTK_CTREE_EXPANSION_EXPAND,
  69. GTK_CTREE_EXPANSION_EXPAND_RECURSIVE,
  70. GTK_CTREE_EXPANSION_COLLAPSE,
  71. GTK_CTREE_EXPANSION_COLLAPSE_RECURSIVE,
  72. GTK_CTREE_EXPANSION_TOGGLE,
  73. GTK_CTREE_EXPANSION_TOGGLE_RECURSIVE
  74. } GtkCTreeExpansionType;
  75. typedef struct _GtkCTree GtkCTree;
  76. typedef struct _GtkCTreeClass GtkCTreeClass;
  77. typedef struct _GtkCTreeRow GtkCTreeRow;
  78. typedef struct _GtkCTreeNode GtkCTreeNode;
  79. typedef void (*GtkCTreeFunc) (GtkCTree *ctree,
  80. GtkCTreeNode *node,
  81. gpointer data);
  82. typedef gboolean (*GtkCTreeGNodeFunc) (GtkCTree *ctree,
  83. guint depth,
  84. GNode *gnode,
  85. GtkCTreeNode *cnode,
  86. gpointer data);
  87. typedef gboolean (*GtkCTreeCompareDragFunc) (GtkCTree *ctree,
  88. GtkCTreeNode *source_node,
  89. GtkCTreeNode *new_parent,
  90. GtkCTreeNode *new_sibling);
  91. struct _GtkCTree
  92. {
  93. GtkCList clist;
  94. GdkGC *lines_gc;
  95. gint tree_indent;
  96. gint tree_spacing;
  97. gint tree_column;
  98. guint line_style : 2;
  99. guint expander_style : 2;
  100. guint show_stub : 1;
  101. GtkCTreeCompareDragFunc drag_compare;
  102. };
  103. struct _GtkCTreeClass
  104. {
  105. GtkCListClass parent_class;
  106. void (*tree_select_row) (GtkCTree *ctree,
  107. GtkCTreeNode *row,
  108. gint column);
  109. void (*tree_unselect_row) (GtkCTree *ctree,
  110. GtkCTreeNode *row,
  111. gint column);
  112. void (*tree_expand) (GtkCTree *ctree,
  113. GtkCTreeNode *node);
  114. void (*tree_collapse) (GtkCTree *ctree,
  115. GtkCTreeNode *node);
  116. void (*tree_move) (GtkCTree *ctree,
  117. GtkCTreeNode *node,
  118. GtkCTreeNode *new_parent,
  119. GtkCTreeNode *new_sibling);
  120. void (*change_focus_row_expansion) (GtkCTree *ctree,
  121. GtkCTreeExpansionType action);
  122. };
  123. struct _GtkCTreeRow
  124. {
  125. GtkCListRow row;
  126. GtkCTreeNode *parent;
  127. GtkCTreeNode *sibling;
  128. GtkCTreeNode *children;
  129. GdkPixmap *pixmap_closed;
  130. GdkBitmap *mask_closed;
  131. GdkPixmap *pixmap_opened;
  132. GdkBitmap *mask_opened;
  133. guint16 level;
  134. guint is_leaf : 1;
  135. guint expanded : 1;
  136. };
  137. struct _GtkCTreeNode {
  138. GList list;
  139. };
  140. /***********************************************************
  141. * Creation, insertion, deletion *
  142. ***********************************************************/
  143. GType gtk_ctree_get_type (void) G_GNUC_CONST;
  144. GtkWidget * gtk_ctree_new_with_titles (gint columns,
  145. gint tree_column,
  146. gchar *titles[]);
  147. GtkWidget * gtk_ctree_new (gint columns,
  148. gint tree_column);
  149. GtkCTreeNode * gtk_ctree_insert_node (GtkCTree *ctree,
  150. GtkCTreeNode *parent,
  151. GtkCTreeNode *sibling,
  152. gchar *text[],
  153. guint8 spacing,
  154. GdkPixmap *pixmap_closed,
  155. GdkBitmap *mask_closed,
  156. GdkPixmap *pixmap_opened,
  157. GdkBitmap *mask_opened,
  158. gboolean is_leaf,
  159. gboolean expanded);
  160. void gtk_ctree_remove_node (GtkCTree *ctree,
  161. GtkCTreeNode *node);
  162. GtkCTreeNode * gtk_ctree_insert_gnode (GtkCTree *ctree,
  163. GtkCTreeNode *parent,
  164. GtkCTreeNode *sibling,
  165. GNode *gnode,
  166. GtkCTreeGNodeFunc func,
  167. gpointer data);
  168. GNode * gtk_ctree_export_to_gnode (GtkCTree *ctree,
  169. GNode *parent,
  170. GNode *sibling,
  171. GtkCTreeNode *node,
  172. GtkCTreeGNodeFunc func,
  173. gpointer data);
  174. /***********************************************************
  175. * Generic recursive functions, querying / finding tree *
  176. * information *
  177. ***********************************************************/
  178. void gtk_ctree_post_recursive (GtkCTree *ctree,
  179. GtkCTreeNode *node,
  180. GtkCTreeFunc func,
  181. gpointer data);
  182. void gtk_ctree_post_recursive_to_depth (GtkCTree *ctree,
  183. GtkCTreeNode *node,
  184. gint depth,
  185. GtkCTreeFunc func,
  186. gpointer data);
  187. void gtk_ctree_pre_recursive (GtkCTree *ctree,
  188. GtkCTreeNode *node,
  189. GtkCTreeFunc func,
  190. gpointer data);
  191. void gtk_ctree_pre_recursive_to_depth (GtkCTree *ctree,
  192. GtkCTreeNode *node,
  193. gint depth,
  194. GtkCTreeFunc func,
  195. gpointer data);
  196. gboolean gtk_ctree_is_viewable (GtkCTree *ctree,
  197. GtkCTreeNode *node);
  198. GtkCTreeNode * gtk_ctree_last (GtkCTree *ctree,
  199. GtkCTreeNode *node);
  200. GtkCTreeNode * gtk_ctree_find_node_ptr (GtkCTree *ctree,
  201. GtkCTreeRow *ctree_row);
  202. GtkCTreeNode * gtk_ctree_node_nth (GtkCTree *ctree,
  203. guint row);
  204. gboolean gtk_ctree_find (GtkCTree *ctree,
  205. GtkCTreeNode *node,
  206. GtkCTreeNode *child);
  207. gboolean gtk_ctree_is_ancestor (GtkCTree *ctree,
  208. GtkCTreeNode *node,
  209. GtkCTreeNode *child);
  210. GtkCTreeNode * gtk_ctree_find_by_row_data (GtkCTree *ctree,
  211. GtkCTreeNode *node,
  212. gpointer data);
  213. /* returns a GList of all GtkCTreeNodes with row->data == data. */
  214. GList * gtk_ctree_find_all_by_row_data (GtkCTree *ctree,
  215. GtkCTreeNode *node,
  216. gpointer data);
  217. GtkCTreeNode * gtk_ctree_find_by_row_data_custom (GtkCTree *ctree,
  218. GtkCTreeNode *node,
  219. gpointer data,
  220. GCompareFunc func);
  221. /* returns a GList of all GtkCTreeNodes with row->data == data. */
  222. GList * gtk_ctree_find_all_by_row_data_custom (GtkCTree *ctree,
  223. GtkCTreeNode *node,
  224. gpointer data,
  225. GCompareFunc func);
  226. gboolean gtk_ctree_is_hot_spot (GtkCTree *ctree,
  227. gint x,
  228. gint y);
  229. /***********************************************************
  230. * Tree signals : move, expand, collapse, (un)select *
  231. ***********************************************************/
  232. void gtk_ctree_move (GtkCTree *ctree,
  233. GtkCTreeNode *node,
  234. GtkCTreeNode *new_parent,
  235. GtkCTreeNode *new_sibling);
  236. void gtk_ctree_expand (GtkCTree *ctree,
  237. GtkCTreeNode *node);
  238. void gtk_ctree_expand_recursive (GtkCTree *ctree,
  239. GtkCTreeNode *node);
  240. void gtk_ctree_expand_to_depth (GtkCTree *ctree,
  241. GtkCTreeNode *node,
  242. gint depth);
  243. void gtk_ctree_collapse (GtkCTree *ctree,
  244. GtkCTreeNode *node);
  245. void gtk_ctree_collapse_recursive (GtkCTree *ctree,
  246. GtkCTreeNode *node);
  247. void gtk_ctree_collapse_to_depth (GtkCTree *ctree,
  248. GtkCTreeNode *node,
  249. gint depth);
  250. void gtk_ctree_toggle_expansion (GtkCTree *ctree,
  251. GtkCTreeNode *node);
  252. void gtk_ctree_toggle_expansion_recursive (GtkCTree *ctree,
  253. GtkCTreeNode *node);
  254. void gtk_ctree_select (GtkCTree *ctree,
  255. GtkCTreeNode *node);
  256. void gtk_ctree_select_recursive (GtkCTree *ctree,
  257. GtkCTreeNode *node);
  258. void gtk_ctree_unselect (GtkCTree *ctree,
  259. GtkCTreeNode *node);
  260. void gtk_ctree_unselect_recursive (GtkCTree *ctree,
  261. GtkCTreeNode *node);
  262. void gtk_ctree_real_select_recursive (GtkCTree *ctree,
  263. GtkCTreeNode *node,
  264. gint state);
  265. /***********************************************************
  266. * Analogons of GtkCList functions *
  267. ***********************************************************/
  268. void gtk_ctree_node_set_text (GtkCTree *ctree,
  269. GtkCTreeNode *node,
  270. gint column,
  271. const gchar *text);
  272. void gtk_ctree_node_set_pixmap (GtkCTree *ctree,
  273. GtkCTreeNode *node,
  274. gint column,
  275. GdkPixmap *pixmap,
  276. GdkBitmap *mask);
  277. void gtk_ctree_node_set_pixtext (GtkCTree *ctree,
  278. GtkCTreeNode *node,
  279. gint column,
  280. const gchar *text,
  281. guint8 spacing,
  282. GdkPixmap *pixmap,
  283. GdkBitmap *mask);
  284. void gtk_ctree_set_node_info (GtkCTree *ctree,
  285. GtkCTreeNode *node,
  286. const gchar *text,
  287. guint8 spacing,
  288. GdkPixmap *pixmap_closed,
  289. GdkBitmap *mask_closed,
  290. GdkPixmap *pixmap_opened,
  291. GdkBitmap *mask_opened,
  292. gboolean is_leaf,
  293. gboolean expanded);
  294. void gtk_ctree_node_set_shift (GtkCTree *ctree,
  295. GtkCTreeNode *node,
  296. gint column,
  297. gint vertical,
  298. gint horizontal);
  299. void gtk_ctree_node_set_selectable (GtkCTree *ctree,
  300. GtkCTreeNode *node,
  301. gboolean selectable);
  302. gboolean gtk_ctree_node_get_selectable (GtkCTree *ctree,
  303. GtkCTreeNode *node);
  304. GtkCellType gtk_ctree_node_get_cell_type (GtkCTree *ctree,
  305. GtkCTreeNode *node,
  306. gint column);
  307. gboolean gtk_ctree_node_get_text (GtkCTree *ctree,
  308. GtkCTreeNode *node,
  309. gint column,
  310. gchar **text);
  311. gboolean gtk_ctree_node_get_pixmap (GtkCTree *ctree,
  312. GtkCTreeNode *node,
  313. gint column,
  314. GdkPixmap **pixmap,
  315. GdkBitmap **mask);
  316. gboolean gtk_ctree_node_get_pixtext (GtkCTree *ctree,
  317. GtkCTreeNode *node,
  318. gint column,
  319. gchar **text,
  320. guint8 *spacing,
  321. GdkPixmap **pixmap,
  322. GdkBitmap **mask);
  323. gboolean gtk_ctree_get_node_info (GtkCTree *ctree,
  324. GtkCTreeNode *node,
  325. gchar **text,
  326. guint8 *spacing,
  327. GdkPixmap **pixmap_closed,
  328. GdkBitmap **mask_closed,
  329. GdkPixmap **pixmap_opened,
  330. GdkBitmap **mask_opened,
  331. gboolean *is_leaf,
  332. gboolean *expanded);
  333. void gtk_ctree_node_set_row_style (GtkCTree *ctree,
  334. GtkCTreeNode *node,
  335. GtkStyle *style);
  336. GtkStyle * gtk_ctree_node_get_row_style (GtkCTree *ctree,
  337. GtkCTreeNode *node);
  338. void gtk_ctree_node_set_cell_style (GtkCTree *ctree,
  339. GtkCTreeNode *node,
  340. gint column,
  341. GtkStyle *style);
  342. GtkStyle * gtk_ctree_node_get_cell_style (GtkCTree *ctree,
  343. GtkCTreeNode *node,
  344. gint column);
  345. void gtk_ctree_node_set_foreground (GtkCTree *ctree,
  346. GtkCTreeNode *node,
  347. const GdkColor *color);
  348. void gtk_ctree_node_set_background (GtkCTree *ctree,
  349. GtkCTreeNode *node,
  350. const GdkColor *color);
  351. void gtk_ctree_node_set_row_data (GtkCTree *ctree,
  352. GtkCTreeNode *node,
  353. gpointer data);
  354. void gtk_ctree_node_set_row_data_full (GtkCTree *ctree,
  355. GtkCTreeNode *node,
  356. gpointer data,
  357. GDestroyNotify destroy);
  358. gpointer gtk_ctree_node_get_row_data (GtkCTree *ctree,
  359. GtkCTreeNode *node);
  360. void gtk_ctree_node_moveto (GtkCTree *ctree,
  361. GtkCTreeNode *node,
  362. gint column,
  363. gfloat row_align,
  364. gfloat col_align);
  365. GtkVisibility gtk_ctree_node_is_visible (GtkCTree *ctree,
  366. GtkCTreeNode *node);
  367. /***********************************************************
  368. * GtkCTree specific functions *
  369. ***********************************************************/
  370. void gtk_ctree_set_indent (GtkCTree *ctree,
  371. gint indent);
  372. void gtk_ctree_set_spacing (GtkCTree *ctree,
  373. gint spacing);
  374. void gtk_ctree_set_show_stub (GtkCTree *ctree,
  375. gboolean show_stub);
  376. void gtk_ctree_set_line_style (GtkCTree *ctree,
  377. GtkCTreeLineStyle line_style);
  378. void gtk_ctree_set_expander_style (GtkCTree *ctree,
  379. GtkCTreeExpanderStyle expander_style);
  380. void gtk_ctree_set_drag_compare_func (GtkCTree *ctree,
  381. GtkCTreeCompareDragFunc cmp_func);
  382. /***********************************************************
  383. * Tree sorting functions *
  384. ***********************************************************/
  385. void gtk_ctree_sort_node (GtkCTree *ctree,
  386. GtkCTreeNode *node);
  387. void gtk_ctree_sort_recursive (GtkCTree *ctree,
  388. GtkCTreeNode *node);
  389. #define gtk_ctree_set_reorderable(t,r) gtk_clist_set_reorderable((GtkCList*) (t),(r))
  390. /* GType for the GtkCTreeNode. This is a boxed type, although it uses
  391. * no-op's for the copy and free routines. It is defined in order to
  392. * provide type information for the signal arguments
  393. */
  394. GType gtk_ctree_node_get_type (void) G_GNUC_CONST;
  395. G_END_DECLS
  396. #endif /* __GTK_CTREE_H__ */
  397. #endif /* GTK_DISABLE_DEPRECATED */