summaryrefslogtreecommitdiffstats
path: root/plug-ins/imagemap/imap_object.h
blob: 0aaf07853327fcb5a4031564633d3e8c1e082ee1 (plain)
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
247
248
249
250
251
252
253
/*
 * This is a plug-in for GIMP.
 *
 * Generates clickable image maps.
 *
 * Copyright (C) 1998-2005 Maurits Rijk  m.rijk@chello.nl
 *
 * 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 3 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, see <https://www.gnu.org/licenses/>.
 *
 */

#ifndef _IMAP_OBJECT_H
#define _IMAP_OBJECT_H

typedef struct Object_t Object_t;
typedef struct ObjectClass_t ObjectClass_t;
typedef struct ObjectList_t ObjectList_t;

#include "imap_edit_area_info.h"
#include "imap_menu_funcs.h"

struct Object_t {
   ObjectClass_t        *class;
   ObjectList_t         *list;
   gint                  refcount;
   gboolean              selected;
   gboolean              locked;
   gchar                *url;
   gchar                *target;
   gchar                *comment;
   gchar                *mouse_over;
   gchar                *mouse_out;
   gchar                *focus;
   gchar                *blur;
};

typedef void (*MoveSashFunc_t)(Object_t*, gint, gint);
typedef void (*OutputFunc_t)(gpointer, const char*, ...) G_GNUC_PRINTF(2,3);

struct AreaInfoDialog_t;

struct ObjectClass_t {
   const gchar          *name;
   AreaInfoDialog_t     *info_dialog;

   gboolean (*is_valid)(Object_t *obj);
   void (*destruct)(Object_t *obj);
   Object_t* (*clone)(Object_t *obj);
   void (*assign)(Object_t *obj, Object_t *des);
   void (*normalize)(Object_t *obj);
   void (*draw)(Object_t *obj, cairo_t *cr);
   void (*draw_sashes)(Object_t *obj, cairo_t *cr);
   MoveSashFunc_t (*near_sash)(Object_t *obj, gint x, gint y);
   gboolean (*point_is_on)(Object_t *obj, gint x, gint y);
   void (*get_dimensions)(Object_t *obj, gint *x, gint *y, gint *width,
                          gint *height);
   void (*resize)(Object_t *obj, gint percentage_x, gint percentage_y);
   void (*move)(Object_t *obj, gint dx, gint dy);
   gpointer (*create_info_widget)(GtkWidget *frame);
   void (*update_info_widget)(Object_t *obj, gpointer data);
   void (*fill_info_tab)(Object_t *obj, gpointer data);
   void (*set_initial_focus)(Object_t *obj, gpointer data);
   void (*update)(Object_t *obj, gpointer data);
   void (*write_csim)(Object_t *obj, gpointer param, OutputFunc_t output);
   void (*write_cern)(Object_t *obj, gpointer param, OutputFunc_t output);
   void (*write_ncsa)(Object_t *obj, gpointer param, OutputFunc_t output);
   void (*do_popup)(Object_t *obj, GdkEventButton *event);

   const gchar* (*get_stock_icon_name)(void);
};

Object_t *object_ref(Object_t *obj);
void object_unref(Object_t *obj);
Object_t* object_init(Object_t *obj, ObjectClass_t *class);
Object_t* object_clone(Object_t *obj);
Object_t* object_assign(Object_t *src, Object_t *des);
void object_draw(Object_t *obj, cairo_t *cr);
void object_edit(Object_t *obj, gboolean add);
void object_select(Object_t *obj);
void object_unselect(Object_t *obj);
void object_move(Object_t *obj, gint dx, gint dy);
void object_move_sash(Object_t *obj, gint dx, gint dy);
void object_remove(Object_t *obj);
void object_lock(Object_t *obj);
void object_unlock(Object_t *obj);
void object_set_url(Object_t *obj, const gchar *url);
void object_set_target(Object_t *obj, const gchar *target);
void object_set_comment(Object_t *obj, const gchar *comment);
void object_set_mouse_over(Object_t *obj, const gchar *mouse_over);
void object_set_mouse_out(Object_t *obj, const gchar *mouse_out);
void object_set_focus(Object_t *obj, const gchar *focus);
void object_set_blur(Object_t *obj, const gchar *blur);
gint object_get_position_in_list(Object_t *obj);

void object_emit_changed_signal(Object_t *obj);
void object_emit_geometry_signal(Object_t *obj);
void object_emit_update_signal(Object_t *obj);

#define object_is_valid(obj) \
        ((obj)->class->is_valid(obj))

#define object_get_dimensions(obj, x, y, width, height) \
        ((obj)->class->get_dimensions((obj), (x), (y), (width), (height)))

#define object_normalize(obj) \
        ((obj)->class->normalize(obj))

#define object_resize(obj, per_x, per_y) \
        ((obj)->class->resize((obj), (per_x), (per_y)))

#define object_update(obj, data) \
        ((obj)->class->update((obj), (data)))

#define object_update_info_widget(obj, data) \
        ((obj)->class->update_info_widget((obj), (data)))

#define object_fill_info_tab(obj, data) \
        ((obj)->class->fill_info_tab((obj), (data)))

#define object_get_stock_icon_name(obj) \
        ((obj)->class->get_stock_icon_name())

typedef struct {
   Object_t *obj;
   gboolean (*finish)(Object_t *obj, gint x, gint y);
   gboolean (*cancel)(GdkEventButton *event, Object_t *obj);
   Object_t* (*create_object)(gint x, gint y);
   void (*set_xy)(Object_t *obj, guint state, gint x, gint y);
} ObjectFactory_t;

