From 0fe025efba32a3003611101ac17f8cfb1d7dd131 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Thu, 27 Nov 1997 04:45:50 +0000 Subject: [PATCH] minor beautification git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@159 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/RegWindow.c | 93 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 62 insertions(+), 31 deletions(-) diff --git a/src/RegWindow.c b/src/RegWindow.c index 2e134e1561..c076a532a4 100644 --- a/src/RegWindow.c +++ b/src/RegWindow.c @@ -51,8 +51,6 @@ #define NUM_COLUMNS 20 -#define NUM_HEADER_ROWS 1 /* also works if #define to 2 */ -#define NUM_ROWS_PER_TRANS 2 /* enumerate different ledger types */ enum { @@ -80,6 +78,8 @@ typedef struct _RegWindow { char type; /* register display type, usually equal to * * account type */ + char header_rows; /* number of header rows */ + /* quick-fill stuff */ XmTextPosition insert; /* used by quickfill for detecting deletes */ QuickFill *qf; /* keeps track of current quickfill node. * @@ -98,13 +98,20 @@ typedef struct _RegWindow { short cellRowLocation [NUM_COLUMNS]; /* cell location, row */ short columnWidths [NUM_COLUMNS]; /* widths (in chars not pixels) */ - String columnLabels [NUM_HEADER_ROWS + NUM_ROWS_PER_TRANS] - [NUM_COLUMNS]; /* column labels */ + String columnLabels [5][NUM_COLUMNS];/* column labels */ + /* first array index must be * + * greater than * + * [NUM_HEADER_ROWS + * + * NUM_ROWS_PER_TRANS] */ unsigned char alignments[NUM_COLUMNS]; /* alignment of display chars */ } RegWindow; +#define NUM_HEADER_ROWS (regData->header_rows) +#define NUM_ROWS_PER_TRANS 2 + + /** PROTOTYPES ******************************************************/ RegWindow * regWindowLedger( Widget parent, Account **acclist, int type); @@ -1719,10 +1726,11 @@ regWindowLedger( Widget parent, Account **acclist, int ledger_type ) } regData = (RegWindow *)_malloc(sizeof(RegWindow)); - regData->changed = 0; /* Nothing has changed yet! */ - regData->currEntry = 0; - regData->insert = 0; /* the insert (cursor) position in - * quickfill cells */ + regData->changed = 0; /* Nothing has changed yet! */ + regData->header_rows = 1; + regData->currEntry = 0; + regData->insert = 0; /* the insert (cursor) position in + * quickfill cells */ /* count the number of accounts we are supposed to display, * and then, store them. */ @@ -1745,7 +1753,18 @@ regWindowLedger( Widget parent, Account **acclist, int ledger_type ) regData->blackacc[0]->regData = regData; windowname = regData->blackacc[0]->accountName; } else { - sprintf (buf, "%s General Ledger", regData->blackacc[0]->accountName); + + regData->header_rows = 2; + + switch (regData->type) { + case GEN_LEDGER: + case INC_LEDGER: + sprintf (buf, "%s General Ledger", regData->blackacc[0]->accountName); + break; + case PORTFOLIO: + sprintf (buf, "%s Portfolio", regData->blackacc[0]->accountName); + break; + } windowname = buf; /* hack alert -- quickfill for ledgers is almost certainly broken */ @@ -2113,28 +2132,6 @@ regWindowLedger( Widget parent, Account **acclist, int ledger_type ) regData -> columnLabels[1][MEMO_CELL_C] = "Memo"; } - switch(regData->type) - { - case BANK: - case CASH: - case ASSET: - case CREDIT: - case LIABILITY: - case INCOME: - case EXPENSE: - case EQUITY: - case GEN_LEDGER: - case INC_LEDGER: - break; - case STOCK: - case MUTUAL: - case PORTFOLIO: - regData -> columnLabels[0][PRCC_CELL_C] = "Price"; - regData -> columnLabels[0][SHRS_CELL_C] = "Tot Shrs"; - regData -> columnLabels[0][VCRD_CELL_C] = "Value"; - break; - } - switch(regData->type) { case BANK: @@ -2185,6 +2182,40 @@ regWindowLedger( Widget parent, Account **acclist, int ledger_type ) break; } + switch(regData->type) + { + case BANK: + case CASH: + case ASSET: + case CREDIT: + case LIABILITY: + case INCOME: + case EXPENSE: + case EQUITY: + case GEN_LEDGER: + case INC_LEDGER: + break; + case STOCK: + case MUTUAL: + case PORTFOLIO: + regData -> columnLabels[0][PRCC_CELL_C] = "Price"; + regData -> columnLabels[0][SHRS_CELL_C] = "Tot Shrs"; + regData -> columnLabels[0][VCRD_CELL_C] = "Value"; + if (1 < NUM_HEADER_ROWS) { + regData -> columnLabels[0][PRCC_CELL_C] = "Sale Price"; + regData -> columnLabels[1][PRCC_CELL_C] = "Purch Price"; + regData -> columnLabels[0][VCRD_CELL_C] = "Debit"; + regData -> columnLabels[1][VCRD_CELL_C] = "Credit"; + regData -> columnLabels[0][DEP_CELL_C] = ""; + regData -> columnLabels[1][DEP_CELL_C] = "Bought"; + regData -> columnLabels[0][SHRS_CELL_C] = ""; + regData -> columnLabels[1][SHRS_CELL_C] = "Tot Shrs"; + regData -> columnLabels[0][BALN_CELL_C] = ""; + regData -> columnLabels[1][BALN_CELL_C] = "Balance"; + } + break; + } + data = (String **)XtMalloc( (NUM_HEADER_ROWS+NUM_ROWS_PER_TRANS) * sizeof(String *));