aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-cell.h
blob: 7a764c021e4bc24fefc44a464b7b0db415ecce9f (plain) (blame)
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
/*
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation.
 *
 * 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 Lesser General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 *
 *
 * Authors:
 *      Miguel de Icaza <miguel@ximian.com>
 *      Chris Lahey <clahey@ximian.com>
 *
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 *
 */

#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
#error "Only <e-util/e-util.h> should be included directly."
#endif

#ifndef _E_CELL_H_
#define _E_CELL_H_

#include <gtk/gtk.h>

#include <e-util/e-table-model.h>

/* Standard GObject macros */
#define E_TYPE_CELL \
    (e_cell_get_type ())
#define E_CELL(obj) \
    (G_TYPE_CHECK_INSTANCE_CAST \
    ((obj), E_TYPE_CELL, ECell))
#define E_CELL_CLASS(cls) \
    (G_TYPE_CHECK_CLASS_CAST \
    ((cls), E_TYPE_CELL, ECellClass))
#define E_CELL_GET_CLASS(obj) \
    (G_TYPE_INSTANCE_GET_CLASS \
    ((obj), E_TYPE_CELL, ECellClass))
#define E_IS_CELL(obj) \
    (G_TYPE_CHECK_INSTANCE_TYPE \
    ((obj), E_TYPE_CELL))
#define E_IS_CELL_CLASS(cls) \
    (G_TYPE_CHECK_CLASS_TYPE \
    ((cls), E_TYPE_CELL))
#define E_CELL_GET_CLASS(obj) \
    (G_TYPE_INSTANCE_GET_CLASS \
    ((obj), E_TYPE_CELL, ECellClass))

G_BEGIN_DECLS

typedef struct _ECell ECell;
typedef struct _ECellClass ECellClass;
typedef struct _ECellView ECellView;

typedef gboolean (*ETableSearchFunc) (gconstpointer haystack,
                      const gchar *needle);

typedef enum {
    E_CELL_SELECTED = 1 << 0,

    E_CELL_JUSTIFICATION = 3 << 1,
    E_CELL_JUSTIFY_CENTER = 0 << 1,
    E_CELL_JUSTIFY_LEFT = 1 << 1,
    E_CELL_JUSTIFY_RIGHT = 2 << 1,
    E_CELL_JUSTIFY_FILL = 3 << 1,

    E_CELL_ALIGN_LEFT = 1 << 1,
    E_CELL_ALIGN_RIGHT = 1 << 2,

    E_CELL_FOCUSED = 1 << 3,

    E_CELL_EDITING = 1 << 4,

    E_CELL_CURSOR = 1 << 5,

    E_CELL_PREEDIT = 1 << 6
} ECellFlags;

typedef enum {
    E_CELL_GRAB = 1 << 0,
    E_CELL_UNGRAB = 1 << 1
} ECellActions;

struct _ECellView {
    ECell *ecell;
    ETableModel *e_table_model;
    void        *e_table_item_view;

    gint   focus_x1, focus_y1, focus_x2, focus_y2;
    gint   focus_col, focus_row;

    void  (*kill_view_cb) (struct _ECellView *, gpointer);
    GList *kill_view_cb_data;
};

struct _ECell {
    GObject parent;
};

struct _ECellClass {
    GObjectClass parent_class;

    ECellView * (*new_view)     (ECell *ecell,
                         ETableModel *table_model,
                         gpointer e_table_item_view);
    void        (*kill_view)        (ECellView *ecell_view);

    void        (*realize)      (ECellView *ecell_view);
    void        (*unrealize)        (ECellView *ecell_view);

