mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-10-13 01:41:59 -05:00
daves patch of Sun, 09 Jan 2000 03:18:52 -0800
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1999 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
1 parent
048c65f851
commit
0ac5892064
16 files changed
+184
-138
No files matched your search
@@ -160,10 +160,11 @@
|
||||
#define __XACC_BASIC_CELL_H__
|
||||
|
||||
/* define a bitmask */
|
||||
#define XACC_CELL_ALLOW_NONE 0x0
|
||||
#define XACC_CELL_ALLOW_SHADOW 0x1
|
||||
#define XACC_CELL_ALLOW_INPUT 0x2
|
||||
#define XACC_CELL_ALLOW_ALL 0x3
|
||||
#define XACC_CELL_ALLOW_NONE 0x0
|
||||
#define XACC_CELL_ALLOW_SHADOW 0x1
|
||||
#define XACC_CELL_ALLOW_INPUT 0x2
|
||||
#define XACC_CELL_ALLOW_ALL 0x3
|
||||
#define XACC_CELL_ALLOW_EXACT_ONLY 0x4
|
||||
|
||||
typedef struct _BasicCell BasicCell;
|
||||
typedef unsigned int uint32;
|
||||
|
||||
@@ -242,7 +242,7 @@ xaccNextRight (CellBlock *arr, int row, int col,
|
||||
|
||||
void
|
||||
xaccNextLeft (CellBlock *arr, int row, int col,
|
||||
int next_row, int next_col)
|
||||
int next_row, int next_col)
|
||||
{
|
||||
if (!arr) return;
|
||||
|
||||
|
||||
@@ -140,7 +140,10 @@ void xaccInitCellBlock (CellBlock *, int numrows, int numcols);
|
||||
void xaccDestroyCellBlock (CellBlock *);
|
||||
|
||||
/* define next cell to traverse to */
|
||||
void xaccNextRight (CellBlock *, int row, int col,
|
||||
void xaccNextRight (CellBlock *, int row, int col,
|
||||
int next_row, int next_col);
|
||||
|
||||
void xaccNextLeft (CellBlock *arr, int row, int col,
|
||||
int next_row, int next_col);
|
||||
|
||||
#endif /* __XACC_CELL_BLOCK_H__ */
|
||||
@@ -317,6 +317,10 @@ const char * leaveCombo (BasicCell *bcell, const char *value)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void xaccClearComboCellMenu (ComboCell * cell)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* =============== end of file =================== */
|
||||
@@ -245,7 +245,7 @@ static int
|
||||
pointer_on_resize_line (GnucashHeader *header, int x, int y)
|
||||
{
|
||||
SheetBlockStyle *style = header->style;
|
||||
int i, j;
|
||||
int j;
|
||||
int pixels = 0;
|
||||
|
||||
for (j = 0; j < style->ncols; j++) {
|
||||
@@ -278,6 +278,8 @@ gnucash_header_event (GnomeCanvasItem *item, GdkEvent *event)
|
||||
gdk_window_set_cursor (GTK_WIDGET(canvas)->window,
|
||||
header->normal_cursor);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ gnucash_sheet_activate_cursor_cell (GnucashSheet *sheet,
|
||||
|
||||
style = gnucash_sheet_get_style (sheet, virt_row, virt_col);
|
||||
if (style->cursor_type == GNUCASH_CURSOR_HEADER ||
|
||||
!gnc_register_cell_valid (table, p_row, p_col) )
|
||||
!gnc_register_cell_valid (table, p_row, p_col, GNC_T))
|
||||
return;
|
||||
|
||||
new_text = gnc_table_enter_update (table, p_row, p_col);
|
||||
@@ -775,7 +775,7 @@ gnucash_sheet_modify_current_cell(GnucashSheet *sheet, const gchar *new_text)
|
||||
gnucash_cursor_get_virt(GNUCASH_CURSOR(sheet->cursor),
|
||||
&v_row, &v_col, &c_row, &c_col);
|
||||
|
||||
if (!gnc_register_cell_valid (table, p_row, p_col))
|
||||
if (!gnc_register_cell_valid (table, p_row, p_col, GNC_T))
|
||||
return NULL;
|
||||
|
||||
old_text = gtk_entry_get_text (GTK_ENTRY(sheet->entry));
|
||||
@@ -847,7 +847,7 @@ gnucash_sheet_insert_cb (GtkWidget *widget, const gchar *new_text,
|
||||
gnucash_cursor_get_virt (GNUCASH_CURSOR(sheet->cursor), &v_row,
|
||||
&v_col, &c_row, &c_col);
|
||||
|
||||
if (!gnc_register_cell_valid (table, p_row, p_col))
|
||||
if (!gnc_register_cell_valid (table, p_row, p_col, GNC_F))
|
||||
return;
|
||||
|
||||
old_text = gtk_entry_get_text (GTK_ENTRY(sheet->entry));
|
||||
@@ -923,7 +923,7 @@ gnucash_sheet_delete_cb (GtkWidget *widget,
|
||||
gnucash_cursor_get_virt (GNUCASH_CURSOR (sheet->cursor),
|
||||
&v_row, &v_col, &c_row, &c_col);
|
||||
|
||||
if (!gnc_register_cell_valid (table, p_row, p_col))
|
||||
if (!gnc_register_cell_valid (table, p_row, p_col, GNC_F))
|
||||
return;
|
||||
|
||||
old_text = gtk_entry_get_text (GTK_ENTRY(sheet->entry));
|
||||
@@ -1108,10 +1108,6 @@ gnucash_button_press_event (GtkWidget *widget, GdkEventButton *event)
|
||||
if (exit_register)
|
||||
return TRUE;
|
||||
|
||||
/* Shouldn't gnc_table_traverse_update fill in valid cells? */
|
||||
if (!gnc_register_cell_valid (table, new_p_row, new_p_col))
|
||||
return TRUE;
|
||||
|
||||
changed_cells = gnucash_sheet_cursor_move (sheet,
|
||||
new_p_row, new_p_col);
|
||||
|
||||
@@ -1215,10 +1211,6 @@ gnucash_sheet_key_press_event (GtkWidget *widget, GdkEventKey *event)
|
||||
direction != GNC_TABLE_TRAVERSE_LEFT)
|
||||
return TRUE;
|
||||
|
||||
/* Shouldn't gnc_table_traverse_update fill in valid cells ? */
|
||||
if (!gnc_register_cell_valid (table, new_p_row, new_p_col))
|
||||
return TRUE;
|
||||
|
||||
gnucash_sheet_cursor_move (sheet, new_p_row, new_p_col);
|
||||
|
||||
/* return true because we handled the key press */
|
||||
@@ -1253,10 +1245,6 @@ gnucash_sheet_goto_virt_row_col (GnucashSheet *sheet,
|
||||
if (exit_register)
|
||||
return;
|
||||
|
||||
/* Shouldn't gnc_table_traverse_update fill in valid cells ? */
|
||||
if (!gnc_register_cell_valid (table, new_p_row, new_p_col))
|
||||
return;
|
||||
|
||||
gnucash_sheet_cursor_move (sheet, new_p_row, new_p_col);
|
||||
}
|
||||
|
||||
@@ -1518,7 +1506,7 @@ gnucash_sheet_block_new (GnucashSheet *sheet, gint virt_row, gint virt_col)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
gnucash_sheet_resize (GnucashSheet *sheet)
|
||||
{
|
||||
gint i, j;
|
||||
@@ -1565,7 +1553,7 @@ gnucash_sheet_resize (GnucashSheet *sheet)
|
||||
sheet->num_virt_cols = sheet->table->num_virt_cols;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
gnucash_sheet_table_load (GnucashSheet *sheet)
|
||||
{
|
||||
|
||||
@@ -174,7 +174,8 @@ typedef struct
|
||||
|
||||
GtkType gnucash_sheet_get_type (void);
|
||||
GtkWidget *gnucash_sheet_new (Table *table);
|
||||
void gnucash_sheet_load_table (GnucashSheet *sheet, Table *table);
|
||||
|
||||
void gnucash_sheet_table_load (GnucashSheet *sheet);
|
||||
|
||||
GtkType gnucash_register_get_type (void);
|
||||
|
||||
@@ -193,6 +194,7 @@ gint gnucash_sheet_col_get_distance(GnucashSheet *sheet, int col_a, int col_b);
|
||||
gint gnucash_sheet_row_get_distance (GnucashSheet *sheet, int row_a,
|
||||
int row_b);
|
||||
|
||||
void gnucash_sheet_redraw_all (GnucashSheet *sheet);
|
||||
void gnucash_sheet_redraw_block (GnucashSheet *sheet, gint row, gint col);
|
||||
|
||||
void gnucash_sheet_cursor_set (GnucashSheet *gsheet,
|
||||
@@ -202,6 +204,9 @@ void gnucash_sheet_cursor_set (GnucashSheet *gsheet,
|
||||
const char * gnucash_sheet_modify_current_cell(GnucashSheet *sheet,
|
||||
const gchar *new_text);
|
||||
|
||||
void gnucash_sheet_block_set_from_table (GnucashSheet *sheet, gint virt_row,
|
||||
gint virt_col);
|
||||
|
||||
void gnucash_sheet_cursor_set_from_table (GnucashSheet *sheet,
|
||||
gncBoolean do_scroll);
|
||||
|
||||
|
||||
@@ -475,7 +475,6 @@ set_dimensions_pass_three (GnucashSheet *sheet, SheetBlockStyle *style,
|
||||
int row, int ideal_width)
|
||||
{
|
||||
int i = row, j;
|
||||
int w = 0;
|
||||
int space = compute_row_width (style, row, 0, style->ncols-1) - ideal_width;
|
||||
int cellspace;
|
||||
int nfills;
|
||||
@@ -566,7 +565,6 @@ static void
|
||||
set_dimensions_aligned (GnucashSheet *sheet, SheetBlockStyle *style, int row)
|
||||
{
|
||||
int i = row, j;
|
||||
int width;
|
||||
int c1, c2;
|
||||
int r;
|
||||
|
||||
|
||||
@@ -99,7 +99,6 @@ static const char *
|
||||
PriceLeave (BasicCell *_cell, const char *val)
|
||||
{
|
||||
PriceCell *cell = (PriceCell *) _cell;
|
||||
double amount;
|
||||
char *newval;
|
||||
|
||||
newval = xaccPriceCellPrintValue(cell);
|
||||
|
||||
+12
-8
@@ -476,7 +476,7 @@ configLayout (SplitRegister *reg)
|
||||
}
|
||||
|
||||
|
||||
#define NEXT_RIGHT(r,c) { \
|
||||
#define NEXT_RIGHT(r,c) { \
|
||||
xaccNextRight (curs, prev_r, prev_c, (r), (c)); \
|
||||
prev_r = r; prev_c = c; \
|
||||
}
|
||||
@@ -532,7 +532,7 @@ configLayout (SplitRegister *reg)
|
||||
} \
|
||||
}
|
||||
|
||||
#define EXIT_RIGHT() { \
|
||||
#define EXIT_RIGHT() { \
|
||||
curs->right_exit_r = prev_r; curs->right_exit_c = prev_c; \
|
||||
}
|
||||
|
||||
@@ -564,20 +564,20 @@ configLayout (SplitRegister *reg)
|
||||
|
||||
#define TRAVERSE_NON_NULL_CELLS_LEFT() { \
|
||||
i = prev_r; \
|
||||
for (j=prev_c -1; j>=0; j--) { \
|
||||
for (j=prev_c -1; j>=0; j--) { \
|
||||
if ((reg->nullCell != curs->cells[i][j]) && \
|
||||
(reg->recnCell != curs->cells[i][j]) && \
|
||||
(XACC_CELL_ALLOW_INPUT & curs->cells[i][j]->input_output)) \
|
||||
{ \
|
||||
{ \
|
||||
NEXT_LEFT (i, j); \
|
||||
} \
|
||||
} \
|
||||
for (i=prev_r-1; i>=0; i--) { \
|
||||
for (i=prev_r-1; i>=0; i--) { \
|
||||
for (j=curs->numCols-1; j>=0; j--) { \
|
||||
if ((reg->nullCell != curs->cells[i][j]) && \
|
||||
(reg->recnCell != curs->cells[i][j]) && \
|
||||
(XACC_CELL_ALLOW_INPUT & curs->cells[i][j]->input_output)) \
|
||||
{ \
|
||||
{ \
|
||||
NEXT_LEFT (i, j); \
|
||||
} \
|
||||
} \
|
||||
@@ -610,7 +610,7 @@ configLayout (SplitRegister *reg)
|
||||
} \
|
||||
}
|
||||
|
||||
#define EXIT_LEFT() { \
|
||||
#define EXIT_LEFT() { \
|
||||
curs->left_exit_r = prev_r; curs->left_exit_c = prev_c; \
|
||||
}
|
||||
|
||||
@@ -683,7 +683,6 @@ configTraverse (SplitRegister *reg)
|
||||
EXIT_LEFT ();
|
||||
PREVIOUS_SPLIT ();
|
||||
|
||||
printf ("SPLIT\n");
|
||||
curs = reg->split_cursor;
|
||||
FIRST_NON_NULL (0,0);
|
||||
TRAVERSE_NON_NULL_CELLS ();
|
||||
@@ -897,6 +896,11 @@ xaccInitSplitRegister (SplitRegister *reg, int type)
|
||||
reg->balanceCell->cell.input_output = XACC_CELL_ALLOW_SHADOW;
|
||||
reg->shrsCell->cell.input_output = XACC_CELL_ALLOW_SHADOW;
|
||||
|
||||
/* The reconcile cell should only be entered with the pointer,
|
||||
* and only then when the user clicks directly on the cell.
|
||||
*/
|
||||
reg->recnCell->input_output |= XACC_CELL_ALLOW_EXACT_ONLY;
|
||||
|
||||
/* the debit/credit/value cells show blank if value is 0.00 */
|
||||
reg->debitCell->blank_zero = 1;
|
||||
reg->creditCell->blank_zero = 1;
|
||||
|
||||
@@ -157,13 +157,16 @@ struct _SplitRegister {
|
||||
int type;
|
||||
|
||||
/* some private data; outsiders should not access this */
|
||||
short num_cols;
|
||||
short num_header_rows;
|
||||
int num_cols;
|
||||
int num_header_rows;
|
||||
|
||||
short num_phys_rows;
|
||||
short num_virt_rows;
|
||||
short cursor_phys_row;
|
||||
short cursor_virt_row;
|
||||
int num_phys_rows;
|
||||
int num_virt_rows;
|
||||
|
||||
int cursor_virt_row;
|
||||
|
||||
int cursor_phys_row;
|
||||
int cursor_phys_col;
|
||||
|
||||
BasicCell *header_label_cells[NUM_CELLS];
|
||||
|
||||
|
||||
+116
-77
@@ -28,14 +28,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "cellblock.h"
|
||||
#include "table-allgui.h"
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#ifdef KDE
|
||||
#define TRUE (1==1)
|
||||
#define FALSE (0==1)
|
||||
@@ -381,7 +378,7 @@ makePassive (Table *table)
|
||||
int r_origin, c_origin;
|
||||
|
||||
|
||||
/* Change the cell background colors to thier "passive" values.
|
||||
/* Change the cell background colors to their "passive" values.
|
||||
* This denotes that the cursor has left this location (which means more or
|
||||
* less the same thing as "the current location is no longer being edited.")
|
||||
* (But only do this if the cursor has a valid current location)
|
||||
@@ -434,7 +431,8 @@ doMoveCursor (Table *table, int new_phys_row, int new_phys_col, int do_move_gui)
|
||||
CellBlock *curs;
|
||||
|
||||
ENTER("doMoveCursor(): new_phys=(%d %d) do_move_gui=%d\n",
|
||||
new_phys_row, new_phys_col, do_move_gui);
|
||||
new_phys_row, new_phys_col, do_move_gui);
|
||||
|
||||
/* Change the cell background colors to their "passive" values.
|
||||
* This denotes that the cursor has left this location (which means more or
|
||||
* less the same thing as "the current location is no longer being edited.")
|
||||
@@ -525,7 +523,7 @@ doMoveCursor (Table *table, int new_phys_row, int new_phys_col, int do_move_gui)
|
||||
phys_col_origin -= table->locators[new_phys_row][new_phys_col]->phys_col_offset;
|
||||
|
||||
/* setting the previous traversal value to the last of a traversal chain will
|
||||
* gaurentee that first entry into a register will occur at the first cell */
|
||||
* guarantee that first entry into a register will occur at the first cell */
|
||||
table->prev_phys_traverse_row = phys_row_origin + curs->last_reenter_traverse_row;
|
||||
table->prev_phys_traverse_col = phys_col_origin + curs->last_reenter_traverse_col;
|
||||
|
||||
@@ -682,16 +680,17 @@ xaccRefreshHeader (Table *table)
|
||||
* with respect to a row/column position, and repositions
|
||||
* the cursor if necessary. This includes saving any uncommited
|
||||
* data in the old cursor, and then moving the cursor and its
|
||||
* GUI.
|
||||
* GUI. Returns true if the cursor was repositioned.
|
||||
*/
|
||||
|
||||
void
|
||||
gncBoolean
|
||||
xaccVerifyCursorPosition (Table *table, int phys_row, int phys_col)
|
||||
{
|
||||
int virt_row, virt_col;
|
||||
int do_commit = 0;
|
||||
gncBoolean do_commit = GNC_F;
|
||||
gncBoolean moved_cursor = GNC_F;
|
||||
|
||||
if (!table) return;
|
||||
if (!table) return FALSE;
|
||||
|
||||
/* Someone may be trying to intentionally invalidate the cursor,
|
||||
* in which case the physical addresses could be out of bounds.
|
||||
@@ -714,11 +713,11 @@ xaccVerifyCursorPosition (Table *table, int phys_row, int phys_col)
|
||||
}
|
||||
|
||||
if (do_commit) {
|
||||
/* before leaving the current virtual position,
|
||||
* commit any edits that have been accumulated
|
||||
* in the cursor */
|
||||
xaccCommitCursor (table);
|
||||
xaccMoveCursorGUI (table, phys_row, phys_col);
|
||||
/* before leaving the current virtual position, commit any edits
|
||||
* that have been accumulated in the cursor */
|
||||
xaccCommitCursor (table);
|
||||
xaccMoveCursorGUI (table, phys_row, phys_col);
|
||||
moved_cursor = GNC_T;
|
||||
} else {
|
||||
|
||||
/* The request might be to move to a cell that is one column over.
|
||||
@@ -728,9 +727,20 @@ xaccVerifyCursorPosition (Table *table, int phys_row, int phys_col)
|
||||
* may also be one row up or down, which, for a two-row cursor,
|
||||
* also might not require a cursor movement).
|
||||
*/
|
||||
table->current_cursor_phys_row = phys_row;
|
||||
table->current_cursor_phys_col = phys_col;
|
||||
if (table->current_cursor_phys_row != phys_row)
|
||||
{
|
||||
table->current_cursor_phys_row = phys_row;
|
||||
moved_cursor = GNC_T;
|
||||
}
|
||||
|
||||
if (table->current_cursor_phys_col != phys_col)
|
||||
{
|
||||
table->current_cursor_phys_col = phys_col;
|
||||
moved_cursor = GNC_T;
|
||||
}
|
||||
}
|
||||
|
||||
return moved_cursor;
|
||||
}
|
||||
|
||||
/* ==================================================== */
|
||||
@@ -790,20 +800,22 @@ wrapVerifyCursorPosition (Table *table, int row, int col)
|
||||
CellBlock *save_curs = table->current_cursor;
|
||||
const int save_phys_row = table->current_cursor_phys_row;
|
||||
const int save_phys_col = table->current_cursor_phys_col;
|
||||
gncBoolean moved_cursor;
|
||||
|
||||
ENTER("wrapVerifyCursorPosition(): (%d %d) val=%s\n",
|
||||
row,col, table->entries[row][col]);
|
||||
/* VerifyCursor will do all sorts of gui-independent machinations */
|
||||
xaccVerifyCursorPosition (table, row, col);
|
||||
|
||||
if ((save_phys_row != table->current_cursor_phys_row) ||
|
||||
(save_phys_col != table->current_cursor_phys_col))
|
||||
/* VerifyCursor will do all sorts of gui-independent machinations */
|
||||
moved_cursor = xaccVerifyCursorPosition (table, row, col);
|
||||
|
||||
if (moved_cursor)
|
||||
{
|
||||
/* make sure *both* the old and the new cursor rows get redrawn */
|
||||
xaccRefreshCursorGUI (table, TRUE);
|
||||
xaccRefreshCursorGUI (table, GNC_T);
|
||||
doRefreshCursorGUI (table, save_curs,
|
||||
save_phys_row, save_phys_col, FALSE);
|
||||
save_phys_row, save_phys_col, GNC_F);
|
||||
}
|
||||
|
||||
LEAVE ("wrapVerifyCursorPosition()\n");
|
||||
}
|
||||
|
||||
@@ -820,8 +832,8 @@ xaccRefreshCursorGUI (Table * table, gncBoolean do_scroll)
|
||||
|
||||
/* ==================================================== */
|
||||
|
||||
int
|
||||
gnc_register_cell_valid(Table *table, int row, int col)
|
||||
gncBoolean
|
||||
gnc_register_cell_valid(Table *table, int row, int col, gncBoolean exact_cell)
|
||||
{
|
||||
int invalid = 0;
|
||||
int io_flag;
|
||||
@@ -872,6 +884,11 @@ gnc_register_cell_valid(Table *table, int row, int col)
|
||||
io_flag = arr->cells[rel_row][rel_col]->input_output;
|
||||
if (0 == (XACC_CELL_ALLOW_INPUT & io_flag)) return GNC_F;
|
||||
|
||||
/* if cell is pointer only and this is not an exact pointer test,
|
||||
* it cannot be entered. */
|
||||
if (!exact_cell && ((XACC_CELL_ALLOW_EXACT_ONLY & io_flag) != 0))
|
||||
return GNC_F;
|
||||
|
||||
if (invalid) return GNC_F;
|
||||
return GNC_T;
|
||||
}
|
||||
@@ -881,8 +898,7 @@ gnc_register_cell_valid(Table *table, int row, int col)
|
||||
*/
|
||||
|
||||
const char *
|
||||
gnc_table_enter_update(Table *table,
|
||||
int row, int col)
|
||||
gnc_table_enter_update(Table *table, int row, int col)
|
||||
{
|
||||
/* If text should be changed, then new_text will be set to non-null
|
||||
on return */
|
||||
@@ -898,12 +914,10 @@ gnc_table_enter_update(Table *table,
|
||||
"enter %d %d (relrow=%d relcol=%d) cell=%p val=%s\n",
|
||||
row, col, rel_row, rel_col,
|
||||
arr->cells[rel_row][rel_col], table->entries[row][col]);
|
||||
|
||||
|
||||
|
||||
/* OK, if there is a callback for this cell, call it */
|
||||
enter = arr->cells[rel_row][rel_col]->enter_cell;
|
||||
|
||||
|
||||
if (enter) {
|
||||
const char *val;
|
||||
|
||||
@@ -1049,15 +1063,53 @@ gnc_table_modify_update(Table *table, int row, int col,
|
||||
|
||||
/* ==================================================== */
|
||||
|
||||
gncBoolean
|
||||
gnc_table_find_valid_cell_horiz(Table *table, int *row, int *col,
|
||||
gncBoolean exact_cell)
|
||||
{
|
||||
int left = *col - 1;
|
||||
int right = *col + 1;
|
||||
|
||||
if ((*row < 0) || (*col < 0) ||
|
||||
(*row >= table->num_phys_rows) ||
|
||||
(*col >= table->num_phys_cols))
|
||||
return GNC_F;
|
||||
|
||||
if (gnc_register_cell_valid(table, *row, *col, exact_cell))
|
||||
return GNC_T;
|
||||
|
||||
while (left >= 0 || right < table->num_phys_cols)
|
||||
{
|
||||
if (gnc_register_cell_valid(table, *row, right, GNC_F))
|
||||
{
|
||||
*col = right;
|
||||
return GNC_T;
|
||||
}
|
||||
|
||||
if (gnc_register_cell_valid(table, *row, left, GNC_F))
|
||||
{
|
||||
*col = left;
|
||||
return GNC_T;
|
||||
}
|
||||
|
||||
left--;
|
||||
right++;
|
||||
}
|
||||
|
||||
return GNC_F;
|
||||
}
|
||||
|
||||
/* ==================================================== */
|
||||
|
||||
gncBoolean
|
||||
gnc_table_traverse_update(Table *table, int row, int col,
|
||||
gncTableTraversalDir dir,
|
||||
int *dest_row,
|
||||
int *dest_col)
|
||||
{
|
||||
gncBoolean exit_register = FALSE;
|
||||
gncBoolean exit_register = GNC_F;
|
||||
CellBlock *arr = table->current_cursor;
|
||||
|
||||
|
||||
ENTER("gnc_table_traverse_update(): proposed (%d %d) -> (%d %d)\n",
|
||||
row, col, *dest_row, *dest_col);
|
||||
|
||||
@@ -1068,7 +1120,7 @@ gnc_table_traverse_update(Table *table, int row, int col,
|
||||
{
|
||||
PERR("gnc_table_traverse_update: destination (%d, %d) out of bounds (%d, %d)\n",
|
||||
*dest_row, *dest_col, table->num_phys_rows, table->num_phys_cols);
|
||||
return TRUE;
|
||||
return GNC_T;
|
||||
}
|
||||
|
||||
/* next, check the current row and column. If they are out of bounds
|
||||
@@ -1092,21 +1144,28 @@ gnc_table_traverse_update(Table *table, int row, int col,
|
||||
/* cannot compute the cell location until we have checked that
|
||||
* row and column have valid values. compute the cell location.
|
||||
*/
|
||||
int next_row, next_col;
|
||||
const int rel_row = table->locators[row][col]->phys_row_offset;
|
||||
const int rel_col = table->locators[row][col]->phys_col_offset;
|
||||
|
||||
if (dir == GNC_TABLE_TRAVERSE_RIGHT) {
|
||||
*dest_row = row - rel_row + arr->right_traverse_r[rel_row][rel_col];
|
||||
*dest_col = col - rel_col + arr->right_traverse_c[rel_row][rel_col];
|
||||
exit_register= ((rel_row == arr->right_exit_r) && (rel_col == arr->right_exit_c));
|
||||
} else {
|
||||
*dest_row = row - rel_row + arr->left_traverse_r[rel_row][rel_col];
|
||||
*dest_col = col - rel_col + arr->left_traverse_c[rel_row][rel_col];
|
||||
exit_register = ((rel_row == arr->left_exit_r) && (rel_col == arr->left_exit_c));
|
||||
}
|
||||
const int rel_col = table->locators[row][col]->phys_col_offset;
|
||||
|
||||
if (dir == GNC_TABLE_TRAVERSE_RIGHT) {
|
||||
*dest_row = row - rel_row + arr->right_traverse_r[rel_row][rel_col];
|
||||
*dest_col = col - rel_col + arr->right_traverse_c[rel_row][rel_col];
|
||||
exit_register = ((rel_row == arr->right_exit_r) &&
|
||||
(rel_col == arr->right_exit_c));
|
||||
} else {
|
||||
*dest_row = row - rel_row + arr->left_traverse_r[rel_row][rel_col];
|
||||
*dest_col = col - rel_col + arr->left_traverse_c[rel_row][rel_col];
|
||||
exit_register = ((rel_row == arr->left_exit_r) &&
|
||||
(rel_col == arr->left_exit_c));
|
||||
}
|
||||
}
|
||||
|
||||
if (gnc_register_cell_valid(table, *dest_row, *dest_col, GNC_F))
|
||||
break;
|
||||
|
||||
if (!gnc_table_find_valid_cell_horiz(table, dest_row, dest_col, GNC_F))
|
||||
return GNC_T;
|
||||
|
||||
break;
|
||||
|
||||
case GNC_TABLE_TRAVERSE_UP:
|
||||
@@ -1119,14 +1178,19 @@ gnc_table_traverse_update(Table *table, int row, int col,
|
||||
/* Keep going in the specified direction until we find a valid
|
||||
* row to land on, or we hit the end of the table. At the end,
|
||||
* turn around and go back until we find a valid row or we get
|
||||
* to where we started.
|
||||
* to where we started. If we still can't find anything, try
|
||||
* going left and right.
|
||||
*/
|
||||
increment = (dir == GNC_TABLE_TRAVERSE_DOWN) ? 1 : -1;
|
||||
|
||||
while (!gnc_register_cell_valid(table, new_row, *dest_col))
|
||||
while (!gnc_register_cell_valid(table, new_row, *dest_col, GNC_F))
|
||||
{
|
||||
if (new_row == row)
|
||||
return TRUE;
|
||||
{
|
||||
new_row = *dest_row;
|
||||
gnc_table_find_valid_cell_horiz(table, &new_row, dest_col, GNC_F);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((new_row < header->numRows) || (new_row >= table->num_phys_rows))
|
||||
{
|
||||
@@ -1140,39 +1204,14 @@ gnc_table_traverse_update(Table *table, int row, int col,
|
||||
*dest_row = new_row;
|
||||
}
|
||||
|
||||
if (!gnc_register_cell_valid(table, *dest_row, *dest_col))
|
||||
return TRUE;
|
||||
if (!gnc_register_cell_valid(table, *dest_row, *dest_col, GNC_F))
|
||||
return GNC_T;
|
||||
|
||||
break;
|
||||
|
||||
case GNC_TABLE_TRAVERSE_POINTER:
|
||||
/* Fan out right and left looking for a valid column to land on. */
|
||||
if (!gnc_register_cell_valid(table, *dest_row, *dest_col))
|
||||
{
|
||||
int left = *dest_col - 1;
|
||||
int right = *dest_col + 1;
|
||||
|
||||
while (left >= 0 || right < table->num_phys_cols)
|
||||
{
|
||||
if (gnc_register_cell_valid(table, *dest_row, right))
|
||||
{
|
||||
*dest_col = right;
|
||||
break;
|
||||
}
|
||||
|
||||
if (gnc_register_cell_valid(table, *dest_row, left))
|
||||
{
|
||||
*dest_col = left;
|
||||
break;
|
||||
}
|
||||
|
||||
left--;
|
||||
right++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!gnc_register_cell_valid(table, *dest_row, *dest_col))
|
||||
return TRUE;
|
||||
if (!gnc_table_find_valid_cell_horiz(table, dest_row, dest_col, GNC_T))
|
||||
return GNC_T;
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -196,10 +196,12 @@ struct _Table {
|
||||
void (*move_cursor) (Table *, int *p_new_phys_row,
|
||||
int *p_new_phys_col,
|
||||
void *client_data);
|
||||
|
||||
/* callback that is called to determine traversal */
|
||||
void (*traverse) (Table *, int *p_new_phys_row,
|
||||
int *p_new_phys_col,
|
||||
void *client_data);
|
||||
|
||||
void * client_data;
|
||||
|
||||
/* string values for each cell,
|
||||
@@ -305,10 +307,11 @@ void xaccRefreshHeader (Table *);
|
||||
* the cursor with respect to a physical row/column position,
|
||||
* and if the resulting virtual position has changed, commits
|
||||
* the changes in the old position, and the repositions the
|
||||
* cursor & gui to the new position.
|
||||
* cursor & gui to the new position. Returns true if the
|
||||
* cursor was repositioned.
|
||||
*/
|
||||
|
||||
void
|
||||
gncBoolean
|
||||
xaccVerifyCursorPosition (Table *table, int phys_row, int phys_col);
|
||||
|
||||
/*
|
||||
@@ -331,9 +334,10 @@ gnc_table_column_width(Table *table, int col);
|
||||
|
||||
void
|
||||
wrapVerifyCursorPosition (Table *table, int row, int col);
|
||||
|
||||
int
|
||||
gnc_register_cell_valid(Table *table, int row, int col);
|
||||
|
||||
gncBoolean
|
||||
gnc_register_cell_valid(Table *table, int row, int col,
|
||||
gncBoolean exact_pointer);
|
||||
|
||||
void
|
||||
doRefreshCursorGUI (Table * table, CellBlock *curs,
|
||||
@@ -373,6 +377,12 @@ gnc_table_traverse_update(Table *table, int row, int col,
|
||||
int *dest_row,
|
||||
int *dest_col);
|
||||
|
||||
/* Find the closest valid horizontal cell */
|
||||
gncBoolean
|
||||
gnc_table_find_valid_cell_horiz(Table *table, int *row, int *col,
|
||||
gncBoolean exact_cell);
|
||||
|
||||
|
||||
/* ==================================================== */
|
||||
/*
|
||||
* In C, we don't have things like C++ templates.
|
||||
|
||||
@@ -52,15 +52,6 @@
|
||||
#include "gnome/gnucash-color.h"
|
||||
#include "gnome/gnucash-style.h"
|
||||
|
||||
static gint
|
||||
register_destroy_event (GtkWidget *widget, Table *table)
|
||||
{
|
||||
if (table)
|
||||
table->table_widget = NULL;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
xaccCreateTable (GtkWidget *widget, void *data)
|
||||
@@ -180,8 +171,6 @@ doRefreshCursorGUI (Table * table, CellBlock *curs,
|
||||
int
|
||||
gnc_table_column_width(Table *table, const int col)
|
||||
{
|
||||
GnucashSheet *sheet = GNUCASH_SHEET(table->table_widget);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ cellCB (Widget mw, XtPointer cd, XtPointer cb)
|
||||
wrapVerifyCursorPosition (table, row, col);
|
||||
}
|
||||
|
||||
invalid = ! gnc_register_cell_valid(table, row, col);
|
||||
invalid = ! gnc_register_cell_valid(table, row, col, GNC_T);
|
||||
|
||||
/* oops the callback failed for some reason ...
|
||||
* reject the enter/edit/leave and return */
|
||||
|
||||
@@ -49,7 +49,8 @@ xaccNextTabGroup (Table *table, void * w) {
|
||||
/* ==================================================== */
|
||||
|
||||
void
|
||||
doRefreshCursorGUI (Table * table, CellBlock *curs, int from_row, int from_col)
|
||||
doRefreshCursorGUI (Table * table, CellBlock *curs,
|
||||
int from_row, int from_col, gncBoolean do_scroll)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user