GnuCash c935c2f+
Loading...
Searching...
No Matches
Files | Data Structures | Macros | Typedefs | Enumerations | Functions

The "Table" is a displayed matrix. More...

Files

file  gtable.h
 This is the API for GTables, a datatype for 2-dimensional tables with automatic resizing and memory management.
 
file  table-allgui.h
 Declarations for the Table object.
 
file  table-control.h
 
file  table-layout.h
 
file  table-model.h
 

Data Structures

struct  VirtualCell
 holds information about each virtual cell. More...
 
struct  TableGUIHandlers
 
struct  Table
 
struct  TableControl
 
struct  PhysicalCellBorders
 
struct  TableModel
 

Macros

#define CURSOR_HEADER   "cursor-header"
 Standard Cursor Names.
 

Typedefs

typedef void(* g_table_entry_constructor) (gpointer entry, gpointer user_data)
 
typedef void(* g_table_entry_destroyer) (gpointer entry, gpointer user_data)
 
typedef void(* TableCursorRefreshCB) (Table *table, VirtualCellLocation vcell_loc, gboolean do_scroll)
 
typedef void(* TableRedrawHelpCB) (Table *table)
 
typedef void(* TableDestroyCB) (Table *table)
 
typedef void(* TableMoveFunc) (VirtualLocation *new_virt_loc, gpointer user_data)
 
typedef gboolean(* TableTraverseFunc) (VirtualLocation *new_virt_loc, gncTableTraversalDir dir, gpointer user_data)
 
typedef const char *(* TableGetEntryHandler) (VirtualLocation virt_loc, gboolean translate, gboolean *conditionally_changed, gpointer user_data)
 
typedef const char *(* TableGetLabelHandler) (VirtualLocation virt_loc, gpointer user_data)
 
typedef char *(* TableGetHelpHandler) (VirtualLocation virt_loc, gpointer user_data)
 
typedef char *(* TableGetTooltipHandler) (VirtualLocation virt_loc, gpointer user_data)
 
typedef CellIOFlags(* TableGetCellIOFlagsHandler) (VirtualLocation virt_loc, gpointer user_data)
 
typedef guint32(* TableGetCellColorHandler) (VirtualLocation virt_loc, gboolean *hatching, gpointer user_data)
 
typedef void(* TableGetCellBorderHandler) (VirtualLocation virt_loc, PhysicalCellBorders *borders, gpointer user_data)
 
typedef gboolean(* TableConfirmHandler) (VirtualLocation virt_loc, gpointer user_data)
 
typedef void(* TableSaveCellHandler) (BasicCell *cell, gpointer save_data, gpointer user_data)
 
typedef void(* TableSaveHandler) (gpointer save_data, gpointer user_data)
 
typedef gpointer(* VirtCellDataAllocator) (void)
 
typedef void(* VirtCellDataDeallocator) (gpointer cell_data)
 
typedef void(* VirtCellDataCopy) (gpointer to, gconstpointer from)
 

Enumerations

enum  RegisterColor {
  COLOR_UNDEFINED = 0 , COLOR_HEADER , COLOR_PRIMARY , COLOR_PRIMARY_ACTIVE ,
  COLOR_SECONDARY , COLOR_SECONDARY_ACTIVE , COLOR_SPLIT , COLOR_SPLIT_ACTIVE ,
  COLOR_NEGATIVE = 16
}
 Color definitions used for table elements. More...
 
enum  gncTableTraversalDir {
  GNC_TABLE_TRAVERSE_POINTER , GNC_TABLE_TRAVERSE_LEFT , GNC_TABLE_TRAVERSE_RIGHT , GNC_TABLE_TRAVERSE_UP ,
  GNC_TABLE_TRAVERSE_DOWN
}
 
enum  CellIOFlags {
  XACC_CELL_ALLOW_NONE = 0 , XACC_CELL_ALLOW_INPUT = 1 << 0 , XACC_CELL_ALLOW_SHADOW = 1 << 1 , XACC_CELL_ALLOW_ALL = XACC_CELL_ALLOW_INPUT | XACC_CELL_ALLOW_SHADOW ,
  XACC_CELL_ALLOW_EXACT_ONLY = 1 << 2 , XACC_CELL_ALLOW_ENTER = 1 << 3 , XACC_CELL_ALLOW_READ_ONLY = XACC_CELL_ALLOW_SHADOW | XACC_CELL_ALLOW_ENTER
}
 
enum  PhysicalCellBorderLineStyle {
  CELL_BORDER_LINE_NONE , CELL_BORDER_LINE_LIGHT , CELL_BORDER_LINE_NORMAL , CELL_BORDER_LINE_HEAVY ,
  CELL_BORDER_LINE_HIGHLIGHT
}
 

Functions

GTableg_table_new (guint entry_size, g_table_entry_constructor constructor, g_table_entry_destroyer destroyer, gpointer user_data)
 Create a new table with the given entry constructor and destroyer.
 
void g_table_destroy (GTable *gtable)
 Free the table and all associated table elements.
 
gpointer g_table_index (GTable *gtable, int row, int col)
 Return the element at the given row and column.
 
void g_table_resize (GTable *gtable, int rows, int cols)
 Resize the table, allocating and deallocating extra table members if needed.
 
int g_table_rows (GTable *gtable)
 Return the number of table rows.
 
int g_table_cols (GTable *gtable)
 Return the number of table columns.
 
void gnc_table_set_default_gui_handlers (TableGUIHandlers *gui_handlers)
 Set the default gui handlers used by new tables.
 
Table * gnc_table_new (TableLayout *layout, TableModel *model, TableControl *control)
 
void gnc_virtual_location_init (VirtualLocation *vloc)
 
void gnc_table_save_state (Table *table, const gchar *state_section)
 Implementation.
 
void gnc_table_destroy (Table *table)
 
int gnc_table_current_cursor_changed (Table *table, gboolean include_conditional)
 
void gnc_table_clear_current_cursor_changes (Table *table)
 
void gnc_table_save_current_cursor (Table *table, CursorBuffer *buffer)
 
void gnc_table_restore_current_cursor (Table *table, CursorBuffer *buffer)
 
const char * gnc_table_get_current_cell_name (Table *table)
 
gboolean gnc_table_get_current_cell_location (Table *table, const char *cell_name, VirtualLocation *virt_loc)
 
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.
 
gboolean gnc_table_virtual_location_in_header (Table *table, VirtualLocation virt_loc)
 
VirtualCellgnc_table_get_virtual_cell (Table *table, VirtualCellLocation vcell_loc)
 returns the virtual cell associated with a particular virtual location.
 
const char * gnc_table_get_entry (Table *table, VirtualLocation virt_loc)
 
char * gnc_table_get_tooltip (Table *table, VirtualLocation virt_loc)
 
const char * gnc_table_get_label (Table *table, VirtualLocation virt_loc)
 
CellIOFlags gnc_table_get_io_flags (Table *table, VirtualLocation virt_loc)
 
guint32 gnc_table_get_color (Table *table, VirtualLocation virt_loc, gboolean *hatching)
 
void gnc_table_get_borders (Table *table, VirtualLocation virt_loc, PhysicalCellBorders *borders)
 
CellAlignment gnc_table_get_align (Table *table, VirtualLocation virt_loc)
 
gboolean gnc_table_is_popup (Table *table, VirtualLocation virt_loc)
 
char * gnc_table_get_help (Table *table)
 
BasicCell * gnc_table_get_cell (Table *table, VirtualLocation virt_loc)
 
const char * gnc_table_get_cell_name (Table *table, VirtualLocation virt_loc)
 
const gchar * gnc_table_get_cell_type_name (Table *table, VirtualLocation virt_loc)
 
gboolean gnc_table_get_cell_location (Table *table, const char *cell_name, VirtualCellLocation vcell_loc, VirtualLocation *virt_loc)
 
const char * gnc_table_get_model_entry (Table *table, const char *cell_name)
 
void gnc_table_save_cells (Table *table, gpointer save_data)
 
VirtualCellgnc_table_get_header_cell (Table *table)
 Return the virtual cell of the header.
 
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.
 
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.
 
void gnc_table_set_virt_cell_data (Table *table, VirtualCellLocation vcell_loc, gconstpointer vcell_data)
 Set the virtual cell data for a particular location.
 
void gnc_table_set_virt_cell_visible (Table *table, VirtualCellLocation vcell_loc, gboolean visible)
 Set the visibility flag for a particular location.
 
void gnc_table_set_virt_cell_cursor (Table *table, VirtualCellLocation vcell_loc, CellBlock *cursor)
 Set the cellblock handler for a virtual cell.
 
void gnc_table_move_cursor (Table *table, VirtualLocation virt_loc)
 will move the cursor (but not the cursor GUI) to the indicated location.
 
void gnc_table_move_cursor_gui (Table *table, VirtualLocation virt_loc)
 will move the cursor and its GUI to the indicated location.
 
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 virtual location has changed, repositions the cursor and gui to the new position.
 
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, or NULL if the coords are out of bounds.
 
gboolean gnc_table_find_close_valid_cell (Table *table, VirtualLocation *virt_loc, gboolean exact_cell)
 Find a close valid cell.
 
void gnc_table_init_gui (Table *table)
 UI-specific functions.
 
void gnc_table_realize_gui (Table *table)
 
void gnc_table_refresh_current_cursor_gui (Table *table, gboolean do_scroll)
 Refresh the current cursor gui.
 
void gnc_table_refresh_gui (Table *table, gboolean do_scroll)
 Refresh the whole GUI from the table.
 
void gnc_table_show_range (Table *table, VirtualCellLocation start_loc, VirtualCellLocation end_loc)
 Try to show the whole range in the register.
 
void gnc_table_refresh_cursor_gui (Table *table, VirtualCellLocation vcell_loc, gboolean do_scroll)
 Refresh the cursor in the given location.
 
void gnc_table_wrap_verify_cursor_position (Table *table, VirtualLocation virt_loc)
 
gboolean gnc_table_virtual_loc_valid (Table *table, VirtualLocation virt_loc, gboolean exact_pointer)
 
gboolean gnc_table_move_tab (Table *table, VirtualLocation *virt_loc, gboolean move_right)
 
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.
 
gboolean gnc_table_enter_update (Table *table, VirtualLocation virt_loc, int *cursor_position, int *start_selection, int *end_selection)
 
void gnc_table_leave_update (Table *table, VirtualLocation virt_loc)
 
gboolean gnc_table_confirm_change (Table *table, VirtualLocation virt_loc)
 
const char * gnc_table_modify_update (Table *table, VirtualLocation virt_loc, const char *change, int change_len, const char *newval, int newval_len, int *cursor_position, int *start_selection, int *end_selection, gboolean *cancelled)
 
gboolean gnc_table_direct_update (Table *table, VirtualLocation virt_loc, char **newval_ptr, int *cursor_position, int *start_selection, int *end_selection, gpointer gui_data)
 
gboolean gnc_table_traverse_update (Table *table, VirtualLocation virt_loc, gncTableTraversalDir dir, VirtualLocation *dest_loc)
 
TableControlgnc_table_control_new (void)
 
void gnc_table_control_destroy (TableControl *control)
 
void gnc_table_control_allow_move (TableControl *control, gboolean allow_move)
 
TableLayout * gnc_table_layout_new (void)
 API Declarations.
 
void gnc_table_layout_destroy (TableLayout *layout)
 
void gnc_table_layout_add_cell (TableLayout *layout, BasicCell *cell)
 
BasicCell * gnc_table_layout_get_cell (TableLayout *layout, const char *cell_name)
 
const char * gnc_table_layout_get_cell_value (TableLayout *layout, const char *cell_name)
 
gboolean gnc_table_layout_get_cell_changed (TableLayout *layout, const char *cell_name, gboolean include_conditional)
 
GList * gnc_table_layout_get_cells (TableLayout *layout)
 
void gnc_table_layout_add_cursor (TableLayout *layout, CellBlock *cursor)
 
CellBlockgnc_table_layout_get_cursor (TableLayout *layout, const char *cursor_name)
 
GList * gnc_table_layout_get_cursors (TableLayout *layout)
 
void gnc_table_layout_set_primary_cursor (TableLayout *layout, CellBlock *cursor)
 
void gnc_table_layout_set_cell (TableLayout *layout, CellBlock *cursor, const char *cell_name, int row, int col)
 
CursorBuffer * gnc_cursor_buffer_new (void)
 
void gnc_cursor_buffer_destroy (CursorBuffer *buffer)
 
void gnc_table_layout_save_cursor (TableLayout *layout, CellBlock *cursor, CursorBuffer *buffer)
 
void gnc_table_layout_restore_cursor (TableLayout *layout, CellBlock *cursor, CursorBuffer *buffer)
 
TableModelgnc_table_model_new (void)
 
void gnc_table_model_destroy (TableModel *model)
 
void gnc_table_model_set_read_only (TableModel *model, gboolean read_only)
 
gboolean gnc_table_model_read_only (TableModel *model)
 
void gnc_table_model_set_reverse_sort (TableModel *model, gboolean read_only)
 