    void        (*draw)         (ECellView *ecell_view,
                         cairo_t *cr,
                         gint model_col,
                         gint view_col, gint row,
                         ECellFlags flags,
                         gint x1,
                         gint y1,
                         gint x2,
                         gint y2);
    gint        (*event)        (ECellView *ecell_view,
                         GdkEvent *event,
                         gint model_col,
                         gint view_col,
                         gint row,
                         ECellFlags flags,
                         ECellActions *actions);
    void        (*focus)        (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row,
                         gint x1,
                         gint y1,
                         gint x2,
                         gint y2);
    void        (*unfocus)      (ECellView *ecell_view);
    gint        (*height)       (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row);

    gpointer    (*enter_edit)       (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row);
    void        (*leave_edit)       (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row,
                         gpointer context);
    gpointer    (*save_state)       (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row,
                         gpointer context);
    void        (*load_state)       (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row,
                         gpointer context,
                         gpointer save_state);
    void        (*free_state)       (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row,
                         gpointer save_state);
    void        (*print)        (ECellView *ecell_view,
                         GtkPrintContext *context,
                         gint model_col,
                         gint view_col,
                         gint row,
                         gdouble width,
                         gdouble height);
    gdouble     (*print_height)     (ECellView *ecell_view,
                         GtkPrintContext *context,
                         gint model_col,
                         gint view_col,
                         gint row,
                         gdouble width);
    gint        (*max_width)        (ECellView *ecell_view,
                         gint model_col,
                         gint view_col);
    gint        (*max_width_by_row) (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row);
    gchar *     (*get_bg_color)     (ECellView *ecell_view,
                         gint row);

    void        (*style_updated)    (ECellView *ecell_view);
};

GType       e_cell_get_type         (void) G_GNUC_CONST;

/* View creation methods. */
ECellView * e_cell_new_view         (ECell *ecell,
                         ETableModel *table_model,
                         gpointer e_table_item_view);
void        e_cell_kill_view        (ECellView *ecell_view);

/* Cell View methods. */
gint        e_cell_event            (ECellView *ecell_view,
                         GdkEvent *event,
                         gint model_col,
                         gint view_col,
                         gint row,
                         ECellFlags flags,
                         ECellActions *actions);
void        e_cell_realize          (ECellView *ecell_view);
void        e_cell_unrealize        (ECellView *ecell_view);
void        e_cell_draw         (ECellView *ecell_view,
                         cairo_t *cr,
                         gint model_col,
                         gint view_col,
                         gint row,
                         ECellFlags flags,
                         gint x1,
                         gint y1,
                         gint x2,
                         gint y2);
void        e_cell_print            (ECellView *ecell_view,
                         GtkPrintContext *context,
                         gint model_col,
                         gint view_col,
                         gint row,
                         gdouble width,
                         gdouble height);
gdouble     e_cell_print_height     (ECellView *ecell_view,
                         GtkPrintContext *context,
                         gint model_col,
                         gint view_col,
                         gint row,
                         gdouble width);
gint        e_cell_max_width        (ECellView *ecell_view,
                         gint model_col,
                         gint view_col);
gint        e_cell_max_width_by_row     (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row);
gboolean    e_cell_max_width_by_row_implemented
                        (ECellView *ecell_view);
gchar *     e_cell_get_bg_color     (ECellView *ecell_view,
                         gint row);
void        e_cell_style_updated        (ECellView *ecell_view);

void        e_cell_focus            (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row,
                         gint x1,
                         gint y1,
                         gint x2,
                         gint y2);
void        e_cell_unfocus          (ECellView *ecell_view);
gint        e_cell_height           (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row);
gpointer    e_cell_enter_edit       (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row);
void        e_cell_leave_edit       (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row,
                         gpointer edit_context);
gpointer    e_cell_save_state       (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row,
                         gpointer edit_context);
void        e_cell_load_state       (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row,
                         gpointer edit_context,
                         gpointer save_state);
void        e_cell_free_state       (ECellView *ecell_view,
                         gint model_col,
                         gint view_col,
                         gint row,
                         gpointer save_state);

G_END_DECLS

#endif /* _E_CELL_H_ */