r898: Applied Bernard Jungen's latest patch:
[rox-filer.git] / ROX-Filer / src / collection.h
blob034c2c608253157ae694de90914b0ae4652256fd
1 /*
2 * $Id$
4 * The collection widget provides an area for displaying a collection of
5 * objects (such as files). It allows the user to choose a selection of
6 * them and provides signals to allow popping up menus, detecting double-clicks
7 * etc.
9 * Thomas Leonard, <tal197@users.sourceforge.net>
13 #ifndef __COLLECTION_H__
14 #define __COLLECTION_H__
16 #include <gdk/gdk.h>
17 #include <gtk/gtkwidget.h>
19 #ifdef __cplusplus
20 extern "C" {
21 #endif /* __cplusplus */
23 #define COLLECTION(obj) GTK_CHECK_CAST((obj), collection_get_type(), Collection)
24 #define COLLECTION_CLASS(klass) GTK_CHECK_CLASS_CAST((klass), \
25 collection_get_type(), CollectionClass)
26 #define IS_COLLECTION(obj) GTK_CHECK_TYPE((obj), collection_get_type())
28 /* If the display gets mucked up then remember to fix it next time we get the
29 * chance.
31 enum
33 PAINT_NORMAL, /* Just redraw what we need to */
34 PAINT_OVERWRITE, /* Draw everything */
35 PAINT_CLEAR, /* Blank everything, then redraw */
39 typedef struct _Collection Collection;
40 typedef struct _CollectionClass CollectionClass;
41 typedef struct _CollectionItem CollectionItem;
42 typedef void (*CollectionDrawFunc)(GtkWidget *widget,
43 CollectionItem *item,
44 GdkRectangle *area,
45 gpointer user_data);
46 typedef gboolean (*CollectionTestFunc)( Collection *collection,
47 int point_x, int point_y,
48 CollectionItem *item,
49 int width, int height,
50 gpointer user_data);
52 struct _CollectionItem
54 gpointer data;
55 gboolean selected;
58 struct _Collection
60 GtkWidget parent_widget;
62 GtkAdjustment *vadj;
63 guint last_scroll; /* Current/previous scroll value */
65 CollectionDrawFunc draw_item;
66 CollectionTestFunc test_point;
67 gpointer cb_user_data; /* Passed to above two functions */
68 int paint_level; /* Complete redraw on next paint? */
69 GdkGC *bg_gc; /* NULL unless pixmap background */
71 gboolean lasso_box; /* Is the box drawn? */
72 int drag_box_x[2]; /* Index 0 is the fixed corner */
73 int drag_box_y[2];
74 GdkGC *xor_gc;
76 CollectionItem *items;
77 gint cursor_item; /* -1 if not shown */
78 gint cursor_item_old; /* May be -1 */
79 gint wink_item; /* -1 if not active */
80 gint winks_left; /* Flashes in this wink op */
81 gint wink_timeout;
82 guint columns;
83 gint number_of_items; /* (often compared with -1) */
84 guint item_width, item_height;
86 guint number_selected;
88 guint array_size;
90 gint auto_scroll; /* Timer */
92 gint block_selection_changed;
95 struct _CollectionClass
97 GtkWidgetClass parent_class;
99 void (*gain_selection)(Collection *collection,
100 gint time);
101 void (*lose_selection)(Collection *collection,
102 gint time);
103 void (*selection_changed)(Collection *collection,
104 gint time);
107 guint collection_get_type (void);
108 GtkWidget *collection_new (GtkAdjustment *vadj);
109 void collection_clear (Collection *collection);
110 void collection_clear_except (Collection *collection, gint item);
111 gint collection_insert (Collection *collection, gpointer data);
112 void collection_remove (Collection *collection, gint item);
113 void collection_unselect_item (Collection *collection, gint item);
114 void collection_select_item (Collection *collection, gint item);
115 void collection_toggle_item (Collection *collection, gint item);
116 void collection_select_all (Collection *collection);
117 void collection_clear_selection (Collection *collection);
118 void collection_draw_item (Collection *collection, gint item,
119 gboolean blank);
120 void collection_set_functions (Collection *collection,
121 CollectionDrawFunc draw_item,
122 CollectionTestFunc test_point,
123 gpointer user_data);
124 void collection_set_item_size (Collection *collection,
125 int width, int height);
126 void collection_qsort (Collection *collection,
127 int (*compar)(const void *,
128 const void *));
129 int collection_find_item (Collection *collection,
130 gpointer data,
131 int (*compar)(const void *,
132 const void *));
133 int collection_get_item (Collection *collection, int x, int y);
134 void collection_set_cursor_item (Collection *collection, gint item);
135 void collection_wink_item (Collection *collection, gint item);
136 void collection_delete_if (Collection *collection,
137 gboolean (*test)(gpointer item,
138 gpointer data),
139 gpointer data);
140 void collection_move_cursor (Collection *collection,
141 int drow, int dcol);
142 void collection_set_autoscroll (Collection *collection,
143 gboolean auto_scroll);
144 void collection_lasso_box (Collection *collection, int x, int y);
145 void collection_end_lasso (Collection *collection,
146 GdkFunction fn);
147 void collection_snap_size (Collection *collection,
148 int rows, int cols);
149 void collection_unblock_selection_changed(Collection *collection,
150 guint time,
151 gboolean emit);
153 #ifdef __cplusplus
155 #endif /* __cplusplus */
157 #endif /* __COLLECTION_H__ */