void gnc_table_model_set_entry_handler (TableModel *model, TableGetEntryHandler entry_handler, const char *cell_name)
 
void gnc_table_model_set_default_entry_handler (TableModel *model, TableGetEntryHandler entry_handler)
 
TableGetEntryHandler gnc_table_model_get_entry_handler (TableModel *model, const char *cell_name)
 
void gnc_table_model_set_label_handler (TableModel *model, TableGetLabelHandler label_handler, const char *cell_name)
 
void gnc_table_model_set_default_label_handler (TableModel *model, TableGetLabelHandler label_handler)
 
TableGetLabelHandler gnc_table_model_get_label_handler (TableModel *model, const char *cell_name)
 
void gnc_table_model_set_help_handler (TableModel *model, TableGetHelpHandler help_handler, const char *cell_name)
 
void gnc_table_model_set_default_help_handler (TableModel *model, TableGetHelpHandler help_handler)
 
TableGetHelpHandler gnc_table_model_get_help_handler (TableModel *model, const char *cell_name)
 
void gnc_table_model_set_tooltip_handler (TableModel *model, TableGetTooltipHandler tooltip_handler, const char *cell_name)
 
void gnc_table_model_set_default_tooltip_handler (TableModel *model, TableGetTooltipHandler tooltip_handler)
 
TableGetTooltipHandler gnc_table_model_get_tooltip_handler (TableModel *model, const char *cell_name)
 
void gnc_table_model_set_io_flags_handler (TableModel *model, TableGetCellIOFlagsHandler io_flags_handler, const char *cell_name)
 
void gnc_table_model_set_default_io_flags_handler (TableModel *model, TableGetCellIOFlagsHandler io_flags_handler)
 
TableGetCellIOFlagsHandler gnc_table_model_get_io_flags_handler (TableModel *model, const char *cell_name)
 
void gnc_table_model_set_cell_color_handler (TableModel *model, TableGetCellColorHandler io_flags_handler, const char *cell_name)
 
void gnc_table_model_set_default_cell_color_handler (TableModel *model, TableGetCellColorHandler io_flags_handler)
 
TableGetCellColorHandler gnc_table_model_get_cell_color_handler (TableModel *model, const char *cell_name)
 
void gnc_table_model_set_cell_border_handler (TableModel *model, TableGetCellBorderHandler io_flags_handler, const char *cell_name)
 
void gnc_table_model_set_default_cell_border_handler (TableModel *model, TableGetCellBorderHandler io_flags_handler)
 
TableGetCellBorderHandler gnc_table_model_get_cell_border_handler (TableModel *model, const char *cell_name)
 
void gnc_table_model_set_confirm_handler (TableModel *model, TableConfirmHandler io_flags_handler, const char *cell_name)
 
void gnc_table_model_set_default_confirm_handler (TableModel *model, TableConfirmHandler io_flags_handler)
 
TableConfirmHandler gnc_table_model_get_confirm_handler (TableModel *model, const char *cell_name)
 
void gnc_table_model_set_save_handler (TableModel *model, TableSaveCellHandler save_handler, const char *cell_name)
 
void gnc_table_model_set_pre_save_handler (TableModel *model, TableSaveHandler save_handler)
 
void gnc_table_model_set_post_save_handler (TableModel *model, TableSaveHandler save_handler)
 
TableSaveCellHandler gnc_table_model_get_save_handler (TableModel *model, const char *cell_name)
 
TableSaveHandler gnc_table_model_get_pre_save_handler (TableModel *model)
 
TableSaveHandler gnc_table_model_get_post_save_handler (TableModel *model)
 

Detailed Description

The "Table" is a displayed matrix.

The table is a complex object; it is not merely a Cellblock. The table provides all of the GUI infrastructure for displaying a row-column matrix of strings.

The table provides one very important function for minimizing memory usage for large matrixes - the notion of a "Cursor". The cursor is a Cellblock (an array of active cells) that is moved to the location that the user is currently editing. The cursor "virtualizes" Cell functions; that is, it makes it seem to the user as if all cells in the table are active, when in fact the only cell that actually needs to be active is the one that the user is currently editing.

The table design allows multiple cursors to be defined. When a user enters a cell, the appropriate cursor is positioned within the table. Cursors cannot overlap: any given cell can be mapped to at most one cursor. Multiple-cursor support allows tables to be designed that have a non-uniform layout. For example, the multiple-cursor support can be used to define a tree structure of headings and sub-headings, where the layout/format of the heading is different from the sub-headings. A financial example is a table which lists splits underneath their parent transaction. This is very different from a checkbook register, where all entries are uniform, and can be handled with a single repeated cursor.

Users of the table must provide a TableView object which provides an API the table uses to obtain information about the data it is displaying such as strings, colors, etc. Thus, the table represents the non-GUI portion of the View object in the Model-View-Controller paradigm.

Macro Definition Documentation

◆ CURSOR_HEADER

#define CURSOR_HEADER   "cursor-header"

Standard Cursor Names.

Definition at line 36 of file table-layout.h.

Typedef Documentation

◆ g_table_entry_constructor

typedef void(* g_table_entry_constructor) (gpointer entry, gpointer user_data)

Definition at line 38 of file gtable.h.

◆ g_table_entry_destroyer

typedef void(* g_table_entry_destroyer) (gpointer entry, gpointer user_data)

Definition at line 39 of file gtable.h.

◆ TableConfirmHandler

typedef gboolean(* TableConfirmHandler) (VirtualLocation virt_loc, gpointer user_data)

Definition at line 90 of file table-model.h.

◆ TableCursorRefreshCB

typedef void(* TableCursorRefreshCB) (Table *table, VirtualCellLocation vcell_loc, gboolean do_scroll)

Definition at line 144 of file table-allgui.h.

◆ TableDestroyCB

typedef void(* TableDestroyCB) (Table *table)

Definition at line 149 of file table-allgui.h.

◆ TableGetCellBorderHandler

typedef void(* TableGetCellBorderHandler) (VirtualLocation virt_loc, PhysicalCellBorders *borders, gpointer user_data)

Definition at line 86 of file table-model.h.

◆ TableGetCellColorHandler

typedef guint32(* TableGetCellColorHandler) (VirtualLocation virt_loc, gboolean *hatching, gpointer user_data)

Definition at line 82 of file table-model.h.

◆ TableGetCellIOFlagsHandler

typedef CellIOFlags(* TableGetCellIOFlagsHandler) (VirtualLocation virt_loc, gpointer user_data)

Definition at line 79 of file table-model.h.

◆ TableGetEntryHandler

typedef const char *(* TableGetEntryHandler) (VirtualLocation virt_loc, gboolean translate, gboolean *conditionally_changed, gpointer user_data)

Definition at line 65 of file table-model.h.

◆ TableGetHelpHandler

typedef char *(* TableGetHelpHandler) (VirtualLocation virt_loc, gpointer user_data)

Definition at line 73 of file table-model.h.

◆ TableGetLabelHandler

typedef const char *(* TableGetLabelHandler) (VirtualLocation virt_loc, gpointer user_data)

Definition at line 70 of file table-model.h.

◆ TableGetTooltipHandler

typedef char *(* TableGetTooltipHandler) (VirtualLocation virt_loc, gpointer user_data)

Definition at line 76 of file table-model.h.

◆ TableMoveFunc

typedef void(* TableMoveFunc) (VirtualLocation *new_virt_loc, gpointer user_data)

Definition at line 45 of file table-control.h.

◆ TableRedrawHelpCB

typedef void(* TableRedrawHelpCB) (Table *table)

Definition at line 148 of file table-allgui.h.

◆ TableSaveCellHandler

typedef void(* TableSaveCellHandler) (BasicCell *cell, gpointer save_data, gpointer user_data)

Definition at line 93 of file table-model.h.

◆ TableSaveHandler

typedef void(* TableSaveHandler) (gpointer save_data, gpointer user_data)

Definition at line 97 of file table-model.h.

◆ TableTraverseFunc

typedef gboolean(* TableTraverseFunc) (VirtualLocation *new_virt_loc, gncTableTraversalDir dir, gpointer user_data)

Definition at line 48 of file table-control.h.

◆ VirtCellDataAllocator

typedef gpointer(* VirtCellDataAllocator) (void)

Definition at line 100 of file table-model.h.

◆ VirtCellDataCopy

typedef void(* VirtCellDataCopy) (gpointer to, gconstpointer from)

Definition at line 102 of file table-model.h.

◆ VirtCellDataDeallocator

typedef void(* VirtCellDataDeallocator) (gpointer cell_data)

Definition at line 101 of file table-model.h.

Enumeration Type Documentation

◆ CellIOFlags

enum CellIOFlags

Definition at line 37 of file table-model.h.

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;

◆ gncTableTraversalDir

enum gncTableTraversalDir

Definition at line 36 of file table-control.h.

37{
38 GNC_TABLE_TRAVERSE_POINTER,
39 GNC_TABLE_TRAVERSE_LEFT,
40 GNC_TABLE_TRAVERSE_RIGHT,
41 GNC_TABLE_TRAVERSE_UP,
42 GNC_TABLE_TRAVERSE_DOWN
43} gncTableTraversalDir;

◆ PhysicalCellBorderLineStyle

enum PhysicalCellBorderLineStyle

Definition at line 48 of file table-model.h.

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;

◆ RegisterColor

Color definitions used for table elements.

Definition at line 184 of file table-allgui.h.

