diff --git a/ChangeLog b/ChangeLog index 645b013670..b80429baf6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2000-08-07 Dave Peticolas + + * 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 + + * 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 * src/gnome/window-reconcile.c: After reconciliation, if the diff --git a/src/SplitLedger.c b/src/SplitLedger.c index 7d6b864255..a31022f79e 100644 --- a/src/SplitLedger.c +++ b/src/SplitLedger.c @@ -140,11 +140,11 @@ struct _SRInfo int cursor_hint_phys_col; /* 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'. * See table-allgui.[ch] for details. */ - gncBoolean exact_traversal; + gboolean exact_traversal; /* The default account where new splits are added */ Account *default_source_account; @@ -153,7 +153,7 @@ struct _SRInfo time_t last_date_entered; /* 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 */ void *user_data; @@ -391,7 +391,7 @@ gnc_copy_split_onto_split(Split *from, Split *to) /* Uses the scheme transaction copying routines */ static void gnc_copy_trans_onto_trans(Transaction *from, Transaction *to, - gncBoolean do_commit) + gboolean do_commit) { 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_col = num_cols - 1; virt_col >= 0; virt_col--) { - Split *split = table->user_data[virt_row][virt_col]; - Transaction *trans = xaccSplitGetParent(split); + Split *split; + Transaction *trans; + + split = gnc_table_get_user_data_virtual (table, virt_row, virt_col); + trans = xaccSplitGetParent(split); if (trans == last_trans) 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_col = num_cols - 1; virt_col >= 0; virt_col--) { - Split *split = table->user_data[virt_row][virt_col]; - Transaction *trans = xaccSplitGetParent(split); + Split *split; + Transaction *trans; + + split = gnc_table_get_user_data_virtual (table, virt_row, virt_col); + trans = xaccSplitGetParent(split); if (trans == last_trans) continue; @@ -622,26 +628,25 @@ gnc_find_trans_in_reg_by_desc(SplitRegister *reg, const char *description) */ static void -LedgerMoveCursor (Table *table, - int *p_new_phys_row, - int *p_new_phys_col, - void * client_data) +LedgerMoveCursor (Table *table, + int *p_new_phys_row, + int *p_new_phys_col) { int new_phys_row = *p_new_phys_row; int new_phys_col = *p_new_phys_col; - SplitRegister *reg = client_data; + SplitRegister *reg = table->user_data; SRInfo *info = xaccSRGetInfo(reg); Transaction *pending_trans = xaccTransLookup(&info->pending_trans_guid); Transaction *new_trans; Transaction *trans; + PhysicalCell *pcell; Split *trans_split; Split *new_split; - gncBoolean saved; - Locator *locator; int new_cell_row; int new_cell_col; int phys_row_offset; int phys_col_offset; + gboolean saved; 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); /* 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 */ trans_split = xaccSRGetTransSplit(reg, new_phys_row, new_phys_col); @@ -680,9 +686,10 @@ LedgerMoveCursor (Table *table, } else { - locator = table->locators[new_phys_row][new_phys_col]; - new_cell_row = locator->phys_row_offset; - new_cell_col = locator->phys_col_offset; + pcell = gnc_table_get_physical_cell (table, new_phys_row, new_phys_col); + + 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 */ @@ -708,12 +715,12 @@ LedgerMoveCursor (Table *table, * then it may have moved. Find out where it is now. */ if (xaccSRGetTransSplitRowCol (reg, new_trans, trans_split, new_split, &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_col = rev_locator->phys_col; + new_phys_row = vcell->phys_loc.phys_row; + new_phys_col = vcell->phys_loc.phys_col; new_phys_row += new_cell_row; new_phys_col += new_cell_col; @@ -751,8 +758,8 @@ LedgerMoveCursor (Table *table, reg->cursor_phys_row = new_phys_row; - locator = table->locators[new_phys_row][new_phys_col]; - reg->cursor_virt_row = locator->virt_row; + pcell = gnc_table_get_physical_cell (table, new_phys_row, new_phys_col); + reg->cursor_virt_row = pcell->virt_loc.virt_row; /* if auto-expansion is enabled, we need to redraw the register * 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); 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_phys_col = new_phys_col; @@ -1002,10 +1010,10 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir, xaccBasicCellSetChanged (&(reg->ncreditCell->cell), GNC_T); /* copy cursor contents into the table */ - xaccCommitCursor (reg->table); + gnc_table_commit_cursor (reg->table); /* and refresh the gui */ - xaccRefreshTableGUI (reg->table); + gnc_table_refresh_gui (reg->table); /* now move to the non-empty amount column */ amount = xaccSplitGetShareAmount (auto_split); @@ -1036,10 +1044,9 @@ static void LedgerTraverse (Table *table, int *p_new_phys_row, int *p_new_phys_col, - gncTableTraversalDir dir, - void * client_data) + gncTableTraversalDir dir) { - SplitRegister *reg = client_data; + SplitRegister *reg = table->user_data; SRInfo *info = xaccSRGetInfo(reg); Transaction *pending_trans = xaccTransLookup(&info->pending_trans_guid); Transaction *trans, *new_trans; @@ -1061,7 +1068,7 @@ LedgerTraverse (Table *table, changed = xaccSplitRegisterGetChangeFlag(reg); 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; if (phys_row < reg->num_header_rows) @@ -1083,8 +1090,12 @@ LedgerTraverse (Table *table, if ((phys_row >= 0) && (phys_col >= 0) && (phys_row < table->num_phys_rows) && (phys_col < table->num_phys_cols)) { - virt_row = table->locators[phys_row][phys_col]->virt_row; - virt_col = table->locators[phys_row][phys_col]->virt_col; + PhysicalCell *pcell; + + 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) && (virt_col == table->current_cursor_virt_col)) @@ -1148,7 +1159,8 @@ LedgerTraverse (Table *table, Split *new_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); xaccSRCancelCursorTransChanges(reg); @@ -1156,11 +1168,11 @@ LedgerTraverse (Table *table, if (xaccSRGetTransSplitRowCol (reg, new_trans, trans_split, new_split, &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) @@ -1185,9 +1197,9 @@ LedgerTraverse (Table *table, /* ======================================================== */ 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); if (info->set_help == NULL) @@ -1219,7 +1231,7 @@ LedgerDestroy (SplitRegister *reg) pending_trans = NULL; } - xaccTransBeginEdit (trans, 1); + xaccTransBeginEdit (trans, TRUE); xaccTransDestroy (trans); xaccTransCommitEdit (trans); @@ -1245,24 +1257,24 @@ static Transaction * xaccSRGetTrans (SplitRegister *reg, int phys_row, int phys_col) { Split *split; + PhysicalCell *pcell; int virt_row, virt_col; if (reg == NULL) return NULL; - if ((phys_row < 0) || (phys_col < 0) || - (phys_row >= reg->table->num_phys_rows) || - (phys_col >= reg->table->num_phys_cols)) + pcell = gnc_table_get_physical_cell (reg->table, phys_row, phys_col); + if (pcell == 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) return xaccSplitGetParent(split); /* 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. */ - virt_row = reg->table->locators[phys_row][phys_col]->virt_row; - virt_col = reg->table->locators[phys_row][phys_col]->virt_col; + virt_row = pcell->virt_loc.virt_row; + virt_col = pcell->virt_loc.virt_col; virt_row --; if ((0 > virt_row) || (0 > virt_col)) { @@ -1270,7 +1282,7 @@ xaccSRGetTrans (SplitRegister *reg, int phys_row, int phys_col) 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) { PERR ("no parent \n"); return NULL; @@ -1286,24 +1298,24 @@ xaccSRGetTransSplit (SplitRegister *reg, int phys_row, int phys_col) { CursorType cursor_type; int virt_row, virt_col; + PhysicalCell *pcell; if (reg == NULL) return NULL; - if ((phys_row < 0) || (phys_col < 0) || - (phys_row >= reg->table->num_phys_rows) || - (phys_col >= reg->table->num_phys_cols)) + pcell = gnc_table_get_physical_cell (reg->table, phys_row, phys_col); + if (pcell == NULL) return NULL; - virt_row = reg->table->locators[phys_row][phys_col]->virt_row; - virt_col = reg->table->locators[phys_row][phys_col]->virt_col; + virt_row = pcell->virt_loc.virt_row; + virt_col = pcell->virt_loc.virt_col; while (1) { cursor_type = xaccSplitRegisterGetCursorTypeRowCol (reg, virt_row, virt_col); 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 --; @@ -1320,6 +1332,7 @@ static Split * xaccSRGetCurrentTransSplit (SplitRegister *reg) { Split *split; + PhysicalCell *pcell; CursorType cursor_type; int phys_row, phys_col; int virt_row, virt_col; @@ -1338,13 +1351,12 @@ xaccSRGetCurrentTransSplit (SplitRegister *reg) phys_row = reg->table->current_cursor_phys_row; phys_col = reg->table->current_cursor_phys_col; - if ((phys_row < 0) || (phys_col < 0) || - (phys_row >= reg->table->num_phys_rows) || - (phys_col >= reg->table->num_phys_cols)) + pcell = gnc_table_get_physical_cell (reg->table, phys_row, phys_col); + if (pcell == NULL) return NULL; - virt_row = reg->table->locators[phys_row][phys_col]->virt_row; - virt_col = reg->table->locators[phys_row][phys_col]->virt_col; + virt_row = pcell->virt_loc.virt_row; + virt_col = pcell->virt_loc.virt_col; while (1) { @@ -1358,7 +1370,7 @@ xaccSRGetCurrentTransSplit (SplitRegister *reg) cursor_type = xaccSplitRegisterGetCursorTypeRowCol (reg, virt_row, virt_col); 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) { Split *split; + PhysicalCell *pcell; int phys_row, phys_col; int virt_row, virt_col; @@ -1383,13 +1396,12 @@ xaccSRGetCurrentTrans (SplitRegister *reg) phys_row = reg->table->current_cursor_phys_row; phys_col = reg->table->current_cursor_phys_col; - if ((phys_row < 0) || (phys_col < 0) || - (phys_row >= reg->table->num_phys_rows) || - (phys_col >= reg->table->num_phys_cols)) + pcell = gnc_table_get_physical_cell (reg->table, phys_row, phys_col); + if (pcell == NULL) return NULL; - virt_row = reg->table->locators[phys_row][phys_col]->virt_row; - virt_col = reg->table->locators[phys_row][phys_col]->virt_col; + virt_row = pcell->virt_loc.virt_row; + virt_col = pcell->virt_loc.virt_col; virt_row --; if ((0 > virt_row) || (0 > virt_col)) { @@ -1397,7 +1409,7 @@ xaccSRGetCurrentTrans (SplitRegister *reg) 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); } @@ -1431,7 +1443,7 @@ xaccSRGetBlankSplit (SplitRegister *reg) /* ======================================================== */ -gncBoolean +gboolean xaccSRGetSplitRowCol (SplitRegister *reg, Split *split, 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_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) { @@ -1460,15 +1472,15 @@ xaccSRGetSplitRowCol (SplitRegister *reg, Split *split, /* ======================================================== */ -gncBoolean +gboolean xaccSRGetTransSplitRowCol (SplitRegister *reg, Transaction *trans, Split *trans_split, Split *split, int *virt_row, int *virt_col) { Table *table = reg->table; - gncBoolean found_trans = GNC_F; - gncBoolean found_trans_split = GNC_F; - gncBoolean found_something = GNC_F; + gboolean found_trans = GNC_F; + gboolean found_trans_split = GNC_F; + gboolean found_something = GNC_F; CursorType cursor_type; int v_row, v_col; 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_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); cursor_type = xaccSplitRegisterGetCursorTypeRowCol(reg, v_row, v_col); @@ -1908,8 +1920,8 @@ xaccSRDeleteCurrentSplit (SplitRegister *reg) account = xaccSplitGetAccount(split); - xaccTransBeginEdit(trans, 1); - xaccAccountBeginEdit(account, 1); + xaccTransBeginEdit(trans, TRUE); + xaccAccountBeginEdit(account, TRUE); xaccSplitDestroy(split); xaccAccountCommitEdit(account); xaccTransCommitEdit(trans); @@ -1960,7 +1972,7 @@ xaccSRDeleteCurrentTrans (SplitRegister *reg) pending_trans = NULL; } - xaccTransBeginEdit (trans, 1); + xaccTransBeginEdit (trans, TRUE); xaccTransDestroy (trans); xaccTransCommitEdit (trans); @@ -1978,7 +1990,7 @@ xaccSRDeleteCurrentTrans (SplitRegister *reg) accounts = gnc_trans_prepend_account_list(trans, NULL); - xaccTransBeginEdit(trans, 1); + xaccTransBeginEdit(trans, TRUE); xaccTransDestroy(trans); xaccTransCommitEdit(trans); @@ -2030,7 +2042,7 @@ xaccSREmptyCurrentTrans (SplitRegister *reg) pending_trans = NULL; } - xaccTransBeginEdit (trans, 1); + xaccTransBeginEdit (trans, TRUE); xaccTransDestroy (trans); xaccTransCommitEdit (trans); @@ -2049,7 +2061,7 @@ xaccSREmptyCurrentTrans (SplitRegister *reg) accounts = gnc_trans_prepend_account_list(trans, NULL); splits = gnc_trans_prepend_split_list(trans, NULL); - xaccTransBeginEdit(trans, 1); + xaccTransBeginEdit(trans, TRUE); for (node = splits; node; node = node->next) if (node->data != split) xaccSplitDestroy(node->data); @@ -2090,9 +2102,9 @@ xaccSRCancelCursorSplitChanges (SplitRegister *reg) xaccSplitRegisterClearChangeFlag(reg); 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 * in sync with xaccSRSaveRegEntry and xaccSRSaveChangedCells. */ -static gncBoolean +static gboolean xaccSRSaveRegEntryToSCM (SplitRegister *reg, SCM trans_scm, SCM split_scm) { Transaction *trans; @@ -2313,8 +2325,8 @@ xaccSRSaveRegEntryToSCM (SplitRegister *reg, SCM trans_scm, SCM split_scm) /* ======================================================== */ /* Copy from the register object to the engine */ -gncBoolean -xaccSRSaveRegEntry (SplitRegister *reg, gncBoolean do_commit) +gboolean +xaccSRSaveRegEntry (SplitRegister *reg, gboolean do_commit) { GList *refresh_accounts; SRInfo *info = xaccSRGetInfo(reg); @@ -2914,7 +2926,7 @@ xaccSRLoadRegEntry (SplitRegister *reg, Split *split) { Split *s = xaccGetOtherSplit (split); - gncBoolean need_to_free = GNC_F; + gboolean need_to_free = GNC_F; if (s) { accname = xaccAccountGetFullName (xaccSplitGetAccount (s), @@ -2955,7 +2967,7 @@ xaccSRLoadRegEntry (SplitRegister *reg, Split *split) reg->table->current_cursor->user_data = split; /* copy cursor contents into the table */ - xaccCommitCursor (reg->table); + gnc_table_commit_cursor (reg->table); LEAVE("SRLoadTransEntry()\n"); } @@ -2976,24 +2988,24 @@ xaccSRCountRows (SplitRegister *reg, SRInfo *info = xaccSRGetInfo(reg); Split *blank_split = xaccSplitLookup(&info->blank_split_guid); CellBlock *lead_cursor; + PhysicalCell *pcell; Transaction *trans; Split *split; - Locator *locator; Table *table; - gncBoolean found_split = GNC_F; - gncBoolean found_trans = GNC_F; - gncBoolean found_trans_split = GNC_F; - gncBoolean on_blank_split = GNC_F; - gncBoolean did_expand = GNC_F; - gncBoolean on_trans_split; - gncBoolean multi_line; - gncBoolean dynamic; + gboolean found_split = GNC_F; + gboolean found_trans = GNC_F; + gboolean found_trans_split = GNC_F; + gboolean on_blank_split = GNC_F; + gboolean did_expand = GNC_F; + gboolean on_trans_split; + gboolean multi_line; + gboolean dynamic; SplitRegisterStyle style; int save_cursor_phys_row; int save_cursor_virt_row; - int save_cell_row; + int save_cell_row = -1; int num_phys_rows; int num_virt_rows; int i; @@ -3002,12 +3014,10 @@ xaccSRCountRows (SplitRegister *reg, style = reg->style; multi_line = (REG_MULTI_LINE == style); dynamic = ((REG_SINGLE_DYNAMIC == style) || (REG_DOUBLE_DYNAMIC == style)); - if ((REG_SINGLE_LINE == style) || - (REG_SINGLE_DYNAMIC == style)) { + if ((REG_SINGLE_LINE == style) || (REG_SINGLE_DYNAMIC == style)) lead_cursor = reg->single_cursor; - } else { + else lead_cursor = reg->double_cursor; - } /* save the current cursor location; if we can't find the * requested transaction/split pair, we restore the @@ -3016,9 +3026,11 @@ xaccSRCountRows (SplitRegister *reg, save_cursor_virt_row = reg->cursor_virt_row; /* save the current cell row offset */ - locator = table->locators[reg->table->current_cursor_phys_row] - [reg->table->current_cursor_phys_col]; - save_cell_row = locator->phys_row_offset; + pcell = gnc_table_get_physical_cell (table, + table->current_cursor_phys_row, + table->current_cursor_phys_col); + if (pcell) + save_cell_row = pcell->virt_loc.phys_row_offset; if (save_cell_row < 0) save_cell_row = 0; @@ -3066,7 +3078,7 @@ xaccSRCountRows (SplitRegister *reg, while (split) { /* do not count the blank split */ if (split != blank_split) { - gncBoolean do_expand; + gboolean do_expand; trans = xaccSplitGetParent(split); @@ -3288,14 +3300,14 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist, Split *split; Table *table; - gncBoolean found_pending = GNC_F; - gncBoolean found_split = GNC_F; - gncBoolean found_trans = GNC_F; - gncBoolean found_trans_split = GNC_F; - gncBoolean did_expand = GNC_F; - gncBoolean on_blank_split; - gncBoolean multi_line; - gncBoolean dynamic; + gboolean found_pending = GNC_F; + gboolean found_split = GNC_F; + gboolean found_trans = GNC_F; + gboolean found_trans_split = GNC_F; + gboolean did_expand = GNC_F; + gboolean on_blank_split; + gboolean multi_line; + gboolean dynamic; SplitRegisterType type; SplitRegisterStyle style; @@ -3313,7 +3325,7 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist, trans = xaccMallocTransaction (); - xaccTransBeginEdit (trans, 1); + xaccTransBeginEdit (trans, TRUE); xaccTransSetDateSecs(trans, info->last_date_entered); xaccTransCommitEdit (trans); @@ -3374,15 +3386,15 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist, /* disable move callback -- we don't want the cascade of * callbacks while we are fiddling with loading the register */ 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 */ /* num_virt_cols is always one. */ - xaccSetTableSize (table, reg->num_phys_rows, reg->num_cols, - reg->num_virt_rows, 1); + gnc_table_set_size (table, reg->num_phys_rows, reg->num_cols, + reg->num_virt_rows, 1); /* 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); @@ -3404,7 +3416,7 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist, /* do not load the blank split */ if (split != blank_split) { Transaction *trans; - gncBoolean do_expand; + gboolean do_expand; PINFO ("load trans %d at phys row %d \n", i, phys_row); @@ -3434,8 +3446,9 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist, Split * secondary; int j = 0; - xaccSetCursor (table, reg->trans_cursor, phys_row, 0, vrow, 0); - xaccMoveCursor (table, phys_row, 0); + gnc_table_set_cursor (table, reg->trans_cursor, + phys_row, 0, vrow, 0); + gnc_table_move_cursor (table, phys_row, 0); xaccSRLoadRegEntry (reg, split); vrow ++; phys_row += reg->trans_cursor->numRows; @@ -3448,9 +3461,9 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist, secondary = xaccTransGetSplit (trans, j); if (secondary != split) { - xaccSetCursor (table, reg->split_cursor, - phys_row, 0, vrow, 0); - xaccMoveCursor (table, phys_row, 0); + gnc_table_set_cursor (table, reg->split_cursor, + phys_row, 0, vrow, 0); + gnc_table_move_cursor (table, phys_row, 0); xaccSRLoadRegEntry (reg, secondary); PINFO ("load split %d at phys row %d addr=%p \n", j, phys_row, secondary); @@ -3463,8 +3476,8 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist, } else { /* the simple case ... */ - xaccSetCursor (table, lead_cursor, phys_row, 0, vrow, 0); - xaccMoveCursor (table, phys_row, 0); + gnc_table_set_cursor (table, lead_cursor, phys_row, 0, vrow, 0); + gnc_table_move_cursor (table, phys_row, 0); xaccSRLoadRegEntry (reg, split); vrow ++; phys_row += lead_cursor->numRows; @@ -3486,8 +3499,8 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist, if (multi_line || (dynamic && info->blank_split_edited)) { /* do the transaction row of the blank split */ - xaccSetCursor (table, reg->trans_cursor, phys_row, 0, vrow, 0); - xaccMoveCursor (table, phys_row, 0); + gnc_table_set_cursor (table, reg->trans_cursor, phys_row, 0, vrow, 0); + gnc_table_move_cursor (table, phys_row, 0); xaccSRLoadRegEntry (reg, split); vrow ++; phys_row += reg->trans_cursor->numRows; @@ -3503,9 +3516,9 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist, secondary = xaccTransGetSplit (trans, j); if (secondary != split) { - xaccSetCursor (table, reg->split_cursor, - phys_row, 0, vrow, 0); - xaccMoveCursor (table, phys_row, 0); + gnc_table_set_cursor (table, reg->split_cursor, + phys_row, 0, vrow, 0); + gnc_table_move_cursor (table, phys_row, 0); xaccSRLoadRegEntry (reg, secondary); PINFO ("load split %d at phys row %d addr=%p \n", j, phys_row, secondary); @@ -3517,8 +3530,8 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist, } while (secondary); } } else { - xaccSetCursor (table, lead_cursor, phys_row, 0, vrow, 0); - xaccMoveCursor (table, phys_row, 0); + gnc_table_set_cursor (table, lead_cursor, phys_row, 0, vrow, 0); + gnc_table_move_cursor (table, phys_row, 0); xaccSRLoadRegEntry (reg, split); vrow ++; 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)) { - xaccMoveCursorGUI(table, row, col); + gnc_table_move_cursor_gui(table, row, col); reg->cursor_phys_row = row; if (reg_buffer != NULL) { 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->exact_traversal = GNC_F; - xaccRefreshTableGUI (table); + gnc_table_refresh_gui (table); /* set the completion character for the xfer cells */ xaccComboCellSetCompleteChar (reg->mxfrmCell, account_separator); @@ -3578,7 +3591,7 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist, table->move_cursor = LedgerMoveCursor; table->traverse = LedgerTraverse; table->set_help = LedgerSetHelp; - table->client_data = reg; + table->user_data = reg; reg->destroy = LedgerDestroy; } @@ -3592,7 +3605,7 @@ LoadXferCell (ComboCell *cell, const char *base_currency, const char *base_security) { - gncBoolean load_everything; + gboolean load_everything; Account * acc; char *name; int n; @@ -3683,7 +3696,7 @@ xaccSRLoadXferCells (SplitRegister *reg, Account *base_account) /* ======================================================== */ -gncBoolean +gboolean xaccSRHasPendingChanges (SplitRegister *reg) { SRInfo *info = xaccSRGetInfo(reg); diff --git a/src/SplitLedger.h b/src/SplitLedger.h index a50c5f9eab..82cb61dfda 100644 --- a/src/SplitLedger.h +++ b/src/SplitLedger.h @@ -122,10 +122,11 @@ #include "splitreg.h" #include "Transaction.h" + /* Callback function type */ typedef gncUIWidget (*SRGetParentCallback) (void *user_data); 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, SRGetParentCallback get_parent, @@ -139,11 +140,11 @@ Transaction * xaccSRGetCurrentTrans (SplitRegister *reg); Split * xaccSRGetCurrentSplit (SplitRegister *reg); Split * xaccSRGetBlankSplit (SplitRegister *reg); -gncBoolean xaccSRGetSplitRowCol (SplitRegister *reg, Split *split, - int *virt_row, int *virt_col); -gncBoolean xaccSRGetTransSplitRowCol (SplitRegister *reg, Transaction *trans, - Split *trans_split, Split *split, - int *virt_row, int *virt_col); +gboolean xaccSRGetSplitRowCol (SplitRegister *reg, Split *split, + int *virt_row, int *virt_col); +gboolean xaccSRGetTransSplitRowCol (SplitRegister *reg, Transaction *trans, + Split *trans_split, Split *split, + int *virt_row, int *virt_col); Split * xaccSRDuplicateCurrent (SplitRegister *reg); @@ -161,11 +162,11 @@ void xaccSRCancelCursorTransChanges (SplitRegister *reg); void xaccSRLoadRegister (SplitRegister *reg, Split **slist, Account *default_source_acc); -gncBoolean xaccSRSaveRegEntry (SplitRegister *reg, gncBoolean do_commit); -void xaccSRRedrawRegEntry (SplitRegister *reg); +gboolean xaccSRSaveRegEntry (SplitRegister *reg, gboolean do_commit); +void xaccSRRedrawRegEntry (SplitRegister *reg); void xaccSRLoadXferCells (SplitRegister *reg, Account *base_account); -gncBoolean xaccSRHasPendingChanges (SplitRegister *reg); +gboolean xaccSRHasPendingChanges (SplitRegister *reg); #endif /* __XACC_SPLIT_LEDGER_H__ */ diff --git a/src/gnome/window-register.c b/src/gnome/window-register.c index ff3df191b3..feda5baaaa 100644 --- a/src/gnome/window-register.c +++ b/src/gnome/window-register.c @@ -46,7 +46,7 @@ #include "dialog-utils.h" #include "query-user.h" #include "enriched-messages.h" -#include "table-gnome.h" +#include "table-allgui.h" #include "gnucash-sheet.h" #include "global-options.h" #include "dialog-find-transactions.h" @@ -1641,7 +1641,7 @@ regWindowLedger(xaccLedgerDisplay *ledger) gnucash_register_set_initial_rows(num_rows); 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); diff --git a/src/register/Makefile.am b/src/register/Makefile.am index 29c10f3513..88f4bde02f 100644 --- a/src/register/Makefile.am +++ b/src/register/Makefile.am @@ -27,7 +27,6 @@ noinst_HEADERS = \ recncell.h \ splitreg.h \ table-allgui.h \ - table-gnome.h \ textcell.h EXTRA_DIST = \ diff --git a/src/register/Makefile.in b/src/register/Makefile.in index 21528c79b2..a04253df1b 100644 --- a/src/register/Makefile.in +++ b/src/register/Makefile.in @@ -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 -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 diff --git a/src/register/basiccell.c b/src/register/basiccell.c index 113607ed02..5658163ed4 100644 --- a/src/register/basiccell.c +++ b/src/register/basiccell.c @@ -170,7 +170,7 @@ xaccBasicCellSetChanged (BasicCell *cell, gncBoolean changed) if (cell == NULL) return; - cell->changed = changed ? 0xffffffff : 0; + cell->changed = changed ? GNC_CELL_CHANGED : 0; } /* ================== end of file ====================== */ diff --git a/src/register/basiccell.h b/src/register/basiccell.h index d2662ced2d..ae536d80df 100644 --- a/src/register/basiccell.h +++ b/src/register/basiccell.h @@ -164,11 +164,8 @@ * initialization & changes. * * The realize() callback will be called when GUI-specific - * initialization needs to be done. For Xt/Motif, the second - * argument will be cast to the parent widget. The third - * 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.) + * initialization needs to be done. For Gnome, the second + * argument will be cast to the parent widget. * * The destroy() callback will be called when the GUI associated * with the cell needs to be destroyed. @@ -181,12 +178,6 @@ * The gui_private member may be used by the derived class to * 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: * Copyright (c) 1998 Linas Vepstas */ @@ -199,6 +190,7 @@ #include "gnc-common.h" #include "gnc-ui-common.h" + /* define a bitmask */ #define XACC_CELL_ALLOW_NONE 0x0 #define XACC_CELL_ALLOW_SHADOW 0x1 @@ -206,62 +198,79 @@ #define XACC_CELL_ALLOW_ALL 0x3 #define XACC_CELL_ALLOW_EXACT_ONLY 0x4 +#define GNC_CELL_CHANGED 0xffffffff + typedef struct _BasicCell BasicCell; -struct _BasicCell { +typedef void (*CellSetValueFunc) (BasicCell *, + const char * new_value); +typedef const char * (*CellEnterFunc) (BasicCell *, + const char * current, + int *cursor_position, + int *start_selection, + int *end_selection); + +typedef const char * (*CellModifyVerifyFunc) (BasicCell *, + const char *old_value, + const char *add_str, + const char *new_value, + int *cursor_position, + int *start_selection, + int *end_selection); + +typedef gboolean (*CellDirectUpdateFunc) (BasicCell *, + const char *oldval, + char **newval_ptr, + int *cursor_position, + int *start_selection, + int *end_selection, + void *gui_data); + +typedef const char * (*CellLeaveFunc) (BasicCell *, + const char * current); + +typedef void (*CellRealizeFunc) (BasicCell *, + void *gui_handle); + +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 */ - /* 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 * blank_help; /* help when value is blank */ - char input_output; /* zero if output-only */ + guint32 changed; /* 2^32-1 if value modified */ + guint8 input_output; /* zero if output-only */ /* "virtual", overloaded set-value method */ - void (*set_value) (BasicCell *, - const char * new_value); + CellSetValueFunc set_value; /* cell-editing callbacks */ - const char * (*enter_cell) (BasicCell *, - const char * current, - int *cursor_position, - int *start_selection, - int *end_selection); - const char * (*modify_verify) (BasicCell *, - const char *old_value, - const char *add_str, - const char *new_value, - int *cursor_position, - int *start_selection, - int *end_selection); - gncBoolean (*direct_update) (BasicCell *, - const char *oldval, - char **newval_ptr, - int *cursor_position, - int *start_selection, - int *end_selection, - void *gui_data); - const char * (*leave_cell) (BasicCell *, - const char * current); + CellEnterFunc enter_cell; + CellModifyVerifyFunc modify_verify; + CellDirectUpdateFunc direct_update; + CellLeaveFunc leave_cell; /* private, GUI-specific callbacks */ - void (* realize) (BasicCell *, - void *gui_handle, - int pixel_width); - void (* move) (BasicCell *, - int phys_row, int phys_col); - void (* destroy) (BasicCell *); + CellRealizeFunc realize; + CellMoveFunc move; + CellDestroyFunc destroy; - char * (*get_help_value) (BasicCell *); + CellGetHelpFunc get_help_value; /* general hook for gui-private data */ void * gui_private; diff --git a/src/register/cellblock.c b/src/register/cellblock.c index 0608ca735d..f62f07ca38 100644 --- a/src/register/cellblock.c +++ b/src/register/cellblock.c @@ -38,242 +38,246 @@ CellBlock * xaccMallocCellBlock (int numrows, int numcols) { - CellBlock *arr; - arr = (CellBlock *) malloc (sizeof (CellBlock)); + CellBlock *cellblock; - arr->numRows = 0; - arr->numCols = 0; + cellblock = g_new(CellBlock, 1); - arr->active_bg_color = 0xffffff; /* white */ - arr->passive_bg_color = 0xffffff; /* white */ - arr->passive_bg_color2 = 0xffffff; /* white */ + cellblock->numRows = 0; + cellblock->numCols = 0; - arr->user_data = NULL; - arr->cells = NULL; - arr->cell_types = NULL; - 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); + cellblock->active_bg_color = 0xffffff; /* white */ + cellblock->passive_bg_color = 0xffffff; /* white */ + cellblock->passive_bg_color2 = 0xffffff; /* white */ - 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 -FreeCellBlockMem (CellBlock *arr) +FreeCellBlockMem (CellBlock *cellblock) { int i; int oldrows, oldcols; - oldrows = arr->numRows; - oldcols = arr->numCols; + oldrows = cellblock->numRows; + oldcols = cellblock->numCols; /* free cell array, if any */ - if (arr->cells) { + if (cellblock->cells) { for (i=0; icells[i]) free (arr->cells[i]); + if (cellblock->cells[i]) + free (cellblock->cells[i]); } - free (arr->cells); + free (cellblock->cells); } /* free label array, if any */ - if (arr->cell_types) { + if (cellblock->cell_types) { for (i=0; icell_types[i]) free (arr->cell_types[i]); + if (cellblock->cell_types[i]) + free (cellblock->cell_types[i]); } } /* free right traversal chain */ - if (arr->right_traverse_r) { + if (cellblock->right_traverse_r) { for (i=0; iright_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; iright_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 */ - if (arr->left_traverse_r) { + if (cellblock->left_traverse_r) { for (i=0; ileft_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; ileft_traverse_c[i]) free (arr->left_traverse_c[i]); + if (cellblock->left_traverse_c[i]) + free (cellblock->left_traverse_c[i]); } } /* free widths, alignments */ - if (arr->widths) free (arr->widths); - if (arr->alignments) free (arr->alignments); + if (cellblock->widths) free (cellblock->widths); + if (cellblock->alignments) free (cellblock->alignments); } /* =================================================== */ void -xaccInitCellBlock (CellBlock *arr, int numrows, int numcols) +xaccInitCellBlock (CellBlock *cellblock, int numrows, int numcols) { int i, j; - if (!arr) return; + if (!cellblock) return; - FreeCellBlockMem (arr); + FreeCellBlockMem (cellblock); /* record new size */ - arr->numRows = numrows; - arr->numCols = numcols; + cellblock->numRows = numrows; + cellblock->numCols = numcols; /* malloc new cell array */ - arr->cells = (BasicCell ***) malloc (numrows * sizeof (BasicCell **)); - arr->cell_types = (short **) malloc (numrows * sizeof (short *)); + cellblock->cells = malloc (numrows * sizeof (BasicCell **)); + cellblock->cell_types = malloc (numrows * sizeof (short *)); for (i=0; icells)[i] = (BasicCell **) malloc (numcols * sizeof (BasicCell *)); - (arr->cell_types)[i] = (short *) malloc (numcols * sizeof (short)); + (cellblock->cells)[i] = malloc (numcols * sizeof (BasicCell *)); + (cellblock->cell_types)[i] = malloc (numcols * sizeof (short)); for (j=0; jcells)[i][j] = NULL; - (arr->cell_types)[i][j] = -1; + (cellblock->cells)[i][j] = NULL; + (cellblock->cell_types)[i][j] = -1; } } /* malloc new right traversal arrays */ - arr->right_traverse_r = (short **) malloc (numrows * sizeof (short *)); - arr->right_traverse_c = (short **) malloc (numrows * sizeof (short *)); + cellblock->right_traverse_r = malloc (numrows * sizeof (short *)); + cellblock->right_traverse_c = malloc (numrows * sizeof (short *)); for (i=0; iright_traverse_r)[i] = (short *) malloc (numcols * sizeof (short)); - (arr->right_traverse_c)[i] = (short *) malloc (numcols * sizeof (short)); + (cellblock->right_traverse_r)[i] = malloc (numcols * sizeof (short)); + (cellblock->right_traverse_c)[i] = malloc (numcols * sizeof (short)); for (j=0; jright_traverse_r)[i][j] = i; - (arr->right_traverse_c)[i][j] = j+1; + (cellblock->right_traverse_r)[i][j] = i; + (cellblock->right_traverse_c)[i][j] = j+1; } /* at end of row, wrap to next row */ - (arr->right_traverse_r)[i][numcols-1] = i+1; - (arr->right_traverse_c)[i][numcols-1] = 0; + (cellblock->right_traverse_r)[i][numcols-1] = i+1; + (cellblock->right_traverse_c)[i][numcols-1] = 0; } /* at end of block, wrap back to begining */ - (arr->right_traverse_r)[numrows-1][numcols-1] = 0; - (arr->right_traverse_c)[numrows-1][numcols-1] = 0; + (cellblock->right_traverse_r)[numrows-1][numcols-1] = 0; + (cellblock->right_traverse_c)[numrows-1][numcols-1] = 0; /* last is last ... */ - arr->last_reenter_traverse_row = numrows-1; - arr->last_reenter_traverse_col = numcols-1; + cellblock->last_reenter_traverse_row = numrows-1; + cellblock->last_reenter_traverse_col = numcols-1; /* malloc new left traversal arrays */ - arr->left_traverse_r = (short **) malloc (numrows * sizeof (short *)); - arr->left_traverse_c = (short **) malloc (numrows * sizeof (short *)); + cellblock->left_traverse_r = malloc (numrows * sizeof (short *)); + cellblock->left_traverse_c = malloc (numrows * sizeof (short *)); for (i=0; ileft_traverse_r)[i] = (short *) malloc (numcols * sizeof (short)); - (arr->left_traverse_c)[i] = (short *) malloc (numcols * sizeof (short)); + (cellblock->left_traverse_r)[i] = malloc (numcols * sizeof (short)); + (cellblock->left_traverse_c)[i] = malloc (numcols * sizeof (short)); for (j=0; jleft_traverse_r)[i][j] = i; - (arr->left_traverse_c)[i][j] = j-1; + (cellblock->left_traverse_r)[i][j] = i; + (cellblock->left_traverse_c)[i][j] = j-1; } /* at start of row, wrap to previous row */ - (arr->left_traverse_r)[i][numcols-1] = i-1; - (arr->left_traverse_c)[i][numcols-1] = numcols-1; + (cellblock->left_traverse_r)[i][numcols-1] = i-1; + (cellblock->left_traverse_c)[i][numcols-1] = numcols-1; } /* at start of block, wrap back to end */ - (arr->right_traverse_r)[0][0] = numrows-1; - (arr->right_traverse_c)[0][0] = numcols-1; + (cellblock->right_traverse_r)[0][0] = numrows-1; + (cellblock->right_traverse_c)[0][0] = numcols-1; /* first is last ... */ - arr->last_left_reenter_traverse_row = 0; - arr->last_left_reenter_traverse_col = 0; + cellblock->last_left_reenter_traverse_row = 0; + cellblock->last_left_reenter_traverse_col = 0; - arr->widths = (short *) malloc (numcols * sizeof(short)); - arr->alignments = (Alignments *) malloc (numcols * sizeof(Alignments)); + cellblock->widths = malloc (numcols * sizeof(short)); + cellblock->alignments = malloc (numcols * sizeof(Alignments)); for (j=0; jwidths[j] = 0; - arr->alignments[j] = ALIGN_RIGHT; + cellblock->widths[j] = 0; + cellblock->alignments[j] = ALIGN_RIGHT; } } /* =================================================== */ void -xaccDestroyCellBlock (CellBlock *arr) +xaccDestroyCellBlock (CellBlock *cellblock) { - if (!arr) return; + if (!cellblock) return; - FreeCellBlockMem (arr); + FreeCellBlockMem (cellblock); /* finally, free this object itself */ - free (arr); + g_free (cellblock); } /* =================================================== */ void -xaccNextRight (CellBlock *arr, int row, int col, +xaccNextRight (CellBlock *cellblock, int row, int col, int next_row, int next_col) { - if (!arr) return; + if (!cellblock) return; /* avoid embarrasement if cell incorrectly specified */ 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 * 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 * just means that we should hop to the next cursor. Thus, large * values for next *are* valid. - * if ((next_row >= arr->numRows) || (next_col >= arr->numCols)) return; */ - (arr->right_traverse_r)[row][col] = next_row; - (arr->right_traverse_c)[row][col] = next_col; + (cellblock->right_traverse_r)[row][col] = next_row; + (cellblock->right_traverse_c)[row][col] = next_col; /* if traversing out (neg values) record this as the last ... */ if ((0 > next_row) || (0 > next_col)) { - arr->last_reenter_traverse_row = row; - arr->last_reenter_traverse_col = col; + cellblock->last_reenter_traverse_row = row; + cellblock->last_reenter_traverse_col = col; } } void -xaccNextLeft (CellBlock *arr, int row, int col, +xaccNextLeft (CellBlock *cellblock, int row, int col, int next_row, int next_col) { - if (!arr) return; + if (!cellblock) return; /* avoid embarrasement if cell incorrectly specified */ 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 * 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 * just means that we should hop to the next cursor. Thus, large * values for next *are* valid. - * if ((next_row >= arr->numRows) || (next_col >= arr->numCols)) return; */ - (arr->left_traverse_r)[row][col] = next_row; - (arr->left_traverse_c)[row][col] = next_col; + (cellblock->left_traverse_r)[row][col] = next_row; + (cellblock->left_traverse_c)[row][col] = next_col; /* if traversing out (neg values) record this as the last ... */ if ((0 > next_row) || (0 > next_col)) { - arr->last_left_reenter_traverse_row = row; - arr->last_left_reenter_traverse_col = col; + cellblock->last_left_reenter_traverse_row = row; + cellblock->last_left_reenter_traverse_col = col; } } diff --git a/src/register/cellblock.h b/src/register/cellblock.h index acf0962b70..fcf5ff15a0 100644 --- a/src/register/cellblock.h +++ b/src/register/cellblock.h @@ -67,11 +67,7 @@ enum _Alignments { ALIGN_FILL, }; -#ifdef MOTIF -typedef unsigned char Alignments; -#else typedef enum _Alignments Alignments; -#endif struct _CellBlock { @@ -86,7 +82,7 @@ struct _CellBlock { BasicCell ***cells; /* row-col array */ short **cell_types; /* row-col array of the cell types in splitreg.h */ - + /* The active_bg_color is the default color (in argb) for the cell * backgrounds when this cell block needs to be "highlighted" in * some way (typically, when this cellblock represents the @@ -103,7 +99,7 @@ struct _CellBlock { guint32 passive_bg_color2; /* other attributes */ - short *widths; /* column widths */ + short *widths; /* column widths */ Alignments *alignments; /* column text alignments */ short **right_traverse_r; @@ -137,9 +133,7 @@ struct _CellBlock { void * user_data; /* 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; @@ -149,10 +143,12 @@ void xaccInitCellBlock (CellBlock *, int numrows, int numcols); void xaccDestroyCellBlock (CellBlock *); /* define next cell to traverse to */ -void xaccNextRight (CellBlock *, int row, int col, - int next_row, int next_col); +void xaccNextRight (CellBlock *cellblock, + int row, int col, + int next_row, int next_col); -void xaccNextLeft (CellBlock *arr, int row, int col, - int next_row, int next_col); +void xaccNextLeft (CellBlock *cellblock, + int row, int col, + int next_row, int next_col); #endif /* __XACC_CELL_BLOCK_H__ */ diff --git a/src/register/gnome/combocell-gnome.c b/src/register/gnome/combocell-gnome.c index 58c74c1104..d39376b5eb 100644 --- a/src/register/gnome/combocell-gnome.c +++ b/src/register/gnome/combocell-gnome.c @@ -36,7 +36,6 @@ #include "splitreg.h" #include "table-allgui.h" -#include "table-gnome.h" #include "combocell.h" #include "gnucash-sheet.h" #include "gnucash-item-edit.h" @@ -77,7 +76,7 @@ typedef struct _PopBox static void block_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 destroyCombo (BasicCell *bcell); static const char * enterCombo (BasicCell *bcell, @@ -697,7 +696,7 @@ ComboHelpValue(BasicCell *bcell) /* =============================================== */ static void -realizeCombo (BasicCell *bcell, void *data, int pixel_width) +realizeCombo (BasicCell *bcell, void *data) { GnucashSheet *sheet = (GnucashSheet *) data; GnomeCanvasItem *item = sheet->item_editor; diff --git a/src/register/gnome/gnucash-cursor.c b/src/register/gnome/gnucash-cursor.c index c22102bc39..55c7c6c167 100644 --- a/src/register/gnome/gnucash-cursor.c +++ b/src/register/gnome/gnucash-cursor.c @@ -96,6 +96,7 @@ void gnucash_cursor_get_phys (GnucashCursor *cursor, int *phys_row, int *phys_col) { Table *table; + VirtualCell *vcell; int virt_row, virt_col; int cell_row, cell_col; @@ -114,10 +115,10 @@ gnucash_cursor_get_phys (GnucashCursor *cursor, int *phys_row, int *phys_col) cell_col = GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_CELL])->col; - *phys_row = - table->rev_locators[virt_row][virt_col]->phys_row + cell_row; - *phys_col = - table->rev_locators[virt_row][virt_col]->phys_col + cell_col; + vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col); + + *phys_row = vcell->phys_loc.phys_row + cell_row; + *phys_col = vcell->phys_loc.phys_col + cell_col; } diff --git a/src/register/gnome/gnucash-grid.h b/src/register/gnome/gnucash-grid.h index e4d09f5d57..03d3df643a 100644 --- a/src/register/gnome/gnucash-grid.h +++ b/src/register/gnome/gnucash-grid.h @@ -23,7 +23,6 @@ #include -#include "table-gnome.h" #include "table-allgui.h" diff --git a/src/register/gnome/gnucash-item-edit.c b/src/register/gnome/gnucash-item-edit.c index c832fcb271..8cff024286 100644 --- a/src/register/gnome/gnucash-item-edit.c +++ b/src/register/gnome/gnucash-item-edit.c @@ -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 virt_row, virt_col, cell_row, cell_col; SheetBlockStyle *style; + PhysicalCell *pcell; char *text; g_return_val_if_fail (IS_ITEM_EDIT(item_edit), FALSE); table = item_edit->sheet->table; - virt_row = table->locators[p_row][p_col]->virt_row; - virt_col = table->locators[p_row][p_col]->virt_col; - cell_row = table->locators[p_row][p_col]->phys_row_offset; - cell_col = table->locators[p_row][p_col]->phys_col_offset; + pcell = gnc_table_get_physical_cell (table, p_row, p_col); + if (pcell == NULL) + return FALSE; + + 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); diff --git a/src/register/gnome/gnucash-sheet.c b/src/register/gnome/gnucash-sheet.c index 30696b2eab..f36635e48d 100644 --- a/src/register/gnome/gnucash-sheet.c +++ b/src/register/gnome/gnucash-sheet.c @@ -25,6 +25,7 @@ * * Author: * Heath Martin + * Dave Peticolas */ @@ -142,6 +143,7 @@ gnucash_sheet_cursor_set_from_table (GnucashSheet *sheet, gncBoolean do_scroll) Table *table; gint cell_row, cell_col; gint p_row, p_col; + PhysicalCell *pcell; GnucashCursor *cursor; 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_col = table->current_cursor_phys_col; - if (p_row < 0 || p_row >= table->num_phys_rows || - p_col < 0 || p_col >= table->num_phys_cols) + pcell = gnc_table_get_physical_cell (table, p_row, p_col); + if (pcell == NULL) return; - cell_row = table->locators[p_row][p_col]->phys_row_offset; - cell_col = table->locators[p_row][p_col]->phys_col_offset; + cell_row = pcell->virt_loc.phys_row_offset; + cell_col = pcell->virt_loc.phys_col_offset; gnucash_sheet_cursor_set(sheet, table->current_cursor_virt_row, @@ -257,7 +259,7 @@ gnucash_sheet_activate_cursor_cell (GnucashSheet *sheet, &virt_row, &virt_col, &cell_row, &cell_col); /* 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), &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); 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; 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 * 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 */ 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), &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; 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), &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; old_text = gtk_entry_get_text (GTK_ENTRY(sheet->entry)); @@ -1058,9 +1060,9 @@ gnucash_sheet_delete_cb (GtkWidget *widget, gnucash_cursor_get_virt (GNUCASH_CURSOR (sheet->cursor), &v_row, &v_col, &c_row, &c_col); - if (!gnc_register_cell_valid (table, p_row, p_col, GNC_F)) + if (!gnc_table_physical_cell_valid (table, p_row, p_col, FALSE)) return; - + old_text = gtk_entry_get_text (GTK_ENTRY(sheet->entry)); if (old_text == NULL) @@ -1313,6 +1315,7 @@ static gboolean gnucash_button_press_event (GtkWidget *widget, GdkEventButton *event) { GnucashSheet *sheet; + VirtualCell *vcell; int xoffset, yoffset; gboolean changed_cells; int x, y; @@ -1376,11 +1379,12 @@ gnucash_button_press_event (GtkWidget *widget, GdkEventButton *event) &new_c_row, &new_c_col)) return TRUE; - new_p_row = table->rev_locators[new_v_row][new_v_col]->phys_row + - new_c_row; + vcell = gnc_table_get_virtual_cell (table, new_v_row, new_v_col); + if (vcell == NULL) + return TRUE; - new_p_col = table->rev_locators[new_v_row][new_v_col]->phys_col + - new_c_col; + new_p_row = vcell->phys_loc.phys_row + new_c_row; + new_p_col = vcell->phys_loc.phys_col + new_c_col; if ((new_p_row == current_p_row) && (new_p_col == current_p_col) && (event->type == GDK_2BUTTON_PRESS)) @@ -1541,7 +1545,7 @@ gnucash_sheet_clipboard_event (GnucashSheet *sheet, GdkEventKey *event) return handled; } -static gncBoolean +static gboolean gnucash_sheet_direct_event(GnucashSheet *sheet, GdkEvent *event) { GtkEditable *editable; @@ -1562,8 +1566,8 @@ gnucash_sheet_direct_event(GnucashSheet *sheet, GdkEvent *event) gnucash_cursor_get_virt(GNUCASH_CURSOR(sheet->cursor), &v_row, &v_col, &c_row, &c_col); - if (!gnc_register_cell_valid (table, p_row, p_col, GNC_T)) - return GNC_F; + if (!gnc_table_physical_cell_valid (table, p_row, p_col, TRUE)) + return FALSE; old_text = gtk_entry_get_text (GTK_ENTRY(sheet->entry)); if (old_text == NULL) @@ -1650,7 +1654,7 @@ gnucash_sheet_key_press_event (GtkWidget *widget, GdkEventKey *event) sheet = GNUCASH_SHEET (widget); table = sheet->table; - header = table->handlers[0][0]; + header = gnc_table_get_header_cell(table)->cellblock; if (gnucash_sheet_direct_event(sheet, (GdkEvent *) event)) return TRUE; @@ -1822,6 +1826,7 @@ gnucash_sheet_goto_virt_row_col (GnucashSheet *sheet, int new_v_row, int new_v_col) { Table *table; + VirtualCell *vcell; gncBoolean exit_register; 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), ¤t_p_row, ¤t_p_col); - new_p_row = table->rev_locators[new_v_row][new_v_col]->phys_row; - new_p_col = table->rev_locators[new_v_row][new_v_col]->phys_col; + vcell = gnc_table_get_virtual_cell (table, new_v_row, new_v_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 * appropriate here. */ @@ -1945,38 +1954,46 @@ gnucash_sheet_block_clear_entries (SheetBlock *block) static void -gnucash_sheet_block_set_entries (GnucashSheet *sheet, gint virt_row, - gint virt_col) +gnucash_sheet_block_set_entries (GnucashSheet *sheet, + gint virt_row, gint virt_col) { gint i,j; - SheetBlock *block; 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); + if (block == NULL) + return; - if (block) { - table = sheet->table; + table = sheet->table; - phys_row_origin = - table->rev_locators[virt_row][virt_col]->phys_row; - phys_col_origin = - table->rev_locators[virt_row][virt_col]->phys_col; + vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col); + if (vcell == NULL) + return; - for (i = 0; i < block->style->nrows; i++) { - for (j = 0; j < block->style->ncols; j++) { + phys_row_origin = vcell->phys_loc.phys_row; + phys_col_origin = vcell->phys_loc.phys_col; - block->entries[i][j] = table->entries [phys_row_origin + i][phys_col_origin + j]; - - block->fg_colors[i][j] = - gnucash_color_argb_to_gdk(table->fg_colors [phys_row_origin + i][phys_col_origin + j]); + for (i = 0; i < block->style->nrows; i++) + for (j = 0; j < block->style->ncols; j++) { + PhysicalCell *pcell; + gint p_row, p_col; - block->bg_colors[i][j] = - gnucash_color_argb_to_gdk (table->bg_colors [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] = + gnucash_color_argb_to_gdk (pcell->fg_color); + block->bg_colors[i][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; SheetBlock *block; SheetBlockStyle *style; - gint i; 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); style = block->style; - if (!style) return; - if (cell_row >= 0 && cell_row <= style->nrows - && cell_col >= 0 && cell_col <= style->ncols) { + if (cell_row >= 0 && cell_row <= style->nrows && + cell_col >= 0 && cell_col <= style->ncols) { + VirtualCell *vcell; + PhysicalCell *pcell; block->entries[cell_row][cell_col] = NULL; - - p_row = table->rev_locators[virt_row][virt_col]->phys_row + - cell_row; - p_col = table->rev_locators[virt_row][virt_col]->phys_col + - cell_col; - block->entries[cell_row][cell_col] = table->entries[p_row][p_col]; + vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col); + if (vcell == NULL) + return; + + 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 gnucash_sheet_col_max_width (GnucashSheet *sheet, gint virt_col, gint cell_col) { diff --git a/src/register/gnome/gnucash-sheet.h b/src/register/gnome/gnucash-sheet.h index 224fd00506..7eaa53ae7f 100644 --- a/src/register/gnome/gnucash-sheet.h +++ b/src/register/gnome/gnucash-sheet.h @@ -24,7 +24,6 @@ #include #include "splitreg.h" -#include "table-gnome.h" #include "table-allgui.h" #define CELL_VPADDING 5 diff --git a/src/register/gnome/gnucash-style.c b/src/register/gnome/gnucash-style.c index c147672eee..610f28e657 100644 --- a/src/register/gnome/gnucash-style.c +++ b/src/register/gnome/gnucash-style.c @@ -1470,20 +1470,26 @@ gnucash_sheet_get_style_from_table (GnucashSheet *sheet, gint vrow, gint vcol) { Table *table; SplitRegister *sr; + VirtualCell *vcell; + CellBlock *cursor; g_return_val_if_fail (sheet != NULL, NULL); g_return_val_if_fail (GNUCASH_IS_SHEET(sheet), NULL); 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]; - else if (table->handlers[vrow][vcol] == sr->double_cursor) + else if (cursor == sr->double_cursor) 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]; - else if (table->handlers[vrow][vcol] == sr->split_cursor) + else if (cursor == sr->split_cursor) return sheet->cursor_style[GNUCASH_CURSOR_SPLIT]; else return sheet->cursor_style[GNUCASH_CURSOR_HEADER]; diff --git a/src/register/splitreg.c b/src/register/splitreg.c index 2b4ce3f7a4..6b6c63266b 100644 --- a/src/register/splitreg.c +++ b/src/register/splitreg.c @@ -32,12 +32,14 @@ * * HISTORY: * Copyright (c) 1998, 1999, 2000 Linas Vepstas + * Copyright (c) 2000 Dave Peticolas */ #include "config.h" #include #include +#include #include "recncell.h" #include "splitreg.h" @@ -89,7 +91,7 @@ static SplitRegisterColors reg_colors = { 0xccccff, /* pale blue, double cursor passive */ 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 */ 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) { \ - SET (NAME, col, row, reg->CN##Cell); \ -} - -#define FANCY(NAME,CN,col,row) { \ +#define SET_CELL(NAME,CN,col,row) { \ SET (NAME, col, row, &(reg->CN##Cell->cell)); \ } @@ -372,44 +370,44 @@ configLayout (SplitRegister *reg) case EQUITY_REGISTER: { curs = reg->double_cursor; - FANCY (DATE, date, 0, 0); - FANCY (NUM, num, 1, 0); - FANCY (DESC, desc, 2, 0); - FANCY (MXFRM, mxfrm, 3, 0); - FANCY (RECN, recn, 4, 0); - FANCY (DEBT, debit, 5, 0); - FANCY (CRED, credit, 6, 0); - FANCY (BALN, balance, 7, 0); + SET_CELL (DATE, date, 0, 0); + SET_CELL (NUM, num, 1, 0); + SET_CELL (DESC, desc, 2, 0); + SET_CELL (MXFRM, mxfrm, 3, 0); + SET_CELL (RECN, recn, 4, 0); + SET_CELL (DEBT, debit, 5, 0); + SET_CELL (CRED, credit, 6, 0); + SET_CELL (BALN, balance, 7, 0); - FANCY (ACTN, action, 1, 1); - FANCY (MEMO, memo, 2, 1); + SET_CELL (ACTN, action, 1, 1); + SET_CELL (MEMO, memo, 2, 1); curs = reg->trans_cursor; - FANCY (DATE, date, 0, 0); - FANCY (NUM, num, 1, 0); - FANCY (DESC, desc, 2, 0); - FANCY (XTO, xto, 3, 0); - FANCY (RECN, recn, 4, 0); - FANCY (DEBT, debit, 5, 0); - FANCY (CRED, credit, 6, 0); - FANCY (BALN, balance, 7, 0); + SET_CELL (DATE, date, 0, 0); + SET_CELL (NUM, num, 1, 0); + SET_CELL (DESC, desc, 2, 0); + SET_CELL (XTO, xto, 3, 0); + SET_CELL (RECN, recn, 4, 0); + SET_CELL (DEBT, debit, 5, 0); + SET_CELL (CRED, credit, 6, 0); + SET_CELL (BALN, balance, 7, 0); curs = reg->split_cursor; - FANCY (ACTN, action, 1, 0); - FANCY (MEMO, memo, 2, 0); - FANCY (XFRM, xfrm, 3, 0); - FANCY (NDEBT, ndebit, 5, 0); - FANCY (NCRED, ncredit, 6, 0); + SET_CELL (ACTN, action, 1, 0); + SET_CELL (MEMO, memo, 2, 0); + SET_CELL (XFRM, xfrm, 3, 0); + SET_CELL (NDEBT, ndebit, 5, 0); + SET_CELL (NCRED, ncredit, 6, 0); curs = reg->single_cursor; - FANCY (DATE, date, 0, 0); - FANCY (NUM, num, 1, 0); - FANCY (DESC, desc, 2, 0); - FANCY (MXFRM, mxfrm, 3, 0); - FANCY (RECN, recn, 4, 0); - FANCY (DEBT, debit, 5, 0); - FANCY (CRED, credit, 6, 0); - FANCY (BALN, balance, 7, 0); + SET_CELL (DATE, date, 0, 0); + SET_CELL (NUM, num, 1, 0); + SET_CELL (DESC, desc, 2, 0); + SET_CELL (MXFRM, mxfrm, 3, 0); + SET_CELL (RECN, recn, 4, 0); + SET_CELL (DEBT, debit, 5, 0); + SET_CELL (CRED, credit, 6, 0); + SET_CELL (BALN, balance, 7, 0); break; } @@ -420,44 +418,44 @@ configLayout (SplitRegister *reg) case SEARCH_LEDGER: { curs = reg->double_cursor; - FANCY (DATE, date, 0, 0); - FANCY (NUM, num, 1, 0); - FANCY (DESC, desc, 2, 0); - FANCY (XTO, xto, 3, 0); - FANCY (MXFRM, mxfrm, 4, 0); - FANCY (RECN, recn, 5, 0); - FANCY (DEBT, debit, 6, 0); - FANCY (CRED, credit, 7, 0); + SET_CELL (DATE, date, 0, 0); + SET_CELL (NUM, num, 1, 0); + SET_CELL (DESC, desc, 2, 0); + SET_CELL (XTO, xto, 3, 0); + SET_CELL (MXFRM, mxfrm, 4, 0); + SET_CELL (RECN, recn, 5, 0); + SET_CELL (DEBT, debit, 6, 0); + SET_CELL (CRED, credit, 7, 0); - FANCY (ACTN, action, 1, 1); - FANCY (MEMO, memo, 2, 1); + SET_CELL (ACTN, action, 1, 1); + SET_CELL (MEMO, memo, 2, 1); curs = reg->trans_cursor; - FANCY (DATE, date, 0, 0); - FANCY (NUM, num, 1, 0); - FANCY (DESC, desc, 2, 0); - FANCY (XTO, mxfrm, 3, 0); - FANCY (XFRM, xto, 4, 0); - FANCY (RECN, recn, 5, 0); - FANCY (DEBT, debit, 6, 0); - FANCY (CRED, credit, 7, 0); + SET_CELL (DATE, date, 0, 0); + SET_CELL (NUM, num, 1, 0); + SET_CELL (DESC, desc, 2, 0); + SET_CELL (XTO, mxfrm, 3, 0); + SET_CELL (XFRM, xto, 4, 0); + SET_CELL (RECN, recn, 5, 0); + SET_CELL (DEBT, debit, 6, 0); + SET_CELL (CRED, credit, 7, 0); curs = reg->split_cursor; - FANCY (ACTN, action, 1, 0); - FANCY (MEMO, memo, 2, 0); - FANCY (XFRM, xfrm, 4, 0); - FANCY (NDEBT, ndebit, 6, 0); - FANCY (NCRED, ncredit, 7, 0); + SET_CELL (ACTN, action, 1, 0); + SET_CELL (MEMO, memo, 2, 0); + SET_CELL (XFRM, xfrm, 4, 0); + SET_CELL (NDEBT, ndebit, 6, 0); + SET_CELL (NCRED, ncredit, 7, 0); curs = reg->single_cursor; - FANCY (DATE, date, 0, 0); - FANCY (NUM, num, 1, 0); - FANCY (DESC, desc, 2, 0); - FANCY (XTO, xto, 3, 0); - FANCY (MXFRM, mxfrm, 4, 0); - FANCY (RECN, recn, 5, 0); - FANCY (DEBT, debit, 6, 0); - FANCY (CRED, credit, 7, 0); + SET_CELL (DATE, date, 0, 0); + SET_CELL (NUM, num, 1, 0); + SET_CELL (DESC, desc, 2, 0); + SET_CELL (XTO, xto, 3, 0); + SET_CELL (MXFRM, mxfrm, 4, 0); + SET_CELL (RECN, recn, 5, 0); + SET_CELL (DEBT, debit, 6, 0); + SET_CELL (CRED, credit, 7, 0); break; } @@ -467,53 +465,53 @@ configLayout (SplitRegister *reg) case CURRENCY_REGISTER: { curs = reg->double_cursor; - FANCY (DATE, date, 0, 0); - FANCY (NUM, num, 1, 0); - FANCY (DESC, desc, 2, 0); - FANCY (MXFRM, mxfrm, 3, 0); - FANCY (RECN, recn, 4, 0); - FANCY (DEBT, debit, 5, 0); - FANCY (CRED, credit, 6, 0); - FANCY (PRIC, price, 7, 0); - FANCY (VALU, value, 8, 0); - FANCY (SHRS, shrs, 9, 0); - FANCY (BALN, balance, 10, 0); + SET_CELL (DATE, date, 0, 0); + SET_CELL (NUM, num, 1, 0); + SET_CELL (DESC, desc, 2, 0); + SET_CELL (MXFRM, mxfrm, 3, 0); + SET_CELL (RECN, recn, 4, 0); + SET_CELL (DEBT, debit, 5, 0); + SET_CELL (CRED, credit, 6, 0); + SET_CELL (PRIC, price, 7, 0); + SET_CELL (VALU, value, 8, 0); + SET_CELL (SHRS, shrs, 9, 0); + SET_CELL (BALN, balance, 10, 0); - FANCY (ACTN, action, 1, 1); - FANCY (MEMO, memo, 2, 1); + SET_CELL (ACTN, action, 1, 1); + SET_CELL (MEMO, memo, 2, 1); curs = reg->trans_cursor; - FANCY (DATE, date, 0, 0); - FANCY (NUM, num, 1, 0); - FANCY (DESC, desc, 2, 0); - FANCY (XTO, xto, 3, 0); - FANCY (RECN, recn, 4, 0); - FANCY (DEBT, debit, 5, 0); - FANCY (CRED, credit, 6, 0); - FANCY (PRIC, price, 7, 0); - FANCY (VALU, value, 8, 0); - FANCY (SHRS, shrs, 9, 0); - FANCY (BALN, balance, 10, 0); + SET_CELL (DATE, date, 0, 0); + SET_CELL (NUM, num, 1, 0); + SET_CELL (DESC, desc, 2, 0); + SET_CELL (XTO, xto, 3, 0); + SET_CELL (RECN, recn, 4, 0); + SET_CELL (DEBT, debit, 5, 0); + SET_CELL (CRED, credit, 6, 0); + SET_CELL (PRIC, price, 7, 0); + SET_CELL (VALU, value, 8, 0); + SET_CELL (SHRS, shrs, 9, 0); + SET_CELL (BALN, balance, 10, 0); curs = reg->split_cursor; - FANCY (ACTN, action, 1, 0); - FANCY (MEMO, memo, 2, 0); - FANCY (XFRM, xfrm, 3, 0); - FANCY (NDEBT, ndebit, 5, 0); - FANCY (NCRED, ncredit, 6, 0); + SET_CELL (ACTN, action, 1, 0); + SET_CELL (MEMO, memo, 2, 0); + SET_CELL (XFRM, xfrm, 3, 0); + SET_CELL (NDEBT, ndebit, 5, 0); + SET_CELL (NCRED, ncredit, 6, 0); curs = reg->single_cursor; - FANCY (DATE, date, 0, 0); - FANCY (NUM, num, 1, 0); - FANCY (DESC, desc, 2, 0); - FANCY (MXFRM, mxfrm, 3, 0); - FANCY (RECN, recn, 4, 0); - FANCY (DEBT, debit, 5, 0); - FANCY (CRED, credit, 6, 0); - FANCY (PRIC, price, 7, 0); - FANCY (VALU, value, 8, 0); - FANCY (SHRS, shrs, 9, 0); - FANCY (BALN, balance, 10, 0); + SET_CELL (DATE, date, 0, 0); + SET_CELL (NUM, num, 1, 0); + SET_CELL (DESC, desc, 2, 0); + SET_CELL (MXFRM, mxfrm, 3, 0); + SET_CELL (RECN, recn, 4, 0); + SET_CELL (DEBT, debit, 5, 0); + SET_CELL (CRED, credit, 6, 0); + SET_CELL (PRIC, price, 7, 0); + SET_CELL (VALU, value, 8, 0); + SET_CELL (SHRS, shrs, 9, 0); + SET_CELL (BALN, balance, 10, 0); break; } @@ -522,53 +520,53 @@ configLayout (SplitRegister *reg) case PORTFOLIO_LEDGER: { curs = reg->double_cursor; - FANCY (DATE, date, 0, 0); - FANCY (NUM, num, 1, 0); - FANCY (DESC, desc, 2, 0); - FANCY (XTO, xto, 3, 0); - FANCY (MXFRM, mxfrm, 4, 0); - FANCY (RECN, recn, 5, 0); - FANCY (DEBT, debit, 6, 0); - FANCY (CRED, credit, 7, 0); - FANCY (PRIC, price, 8, 0); - FANCY (VALU, value, 9, 0); - FANCY (SHRS, shrs, 10, 0); + SET_CELL (DATE, date, 0, 0); + SET_CELL (NUM, num, 1, 0); + SET_CELL (DESC, desc, 2, 0); + SET_CELL (XTO, xto, 3, 0); + SET_CELL (MXFRM, mxfrm, 4, 0); + SET_CELL (RECN, recn, 5, 0); + SET_CELL (DEBT, debit, 6, 0); + SET_CELL (CRED, credit, 7, 0); + SET_CELL (PRIC, price, 8, 0); + SET_CELL (VALU, value, 9, 0); + SET_CELL (SHRS, shrs, 10, 0); - FANCY (ACTN, action, 1, 1); - FANCY (MEMO, memo, 2, 1); + SET_CELL (ACTN, action, 1, 1); + SET_CELL (MEMO, memo, 2, 1); curs = reg->trans_cursor; - FANCY (DATE, date, 0, 0); - FANCY (NUM, num, 1, 0); - FANCY (DESC, desc, 2, 0); - FANCY (XTO, mxfrm, 3, 0); - FANCY (XFRM, xto, 4, 0); - FANCY (RECN, recn, 5, 0); - FANCY (DEBT, debit, 6, 0); - FANCY (CRED, credit, 7, 0); - FANCY (PRIC, price, 8, 0); - FANCY (VALU, value, 9, 0); - FANCY (SHRS, shrs, 10, 0); + SET_CELL (DATE, date, 0, 0); + SET_CELL (NUM, num, 1, 0); + SET_CELL (DESC, desc, 2, 0); + SET_CELL (XTO, mxfrm, 3, 0); + SET_CELL (XFRM, xto, 4, 0); + SET_CELL (RECN, recn, 5, 0); + SET_CELL (DEBT, debit, 6, 0); + SET_CELL (CRED, credit, 7, 0); + SET_CELL (PRIC, price, 8, 0); + SET_CELL (VALU, value, 9, 0); + SET_CELL (SHRS, shrs, 10, 0); curs = reg->split_cursor; - FANCY (ACTN, action, 1, 0); - FANCY (MEMO, memo, 2, 0); - FANCY (XFRM, xfrm, 4, 0); - FANCY (NDEBT, ndebit, 6, 0); - FANCY (NCRED, ncredit, 7, 0); + SET_CELL (ACTN, action, 1, 0); + SET_CELL (MEMO, memo, 2, 0); + SET_CELL (XFRM, xfrm, 4, 0); + SET_CELL (NDEBT, ndebit, 6, 0); + SET_CELL (NCRED, ncredit, 7, 0); curs = reg->single_cursor; - FANCY (DATE, date, 0, 0); - FANCY (NUM, num, 1, 0); - FANCY (DESC, desc, 2, 0); - FANCY (XTO, xto, 3, 0); - FANCY (MXFRM, mxfrm, 4, 0); - FANCY (RECN, recn, 5, 0); - FANCY (DEBT, debit, 6, 0); - FANCY (CRED, credit, 7, 0); - FANCY (PRIC, price, 8, 0); - FANCY (VALU, value, 9, 0); - FANCY (SHRS, shrs, 10, 0); + SET_CELL (DATE, date, 0, 0); + SET_CELL (NUM, num, 1, 0); + SET_CELL (DESC, desc, 2, 0); + SET_CELL (XTO, xto, 3, 0); + SET_CELL (MXFRM, mxfrm, 4, 0); + SET_CELL (RECN, recn, 5, 0); + SET_CELL (DEBT, debit, 6, 0); + SET_CELL (CRED, credit, 7, 0); + SET_CELL (PRIC, price, 8, 0); + SET_CELL (VALU, value, 9, 0); + SET_CELL (SHRS, shrs, 10, 0); break; } @@ -844,14 +842,14 @@ configTable(SplitRegister *reg) switch (reg->style) { case REG_SINGLE_LINE: case REG_SINGLE_DYNAMIC: - reg->table->alternate_bg_colors = GNC_T; + reg->table->alternate_bg_colors = TRUE; break; case REG_DOUBLE_LINE: case REG_DOUBLE_DYNAMIC: reg->table->alternate_bg_colors = reg_colors.double_alternate_virt; break; default: - reg->table->alternate_bg_colors = GNC_F; + reg->table->alternate_bg_colors = FALSE; break; } } @@ -1084,8 +1082,8 @@ xaccInitSplitRegister (SplitRegister *reg, reg->shrsCell->cell.input_output = XACC_CELL_ALLOW_SHADOW; /* by default, don't blank zeros on the balance or price cells. */ - xaccSetPriceCellBlankZero(reg->balanceCell, GNC_F); - xaccSetPriceCellBlankZero(reg->priceCell, GNC_F); + xaccSetPriceCellBlankZero(reg->balanceCell, FALSE); + xaccSetPriceCellBlankZero(reg->priceCell, FALSE); /* The reconcile cell should only be entered with the pointer, * and only then when the user clicks directly on the cell. @@ -1100,24 +1098,24 @@ xaccInitSplitRegister (SplitRegister *reg, xaccSetPriceCellValue (reg->ncreditCell, 0.0); /* Initialize shares cell */ - xaccSetPriceCellSharesValue (reg->shrsCell, GNC_T); + xaccSetPriceCellSharesValue (reg->shrsCell, TRUE); /* The action cell should accept strings not in the list */ - xaccComboCellSetStrict (reg->actionCell, GNC_F); + xaccComboCellSetStrict (reg->actionCell, FALSE); xaccSetBasicCellBlankHelp (®->actionCell->cell, ACTION_CELL_HELP); /* number format for share quantities in stock ledgers */ switch (type) { case CURRENCY_REGISTER: - xaccSetPriceCellIsCurrency (reg->priceCell, GNC_T); + xaccSetPriceCellIsCurrency (reg->priceCell, TRUE); case STOCK_REGISTER: case PORTFOLIO_LEDGER: - xaccSetPriceCellSharesValue (reg->debitCell, GNC_T); - xaccSetPriceCellSharesValue (reg->creditCell, GNC_T); - xaccSetPriceCellSharesValue (reg->ndebitCell, GNC_T); - xaccSetPriceCellSharesValue (reg->ncreditCell, GNC_T); - xaccSetPriceCellIsCurrency (reg->priceCell, GNC_T); + xaccSetPriceCellSharesValue (reg->debitCell, TRUE); + xaccSetPriceCellSharesValue (reg->creditCell, TRUE); + xaccSetPriceCellSharesValue (reg->ndebitCell, TRUE); + xaccSetPriceCellSharesValue (reg->ncreditCell, TRUE); + xaccSetPriceCellIsCurrency (reg->priceCell, TRUE); xaccSetBasicCellBlankHelp (®->priceCell->cell, PRICE_CELL_HELP); xaccSetBasicCellBlankHelp (®->valueCell->cell, VALUE_CELL_HELP); @@ -1148,22 +1146,22 @@ xaccInitSplitRegister (SplitRegister *reg, phys_c = header->numCols; reg->num_cols = phys_c; - table = xaccMallocTable (); - xaccSetTableSize (table, phys_r, phys_c, reg->num_virt_rows, 1); - xaccSetCursor (table, header, 0, 0, 0, 0); + table = gnc_table_new (); + gnc_table_set_size (table, phys_r, phys_c, reg->num_virt_rows, 1); + gnc_table_set_cursor (table, header, 0, 0, 0, 0); - /* the SetCursor call below is for most practical purposes useless. - * It simply installs a cursor (the single-line cursor, but it could - * of been any of them), and moves it to the first editable row. - * Whoop-de-doo, since this is promptly over-ridden when real 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 - * with it. Don't want to freak out any programmers. - */ - xaccSetCursor (table, reg->single_cursor, + /* The call below is for most practical purposes useless. + * It simply installs a cursor (the single-line cursor, but it + * could of been any of them), and moves it to the first editable + * row. Whoop-de-doo, since this is promptly over-ridden when real + * 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 + * with it. Don't want to freak out any programmers. */ + gnc_table_set_cursor (table, reg->single_cursor, reg->cursor_phys_row, 0, reg->cursor_virt_row, 0); - xaccMoveCursor (table, header->numRows, 0); + + gnc_table_move_cursor (table, header->numRows, 0); reg->table = table; @@ -1184,10 +1182,10 @@ xaccConfigSplitRegister (SplitRegister *reg, /* Make sure that any GUI elements associated with this reconfig * are properly initialized. */ - xaccCreateCursor (reg->table, reg->single_cursor); - xaccCreateCursor (reg->table, reg->double_cursor); - xaccCreateCursor (reg->table, reg->trans_cursor); - xaccCreateCursor (reg->table, reg->split_cursor); + gnc_table_create_cursor (reg->table, reg->single_cursor); + gnc_table_create_cursor (reg->table, reg->double_cursor); + gnc_table_create_cursor (reg->table, reg->trans_cursor); + gnc_table_create_cursor (reg->table, reg->split_cursor); configTable(reg); } @@ -1198,13 +1196,13 @@ void xaccDestroySplitRegister (SplitRegister *reg) { /* give the user a chance to clean up */ - if (reg->destroy) { - (*(reg->destroy)) (reg); - } + if (reg->destroy) + (*(reg->destroy)) (reg); + reg->destroy = NULL; reg->user_data = NULL; - xaccDestroyTable (reg->table); + gnc_table_destroy (reg->table); reg->table = NULL; xaccDestroyCellBlock (reg->header); @@ -1357,6 +1355,7 @@ CursorType xaccSplitRegisterGetCursorTypeRowCol (SplitRegister *reg, int virt_row, int virt_col) { + VirtualCell *vcell; Table *table; if (reg == NULL) @@ -1366,11 +1365,11 @@ xaccSplitRegisterGetCursorTypeRowCol (SplitRegister *reg, if (table == NULL) return CURSOR_NONE; - if ((virt_row < 0) || (virt_row >= table->num_virt_rows) || - (virt_col < 0) || (virt_col >= table->num_virt_cols)) + vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col); + if (vcell == NULL) 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) { Table *table; - Locator *locator; + VirtualCell *vcell; + PhysicalCell *pcell; CellBlock *cellblock; int phys_row, phys_col; int virt_row, virt_col; @@ -1473,18 +1473,20 @@ sr_current_cell (SplitRegister *reg) phys_row = table->current_cursor_phys_row; phys_col = table->current_cursor_phys_col; - if ((phys_row < 0) || (phys_row >= table->num_phys_rows) || - (phys_col < 0) || (phys_col >= table->num_phys_cols)) + pcell = gnc_table_get_physical_cell (table, phys_row, phys_col); + if (pcell == 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; - virt_col = locator->virt_col; - cell_row = locator->phys_row_offset; - cell_col = locator->phys_col_offset; + vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col); + if (vcell == NULL) + return NULL; - cellblock = table->handlers[virt_row][virt_col]; + cellblock = vcell->cellblock; return cellblock->cells[cell_row][cell_col]; } @@ -1506,37 +1508,40 @@ xaccSplitRegisterGetCellTypeRowCol (SplitRegister *reg, /* ============================================== */ -gncBoolean +gboolean xaccSplitRegisterGetCellRowCol (SplitRegister *reg, CellType cell_type, int *p_phys_row, int *p_phys_col) { Table *table; - Locator *locator; + VirtualCell *vcell; + PhysicalCell *pcell; CellBlock *cellblock; int phys_row, phys_col; int virt_row, virt_col; int cell_row, cell_col; if (reg == NULL) - return GNC_F; + return FALSE; table = reg->table; if (table == NULL) - return GNC_F; + return FALSE; phys_row = table->current_cursor_phys_row; phys_col = table->current_cursor_phys_col; - if ((phys_row < 0) || (phys_row >= table->num_phys_rows) || - (phys_col < 0) || (phys_col >= table->num_phys_cols)) - return GNC_F; + pcell = gnc_table_get_physical_cell (table, phys_row, phys_col); + if (pcell == NULL) + 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; - virt_col = locator->virt_col; + vcell = gnc_table_get_virtual_cell (table, virt_row, 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_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) { - 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 = rev_locator->phys_row + cell_row; - phys_col = rev_locator->phys_col + cell_col; + phys_row = vcell->phys_loc.phys_row + cell_row; + phys_col = vcell->phys_loc.phys_col + cell_col; if (p_phys_row != NULL) *p_phys_row = phys_row; @@ -1558,11 +1561,11 @@ xaccSplitRegisterGetCellRowCol (SplitRegister *reg, CellType cell_type, if (p_phys_col != NULL) *p_phys_col = phys_col; - return GNC_T; + return TRUE; } } - return GNC_F; + return FALSE; } /* ============================================== */ @@ -1572,9 +1575,7 @@ xaccMallocSplitRegisterBuffer () { SplitRegisterBuffer *srb; - srb = calloc(1, sizeof(SplitRegisterBuffer)); - - assert(srb != NULL); + srb = g_new0(SplitRegisterBuffer, 1); return srb; } @@ -1587,9 +1588,7 @@ destroyCellBuffer(CellBuffer *cb) if (cb == NULL) return; - if (cb->value != NULL) - free(cb->value); - + g_free(cb->value); cb->value = NULL; } @@ -1617,7 +1616,7 @@ xaccDestroySplitRegisterBuffer (SplitRegisterBuffer *srb) destroyCellBuffer(&srb->ncreditCell); destroyCellBuffer(&srb->ndebitCell); - free(srb); + g_free(srb); } /* ============================================== */ @@ -1628,16 +1627,8 @@ saveCell(BasicCell *bcell, CellBuffer *cb) if ((bcell == NULL) || (cb == NULL)) return; - if (cb->value != NULL) - free(cb->value); - - cb->value = bcell->value; - - if (cb->value != NULL) - { - cb->value = strdup(cb->value); - assert(cb->value != NULL); - } + g_free(cb->value); + cb->value = g_strdup(bcell->value); cb->changed = bcell->changed; } diff --git a/src/register/table-allgui.c b/src/register/table-allgui.c index 283c1b75c4..7c3c76f4f0 100644 --- a/src/register/table-allgui.c +++ b/src/register/table-allgui.c @@ -27,44 +27,74 @@ * * HISTORY: * Copyright (c) 1998,1999,2000 Linas Vepstas + * Copyright (c) 2000 Dave Peticolas */ #include #include #include -#include "util.h" -#include "cellblock.h" +#include + #include "table-allgui.h" +#include "cellblock.h" +#include "util.h" -#ifdef KDE -#define TRUE (1==1) -#define FALSE (0==1) -#endif -static void xaccFreeTableEntries (Table * table); -static void xaccTableResize (Table * table, - int new_phys_rows, int new_phys_cols, - int new_virt_rows, int new_virt_cols); +/** Datatypes **********************************************************/ + +/* The generic TableCell is used for memory allocation purposes. */ +typedef union _TableCell TableCell; +union _TableCell +{ + VirtualCell virt_cell; + PhysicalCell phys_cell; +}; + + +/** Static Globals *****************************************************/ /* This static indicates the debugging module that this .o belongs to. */ static short module = MOD_REGISTER; -/* ==================================================== */ +static GMemChunk *cell_mem_chunk = NULL; + + +/** Prototypes *********************************************************/ +static void gnc_table_init (Table * table); +static void gnc_table_free_data (Table * table); +static void gnc_virtual_cell_free (TableCell *tcell); +static void gnc_physical_cell_free (TableCell *tcell); +static void gnc_table_resize (Table * table, + int new_phys_rows, int new_phys_cols, + int new_virt_rows, int new_virt_cols); + + +/** Implementation *****************************************************/ Table * -xaccMallocTable (void) +gnc_table_new (void) { Table *table; - table = (Table *) malloc (sizeof (Table)); - xaccInitTable (table); + + /* Do this here for lower overhead. */ + if (cell_mem_chunk == NULL) + cell_mem_chunk = g_mem_chunk_create(TableCell, 2048, G_ALLOC_AND_FREE); + + table = g_new0(Table, 1); + + gnc_table_init (table); + + table->virt_cells = g_ptr_array_new(); + table->phys_cells = g_ptr_array_new(); + return table; } /* ==================================================== */ -void -xaccInitTable (Table * table) +static void +gnc_table_init (Table * table) { table->num_phys_rows = -1; table->num_phys_cols = -1; @@ -80,69 +110,133 @@ xaccInitTable (Table * table) table->move_cursor = NULL; table->traverse = NULL; table->set_help = NULL; - table->client_data = NULL; - - table->entries = NULL; - table->bg_colors = NULL; - table->fg_colors = NULL; - table->locators = NULL; - table->rev_locators = NULL; table->user_data = NULL; - table->handlers = NULL; - table->alternate_bg_colors = GNC_F; + table->alternate_bg_colors = FALSE; + + + /* initialize private data */ + + table->virt_cells = NULL; + table->phys_cells = NULL; /* invalidate the "previous" traversed cell */ table->prev_phys_traverse_row = -1; table->prev_phys_traverse_col = -1; - /* call the "derived" class constructor */ - TABLE_PRIVATE_DATA_INIT (table); + table->ui_data = NULL; + table->destroy = NULL; } /* ==================================================== */ void -xaccDestroyTable (Table * table) +gnc_table_destroy (Table * table) { - /* call derived class destructor */ - TABLE_PRIVATE_DATA_DESTROY (table); + /* invoke destroy callback */ + if (table->destroy) + table->destroy(table); - /* free the gui-independent parts */ - xaccFreeTableEntries (table); + /* free the dynamic structures */ + gnc_table_free_data (table); + + /* free the pointer arrays */ + if (table->virt_cells != NULL) + g_ptr_array_free(table->virt_cells, FALSE); + if (table->phys_cells != NULL) + g_ptr_array_free(table->phys_cells, FALSE); /* intialize vars to null value so that any access is voided. */ - xaccInitTable (table); - free (table); + gnc_table_init (table); + + g_free (table); +} + +/* ==================================================== */ + +VirtualCell * +gnc_table_get_virtual_cell (Table *table, int virt_row, int virt_col) +{ + TableCell *tcell; + guint index; + + if (table == NULL) + return NULL; + + if ((virt_row < 0) || (virt_row >= table->num_virt_rows) || + (virt_col < 0) || (virt_col >= table->num_virt_cols)) + return NULL; + + index = (virt_row * table->num_virt_cols) + virt_col; + + tcell = table->virt_cells->pdata[index]; + + return &tcell->virt_cell; +} + +/* ==================================================== */ + +PhysicalCell * +gnc_table_get_physical_cell (Table *table, int phys_row, int phys_col) +{ + TableCell *tcell; + guint index; + + if (table == NULL) + return NULL; + + if ((phys_row < 0) || (phys_row >= table->num_phys_rows) || + (phys_col < 0) || (phys_col >= table->num_phys_cols)) + return NULL; + + index = (phys_row * table->num_phys_cols) + phys_col; + + tcell = table->phys_cells->pdata[index]; + + return &tcell->phys_cell; +} + +/* ==================================================== */ + +VirtualCell * +gnc_table_get_header_cell (Table *table) +{ + return gnc_table_get_virtual_cell (table, 0, 0); } /* ==================================================== */ void -xaccSetTableSize (Table * table, int phys_rows, int phys_cols, - int virt_rows, int virt_cols) +gnc_table_set_size (Table * table, + int phys_rows, int phys_cols, + int virt_rows, int virt_cols) { - /* invalidate the current cursor position, if the array - * is shrinking. This must be done since the table is probably - * shrinking because some rows were deleted, and there's a - * pretty good chance (100% with current design) that the - * cursor is located on the deleted rows. - */ + /* Invalidate the current cursor position, if the array is + * shrinking. This must be done since the table is probably + * shrinking because some rows were deleted, and there's a pretty + * good chance (100% with current design) that the cursor is + * located on the deleted rows. */ if ((virt_rows < table->num_virt_rows) || (virt_cols < table->num_virt_cols) || (phys_rows < table->num_phys_rows) || (phys_cols < table->num_phys_cols)) { CellBlock *curs; + table->current_cursor_virt_row = -1; table->current_cursor_virt_col = -1; table->current_cursor_phys_row = -1; table->current_cursor_phys_col = -1; + curs = table->current_cursor; - if (curs) curs->user_data = NULL; + + if (curs) + curs->user_data = NULL; + table->current_cursor = NULL; } - xaccTableResize (table, phys_rows, phys_cols, virt_rows, virt_cols); + + gnc_table_resize (table, phys_rows, phys_cols, virt_rows, virt_cols); /* invalidate the "previous" traversed cell */ table->prev_phys_traverse_row = -1; @@ -151,698 +245,785 @@ xaccSetTableSize (Table * table, int phys_rows, int phys_cols, /* ==================================================== */ -#define NOOP(x) /* a big old no-op */ -#define FREEUP(x) { if(x) free(x); } - -#define FREE_ARR(nrows,ncols,arrname,freeup,killval) \ -{ \ - int i,j; \ - /* free the arrname */ \ - if (table->arrname) { \ - for (i=0; iarrname[i]) { \ - for (j=0; jarrname[i][j]); \ - table->arrname[i][j] = killval; \ - } \ - free (table->arrname[i]); \ - } \ - table->arrname[i] = NULL; \ - } \ - free (table->arrname); \ - } \ - table->arrname = NULL; \ -} - -#define FREE_PARR(arrname,freeup,killval) \ - FREE_ARR (table->num_phys_rows, table->num_phys_cols, arrname,freeup,killval); - -#define FREE_VARR(arrname,freeup,killval) \ - FREE_ARR (table->num_virt_rows, table->num_virt_cols, arrname,freeup,killval); - - static void -xaccFreeTableEntries (Table * table) +gnc_table_free_data (Table * table) { - /* free the entries */ - FREE_PARR (entries, FREEUP, NULL); - - /* free the locators */ - FREE_PARR (locators, FREEUP, NULL); - FREE_VARR (rev_locators, FREEUP, NULL); - - /* free the foreground and background color arrays */ - FREE_PARR (bg_colors, NOOP, 0xffffff); - FREE_PARR (fg_colors, NOOP, 0x0); - - /* null out user data and handlers */ - FREE_VARR (handlers, NOOP, NULL); - FREE_VARR (user_data, NOOP, NULL); -} - -/* ==================================================== */ - -static Locator * -xaccMallocLocator (void) -{ - Locator *loc; - loc = (Locator *) malloc (sizeof (Locator)); - loc->phys_row_offset = -1; - loc->phys_col_offset = -1; - loc->virt_row = -1; - loc->virt_col = -1; - - return (loc); -} - -/* ==================================================== */ -static RevLocator * -xaccMallocRevLocator (void) -{ - RevLocator *rloc; - rloc = (RevLocator *) malloc (sizeof (RevLocator)); - rloc->phys_row = -1; - rloc->phys_col = -1; - - return (rloc); -} - -/* ==================================================== */ - -static void -xaccTableResize (Table * table, - int new_phys_rows, int new_phys_cols, - int new_virt_rows, int new_virt_cols) -{ - if (!table) return; - if ((new_phys_rows < new_virt_rows) || - (new_phys_cols < new_virt_cols)) { - FATAL ("xaccTableResize(): the number of physical rows (%d %d)" - "must equal or exceed the number of virtual rows (%d %d)\n", - new_phys_rows, new_phys_cols, - new_virt_rows, new_virt_cols); - exit (1); - } - - /* resize the string data array */ - XACC_RESIZE_ARRAY ((table->num_phys_rows), - (table->num_phys_cols), - new_phys_rows, - new_phys_cols, - (table->entries), - char *, - (strdup ("")), - free); - - /* resize the locator array */ - XACC_RESIZE_ARRAY ((table->num_phys_rows), - (table->num_phys_cols), - new_phys_rows, - new_phys_cols, - (table->locators), - Locator *, - (xaccMallocLocator ()), - free); - - /* resize the reverse locator array */ - XACC_RESIZE_ARRAY ((table->num_virt_rows), - (table->num_virt_cols), - new_virt_rows, - new_virt_cols, - (table->rev_locators), - RevLocator *, - (xaccMallocRevLocator ()), - free); - - - /* resize the bg color array (white background) */ - XACC_RESIZE_ARRAY ((table->num_phys_rows), - (table->num_phys_cols), - new_phys_rows, - new_phys_cols, - (table->bg_colors), - guint32, - ((guint32) 0xffffff), /* white */ - NOOP); /* no-op */ - - /* resize the foreground color array (black text) */ - XACC_RESIZE_ARRAY ((table->num_phys_rows), - (table->num_phys_cols), - new_phys_rows, - new_phys_cols, - (table->fg_colors), - guint32, - ((guint32) 0x0), /* black */ - NOOP); /* no-op */ - - - /* resize the user-data hooks */ - XACC_RESIZE_ARRAY ((table->num_virt_rows), - (table->num_virt_cols), - new_virt_rows, - new_virt_cols, - (table->user_data), - void *, - (NULL), - NOOP); /* no-op */ - - /* resize the handler array */ - XACC_RESIZE_ARRAY ((table->num_virt_rows), - (table->num_virt_cols), - new_virt_rows, - new_virt_cols, - (table->handlers), - CellBlock *, - (NULL), - NOOP); /* no-op */ - - /* call the "derived" class resize method */ - TABLE_PRIVATE_DATA_RESIZE (table, - new_phys_rows, new_phys_cols, - new_virt_rows, new_virt_cols); - - /* we are done with the physical dimensions. - * record them for posterity. */ - table->num_phys_rows = new_phys_rows; - table->num_phys_cols = new_phys_cols; - - /* we are done with the virtual dimensions. - * record them for posterity. */ - table->num_virt_rows = new_virt_rows; - table->num_virt_cols = new_virt_cols; - -} - -/* ==================================================== */ - -void -xaccSetCursor (Table *table, CellBlock *curs, - int phys_row_origin, int phys_col_origin, - int virt_row, int virt_col) -{ - int i,j; - - /* reject various bad values that might get passed in */ - if ((!table) || (!curs)) return; - if ((0 > phys_row_origin) || (0 > phys_col_origin)) return; - if (phys_row_origin >= table->num_phys_rows) return; - if (phys_col_origin >= table->num_phys_cols) return; - - if ((0 > virt_row) || (0 > virt_col)) return; - if (virt_row >= table->num_virt_rows) return; - if (virt_col >= table->num_virt_cols) return; - - /* this cursor is the handler for this block */ - table->handlers[virt_row][virt_col] = curs; - - table->rev_locators[virt_row][virt_col]->phys_row = phys_row_origin; - table->rev_locators[virt_row][virt_col]->phys_col = phys_col_origin; - - /* intialize the mapping so that we will be able to find - * the handler, given this range of physical cell addresses */ - for (i=0; inumRows; i++) { - for (j=0; jnumCols; j++) { - Locator *loc; - loc = table->locators[phys_row_origin+i][phys_col_origin+j]; - loc->phys_row_offset = i; - loc->phys_col_offset = j; - loc->virt_row = virt_row; - loc->virt_col = virt_col; - } - } -} - -/* ==================================================== */ - -static void -makePassive (Table *table) -{ - int i,j; - CellBlock *curs; - int phys_row = table->current_cursor_phys_row; - int phys_col = table->current_cursor_phys_col; - int r_origin, c_origin; - int virt_row; - - /* Change the cell background colors to their "passive" values. - * This denotes that the cursor has left this location (which means more or - * less the same thing as "the current location is no longer being edited.") - * (But only do this if the cursor has a valid current location) - */ - if ((0 > phys_row) || (0 > phys_col)) return; - - r_origin = phys_row; - c_origin = phys_col; - r_origin -= table->locators[phys_row][phys_col]->phys_row_offset; - c_origin -= table->locators[phys_row][phys_col]->phys_col_offset; - - virt_row = table->locators[phys_row][phys_col]->virt_row; - - curs = table->current_cursor; - - for (i=0; inumRows; i++) { - for (j=0; jnumCols; j++) { - BasicCell *cell; - guint32 color; - - if (table->alternate_bg_colors) { - if ((virt_row % 2) == 1) - color = curs->passive_bg_color; - else - color = curs->passive_bg_color2; - } - else if (0 == i) - color = curs->passive_bg_color; - else - color = curs->passive_bg_color2; - - table->bg_colors[i+r_origin][j+c_origin] = color; - - cell = curs->cells[i][j]; - if (cell) { - if (cell->use_bg_color) { - table->bg_colors[i+r_origin][j+c_origin] = cell->bg_color; - } - if (cell->use_fg_color) { - table->fg_colors[i+r_origin][j+c_origin] = cell->fg_color; - } - } - } - } -} - - -/* ==================================================== */ - -static void -doMoveCursor (Table *table, int new_phys_row, int new_phys_col, - int do_move_gui) -{ - int i,j; - int phys_row_origin, phys_col_origin; - int new_virt_row, new_virt_col; - CellBlock *curs; - - ENTER("new_phys=(%d %d) do_move_gui=%d\n", - new_phys_row, new_phys_col, do_move_gui); - - /* Change the cell background colors to their "passive" values. - * This denotes that the cursor has left this location (which means more or - * less the same thing as "the current location is no longer being edited.") - */ - makePassive (table); - - /* call the callback, allowing the app to commit any changes - * associated with the current location of the cursor. - * Note that this callback may recursively call this routine. */ - if (table->move_cursor) { - (table->move_cursor) (table, &new_phys_row, &new_phys_col, - table->client_data); - - /* The above callback can cause this routine to be called - * recursively. As a result of this recursion, the cursor may - * have gotten repositioned. We need to make sure we make - * passive again. */ - makePassive (table); - if (do_move_gui) - xaccRefreshCursorGUI(table, GNC_F); - } - - /* check for out-of-bounds conditions (which may be deliberate) */ - if ((0 > new_phys_row) || (0 > new_phys_col) || - (new_phys_row >= table->num_phys_rows) || - (new_phys_col >= table->num_phys_cols)) { - new_virt_row = -1; - new_virt_col = -1; - } else { - new_virt_row = table->locators[new_phys_row][new_phys_col]->virt_row; - new_virt_col = table->locators[new_phys_row][new_phys_col]->virt_col; - } - - /* invalidate the cursor for now; we'll fix it back up below */ - table->current_cursor_phys_row = -1; - table->current_cursor_phys_col = -1; - table->current_cursor_virt_row = -1; - table->current_cursor_virt_col = -1; - table->prev_phys_traverse_row = -1; - table->prev_phys_traverse_col = -1; - curs = table->current_cursor; - if (curs) curs->user_data = NULL; - table->current_cursor = NULL; - - /* check for out-of-bounds conditions (which may be deliberate) */ - if ((0 > new_virt_row) || (0 > new_virt_col)) { - /* if the location is invalid, then we should take this - * as a command to unmap the cursor gui. So do it .. */ - if (do_move_gui && curs) { - for (i=0; inumRows; i++) { - for (j=0; jnumCols; j++) { - BasicCell *cell; - cell = curs->cells[i][j]; - if (cell) { - cell->changed = 0; - if (cell->move) { - (cell->move) (cell, -1, -1); - } - } - } - } - } - LEAVE("out of bounds\n"); - return; - } - - if (new_virt_row >= table->num_virt_rows) return; - if (new_virt_col >= table->num_virt_cols) return; - if (new_phys_row >= table->num_phys_rows) return; - if (new_phys_col >= table->num_phys_cols) return; - - /* ok, we now have a valid position. Find the new cursor to use, - * and initialize its cells */ - curs = table->handlers[new_virt_row][new_virt_col]; - table->current_cursor = curs; - - /* record the new position ... */ - table->current_cursor_virt_row = new_virt_row; - table->current_cursor_virt_col = new_virt_col; - table->current_cursor_phys_row = new_phys_row; - table->current_cursor_phys_col = new_phys_col; - - /* compute some useful offsets ... */ - phys_row_origin = new_phys_row; - phys_row_origin -= table->locators[new_phys_row][new_phys_col]->phys_row_offset; - - phys_col_origin = new_phys_col; - phys_col_origin -= table->locators[new_phys_row][new_phys_col]->phys_col_offset; - - /* setting the previous traversal value to the last of a traversal chain - * will guarantee that the first entry into a register will occur at the - * first cell */ - table->prev_phys_traverse_row = (phys_row_origin + - curs->last_reenter_traverse_row); - table->prev_phys_traverse_col = (phys_col_origin + - curs->last_reenter_traverse_col); - - /* update the cell values to reflect the new position */ - for (i=0; inumRows; i++) { - for (j=0; jnumCols; j++) { - BasicCell *cell; - - /* change the cursor row to the active color */ - table->bg_colors[i+phys_row_origin][j+phys_col_origin] = curs->active_bg_color; - - cell = curs->cells[i][j]; - if (cell) { - char * cell_val = table->entries[i+phys_row_origin][j+phys_col_origin]; - - if (do_move_gui) { - /* if a cell has a GUI, move that first, before setting - * the cell value. Otherwise, we'll end up putting the - * new values in the old cell locations, and that would - * lead to confusion of all sorts. */ - if (cell->move) { - (cell->move) (cell, i+phys_row_origin, j+phys_col_origin); - } - } - - /* OK, now copy the string value from the table at large - * into the cell handler. */ - if (XACC_CELL_ALLOW_SHADOW & (cell->input_output)) { - xaccSetBasicCellValue (cell, cell_val); - cell->changed = 0; - } - - if (cell->use_bg_color) { - table->bg_colors[i+phys_row_origin][j+phys_col_origin] = cell->bg_color; - } - if (cell->use_fg_color) { - table->fg_colors[i+phys_row_origin][j+phys_col_origin] = cell->fg_color; - } - } - } - } - - curs->user_data = table->user_data[new_virt_row][new_virt_col]; - LEAVE("did move\n"); -} - -/* ==================================================== */ - -void xaccMoveCursor (Table *table, int new_phys_row, int new_phys_col) -{ - if (!table) return; - - doMoveCursor (table, new_phys_row, new_phys_col, 0); -} - -/* same as above, but be sure to deal with GUI elements as well */ -void xaccMoveCursorGUI (Table *table, int new_phys_row, int new_phys_col) -{ - if (!table) return; - - doMoveCursor (table, new_phys_row, new_phys_col, 1); -} - -/* ==================================================== */ - -void xaccCommitCursor (Table *table) -{ - int i,j; - int virt_row, virt_col; - CellBlock *curs; - int phys_row, phys_col; - int phys_row_origin, phys_col_origin; - - if (!table) return; - - curs = table->current_cursor; - if (!curs) return; - - virt_row = table->current_cursor_virt_row; - virt_col = table->current_cursor_virt_col; - - /* can't commit if cursor is bad */ - if ((0 > virt_row) || (0 > virt_col)) return; - if (virt_row >= table->num_virt_rows) return; - if (virt_col >= table->num_virt_cols) return; - - /* compute the true origin of the cell block */ - phys_row = table->current_cursor_phys_row; - phys_col = table->current_cursor_phys_col; - phys_row_origin = table->current_cursor_phys_row; - phys_col_origin = table->current_cursor_phys_col; - phys_row_origin -= table->locators[phys_row][phys_col]->phys_row_offset; - phys_col_origin -= table->locators[phys_row][phys_col]->phys_col_offset; - - for (i=0; inumRows; i++) { - for (j=0; jnumCols; j++) { - BasicCell *cell; - - cell = curs->cells[i][j]; - if (cell) { - int iphys = i + phys_row_origin; - int jphys = j + phys_col_origin; - /*PINFO ("rowcol (%d,%d) oldval=%s newval=%s\n", - iphys, jphys, table->entries[iphys][jphys], cell->value);*/ - if (table->entries[iphys][jphys]) { - free (table->entries[iphys][jphys]); - } - table->entries[iphys][jphys] = strdup (cell->value); - if (cell->use_bg_color) { - table->bg_colors[iphys][jphys] = cell->bg_color; - } - if (cell->use_fg_color) { - table->fg_colors[iphys][jphys] = cell->fg_color; - } - } - } - } - - table->user_data[virt_row][virt_col] = curs->user_data; -} - -/* ==================================================== */ -/* hack alert -- assumes that first block is header. */ -/* hack alert -- this routine is *just like* that above, - * except that its's committing the very first cursor. - * with cleverness we could probably eliminate this routine - * entirely ... */ - -void -xaccRefreshHeader (Table *table) -{ - int i,j; - CellBlock *arr; - - if (!table) return; - if (!(table->entries)) return; - - /* copy header data into entries cache */ - arr = table->handlers[0][0]; - if (arr) { - for (i=0; inumRows; i++) { - for (j=0; jnumCols; j++) { - if (table->entries[i][j]) free (table->entries[i][j]); - if (arr->cells[i][j]) { - if ((arr->cells[i][j])->value) { - - table->entries[i][j] = strdup ((arr->cells[i][j])->value); - } else { - table->entries[i][j] = strdup (""); - } - } else { - table->entries[i][j] = strdup (""); - } - } - } - } -} - -/* ==================================================== */ -/* verifyCursorPosition checks the location of the cursor - * with respect to a row/column position, and repositions - * the cursor if necessary. This includes saving any uncommited - * data in the old cursor, and then moving the cursor and its - * GUI. Returns true if the cursor was repositioned. - */ - -gncBoolean -xaccVerifyCursorPosition (Table *table, int phys_row, int phys_col) -{ - int virt_row, virt_col; - gncBoolean do_commit = GNC_F; - gncBoolean moved_cursor = GNC_F; - - if (!table) return GNC_F; - - /* Someone may be trying to intentionally invalidate the cursor, - * in which case the physical addresses could be out of bounds. - * For example, in order to unmap it in preparation for a reconfig. - * So, if the specified location is out of bounds, then - * the cursor MUST be moved. - */ - - if ((0 > phys_row) || (0 > phys_col)) do_commit = 1; - if (phys_row >= table->num_phys_rows) do_commit = 1; - if (phys_col >= table->num_phys_cols) do_commit = 1; - - /* Hmm, phys position is valid. Check the virtual position. */ - if (!do_commit) { - virt_row = table->locators[phys_row][phys_col]->virt_row; - virt_col = table->locators[phys_row][phys_col]->virt_col; - - if ((virt_row != table->current_cursor_virt_row) || - (virt_col != table->current_cursor_virt_col)) do_commit = 1; - } - - if (do_commit) { - /* before leaving the current virtual position, commit any edits - * that have been accumulated in the cursor */ - xaccCommitCursor (table); - xaccMoveCursorGUI (table, phys_row, phys_col); - moved_cursor = GNC_T; - } else { - - /* The request might be to move to a cell that is one column over. - * If so, then do_commit will be zero, as there will have been no - * reason to actually move a cursor. However, we want to keep - * positions accurate, so record the new location. (The move may - * may also be one row up or down, which, for a two-row cursor, - * also might not require a cursor movement). - */ - if (table->current_cursor_phys_row != phys_row) - { - table->current_cursor_phys_row = phys_row; - moved_cursor = GNC_T; - } - - if (table->current_cursor_phys_col != phys_col) - { - table->current_cursor_phys_col = phys_col; - moved_cursor = GNC_T; - } - } - - return moved_cursor; -} - -/* ==================================================== */ - -void * -xaccGetUserData (Table *table, int phys_row, int phys_col) -{ - int virt_row, virt_col; - - if (!table) return NULL; - - /* check for out-of-bounds conditions */ - if ((0 > phys_row) || (0 > phys_col) || - (phys_row >= table->num_phys_rows) || - (phys_col >= table->num_phys_cols)) { - return NULL; - } - - virt_row = table->locators[phys_row][phys_col]->virt_row; - virt_col = table->locators[phys_row][phys_col]->virt_col; - - return (table->user_data[virt_row][virt_col]); -} - -/* ==================================================== */ -/* if any of the cells have GUI specific components that need - * initialization, initialize them now. The realize() callback - * on the cursor cell is how we inform the cell handler that - * now is the time to initialize its GUI. */ - -void -xaccCreateCursor (Table * table, CellBlock *curs) -{ - int i,j; - - if (!curs || !table) return; - if (!table->table_widget) return; - - for (i=0; inumRows; i++) { - for (j=0; jnumCols; j++) { - BasicCell *cell; - cell = curs->cells[i][j]; - if (cell) { - void (*realize) (BasicCell *, void *gui, int pixel_width); - realize = cell->realize; - if (realize) { - realize (cell, - ((void *) table->table_widget), - gnc_table_column_width(table, j)); - } - } + if (table == NULL) + return; + + if (table->virt_cells != NULL) + { + gpointer *tcp; + guint len; + + tcp = table->virt_cells->pdata; + len = table->virt_cells->len; + + while (len > 0) + { + gnc_virtual_cell_free(*tcp); + tcp++; + len--; } + + g_ptr_array_set_size(table->virt_cells, 0); + } + + if (table->phys_cells != NULL) + { + gpointer *tcp; + guint len; + + tcp = table->phys_cells->pdata; + len = table->phys_cells->len; + + while (len > 0) + { + gnc_physical_cell_free(*tcp); + tcp++; + len--; + } + + g_ptr_array_set_size(table->phys_cells, 0); } } /* ==================================================== */ -void -wrapVerifyCursorPosition (Table *table, int row, int col) +static void +gnc_virtual_location_init (VirtualLocation *vloc) +{ + if (vloc == NULL) + return; + + vloc->phys_row_offset = -1; + vloc->phys_col_offset = -1; + vloc->virt_row = -1; + vloc->virt_col = -1; +} + +/* ==================================================== */ + +static void +gnc_physical_location_init (PhysicalLocation *ploc) +{ + if (ploc == NULL) + return; + + ploc->phys_row = -1; + ploc->phys_col = -1; +} + +/* ==================================================== */ + +static TableCell * +gnc_virtual_cell_new (void) +{ + TableCell *tcell; + VirtualCell *vcell; + + tcell = g_chunk_new(TableCell, cell_mem_chunk); + + vcell = &tcell->virt_cell; + + vcell->cellblock = NULL; + vcell->user_data = NULL; + + gnc_physical_location_init(&vcell->phys_loc); + + return tcell; +} + +/* ==================================================== */ + +static void +gnc_virtual_cell_free (TableCell *tcell) +{ + if (tcell == NULL) + return; + + g_mem_chunk_free(cell_mem_chunk, tcell); +} + +/* ==================================================== */ + +static TableCell * +gnc_physical_cell_new (void) +{ + TableCell *tcell; + PhysicalCell *pcell; + + tcell = g_chunk_new(TableCell, cell_mem_chunk); + + pcell = &tcell->phys_cell; + + pcell->entry = strdup(""); + assert(pcell->entry != NULL); + + pcell->fg_color = 0x000000; /* black */ + pcell->bg_color = 0xffffff; /* white */ + + gnc_virtual_location_init(&pcell->virt_loc); + + return tcell; +} + +/* ==================================================== */ + +static void +gnc_physical_cell_free (TableCell *tcell) +{ + if (tcell == NULL) + return; + + if (tcell->phys_cell.entry != NULL) + free(tcell->phys_cell.entry); + + tcell->phys_cell.entry = NULL; + + g_mem_chunk_free(cell_mem_chunk, tcell); +} + +/* ==================================================== */ + +typedef TableCell * (*CellAllocator) (void); +typedef void (*CellDeAllocator) (TableCell *); + +static void +gnc_array_resize (GPtrArray *array, + int rows, int cols, + CellAllocator allocator, + CellDeAllocator deallocator) +{ + guint old_len = array->len; + guint new_len = rows * cols; + + if (new_len == old_len) + return; + + /* If shrinking, free extra cells */ + if (new_len < old_len) + { + gpointer *tcp; + guint i; + + tcp = &array->pdata[new_len]; + for (i = new_len; i < old_len; i++, tcp++) + deallocator(*tcp); + } + + /* Change the size */ + g_ptr_array_set_size(array, new_len); + + /* If expanding, create the new cells */ + if (new_len > old_len) + { + gpointer *tcp; + guint i; + + tcp = &array->pdata[old_len]; + for (i = old_len; i < new_len; i++, tcp++) + *tcp = allocator(); + } +} + +/* ==================================================== */ + +static void +gnc_table_resize (Table * table, + int new_phys_rows, int new_phys_cols, + int new_virt_rows, int new_virt_cols) +{ + if (!table) return; + + if ((new_phys_rows < new_virt_rows) || + (new_phys_cols < new_virt_cols)) + { + FATAL ("xaccTableResize(): the number of physical rows (%d %d)" + "must equal or exceed the number of virtual rows (%d %d)\n", + new_phys_rows, new_phys_cols, + new_virt_rows, new_virt_cols); + exit (1); + } + + gnc_array_resize (table->virt_cells, + new_virt_rows, new_virt_cols, + gnc_virtual_cell_new, + gnc_virtual_cell_free); + + gnc_array_resize (table->phys_cells, + new_phys_rows, new_phys_cols, + gnc_physical_cell_new, + gnc_physical_cell_free); + + table->num_phys_rows = new_phys_rows; + table->num_phys_cols = new_phys_cols; + + table->num_virt_rows = new_virt_rows; + table->num_virt_cols = new_virt_cols; +} + +/* ==================================================== */ + +void +gnc_table_set_cursor (Table *table, CellBlock *curs, + int phys_row_origin, int phys_col_origin, + int virt_row, int virt_col) +{ + VirtualCell *vcell; + int cell_row, cell_col; + + if ((table == NULL) || (curs == NULL)) + return; + + if ((phys_row_origin < 0) || (phys_row_origin >= table->num_phys_rows) || + (phys_col_origin < 0) || (phys_col_origin >= table->num_phys_cols)) + return; + + vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col); + if (vcell == NULL) + return; + + /* this cursor is the handler for this block */ + vcell->cellblock = curs; + + vcell->phys_loc.phys_row = phys_row_origin; + vcell->phys_loc.phys_col = phys_col_origin; + + /* intialize the mapping so that we will be able to find + * the handler, given this range of physical cell addresses */ + for (cell_row = 0; cell_row < curs->numRows; cell_row++) + for (cell_col = 0; cell_col < curs->numCols; cell_col++) + { + PhysicalCell *pcell; + + pcell = gnc_table_get_physical_cell (table, + phys_row_origin + cell_row, + phys_col_origin + cell_col); + + pcell->virt_loc.phys_row_offset = cell_row; + pcell->virt_loc.phys_col_offset = cell_col; + pcell->virt_loc.virt_row = virt_row; + pcell->virt_loc.virt_col = virt_col; + } +} + +/* ==================================================== */ + +/* Change the cell background colors to their "passive" values. This + * denotes that the cursor has left this location (which means more or + * less the same thing as "the current location is no longer being + * edited.") */ +static void +gnc_table_make_passive (Table *table) +{ + CellBlock *curs; + PhysicalCell *pcell; + int phys_row_origin, phys_col_origin; + int cell_row, cell_col; + int virt_row; + + pcell = gnc_table_get_physical_cell (table, + table->current_cursor_phys_row, + table->current_cursor_phys_col); + if (pcell == NULL) + return; + + phys_row_origin = table->current_cursor_phys_row; + phys_col_origin = table->current_cursor_phys_col; + phys_row_origin -= pcell->virt_loc.phys_row_offset; + phys_col_origin -= pcell->virt_loc.phys_col_offset; + + virt_row = pcell->virt_loc.virt_row; + + curs = table->current_cursor; + + for (cell_row=0; cell_row < curs->numRows; cell_row++) + for (cell_col = 0; cell_col < curs->numCols; cell_col++) + { + BasicCell *cell; + guint32 color; + + pcell = gnc_table_get_physical_cell (table, + phys_row_origin + cell_row, + phys_col_origin + cell_col); + + if (table->alternate_bg_colors) + { + if ((virt_row % 2) == 1) + color = curs->passive_bg_color; + else + color = curs->passive_bg_color2; + } + else if (cell_row == 0) + color = curs->passive_bg_color; + else + color = curs->passive_bg_color2; + + pcell->bg_color = color; + + cell = curs->cells[cell_row][cell_col]; + if (cell) + { + if (cell->use_bg_color) + pcell->bg_color = cell->bg_color; + if (cell->use_fg_color) + pcell->fg_color = cell->fg_color; + } + } +} + + +/* ==================================================== */ + +static void +gnc_table_move_cursor_internal (Table *table, + int new_phys_row, int new_phys_col, + gboolean do_move_gui) +{ + int cell_row, cell_col; + int phys_row_origin, phys_col_origin; + int new_virt_row, new_virt_col; + PhysicalCell *pcell; + VirtualCell *vcell; + CellBlock *curs; + + ENTER("new_phys=(%d %d) do_move_gui=%d\n", + new_phys_row, new_phys_col, do_move_gui); + + /* Change the cell background colors to their "passive" values. + * This denotes that the cursor has left this location (which means + * more or less the same thing as "the current location is no longer + * being edited.") */ + gnc_table_make_passive (table); + + /* call the callback, allowing the app to commit any changes + * associated with the current location of the cursor. Note that + * this callback may recursively call this routine. */ + if (table->move_cursor) + { + (table->move_cursor) (table, &new_phys_row, &new_phys_col); + + /* The above callback can cause this routine to be called + * recursively. As a result of this recursion, the cursor may + * have gotten repositioned. We need to make sure we make + * passive again. */ + gnc_table_make_passive (table); + if (do_move_gui) + gnc_table_refresh_current_cursor_gui (table, FALSE); + } + + pcell = gnc_table_get_physical_cell (table, new_phys_row, new_phys_col); + if (pcell == NULL) + { + new_virt_row = -1; + new_virt_col = -1; + } + else + { + new_virt_row = pcell->virt_loc.virt_row; + new_virt_col = pcell->virt_loc.virt_col; + } + + /* invalidate the cursor for now; we'll fix it back up below */ + table->current_cursor_phys_row = -1; + table->current_cursor_phys_col = -1; + table->current_cursor_virt_row = -1; + table->current_cursor_virt_col = -1; + table->prev_phys_traverse_row = -1; + table->prev_phys_traverse_col = -1; + curs = table->current_cursor; + if (curs) + curs->user_data = NULL; + table->current_cursor = NULL; + + /* check for out-of-bounds conditions (which may be deliberate) */ + if ((0 > new_virt_row) || (0 > new_virt_col)) + { + /* if the location is invalid, then we should take this + * as a command to unmap the cursor gui. So do it .. */ + if (do_move_gui && curs) + { + for (cell_row = 0; cell_row < curs->numRows; cell_row++) + for (cell_col = 0; cell_col < curs->numCols; cell_col++) + { + BasicCell *cell; + + cell = curs->cells[cell_row][cell_col]; + if (cell) + { + cell->changed = 0; + if (cell->move) + (cell->move) (cell, -1, -1); + } + } + } + LEAVE("out of bounds\n"); + return; + } + + if (new_virt_row >= table->num_virt_rows) return; + if (new_virt_col >= table->num_virt_cols) return; + if (new_phys_row >= table->num_phys_rows) return; + if (new_phys_col >= table->num_phys_cols) return; + + /* ok, we now have a valid position. Find the new cursor to use, + * and initialize its cells */ + vcell = gnc_table_get_virtual_cell (table, new_virt_row, new_virt_col); + curs = vcell->cellblock; + table->current_cursor = curs; + + /* record the new position */ + table->current_cursor_virt_row = new_virt_row; + table->current_cursor_virt_col = new_virt_col; + table->current_cursor_phys_row = new_phys_row; + table->current_cursor_phys_col = new_phys_col; + + /* compute some useful offsets */ + phys_row_origin = new_phys_row; + phys_row_origin -= pcell->virt_loc.phys_row_offset; + + phys_col_origin = new_phys_col; + phys_col_origin -= pcell->virt_loc.phys_col_offset; + + /* setting the previous traversal value to the last of a traversal chain + * will guarantee that the first entry into a register will occur at the + * first cell */ + table->prev_phys_traverse_row = (phys_row_origin + + curs->last_reenter_traverse_row); + table->prev_phys_traverse_col = (phys_col_origin + + curs->last_reenter_traverse_col); + + /* update the cell values to reflect the new position */ + for (cell_row = 0; cell_row < curs->numRows; cell_row++) + for (cell_col = 0; cell_col < curs->numCols; cell_col++) + { + BasicCell *cell; + + pcell = gnc_table_get_physical_cell (table, + phys_row_origin + cell_row, + phys_col_origin + cell_col); + + /* change the cursor row to the active color */ + pcell->bg_color = curs->active_bg_color; + + cell = curs->cells[cell_row][cell_col]; + if (cell) + { + if (do_move_gui) { + /* if a cell has a GUI, move that first, before setting + * the cell value. Otherwise, we'll end up putting the + * new values in the old cell locations, and that would + * lead to confusion of all sorts. */ + if (cell->move) + (cell->move) (cell, + phys_row_origin + cell_row, + phys_col_origin + cell_col); + } + + /* OK, now copy the string value from the table at large + * into the cell handler. */ + if (XACC_CELL_ALLOW_SHADOW & (cell->input_output)) + { + xaccSetBasicCellValue (cell, pcell->entry); + cell->changed = 0; + } + + if (cell->use_bg_color) + pcell->bg_color = cell->bg_color; + if (cell->use_fg_color) + pcell->fg_color = cell->fg_color; + } + } + + curs->user_data = vcell->user_data; + + LEAVE("did move\n"); +} + +/* ==================================================== */ + +void +gnc_table_move_cursor (Table *table, int new_phys_row, int new_phys_col) +{ + if (!table) return; + + gnc_table_move_cursor_internal (table, new_phys_row, new_phys_col, FALSE); +} + +/* same as above, but be sure to deal with GUI elements as well */ +void +gnc_table_move_cursor_gui (Table *table, int new_phys_row, int new_phys_col) +{ + if (!table) return; + + gnc_table_move_cursor_internal (table, new_phys_row, new_phys_col, TRUE); +} + +/* ==================================================== */ + +void +gnc_table_commit_cursor (Table *table) +{ + CellBlock *curs; + VirtualCell *vcell; + PhysicalCell *pcell; + int cell_row, cell_col; + int virt_row, virt_col; + int phys_row, phys_col; + int phys_row_origin, phys_col_origin; + + if (!table) return; + + curs = table->current_cursor; + if (!curs) return; + + virt_row = table->current_cursor_virt_row; + virt_col = table->current_cursor_virt_col; + + /* can't commit if cursor is bad */ + if ((0 > virt_row) || (0 > virt_col)) return; + if (virt_row >= table->num_virt_rows) return; + if (virt_col >= table->num_virt_cols) return; + + /* compute the true origin of the cell block */ + phys_row = table->current_cursor_phys_row; + phys_col = table->current_cursor_phys_col; + + pcell = gnc_table_get_physical_cell (table, phys_row, phys_col); + if (pcell == NULL) return; + + phys_row_origin = table->current_cursor_phys_row; + phys_col_origin = table->current_cursor_phys_col; + phys_row_origin -= pcell->virt_loc.phys_row_offset; + phys_col_origin -= pcell->virt_loc.phys_col_offset; + + for (cell_row = 0; cell_row < curs->numRows; cell_row++) + for (cell_col = 0; cell_col < curs->numCols; cell_col++) + { + BasicCell *cell; + + cell = curs->cells[cell_row][cell_col]; + if (cell) + { + pcell = gnc_table_get_physical_cell (table, + phys_row_origin + cell_row, + phys_col_origin + cell_col); + + if (pcell->entry) + free (pcell->entry); + pcell->entry = strdup (cell->value); + if (cell->use_bg_color) + pcell->bg_color = cell->bg_color; + if (cell->use_fg_color) + pcell->fg_color = cell->fg_color; + } + } + + vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col); + vcell->user_data = curs->user_data; +} + +/* ==================================================== */ + +void +gnc_table_refresh_header (Table *table) +{ + int cell_row, cell_col; + VirtualCell *vcell; + CellBlock *cb; + + if (!table) return; + + vcell = gnc_table_get_header_cell (table); + if (vcell == NULL) return; + + cb = vcell->cellblock; + if (cb == NULL) return; + + for (cell_row = 0; cell_row < cb->numRows; cell_row++) + for (cell_col = 0; cell_col < cb->numCols; cell_col++) + { + PhysicalCell *pcell; + BasicCell *cell; + + /* Assumes header starts at physical (0, 0) */ + pcell = gnc_table_get_physical_cell (table, cell_row, cell_col); + + if (pcell->entry) + free(pcell->entry); + + cell = cb->cells[cell_row][cell_col]; + + if (cell && cell->value) + pcell->entry = strdup (cell->value); + else + pcell->entry = strdup (""); + } +} + +/* ==================================================== */ + +/* gnc_table_verify_cursor_position checks the location of the cursor + * with respect to a row/column position, and repositions the cursor + * if necessary. This includes saving any uncommited data in the old + * cursor, and then moving the cursor and its GUI. Returns true if the + * cursor was repositioned. */ +gboolean +gnc_table_verify_cursor_position (Table *table, int phys_row, int phys_col) +{ + gboolean do_commit = FALSE; + gboolean moved_cursor = FALSE; + + if (!table) return FALSE; + + /* Someone may be trying to intentionally invalidate the cursor, in + * which case the physical addresses could be out of bounds. For + * example, in order to unmap it in preparation for a reconfig. + * So, if the specified location is out of bounds, then the cursor + * MUST be moved. */ + + if ((0 > phys_row) || (0 > phys_col)) do_commit = TRUE; + if (phys_row >= table->num_phys_rows) do_commit = TRUE; + if (phys_col >= table->num_phys_cols) do_commit = TRUE; + + /* Physical position is valid. Check the virtual position. */ + if (!do_commit) + { + PhysicalCell *pcell; + int virt_row, 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) || + (virt_col != table->current_cursor_virt_col)) + do_commit = TRUE; + } + + if (do_commit) + { + /* before leaving the current virtual position, commit any edits + * that have been accumulated in the cursor */ + gnc_table_commit_cursor (table); + gnc_table_move_cursor_gui (table, phys_row, phys_col); + moved_cursor = TRUE; + } + else + { + /* The request might be to move to a cell that is one column over. + * If so, then do_commit will be zero, as there will have been no + * reason to actually move a cursor. However, we want to keep + * positions accurate, so record the new location. (The move may + * may also be one row up or down, which, for a two-row cursor, + * also might not require a cursor movement). */ + if (table->current_cursor_phys_row != phys_row) + { + table->current_cursor_phys_row = phys_row; + moved_cursor = TRUE; + } + + if (table->current_cursor_phys_col != phys_col) + { + table->current_cursor_phys_col = phys_col; + moved_cursor = TRUE; + } + } + + return moved_cursor; +} + +/* ==================================================== */ + +void * +gnc_table_get_user_data_physical (Table *table, int phys_row, int phys_col) +{ + PhysicalCell *pcell; + VirtualCell *vcell; + int virt_row, virt_col; + + if (!table) return NULL; + + pcell = gnc_table_get_physical_cell (table, phys_row, phys_col); + if (pcell == NULL) + return NULL; + + virt_row = pcell->virt_loc.virt_row; + virt_col = pcell->virt_loc.virt_col; + + vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col); + if (vcell == NULL) + return NULL; + + return vcell->user_data; +} + +/* ==================================================== */ + +void * +gnc_table_get_user_data_virtual (Table *table, int virt_row, int virt_col) +{ + VirtualCell *vcell; + + if (!table) return NULL; + + vcell = gnc_table_get_virtual_cell (table, virt_row, virt_col); + if (vcell == NULL) + return NULL; + + return vcell->user_data; +} + +/* ==================================================== */ + +/* if any of the cells have GUI specific components that need + * initialization, initialize them now. The realize() callback + * on the cursor cell is how we inform the cell handler that + * now is the time to initialize its GUI. */ +void +gnc_table_create_cursor (Table * table, CellBlock *curs) +{ + int cell_row, cell_col; + + if (!curs || !table) return; + if (!table->ui_data) return; + + for (cell_row = 0; cell_row < curs->numRows; cell_row++) + for (cell_col = 0; cell_col < curs->numCols; cell_col++) + { + BasicCell *cell; + cell = curs->cells[cell_row][cell_col]; + if (cell && cell->realize) + cell->realize (cell, table->ui_data); + } +} + +/* ==================================================== */ + +void +gnc_table_wrap_verify_cursor_position (Table *table, + int phys_row, int phys_col) { CellBlock *save_curs = table->current_cursor; const int save_phys_row = table->current_cursor_phys_row; const int save_phys_col = table->current_cursor_phys_col; - gncBoolean moved_cursor; + gboolean moved_cursor; if (!table) return; - ENTER("(%d %d) val=%s\n", - row,col, table->entries[row][col]); + ENTER("(%d %d)", phys_row, phys_col); /* VerifyCursor will do all sorts of gui-independent machinations */ - moved_cursor = xaccVerifyCursorPosition (table, row, col); + moved_cursor = gnc_table_verify_cursor_position (table, phys_row, phys_col); if (moved_cursor) { /* make sure *both* the old and the new cursor rows get redrawn */ - xaccRefreshCursorGUI (table, GNC_T); - doRefreshCursorGUI (table, save_curs, - save_phys_row, save_phys_col, GNC_F); + gnc_table_refresh_current_cursor_gui (table, TRUE); + gnc_table_refresh_cursor_gui (table, save_curs, + save_phys_row, save_phys_col, FALSE); } LEAVE ("\n"); @@ -851,129 +1032,145 @@ wrapVerifyCursorPosition (Table *table, int row, int col) /* ==================================================== */ void -xaccRefreshCursorGUI (Table * table, gncBoolean do_scroll) +gnc_table_refresh_current_cursor_gui (Table * table, gboolean do_scroll) { if (!table) return; - doRefreshCursorGUI (table, table->current_cursor, - table->current_cursor_phys_row, - table->current_cursor_phys_col, - do_scroll); + gnc_table_refresh_cursor_gui (table, table->current_cursor, + table->current_cursor_phys_row, + table->current_cursor_phys_col, + do_scroll); } /* ==================================================== */ -gncBoolean -gnc_register_cell_valid(Table *table, int row, int col, gncBoolean exact_cell) +gboolean +gnc_table_physical_cell_valid(Table *table, + int phys_row, int phys_col, + gboolean exact_cell) { - int invalid = 0; - int io_flag; - int rel_row, rel_col; + CellBlock *cb; + VirtualCell *vcell; + PhysicalCell *pcell; + gboolean invalid = FALSE; + int cell_row, cell_col; int virt_row, virt_col; - CellBlock *arr, *header; + int io_flag; - if (!table) return GNC_F; + if (!table) return FALSE; + + pcell = gnc_table_get_physical_cell(table, phys_row, phys_col); /* can't edit outside of the physical space */ - invalid = (0 > row) || (0 > col) ; - invalid = invalid || (row >= table->num_phys_rows); - invalid = invalid || (col >= table->num_phys_cols); - - /* In case we're called after table has been destroyed. */ - invalid = invalid || (table->handlers == NULL); - - if (invalid) return GNC_F; + if (pcell == NULL) + return FALSE; /* header rows cannot be modified */ - /* hack alert -- assumes that header is first cell */ - /* if 0,0 is not a header row, then trouble ... */ - header = table->handlers[0][0]; - invalid = invalid || (row < header->numRows); + vcell = gnc_table_get_header_cell (table); + if (vcell == NULL) + return FALSE; + + invalid = invalid || (phys_row < vcell->cellblock->numRows); /* compute the cell location */ - virt_row = table->locators[row][col]->virt_row; - virt_col = table->locators[row][col]->virt_col; + virt_row = pcell->virt_loc.virt_row; + virt_col = pcell->virt_loc.virt_col; - rel_row = table->locators[row][col]->phys_row_offset; - rel_col = table->locators[row][col]->phys_col_offset; + cell_row = pcell->virt_loc.phys_row_offset; + cell_col = pcell->virt_loc.phys_col_offset; /* verify that offsets are valid. This may occur if the app that is * using the table has a paritally initialized cursor. (probably due * to a programming error, but maybe they meant to do this). */ invalid = invalid || (0 > virt_row); invalid = invalid || (0 > virt_col); - invalid = invalid || (0 > rel_row); - invalid = invalid || (0 > rel_col); + invalid = invalid || (0 > cell_row); + invalid = invalid || (0 > cell_col); - if (invalid) return GNC_F; + if (invalid) return FALSE; - arr = table->handlers[virt_row][virt_col]; + cb = vcell->cellblock; /* check for a cell handler, but only if cell address is valid */ - if (arr == NULL) return GNC_F; - if (arr->cells[rel_row][rel_col] == NULL) return GNC_F; + if (cb == NULL) return FALSE; + if (cb->cells[cell_row][cell_col] == NULL) return FALSE; /* if cell is marked as output-only, you can't enter */ - io_flag = arr->cells[rel_row][rel_col]->input_output; - if (0 == (XACC_CELL_ALLOW_INPUT & io_flag)) return GNC_F; + io_flag = cb->cells[cell_row][cell_col]->input_output; + if (0 == (XACC_CELL_ALLOW_INPUT & io_flag)) return FALSE; /* if cell is pointer only and this is not an exact pointer test, * it cannot be entered. */ if (!exact_cell && ((XACC_CELL_ALLOW_EXACT_ONLY & io_flag) != 0)) - return GNC_F; + return FALSE; - if (invalid) return GNC_F; - return GNC_T; + if (invalid) return FALSE; + + return TRUE; } -/* ======================================================================== - Handle the non gui-specific parts of a cell enter callback -*/ +/* ==================================================== */ +/* Handle the non gui-specific parts of a cell enter callback */ const char * -gnc_table_enter_update(Table *table, int row, int col, int *cursor_position, - int *start_selection, int *end_selection) +gnc_table_enter_update(Table *table, + int phys_row, int phys_col, + int *cursor_position, + int *start_selection, + int *end_selection) { - /* If text should be changed, then new_text will be set to non-null - on return */ + const char *retval = NULL; + PhysicalCell *pcell; + CellEnterFunc enter; + CellBlock *cb; + int cell_row; + int cell_col; - CellBlock *arr = table->current_cursor; - const int rel_row = table->locators[row][col]->phys_row_offset; - const int rel_col = table->locators[row][col]->phys_col_offset; - char *retval = NULL; + if (table == NULL) + return NULL; - const char * (*enter) (BasicCell *, const char *, int *, int *, int *); + cb = table->current_cursor; + + pcell = gnc_table_get_physical_cell (table, phys_row, phys_col); + if (pcell == NULL) + return NULL; + + cell_row = pcell->virt_loc.phys_row_offset; + cell_col = pcell->virt_loc.phys_col_offset; ENTER("enter %d %d (relrow=%d relcol=%d) cell=%p val=%s\n", - row, col, rel_row, rel_col, - arr->cells[rel_row][rel_col], table->entries[row][col]); + phys_row, phys_col, cell_row, cell_col, + cb->cells[cell_row][cell_col], pcell->entry); /* OK, if there is a callback for this cell, call it */ - enter = arr->cells[rel_row][rel_col]->enter_cell; + enter = cb->cells[cell_row][cell_col]->enter_cell; - if (enter) { + if (enter) + { const char *val; DEBUG("gnc_table_enter_update(): %d %d has enter handler\n", - rel_row, rel_col); + cell_row, cell_col); - val = table->entries[row][col]; - retval = (char *) enter(arr->cells[rel_row][rel_col], val, - cursor_position, start_selection, end_selection); + val = pcell->entry; + retval = enter(cb->cells[cell_row][cell_col], val, + cursor_position, start_selection, end_selection); - /* enter() might return null, or it might return a pointer to - * val, or it might return a new pointer (to newly malloc memory). - * Replace the old pointer with a new one only if the new one is - * different, freeing the old one. (Doing a strcmp would leak memory). - */ - if (retval && (val != retval)) { + /* enter() might return null, or it might return a pointer to val, + * or it might return a new pointer (to newly malloc memory). + * Replace the old pointer with a new one only if the new one is + * different, freeing the old one. (Doing a strcmp would leak + * memory). */ + if (retval && (val != retval)) + { if (safe_strcmp(retval, val) != 0) - (arr->cells[rel_row][rel_col])->changed = 0xffffffff; - if (table->entries[row][col]) free (table->entries[row][col]); - table->entries[row][col] = retval; - } else { - retval = NULL; + (cb->cells[cell_row][cell_col])->changed = GNC_CELL_CHANGED; + if (pcell->entry) + free (pcell->entry); + pcell->entry = (char *) retval; } + else + retval = NULL; } if (table->set_help) @@ -981,10 +1178,10 @@ gnc_table_enter_update(Table *table, int row, int col, int *cursor_position, BasicCell *cell; char *help_str; - cell = arr->cells[rel_row][rel_col]; + cell = cb->cells[cell_row][cell_col]; help_str = xaccBasicCellGetHelp(cell); - table->set_help(table, help_str, table->client_data); + table->set_help(table, help_str); if (help_str != NULL) free(help_str); @@ -992,69 +1189,90 @@ gnc_table_enter_update(Table *table, int row, int col, int *cursor_position, /* record this position as the cell that will be * traversed out of if a traverse even happens */ - table->prev_phys_traverse_row = row; - table->prev_phys_traverse_col = col; + table->prev_phys_traverse_row = phys_row; + table->prev_phys_traverse_col = phys_col; LEAVE("return %s\n", retval); + return retval; } /* ==================================================== */ const char * -gnc_table_leave_update(Table *table, int row, int col, - const char* callback_text) +gnc_table_leave_update(Table *table, + int phys_row, int phys_col, + const char *callback_text) { - CellBlock *arr = table->current_cursor; - const int rel_row = table->locators[row][col]->phys_row_offset; - const int rel_col = table->locators[row][col]->phys_col_offset; - const char * (*leave) (BasicCell *, const char *); const char *retval = NULL; - - ENTER("proposed (%d %d) rel(%d %d) \"%s\"\n", - row, col, rel_row, rel_col, callback_text); + PhysicalCell *pcell; + CellLeaveFunc leave; + CellBlock *cb; + int cell_row; + int cell_col; - if (!callback_text) callback_text = ""; + if (table == NULL) + return NULL; + + cb = table->current_cursor; + + pcell = gnc_table_get_physical_cell (table, phys_row, phys_col); + if (pcell == NULL) + return NULL; + + cell_row = pcell->virt_loc.phys_row_offset; + cell_col = pcell->virt_loc.phys_col_offset; + + ENTER("proposed (%d %d) rel(%d %d) \"%s\"\n", + phys_row, phys_col, cell_row, cell_col, callback_text); + + if (!callback_text) + callback_text = ""; /* OK, if there is a callback for this cell, call it */ - leave = arr->cells[rel_row][rel_col]->leave_cell; - if (leave) { - retval = leave(arr->cells[rel_row][rel_col], callback_text); - + leave = cb->cells[cell_row][cell_col]->leave_cell; + if (leave) + { + retval = leave(cb->cells[cell_row][cell_col], callback_text); + /* leave() might return null, or it might return a pointer to - * callback_text, or it might return a new pointer (to newly - * malloced memory). - */ - if (retval == callback_text) { - retval = NULL; - } + * callback_text, or it might return a new pointer (to newly + * malloced memory). */ + if (retval == callback_text) + retval = NULL; } - if (!retval) retval = strdup (callback_text); - + if (!retval) + retval = strdup (callback_text); + /* save whatever was returned; but lets check for - * changes to avoid roiling the cells too much */ - if (table->entries[row][col]) { - if (strcmp (table->entries[row][col], retval)) { - free (table->entries[row][col]); - table->entries[row][col] = (char *) retval; - (arr->cells[rel_row][rel_col])->changed = 0xffffffff; - } else { - /* leave() allocated memory, which we will not be using ... */ + * changes to avoid roiling the cells too much. */ + if (pcell->entry) + { + if (safe_strcmp (pcell->entry, retval)) + { + free (pcell->entry); + pcell->entry = (char *) retval; + (cb->cells[cell_row][cell_col])->changed = GNC_CELL_CHANGED; + } + else + { + /* leave() allocated memory, which we will not be using */ free ((char *) retval); retval = NULL; } - } else { - table->entries[row][col] = (char *) retval; - (arr->cells[rel_row][rel_col])->changed = 0xffffffff; } - + else + { + pcell->entry = (char *) retval; + (cb->cells[cell_row][cell_col])->changed = GNC_CELL_CHANGED; + } + /* return the result of the final decisionmaking */ - if (strcmp (table->entries[row][col], callback_text)) { - retval = table->entries[row][col]; - } else { - retval = NULL; - } + if (safe_strcmp (pcell->entry, callback_text)) + retval = pcell->entry; + else + retval = NULL; LEAVE("return %s\n", retval); @@ -1063,9 +1281,11 @@ gnc_table_leave_update(Table *table, int row, int col, /* ==================================================== */ +/* returned result should not be touched by the caller. + * NULL return value means the edit was rejected. */ const char * gnc_table_modify_update(Table *table, - int row, int col, + int phys_row, int phys_col, const char *oldval, const char *change, char *newval, @@ -1073,43 +1293,53 @@ gnc_table_modify_update(Table *table, int *start_selection, int *end_selection) { - /* returned result should not be touched by the caller */ - /* NULL return value means the edit was rejected */ - - CellBlock *arr = table->current_cursor; - - /* compute the cell location */ - const int rel_row = table->locators[row][col]->phys_row_offset; - const int rel_col = table->locators[row][col]->phys_col_offset; - - const char * (*mv) (BasicCell *, - const char *, const char *, const char *, - int *, int *, int *); - const char *retval = NULL; + CellModifyVerifyFunc mv; + PhysicalCell *pcell; + CellBlock *cb; + int cell_row; + int cell_col; + + if (table == NULL) + return NULL; + + cb = table->current_cursor; + + pcell = gnc_table_get_physical_cell (table, phys_row, phys_col); + if (pcell == NULL) + return NULL; + + cell_row = pcell->virt_loc.phys_row_offset; + cell_col = pcell->virt_loc.phys_col_offset; ENTER ("\n"); /* OK, if there is a callback for this cell, call it */ - mv = arr->cells[rel_row][rel_col]->modify_verify; - if (mv) { - retval = (*mv) (arr->cells[rel_row][rel_col], - oldval, change, newval, - cursor_position, start_selection, end_selection); + mv = cb->cells[cell_row][cell_col]->modify_verify; + if (mv) + { + retval = mv (cb->cells[cell_row][cell_col], + oldval, change, newval, cursor_position, + start_selection, end_selection); /* if the callback returned a non-null value, allow the edit */ - if (retval) { + if (retval) + { /* update data. bounds check done earlier */ - if (table->entries[row][col]) free (table->entries[row][col]); - table->entries[row][col] = (char *) retval; - (arr->cells[rel_row][rel_col])->changed = 0xffffffff; + if (pcell->entry) + free (pcell->entry); + pcell->entry = (char *) retval; + (cb->cells[cell_row][cell_col])->changed = GNC_CELL_CHANGED; } - } else { + } + else + { /* update data. bounds check done earlier */ - if (table->entries[row][col]) free (table->entries[row][col]); - table->entries[row][col] = newval; + if (pcell->entry) + free (pcell->entry); + pcell->entry = newval; retval = newval; - (arr->cells[rel_row][rel_col])->changed = 0xffffffff; + (cb->cells[cell_row][cell_col])->changed = GNC_CELL_CHANGED; } if (table->set_help) @@ -1117,27 +1347,27 @@ gnc_table_modify_update(Table *table, BasicCell *cell; char *help_str; - cell = arr->cells[rel_row][rel_col]; + cell = cb->cells[cell_row][cell_col]; help_str = xaccBasicCellGetHelp(cell); - table->set_help(table, help_str, table->client_data); + table->set_help(table, help_str); if (help_str != NULL) free(help_str); } LEAVE ("change %d %d (relrow=%d relcol=%d) cell=%p val=%s\n", - row, col, rel_row, rel_col, - arr->cells[rel_row][rel_col], table->entries[row][col]); - - return(retval); + phys_row, phys_col, cell_row, cell_col, + cb->cells[cell_row][cell_col], pcell->entry); + + return retval; } /* ==================================================== */ -gncBoolean +gboolean gnc_table_direct_update(Table *table, - int row, int col, + int phys_row, int phys_col, const char *oldval, char **newval_ptr, int *cursor_position, @@ -1145,25 +1375,40 @@ gnc_table_direct_update(Table *table, int *end_selection, void *gui_data) { - CellBlock *arr = table->current_cursor; + PhysicalCell *pcell; + gboolean result; + BasicCell *cell; + CellBlock *cb; + int cell_row; + int cell_col; - const int rel_row = table->locators[row][col]->phys_row_offset; - const int rel_col = table->locators[row][col]->phys_col_offset; + if (table == NULL) + return FALSE; - BasicCell *cell = arr->cells[rel_row][rel_col]; + cb = table->current_cursor; - gncBoolean result; + pcell = gnc_table_get_physical_cell (table, phys_row, phys_col); + if (pcell == NULL) + return FALSE; + + cell_row = pcell->virt_loc.phys_row_offset; + cell_col = pcell->virt_loc.phys_col_offset; + + cell = cb->cells[cell_row][cell_col]; + + ENTER ("\n"); if (cell->direct_update == NULL) - return GNC_F; + return FALSE; result = cell->direct_update(cell, oldval, newval_ptr, cursor_position, start_selection, end_selection, gui_data); if ((*newval_ptr != oldval) && (*newval_ptr != NULL)) { - if (table->entries[row][col]) free (table->entries[row][col]); - table->entries[row][col] = *newval_ptr; - cell->changed = 0xffffffff; + if (pcell->entry) + free (pcell->entry); + pcell->entry = *newval_ptr; + cell->changed = GNC_CELL_CHANGED; } if (table->set_help) @@ -1172,7 +1417,7 @@ gnc_table_direct_update(Table *table, help_str = xaccBasicCellGetHelp(cell); - table->set_help(table, help_str, table->client_data); + table->set_help(table, help_str); if (help_str != NULL) free(help_str); @@ -1183,95 +1428,118 @@ gnc_table_direct_update(Table *table, /* ==================================================== */ -gncBoolean -gnc_table_find_valid_cell_horiz(Table *table, int *row, int *col, - gncBoolean exact_cell) +gboolean +gnc_table_find_valid_cell_horiz(Table *table, + int *phys_row, int *phys_col, + gboolean exact_cell) { - int left = *col - 1; - int right = *col + 1; + int left = *phys_col - 1; + int right = *phys_col + 1; - if ((*row < 0) || (*col < 0) || - (*row >= table->num_phys_rows) || - (*col >= table->num_phys_cols)) - return GNC_F; + if ((*phys_row < 0) || (*phys_col < 0) || + (*phys_row >= table->num_phys_rows) || + (*phys_col >= table->num_phys_cols)) + return FALSE; - if (gnc_register_cell_valid(table, *row, *col, exact_cell)) - return GNC_T; + if (gnc_table_physical_cell_valid(table, *phys_row, *phys_col, exact_cell)) + return TRUE; while (left >= 0 || right < table->num_phys_cols) { - if (gnc_register_cell_valid(table, *row, right, GNC_F)) + if (gnc_table_physical_cell_valid(table, *phys_row, right, FALSE)) { - *col = right; - return GNC_T; + *phys_col = right; + return TRUE; } - if (gnc_register_cell_valid(table, *row, left, GNC_F)) + if (gnc_table_physical_cell_valid(table, *phys_row, left, FALSE)) { - *col = left; - return GNC_T; + *phys_col = left; + return TRUE; } left--; right++; } - return GNC_F; + return FALSE; } /* ==================================================== */ -gncBoolean -gnc_table_traverse_update(Table *table, int row, int col, +gboolean +gnc_table_traverse_update(Table *table, + int phys_row, int phys_col, gncTableTraversalDir dir, int *dest_row, int *dest_col) { - CellBlock *arr = table->current_cursor; + CellBlock *cb; + + if (table == NULL) + return FALSE; + + cb = table->current_cursor; ENTER("proposed (%d %d) -> (%d %d)\n", - row, col, *dest_row, *dest_col); + phys_row, phys_col, *dest_row, *dest_col); /* first, make sure our destination cell is valid. If it is out of - * bounds report an error. I don't think this ever happens. */ + * bounds report an error. I don't think this ever happens. */ if ((*dest_row >= table->num_phys_rows) || (*dest_row < 0) || (*dest_col >= table->num_phys_cols) || (*dest_col < 0)) { PERR("destination (%d, %d) out of bounds (%d, %d)\n", *dest_row, *dest_col, table->num_phys_rows, table->num_phys_cols); - return GNC_T; + return TRUE; } /* next, check the current row and column. If they are out of bounds * we can recover by treating the traversal as a mouse point. This can * occur whenever the register widget is resized smaller, maybe?. */ - if ((row >= table->num_phys_rows) || (row < 0) || - (col >= table->num_phys_cols) || (col < 0)) { + if ((phys_row >= table->num_phys_rows) || (phys_row < 0) || + (phys_col >= table->num_phys_cols) || (phys_col < 0)) + { PINFO("source (%d, %d) out of bounds (%d, %d)\n", - row, col, table->num_phys_rows, table->num_phys_cols); + phys_row, phys_col, table->num_phys_rows, table->num_phys_cols); table->prev_phys_traverse_row = *dest_row; table->prev_phys_traverse_col = *dest_col; dir = GNC_TABLE_TRAVERSE_POINTER; } /* process forward-moving traversals */ - switch(dir) { + switch(dir) + { case GNC_TABLE_TRAVERSE_RIGHT: case GNC_TABLE_TRAVERSE_LEFT: { - /* cannot compute the cell location until we have checked that - * row and column have valid values. compute the cell location. - */ - const int rel_row = table->locators[row][col]->phys_row_offset; - const int rel_col = table->locators[row][col]->phys_col_offset; + PhysicalCell *pcell; + int cell_row, cell_col; - if (dir == GNC_TABLE_TRAVERSE_RIGHT) { - *dest_row = row - rel_row + arr->right_traverse_r[rel_row][rel_col]; - *dest_col = col - rel_col + arr->right_traverse_c[rel_row][rel_col]; - } else { - *dest_row = row - rel_row + arr->left_traverse_r[rel_row][rel_col]; - *dest_col = col - rel_col + arr->left_traverse_c[rel_row][rel_col]; + /* cannot compute the cell location until we have checked that + * row and column have valid values. compute the cell + * location. */ + pcell = gnc_table_get_physical_cell (table, phys_row, phys_col); + if (pcell == NULL) + return FALSE; + + cell_row = pcell->virt_loc.phys_row_offset; + cell_col = pcell->virt_loc.phys_col_offset; + + if (dir == GNC_TABLE_TRAVERSE_RIGHT) + { + *dest_row = (phys_row - cell_row + + cb->right_traverse_r[cell_row][cell_col]); + *dest_col = (phys_col - cell_col + + cb->right_traverse_c[cell_row][cell_col]); + } + else + { + *dest_row = (phys_row - cell_row + + cb->left_traverse_r[cell_row][cell_col]); + *dest_col = (phys_col - cell_col + + cb->left_traverse_c[cell_row][cell_col]); } } @@ -1280,7 +1548,8 @@ gnc_table_traverse_update(Table *table, int row, int col, case GNC_TABLE_TRAVERSE_UP: case GNC_TABLE_TRAVERSE_DOWN: { - CellBlock *header = table->handlers[0][0]; + VirtualCell *vcell = gnc_table_get_header_cell (table); + CellBlock *header = vcell->cellblock; int new_row = *dest_row; int increment; @@ -1288,16 +1557,16 @@ gnc_table_traverse_update(Table *table, int row, int col, * row to land on, or we hit the end of the table. At the end, * turn around and go back until we find a valid row or we get * to where we started. If we still can't find anything, try - * going left and right. - */ + * going left and right. */ increment = (dir == GNC_TABLE_TRAVERSE_DOWN) ? 1 : -1; - while (!gnc_register_cell_valid(table, new_row, *dest_col, GNC_F)) + while (!gnc_table_physical_cell_valid(table, + new_row, *dest_col, FALSE)) { - if (new_row == row) + if (new_row == phys_row) { new_row = *dest_row; - gnc_table_find_valid_cell_horiz(table, &new_row, dest_col, GNC_F); + gnc_table_find_valid_cell_horiz(table, &new_row, dest_col, FALSE); break; } @@ -1313,14 +1582,14 @@ gnc_table_traverse_update(Table *table, int row, int col, *dest_row = new_row; } - if (!gnc_register_cell_valid(table, *dest_row, *dest_col, GNC_F)) - return GNC_T; + if (!gnc_table_physical_cell_valid(table, *dest_row, *dest_col, FALSE)) + return TRUE; break; case GNC_TABLE_TRAVERSE_POINTER: - if (!gnc_table_find_valid_cell_horiz(table, dest_row, dest_col, GNC_T)) - return GNC_T; + if (!gnc_table_find_valid_cell_horiz(table, dest_row, dest_col, TRUE)) + return TRUE; break; @@ -1332,7 +1601,7 @@ gnc_table_traverse_update(Table *table, int row, int col, /* Call the table traverse callback for any modifications. */ if (table->traverse) - (table->traverse) (table, dest_row, dest_col, dir, table->client_data); + (table->traverse) (table, dest_row, dest_col, dir); table->prev_phys_traverse_row = *dest_row; table->prev_phys_traverse_col = *dest_col; @@ -1340,7 +1609,7 @@ gnc_table_traverse_update(Table *table, int row, int col, LEAVE("dest_row = %d, dest_col = %d\n", *dest_row, *dest_col); - return GNC_F; + return FALSE; } /* ================== end of file ======================= */ diff --git a/src/register/table-allgui.h b/src/register/table-allgui.h index 702d59dbb0..f5f705ab72 100644 --- a/src/register/table-allgui.h +++ b/src/register/table-allgui.h @@ -94,30 +94,20 @@ * * HISTORY: * Copyright (c) 1998,1999,2000 Linas Vepstas + * Copyright (c) 2000 Dave Peticolas */ -#ifndef __XACC_TABLE_ALLGUI_H__ -#define __XACC_TABLE_ALLGUI_H__ +#ifndef __TABLE_ALLGUI_H__ +#define __TABLE_ALLGUI_H__ #include -#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 "basiccell.h" #include "cellblock.h" + typedef enum { GNC_TABLE_TRAVERSE_POINTER, GNC_TABLE_TRAVERSE_LEFT, @@ -126,9 +116,9 @@ typedef enum { GNC_TABLE_TRAVERSE_DOWN } gncTableTraversalDir; -/* The Locator structure is used provide a mapping from - * the physical array of cells to the logical array of - * virtual cell blocks. + +/* The VirtualLocation structure contains the virtual + * location of a physical cell. * * There is one instance of Locator for each physical cell. * 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 * the cell block. */ -struct _Locator { +typedef struct _VirtualLocation VirtualLocation; +struct _VirtualLocation { short phys_row_offset; short phys_col_offset; short virt_row; 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. * - * There is one instance of a RevLocator for each virtual cell. + * There is one instance of a PhysicalLocation for each virtual cell. */ - -struct _RevLocator { +typedef struct _PhysicalLocation PhysicalLocation; +struct _PhysicalLocation { short phys_row; 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, - const char *help_str, - void *client_data); + const char *help_str); + +typedef void (*TableDestroyFunc) (Table *table); /* 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 * 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. * * Given the location of the virtual row and column, the - * corresponding GUI handler, and any associated user data can - * be directly accessed. + * corresponding GUI handler, and any associated user data + * can be directly accessed. */ - -struct _Table { - +struct _Table +{ int num_phys_rows; int num_phys_cols; int num_virt_rows; @@ -193,39 +218,26 @@ struct _Table { * The fields termed "phys_row" and "phys_col" would * be better termed phys row and column "origins", as the * cursor extends down and to the right from the location - * given by the phys values. - */ + * given by the physical values. */ CellBlock *current_cursor; + int current_cursor_phys_row; int current_cursor_phys_col; int current_cursor_virt_row; int current_cursor_virt_col; /* callback that is called when the cursor is moved */ - /* hack alert -- this should be a callback list, actually */ - void (*move_cursor) (Table *, int *p_new_phys_row, - int *p_new_phys_col, - void *client_data); + TableMoveFunc move_cursor; /* callback that is called to determine traversal */ - void (*traverse) (Table *, int *p_new_phys_row, - int *p_new_phys_col, - gncTableTraversalDir dir, - void *client_data); + TableTraverseFunc traverse; + /* callback to set a help string associated with a cell */ TableSetHelpFunc set_help; - void * client_data; - - /* string values for each cell, - * 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; + /* This value is initialized to NULL and never touched afterwards. + * It can be used by higher-level code. */ + void * user_data; /* Determines whether the passive background * colors alternate between odd and even virt @@ -233,314 +245,190 @@ struct _Table { * physical rows within cellblocks. */ gncBoolean alternate_bg_colors; - /* handler locators for each cell, - * of dimension num_phys_rows * num_phys_cols */ - Locator ***locators; - /* reverse locators for each cell, - of dimension num_virt_rows * num_virt_cols */ - RevLocator ***rev_locators; + /* private data */ - /* user hooks, of dimension num_virt_rows * num_virt_cols */ - void ***user_data; + /* This is black-box stuff that higher-level code should not access */ - /* cell blocks, of dimension num_virt_rows * num_virt_cols */ - CellBlock ***handlers; + /* The virtual and physical cell information */ + GPtrArray *virt_cells; + GPtrArray *phys_cells; - /* private data, caches, etc. */ - /* This is black-box stuff that no user of this class - * should ever want to access */ - - /* 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. - */ + /* 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_col; - /* Since we are using C not C++, but we need inheritance, - * cock it up with a #defined thingy that the "derived class" - * can specify. - */ - TABLE_PRIVATE_DATA + void * ui_data; + TableDestroyFunc destroy; }; -Table * xaccMallocTable (void); -void xaccInitTable (Table *); -void xaccDestroyTable (Table *); +/* Functions to create and destroy Tables. */ +Table * gnc_table_new (void); +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 - * indicated dimensions. - */ -void xaccSetTableSize (Table * table, int phys_rows, int phys_cols, - int virt_rows, int virt_cols); +PhysicalCell * gnc_table_get_physical_cell (Table *table, + int phys_row, int phys_col); -/* The xaccCreateCursor() method can be called whenever a reconfig - * of the cursor may require new gui elements to be initialized. - */ -void xaccCreateCursor (Table *, CellBlock *); +/* 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); + +/* The gnc_table_create_cursor() method can be called whenever a + * reconfig of the cursor may require new gui elements to be + * initialized. */ +void gnc_table_create_cursor (Table *, CellBlock *); /* indicate what handler should be used for a given virtual block */ -void -xaccSetCursor (Table *table, CellBlock *curs, - int phys_row_origin, int phys_col_origin, - int virt_row, int virt_col); +void gnc_table_set_cursor (Table *table, CellBlock *curs, + int phys_row_origin, int phys_col_origin, + 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 - * 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 xaccMoveCursor (Table *, int phys_row, int phys_col); +/* The gnc_table_move_cursor_gui() method will move the cursor and its + * GUI to the indicated location. Through a series of callbacks, all + * GUI elements get repositioned. */ +void gnc_table_move_cursor_gui (Table *table, + int phys_row, int phys_col); -/* The xaccMoveCursorGUI() method will move the cursor and its GUI - * to the indicated location. Through a series of callbacks, - * all GUI elements get repositioned. - */ -void xaccMoveCursorGUI (Table *, int phys_row, int phys_col); +/* The gnc_table_commit_cursor() 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 + * intermediary to format, fix up, and otherwise control the data, + * and, when ready, it is commited from the cursor into the + * table. */ +void gnc_table_commit_cursor (Table *table); -/* 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 - * intermediary to format, fix up, and otherwise control the data, - * and, when ready, it is commited from the cursor into the table. - */ -void xaccCommitCursor (Table *); +/* Refresh the table header. */ +void gnc_table_refresh_header (Table *table); -/* hack alert -- - * for all practical purposes, RefreshHeader is identical - * 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 gnc_table_get_user_data_physical() method returns the user data + * associated with a cursor located at the given physical coords, or + * NULL if the coords are out of bounds. */ +void * gnc_table_get_user_data_physical (Table *table, + int phys_row, int phys_col); -/* The xaccVerifyCursorPosition() 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 & gui to the new position. Returns true if the - * cursor was repositioned. - */ +/* The gnc_table_get_user_data_virtual() method returns the user data + * 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); -gncBoolean -xaccVerifyCursorPosition (Table *table, int phys_row, int phys_col); - -/* - * The xaccGetUserData() method is a convenience function that - * simplifies the lookup of the any user data that is hooked - * to the indicated row and column. It returns NULL if the - * row and column are out of bounds. - */ - -void * xaccGetUserData (Table *table, int phys_row, int phys_col); +/* Find the closest valid horizontal cell. If exact_cell is true, + * cells that must be explicitly selected by the user (as opposed + * to just tabbing into), are considered valid cells. */ +gboolean gnc_table_find_valid_cell_horiz(Table *table, + int *phys_row, int *phys_col, + gboolean exact_cell); /* ==================================================== */ -/* these are used internally by table-{motif,gtk}.c - perhaps these should go in a table-allguiP.h -*/ +/* UI-specific functions */ -int -gnc_table_column_width(Table *table, int col); +/* Initialize the GUI from a table */ +void gnc_table_init_gui (gncUIWidget widget, void *data); -void -wrapVerifyCursorPosition (Table *table, int row, int col); +/* Refresh the current cursor gui */ +void gnc_table_refresh_current_cursor_gui (Table * table, + gboolean do_scroll); -gncBoolean -gnc_register_cell_valid(Table *table, int row, int col, - gncBoolean exact_pointer); +/* Refresh the whole GUI from the table. */ +void gnc_table_refresh_gui (Table *table); -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 */ -/* - * gnc_table_enter_update() is a utility function used to determine - * 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 - * it returns non-null, then the returned value will be used as the - * new cell value, and an editor for the cell will not be mapped - * (viz, the user will be prevented from updating the cell). - * The function is also passed pointers to the current cursor - * position, start selection position, and end selection position. - * If the function returns NULL, then it may change any of those - * values and the mapped editing widget will be modified accordingly. +void gnc_table_wrap_verify_cursor_position (Table *table, + 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 + * map an editing widget onto this cell, and allow user input. If it + * returns non-null, then the returned value will be used as the new + * cell value, and an editor for the cell will not be mapped (viz, + * the user will be prevented from updating the cell). The function + * is also passed pointers to the current cursor position, start + * selection position, and end selection position. If the function + * returns NULL, then it may change any of those values and the + * mapped editing widget will be modified accordingly. * * 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. - * However, don't just change it, because it will break functional code. - */ -const char * -gnc_table_enter_update(Table *table, - int row, int col, - int *cursor_position, - int *start_selection, - int *end_selection); + * However, don't just change it, because it will break functional code. */ +const char * gnc_table_enter_update(Table *table, + int phys_row, int phys_col, + int *cursor_position, + int *start_selection, + int *end_selection); -const char * -gnc_table_leave_update(Table *table, - int row, int col, - const char* old_text); +const char * gnc_table_leave_update(Table *table, + int phys_row, int phys_col, + const char *old_text); -const char * -gnc_table_modify_update(Table *table, - int row, int col, - const char *oldval, - const char *change, - char *newval, - int *cursor_position, - int *start_selection, - int *end_selection); +const char * gnc_table_modify_update(Table *table, + int phys_row, int phys_col, + const char *oldval, + const char *change, + char *newval, + int *cursor_position, + int *start_selection, + int *end_selection); -gncBoolean -gnc_table_direct_update(Table *table, - int row, int col, - const char *oldval, - char **newval_ptr, - int *cursor_position, - int *start_selection, - int *end_selection, - void *gui_data); +gboolean gnc_table_direct_update(Table *table, + int phys_row, int phys_col, + const char *oldval, + char **newval_ptr, + int *cursor_position, + int *start_selection, + int *end_selection, + void *gui_data); -gncBoolean -gnc_table_traverse_update(Table *table, - int row, int col, - gncTableTraversalDir dir, - int *dest_row, - int *dest_col); +gboolean gnc_table_traverse_update(Table *table, + int phys_row, int phys_col, + gncTableTraversalDir dir, + int *dest_row, + int *dest_col); -/* Find the closest valid horizontal cell. If exact_cell is true, - * cells that must be explicitly selected by the user (as opposed - * to just tabbing into), are considered valid cells. */ -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_cols) { \ - \ - /* new table has fewer columns. */ \ - /* Simply truncate the columns */ \ - for (i=0; i * Copyright (c) 1999 Heath Martin * Copyright (c) 2000 Heath Martin + * Copyright (c) 2000 Dave Peticolas */ -/* - 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 #include @@ -48,17 +43,31 @@ #include "cellblock.h" #include "table-allgui.h" -#include "table-gnome.h" -#include "util.h" #include "splitreg.h" +#include "util.h" #include "gnucash-sheet.h" #include "gnucash-color.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 -xaccCreateTable (GtkWidget *widget, void *data) +gnc_table_init_gui (gncUIWidget widget, void *data) { SplitRegister *sr; GnucashSheet *sheet; @@ -69,15 +78,17 @@ xaccCreateTable (GtkWidget *widget, void *data) g_return_if_fail (GNUCASH_IS_REGISTER (widget)); g_return_if_fail (data != NULL); - sr = (SplitRegister *)data; + sr = (SplitRegister *) data; greg = GNUCASH_REGISTER(widget); sheet = GNUCASH_SHEET(greg->sheet); sheet->split_register = data; table = sheet->table; - table->table_widget = GTK_WIDGET(sheet); - gtk_widget_ref (table->table_widget); + table->destroy = table_destroy_cb; + table->ui_data = sheet; + + gtk_widget_ref (GTK_WIDGET(sheet)); /* config the cell-block styles */ @@ -106,7 +117,7 @@ xaccCreateTable (GtkWidget *widget, void *data) sr->split_cursor, GNUCASH_CURSOR_SPLIT); - xaccRefreshHeader (table); + gnc_table_refresh_header (table); gnucash_sheet_table_load (sheet); gnucash_sheet_cursor_set_from_table (sheet, TRUE); @@ -115,7 +126,7 @@ xaccCreateTable (GtkWidget *widget, void *data) void -xaccRefreshTableGUI (Table * table) +gnc_table_refresh_gui (Table * table) { GnucashSheet *sheet; SheetBlockStyle *style; @@ -123,13 +134,13 @@ xaccRefreshTableGUI (Table * table) if (!table) return; - if (!table->table_widget) + if (!table->ui_data) 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); - sr = (SplitRegister *)sheet->split_register; + sheet = GNUCASH_SHEET(table->ui_data); + sr = sheet->split_register; style = sheet->cursor_style[GNUCASH_CURSOR_HEADER]; gnucash_sheet_style_recompile (style, sr->header, sr, @@ -158,48 +169,42 @@ xaccRefreshTableGUI (Table * table) void -doRefreshCursorGUI (Table * table, CellBlock *curs, - int from_row, int from_col, gncBoolean do_scroll) +gnc_table_refresh_cursor_gui (Table * table, + CellBlock *curs, + int phys_row, int phys_col, + gboolean do_scroll) { GnucashSheet *sheet; + PhysicalCell *pcell; gint virt_row, virt_col; if (!table) return; - if (!table->table_widget) + if (!table->ui_data) 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 (!curs) return; - if ((0 > from_row) || (0 > from_col)) return; - if ((from_row >= table->num_phys_rows) || - (from_col >= table->num_phys_cols)) + if ((0 > phys_row) || (0 > phys_col)) return; + if ((phys_row >= table->num_phys_rows) || + (phys_col >= table->num_phys_cols)) return; - sheet = GNUCASH_SHEET(table->table_widget); + sheet = GNUCASH_SHEET(table->ui_data); /* compute the physical bounds of the current cursor */ - virt_row = table->locators[from_row][from_col]->virt_row; - virt_col = table->locators[from_row][from_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; gnucash_sheet_cursor_set_from_table (sheet, do_scroll); gnucash_sheet_block_set_from_table (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 ======================= */ diff --git a/src/register/table-gnome.h b/src/register/table-gnome.h deleted file mode 100644 index 5bda3545d8..0000000000 --- a/src/register/table-gnome.h +++ /dev/null @@ -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 - */ - - -#ifndef __XACC_TABLE_GNOME_H__ -#define __XACC_TABLE_GNOME_H__ - -#include "config.h" - -#include - -#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 ======================= */