r1553: Created View interface and started moving collection specific stuff
[rox-filer.git] / ROX-Filer / src / collection.h
blobe5fdea00bb4f2e13b62507dde32787da926296bf
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(obj) G_TYPE_INSTANCE_GET_CLASS((obj), \
25 collection_get_type(), CollectionClass)
26 #define IS_COLLECTION(obj) \
27 G_TYPE_CHECK_INSTANCE_TYPE((obj), collection_get_type())
29 /* If the display gets mucked up then remember to fix it next time we get the
30 * chance.
32 enum
34 PAINT_NORMAL, /* Just redraw what we need to */
35 PAINT_OVERWRITE, /* Draw everything */
36 PAINT_CLEAR, /* Blank everything, then redraw */
40 typedef struct _CollectionClass CollectionClass;
41 typedef void (*CollectionDrawFunc)(GtkWidget *widget,
42 CollectionItem *item,
43 GdkRectangle *area,
44 gpointer user_data);
45 typedef gboolean (*CollectionTestFunc)( Collection *collection,
46 int point_x, int point_y,
47 CollectionItem *item,
48 int width, int height,
49 gpointer user_data);
50 typedef void (*CollectionFreeFunc)(Collection *collection,
51 CollectionItem *item);
53 struct _CollectionItem
55 gpointer data;
56 gpointer view_data;
57 gboolean selected;
60 struct _Collection
62 GtkWidget parent_widget;
64 /* With 2.0, the collection is in a Viewport, and this is used only to
65 * force scrolling, etc.
67 GtkAdjustment *vadj;
69 CollectionDrawFunc draw_item;
70 CollectionTestFunc test_point;
71 CollectionFreeFunc free_item;
72 gpointer cb_user_data; /* Passed to above functions */
74 gboolean lasso_box; /* Is the box drawn? */
75 int drag_box_x[2]; /* Index 0 is the fixed corner */
76 int drag_box_y[2];
77 GdkGC *xor_gc;
79 CollectionItem *items;
80 gint cursor_item; /* -1 if not shown */
81 gint cursor_item_old; /* May be -1 */
82 gint wink_item; /* -1 if not active */
83 gint wink_on_map; /* -1 if not waiting for map */
84 gint winks_left; /* Flashes in this wink op */
85 gint wink_timeout;
86 guint columns;
87 gint number_of_items; /* (often compared with -1) */
88 guint item_width, item_height;
90 guint number_selected;
92 guint array_size;
94 gint auto_scroll; /* Timer */
96 gint block_selection_changed;
99 struct _CollectionClass
101 GtkWidgetClass parent_class;
103 void (*gain_selection)(Collection *collection,
104 gint time);
105 void (*lose_selection)(Collection *collection,
106 gint time);
107 void (*selection_changed)(Collection *collection,
108 gint time);
110 void (*draw_item)(GtkWidget *widget,
111 CollectionItem *item,
112 GdkRectangle *area);
114 gboolean (*test_point)(Collection *collection,
115 int point_x, int point_y,
116 CollectionItem *item,
117 int width, int height);
119 void (*free_item)(Collection *collection,
120 CollectionItem *item);
123 GType collection_get_type (void);
124 GtkWidget *collection_new (void);
125 void collection_clear (Collection *collection);
126 void collection_clear_except (Collection *collection, gint item);
127 gint collection_insert (Collection *collection,
128 gpointer data,
129 gpointer view);
130 void collection_remove (Collection *collection, gint item);
131 void collection_unselect_item (Collection *collection, gint item);
132 void collection_select_item (Collection *collection, gint item);
133 void collection_toggle_item (Collection *collection, gint item);
134 void collection_select_all (Collection *collection);
135 void collection_clear_selection (Collection *collection);
136 void collection_invert_selection (Collection *collection);
137 void collection_draw_item (Collection *collection, gint item,
138 gboolean blank);
139 void collection_set_item_size (Collection *collection,
140 int width, int height);
141 void collection_qsort (Collection *collection,
142 int (*compar)(const void *,
143 const void *));
144 int collection_find_item (Collection *collection,
145 gpointer data,
146 int (*compar)(const void *,
147 const void *));
148 int collection_get_item (Collection *collection, int x, int y);
149 int collection_selected_item_number (Collection *collection);
150 void collection_set_cursor_item (Collection *collection, gint item);
151 void collection_wink_item (Collection *collection, gint item);
152 void collection_delete_if (Collection *collection,
153 gboolean (*test)(gpointer item,
154 gpointer data),
155 gpointer data);
156 void collection_move_cursor (Collection *collection,
157 int drow, int dcol);
158 void collection_set_autoscroll (Collection *collection,
159 gboolean auto_scroll);
160 void collection_lasso_box (Collection *collection, int x, int y);
161 void collection_end_lasso (Collection *collection,
162 GdkFunction fn);
163 void collection_snap_size (Collection *collection,
164 int rows, int cols);
165 void collection_unblock_selection_changed(Collection *collection,
166 guint time,
167 gboolean emit);
169 #ifdef __cplusplus
171 #endif /* __cplusplus */
173 #endif /* __COLLECTION_H__ */