184 {
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
RegisterColor
Color definitions used for table elements.

Function Documentation

◆ g_table_cols()

int g_table_cols ( GTable gtable)

Return the number of table columns.

Definition at line 165 of file gtable.c.

166{
167 if (gtable == NULL)
168 return 0;
169
170 return gtable->cols;
171}

◆ g_table_destroy()

void g_table_destroy ( GTable gtable)

Free the table and all associated table elements.

Definition at line 69 of file gtable.c.

70{
71 if (gtable == NULL)
72 return;
73
74 g_table_resize (gtable, 0, 0);
75
76 g_array_free (gtable->array, TRUE);
77
78 gtable->array = NULL;
79
80 g_free(gtable);
81}
void g_table_resize(GTable *gtable, int rows, int cols)
Resize the table, allocating and deallocating extra table members if needed.
Definition gtable.c:104

◆ g_table_index()

gpointer g_table_index ( GTable gtable,
int  row,
int  col 
)

Return the element at the given row and column.

If the coordinates are out-of-bounds, return NULL

Definition at line 84 of file gtable.c.

85{
86 guint index = row * gtable->cols + col;
87 guint offset = index * gtable->entry_size;
88
89 if (gtable == NULL)
90 return NULL;
91 if ((row < 0) || (col < 0))
92 return NULL;
93 if (row >= gtable->rows)
94 return NULL;
95 if (col >= gtable->cols)
96 return NULL;
97
98 g_return_val_if_fail (gtable->array != NULL, NULL);
99 g_return_val_if_fail (gtable->array->len > index, NULL);
100 return &gtable->array->data[offset];
101}

◆ g_table_new()

GTable * g_table_new ( guint  entry_size,
g_table_entry_constructor  constructor,
g_table_entry_destroyer  destroyer,
gpointer  user_data 
)

Create a new table with the given entry constructor and destroyer.

Both functions must be given. They are used to initialize the table entries and free unneeded memory when resizing and destroying.

Definition at line 44 of file gtable.c.

48{
49 GTable *gtable;
50
51 gtable = g_new(GTable, 1);
52
53 gtable->array = g_array_new(FALSE, FALSE, entry_size);
54
55 gtable->entry_size = entry_size;
56
57 gtable->rows = 0;
58 gtable->cols = 0;
59
60 gtable->constructor = constructor;
61 gtable->destroyer = destroyer;
62
63 gtable->user_data = user_data;
64
65 return gtable;
66}

◆ g_table_resize()

void g_table_resize ( GTable gtable,
int  rows,
int  cols 
)

Resize the table, allocating and deallocating extra table members if needed.

The relationship between table members before and after resizing is undefined, except in the case where the number of rows changes, but not the number of columns. In that case, higher-numbered rows are discarded first.

Definition at line 104 of file gtable.c.

105{
106 guint old_len;
107 guint new_len;
108
109 if (gtable == NULL)
110 return;
111 if ((rows < 0) || (cols < 0))
112 return;
113
114 old_len = gtable->array->len;
115 new_len = rows * cols;
116
117 if (new_len == old_len)
118 return;
119
120 /* If shrinking, destroy extra cells */
121 if ((new_len < old_len) && gtable->destroyer)
122 {
123 gchar *entry;
124 guint i;
125
126 entry = &gtable->array->data[new_len * gtable->entry_size];
127 for (i = new_len; i < old_len; i++)
128 {
129 gtable->destroyer(entry, gtable->user_data);
130 entry += gtable->entry_size;
131 }
132 }
133
134 /* Change the size */
135 g_array_set_size(gtable->array, new_len);
136
137 /* If expanding, construct the new cells */
138 if ((new_len > old_len) && gtable->constructor)
139 {
140 gchar *entry;
141 guint i;
142
143 entry = &gtable->array->data[old_len * gtable->entry_size];
144 for (i = old_len; i < new_len; i++)
145 {
146 gtable->constructor(entry, gtable->user_data);
147 entry += gtable->entry_size;
148 }
149 }
150
151 gtable->rows = rows;
152 gtable->cols = cols;
153}

◆ g_table_rows()

int g_table_rows ( GTable gtable)

Return the number of table rows.

Definition at line 156 of file gtable.c.

157{
158 if (gtable == NULL)
159 return 0;
160
161 return gtable->rows;
162}

◆ gnc_cursor_buffer_destroy()

void gnc_cursor_buffer_destroy ( CursorBuffer *  buffer)

Definition at line 329 of file table-layout.c.

330{
331 if (!buffer) return;
332
333 gnc_cursor_buffer_clear (buffer);
334
335 g_free (buffer);
336}

◆ gnc_cursor_buffer_new()

CursorBuffer * gnc_cursor_buffer_new ( void  )

Definition at line 286 of file table-layout.c.

287{
288 CursorBuffer *buffer;
289
290 buffer = g_new0 (CursorBuffer, 1);
291
292 return buffer;
293}

◆ gnc_table_clear_current_cursor_changes()

void gnc_table_clear_current_cursor_changes ( Table *  table)

Definition at line 156 of file table-allgui.c.

157{
158 if (!table)
159 return;
160
161 gnc_cellblock_clear_changes (table->current_cursor);
162}
void gnc_cellblock_clear_changes(CellBlock *cursor)
Sets all cells in the cellblock to not changed.
Definition cellblock.c:189

◆ gnc_table_confirm_change()

gboolean gnc_table_confirm_change ( Table *  table,
VirtualLocation  virt_loc 
)

Definition at line 1186 of file table-allgui.c.

1187{
1188 TableConfirmHandler confirm_handler;
1189 const char *cell_name;
1190
1191 if (!table || !table->model)
1192 return TRUE;
1193
1194 cell_name = gnc_table_get_cell_name (table, virt_loc);
1195
1196 confirm_handler = gnc_table_model_get_confirm_handler (table->model,
1197 cell_name);
1198 if (!confirm_handler)
1199 return TRUE;
1200
1201 return confirm_handler (virt_loc, table->model->handler_user_data);
1202}

◆ gnc_table_control_allow_move()

void gnc_table_control_allow_move ( TableControl control,
gboolean  allow_move 
)

Definition at line 48 of file table-control.c.

50{
51 if (!control) return;
52 control->allow_move = allow_move;
53}

◆ gnc_table_control_destroy()

void gnc_table_control_destroy ( TableControl control)

Definition at line 41 of file table-control.c.

42{
43 if (!control) return;
44 g_free (control);
45}

◆ gnc_table_control_new()

TableControl * gnc_table_control_new ( void  )

Definition at line 31 of file table-control.c.

32{
33 TableControl *control;
34
35 control = g_new0 (TableControl, 1);
36
37 return control;
38}

◆ gnc_table_current_cursor_changed()

int gnc_table_current_cursor_changed ( Table *  table,
gboolean  include_conditional 
)

Definition at line 146 of file table-allgui.c.

148{
149 if (!table)
150 return FALSE;
151
152 return gnc_cellblock_changed (table->current_cursor, include_conditional);
153}
int gnc_cellblock_changed(CellBlock *cursor, gboolean include_conditional)
Return number of changed cells.
Definition cellblock.c:157

◆ gnc_table_destroy()

void gnc_table_destroy ( Table *  table)

Definition at line 118 of file table-allgui.c.

119{
120 /* invoke destroy callback */
121 if (table->gui_handlers.destroy)
122 table->gui_handlers.destroy (table);
123
124 /* free the dynamic structures */
125 gnc_table_free_data (table);
126
127 /* free the cell tables */
128 g_table_destroy (table->virt_cells);
129
130 gnc_table_layout_destroy (table->layout);
131 table->layout = NULL;
132
133 gnc_table_control_destroy (table->control);
134 table->control = NULL;
135
136 gnc_table_model_destroy (table->model);
137 table->model = NULL;
138
139 /* initialize vars to null value so that any access is voided. */
140 gnc_table_init (table);
141
142 g_free (table);
143}
void g_table_destroy(GTable *gtable)
Free the table and all associated table elements.
Definition gtable.c:69

◆ gnc_table_direct_update()

gboolean gnc_table_direct_update ( Table *  table,
VirtualLocation  virt_loc,
char **  newval_ptr,
int *  cursor_position,
int *  start_selection,
int *  end_selection,
gpointer  gui_data 
)

Definition at line 1300 of file table-allgui.c.

1307{
1308 gboolean result;
1309 BasicCell *cell;
1310 CellBlock *cb;
1311 int cell_row;
1312 int cell_col;
1313 char * old_value;
1314
1315 g_return_val_if_fail (table, FALSE);
1316 g_return_val_if_fail (table->model, FALSE);
1317
1318 if (gnc_table_model_read_only (table->model))
1319 {
1320 PWARN ("input to read-only table");
1321 return FALSE;
1322 }
1323
1324 cb = table->current_cursor;
1325
1326 cell_row = virt_loc.phys_row_offset;
1327 cell_col = virt_loc.phys_col_offset;
1328
1329 cell = gnc_cellblock_get_cell (cb, cell_row, cell_col);
1330 if (!cell)
1331 return FALSE;
1332
1333 ENTER ("");
1334
1335 gboolean changed = cell->changed;
1336 old_value = g_strdup (cell->value);
1337
1338 CellDirectUpdateFunc du = cell->direct_update;
1339
1340 if (du == NULL)
1341 du = table->gui_handlers.default_direct_update;
1342
1343 if (du == NULL)
1344 {
1345 LEAVE("no direct update");
1346 return FALSE;
1347 }
1348
1349 result = du (cell, cursor_position, start_selection, end_selection, gui_data);
1350
1351 if (g_strcmp0 (old_value, cell->value) != 0)
1352 {
1353 if (!gnc_table_confirm_change (table, virt_loc))
1354 {
1355 gnc_basic_cell_set_value (cell, old_value);
1356 *newval_ptr = NULL;
1357 result = TRUE;
1358 }
1359 else
1360 {
1361 if (!changed)
1362 cell->changed = TRUE;
1363 *newval_ptr = cell->value;
1364 }
1365 }
1366 else
1367 *newval_ptr = NULL;
1368
1369 g_free (old_value);
1370
1371 if (table->gui_handlers.redraw_help)
1372 table->gui_handlers.redraw_help (table);
1373
1374 LEAVE("");
1375 return result;
1376}
BasicCell * gnc_cellblock_get_cell(CellBlock *cellblock, int row, int col)
Retrieve the Cell at the specified coordinates.
Definition cellblock.c:109
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition qoflog.h:282
#define PWARN(format, args...)
Log a warning.
Definition qoflog.h:250
#define ENTER(format, args...)
Print a function entry debugging message.
Definition qoflog.h:272

◆ gnc_table_enter_update()

gboolean gnc_table_enter_update ( Table *  table,
VirtualLocation  virt_loc,
int *  cursor_position,
int *  start_selection,
int *  end_selection 
)

Definition at line 1053 of file table-allgui.c.

1058{
1059 gboolean can_edit = TRUE;
1060 CellEnterFunc enter;
1061 BasicCell *cell;
1062 CellBlock *cb;
1063 int cell_row;
1064 int cell_col;
1065 CellIOFlags io_flags;
1066
1067 if (table == NULL)
1068 return FALSE;
1069
1070 cb = table->current_cursor;
1071
1072 cell_row = virt_loc.phys_row_offset;
1073 cell_col = virt_loc.phys_col_offset;
1074
1075 ENTER("enter %d %d (relrow=%d relcol=%d)",
1076 virt_loc.vcell_loc.virt_row,
1077 virt_loc.vcell_loc.virt_col,
1078 cell_row, cell_col);
1079
1080 /* OK, if there is a callback for this cell, call it */
1081 cell = gnc_cellblock_get_cell (cb, cell_row, cell_col);
1082 if (!cell)
1083 {
1084 LEAVE("no cell");
1085 return FALSE;
1086 }
1087
1088 io_flags = gnc_table_get_io_flags (table, virt_loc);
1089 if (io_flags == XACC_CELL_ALLOW_READ_ONLY)
1090 {
1091 if (table->gui_handlers.redraw_help)
1092 table->gui_handlers.redraw_help (table);
1093 LEAVE("read only cell");
1094 return FALSE;
1095 }
1096
1097 enter = cell->enter_cell;
1098
1099 if (enter)
1100 {
1101 char * old_value;
1102
1103 DEBUG("gnc_table_enter_update(): %d %d has enter handler\n",
1104 cell_row, cell_col);
1105
1106 old_value = g_strdup (cell->value);
1107
1108 can_edit = enter (cell, cursor_position, start_selection, end_selection);
1109
1110 if (g_strcmp0 (old_value, cell->value) != 0)
1111 {
1112 if (gnc_table_model_read_only (table->model))
1113 {
1114 PWARN ("enter update changed read-only table");
1115 }
1116
1117 cell->changed = TRUE;
1118 }
1119
1120 g_free (old_value);
1121 }
1122
1123 if (table->gui_handlers.redraw_help)
1124 table->gui_handlers.redraw_help (table);
1125
1126 LEAVE("return %d\n", can_edit);
1127 return can_edit;
1128}
#define DEBUG(format, args...)
Print a debugging message.
Definition qoflog.h:264

◆ gnc_table_find_close_valid_cell()

gboolean gnc_table_find_close_valid_cell ( Table *  table,
VirtualLocation *  virt_loc,
gboolean  exact_cell 
)

Find a close valid cell.

If exact_cell is true, cells that must be explicitly selected by the user (as opposed to just tabbing into), are considered valid cells.

Definition at line 1509 of file table-allgui.c.

1511{
1512 if (!gnc_table_find_valid_row_vert (table, virt_loc))
1513 return FALSE;
1514
1515 return gnc_table_find_valid_cell_horiz (table, virt_loc, exact_pointer);
1516}

◆ gnc_table_get_align()

CellAlignment gnc_table_get_align ( Table *  table,
VirtualLocation  virt_loc 
)

Definition at line 412 of file table-allgui.c.

413{
414 BasicCell *cell;
415
416 cell = gnc_table_get_cell (table, virt_loc);
417 if (!cell)
418 return CELL_ALIGN_RIGHT;
419
420 return cell->alignment;
421}

◆ gnc_table_get_borders()

void gnc_table_get_borders ( Table *  table,
VirtualLocation  virt_loc,
PhysicalCellBorders borders 
)

Definition at line 392 of file table-allgui.c.

394{
395 TableGetCellBorderHandler cell_border_handler;
396 const char *cell_name;
397
398 if (!table || !table->model)
399 return;
400
401 cell_name = gnc_table_get_cell_name (table, virt_loc);
402
403 cell_border_handler =
404 gnc_table_model_get_cell_border_handler (table->model, cell_name);
405 if (!cell_border_handler)
406 return;
407
408 cell_border_handler (virt_loc, borders, table->model->handler_user_data);
409}

◆ gnc_table_get_cell()

BasicCell * gnc_table_get_cell ( Table *  table,
VirtualLocation  virt_loc 
)

Definition at line 457 of file table-allgui.c.

458{
459 VirtualCell *vcell;
460
461 if (!table)
462 return NULL;
463
464 vcell = gnc_table_get_virtual_cell (table, virt_loc.vcell_loc);
465 if (!vcell)
466 return NULL;
467
468 return gnc_cellblock_get_cell (vcell->cellblock,
469 virt_loc.phys_row_offset,
470 virt_loc.phys_col_offset);
471}
VirtualCell * gnc_table_get_virtual_cell(Table *table, VirtualCellLocation vcell_loc)
returns the virtual cell associated with a particular virtual location.
holds information about each virtual cell.

◆ gnc_table_get_cell_location()

gboolean gnc_table_get_cell_location ( Table *  table,
const char *  cell_name,
VirtualCellLocation  vcell_loc,
VirtualLocation *  virt_loc 
)

Definition at line 499 of file table-allgui.c.

503{
504 VirtualCell *vcell;
505 CellBlock *cellblock;
506 int cell_row, cell_col;
507
508 if (table == NULL)
509 return FALSE;
510
511 vcell = gnc_table_get_virtual_cell (table, vcell_loc);
512 if (vcell == NULL)
513 return FALSE;
514
515 cellblock = vcell->cellblock;
516
517 for (cell_row = 0; cell_row < cellblock->num_rows; cell_row++)
518 for (cell_col = 0; cell_col < cellblock->num_cols; cell_col++)
519 {
520 BasicCell *cell;
521
522 cell = gnc_cellblock_get_cell (cellblock, cell_row, cell_col);
523 if (!cell)
524 continue;
525
526 if (gnc_basic_cell_has_name (cell, cell_name))
527 {
528 if (virt_loc != NULL)
529 {
530 virt_loc->vcell_loc = vcell_loc;
531
532 virt_loc->phys_row_offset = cell_row;
533 virt_loc->phys_col_offset = cell_col;
534 }
535
536 return TRUE;
537 }
538 }
539
540 return FALSE;
541}

◆ gnc_table_get_cell_name()

const char * gnc_table_get_cell_name ( Table *  table,
VirtualLocation  virt_loc 
)

Definition at line 474 of file table-allgui.c.

475{
476 BasicCell *cell;
477
478 cell = gnc_table_get_cell (table, virt_loc);
479 if (cell == NULL)
480 return NULL;
481
482 return cell->cell_name;
483}

◆ gnc_table_get_cell_type_name()

const gchar * gnc_table_get_cell_type_name ( Table *  table,
VirtualLocation  virt_loc 
)

Definition at line 486 of file table-allgui.c.

487{
488 BasicCell *cell;
489
490 cell = gnc_table_get_cell (table, virt_loc);
491 if (cell == NULL)
492 return NULL;
493
494 return cell->cell_type_name;
495}

◆ gnc_table_get_color()

guint32 gnc_table_get_color ( Table *  table,
VirtualLocation  virt_loc,
gboolean *  hatching 
)

Definition at line 367 of file table-allgui.c.

369{
370 TableGetCellColorHandler color_handler;
371 const char *handler_name;
372
373 if (hatching)
374 *hatching = FALSE;
375
376 if (!table || !table->model)
377 return COLOR_UNDEFINED;
378
379 handler_name = gnc_table_get_cell_name (table, virt_loc);
380
381 color_handler =
382 gnc_table_model_get_cell_color_handler (table->model, handler_name);
383
384 if (!color_handler)
385 return COLOR_UNDEFINED;
386
387 return color_handler (virt_loc, hatching,
388 table->model->handler_user_data);
389}

◆ gnc_table_get_current_cell_location()

gboolean gnc_table_get_current_cell_location ( Table *  table,
const char *  cell_name,
VirtualLocation *  virt_loc 
)

Definition at line 194 of file table-allgui.c.

197{
198 if (table == NULL)
199 return FALSE;
200
201 return gnc_table_get_cell_location (table, cell_name,
202 table->current_cursor_loc.vcell_loc,
203 virt_loc);
204}

◆ gnc_table_get_current_cell_name()

const char * gnc_table_get_current_cell_name ( Table *  table)

Definition at line 185 of file table-allgui.c.

186{
187 if (table == NULL)
188 return NULL;
189
190 return gnc_table_get_cell_name (table, table->current_cursor_loc);
191}

◆ gnc_table_get_entry()

const char * gnc_table_get_entry ( Table *  table,
VirtualLocation  virt_loc 
)

Definition at line 273 of file table-allgui.c.

274{
275 BasicCell *cell = gnc_table_get_cell (table, virt_loc);
276
277 if (!cell || !cell->cell_name)
278 return "";
279
280 if (virt_cell_loc_equal (table->current_cursor_loc.vcell_loc,
281 virt_loc.vcell_loc))
282 {
283 CellIOFlags io_flags = gnc_table_get_io_flags (table, virt_loc);
284
285 if (io_flags & XACC_CELL_ALLOW_INPUT)
286 return cell->value;
287 }
288
289 return table_get_model_entry (table, virt_loc, TRUE, NULL, cell->cell_name);
290}

◆ gnc_table_get_header_cell()

VirtualCell * gnc_table_get_header_cell ( Table *  table)

Return the virtual cell of the header.

Definition at line 237 of file table-allgui.c.

238{
239 VirtualCellLocation vcell_loc = { 0, 0 };
240
241 return gnc_table_get_virtual_cell (table, vcell_loc);
242}

◆ gnc_table_get_help()

char * gnc_table_get_help ( Table *  table)

Definition at line 436 of file table-allgui.c.

437{
438 TableGetHelpHandler help_handler;
439 VirtualLocation virt_loc;
440 const char * cell_name;
441
442 if (!table)
443 return NULL;
444
445 virt_loc = table->current_cursor_loc;
446
447 cell_name = gnc_table_get_cell_name (table, virt_loc);
448
449 help_handler = gnc_table_model_get_help_handler (table->model, cell_name);
450 if (!help_handler)
451 return NULL;
452
453 return help_handler (virt_loc, table->model->handler_user_data);
454}

◆ gnc_table_get_io_flags()

CellIOFlags gnc_table_get_io_flags ( Table *  table,
VirtualLocation  virt_loc 
)

Definition at line 319 of file table-allgui.c.

320{
321 TableGetCellIOFlagsHandler io_flags_handler;
322 const char *cell_name;
323 CellIOFlags flags;
324
325 if (!table || !table->model)
326 return XACC_CELL_ALLOW_NONE;
327
328 cell_name = gnc_table_get_cell_name (table, virt_loc);
329
330 io_flags_handler =
331 gnc_table_model_get_io_flags_handler (table->model, cell_name);
332 if (!io_flags_handler)
333 return XACC_CELL_ALLOW_NONE;
334
335 flags = io_flags_handler (virt_loc, table->model->handler_user_data);
336
337 if (gnc_table_model_read_only (table->model))
338 flags &= XACC_CELL_ALLOW_SHADOW;
339
340 return flags;
341}

◆ gnc_table_get_label()

const char * gnc_table_get_label ( Table *  table,
VirtualLocation  virt_loc 
)

Definition at line 344 of file table-allgui.c.

345{
346 TableGetLabelHandler label_handler;
347 const char *cell_name;
348 const char *label;
349
350 if (!table || !table->model)
351 return "";
352
353 cell_name = gnc_table_get_cell_name (table, virt_loc);
354
355 label_handler = gnc_table_model_get_label_handler (table->model, cell_name);
356 if (!label_handler)
357 return "";
358
359 label = label_handler (virt_loc, table->model->handler_user_data);
360 if (!label)
361 return "";
362
363 return label;
364}

◆ gnc_table_get_model_entry()

const char * gnc_table_get_model_entry ( Table *  table,
const char *  cell_name 
)

Definition at line 293 of file table-allgui.c.

294{
295 return table_get_model_entry (table, table->current_cursor_loc, TRUE, NULL,
296 cell_name);
297}

◆ gnc_table_get_tooltip()

char * gnc_table_get_tooltip ( Table *  table,
VirtualLocation  virt_loc 
)

Definition at line 300 of file table-allgui.c.

301{
302 TableGetTooltipHandler tooltip_handler;
303 BasicCell *cell;
304
305 cell = gnc_table_get_cell (table, virt_loc);
306 if (!cell || !cell->cell_name)
307 return NULL;
308
309 tooltip_handler =
310 gnc_table_model_get_tooltip_handler (table->model, cell->cell_name);
311
312 if (!tooltip_handler)
313 return NULL;
314
315 return tooltip_handler (virt_loc, table->model->handler_user_data);
316}

◆ gnc_table_get_vcell_data()

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, or NULL if the coords are out of bounds.

Definition at line 931 of file table-allgui.c.

932{
933 VirtualCell *vcell;
934
935 if (!table) return NULL;
936
937 vcell = gnc_table_get_virtual_cell (table, vcell_loc);
938 if (vcell == NULL)
939 return NULL;
940
941 return vcell->vcell_data;
942}
gpointer vcell_data
Array of physical cells.

◆ gnc_table_get_virtual_cell()

VirtualCell * gnc_table_get_virtual_cell ( Table *  table,
VirtualCellLocation  vcell_loc 
)

returns the virtual cell associated with a particular virtual location.

If the location is out of bounds, NULL is * returned.

Definition at line 227 of file table-allgui.c.

228{
229 if (table == NULL)
230 return NULL;
231
232 return g_table_index (table->virt_cells,
233 vcell_loc.virt_row, vcell_loc.virt_col);
234}
gpointer g_table_index(GTable *gtable, int row, int col)
Return the element at the given row and column.
Definition gtable.c:84

◆ gnc_table_init_gui()

void gnc_table_init_gui ( Table *  table)

UI-specific functions.

Initialize the GUI from a table

Definition at line 173 of file table-gnome.c.

174{
175 table->gui_handlers.redraw_help = table_ui_redraw_cb;
176 table->gui_handlers.destroy = table_destroy_cb;
177 table->gui_handlers.default_direct_update = table_default_direct_update;
178}

◆ gnc_table_is_popup()

gboolean gnc_table_is_popup ( Table *  table,
VirtualLocation  virt_loc 
)

Definition at line 424 of file table-allgui.c.

425{
426 BasicCell *cell;
427
428 cell = gnc_table_get_cell (table, virt_loc);
429 if (!cell)
430 return FALSE;
431
432 return cell->is_popup;
433}

◆ gnc_table_layout_add_cell()

void gnc_table_layout_add_cell ( TableLayout *  layout,
BasicCell *  cell 
)

Definition at line 98 of file table-layout.c.

100{
101 GList *node;
102
103 g_return_if_fail (layout != NULL);
104 g_return_if_fail (cell != NULL);
105
106 for (node = layout->cells; node; node = node->next)
107 {
108 BasicCell *list_cell = node->data;
109
110 if (gnc_basic_cell_has_name (list_cell, cell->cell_name))
111 {
112 if (list_cell == cell)
113 return;
114
115 gnc_basic_cell_destroy (list_cell);
116 break;
117 }
118 }
119
120 if (!node)
121 layout->cells = g_list_append (layout->cells, cell);
122 else
123 node->data = cell;
124}

◆ gnc_table_layout_add_cursor()

void gnc_table_layout_add_cursor ( TableLayout *  layout,
CellBlock cursor 
)

Definition at line 186 of file table-layout.c.

188{
189 GList *node;
190
191 g_return_if_fail (layout != NULL);
192 g_return_if_fail (cursor != NULL);
193
194 if (g_list_find (layout->cursors, cursor))
195 return;
196
197 for (node = layout->cursors; node; node = node->next)
198 {
199 CellBlock *list_cursor = node->data;
200
201 if (strcmp (list_cursor->cursor_name, cursor->cursor_name) == 0)
202 {
203 layout->cursors = g_list_remove (layout->cursors, list_cursor);
204 gnc_cellblock_destroy (list_cursor);
205 break;
206 }
207 }
208
209 layout->cursors = g_list_append (layout->cursors, cursor);
210}
void gnc_cellblock_destroy(CellBlock *cellblock)
Delete a CellBlock and its Cells.
Definition cellblock.c:78

◆ gnc_table_layout_destroy()

void gnc_table_layout_destroy ( TableLayout *  layout)

Definition at line 69 of file table-layout.c.

70{
71 GList *node;
72
73 if (!layout)
74 return;
75
76 for (node = layout->cells; node; node = node->next)
77 {
78 BasicCell *cell = node->data;
79
80 gnc_basic_cell_destroy (cell);
81 }
82 g_list_free (layout->cells);
83 layout->cells = NULL;
84
85 for (node = layout->cursors; node; node = node->next)
86 {
87 CellBlock *cursor = node->data;
88
89 gnc_cellblock_destroy (cursor);
90 }
91 g_list_free (layout->cursors);
92 layout->cursors = NULL;
93
94 g_free (layout);
95}

◆ gnc_table_layout_get_cell()

BasicCell * gnc_table_layout_get_cell ( TableLayout *  layout,
const char *  cell_name 
)

Definition at line 127 of file table-layout.c.

128{
129 GList *node;
130
131 g_return_val_if_fail (layout != NULL, NULL);
132
133 for (node = layout->cells; node; node = node->next)
134 {
135 BasicCell *list_cell = node->data;
136
137 if (gnc_basic_cell_has_name (list_cell, cell_name))
138 return list_cell;
139 }
140
141 return NULL;
142}

◆ gnc_table_layout_get_cell_changed()

gboolean gnc_table_layout_get_cell_changed ( TableLayout *  layout,
const char *  cell_name,
gboolean  include_conditional 
)

Definition at line 158 of file table-layout.c.

161{
162 BasicCell *cell;
163
164 g_return_val_if_fail (layout != NULL, FALSE);
165
166 cell = gnc_table_layout_get_cell (layout, cell_name);
167 if (!cell) return FALSE;
168
169 if (!include_conditional)
170 return gnc_basic_cell_get_changed (cell);
171 else
172 return (gnc_basic_cell_get_changed (cell) ||
173 gnc_basic_cell_get_conditionally_changed (cell));
174}

◆ gnc_table_layout_get_cell_value()

const char * gnc_table_layout_get_cell_value ( TableLayout *  layout,
const char *  cell_name 
)

Definition at line 145 of file table-layout.c.

146{
147 BasicCell *cell;
148
149 g_return_val_if_fail (layout != NULL, NULL);
150
151 cell = gnc_table_layout_get_cell (layout, cell_name);
152 if (!cell) return NULL;
153
154 return gnc_basic_cell_get_value (cell);
155}

◆ gnc_table_layout_get_cells()

GList * gnc_table_layout_get_cells ( TableLayout *  layout)

Definition at line 177 of file table-layout.c.

178{
179 if (!layout)
180 return NULL;
181
182 return layout->cells;
183}

◆ gnc_table_layout_get_cursor()

CellBlock * gnc_table_layout_get_cursor ( TableLayout *  layout,
const char *  cursor_name 
)

Definition at line 213 of file table-layout.c.

215{
216 GList *node;
217
218 g_return_val_if_fail (layout != NULL, NULL);
219
220 if (!cursor_name)
221 return NULL;
222
223 for (node = layout->cursors; node; node = node->next)
224 {
225 CellBlock *cursor = node->data;
226
227 if (strcmp (cursor_name, cursor->cursor_name) == 0)
228 return cursor;
229 }
230
231 return NULL;
232}

◆ gnc_table_layout_get_cursors()

GList * gnc_table_layout_get_cursors ( TableLayout *  layout)

Definition at line 235 of file table-layout.c.

236{
237 g_return_val_if_fail (layout != NULL, NULL);
238 return layout->cursors;
239}

◆ gnc_table_layout_new()

TableLayout * gnc_table_layout_new ( void  )

API Declarations.

Definition at line 59 of file table-layout.c.

60{
61 TableLayout *layout;
62
63 layout = g_new0 (TableLayout, 1);
64
65 return layout;
66}

◆ gnc_table_layout_restore_cursor()

void gnc_table_layout_restore_cursor ( TableLayout *  layout,
CellBlock cursor,
CursorBuffer *  buffer 
)

Definition at line 415 of file table-layout.c.

418{
419 GList *node;
420
421 if (!layout || !cursor || !buffer)
422 return;
423
424 for (node = buffer->cell_buffers; node; node = node->next)
425 {
426 CellBuffer *cb = node->data;
427 BasicCell *cell;
428
429 cell = gnc_table_layout_get_cell (layout, cb->cell_name);
430
431 restore_cell (cell, cb, cursor);
432 }
433}

◆ gnc_table_layout_save_cursor()

void gnc_table_layout_save_cursor ( TableLayout *  layout,
CellBlock cursor,
CursorBuffer *  buffer 
)

Definition at line 357 of file table-layout.c.

360{
361 GList *node;
362
363 if (!layout || !cursor || !buffer)
364 return;
365
366 gnc_cursor_buffer_clear (buffer);
367
368 for (node = layout->cells; node; node = node->next)
369 {
370 BasicCell *list_cell = node->data;
371 CellBuffer *cb;
372
373 if (!gnc_basic_cell_get_changed (list_cell) &&
374 !gnc_basic_cell_get_conditionally_changed (list_cell))
375 continue;
376
377 cb = save_cell (list_cell);
378
379 buffer->cell_buffers = g_list_prepend (buffer->cell_buffers, cb);
380 }
381}

◆ gnc_table_layout_set_cell()

void gnc_table_layout_set_cell ( TableLayout *  layout,
CellBlock cursor,
const char *  cell_name,
int  row,
int  col 
)

Definition at line 250 of file table-layout.c.

254{
255 CellBlock *header;
256 BasicCell *cell;
257
258 g_return_if_fail (layout != NULL);
259 g_return_if_fail (layout->primary_cursor != NULL);
260 g_return_if_fail (cursor != NULL);
261 g_return_if_fail (cell_name != NULL);
262 g_return_if_fail (row >= 0);
263 g_return_if_fail (col >= 0);
264 g_return_if_fail (row < cursor->num_rows);
265 g_return_if_fail (col < cursor->num_cols);
266
267 header = gnc_table_layout_get_cursor (layout, CURSOR_HEADER);
268 cell = gnc_table_layout_get_cell (layout, cell_name);
269
270 g_return_if_fail (header != NULL);
271 g_return_if_fail (cell != NULL);
272
273 cursor->start_col = MIN (cursor->start_col, col);
274 cursor->stop_col = MAX (cursor->stop_col, col);
275
276 header->start_col = MIN (header->start_col, col);
277 header->stop_col = MAX (header->stop_col, col);
278
279 gnc_cellblock_set_cell (cursor, row, col, cell);
280
281 if (cursor == layout->primary_cursor)
282 gnc_cellblock_set_cell (header, row, col, cell);
283}
void gnc_cellblock_set_cell(CellBlock *cellblock, int row, int col, BasicCell *cell)
Add a cell to the CellBlock at the specified coordinates.
Definition cellblock.c:92
#define CURSOR_HEADER
Standard Cursor Names.

◆ gnc_table_layout_set_primary_cursor()

void gnc_table_layout_set_primary_cursor ( TableLayout *  layout,
CellBlock cursor 
)

Definition at line 242 of file table-layout.c.

244{
245 g_return_if_fail (layout != NULL);
246 layout->primary_cursor = cursor;
247}

◆ gnc_table_leave_update()

void gnc_table_leave_update ( Table *  table,
VirtualLocation  virt_loc 
)

Definition at line 1131 of file table-allgui.c.

1132{
1133 CellLeaveFunc leave;
1134 BasicCell *cell;
1135 CellBlock *cb;
1136 int cell_row;
1137 int cell_col;
1138
1139 if (table == NULL)
1140 return;
1141
1142 cb = table->current_cursor;
1143
1144 cell_row = virt_loc.phys_row_offset;
1145 cell_col = virt_loc.phys_col_offset;
1146
1147 ENTER("proposed (%d %d) rel(%d %d)\n",
1148 virt_loc.vcell_loc.virt_row,
1149 virt_loc.vcell_loc.virt_col,
1150 cell_row, cell_col);
1151
1152 /* OK, if there is a callback for this cell, call it */
1153 cell = gnc_cellblock_get_cell (cb, cell_row, cell_col);
1154 if (!cell)
1155 {
1156 LEAVE("no cell");
1157 return;
1158 }
1159
1160 leave = cell->leave_cell;
1161
1162 if (leave)
1163 {
1164 char * old_value;
1165
1166 old_value = g_strdup (cell->value);
1167
1168 leave (cell);
1169
1170 if (g_strcmp0 (old_value, cell->value) != 0)
1171 {
1172 if (gnc_table_model_read_only (table->model))
1173 {
1174 PWARN ("leave update changed read-only table");
1175 }
1176
1177 cell->changed = TRUE;
1178 }
1179
1180 g_free (old_value);
1181 }
1182 LEAVE("");
1183}

◆ gnc_table_model_destroy()

void gnc_table_model_destroy ( TableModel model)

Definition at line 154 of file table-model.c.

155{
156 if (!model) return;
157
158 gnc_table_model_handler_hash_destroy (model->entry_handlers);
159 model->entry_handlers = NULL;
160
161 gnc_table_model_handler_hash_destroy (model->label_handlers);
162 model->label_handlers = NULL;
163
164 gnc_table_model_handler_hash_destroy (model->tooltip_handlers);
165 model->tooltip_handlers = NULL;
166
167 gnc_table_model_handler_hash_destroy (model->help_handlers);
168 model->help_handlers = NULL;
169
170 gnc_table_model_handler_hash_destroy (model->io_flags_handlers);
171 model->io_flags_handlers = NULL;
172
173 gnc_table_model_handler_hash_destroy (model->cell_color_handlers);
174 model->cell_color_handlers = NULL;
175
176 gnc_table_model_handler_hash_destroy (model->cell_border_handlers);
177 model->cell_border_handlers = NULL;
178
179 gnc_table_model_handler_hash_destroy (model->confirm_handlers);
180 model->confirm_handlers = NULL;
181
182 gnc_table_model_handler_hash_destroy (model->save_handlers);
183 model->save_handlers = NULL;
184
185 g_free (model);
186}

◆ gnc_table_model_get_cell_border_handler()

TableGetCellBorderHandler gnc_table_model_get_cell_border_handler ( TableModel model,
const char *  cell_name 
)

Definition at line 442 of file table-model.c.

444{
445 g_return_val_if_fail (model != NULL, NULL);
446
447 return gnc_table_model_handler_hash_lookup (model->cell_border_handlers,
448 cell_name);
449}

◆ gnc_table_model_get_cell_color_handler()

TableGetCellColorHandler gnc_table_model_get_cell_color_handler ( TableModel model,
const char *  cell_name 
)

Definition at line 406 of file table-model.c.

408{
409 g_return_val_if_fail (model != NULL, NULL);
410
411 return gnc_table_model_handler_hash_lookup (model->cell_color_handlers,
412 cell_name);
413}

◆ gnc_table_model_get_confirm_handler()

TableConfirmHandler gnc_table_model_get_confirm_handler ( TableModel model,
const char *  cell_name 
)

Definition at line 478 of file table-model.c.

480{
481 g_return_val_if_fail (model != NULL, NULL);
482
483 return gnc_table_model_handler_hash_lookup (model->confirm_handlers,
484 cell_name);
485}

◆ gnc_table_model_get_entry_handler()

TableGetEntryHandler gnc_table_model_get_entry_handler ( TableModel model,
const char *  cell_name 
)

Definition at line 237 of file table-model.c.

238{
239 g_return_val_if_fail (model != NULL, NULL);
240
241 return gnc_table_model_handler_hash_lookup (model->entry_handlers,
242 cell_name);
243}

◆ gnc_table_model_get_help_handler()

TableGetHelpHandler gnc_table_model_get_help_handler ( TableModel model,
const char *  cell_name 
)

Definition at line 336 of file table-model.c.

337{
338 g_return_val_if_fail (model != NULL, NULL);
339
340 return gnc_table_model_handler_hash_lookup (model->help_handlers, cell_name);
341}

◆ gnc_table_model_get_io_flags_handler()

TableGetCellIOFlagsHandler gnc_table_model_get_io_flags_handler ( TableModel model,
const char *  cell_name 
)

Definition at line 370 of file table-model.c.

372{
373 g_return_val_if_fail (model != NULL, NULL);
374
375 return gnc_table_model_handler_hash_lookup (model->io_flags_handlers,
376 cell_name);
377}

◆ gnc_table_model_get_label_handler()

TableGetLabelHandler gnc_table_model_get_label_handler ( TableModel model,
const char *  cell_name 
)

Definition at line 270 of file table-model.c.

271{
272 g_return_val_if_fail (model != NULL, NULL);
273
274 return gnc_table_model_handler_hash_lookup (model->label_handlers,
275 cell_name);
276}

◆ gnc_table_model_get_post_save_handler()

TableSaveHandler gnc_table_model_get_post_save_handler ( TableModel model)

Definition at line 541 of file table-model.c.

543{
544 g_return_val_if_fail (model != NULL, NULL);
545
546 return model->post_save_handler;
547}

◆ gnc_table_model_get_pre_save_handler()

TableSaveHandler gnc_table_model_get_pre_save_handler ( TableModel model)

Definition at line 532 of file table-model.c.

534{
535 g_return_val_if_fail (model != NULL, NULL);
536
537 return model->pre_save_handler;
538}

◆ gnc_table_model_get_save_handler()

TableSaveCellHandler gnc_table_model_get_save_handler ( TableModel model,
const char *  cell_name 
)

Definition at line 522 of file table-model.c.

525{
526 g_return_val_if_fail (model != NULL, NULL);
527
528 return gnc_table_model_handler_hash_lookup (model->save_handlers, cell_name);
529}

◆ gnc_table_model_get_tooltip_handler()

TableGetTooltipHandler gnc_table_model_get_tooltip_handler ( TableModel model,
const char *  cell_name 
)

Definition at line 303 of file table-model.c.

304{
305 g_return_val_if_fail (model != NULL, NULL);
306
307 return gnc_table_model_handler_hash_lookup (model->tooltip_handlers,
308 cell_name);
309}

◆ gnc_table_model_new()

TableModel * gnc_table_model_new ( void  )

Definition at line 127 of file table-model.c.

128{
129 TableModel *model;
130
131 model = g_new0 (TableModel, 1);
132
133 model->entry_handlers = gnc_table_model_handler_hash_new ();
134 model->label_handlers = gnc_table_model_handler_hash_new ();
135 model->help_handlers = gnc_table_model_handler_hash_new ();
136 model->tooltip_handlers = gnc_table_model_handler_hash_new ();
137 model->io_flags_handlers = gnc_table_model_handler_hash_new ();
138 model->cell_color_handlers = gnc_table_model_handler_hash_new ();
139 model->cell_border_handlers = gnc_table_model_handler_hash_new ();
140 model->confirm_handlers = gnc_table_model_handler_hash_new ();
141 model->save_handlers = gnc_table_model_handler_hash_new ();
142
143 model->read_only = FALSE;
144 model->dividing_row_upper = -1;
145 model->dividing_row = -1;
146 model->dividing_row_lower = -1;
147
148 model->blank_trans_row = -1;
149
150 return model;
151}

◆ gnc_table_model_read_only()

gboolean gnc_table_model_read_only ( TableModel model)

Definition at line 197 of file table-model.c.

198{
199 g_return_val_if_fail (model, FALSE);
200
201 return model->read_only;
202}

◆ gnc_table_model_set_cell_border_handler()

void gnc_table_model_set_cell_border_handler ( TableModel model,
TableGetCellBorderHandler  io_flags_handler,
const char *  cell_name 
)

Definition at line 416 of file table-model.c.

420{
421 g_return_if_fail (model != NULL);
422 g_return_if_fail (cell_name != NULL);
423
424 gnc_table_model_handler_hash_insert (model->cell_border_handlers,
425 cell_name,
426 cell_border_handler);
427}

◆ gnc_table_model_set_cell_color_handler()

void gnc_table_model_set_cell_color_handler ( TableModel model,
TableGetCellColorHandler  io_flags_handler,
const char *  cell_name 
)

Definition at line 380 of file table-model.c.

384{
385 g_return_if_fail (model != NULL);
386 g_return_if_fail (cell_name != NULL);
387
388 gnc_table_model_handler_hash_insert (model->cell_color_handlers,
389 cell_name,
390 color_handler);
391}

◆ gnc_table_model_set_confirm_handler()

void gnc_table_model_set_confirm_handler ( TableModel model,
TableConfirmHandler  io_flags_handler,
const char *  cell_name 
)

Definition at line 452 of file table-model.c.

456{
457 g_return_if_fail (model != NULL);
458 g_return_if_fail (cell_name != NULL);
459
460 gnc_table_model_handler_hash_insert (model->confirm_handlers,
461 cell_name,
462 confirm_handler);
463}

◆ gnc_table_model_set_default_cell_border_handler()

void gnc_table_model_set_default_cell_border_handler ( TableModel model,
TableGetCellBorderHandler  io_flags_handler 
)

Definition at line 430 of file table-model.c.

433{
434 g_return_if_fail (model != NULL);
435
436 gnc_table_model_handler_hash_insert (model->cell_border_handlers,
437 DEFAULT_HANDLER,
438 cell_border_handler);
439}

◆ gnc_table_model_set_default_cell_color_handler()

void gnc_table_model_set_default_cell_color_handler ( TableModel model,
TableGetCellColorHandler  io_flags_handler 
)

Definition at line 394 of file table-model.c.

397{
398 g_return_if_fail (model != NULL);
399
400 gnc_table_model_handler_hash_insert (model->cell_color_handlers,
401 DEFAULT_HANDLER,
402 color_handler);
403}

◆ gnc_table_model_set_default_confirm_handler()

void gnc_table_model_set_default_confirm_handler ( TableModel model,
TableConfirmHandler  io_flags_handler 
)

Definition at line 466 of file table-model.c.

469{
470 g_return_if_fail (model != NULL);
471
472 gnc_table_model_handler_hash_insert (model->confirm_handlers,
473 DEFAULT_HANDLER,
474 confirm_handler);
475}

◆ gnc_table_model_set_default_entry_handler()

void gnc_table_model_set_default_entry_handler ( TableModel model,
TableGetEntryHandler  entry_handler 
)

Definition at line 226 of file table-model.c.

228{
229 g_return_if_fail (model != NULL);
230
231 gnc_table_model_handler_hash_insert (model->entry_handlers,
232 DEFAULT_HANDLER,
233 entry_handler);
234}

◆ gnc_table_model_set_default_help_handler()

void gnc_table_model_set_default_help_handler ( TableModel model,
TableGetHelpHandler  help_handler 
)

Definition at line 325 of file table-model.c.

327{
328 g_return_if_fail (model != NULL);
329
330 gnc_table_model_handler_hash_insert (model->help_handlers,
331 DEFAULT_HANDLER,
332 help_handler);
333}

◆ gnc_table_model_set_default_io_flags_handler()

void gnc_table_model_set_default_io_flags_handler ( TableModel model,
TableGetCellIOFlagsHandler  io_flags_handler 
)

Definition at line 358 of file table-model.c.

361{
362 g_return_if_fail (model != NULL);
363
364 gnc_table_model_handler_hash_insert (model->io_flags_handlers,
365 DEFAULT_HANDLER,
366 io_flags_handler);
367}

◆ gnc_table_model_set_default_label_handler()

void gnc_table_model_set_default_label_handler ( TableModel model,
TableGetLabelHandler  label_handler 
)

Definition at line 259 of file table-model.c.

261{
262 g_return_if_fail (model != NULL);
263
264 gnc_table_model_handler_hash_insert (model->label_handlers,
265 DEFAULT_HANDLER,
266 label_handler);
267}

◆ gnc_table_model_set_default_tooltip_handler()

void gnc_table_model_set_default_tooltip_handler ( TableModel model,
TableGetTooltipHandler  tooltip_handler 
)

Definition at line 292 of file table-model.c.

294{
295 g_return_if_fail (model != NULL);
296
297 gnc_table_model_handler_hash_insert (model->tooltip_handlers,
298 DEFAULT_HANDLER,
299 tooltip_handler);
300}

◆ gnc_table_model_set_entry_handler()

void gnc_table_model_set_entry_handler ( TableModel model,
TableGetEntryHandler  entry_handler,
const char *  cell_name 
)

Definition at line 213 of file table-model.c.

216{
217 g_return_if_fail (model != NULL);
218 g_return_if_fail (cell_name != NULL);
219
220 gnc_table_model_handler_hash_insert (model->entry_handlers,
221 cell_name,
222 entry_handler);
223}

◆ gnc_table_model_set_help_handler()

void gnc_table_model_set_help_handler ( TableModel model,
TableGetHelpHandler  help_handler,
const char *  cell_name 
)

Definition at line 312 of file table-model.c.

315{
316 g_return_if_fail (model != NULL);
317 g_return_if_fail (cell_name != NULL);
318
319 gnc_table_model_handler_hash_insert (model->help_handlers,
320 cell_name,
321 help_handler);
322}

◆ gnc_table_model_set_io_flags_handler()

void gnc_table_model_set_io_flags_handler ( TableModel model,
TableGetCellIOFlagsHandler  io_flags_handler,
const char *  cell_name 
)

Definition at line 344 of file table-model.c.

348{
349 g_return_if_fail (model != NULL);
350 g_return_if_fail (cell_name != NULL);
351
352 gnc_table_model_handler_hash_insert (model->io_flags_handlers,
353 cell_name,
354 io_flags_handler);
355}

◆ gnc_table_model_set_label_handler()

void gnc_table_model_set_label_handler ( TableModel model,
TableGetLabelHandler  label_handler,
const char *  cell_name 
)

Definition at line 246 of file table-model.c.

249{
250 g_return_if_fail (model != NULL);
251 g_return_if_fail (cell_name != NULL);
252
253 gnc_table_model_handler_hash_insert (model->label_handlers,
254 cell_name,
255 label_handler);
256}

◆ gnc_table_model_set_post_save_handler()

void gnc_table_model_set_post_save_handler ( TableModel model,
TableSaveHandler  save_handler 
)

Definition at line 512 of file table-model.c.

515{
516 g_return_if_fail (model != NULL);
517
518 model->post_save_handler = save_handler;
519}

◆ gnc_table_model_set_pre_save_handler()

void gnc_table_model_set_pre_save_handler ( TableModel model,
TableSaveHandler  save_handler 
)

Definition at line 502 of file table-model.c.

505{
506 g_return_if_fail (model != NULL);
507
508 model->pre_save_handler = save_handler;
509}

◆ gnc_table_model_set_read_only()

void gnc_table_model_set_read_only ( TableModel model,
gboolean  read_only 
)

Definition at line 189 of file table-model.c.

190{
191 g_return_if_fail (model);
192
193 model->read_only = read_only;
194}

◆ gnc_table_model_set_reverse_sort()

void gnc_table_model_set_reverse_sort ( TableModel model,
gboolean  read_only 
)

Definition at line 205 of file table-model.c.

207{
208 g_return_if_fail (model);
209 model->reverse_sort = reverse_sort;
210}

◆ gnc_table_model_set_save_handler()

void gnc_table_model_set_save_handler ( TableModel model,
TableSaveCellHandler  save_handler,
const char *  cell_name 
)

Definition at line 488 of file table-model.c.

492{
493 g_return_if_fail (model != NULL);
494 g_return_if_fail (cell_name != NULL);
495
496 gnc_table_model_handler_hash_insert (model->save_handlers,
497 cell_name,
498 save_handler);
499}

◆ gnc_table_model_set_tooltip_handler()

void gnc_table_model_set_tooltip_handler ( TableModel model,
TableGetTooltipHandler  tooltip_handler,
const char *  cell_name 
)

Definition at line 279 of file table-model.c.

282{
283 g_return_if_fail (model != NULL);
284 g_return_if_fail (cell_name != NULL);
285
286 gnc_table_model_handler_hash_insert (model->tooltip_handlers,
287 cell_name,
288 tooltip_handler);
289}

◆ gnc_table_modify_update()

const char * gnc_table_modify_update ( Table *  table,
VirtualLocation  virt_loc,
const char *  change,
int  change_len,
const char *  newval,
int  newval_len,
int *  cursor_position,
int *  start_selection,
int *  end_selection,
gboolean *  cancelled 
)

Definition at line 1207 of file table-allgui.c.

1217{
1218 gboolean changed = FALSE;
1219 CellModifyVerifyFunc mv;
1220 BasicCell *cell;
1221 CellBlock *cb;
1222 int cell_row;
1223 int cell_col;
1224 char * old_value;
1225
1226 g_return_val_if_fail (table, NULL);
1227 g_return_val_if_fail (table->model, NULL);
1228
1229 if (gnc_table_model_read_only (table->model))
1230 {
1231 PWARN ("change to read-only table");
1232 return NULL;
1233 }
1234
1235 cb = table->current_cursor;
1236
1237 cell_row = virt_loc.phys_row_offset;
1238 cell_col = virt_loc.phys_col_offset;
1239
1240 ENTER ("");
1241
1242 if (!gnc_table_confirm_change (table, virt_loc))
1243 {
1244 if (cancelled)
1245 *cancelled = TRUE;
1246
1247 LEAVE("change cancelled");
1248 return NULL;
1249 }
1250
1251 if (cancelled)
1252 *cancelled = FALSE;
1253
1254 /* OK, if there is a callback for this cell, call it */
1255 cell = gnc_cellblock_get_cell (cb, cell_row, cell_col);
1256 if (!cell)
1257 {
1258 LEAVE("no cell");
1259 return NULL;
1260 }
1261
1262 mv = cell->modify_verify;
1263
1264 old_value = g_strdup (cell->value);
1265
1266 if (mv)
1267 {
1268 mv (cell, change, change_len, newval, newval_len,
1269 cursor_position, start_selection, end_selection);
1270 }
1271 else
1272 {
1273 gnc_basic_cell_set_value (cell, newval);
1274 }
1275
1276 if (g_strcmp0 (old_value, cell->value) != 0)
1277 {
1278 changed = TRUE;
1279 cell->changed = TRUE;
1280 }
1281
1282 g_free (old_value);
1283
1284 if (table->gui_handlers.redraw_help)
1285 table->gui_handlers.redraw_help (table);
1286
1287 LEAVE ("change %d %d (relrow=%d relcol=%d) val=%s\n",
1288 virt_loc.vcell_loc.virt_row,
1289 virt_loc.vcell_loc.virt_col,
1290 cell_row, cell_col,
1291 cell->value ? cell->value : "(null)");
1292
1293 if (changed)
1294 return cell->value;
1295 else
1296 return NULL;
1297}

◆ gnc_table_move_cursor()

void gnc_table_move_cursor ( Table *  table,
VirtualLocation  virt_loc 
)

will move the cursor (but not the cursor GUI) to the indicated location.

This function is useful when loading the table from the cursor: data can be loaded into the cursor, then committed to the table, all without the annoying screen flashing associated with GUI redraw.

Definition at line 877 of file table-allgui.c.

878{
879 if (!table) return;
880
881 gnc_table_move_cursor_internal (table, new_virt_loc, FALSE);
882}

◆ gnc_table_move_cursor_gui()

void gnc_table_move_cursor_gui ( Table *  table,
VirtualLocation  virt_loc 
)

will move the cursor and its GUI to the indicated location.

Through a series of callbacks, all GUI elements get repositioned.

Definition at line 886 of file table-allgui.c.

887{
888 if (!table) return;
889
890 gnc_table_move_cursor_internal (table, new_virt_loc, TRUE);
891}

◆ gnc_table_move_tab()

gboolean gnc_table_move_tab ( Table *  table,
VirtualLocation *  virt_loc,
gboolean  move_right 
)

Definition at line 1530 of file table-allgui.c.

1533{
1534 VirtualCell *vcell;
1535 VirtualLocation vloc;
1536 BasicCell *cell;
1537
1538 if ((table == NULL) || (virt_loc == NULL))
1539 return FALSE;
1540
1541 vloc = *virt_loc;
1542
1543 vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
1544 if ((vcell == NULL) || (vcell->cellblock == NULL) || !vcell->visible)
1545 return FALSE;
1546
1547 while (1)
1548 {
1549 CellIOFlags io_flags;
1550
1551 if (move_right)
1552 {
1553 vloc.phys_col_offset++;
1554
1555 if (vloc.phys_col_offset >= vcell->cellblock->num_cols)
1556 {
1557 if (!gnc_table_move_vertical_position (table, &vloc, 1))
1558 return FALSE;
1559
1560 vloc.phys_col_offset = 0;
1561 }
1562 }
1563 else
1564 {
1565 vloc.phys_col_offset--;
1566
1567 if (vloc.phys_col_offset < 0)
1568 {
1569 if (!gnc_table_move_vertical_position (table, &vloc, -1))
1570 return FALSE;
1571
1572 vloc.phys_col_offset = vcell->cellblock->num_cols - 1;
1573 }
1574 }
1575
1576 vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
1577 if ((vcell == NULL) || (vcell->cellblock == NULL) || !vcell->visible)
1578 return FALSE;
1579
1580 cell = gnc_cellblock_get_cell (vcell->cellblock,
1581 vloc.phys_row_offset,
1582 vloc.phys_col_offset);
1583 if (!cell)
1584 continue;
1585
1586 io_flags = gnc_table_get_io_flags (table, vloc);
1587
1588 if (!(io_flags & XACC_CELL_ALLOW_INPUT))
1589 continue;
1590
1591 if (io_flags & XACC_CELL_ALLOW_EXACT_ONLY)
1592 continue;
1593
1594 break;
1595 }
1596
1597 {
1598 gboolean changed = !virt_loc_equal (vloc, *virt_loc);
1599
1600 *virt_loc = vloc;
1601
1602 return changed;
1603 }
1604}
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.

◆ gnc_table_move_vertical_position()

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.

Virtual cells that are not visible are skipped over.

Parameters
tableThe table
virt_locThe virtual location to start from. If the move succeeds, it is updated with the new location.
phys_row_offsetThe number of physical rows to move. A positive number moves down and a negative number moves up.
Returns
TRUE if the location changed, FALSE otherwise

Definition at line 1607 of file table-allgui.c.

1610{
1611 VirtualLocation vloc;
1612 VirtualCell *vcell;
1613 gint last_visible_row;
1614
1615 if ((table == NULL) || (virt_loc == NULL))
1616 return FALSE;
1617
1618 vloc = *virt_loc;
1619 last_visible_row = vloc.vcell_loc.virt_row;
1620
1621 vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
1622 if ((vcell == NULL) || (vcell->cellblock == NULL))
1623 return FALSE;
1624
1625 while (phys_row_offset != 0)
1626 {
1627 /* going up */
1628 if (phys_row_offset < 0)
1629 {
1630 phys_row_offset++;
1631
1632 /* room left in the current cursor */
1633 if (vloc.phys_row_offset > 0)
1634 {
1635 vloc.phys_row_offset--;
1636 continue;
1637 }
1638
1639 /* end of the line */
1640 if (vloc.vcell_loc.virt_row == 1)
1641 break;
1642
1643 do
1644 {
1645 vloc.vcell_loc.virt_row--;
1646
1647 vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
1648 }
1649 while (vcell && vcell->cellblock && !vcell->visible);
1650
1651 if (!vcell || !vcell->cellblock)
1652 break;
1653
1654 last_visible_row = vloc.vcell_loc.virt_row;
1655 vloc.phys_row_offset = vcell->cellblock->num_rows - 1;
1656 }
1657 /* going down */
1658 else
1659 {
1660 phys_row_offset--;
1661
1662 /* room left in the current cursor */
1663 if (vloc.phys_row_offset < (vcell->cellblock->num_rows - 1))
1664 {
1665 vloc.phys_row_offset++;
1666 continue;
1667 }
1668
1669 /* end of the line */
1670 if (vloc.vcell_loc.virt_row == (table->num_virt_rows - 1))
1671 break;
1672
1673 do
1674 {
1675 vloc.vcell_loc.virt_row++;
1676
1677 vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
1678 }
1679 while (vcell && vcell->cellblock && !vcell->visible);
1680
1681 if (!vcell || !vcell->cellblock)
1682 break;
1683
1684 last_visible_row = vloc.vcell_loc.virt_row;
1685 vloc.phys_row_offset = 0;
1686 }
1687 }
1688
1689 vloc.vcell_loc.virt_row = last_visible_row;
1690
1691 {
1692 gboolean changed = !virt_loc_equal (vloc, *virt_loc);
1693
1694 *virt_loc = vloc;
1695
1696 return changed;
1697 }
1698}

◆ gnc_table_new()

Table * gnc_table_new ( TableLayout *  layout,
TableModel model,
TableControl control 
)

Definition at line 76 of file table-allgui.c.

77{
78 Table *table;
79
80 g_return_val_if_fail (layout != NULL, NULL);
81 g_return_val_if_fail (model != NULL, NULL);
82 g_return_val_if_fail (control != NULL, NULL);
83
84 table = g_new0 (Table, 1);
85
86 table->layout = layout;
87 table->model = model;
88 table->control = control;
89
90 table->gui_handlers = default_gui_handlers;
91
92 gnc_table_init (table);
93
94 table->virt_cells = g_table_new (sizeof (VirtualCell),
95 gnc_virtual_cell_construct,
96 gnc_virtual_cell_destroy, table);
97
98 return table;
99}
GTable * g_table_new(guint entry_size, g_table_entry_constructor constructor, g_table_entry_destroyer destroyer, gpointer user_data)
Create a new table with the given entry constructor and destroyer.
Definition gtable.c:44

◆ gnc_table_realize_gui()

void gnc_table_realize_gui ( Table *  table)

Definition at line 949 of file table-allgui.c.

950{
951 GList *cells;
952 GList *node;
953
954 if (!table) return;
955 if (!table->ui_data) return;
956
957 cells = gnc_table_layout_get_cells (table->layout);
958
959 for (node = cells; node; node = node->next)
960 {
961 BasicCell *cell = node->data;
962
963 if (cell->gui_realize)
964 cell->gui_realize (cell, table->ui_data);
965 }
966}

◆ gnc_table_refresh_current_cursor_gui()

void gnc_table_refresh_current_cursor_gui ( Table *  table,
gboolean  do_scroll 
)

Refresh the current cursor gui.

Definition at line 994 of file table-allgui.c.

995{
996 if (!table) return;
997
998 gnc_table_refresh_cursor_gui (table, table->current_cursor_loc.vcell_loc,
999 do_scroll);
1000}
void gnc_table_refresh_cursor_gui(Table *table, VirtualCellLocation vcell_loc, gboolean do_scroll)
Refresh the cursor in the given location.

◆ gnc_table_refresh_cursor_gui()

void gnc_table_refresh_cursor_gui ( Table *  table,
VirtualCellLocation  vcell_loc,
gboolean  do_scroll 
)

Refresh the cursor in the given location.

If do_scroll is TRUE, scroll the register so the location is in view.

Definition at line 1519 of file table-allgui.c.

1522{
1523 g_return_if_fail (table != NULL);
1524 g_return_if_fail (table->gui_handlers.cursor_refresh != NULL);
1525
1526 table->gui_handlers.cursor_refresh (table, vcell_loc, do_scroll);
1527}

◆ gnc_table_refresh_gui()

void gnc_table_refresh_gui ( Table *  table,
gboolean  do_scroll 
)

Refresh the whole GUI from the table.

Definition at line 181 of file table-gnome.c.

182{
183 GnucashSheet *sheet;
184
185 if (!table)
186 return;
187 if (!table->ui_data)
188 return;
189
190 g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data));
191
192 sheet = GNUCASH_SHEET(table->ui_data);
193
194 gnucash_sheet_styles_recompile (sheet);
195 gnucash_sheet_table_load (sheet, do_scroll);
196 gnucash_sheet_redraw_all (sheet);
197}

