mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-09-03 20:53:02 -05:00
Move all split-register code from register-core to ledger-core.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5272 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
+4
-2
@@ -121,6 +121,7 @@ src/engine/test/test-split-vs-account.c
|
||||
src/engine/test/test-freq-spec.c
|
||||
src/engine/test/test-scm-query.c
|
||||
src/engine/test/test-group-vs-book.c
|
||||
src/engine/SX-ttinfo.c
|
||||
src/engine/kvp-scm.c
|
||||
src/engine/test-core/test-engine-stuff.c
|
||||
src/engine/test-core/gncmod-test-engine.c
|
||||
@@ -218,6 +219,7 @@ src/gnome/window-register.c
|
||||
src/gnome/window-report.c
|
||||
src/gnome/argv-list-converters.c
|
||||
src/gnome/file-utils.c
|
||||
src/gnome/dialog-sx-from-trans.c
|
||||
src/guile/guile-util.c
|
||||
src/guile/tip-of-the-day.c
|
||||
src/import-export/qif-import/dialog-account-picker.c
|
||||
@@ -237,8 +239,8 @@ src/register/ledger-core/gnc-ledger-display.c
|
||||
src/register/ledger-core/split-register-model.c
|
||||
src/register/ledger-core/split-register-model-save.c
|
||||
src/register/ledger-core/split-register-load.c
|
||||
src/register/ledger-core/split-register-layout.c
|
||||
src/register/register-core/QuickFill.c
|
||||
src/register/register-core/basiccell.c
|
||||
src/register/register-core/cell-factory.c
|
||||
src/register/register-core/cellblock.c
|
||||
src/register/register-core/gncmod-register-core.c
|
||||
@@ -248,12 +250,12 @@ src/register/register-core/pricecell.c
|
||||
src/register/register-core/quickfillcell.c
|
||||
src/register/register-core/recncell.c
|
||||
src/register/register-core/register-common.c
|
||||
src/register/register-core/splitreg.c
|
||||
src/register/register-core/table-allgui.c
|
||||
src/register/register-core/table-control.c
|
||||
src/register/register-core/table-html.c
|
||||
src/register/register-core/table-layout.c
|
||||
src/register/register-core/table-model.c
|
||||
src/register/register-core/basiccell.c
|
||||
src/register/register-gnome/combocell-gnome.c
|
||||
src/register/register-gnome/datecell-gnome.c
|
||||
src/register/register-gnome/gncmod-register-gnome.c
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include "gnc-ledger-display.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "messages.h"
|
||||
#include "splitreg.h"
|
||||
#include "window-help.h"
|
||||
#include "window-register.h"
|
||||
|
||||
|
||||
@@ -710,9 +710,9 @@ schedXact_editor_create_ledger( SchedXactionEditorDialog *sxed )
|
||||
|
||||
/* configure... */
|
||||
/* don't use double-line */
|
||||
xaccConfigSplitRegister(splitreg,
|
||||
splitreg->type, splitreg->style,
|
||||
FALSE );
|
||||
gnc_split_register_config(splitreg,
|
||||
splitreg->type, splitreg->style,
|
||||
FALSE );
|
||||
/* don't show present/future divider [by definition, not necessary] */
|
||||
xaccSRShowPresentDivider( splitreg, FALSE );
|
||||
|
||||
@@ -1230,7 +1230,7 @@ sxed_reg_deleteCB( GtkWidget *w, gpointer d )
|
||||
|
||||
trans = xaccSplitGetParent(split);
|
||||
style = reg->style;
|
||||
cursor_class = xaccSplitRegisterGetCurrentCursorClass(reg);
|
||||
cursor_class = gnc_split_register_get_current_cursor_class(reg);
|
||||
|
||||
/* Deleting the blank split just cancels */
|
||||
{
|
||||
|
||||
@@ -63,7 +63,6 @@
|
||||
#include "guile-util.h"
|
||||
#include "messages.h"
|
||||
#include "recncell.h"
|
||||
#include "splitreg.h"
|
||||
#include "split-register.h"
|
||||
#include "top-level.h"
|
||||
#include "window-help.h"
|
||||
|
||||
@@ -293,7 +293,7 @@ gnc_register_change_style (RegWindow *regData, SplitRegisterStyle style)
|
||||
if (style == reg->style)
|
||||
return;
|
||||
|
||||
xaccConfigSplitRegister (reg, reg->type, style, reg->use_double_line);
|
||||
gnc_split_register_config (reg, reg->type, style, reg->use_double_line);
|
||||
|
||||
xaccLedgerDisplayRefresh (regData->ledger);
|
||||
}
|
||||
@@ -343,7 +343,7 @@ gnc_register_double_line_cb (GtkWidget *w, gpointer data)
|
||||
if (use_double_line == reg->use_double_line)
|
||||
return;
|
||||
|
||||
xaccConfigSplitRegister (reg, reg->type, reg->style, use_double_line);
|
||||
gnc_split_register_config (reg, reg->type, reg->style, use_double_line);
|
||||
|
||||
xaccLedgerDisplayRefresh (regData->ledger);
|
||||
}
|
||||
@@ -1781,7 +1781,7 @@ gnc_register_match_trans_row (VirtualLocation virt_loc,
|
||||
SplitRegister *sr;
|
||||
|
||||
sr = xaccLedgerDisplayGetSR (regData->ledger);
|
||||
cursor_class = xaccSplitRegisterGetCursorClass (sr, virt_loc.vcell_loc);
|
||||
cursor_class = gnc_split_register_get_cursor_class (sr, virt_loc.vcell_loc);
|
||||
|
||||
return (cursor_class == CURSOR_CLASS_TRANS);
|
||||
}
|
||||
@@ -2202,7 +2202,7 @@ regWindowLedger (xaccLedgerDisplay *ledger)
|
||||
FALSE);
|
||||
|
||||
/* be sure to initialize the gui elements associated with the cursor */
|
||||
xaccConfigSplitRegister (reg, reg->type, reg->style, use_double_line);
|
||||
gnc_split_register_config (reg, reg->type, reg->style, use_double_line);
|
||||
|
||||
check = GTK_CHECK_MENU_ITEM (regData->double_line_check);
|
||||
|
||||
@@ -3013,7 +3013,7 @@ deleteCB(GtkWidget *widget, gpointer data)
|
||||
|
||||
trans = xaccSplitGetParent(split);
|
||||
style = reg->style;
|
||||
cursor_class = xaccSplitRegisterGetCurrentCursorClass(reg);
|
||||
cursor_class = gnc_split_register_get_current_cursor_class (reg);
|
||||
|
||||
/* Deleting the blank split just cancels */
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ libgncmod_ledger_core_la_SOURCES = \
|
||||
gncmod-ledger-core.c \
|
||||
split-register.c \
|
||||
split-register-control.c \
|
||||
split-register-layout.c \
|
||||
split-register-load.c \
|
||||
split-register-model.c \
|
||||
split-register-model-save.c \
|
||||
@@ -15,6 +16,7 @@ noinst_HEADERS = \
|
||||
RegWindow.h \
|
||||
split-register.h \
|
||||
split-register-control.h \
|
||||
split-register-layout.h \
|
||||
split-register-model.h \
|
||||
split-register-model-save.h \
|
||||
split-register-p.h
|
||||
|
||||
@@ -55,9 +55,6 @@ struct _xaccLedgerDisplay
|
||||
|
||||
SplitRegister *reg;
|
||||
|
||||
TableControl *control;
|
||||
TableModel *model;
|
||||
|
||||
gboolean loading;
|
||||
|
||||
LedgerDisplayDestroy destroy;
|
||||
@@ -561,18 +558,12 @@ close_handler (gpointer user_data)
|
||||
if (ld->destroy)
|
||||
ld->destroy (ld);
|
||||
|
||||
xaccDestroySplitRegister (ld->reg);
|
||||
gnc_split_register_destroy (ld->reg);
|
||||
ld->reg = NULL;
|
||||
|
||||
xaccFreeQuery (ld->query);
|
||||
ld->query = NULL;
|
||||
|
||||
gnc_table_control_destroy (ld->control);
|
||||
ld->control = NULL;
|
||||
|
||||
gnc_table_model_destroy (ld->model);
|
||||
ld->model = NULL;
|
||||
|
||||
g_free (ld);
|
||||
}
|
||||
|
||||
@@ -757,17 +748,7 @@ xaccLedgerDisplayInternal (Account *lead_account, Query *q,
|
||||
* The main register window itself *
|
||||
\******************************************************************/
|
||||
|
||||
if (templateMode)
|
||||
ld->model = gnc_template_register_model_new ();
|
||||
else
|
||||
ld->model = gnc_split_register_model_new ();
|
||||
|
||||
ld->control = gnc_split_register_control_new ();
|
||||
|
||||
ld->reg = gnc_register_new (reg_type, style, FALSE,
|
||||
ld->control, ld->model, templateMode);
|
||||
|
||||
ld->control->user_data = ld->reg;
|
||||
ld->reg = gnc_split_register_new (reg_type, style, FALSE, templateMode);
|
||||
|
||||
xaccSRSetData (ld->reg, ld, xaccLedgerDisplayParent);
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
|
||||
#include "Account.h"
|
||||
#include "Query.h"
|
||||
#include "splitreg.h"
|
||||
#include "split-register.h"
|
||||
#include "SchedXaction.h"
|
||||
#include "Transaction.h"
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include "split-register-control.h"
|
||||
#include "split-register-model-save.h"
|
||||
#include "split-register-p.h"
|
||||
#include "splitreg.h"
|
||||
#include "table-allgui.h"
|
||||
|
||||
|
||||
@@ -205,7 +204,7 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc,
|
||||
old_split = xaccSRGetCurrentSplit (reg);
|
||||
old_trans = xaccSRGetCurrentTrans (reg);
|
||||
old_trans_split = xaccSRGetCurrentTransSplit (reg, &old_trans_split_loc);
|
||||
old_class = xaccSplitRegisterGetCurrentCursorClass (reg);
|
||||
old_class = gnc_split_register_get_current_cursor_class (reg);
|
||||
|
||||
exact_traversal = info->exact_traversal;
|
||||
|
||||
@@ -231,7 +230,8 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc,
|
||||
/* The split at the transaction line we are moving to */
|
||||
new_trans_split = xaccSRGetTransSplit (reg, new_virt_loc.vcell_loc, NULL);
|
||||
|
||||
new_class = xaccSplitRegisterGetCursorClass (reg, new_virt_loc.vcell_loc);
|
||||
new_class = gnc_split_register_get_cursor_class (reg,
|
||||
new_virt_loc.vcell_loc);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -320,7 +320,8 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc,
|
||||
new_trans = xaccSRGetTrans (reg, new_virt_loc.vcell_loc);
|
||||
new_split = sr_get_split (reg, new_virt_loc.vcell_loc);
|
||||
new_trans_split = xaccSRGetTransSplit (reg, new_virt_loc.vcell_loc, NULL);
|
||||
new_class = xaccSplitRegisterGetCursorClass (reg, new_virt_loc.vcell_loc);
|
||||
new_class = gnc_split_register_get_cursor_class (reg,
|
||||
new_virt_loc.vcell_loc);
|
||||
}
|
||||
else if (info->traverse_to_new)
|
||||
{
|
||||
@@ -557,7 +558,7 @@ gnc_split_register_auto_completion (SplitRegister *reg,
|
||||
if (trans == NULL)
|
||||
return FALSE;
|
||||
|
||||
cursor_class = xaccSplitRegisterGetCurrentCursorClass (reg);
|
||||
cursor_class = gnc_split_register_get_current_cursor_class (reg);
|
||||
cell_name = gnc_table_get_current_cell_name (reg->table);
|
||||
|
||||
switch (cursor_class)
|
||||
@@ -1048,7 +1049,8 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc,
|
||||
|
||||
new_split = sr_get_split (reg, virt_loc.vcell_loc);
|
||||
trans_split = xaccSRGetTransSplit (reg, virt_loc.vcell_loc, NULL);
|
||||
new_class = xaccSplitRegisterGetCursorClass (reg, virt_loc.vcell_loc);
|
||||
new_class = gnc_split_register_get_cursor_class (reg,
|
||||
virt_loc.vcell_loc);
|
||||
|
||||
xaccSRCancelCursorTransChanges (reg);
|
||||
|
||||
|
||||
@@ -0,0 +1,601 @@
|
||||
/********************************************************************\
|
||||
* split-register-layout.c -- split register layout object *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "gnc-engine-util.h"
|
||||
#include "messages.h"
|
||||
#include "split-register-layout.h"
|
||||
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_REGISTER;
|
||||
|
||||
|
||||
static void
|
||||
gnc_register_add_cell (TableLayout *layout,
|
||||
const char *cell_name,
|
||||
const char *cell_type_name,
|
||||
const char *sample_text,
|
||||
CellAlignment alignment,
|
||||
gboolean expandable,
|
||||
gboolean span)
|
||||
{
|
||||
BasicCell *cell;
|
||||
|
||||
g_return_if_fail (layout != NULL);
|
||||
g_return_if_fail (cell_type_name != NULL);
|
||||
|
||||
cell = gnc_register_make_cell (cell_type_name);
|
||||
|
||||
gnc_basic_cell_set_name (cell, cell_name);
|
||||
gnc_basic_cell_set_sample_text (cell, sample_text);
|
||||
gnc_basic_cell_set_alignment (cell, alignment);
|
||||
gnc_basic_cell_set_expandable (cell, expandable);
|
||||
gnc_basic_cell_set_span (cell, span);
|
||||
|
||||
gnc_table_layout_add_cell (layout, cell);
|
||||
}
|
||||
|
||||
static void
|
||||
copy_cursor_row (TableLayout *layout, CellBlock *to, CellBlock *from, int row)
|
||||
{
|
||||
int col;
|
||||
|
||||
for (col = 0; col < from->num_cols; col++)
|
||||
{
|
||||
BasicCell *cell;
|
||||
|
||||
cell = gnc_cellblock_get_cell (from, row, col);
|
||||
if (!cell || !cell->cell_name)
|
||||
continue;
|
||||
|
||||
gnc_table_layout_set_cell (layout, to, cell->cell_name, row, col);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
|
||||
{
|
||||
CellBlock *curs;
|
||||
CellBlock *curs_last;
|
||||
|
||||
switch (reg->type)
|
||||
{
|
||||
case BANK_REGISTER:
|
||||
case CASH_REGISTER:
|
||||
case ASSET_REGISTER:
|
||||
case CREDIT_REGISTER:
|
||||
case LIABILITY_REGISTER:
|
||||
case INCOME_REGISTER:
|
||||
case EXPENSE_REGISTER:
|
||||
case EQUITY_REGISTER:
|
||||
{
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_SINGLE_LEDGER);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
|
||||
gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, MXFRM_CELL, 0, 3);
|
||||
gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
|
||||
if (reg->template)
|
||||
{
|
||||
gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
|
||||
}
|
||||
gnc_table_layout_set_cell (layout, curs, BALN_CELL, 0, 7);
|
||||
|
||||
curs_last = curs;
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_DOUBLE_LEDGER);
|
||||
|
||||
copy_cursor_row (layout, curs, curs_last, 0);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 1, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
|
||||
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_SINGLE_JOURNAL);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
|
||||
gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0, 6);
|
||||
gnc_table_layout_set_cell (layout, curs, TBALN_CELL, 0, 7);
|
||||
|
||||
curs_last = curs;
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_DOUBLE_JOURNAL);
|
||||
|
||||
copy_cursor_row (layout, curs, curs_last, 0);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
|
||||
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_SPLIT);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 0, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 0, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, XFRM_CELL, 0, 3);
|
||||
gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
|
||||
if (reg->template)
|
||||
{
|
||||
gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------- */
|
||||
case INCOME_LEDGER:
|
||||
case GENERAL_LEDGER:
|
||||
case SEARCH_LEDGER:
|
||||
{
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_SINGLE_LEDGER);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
|
||||
gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, MXFRM_CELL, 0, 3);
|
||||
gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
|
||||
if (reg->template)
|
||||
{
|
||||
gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
|
||||
}
|
||||
|
||||
curs_last = curs;
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_DOUBLE_LEDGER);
|
||||
|
||||
copy_cursor_row (layout, curs, curs_last, 0);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 1, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
|
||||
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_SINGLE_JOURNAL);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
|
||||
gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0, 6);
|
||||
|
||||
curs_last = curs;
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_DOUBLE_JOURNAL);
|
||||
|
||||
copy_cursor_row (layout, curs, curs_last, 0);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
|
||||
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_SPLIT);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 0, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 0, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, XFRM_CELL, 0, 3);
|
||||
gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
|
||||
if (reg->template)
|
||||
{
|
||||
gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------- */
|
||||
case STOCK_REGISTER:
|
||||
case CURRENCY_REGISTER:
|
||||
{
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_SINGLE_LEDGER);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
|
||||
gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, MXFRM_CELL, 0, 3);
|
||||
gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
|
||||
gnc_table_layout_set_cell (layout, curs, SHRS_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, PRIC_CELL, 0, 6);
|
||||
gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 7);
|
||||
gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 8);
|
||||
gnc_table_layout_set_cell (layout, curs, BALN_CELL, 0, 9);
|
||||
|
||||
curs_last = curs;
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_DOUBLE_LEDGER);
|
||||
|
||||
copy_cursor_row (layout, curs, curs_last, 0);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 1, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
|
||||
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_SINGLE_JOURNAL);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
|
||||
gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, TSHRS_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0, 7);
|
||||
gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0, 8);
|
||||
gnc_table_layout_set_cell (layout, curs, TBALN_CELL, 0, 9);
|
||||
|
||||
curs_last = curs;
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_DOUBLE_JOURNAL);
|
||||
|
||||
copy_cursor_row (layout, curs, curs_last, 0);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
|
||||
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_SPLIT);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 0, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 0, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, XFRM_CELL, 0, 3);
|
||||
gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
|
||||
gnc_table_layout_set_cell (layout, curs, SHRS_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, PRIC_CELL, 0, 6);
|
||||
gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 7);
|
||||
gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 8);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------- */
|
||||
case PORTFOLIO_LEDGER:
|
||||
{
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_SINGLE_LEDGER);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
|
||||
gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, MXFRM_CELL, 0, 3);
|
||||
gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
|
||||
gnc_table_layout_set_cell (layout, curs, SHRS_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, PRIC_CELL, 0, 6);
|
||||
gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 7);
|
||||
gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 8);
|
||||
|
||||
curs_last = curs;
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_DOUBLE_LEDGER);
|
||||
|
||||
copy_cursor_row (layout, curs, curs_last, 0);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 1, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
|
||||
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_SINGLE_JOURNAL);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, DATE_CELL, 0, 0);
|
||||
gnc_table_layout_set_cell (layout, curs, NUM_CELL, 0, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, DESC_CELL, 0, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, TSHRS_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0, 7);
|
||||
gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0, 8);
|
||||
|
||||
curs_last = curs;
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_DOUBLE_JOURNAL);
|
||||
|
||||
copy_cursor_row (layout, curs, curs_last, 0);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, NOTES_CELL, 1, 2);
|
||||
|
||||
curs = gnc_table_layout_get_cursor (layout,
|
||||
CURSOR_SPLIT);
|
||||
|
||||
gnc_table_layout_set_cell (layout, curs, ACTN_CELL, 0, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, MEMO_CELL, 0, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, XFRM_CELL, 0, 3);
|
||||
gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
|
||||
gnc_table_layout_set_cell (layout, curs, SHRS_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, PRIC_CELL, 0, 6);
|
||||
gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 7);
|
||||
gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 8);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------- */
|
||||
default:
|
||||
PERR ("unknown register type %d \n", reg->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_split_register_layout_add_cursors (SplitRegister *reg,
|
||||
TableLayout *layout)
|
||||
{
|
||||
CellBlock *cursor;
|
||||
int num_cols;
|
||||
|
||||
switch (reg->type)
|
||||
{
|
||||
case BANK_REGISTER:
|
||||
case CASH_REGISTER:
|
||||
case ASSET_REGISTER:
|
||||
case CREDIT_REGISTER:
|
||||
case LIABILITY_REGISTER:
|
||||
case INCOME_REGISTER:
|
||||
case EXPENSE_REGISTER:
|
||||
case EQUITY_REGISTER:
|
||||
num_cols = 8;
|
||||
break;
|
||||
|
||||
case INCOME_LEDGER:
|
||||
case GENERAL_LEDGER:
|
||||
case SEARCH_LEDGER:
|
||||
num_cols = 7;
|
||||
break;
|
||||
|
||||
case STOCK_REGISTER:
|
||||
case CURRENCY_REGISTER:
|
||||
num_cols = 11;
|
||||
break;
|
||||
|
||||
case PORTFOLIO_LEDGER:
|
||||
num_cols = 9;
|
||||
break;
|
||||
|
||||
default:
|
||||
PERR("Bad register type");
|
||||
g_assert (FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
cursor = gnc_cellblock_new (1, num_cols, CURSOR_HEADER);
|
||||
gnc_table_layout_add_cursor (layout, cursor);
|
||||
|
||||
/* cursors used in ledger mode */
|
||||
cursor = gnc_cellblock_new (1, num_cols, CURSOR_SINGLE_LEDGER);
|
||||
gnc_table_layout_add_cursor (layout, cursor);
|
||||
|
||||
gnc_table_layout_set_primary_cursor (layout, cursor);
|
||||
|
||||
cursor = gnc_cellblock_new (2, num_cols, CURSOR_DOUBLE_LEDGER);
|
||||
gnc_table_layout_add_cursor (layout, cursor);
|
||||
|
||||
/* cursors used for journal mode */
|
||||
cursor = gnc_cellblock_new (1, num_cols, CURSOR_SINGLE_JOURNAL);
|
||||
gnc_table_layout_add_cursor (layout, cursor);
|
||||
|
||||
cursor = gnc_cellblock_new (2, num_cols, CURSOR_DOUBLE_JOURNAL);
|
||||
gnc_table_layout_add_cursor (layout, cursor);
|
||||
|
||||
cursor = gnc_cellblock_new (1, num_cols, CURSOR_SPLIT);
|
||||
gnc_table_layout_add_cursor (layout, cursor);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_split_register_layout_add_cells (SplitRegister *reg,
|
||||
TableLayout *layout)
|
||||
{
|
||||
gnc_register_add_cell (layout,
|
||||
DATE_CELL,
|
||||
DATE_CELL_TYPE_NAME,
|
||||
N_("sample:12/12/2000") + 7,
|
||||
CELL_ALIGN_RIGHT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
NUM_CELL,
|
||||
NUM_CELL_TYPE_NAME,
|
||||
N_("sample:99999") + 7,
|
||||
CELL_ALIGN_LEFT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
DESC_CELL,
|
||||
QUICKFILL_CELL_TYPE_NAME,
|
||||
N_("sample:Description of a transaction") + 7,
|
||||
CELL_ALIGN_LEFT,
|
||||
TRUE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
RECN_CELL,
|
||||
RECN_CELL_TYPE_NAME,
|
||||
N_("Reconciled:R") + 11,
|
||||
CELL_ALIGN_CENTER,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
BALN_CELL,
|
||||
PRICE_CELL_TYPE_NAME,
|
||||
N_("sample:999,999.000") + 7,
|
||||
CELL_ALIGN_RIGHT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
XFRM_CELL,
|
||||
COMBO_CELL_TYPE_NAME,
|
||||
N_("Transfer"),
|
||||
CELL_ALIGN_LEFT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
MXFRM_CELL,
|
||||
COMBO_CELL_TYPE_NAME,
|
||||
N_("sample:Expenses:Automobile:Gasoline") + 7,
|
||||
CELL_ALIGN_RIGHT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
ACTN_CELL,
|
||||
COMBO_CELL_TYPE_NAME,
|
||||
N_("sample:Expenses:Automobile:Gasoline") + 7,
|
||||
CELL_ALIGN_RIGHT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
MEMO_CELL,
|
||||
QUICKFILL_CELL_TYPE_NAME,
|
||||
N_("sample:Memo field sample text string") + 7,
|
||||
CELL_ALIGN_LEFT,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
DEBT_CELL,
|
||||
PRICE_CELL_TYPE_NAME,
|
||||
N_("sample:999,999.000") + 7,
|
||||
CELL_ALIGN_RIGHT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
CRED_CELL,
|
||||
PRICE_CELL_TYPE_NAME,
|
||||
N_("sample:999,999.000") + 7,
|
||||
CELL_ALIGN_RIGHT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
PRIC_CELL,
|
||||
PRICE_CELL_TYPE_NAME,
|
||||
N_("sample:999,999.000") + 7,
|
||||
CELL_ALIGN_RIGHT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
SHRS_CELL,
|
||||
PRICE_CELL_TYPE_NAME,
|
||||
N_("sample:999,999.000") + 7,
|
||||
CELL_ALIGN_RIGHT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
TDEBT_CELL,
|
||||
PRICE_CELL_TYPE_NAME,
|
||||
N_("sample:999,999.000") + 7,
|
||||
CELL_ALIGN_RIGHT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
TCRED_CELL,
|
||||
PRICE_CELL_TYPE_NAME,
|
||||
N_("sample:999,999.000") + 7,
|
||||
CELL_ALIGN_RIGHT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
TSHRS_CELL,
|
||||
PRICE_CELL_TYPE_NAME,
|
||||
N_("sample:999,999.000") + 7,
|
||||
CELL_ALIGN_RIGHT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
TBALN_CELL,
|
||||
PRICE_CELL_TYPE_NAME,
|
||||
N_("sample:999,999.000") + 7,
|
||||
CELL_ALIGN_RIGHT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
NOTES_CELL,
|
||||
QUICKFILL_CELL_TYPE_NAME,
|
||||
N_("sample:Notes field sample text string") + 7,
|
||||
CELL_ALIGN_LEFT,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
FCRED_CELL,
|
||||
QUICKFILL_CELL_TYPE_NAME,
|
||||
N_("sample:(x + 0.33 * y + (x+y) )") + 7,
|
||||
CELL_ALIGN_LEFT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
|
||||
gnc_register_add_cell (layout,
|
||||
FDEBT_CELL,
|
||||
QUICKFILL_CELL_TYPE_NAME,
|
||||
N_("sample:(x + 0.33 * y + (x+y) )") + 7,
|
||||
CELL_ALIGN_LEFT,
|
||||
FALSE,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
TableLayout *
|
||||
gnc_split_register_layout_new (SplitRegister *reg)
|
||||
{
|
||||
TableLayout *layout;
|
||||
|
||||
layout = gnc_table_layout_new ();
|
||||
|
||||
gnc_split_register_layout_add_cells (reg, layout);
|
||||
gnc_split_register_layout_add_cursors (reg, layout);
|
||||
gnc_split_register_set_cells (reg, layout);
|
||||
|
||||
return layout;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/********************************************************************\
|
||||
* split-register-layout.h -- split register layout object *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#ifndef SPLIT_REGISTER_LAYOUT_H
|
||||
#define SPLIT_REGISTER_LAYOUT_H
|
||||
|
||||
#include "table-layout.h"
|
||||
#include "split-register.h"
|
||||
|
||||
TableLayout * gnc_split_register_layout_new (SplitRegister *reg);
|
||||
|
||||
#endif
|
||||
@@ -470,7 +470,8 @@ xaccSRLoadRegister (SplitRegister *reg, GList * slist,
|
||||
info->cursor_hint_trans = xaccSRGetCurrentTrans (reg);
|
||||
info->cursor_hint_split = xaccSRGetCurrentSplit (reg);
|
||||
info->cursor_hint_trans_split = xaccSRGetCurrentTransSplit (reg, NULL);
|
||||
info->cursor_hint_cursor_class = xaccSplitRegisterGetCurrentCursorClass(reg);
|
||||
info->cursor_hint_cursor_class =
|
||||
gnc_split_register_get_current_cursor_class(reg);
|
||||
info->hint_set_by_traverse = FALSE;
|
||||
info->traverse_to_new = FALSE;
|
||||
info->exact_traversal = FALSE;
|
||||
|
||||
@@ -72,8 +72,8 @@ use_security_cells (SplitRegister *reg, VirtualLocation virt_loc)
|
||||
if (!split)
|
||||
return TRUE;
|
||||
|
||||
cursor_class = xaccSplitRegisterGetCursorClass (reg,
|
||||
virt_loc.vcell_loc);
|
||||
cursor_class = gnc_split_register_get_cursor_class (reg,
|
||||
virt_loc.vcell_loc);
|
||||
if (cursor_class != CURSOR_CLASS_SPLIT)
|
||||
return TRUE;
|
||||
|
||||
@@ -573,7 +573,8 @@ gnc_split_register_get_border (VirtualLocation virt_loc,
|
||||
return;
|
||||
}
|
||||
|
||||
cursor_class = xaccCursorNameToClass (vcell->cellblock->cursor_name);
|
||||
cursor_class =
|
||||
gnc_split_register_cursor_name_to_class (vcell->cellblock->cursor_name);
|
||||
|
||||
if (cursor_class == CURSOR_CLASS_TRANS &&
|
||||
virt_loc.phys_col_offset == vcell->cellblock->start_col)
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "Group.h"
|
||||
#include "gnc-ledger-display.h"
|
||||
#include "splitreg.h"
|
||||
#include "split-register.h"
|
||||
|
||||
|
||||
#define SPLIT_TRANS_STR _("-- Split Transaction --")
|
||||
@@ -144,4 +144,6 @@ gboolean gnc_split_register_recn_cell_confirm (char old_flag, gpointer data);
|
||||
|
||||
void LedgerDestroy (SplitRegister *reg);
|
||||
|
||||
CursorClass gnc_split_register_cursor_name_to_class (const char *cursor_name);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "global-options.h"
|
||||
#include "gnc-engine-util.h"
|
||||
@@ -171,7 +172,7 @@ xaccSRGetTransSplit (SplitRegister *reg,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor_class = xaccSplitRegisterGetCursorClass (reg, vcell_loc);
|
||||
cursor_class = gnc_split_register_get_cursor_class (reg, vcell_loc);
|
||||
|
||||
if (cursor_class == CURSOR_CLASS_TRANS)
|
||||
{
|
||||
@@ -222,7 +223,7 @@ xaccSRFindSplit (SplitRegister *reg,
|
||||
s = sr_get_split (reg, vc_loc);
|
||||
t = xaccSplitGetParent(s);
|
||||
|
||||
cursor_class = xaccSplitRegisterGetCursorClass(reg, vc_loc);
|
||||
cursor_class = gnc_split_register_get_cursor_class (reg, vc_loc);
|
||||
|
||||
if (t == trans)
|
||||
found_trans = TRUE;
|
||||
@@ -266,7 +267,7 @@ xaccSRShowTrans (SplitRegister *reg,
|
||||
VirtualCellLocation vc_loc = { v_row, 0 };
|
||||
CursorClass cursor_class;
|
||||
|
||||
cursor_class = xaccSplitRegisterGetCursorClass (reg, vc_loc);
|
||||
cursor_class = gnc_split_register_get_cursor_class (reg, vc_loc);
|
||||
if (cursor_class == CURSOR_CLASS_TRANS)
|
||||
break;
|
||||
|
||||
@@ -294,7 +295,7 @@ xaccSRSetTransVisible (SplitRegister *reg,
|
||||
{
|
||||
vcell_loc.virt_row++;
|
||||
|
||||
cursor_class = xaccSplitRegisterGetCursorClass (reg, vcell_loc);
|
||||
cursor_class = gnc_split_register_get_cursor_class (reg, vcell_loc);
|
||||
if (cursor_class != CURSOR_CLASS_SPLIT)
|
||||
return;
|
||||
|
||||
@@ -415,3 +416,67 @@ sr_set_last_num (SplitRegister *reg, const char *num)
|
||||
|
||||
xaccAccountSetLastNum (account, num);
|
||||
}
|
||||
|
||||
static CursorClass
|
||||
gnc_split_register_cursor_class (SplitRegister *reg,
|
||||
CellBlock *cursor)
|
||||
{
|
||||
if (cursor == NULL)
|
||||
return CURSOR_CLASS_NONE;
|
||||
|
||||
return gnc_split_register_cursor_name_to_class (cursor->cursor_name);
|
||||
}
|
||||
|
||||
CursorClass
|
||||
gnc_split_register_get_cursor_class (SplitRegister *reg,
|
||||
VirtualCellLocation vcell_loc)
|
||||
{
|
||||
VirtualCell *vcell;
|
||||
Table *table;
|
||||
|
||||
if (reg == NULL)
|
||||
return CURSOR_CLASS_NONE;
|
||||
|
||||
table = reg->table;
|
||||
if (table == NULL)
|
||||
return CURSOR_CLASS_NONE;
|
||||
|
||||
vcell = gnc_table_get_virtual_cell (table, vcell_loc);
|
||||
if (vcell == NULL)
|
||||
return CURSOR_CLASS_NONE;
|
||||
|
||||
return gnc_split_register_cursor_class (reg, vcell->cellblock);
|
||||
}
|
||||
|
||||
CursorClass
|
||||
gnc_split_register_get_current_cursor_class (SplitRegister *reg)
|
||||
{
|
||||
Table *table;
|
||||
|
||||
if (reg == NULL)
|
||||
return CURSOR_CLASS_NONE;
|
||||
|
||||
table = reg->table;
|
||||
if (table == NULL)
|
||||
return CURSOR_CLASS_NONE;
|
||||
|
||||
return gnc_split_register_cursor_class (reg, table->current_cursor);
|
||||
}
|
||||
|
||||
CursorClass
|
||||
gnc_split_register_cursor_name_to_class (const char *cursor_name)
|
||||
{
|
||||
if (cursor_name == NULL)
|
||||
return CURSOR_CLASS_NONE;
|
||||
|
||||
if (strcmp (cursor_name, CURSOR_SINGLE_LEDGER) == 0 ||
|
||||
strcmp (cursor_name, CURSOR_DOUBLE_LEDGER) == 0 ||
|
||||
strcmp (cursor_name, CURSOR_SINGLE_JOURNAL) == 0 ||
|
||||
strcmp (cursor_name, CURSOR_DOUBLE_JOURNAL) == 0)
|
||||
return CURSOR_CLASS_TRANS;
|
||||
|
||||
if (strcmp (cursor_name, CURSOR_SPLIT) == 0)
|
||||
return CURSOR_CLASS_SPLIT;
|
||||
|
||||
return CURSOR_CLASS_NONE;
|
||||
}
|
||||
|
||||
@@ -122,8 +122,10 @@
|
||||
#include "pricecell.h"
|
||||
#include "quickfillcell.h"
|
||||
#include "recncell.h"
|
||||
#include "splitreg.h"
|
||||
#include "split-register.h"
|
||||
#include "split-register-control.h"
|
||||
#include "split-register-layout.h"
|
||||
#include "split-register-model.h"
|
||||
#include "split-register-model-save.h"
|
||||
#include "table-allgui.h"
|
||||
|
||||
@@ -486,7 +488,7 @@ xaccSRGetSplitAmountVirtLoc (SplitRegister *reg, Split *split,
|
||||
if (!xaccSRGetSplitVirtLoc (reg, split, &v_loc.vcell_loc))
|
||||
return FALSE;
|
||||
|
||||
cursor_class = xaccSplitRegisterGetCursorClass (reg, v_loc.vcell_loc);
|
||||
cursor_class = gnc_split_register_get_cursor_class (reg, v_loc.vcell_loc);
|
||||
|
||||
value = xaccSplitGetValue (split);
|
||||
|
||||
@@ -532,7 +534,7 @@ xaccSRDuplicateCurrent (SplitRegister *reg)
|
||||
if (trans == NULL)
|
||||
return NULL;
|
||||
|
||||
cursor_class = xaccSplitRegisterGetCurrentCursorClass (reg);
|
||||
cursor_class = gnc_split_register_get_current_cursor_class (reg);
|
||||
|
||||
/* Can't do anything with this. */
|
||||
if (cursor_class == CURSOR_CLASS_NONE)
|
||||
@@ -693,7 +695,7 @@ xaccSRCopyCurrentInternal (SplitRegister *reg, gboolean use_cut_semantics)
|
||||
if (trans == NULL)
|
||||
return;
|
||||
|
||||
cursor_class = xaccSplitRegisterGetCurrentCursorClass (reg);
|
||||
cursor_class = gnc_split_register_get_current_cursor_class (reg);
|
||||
|
||||
/* Can't do anything with this. */
|
||||
if (cursor_class == CURSOR_CLASS_NONE)
|
||||
@@ -786,7 +788,7 @@ xaccSRCutCurrent (SplitRegister *reg)
|
||||
if (trans == NULL)
|
||||
return;
|
||||
|
||||
cursor_class = xaccSplitRegisterGetCurrentCursorClass (reg);
|
||||
cursor_class = gnc_split_register_get_current_cursor_class (reg);
|
||||
|
||||
/* Can't do anything with this. */
|
||||
if (cursor_class == CURSOR_CLASS_NONE)
|
||||
@@ -832,7 +834,7 @@ xaccSRPasteCurrent (SplitRegister *reg)
|
||||
if (trans == NULL)
|
||||
return;
|
||||
|
||||
cursor_class = xaccSplitRegisterGetCurrentCursorClass (reg);
|
||||
cursor_class = gnc_split_register_get_current_cursor_class (reg);
|
||||
|
||||
/* Can't do anything with this. */
|
||||
if (cursor_class == CURSOR_CLASS_NONE)
|
||||
@@ -1928,3 +1930,358 @@ xaccSRFullRefreshOK (SplitRegister *reg)
|
||||
|
||||
return info->full_refresh;
|
||||
}
|
||||
|
||||
/* configAction strings into the action cell */
|
||||
/* hack alert -- this stuff really, really should be in a config file ... */
|
||||
static void
|
||||
gnc_split_register_config_action (SplitRegister *reg)
|
||||
{
|
||||
ComboCell *cell;
|
||||
|
||||
cell = (ComboCell *) gnc_table_layout_get_cell (reg->table->layout,
|
||||
ACTN_CELL);
|
||||
|
||||
/* setup strings in the action pull-down */
|
||||
switch (reg->type)
|
||||
{
|
||||
case BANK_REGISTER:
|
||||
/* broken ! FIXME bg */
|
||||
case SEARCH_LEDGER:
|
||||
gnc_combo_cell_add_menu_item (cell, _("Deposit"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Withdraw"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Check"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Int"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("ATM"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Teller"));
|
||||
/* Action: Point Of Sale */
|
||||
gnc_combo_cell_add_menu_item (cell, _("POS"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Phone"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Online"));
|
||||
/* Action: Automatic Deposit ?!? */
|
||||
gnc_combo_cell_add_menu_item (cell, _("AutoDep"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Wire"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Credit"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Direct Debit"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Transfer"));
|
||||
break;
|
||||
case CASH_REGISTER:
|
||||
gnc_combo_cell_add_menu_item (cell, _("Buy"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Sell"));
|
||||
break;
|
||||
case ASSET_REGISTER:
|
||||
gnc_combo_cell_add_menu_item (cell, _("Buy"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Sell"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Fee"));
|
||||
break;
|
||||
case CREDIT_REGISTER:
|
||||
gnc_combo_cell_add_menu_item (cell, _("ATM"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Buy"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Credit"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Fee"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Int"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Online"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Sell"));
|
||||
break;
|
||||
case LIABILITY_REGISTER:
|
||||
gnc_combo_cell_add_menu_item (cell, _("Buy"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Sell"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Loan"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Int"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Payment"));
|
||||
break;
|
||||
case INCOME_LEDGER:
|
||||
case INCOME_REGISTER:
|
||||
gnc_combo_cell_add_menu_item (cell, _("Buy"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Sell"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Int"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Payment"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Rebate"));
|
||||
break;
|
||||
case EXPENSE_REGISTER:
|
||||
gnc_combo_cell_add_menu_item (cell, _("Buy"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Sell"));
|
||||
break;
|
||||
case GENERAL_LEDGER:
|
||||
case EQUITY_REGISTER:
|
||||
gnc_combo_cell_add_menu_item (cell, _("Buy"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Sell"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Equity"));
|
||||
break;
|
||||
case STOCK_REGISTER:
|
||||
case PORTFOLIO_LEDGER:
|
||||
case CURRENCY_REGISTER:
|
||||
gnc_combo_cell_add_menu_item (cell, _("Buy"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Sell"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Price"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Fee"));
|
||||
/* Action: Dividend */
|
||||
gnc_combo_cell_add_menu_item (cell, _("Div"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Int"));
|
||||
/* Action: Long Term Capital Gains */
|
||||
gnc_combo_cell_add_menu_item (cell, _("LTCG"));
|
||||
/* Action: Short Term Capital Gains */
|
||||
gnc_combo_cell_add_menu_item (cell, _("STCG"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Income"));
|
||||
/* Action: Distribution */
|
||||
gnc_combo_cell_add_menu_item (cell, _("Dist"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Split"));
|
||||
break;
|
||||
|
||||
default:
|
||||
gnc_combo_cell_add_menu_item (cell, _("Buy"));
|
||||
gnc_combo_cell_add_menu_item (cell, _("Sell"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_split_register_config_cells (SplitRegister *reg)
|
||||
{
|
||||
/* The num cell is the transaction number */
|
||||
xaccSetBasicCellBlankHelp (gnc_table_layout_get_cell (reg->table->layout,
|
||||
NUM_CELL),
|
||||
_("Enter the transaction number, such as the "
|
||||
"check number"));
|
||||
|
||||
/* the xfer cells */
|
||||
{
|
||||
const char *help = _("Enter the account to transfer from, or choose "
|
||||
"one from the list");
|
||||
xaccSetBasicCellBlankHelp (gnc_table_layout_get_cell (reg->table->layout,
|
||||
MXFRM_CELL), help);
|
||||
xaccSetBasicCellBlankHelp (gnc_table_layout_get_cell (reg->table->layout,
|
||||
XFRM_CELL), help);
|
||||
}
|
||||
|
||||
{
|
||||
const char *help = _("This transaction has multiple splits; "
|
||||
"press the Split button to see them all");
|
||||
|
||||
gnc_combo_cell_add_ignore_string
|
||||
((ComboCell *)
|
||||
gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL),
|
||||
_("-- Split Transaction --"), help);
|
||||
}
|
||||
|
||||
{
|
||||
const char *help = _("This transaction is a stock split; "
|
||||
"press the Split button to see details");
|
||||
|
||||
gnc_combo_cell_add_ignore_string
|
||||
((ComboCell *)
|
||||
gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL),
|
||||
_("-- Stock Split --"), help);
|
||||
}
|
||||
|
||||
/* the action cell */
|
||||
gnc_combo_cell_set_autosize
|
||||
((ComboCell *)
|
||||
gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL), TRUE);
|
||||
|
||||
/* the memo cell */
|
||||
xaccSetBasicCellBlankHelp
|
||||
(gnc_table_layout_get_cell (reg->table->layout, MEMO_CELL),
|
||||
_("Enter a description of the split"));
|
||||
|
||||
/* the desc cell */
|
||||
xaccSetBasicCellBlankHelp
|
||||
(gnc_table_layout_get_cell (reg->table->layout, DESC_CELL),
|
||||
_("Enter a description of the transaction"));
|
||||
|
||||
/* the notes cell */
|
||||
xaccSetBasicCellBlankHelp
|
||||
(gnc_table_layout_get_cell (reg->table->layout, NOTES_CELL),
|
||||
_("Enter notes for the transaction"));
|
||||
|
||||
/* the formula cells */
|
||||
xaccSetBasicCellBlankHelp
|
||||
(gnc_table_layout_get_cell (reg->table->layout, FCRED_CELL),
|
||||
_("Enter credit formula for real transaction"));
|
||||
|
||||
xaccSetBasicCellBlankHelp
|
||||
(gnc_table_layout_get_cell (reg->table->layout, FDEBT_CELL),
|
||||
_("Enter debit formula for real transaction"));
|
||||
|
||||
/* Use 6 decimal places for prices */
|
||||
gnc_price_cell_set_fraction
|
||||
((PriceCell *)
|
||||
gnc_table_layout_get_cell (reg->table->layout, PRIC_CELL), 1000000);
|
||||
|
||||
/* Initialize shares and share balance cells */
|
||||
gnc_price_cell_set_print_info
|
||||
((PriceCell *) gnc_table_layout_get_cell (reg->table->layout, SHRS_CELL),
|
||||
gnc_default_share_print_info ());
|
||||
|
||||
gnc_price_cell_set_print_info
|
||||
((PriceCell *) gnc_table_layout_get_cell (reg->table->layout, TSHRS_CELL),
|
||||
gnc_default_share_print_info ());
|
||||
|
||||
/* The action cell should accept strings not in the list */
|
||||
gnc_combo_cell_set_strict
|
||||
((ComboCell *)
|
||||
gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL), FALSE);
|
||||
|
||||
xaccSetBasicCellBlankHelp
|
||||
(gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL),
|
||||
_("Enter the type of transaction, or choose "
|
||||
"one from the list"));
|
||||
|
||||
/* number format for share quantities in stock ledgers */
|
||||
switch (reg->type)
|
||||
{
|
||||
case CURRENCY_REGISTER:
|
||||
case STOCK_REGISTER:
|
||||
case PORTFOLIO_LEDGER:
|
||||
gnc_price_cell_set_print_info
|
||||
((PriceCell *)
|
||||
gnc_table_layout_get_cell (reg->table->layout, PRIC_CELL),
|
||||
gnc_default_price_print_info ());
|
||||
|
||||
xaccSetBasicCellBlankHelp
|
||||
(gnc_table_layout_get_cell (reg->table->layout, PRIC_CELL),
|
||||
_("Enter the share price"));
|
||||
|
||||
xaccSetBasicCellBlankHelp
|
||||
(gnc_table_layout_get_cell (reg->table->layout, SHRS_CELL),
|
||||
_("Enter the number of shares bought or sold"));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* add menu items for the action cell */
|
||||
gnc_split_register_config_action (reg);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_split_register_init (SplitRegister *reg,
|
||||
SplitRegisterType type,
|
||||
SplitRegisterStyle style,
|
||||
gboolean use_double_line,
|
||||
gboolean templateMode)
|
||||
{
|
||||
TableLayout *layout;
|
||||
TableModel *model;
|
||||
TableControl *control;
|
||||
|
||||
reg->user_data = NULL;
|
||||
reg->destroy = NULL;
|
||||
|
||||
reg->type = type;
|
||||
reg->style = style;
|
||||
reg->use_double_line = use_double_line;
|
||||
reg->template = templateMode;
|
||||
|
||||
layout = gnc_split_register_layout_new (reg);
|
||||
|
||||
model = gnc_split_register_model_new ();
|
||||
model->handler_user_data = reg;
|
||||
|
||||
control = gnc_split_register_control_new ();
|
||||
control->user_data = reg;
|
||||
|
||||
reg->table = gnc_table_new (layout, model, control);
|
||||
|
||||
gnc_split_register_config_cells (reg);
|
||||
|
||||
/* Set up header */
|
||||
{
|
||||
VirtualCellLocation vcell_loc = { 0, 0 };
|
||||
CellBlock *header;
|
||||
|
||||
header = gnc_table_layout_get_cursor (reg->table->layout, CURSOR_HEADER);
|
||||
|
||||
gnc_table_set_vcell (reg->table, header, NULL, TRUE, TRUE, vcell_loc);
|
||||
}
|
||||
|
||||
/* Set up first and only initial row */
|
||||
{
|
||||
VirtualLocation vloc;
|
||||
CellBlock *cursor;
|
||||
|
||||
vloc.vcell_loc.virt_row = 1;
|
||||
vloc.vcell_loc.virt_col = 0;
|
||||
vloc.phys_row_offset = 0;
|
||||
vloc.phys_col_offset = 0;
|
||||
|
||||
cursor = gnc_table_layout_get_cursor (reg->table->layout,
|
||||
CURSOR_SINGLE_LEDGER);
|
||||
|
||||
gnc_table_set_vcell (reg->table, cursor, NULL, TRUE, TRUE, vloc.vcell_loc);
|
||||
gnc_table_move_cursor (reg->table, vloc);
|
||||
}
|
||||
}
|
||||
|
||||
SplitRegister *
|
||||
gnc_split_register_new (SplitRegisterType type,
|
||||
SplitRegisterStyle style,
|
||||
gboolean use_double_line,
|
||||
gboolean templateMode)
|
||||
{
|
||||
SplitRegister * reg;
|
||||
|
||||
reg = g_new0 (SplitRegister, 1);
|
||||
|
||||
if (type >= NUM_SINGLE_REGISTER_TYPES)
|
||||
style = REG_STYLE_JOURNAL;
|
||||
|
||||
gnc_split_register_init (reg,
|
||||
type,
|
||||
style,
|
||||
use_double_line,
|
||||
templateMode);
|
||||
|
||||
return reg;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_split_register_config (SplitRegister *reg,
|
||||
SplitRegisterType newtype,
|
||||
SplitRegisterStyle newstyle,
|
||||
gboolean use_double_line)
|
||||
{
|
||||
if (!reg) return;
|
||||
|
||||
reg->type = newtype;
|
||||
|
||||
if (reg->type >= NUM_SINGLE_REGISTER_TYPES)
|
||||
newstyle = REG_STYLE_JOURNAL;
|
||||
|
||||
reg->style = newstyle;
|
||||
reg->use_double_line = use_double_line;
|
||||
|
||||
gnc_table_realize_gui (reg->table);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_split_register_destroy (SplitRegister *reg)
|
||||
{
|
||||
GList *node;
|
||||
|
||||
if (!reg)
|
||||
return;
|
||||
|
||||
/* give the user a chance to clean up */
|
||||
if (reg->destroy)
|
||||
(reg->destroy) (reg);
|
||||
|
||||
reg->destroy = NULL;
|
||||
reg->user_data = NULL;
|
||||
|
||||
gnc_table_destroy (reg->table);
|
||||
reg->table = NULL;
|
||||
|
||||
g_free (reg->debit_str);
|
||||
g_free (reg->tdebit_str);
|
||||
g_free (reg->credit_str);
|
||||
g_free (reg->tcredit_str);
|
||||
|
||||
reg->debit_str = NULL;
|
||||
reg->tdebit_str = NULL;
|
||||
reg->credit_str = NULL;
|
||||
reg->tcredit_str = NULL;
|
||||
|
||||
/* free the memory itself */
|
||||
g_free (reg);
|
||||
}
|
||||
|
||||
@@ -29,13 +29,82 @@
|
||||
#include "Group.h"
|
||||
#include "Transaction.h"
|
||||
#include "gnc-common.h"
|
||||
#include "splitreg.h"
|
||||
#include "table-allgui.h"
|
||||
|
||||
|
||||
/* Datatypes */
|
||||
typedef struct _SplitRegisterColors SplitRegisterColors;
|
||||
/** Datatypes *******************************************************/
|
||||
|
||||
struct _SplitRegisterColors
|
||||
/* Register types.
|
||||
* "registers" are single-account display windows.
|
||||
* "ledgers" are multiple-account display windows */
|
||||
typedef enum
|
||||
{
|
||||
BANK_REGISTER,
|
||||
CASH_REGISTER,
|
||||
ASSET_REGISTER,
|
||||
CREDIT_REGISTER,
|
||||
LIABILITY_REGISTER,
|
||||
INCOME_REGISTER,
|
||||
EXPENSE_REGISTER,
|
||||
EQUITY_REGISTER,
|
||||
STOCK_REGISTER,
|
||||
CURRENCY_REGISTER,
|
||||
NUM_SINGLE_REGISTER_TYPES,
|
||||
|
||||
GENERAL_LEDGER = NUM_SINGLE_REGISTER_TYPES,
|
||||
INCOME_LEDGER,
|
||||
PORTFOLIO_LEDGER,
|
||||
SEARCH_LEDGER,
|
||||
|
||||
NUM_REGISTER_TYPES
|
||||
} SplitRegisterType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
REG_STYLE_LEDGER,
|
||||
REG_STYLE_AUTO_LEDGER,
|
||||
REG_STYLE_JOURNAL
|
||||
} SplitRegisterStyle;
|
||||
|
||||
/* Cell Names. T* cells are transaction summary cells */
|
||||
#define ACTN_CELL "action"
|
||||
#define BALN_CELL "balance"
|
||||
#define CRED_CELL "credit"
|
||||
#define DATE_CELL "date"
|
||||
#define DEBT_CELL "debit"
|
||||
#define DESC_CELL "description"
|
||||
#define FCRED_CELL "credit-formula"
|
||||
#define FDEBT_CELL "debit formula"
|
||||
#define MEMO_CELL "memo"
|
||||
#define MXFRM_CELL "transfer"
|
||||
#define NOTES_CELL "notes"
|
||||
#define NUM_CELL "num"
|
||||
#define PRIC_CELL "price"
|
||||
#define RECN_CELL "reconcile"
|
||||
#define SHRS_CELL "shares"
|
||||
#define TBALN_CELL "trans-balance"
|
||||
#define TCRED_CELL "trans-credit"
|
||||
#define TDEBT_CELL "trans-debit"
|
||||
#define TSHRS_CELL "trans-shares"
|
||||
#define XFRM_CELL "account"
|
||||
|
||||
/* Cursor Names */
|
||||
#define CURSOR_SINGLE_LEDGER "cursor-single-ledger"
|
||||
#define CURSOR_DOUBLE_LEDGER "cursor-double-ledger"
|
||||
#define CURSOR_SINGLE_JOURNAL "cursor-single-journal"
|
||||
#define CURSOR_DOUBLE_JOURNAL "cursor-double-journal"
|
||||
#define CURSOR_SPLIT "cursor-split"
|
||||
|
||||
/* Types of cursors */
|
||||
typedef enum
|
||||
{
|
||||
CURSOR_CLASS_NONE = -1,
|
||||
CURSOR_CLASS_SPLIT,
|
||||
CURSOR_CLASS_TRANS,
|
||||
NUM_CURSOR_CLASSES
|
||||
} CursorClass;
|
||||
|
||||
typedef struct split_register_colors
|
||||
{
|
||||
guint32 header_bg_color;
|
||||
|
||||
@@ -49,14 +118,81 @@ struct _SplitRegisterColors
|
||||
guint32 split_active_bg_color;
|
||||
|
||||
gboolean double_alternate_virt;
|
||||
};
|
||||
} SplitRegisterColors;
|
||||
|
||||
|
||||
typedef struct split_register SplitRegister;
|
||||
|
||||
typedef void (*SplitRegisterDestroyCB) (SplitRegister *reg);
|
||||
|
||||
struct split_register
|
||||
{
|
||||
/* the table itself that implements the underlying GUI. */
|
||||
Table * table;
|
||||
|
||||
SplitRegisterType type;
|
||||
SplitRegisterStyle style;
|
||||
|
||||
gboolean use_double_line;
|
||||
|
||||
/* some private data; outsiders should not access this */
|
||||
|
||||
/**
|
||||
* A flag indicating a "template" register.
|
||||
**/
|
||||
gboolean template; /* FIXME: this should not be here! */
|
||||
|
||||
/**
|
||||
* The template account which the transactions in a template
|
||||
* splitregister will belong to.
|
||||
**/
|
||||
Account *templateAcct; /* FIXME: this should not be here! */
|
||||
|
||||
/* user_data allows users of this object to hang
|
||||
* private data onto it */
|
||||
gpointer user_data;
|
||||
|
||||
/* The destroy callback gives user's a chance
|
||||
* to free up any associated user_hook data */
|
||||
SplitRegisterDestroyCB destroy;
|
||||
|
||||
/* configured strings for debit/credit headers */
|
||||
char *debit_str;
|
||||
char *credit_str;
|
||||
char *tdebit_str;
|
||||
char *tcredit_str;
|
||||
};
|
||||
|
||||
/* Callback function type */
|
||||
typedef gncUIWidget (*SRGetParentCallback) (gpointer user_data);
|
||||
typedef void (*SRSetHelpCallback) (gpointer user_data, const char *help_str);
|
||||
|
||||
|
||||
/** Prototypes ******************************************************/
|
||||
|
||||
/* Create and return a new split register. */
|
||||
SplitRegister * gnc_split_register_new (SplitRegisterType type,
|
||||
SplitRegisterStyle style,
|
||||
gboolean use_double_line,
|
||||
gboolean templateMode);
|
||||
|
||||
/* Configure the split register. */
|
||||
void gnc_split_register_config (SplitRegister *reg,
|
||||
SplitRegisterType type,
|
||||
SplitRegisterStyle style,
|
||||
gboolean use_double_line);
|
||||
|
||||
/* Destroy the split register. */
|
||||
void gnc_split_register_destroy (SplitRegister *reg);
|
||||
|
||||
/* Returns the class of the current cursor */
|
||||
CursorClass gnc_split_register_get_current_cursor_class (SplitRegister *reg);
|
||||
|
||||
/* Returns the class of the cursor at the given virtual cell location. */
|
||||
CursorClass gnc_split_register_get_cursor_class
|
||||
(SplitRegister *reg,
|
||||
VirtualCellLocation vcell_loc);
|
||||
|
||||
/* The xaccSRSetData() method sets the user data and callback
|
||||
* hooks for the register. */
|
||||
void xaccSRSetData(SplitRegister *reg, gpointer user_data,
|
||||
|
||||
@@ -14,7 +14,6 @@ libgncmod_register_core_la_SOURCES = \
|
||||
quickfillcell.c \
|
||||
recncell.c \
|
||||
register-common.c \
|
||||
splitreg.c \
|
||||
table-allgui.c \
|
||||
table-control.c \
|
||||
table-layout.c \
|
||||
@@ -33,7 +32,6 @@ noinst_HEADERS = \
|
||||
quickfillcell.h \
|
||||
recncell.h \
|
||||
register-common.h \
|
||||
splitreg.h \
|
||||
table-allgui.h \
|
||||
table-control.h \
|
||||
table-layout.h \
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,198 +0,0 @@
|
||||
/********************************************************************\
|
||||
* splitreg.h -- general ledger object build on top of table object *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
/*
|
||||
* FILE:
|
||||
* splitreg.h
|
||||
*
|
||||
* FUNCTION:
|
||||
* Implements a basic display register/ledger.
|
||||
* This object makes specific cells have specific properties
|
||||
* (price, text, date, etc.) and specific names that correspond.
|
||||
* It also determines the actual physical layout, arrangement
|
||||
* of columns, etc.
|
||||
*
|
||||
* See src/doc/design/gnucash-design.info for more information.
|
||||
*
|
||||
* DESIGN HOPES:
|
||||
* Should probably move at least some of the layout to a config
|
||||
* file. Might make good sense to use scheme/guile for the layout.
|
||||
*
|
||||
* HISTORY:
|
||||
* Copyright (c) 1998, 1999, 2000 Linas Vepstas
|
||||
*/
|
||||
|
||||
#ifndef SPLITREG_H
|
||||
#define SPLITREG_H
|
||||
|
||||
#include "Account.h" /* FIXME No Engine headers!!! */
|
||||
|
||||
#include "table-allgui.h"
|
||||
|
||||
/* defined register types.
|
||||
* "registers" are single-account display windows.
|
||||
* "ledgers" are multiple-account display windows */
|
||||
typedef enum
|
||||
{
|
||||
BANK_REGISTER,
|
||||
CASH_REGISTER,
|
||||
ASSET_REGISTER,
|
||||
CREDIT_REGISTER,
|
||||
LIABILITY_REGISTER,
|
||||
INCOME_REGISTER,
|
||||
EXPENSE_REGISTER,
|
||||
EQUITY_REGISTER,
|
||||
STOCK_REGISTER,
|
||||
CURRENCY_REGISTER,
|
||||
NUM_SINGLE_REGISTER_TYPES,
|
||||
|
||||
GENERAL_LEDGER = NUM_SINGLE_REGISTER_TYPES,
|
||||
INCOME_LEDGER,
|
||||
PORTFOLIO_LEDGER,
|
||||
SEARCH_LEDGER,
|
||||
|
||||
NUM_REGISTER_TYPES
|
||||
} SplitRegisterType;
|
||||
|
||||
/* Cell Names */
|
||||
#define DATE_CELL "date"
|
||||
#define NUM_CELL "num"
|
||||
#define DESC_CELL "description"
|
||||
#define RECN_CELL "reconcile"
|
||||
#define BALN_CELL "balance"
|
||||
#define ACTN_CELL "action"
|
||||
#define XFRM_CELL "account"
|
||||
#define MEMO_CELL "memo"
|
||||
#define DEBT_CELL "debit"
|
||||
#define CRED_CELL "credit"
|
||||
#define PRIC_CELL "price"
|
||||
#define SHRS_CELL "shares"
|
||||
#define MXFRM_CELL "transfer"
|
||||
|
||||
/* T* cells are transaction summary cells */
|
||||
#define TDEBT_CELL "trans-debit"
|
||||
#define TCRED_CELL "trans-credit"
|
||||
#define TSHRS_CELL "trans-shares"
|
||||
#define TBALN_CELL "trans-balance"
|
||||
#define NOTES_CELL "notes"
|
||||
#define FDEBT_CELL "debit formula"
|
||||
#define FCRED_CELL "credit-formula"
|
||||
|
||||
/*
|
||||
* enumerated display styles
|
||||
* REG_SINGLE_LINE -- show one line per transaction
|
||||
* REG_DOUBLE_LINE -- show two lines per transaction
|
||||
* REG_MULTI_LINE -- show multiple lines per transaction
|
||||
* REG_SINGLE_DYNAMIC -- dynamically expand edited transaction,
|
||||
* all other transactions on one line
|
||||
* REG_DOUBLE_DYNAMIC -- dynamically expand edited transaction,
|
||||
* all other transactions on two lines
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
REG_STYLE_LEDGER,
|
||||
REG_STYLE_AUTO_LEDGER,
|
||||
REG_STYLE_JOURNAL
|
||||
} SplitRegisterStyle;
|
||||
|
||||
/* Types of cursors */
|
||||
typedef enum
|
||||
{
|
||||
CURSOR_CLASS_NONE = -1,
|
||||
CURSOR_CLASS_SPLIT,
|
||||
CURSOR_CLASS_TRANS,
|
||||
NUM_CURSOR_CLASSES
|
||||
} CursorClass;
|
||||
|
||||
#define CURSOR_SINGLE_LEDGER "cursor-single-ledger"
|
||||
#define CURSOR_DOUBLE_LEDGER "cursor-double-ledger"
|
||||
#define CURSOR_SINGLE_JOURNAL "cursor-single-journal"
|
||||
#define CURSOR_DOUBLE_JOURNAL "cursor-double-journal"
|
||||
#define CURSOR_SPLIT "cursor-split"
|
||||
|
||||
typedef struct split_register SplitRegister;
|
||||
|
||||
typedef void (*SplitRegisterDestroyCB) (SplitRegister *reg);
|
||||
|
||||
struct split_register
|
||||
{
|
||||
/* the table itself that implements the underlying GUI. */
|
||||
Table * table;
|
||||
|
||||
SplitRegisterType type;
|
||||
SplitRegisterStyle style;
|
||||
gboolean use_double_line;
|
||||
|
||||
/* some private data; outsiders should not access this */
|
||||
|
||||
/**
|
||||
* A flag indicating a "template" register.
|
||||
**/
|
||||
gboolean template; /* FIXME: this should not be here! */
|
||||
|
||||
/**
|
||||
* The template account which the transactions in a template
|
||||
* splitregister will belong to.
|
||||
**/
|
||||
Account *templateAcct; /* FIXME: this should not be here! */
|
||||
|
||||
/* user_data allows users of this object to hang
|
||||
* private data onto it */
|
||||
gpointer user_data;
|
||||
|
||||
/* The destroy callback gives user's a chance
|
||||
* to free up any associated user_hook data */
|
||||
SplitRegisterDestroyCB destroy;
|
||||
|
||||
/* configured strings for debit/credit headers */
|
||||
char *debit_str;
|
||||
char *credit_str;
|
||||
char *tdebit_str;
|
||||
char *tcredit_str;
|
||||
};
|
||||
|
||||
|
||||
SplitRegister *
|
||||
gnc_register_new (SplitRegisterType type,
|
||||
SplitRegisterStyle style,
|
||||
gboolean use_double_line,
|
||||
TableControl *control,
|
||||
TableModel *model,
|
||||
gboolean templateMode);
|
||||
|
||||
void xaccConfigSplitRegister (SplitRegister *reg,
|
||||
SplitRegisterType type,
|
||||
SplitRegisterStyle style,
|
||||
gboolean use_double_line);
|
||||
|
||||
void xaccDestroySplitRegister (SplitRegister *reg);
|
||||
|
||||
/* Returns the type of the current cursor */
|
||||
CursorClass xaccSplitRegisterGetCurrentCursorClass (SplitRegister *reg);
|
||||
|
||||
/* Returns the type of the cursor at the given virtual row and column. */
|
||||
CursorClass xaccSplitRegisterGetCursorClass (SplitRegister *reg,
|
||||
VirtualCellLocation vcell_loc);
|
||||
|
||||
CursorClass xaccCursorNameToClass (const char *cursor_name);
|
||||
|
||||
#endif
|
||||
@@ -63,18 +63,19 @@ static void gnc_table_resize (Table * table, int virt_rows, int virt_cols);
|
||||
/** Implementation *****************************************************/
|
||||
|
||||
Table *
|
||||
gnc_table_new (TableControl *control, TableModel *model)
|
||||
gnc_table_new (TableLayout *layout, TableModel *model, TableControl *control)
|
||||
{
|
||||
Table *table;
|
||||
|
||||
g_return_val_if_fail (control != NULL, NULL);
|
||||
g_return_val_if_fail (layout != NULL, NULL);
|
||||
g_return_val_if_fail (model != NULL, NULL);
|
||||
g_return_val_if_fail (control != NULL, NULL);
|
||||
|
||||
table = g_new0 (Table, 1);
|
||||
|
||||
table->control = control;
|
||||
table->layout = gnc_table_layout_new ();
|
||||
table->layout = layout;
|
||||
table->model = model;
|
||||
table->control = control;
|
||||
|
||||
gnc_table_init (table);
|
||||
|
||||
@@ -119,6 +120,12 @@ gnc_table_destroy (Table * table)
|
||||
gnc_table_layout_destroy (table->layout);
|
||||
table->layout = NULL;
|
||||
|
||||
gnc_table_control_destroy (table->control);
|
||||
table->control = NULL;
|
||||
|
||||
gnc_table_model_destroy (table->model);
|
||||
table->model = NULL;
|
||||
|
||||
/* intialize vars to null value so that any access is voided. */
|
||||
gnc_table_init (table);
|
||||
|
||||
|
||||
@@ -120,9 +120,9 @@ typedef void (*TableDestroyFunc) (Table *table);
|
||||
|
||||
struct table
|
||||
{
|
||||
TableLayout *layout;
|
||||
TableModel *model;
|
||||
TableControl *control;
|
||||
TableLayout *layout;
|
||||
TableModel *model;
|
||||
|
||||
int num_virt_rows;
|
||||
int num_virt_cols;
|
||||
@@ -143,7 +143,9 @@ struct table
|
||||
|
||||
|
||||
/* Functions to create and destroy Tables. */
|
||||
Table * gnc_table_new (TableControl *control, TableModel *model);
|
||||
Table * gnc_table_new (TableLayout *layout,
|
||||
TableModel *model,
|
||||
TableControl *control);
|
||||
|
||||
void gnc_table_save_state (Table *table);
|
||||
void gnc_table_destroy (Table *table);
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#include "global-options.h"
|
||||
#include "gnucash-sheet.h"
|
||||
#include "gnucash-style.h"
|
||||
#include "splitreg.h"
|
||||
#include "table-allgui.h"
|
||||
|
||||
|
||||
@@ -88,7 +87,7 @@ gnc_table_save_state (Table *table)
|
||||
if (width <= 0)
|
||||
continue;
|
||||
|
||||
if (gnc_basic_cell_has_name (cell, DESC_CELL))
|
||||
if (cell->expandable)
|
||||
continue;
|
||||
|
||||
assoc = gh_cons (gh_str02scm(cell->cell_name),
|
||||
|
||||
Reference in New Issue
Block a user