mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Reimplement the register Table object using glib's dynamic arrays.
Clean up the code and standardize the function naming convention. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2644 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
6551923875
commit
4f7aca77fd
16
ChangeLog
16
ChangeLog
@ -1,3 +1,19 @@
|
||||
2000-08-07 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/register/table-allgui.c: reimplement the Table code using
|
||||
glib's dynamic arrays. Clean up the code and homogenize the
|
||||
function naming convention.
|
||||
|
||||
2000-08-04 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/register/table-gnome.h: remove unused data members
|
||||
|
||||
* src/register/basiccell.h: remove the pixel_width argument
|
||||
to the realize callback, it is no longer used.
|
||||
|
||||
* src/register/table-allgui.c: remove the gnc_table_column_width
|
||||
call.
|
||||
|
||||
2000-07-22 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/gnome/window-reconcile.c: After reconciliation, if the
|
||||
|
@ -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);
|
||||
|
@ -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__ */
|
||||
|
@ -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);
|
||||
|
||||
|
@ -27,7 +27,6 @@ noinst_HEADERS = \
|
||||
recncell.h \
|
||||
splitreg.h \
|
||||
table-allgui.h \
|
||||
table-gnome.h \
|
||||
textcell.h
|
||||
|
||||
EXTRA_DIST = \
|
||||
|
@ -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
|
||||
|
@ -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 ====================== */
|
||||
|
@ -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;
|
||||
|
@ -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; i<oldrows; i++) {
|
||||
if (arr->cells[i]) free (arr->cells[i]);
|
||||
if (cellblock->cells[i])
|
||||
free (cellblock->cells[i]);
|
||||
}
|
||||
free (arr->cells);
|
||||
free (cellblock->cells);
|
||||
}
|
||||
|
||||
/* free label array, if any */
|
||||
if (arr->cell_types) {
|
||||
if (cellblock->cell_types) {
|
||||
for (i=0; i<oldrows; i++) {
|
||||
if (arr->cell_types[i]) free (arr->cell_types[i]);
|
||||
if (cellblock->cell_types[i])
|
||||
free (cellblock->cell_types[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* free right traversal chain */
|
||||
if (arr->right_traverse_r) {
|
||||
if (cellblock->right_traverse_r) {
|
||||
for (i=0; i<oldrows; i++) {
|
||||
if (arr->right_traverse_r[i]) free (arr->right_traverse_r[i]);
|
||||
if (cellblock->right_traverse_r[i])
|
||||
free (cellblock->right_traverse_r[i]);
|
||||
}
|
||||
}
|
||||
if (arr->right_traverse_c) {
|
||||
if (cellblock->right_traverse_c) {
|
||||
for (i=0; i<oldrows; i++) {
|
||||
if (arr->right_traverse_c[i]) free (arr->right_traverse_c[i]);
|
||||
if (cellblock->right_traverse_c[i])
|
||||
free (cellblock->right_traverse_c[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* free left traversal chain */
|
||||
if (arr->left_traverse_r) {
|
||||
if (cellblock->left_traverse_r) {
|
||||
for (i=0; i<oldrows; i++) {
|
||||
if (arr->left_traverse_r[i]) free (arr->left_traverse_r[i]);
|
||||
if (cellblock->left_traverse_r[i])
|
||||
free (cellblock->left_traverse_r[i]);
|
||||
}
|
||||
}
|
||||
if (arr->left_traverse_c) {
|
||||
if (cellblock->left_traverse_c) {
|
||||
for (i=0; i<oldrows; i++) {
|
||||
if (arr->left_traverse_c[i]) free (arr->left_traverse_c[i]);
|
||||
if (cellblock->left_traverse_c[i])
|
||||
free (cellblock->left_traverse_c[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* free widths, alignments */
|
||||
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; i<numrows; i++) {
|
||||
(arr->cells)[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; j<numcols; j++) {
|
||||
(arr->cells)[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; i<numrows; i++) {
|
||||
(arr->right_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; j<numcols-1; j++) {
|
||||
/* default traversal is same row, next column */
|
||||
(arr->right_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; i<numrows; i++) {
|
||||
(arr->left_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; j<numcols-1; j++) {
|
||||
/* default traversal is same row, previous column */
|
||||
(arr->left_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; j<numcols; j++) {
|
||||
arr->widths[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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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__ */
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
#include <gnome.h>
|
||||
|
||||
#include "table-gnome.h"
|
||||
#include "table-allgui.h"
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
*
|
||||
* Author:
|
||||
* Heath Martin <martinh@pegasus.cc.ucf.edu>
|
||||
* Dave Peticolas <dave@krondo.com>
|
||||
*/
|
||||
|
||||
|
||||
@ -142,6 +143,7 @@ gnucash_sheet_cursor_set_from_table (GnucashSheet *sheet, gncBoolean do_scroll)
|
||||
Table *table;
|
||||
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)
|
||||
{
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <gnome.h>
|
||||
|
||||
#include "splitreg.h"
|
||||
#include "table-gnome.h"
|
||||
#include "table-allgui.h"
|
||||
|
||||
#define CELL_VPADDING 5
|
||||
|
@ -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];
|
||||
|
@ -32,12 +32,14 @@
|
||||
*
|
||||
* HISTORY:
|
||||
* Copyright (c) 1998, 1999, 2000 Linas Vepstas
|
||||
* Copyright (c) 2000 Dave Peticolas <dave@krondo.com>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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 <glib.h>
|
||||
|
||||
#ifdef MOTIF
|
||||
#include "table-motif.h"
|
||||
#endif
|
||||
|
||||
#ifdef GNOME
|
||||
#include "table-gnome.h"
|
||||
#endif
|
||||
|
||||
#ifdef KDE
|
||||
#include "table-qt.h"
|
||||
#endif
|
||||
|
||||
#include "gnc-common.h"
|
||||
|
||||
#include "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_rows; i++) { \
|
||||
for (j=new_cols; j<old_cols; j++) { \
|
||||
free_cell_op (arr[i][j]); \
|
||||
arr[i][j] = 0x0; /* plain null, not null_val */ \
|
||||
} \
|
||||
} \
|
||||
} else { \
|
||||
\
|
||||
/* if we are here, the new table has more */ \
|
||||
/* columns. Realloc the columns. */ \
|
||||
for (i=0; i<new_rows; i++) { \
|
||||
type *old_row; \
|
||||
\
|
||||
old_row = arr[i]; \
|
||||
arr[i] = (type *) malloc (new_cols * sizeof (type)); \
|
||||
for (j=0; j<old_cols; j++) { \
|
||||
arr[i][j] = old_row[j]; \
|
||||
} \
|
||||
for (j=old_cols; j<new_cols; j++) { \
|
||||
arr[i][j] = null_val; \
|
||||
} \
|
||||
free (old_row); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
/* new table has fewer rows. Simply truncate the rows */ \
|
||||
for (i=new_rows; i<old_rows; i++) { \
|
||||
for (j=0; j<old_cols; j++) { \
|
||||
free_cell_op (arr[i][j]); \
|
||||
} \
|
||||
free (arr[i]); \
|
||||
arr[i] = NULL; \
|
||||
} \
|
||||
\
|
||||
} else { \
|
||||
type **old_entries; \
|
||||
\
|
||||
/* if we are here, there are more new than old rows */ \
|
||||
if (old_cols >= new_cols) { \
|
||||
\
|
||||
/* new table has fewer columns. */ \
|
||||
/* Simply truncate the columns */ \
|
||||
for (i=0; i<old_rows; i++) { \
|
||||
for (j=new_cols; j<old_cols; j++) { \
|
||||
free_cell_op (arr[i][j]); \
|
||||
arr[i][j] = 0x0; /* plain null, not null_val */ \
|
||||
} \
|
||||
} \
|
||||
} else { \
|
||||
\
|
||||
/* if we are here, the new table has more */ \
|
||||
/* columns. Realloc the columns. */ \
|
||||
for (i=0; i<old_rows; i++) { \
|
||||
type *old_row; \
|
||||
\
|
||||
old_row = arr[i]; \
|
||||
arr[i] = (type *) malloc (new_cols * sizeof (type)); \
|
||||
for (j=0; j<old_cols; j++) { \
|
||||
arr[i][j] = old_row[j]; \
|
||||
} \
|
||||
for (j=old_cols; j<new_cols; j++) { \
|
||||
arr[i][j] = null_val; \
|
||||
} \
|
||||
free (old_row); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
/* now, add all new rows */ \
|
||||
old_entries = arr; \
|
||||
arr = (type **) malloc (new_rows * sizeof (type *)); \
|
||||
for (i=0; i<old_rows; i++) { \
|
||||
arr[i] = old_entries[i]; \
|
||||
} \
|
||||
if (old_entries) free (old_entries); \
|
||||
\
|
||||
for (i=old_rows; i<new_rows; i++) { \
|
||||
arr[i] = (type *) malloc (new_cols * sizeof (type)); \
|
||||
for (j=0; j<new_cols; j++) { \
|
||||
arr[i][j] = null_val; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
/* ==================================================== */
|
||||
|
||||
#endif /* __XACC_TABLE_ALLGUI_H__ */
|
||||
#endif /* __TABLE_ALLGUI_H__ */
|
||||
|
||||
/* ================== end of file ======================= */
|
||||
|
@ -24,21 +24,16 @@
|
||||
*
|
||||
* FUNCTION:
|
||||
* Implements the infrastructure for the displayed table.
|
||||
* This is the Gtk implementation;
|
||||
* This is the Gnome implementation.
|
||||
*
|
||||
* HISTORY:
|
||||
* Copyright (c) 1998 Linas Vepstas
|
||||
* Copyright (c) 1998 Rob Browning <rlb@cs.utexas.edu>
|
||||
* Copyright (c) 1999 Heath Martin <martinh@pegasus.cc.ucf.edu>
|
||||
* Copyright (c) 2000 Heath Martin <martinh@pegasus.cc.ucf.edu>
|
||||
* Copyright (c) 2000 Dave Peticolas <dave@krondo.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
TODO: fix up alignments in a UI independent manner.
|
||||
|
||||
deal with the fact (if necessary) that the gtk UI can't directly
|
||||
"cancel" a traverse.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -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 ======================= */
|
||||
|
||||
|
||||
|
@ -1,105 +0,0 @@
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
/*
|
||||
* FILE:
|
||||
* table-gnome.h
|
||||
*
|
||||
* FUNCTION:
|
||||
* This file defines the GNOME-specific GUI portions of the Table object.
|
||||
*
|
||||
* HISTORY:
|
||||
* Copyright (c) 1998 Linas Vepstas
|
||||
* Copyright (c) 1998 Rob Browning <rlb@cs.utexas.edu>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __XACC_TABLE_GNOME_H__
|
||||
#define __XACC_TABLE_GNOME_H__
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gnome.h>
|
||||
|
||||
#include "gnc-common.h"
|
||||
|
||||
|
||||
/* We use C not C++ in this project, but we none-the-less need
|
||||
* the general mechanism of inheritance. The three #defines
|
||||
* below implement that.
|
||||
*
|
||||
* the TABLE_PRIVATE_DATA declaration should be thought of as a
|
||||
* "derived class" of which Table is the base class. This
|
||||
* define is included as a part of the definition of the Table
|
||||
* structure in table-allgui.h
|
||||
*
|
||||
* The TABLE_PRIVATE_DATA_INIT and DESTROY are the constructors
|
||||
* and destructors, respectively, for this derived class.
|
||||
* These are included in the xaccTableInit() and the xaccTableDestroy()
|
||||
* routines in the file table-allgui.c, where they are called,
|
||||
* respectively, last, and first, just as "real" constructors &
|
||||
* destructors would be
|
||||
|
||||
TODO:
|
||||
|
||||
- Still need prev_entry_text?
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#define TABLE_PRIVATE_DATA \
|
||||
/* Gtk-only private table members */ \
|
||||
GtkWidget *table_widget; /* the Sheet */ \
|
||||
gint insert_signal_tag; \
|
||||
gint delete_signal_tag; \
|
||||
gint entry_needs_reconnect;
|
||||
|
||||
|
||||
|
||||
#define TABLE_PRIVATE_DATA_INIT(table) { \
|
||||
table->table_widget = NULL; \
|
||||
table->insert_signal_tag = -1; \
|
||||
table->delete_signal_tag = -1; \
|
||||
table->entry_needs_reconnect = FALSE; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define TABLE_PRIVATE_DATA_DESTROY(table) { \
|
||||
\
|
||||
/* Let GTK know we're finished with this */ \
|
||||
if(table->table_widget) gtk_widget_unref(table->table_widget); \
|
||||
table->table_widget = NULL; \
|
||||
\
|
||||
}
|
||||
|
||||
/* nothing to resize */
|
||||
#define TABLE_PRIVATE_DATA_RESIZE(a,b,c,d,e)
|
||||
|
||||
typedef struct _Table Table;
|
||||
|
||||
|
||||
void xaccCreateTable (GtkWidget *, void *);
|
||||
void doRefreshCursorGUI (Table *, CellBlock *, int, int, gncBoolean);
|
||||
void xaccRefreshTableGUI (Table *);
|
||||
|
||||
#endif __XACC_TABLE_GNOME_H__
|
||||
|
||||
/* ================== end of file ======================= */
|
Loading…
Reference in New Issue
Block a user