ledger window traversal fixes

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@260 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1997-12-04 01:30:19 +00:00
parent cb0ee037c6
commit 2618bc0536

View File

@ -2917,6 +2917,7 @@ regCB( Widget mw, XtPointer cd, XtPointer cb )
XbaeMatrixTraverseCellCallbackStruct *tcbs = XbaeMatrixTraverseCellCallbackStruct *tcbs =
(XbaeMatrixTraverseCellCallbackStruct *)cb; (XbaeMatrixTraverseCellCallbackStruct *)cb;
/* If the quark is zero, then it is likely that we are /* If the quark is zero, then it is likely that we are
* here because we traversed out of a cell that had a * here because we traversed out of a cell that had a
* PopBox in it. The PopBox is clever enough to put * PopBox in it. The PopBox is clever enough to put
@ -2983,48 +2984,51 @@ regCB( Widget mw, XtPointer cd, XtPointer cb )
} }
} }
if( IN_DESC_CELL(row,col) ) if( IN_DESC_CELL(row,col) ) {
{
tcbs->next_column = PAY_CELL_C; tcbs->next_column = PAY_CELL_C;
tcbs->next_row = row - DESC_CELL_R + PAY_CELL_R; tcbs->next_row = row - DESC_CELL_R + PAY_CELL_R;
if( regData->qf != NULL ) if( regData->qf != NULL ) {
if( regData->qf->trans != NULL ) { if( regData->qf->trans != NULL ) {
/* hack alert -- this is guarenteed to break for ledgers */ /* hack alert -- this is guarenteed to break for ledgers */
Account *acc = regData->blackacc[0]; Account *acc = regData->blackacc[0];
double themount; double themount;
themount = xaccGetAmount (acc, regData->qf->trans); themount = xaccGetAmount (acc, regData->qf->trans);
if( 0.0 > themount ) if( 0.0 > themount ) {
{
sprintf( buf, "%.2f ", - themount ); sprintf( buf, "%.2f ", - themount );
XbaeMatrixSetCell( reg, tcbs->next_row, XbaeMatrixSetCell( reg, tcbs->next_row,
tcbs->next_column, buf ); tcbs->next_column, buf );
} }
} }
} }
}
if( IN_PAY_CELL(row,col) ) if( IN_PAY_CELL(row,col) ) {
{
/* In this field, we either go to the deposit field, /* In this field, we either go to the deposit field,
* if the user hasn't entered any data in this field, * if the user hasn't entered any data in this field,
* or to the action field, if the user has entered data */ * or to the action field, if the user has entered data */
XbaeMatrixCommitEdit(reg,True); XbaeMatrixCommitEdit(reg,True);
if( strcmp(XbaeMatrixGetCell(reg,tcbs->row,tcbs->column),"") != 0 ) if( strcmp(XbaeMatrixGetCell(reg,tcbs->row,tcbs->column),"") != 0 ) {
{ /* hmm .. for stocks & mutual funds, the next field is price.
* ordinary accounts don't have a price so hop to action. */
if ((STOCK == regData->type) ||
(MUTUAL == regData->type) ||
(PORTFOLIO == regData->type)) {
tcbs->next_column = PRCC_CELL_C;
tcbs->next_row = row - PAY_CELL_R + PRCC_CELL_R;
} else {
tcbs->next_column = ACTN_CELL_C; tcbs->next_column = ACTN_CELL_C;
tcbs->next_row = row - PAY_CELL_R + ACTN_CELL_R; tcbs->next_row = row - PAY_CELL_R + ACTN_CELL_R;
} }
else } else {
{
tcbs->next_column = DEP_CELL_C; tcbs->next_column = DEP_CELL_C;
tcbs->next_row = row - PAY_CELL_R + DEP_CELL_R; tcbs->next_row = row - PAY_CELL_R + DEP_CELL_R;
if( regData->qf != NULL ) if( NULL != regData->qf ) {
if( regData->qf->trans != NULL ) { if( regData->qf->trans != NULL ) {
/* hack alert -- this is guarenteed to break for ledgers */ /* hack alert -- this is guarenteed to break for ledgers */
Account *acc = regData->blackacc[0]; Account *acc = regData->blackacc[0];
double themount; double themount;
themount = xaccGetAmount (acc, regData->qf->trans); themount = xaccGetAmount (acc, regData->qf->trans);
if( 0.0 <= themount ) if( 0.0 <= themount ) {
{
sprintf( buf, "%.2f ", themount ); sprintf( buf, "%.2f ", themount );
XbaeMatrixSetCell( reg, tcbs->next_row, XbaeMatrixSetCell( reg, tcbs->next_row,
tcbs->next_column, buf ); tcbs->next_column, buf );
@ -3032,17 +3036,47 @@ regCB( Widget mw, XtPointer cd, XtPointer cb )
} }
} }
} }
}
if( IN_DEP_CELL(row,col) ) if( IN_DEP_CELL(row,col) ) {
{ /* hmm .. for stocks & mutual funds, the next field is price.
* ordinary accounts don't have a price so hop to action. */
if ((STOCK == regData->type) ||
(MUTUAL == regData->type) ||
(PORTFOLIO == regData->type)) {
tcbs->next_column = PRCC_CELL_C;
tcbs->next_row = row - DEP_CELL_R + PRCC_CELL_R;
} else {
tcbs->next_column = ACTN_CELL_C; tcbs->next_column = ACTN_CELL_C;
tcbs->next_row = row - DEP_CELL_R + ACTN_CELL_R; tcbs->next_row = row - DEP_CELL_R + ACTN_CELL_R;
} }
}
/* price-credit cell only in stock, mutual registers */
if ((STOCK == regData->type) ||
(MUTUAL == regData->type)) {
if( IN_PRCC_CELL(row,col) ) {
tcbs->next_column = ACTN_CELL_C;
tcbs->next_row = row - PRCC_CELL_R + ACTN_CELL_R;
}
}
/* price-debit cell only in portfolio ledger */
if ((PORTFOLIO == regData->type)) {
if( IN_PRCC_CELL(row,col) ) {
tcbs->next_column = PRCD_CELL_C;
tcbs->next_row = row - PRCC_CELL_R + PRCD_CELL_R;
}
if( IN_PRCD_CELL(row,col) ) {
tcbs->next_column = ACTN_CELL_C;
tcbs->next_row = row - PRCD_CELL_R + ACTN_CELL_R;
}
}
/* If we are in the memo cell, stay there! */ /* If we are in the memo cell, stay there! */
if( (IN_MEMO_CELL(row,col)) && if( (IN_MEMO_CELL(row,col)) &&
(IN_BAD_CELL(tcbs->next_row,tcbs->next_column)) ) (IN_BAD_CELL(tcbs->next_row,tcbs->next_column)) ) {
{
tcbs->next_row = row; tcbs->next_row = row;
tcbs->next_column = MEMO_CELL_C; tcbs->next_column = MEMO_CELL_C;
} }
@ -3051,9 +3085,8 @@ regCB( Widget mw, XtPointer cd, XtPointer cb )
regData->prev_row = tcbs->next_row; regData->prev_row = tcbs->next_row;
regData->prev_col = tcbs->next_column; regData->prev_col = tcbs->next_column;
} }
}
break; break;
}
default: default:
PERR("regDB(): We shouldn't get here!"); PERR("regDB(): We shouldn't get here!");
} }