◆ gnc_table_restore_current_cursor()

void gnc_table_restore_current_cursor ( Table *  table,
CursorBuffer *  buffer 
)

Definition at line 174 of file table-allgui.c.

176{
177 if (!table || !buffer)
178 return;
179
180 gnc_table_layout_restore_cursor (table->layout,
181 table->current_cursor, buffer);
182}

◆ gnc_table_save_cells()

void gnc_table_save_cells ( Table *  table,
gpointer  save_data 
)

Definition at line 544 of file table-allgui.c.

545{
546 TableSaveHandler save_handler;
547 GList * cells;
548 GList * node;
549
550 g_return_if_fail (table);
551
552 /* ignore any changes to read-only tables */
553 if (gnc_table_model_read_only (table->model))
554 return;
555
556 // gnc_table_leave_update (table, table->current_cursor_loc);
557
558 save_handler = gnc_table_model_get_pre_save_handler (table->model);
559 if (save_handler)
560 save_handler (save_data, table->model->handler_user_data);
561
562 cells = gnc_table_layout_get_cells (table->layout);
563 for (node = cells; node; node = node->next)
564 {
565 BasicCell * cell = node->data;
566 TableSaveCellHandler save_cell_handler;
567
568 if (!cell) continue;
569
570 if (!gnc_table_layout_get_cell_changed (table->layout,
571 cell->cell_name, TRUE))
572 continue;
573
574 save_cell_handler = gnc_table_model_get_save_handler (table->model,
575 cell->cell_name);
576 if (save_cell_handler)
577 save_cell_handler (cell, save_data, table->model->handler_user_data);
578 }
579
580 save_handler = gnc_table_model_get_post_save_handler (table->model);
581 if (save_handler)
582 save_handler (save_data, table->model->handler_user_data);
583}

