GnuCash  5.6-139-g03622b03d0+
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;
158 
159 struct table
160 {
161  TableLayout *layout;
162  TableModel *model;
163  TableControl *control;
164 
165  int num_virt_rows;
166  int num_virt_cols;
167 
168  CellBlock *current_cursor;
169 
170  VirtualLocation current_cursor_loc;
171 
172  /* private data */
173 
174  /* The virtual cell table */
175  GTable *virt_cells;
176 
177  TableGUIHandlers gui_handlers;
178  gpointer ui_data;
179 };
180 
182 typedef enum {
183  COLOR_UNDEFINED = 0, // 0
184  COLOR_HEADER, // 1
185  COLOR_PRIMARY, // 2
186  COLOR_PRIMARY_ACTIVE, // 3
187  COLOR_SECONDARY, // 4
188  COLOR_SECONDARY_ACTIVE, // 5
189  COLOR_SPLIT, // 6
190  COLOR_SPLIT_ACTIVE, // 7
191  COLOR_NEGATIVE = 16, // 16
192 } RegisterColor;
193 
194 
197 
198 /* Functions to create and destroy Tables. */
199 Table * gnc_table_new (TableLayout *layout,
200  TableModel *model,
201  TableControl *control);
202 void gnc_virtual_location_init (VirtualLocation *vloc);
203 
204 void gnc_table_save_state (Table *table, const gchar *state_section);
205 void gnc_table_destroy (Table *table);
206 
207 
208 /* Functions to work with current cursor */
209 int gnc_table_current_cursor_changed (Table *table,
210  gboolean include_conditional);
211 
212 void gnc_table_clear_current_cursor_changes (Table *table);
213 
214 void gnc_table_save_current_cursor (Table *table, CursorBuffer *buffer);
215 void gnc_table_restore_current_cursor (Table *table,
216  CursorBuffer *buffer);
217 
218 const char * gnc_table_get_current_cell_name (Table *table);
219 
220 gboolean gnc_table_get_current_cell_location (Table *table,
221  const char *cell_name,
222  VirtualLocation *virt_loc);
223 
224 
228  VirtualCellLocation vcell_loc);
229 
230 gboolean gnc_table_virtual_location_in_header (Table *table,
231  VirtualLocation virt_loc);
232 
233 
237  VirtualCellLocation vcell_loc);
238 
239 const char * gnc_table_get_entry (Table *table, VirtualLocation virt_loc);
240 
241 char * gnc_table_get_tooltip (Table *table, VirtualLocation virt_loc);
242 
243 const char * gnc_table_get_label (Table *table, VirtualLocation virt_loc);
244 
245 CellIOFlags gnc_table_get_io_flags (Table *table, VirtualLocation virt_loc);
246 
247 guint32 gnc_table_get_color (Table *table, VirtualLocation virt_loc,
248  gboolean *hatching);
249 
250 void gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
251  PhysicalCellBorders *borders);
252 
253 CellAlignment gnc_table_get_align (Table *table, VirtualLocation virt_loc);
254 
255 gboolean gnc_table_is_popup (Table *table, VirtualLocation virt_loc);
256 
257 char * gnc_table_get_help (Table *table);
258 
259 BasicCell * gnc_table_get_cell (Table *table, VirtualLocation virt_loc);
260 
261 const char * gnc_table_get_cell_name (Table *table,
262  VirtualLocation virt_loc);
263 const gchar * gnc_table_get_cell_type_name (Table *table,
264  VirtualLocation virt_loc);
265 gboolean gnc_table_get_cell_location (Table *table,
266  const char * cell_name,
267  VirtualCellLocation vcell_loc,
268  VirtualLocation *virt_loc);
269 
270 void gnc_table_save_cells (Table *table, gpointer save_data);
271 
272 
275 
278 void gnc_table_set_size (Table * table, int virt_rows, int virt_cols);
279 
281 void gnc_table_set_vcell (Table *table, CellBlock *cursor,
282  gconstpointer vcell_data,
283  gboolean visible,
284  gboolean start_primary_color,
285  VirtualCellLocation vcell_loc);
286 
289  VirtualCellLocation vcell_loc,
290  gconstpointer vcell_data);
291 
294  VirtualCellLocation vcell_loc,
295  gboolean visible);
296 
299  VirtualCellLocation vcell_loc,
300  CellBlock *cursor);
301 
306 void gnc_table_move_cursor (Table *table, VirtualLocation virt_loc);
307 
310 void gnc_table_move_cursor_gui (Table *table, VirtualLocation virt_loc);
311 
316 gboolean gnc_table_verify_cursor_position (Table *table,
317  VirtualLocation virt_loc);
318 
321 gpointer gnc_table_get_vcell_data (Table *table,
322  VirtualCellLocation vcell_loc);
323 
327 gboolean gnc_table_find_close_valid_cell (Table *table,
328  VirtualLocation *virt_loc,
329  gboolean exact_cell);
330 
334 void gnc_table_init_gui (Table *table);
335 
336 void gnc_table_realize_gui (Table *table);
337 
340  gboolean do_scroll);
341 
343 void gnc_table_refresh_gui (Table *table, gboolean do_scroll);
344 
346 void gnc_table_show_range (Table *table,
347  VirtualCellLocation start_loc,
348  VirtualCellLocation end_loc);
349 
352 void gnc_table_refresh_cursor_gui (Table * table,
353  VirtualCellLocation vcell_loc,
354  gboolean do_scroll);
355 
356 /* ==================================================== */
357 
358 void gnc_table_wrap_verify_cursor_position (Table *table,
359  VirtualLocation virt_loc);
360 
361 gboolean gnc_table_virtual_loc_valid(Table *table,
362  VirtualLocation virt_loc,
363  gboolean exact_pointer);
364 
365 gboolean gnc_table_move_tab (Table *table,
366  VirtualLocation *virt_loc,
367  gboolean move_right);
368 
382 gboolean gnc_table_move_vertical_position (Table *table,
383  VirtualLocation *virt_loc,
384  int phys_row_offset);
385 
386 gboolean gnc_table_enter_update(Table *table,
387  VirtualLocation virt_loc,
388  int *cursor_position,
389  int *start_selection,
390  int *end_selection);
391 
392 void gnc_table_leave_update(Table *table, VirtualLocation virt_loc);
393 
394 gboolean gnc_table_confirm_change(Table *table, VirtualLocation virt_loc);
395 
396 const char * gnc_table_modify_update(Table *table,
397  VirtualLocation virt_loc,
398  const char *change,
399  int change_len,
400  const char *newval,
401  int newval_len,
402  int *cursor_position,
403  int *start_selection,
404  int *end_selection,
405  gboolean *cancelled);
406 
407 gboolean gnc_table_direct_update(Table *table,
408  VirtualLocation virt_loc,
409  char **newval_ptr,
410  int *cursor_position,
411  int *start_selection,
412  int *end_selection,
413  gpointer gui_data);
414 
415 gboolean gnc_table_traverse_update(Table *table,
416  VirtualLocation virt_loc,
417  gncTableTraversalDir dir,
418  VirtualLocation *dest_loc);
419 
420 #endif /* TABLE_ALLGUI_H */
421 
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:932
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:720
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:887
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:587
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:700
void gnc_table_init_gui(Table *table)
UI-specific functions.
Definition: table-gnome.c:158
void gnc_table_refresh_gui(Table *table, gboolean do_scroll)
Refresh the whole GUI from the table.
Definition: table-gnome.c:165
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:215
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:898
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:664
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:995
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:737
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:182
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:878
This is the API for GTables, a datatype for 2-dimensional tables with automatic resizing and memory m...
Common declarations for the register core.