mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Remove static tab traversal information and configuration.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3004 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
fad189e49f
commit
bff2325582
@ -87,34 +87,9 @@ gnc_cellblock_cell_free (gpointer _cb_cell, gpointer user_data)
|
||||
|
||||
/* =================================================== */
|
||||
|
||||
static gpointer
|
||||
gnc_cell_traverse_info_new (gpointer user_data)
|
||||
{
|
||||
CellTraverseInfo *ct_info;
|
||||
|
||||
ct_info = g_new0(CellTraverseInfo, 1);
|
||||
|
||||
return ct_info;
|
||||
}
|
||||
|
||||
/* =================================================== */
|
||||
|
||||
static void
|
||||
gnc_cell_traverse_info_free (gpointer ct_info, gpointer user_data)
|
||||
{
|
||||
g_free (ct_info);
|
||||
}
|
||||
|
||||
/* =================================================== */
|
||||
|
||||
static void
|
||||
gnc_cellblock_init (CellBlock *cellblock, int rows, int cols)
|
||||
{
|
||||
CellTraverseInfo *ct_info;
|
||||
int row, col;
|
||||
|
||||
if (!cellblock) return;
|
||||
|
||||
/* init colors */
|
||||
cellblock->active_bg_color = 0xffffff; /* white */
|
||||
cellblock->passive_bg_color = 0xffffff; /* white */
|
||||
@ -128,47 +103,6 @@ gnc_cellblock_init (CellBlock *cellblock, int rows, int cols)
|
||||
cellblock->cb_cells = g_table_new (gnc_cellblock_cell_new,
|
||||
gnc_cellblock_cell_free, NULL);
|
||||
g_table_resize (cellblock->cb_cells, rows, cols);
|
||||
|
||||
/* malloc new traversal table */
|
||||
cellblock->traverse_info = g_table_new (gnc_cell_traverse_info_new,
|
||||
gnc_cell_traverse_info_free, NULL);
|
||||
g_table_resize (cellblock->traverse_info, rows, cols);
|
||||
|
||||
for (row = 0; row < rows; row++)
|
||||
{
|
||||
for (col = 0; col < cols; col++)
|
||||
{
|
||||
ct_info = g_table_index (cellblock->traverse_info, row, col);
|
||||
|
||||
/* default right traversal is same row, next column */
|
||||
ct_info->right_traverse_row = row;
|
||||
ct_info->right_traverse_col = col + 1;
|
||||
|
||||
/* default left traversal is same row, previous column */
|
||||
ct_info->left_traverse_row = row;
|
||||
ct_info->left_traverse_col = col - 1;
|
||||
}
|
||||
|
||||
/* at end of row, wrap to next row */
|
||||
ct_info = g_table_index (cellblock->traverse_info, row, cols - 1);
|
||||
ct_info->right_traverse_row = row + 1;
|
||||
ct_info->right_traverse_col = 0;
|
||||
|
||||
/* at start of row, wrap to previous row */
|
||||
ct_info = g_table_index (cellblock->traverse_info, row, 0);
|
||||
ct_info->left_traverse_row = row - 1;
|
||||
ct_info->left_traverse_col = cols - 1;
|
||||
}
|
||||
|
||||
/* at end of block, wrap back to begining */
|
||||
ct_info = g_table_index (cellblock->traverse_info, rows - 1, cols - 1);
|
||||
ct_info->right_traverse_row = 0;
|
||||
ct_info->right_traverse_col = 0;
|
||||
|
||||
/* at start of block, wrap back to end */
|
||||
ct_info = g_table_index (cellblock->traverse_info, 0, 0);
|
||||
ct_info->left_traverse_row = rows - 1;
|
||||
ct_info->left_traverse_col = cols - 1;
|
||||
}
|
||||
|
||||
/* =================================================== */
|
||||
@ -181,9 +115,6 @@ gnc_cellblock_destroy (CellBlock *cellblock)
|
||||
g_table_destroy (cellblock->cb_cells);
|
||||
cellblock->cb_cells = NULL;
|
||||
|
||||
g_table_destroy (cellblock->traverse_info);
|
||||
cellblock->traverse_info = NULL;
|
||||
|
||||
g_free (cellblock);
|
||||
}
|
||||
|
||||
@ -198,69 +129,4 @@ gnc_cellblock_get_cell (CellBlock *cellblock, int row, int col)
|
||||
return g_table_index (cellblock->cb_cells, row, col);
|
||||
}
|
||||
|
||||
/* =================================================== */
|
||||
|
||||
CellTraverseInfo *
|
||||
gnc_cellblock_get_traverse (CellBlock *cellblock, int row, int col)
|
||||
{
|
||||
if (cellblock == NULL)
|
||||
return NULL;
|
||||
|
||||
return g_table_index (cellblock->traverse_info, row, col);
|
||||
}
|
||||
|
||||
/* =================================================== */
|
||||
|
||||
void
|
||||
gnc_cellblock_next_right (CellBlock *cellblock,
|
||||
int row, int col,
|
||||
int next_row, int next_col)
|
||||
{
|
||||
CellTraverseInfo *ct_info;
|
||||
|
||||
if (!cellblock) return;
|
||||
|
||||
/* avoid embarrasement if cell incorrectly specified */
|
||||
if ((0 > row) || (0 > col)) return;
|
||||
if ((row >= cellblock->num_rows) || (col >= cellblock->num_cols)) return;
|
||||
|
||||
ct_info = gnc_cellblock_get_traverse (cellblock, row, col);
|
||||
|
||||
/* -1 is a valid value for next_*, signifying that traversal should
|
||||
* go to next tab group, so do not check for neg values. */
|
||||
|
||||
/* if the "next" location to hop to is larger than the cursor, that
|
||||
* just means that we should hop to the next cursor. Thus, large
|
||||
* values for next *are* valid. */
|
||||
|
||||
ct_info->right_traverse_row = next_row;
|
||||
ct_info->right_traverse_col = next_col;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_cellblock_next_left (CellBlock *cellblock,
|
||||
int row, int col,
|
||||
int next_row, int next_col)
|
||||
{
|
||||
CellTraverseInfo *ct_info;
|
||||
|
||||
if (!cellblock) return;
|
||||
|
||||
/* avoid embarrasement if cell incorrectly specified */
|
||||
if ((0 > row) || (0 > col)) return;
|
||||
if ((row >= cellblock->num_rows) || (col >= cellblock->num_cols)) return;
|
||||
|
||||
ct_info = gnc_cellblock_get_traverse (cellblock, row, col);
|
||||
|
||||
/* -1 is a valid value for next ... it signifies that traversal
|
||||
* should go to next tab group, so do not check for neg values. */
|
||||
|
||||
/* if the "next" location to hop to is larger than the cursor, that
|
||||
* just means that we should hop to the next cursor. Thus, large
|
||||
* values for next *are* valid. */
|
||||
|
||||
ct_info->left_traverse_row = next_row;
|
||||
ct_info->left_traverse_col = next_col;
|
||||
}
|
||||
|
||||
/* --------------- end of file ----------------- */
|
||||
|
@ -83,15 +83,6 @@ typedef struct
|
||||
gboolean span; /* can span multiple columns */
|
||||
} CellBlockCell;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short right_traverse_row;
|
||||
short right_traverse_col;
|
||||
|
||||
short left_traverse_row;
|
||||
short left_traverse_col;
|
||||
} CellTraverseInfo;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -114,14 +105,6 @@ typedef struct
|
||||
guint32 passive_bg_color;
|
||||
guint32 passive_bg_color2;
|
||||
|
||||
/* The traverse and exit information is automatically created and
|
||||
* managed by the routines below. They control the tab-traversal
|
||||
* order through this cell block. If the cell (i,j) has input-focus,
|
||||
* then hitting the tab key on the keyboard will take input-focus to
|
||||
* cell (inext,jnext), where inext = right_traverse_r[i][j] and
|
||||
* jnext = right_traverse_c[i][j]. */
|
||||
GTable *traverse_info;
|
||||
|
||||
} CellBlock;
|
||||
|
||||
|
||||
@ -132,16 +115,4 @@ void gnc_cellblock_destroy (CellBlock *cellblock);
|
||||
CellBlockCell * gnc_cellblock_get_cell (CellBlock *cellblock,
|
||||
int row, int col);
|
||||
|
||||
CellTraverseInfo * gnc_cellblock_get_traverse (CellBlock *cellblock,
|
||||
int row, int col);
|
||||
|
||||
/* define next cell to traverse to */
|
||||
void gnc_cellblock_next_right (CellBlock *cellblock,
|
||||
int row, int col,
|
||||
int next_row, int next_col);
|
||||
|
||||
void gnc_cellblock_next_left (CellBlock *cellblock,
|
||||
int row, int col,
|
||||
int next_row, int next_col);
|
||||
|
||||
#endif /* __XACC_CELL_BLOCK_H__ */
|
||||
|
@ -584,239 +584,6 @@ configLayout (SplitRegister *reg)
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================== */
|
||||
/* define the traversal order -- negative cells mean "traverse out of table" */
|
||||
|
||||
/* Right Traversals */
|
||||
|
||||
#define FIRST_RIGHT(r,c) { \
|
||||
prev_r = r; prev_c = c; \
|
||||
}
|
||||
|
||||
|
||||
#define NEXT_RIGHT(r,c) { \
|
||||
gnc_cellblock_next_right (curs, prev_r, prev_c, (r), (c)); \
|
||||
prev_r = r; prev_c = c; \
|
||||
}
|
||||
|
||||
|
||||
#define TRAVERSE_NON_NULL_CELLS() { \
|
||||
i = prev_r; \
|
||||
for (j=prev_c+1; j<curs->num_cols; j++) { \
|
||||
CellBlockCell *cb_cell; \
|
||||
cb_cell = gnc_cellblock_get_cell (curs, i, j); \
|
||||
if ((reg->nullCell != cb_cell->cell) && \
|
||||
((BasicCell *) reg->recnCell != cb_cell->cell) && \
|
||||
(XACC_CELL_ALLOW_INPUT & cb_cell->cell->input_output)) \
|
||||
{ \
|
||||
NEXT_RIGHT (i, j); \
|
||||
} \
|
||||
} \
|
||||
for (i=prev_r+1; i<curs->num_rows; i++) { \
|
||||
for (j=0; j<curs->num_cols; j++) { \
|
||||
CellBlockCell *cb_cell; \
|
||||
cb_cell = gnc_cellblock_get_cell (curs, i, j); \
|
||||
if ((reg->nullCell != cb_cell->cell) && \
|
||||
((BasicCell *) reg->recnCell != cb_cell->cell) && \
|
||||
(XACC_CELL_ALLOW_INPUT & cb_cell->cell->input_output)) \
|
||||
{ \
|
||||
NEXT_RIGHT (i, j); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define FIRST_NON_NULL(r,c) { \
|
||||
i = r; \
|
||||
for (j=c; j<curs->num_cols; j++) { \
|
||||
CellBlockCell *cb_cell; \
|
||||
cb_cell = gnc_cellblock_get_cell (curs, i, j); \
|
||||
if ((reg->nullCell != cb_cell->cell) && \
|
||||
((BasicCell *) reg->recnCell != cb_cell->cell) && \
|
||||
(XACC_CELL_ALLOW_INPUT & cb_cell->cell->input_output)) \
|
||||
{ \
|
||||
FIRST_RIGHT (i, j); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define NEXT_NON_NULL(r,c) { \
|
||||
i = r; \
|
||||
for (j=c+1; j<curs->num_cols; j++) { \
|
||||
CellBlockCell *cb_cell; \
|
||||
cb_cell = gnc_cellblock_get_cell (curs, i, j); \
|
||||
if ((reg->nullCell != cb_cell->cell) && \
|
||||
((BasicCell *) reg->recnCell != cb_cell->cell) && \
|
||||
(XACC_CELL_ALLOW_INPUT & cb_cell->cell->input_output)) \
|
||||
{ \
|
||||
NEXT_RIGHT (i, j); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define NEXT_SPLIT() { \
|
||||
i = 0; \
|
||||
for (j=0; j<reg->split_cursor->num_cols; j++) { \
|
||||
CellBlockCell *cb_cell; \
|
||||
cb_cell = gnc_cellblock_get_cell (reg->split_cursor, i, j); \
|
||||
if ((reg->nullCell != cb_cell->cell) && \
|
||||
((BasicCell *) reg->recnCell != cb_cell->cell) && \
|
||||
(XACC_CELL_ALLOW_INPUT & cb_cell->cell->input_output)) \
|
||||
{ \
|
||||
NEXT_RIGHT (i+1, j); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
/* Left Traversals */
|
||||
|
||||
#define LAST_LEFT(r,c) { \
|
||||
prev_r = r; prev_c = c; \
|
||||
}
|
||||
|
||||
#define NEXT_LEFT(r,c) { \
|
||||
gnc_cellblock_next_left (curs, prev_r, prev_c, (r), (c)); \
|
||||
prev_r = r; prev_c = c; \
|
||||
}
|
||||
|
||||
#define TRAVERSE_NON_NULL_CELLS_LEFT() { \
|
||||
i = prev_r; \
|
||||
for (j=prev_c -1; j>=0; j--) { \
|
||||
CellBlockCell *cb_cell; \
|
||||
cb_cell = gnc_cellblock_get_cell (curs, i, j); \
|
||||
if ((reg->nullCell != cb_cell->cell) && \
|
||||
((BasicCell *) reg->recnCell != cb_cell->cell) && \
|
||||
(XACC_CELL_ALLOW_INPUT & cb_cell->cell->input_output)) \
|
||||
{ \
|
||||
NEXT_LEFT (i, j); \
|
||||
} \
|
||||
} \
|
||||
for (i=prev_r-1; i>=0; i--) { \
|
||||
for (j=curs->num_cols-1; j>=0; j--) { \
|
||||
CellBlockCell *cb_cell; \
|
||||
cb_cell = gnc_cellblock_get_cell (curs, i, j); \
|
||||
if ((reg->nullCell != cb_cell->cell) && \
|
||||
((BasicCell *) reg->recnCell != cb_cell->cell) && \
|
||||
(XACC_CELL_ALLOW_INPUT & cb_cell->cell->input_output)) \
|
||||
{ \
|
||||
NEXT_LEFT (i, j); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define LAST_NON_NULL(r,c) { \
|
||||
i = r; \
|
||||
for (j=c; j>=0; j--) { \
|
||||
CellBlockCell *cb_cell; \
|
||||
cb_cell = gnc_cellblock_get_cell (curs, i, j); \
|
||||
if ((reg->nullCell != cb_cell->cell) && \
|
||||
((BasicCell *) reg->recnCell != cb_cell->cell) && \
|
||||
(XACC_CELL_ALLOW_INPUT & cb_cell->cell->input_output)) \
|
||||
{ \
|
||||
LAST_LEFT (i, j); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define PREVIOUS_NON_NULL(r,c) { \
|
||||
i = r; \
|
||||
for (j=c-1; j>=0; j--) { \
|
||||
CellBlockCell *cb_cell; \
|
||||
cb_cell = gnc_cellblock_get_cell (curs, i, j); \
|
||||
if ((reg->nullCell != cb_cell->cell && \
|
||||
((BasicCell *) reg->recnCell != cb_cell->cell) && \
|
||||
(XACC_CELL_ALLOW_INPUT & cb_cell->cell->input_output)) \
|
||||
{ \
|
||||
NEXT_LEFT (i, j); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define PREVIOUS_SPLIT() { \
|
||||
i = reg->split_cursor->num_rows-1; \
|
||||
for (j=reg->split_cursor->num_cols-1; j>=0; j--) { \
|
||||
CellBlockCell *cb_cell; \
|
||||
cb_cell = gnc_cellblock_get_cell (reg->split_cursor, i, j); \
|
||||
if ((reg->nullCell != cb_cell->cell) && \
|
||||
((BasicCell *) reg->recnCell != cb_cell->cell) && \
|
||||
(XACC_CELL_ALLOW_INPUT & cb_cell->cell->input_output)) \
|
||||
{ \
|
||||
NEXT_LEFT (i-1, j); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
static void
|
||||
configTraverse (SplitRegister *reg)
|
||||
{
|
||||
int i,j;
|
||||
int prev_r=0, prev_c=0;
|
||||
int first_r, first_c;
|
||||
CellBlock *curs = NULL;
|
||||
|
||||
curs = reg->single_cursor;
|
||||
/* lead in with the date cell, return to the date cell */
|
||||
FIRST_NON_NULL (0, 0);
|
||||
first_r = prev_r; first_c = prev_c;
|
||||
TRAVERSE_NON_NULL_CELLS ();
|
||||
/* wrap back to start of row after hitting the commit button */
|
||||
NEXT_RIGHT (first_r, first_c);
|
||||
|
||||
/* left traverses */
|
||||
LAST_NON_NULL (curs->num_rows-1, curs->num_cols - 1);
|
||||
first_r = prev_r; first_c = prev_c;
|
||||
TRAVERSE_NON_NULL_CELLS_LEFT();
|
||||
NEXT_LEFT (first_r, first_c);
|
||||
|
||||
curs = reg->double_cursor;
|
||||
/* lead in with the date cell, return to the date cell */
|
||||
FIRST_NON_NULL (0, 0);
|
||||
first_r = prev_r; first_c = prev_c;
|
||||
TRAVERSE_NON_NULL_CELLS ();
|
||||
/* for double-line, hop back one row */
|
||||
NEXT_RIGHT (first_r, first_c);
|
||||
|
||||
/* left traverses */
|
||||
LAST_NON_NULL (curs->num_rows-1, curs->num_cols - 1);
|
||||
first_r = prev_r; first_c = prev_c;
|
||||
TRAVERSE_NON_NULL_CELLS_LEFT ();
|
||||
NEXT_LEFT (first_r, first_c);
|
||||
|
||||
curs = reg->trans_cursor;
|
||||
FIRST_NON_NULL (0,0);
|
||||
TRAVERSE_NON_NULL_CELLS ();
|
||||
/* hop to start of next row (the split cursor) */
|
||||
NEXT_SPLIT();
|
||||
|
||||
/* left_traverses */
|
||||
LAST_NON_NULL (curs->num_rows-1, curs->num_cols - 1);
|
||||
TRAVERSE_NON_NULL_CELLS_LEFT ();
|
||||
PREVIOUS_SPLIT ();
|
||||
|
||||
curs = reg->split_cursor;
|
||||
FIRST_NON_NULL (0,0);
|
||||
TRAVERSE_NON_NULL_CELLS ();
|
||||
/* hop to start of next row (the split cursor) */
|
||||
NEXT_SPLIT();
|
||||
|
||||
/* left_traverses */
|
||||
LAST_NON_NULL (curs->num_rows-1, curs->num_cols - 1);
|
||||
TRAVERSE_NON_NULL_CELLS_LEFT ();
|
||||
PREVIOUS_SPLIT ();
|
||||
}
|
||||
|
||||
/* ============================================== */
|
||||
|
||||
SplitRegister *
|
||||
@ -1126,18 +893,9 @@ xaccInitSplitRegister (SplitRegister *reg,
|
||||
break;
|
||||
}
|
||||
|
||||
/* -------------------------------- */
|
||||
|
||||
/* define how traversal works. This must be done *after* the
|
||||
* balance, etc. cells have been marked read-only, since otherwise
|
||||
* config will try to pick them up. */
|
||||
configTraverse (reg);
|
||||
|
||||
/* add menu items for the action cell */
|
||||
configAction (reg);
|
||||
|
||||
/* -------------------------------- */
|
||||
|
||||
phys_r = header->num_rows;
|
||||
reg->cursor_virt_row = 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user