◆ gnc_table_save_current_cursor()

void gnc_table_save_current_cursor ( Table *  table,
CursorBuffer *  buffer 
)

Definition at line 165 of file table-allgui.c.

166{
167 if (!table || !buffer)
168 return;
169
170 gnc_table_layout_save_cursor (table->layout, table->current_cursor, buffer);
171}

◆ gnc_table_save_state()

void gnc_table_save_state ( Table *  table,
const gchar *  state_section 
)

Implementation.

Definition at line 71 of file table-gnome.c.

72{
73 GnucashSheet *sheet;
74 GNCHeaderWidths widths;
75 GList *node;
76 gchar *key;
77 GKeyFile *state_file = gnc_state_get_current();
78
79 if (!table)
80 return;
81
82 if (table->ui_data == NULL)
83 return;
84
85 if (!gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SAVE_GEOMETRY))
86 return;
87 sheet = GNUCASH_SHEET (table->ui_data);
88
89 widths = gnc_header_widths_new ();
90
91 gnucash_sheet_get_header_widths (sheet, widths);
92
93 node = gnc_table_layout_get_cells (table->layout);
94 for (; node; node = node->next)
95 {
96 BasicCell *cell = node->data;
97 int width;
98
99 width = gnc_header_widths_get_width (widths, cell->cell_name);
100
101 /* Remember whether the column is visible */
102 key = g_strdup_printf("%s_width", cell->cell_name);
103 if ((width > 0) && (!cell->expandable))
104 {
105 g_key_file_set_integer (state_file, state_section, key, width);
106 }
107 else if (g_key_file_has_key (state_file, state_section, key, NULL))
108 g_key_file_remove_key (state_file, state_section, key, NULL);
109 g_free (key);
110 }
111 gnc_header_widths_destroy (widths);
112}
GKeyFile * gnc_state_get_current(void)
Returns a pointer to the most recently loaded state.
Definition gnc-state.c:248
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.

