add single-line display xfer cell

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1024 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-08-23 00:24:31 +00:00
parent bb484ae0d9
commit 2f937b292c
4 changed files with 108 additions and 74 deletions

View File

@ -179,7 +179,8 @@ xaccLedgerDisplaySimple (Account *acc)
} }
/* default to single-line display */ /* default to single-line display */
reg_type |= REG_SHOW_TDETAIL; reg_type |= REG_SHOW_TAMOUNT;
reg_type |= REG_SHOW_TXFRM;
retval = xaccLedgerDisplayGeneral (acc, NULL, reg_type); retval = xaccLedgerDisplayGeneral (acc, NULL, reg_type);
return retval; return retval;
@ -252,7 +253,8 @@ xaccLedgerDisplayAccGroup (Account *acc)
} }
/* default to single-line display */ /* default to single-line display */
ledger_type |= REG_SHOW_TDETAIL; ledger_type |= REG_SHOW_TAMOUNT;
ledger_type |= REG_SHOW_TXFRM;
retval = xaccLedgerDisplayGeneral (acc, list, ledger_type); retval = xaccLedgerDisplayGeneral (acc, list, ledger_type);

View File

@ -207,8 +207,8 @@ printf ("save split is %p \n", split);
* and that's that. For a two-line display, we want to reparent * and that's that. For a two-line display, we want to reparent
* the "other" split, but only if there is one ... * the "other" split, but only if there is one ...
*/ */
if (MOD_XFRM & changed) { if ((MOD_XFRM | MOD_TXFRM) & changed) {
Account *old_acc, *new_acc; Account *old_acc=NULL, *new_acc=NULL;
Split *split_to_modify = NULL; Split *split_to_modify = NULL;
if (reg->type & REG_MULTI_LINE) { if (reg->type & REG_MULTI_LINE) {
@ -224,7 +224,11 @@ printf ("save split is %p \n", split);
/* do some reparenting. Insertion into new account will automatically /* do some reparenting. Insertion into new account will automatically
* delete from the old account */ * delete from the old account */
old_acc = xaccSplitGetAccount (split_to_modify); old_acc = xaccSplitGetAccount (split_to_modify);
new_acc = xaccGetAccountByName (trans, reg->xfrmCell->cell.value); if (MOD_XFRM & changed) {
new_acc = xaccGetAccountByName (trans, reg->xfrmCell->cell.value);
} else {
new_acc = xaccGetAccountByName (trans, reg->xfrmTransCell->cell.value);
}
xaccAccountInsertSplit (new_acc, split_to_modify); xaccAccountInsertSplit (new_acc, split_to_modify);
/* make sure any open windows of the old account get redrawn */ /* make sure any open windows of the old account get redrawn */
@ -297,6 +301,30 @@ xaccTransGetDescription(trans));
/* ======================================================== */ /* ======================================================== */
#define LOAD_XFRM(cellname) { \
char * accname=NULL; \
\
/* Show the transfer-from account name. */ \
/* What gets displayed depends on the display format. */ \
/* For a multi-line display, show the account for each member split. */ \
/* For a one or two-line display, show the other account, but only */ \
/* if there are exactly two splits. */ \
if (reg->type & REG_MULTI_LINE) { \
accname = xaccAccountGetName (xaccSplitGetAccount (split)); \
xaccSetComboCellValue (reg->cellname, accname); \
} else { \
Split *s = xaccGetOtherSplit (split); \
if (s) { \
accname = xaccAccountGetName (xaccSplitGetAccount (s)); \
} else { \
accname = SPLIT_STR; \
} \
xaccSetComboCellValue (reg->cellname, accname); \
} \
}
/* ======================================================== */
static void static void
xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit) xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit)
{ {
@ -308,6 +336,7 @@ xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit)
/* we interpret a NULL split as a blank split */ /* we interpret a NULL split as a blank split */
xaccSetDateCellValueSecs (reg->dateCell, 0); xaccSetDateCellValueSecs (reg->dateCell, 0);
xaccSetBasicCellValue (reg->numCell, ""); xaccSetBasicCellValue (reg->numCell, "");
xaccSetComboCellValue (reg->xfrmTransCell, "");
xaccSetQuickFillCellValue (reg->descCell, ""); xaccSetQuickFillCellValue (reg->descCell, "");
xaccSetBasicCellValue (reg->recnCell, ""); xaccSetBasicCellValue (reg->recnCell, "");
xaccSetDebCredCellValue (reg->debitTransCell, xaccSetDebCredCellValue (reg->debitTransCell,
@ -325,6 +354,7 @@ xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit)
xaccSetDateCellValueSecs (reg->dateCell, secs); xaccSetDateCellValueSecs (reg->dateCell, secs);
xaccSetBasicCellValue (reg->numCell, xaccTransGetNum (trans)); xaccSetBasicCellValue (reg->numCell, xaccTransGetNum (trans));
LOAD_XFRM (xfrmTransCell);
xaccSetQuickFillCellValue (reg->descCell, xaccTransGetDescription (trans)); xaccSetQuickFillCellValue (reg->descCell, xaccTransGetDescription (trans));
buff[0] = xaccSplitGetReconcile (split); buff[0] = xaccSplitGetReconcile (split);
@ -371,7 +401,6 @@ xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit)
static void static void
xaccSRLoadSplitEntry (SplitRegister *reg, Split *split, int do_commit) xaccSRLoadSplitEntry (SplitRegister *reg, Split *split, int do_commit)
{ {
char *accname;
char buff[2]; char buff[2];
if (!split) { if (!split) {
@ -388,32 +417,13 @@ xaccSRLoadSplitEntry (SplitRegister *reg, Split *split, int do_commit)
double amt; double amt;
xaccSetComboCellValue (reg->actionCell, xaccSplitGetAction (split)); xaccSetComboCellValue (reg->actionCell, xaccSplitGetAction (split));
LOAD_XFRM (xfrmCell);
xaccSetBasicCellValue (reg->memoCell, xaccSplitGetMemo (split)); xaccSetBasicCellValue (reg->memoCell, xaccSplitGetMemo (split));
buff[0] = xaccSplitGetReconcile (split); buff[0] = xaccSplitGetReconcile (split);
buff[1] = 0x0; buff[1] = 0x0;
xaccSetBasicCellValue (reg->recsCell, buff); xaccSetBasicCellValue (reg->recsCell, buff);
/* Show the transfer-from account name.
* What gets displayed depends on the display format.
* For a multi-line display, show the account for each member split.
* For a two-line display, show the other account, but only if there
* are exactly two splits.
*/
if (reg->type & REG_DOUBLE_LINE) {
Split *s = xaccGetOtherSplit (split);
if (s) {
accname = xaccAccountGetName (xaccSplitGetAccount (s));
} else {
accname = SPLIT_STR;
}
xaccSetComboCellValue (reg->xfrmCell, accname);
}
if (reg->type & REG_MULTI_LINE) {
accname = xaccAccountGetName (xaccSplitGetAccount (split));
xaccSetComboCellValue (reg->xfrmCell, accname);
}
if ((EQUITY_REGISTER == (reg->type & REG_TYPE_MASK)) || if ((EQUITY_REGISTER == (reg->type & REG_TYPE_MASK)) ||
(STOCK_REGISTER == (reg->type & REG_TYPE_MASK)) || (STOCK_REGISTER == (reg->type & REG_TYPE_MASK)) ||
(PORTFOLIO == (reg->type & REG_TYPE_MASK))) (PORTFOLIO == (reg->type & REG_TYPE_MASK)))

View File

@ -41,24 +41,25 @@
/* utility defines for cell configuration data */ /* utility defines for cell configuration data */
#define DATE_CELL 0 #define DATE_CELL 0
#define NUM_CELL 1 #define NUM_CELL 1
#define DESC_CELL 2 #define TXFRM_CELL 2
#define RECN_CELL 3 /* transaction recn */ #define DESC_CELL 3
#define TCRED_CELL 4 #define RECN_CELL 4 /* transaction recn */
#define TDEBT_CELL 5 #define TCRED_CELL 5
#define TPRIC_CELL 6 #define TDEBT_CELL 6
#define TVALU_CELL 7 #define TPRIC_CELL 7
#define SHRS_CELL 8 #define TVALU_CELL 8
#define BALN_CELL 9 #define SHRS_CELL 9
#define BALN_CELL 10
#define ACTN_CELL 10 #define ACTN_CELL 11
#define XFRM_CELL 11 #define XFRM_CELL 12
#define XTO_CELL 12 #define XTO_CELL 13
#define MEMO_CELL 13 #define MEMO_CELL 14
#define RECS_CELL 14 /* split recn */ #define RECS_CELL 15 /* split recn */
#define CRED_CELL 15 #define CRED_CELL 16
#define DEBT_CELL 16 #define DEBT_CELL 17
#define PRIC_CELL 17 #define PRIC_CELL 18
#define VALU_CELL 18 #define VALU_CELL 19
/* utility defines for setting of cell values */ /* utility defines for setting of cell values */
@ -70,6 +71,10 @@
#define NUM_CELL_R (reg->rows[NUM_CELL]) #define NUM_CELL_R (reg->rows[NUM_CELL])
#define NUM_CELL_W (reg->wids[NUM_CELL]) #define NUM_CELL_W (reg->wids[NUM_CELL])
#define TXFRM_CELL_C (reg->cols[TXFRM_CELL])
#define TXFRM_CELL_R (reg->rows[TXFRM_CELL])
#define TXFRM_CELL_W (reg->wids[TXFRM_CELL])
#define DESC_CELL_C (reg->cols[DESC_CELL]) #define DESC_CELL_C (reg->cols[DESC_CELL])
#define DESC_CELL_R (reg->rows[DESC_CELL]) #define DESC_CELL_R (reg->rows[DESC_CELL])
#define DESC_CELL_W (reg->wids[DESC_CELL]) #define DESC_CELL_W (reg->wids[DESC_CELL])
@ -157,18 +162,20 @@ configLayout (SplitRegister *reg)
{ {
int type = (reg->type) & REG_TYPE_MASK; int type = (reg->type) & REG_TYPE_MASK;
int show_recs = (reg->type) & REG_SHOW_RECS; int show_recs = (reg->type) & REG_SHOW_RECS;
int show_tdetail = (reg->type) & REG_SHOW_TDETAIL; int show_tamount = (reg->type) & REG_SHOW_TAMOUNT;
int show_sdetail = (reg->type) & REG_SHOW_SDETAIL; int show_samount = (reg->type) & REG_SHOW_SAMOUNT;
int show_txfrm = (reg->type) & REG_SHOW_TXFRM;
/* perform a bsic layout that's valid for most /* perform a bsic layout that's valid for most
* of the ledgers; then customize with case * of the ledgers; then customize with case
* statements. */ * statements. */
reg->num_cols = 8; reg->num_cols = 8;
reg->num_header_rows = 1; reg->num_header_rows = 1;
SET (DATE_CELL, 0, 0, 11, DATE_STR); SET (DATE_CELL, 0, 0, 11, DATE_STR);
SET (NUM_CELL, 1, 0, 7, NUM_STR); SET (NUM_CELL, 1, 0, 7, NUM_STR);
SET (DESC_CELL, 3, 0, 29, DESC_STR); SET (TXFRM_CELL, -1, -1, 14, XFRM_STR);
SET (RECN_CELL, 4, 0, 1, "R"); SET (DESC_CELL, 3, 0, 29, DESC_STR);
SET (RECN_CELL, 4, 0, 1, "R");
SET (TDEBT_CELL, -1, -1, 12, DEBIT_STR); SET (TDEBT_CELL, -1, -1, 12, DEBIT_STR);
SET (TCRED_CELL, -1, -1, 12, CREDIT_STR); SET (TCRED_CELL, -1, -1, 12, CREDIT_STR);
SET (TPRIC_CELL, -1, -1, 9, PRICE_STR); SET (TPRIC_CELL, -1, -1, 9, PRICE_STR);
@ -191,6 +198,11 @@ configLayout (SplitRegister *reg)
SET (RECS_CELL, 4, 0, 1, "R"); SET (RECS_CELL, 4, 0, 1, "R");
} }
/* show or hide the transaction transfer-from field */
if (show_txfrm) {
SET (TXFRM_CELL, 2, 0, 14, XFRM_STR);
}
switch (type) { switch (type) {
case BANK_REGISTER: case BANK_REGISTER:
case CASH_REGISTER: case CASH_REGISTER:
@ -207,11 +219,11 @@ configLayout (SplitRegister *reg)
SET (VALU_CELL, -1, -1, 10, VALUE_STR); SET (VALU_CELL, -1, -1, 10, VALUE_STR);
SET (SHRS_CELL, -1, -1, 10, TOT_SHRS_STR); SET (SHRS_CELL, -1, -1, 10, TOT_SHRS_STR);
if (show_sdetail) { if (show_samount) {
SET (DEBT_CELL, 5, 0, 12, DEBIT_STR); SET (DEBT_CELL, 5, 0, 12, DEBIT_STR);
SET (CRED_CELL, 6, 0, 12, CREDIT_STR); SET (CRED_CELL, 6, 0, 12, CREDIT_STR);
} }
if (show_tdetail) { if (show_tamount) {
SET (TDEBT_CELL, 5, 0, 12, DEBIT_STR); SET (TDEBT_CELL, 5, 0, 12, DEBIT_STR);
SET (TCRED_CELL, 6, 0, 12, CREDIT_STR); SET (TCRED_CELL, 6, 0, 12, CREDIT_STR);
} }
@ -220,13 +232,13 @@ configLayout (SplitRegister *reg)
case STOCK_REGISTER: case STOCK_REGISTER:
reg->num_cols = 11; reg->num_cols = 11;
SET (XTO_CELL, -1, -1, 14, XFTO_STR); SET (XTO_CELL, -1, -1, 14, XFTO_STR);
if (show_sdetail) { if (show_samount) {
SET (PRIC_CELL, 7, 0, 9, PRICE_STR); SET (PRIC_CELL, 7, 0, 9, PRICE_STR);
SET (VALU_CELL, 8, 0, 10, VALUE_STR); SET (VALU_CELL, 8, 0, 10, VALUE_STR);
SET (SHRS_CELL, 9, 0, 10, TOT_SHRS_STR); SET (SHRS_CELL, 9, 0, 10, TOT_SHRS_STR);
SET (BALN_CELL, 10, 0, 12, BALN_STR); SET (BALN_CELL, 10, 0, 12, BALN_STR);
} }
if (show_tdetail) { if (show_tamount) {
SET (TDEBT_CELL, 5, 0, 12, DEBIT_STR); SET (TDEBT_CELL, 5, 0, 12, DEBIT_STR);
SET (TCRED_CELL, 6, 0, 12, CREDIT_STR); SET (TCRED_CELL, 6, 0, 12, CREDIT_STR);
SET (TPRIC_CELL, 7, 0, 9, PRICE_STR); SET (TPRIC_CELL, 7, 0, 9, PRICE_STR);
@ -286,7 +298,8 @@ configLayout (SplitRegister *reg)
/* define the traversal order */ /* define the traversal order */
/* negative cells mean "traverse out of table" */ /* negative cells mean "traverse out of table" */
/* hack alert -- redesign so that we hop from one row to the next, if desired. */ /* hack alert -- redesign so that we hop from one row to the next, if desired. */
/* hack alert -- if tdetail or sdetail is set then don't traverse there */ /* hack alert -- if show_tamount or show_samount is set then don't traverse there */
/* hack alert -- fix show_txfrm also ... */
static void static void
configTraverse (SplitRegister *reg) configTraverse (SplitRegister *reg)
@ -414,6 +427,7 @@ configCursors (SplitRegister *reg)
FANCY (date, Date, DATE); FANCY (date, Date, DATE);
BASIC (num, Text, NUM); BASIC (num, Text, NUM);
FANCY (xfrmTrans, Combo, TXFRM);
FANCY (desc, QuickFill, DESC); FANCY (desc, QuickFill, DESC);
BASIC (recn, Recn, RECN); BASIC (recn, Recn, RECN);
FANCY (creditTrans, Price, TCRED); FANCY (creditTrans, Price, TCRED);
@ -434,6 +448,7 @@ configCursors (SplitRegister *reg)
*/ */
reg->dateCell -> cell.bg_color = 0xccccff; reg->dateCell -> cell.bg_color = 0xccccff;
reg->numCell -> bg_color = 0xccccff; reg->numCell -> bg_color = 0xccccff;
reg->xfrmTransCell -> cell.bg_color = 0xccccff;
reg->descCell -> cell.bg_color = 0xccccff; reg->descCell -> cell.bg_color = 0xccccff;
reg->recnCell -> bg_color = 0xccccff; reg->recnCell -> bg_color = 0xccccff;
reg->creditTransCell-> cell.bg_color = 0xccccff; reg->creditTransCell-> cell.bg_color = 0xccccff;
@ -522,6 +537,7 @@ xaccInitSplitRegister (SplitRegister *reg, int type)
reg->nullTransCell = xaccMallocBasicCell(); reg->nullTransCell = xaccMallocBasicCell();
reg->dateCell = xaccMallocDateCell(); reg->dateCell = xaccMallocDateCell();
reg->numCell = xaccMallocTextCell(); reg->numCell = xaccMallocTextCell();
reg->xfrmTransCell = xaccMallocComboCell();
reg->descCell = xaccMallocQuickFillCell(); reg->descCell = xaccMallocQuickFillCell();
reg->recnCell = xaccMallocRecnCell(); reg->recnCell = xaccMallocRecnCell();
reg->creditTransCell = xaccMallocPriceCell(); reg->creditTransCell = xaccMallocPriceCell();
@ -670,6 +686,7 @@ xaccDestroySplitRegister (SplitRegister *reg)
xaccDestroyDateCell (reg->dateCell); xaccDestroyDateCell (reg->dateCell);
xaccDestroyBasicCell (reg->numCell); xaccDestroyBasicCell (reg->numCell);
xaccDestroyComboCell (reg->xfrmTransCell);
xaccDestroyQuickFillCell (reg->descCell); xaccDestroyQuickFillCell (reg->descCell);
xaccDestroyBasicCell (reg->recnCell); xaccDestroyBasicCell (reg->recnCell);
xaccDestroyPriceCell (reg->creditTransCell); xaccDestroyPriceCell (reg->creditTransCell);
@ -690,6 +707,7 @@ xaccDestroySplitRegister (SplitRegister *reg)
reg->dateCell = NULL; reg->dateCell = NULL;
reg->numCell = NULL; reg->numCell = NULL;
reg->xfrmTransCell = NULL;
reg->descCell = NULL; reg->descCell = NULL;
reg->recnCell = NULL; reg->recnCell = NULL;
reg->creditTransCell = NULL; reg->creditTransCell = NULL;
@ -723,6 +741,7 @@ xaccSplitRegisterGetChangeFlag (SplitRegister *reg)
/* be careful to use bitwise ands and ors to assemble bit flag */ /* be careful to use bitwise ands and ors to assemble bit flag */
changed |= MOD_DATE & reg->dateCell->cell.changed; changed |= MOD_DATE & reg->dateCell->cell.changed;
changed |= MOD_NUM & reg->numCell->changed; changed |= MOD_NUM & reg->numCell->changed;
changed |= MOD_TXFRM & reg->xfrmTransCell->cell.changed;
changed |= MOD_DESC & reg->descCell->cell.changed; changed |= MOD_DESC & reg->descCell->cell.changed;
changed |= MOD_RECN & reg->recnCell->changed; changed |= MOD_RECN & reg->recnCell->changed;
changed |= MOD_TAMNT & reg->creditTransCell->cell.changed; changed |= MOD_TAMNT & reg->creditTransCell->cell.changed;

View File

@ -73,31 +73,33 @@
#define PORTFOLIO 11 #define PORTFOLIO 11
#define REG_TYPE_MASK 0xff #define REG_TYPE_MASK 0xff
#define REG_SHOW_TDETAIL 0x0100 #define REG_SHOW_TAMOUNT 0x0100
#define REG_SHOW_SDETAIL 0x0200 #define REG_SHOW_SAMOUNT 0x0200
#define REG_SHOW_RECS 0x0400 #define REG_SHOW_TXFRM 0x0400
#define REG_DOUBLE_LINE 0x0800 #define REG_SHOW_RECS 0x0800
#define REG_MULTI_LINE 0x1000 #define REG_DOUBLE_LINE 0x1000
#define REG_MULTI_LINE 0x2000
/* modified flags -- indicate how values have been modified */ /* modified flags -- indicate how values have been modified */
#define MOD_NONE 0x0000 #define MOD_NONE 0x0000
#define MOD_DATE 0x0001 #define MOD_DATE 0x0001
#define MOD_NUM 0x0002 #define MOD_NUM 0x0002
#define MOD_DESC 0x0004 #define MOD_TXFRM 0x0004
#define MOD_RECN 0x0008 #define MOD_DESC 0x0008
#define MOD_TAMNT 0x0010 #define MOD_RECN 0x0010
#define MOD_TPRIC 0x0020 #define MOD_TAMNT 0x0020
#define MOD_TVALU 0x0040 #define MOD_TPRIC 0x0040
#define MOD_TVALU 0x0080
#define MOD_ACTN 0x0080 #define MOD_ACTN 0x0100
#define MOD_XFRM 0x0100 #define MOD_XFRM 0x0200
#define MOD_XTO 0x0200 #define MOD_XTO 0x0400
#define MOD_MEMO 0x0400 #define MOD_MEMO 0x0800
#define MOD_AMNT 0x0800 #define MOD_AMNT 0x1000
#define MOD_PRIC 0x1000 #define MOD_PRIC 0x2000
#define MOD_VALU 0x2000 #define MOD_VALU 0x4000
#define MOD_NEW 0x4000 #define MOD_NEW 0x8000
#define MOD_ALL 0x7fff #define MOD_ALL 0xffff
/* The value of NUM_CELLS should be larger than the number of /* The value of NUM_CELLS should be larger than the number of
* cells defined in the structure below! * cells defined in the structure below!
@ -119,6 +121,7 @@ struct _SplitRegister {
/* these are handled only by the transaction cursor */ /* these are handled only by the transaction cursor */
DateCell * dateCell; DateCell * dateCell;
BasicCell * numCell; BasicCell * numCell;
ComboCell * xfrmTransCell;
QuickFillCell * descCell; QuickFillCell * descCell;
BasicCell * recnCell; /* main transaction line reconcile */ BasicCell * recnCell; /* main transaction line reconcile */
PriceCell * creditTransCell; PriceCell * creditTransCell;
@ -130,7 +133,7 @@ struct _SplitRegister {
BasicCell * nullTransCell; BasicCell * nullTransCell;
/* split cells */ /* split cells */
/* these are hndled only by the split cursor */ /* these are handled only by the split cursor */
ComboCell * actionCell; ComboCell * actionCell;
ComboCell * xfrmCell; ComboCell * xfrmCell;
ComboCell * xtoCell; ComboCell * xtoCell;