1 /* 2 * 3 * This program is free software; you can redistribute it and/or modify it 4 * under the terms of the GNU Lesser General Public License as published by 5 * the Free Software Foundation. 6 * 7 * This program is distributed in the hope that it will be useful, but 8 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 9 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10 * for more details. 11 * 12 * You should have received a copy of the GNU Lesser General Public License 13 * along with this program; if not, see <http://www.gnu.org/licenses/>. 14 * 15 * 16 * Authors: 17 * Chris Lahey <clahey@ximian.com> 18 * Miguel de Icaza <miguel@gnu.org> 19 * 20 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) 21 * 22 */ 23 24 #if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION) 25 #error "Only <e-util/e-util.h> should be included directly." 26 #endif 27 28 #ifndef _E_TABLE_ITEM_H_ 29 #define _E_TABLE_ITEM_H_ 30 31 #include <libgnomecanvas/libgnomecanvas.h> 32 33 #include <e-util/e-printable.h> 34 #include <e-util/e-selection-model.h> 35 #include <e-util/e-table-defines.h> 36 #include <e-util/e-table-header.h> 37 #include <e-util/e-table-model.h> 38 39 /* Standard GObject macros */ 40 #define E_TYPE_TABLE_ITEM \ 41 (e_table_item_get_type ()) 42 #define E_TABLE_ITEM(obj) \ 43 (G_TYPE_CHECK_INSTANCE_CAST \ 44 ((obj), E_TYPE_TABLE_ITEM, ETableItem)) 45 #define E_TABLE_ITEM_CLASS(cls) \ 46 (G_TYPE_CHECK_CLASS_CAST \ 47 ((cls), E_TYPE_TABLE_ITEM, ETableItemClass)) 48 #define E_IS_TABLE_ITEM(obj) \ 49 (G_TYPE_CHECK_INSTANCE_TYPE \ 50 ((obj), E_TYPE_TABLE_ITEM)) 51 #define E_IS_TABLE_ITEM_CLASS(cls) \ 52 (G_TYPE_CHECK_CLASS_TYPE \ 53 ((cls), E_TYPE_TABLE_ITEM)) 54 #define E_TABLE_ITEM_GET_CLASS(obj) \ 55 (G_TYPE_INSTANCE_GET_CLASS \ 56 ((obj), E_TYPE_TABLE_ITEM, ETableItemClass)) 57 58 G_BEGIN_DECLS 59 60 typedef struct _ETableItem ETableItem; 61 typedef struct _ETableItemClass ETableItemClass; 62 63 struct _ETableItem { 64 GnomeCanvasItem parent; 65 ETableModel *table_model; 66 ETableHeader *header; 67 68 ETableModel *source_model; 69 ESelectionModel *selection; 70 71 gint minimum_width, width, height; 72 73 gint cols, rows; 74 75 gint click_count; 76 77 /* 78 * Ids for the signals we connect to 79 */ 80 gint header_dim_change_id; 81 gint header_structure_change_id; 82 gint header_request_width_id; 83 gint table_model_pre_change_id; 84 gint table_model_no_change_id; 85 gint table_model_change_id; 86 gint table_model_row_change_id; 87 gint table_model_cell_change_id; 88 gint table_model_rows_inserted_id; 89 gint table_model_rows_deleted_id; 90 91 gint selection_change_id; 92 gint selection_row_change_id; 93 gint cursor_change_id; 94 gint cursor_activated_id; 95 96 guint cursor_idle_id; 97 98 /* View row, -1 means unknown */ 99 gint old_cursor_row; 100 101 guint alternating_row_colors : 1; 102 guint horizontal_draw_grid : 1; 103 guint vertical_draw_grid : 1; 104 guint draw_focus : 1; 105 guint uniform_row_height : 1; 106 guint cell_views_realized : 1; 107 108 guint needs_redraw : 1; 109 guint needs_compute_height : 1; 110 guint needs_compute_width : 1; 111 112 guint uses_source_model : 1; 113 114 guint in_key_press : 1; 115 116 guint maybe_in_drag : 1; 117 guint in_drag : 1; 118 guint unused__grabbed : 1; /* this one is not used in the code */ 119 120 guint maybe_did_something : 1; 121 122 guint cursor_on_screen : 1; 123 guint gtk_grabbed : 1; 124 125 guint queue_show_cursor : 1; 126 guint grab_cancelled : 1; 127 128 gint frozen_count; 129 130 gint cursor_x1; 131 gint cursor_y1; 132 gint cursor_x2; 133 gint cursor_y2; 134 135 gint drag_col; 136 gint drag_row; 137 gint drag_x; 138 gint drag_y; 139 guint drag_state; 140 141 /* 142 * Realized views, per column 143 */ 144 ECellView **cell_views; 145 gint n_cells; 146 147 gint *height_cache; 148 gint uniform_row_height_cache; 149 gint height_cache_idle_id; 150 gint height_cache_idle_count; 151 152 /* 153 * Lengh Threshold: above this, we stop computing correctly 154 * the size 155 */ 156 gint length_threshold; 157 158 gint row_guess; 159 ECursorMode cursor_mode; 160 161 gint motion_col, motion_row; 162 163 /* 164 * During editing 165 */ 166 gint editing_col, editing_row; 167 gpointer edit_ctx; 168 169 gint save_col, save_row; 170 gpointer save_state; 171 172 gint grabbed_col, grabbed_row; 173 gint grabbed_count; 174 }; 175 176 struct _ETableItemClass { 177 GnomeCanvasItemClass parent_class; 178 179 void (*cursor_change) (ETableItem *eti, 180 gint row); 181 void (*cursor_activated) (ETableItem *eti, 182 gint row); 183 void (*double_click) (ETableItem *eti, 184 gint row, 185 gint col, 186 GdkEvent *event); 187 gboolean (*right_click) (ETableItem *eti, 188 gint row, 189 gint col, 190 GdkEvent *event); 191 gboolean (*click) (ETableItem *eti, 192 gint row, 193 gint col, 194 GdkEvent *event); 195 gboolean (*key_press) (ETableItem *eti, 196 gint row, 197 gint col, 198 GdkEvent *event); 199 gboolean (*start_drag) (ETableItem *eti, 200 gint row, 201 gint col, 202 GdkEvent *event); 203 void (*style_updated) (ETableItem *eti); 204 void (*selection_model_removed) 205 (ETableItem *eti, 206 ESelectionModel *selection); 207 void (*selection_model_added) 208 (ETableItem *eti, 209 ESelectionModel *selection); 210 void (*get_bg_color) (ETableItem *eti, 211 gint row, 212 gint col, 213 GdkRGBA *inout_background); 214 }; 215 216 GType e_table_item_get_type (void) G_GNUC_CONST; 217 218 /* 219 * Focus 220 */ 221 void e_table_item_set_cursor (ETableItem *eti, 222 gint col, 223 gint row); 224 225 gint e_table_item_get_focused_column (ETableItem *eti); 226 227 void e_table_item_leave_edit (ETableItem *eti); 228 void e_table_item_enter_edit (ETableItem *eti, 229 gint col, 230 gint row); 231 232 void e_table_item_redraw_range (ETableItem *eti, 233 gint start_col, 234 gint start_row, 235 gint end_col, 236 gint end_row); 237 238 EPrintable * e_table_item_get_printable (ETableItem *eti); 239 void e_table_item_compute_location (ETableItem *eti, 240 gint *x, 241 gint *y, 242 gint *row, 243 gint *col); 244 void e_table_item_compute_mouse_over (ETableItem *eti, 245 gint x, 246 gint y, 247 gint *row, 248 gint *col); 249 void e_table_item_get_cell_geometry (ETableItem *eti, 250 gint *row, 251 gint *col, 252 gint *x, 253 gint *y, 254 gint *width, 255 gint *height); 256 257 gint e_table_item_row_diff (ETableItem *eti, 258 gint start_row, 259 gint end_row); 260 261 gboolean e_table_item_is_editing (ETableItem *eti); 262 263 void e_table_item_cursor_scrolled (ETableItem *eti); 264 265 void e_table_item_cancel_scroll_to_cursor 266 (ETableItem *eti); 267 gboolean e_table_item_get_row_selected (ETableItem *eti, 268 gint row); 269 void e_table_item_freeze (ETableItem *eti); 270 void e_table_item_thaw (ETableItem *eti); 271 272 G_END_DECLS 273 274 #endif /* _E_TABLE_ITEM_H_ */ 275