mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
fix the cell update problems with the new split register
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@925 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
4d8f7a4366
commit
9158305927
@ -45,7 +45,7 @@ BasicCell * xaccMallocBasicCell (void)
|
||||
|
||||
void xaccInitBasicCell (BasicCell *cell)
|
||||
{
|
||||
cell->input_output = 1;
|
||||
cell->input_output = XACC_CELL_ALLOW_ALL;
|
||||
cell->width = 0;
|
||||
cell->alignment = 0;
|
||||
cell->bg_color = 0xffffff; /* white */
|
||||
|
@ -35,10 +35,19 @@
|
||||
* to understand special cell formats.
|
||||
*
|
||||
* MEMBERS:
|
||||
* The input_output member is zero if the cell is supposed
|
||||
* to only display values, but not accept user input. If
|
||||
* non-zero, then the callbacks below are used to when the
|
||||
* cell is entered.
|
||||
* The input_output member controls how the cell accepts
|
||||
* input, and whether it displays it's value. It is a
|
||||
* a flag of OR-ed together values. Flag bits include:
|
||||
*
|
||||
* XACC_CELL_ALLOW_INPUT accept keyboard & mouse
|
||||
* input from the user.
|
||||
* XACC_CELL_ALLOW_SHADOW copy ("shadow") the contents
|
||||
* of register cells.
|
||||
*
|
||||
* If ALLOW_INPUT is not set, the cell is supposed to
|
||||
* to only display values, but not accept user input. If
|
||||
* set, then the callbacks below are used to when the
|
||||
* cell is entered.
|
||||
*
|
||||
*
|
||||
* USER CALLBACKS:
|
||||
@ -131,6 +140,12 @@
|
||||
#ifndef __XACC_BASIC_CELL_H__
|
||||
#define __XACC_BASIC_CELL_H__
|
||||
|
||||
/* define a bitmask */
|
||||
#define XACC_CELL_ALLOW_NONE 0x0
|
||||
#define XACC_CELL_ALLOW_SHADOW 0x1
|
||||
#define XACC_CELL_ALLOW_INPUT 0x2
|
||||
#define XACC_CELL_ALLOW_ALL 0x3
|
||||
|
||||
typedef struct _BasicCell BasicCell;
|
||||
typedef unsigned int uint32;
|
||||
|
||||
|
@ -363,7 +363,7 @@ void xaccInitBasicRegister (BasicRegister *reg, int type)
|
||||
FANCY (value, Price, VALU);
|
||||
|
||||
FANCY (balance, Price, BALN);
|
||||
reg->balanceCell->cell.input_output = 0;
|
||||
reg->balanceCell->cell.input_output = XACC_CELL_ALLOW_NONE;
|
||||
reg->debitCell->blank_zero = 1;
|
||||
reg->creditCell->blank_zero = 1;
|
||||
reg->valueCell->blank_zero = 1;
|
||||
|
@ -325,6 +325,7 @@ void xaccInitSplitRegister (SplitRegister *reg, int type)
|
||||
Table * table;
|
||||
CellBlock *curs, *header;
|
||||
int phys_r, phys_c;
|
||||
int i;
|
||||
|
||||
reg->user_hook = NULL;
|
||||
reg->destroy = NULL;
|
||||
@ -357,27 +358,23 @@ void xaccInitSplitRegister (SplitRegister *reg, int type)
|
||||
curs = xaccMallocCellBlock (1, reg->num_cols);
|
||||
reg->trans_cursor = curs;
|
||||
|
||||
{
|
||||
/* hack alertoid yeah */
|
||||
/*
|
||||
make sure that "blank" cells stay blank, and don't
|
||||
get trailing garbage in them as things move about.
|
||||
but this is broken, as when the cuirsor is moved,
|
||||
the contents of the register are copied into the
|
||||
supposedly "blank" cell, and all is screwed up.
|
||||
Fix this later ....
|
||||
*/
|
||||
int i;
|
||||
BasicCell *nullcell;
|
||||
nullcell = xaccMallocBasicCell();
|
||||
xaccSetBasicCellValue (nullcell, "");
|
||||
nullcell->input_output = 0;
|
||||
nullcell->width = 1;
|
||||
nullcell->bg_color = 0xccccff;
|
||||
for (i=0; i<reg->num_cols; i++) {
|
||||
xaccAddCell (curs, nullcell, 0, i);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* The Null Cell is used to make sure that "empty"
|
||||
* cells stay empty. This solves the problem of
|
||||
* having the table be reformatted, the result of
|
||||
* which is that an empty cell has landed on a cell
|
||||
* that was previously non-empty. We want to make
|
||||
* sure that we erase those cell contents. The null
|
||||
* cells handles this for us.
|
||||
*/
|
||||
|
||||
reg -> nullTransCell = xaccMallocBasicCell();
|
||||
reg -> nullTransCell -> input_output = XACC_CELL_ALLOW_NONE;
|
||||
reg -> nullTransCell -> width = 1;
|
||||
xaccSetBasicCellValue (reg->nullTransCell, "");
|
||||
for (i=0; i<reg->num_cols; i++) {
|
||||
xaccAddCell (curs, reg->nullTransCell, 0, i);
|
||||
}
|
||||
|
||||
FANCY (date, Date, DATE);
|
||||
BASIC (num, Text, NUM);
|
||||
@ -397,6 +394,7 @@ xaccAddCell (curs, nullcell, 0, i);
|
||||
reg->balanceCell->cell.bg_color = 0xccccff;
|
||||
reg->dateCell->cell.bg_color = 0xccccff;
|
||||
reg->numCell->bg_color = 0xccccff;
|
||||
reg->nullTransCell->bg_color = 0xccccff;
|
||||
|
||||
/* --------------------------- */
|
||||
/* define the ledger cursor that handles splits */
|
||||
@ -404,18 +402,19 @@ xaccAddCell (curs, nullcell, 0, i);
|
||||
curs = xaccMallocCellBlock (1, reg->num_cols);
|
||||
reg->split_cursor = curs;
|
||||
|
||||
{
|
||||
/* hack alertoid yeah */
|
||||
int i;
|
||||
BasicCell *nullcell;
|
||||
nullcell = xaccMallocBasicCell();
|
||||
xaccSetBasicCellValue (nullcell, "");
|
||||
nullcell->input_output = 0;
|
||||
nullcell->width = 1;
|
||||
for (i=0; i<reg->num_cols; i++) {
|
||||
xaccAddCell (curs, nullcell, 0, i);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* The Null Cell is used to make sure that "empty"
|
||||
* cells stay empty. See above.
|
||||
*/
|
||||
|
||||
reg -> nullSplitCell = xaccMallocBasicCell();
|
||||
reg -> nullSplitCell -> input_output = XACC_CELL_ALLOW_NONE;
|
||||
reg -> nullSplitCell -> width = 1;
|
||||
xaccSetBasicCellValue (reg->nullSplitCell, "");
|
||||
for (i=0; i<reg->num_cols; i++) {
|
||||
xaccAddCell (curs, reg->nullSplitCell, 0, i);
|
||||
}
|
||||
|
||||
FANCY (xfrm, Combo, XFRM);
|
||||
FANCY (xto, Combo, XTO);
|
||||
FANCY (action, Combo, ACTN);
|
||||
@ -435,7 +434,7 @@ xaccAddCell (curs, nullcell, 0, i);
|
||||
/* do some misc cell config */
|
||||
|
||||
/* balance cell does not accept input; its display only. */
|
||||
reg->balanceCell->cell.input_output = 0;
|
||||
reg->balanceCell->cell.input_output = XACC_CELL_ALLOW_NONE;
|
||||
|
||||
/* the debit/credit/value cells show blank if value is 0.00 */
|
||||
reg->debitCell->blank_zero = 1;
|
||||
|
@ -109,6 +109,9 @@ struct _SplitRegister {
|
||||
ComboCell * xtoCell;
|
||||
PriceCell * balanceCell;
|
||||
|
||||
BasicCell * nullTransCell;
|
||||
BasicCell * nullSplitCell;
|
||||
|
||||
/* the type of the register, must be one of the enumerated types
|
||||
* above *_REGISTER, *_LEDGER, above */
|
||||
int type;
|
||||
|
@ -435,8 +435,10 @@ doMoveCursor (Table *table, int new_phys_row, int new_phys_col, int do_move_gui)
|
||||
|
||||
/* OK, now copy the string value from the table at large
|
||||
* into the cell handler. */
|
||||
xaccSetBasicCellValue (cell, cell_val);
|
||||
cell->changed = 0;
|
||||
if (XACC_CELL_ALLOW_SHADOW & (cell->input_output)) {
|
||||
xaccSetBasicCellValue (cell, cell_val);
|
||||
cell->changed = 0;
|
||||
}
|
||||
|
||||
/* umm, a right now, we'll let the active cursor color override the
|
||||
* individual cell defaults, but for now this is an experiment.
|
||||
|
@ -105,7 +105,8 @@ verify_cell_interaction_OK(Table *table, const int row, const int col)
|
||||
} else {
|
||||
/* if cell is marked as output-only,
|
||||
* then don't call callbacks */
|
||||
if (0 == (arr->cells[rel_row][rel_col])->input_output) {
|
||||
if (0 == (XACC_CELL_ALLOW_INPUT & ((arr->cells[rel_row][rel_col])->input_output)))
|
||||
{
|
||||
invalid = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,8 @@ cellCB (Widget mw, XtPointer cd, XtPointer cb)
|
||||
} else {
|
||||
/* if cell is marked as output-only,
|
||||
* then don't call callbacks */
|
||||
if (0 == (arr->cells[rel_row][rel_col])->input_output) {
|
||||
if (0 == (XACC_CELL_ALLOW_INPUT & ((arr->cells[rel_row][rel_col])->input_output)))
|
||||
{
|
||||
invalid = TRUE;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user