Reimplement the register Table object using glib's dynamic arrays.

Clean up the code and standardize the function naming convention.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2644 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-08-07 18:11:01 +00:00
parent 6551923875
commit 4f7aca77fd
22 changed files with 2117 additions and 2000 deletions

View File

@ -1,3 +1,19 @@
2000-08-07 Dave Peticolas <dave@krondo.com>
* src/register/table-allgui.c: reimplement the Table code using
glib's dynamic arrays. Clean up the code and homogenize the
function naming convention.
2000-08-04 Dave Peticolas <dave@krondo.com>
* src/register/table-gnome.h: remove unused data members
* src/register/basiccell.h: remove the pixel_width argument
to the realize callback, it is no longer used.
* src/register/table-allgui.c: remove the gnc_table_column_width
call.
2000-07-22 Dave Peticolas <dave@krondo.com> 2000-07-22 Dave Peticolas <dave@krondo.com>
* src/gnome/window-reconcile.c: After reconciliation, if the * src/gnome/window-reconcile.c: After reconciliation, if the

View File

@ -140,11 +140,11 @@ struct _SRInfo
int cursor_hint_phys_col; int cursor_hint_phys_col;
/* If the hints were set by the traverse callback */ /* If the hints were set by the traverse callback */
gncBoolean hint_set_by_traverse; gboolean hint_set_by_traverse;
/* A flag indicating if the last traversal was 'exact'. /* A flag indicating if the last traversal was 'exact'.
* See table-allgui.[ch] for details. */ * See table-allgui.[ch] for details. */
gncBoolean exact_traversal; gboolean exact_traversal;
/* The default account where new splits are added */ /* The default account where new splits are added */
Account *default_source_account; Account *default_source_account;
@ -153,7 +153,7 @@ struct _SRInfo
time_t last_date_entered; time_t last_date_entered;
/* true if the current blank split has been edited and commited */ /* true if the current blank split has been edited and commited */
gncBoolean blank_split_edited; gboolean blank_split_edited;
/* User data for users of SplitRegisters */ /* User data for users of SplitRegisters */
void *user_data; void *user_data;
@ -391,7 +391,7 @@ gnc_copy_split_onto_split(Split *from, Split *to)
/* Uses the scheme transaction copying routines */ /* Uses the scheme transaction copying routines */
static void static void
gnc_copy_trans_onto_trans(Transaction *from, Transaction *to, gnc_copy_trans_onto_trans(Transaction *from, Transaction *to,
gncBoolean do_commit) gboolean do_commit)
{ {
SCM trans_scm; SCM trans_scm;
@ -544,8 +544,11 @@ gnc_find_split_in_reg_by_memo(SplitRegister *reg, const char *memo,
for (virt_row = num_rows - 1; virt_row >= 0; virt_row--) for (virt_row = num_rows - 1; virt_row >= 0; virt_row--)
for (virt_col = num_cols - 1; virt_col >= 0; virt_col--) for (virt_col = num_cols - 1; virt_col >= 0; virt_col--)
{ {
Split *split = table->user_data[virt_row][virt_col]; Split *split;
Transaction *trans = xaccSplitGetParent(split); Transaction *trans;
split = gnc_table_get_user_data_virtual (table, virt_row, virt_col);
trans = xaccSplitGetParent(split);
if (trans == last_trans) if (trans == last_trans)
continue; continue;
@ -584,8 +587,11 @@ gnc_find_trans_in_reg_by_desc(SplitRegister *reg, const char *description)
for (virt_row = num_rows - 1; virt_row >= 0; virt_row--) for (virt_row = num_rows - 1; virt_row >= 0; virt_row--)
for (virt_col = num_cols - 1; virt_col >= 0; virt_col--) for (virt_col = num_cols - 1; virt_col >= 0; virt_col--)
{ {
Split *split = table->user_data[virt_row][virt_col]; Split *split;
Transaction *trans = xaccSplitGetParent(split); Transaction *trans;
split = gnc_table_get_user_data_virtual (table, virt_row, virt_col);
trans = xaccSplitGetParent(split);
if (trans == last_trans) if (trans == last_trans)
continue; continue;
@ -624,24 +630,23 @@ gnc_find_trans_in_reg_by_desc(SplitRegister *reg, const char *description)
static void static void
LedgerMoveCursor (Table *table, LedgerMoveCursor (Table *table,
int *p_new_phys_row, int *p_new_phys_row,
int *p_new_phys_col, int *p_new_phys_col)
void * client_data)
{ {
int new_phys_row = *p_new_phys_row; int new_phys_row = *p_new_phys_row;
int new_phys_col = *p_new_phys_col; int new_phys_col = *p_new_phys_col;
SplitRegister *reg = client_data; SplitRegister *reg = table->user_data;
SRInfo *info = xaccSRGetInfo(reg); SRInfo *info = xaccSRGetInfo(reg);
Transaction *pending_trans = xaccTransLookup(&info->pending_trans_guid); Transaction *pending_trans = xaccTransLookup(&info->pending_trans_guid);
Transaction *new_trans; Transaction *new_trans;
Transaction *trans; Transaction *trans;
PhysicalCell *pcell;
Split *trans_split; Split *trans_split;
Split *new_split; Split *new_split;
gncBoolean saved;
Locator *locator;
int new_cell_row; int new_cell_row;
int new_cell_col; int new_cell_col;
int phys_row_offset; int phys_row_offset;
int phys_col_offset; int phys_col_offset;
gboolean saved;
PINFO ("start callback %d %d \n", new_phys_row, new_phys_col); PINFO ("start callback %d %d \n", new_phys_row, new_phys_col);
@ -658,7 +663,8 @@ LedgerMoveCursor (Table *table,
new_trans = xaccSRGetTrans(reg, new_phys_row, new_phys_col); new_trans = xaccSRGetTrans(reg, new_phys_row, new_phys_col);
/* The split we are moving to */ /* The split we are moving to */
new_split = xaccGetUserData(reg->table, new_phys_row, new_phys_col); new_split = gnc_table_get_user_data_physical(reg->table,
new_phys_row, new_phys_col);
/* The split at the transaction line we are moving to */ /* The split at the transaction line we are moving to */
trans_split = xaccSRGetTransSplit(reg, new_phys_row, new_phys_col); trans_split = xaccSRGetTransSplit(reg, new_phys_row, new_phys_col);
@ -680,9 +686,10 @@ LedgerMoveCursor (Table *table,
} }
else else
{ {
locator = table->locators[new_phys_row][new_phys_col]; pcell = gnc_table_get_physical_cell (table, new_phys_row, new_phys_col);
new_cell_row = locator->phys_row_offset;
new_cell_col = locator->phys_col_offset; new_cell_row = pcell->virt_loc.phys_row_offset;
new_cell_col = pcell->virt_loc.phys_col_offset;
} }
/* commit the contents of the cursor into the database */ /* commit the contents of the cursor into the database */
@ -708,12 +715,12 @@ LedgerMoveCursor (Table *table,
* then it may have moved. Find out where it is now. */ * then it may have moved. Find out where it is now. */
if (xaccSRGetTransSplitRowCol (reg, new_trans, trans_split, new_split, if (xaccSRGetTransSplitRowCol (reg, new_trans, trans_split, new_split,
&virt_row, &virt_col)) { &virt_row, &virt_col)) {
RevLocator *rev_locator; VirtualCell *vcell;
rev_locator = table->rev_locators[virt_row][virt_col]; vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col);
new_phys_row = rev_locator->phys_row; new_phys_row = vcell->phys_loc.phys_row;
new_phys_col = rev_locator->phys_col; new_phys_col = vcell->phys_loc.phys_col;
new_phys_row += new_cell_row; new_phys_row += new_cell_row;
new_phys_col += new_cell_col; new_phys_col += new_cell_col;
@ -751,8 +758,8 @@ LedgerMoveCursor (Table *table,
reg->cursor_phys_row = new_phys_row; reg->cursor_phys_row = new_phys_row;
locator = table->locators[new_phys_row][new_phys_col]; pcell = gnc_table_get_physical_cell (table, new_phys_row, new_phys_col);
reg->cursor_virt_row = locator->virt_row; reg->cursor_virt_row = pcell->virt_loc.virt_row;
/* if auto-expansion is enabled, we need to redraw the register /* if auto-expansion is enabled, we need to redraw the register
* to expand out the splits at the new location. We use the * to expand out the splits at the new location. We use the
@ -767,7 +774,8 @@ LedgerMoveCursor (Table *table,
trans_split = xaccSRGetTransSplit(reg, new_phys_row, new_phys_col); trans_split = xaccSRGetTransSplit(reg, new_phys_row, new_phys_col);
info->cursor_hint_trans_split = trans_split; info->cursor_hint_trans_split = trans_split;
new_split = xaccGetUserData (reg->table, new_phys_row, new_phys_col); new_split = gnc_table_get_user_data_physical (reg->table,
new_phys_row, new_phys_col);
info->cursor_hint_split = new_split; info->cursor_hint_split = new_split;
info->cursor_hint_phys_col = new_phys_col; info->cursor_hint_phys_col = new_phys_col;
@ -1002,10 +1010,10 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir,
xaccBasicCellSetChanged (&(reg->ncreditCell->cell), GNC_T); xaccBasicCellSetChanged (&(reg->ncreditCell->cell), GNC_T);
/* copy cursor contents into the table */ /* copy cursor contents into the table */
xaccCommitCursor (reg->table); gnc_table_commit_cursor (reg->table);
/* and refresh the gui */ /* and refresh the gui */
xaccRefreshTableGUI (reg->table); gnc_table_refresh_gui (reg->table);
/* now move to the non-empty amount column */ /* now move to the non-empty amount column */
amount = xaccSplitGetShareAmount (auto_split); amount = xaccSplitGetShareAmount (auto_split);
@ -1036,10 +1044,9 @@ static void
LedgerTraverse (Table *table, LedgerTraverse (Table *table,
int *p_new_phys_row, int *p_new_phys_row,
int *p_new_phys_col, int *p_new_phys_col,
gncTableTraversalDir dir, gncTableTraversalDir dir)
void * client_data)
{ {
SplitRegister *reg = client_data; SplitRegister *reg = table->user_data;
SRInfo *info = xaccSRGetInfo(reg); SRInfo *info = xaccSRGetInfo(reg);
Transaction *pending_trans = xaccTransLookup(&info->pending_trans_guid); Transaction *pending_trans = xaccTransLookup(&info->pending_trans_guid);
Transaction *trans, *new_trans; Transaction *trans, *new_trans;
@ -1061,7 +1068,7 @@ LedgerTraverse (Table *table,
changed = xaccSplitRegisterGetChangeFlag(reg); changed = xaccSplitRegisterGetChangeFlag(reg);
if (!changed && (pending_trans != trans)) if (!changed && (pending_trans != trans))
{ {
if (gnc_register_cell_valid(table, phys_row, phys_col, GNC_F)) if (gnc_table_physical_cell_valid(table, phys_row, phys_col, FALSE))
return; return;
if (phys_row < reg->num_header_rows) if (phys_row < reg->num_header_rows)
@ -1083,8 +1090,12 @@ LedgerTraverse (Table *table,
if ((phys_row >= 0) && (phys_col >= 0) && if ((phys_row >= 0) && (phys_col >= 0) &&
(phys_row < table->num_phys_rows) && (phys_col < table->num_phys_cols)) (phys_row < table->num_phys_rows) && (phys_col < table->num_phys_cols))
{ {
virt_row = table->locators[phys_row][phys_col]->virt_row; PhysicalCell *pcell;
virt_col = table->locators[phys_row][phys_col]->virt_col;
pcell = gnc_table_get_physical_cell (table, phys_row, phys_col);
virt_row = pcell->virt_loc.virt_row;
virt_col = pcell->virt_loc.virt_col;
if ((virt_row == table->current_cursor_virt_row) && if ((virt_row == table->current_cursor_virt_row) &&
(virt_col == table->current_cursor_virt_col)) (virt_col == table->current_cursor_virt_col))
@ -1148,7 +1159,8 @@ LedgerTraverse (Table *table,
Split *new_split; Split *new_split;
Split *trans_split; Split *trans_split;
new_split = xaccGetUserData(reg->table, phys_row, phys_col); new_split = gnc_table_get_user_data_physical(reg->table,
phys_row, phys_col);
trans_split = xaccSRGetTransSplit(reg, phys_row, phys_col); trans_split = xaccSRGetTransSplit(reg, phys_row, phys_col);
xaccSRCancelCursorTransChanges(reg); xaccSRCancelCursorTransChanges(reg);
@ -1156,11 +1168,11 @@ LedgerTraverse (Table *table,
if (xaccSRGetTransSplitRowCol (reg, new_trans, trans_split, new_split, if (xaccSRGetTransSplitRowCol (reg, new_trans, trans_split, new_split,
&virt_row, &virt_col)) &virt_row, &virt_col))
{ {
RevLocator *rev_locator; VirtualCell *vcell;
rev_locator = table->rev_locators[virt_row][virt_col]; vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col);
phys_row = rev_locator->phys_row; phys_row = vcell->phys_loc.phys_row;
} }
if (phys_row >= table->num_phys_rows) if (phys_row >= table->num_phys_rows)
@ -1185,9 +1197,9 @@ LedgerTraverse (Table *table,
/* ======================================================== */ /* ======================================================== */
static void static void
LedgerSetHelp (Table *table, const char *help_str, void *client_data) LedgerSetHelp (Table *table, const char *help_str)
{ {
SplitRegister *reg = client_data; SplitRegister *reg = table->user_data;
SRInfo *info = xaccSRGetInfo(reg); SRInfo *info = xaccSRGetInfo(reg);
if (info->set_help == NULL) if (info->set_help == NULL)
@ -1219,7 +1231,7 @@ LedgerDestroy (SplitRegister *reg)
pending_trans = NULL; pending_trans = NULL;
} }
xaccTransBeginEdit (trans, 1); xaccTransBeginEdit (trans, TRUE);
xaccTransDestroy (trans); xaccTransDestroy (trans);
xaccTransCommitEdit (trans); xaccTransCommitEdit (trans);
@ -1245,24 +1257,24 @@ static Transaction *
xaccSRGetTrans (SplitRegister *reg, int phys_row, int phys_col) xaccSRGetTrans (SplitRegister *reg, int phys_row, int phys_col)
{ {
Split *split; Split *split;
PhysicalCell *pcell;
int virt_row, virt_col; int virt_row, virt_col;
if (reg == NULL) if (reg == NULL)
return NULL; return NULL;
if ((phys_row < 0) || (phys_col < 0) || pcell = gnc_table_get_physical_cell (reg->table, phys_row, phys_col);
(phys_row >= reg->table->num_phys_rows) || if (pcell == NULL)
(phys_col >= reg->table->num_phys_cols))
return NULL; return NULL;
split = xaccGetUserData(reg->table, phys_row, phys_col); split = gnc_table_get_user_data_physical (reg->table, phys_row, phys_col);
if (split != NULL) if (split != NULL)
return xaccSplitGetParent(split); return xaccSplitGetParent(split);
/* Split is blank. Assume it is the blank split of a multi-line /* Split is blank. Assume it is the blank split of a multi-line
* transaction. Go back one row to find a split in the transaction. */ * transaction. Go back one row to find a split in the transaction. */
virt_row = reg->table->locators[phys_row][phys_col]->virt_row; virt_row = pcell->virt_loc.virt_row;
virt_col = reg->table->locators[phys_row][phys_col]->virt_col; virt_col = pcell->virt_loc.virt_col;
virt_row --; virt_row --;
if ((0 > virt_row) || (0 > virt_col)) { if ((0 > virt_row) || (0 > virt_col)) {
@ -1270,7 +1282,7 @@ xaccSRGetTrans (SplitRegister *reg, int phys_row, int phys_col)
return NULL; return NULL;
} }
split = (Split *) reg->table->user_data[virt_row][virt_col]; split = gnc_table_get_user_data_virtual (reg->table, virt_row, virt_col);
if (split == NULL) { if (split == NULL) {
PERR ("no parent \n"); PERR ("no parent \n");
return NULL; return NULL;
@ -1286,24 +1298,24 @@ xaccSRGetTransSplit (SplitRegister *reg, int phys_row, int phys_col)
{ {
CursorType cursor_type; CursorType cursor_type;
int virt_row, virt_col; int virt_row, virt_col;
PhysicalCell *pcell;
if (reg == NULL) if (reg == NULL)
return NULL; return NULL;
if ((phys_row < 0) || (phys_col < 0) || pcell = gnc_table_get_physical_cell (reg->table, phys_row, phys_col);
(phys_row >= reg->table->num_phys_rows) || if (pcell == NULL)
(phys_col >= reg->table->num_phys_cols))
return NULL; return NULL;
virt_row = reg->table->locators[phys_row][phys_col]->virt_row; virt_row = pcell->virt_loc.virt_row;
virt_col = reg->table->locators[phys_row][phys_col]->virt_col; virt_col = pcell->virt_loc.virt_col;
while (1) while (1)
{ {
cursor_type = xaccSplitRegisterGetCursorTypeRowCol (reg, cursor_type = xaccSplitRegisterGetCursorTypeRowCol (reg,
virt_row, virt_col); virt_row, virt_col);
if (cursor_type == CURSOR_TRANS) if (cursor_type == CURSOR_TRANS)
return reg->table->user_data[virt_row][virt_col]; return gnc_table_get_user_data_virtual (reg->table, virt_row, virt_col);
virt_row --; virt_row --;
@ -1320,6 +1332,7 @@ static Split *
xaccSRGetCurrentTransSplit (SplitRegister *reg) xaccSRGetCurrentTransSplit (SplitRegister *reg)
{ {
Split *split; Split *split;
PhysicalCell *pcell;
CursorType cursor_type; CursorType cursor_type;
int phys_row, phys_col; int phys_row, phys_col;
int virt_row, virt_col; int virt_row, virt_col;
@ -1338,13 +1351,12 @@ xaccSRGetCurrentTransSplit (SplitRegister *reg)
phys_row = reg->table->current_cursor_phys_row; phys_row = reg->table->current_cursor_phys_row;
phys_col = reg->table->current_cursor_phys_col; phys_col = reg->table->current_cursor_phys_col;
if ((phys_row < 0) || (phys_col < 0) || pcell = gnc_table_get_physical_cell (reg->table, phys_row, phys_col);
(phys_row >= reg->table->num_phys_rows) || if (pcell == NULL)
(phys_col >= reg->table->num_phys_cols))
return NULL; return NULL;
virt_row = reg->table->locators[phys_row][phys_col]->virt_row; virt_row = pcell->virt_loc.virt_row;
virt_col = reg->table->locators[phys_row][phys_col]->virt_col; virt_col = pcell->virt_loc.virt_col;
while (1) while (1)
{ {
@ -1358,7 +1370,7 @@ xaccSRGetCurrentTransSplit (SplitRegister *reg)
cursor_type = xaccSplitRegisterGetCursorTypeRowCol (reg, cursor_type = xaccSplitRegisterGetCursorTypeRowCol (reg,
virt_row, virt_col); virt_row, virt_col);
if (cursor_type == CURSOR_TRANS) if (cursor_type == CURSOR_TRANS)
return reg->table->user_data[virt_row][virt_col]; return gnc_table_get_user_data_virtual (reg->table, virt_row, virt_col);
} }
} }
@ -1368,6 +1380,7 @@ Transaction *
xaccSRGetCurrentTrans (SplitRegister *reg) xaccSRGetCurrentTrans (SplitRegister *reg)
{ {
Split *split; Split *split;
PhysicalCell *pcell;
int phys_row, phys_col; int phys_row, phys_col;
int virt_row, virt_col; int virt_row, virt_col;
@ -1383,13 +1396,12 @@ xaccSRGetCurrentTrans (SplitRegister *reg)
phys_row = reg->table->current_cursor_phys_row; phys_row = reg->table->current_cursor_phys_row;
phys_col = reg->table->current_cursor_phys_col; phys_col = reg->table->current_cursor_phys_col;
if ((phys_row < 0) || (phys_col < 0) || pcell = gnc_table_get_physical_cell (reg->table, phys_row, phys_col);
(phys_row >= reg->table->num_phys_rows) || if (pcell == NULL)
(phys_col >= reg->table->num_phys_cols))
return NULL; return NULL;
virt_row = reg->table->locators[phys_row][phys_col]->virt_row; virt_row = pcell->virt_loc.virt_row;
virt_col = reg->table->locators[phys_row][phys_col]->virt_col; virt_col = pcell->virt_loc.virt_col;
virt_row --; virt_row --;
if ((0 > virt_row) || (0 > virt_col)) { if ((0 > virt_row) || (0 > virt_col)) {
@ -1397,7 +1409,7 @@ xaccSRGetCurrentTrans (SplitRegister *reg)
return NULL; return NULL;
} }
split = (Split *) reg->table->user_data[virt_row][virt_col]; split = gnc_table_get_user_data_virtual (reg->table, virt_row, virt_col);
return xaccSplitGetParent(split); return xaccSplitGetParent(split);
} }
@ -1431,7 +1443,7 @@ xaccSRGetBlankSplit (SplitRegister *reg)
/* ======================================================== */ /* ======================================================== */
gncBoolean gboolean
xaccSRGetSplitRowCol (SplitRegister *reg, Split *split, xaccSRGetSplitRowCol (SplitRegister *reg, Split *split,
int *virt_row, int *virt_col) int *virt_row, int *virt_col)
{ {
@ -1442,7 +1454,7 @@ xaccSRGetSplitRowCol (SplitRegister *reg, Split *split,
for (v_row = 1; v_row < table->num_virt_rows; v_row++) for (v_row = 1; v_row < table->num_virt_rows; v_row++)
for (v_col = 0; v_col < table->num_virt_cols; v_col++) for (v_col = 0; v_col < table->num_virt_cols; v_col++)
{ {
s = (Split *) table->user_data[v_row][v_col]; s = gnc_table_get_user_data_virtual (table, v_row, v_col);
if (s == split) if (s == split)
{ {
@ -1460,15 +1472,15 @@ xaccSRGetSplitRowCol (SplitRegister *reg, Split *split,
/* ======================================================== */ /* ======================================================== */
gncBoolean gboolean
xaccSRGetTransSplitRowCol (SplitRegister *reg, Transaction *trans, xaccSRGetTransSplitRowCol (SplitRegister *reg, Transaction *trans,
Split *trans_split, Split *split, Split *trans_split, Split *split,
int *virt_row, int *virt_col) int *virt_row, int *virt_col)
{ {
Table *table = reg->table; Table *table = reg->table;
gncBoolean found_trans = GNC_F; gboolean found_trans = GNC_F;
gncBoolean found_trans_split = GNC_F; gboolean found_trans_split = GNC_F;
gncBoolean found_something = GNC_F; gboolean found_something = GNC_F;
CursorType cursor_type; CursorType cursor_type;
int v_row, v_col; int v_row, v_col;
Transaction *t; Transaction *t;
@ -1477,7 +1489,7 @@ xaccSRGetTransSplitRowCol (SplitRegister *reg, Transaction *trans,
for (v_row = 1; v_row < table->num_virt_rows; v_row++) for (v_row = 1; v_row < table->num_virt_rows; v_row++)
for (v_col = 0; v_col < table->num_virt_cols; v_col++) for (v_col = 0; v_col < table->num_virt_cols; v_col++)
{ {
s = table->user_data[v_row][v_col]; s = gnc_table_get_user_data_virtual (table, v_row, v_col);
t = xaccSplitGetParent(s); t = xaccSplitGetParent(s);
cursor_type = xaccSplitRegisterGetCursorTypeRowCol(reg, v_row, v_col); cursor_type = xaccSplitRegisterGetCursorTypeRowCol(reg, v_row, v_col);
@ -1908,8 +1920,8 @@ xaccSRDeleteCurrentSplit (SplitRegister *reg)
account = xaccSplitGetAccount(split); account = xaccSplitGetAccount(split);
xaccTransBeginEdit(trans, 1); xaccTransBeginEdit(trans, TRUE);
xaccAccountBeginEdit(account, 1); xaccAccountBeginEdit(account, TRUE);
xaccSplitDestroy(split); xaccSplitDestroy(split);
xaccAccountCommitEdit(account); xaccAccountCommitEdit(account);
xaccTransCommitEdit(trans); xaccTransCommitEdit(trans);
@ -1960,7 +1972,7 @@ xaccSRDeleteCurrentTrans (SplitRegister *reg)
pending_trans = NULL; pending_trans = NULL;
} }
xaccTransBeginEdit (trans, 1); xaccTransBeginEdit (trans, TRUE);
xaccTransDestroy (trans); xaccTransDestroy (trans);
xaccTransCommitEdit (trans); xaccTransCommitEdit (trans);
@ -1978,7 +1990,7 @@ xaccSRDeleteCurrentTrans (SplitRegister *reg)
accounts = gnc_trans_prepend_account_list(trans, NULL); accounts = gnc_trans_prepend_account_list(trans, NULL);
xaccTransBeginEdit(trans, 1); xaccTransBeginEdit(trans, TRUE);
xaccTransDestroy(trans); xaccTransDestroy(trans);
xaccTransCommitEdit(trans); xaccTransCommitEdit(trans);
@ -2030,7 +2042,7 @@ xaccSREmptyCurrentTrans (SplitRegister *reg)
pending_trans = NULL; pending_trans = NULL;
} }
xaccTransBeginEdit (trans, 1); xaccTransBeginEdit (trans, TRUE);
xaccTransDestroy (trans); xaccTransDestroy (trans);
xaccTransCommitEdit (trans); xaccTransCommitEdit (trans);
@ -2049,7 +2061,7 @@ xaccSREmptyCurrentTrans (SplitRegister *reg)
accounts = gnc_trans_prepend_account_list(trans, NULL); accounts = gnc_trans_prepend_account_list(trans, NULL);
splits = gnc_trans_prepend_split_list(trans, NULL); splits = gnc_trans_prepend_split_list(trans, NULL);
xaccTransBeginEdit(trans, 1); xaccTransBeginEdit(trans, TRUE);
for (node = splits; node; node = node->next) for (node = splits; node; node = node->next)
if (node->data != split) if (node->data != split)
xaccSplitDestroy(node->data); xaccSplitDestroy(node->data);
@ -2090,9 +2102,9 @@ xaccSRCancelCursorSplitChanges (SplitRegister *reg)
xaccSplitRegisterClearChangeFlag(reg); xaccSplitRegisterClearChangeFlag(reg);
if (gnc_table_find_valid_cell_horiz(reg->table, &row, &col, GNC_F)) if (gnc_table_find_valid_cell_horiz(reg->table, &row, &col, GNC_F))
xaccMoveCursorGUI(reg->table, row, col); gnc_table_move_cursor_gui(reg->table, row, col);
xaccRefreshTableGUI(reg->table); gnc_table_refresh_gui(reg->table);
} }
/* ======================================================== */ /* ======================================================== */
@ -2155,7 +2167,7 @@ xaccSRRedrawRegEntry (SplitRegister *reg)
/* Copy from the register object to scheme. This needs to be /* Copy from the register object to scheme. This needs to be
* in sync with xaccSRSaveRegEntry and xaccSRSaveChangedCells. */ * in sync with xaccSRSaveRegEntry and xaccSRSaveChangedCells. */
static gncBoolean static gboolean
xaccSRSaveRegEntryToSCM (SplitRegister *reg, SCM trans_scm, SCM split_scm) xaccSRSaveRegEntryToSCM (SplitRegister *reg, SCM trans_scm, SCM split_scm)
{ {
Transaction *trans; Transaction *trans;
@ -2313,8 +2325,8 @@ xaccSRSaveRegEntryToSCM (SplitRegister *reg, SCM trans_scm, SCM split_scm)
/* ======================================================== */ /* ======================================================== */
/* Copy from the register object to the engine */ /* Copy from the register object to the engine */
gncBoolean gboolean
xaccSRSaveRegEntry (SplitRegister *reg, gncBoolean do_commit) xaccSRSaveRegEntry (SplitRegister *reg, gboolean do_commit)
{ {
GList *refresh_accounts; GList *refresh_accounts;
SRInfo *info = xaccSRGetInfo(reg); SRInfo *info = xaccSRGetInfo(reg);
@ -2914,7 +2926,7 @@ xaccSRLoadRegEntry (SplitRegister *reg, Split *split)
{ {
Split *s = xaccGetOtherSplit (split); Split *s = xaccGetOtherSplit (split);
gncBoolean need_to_free = GNC_F; gboolean need_to_free = GNC_F;
if (s) { if (s) {
accname = xaccAccountGetFullName (xaccSplitGetAccount (s), accname = xaccAccountGetFullName (xaccSplitGetAccount (s),
@ -2955,7 +2967,7 @@ xaccSRLoadRegEntry (SplitRegister *reg, Split *split)
reg->table->current_cursor->user_data = split; reg->table->current_cursor->user_data = split;
/* copy cursor contents into the table */ /* copy cursor contents into the table */
xaccCommitCursor (reg->table); gnc_table_commit_cursor (reg->table);
LEAVE("SRLoadTransEntry()\n"); LEAVE("SRLoadTransEntry()\n");
} }
@ -2976,24 +2988,24 @@ xaccSRCountRows (SplitRegister *reg,
SRInfo *info = xaccSRGetInfo(reg); SRInfo *info = xaccSRGetInfo(reg);
Split *blank_split = xaccSplitLookup(&info->blank_split_guid); Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
CellBlock *lead_cursor; CellBlock *lead_cursor;
PhysicalCell *pcell;
Transaction *trans; Transaction *trans;
Split *split; Split *split;
Locator *locator;
Table *table; Table *table;
gncBoolean found_split = GNC_F; gboolean found_split = GNC_F;
gncBoolean found_trans = GNC_F; gboolean found_trans = GNC_F;
gncBoolean found_trans_split = GNC_F; gboolean found_trans_split = GNC_F;
gncBoolean on_blank_split = GNC_F; gboolean on_blank_split = GNC_F;
gncBoolean did_expand = GNC_F; gboolean did_expand = GNC_F;
gncBoolean on_trans_split; gboolean on_trans_split;
gncBoolean multi_line; gboolean multi_line;
gncBoolean dynamic; gboolean dynamic;
SplitRegisterStyle style; SplitRegisterStyle style;
int save_cursor_phys_row; int save_cursor_phys_row;
int save_cursor_virt_row; int save_cursor_virt_row;
int save_cell_row; int save_cell_row = -1;
int num_phys_rows; int num_phys_rows;
int num_virt_rows; int num_virt_rows;
int i; int i;
@ -3002,12 +3014,10 @@ xaccSRCountRows (SplitRegister *reg,
style = reg->style; style = reg->style;
multi_line = (REG_MULTI_LINE == style); multi_line = (REG_MULTI_LINE == style);
dynamic = ((REG_SINGLE_DYNAMIC == style) || (REG_DOUBLE_DYNAMIC == style)); dynamic = ((REG_SINGLE_DYNAMIC == style) || (REG_DOUBLE_DYNAMIC == style));
if ((REG_SINGLE_LINE == style) || if ((REG_SINGLE_LINE == style) || (REG_SINGLE_DYNAMIC == style))
(REG_SINGLE_DYNAMIC == style)) {
lead_cursor = reg->single_cursor; lead_cursor = reg->single_cursor;
} else { else
lead_cursor = reg->double_cursor; lead_cursor = reg->double_cursor;
}
/* save the current cursor location; if we can't find the /* save the current cursor location; if we can't find the
* requested transaction/split pair, we restore the * requested transaction/split pair, we restore the
@ -3016,9 +3026,11 @@ xaccSRCountRows (SplitRegister *reg,
save_cursor_virt_row = reg->cursor_virt_row; save_cursor_virt_row = reg->cursor_virt_row;
/* save the current cell row offset */ /* save the current cell row offset */
locator = table->locators[reg->table->current_cursor_phys_row] pcell = gnc_table_get_physical_cell (table,
[reg->table->current_cursor_phys_col]; table->current_cursor_phys_row,
save_cell_row = locator->phys_row_offset; table->current_cursor_phys_col);
if (pcell)
save_cell_row = pcell->virt_loc.phys_row_offset;
if (save_cell_row < 0) if (save_cell_row < 0)
save_cell_row = 0; save_cell_row = 0;
@ -3066,7 +3078,7 @@ xaccSRCountRows (SplitRegister *reg,
while (split) { while (split) {
/* do not count the blank split */ /* do not count the blank split */
if (split != blank_split) { if (split != blank_split) {
gncBoolean do_expand; gboolean do_expand;
trans = xaccSplitGetParent(split); trans = xaccSplitGetParent(split);
@ -3288,14 +3300,14 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
Split *split; Split *split;
Table *table; Table *table;
gncBoolean found_pending = GNC_F; gboolean found_pending = GNC_F;
gncBoolean found_split = GNC_F; gboolean found_split = GNC_F;
gncBoolean found_trans = GNC_F; gboolean found_trans = GNC_F;
gncBoolean found_trans_split = GNC_F; gboolean found_trans_split = GNC_F;
gncBoolean did_expand = GNC_F; gboolean did_expand = GNC_F;
gncBoolean on_blank_split; gboolean on_blank_split;
gncBoolean multi_line; gboolean multi_line;
gncBoolean dynamic; gboolean dynamic;
SplitRegisterType type; SplitRegisterType type;
SplitRegisterStyle style; SplitRegisterStyle style;
@ -3313,7 +3325,7 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
trans = xaccMallocTransaction (); trans = xaccMallocTransaction ();
xaccTransBeginEdit (trans, 1); xaccTransBeginEdit (trans, TRUE);
xaccTransSetDateSecs(trans, info->last_date_entered); xaccTransSetDateSecs(trans, info->last_date_entered);
xaccTransCommitEdit (trans); xaccTransCommitEdit (trans);
@ -3374,15 +3386,15 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
/* disable move callback -- we don't want the cascade of /* disable move callback -- we don't want the cascade of
* callbacks while we are fiddling with loading the register */ * callbacks while we are fiddling with loading the register */
table->move_cursor = NULL; table->move_cursor = NULL;
xaccMoveCursorGUI (table, -1, -1); gnc_table_move_cursor_gui (table, -1, -1);
/* resize the table to the sizes we just counted above */ /* resize the table to the sizes we just counted above */
/* num_virt_cols is always one. */ /* num_virt_cols is always one. */
xaccSetTableSize (table, reg->num_phys_rows, reg->num_cols, gnc_table_set_size (table, reg->num_phys_rows, reg->num_cols,
reg->num_virt_rows, 1); reg->num_virt_rows, 1);
/* make sure that the header is loaded */ /* make sure that the header is loaded */
xaccSetCursor (table, reg->header, 0, 0, 0, 0); gnc_table_set_cursor (table, reg->header, 0, 0, 0, 0);
PINFO ("load register of %d phys rows ----------- \n", reg->num_phys_rows); PINFO ("load register of %d phys rows ----------- \n", reg->num_phys_rows);
@ -3404,7 +3416,7 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
/* do not load the blank split */ /* do not load the blank split */
if (split != blank_split) { if (split != blank_split) {
Transaction *trans; Transaction *trans;
gncBoolean do_expand; gboolean do_expand;
PINFO ("load trans %d at phys row %d \n", i, phys_row); PINFO ("load trans %d at phys row %d \n", i, phys_row);
@ -3434,8 +3446,9 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
Split * secondary; Split * secondary;
int j = 0; int j = 0;
xaccSetCursor (table, reg->trans_cursor, phys_row, 0, vrow, 0); gnc_table_set_cursor (table, reg->trans_cursor,
xaccMoveCursor (table, phys_row, 0); phys_row, 0, vrow, 0);
gnc_table_move_cursor (table, phys_row, 0);
xaccSRLoadRegEntry (reg, split); xaccSRLoadRegEntry (reg, split);
vrow ++; vrow ++;
phys_row += reg->trans_cursor->numRows; phys_row += reg->trans_cursor->numRows;
@ -3448,9 +3461,9 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
secondary = xaccTransGetSplit (trans, j); secondary = xaccTransGetSplit (trans, j);
if (secondary != split) { if (secondary != split) {
xaccSetCursor (table, reg->split_cursor, gnc_table_set_cursor (table, reg->split_cursor,
phys_row, 0, vrow, 0); phys_row, 0, vrow, 0);
xaccMoveCursor (table, phys_row, 0); gnc_table_move_cursor (table, phys_row, 0);
xaccSRLoadRegEntry (reg, secondary); xaccSRLoadRegEntry (reg, secondary);
PINFO ("load split %d at phys row %d addr=%p \n", PINFO ("load split %d at phys row %d addr=%p \n",
j, phys_row, secondary); j, phys_row, secondary);
@ -3463,8 +3476,8 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
} else { } else {
/* the simple case ... */ /* the simple case ... */
xaccSetCursor (table, lead_cursor, phys_row, 0, vrow, 0); gnc_table_set_cursor (table, lead_cursor, phys_row, 0, vrow, 0);
xaccMoveCursor (table, phys_row, 0); gnc_table_move_cursor (table, phys_row, 0);
xaccSRLoadRegEntry (reg, split); xaccSRLoadRegEntry (reg, split);
vrow ++; vrow ++;
phys_row += lead_cursor->numRows; phys_row += lead_cursor->numRows;
@ -3486,8 +3499,8 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
if (multi_line || (dynamic && info->blank_split_edited)) { if (multi_line || (dynamic && info->blank_split_edited)) {
/* do the transaction row of the blank split */ /* do the transaction row of the blank split */
xaccSetCursor (table, reg->trans_cursor, phys_row, 0, vrow, 0); gnc_table_set_cursor (table, reg->trans_cursor, phys_row, 0, vrow, 0);
xaccMoveCursor (table, phys_row, 0); gnc_table_move_cursor (table, phys_row, 0);
xaccSRLoadRegEntry (reg, split); xaccSRLoadRegEntry (reg, split);
vrow ++; vrow ++;
phys_row += reg->trans_cursor->numRows; phys_row += reg->trans_cursor->numRows;
@ -3503,9 +3516,9 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
secondary = xaccTransGetSplit (trans, j); secondary = xaccTransGetSplit (trans, j);
if (secondary != split) { if (secondary != split) {
xaccSetCursor (table, reg->split_cursor, gnc_table_set_cursor (table, reg->split_cursor,
phys_row, 0, vrow, 0); phys_row, 0, vrow, 0);
xaccMoveCursor (table, phys_row, 0); gnc_table_move_cursor (table, phys_row, 0);
xaccSRLoadRegEntry (reg, secondary); xaccSRLoadRegEntry (reg, secondary);
PINFO ("load split %d at phys row %d addr=%p \n", PINFO ("load split %d at phys row %d addr=%p \n",
j, phys_row, secondary); j, phys_row, secondary);
@ -3517,8 +3530,8 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
} while (secondary); } while (secondary);
} }
} else { } else {
xaccSetCursor (table, lead_cursor, phys_row, 0, vrow, 0); gnc_table_set_cursor (table, lead_cursor, phys_row, 0, vrow, 0);
xaccMoveCursor (table, phys_row, 0); gnc_table_move_cursor (table, phys_row, 0);
xaccSRLoadRegEntry (reg, split); xaccSRLoadRegEntry (reg, split);
vrow ++; vrow ++;
phys_row += lead_cursor->numRows; phys_row += lead_cursor->numRows;
@ -3531,13 +3544,13 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
if (gnc_table_find_valid_cell_horiz(table, &row, &col, GNC_F)) if (gnc_table_find_valid_cell_horiz(table, &row, &col, GNC_F))
{ {
xaccMoveCursorGUI(table, row, col); gnc_table_move_cursor_gui(table, row, col);
reg->cursor_phys_row = row; reg->cursor_phys_row = row;
if (reg_buffer != NULL) if (reg_buffer != NULL)
{ {
xaccSplitRegisterRestoreCursorChanged(reg, reg_buffer); xaccSplitRegisterRestoreCursorChanged(reg, reg_buffer);
xaccCommitCursor (table); gnc_table_commit_cursor (table);
} }
} }
@ -3567,7 +3580,7 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
info->hint_set_by_traverse = GNC_F; info->hint_set_by_traverse = GNC_F;
info->exact_traversal = GNC_F; info->exact_traversal = GNC_F;
xaccRefreshTableGUI (table); gnc_table_refresh_gui (table);
/* set the completion character for the xfer cells */ /* set the completion character for the xfer cells */
xaccComboCellSetCompleteChar (reg->mxfrmCell, account_separator); xaccComboCellSetCompleteChar (reg->mxfrmCell, account_separator);
@ -3578,7 +3591,7 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
table->move_cursor = LedgerMoveCursor; table->move_cursor = LedgerMoveCursor;
table->traverse = LedgerTraverse; table->traverse = LedgerTraverse;
table->set_help = LedgerSetHelp; table->set_help = LedgerSetHelp;
table->client_data = reg; table->user_data = reg;
reg->destroy = LedgerDestroy; reg->destroy = LedgerDestroy;
} }
@ -3592,7 +3605,7 @@ LoadXferCell (ComboCell *cell,
const char *base_currency, const char *base_currency,
const char *base_security) const char *base_security)
{ {
gncBoolean load_everything; gboolean load_everything;
Account * acc; Account * acc;
char *name; char *name;
int n; int n;
@ -3683,7 +3696,7 @@ xaccSRLoadXferCells (SplitRegister *reg, Account *base_account)
/* ======================================================== */ /* ======================================================== */
gncBoolean gboolean
xaccSRHasPendingChanges (SplitRegister *reg) xaccSRHasPendingChanges (SplitRegister *reg)
{ {
SRInfo *info = xaccSRGetInfo(reg); SRInfo *info = xaccSRGetInfo(reg);

View File

@ -122,10 +122,11 @@
#include "splitreg.h" #include "splitreg.h"
#include "Transaction.h" #include "Transaction.h"
/* Callback function type */ /* Callback function type */
typedef gncUIWidget (*SRGetParentCallback) (void *user_data); typedef gncUIWidget (*SRGetParentCallback) (void *user_data);
typedef void (*SRSetHelpCallback) (void *user_data, const char *help_str); typedef void (*SRSetHelpCallback) (void *user_data, const char *help_str);
typedef gncBoolean (*SRReverseBalanceCallback) (Account *account); typedef gboolean (*SRReverseBalanceCallback) (Account *account);
void xaccSRSetData(SplitRegister *reg, void *user_data, void xaccSRSetData(SplitRegister *reg, void *user_data,
SRGetParentCallback get_parent, SRGetParentCallback get_parent,
@ -139,9 +140,9 @@ Transaction * xaccSRGetCurrentTrans (SplitRegister *reg);
Split * xaccSRGetCurrentSplit (SplitRegister *reg); Split * xaccSRGetCurrentSplit (SplitRegister *reg);
Split * xaccSRGetBlankSplit (SplitRegister *reg); Split * xaccSRGetBlankSplit (SplitRegister *reg);
gncBoolean xaccSRGetSplitRowCol (SplitRegister *reg, Split *split, gboolean xaccSRGetSplitRowCol (SplitRegister *reg, Split *split,
int *virt_row, int *virt_col); int *virt_row, int *virt_col);
gncBoolean xaccSRGetTransSplitRowCol (SplitRegister *reg, Transaction *trans, gboolean xaccSRGetTransSplitRowCol (SplitRegister *reg, Transaction *trans,
Split *trans_split, Split *split, Split *trans_split, Split *split,
int *virt_row, int *virt_col); int *virt_row, int *virt_col);
@ -161,11 +162,11 @@ void xaccSRCancelCursorTransChanges (SplitRegister *reg);
void xaccSRLoadRegister (SplitRegister *reg, Split **slist, void xaccSRLoadRegister (SplitRegister *reg, Split **slist,
Account *default_source_acc); Account *default_source_acc);
gncBoolean xaccSRSaveRegEntry (SplitRegister *reg, gncBoolean do_commit); gboolean xaccSRSaveRegEntry (SplitRegister *reg, gboolean do_commit);
void xaccSRRedrawRegEntry (SplitRegister *reg); void xaccSRRedrawRegEntry (SplitRegister *reg);
void xaccSRLoadXferCells (SplitRegister *reg, Account *base_account); void xaccSRLoadXferCells (SplitRegister *reg, Account *base_account);
gncBoolean xaccSRHasPendingChanges (SplitRegister *reg); gboolean xaccSRHasPendingChanges (SplitRegister *reg);
#endif /* __XACC_SPLIT_LEDGER_H__ */ #endif /* __XACC_SPLIT_LEDGER_H__ */

View File

@ -46,7 +46,7 @@
#include "dialog-utils.h" #include "dialog-utils.h"
#include "query-user.h" #include "query-user.h"
#include "enriched-messages.h" #include "enriched-messages.h"
#include "table-gnome.h" #include "table-allgui.h"
#include "gnucash-sheet.h" #include "gnucash-sheet.h"
#include "global-options.h" #include "global-options.h"
#include "dialog-find-transactions.h" #include "dialog-find-transactions.h"
@ -1641,7 +1641,7 @@ regWindowLedger(xaccLedgerDisplay *ledger)
gnucash_register_set_initial_rows(num_rows); gnucash_register_set_initial_rows(num_rows);
register_widget = gnucash_register_new(ledger->ledger->table); register_widget = gnucash_register_new(ledger->ledger->table);
xaccCreateTable(register_widget, ledger->ledger); gnc_table_init_gui(register_widget, ledger->ledger);
gtk_container_add(GTK_CONTAINER(table_frame), register_widget); gtk_container_add(GTK_CONTAINER(table_frame), register_widget);

View File

@ -27,7 +27,6 @@ noinst_HEADERS = \
recncell.h \ recncell.h \
splitreg.h \ splitreg.h \
table-allgui.h \ table-allgui.h \
table-gnome.h \
textcell.h textcell.h
EXTRA_DIST = \ EXTRA_DIST = \

View File

@ -120,7 +120,7 @@ noinst_LIBRARIES = libgncregister.a
libgncregister_a_SOURCES = QuickFill.c basiccell.c cellblock.c datecell.c numcell.c pricecell.c quickfillcell.c recncell.c splitreg.c table-allgui.c table-gnome.c textcell.c libgncregister_a_SOURCES = QuickFill.c basiccell.c cellblock.c datecell.c numcell.c pricecell.c quickfillcell.c recncell.c splitreg.c table-allgui.c table-gnome.c textcell.c
noinst_HEADERS = QuickFill.h basiccell.h cellblock.h combocell.h datecell.h numcell.h pricecell.h quickfillcell.h recncell.h splitreg.h table-allgui.h table-gnome.h textcell.h noinst_HEADERS = QuickFill.h basiccell.h cellblock.h combocell.h datecell.h numcell.h pricecell.h quickfillcell.h recncell.h splitreg.h table-allgui.h textcell.h
EXTRA_DIST = .cvsignore design.txt table-html.c table-html.h EXTRA_DIST = .cvsignore design.txt table-html.c table-html.h

View File

@ -170,7 +170,7 @@ xaccBasicCellSetChanged (BasicCell *cell, gncBoolean changed)
if (cell == NULL) if (cell == NULL)
return; return;
cell->changed = changed ? 0xffffffff : 0; cell->changed = changed ? GNC_CELL_CHANGED : 0;
} }
/* ================== end of file ====================== */ /* ================== end of file ====================== */

View File

@ -164,11 +164,8 @@
* initialization & changes. * initialization & changes.
* *
* The realize() callback will be called when GUI-specific * The realize() callback will be called when GUI-specific
* initialization needs to be done. For Xt/Motif, the second * initialization needs to be done. For Gnome, the second
* argument will be cast to the parent widget. The third * argument will be cast to the parent widget.
* argument passes in the desired pixel-width for the GUI
* element. (Yes, the pixel-size thing is a hack that we
* allow for the moment. See below for more info.)
* *
* The destroy() callback will be called when the GUI associated * The destroy() callback will be called when the GUI associated
* with the cell needs to be destroyed. * with the cell needs to be destroyed.
@ -181,12 +178,6 @@
* The gui_private member may be used by the derived class to * The gui_private member may be used by the derived class to
* store any additional GUI-specific data. * store any additional GUI-specific data.
* *
* GUI HACK ALERT NOTES:
* The realize method takes a width argument only as a hack
* to work around the fact that the combo-box requires a width
* in pixels, rather than in characters. It would be nice if
* ComboBox supported the XmNunits resource, but it doesn't.
*
* HISTORY: * HISTORY:
* Copyright (c) 1998 Linas Vepstas * Copyright (c) 1998 Linas Vepstas
*/ */
@ -199,6 +190,7 @@
#include "gnc-common.h" #include "gnc-common.h"
#include "gnc-ui-common.h" #include "gnc-ui-common.h"
/* define a bitmask */ /* define a bitmask */
#define XACC_CELL_ALLOW_NONE 0x0 #define XACC_CELL_ALLOW_NONE 0x0
#define XACC_CELL_ALLOW_SHADOW 0x1 #define XACC_CELL_ALLOW_SHADOW 0x1
@ -206,62 +198,79 @@
#define XACC_CELL_ALLOW_ALL 0x3 #define XACC_CELL_ALLOW_ALL 0x3
#define XACC_CELL_ALLOW_EXACT_ONLY 0x4 #define XACC_CELL_ALLOW_EXACT_ONLY 0x4
#define GNC_CELL_CHANGED 0xffffffff
typedef struct _BasicCell BasicCell; typedef struct _BasicCell BasicCell;
struct _BasicCell { typedef void (*CellSetValueFunc) (BasicCell *,
/* cell attributes */
/* hack alert -- may want to redesign color to use named color strings. */
guint32 bg_color; /* background color, ARGB format */
guint32 fg_color; /* forground (text) color ARGB format */
gboolean use_fg_color; /* if 0, above is ignored */
gboolean use_bg_color; /* if 0, above is ignored */
/* hack alert -- add support for e.g. bold fonts !?!?! italic fonts ?? */
/* ==================================================== */
char * value; /* current value */
char *blank_help; /* help when value is blank */
guint32 changed; /* 2^32-1 if value modified */
char input_output; /* zero if output-only */
/* "virtual", overloaded set-value method */
void (*set_value) (BasicCell *,
const char * new_value); const char * new_value);
/* cell-editing callbacks */ typedef const char * (*CellEnterFunc) (BasicCell *,
const char * (*enter_cell) (BasicCell *,
const char * current, const char * current,
int *cursor_position, int *cursor_position,
int *start_selection, int *start_selection,
int *end_selection); int *end_selection);
const char * (*modify_verify) (BasicCell *,
typedef const char * (*CellModifyVerifyFunc) (BasicCell *,
const char *old_value, const char *old_value,
const char *add_str, const char *add_str,
const char *new_value, const char *new_value,
int *cursor_position, int *cursor_position,
int *start_selection, int *start_selection,
int *end_selection); int *end_selection);
gncBoolean (*direct_update) (BasicCell *,
typedef gboolean (*CellDirectUpdateFunc) (BasicCell *,
const char *oldval, const char *oldval,
char **newval_ptr, char **newval_ptr,
int *cursor_position, int *cursor_position,
int *start_selection, int *start_selection,
int *end_selection, int *end_selection,
void *gui_data); void *gui_data);
const char * (*leave_cell) (BasicCell *,
typedef const char * (*CellLeaveFunc) (BasicCell *,
const char * current); const char * current);
/* private, GUI-specific callbacks */ typedef void (*CellRealizeFunc) (BasicCell *,
void (* realize) (BasicCell *, void *gui_handle);
void *gui_handle,
int pixel_width);
void (* move) (BasicCell *,
int phys_row, int phys_col);
void (* destroy) (BasicCell *);
char * (*get_help_value) (BasicCell *); typedef void (*CellMoveFunc) (BasicCell *,
int phys_row, int phys_col);
typedef void (*CellDestroyFunc) (BasicCell *);
typedef char * (*CellGetHelpFunc) (BasicCell *);
struct _BasicCell
{
/* cell attributes */
/* hack alert -- may want to redesign color to use named color strings. */
guint32 bg_color; /* background color, ARGB format */
guint32 fg_color; /* forground (text) color ARGB format */
gboolean use_fg_color; /* if 0, above is ignored */
gboolean use_bg_color; /* if 0, above is ignored */
char * value; /* current value */
char * blank_help; /* help when value is blank */
guint32 changed; /* 2^32-1 if value modified */
guint8 input_output; /* zero if output-only */
/* "virtual", overloaded set-value method */
CellSetValueFunc set_value;
/* cell-editing callbacks */
CellEnterFunc enter_cell;
CellModifyVerifyFunc modify_verify;
CellDirectUpdateFunc direct_update;
CellLeaveFunc leave_cell;
/* private, GUI-specific callbacks */
CellRealizeFunc realize;
CellMoveFunc move;
CellDestroyFunc destroy;
CellGetHelpFunc get_help_value;
/* general hook for gui-private data */ /* general hook for gui-private data */
void * gui_private; void * gui_private;

View File

@ -38,242 +38,246 @@
CellBlock * xaccMallocCellBlock (int numrows, int numcols) CellBlock * xaccMallocCellBlock (int numrows, int numcols)
{ {
CellBlock *arr; CellBlock *cellblock;
arr = (CellBlock *) malloc (sizeof (CellBlock));
arr->numRows = 0; cellblock = g_new(CellBlock, 1);
arr->numCols = 0;
arr->active_bg_color = 0xffffff; /* white */ cellblock->numRows = 0;
arr->passive_bg_color = 0xffffff; /* white */ cellblock->numCols = 0;
arr->passive_bg_color2 = 0xffffff; /* white */
arr->user_data = NULL; cellblock->active_bg_color = 0xffffff; /* white */
arr->cells = NULL; cellblock->passive_bg_color = 0xffffff; /* white */
arr->cell_types = NULL; cellblock->passive_bg_color2 = 0xffffff; /* white */
arr->right_traverse_r = NULL;
arr->right_traverse_c = NULL;
arr->left_traverse_r = NULL;
arr->left_traverse_c = NULL;
arr->widths = NULL;
arr->alignments = NULL;
xaccInitCellBlock (arr, numrows, numcols);
return arr; cellblock->user_data = NULL;
cellblock->cells = NULL;
cellblock->cell_types = NULL;
cellblock->right_traverse_r = NULL;
cellblock->right_traverse_c = NULL;
cellblock->left_traverse_r = NULL;
cellblock->left_traverse_c = NULL;
cellblock->widths = NULL;
cellblock->alignments = NULL;
xaccInitCellBlock (cellblock, numrows, numcols);
return cellblock;
} }
/* =================================================== */ /* =================================================== */
static void static void
FreeCellBlockMem (CellBlock *arr) FreeCellBlockMem (CellBlock *cellblock)
{ {
int i; int i;
int oldrows, oldcols; int oldrows, oldcols;
oldrows = arr->numRows; oldrows = cellblock->numRows;
oldcols = arr->numCols; oldcols = cellblock->numCols;
/* free cell array, if any */ /* free cell array, if any */
if (arr->cells) { if (cellblock->cells) {
for (i=0; i<oldrows; i++) { for (i=0; i<oldrows; i++) {
if (arr->cells[i]) free (arr->cells[i]); if (cellblock->cells[i])
free (cellblock->cells[i]);
} }
free (arr->cells); free (cellblock->cells);
} }
/* free label array, if any */ /* free label array, if any */
if (arr->cell_types) { if (cellblock->cell_types) {
for (i=0; i<oldrows; i++) { for (i=0; i<oldrows; i++) {
if (arr->cell_types[i]) free (arr->cell_types[i]); if (cellblock->cell_types[i])
free (cellblock->cell_types[i]);
} }
} }
/* free right traversal chain */ /* free right traversal chain */
if (arr->right_traverse_r) { if (cellblock->right_traverse_r) {
for (i=0; i<oldrows; i++) { for (i=0; i<oldrows; i++) {
if (arr->right_traverse_r[i]) free (arr->right_traverse_r[i]); if (cellblock->right_traverse_r[i])
free (cellblock->right_traverse_r[i]);
} }
} }
if (arr->right_traverse_c) { if (cellblock->right_traverse_c) {
for (i=0; i<oldrows; i++) { for (i=0; i<oldrows; i++) {
if (arr->right_traverse_c[i]) free (arr->right_traverse_c[i]); if (cellblock->right_traverse_c[i])
free (cellblock->right_traverse_c[i]);
} }
} }
/* free left traversal chain */ /* free left traversal chain */
if (arr->left_traverse_r) { if (cellblock->left_traverse_r) {
for (i=0; i<oldrows; i++) { for (i=0; i<oldrows; i++) {
if (arr->left_traverse_r[i]) free (arr->left_traverse_r[i]); if (cellblock->left_traverse_r[i])
free (cellblock->left_traverse_r[i]);
} }
} }
if (arr->left_traverse_c) { if (cellblock->left_traverse_c) {
for (i=0; i<oldrows; i++) { for (i=0; i<oldrows; i++) {
if (arr->left_traverse_c[i]) free (arr->left_traverse_c[i]); if (cellblock->left_traverse_c[i])
free (cellblock->left_traverse_c[i]);
} }
} }
/* free widths, alignments */ /* free widths, alignments */
if (arr->widths) free (arr->widths); if (cellblock->widths) free (cellblock->widths);
if (arr->alignments) free (arr->alignments); if (cellblock->alignments) free (cellblock->alignments);
} }
/* =================================================== */ /* =================================================== */
void void
xaccInitCellBlock (CellBlock *arr, int numrows, int numcols) xaccInitCellBlock (CellBlock *cellblock, int numrows, int numcols)
{ {
int i, j; int i, j;
if (!arr) return; if (!cellblock) return;
FreeCellBlockMem (arr); FreeCellBlockMem (cellblock);
/* record new size */ /* record new size */
arr->numRows = numrows; cellblock->numRows = numrows;
arr->numCols = numcols; cellblock->numCols = numcols;
/* malloc new cell array */ /* malloc new cell array */
arr->cells = (BasicCell ***) malloc (numrows * sizeof (BasicCell **)); cellblock->cells = malloc (numrows * sizeof (BasicCell **));
arr->cell_types = (short **) malloc (numrows * sizeof (short *)); cellblock->cell_types = malloc (numrows * sizeof (short *));
for (i=0; i<numrows; i++) { for (i=0; i<numrows; i++) {
(arr->cells)[i] = (BasicCell **) malloc (numcols * sizeof (BasicCell *)); (cellblock->cells)[i] = malloc (numcols * sizeof (BasicCell *));
(arr->cell_types)[i] = (short *) malloc (numcols * sizeof (short)); (cellblock->cell_types)[i] = malloc (numcols * sizeof (short));
for (j=0; j<numcols; j++) { for (j=0; j<numcols; j++) {
(arr->cells)[i][j] = NULL; (cellblock->cells)[i][j] = NULL;
(arr->cell_types)[i][j] = -1; (cellblock->cell_types)[i][j] = -1;
} }
} }
/* malloc new right traversal arrays */ /* malloc new right traversal arrays */
arr->right_traverse_r = (short **) malloc (numrows * sizeof (short *)); cellblock->right_traverse_r = malloc (numrows * sizeof (short *));
arr->right_traverse_c = (short **) malloc (numrows * sizeof (short *)); cellblock->right_traverse_c = malloc (numrows * sizeof (short *));
for (i=0; i<numrows; i++) { for (i=0; i<numrows; i++) {
(arr->right_traverse_r)[i] = (short *) malloc (numcols * sizeof (short)); (cellblock->right_traverse_r)[i] = malloc (numcols * sizeof (short));
(arr->right_traverse_c)[i] = (short *) malloc (numcols * sizeof (short)); (cellblock->right_traverse_c)[i] = malloc (numcols * sizeof (short));
for (j=0; j<numcols-1; j++) { for (j=0; j<numcols-1; j++) {
/* default traversal is same row, next column */ /* default traversal is same row, next column */
(arr->right_traverse_r)[i][j] = i; (cellblock->right_traverse_r)[i][j] = i;
(arr->right_traverse_c)[i][j] = j+1; (cellblock->right_traverse_c)[i][j] = j+1;
} }
/* at end of row, wrap to next row */ /* at end of row, wrap to next row */
(arr->right_traverse_r)[i][numcols-1] = i+1; (cellblock->right_traverse_r)[i][numcols-1] = i+1;
(arr->right_traverse_c)[i][numcols-1] = 0; (cellblock->right_traverse_c)[i][numcols-1] = 0;
} }
/* at end of block, wrap back to begining */ /* at end of block, wrap back to begining */
(arr->right_traverse_r)[numrows-1][numcols-1] = 0; (cellblock->right_traverse_r)[numrows-1][numcols-1] = 0;
(arr->right_traverse_c)[numrows-1][numcols-1] = 0; (cellblock->right_traverse_c)[numrows-1][numcols-1] = 0;
/* last is last ... */ /* last is last ... */
arr->last_reenter_traverse_row = numrows-1; cellblock->last_reenter_traverse_row = numrows-1;
arr->last_reenter_traverse_col = numcols-1; cellblock->last_reenter_traverse_col = numcols-1;
/* malloc new left traversal arrays */ /* malloc new left traversal arrays */
arr->left_traverse_r = (short **) malloc (numrows * sizeof (short *)); cellblock->left_traverse_r = malloc (numrows * sizeof (short *));
arr->left_traverse_c = (short **) malloc (numrows * sizeof (short *)); cellblock->left_traverse_c = malloc (numrows * sizeof (short *));
for (i=0; i<numrows; i++) { for (i=0; i<numrows; i++) {
(arr->left_traverse_r)[i] = (short *) malloc (numcols * sizeof (short)); (cellblock->left_traverse_r)[i] = malloc (numcols * sizeof (short));
(arr->left_traverse_c)[i] = (short *) malloc (numcols * sizeof (short)); (cellblock->left_traverse_c)[i] = malloc (numcols * sizeof (short));
for (j=0; j<numcols-1; j++) { for (j=0; j<numcols-1; j++) {
/* default traversal is same row, previous column */ /* default traversal is same row, previous column */
(arr->left_traverse_r)[i][j] = i; (cellblock->left_traverse_r)[i][j] = i;
(arr->left_traverse_c)[i][j] = j-1; (cellblock->left_traverse_c)[i][j] = j-1;
} }
/* at start of row, wrap to previous row */ /* at start of row, wrap to previous row */
(arr->left_traverse_r)[i][numcols-1] = i-1; (cellblock->left_traverse_r)[i][numcols-1] = i-1;
(arr->left_traverse_c)[i][numcols-1] = numcols-1; (cellblock->left_traverse_c)[i][numcols-1] = numcols-1;
} }
/* at start of block, wrap back to end */ /* at start of block, wrap back to end */
(arr->right_traverse_r)[0][0] = numrows-1; (cellblock->right_traverse_r)[0][0] = numrows-1;
(arr->right_traverse_c)[0][0] = numcols-1; (cellblock->right_traverse_c)[0][0] = numcols-1;
/* first is last ... */ /* first is last ... */
arr->last_left_reenter_traverse_row = 0; cellblock->last_left_reenter_traverse_row = 0;
arr->last_left_reenter_traverse_col = 0; cellblock->last_left_reenter_traverse_col = 0;
arr->widths = (short *) malloc (numcols * sizeof(short)); cellblock->widths = malloc (numcols * sizeof(short));
arr->alignments = (Alignments *) malloc (numcols * sizeof(Alignments)); cellblock->alignments = malloc (numcols * sizeof(Alignments));
for (j=0; j<numcols; j++) { for (j=0; j<numcols; j++) {
arr->widths[j] = 0; cellblock->widths[j] = 0;
arr->alignments[j] = ALIGN_RIGHT; cellblock->alignments[j] = ALIGN_RIGHT;
} }
} }
/* =================================================== */ /* =================================================== */
void void
xaccDestroyCellBlock (CellBlock *arr) xaccDestroyCellBlock (CellBlock *cellblock)
{ {
if (!arr) return; if (!cellblock) return;
FreeCellBlockMem (arr); FreeCellBlockMem (cellblock);
/* finally, free this object itself */ /* finally, free this object itself */
free (arr); g_free (cellblock);
} }
/* =================================================== */ /* =================================================== */
void void
xaccNextRight (CellBlock *arr, int row, int col, xaccNextRight (CellBlock *cellblock, int row, int col,
int next_row, int next_col) int next_row, int next_col)
{ {
if (!arr) return; if (!cellblock) return;
/* avoid embarrasement if cell incorrectly specified */ /* avoid embarrasement if cell incorrectly specified */
if ((0 > row) || (0 > col)) return; if ((0 > row) || (0 > col)) return;
if ((row >= arr->numRows) || (col >= arr->numCols)) return; if ((row >= cellblock->numRows) || (col >= cellblock->numCols)) return;
/* -1 is a valid value for next ... it signifies that traversal /* -1 is a valid value for next ... it signifies that traversal
* should go to next tab group, so do not check for neg values. * should go to next tab group, so do not check for neg values.
* if ((0 > next_row) || (0 > next_col)) return;
*/ */
/* if the "next" location to hop to is larger than the cursor, that /* 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 * just means that we should hop to the next cursor. Thus, large
* values for next *are* valid. * values for next *are* valid.
* if ((next_row >= arr->numRows) || (next_col >= arr->numCols)) return;
*/ */
(arr->right_traverse_r)[row][col] = next_row; (cellblock->right_traverse_r)[row][col] = next_row;
(arr->right_traverse_c)[row][col] = next_col; (cellblock->right_traverse_c)[row][col] = next_col;
/* if traversing out (neg values) record this as the last ... */ /* if traversing out (neg values) record this as the last ... */
if ((0 > next_row) || (0 > next_col)) { if ((0 > next_row) || (0 > next_col)) {
arr->last_reenter_traverse_row = row; cellblock->last_reenter_traverse_row = row;
arr->last_reenter_traverse_col = col; cellblock->last_reenter_traverse_col = col;
} }
} }
void void
xaccNextLeft (CellBlock *arr, int row, int col, xaccNextLeft (CellBlock *cellblock, int row, int col,
int next_row, int next_col) int next_row, int next_col)
{ {
if (!arr) return; if (!cellblock) return;
/* avoid embarrasement if cell incorrectly specified */ /* avoid embarrasement if cell incorrectly specified */
if ((0 > row) || (0 > col)) return; if ((0 > row) || (0 > col)) return;
if ((row >= arr->numRows) || (col >= arr->numCols)) return; if ((row >= cellblock->numRows) || (col >= cellblock->numCols)) return;
/* -1 is a valid value for next ... it signifies that traversal /* -1 is a valid value for next ... it signifies that traversal
* should go to next tab group, so do not check for neg values. * should go to next tab group, so do not check for neg values.
* if ((0 > next_row) || (0 > next_col)) return;
*/ */
/* if the "next" location to hop to is larger than the cursor, that /* 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 * just means that we should hop to the next cursor. Thus, large
* values for next *are* valid. * values for next *are* valid.
* if ((next_row >= arr->numRows) || (next_col >= arr->numCols)) return;
*/ */
(arr->left_traverse_r)[row][col] = next_row; (cellblock->left_traverse_r)[row][col] = next_row;
(arr->left_traverse_c)[row][col] = next_col; (cellblock->left_traverse_c)[row][col] = next_col;
/* if traversing out (neg values) record this as the last ... */ /* if traversing out (neg values) record this as the last ... */
if ((0 > next_row) || (0 > next_col)) { if ((0 > next_row) || (0 > next_col)) {
arr->last_left_reenter_traverse_row = row; cellblock->last_left_reenter_traverse_row = row;
arr->last_left_reenter_traverse_col = col; cellblock->last_left_reenter_traverse_col = col;
} }
} }

View File

@ -67,11 +67,7 @@ enum _Alignments {
ALIGN_FILL, ALIGN_FILL,
}; };
#ifdef MOTIF
typedef unsigned char Alignments;
#else
typedef enum _Alignments Alignments; typedef enum _Alignments Alignments;
#endif
struct _CellBlock { struct _CellBlock {
@ -137,9 +133,7 @@ struct _CellBlock {
void * user_data; void * user_data;
/* above is a pointer to anything the programmer-user of this struct /* above is a pointer to anything the programmer-user of this struct
* wants it to be. Handy for stuff. * wants it to be. Handy for stuff. */
*/
}; };
typedef struct _CellBlock CellBlock; typedef struct _CellBlock CellBlock;
@ -149,10 +143,12 @@ void xaccInitCellBlock (CellBlock *, int numrows, int numcols);
void xaccDestroyCellBlock (CellBlock *); void xaccDestroyCellBlock (CellBlock *);
/* define next cell to traverse to */ /* define next cell to traverse to */
void xaccNextRight (CellBlock *, int row, int col, void xaccNextRight (CellBlock *cellblock,
int row, int col,
int next_row, int next_col); int next_row, int next_col);
void xaccNextLeft (CellBlock *arr, int row, int col, void xaccNextLeft (CellBlock *cellblock,
int row, int col,
int next_row, int next_col); int next_row, int next_col);
#endif /* __XACC_CELL_BLOCK_H__ */ #endif /* __XACC_CELL_BLOCK_H__ */

View File

@ -36,7 +36,6 @@
#include "splitreg.h" #include "splitreg.h"
#include "table-allgui.h" #include "table-allgui.h"
#include "table-gnome.h"
#include "combocell.h" #include "combocell.h"
#include "gnucash-sheet.h" #include "gnucash-sheet.h"
#include "gnucash-item-edit.h" #include "gnucash-item-edit.h"
@ -77,7 +76,7 @@ typedef struct _PopBox
static void block_list_signals (ComboCell *cell); static void block_list_signals (ComboCell *cell);
static void unblock_list_signals (ComboCell *cell); static void unblock_list_signals (ComboCell *cell);
static void realizeCombo (BasicCell *bcell, void *w, int width); static void realizeCombo (BasicCell *bcell, void *w);
static void moveCombo (BasicCell *bcell, int phys_row, int phys_col); static void moveCombo (BasicCell *bcell, int phys_row, int phys_col);
static void destroyCombo (BasicCell *bcell); static void destroyCombo (BasicCell *bcell);
static const char * enterCombo (BasicCell *bcell, static const char * enterCombo (BasicCell *bcell,
@ -697,7 +696,7 @@ ComboHelpValue(BasicCell *bcell)
/* =============================================== */ /* =============================================== */
static void static void
realizeCombo (BasicCell *bcell, void *data, int pixel_width) realizeCombo (BasicCell *bcell, void *data)
{ {
GnucashSheet *sheet = (GnucashSheet *) data; GnucashSheet *sheet = (GnucashSheet *) data;
GnomeCanvasItem *item = sheet->item_editor; GnomeCanvasItem *item = sheet->item_editor;

View File

@ -96,6 +96,7 @@ void
gnucash_cursor_get_phys (GnucashCursor *cursor, int *phys_row, int *phys_col) gnucash_cursor_get_phys (GnucashCursor *cursor, int *phys_row, int *phys_col)
{ {
Table *table; Table *table;
VirtualCell *vcell;
int virt_row, virt_col; int virt_row, virt_col;
int cell_row, cell_col; int cell_row, cell_col;
@ -114,10 +115,10 @@ gnucash_cursor_get_phys (GnucashCursor *cursor, int *phys_row, int *phys_col)
cell_col = cell_col =
GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_CELL])->col; GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_CELL])->col;
*phys_row = vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col);
table->rev_locators[virt_row][virt_col]->phys_row + cell_row;
*phys_col = *phys_row = vcell->phys_loc.phys_row + cell_row;
table->rev_locators[virt_row][virt_col]->phys_col + cell_col; *phys_col = vcell->phys_loc.phys_col + cell_col;
} }

View File

@ -23,7 +23,6 @@
#include <gnome.h> #include <gnome.h>
#include "table-gnome.h"
#include "table-allgui.h" #include "table-allgui.h"

View File

@ -461,16 +461,21 @@ item_edit_set_cursor_pos (ItemEdit *item_edit, int p_row, int p_col, int x,
gint o_x, o_y; gint o_x, o_y;
gint virt_row, virt_col, cell_row, cell_col; gint virt_row, virt_col, cell_row, cell_col;
SheetBlockStyle *style; SheetBlockStyle *style;
PhysicalCell *pcell;
char *text; char *text;
g_return_val_if_fail (IS_ITEM_EDIT(item_edit), FALSE); g_return_val_if_fail (IS_ITEM_EDIT(item_edit), FALSE);
table = item_edit->sheet->table; table = item_edit->sheet->table;
virt_row = table->locators[p_row][p_col]->virt_row; pcell = gnc_table_get_physical_cell (table, p_row, p_col);
virt_col = table->locators[p_row][p_col]->virt_col; if (pcell == NULL)
cell_row = table->locators[p_row][p_col]->phys_row_offset; return FALSE;
cell_col = table->locators[p_row][p_col]->phys_col_offset;
virt_row = pcell->virt_loc.virt_row;
virt_col = pcell->virt_loc.virt_col;
cell_row = pcell->virt_loc.phys_row_offset;
cell_col = pcell->virt_loc.phys_col_offset;
style = gnucash_sheet_get_style (item_edit->sheet, virt_row, 0); style = gnucash_sheet_get_style (item_edit->sheet, virt_row, 0);

View File

@ -25,6 +25,7 @@
* *
* Author: * Author:
* Heath Martin <martinh@pegasus.cc.ucf.edu> * Heath Martin <martinh@pegasus.cc.ucf.edu>
* Dave Peticolas <dave@krondo.com>
*/ */
@ -142,6 +143,7 @@ gnucash_sheet_cursor_set_from_table (GnucashSheet *sheet, gncBoolean do_scroll)
Table *table; Table *table;
gint cell_row, cell_col; gint cell_row, cell_col;
gint p_row, p_col; gint p_row, p_col;
PhysicalCell *pcell;
GnucashCursor *cursor; GnucashCursor *cursor;
g_return_if_fail (sheet != NULL); g_return_if_fail (sheet != NULL);
@ -152,12 +154,12 @@ gnucash_sheet_cursor_set_from_table (GnucashSheet *sheet, gncBoolean do_scroll)
p_row = table->current_cursor_phys_row; p_row = table->current_cursor_phys_row;
p_col = table->current_cursor_phys_col; p_col = table->current_cursor_phys_col;
if (p_row < 0 || p_row >= table->num_phys_rows || pcell = gnc_table_get_physical_cell (table, p_row, p_col);
p_col < 0 || p_col >= table->num_phys_cols) if (pcell == NULL)
return; return;
cell_row = table->locators[p_row][p_col]->phys_row_offset; cell_row = pcell->virt_loc.phys_row_offset;
cell_col = table->locators[p_row][p_col]->phys_col_offset; cell_col = pcell->virt_loc.phys_col_offset;
gnucash_sheet_cursor_set(sheet, gnucash_sheet_cursor_set(sheet,
table->current_cursor_virt_row, table->current_cursor_virt_row,
@ -257,7 +259,7 @@ gnucash_sheet_activate_cursor_cell (GnucashSheet *sheet,
&virt_row, &virt_col, &cell_row, &cell_col); &virt_row, &virt_col, &cell_row, &cell_col);
/* This should be a no-op */ /* This should be a no-op */
wrapVerifyCursorPosition (table, p_row, p_col); gnc_table_wrap_verify_cursor_position (table, p_row, p_col);
gnucash_cursor_get_phys (GNUCASH_CURSOR(sheet->cursor), gnucash_cursor_get_phys (GNUCASH_CURSOR(sheet->cursor),
&p_row, &p_col); &p_row, &p_col);
@ -266,7 +268,7 @@ gnucash_sheet_activate_cursor_cell (GnucashSheet *sheet,
style = gnucash_sheet_get_style (sheet, virt_row, virt_col); style = gnucash_sheet_get_style (sheet, virt_row, virt_col);
if (style->cursor_type == GNUCASH_CURSOR_HEADER || if (style->cursor_type == GNUCASH_CURSOR_HEADER ||
!gnc_register_cell_valid (table, p_row, p_col, GNC_T)) !gnc_table_physical_cell_valid (table, p_row, p_col, TRUE))
return; return;
editable = GTK_EDITABLE(sheet->entry); editable = GTK_EDITABLE(sheet->entry);
@ -322,7 +324,7 @@ gnucash_sheet_cursor_move (GnucashSheet *sheet, gint phys_row, gint phys_col)
/* Do the move. This may result in table restructuring due to /* Do the move. This may result in table restructuring due to
* commits, auto modes, etc. */ * commits, auto modes, etc. */
wrapVerifyCursorPosition (table, phys_row, phys_col); gnc_table_wrap_verify_cursor_position (table, phys_row, phys_col);
/* A complete reload can leave us with editing back on */ /* A complete reload can leave us with editing back on */
if (sheet->editing) if (sheet->editing)
@ -869,7 +871,7 @@ gnucash_sheet_modify_current_cell(GnucashSheet *sheet, const gchar *new_text)
gnucash_cursor_get_virt(GNUCASH_CURSOR(sheet->cursor), gnucash_cursor_get_virt(GNUCASH_CURSOR(sheet->cursor),
&v_row, &v_col, &c_row, &c_col); &v_row, &v_col, &c_row, &c_col);
if (!gnc_register_cell_valid (table, p_row, p_col, GNC_T)) if (!gnc_table_physical_cell_valid (table, p_row, p_col, TRUE))
return NULL; return NULL;
old_text = gtk_entry_get_text (GTK_ENTRY(sheet->entry)); old_text = gtk_entry_get_text (GTK_ENTRY(sheet->entry));
@ -952,7 +954,7 @@ gnucash_sheet_insert_cb (GtkWidget *widget, const gchar *new_text,
gnucash_cursor_get_virt (GNUCASH_CURSOR(sheet->cursor), gnucash_cursor_get_virt (GNUCASH_CURSOR(sheet->cursor),
&v_row, &v_col, &c_row, &c_col); &v_row, &v_col, &c_row, &c_col);
if (!gnc_register_cell_valid (table, p_row, p_col, GNC_F)) if (!gnc_table_physical_cell_valid (table, p_row, p_col, FALSE))
return; return;
old_text = gtk_entry_get_text (GTK_ENTRY(sheet->entry)); old_text = gtk_entry_get_text (GTK_ENTRY(sheet->entry));
@ -1058,7 +1060,7 @@ gnucash_sheet_delete_cb (GtkWidget *widget,
gnucash_cursor_get_virt (GNUCASH_CURSOR (sheet->cursor), gnucash_cursor_get_virt (GNUCASH_CURSOR (sheet->cursor),
&v_row, &v_col, &c_row, &c_col); &v_row, &v_col, &c_row, &c_col);
if (!gnc_register_cell_valid (table, p_row, p_col, GNC_F)) if (!gnc_table_physical_cell_valid (table, p_row, p_col, FALSE))
return; return;
old_text = gtk_entry_get_text (GTK_ENTRY(sheet->entry)); old_text = gtk_entry_get_text (GTK_ENTRY(sheet->entry));
@ -1313,6 +1315,7 @@ static gboolean
gnucash_button_press_event (GtkWidget *widget, GdkEventButton *event) gnucash_button_press_event (GtkWidget *widget, GdkEventButton *event)
{ {
GnucashSheet *sheet; GnucashSheet *sheet;
VirtualCell *vcell;
int xoffset, yoffset; int xoffset, yoffset;
gboolean changed_cells; gboolean changed_cells;
int x, y; int x, y;
@ -1376,11 +1379,12 @@ gnucash_button_press_event (GtkWidget *widget, GdkEventButton *event)
&new_c_row, &new_c_col)) &new_c_row, &new_c_col))
return TRUE; return TRUE;
new_p_row = table->rev_locators[new_v_row][new_v_col]->phys_row + vcell = gnc_table_get_virtual_cell (table, new_v_row, new_v_col);
new_c_row; if (vcell == NULL)
return TRUE;
new_p_col = table->rev_locators[new_v_row][new_v_col]->phys_col + new_p_row = vcell->phys_loc.phys_row + new_c_row;
new_c_col; new_p_col = vcell->phys_loc.phys_col + new_c_col;
if ((new_p_row == current_p_row) && (new_p_col == current_p_col) && if ((new_p_row == current_p_row) && (new_p_col == current_p_col) &&
(event->type == GDK_2BUTTON_PRESS)) (event->type == GDK_2BUTTON_PRESS))
@ -1541,7 +1545,7 @@ gnucash_sheet_clipboard_event (GnucashSheet *sheet, GdkEventKey *event)
return handled; return handled;
} }
static gncBoolean static gboolean
gnucash_sheet_direct_event(GnucashSheet *sheet, GdkEvent *event) gnucash_sheet_direct_event(GnucashSheet *sheet, GdkEvent *event)
{ {
GtkEditable *editable; GtkEditable *editable;
@ -1562,8 +1566,8 @@ gnucash_sheet_direct_event(GnucashSheet *sheet, GdkEvent *event)
gnucash_cursor_get_virt(GNUCASH_CURSOR(sheet->cursor), gnucash_cursor_get_virt(GNUCASH_CURSOR(sheet->cursor),
&v_row, &v_col, &c_row, &c_col); &v_row, &v_col, &c_row, &c_col);
if (!gnc_register_cell_valid (table, p_row, p_col, GNC_T)) if (!gnc_table_physical_cell_valid (table, p_row, p_col, TRUE))
return GNC_F; return FALSE;
old_text = gtk_entry_get_text (GTK_ENTRY(sheet->entry)); old_text = gtk_entry_get_text (GTK_ENTRY(sheet->entry));
if (old_text == NULL) if (old_text == NULL)
@ -1650,7 +1654,7 @@ gnucash_sheet_key_press_event (GtkWidget *widget, GdkEventKey *event)
sheet = GNUCASH_SHEET (widget); sheet = GNUCASH_SHEET (widget);
table = sheet->table; table = sheet->table;
header = table->handlers[0][0]; header = gnc_table_get_header_cell(table)->cellblock;
if (gnucash_sheet_direct_event(sheet, (GdkEvent *) event)) if (gnucash_sheet_direct_event(sheet, (GdkEvent *) event))
return TRUE; return TRUE;
@ -1822,6 +1826,7 @@ gnucash_sheet_goto_virt_row_col (GnucashSheet *sheet,
int new_v_row, int new_v_col) int new_v_row, int new_v_col)
{ {
Table *table; Table *table;
VirtualCell *vcell;
gncBoolean exit_register; gncBoolean exit_register;
int current_p_row, current_p_col, new_p_row, new_p_col; int current_p_row, current_p_col, new_p_row, new_p_col;
@ -1832,8 +1837,12 @@ gnucash_sheet_goto_virt_row_col (GnucashSheet *sheet,
gnucash_cursor_get_phys (GNUCASH_CURSOR(sheet->cursor), gnucash_cursor_get_phys (GNUCASH_CURSOR(sheet->cursor),
&current_p_row, &current_p_col); &current_p_row, &current_p_col);
new_p_row = table->rev_locators[new_v_row][new_v_col]->phys_row; vcell = gnc_table_get_virtual_cell (table, new_v_row, new_v_col);
new_p_col = table->rev_locators[new_v_row][new_v_col]->phys_col; if (vcell == NULL)
return;
new_p_row = vcell->phys_loc.phys_row;
new_p_col = vcell->phys_loc.phys_col;
/* It's not really a pointer traverse, but it seems the most /* It's not really a pointer traverse, but it seems the most
* appropriate here. */ * appropriate here. */
@ -1945,37 +1954,45 @@ gnucash_sheet_block_clear_entries (SheetBlock *block)
static void static void
gnucash_sheet_block_set_entries (GnucashSheet *sheet, gint virt_row, gnucash_sheet_block_set_entries (GnucashSheet *sheet,
gint virt_col) gint virt_row, gint virt_col)
{ {
gint i,j; gint i,j;
SheetBlock *block;
Table *table; Table *table;
gint phys_row_origin, phys_col_origin; SheetBlock *block;
VirtualCell *vcell;
gint phys_row_origin;
gint phys_col_origin;
block = gnucash_sheet_get_block (sheet, virt_row, virt_col); block = gnucash_sheet_get_block (sheet, virt_row, virt_col);
if (block == NULL)
return;
if (block) {
table = sheet->table; table = sheet->table;
phys_row_origin = vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col);
table->rev_locators[virt_row][virt_col]->phys_row; if (vcell == NULL)
phys_col_origin = return;
table->rev_locators[virt_row][virt_col]->phys_col;
for (i = 0; i < block->style->nrows; i++) { phys_row_origin = vcell->phys_loc.phys_row;
phys_col_origin = vcell->phys_loc.phys_col;
for (i = 0; i < block->style->nrows; i++)
for (j = 0; j < block->style->ncols; j++) { for (j = 0; j < block->style->ncols; j++) {
PhysicalCell *pcell;
gint p_row, p_col;
block->entries[i][j] = table->entries [phys_row_origin + i][phys_col_origin + j]; p_row = phys_row_origin + i;
p_col = phys_col_origin + j;
pcell = gnc_table_get_physical_cell (table,
p_row, p_col);
block->entries[i][j] = pcell->entry;
block->fg_colors[i][j] = block->fg_colors[i][j] =
gnucash_color_argb_to_gdk(table->fg_colors [phys_row_origin + i][phys_col_origin + j]); gnucash_color_argb_to_gdk (pcell->fg_color);
block->bg_colors[i][j] = block->bg_colors[i][j] =
gnucash_color_argb_to_gdk (table->bg_colors [phys_row_origin + i][phys_col_origin + j]); gnucash_color_argb_to_gdk (pcell->bg_color);
}
}
} }
} }
@ -1989,7 +2006,6 @@ gnucash_sheet_block_set_from_table (GnucashSheet *sheet, gint virt_row,
Table *table; Table *table;
SheetBlock *block; SheetBlock *block;
SheetBlockStyle *style; SheetBlockStyle *style;
gint i; gint i;
block = gnucash_sheet_get_block (sheet, virt_row, virt_col); block = gnucash_sheet_get_block (sheet, virt_row, virt_col);
@ -2060,26 +2076,32 @@ gnucash_sheet_cell_set_from_table (GnucashSheet *sheet, gint virt_row,
block = gnucash_sheet_get_block (sheet, virt_row, virt_col); block = gnucash_sheet_get_block (sheet, virt_row, virt_col);
style = block->style; style = block->style;
if (!style) if (!style)
return; return;
if (cell_row >= 0 && cell_row <= style->nrows if (cell_row >= 0 && cell_row <= style->nrows &&
&& cell_col >= 0 && cell_col <= style->ncols) { cell_col >= 0 && cell_col <= style->ncols) {
VirtualCell *vcell;
PhysicalCell *pcell;
block->entries[cell_row][cell_col] = NULL; block->entries[cell_row][cell_col] = NULL;
p_row = table->rev_locators[virt_row][virt_col]->phys_row + vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col);
cell_row; if (vcell == NULL)
p_col = table->rev_locators[virt_row][virt_col]->phys_col + return;
cell_col;
block->entries[cell_row][cell_col] = table->entries[p_row][p_col]; p_row = vcell->phys_loc.phys_row + cell_row;
p_col = vcell->phys_loc.phys_col + cell_col;
pcell = gnc_table_get_physical_cell (table, p_row, p_col);
if (pcell == NULL)
return;
block->entries[cell_row][cell_col] = pcell->entry;
} }
} }
gint gint
gnucash_sheet_col_max_width (GnucashSheet *sheet, gint virt_col, gint cell_col) gnucash_sheet_col_max_width (GnucashSheet *sheet, gint virt_col, gint cell_col)
{ {

View File

@ -24,7 +24,6 @@
#include <gnome.h> #include <gnome.h>
#include "splitreg.h" #include "splitreg.h"
#include "table-gnome.h"
#include "table-allgui.h" #include "table-allgui.h"
#define CELL_VPADDING 5 #define CELL_VPADDING 5

View File

@ -1470,20 +1470,26 @@ gnucash_sheet_get_style_from_table (GnucashSheet *sheet, gint vrow, gint vcol)
{ {
Table *table; Table *table;
SplitRegister *sr; SplitRegister *sr;
VirtualCell *vcell;
CellBlock *cursor;
g_return_val_if_fail (sheet != NULL, NULL); g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (GNUCASH_IS_SHEET(sheet), NULL); g_return_val_if_fail (GNUCASH_IS_SHEET(sheet), NULL);
table = sheet->table; table = sheet->table;
sr = (SplitRegister *)sheet->split_register; sr = sheet->split_register;
if (table->handlers[vrow][vcol] == sr->single_cursor) vcell = gnc_table_get_virtual_cell (table, vrow, vcol);
cursor = vcell->cellblock;
if (cursor == sr->single_cursor)
return sheet->cursor_style[GNUCASH_CURSOR_SINGLE]; return sheet->cursor_style[GNUCASH_CURSOR_SINGLE];
else if (table->handlers[vrow][vcol] == sr->double_cursor) else if (cursor == sr->double_cursor)
return sheet->cursor_style[GNUCASH_CURSOR_DOUBLE]; return sheet->cursor_style[GNUCASH_CURSOR_DOUBLE];
else if (table->handlers[vrow][vcol] == sr->trans_cursor) else if (cursor == sr->trans_cursor)
return sheet->cursor_style[GNUCASH_CURSOR_TRANS]; return sheet->cursor_style[GNUCASH_CURSOR_TRANS];
else if (table->handlers[vrow][vcol] == sr->split_cursor) else if (cursor == sr->split_cursor)
return sheet->cursor_style[GNUCASH_CURSOR_SPLIT]; return sheet->cursor_style[GNUCASH_CURSOR_SPLIT];
else else
return sheet->cursor_style[GNUCASH_CURSOR_HEADER]; return sheet->cursor_style[GNUCASH_CURSOR_HEADER];

View File

@ -32,12 +32,14 @@
* *
* HISTORY: * HISTORY:
* Copyright (c) 1998, 1999, 2000 Linas Vepstas * Copyright (c) 1998, 1999, 2000 Linas Vepstas
* Copyright (c) 2000 Dave Peticolas <dave@krondo.com>
*/ */
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <glib.h>
#include "recncell.h" #include "recncell.h"
#include "splitreg.h" #include "splitreg.h"
@ -89,7 +91,7 @@ static SplitRegisterColors reg_colors = {
0xccccff, /* pale blue, double cursor passive */ 0xccccff, /* pale blue, double cursor passive */
0xffffff, /* white, double cursor passive 2 */ 0xffffff, /* white, double cursor passive 2 */
GNC_F, /* double mode alternate by physical row */ FALSE, /* double mode alternate by physical row */
0xffdddd, /* pale red, trans cursor active */ 0xffdddd, /* pale red, trans cursor active */
0xccccff, /* pale blue, trans cursor passive */ 0xccccff, /* pale blue, trans cursor passive */
@ -330,13 +332,9 @@ configAction (SplitRegister *reg)
} \ } \
} }
/* BASIC & FANCY macros initialize cells in the register */ /* SET_CELL macro initializes cells in the register */
#define BASIC(NAME,CN,col,row) { \ #define SET_CELL(NAME,CN,col,row) { \
SET (NAME, col, row, reg->CN##Cell); \
}
#define FANCY(NAME,CN,col,row) { \
SET (NAME, col, row, &(reg->CN##Cell->cell)); \ SET (NAME, col, row, &(reg->CN##Cell->cell)); \
} }
@ -372,44 +370,44 @@ configLayout (SplitRegister *reg)
case EQUITY_REGISTER: case EQUITY_REGISTER:
{ {
curs = reg->double_cursor; curs = reg->double_cursor;
FANCY (DATE, date, 0, 0); SET_CELL (DATE, date, 0, 0);
FANCY (NUM, num, 1, 0); SET_CELL (NUM, num, 1, 0);
FANCY (DESC, desc, 2, 0); SET_CELL (DESC, desc, 2, 0);
FANCY (MXFRM, mxfrm, 3, 0); SET_CELL (MXFRM, mxfrm, 3, 0);
FANCY (RECN, recn, 4, 0); SET_CELL (RECN, recn, 4, 0);
FANCY (DEBT, debit, 5, 0); SET_CELL (DEBT, debit, 5, 0);
FANCY (CRED, credit, 6, 0); SET_CELL (CRED, credit, 6, 0);
FANCY (BALN, balance, 7, 0); SET_CELL (BALN, balance, 7, 0);
FANCY (ACTN, action, 1, 1); SET_CELL (ACTN, action, 1, 1);
FANCY (MEMO, memo, 2, 1); SET_CELL (MEMO, memo, 2, 1);
curs = reg->trans_cursor; curs = reg->trans_cursor;
FANCY (DATE, date, 0, 0); SET_CELL (DATE, date, 0, 0);
FANCY (NUM, num, 1, 0); SET_CELL (NUM, num, 1, 0);
FANCY (DESC, desc, 2, 0); SET_CELL (DESC, desc, 2, 0);
FANCY (XTO, xto, 3, 0); SET_CELL (XTO, xto, 3, 0);
FANCY (RECN, recn, 4, 0); SET_CELL (RECN, recn, 4, 0);
FANCY (DEBT, debit, 5, 0); SET_CELL (DEBT, debit, 5, 0);
FANCY (CRED, credit, 6, 0); SET_CELL (CRED, credit, 6, 0);
FANCY (BALN, balance, 7, 0); SET_CELL (BALN, balance, 7, 0);
curs = reg->split_cursor; curs = reg->split_cursor;
FANCY (ACTN, action, 1, 0); SET_CELL (ACTN, action, 1, 0);
FANCY (MEMO, memo, 2, 0); SET_CELL (MEMO, memo, 2, 0);
FANCY (XFRM, xfrm, 3, 0); SET_CELL (XFRM, xfrm, 3, 0);
FANCY (NDEBT, ndebit, 5, 0); SET_CELL (NDEBT, ndebit, 5, 0);
FANCY (NCRED, ncredit, 6, 0); SET_CELL (NCRED, ncredit, 6, 0);
curs = reg->single_cursor; curs = reg->single_cursor;
FANCY (DATE, date, 0, 0); SET_CELL (DATE, date, 0, 0);
FANCY (NUM, num, 1, 0); SET_CELL (NUM, num, 1, 0);
FANCY (DESC, desc, 2, 0); SET_CELL (DESC, desc, 2, 0);
FANCY (MXFRM, mxfrm, 3, 0); SET_CELL (MXFRM, mxfrm, 3, 0);
FANCY (RECN, recn, 4, 0); SET_CELL (RECN, recn, 4, 0);
FANCY (DEBT, debit, 5, 0); SET_CELL (DEBT, debit, 5, 0);
FANCY (CRED, credit, 6, 0); SET_CELL (CRED, credit, 6, 0);
FANCY (BALN, balance, 7, 0); SET_CELL (BALN, balance, 7, 0);
break; break;
} }
@ -420,44 +418,44 @@ configLayout (SplitRegister *reg)
case SEARCH_LEDGER: case SEARCH_LEDGER:
{ {
curs = reg->double_cursor; curs = reg->double_cursor;
FANCY (DATE, date, 0, 0); SET_CELL (DATE, date, 0, 0);
FANCY (NUM, num, 1, 0); SET_CELL (NUM, num, 1, 0);
FANCY (DESC, desc, 2, 0); SET_CELL (DESC, desc, 2, 0);
FANCY (XTO, xto, 3, 0); SET_CELL (XTO, xto, 3, 0);
FANCY (MXFRM, mxfrm, 4, 0); SET_CELL (MXFRM, mxfrm, 4, 0);
FANCY (RECN, recn, 5, 0); SET_CELL (RECN, recn, 5, 0);
FANCY (DEBT, debit, 6, 0); SET_CELL (DEBT, debit, 6, 0);
FANCY (CRED, credit, 7, 0); SET_CELL (CRED, credit, 7, 0);
FANCY (ACTN, action, 1, 1); SET_CELL (ACTN, action, 1, 1);
FANCY (MEMO, memo, 2, 1); SET_CELL (MEMO, memo, 2, 1);
curs = reg->trans_cursor; curs = reg->trans_cursor;
FANCY (DATE, date, 0, 0); SET_CELL (DATE, date, 0, 0);
FANCY (NUM, num, 1, 0); SET_CELL (NUM, num, 1, 0);
FANCY (DESC, desc, 2, 0); SET_CELL (DESC, desc, 2, 0);
FANCY (XTO, mxfrm, 3, 0); SET_CELL (XTO, mxfrm, 3, 0);
FANCY (XFRM, xto, 4, 0); SET_CELL (XFRM, xto, 4, 0);
FANCY (RECN, recn, 5, 0); SET_CELL (RECN, recn, 5, 0);
FANCY (DEBT, debit, 6, 0); SET_CELL (DEBT, debit, 6, 0);
FANCY (CRED, credit, 7, 0); SET_CELL (CRED, credit, 7, 0);
curs = reg->split_cursor; curs = reg->split_cursor;
FANCY (ACTN, action, 1, 0); SET_CELL (ACTN, action, 1, 0);
FANCY (MEMO, memo, 2, 0); SET_CELL (MEMO, memo, 2, 0);
FANCY (XFRM, xfrm, 4, 0); SET_CELL (XFRM, xfrm, 4, 0);
FANCY (NDEBT, ndebit, 6, 0); SET_CELL (NDEBT, ndebit, 6, 0);
FANCY (NCRED, ncredit, 7, 0); SET_CELL (NCRED, ncredit, 7, 0);
curs = reg->single_cursor; curs = reg->single_cursor;
FANCY (DATE, date, 0, 0); SET_CELL (DATE, date, 0, 0);
FANCY (NUM, num, 1, 0); SET_CELL (NUM, num, 1, 0);
FANCY (DESC, desc, 2, 0); SET_CELL (DESC, desc, 2, 0);
FANCY (XTO, xto, 3, 0); SET_CELL (XTO, xto, 3, 0);
FANCY (MXFRM, mxfrm, 4, 0); SET_CELL (MXFRM, mxfrm, 4, 0);
FANCY (RECN, recn, 5, 0); SET_CELL (RECN, recn, 5, 0);
FANCY (DEBT, debit, 6, 0); SET_CELL (DEBT, debit, 6, 0);
FANCY (CRED, credit, 7, 0); SET_CELL (CRED, credit, 7, 0);
break; break;
} }
@ -467,53 +465,53 @@ configLayout (SplitRegister *reg)
case CURRENCY_REGISTER: case CURRENCY_REGISTER:
{ {
curs = reg->double_cursor; curs = reg->double_cursor;
FANCY (DATE, date, 0, 0); SET_CELL (DATE, date, 0, 0);
FANCY (NUM, num, 1, 0); SET_CELL (NUM, num, 1, 0);
FANCY (DESC, desc, 2, 0); SET_CELL (DESC, desc, 2, 0);
FANCY (MXFRM, mxfrm, 3, 0); SET_CELL (MXFRM, mxfrm, 3, 0);
FANCY (RECN, recn, 4, 0); SET_CELL (RECN, recn, 4, 0);
FANCY (DEBT, debit, 5, 0); SET_CELL (DEBT, debit, 5, 0);
FANCY (CRED, credit, 6, 0); SET_CELL (CRED, credit, 6, 0);
FANCY (PRIC, price, 7, 0); SET_CELL (PRIC, price, 7, 0);
FANCY (VALU, value, 8, 0); SET_CELL (VALU, value, 8, 0);
FANCY (SHRS, shrs, 9, 0); SET_CELL (SHRS, shrs, 9, 0);
FANCY (BALN, balance, 10, 0); SET_CELL (BALN, balance, 10, 0);
FANCY (ACTN, action, 1, 1); SET_CELL (ACTN, action, 1, 1);
FANCY (MEMO, memo, 2, 1); SET_CELL (MEMO, memo, 2, 1);
curs = reg->trans_cursor; curs = reg->trans_cursor;
FANCY (DATE, date, 0, 0); SET_CELL (DATE, date, 0, 0);
FANCY (NUM, num, 1, 0); SET_CELL (NUM, num, 1, 0);
FANCY (DESC, desc, 2, 0); SET_CELL (DESC, desc, 2, 0);
FANCY (XTO, xto, 3, 0); SET_CELL (XTO, xto, 3, 0);
FANCY (RECN, recn, 4, 0); SET_CELL (RECN, recn, 4, 0);
FANCY (DEBT, debit, 5, 0); SET_CELL (DEBT, debit, 5, 0);
FANCY (CRED, credit, 6, 0); SET_CELL (CRED, credit, 6, 0);
FANCY (PRIC, price, 7, 0); SET_CELL (PRIC, price, 7, 0);
FANCY (VALU, value, 8, 0); SET_CELL (VALU, value, 8, 0);
FANCY (SHRS, shrs, 9, 0); SET_CELL (SHRS, shrs, 9, 0);
FANCY (BALN, balance, 10, 0); SET_CELL (BALN, balance, 10, 0);
curs = reg->split_cursor; curs = reg->split_cursor;
FANCY (ACTN, action, 1, 0); SET_CELL (ACTN, action, 1, 0);
FANCY (MEMO, memo, 2, 0); SET_CELL (MEMO, memo, 2, 0);
FANCY (XFRM, xfrm, 3, 0); SET_CELL (XFRM, xfrm, 3, 0);
FANCY (NDEBT, ndebit, 5, 0); SET_CELL (NDEBT, ndebit, 5, 0);
FANCY (NCRED, ncredit, 6, 0); SET_CELL (NCRED, ncredit, 6, 0);
curs = reg->single_cursor; curs = reg->single_cursor;
FANCY (DATE, date, 0, 0); SET_CELL (DATE, date, 0, 0);
FANCY (NUM, num, 1, 0); SET_CELL (NUM, num, 1, 0);
FANCY (DESC, desc, 2, 0); SET_CELL (DESC, desc, 2, 0);
FANCY (MXFRM, mxfrm, 3, 0); SET_CELL (MXFRM, mxfrm, 3, 0);
FANCY (RECN, recn, 4, 0); SET_CELL (RECN, recn, 4, 0);
FANCY (DEBT, debit, 5, 0); SET_CELL (DEBT, debit, 5, 0);
FANCY (CRED, credit, 6, 0); SET_CELL (CRED, credit, 6, 0);
FANCY (PRIC, price, 7, 0); SET_CELL (PRIC, price, 7, 0);
FANCY (VALU, value, 8, 0); SET_CELL (VALU, value, 8, 0);
FANCY (SHRS, shrs, 9, 0); SET_CELL (SHRS, shrs, 9, 0);
FANCY (BALN, balance, 10, 0); SET_CELL (BALN, balance, 10, 0);
break; break;
} }
@ -522,53 +520,53 @@ configLayout (SplitRegister *reg)
case PORTFOLIO_LEDGER: case PORTFOLIO_LEDGER:
{ {
curs = reg->double_cursor; curs = reg->double_cursor;
FANCY (DATE, date, 0, 0); SET_CELL (DATE, date, 0, 0);
FANCY (NUM, num, 1, 0); SET_CELL (NUM, num, 1, 0);
FANCY (DESC, desc, 2, 0); SET_CELL (DESC, desc, 2, 0);
FANCY (XTO, xto, 3, 0); SET_CELL (XTO, xto, 3, 0);
FANCY (MXFRM, mxfrm, 4, 0); SET_CELL (MXFRM, mxfrm, 4, 0);
FANCY (RECN, recn, 5, 0); SET_CELL (RECN, recn, 5, 0);
FANCY (DEBT, debit, 6, 0); SET_CELL (DEBT, debit, 6, 0);
FANCY (CRED, credit, 7, 0); SET_CELL (CRED, credit, 7, 0);
FANCY (PRIC, price, 8, 0); SET_CELL (PRIC, price, 8, 0);
FANCY (VALU, value, 9, 0); SET_CELL (VALU, value, 9, 0);
FANCY (SHRS, shrs, 10, 0); SET_CELL (SHRS, shrs, 10, 0);
FANCY (ACTN, action, 1, 1); SET_CELL (ACTN, action, 1, 1);
FANCY (MEMO, memo, 2, 1); SET_CELL (MEMO, memo, 2, 1);
curs = reg->trans_cursor; curs = reg->trans_cursor;
FANCY (DATE, date, 0, 0); SET_CELL (DATE, date, 0, 0);
FANCY (NUM, num, 1, 0); SET_CELL (NUM, num, 1, 0);
FANCY (DESC, desc, 2, 0); SET_CELL (DESC, desc, 2, 0);
FANCY (XTO, mxfrm, 3, 0); SET_CELL (XTO, mxfrm, 3, 0);
FANCY (XFRM, xto, 4, 0); SET_CELL (XFRM, xto, 4, 0);
FANCY (RECN, recn, 5, 0); SET_CELL (RECN, recn, 5, 0);
FANCY (DEBT, debit, 6, 0); SET_CELL (DEBT, debit, 6, 0);
FANCY (CRED, credit, 7, 0); SET_CELL (CRED, credit, 7, 0);
FANCY (PRIC, price, 8, 0); SET_CELL (PRIC, price, 8, 0);
FANCY (VALU, value, 9, 0); SET_CELL (VALU, value, 9, 0);
FANCY (SHRS, shrs, 10, 0); SET_CELL (SHRS, shrs, 10, 0);
curs = reg->split_cursor; curs = reg->split_cursor;
FANCY (ACTN, action, 1, 0); SET_CELL (ACTN, action, 1, 0);
FANCY (MEMO, memo, 2, 0); SET_CELL (MEMO, memo, 2, 0);
FANCY (XFRM, xfrm, 4, 0); SET_CELL (XFRM, xfrm, 4, 0);
FANCY (NDEBT, ndebit, 6, 0); SET_CELL (NDEBT, ndebit, 6, 0);
FANCY (NCRED, ncredit, 7, 0); SET_CELL (NCRED, ncredit, 7, 0);
curs = reg->single_cursor; curs = reg->single_cursor;
FANCY (DATE, date, 0, 0); SET_CELL (DATE, date, 0, 0);
FANCY (NUM, num, 1, 0); SET_CELL (NUM, num, 1, 0);
FANCY (DESC, desc, 2, 0); SET_CELL (DESC, desc, 2, 0);
FANCY (XTO, xto, 3, 0); SET_CELL (XTO, xto, 3, 0);
FANCY (MXFRM, mxfrm, 4, 0); SET_CELL (MXFRM, mxfrm, 4, 0);
FANCY (RECN, recn, 5, 0); SET_CELL (RECN, recn, 5, 0);
FANCY (DEBT, debit, 6, 0); SET_CELL (DEBT, debit, 6, 0);
FANCY (CRED, credit, 7, 0); SET_CELL (CRED, credit, 7, 0);
FANCY (PRIC, price, 8, 0); SET_CELL (PRIC, price, 8, 0);
FANCY (VALU, value, 9, 0); SET_CELL (VALU, value, 9, 0);
FANCY (SHRS, shrs, 10, 0); SET_CELL (SHRS, shrs, 10, 0);
break; break;
} }
@ -844,14 +842,14 @@ configTable(SplitRegister *reg)
switch (reg->style) { switch (reg->style) {
case REG_SINGLE_LINE: case REG_SINGLE_LINE:
case REG_SINGLE_DYNAMIC: case REG_SINGLE_DYNAMIC:
reg->table->alternate_bg_colors = GNC_T; reg->table->alternate_bg_colors = TRUE;
break; break;
case REG_DOUBLE_LINE: case REG_DOUBLE_LINE:
case REG_DOUBLE_DYNAMIC: case REG_DOUBLE_DYNAMIC:
reg->table->alternate_bg_colors = reg_colors.double_alternate_virt; reg->table->alternate_bg_colors = reg_colors.double_alternate_virt;
break; break;
default: default:
reg->table->alternate_bg_colors = GNC_F; reg->table->alternate_bg_colors = FALSE;
break; break;
} }
} }
@ -1084,8 +1082,8 @@ xaccInitSplitRegister (SplitRegister *reg,
reg->shrsCell->cell.input_output = XACC_CELL_ALLOW_SHADOW; reg->shrsCell->cell.input_output = XACC_CELL_ALLOW_SHADOW;
/* by default, don't blank zeros on the balance or price cells. */ /* by default, don't blank zeros on the balance or price cells. */
xaccSetPriceCellBlankZero(reg->balanceCell, GNC_F); xaccSetPriceCellBlankZero(reg->balanceCell, FALSE);
xaccSetPriceCellBlankZero(reg->priceCell, GNC_F); xaccSetPriceCellBlankZero(reg->priceCell, FALSE);
/* The reconcile cell should only be entered with the pointer, /* The reconcile cell should only be entered with the pointer,
* and only then when the user clicks directly on the cell. * and only then when the user clicks directly on the cell.
@ -1100,24 +1098,24 @@ xaccInitSplitRegister (SplitRegister *reg,
xaccSetPriceCellValue (reg->ncreditCell, 0.0); xaccSetPriceCellValue (reg->ncreditCell, 0.0);
/* Initialize shares cell */ /* Initialize shares cell */
xaccSetPriceCellSharesValue (reg->shrsCell, GNC_T); xaccSetPriceCellSharesValue (reg->shrsCell, TRUE);
/* The action cell should accept strings not in the list */ /* The action cell should accept strings not in the list */
xaccComboCellSetStrict (reg->actionCell, GNC_F); xaccComboCellSetStrict (reg->actionCell, FALSE);
xaccSetBasicCellBlankHelp (&reg->actionCell->cell, ACTION_CELL_HELP); xaccSetBasicCellBlankHelp (&reg->actionCell->cell, ACTION_CELL_HELP);
/* number format for share quantities in stock ledgers */ /* number format for share quantities in stock ledgers */
switch (type) { switch (type) {
case CURRENCY_REGISTER: case CURRENCY_REGISTER:
xaccSetPriceCellIsCurrency (reg->priceCell, GNC_T); xaccSetPriceCellIsCurrency (reg->priceCell, TRUE);
case STOCK_REGISTER: case STOCK_REGISTER:
case PORTFOLIO_LEDGER: case PORTFOLIO_LEDGER:
xaccSetPriceCellSharesValue (reg->debitCell, GNC_T); xaccSetPriceCellSharesValue (reg->debitCell, TRUE);
xaccSetPriceCellSharesValue (reg->creditCell, GNC_T); xaccSetPriceCellSharesValue (reg->creditCell, TRUE);
xaccSetPriceCellSharesValue (reg->ndebitCell, GNC_T); xaccSetPriceCellSharesValue (reg->ndebitCell, TRUE);
xaccSetPriceCellSharesValue (reg->ncreditCell, GNC_T); xaccSetPriceCellSharesValue (reg->ncreditCell, TRUE);
xaccSetPriceCellIsCurrency (reg->priceCell, GNC_T); xaccSetPriceCellIsCurrency (reg->priceCell, TRUE);
xaccSetBasicCellBlankHelp (&reg->priceCell->cell, PRICE_CELL_HELP); xaccSetBasicCellBlankHelp (&reg->priceCell->cell, PRICE_CELL_HELP);
xaccSetBasicCellBlankHelp (&reg->valueCell->cell, VALUE_CELL_HELP); xaccSetBasicCellBlankHelp (&reg->valueCell->cell, VALUE_CELL_HELP);
@ -1148,22 +1146,22 @@ xaccInitSplitRegister (SplitRegister *reg,
phys_c = header->numCols; phys_c = header->numCols;
reg->num_cols = phys_c; reg->num_cols = phys_c;
table = xaccMallocTable (); table = gnc_table_new ();
xaccSetTableSize (table, phys_r, phys_c, reg->num_virt_rows, 1); gnc_table_set_size (table, phys_r, phys_c, reg->num_virt_rows, 1);
xaccSetCursor (table, header, 0, 0, 0, 0); gnc_table_set_cursor (table, header, 0, 0, 0, 0);
/* the SetCursor call below is for most practical purposes useless. /* The call below is for most practical purposes useless.
* It simply installs a cursor (the single-line cursor, but it could * It simply installs a cursor (the single-line cursor, but it
* of been any of them), and moves it to the first editable row. * could of been any of them), and moves it to the first editable
* Whoop-de-doo, since this is promptly over-ridden when real data * row. Whoop-de-doo, since this is promptly over-ridden when real
* gets loaded. Its just sort of here as a fail-safe fallback, * data gets loaded. Its just sort of here as a fail-safe fallback,
* in case someone just creates a register but doesn't do anything * in case someone just creates a register but doesn't do anything
* with it. Don't want to freak out any programmers. * with it. Don't want to freak out any programmers. */
*/ gnc_table_set_cursor (table, reg->single_cursor,
xaccSetCursor (table, reg->single_cursor,
reg->cursor_phys_row, 0, reg->cursor_phys_row, 0,
reg->cursor_virt_row, 0); reg->cursor_virt_row, 0);
xaccMoveCursor (table, header->numRows, 0);
gnc_table_move_cursor (table, header->numRows, 0);
reg->table = table; reg->table = table;
@ -1184,10 +1182,10 @@ xaccConfigSplitRegister (SplitRegister *reg,
/* Make sure that any GUI elements associated with this reconfig /* Make sure that any GUI elements associated with this reconfig
* are properly initialized. */ * are properly initialized. */
xaccCreateCursor (reg->table, reg->single_cursor); gnc_table_create_cursor (reg->table, reg->single_cursor);
xaccCreateCursor (reg->table, reg->double_cursor); gnc_table_create_cursor (reg->table, reg->double_cursor);
xaccCreateCursor (reg->table, reg->trans_cursor); gnc_table_create_cursor (reg->table, reg->trans_cursor);
xaccCreateCursor (reg->table, reg->split_cursor); gnc_table_create_cursor (reg->table, reg->split_cursor);
configTable(reg); configTable(reg);
} }
@ -1198,13 +1196,13 @@ void
xaccDestroySplitRegister (SplitRegister *reg) xaccDestroySplitRegister (SplitRegister *reg)
{ {
/* give the user a chance to clean up */ /* give the user a chance to clean up */
if (reg->destroy) { if (reg->destroy)
(*(reg->destroy)) (reg); (*(reg->destroy)) (reg);
}
reg->destroy = NULL; reg->destroy = NULL;
reg->user_data = NULL; reg->user_data = NULL;
xaccDestroyTable (reg->table); gnc_table_destroy (reg->table);
reg->table = NULL; reg->table = NULL;
xaccDestroyCellBlock (reg->header); xaccDestroyCellBlock (reg->header);
@ -1357,6 +1355,7 @@ CursorType
xaccSplitRegisterGetCursorTypeRowCol (SplitRegister *reg, xaccSplitRegisterGetCursorTypeRowCol (SplitRegister *reg,
int virt_row, int virt_col) int virt_row, int virt_col)
{ {
VirtualCell *vcell;
Table *table; Table *table;
if (reg == NULL) if (reg == NULL)
@ -1366,11 +1365,11 @@ xaccSplitRegisterGetCursorTypeRowCol (SplitRegister *reg,
if (table == NULL) if (table == NULL)
return CURSOR_NONE; return CURSOR_NONE;
if ((virt_row < 0) || (virt_row >= table->num_virt_rows) || vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col);
(virt_col < 0) || (virt_col >= table->num_virt_cols)) if (vcell == NULL)
return CURSOR_NONE; return CURSOR_NONE;
return sr_cellblock_cursor_type(reg, table->handlers[virt_row][virt_col]); return sr_cellblock_cursor_type(reg, vcell->cellblock);
} }
/* ============================================== */ /* ============================================== */
@ -1457,7 +1456,8 @@ static BasicCell *
sr_current_cell (SplitRegister *reg) sr_current_cell (SplitRegister *reg)
{ {
Table *table; Table *table;
Locator *locator; VirtualCell *vcell;
PhysicalCell *pcell;
CellBlock *cellblock; CellBlock *cellblock;
int phys_row, phys_col; int phys_row, phys_col;
int virt_row, virt_col; int virt_row, virt_col;
@ -1473,18 +1473,20 @@ sr_current_cell (SplitRegister *reg)
phys_row = table->current_cursor_phys_row; phys_row = table->current_cursor_phys_row;
phys_col = table->current_cursor_phys_col; phys_col = table->current_cursor_phys_col;
if ((phys_row < 0) || (phys_row >= table->num_phys_rows) || pcell = gnc_table_get_physical_cell (table, phys_row, phys_col);
(phys_col < 0) || (phys_col >= table->num_phys_cols)) if (pcell == NULL)
return NULL; return NULL;
locator = table->locators[phys_row][phys_col]; virt_row = pcell->virt_loc.virt_row;
virt_col = pcell->virt_loc.virt_col;
cell_row = pcell->virt_loc.phys_row_offset;
cell_col = pcell->virt_loc.phys_col_offset;
virt_row = locator->virt_row; vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col);
virt_col = locator->virt_col; if (vcell == NULL)
cell_row = locator->phys_row_offset; return NULL;
cell_col = locator->phys_col_offset;
cellblock = table->handlers[virt_row][virt_col]; cellblock = vcell->cellblock;
return cellblock->cells[cell_row][cell_col]; return cellblock->cells[cell_row][cell_col];
} }
@ -1506,37 +1508,40 @@ xaccSplitRegisterGetCellTypeRowCol (SplitRegister *reg,
/* ============================================== */ /* ============================================== */
gncBoolean gboolean
xaccSplitRegisterGetCellRowCol (SplitRegister *reg, CellType cell_type, xaccSplitRegisterGetCellRowCol (SplitRegister *reg, CellType cell_type,
int *p_phys_row, int *p_phys_col) int *p_phys_row, int *p_phys_col)
{ {
Table *table; Table *table;
Locator *locator; VirtualCell *vcell;
PhysicalCell *pcell;
CellBlock *cellblock; CellBlock *cellblock;
int phys_row, phys_col; int phys_row, phys_col;
int virt_row, virt_col; int virt_row, virt_col;
int cell_row, cell_col; int cell_row, cell_col;
if (reg == NULL) if (reg == NULL)
return GNC_F; return FALSE;
table = reg->table; table = reg->table;
if (table == NULL) if (table == NULL)
return GNC_F; return FALSE;
phys_row = table->current_cursor_phys_row; phys_row = table->current_cursor_phys_row;
phys_col = table->current_cursor_phys_col; phys_col = table->current_cursor_phys_col;
if ((phys_row < 0) || (phys_row >= table->num_phys_rows) || pcell = gnc_table_get_physical_cell (table, phys_row, phys_col);
(phys_col < 0) || (phys_col >= table->num_phys_cols)) if (pcell == NULL)
return GNC_F; return FALSE;
locator = table->locators[phys_row][phys_col]; virt_row = pcell->virt_loc.virt_row;
virt_col = pcell->virt_loc.virt_col;
virt_row = locator->virt_row; vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col);
virt_col = locator->virt_col; if (vcell == NULL)
return FALSE;
cellblock = table->handlers[virt_row][virt_col]; cellblock = vcell->cellblock;
for (cell_row = 0; cell_row < cellblock->numRows; cell_row++) for (cell_row = 0; cell_row < cellblock->numRows; cell_row++)
for (cell_col = 0; cell_col < cellblock->numCols; cell_col++) for (cell_col = 0; cell_col < cellblock->numCols; cell_col++)
@ -1545,12 +1550,10 @@ xaccSplitRegisterGetCellRowCol (SplitRegister *reg, CellType cell_type,
if (sr_cell_type (reg, cell) == cell_type) if (sr_cell_type (reg, cell) == cell_type)
{ {
RevLocator *rev_locator; vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col);
rev_locator = table->rev_locators[virt_row][virt_col]; phys_row = vcell->phys_loc.phys_row + cell_row;
phys_col = vcell->phys_loc.phys_col + cell_col;
phys_row = rev_locator->phys_row + cell_row;
phys_col = rev_locator->phys_col + cell_col;
if (p_phys_row != NULL) if (p_phys_row != NULL)
*p_phys_row = phys_row; *p_phys_row = phys_row;
@ -1558,11 +1561,11 @@ xaccSplitRegisterGetCellRowCol (SplitRegister *reg, CellType cell_type,
if (p_phys_col != NULL) if (p_phys_col != NULL)
*p_phys_col = phys_col; *p_phys_col = phys_col;
return GNC_T; return TRUE;
} }
} }
return GNC_F; return FALSE;
} }
/* ============================================== */ /* ============================================== */
@ -1572,9 +1575,7 @@ xaccMallocSplitRegisterBuffer ()
{ {
SplitRegisterBuffer *srb; SplitRegisterBuffer *srb;
srb = calloc(1, sizeof(SplitRegisterBuffer)); srb = g_new0(SplitRegisterBuffer, 1);
assert(srb != NULL);
return srb; return srb;
} }
@ -1587,9 +1588,7 @@ destroyCellBuffer(CellBuffer *cb)
if (cb == NULL) if (cb == NULL)
return; return;
if (cb->value != NULL) g_free(cb->value);
free(cb->value);
cb->value = NULL; cb->value = NULL;
} }
@ -1617,7 +1616,7 @@ xaccDestroySplitRegisterBuffer (SplitRegisterBuffer *srb)
destroyCellBuffer(&srb->ncreditCell); destroyCellBuffer(&srb->ncreditCell);
destroyCellBuffer(&srb->ndebitCell); destroyCellBuffer(&srb->ndebitCell);
free(srb); g_free(srb);
} }
/* ============================================== */ /* ============================================== */
@ -1628,16 +1627,8 @@ saveCell(BasicCell *bcell, CellBuffer *cb)
if ((bcell == NULL) || (cb == NULL)) if ((bcell == NULL) || (cb == NULL))
return; return;
if (cb->value != NULL) g_free(cb->value);
free(cb->value); cb->value = g_strdup(bcell->value);
cb->value = bcell->value;
if (cb->value != NULL)
{
cb->value = strdup(cb->value);
assert(cb->value != NULL);
}
cb->changed = bcell->changed; cb->changed = bcell->changed;
} }

File diff suppressed because it is too large Load Diff

View File

@ -94,30 +94,20 @@
* *
* HISTORY: * HISTORY:
* Copyright (c) 1998,1999,2000 Linas Vepstas * Copyright (c) 1998,1999,2000 Linas Vepstas
* Copyright (c) 2000 Dave Peticolas
*/ */
#ifndef __XACC_TABLE_ALLGUI_H__ #ifndef __TABLE_ALLGUI_H__
#define __XACC_TABLE_ALLGUI_H__ #define __TABLE_ALLGUI_H__
#include <glib.h> #include <glib.h>
#ifdef MOTIF
#include "table-motif.h"
#endif
#ifdef GNOME
#include "table-gnome.h"
#endif
#ifdef KDE
#include "table-qt.h"
#endif
#include "gnc-common.h" #include "gnc-common.h"
#include "basiccell.h" #include "basiccell.h"
#include "cellblock.h" #include "cellblock.h"
typedef enum { typedef enum {
GNC_TABLE_TRAVERSE_POINTER, GNC_TABLE_TRAVERSE_POINTER,
GNC_TABLE_TRAVERSE_LEFT, GNC_TABLE_TRAVERSE_LEFT,
@ -126,9 +116,9 @@ typedef enum {
GNC_TABLE_TRAVERSE_DOWN GNC_TABLE_TRAVERSE_DOWN
} gncTableTraversalDir; } gncTableTraversalDir;
/* The Locator structure is used provide a mapping from
* the physical array of cells to the logical array of /* The VirtualLocation structure contains the virtual
* virtual cell blocks. * location of a physical cell.
* *
* There is one instance of Locator for each physical cell. * There is one instance of Locator for each physical cell.
* The virt_row and virt_col members identify the corresponding * The virt_row and virt_col members identify the corresponding
@ -138,31 +128,67 @@ typedef enum {
* should never be less than zero, or greater than the size of * should never be less than zero, or greater than the size of
* the cell block. * the cell block.
*/ */
struct _Locator { typedef struct _VirtualLocation VirtualLocation;
struct _VirtualLocation {
short phys_row_offset; short phys_row_offset;
short phys_col_offset; short phys_col_offset;
short virt_row; short virt_row;
short virt_col; short virt_col;
}; };
typedef struct _Locator Locator;
/* The RevLocator gives a reverse mapping from a virtual /* The PhysicalLocation gives a reverse mapping from a virtual
* cell block to the origin of the block in physical coordinates. * cell block to the origin of the block in physical coordinates.
* *
* There is one instance of a RevLocator for each virtual cell. * There is one instance of a PhysicalLocation for each virtual cell.
*/ */
typedef struct _PhysicalLocation PhysicalLocation;
struct _RevLocator { struct _PhysicalLocation {
short phys_row; short phys_row;
short phys_col; short phys_col;
}; };
typedef struct _RevLocator RevLocator;
/* The VirtualCell structure holds information about each virtual cell. */
typedef struct _VirtualCell VirtualCell;
struct _VirtualCell
{
CellBlock *cellblock; /* Array of physical cells */
PhysicalLocation phys_loc; /* Physical location of cell (0, 0) */
void *user_data; /* Used by higher-level code */
};
/* The PhysicalCell structure holds information for each physical location. */
typedef struct _PhysicalCell PhysicalCell;
struct _PhysicalCell
{
char *entry; /* The cell data */
VirtualLocation virt_loc; /* Cell virtual location */
guint32 fg_color; /* Cell foreground ARGB */
guint32 bg_color; /* Cell background ARGB */
};
typedef struct _Table Table;
typedef void (*TableMoveFunc) (Table *table,
int *p_new_phys_row,
int *p_new_phys_col);
typedef void (*TableTraverseFunc) (Table *table,
int *p_new_phys_row,
int *p_new_phys_col,
gncTableTraversalDir dir);
typedef void (*TableSetHelpFunc) (Table *table, typedef void (*TableSetHelpFunc) (Table *table,
const char *help_str, const char *help_str);
void *client_data);
typedef void (*TableDestroyFunc) (Table *table);
/* The number of "physical" rows/cols is the number /* The number of "physical" rows/cols is the number
@ -173,16 +199,15 @@ typedef void (*TableSetHelpFunc) (Table *table,
* *
* Given the location of a physical row & col, the corresponding * Given the location of a physical row & col, the corresponding
* virtual row & col can be found by looking it up in the * virtual row & col can be found by looking it up in the
* "locators" member. The locator will provide the matching * Location member. The Location will provide the matching
* virtual row and column. * virtual row and column.
* *
* Given the location of the virtual row and column, the * Given the location of the virtual row and column, the
* corresponding GUI handler, and any associated user data can * corresponding GUI handler, and any associated user data
* be directly accessed. * can be directly accessed.
*/ */
struct _Table
struct _Table { {
int num_phys_rows; int num_phys_rows;
int num_phys_cols; int num_phys_cols;
int num_virt_rows; int num_virt_rows;
@ -193,39 +218,26 @@ struct _Table {
* The fields termed "phys_row" and "phys_col" would * The fields termed "phys_row" and "phys_col" would
* be better termed phys row and column "origins", as the * be better termed phys row and column "origins", as the
* cursor extends down and to the right from the location * cursor extends down and to the right from the location
* given by the phys values. * given by the physical values. */
*/
CellBlock *current_cursor; CellBlock *current_cursor;
int current_cursor_phys_row; int current_cursor_phys_row;
int current_cursor_phys_col; int current_cursor_phys_col;
int current_cursor_virt_row; int current_cursor_virt_row;
int current_cursor_virt_col; int current_cursor_virt_col;
/* callback that is called when the cursor is moved */ /* callback that is called when the cursor is moved */
/* hack alert -- this should be a callback list, actually */ TableMoveFunc move_cursor;
void (*move_cursor) (Table *, int *p_new_phys_row,
int *p_new_phys_col,
void *client_data);
/* callback that is called to determine traversal */ /* callback that is called to determine traversal */
void (*traverse) (Table *, int *p_new_phys_row, TableTraverseFunc traverse;
int *p_new_phys_col,
gncTableTraversalDir dir,
void *client_data);
/* callback to set a help string associated with a cell */
TableSetHelpFunc set_help; TableSetHelpFunc set_help;
void * client_data; /* This value is initialized to NULL and never touched afterwards.
* It can be used by higher-level code. */
/* string values for each cell, void * user_data;
* of dimension num_phys_rows * num_phys_cols */
char ***entries;
/* background colors for each cell, format ARGB,
* and foreground (text) colors, format ARGB,
* of dimension num_phys_rows * num_phys_cols */
guint32 **bg_colors;
guint32 **fg_colors;
/* Determines whether the passive background /* Determines whether the passive background
* colors alternate between odd and even virt * colors alternate between odd and even virt
@ -233,169 +245,168 @@ struct _Table {
* physical rows within cellblocks. */ * physical rows within cellblocks. */
gncBoolean alternate_bg_colors; gncBoolean alternate_bg_colors;
/* handler locators for each cell,
* of dimension num_phys_rows * num_phys_cols */
Locator ***locators;
/* reverse locators for each cell, /* private data */
of dimension num_virt_rows * num_virt_cols */
RevLocator ***rev_locators;
/* user hooks, of dimension num_virt_rows * num_virt_cols */ /* This is black-box stuff that higher-level code should not access */
void ***user_data;
/* cell blocks, of dimension num_virt_rows * num_virt_cols */ /* The virtual and physical cell information */
CellBlock ***handlers; GPtrArray *virt_cells;
GPtrArray *phys_cells;
/* private data, caches, etc. */ /* This class implements tab-key and arrow key traversal through the
/* This is black-box stuff that no user of this class * cells of the table. To perform this traversal, the location of
* should ever want to access */ * the "previous" cell having input focus is required. */
/* This class implements tab-key and arrow key
* traversal through the cells of the table.
* To perform this traversal, the location
* of the "previous" cell having input focus
* is required.
*/
int prev_phys_traverse_row; int prev_phys_traverse_row;
int prev_phys_traverse_col; int prev_phys_traverse_col;
/* Since we are using C not C++, but we need inheritance, void * ui_data;
* cock it up with a #defined thingy that the "derived class"
* can specify.
*/
TABLE_PRIVATE_DATA
TableDestroyFunc destroy;
}; };
Table * xaccMallocTable (void); /* Functions to create and destroy Tables. */
void xaccInitTable (Table *); Table * gnc_table_new (void);
void xaccDestroyTable (Table *); void gnc_table_destroy (Table *);
/* These functions return the virtual/physical cell associated with a
* particular virtual/physical row & column pair. If the pair is out
* of bounds, NULL is returned. */
VirtualCell * gnc_table_get_virtual_cell (Table *table,
int virt_row, int virt_col);
/* The xaccSetTableSize() method will resize the table to the PhysicalCell * gnc_table_get_physical_cell (Table *table,
* indicated dimensions. int phys_row, int phys_col);
*/
void xaccSetTableSize (Table * table, int phys_rows, int phys_cols, /* Return the virtual cell of the header */
VirtualCell * gnc_table_get_header_cell (Table *table);
/* The gnc_table_set_size() method will resize the table to the
* indicated dimensions. */
void gnc_table_set_size (Table * table,
int phys_rows, int phys_cols,
int virt_rows, int virt_cols); int virt_rows, int virt_cols);
/* The xaccCreateCursor() method can be called whenever a reconfig /* The gnc_table_create_cursor() method can be called whenever a
* of the cursor may require new gui elements to be initialized. * reconfig of the cursor may require new gui elements to be
*/ * initialized. */
void xaccCreateCursor (Table *, CellBlock *); void gnc_table_create_cursor (Table *, CellBlock *);
/* indicate what handler should be used for a given virtual block */ /* indicate what handler should be used for a given virtual block */
void void gnc_table_set_cursor (Table *table, CellBlock *curs,
xaccSetCursor (Table *table, CellBlock *curs,
int phys_row_origin, int phys_col_origin, int phys_row_origin, int phys_col_origin,
int virt_row, int virt_col); int virt_row, int virt_col);
/* The gnc_table_move_cursor() method 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. */
void gnc_table_move_cursor (Table *table, int phys_row, int phys_col);
/* The xaccMoveCursor() method will move the cursor (but not the /* The gnc_table_move_cursor_gui() method will move the cursor and its
* cursor GUI) to the indicated location. This function is useful * GUI to the indicated location. Through a series of callbacks, all
* when loading the table from the cursor: data can be loaded into * GUI elements get repositioned. */
* the cursor, then committed to the table, all without the annoying void gnc_table_move_cursor_gui (Table *table,
* screen flashing associated with GUI redraw. int phys_row, int phys_col);
*/
void xaccMoveCursor (Table *, int phys_row, int phys_col);
/* The xaccMoveCursorGUI() method will move the cursor and its GUI /* The gnc_table_commit_cursor() method will copy text in the cursor
* to the indicated location. Through a series of callbacks, * cells into the table. This function is useful during the initial
* all GUI elements get repositioned.
*/
void xaccMoveCursorGUI (Table *, int phys_row, int phys_col);
/* The xaccCommitCursor() method will copy text in the cursor cells
* into the table. This function is useful during the initial
* load of the table with data: the cursor can be used as an * load of the table with data: the cursor can be used as an
* intermediary to format, fix up, and otherwise control the data, * intermediary to format, fix up, and otherwise control the data,
* and, when ready, it is commited from the cursor into the table. * and, when ready, it is commited from the cursor into the
*/ * table. */
void xaccCommitCursor (Table *); void gnc_table_commit_cursor (Table *table);
/* hack alert -- /* Refresh the table header. */
* for all practical purposes, RefreshHeader is identical void gnc_table_refresh_header (Table *table);
* to CommitCursor(), except that it acts on cellblock 0,0.
* it should probably be made obsolete.
*/
void xaccRefreshHeader (Table *);
/* The gnc_table_verify_cursor_position() method checks the location
* of 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
* and gui to the new position. Returns true if the cursor was
* repositioned. */
gboolean gnc_table_verify_cursor_position (Table *table,
int phys_row, int phys_col);
/* The xaccVerifyCursorPosition() method checks the location of /* The gnc_table_get_user_data_physical() method returns the user data
* the cursor with respect to a physical row/column position, * associated with a cursor located at the given physical coords, or
* and if the resulting virtual position has changed, commits * NULL if the coords are out of bounds. */
* the changes in the old position, and the repositions the void * gnc_table_get_user_data_physical (Table *table,
* cursor & gui to the new position. Returns true if the int phys_row, int phys_col);
* cursor was repositioned.
*/
gncBoolean /* The gnc_table_get_user_data_virtual() method returns the user data
xaccVerifyCursorPosition (Table *table, int phys_row, int phys_col); * associated with a cursor located at the given virtual coords, or
* NULL if the coords are out of bounds. */
void * gnc_table_get_user_data_virtual (Table *table,
int virt_row, int virt_col);
/* /* Find the closest valid horizontal cell. If exact_cell is true,
* The xaccGetUserData() method is a convenience function that * cells that must be explicitly selected by the user (as opposed
* simplifies the lookup of the any user data that is hooked * to just tabbing into), are considered valid cells. */
* to the indicated row and column. It returns NULL if the gboolean gnc_table_find_valid_cell_horiz(Table *table,
* row and column are out of bounds. int *phys_row, int *phys_col,
*/ gboolean exact_cell);
void * xaccGetUserData (Table *table, int phys_row, int phys_col);
/* ==================================================== */ /* ==================================================== */
/* these are used internally by table-{motif,gtk}.c /* UI-specific functions */
perhaps these should go in a table-allguiP.h
*/
int /* Initialize the GUI from a table */
gnc_table_column_width(Table *table, int col); void gnc_table_init_gui (gncUIWidget widget, void *data);
void /* Refresh the current cursor gui */
wrapVerifyCursorPosition (Table *table, int row, int col); void gnc_table_refresh_current_cursor_gui (Table * table,
gboolean do_scroll);
gncBoolean /* Refresh the whole GUI from the table. */
gnc_register_cell_valid(Table *table, int row, int col, void gnc_table_refresh_gui (Table *table);
gncBoolean exact_pointer);
void
doRefreshCursorGUI (Table * table, CellBlock *curs,
int from_row, int from_col, gncBoolean do_scroll);
void /* ==================================================== */
xaccRefreshCursorGUI (Table * table, gncBoolean do_scroll); /* Functions used internally by table-gnome.c.
* perhaps these should go in a table-allguiP.h */
/* void gnc_table_wrap_verify_cursor_position (Table *table,
* gnc_table_enter_update() is a utility function used to determine int phys_row, int phys_col);
gboolean gnc_table_physical_cell_valid(Table *table,
int phys_row, int phys_col,
gboolean exact_pointer);
void gnc_table_refresh_cursor_gui (Table * table, CellBlock *curs,
int phys_row, int phys_col,
gncBoolean do_scroll);
/* gnc_table_enter_update() is a utility function used to determine
* how the gui will respond. If it returns NULL, then the GUI will * how the gui will respond. If it returns NULL, then the GUI will
* map an editing widget onto this cell, and allow user input. If * map an editing widget onto this cell, and allow user input. If it
* it returns non-null, then the returned value will be used as the * returns non-null, then the returned value will be used as the new
* new cell value, and an editor for the cell will not be mapped * cell value, and an editor for the cell will not be mapped (viz,
* (viz, the user will be prevented from updating the cell). * the user will be prevented from updating the cell). The function
* The function is also passed pointers to the current cursor * is also passed pointers to the current cursor position, start
* position, start selection position, and end selection position. * selection position, and end selection position. If the function
* If the function returns NULL, then it may change any of those * returns NULL, then it may change any of those values and the
* values and the mapped editing widget will be modified accordingly. * mapped editing widget will be modified accordingly.
* *
* Note: since this is an internal-use-only routine, if you do not * Note: since this is an internal-use-only routine, if you do not
* like this semantic, cut&paste this code and change it to suit you. * like this semantic, cut&paste this code and change it to suit you.
* However, don't just change it, because it will break functional code. * However, don't just change it, because it will break functional code. */
*/ const char * gnc_table_enter_update(Table *table,
const char * int phys_row, int phys_col,
gnc_table_enter_update(Table *table,
int row, int col,
int *cursor_position, int *cursor_position,
int *start_selection, int *start_selection,
int *end_selection); int *end_selection);
const char * const char * gnc_table_leave_update(Table *table,
gnc_table_leave_update(Table *table, int phys_row, int phys_col,
int row, int col, const char *old_text);
const char* old_text);
const char * const char * gnc_table_modify_update(Table *table,
gnc_table_modify_update(Table *table, int phys_row, int phys_col,
int row, int col,
const char *oldval, const char *oldval,
const char *change, const char *change,
char *newval, char *newval,
@ -403,9 +414,8 @@ gnc_table_modify_update(Table *table,
int *start_selection, int *start_selection,
int *end_selection); int *end_selection);
gncBoolean gboolean gnc_table_direct_update(Table *table,
gnc_table_direct_update(Table *table, int phys_row, int phys_col,
int row, int col,
const char *oldval, const char *oldval,
char **newval_ptr, char **newval_ptr,
int *cursor_position, int *cursor_position,
@ -413,134 +423,12 @@ gnc_table_direct_update(Table *table,
int *end_selection, int *end_selection,
void *gui_data); void *gui_data);
gncBoolean gboolean gnc_table_traverse_update(Table *table,
gnc_table_traverse_update(Table *table, int phys_row, int phys_col,
int row, int col,
gncTableTraversalDir dir, gncTableTraversalDir dir,
int *dest_row, int *dest_row,
int *dest_col); int *dest_col);
/* Find the closest valid horizontal cell. If exact_cell is true, #endif /* __TABLE_ALLGUI_H__ */
* cells that must be explicitly selected by the user (as opposed
* to just tabbing into), are considered valid cells. */
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.
* So cook up a #define that acts like a template.
* This one will resize a 2D array in a reasonably
* efficient manner.
*/
#define XACC_RESIZE_ARRAY(table_rows,table_cols,new_rows,new_cols,arr,type,null_val,free_cell_op) \
{ \
int old_rows, old_cols; \
int i,j; \
\
/* save old table size */ \
old_rows = table_rows; \
old_cols = table_cols; \
if (0 > old_rows) old_rows = 0; \
if (0 > old_cols) old_cols = 0; \
\
/* realloc to get the new table size. Note that the */ \
/* new table may be wider or slimmer, taller or shorter. */ \
if (old_rows >= new_rows) { \
if (old_cols >= new_cols) { \
\
/* if we are here, new table has fewer cols */ \
/* simply truncate columns */ \
for (i=0; i<new_rows; i++) { \
for (j=new_cols; j<old_cols; j++) { \
free_cell_op (arr[i][j]); \
arr[i][j] = 0x0; /* plain null, not null_val */ \
} \
} \
} else { \
\
/* if we are here, the new table has more */ \
/* columns. Realloc the columns. */ \
for (i=0; i<new_rows; i++) { \
type *old_row; \
\
old_row = arr[i]; \
arr[i] = (type *) malloc (new_cols * sizeof (type)); \
for (j=0; j<old_cols; j++) { \
arr[i][j] = old_row[j]; \
} \
for (j=old_cols; j<new_cols; j++) { \
arr[i][j] = null_val; \
} \
free (old_row); \
} \
} \
\
/* new table has fewer rows. Simply truncate the rows */ \
for (i=new_rows; i<old_rows; i++) { \
for (j=0; j<old_cols; j++) { \
free_cell_op (arr[i][j]); \
} \
free (arr[i]); \
arr[i] = NULL; \
} \
\
} else { \
type **old_entries; \
\
/* if we are here, there are more new than old rows */ \
if (old_cols >= new_cols) { \
\
/* new table has fewer columns. */ \
/* Simply truncate the columns */ \
for (i=0; i<old_rows; i++) { \
for (j=new_cols; j<old_cols; j++) { \
free_cell_op (arr[i][j]); \
arr[i][j] = 0x0; /* plain null, not null_val */ \
} \
} \
} else { \
\
/* if we are here, the new table has more */ \
/* columns. Realloc the columns. */ \
for (i=0; i<old_rows; i++) { \
type *old_row; \
\
old_row = arr[i]; \
arr[i] = (type *) malloc (new_cols * sizeof (type)); \
for (j=0; j<old_cols; j++) { \
arr[i][j] = old_row[j]; \
} \
for (j=old_cols; j<new_cols; j++) { \
arr[i][j] = null_val; \
} \
free (old_row); \
} \
} \
\
/* now, add all new rows */ \
old_entries = arr; \
arr = (type **) malloc (new_rows * sizeof (type *)); \
for (i=0; i<old_rows; i++) { \
arr[i] = old_entries[i]; \
} \
if (old_entries) free (old_entries); \
\
for (i=old_rows; i<new_rows; i++) { \
arr[i] = (type *) malloc (new_cols * sizeof (type)); \
for (j=0; j<new_cols; j++) { \
arr[i][j] = null_val; \
} \
} \
} \
}
/* ==================================================== */
#endif /* __XACC_TABLE_ALLGUI_H__ */
/* ================== end of file ======================= */ /* ================== end of file ======================= */

View File

@ -24,21 +24,16 @@
* *
* FUNCTION: * FUNCTION:
* Implements the infrastructure for the displayed table. * Implements the infrastructure for the displayed table.
* This is the Gtk implementation; * This is the Gnome implementation.
* *
* HISTORY: * HISTORY:
* Copyright (c) 1998 Linas Vepstas * Copyright (c) 1998 Linas Vepstas
* Copyright (c) 1998 Rob Browning <rlb@cs.utexas.edu> * Copyright (c) 1998 Rob Browning <rlb@cs.utexas.edu>
* Copyright (c) 1999 Heath Martin <martinh@pegasus.cc.ucf.edu> * Copyright (c) 1999 Heath Martin <martinh@pegasus.cc.ucf.edu>
* Copyright (c) 2000 Heath Martin <martinh@pegasus.cc.ucf.edu> * Copyright (c) 2000 Heath Martin <martinh@pegasus.cc.ucf.edu>
* Copyright (c) 2000 Dave Peticolas <dave@krondo.com>
*/ */
/*
TODO: fix up alignments in a UI independent manner.
deal with the fact (if necessary) that the gtk UI can't directly
"cancel" a traverse.
*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -48,17 +43,31 @@
#include "cellblock.h" #include "cellblock.h"
#include "table-allgui.h" #include "table-allgui.h"
#include "table-gnome.h"
#include "util.h"
#include "splitreg.h" #include "splitreg.h"
#include "util.h"
#include "gnucash-sheet.h" #include "gnucash-sheet.h"
#include "gnucash-color.h" #include "gnucash-color.h"
#include "gnucash-style.h" #include "gnucash-style.h"
static void
table_destroy_cb(Table *table)
{
if (table == NULL)
return;
if (table->ui_data == NULL)
return;
if (table->ui_data)
gtk_widget_unref(GTK_WIDGET(table->ui_data));
table->ui_data = NULL;
}
void void
xaccCreateTable (GtkWidget *widget, void *data) gnc_table_init_gui (gncUIWidget widget, void *data)
{ {
SplitRegister *sr; SplitRegister *sr;
GnucashSheet *sheet; GnucashSheet *sheet;
@ -69,15 +78,17 @@ xaccCreateTable (GtkWidget *widget, void *data)
g_return_if_fail (GNUCASH_IS_REGISTER (widget)); g_return_if_fail (GNUCASH_IS_REGISTER (widget));
g_return_if_fail (data != NULL); g_return_if_fail (data != NULL);
sr = (SplitRegister *)data; sr = (SplitRegister *) data;
greg = GNUCASH_REGISTER(widget); greg = GNUCASH_REGISTER(widget);
sheet = GNUCASH_SHEET(greg->sheet); sheet = GNUCASH_SHEET(greg->sheet);
sheet->split_register = data; sheet->split_register = data;
table = sheet->table; table = sheet->table;
table->table_widget = GTK_WIDGET(sheet); table->destroy = table_destroy_cb;
gtk_widget_ref (table->table_widget); table->ui_data = sheet;
gtk_widget_ref (GTK_WIDGET(sheet));
/* config the cell-block styles */ /* config the cell-block styles */
@ -106,7 +117,7 @@ xaccCreateTable (GtkWidget *widget, void *data)
sr->split_cursor, sr->split_cursor,
GNUCASH_CURSOR_SPLIT); GNUCASH_CURSOR_SPLIT);
xaccRefreshHeader (table); gnc_table_refresh_header (table);
gnucash_sheet_table_load (sheet); gnucash_sheet_table_load (sheet);
gnucash_sheet_cursor_set_from_table (sheet, TRUE); gnucash_sheet_cursor_set_from_table (sheet, TRUE);
@ -115,7 +126,7 @@ xaccCreateTable (GtkWidget *widget, void *data)
void void
xaccRefreshTableGUI (Table * table) gnc_table_refresh_gui (Table * table)
{ {
GnucashSheet *sheet; GnucashSheet *sheet;
SheetBlockStyle *style; SheetBlockStyle *style;
@ -123,13 +134,13 @@ xaccRefreshTableGUI (Table * table)
if (!table) if (!table)
return; return;
if (!table->table_widget) if (!table->ui_data)
return; return;
g_return_if_fail (GNUCASH_IS_SHEET (table->table_widget)); g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data));
sheet = GNUCASH_SHEET(table->table_widget); sheet = GNUCASH_SHEET(table->ui_data);
sr = (SplitRegister *)sheet->split_register; sr = sheet->split_register;
style = sheet->cursor_style[GNUCASH_CURSOR_HEADER]; style = sheet->cursor_style[GNUCASH_CURSOR_HEADER];
gnucash_sheet_style_recompile (style, sr->header, sr, gnucash_sheet_style_recompile (style, sr->header, sr,
@ -158,48 +169,42 @@ xaccRefreshTableGUI (Table * table)
void void
doRefreshCursorGUI (Table * table, CellBlock *curs, gnc_table_refresh_cursor_gui (Table * table,
int from_row, int from_col, gncBoolean do_scroll) CellBlock *curs,
int phys_row, int phys_col,
gboolean do_scroll)
{ {
GnucashSheet *sheet; GnucashSheet *sheet;
PhysicalCell *pcell;
gint virt_row, virt_col; gint virt_row, virt_col;
if (!table) if (!table)
return; return;
if (!table->table_widget) if (!table->ui_data)
return; return;
g_return_if_fail (GNUCASH_IS_SHEET (table->table_widget)); g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data));
/* if the current cursor is undefined, there is nothing to do. */ /* if the current cursor is undefined, there is nothing to do. */
if (!curs) return; if (!curs) return;
if ((0 > from_row) || (0 > from_col)) return; if ((0 > phys_row) || (0 > phys_col)) return;
if ((from_row >= table->num_phys_rows) || if ((phys_row >= table->num_phys_rows) ||
(from_col >= table->num_phys_cols)) (phys_col >= table->num_phys_cols))
return; return;
sheet = GNUCASH_SHEET(table->table_widget); sheet = GNUCASH_SHEET(table->ui_data);
/* compute the physical bounds of the current cursor */ /* compute the physical bounds of the current cursor */
virt_row = table->locators[from_row][from_col]->virt_row; pcell = gnc_table_get_physical_cell (table, phys_row, phys_col);
virt_col = table->locators[from_row][from_col]->virt_col;
virt_row = pcell->virt_loc.virt_row;
virt_col = pcell->virt_loc.virt_col;
gnucash_sheet_cursor_set_from_table (sheet, do_scroll); gnucash_sheet_cursor_set_from_table (sheet, do_scroll);
gnucash_sheet_block_set_from_table (sheet, virt_row, virt_col); gnucash_sheet_block_set_from_table (sheet, virt_row, virt_col);
gnucash_sheet_redraw_block (sheet, virt_row, virt_col); gnucash_sheet_redraw_block (sheet, virt_row, virt_col);
} }
/* FIXME: this won't really do what is expected, since
* our sheet doesn't necessarily have constant width columns.
*
*/
int
gnc_table_column_width(Table *table, const int col)
{
return 0;
}
/* ================== end of file ======================= */ /* ================== end of file ======================= */

View File

@ -1,105 +0,0 @@
/********************************************************************\
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
* *
\********************************************************************/
/*
* FILE:
* table-gnome.h
*
* FUNCTION:
* This file defines the GNOME-specific GUI portions of the Table object.
*
* HISTORY:
* Copyright (c) 1998 Linas Vepstas
* Copyright (c) 1998 Rob Browning <rlb@cs.utexas.edu>
*/
#ifndef __XACC_TABLE_GNOME_H__
#define __XACC_TABLE_GNOME_H__
#include "config.h"
#include <gnome.h>
#include "gnc-common.h"
/* We use C not C++ in this project, but we none-the-less need
* the general mechanism of inheritance. The three #defines
* below implement that.
*
* the TABLE_PRIVATE_DATA declaration should be thought of as a
* "derived class" of which Table is the base class. This
* define is included as a part of the definition of the Table
* structure in table-allgui.h
*
* The TABLE_PRIVATE_DATA_INIT and DESTROY are the constructors
* and destructors, respectively, for this derived class.
* These are included in the xaccTableInit() and the xaccTableDestroy()
* routines in the file table-allgui.c, where they are called,
* respectively, last, and first, just as "real" constructors &
* destructors would be
TODO:
- Still need prev_entry_text?
*/
#define TABLE_PRIVATE_DATA \
/* Gtk-only private table members */ \
GtkWidget *table_widget; /* the Sheet */ \
gint insert_signal_tag; \
gint delete_signal_tag; \
gint entry_needs_reconnect;
#define TABLE_PRIVATE_DATA_INIT(table) { \
table->table_widget = NULL; \
table->insert_signal_tag = -1; \
table->delete_signal_tag = -1; \
table->entry_needs_reconnect = FALSE; \
}
#define TABLE_PRIVATE_DATA_DESTROY(table) { \
\
/* Let GTK know we're finished with this */ \
if(table->table_widget) gtk_widget_unref(table->table_widget); \
table->table_widget = NULL; \
\
}
/* nothing to resize */
#define TABLE_PRIVATE_DATA_RESIZE(a,b,c,d,e)
typedef struct _Table Table;
void xaccCreateTable (GtkWidget *, void *);
void doRefreshCursorGUI (Table *, CellBlock *, int, int, gncBoolean);
void xaccRefreshTableGUI (Table *);
#endif __XACC_TABLE_GNOME_H__
/* ================== end of file ======================= */