gboolean object_on_button_press(GtkWidget *widget, GdkEventButton *event,
                                gpointer data);

typedef struct {
   GList *list;
} ObjectListCallback_t;

struct ObjectList_t {
   GList *list;
   gboolean changed;
   ObjectListCallback_t changed_cb;
   ObjectListCallback_t update_cb;
   ObjectListCallback_t add_cb;
   ObjectListCallback_t remove_cb;
   ObjectListCallback_t select_cb;
   ObjectListCallback_t move_cb;
   ObjectListCallback_t geometry_cb;
};

ObjectList_t *make_object_list (void);
void object_list_destruct(ObjectList_t *list);
ObjectList_t *object_list_copy(ObjectList_t *des, ObjectList_t *src);
ObjectList_t *object_list_append_list(ObjectList_t *des, ObjectList_t *src);

void object_list_append(ObjectList_t *list, Object_t *object);
void object_list_prepend(ObjectList_t *list, Object_t *object);
void object_list_insert(ObjectList_t *list, gint position, Object_t *object);
void object_list_remove(ObjectList_t *list, Object_t *object);
void object_list_remove_link(ObjectList_t *list, GList *link);
void object_list_update(ObjectList_t *list, Object_t *object);
void object_list_draw(ObjectList_t *list, cairo_t *cr);
void object_list_draw_selected(ObjectList_t *list, cairo_t *cr);
Object_t *object_list_find(ObjectList_t *list, gint x, gint y);
Object_t *object_list_near_sash(ObjectList_t *list, gint x, gint y,
                                MoveSashFunc_t *sash_func);

gint object_list_cut(ObjectList_t *list);
void object_list_copy_to_paste_buffer(ObjectList_t *list);
void object_list_paste(ObjectList_t *list);

void object_list_remove_all(ObjectList_t *list);
void object_list_delete_selected(ObjectList_t *list);
void object_list_edit_selected(ObjectList_t *list);
gint object_list_select_all(ObjectList_t *list);
void object_list_select_next(ObjectList_t *list);
void object_list_select_prev(ObjectList_t *list);
gint object_list_select_region(ObjectList_t *list, gint x, gint y, gint width,
                               gint height);
gint object_list_deselect_all(ObjectList_t *list, Object_t *exception);
gint object_list_nr_selected(ObjectList_t *list);
void object_list_resize(ObjectList_t *list, gint percentage_x,
                        gint percentage_y);
void object_list_move_selected(ObjectList_t *list, gint dx, gint dy);
void object_list_move_up(ObjectList_t *list, Object_t *obj);
void object_list_move_down(ObjectList_t *list, Object_t *obj);
void object_list_move_selected_up(ObjectList_t *list);
void object_list_move_selected_down(ObjectList_t *list);
void object_list_move_to_front(ObjectList_t *list);
void object_list_send_to_back(ObjectList_t *list);
void object_list_move_sash_selected(ObjectList_t *list, gint dx, gint dy);

void object_list_write_csim(ObjectList_t *list, gpointer param,
                            OutputFunc_t output);
void object_list_write_cern(ObjectList_t *list, gpointer param,
                            OutputFunc_t output);
void object_list_write_ncsa(ObjectList_t *list, gpointer param,
                            OutputFunc_t output);

typedef void (*ObjectListCallbackFunc_t)(Object_t*, gpointer);

gpointer object_list_add_changed_cb(ObjectList_t *list,
                                    ObjectListCallbackFunc_t func,
                                    gpointer data);
gpointer object_list_add_update_cb(ObjectList_t *list,
                                   ObjectListCallbackFunc_t func,
                                   gpointer data);
gpointer object_list_add_add_cb(ObjectList_t *list,
                                ObjectListCallbackFunc_t func, gpointer data);
gpointer object_list_add_remove_cb(ObjectList_t *list,
                                   ObjectListCallbackFunc_t func,
                                   gpointer data);
gpointer object_list_add_select_cb(ObjectList_t *list,
                                   ObjectListCallbackFunc_t func,
                                   gpointer data);
gpointer object_list_add_move_cb(ObjectList_t *list,
                                 ObjectListCallbackFunc_t func, gpointer data);
gpointer object_list_add_geometry_cb(ObjectList_t *list,
                                     ObjectListCallbackFunc_t func,
                                     gpointer data);

void object_list_remove_add_cb(ObjectList_t *list, gpointer id);
void object_list_remove_select_cb(ObjectList_t *list, gpointer id);
void object_list_remove_remove_cb(ObjectList_t *list, gpointer id);
void object_list_remove_move_cb(ObjectList_t *list, gpointer id);
void object_list_remove_geometry_cb(ObjectList_t *list, gpointer id);

#define object_list_clear_changed(list) ((list)->changed = FALSE)
#define object_list_set_changed(list, ischanged) \
        ((list)->changed = (ischanged))
#define object_list_get_changed(list) ((list)->changed)

void clear_paste_buffer(void);
gpointer paste_buffer_add_add_cb(ObjectListCallbackFunc_t func, gpointer data);
gpointer paste_buffer_add_remove_cb(ObjectListCallbackFunc_t func,
                                    gpointer data);
ObjectList_t *get_paste_buffer(void);

void do_object_locked_dialog(void);

#endif /* _IMAP_OBJECT_H */