◆ gnc_table_set_default_gui_handlers()

void gnc_table_set_default_gui_handlers ( TableGUIHandlers gui_handlers)

Set the default gui handlers used by new tables.

Set the default gui handlers used by new tables.

Definition at line 67 of file table-allgui.c.

68{
69 if (!gui_handlers)
70 memset (&default_gui_handlers, 0, sizeof (default_gui_handlers));
71 else
72 default_gui_handlers = *gui_handlers;
73}

◆ gnc_table_set_size()

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 at line 586 of file table-allgui.c.

587{
588 /* Invalidate the current cursor position, if the array is
589 * shrinking. This must be done since the table is probably
590 * shrinking because some rows were deleted, and the cursor
591 * could be on the deleted rows. */
592 if ((virt_rows < table->num_virt_rows) ||
593 (virt_cols < table->num_virt_cols))
594 {
595 gnc_virtual_location_init (&table->current_cursor_loc);
596 table->current_cursor = NULL;
597 }
598
599 gnc_table_resize (table, virt_rows, virt_cols);
600}

◆ gnc_table_set_vcell()

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 at line 663 of file table-allgui.c.

669{
670 VirtualCell *vcell;
671
672 if ((table == NULL) || (cursor == NULL))
673 return;
674
675 if ((vcell_loc.virt_row >= table->num_virt_rows) ||
676 (vcell_loc.virt_col >= table->num_virt_cols))
677 gnc_table_resize (table,
678 MAX (table->num_virt_rows, vcell_loc.virt_row + 1),
679 MAX (table->num_virt_cols, vcell_loc.virt_col + 1));
680
681 vcell = gnc_table_get_virtual_cell (table, vcell_loc);
682 if (vcell == NULL)
683 return;
684
685 /* this cursor is the handler for this block */
686 vcell->cellblock = cursor;
687
688 /* copy the vcell user data */
689 if (table->model->cell_data_copy)
690 table->model->cell_data_copy (vcell->vcell_data, vcell_data);
691 else
692 vcell->vcell_data = (gpointer) vcell_data;
693
694 vcell->visible = visible ? 1 : 0;
695 vcell->start_primary_color = start_primary_color ? 1 : 0;
696}
unsigned int start_primary_color
visible in the GUI

