finish up general porting

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@995 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-08-13 04:02:52 +00:00
parent 0d75fa56f7
commit d388dee6eb
2 changed files with 103 additions and 52 deletions

View File

@ -117,7 +117,7 @@ ledgerIsMember (xaccLedgerDisplay *reg, Account * acc)
if (!acc) return 0; if (!acc) return 0;
if (!reg) return 0; if (!reg) return 0;
if (acc == reg->lead_acct) return 1; if (acc == reg->leader) return 1;
if (! (reg->displayed_accounts)) return 0; if (! (reg->displayed_accounts)) return 0;
@ -274,39 +274,43 @@ xaccLedgerDisplayGeneral (Account *lead_acc, Account **acclist, int ledger_type)
\******************************************************************/ \******************************************************************/
/* the two macros below will search for a register windows associated /* the two macros below will search for a register windows associated
* with the leading account. If they exist, then they will be returned, * with the leading account. If they exist, then they will return,
* and that will be that. If they do not exist, they will be created. * and that will be that. If they do not exist, they will be created.
* *
* There are two lists for lead-accounts: simple, single-account * There are two lists for lead-accounts: simple, single-account
* registers, which display one account only, and multiple-account * registers, which display one account only, and multiple-account
* registers. A leading account can have at most one of each. * registers. A leading account can have at most one of each.
* For a multiple-account register with a lead_acct, all accounts * For a multiple-account register with a leader, all accounts
* shown in the register are sub-accounts of the lead_acct. * shown in the register are sub-accounts of the leader.
* *
* A third possibility exists: a multiple-account register, with * A third possibility exists: a multiple-account register, with
* no lead_acct account. In such a case, the list of accounts being * no leader account. In such a case, the list of accounts being
* displayed have no particular relationshp to each other. There * displayed have no particular relationshp to each other. There
* can be an arbitrary number of multiple-account lead_acct-less * can be an arbitrary number of multiple-account leader-less
* registers. * registers.
*/ */
regData = NULL; regData = NULL;
if (lead_acc) { if (lead_acc) {
if (!acclist) { if (!acclist) {
FETCH_FROM_LIST (xaccLedgerDisplay, regList, lead_acc, lead_acct, regData); FETCH_FROM_LIST (xaccLedgerDisplay, regList, lead_acc, leader, regData);
} else { } else {
FETCH_FROM_LIST (xaccLedgerDisplay, ledgerList, lead_acc, lead_acct, regData); FETCH_FROM_LIST (xaccLedgerDisplay, ledgerList, lead_acc, leader, regData);
} }
} }
/* if regData is null, then no lead_acct account was specified */ /* if regData is null, then no leader account was specified */
if (!regData) { if (!regData) {
regData = (xaccLedgerDisplay *) malloc (sizeof (xaccLedgerDisplay)); regData = (xaccLedgerDisplay *) malloc (sizeof (xaccLedgerDisplay));
regData->lead_acct = NULL;
regData->redraw = NULL;
regData->gui_hook = NULL;
regData->dirty = 0;
} }
regData->leader = lead_acc;
regData->redraw = NULL;
regData->destroy = NULL;
regData->gui_hook = NULL;
regData->dirty = 0;
regData->balance = 0.0;
regData->clearedBalance = 0.0;
/* count the number of accounts we are supposed to display, /* count the number of accounts we are supposed to display,
* and then, store them. */ * and then, store them. */
regData->numAcc = accListCount (acclist); regData->numAcc = accListCount (acclist);
@ -315,8 +319,6 @@ xaccLedgerDisplayGeneral (Account *lead_acc, Account **acclist, int ledger_type)
fullList = ledgerListAdd (fullList, regData); fullList = ledgerListAdd (fullList, regData);
/* create GUI here */
/******************************************************************\ /******************************************************************\
* The main register window itself * * The main register window itself *
\******************************************************************/ \******************************************************************/
@ -342,42 +344,37 @@ xaccLedgerDisplayRefresh (xaccLedgerDisplay *regData)
if (!(regData->dirty)) return; if (!(regData->dirty)) return;
regData->dirty = 0; /* mark clean */ regData->dirty = 0; /* mark clean */
/* The lead_acct account is used by the register gui to /* The leader account is used by the register gui to
* assign a default source account for a "blank split" * assign a default source account for a "blank split"
* that is attached to the bottom of the register. * that is attached to the bottom of the register.
* The "blank split" is what the user edits to create * The "blank split" is what the user edits to create
* new splits and get them into the system. * new splits and get them into the system.
*/ */
xaccSRLoadRegister (regData->ledger, xaccSRLoadRegister (regData->ledger,
xaccAccountGetSplitList (regData->lead_acct), xaccAccountGetSplitList (regData->leader),
regData->lead_acct); regData->leader);
/* hack alert -- this computation of totals is incorrect /* hack alert -- this computation of totals is incorrect
* for multi-account ledgers */ * for multi-account ledgers */
#ifdef LATER
/* provide some convenience data for the ture GUI window. /* provide some convenience data for the ture GUI window.
* If the GUI wants to display yet other stuff, its on its own. * If the GUI wants to display yet other stuff, its on its own.
*/ */
if( NULL != regData->balance ) { regData->balance = xaccAccountGetBalance (regData->leader);
double prt_balance, prt_clearedBalance; regData->clearedBalance = xaccAccountGetClearedBalance (regData->leader);
prt_balance = xaccAccountGetBalance (regData->lead_acct);
prt_clearedBalance = xaccAccountGetClearedBalance (regData->lead_acct);
/* for income and expense acounts, we have to reverse /* for income and expense acounts, we have to reverse
* the meaning of balance, since, in a dual entry * the meaning of balance, since, in a dual entry
* system, income will show up as a credit to a * system, income will show up as a credit to a
* bank account, and a debit to the income account. * bank account, and a debit to the income account.
* Thus, positive and negative are interchanged */ * Thus, positive and negative are interchanged */
if ((INCOME_REGISTER == regData->type) || if ((INCOME_REGISTER == regData->type) ||
(EXPENSE_REGISTER == regData->type)) { (EXPENSE_REGISTER == regData->type)) {
prt_balance = -prt_balance; regData->balance = - (regData->balance);
prt_clearedBalance = -prt_clearedBalance; regData->clearedBalance = - (regData->clearedBalance);
}
} }
#endif
/* OK, now tell this specific GUI window to redraw itself ... */ /* OK, now tell this specific GUI window to redraw itself ... */
if (regData->redraw) { if (regData->redraw) {
@ -441,11 +438,52 @@ xaccAccountDisplayRefresh (Account *acc)
RefreshAllRegs (acc); RefreshAllRegs (acc);
} }
#ifdef LATER
/********************************************************************\ /********************************************************************\
* xaccDestroyxaccLedgerDisplay() \********************************************************************/
* It is enought to call just XtDestroy Widget. Any allocated
* memory will be freed by the close callbacks. void
xaccAccListDisplayRefresh (Account **acc_list)
{
Account *acc;
int i;
/* avoid excess screen flicker with a two-phase refresh */
i = 0; acc = acc_list[0];
while (acc) {
MarkDirtyAllRegs (acc);
i++; acc = acc_list[i];
}
i = 0; acc = acc_list[0];
while (acc) {
RefreshAllRegs (acc);
i++; acc = acc_list[i];
}
}
/********************************************************************\
\********************************************************************/
void
xaccTransDisplayRefresh (Transaction *trans)
{
int i, num_splits;
/* avoid excess screen flicker with a two-phase refresh */
num_splits = xaccTransCountSplits (trans);
for (i=0; i<num_splits; i++) {
Split *split = xaccTransGetSplit (trans, i);
Account *acc = xaccSplitGetAccount (split);
MarkDirtyAllRegs (acc);
}
for (i=0; i<num_splits; i++) {
Split *split = xaccTransGetSplit (trans, i);
Account *acc = xaccSplitGetAccount (split);
RefreshAllRegs (acc);
}
}
/********************************************************************\
* xaccDestroyLedgerDisplay()
\********************************************************************/ \********************************************************************/
void void
@ -455,12 +493,16 @@ xaccDestroyLedgerDisplay (Account *acc)
int n; int n;
/* find the single-account window for this account, if any */ /* find the single-account window for this account, if any */
FIND_IN_LIST (xaccLedgerDisplay, regList, acc, lead_acct, regData); FIND_IN_LIST (xaccLedgerDisplay, regList, acc, leader, regData);
if (regData) XtDestroyWidget(regData->dialog); if (regData) {
if (regData->destroy) { (regData->destroy) (regData); }
}
/* find the multiple-account window for this account, if any */ /* find the multiple-account window for this account, if any */
FIND_IN_LIST (xaccLedgerDisplay, ledgerList, acc, lead_acct, regData); FIND_IN_LIST (xaccLedgerDisplay, ledgerList, acc, leader, regData);
if (regData) XtDestroyWidget(regData->dialog); if (regData) {
if (regData->destroy) { (regData->destroy) (regData); }
}
/* cruise throught the miscellanous account windows */ /* cruise throught the miscellanous account windows */
n = 0; n = 0;
@ -469,7 +511,9 @@ xaccDestroyLedgerDisplay (Account *acc)
int got_one; int got_one;
got_one = ledgerIsMember (regData, acc); got_one = ledgerIsMember (regData, acc);
/* if (got_one) XtDestroyWidget(regData->dialog); */ if (got_one) {
if (regData->destroy) { (regData->destroy) (regData); }
}
n++; n++;
regData = fullList[n]; regData = fullList[n];
} }
@ -485,25 +529,23 @@ xaccDestroyLedgerDisplay (Account *acc)
* cb - * * cb - *
* Return: none * * Return: none *
\********************************************************************/ \********************************************************************/
static void void
closeLedgerDisplay( Widget mw, XtPointer cd, XtPointer cb ) xaccLedgerDisplayClose (xaccLedgerDisplay *regData)
{ {
xaccLedgerDisplay *regData = (xaccLedgerDisplay *)cd; Account *acc = regData->leader;
Account *acc = regData->lead_acct;
/* Save any unsaved changes */ /* Save any unsaved changes */
xaccSRSaveRegEntry (regData->ledger); xaccSRSaveRegEntry (regData->ledger);
xaccDestroyBasicRegister (regData->ledger); xaccDestroySplitRegister (regData->ledger);
/* whether this is a single or multi-account window, remove it */ /* whether this is a single or multi-account window, remove it */
REMOVE_FROM_LIST (xaccLedgerDisplay, regList, acc, lead_acct); REMOVE_FROM_LIST (xaccLedgerDisplay, regList, acc, leader);
REMOVE_FROM_LIST (xaccLedgerDisplay, ledgerList, acc, lead_acct); REMOVE_FROM_LIST (xaccLedgerDisplay, ledgerList, acc, leader);
ledgerListRemove (fullList, regData); ledgerListRemove (fullList, regData);
free(regData); free(regData);
} }
#endif
/************************** END OF FILE *************************/ /************************** END OF FILE *************************/

