1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Author :
* Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
#ifndef _E_ICON_BAR_H_
#define _E_ICON_BAR_H_
#include <gdk_imlib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gal/widgets/e-canvas.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* EIconBar is a subclass of GnomeCanvas for displaying a vertical column of
* icons and descriptions. It provides 2 views - large icons and small icons.
*/
/* This contains information on one item. */
typedef struct _EIconBarItem EIconBarItem;
struct _EIconBarItem
{
GnomeCanvasItem *text;
GnomeCanvasItem *image;
/* This holds the original pixbuf so that we can blend
to the background if the style changes */
GdkPixbuf *pixbuf;
/* This is user data attached to the item, e.g. a URL. */
gpointer data;
GtkDestroyNotify destroy;
/* This is the height of the item. */
gint item_height;
/* This is the actual x, width and height of the text, rather than
the maximum allowed area. */
gint text_x;
gint text_width;
gint text_height;
gint icon_y, text_y;
};
/* These are the view types. Defaults to LARGE_ICONS. */
typedef enum
{
E_ICON_BAR_LARGE_ICONS,
E_ICON_BAR_SMALL_ICONS
} EIconBarViewType;
/* These index our colors array. */
typedef enum
{
E_ICON_BAR_COLOR_EDITING_TEXT,
E_ICON_BAR_COLOR_EDITING_RECT,
E_ICON_BAR_COLOR_EDITING_RECT_OUTLINE,
E_ICON_BAR_COLOR_LAST
} EIconBarColors;
#define E_ICON_BAR(obj) GTK_CHECK_CAST (obj, e_icon_bar_get_type (), EIconBar)
#define E_ICON_BAR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_icon_bar_get_type (), EIconBarClass)
#define E_IS_ICON_BAR(obj) GTK_CHECK_TYPE (obj, e_icon_bar_get_type ())
typedef struct _EIconBar EIconBar;
typedef struct _EIconBarClass EIconBarClass;
struct _EIconBar
{
ECanvas canvas;
/* This specifies if we are using large icons or small icons. */
EIconBarViewType view_type;
/* This is an array of EIconBarItem elements. */
GArray *items;
/* This is the index of the item which has been pressed, or -1.
It will be shown as pressed in while the mouse is over it. */
gint pressed_item_num;
/* This is the coordinates of where the button was pressed. If the
mouse moves a certain distance with the button still pressed, we
start a drag. */
gint pressed_x;
gint pressed_y;
/* This is the index of the item the mouse is currently over, or -1.
It will be highlighted unless one of the items is pressed. */
gint mouse_over_item_num;
/* This is the item that we are currently editing, or -1. */
gint editing_item_num;
/* This is a GnomeCanvasRect which is placed around the edited item. */
GnomeCanvasItem *edit_rect_item;
/* This is the index of the item which is being dragged, or -1.
If the drag results in a move it will be deleted. */
gint dragged_item_num;
/* This is TRUE if we are dragging over this EIconBar. */
gboolean in_drag;
/* This is used in drag-and-drop to indicate the item which the mouse
is currently before, e.g. if it is 1 then a dropped item would be
inserted between items 0 and 1. It ranges from 0 to the number of
items, or is -1 when the mouse is not dragging between items. */
gint dragging_before_item_num;
/* These are the common positions of all the items in the EIconBar. */
gint icon_x, icon_w, icon_h, text_x, text_w, spacing;
/* This is the source id of our auto-scroll timeout handler, used when
in the middle of drag-and-drop operations. */
gint auto_scroll_timeout_id;
gint auto_scroll_delay;
gboolean scrolling_up;
/* Colors for drawing. */
GdkColor colors[E_ICON_BAR_COLOR_LAST];
/* Signal connection id for "value_changed" signal of vadjustment. */
guint vadjustment_value_changed_id;
};
struct _EIconBarClass
{
ECanvasClass parent_class;
void (*selected_item) (EIconBar *icon_bar,
GdkEvent *event,
gint item_num);
void (*dragged_item) (EIconBar *icon_bar,
GdkEvent *event,
gint item_num);
};
GtkType e_icon_bar_get_type (void);
GtkWidget* e_icon_bar_new (void);
/* Sets the view type. */
void e_icon_bar_set_view_type (EIconBar *icon_bar,
EIconBarViewType view_type);
/* Adds a new item to a group at the given position. If position is -1 it is
added at the end. It returns the index of the item. */
gint e_icon_bar_add_item (EIconBar *icon_bar,
GdkPixbuf *image,
const gchar *text,
gint position);
/* Reorders an item. Note that position refers to the new position to add the
item after removing it from its current position. If position is -1 it is
moved to the end of the bar. */
void e_icon_bar_reorder_item (EIconBar *icon_bar,
gint item_num,
gint new_position);
void e_icon_bar_remove_item (EIconBar *icon_bar,
gint item_num);
GdkPixbuf * e_icon_bar_get_item_image (EIconBar *icon_bar,
gint item_num);
void e_icon_bar_set_item_image (EIconBar *icon_bar,
gint item_num,
GdkPixbuf *image);
gchar* e_icon_bar_get_item_text (EIconBar *icon_bar,
gint item_num);
void e_icon_bar_set_item_text (EIconBar *icon_bar,
gint item_num,
gchar *text);
gpointer e_icon_bar_get_item_data (EIconBar *icon_bar,
gint item_num);
void e_icon_bar_set_item_data (EIconBar *icon_bar,
gint item_num,
gpointer data);
void e_icon_bar_set_item_data_full (EIconBar *icon_bar,
gint item_num,
gpointer data,
GtkDestroyNotify destroy);
void e_icon_bar_start_editing_item (EIconBar *icon_bar,
gint item_num);
void e_icon_bar_stop_editing_item (EIconBar *icon_bar,
gboolean accept);
/*
* INTERNAL FUNCTIONS - for use by EIconBarBgItem.
*/
/* This returns the index of the item at the given position on the EIconBar,
or -1 if no item is found. If before_item is not NULL, it returns the
item which the mouse is before, or -1 (this is used for dragging). */
gint e_icon_bar_find_item_at_position (EIconBar *icon_bar,
gint x,
gint y,
gint *before_item);
void e_icon_bar_item_pressed (EIconBar *icon_bar,
gint item_num,
GdkEvent *event);
void e_icon_bar_item_released (EIconBar *icon_bar,
gint item_num,
GdkEvent *event);
void e_icon_bar_item_motion (EIconBar *icon_bar,
gint item_num,
GdkEvent *event);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _E_ICON_BAR_H_ */
|