GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
table-model.h
1 /********************************************************************\
2  * table-model.h -- 2D grid table object model *
3  * Copyright (c) 2001 Free Software Foundation *
4  * Author: Dave Peticolas <[email protected]> *
5  * *
6  * This program is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU General Public License as *
8  * published by the Free Software Foundation; either version 2 of *
9  * the License, or (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License*
17  * along with this program; if not, contact: *
18  * *
19  * Free Software Foundation Voice: +1-617-542-5942 *
20  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
21  * Boston, MA 02110-1301, USA [email protected] *
22  * *
23 \********************************************************************/
24 
25 #ifndef TABLE_MODEL_H
26 #define TABLE_MODEL_H
27 
28 #include <glib.h>
29 
30 #include "basiccell.h"
31 #include "register-common.h"
32 
33 typedef enum
34 {
35  XACC_CELL_ALLOW_NONE = 0,
36  XACC_CELL_ALLOW_INPUT = 1 << 0,
37  XACC_CELL_ALLOW_SHADOW = 1 << 1,
38  XACC_CELL_ALLOW_ALL = XACC_CELL_ALLOW_INPUT | XACC_CELL_ALLOW_SHADOW,
39  XACC_CELL_ALLOW_EXACT_ONLY = 1 << 2,
40  XACC_CELL_ALLOW_ENTER = 1 << 3,
41  XACC_CELL_ALLOW_READ_ONLY = XACC_CELL_ALLOW_SHADOW | XACC_CELL_ALLOW_ENTER
42 } CellIOFlags;
43 
44 typedef enum
45 {
46  CELL_BORDER_LINE_NONE,
47  CELL_BORDER_LINE_LIGHT,
48  CELL_BORDER_LINE_NORMAL,
49  CELL_BORDER_LINE_HEAVY,
50  CELL_BORDER_LINE_HIGHLIGHT
51 } PhysicalCellBorderLineStyle;
52 
53 typedef struct
54 {
55  PhysicalCellBorderLineStyle top;
56  PhysicalCellBorderLineStyle bottom;
57  PhysicalCellBorderLineStyle left;
58  PhysicalCellBorderLineStyle right;
60 
61 typedef const char * (*TableGetEntryHandler) (VirtualLocation virt_loc,
62  gboolean translate,
63  gboolean *conditionally_changed,
64  gpointer user_data);
65 
66 typedef const char * (*TableGetLabelHandler) (VirtualLocation virt_loc,
67  gpointer user_data);
68 
69 typedef char * (*TableGetHelpHandler) (VirtualLocation virt_loc,
70  gpointer user_data);
71 
72 typedef CellIOFlags (*TableGetCellIOFlagsHandler) (VirtualLocation virt_loc,
73  gpointer user_data);
74 
75 typedef guint32 (*TableGetFGColorHandler) (VirtualLocation virt_loc,
76  gpointer user_data);
77 
78 typedef guint32 (*TableGetBGColorHandler) (VirtualLocation virt_loc,
79  gboolean *hatching,
80  gpointer user_data);
81 
82 typedef void (*TableGetCellBorderHandler) (VirtualLocation virt_loc,
83  PhysicalCellBorders *borders,
84  gpointer user_data);
85 
86 typedef gboolean (*TableConfirmHandler) (VirtualLocation virt_loc,
87  gpointer user_data);
88 
89 typedef void (*TableSaveCellHandler) (BasicCell * cell,
90  gpointer save_data,
91  gpointer user_data);
92 
93 typedef void (*TableSaveHandler) (gpointer save_data,
94  gpointer user_data);
95 
96 typedef gpointer (*VirtCellDataAllocator) (void);
97 typedef void (*VirtCellDataDeallocator) (gpointer cell_data);
98 typedef void (*VirtCellDataCopy) (gpointer to, gconstpointer from);
99 
100 typedef struct
101 {
102  GHashTable *entry_handlers;
103  GHashTable *label_handlers;
104  GHashTable *help_handlers;
105  GHashTable *io_flags_handlers;
106  GHashTable *fg_color_handlers;
107  GHashTable *bg_color_handlers;
108  GHashTable *cell_border_handlers;
109  GHashTable *confirm_handlers;
110 
111  GHashTable *save_handlers;
112  TableSaveHandler pre_save_handler;
113  TableSaveHandler post_save_handler;
114 
115  gpointer handler_user_data;
116 
117  /* If true, denotes that this table is read-only
118  * and edits should not be allowed. */
119  gboolean read_only;
120 
121  /* If positive, denotes a row that marks a boundary that should
122  * be visually distinguished. */
123  int dividing_row;
124  /* If positive, denotes a row that marks a boundary that should
125  * be visually distinguished, but different from the others. */
126  int dividing_row_upper;
127  /* If positive, denotes a row that marks a boundary that should
128  * be visually distinguished. */
129  int dividing_row_lower;
130 
131  VirtCellDataAllocator cell_data_allocator;
132  VirtCellDataDeallocator cell_data_deallocator;
133  VirtCellDataCopy cell_data_copy;
134 } TableModel;
135 
136 
137 TableModel * gnc_table_model_new (void);
138 void gnc_table_model_destroy (TableModel *model);
139 
140 void gnc_table_model_set_read_only (TableModel *model,
141  gboolean read_only);
142 gboolean gnc_table_model_read_only (TableModel *model);
143 
144 void gnc_table_model_set_entry_handler
145 (TableModel *model,
146  TableGetEntryHandler entry_handler,
147  const char * cell_name);
148 void gnc_table_model_set_default_entry_handler
149 (TableModel *model,
150  TableGetEntryHandler entry_handler);
151 TableGetEntryHandler gnc_table_model_get_entry_handler
152 (TableModel *model,
153  const char * cell_name);
154 
155 void gnc_table_model_set_label_handler
156 (TableModel *model,
157  TableGetLabelHandler label_handler,
158  const char * cell_name);
159 void gnc_table_model_set_default_label_handler
160 (TableModel *model,
161  TableGetLabelHandler label_handler);
162 TableGetLabelHandler gnc_table_model_get_label_handler
163 (TableModel *model,
164  const char * cell_name);
165 
166 void gnc_table_model_set_help_handler
167 (TableModel *model,
168  TableGetHelpHandler help_handler,
169  const char * cell_name);
170 void gnc_table_model_set_default_help_handler
171 (TableModel *model,
172  TableGetHelpHandler help_handler);
173 TableGetHelpHandler gnc_table_model_get_help_handler
174 (TableModel *model,
175  const char * cell_name);
176 
177 void gnc_table_model_set_io_flags_handler
178 (TableModel *model,
179  TableGetCellIOFlagsHandler io_flags_handler,
180  const char * cell_name);
181 void gnc_table_model_set_default_io_flags_handler
182 (TableModel *model,
183  TableGetCellIOFlagsHandler io_flags_handler);
184 TableGetCellIOFlagsHandler gnc_table_model_get_io_flags_handler
185 (TableModel *model,
186  const char * cell_name);
187 
188 void gnc_table_model_set_fg_color_handler
189 (TableModel *model,
190  TableGetFGColorHandler io_flags_handler,
191  const char * cell_name);
192 void gnc_table_model_set_default_fg_color_handler
193 (TableModel *model,
194  TableGetFGColorHandler io_flags_handler);
195 TableGetFGColorHandler gnc_table_model_get_fg_color_handler
196 (TableModel *model,
197  const char * cell_name);
198 
199 void gnc_table_model_set_bg_color_handler
200 (TableModel *model,
201  TableGetBGColorHandler io_flags_handler,
202  const char * cell_name);
203 void gnc_table_model_set_default_bg_color_handler
204 (TableModel *model,
205  TableGetBGColorHandler io_flags_handler);
206 TableGetBGColorHandler gnc_table_model_get_bg_color_handler
207 (TableModel *model,
208  const char * cell_name);
209 
210 void gnc_table_model_set_cell_border_handler
211 (TableModel *model,
212  TableGetCellBorderHandler io_flags_handler,
213  const char * cell_name);
214 void gnc_table_model_set_default_cell_border_handler
215 (TableModel *model,
216  TableGetCellBorderHandler io_flags_handler);
217 TableGetCellBorderHandler gnc_table_model_get_cell_border_handler
218 (TableModel *model,
219  const char * cell_name);
220 
221 void gnc_table_model_set_confirm_handler
222 (TableModel *model,
223  TableConfirmHandler io_flags_handler,
224  const char * cell_name);
225 void gnc_table_model_set_default_confirm_handler
226 (TableModel *model,
227  TableConfirmHandler io_flags_handler);
228 TableConfirmHandler gnc_table_model_get_confirm_handler
229 (TableModel *model,
230  const char * cell_name);
231 
232 void gnc_table_model_set_save_handler
233 (TableModel *model,
234  TableSaveCellHandler save_handler,
235  const char * cell_name);
236 void gnc_table_model_set_pre_save_handler
237 (TableModel *model,
238  TableSaveHandler save_handler);
239 void gnc_table_model_set_post_save_handler
240 (TableModel *model,
241  TableSaveHandler save_handler);
242 TableSaveCellHandler gnc_table_model_get_save_handler
243 (TableModel *model,
244  const char * cell_name);
245 TableSaveHandler gnc_table_model_get_pre_save_handler
246 (TableModel *model);
247 TableSaveHandler gnc_table_model_get_post_save_handler
248 (TableModel *model);
249 
250 #endif
Common declarations for the register core.