GnuCash  5.6-150-g038405b370+
table-allgui.h
Go to the documentation of this file.
1 /********************************************************************\
2  * table-allgui.h -- 2D grid table object, embeds cells for i/o *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * the License, or (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License*
15  * along with this program; if not, contact: *
16  * *
17  * Free Software Foundation Voice: +1-617-542-5942 *
18  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19  * Boston, MA 02110-1301, USA gnu@gnu.org *
20  * *
21 \********************************************************************/
118 #ifndef TABLE_ALLGUI_H
119 #define TABLE_ALLGUI_H
120 
121 #include <glib.h>
122 
123 #include "basiccell.h"
124 #include "cellblock.h"
125 #include "gtable.h"
126 #include "register-common.h"
127 #include "table-control.h"
128 #include "table-layout.h"
129 #include "table-model.h"
130 
132 typedef struct
133 {
134  CellBlock *cellblock;
135  gpointer vcell_data;
137  /* flags */
138  unsigned int visible : 1;
139  unsigned int start_primary_color : 1;
140 } VirtualCell;
141 
142 typedef struct table Table;
143 
144 typedef void (*TableCursorRefreshCB) (Table *table,
145  VirtualCellLocation vcell_loc,
146  gboolean do_scroll);
147 
148 typedef void (*TableRedrawHelpCB) (Table *table);
149 typedef void (*TableDestroyCB) (Table *table);
150 
151 typedef struct
152 {
153  TableCursorRefreshCB cursor_refresh;
154 
155  TableRedrawHelpCB redraw_help;
156  TableDestroyCB destroy;
157 
158  CellDirectUpdateFunc default_direct_update;
160 
161 struct table
162 {
163  TableLayout *layout;
164  TableModel *model;
165  TableControl *control;
166 
167  int num_virt_rows;
168  int num_virt_cols;
169 
170  CellBlock *current_cursor;
171 
172  VirtualLocation current_cursor_loc;
173 
174  /* private data */
175 
176  /* The virtual cell table */
177  GTable *virt_cells;
178 
179  TableGUIHandlers gui_handlers;
180  gpointer ui_data;
181 };
182 
184 typedef enum {
185  COLOR_UNDEFINED = 0, // 0
186  COLOR_HEADER, // 1
187  COLOR_PRIMARY, // 2
188  COLOR_PRIMARY_ACTIVE, // 3
189  COLOR_SECONDARY, // 4
190  COLOR_SECONDARY_ACTIVE, // 5
191  COLOR_SPLIT, // 6
192  COLOR_SPLIT_ACTIVE, // 7
193  COLOR_NEGATIVE = 16, // 16
194 } RegisterColor;
195 
196 
199 
200 /* Functions to create and destroy Tables. */
201 Table * gnc_table_new (TableLayout *layout,
202  TableModel *model,
203  TableControl *control);
204 void gnc_virtual_location_init (VirtualLocation *vloc);
205 
206 void gnc_table_save_state (Table *table, const gchar *state_section);
207 void gnc_table_destroy (Table *table);
208 
209 
210 /* Functions to work with current cursor */
211 int gnc_table_current_cursor_changed (Table *table,
212  gboolean include_conditional);
213 
214 void gnc_table_clear_current_cursor_changes (Table *table);
215 
216 void gnc_table_save_current_cursor (Table *table, CursorBuffer *buffer);
217 void gnc_table_restore_current_cursor (Table *table,
218  CursorBuffer *buffer);
219 
220 const char * gnc_table_get_current_cell_name (Table *table);
221 
222 gboolean gnc_table_get_current_cell_location (Table *table,
223  const char *cell_name,
224  VirtualLocation *virt_loc);
225 
226 
230  VirtualCellLocation vcell_loc);
231 
232 gboolean gnc_table_virtual_location_in_header (Table *table,
233  VirtualLocation virt_loc);
234 
235 
239  VirtualCellLocation vcell_loc);
240 
241 const char * gnc_table_get_entry (Table *table, VirtualLocation virt_loc);
242 
243 char * gnc_table_get_tooltip (Table *table, VirtualLocation virt_loc);
244 
245 const char * gnc_table_get_label (Table *table, VirtualLocation virt_loc);
246 
247 CellIOFlags gnc_table_get_io_flags (Table *table, VirtualLocation virt_loc);
248 
249 guint32 gnc_table_get_color (Table *table, VirtualLocation virt_loc,
250  gboolean *hatching);
251 
252 void gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
253  PhysicalCellBorders *borders);
254 
255 CellAlignment gnc_table_get_align (Table *table, VirtualLocation virt_loc);
256 
257 gboolean gnc_table_is_popup (Table *table, VirtualLocation virt_loc);
258 
259 char * gnc_table_get_help (Table *table);
260 
261 BasicCell * gnc_table_get_cell (Table *table, VirtualLocation virt_loc);
262 
263 const char * gnc_table_get_cell_name (Table *table,
264  VirtualLocation virt_loc);
265 const gchar * gnc_table_get_cell_type_name (Table *table,
266  VirtualLocation virt_loc);
267 gboolean gnc_table_get_cell_location (Table *table,
268  const char * cell_name,
269  VirtualCellLocation vcell_loc,
270  VirtualLocation *virt_loc);
271 
272 const char * gnc_table_get_model_entry (Table *table, const char *cell_name);
273 
274 void gnc_table_save_cells (Table *table, gpointer save_data);
275 
276 
279 
282 void gnc_table_set_size (Table * table, int virt_rows, int virt_cols);
283 
285 void gnc_table_set_vcell (Table *table, CellBlock *cursor,
286  gconstpointer vcell_data,
287  gboolean visible,
288  gboolean start_primary_color,
289  VirtualCellLocation vcell_loc);
290 
293  VirtualCellLocation vcell_loc,
294  gconstpointer vcell_data);
295 
298  VirtualCellLocation vcell_loc,
299  gboolean visible);
300 
303  VirtualCellLocation vcell_loc,
304  CellBlock *cursor);
305 
310 void gnc_table_move_cursor (Table *table, VirtualLocation virt_loc);
311 
314 void gnc_table_move_cursor_gui (Table *table, VirtualLocation virt_loc);
315 
320 gboolean gnc_table_verify_cursor_position (Table *table,
321  VirtualLocation virt_loc);
322 
325 gpointer gnc_table_get_vcell_data (Table *table,
326  VirtualCellLocation vcell_loc);
327 
331 gboolean gnc_table_find_close_valid_cell (Table *table,
332  VirtualLocation *virt_loc,
333  gboolean exact_cell);
334 
338 void gnc_table_init_gui (Table *table);
339 
340 void gnc_table_realize_gui (Table *table);
341 
344  gboolean do_scroll);
345 
347 void gnc_table_refresh_gui (Table *table, gboolean do_scroll);
348 
350 void gnc_table_show_range (Table *table,
351  VirtualCellLocation start_loc,
352  VirtualCellLocation end_loc);
353 
356 void gnc_table_refresh_cursor_gui (Table * table,
357  VirtualCellLocation vcell_loc,
358  gboolean do_scroll);
359 
360 /* ==================================================== */
361 
362 void gnc_table_wrap_verify_cursor_position (Table *table,
363  VirtualLocation virt_loc);
364 
365 gboolean gnc_table_virtual_loc_valid(Table *table,
366  VirtualLocation virt_loc,
367  gboolean exact_pointer);
368 
369 gboolean gnc_table_move_tab (Table *table,
370  VirtualLocation *virt_loc,
371  gboolean move_right);
372 
386 gboolean gnc_table_move_vertical_position (Table *table,
387  VirtualLocation *virt_loc,
388  int phys_row_offset);
389 
390 gboolean gnc_table_enter_update(Table *table,
391  VirtualLocation virt_loc,
392  int *cursor_position,
393  int *start_selection,
394  int *end_selection);
395 
396 void gnc_table_leave_update(Table *table, VirtualLocation virt_loc);
397 
398 gboolean gnc_table_confirm_change(Table *table, VirtualLocation virt_loc);
399 
400 const char * gnc_table_modify_update(Table *table,
401  VirtualLocation virt_loc,
402  const char *change,
403  int change_len,
404  const char *newval,
405  int newval_len,
406  int *cursor_position,
407  int *start_selection,
408  int *end_selection,
409  gboolean *cancelled);
410 
411 gboolean gnc_table_direct_update(Table *table,
412  VirtualLocation virt_loc,
413  char **newval_ptr,
414  int *cursor_position,
415  int *start_selection,
416  int *end_selection,
417  gpointer gui_data);
418 
419 gboolean gnc_table_traverse_update(Table *table,
420  VirtualLocation virt_loc,
421  gncTableTraversalDir dir,
422  VirtualLocation *dest_loc);
423 
424 #endif /* TABLE_ALLGUI_H */
425 
gpointer vcell_data
Array of physical cells.
Definition: table-allgui.h:135
gpointer gnc_table_get_vcell_data(Table *table, VirtualCellLocation vcell_loc)
returns the virtual cell data associated with a cursor located at the given virtual coords...
Definition: table-allgui.c:931
void gnc_table_set_virt_cell_visible(Table *table, VirtualCellLocation vcell_loc, gboolean visible)
Set the visibility flag for a particular location.
Definition: table-allgui.c:719
holds information about each virtual cell.
Definition: table-allgui.h:132
void gnc_table_move_cursor_gui(Table *table, VirtualLocation virt_loc)
will move the cursor and its GUI to the indicated location.
Definition: table-allgui.c:886
gboolean gnc_table_find_close_valid_cell(Table *table, VirtualLocation *virt_loc, gboolean exact_cell)
Find a close valid cell.
void gnc_table_set_size(Table *table, int virt_rows, int virt_cols)
The gnc_table_set_size() method will resize the table to the indicated dimensions.
Definition: table-allgui.c:586
VirtualCell * gnc_table_get_header_cell(Table *table)
Return the virtual cell of the header.
Definition: table-allgui.c:237
void gnc_table_set_virt_cell_data(Table *table, VirtualCellLocation vcell_loc, gconstpointer vcell_data)
Set the virtual cell data for a particular location.
Definition: table-allgui.c:699
void gnc_table_init_gui(Table *table)
UI-specific functions.
Definition: table-gnome.c:173
void gnc_table_refresh_gui(Table *table, gboolean do_scroll)
Refresh the whole GUI from the table.
Definition: table-gnome.c:181
void gnc_table_show_range(Table *table, VirtualCellLocation start_loc, VirtualCellLocation end_loc)
Try to show the whole range in the register.
Definition: table-gnome.c:231
VirtualCell * gnc_table_get_virtual_cell(Table *table, VirtualCellLocation vcell_loc)
returns the virtual cell associated with a particular virtual location.
Definition: table-allgui.c:227
void gnc_table_set_default_gui_handlers(TableGUIHandlers *gui_handlers)
Set the default gui handlers used by new tables.
Definition: table-allgui.c:67
gboolean gnc_table_verify_cursor_position(Table *table, VirtualLocation virt_loc)
checks the location of the cursor with respect to a virtual location position, and if the resulting v...
Definition: table-allgui.c:897
unsigned int start_primary_color
visible in the GUI
Definition: table-allgui.h:139
void gnc_table_set_vcell(Table *table, CellBlock *cursor, gconstpointer vcell_data, gboolean visible, gboolean start_primary_color, VirtualCellLocation vcell_loc)
Indicate what handler should be used for a given virtual block.
Definition: table-allgui.c:663
Definition: gtable.c:28
gboolean gnc_table_move_vertical_position(Table *table, VirtualLocation *virt_loc, int phys_row_offset)
Moves away from virtual location virt_loc by phys_row_offset physical rows.
unsigned int visible
Used by higher-level code.
Definition: table-allgui.h:138
void gnc_table_refresh_cursor_gui(Table *table, VirtualCellLocation vcell_loc, gboolean do_scroll)
Refresh the cursor in the given location.
void gnc_table_refresh_current_cursor_gui(Table *table, gboolean do_scroll)
Refresh the current cursor gui.
Definition: table-allgui.c:994
void gnc_table_set_virt_cell_cursor(Table *table, VirtualCellLocation vcell_loc, CellBlock *cursor)
Set the cellblock handler for a virtual cell.
Definition: table-allgui.c:736
gboolean gnc_table_virtual_cell_out_of_bounds(Table *table, VirtualCellLocation vcell_loc)
checks the given location and returns true if it is out of bounds of the table.
Definition: table-allgui.c:207
RegisterColor
Color definitions used for table elements.
Definition: table-allgui.h:184
void gnc_table_save_state(Table *table, const gchar *state_section)
Implementation.
Definition: table-gnome.c:71
Declarations for the CellBlock object.
void gnc_table_move_cursor(Table *table, VirtualLocation virt_loc)
will move the cursor (but not the cursor GUI) to the indicated location.
Definition: table-allgui.c:877
This is the API for GTables, a datatype for 2-dimensional tables with automatic resizing and memory m...
Common declarations for the register core.