◆ gnc_table_set_virt_cell_cursor()

void gnc_table_set_virt_cell_cursor ( Table *  table,
VirtualCellLocation  vcell_loc,
CellBlock cursor 
)

Set the cellblock handler for a virtual cell.

Definition at line 736 of file table-allgui.c.

739{
740 VirtualCell *vcell;
741
742 if (table == NULL)
743 return;
744
745 vcell = gnc_table_get_virtual_cell (table, vcell_loc);
746 if (vcell == NULL)
747 return;
748
749 vcell->cellblock = cursor;
750}

◆ gnc_table_set_virt_cell_data()

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 at line 699 of file table-allgui.c.

702{
703 VirtualCell *vcell;
704
705 if (table == NULL)
706 return;
707
708 vcell = gnc_table_get_virtual_cell (table, vcell_loc);
709 if (vcell == NULL)
710 return;
711
712 if (table->model->cell_data_copy)
713 table->model->cell_data_copy (vcell->vcell_data, vcell_data);
714 else
715 vcell->vcell_data = (gpointer) vcell_data;
716}

◆ gnc_table_set_virt_cell_visible()

void gnc_table_set_virt_cell_visible ( Table *  table,
VirtualCellLocation  vcell_loc,
gboolean  visible 
)

Set the visibility flag for a particular location.

