mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Clean up register code. Separate register type and register style.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2496 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
d19485f074
commit
8d966b080d
@ -1,5 +1,9 @@
|
||||
2000-06-21 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/register/splitreg.h: break out the register type and the
|
||||
register style into two separate struct members, instead of using
|
||||
bitmasks. This is much, much simpler.
|
||||
|
||||
* src/optional/swig/Makefile.am (gnucash-engine-perl5_wrap.c):
|
||||
remove the -stat argument, it's no longer support in later swig
|
||||
versions.
|
||||
|
@ -153,9 +153,8 @@ ledgerIsMember (xaccLedgerDisplay *reg, Account * acc)
|
||||
xaccLedgerDisplay *
|
||||
xaccLedgerDisplaySimple (Account *acc)
|
||||
{
|
||||
xaccLedgerDisplay *retval;
|
||||
int acc_type;
|
||||
int reg_type = -1;
|
||||
SplitRegisterType reg_type;
|
||||
GNCAccountType acc_type;
|
||||
|
||||
acc_type = xaccAccountGetType (acc);
|
||||
|
||||
@ -197,11 +196,7 @@ xaccLedgerDisplaySimple (Account *acc)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* default to single-line display */
|
||||
reg_type |= REG_SINGLE_LINE;
|
||||
|
||||
retval = xaccLedgerDisplayGeneral (acc, NULL, reg_type);
|
||||
return retval;
|
||||
return xaccLedgerDisplayGeneral (acc, NULL, reg_type, REG_SINGLE_LINE);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -216,12 +211,13 @@ xaccLedgerDisplaySimple (Account *acc)
|
||||
xaccLedgerDisplay *
|
||||
xaccLedgerDisplayAccGroup (Account *acc)
|
||||
{
|
||||
SplitRegisterType ledger_type;
|
||||
xaccLedgerDisplay *retval;
|
||||
GNCAccountType acc_type;
|
||||
GNCAccountType le_type;
|
||||
Account **list;
|
||||
int ledger_type;
|
||||
Account *le;
|
||||
int n;
|
||||
int acc_type, le_type;
|
||||
|
||||
/* build a flat list from the tree */
|
||||
list = xaccGroupToList (acc);
|
||||
@ -270,12 +266,10 @@ xaccLedgerDisplayAccGroup (Account *acc)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* default to single-line display */
|
||||
ledger_type |= REG_SINGLE_LINE;
|
||||
|
||||
retval = xaccLedgerDisplayGeneral (acc, list, ledger_type);
|
||||
retval = xaccLedgerDisplayGeneral (acc, list, ledger_type, REG_SINGLE_LINE);
|
||||
|
||||
if (list) _free (list);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -320,7 +314,7 @@ xaccLedgerDisplaySetHelp(void *user_data, const char *help_str)
|
||||
|
||||
xaccLedgerDisplay *
|
||||
xaccLedgerDisplayGeneral (Account *lead_acc, Account **acclist,
|
||||
int ledger_type)
|
||||
SplitRegisterType type, SplitRegisterStyle style)
|
||||
{
|
||||
xaccLedgerDisplay *regData = NULL;
|
||||
gboolean show_all;
|
||||
@ -373,7 +367,7 @@ xaccLedgerDisplayGeneral (Account *lead_acc, Account **acclist,
|
||||
* and then, store them. */
|
||||
regData->numAcc = accListCount (acclist);
|
||||
regData->displayed_accounts = accListCopy (acclist);
|
||||
regData->type = ledger_type;
|
||||
regData->type = type;
|
||||
|
||||
show_all = gnc_lookup_boolean_option("Register",
|
||||
"Show All Transactions",
|
||||
@ -386,7 +380,7 @@ xaccLedgerDisplayGeneral (Account *lead_acc, Account **acclist,
|
||||
* configurable, or maybe we should go back a time range instead
|
||||
* of picking a number, or maybe we should be able to exclude
|
||||
* based on reconciled status. Anyway, this works for now. */
|
||||
if (!show_all && ((ledger_type & REG_TYPE_MASK) != SEARCH_LEDGER))
|
||||
if (!show_all && (type != SEARCH_LEDGER))
|
||||
xaccQuerySetMaxSplits(regData->query, 30);
|
||||
|
||||
xaccQuerySetGroup(regData->query, gncGetCurrentGroup());
|
||||
@ -410,7 +404,7 @@ xaccLedgerDisplayGeneral (Account *lead_acc, Account **acclist,
|
||||
|
||||
/* xaccMallocSplitRegister will malloc & initialize the register,
|
||||
* but will not do the gui init */
|
||||
regData->ledger = xaccMallocSplitRegister (ledger_type);
|
||||
regData->ledger = xaccMallocSplitRegister (type, style);
|
||||
|
||||
xaccSRSetData(regData->ledger, regData,
|
||||
xaccLedgerDisplayParent,
|
||||
|
@ -46,8 +46,9 @@ struct _xaccLedgerDisplay {
|
||||
short numAcc; /* number of accounts in list */
|
||||
Query *query; /* query engine & filter for displaying */
|
||||
|
||||
short type; /* register display type, usually equal to *
|
||||
SplitRegisterType type; /* register display type, usually equal to *
|
||||
* account type, but not always. */
|
||||
|
||||
double balance; /* balance */
|
||||
double clearedBalance;
|
||||
double reconciledBalance;
|
||||
@ -81,7 +82,8 @@ xaccLedgerDisplay * xaccLedgerDisplayAccGroup (Account *acc);
|
||||
*/
|
||||
xaccLedgerDisplay * xaccLedgerDisplayGeneral (Account *lead_acc,
|
||||
Account **acclist,
|
||||
int ledger_type);
|
||||
SplitRegisterType type,
|
||||
SplitRegisterStyle style);
|
||||
|
||||
/*
|
||||
* redisplay/redraw all windows that contain any transactions
|
||||
|
@ -642,7 +642,6 @@ LedgerMoveCursor (Table *table,
|
||||
int new_cell_col;
|
||||
int phys_row_offset;
|
||||
int phys_col_offset;
|
||||
int style;
|
||||
|
||||
PINFO ("start callback %d %d \n", new_phys_row, new_phys_col);
|
||||
|
||||
@ -759,9 +758,8 @@ LedgerMoveCursor (Table *table,
|
||||
* to expand out the splits at the new location. We use the
|
||||
* cursor_hint data members to tell the refresh routine where
|
||||
* to go. */
|
||||
style = ((reg->type) & REG_STYLE_MASK);
|
||||
if ((REG_SINGLE_DYNAMIC == style) ||
|
||||
(REG_DOUBLE_DYNAMIC == style))
|
||||
if ((REG_SINGLE_DYNAMIC == reg->style) ||
|
||||
(REG_DOUBLE_DYNAMIC == reg->style))
|
||||
{
|
||||
new_trans = xaccSRGetTrans(reg, new_phys_row, new_phys_col);
|
||||
info->cursor_hint_trans = new_trans;
|
||||
@ -808,6 +806,7 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir,
|
||||
SRInfo *info = xaccSRGetInfo(reg);
|
||||
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
|
||||
Transaction *pending_trans = xaccTransLookup(&info->pending_trans_guid);
|
||||
SplitRegisterType reg_type;
|
||||
CursorType cursor_type;
|
||||
unsigned int changed;
|
||||
CellType cell_type;
|
||||
@ -826,6 +825,7 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir,
|
||||
if (trans == NULL)
|
||||
return;
|
||||
|
||||
reg_type = reg->type;
|
||||
cursor_type = xaccSplitRegisterGetCursorType(reg);
|
||||
cell_type = xaccSplitRegisterGetCellType(reg);
|
||||
changed = xaccSplitRegisterGetChangeFlag(reg);
|
||||
@ -940,7 +940,6 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir,
|
||||
break;
|
||||
|
||||
case CURSOR_SPLIT: {
|
||||
SplitRegisterType typo = reg->type & REG_TYPE_MASK;
|
||||
char *memo, *fullname;
|
||||
gboolean unit_price;
|
||||
Split *auto_split;
|
||||
@ -999,9 +998,9 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir,
|
||||
xaccBasicCellSetChanged(&(reg->xfrmCell->cell), GNC_T);
|
||||
|
||||
/* auto-complete the amounts */
|
||||
if ((STOCK_REGISTER == typo) ||
|
||||
(CURRENCY_REGISTER == typo) ||
|
||||
(PORTFOLIO_LEDGER == typo))
|
||||
if ((STOCK_REGISTER == reg_type) ||
|
||||
(CURRENCY_REGISTER == reg_type) ||
|
||||
(PORTFOLIO_LEDGER == reg_type))
|
||||
amount = xaccSplitGetShareAmount (auto_split);
|
||||
else
|
||||
amount = xaccSplitGetValue (auto_split);
|
||||
@ -2181,7 +2180,6 @@ xaccSRSaveRegEntryToSCM (SplitRegister *reg, SCM trans_scm, SCM split_scm)
|
||||
{
|
||||
Transaction *trans;
|
||||
unsigned int changed;
|
||||
int style;
|
||||
|
||||
/* use the changed flag to avoid heavy-weight updates
|
||||
* of the split & transaction fields. This will help
|
||||
@ -2190,8 +2188,6 @@ xaccSRSaveRegEntryToSCM (SplitRegister *reg, SCM trans_scm, SCM split_scm)
|
||||
if (!changed)
|
||||
return GNC_F;
|
||||
|
||||
style = (reg->type) & REG_STYLE_MASK;
|
||||
|
||||
/* get the handle to the current split and transaction */
|
||||
trans = xaccSRGetCurrentTrans (reg);
|
||||
if (trans == NULL)
|
||||
@ -2301,9 +2297,9 @@ xaccSRSaveRegEntryToSCM (SplitRegister *reg, SCM trans_scm, SCM split_scm)
|
||||
|
||||
price = gnc_split_scm_get_share_price(split_scm);
|
||||
|
||||
if ((STOCK_REGISTER == (reg->type & REG_TYPE_MASK)) ||
|
||||
(CURRENCY_REGISTER == (reg->type & REG_TYPE_MASK)) ||
|
||||
(PORTFOLIO_LEDGER == (reg->type & REG_TYPE_MASK)))
|
||||
if ((STOCK_REGISTER == (reg->type)) ||
|
||||
(CURRENCY_REGISTER == (reg->type)) ||
|
||||
(PORTFOLIO_LEDGER == (reg->type)))
|
||||
;
|
||||
else
|
||||
new_amount = new_amount / price;
|
||||
@ -2486,10 +2482,8 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
|
||||
{
|
||||
GList *refresh_accounts = NULL;
|
||||
unsigned int changed;
|
||||
int style;
|
||||
|
||||
changed = xaccSplitRegisterGetChangeFlag (reg);
|
||||
style = (reg->type) & REG_STYLE_MASK;
|
||||
|
||||
/* copy the contents from the cursor to the split */
|
||||
if (MOD_DATE & changed) {
|
||||
@ -2676,9 +2670,9 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
|
||||
}
|
||||
|
||||
if (((MOD_AMNT | MOD_PRIC | MOD_VALU) & changed) &&
|
||||
((STOCK_REGISTER == (reg->type & REG_TYPE_MASK)) ||
|
||||
(CURRENCY_REGISTER == (reg->type & REG_TYPE_MASK)) ||
|
||||
(PORTFOLIO_LEDGER == (reg->type & REG_TYPE_MASK)))) {
|
||||
((STOCK_REGISTER == (reg->type)) ||
|
||||
(CURRENCY_REGISTER == (reg->type)) ||
|
||||
(PORTFOLIO_LEDGER == (reg->type)))) {
|
||||
|
||||
double value;
|
||||
double price;
|
||||
@ -2803,9 +2797,9 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
|
||||
|
||||
DEBUG ("MOD_AMNT: %f\n", new_amount);
|
||||
|
||||
if ((STOCK_REGISTER == (reg->type & REG_TYPE_MASK)) ||
|
||||
(CURRENCY_REGISTER == (reg->type & REG_TYPE_MASK)) ||
|
||||
(PORTFOLIO_LEDGER == (reg->type & REG_TYPE_MASK)))
|
||||
if ((STOCK_REGISTER == (reg->type)) ||
|
||||
(CURRENCY_REGISTER == (reg->type)) ||
|
||||
(PORTFOLIO_LEDGER == (reg->type)))
|
||||
xaccSplitSetShareAmount (split, new_amount);
|
||||
else
|
||||
xaccSplitSetValue (split, new_amount);
|
||||
@ -2839,7 +2833,7 @@ xaccSRLoadRegEntry (SplitRegister *reg, Split *split)
|
||||
{
|
||||
SRInfo *info = xaccSRGetInfo(reg);
|
||||
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
|
||||
int typo = reg->type & REG_TYPE_MASK;
|
||||
SplitRegisterType reg_type = reg->type;
|
||||
char buff[2];
|
||||
double baln;
|
||||
|
||||
@ -2899,8 +2893,8 @@ xaccSRLoadRegEntry (SplitRegister *reg, Split *split)
|
||||
if (reverse_balance(account))
|
||||
baln = -baln;
|
||||
}
|
||||
else if ((INCOME_REGISTER == typo) ||
|
||||
(EXPENSE_REGISTER == typo)) {
|
||||
else if ((INCOME_REGISTER == reg_type) ||
|
||||
(EXPENSE_REGISTER == reg_type)) {
|
||||
baln = -baln;
|
||||
}
|
||||
|
||||
@ -2969,9 +2963,9 @@ xaccSRLoadRegEntry (SplitRegister *reg, Split *split)
|
||||
buff[1] = 0x0;
|
||||
xaccSetBasicCellValue (reg->recnCell, buff);
|
||||
|
||||
if ((STOCK_REGISTER == typo) ||
|
||||
(CURRENCY_REGISTER == typo) ||
|
||||
(PORTFOLIO_LEDGER == typo))
|
||||
if ((STOCK_REGISTER == reg_type) ||
|
||||
(CURRENCY_REGISTER == reg_type) ||
|
||||
(PORTFOLIO_LEDGER == reg_type))
|
||||
{
|
||||
amt = xaccSplitGetShareAmount (split);
|
||||
} else {
|
||||
@ -2984,7 +2978,7 @@ xaccSRLoadRegEntry (SplitRegister *reg, Split *split)
|
||||
xaccSetPriceCellValue (reg->valueCell, xaccSplitGetValue (split));
|
||||
}
|
||||
|
||||
reg->table->current_cursor->user_data = (void *) split;
|
||||
reg->table->current_cursor->user_data = split;
|
||||
|
||||
/* copy cursor contents into the table */
|
||||
xaccCommitCursor (reg->table);
|
||||
@ -3022,16 +3016,16 @@ xaccSRCountRows (SplitRegister *reg,
|
||||
gncBoolean multi_line;
|
||||
gncBoolean dynamic;
|
||||
|
||||
SplitRegisterStyle style;
|
||||
int save_cursor_phys_row;
|
||||
int save_cursor_virt_row;
|
||||
int save_cell_row;
|
||||
int num_phys_rows;
|
||||
int num_virt_rows;
|
||||
int style;
|
||||
int i;
|
||||
|
||||
table = reg->table;
|
||||
style = (reg->type) & REG_STYLE_MASK;
|
||||
style = reg->style;
|
||||
multi_line = (REG_MULTI_LINE == style);
|
||||
dynamic = ((REG_SINGLE_DYNAMIC == style) || (REG_DOUBLE_DYNAMIC == style));
|
||||
if ((REG_SINGLE_LINE == style) ||
|
||||
@ -3329,9 +3323,10 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
|
||||
gncBoolean multi_line;
|
||||
gncBoolean dynamic;
|
||||
|
||||
SplitRegisterType type;
|
||||
SplitRegisterStyle style;
|
||||
unsigned int changed;
|
||||
int save_phys_col;
|
||||
int type, style;
|
||||
int phys_row;
|
||||
int vrow;
|
||||
int i;
|
||||
@ -3357,8 +3352,8 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
|
||||
info->default_source_account = default_source_acc;
|
||||
|
||||
table = reg->table;
|
||||
type = (reg->type) & REG_TYPE_MASK;
|
||||
style = (reg->type) & REG_STYLE_MASK;
|
||||
type = reg->type;
|
||||
style = reg->style;
|
||||
multi_line = (REG_MULTI_LINE == style);
|
||||
dynamic = ((REG_SINGLE_DYNAMIC == style) || (REG_DOUBLE_DYNAMIC == style));
|
||||
if ((REG_SINGLE_LINE == style) ||
|
||||
|
@ -585,10 +585,12 @@ gnc_ui_find_transactions_dialog_ok_cb(GtkButton * button,
|
||||
|
||||
if(!ftd->ledger) {
|
||||
new_ledger = TRUE;
|
||||
ftd->ledger = xaccLedgerDisplayGeneral(NULL, NULL, SEARCH_LEDGER);
|
||||
xaccFreeQuery(ftd->ledger->query);
|
||||
ftd->ledger = xaccLedgerDisplayGeneral(NULL, NULL,
|
||||
SEARCH_LEDGER,
|
||||
REG_SINGLE_LINE);
|
||||
xaccFreeQuery(ftd->ledger->query);
|
||||
}
|
||||
|
||||
|
||||
switch(search_type) {
|
||||
case 0:
|
||||
ftd->ledger->query = q;
|
||||
|
@ -231,14 +231,11 @@ gnc_register_jump_to_split(RegWindow *regData, Split *split)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
gnc_register_get_default_type(SplitRegister *reg)
|
||||
static SplitRegisterStyle
|
||||
gnc_get_default_register_style()
|
||||
{
|
||||
SplitRegisterStyle new_style = REG_SINGLE_LINE;
|
||||
char *style_string;
|
||||
int new_style = REG_SINGLE_LINE;
|
||||
int type = reg->type;
|
||||
|
||||
type &= ~REG_STYLE_MASK;
|
||||
|
||||
style_string = gnc_lookup_multichoice_option("Register",
|
||||
"Default Register Mode",
|
||||
@ -255,25 +252,19 @@ gnc_register_get_default_type(SplitRegister *reg)
|
||||
else if (safe_strcmp(style_string, "auto_double") == 0)
|
||||
new_style = REG_DOUBLE_DYNAMIC;
|
||||
|
||||
type |= new_style;
|
||||
|
||||
if (style_string != NULL)
|
||||
free(style_string);
|
||||
|
||||
return type;
|
||||
return new_style;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gnc_register_change_style(RegWindow *regData, int style_code)
|
||||
gnc_register_change_style(RegWindow *regData, SplitRegisterStyle style)
|
||||
{
|
||||
SplitRegister *reg = regData->ledger->ledger;
|
||||
int type = reg->type;
|
||||
|
||||
type &= ~REG_STYLE_MASK;
|
||||
type |= style_code;
|
||||
|
||||
xaccConfigSplitRegister(reg, type);
|
||||
xaccConfigSplitRegister(reg, reg->type, style);
|
||||
|
||||
regData->ledger->dirty = 1;
|
||||
xaccLedgerDisplayRefresh(regData->ledger);
|
||||
@ -892,7 +883,7 @@ gnc_register_create_status_bar(RegWindow *regData)
|
||||
|
||||
regData->statusbar = statusbar;
|
||||
|
||||
switch (regData->ledger->ledger->type & REG_TYPE_MASK)
|
||||
switch (regData->ledger->type)
|
||||
{
|
||||
case GENERAL_LEDGER:
|
||||
case INCOME_LEDGER:
|
||||
@ -1318,12 +1309,8 @@ gnc_register_create_menu_bar(RegWindow *regData, GtkWidget *statusbar)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
int index;
|
||||
int style;
|
||||
|
||||
style = gnc_register_get_default_type(regData->ledger->ledger);
|
||||
style &= REG_STYLE_MASK;
|
||||
|
||||
switch (style)
|
||||
switch (gnc_get_default_register_style())
|
||||
{
|
||||
default:
|
||||
case REG_SINGLE_LINE:
|
||||
@ -1430,11 +1417,9 @@ gnc_register_record_cb(GnucashRegister *reg, gpointer data)
|
||||
* when you are entering transactions. */
|
||||
{
|
||||
SplitRegister *sr = regData->ledger->ledger;
|
||||
int type = sr->type;
|
||||
SplitRegisterStyle style = sr->style;
|
||||
|
||||
type &= REG_STYLE_MASK;
|
||||
|
||||
if ((type == REG_SINGLE_LINE) || (type == REG_DOUBLE_LINE))
|
||||
if ((style == REG_SINGLE_LINE) || (style == REG_DOUBLE_LINE))
|
||||
{
|
||||
Split *blank_split;
|
||||
|
||||
@ -1496,7 +1481,7 @@ gnc_reg_set_window_name(RegWindow *regData)
|
||||
if (regData == NULL)
|
||||
return;
|
||||
|
||||
switch (regData->ledger->type & REG_TYPE_MASK)
|
||||
switch (regData->ledger->type)
|
||||
{
|
||||
case GENERAL_LEDGER:
|
||||
case INCOME_LEDGER:
|
||||
@ -1667,19 +1652,17 @@ regWindowLedger(xaccLedgerDisplay *ledger)
|
||||
}
|
||||
|
||||
/* be sure to initialize the gui elements associated with the cursor */
|
||||
xaccConfigSplitRegister(ledger->ledger,
|
||||
gnc_register_get_default_type(ledger->ledger));
|
||||
xaccConfigSplitRegister(ledger->ledger, ledger->type,
|
||||
gnc_get_default_register_style());
|
||||
|
||||
/* Allow grow, allow shrink, auto-shrink */
|
||||
gtk_window_set_policy(GTK_WINDOW(register_window), TRUE, TRUE, TRUE);
|
||||
|
||||
{
|
||||
int type;
|
||||
int *width;
|
||||
char *prefix;
|
||||
|
||||
type = ledger->ledger->type & REG_TYPE_MASK;
|
||||
switch (type)
|
||||
switch (ledger->type)
|
||||
{
|
||||
case STOCK_REGISTER:
|
||||
case PORTFOLIO_LEDGER:
|
||||
@ -1798,7 +1781,7 @@ gnc_reg_save_size(RegWindow *regData)
|
||||
int *width;
|
||||
char *prefix;
|
||||
|
||||
switch (regData->ledger->ledger->type & REG_TYPE_MASK)
|
||||
switch (regData->ledger->type)
|
||||
{
|
||||
case STOCK_REGISTER:
|
||||
case PORTFOLIO_LEDGER:
|
||||
@ -2261,13 +2244,13 @@ gnc_transaction_delete_query(GtkWindow *parent)
|
||||
static void
|
||||
deleteCB(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
RegWindow *regData = (RegWindow *) data;
|
||||
RegWindow *regData = data;
|
||||
SplitRegisterStyle style;
|
||||
CursorType cursor_type;
|
||||
Transaction *trans;
|
||||
char *buf = NULL;
|
||||
Split *split;
|
||||
gint result;
|
||||
int style;
|
||||
|
||||
/* get the current split based on cursor position */
|
||||
split = xaccSRGetCurrentSplit(regData->ledger->ledger);
|
||||
@ -2278,7 +2261,7 @@ deleteCB(GtkWidget *widget, gpointer data)
|
||||
}
|
||||
|
||||
trans = xaccSplitGetParent(split);
|
||||
style = regData->ledger->ledger->type & REG_STYLE_MASK;
|
||||
style = regData->ledger->ledger->style;
|
||||
cursor_type = xaccSplitRegisterGetCursorType(regData->ledger->ledger);
|
||||
|
||||
/* Deleting the blank split just cancels */
|
||||
|
@ -1384,7 +1384,7 @@ gnucash_sheet_style_compile (GnucashSheet *sheet, CellBlock *cellblock,
|
||||
|
||||
style = g_new0(SheetBlockStyle, 1);
|
||||
|
||||
style->reg_type = sr->type & REG_TYPE_MASK;
|
||||
style->reg_type = sr->type;
|
||||
style->cursor_type = cursor_type;
|
||||
|
||||
style->nrows = cellblock->numRows;
|
||||
|
@ -168,10 +168,12 @@ xaccSplitRegisterSetCreditStringGetter(SRStringGetter getter)
|
||||
static void
|
||||
configLabels (SplitRegister *reg)
|
||||
{
|
||||
SplitRegisterType type;
|
||||
BasicCell *hc;
|
||||
int type = (reg->type) & REG_TYPE_MASK;
|
||||
char *string;
|
||||
|
||||
type = reg->type;
|
||||
|
||||
LABEL (DATE, DATE_STR);
|
||||
LABEL (NUM, NUM_STR);
|
||||
LABEL (DESC, DESC_STR);
|
||||
@ -222,10 +224,8 @@ configLabels (SplitRegister *reg)
|
||||
static void
|
||||
configAction (SplitRegister *reg)
|
||||
{
|
||||
int type = (reg->type) & REG_TYPE_MASK;
|
||||
|
||||
/* setup strings in the action pull-down */
|
||||
switch (type) {
|
||||
switch (reg->type) {
|
||||
case BANK_REGISTER:
|
||||
case SEARCH_LEDGER: /* broken ! FIXME bg */
|
||||
xaccAddComboCellMenuItem ( reg->actionCell, DEPOSIT_STR);
|
||||
@ -346,7 +346,6 @@ static void
|
||||
configLayout (SplitRegister *reg)
|
||||
{
|
||||
CellBlock *curs, *header;
|
||||
int type = (reg->type) & REG_TYPE_MASK;
|
||||
int i;
|
||||
|
||||
/* define header for macros */
|
||||
@ -362,7 +361,7 @@ configLayout (SplitRegister *reg)
|
||||
reg->double_cursor->cells[1][i] = reg->nullCell;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
switch (reg->type) {
|
||||
case BANK_REGISTER:
|
||||
case CASH_REGISTER:
|
||||
case ASSET_REGISTER:
|
||||
@ -576,7 +575,7 @@ configLayout (SplitRegister *reg)
|
||||
|
||||
/* --------------------------------------------------------- */
|
||||
default:
|
||||
PERR ("unknown register type %d \n", type);
|
||||
PERR ("unknown register type %d \n", reg->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -816,11 +815,13 @@ configTraverse (SplitRegister *reg)
|
||||
/* ============================================== */
|
||||
|
||||
SplitRegister *
|
||||
xaccMallocSplitRegister (int type)
|
||||
xaccMallocSplitRegister (SplitRegisterType type, SplitRegisterStyle style)
|
||||
{
|
||||
SplitRegister * reg;
|
||||
reg = (SplitRegister *) malloc (sizeof (SplitRegister));
|
||||
xaccInitSplitRegister (reg, type);
|
||||
|
||||
reg = malloc (sizeof (SplitRegister));
|
||||
xaccInitSplitRegister (reg, type, style);
|
||||
|
||||
return reg;
|
||||
}
|
||||
|
||||
@ -837,12 +838,10 @@ xaccSetSplitRegisterColors (SplitRegisterColors reg_colors_new)
|
||||
static void
|
||||
configTable(SplitRegister *reg)
|
||||
{
|
||||
int style = reg->type & REG_STYLE_MASK;
|
||||
|
||||
if ((reg == NULL) || (reg->table == NULL))
|
||||
return;
|
||||
|
||||
switch (style) {
|
||||
switch (reg->style) {
|
||||
case REG_SINGLE_LINE:
|
||||
case REG_SINGLE_DYNAMIC:
|
||||
reg->table->alternate_bg_colors = GNC_T;
|
||||
@ -910,9 +909,7 @@ configCursors (SplitRegister *reg)
|
||||
static void
|
||||
mallocCursors (SplitRegister *reg)
|
||||
{
|
||||
int type = (reg->type) & REG_TYPE_MASK;
|
||||
|
||||
switch (type) {
|
||||
switch (reg->type) {
|
||||
case BANK_REGISTER:
|
||||
case CASH_REGISTER:
|
||||
case ASSET_REGISTER:
|
||||
@ -968,7 +965,9 @@ mallocCursors (SplitRegister *reg)
|
||||
reg->CN##Cell = xaccMalloc##TYPE##Cell(); \
|
||||
|
||||
void
|
||||
xaccInitSplitRegister (SplitRegister *reg, int type)
|
||||
xaccInitSplitRegister (SplitRegister *reg,
|
||||
SplitRegisterType type,
|
||||
SplitRegisterStyle style)
|
||||
{
|
||||
Table * table;
|
||||
CellBlock *header;
|
||||
@ -978,6 +977,7 @@ xaccInitSplitRegister (SplitRegister *reg, int type)
|
||||
reg->user_data = NULL;
|
||||
reg->destroy = NULL;
|
||||
reg->type = type;
|
||||
reg->style = style;
|
||||
|
||||
/* --------------------------- */
|
||||
/* define the number of columns in the display, malloc the cursors */
|
||||
@ -1107,7 +1107,7 @@ xaccInitSplitRegister (SplitRegister *reg, int type)
|
||||
xaccSetBasicCellBlankHelp (®->actionCell->cell, ACTION_CELL_HELP);
|
||||
|
||||
/* number format for share quantities in stock ledgers */
|
||||
switch (type & REG_TYPE_MASK) {
|
||||
switch (type) {
|
||||
case CURRENCY_REGISTER:
|
||||
xaccSetPriceCellIsCurrency (reg->priceCell, GNC_T);
|
||||
|
||||
@ -1173,11 +1173,14 @@ xaccInitSplitRegister (SplitRegister *reg, int type)
|
||||
/* ============================================== */
|
||||
|
||||
void
|
||||
xaccConfigSplitRegister (SplitRegister *reg, int newtype)
|
||||
xaccConfigSplitRegister (SplitRegister *reg,
|
||||
SplitRegisterType newtype,
|
||||
SplitRegisterStyle newstyle)
|
||||
{
|
||||
if (!reg) return;
|
||||
|
||||
reg->type = newtype;
|
||||
reg->style = newstyle;
|
||||
|
||||
/* Make sure that any GUI elements associated with this reconfig
|
||||
* are properly initialized. */
|
||||
|
@ -80,8 +80,6 @@ typedef enum
|
||||
SEARCH_LEDGER = 14
|
||||
} SplitRegisterType;
|
||||
|
||||
#define REG_TYPE_MASK 0xff
|
||||
|
||||
/* These values are used to identify the cells in the register. */
|
||||
typedef enum
|
||||
{
|
||||
@ -119,12 +117,14 @@ typedef enum
|
||||
* REG_DOUBLE_DYNAMIC -- dynamically expand edited transaction,
|
||||
* all other transactions on two lines
|
||||
*/
|
||||
#define REG_SINGLE_LINE (1 << 8)
|
||||
#define REG_DOUBLE_LINE (2 << 8)
|
||||
#define REG_MULTI_LINE (3 << 8)
|
||||
#define REG_SINGLE_DYNAMIC (4 << 8)
|
||||
#define REG_DOUBLE_DYNAMIC (5 << 8)
|
||||
#define REG_STYLE_MASK (0xff << 8)
|
||||
typedef enum
|
||||
{
|
||||
REG_SINGLE_LINE = 1,
|
||||
REG_DOUBLE_LINE = 2,
|
||||
REG_MULTI_LINE = 3,
|
||||
REG_SINGLE_DYNAMIC = 4,
|
||||
REG_DOUBLE_DYNAMIC = 5
|
||||
} SplitRegisterStyle;
|
||||
|
||||
/* modified flags -- indicate which cell values have been modified by user */
|
||||
#define MOD_NONE 0x0000
|
||||
@ -193,9 +193,11 @@ struct _SplitRegister {
|
||||
PriceCell * ncreditCell;
|
||||
PriceCell * ndebitCell;
|
||||
|
||||
/* the type of the register, must be one of the enumerated types
|
||||
* above *_REGISTER, *_LEDGER, above */
|
||||
int type;
|
||||
/* The type of the register, must be one of the enumerated types
|
||||
* named *_REGISTER, *_LEDGER, above */
|
||||
SplitRegisterType type;
|
||||
|
||||
SplitRegisterStyle style;
|
||||
|
||||
/* some private data; outsiders should not access this */
|
||||
int num_cols;
|
||||
@ -247,16 +249,21 @@ typedef char* (*SRStringGetter) (SplitRegisterType);
|
||||
void xaccSplitRegisterSetDebitStringGetter(SRStringGetter getter);
|
||||
void xaccSplitRegisterSetCreditStringGetter(SRStringGetter getter);
|
||||
|
||||
SplitRegister * xaccMallocSplitRegister (int type);
|
||||
void xaccInitSplitRegister (SplitRegister *, int type);
|
||||
void xaccConfigSplitRegister (SplitRegister *, int type);
|
||||
void xaccDestroySplitRegister (SplitRegister *);
|
||||
SplitRegister * xaccMallocSplitRegister (SplitRegisterType type,
|
||||
SplitRegisterStyle style);
|
||||
void xaccInitSplitRegister (SplitRegister *reg,
|
||||
SplitRegisterType type,
|
||||
SplitRegisterStyle style);
|
||||
void xaccConfigSplitRegister (SplitRegister *reg,
|
||||
SplitRegisterType type,
|
||||
SplitRegisterStyle style);
|
||||
void xaccDestroySplitRegister (SplitRegister *reg);
|
||||
|
||||
void xaccSetSplitRegisterColors (SplitRegisterColors reg_colors);
|
||||
void xaccSplitRegisterConfigColors (SplitRegister *reg);
|
||||
|
||||
/* returns non-zero value if updates have been made to data */
|
||||
unsigned int xaccSplitRegisterGetChangeFlag (SplitRegister *);
|
||||
unsigned int xaccSplitRegisterGetChangeFlag (SplitRegister *reg);
|
||||
|
||||
/* Clears all change flags in the register. Does not alter values */
|
||||
void xaccSplitRegisterClearChangeFlag (SplitRegister *reg);
|
||||
|
Loading…
Reference in New Issue
Block a user