GnuCash  5.6-150-g038405b370+
table-model.h
Go to the documentation of this file.
1 /********************************************************************\
2  * table-model.h -- 2D grid table object model *
3  * Copyright (c) 2001 Free Software Foundation *
4  * Author: Dave Peticolas <dave@krondo.com> *
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 gnu@gnu.org *
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 
37 typedef enum
38 {
39  XACC_CELL_ALLOW_NONE = 0,
40  XACC_CELL_ALLOW_INPUT = 1 << 0,
41  XACC_CELL_ALLOW_SHADOW = 1 << 1,
42  XACC_CELL_ALLOW_ALL = XACC_CELL_ALLOW_INPUT | XACC_CELL_ALLOW_SHADOW,
43  XACC_CELL_ALLOW_EXACT_ONLY = 1 << 2,
44  XACC_CELL_ALLOW_ENTER = 1 << 3,
45  XACC_CELL_ALLOW_READ_ONLY = XACC_CELL_ALLOW_SHADOW | XACC_CELL_ALLOW_ENTER
46 } CellIOFlags;
47 
48 typedef enum
49 {
50  CELL_BORDER_LINE_NONE,
51  CELL_BORDER_LINE_LIGHT,
52  CELL_BORDER_LINE_NORMAL,
53  CELL_BORDER_LINE_HEAVY,
54  CELL_BORDER_LINE_HIGHLIGHT
55 } PhysicalCellBorderLineStyle;
56 
57 typedef struct
58 {
59  PhysicalCellBorderLineStyle top;
60  PhysicalCellBorderLineStyle bottom;
61  PhysicalCellBorderLineStyle left;
62  PhysicalCellBorderLineStyle right;
64 
65 typedef const char * (*TableGetEntryHandler) (VirtualLocation virt_loc,
66  gboolean translate,
67  gboolean *conditionally_changed,
68  gpointer user_data);
69 
70 typedef const char * (*TableGetLabelHandler) (VirtualLocation virt_loc,
71  gpointer user_data);
72 
73 typedef char * (*TableGetHelpHandler) (VirtualLocation virt_loc,
74  gpointer user_data);
75 
76 typedef char * (*TableGetTooltipHandler) (VirtualLocation virt_loc,
77  gpointer user_data);
78 
79 typedef CellIOFlags (*TableGetCellIOFlagsHandler) (VirtualLocation virt_loc,
80  gpointer user_data);
81 
82 typedef guint32 (*TableGetCellColorHandler) (VirtualLocation virt_loc,
83  gboolean *hatching,
84  gpointer user_data);
85 
86 typedef void (*TableGetCellBorderHandler) (VirtualLocation virt_loc,
87  PhysicalCellBorders *borders,
88  gpointer user_data);
89 
90 typedef gboolean (*TableConfirmHandler) (VirtualLocation virt_loc,
91  gpointer user_data);
92 
93 typedef void (*TableSaveCellHandler) (BasicCell * cell,
94  gpointer save_data,
95  gpointer user_data);
96 
97 typedef void (*TableSaveHandler) (gpointer save_data,
98  gpointer user_data);
99 
100 typedef gpointer (*VirtCellDataAllocator) (void);
101 typedef void (*VirtCellDataDeallocator) (gpointer cell_data);
102 typedef void (*VirtCellDataCopy) (gpointer to, gconstpointer from);
103 
104 typedef struct
105 {
106  GHashTable *entry_handlers;
107  GHashTable *label_handlers;
108  GHashTable *help_handlers;
109  GHashTable *tooltip_handlers;
110  GHashTable *io_flags_handlers;
111  GHashTable *cell_color_handlers;
112  GHashTable *cell_border_handlers;
113  GHashTable *confirm_handlers;
114 
115  GHashTable *save_handlers;
116  TableSaveHandler pre_save_handler;
117  TableSaveHandler post_save_handler;
118 
119  gpointer handler_user_data;
120 
121  /* If true, denotes that this table is read-only
122  * and edits should not be allowed. */
123  gboolean read_only;
124 
125  /* If true, denotes that this table is being displayed
126  * in the reverse direction. */
127  gboolean reverse_sort;
128 
129  /* If positive, denotes a row that marks a boundary that should
130  * be visually distinguished. */
131  int dividing_row;
132  /* If positive, denotes a row that marks a boundary that should
133  * be visually distinguished, but different from the others. */
134  int dividing_row_upper;
135  /* If positive, denotes a row that marks a boundary that should
136  * be visually distinguished. */
137  int dividing_row_lower;
138 
139  /* If positive, denotes the row position of the blank trans */
140  int blank_trans_row;
141 
142  VirtCellDataAllocator cell_data_allocator;
143  VirtCellDataDeallocator cell_data_deallocator;
144  VirtCellDataCopy cell_data_copy;
145 } TableModel;
146 
147 
148 TableModel * gnc_table_model_new (void);
149 void gnc_table_model_destroy (TableModel *model);
150 
151 void gnc_table_model_set_read_only (TableModel *model,
152  gboolean read_only);
153 gboolean gnc_table_model_read_only (TableModel *model);
154 
155 void gnc_table_model_set_reverse_sort (TableModel *model,
156  gboolean read_only);
157 
158 void gnc_table_model_set_entry_handler
159 (TableModel *model,
160  TableGetEntryHandler entry_handler,
161  const char * cell_name);
162 void gnc_table_model_set_default_entry_handler
163 (TableModel *model,
164  TableGetEntryHandler entry_handler);
165 TableGetEntryHandler gnc_table_model_get_entry_handler
166 (TableModel *model,
167  const char * cell_name);
168 
169 void gnc_table_model_set_label_handler
170 (TableModel *model,
171  TableGetLabelHandler label_handler,
172  const char * cell_name);
173 void gnc_table_model_set_default_label_handler
174 (TableModel *model,
175  TableGetLabelHandler label_handler);
176 TableGetLabelHandler gnc_table_model_get_label_handler
177 (TableModel *model,
178  const char * cell_name);
179 
180 void gnc_table_model_set_help_handler
181 (TableModel *model,
182  TableGetHelpHandler help_handler,
183  const char * cell_name);
184 void gnc_table_model_set_default_help_handler
185 (TableModel *model,
186  TableGetHelpHandler help_handler);
187 TableGetHelpHandler gnc_table_model_get_help_handler
188 (TableModel *model,
189  const char * cell_name);
190 
191 void gnc_table_model_set_tooltip_handler
192 (TableModel *model,
193  TableGetTooltipHandler tooltip_handler,
194  const char * cell_name);
195 void gnc_table_model_set_default_tooltip_handler
196 (TableModel *model,
197  TableGetTooltipHandler tooltip_handler);
198 TableGetTooltipHandler gnc_table_model_get_tooltip_handler
199 (TableModel *model,
200  const char * cell_name);
201 
202 void gnc_table_model_set_io_flags_handler
203 (TableModel *model,
204  TableGetCellIOFlagsHandler io_flags_handler,
205  const char * cell_name);
206 void gnc_table_model_set_default_io_flags_handler
207 (TableModel *model,
208  TableGetCellIOFlagsHandler io_flags_handler);
209 TableGetCellIOFlagsHandler gnc_table_model_get_io_flags_handler
210 (TableModel *model,
211  const char * cell_name);
212 
213 void gnc_table_model_set_cell_color_handler
214 (TableModel *model,
215  TableGetCellColorHandler io_flags_handler,
216  const char * cell_name);
217  void gnc_table_model_set_default_cell_color_handler
218 (TableModel *model,
219  TableGetCellColorHandler io_flags_handler);
220 TableGetCellColorHandler gnc_table_model_get_cell_color_handler
221 (TableModel *model,
222  const char * cell_name);
223 
224 void gnc_table_model_set_cell_border_handler
225 (TableModel *model,
226  TableGetCellBorderHandler io_flags_handler,
227  const char * cell_name);
228 void gnc_table_model_set_default_cell_border_handler
229 (TableModel *model,
230  TableGetCellBorderHandler io_flags_handler);
231 TableGetCellBorderHandler gnc_table_model_get_cell_border_handler
232 (TableModel *model,
233  const char * cell_name);
234 
235 void gnc_table_model_set_confirm_handler
236 (TableModel *model,
237  TableConfirmHandler io_flags_handler,
238  const char * cell_name);
239 void gnc_table_model_set_default_confirm_handler
240 (TableModel *model,
241  TableConfirmHandler io_flags_handler);
242 TableConfirmHandler gnc_table_model_get_confirm_handler
243 (TableModel *model,
244  const char * cell_name);
245 
246 void gnc_table_model_set_save_handler
247 (TableModel *model,
248  TableSaveCellHandler save_handler,
249  const char * cell_name);
250 void gnc_table_model_set_pre_save_handler
251 (TableModel *model,
252  TableSaveHandler save_handler);
253 void gnc_table_model_set_post_save_handler
254 (TableModel *model,
255  TableSaveHandler save_handler);
256 TableSaveCellHandler gnc_table_model_get_save_handler
257 (TableModel *model,
258  const char * cell_name);
259 TableSaveHandler gnc_table_model_get_pre_save_handler
260 (TableModel *model);
261 TableSaveHandler gnc_table_model_get_post_save_handler
262 (TableModel *model);
264 #endif
Common declarations for the register core.