Definition at line 719 of file table-allgui.c.

722{
723 VirtualCell *vcell;
724
725 if (table == NULL)
726 return;
727
728 vcell = gnc_table_get_virtual_cell (table, vcell_loc);
729 if (vcell == NULL)
730 return;
731
732 vcell->visible = visible ? 1 : 0;
733}

◆ gnc_table_show_range()

void gnc_table_show_range ( Table *  table,
VirtualCellLocation  start_loc,
VirtualCellLocation  end_loc 
)

Try to show the whole range in the register.

Definition at line 231 of file table-gnome.c.

234{
235 GnucashSheet *sheet;
236
237 if (!table || !table->ui_data)
238 return;
239
240 g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data));
241
243 return;
244
246 return;
247
248 sheet = GNUCASH_SHEET (table->ui_data);
249
250 gnucash_sheet_show_range (sheet, start_loc, end_loc);
251}
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.

◆ gnc_table_traverse_update()

gboolean gnc_table_traverse_update ( Table *  table,
VirtualLocation  virt_loc,
gncTableTraversalDir  dir,
VirtualLocation *  dest_loc 
)

Definition at line 1701 of file table-allgui.c.

1705{
1706 gboolean abort_move;
1707
1708 if ((table == NULL) || (dest_loc == NULL))
1709 return FALSE;
1710
1711 ENTER("proposed (%d %d) -> (%d %d)\n",
1712 virt_loc.vcell_loc.virt_row, virt_loc.vcell_loc.virt_row,
1713 dest_loc->vcell_loc.virt_row, dest_loc->vcell_loc.virt_col);
1714
1715 /* first, make sure our destination cell is valid. If it is out
1716 * of bounds report an error. I don't think this ever happens. */
1717 if (gnc_table_virtual_cell_out_of_bounds (table, dest_loc->vcell_loc))
1718 {
1719 PERR("destination (%d, %d) out of bounds (%d, %d)\n",
1720 dest_loc->vcell_loc.virt_row, dest_loc->vcell_loc.virt_col,
1721 table->num_virt_rows, table->num_virt_cols);
1722 LEAVE("");
1723 return TRUE;
1724 }
1725
1726 /* next, check the current row and column. If they are out of bounds
1727 * we can recover by treating the traversal as a mouse point. This can
1728 * occur whenever the register widget is resized smaller, maybe?. */
1729 if (!gnc_table_virtual_loc_valid (table, virt_loc, TRUE))
1730 {
1731 PINFO("source (%d, %d) out of bounds (%d, %d)\n",
1732 virt_loc.vcell_loc.virt_row, virt_loc.vcell_loc.virt_col,
1733 table->num_virt_rows, table->num_virt_cols);
1734
1735 dir = GNC_TABLE_TRAVERSE_POINTER;
1736 }
1737
1738 /* process forward-moving traversals */
1739 switch (dir)
1740 {
1741 case GNC_TABLE_TRAVERSE_RIGHT:
1742 case GNC_TABLE_TRAVERSE_LEFT:
1743 gnc_table_find_valid_cell_horiz(table, dest_loc, FALSE);
1744
1745 break;
1746
1747 case GNC_TABLE_TRAVERSE_UP:
1748 case GNC_TABLE_TRAVERSE_DOWN:
1749 {
1750 VirtualLocation new_loc = *dest_loc;
1751 int increment;
1752 int col_offset = 0;
1753 gboolean second_traversal = FALSE;
1754
1755 /* Keep going in the specified direction until we find a valid
1756 * row to land on, or we hit the end of the table. At the end,
1757 * turn around and go back until we find a valid row or we get
1758 * to where we started. If we still can't find anything, try
1759 * going left and right. */
1760 increment = (dir == GNC_TABLE_TRAVERSE_DOWN) ? 1 : -1;
1761
1762 while (!gnc_table_virtual_loc_valid(table, new_loc, FALSE))
1763 {
1764 if (virt_loc_equal (new_loc, virt_loc))
1765 {
1766 new_loc = *dest_loc;
1767 gnc_table_find_valid_cell_horiz(table, &new_loc, FALSE);
1768 break;
1769 }
1770
1771 if (!gnc_table_move_vertical_position (table, &new_loc, increment))
1772 {
1773 /* Special case: if there is no valid cell at all in the column
1774 * we are scanning, (both up and down directions didn't work)
1775 * attempt to do the same in the next column.
1776 * Hack alert: there is no check to see if there really is a
1777 * valid next column. However this situation so far only happens
1778 * after a pagedown/pageup key event in the SX transaction editor
1779 * which always tests the first column to start (which has no
1780 * editable cells) and in that situation there is a valid next column.
1781 */
1782 if (!second_traversal)
1783 second_traversal = TRUE;
1784 else
1785 {
1786 second_traversal = FALSE;
1787 col_offset++;
1788 }
1789 increment *= -1;
1790 new_loc = *dest_loc;
1791 new_loc.phys_col_offset = new_loc.phys_col_offset + col_offset;
1792 }
1793 }
1794
1795 *dest_loc = new_loc;
1796 }
1797
1798 if (!gnc_table_virtual_loc_valid(table, *dest_loc, FALSE))
1799 {
1800 LEAVE("");
1801 return TRUE;
1802 }
1803
1804 break;
1805
1806 case GNC_TABLE_TRAVERSE_POINTER:
1807 if (!gnc_table_find_valid_cell_horiz(table, dest_loc, TRUE))
1808 {
1809 LEAVE("");
1810 return TRUE;
1811 }
1812
1813 break;
1814
1815 default:
1816 g_return_val_if_fail (FALSE, TRUE);
1817 break;
1818 }
1819
1820 /* Call the table traverse callback for any modifications. */
1821 if (table->control->traverse)
1822 abort_move = table->control->traverse (dest_loc, dir,
1823 table->control->user_data);
1824 else
1825 abort_move = FALSE;
1826
1827 LEAVE("dest_row = %d, dest_col = %d\n",
1828 dest_loc->vcell_loc.virt_row, dest_loc->vcell_loc.virt_col);
1829
1830 return abort_move;
1831}
#define PINFO(format, args...)
Print an informational note.
Definition qoflog.h:256
#define PERR(format, args...)
Log a serious error.
Definition qoflog.h:244

◆ gnc_table_verify_cursor_position()

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 virtual location has changed, repositions the cursor and gui to the new position.

Returns true if the cell cursor was repositioned.

Definition at line 897 of file table-allgui.c.

898{
899 gboolean do_move = FALSE;
900 gboolean moved_cursor = FALSE;
901
902 if (!table) return FALSE;
903
904 /* Someone may be trying to intentionally invalidate the cursor, in
905 * which case the physical addresses could be out of bounds. For
906 * example, in order to unmap it in preparation for a reconfig.
907 * So, if the specified location is out of bounds, then the cursor
908 * MUST be moved. */
909 if (gnc_table_virtual_cell_out_of_bounds (table, virt_loc.vcell_loc))
910 do_move = TRUE;
911
912 if (!virt_cell_loc_equal (virt_loc.vcell_loc,
913 table->current_cursor_loc.vcell_loc))
914 do_move = TRUE;
915
916 if (do_move)
917 {
919 moved_cursor = TRUE;
920 }
921 else if (!virt_loc_equal (virt_loc, table->current_cursor_loc))
922 {
923 table->current_cursor_loc = virt_loc;
924 moved_cursor = TRUE;
925 }
926
927 return moved_cursor;
928}
void gnc_table_move_cursor_gui(Table *table, VirtualLocation new_virt_loc)
will move the cursor and its GUI to the indicated location.

◆ gnc_table_virtual_cell_out_of_bounds()

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 at line 207 of file table-allgui.c.

209{
210 if (!table)
211 return TRUE;
212
213 return ((vcell_loc.virt_row < 0) ||
214 (vcell_loc.virt_row >= table->num_virt_rows) ||
215 (vcell_loc.virt_col < 0) ||
216 (vcell_loc.virt_col >= table->num_virt_cols));
217}

◆ gnc_table_virtual_loc_valid()

gboolean gnc_table_virtual_loc_valid ( Table *  table,
VirtualLocation  virt_loc,
gboolean  exact_pointer 
)

Definition at line 1003 of file table-allgui.c.

1006{
1007 VirtualCell *vcell;
1008 CellIOFlags io_flags;
1009
1010 if (!table) return FALSE;
1011
1012 /* header rows cannot be modified */
1013 if (virt_loc.vcell_loc.virt_row == 0)
1014 return FALSE;
1015
1016 vcell = gnc_table_get_virtual_cell(table, virt_loc.vcell_loc);
1017 if (vcell == NULL)
1018 return FALSE;
1019
1020 if (!vcell->visible)
1021 return FALSE;
1022
1023 /* verify that offsets are valid. This may occur if the app that is
1024 * using the table has a partially initialized cursor. (probably due
1025 * to a programming error, but maybe they meant to do this). */
1026 if ((0 > virt_loc.phys_row_offset) || (0 > virt_loc.phys_col_offset))
1027 return FALSE;
1028
1029 /* check for a cell handler, but only if cell address is valid */
1030 if (vcell->cellblock == NULL) return FALSE;
1031
1032 /* if table is read-only, any cell is ok :) */
1033 if (gnc_table_model_read_only (table->model)) return TRUE;
1034
1035 io_flags = gnc_table_get_io_flags (table, virt_loc);
1036
1037 /* if the cell allows ENTER, then it is ok */
1038 if (io_flags & XACC_CELL_ALLOW_ENTER) return TRUE;
1039
1040 /* if cell is marked as output-only, you can't enter */
1041 if (0 == (XACC_CELL_ALLOW_INPUT & io_flags)) return FALSE;
1042
1043 /* if cell is pointer only and this is not an exact pointer test,
1044 * it cannot be entered. */
1045 if (!exact_pointer && ((XACC_CELL_ALLOW_EXACT_ONLY & io_flags) != 0))
1046 return FALSE;
1047
1048 return TRUE;
1049}

◆ gnc_table_virtual_location_in_header()

gboolean gnc_table_virtual_location_in_header ( Table *  table,
VirtualLocation  virt_loc 
)

Definition at line 220 of file table-allgui.c.

222{
223 return (virt_loc.vcell_loc.virt_row == 0);
224}

◆ gnc_table_wrap_verify_cursor_position()

void gnc_table_wrap_verify_cursor_position ( Table *  table,
VirtualLocation  virt_loc 
)

Definition at line 969 of file table-allgui.c.

970{
971 VirtualLocation save_loc;
972 gboolean moved_cursor;
973
974 if (!table) return;
975
976 ENTER("(%d %d)", virt_loc.vcell_loc.virt_row, virt_loc.vcell_loc.virt_col);
977
978 save_loc = table->current_cursor_loc;
979
980 /* VerifyCursor will do all sorts of gui-independent machinations */
981 moved_cursor = gnc_table_verify_cursor_position (table, virt_loc);
982
983 if (moved_cursor)
984 {
985 /* make sure *both* the old and the new cursor rows get redrawn */
987 gnc_table_refresh_cursor_gui (table, save_loc.vcell_loc, FALSE);
988 }
989
990 LEAVE ("");
991}
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...
void gnc_table_refresh_current_cursor_gui(Table *table, gboolean do_scroll)
Refresh the current cursor gui.

◆ gnc_virtual_location_init()

void gnc_virtual_location_init ( VirtualLocation *  vloc)

Definition at line 612 of file table-allgui.c.

613{
614 if (vloc == NULL)
615 return;
616
617 vloc->phys_row_offset = -1;
618 vloc->phys_col_offset = -1;
619 vloc->vcell_loc.virt_row = -1;
620 vloc->vcell_loc.virt_col = -1;
621}