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