View File

@ -37,17 +37,21 @@
typedef struct _xaccLedgerDisplay xaccLedgerDisplay; typedef struct _xaccLedgerDisplay xaccLedgerDisplay;
struct _xaccLedgerDisplay { struct _xaccLedgerDisplay {
Account *lead_acct; /* leading. "master" account */ Account *leader; /* leading. "master" account */
Account **displayed_accounts; /* The list of accounts shown here */ Account **displayed_accounts; /* The list of accounts shown here */
short numAcc; /* number of accounts in list */ short numAcc; /* number of accounts in list */
short type; /* register display type, usually equal to * short type; /* register display type, usually equal to *
* account type, but not always. */ * account type, but not always. */
double balance; /* balance */
double clearedBalance;
/* GUI related stuff */
short dirty; /* dirty flag, non zero if redraw needed */ short dirty; /* dirty flag, non zero if redraw needed */
SplitRegister *ledger; /* main ledger window */ SplitRegister *ledger; /* main ledger window */
void *gui_hook; /* GUI-specific state */ void *gui_hook; /* GUI-specific state */
void (*redraw) (xaccLedgerDisplay *); /* redraw callback */ void (*redraw) (xaccLedgerDisplay *); /* redraw callback */
void (*destroy) (xaccLedgerDisplay *); /* destroy callback */
}; };
@ -75,6 +79,7 @@ extern xaccLedgerDisplay * xaccLedgerDisplayGeneral
* that are associated with the indicated account. * that are associated with the indicated account.
*/ */
extern void xaccAccountDisplayRefresh (Account *acc); extern void xaccAccountDisplayRefresh (Account *acc);
extern void xaccAccListDisplayRefresh (Account **acc);
/* /*
* redisplay/redraw all windows that contain this transaction * redisplay/redraw all windows that contain this transaction
@ -87,6 +92,10 @@ extern void xaccTransDisplayRefresh (Transaction *trans);
*/ */
extern void xaccLedgerDisplayRefresh (xaccLedgerDisplay *); extern void xaccLedgerDisplayRefresh (xaccLedgerDisplay *);
/*
* close the window
*/
extern void xaccLedgerDisplayClose (xaccLedgerDisplay *);
#endif /* __MULTI_LEDGER_H__ */ #endif /* __MULTI_LEDGER_H__ */
/************************** END OF FILE *************************/ /************************** END OF FILE *************************/