2 * The collection widget provides an area for displaying a collection of
3 * objects (such as files). It allows the user to choose a selection of
4 * them and provides signals to allow popping up menus, detecting double-clicks
7 * Thomas Leonard, <tal197@users.sourceforge.net>
11 #ifndef __COLLECTION_H__
12 #define __COLLECTION_H__
15 #include <gtk/gtkwidget.h>
19 #endif /* __cplusplus */
21 #define COLLECTION(obj) GTK_CHECK_CAST((obj), collection_get_type(), Collection)
22 #define COLLECTION_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), \
23 collection_get_type(), CollectionClass)
24 #define IS_COLLECTION(obj) \
25 G_TYPE_CHECK_INSTANCE_TYPE((obj), collection_get_type())
27 /* If the display gets mucked up then remember to fix it next time we get the
32 PAINT_NORMAL
, /* Just redraw what we need to */
33 PAINT_OVERWRITE
, /* Draw everything */
34 PAINT_CLEAR
, /* Blank everything, then redraw */
37 typedef struct _Collection Collection
;
39 /* Each item in a Collection has one of these, which stores its selected
40 * state, data, and view_data.
42 typedef struct _CollectionItem CollectionItem
;
44 typedef struct _CollectionClass CollectionClass
;
45 typedef void (*CollectionDrawFunc
)(GtkWidget
*widget
,
49 typedef gboolean (*CollectionTestFunc
)( Collection
*collection
,
50 int point_x
, int point_y
,
52 int width
, int height
,
54 typedef void (*CollectionFreeFunc
)(Collection
*collection
,
55 CollectionItem
*item
);
57 struct _CollectionItem
66 GtkWidget parent_widget
;
68 /* With 2.0, the collection is in a Viewport, and this is used only to
69 * force scrolling, etc.
73 CollectionDrawFunc draw_item
;
74 CollectionTestFunc test_point
;
75 CollectionFreeFunc free_item
;
76 gpointer cb_user_data
; /* Passed to above functions */
78 gboolean lasso_box
; /* Is the box drawn? */
79 int drag_box_x
[2]; /* Index 0 is the fixed corner */
83 CollectionItem
*items
;
84 gint cursor_item
; /* -1 if not shown */
85 gint cursor_item_old
; /* May be -1 */
86 gint wink_item
; /* -1 if not active */
87 gint wink_on_map
; /* -1 if not waiting for map */
88 gint winks_left
; /* Flashes in this wink op */
91 gboolean vertical_order
; /* order elements vertically? */
92 gint number_of_items
; /* (often compared with -1) */
93 guint item_width
, item_height
;
95 guint number_selected
;
99 gint block_selection_changed
;
102 struct _CollectionClass
104 GtkWidgetClass parent_class
;
106 void (*gain_selection
)(Collection
*collection
,
108 void (*lose_selection
)(Collection
*collection
,
110 void (*selection_changed
)(Collection
*collection
,
114 GType
collection_get_type (void);
115 GtkWidget
*collection_new (void);
116 void collection_clear (Collection
*collection
);
117 void collection_clear_except (Collection
*collection
, gint item
);
118 gint
collection_insert (Collection
*collection
,
121 void collection_remove (Collection
*collection
, gint item
);
122 void collection_unselect_item (Collection
*collection
, gint item
);
123 void collection_select_item (Collection
*collection
, gint item
);
124 void collection_toggle_item (Collection
*collection
, gint item
);
125 void collection_select_all (Collection
*collection
);
126 void collection_clear_selection (Collection
*collection
);
127 void collection_invert_selection (Collection
*collection
);
128 void collection_draw_item (Collection
*collection
, gint item
,
130 void collection_set_item_size (Collection
*collection
,
131 int width
, int height
);
132 void collection_qsort (Collection
*collection
,
133 int (*compar
)(const void *,
136 int collection_find_item (Collection
*collection
,
138 int (*compar
)(const void *,
141 int collection_get_item (Collection
*collection
, int x
, int y
);
142 void collection_set_cursor_item (Collection
*collection
, gint item
,
143 gboolean may_scroll
);
144 void collection_wink_item (Collection
*collection
, gint item
);
145 void collection_delete_if (Collection
*collection
,
146 gboolean (*test
)(gpointer item
,
149 void collection_move_cursor (Collection
*collection
,
151 void collection_lasso_box (Collection
*collection
, int x
, int y
);
152 void collection_end_lasso (Collection
*collection
,
154 void collection_snap_size (Collection
*collection
,
156 void collection_unblock_selection_changed(Collection
*collection
,
159 void collection_item_to_rowcol (const Collection
*collection
,
160 int item
, int *row
, int *col
);
161 int collection_rowcol_to_item (const Collection
*collection
,
165 #endif /* __cplusplus */
167 #endif /* __COLLECTION_H__ */