comparison finch/libgnt/gnttree.h @ 18404:9a0f99ea664d

Resize tree-columns nicely when the tree is resized. We can tell it to set a fixed with for a column, or maintain the width-ratio when resizing.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 01 Jul 2007 12:21:30 +0000
parents 1f9db757efc2
children e79da0369a6d
comparison
equal deleted inserted replaced
18403:8ee1f173253c 18404:9a0f99ea664d
38 #define GNT_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_TREE, GntTreeClass)) 38 #define GNT_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_TREE, GntTreeClass))
39 #define GNT_IS_TREE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_TREE)) 39 #define GNT_IS_TREE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_TREE))
40 #define GNT_IS_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_TREE)) 40 #define GNT_IS_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_TREE))
41 #define GNT_TREE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_TREE, GntTreeClass)) 41 #define GNT_TREE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_TREE, GntTreeClass))
42 42
43 #define GNT_TREE_FLAGS(obj) (GNT_TREE(obj)->priv.flags)
44 #define GNT_TREE_SET_FLAGS(obj, flags) (GNT_TREE_FLAGS(obj) |= flags)
45 #define GNT_TREE_UNSET_FLAGS(obj, flags) (GNT_TREE_FLAGS(obj) &= ~(flags))
46
47 typedef struct _GntTree GntTree; 43 typedef struct _GntTree GntTree;
48 typedef struct _GntTreePriv GntTreePriv; 44 typedef struct _GntTreePriv GntTreePriv;
49 typedef struct _GntTreeClass GntTreeClass; 45 typedef struct _GntTreeClass GntTreeClass;
50 46
51 typedef struct _GntTreeRow GntTreeRow; 47 typedef struct _GntTreeRow GntTreeRow;
52 typedef struct _GntTreeCol GntTreeCol; 48 typedef struct _GntTreeCol GntTreeCol;
49
50 typedef enum {
51 GNT_TREE_COLUMN_INVISIBLE = 1 << 0,
52 GNT_TREE_COLUMN_FIXED_SIZE = 1 << 1,
53 } GntTreeColumnFlag;
53 54
54 struct _GntTree 55 struct _GntTree
55 { 56 {
56 GntWidget parent; 57 GntWidget parent;
57 58
72 int ncol; /* No. of columns */ 73 int ncol; /* No. of columns */
73 struct _GntTreeColInfo 74 struct _GntTreeColInfo
74 { 75 {
75 int width; 76 int width;
76 char *title; 77 char *title;
77 gboolean invisible; 78 int width_ratio;
79 GntTreeColumnFlag flags;
78 } *columns; /* Would a GList be better? */ 80 } *columns; /* Would a GList be better? */
79 gboolean show_title; 81 gboolean show_title;
80 gboolean show_separator; /* Whether to show column separators */ 82 gboolean show_separator; /* Whether to show column separators */
81 83
82 GString *search; 84 GString *search;
366 * @param eq 368 * @param eq
367 * @param kd 369 * @param kd
368 */ 370 */
369 void gnt_tree_set_hash_fns(GntTree *tree, gpointer hash, gpointer eq, gpointer kd); 371 void gnt_tree_set_hash_fns(GntTree *tree, gpointer hash, gpointer eq, gpointer kd);
370 372
371 /* This can be useful when, for example, we want to store some data 373 /**
372 * which we don't want/need to display. */ 374 * Set whether a column is visible or not.
375 * This can be useful when, for example, we want to store some data
376 * which we don't want/need to display.
377 *
378 * @param tree The tree
379 * @param col The index of the column
380 * @param vis If @c FALSE, the column will not be displayed
381 */
382 void gnt_tree_set_column_visible(GntTree *tree, int col, gboolean vis);
383
384 /**
385 * Set whether a column can be resized to keep the same ratio when the
386 * tree is resized.
387 *
388 * @param tree The tree
389 * @param col The index of the column
390 * @param res If @c FALSE, the column will not be resized when the
391 * tree is resized
392 */
393 void gnt_tree_set_column_resizable(GntTree *tree, int col, gboolean res);
394
395 /**
396 * Set column widths to use when calculating column widths after a tree
397 * is resized.
398 *
399 * @param tree The tree
400 * @param cols Array of widths. The width must have the same number
401 * of entries as the number of columns in the tree, or
402 * end with a negative value for a column-width.
403 */
404 void gnt_tree_set_column_width_ratio(GntTree *tree, int cols[]);
405
406 G_END_DECLS
407
408 /* The following functions should NOT be used by applications. */
409
410 /* This should be called by the subclasses of GntTree's in their _new function */
373 /** 411 /**
374 * 412 *
375 * @param tree 413 * @param tree
376 * @param col 414 * @param col
377 * @param vis
378 */
379 void gnt_tree_set_column_visible(GntTree *tree, int col, gboolean vis);
380
381 G_END_DECLS
382
383 /* The following functions should NOT be used by applications. */
384
385 /* This should be called by the subclasses of GntTree's in their _new function */
386 /**
387 *
388 * @param tree
389 * @param col
390 */ 415 */
391 void _gnt_tree_init_internals(GntTree *tree, int col); 416 void _gnt_tree_init_internals(GntTree *tree, int col);
392 417
393 #endif /* GNT_TREE_H */ 418 #endif /* GNT_TREE_H */