1 /* 2 * This program is free software; you can redistribute it and/or modify it 3 * under the terms of the GNU Lesser General Public License as published by 4 * the Free Software Foundation. 5 * 6 * This program is distributed in the hope that it will be useful, but 7 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 8 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9 * for more details. 10 * 11 * You should have received a copy of the GNU Lesser General Public License 12 * along with this program; if not, see <http://www.gnu.org/licenses/>. 13 * 14 * 15 * Authors: 16 * Miguel de Icaza <miguel@ximian.com> 17 * Chris Lahey <clahey@ximian.com> 18 * 19 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) 20 * 21 */ 22 23 #if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION) 24 #error "Only <e-util/e-util.h> should be included directly." 25 #endif 26 27 #ifndef _E_CELL_H_ 28 #define _E_CELL_H_ 29 30 #include <gtk/gtk.h> 31 32 #include <e-util/e-table-model.h> 33 34 /* Standard GObject macros */ 35 #define E_TYPE_CELL \ 36 (e_cell_get_type ()) 37 #define E_CELL(obj) \ 38 (G_TYPE_CHECK_INSTANCE_CAST \ 39 ((obj), E_TYPE_CELL, ECell)) 40 #define E_CELL_CLASS(cls) \ 41 (G_TYPE_CHECK_CLASS_CAST \ 42 ((cls), E_TYPE_CELL, ECellClass)) 43 #define E_CELL_GET_CLASS(obj) \ 44 (G_TYPE_INSTANCE_GET_CLASS \ 45 ((obj), E_TYPE_CELL, ECellClass)) 46 #define E_IS_CELL(obj) \ 47 (G_TYPE_CHECK_INSTANCE_TYPE \ 48 ((obj), E_TYPE_CELL)) 49 #define E_IS_CELL_CLASS(cls) \ 50 (G_TYPE_CHECK_CLASS_TYPE \ 51 ((cls), E_TYPE_CELL)) 52 #define E_CELL_GET_CLASS(obj) \ 53 (G_TYPE_INSTANCE_GET_CLASS \ 54 ((obj), E_TYPE_CELL, ECellClass)) 55 56 G_BEGIN_DECLS 57 58 typedef struct _ECell ECell; 59 typedef struct _ECellClass ECellClass; 60 typedef struct _ECellView ECellView; 61 62 typedef gboolean (*ETableSearchFunc) (gconstpointer haystack, 63 const gchar *needle); 64 65 typedef enum { 66 E_CELL_SELECTED = 1 << 0, 67 68 E_CELL_JUSTIFICATION = 3 << 1, 69 E_CELL_JUSTIFY_CENTER = 0 << 1, 70 E_CELL_JUSTIFY_LEFT = 1 << 1, 71 E_CELL_JUSTIFY_RIGHT = 2 << 1, 72 E_CELL_JUSTIFY_FILL = 3 << 1, 73 74 E_CELL_ALIGN_LEFT = 1 << 1, 75 E_CELL_ALIGN_RIGHT = 1 << 2, 76 77 E_CELL_FOCUSED = 1 << 3, 78 79 E_CELL_EDITING = 1 << 4, 80 81 E_CELL_CURSOR = 1 << 5, 82 83 E_CELL_PREEDIT = 1 << 6 84 } ECellFlags; 85 86 typedef enum { 87 E_CELL_GRAB = 1 << 0, 88 E_CELL_UNGRAB = 1 << 1 89 } ECellActions; 90 91 struct _ECellView { 92 ECell *ecell; 93 ETableModel *e_table_model; 94 void *e_table_item_view; 95 96 gint focus_x1, focus_y1, focus_x2, focus_y2; 97 gint focus_col, focus_row; 98 99 void (*kill_view_cb) (struct _ECellView *, gpointer); 100 GList *kill_view_cb_data; 101 }; 102 103 struct _ECell { 104 GObject parent; 105 }; 106 107 struct _ECellClass { 108 GObjectClass parent_class; 109 110 ECellView * (*new_view) (ECell *ecell, 111 ETableModel *table_model, 112 gpointer e_table_item_view); 113 void (*kill_view) (ECellView *ecell_view); 114 115 void (*realize) (ECellView *ecell_view); 116 void (*unrealize) (ECellView *ecell_view); 117 118 void (*draw) (ECellView *ecell_view, 119 cairo_t *cr, 120 gint model_col, 121 gint view_col, gint row, 122 ECellFlags flags, 123 gint x1, 124 gint y1, 125 gint x2, 126 gint y2); 127 gint (*event) (ECellView *ecell_view, 128 GdkEvent *event, 129 gint model_col, 130 gint view_col, 131 gint row, 132 ECellFlags flags, 133 ECellActions *actions); 134 void (*focus) (ECellView *ecell_view, 135 gint model_col, 136 gint view_col, 137 gint row, 138 gint x1, 139 gint y1, 140 gint x2, 141 gint y2); 142 void (*unfocus) (ECellView *ecell_view); 143 gint (*height) (ECellView *ecell_view, 144 gint model_col, 145 gint view_col, 146 gint row); 147 148 gpointer (*enter_edit) (ECellView *ecell_view, 149 gint model_col, 150 gint view_col, 151 gint row); 152 void (*leave_edit) (ECellView *ecell_view, 153 gint model_col, 154 gint view_col, 155 gint row, 156 gpointer context); 157 gpointer (*save_state) (ECellView *ecell_view, 158 gint model_col, 159 gint view_col, 160 gint row, 161 gpointer context); 162 void (*load_state) (ECellView *ecell_view, 163 gint model_col, 164 gint view_col, 165 gint row, 166 gpointer context, 167 gpointer save_state); 168 void (*free_state) (ECellView *ecell_view, 169 gint model_col, 170 gint view_col, 171 gint row, 172 gpointer save_state); 173 void (*print) (ECellView *ecell_view, 174 GtkPrintContext *context, 175 gint model_col, 176 gint view_col, 177 gint row, 178 gdouble width, 179 gdouble height); 180 gdouble (*print_height) (ECellView *ecell_view, 181 GtkPrintContext *context, 182 gint model_col, 183 gint view_col, 184 gint row, 185 gdouble width); 186 gint (*max_width) (ECellView *ecell_view, 187 gint model_col, 188 gint view_col); 189 gint (*max_width_by_row) (ECellView *ecell_view, 190 gint model_col, 191 gint view_col, 192 gint row); 193 gchar * (*get_bg_color) (ECellView *ecell_view, 194 gint row); 195 196 void (*style_updated) (ECellView *ecell_view); 197 }; 198 199 GType e_cell_get_type (void) G_GNUC_CONST; 200 201 /* View creation methods. */ 202 ECellView * e_cell_new_view (ECell *ecell, 203 ETableModel *table_model, 204 gpointer e_table_item_view); 205 void e_cell_kill_view (ECellView *ecell_view); 206 207 /* Cell View methods. */ 208 gint e_cell_event (ECellView *ecell_view, 209 GdkEvent *event, 210 gint model_col, 211 gint view_col, 212 gint row, 213 ECellFlags flags, 214 ECellActions *actions); 215 void e_cell_realize (ECellView *ecell_view); 216 void e_cell_unrealize (ECellView *ecell_view); 217 void e_cell_draw (ECellView *ecell_view, 218 cairo_t *cr, 219 gint model_col, 220 gint view_col, 221 gint row, 222 ECellFlags flags, 223 gint x1, 224 gint y1, 225 gint x2, 226 gint y2); 227 void e_cell_print (ECellView *ecell_view, 228 GtkPrintContext *context, 229 gint model_col, 230 gint view_col, 231 gint row, 232 gdouble width, 233 gdouble height); 234 gdouble e_cell_print_height (ECellView *ecell_view, 235 GtkPrintContext *context, 236 gint model_col, 237 gint view_col, 238 gint row, 239 gdouble width); 240 gint e_cell_max_width (ECellView *ecell_view, 241 gint model_col, 242 gint view_col); 243 gint e_cell_max_width_by_row (ECellView *ecell_view, 244 gint model_col, 245 gint view_col, 246 gint row); 247 gboolean e_cell_max_width_by_row_implemented 248 (ECellView *ecell_view); 249 gchar * e_cell_get_bg_color (ECellView *ecell_view, 250 gint row); 251 void e_cell_style_updated (ECellView *ecell_view); 252 253 void e_cell_focus (ECellView *ecell_view, 254 gint model_col, 255 gint view_col, 256 gint row, 257 gint x1, 258 gint y1, 259 gint x2, 260 gint y2); 261 void e_cell_unfocus (ECellView *ecell_view); 262 gint e_cell_height (ECellView *ecell_view, 263 gint model_col, 264 gint view_col, 265 gint row); 266 gpointer e_cell_enter_edit (ECellView *ecell_view, 267 gint model_col, 268 gint view_col, 269 gint row); 270 void e_cell_leave_edit (ECellView *ecell_view, 271 gint model_col, 272 gint view_col, 273 gint row, 274 gpointer edit_context); 275 gpointer e_cell_save_state (ECellView *ecell_view, 276 gint model_col, 277 gint view_col, 278 gint row, 279 gpointer edit_context); 280 void e_cell_load_state (ECellView *ecell_view, 281 gint model_col, 282 gint view_col, 283 gint row, 284 gpointer edit_context, 285 gpointer save_state); 286 void e_cell_free_state (ECellView *ecell_view, 287 gint model_col, 288 gint view_col, 289 gint row, 290 gpointer save_state); 291 292 G_END_DECLS 293 294 #endif /* _E_CELL_H_ */ 295