2001-07-21 Dave Peticolas <dave@krondo.com>

* src/register/cell-factory.[ch]: a new object for creation of
	register cells. allows new cell types to be added dynamically.

	* src/register/gnome/gnucash-style.c: fix for removal of
	label from cellblock cells.

	* src/register/table-allgui.[ch]: fix for changed flag and
	callback changes.

	* src/register/splitreg.[ch]: remove fixed cells, use a dynamic
	list. Fix code appropriately.

	* src/register/register-common.[ch]: add wrapper for a global cell
	factory.

	* src/register/gnome/datecell-gnome.c: same as below

	* src/register/gnome/combocell-gnome.c: same as below

	* src/register/textcell.[ch]: same as below

	* src/register/recncell.[ch]: same as below

	* src/register/quickfillcell.[ch]: same as below

	* src/register/pricecell.[ch]: same as below

	* src/register/numcell.[ch]: same as below

	* src/register/datecell.h: same as below

	* src/register/combocell.h: make destructor private.
	constructor returns 'BasicCell *'.

	* src/register/cellblock.[ch]: remove 'label' members -- no longer
	used.

	* src/register/basiccell.[ch]: 'virtualize' destructor.
	simplify changed flags.

	* src/register/Makefile.am (SUBDIRS): add cell-factory.[ch]

	* src/gnome/gnc-html.c: fix includes

	* src/SplitLedger.c: update for api changes

	* src/MultiLedger.c: update for api changes


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4973 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-07-22 02:29:52 +00:00
parent 969645fef0
commit 7c11369570
32 changed files with 1307 additions and 962 deletions

View File

@ -1,3 +1,53 @@
2001-07-21 Dave Peticolas <dave@krondo.com>
* src/register/cell-factory.[ch]: a new object for creation of
register cells. allows new cell types to be added dynamically.
* src/register/gnome/gnucash-style.c: fix for removal of
label from cellblock cells.
* src/register/table-allgui.[ch]: fix for changed flag and
callback changes.
* src/register/splitreg.[ch]: remove fixed cells, use a dynamic
list. Fix code appropriately.
* src/register/register-common.[ch]: add wrapper for a global cell
factory.
* src/register/gnome/datecell-gnome.c: same as below
* src/register/gnome/combocell-gnome.c: same as below
* src/register/textcell.[ch]: same as below
* src/register/recncell.[ch]: same as below
* src/register/quickfillcell.[ch]: same as below
* src/register/pricecell.[ch]: same as below
* src/register/numcell.[ch]: same as below
* src/register/datecell.h: same as below
* src/register/combocell.h: make destructor private.
constructor returns 'BasicCell *'.
* src/register/cellblock.[ch]: remove 'label' members -- no longer
used.
* src/register/basiccell.[ch]: 'virtualize' destructor.
simplify changed flags.
* src/register/Makefile.am (SUBDIRS): add cell-factory.[ch]
* src/gnome/gnc-html.c: fix includes
* src/SplitLedger.c: update for api changes
* src/MultiLedger.c: update for api changes
2001-07-20 James LewisMoss <jimdres@mindspring.com>
* src/gnome/top-level.c (gnucash_ui_init): remove the \n's frome

View File

@ -820,8 +820,7 @@ xaccLedgerDisplayInternal (Account *lead_account, Query *q,
model.cell_data_deallocator = xaccMLGUIDFree;
model.cell_data_copy = xaccMLGUIDCopy;
ld->reg = xaccMallocSplitRegister (reg_type, style, FALSE, &model,
templateMode);
ld->reg = gnc_register_new (reg_type, style, FALSE, &model, templateMode);
xaccSRSetData (ld->reg, ld,
xaccLedgerDisplayParent,
xaccLedgerDisplaySetHelp);

File diff suppressed because it is too large Load Diff

View File

@ -59,6 +59,7 @@
#include "gnc-html-history.h"
#include "gnc-network.h"
#include "gnc-ui.h"
#include "gnc-ui-util.h"
#include "query-user.h"
#include "window-help.h"
#include "window-main.h"

View File

@ -1,9 +1,11 @@
SUBDIRS = gnome
noinst_LIBRARIES = libgncregister.a
libgncregister_a_SOURCES = \
QuickFill.c \
basiccell.c \
cell-factory.c \
cellblock.c \
gtable.c \
numcell.c \
@ -19,6 +21,7 @@ libgncregister_a_SOURCES = \
noinst_HEADERS = \
QuickFill.h \
basiccell.h \
cell-factory.h \
cellblock.h \
combocell.h \
datecell.h \
@ -46,6 +49,3 @@ INCLUDES = \
-I${top_srcdir}/src/register/gnome \
${GNOME_INCLUDEDIR} \
${GUILE_INCS}
SUBDIRS = gnome

View File

@ -76,8 +76,8 @@ BasicCellHelpValue(BasicCell *cell)
static void
xaccClearBasicCell (BasicCell *cell)
{
cell->changed = 0;
cell->conditionally_changed = 0;
cell->changed = FALSE;
cell->conditionally_changed = FALSE;
cell->value = NULL;
cell->value_w = NULL;
@ -89,9 +89,9 @@ xaccClearBasicCell (BasicCell *cell)
cell->modify_verify = NULL;
cell->direct_update = NULL;
cell->leave_cell = NULL;
cell->realize = NULL;
cell->move = NULL;
cell->destroy = NULL;
cell->gui_realize = NULL;
cell->gui_move = NULL;
cell->gui_destroy = NULL;
cell->get_help_value = NULL;
cell->is_popup = FALSE;
@ -114,11 +114,14 @@ xaccInitBasicCell (BasicCell *cell)
/* ===================================================== */
void
xaccDestroyBasicCell (BasicCell *cell)
gnc_basic_cell_destroy (BasicCell *cell)
{
/* give any gui elements a chance to clean up */
if (cell->destroy)
(*(cell->destroy)) (cell);
cell->destroy (cell);
/* give any gui elements a chance to clean up */
if (cell->gui_destroy)
(*(cell->gui_destroy)) (cell);
/* free up data strings */
g_free (cell->value);
@ -139,6 +142,16 @@ xaccDestroyBasicCell (BasicCell *cell)
/* ===================================================== */
const char *
gnc_basic_cell_get_value (BasicCell *cell)
{
g_return_val_if_fail (cell != NULL, NULL);
return cell->value;
}
/* ===================================================== */
void
xaccSetBasicCellValue (BasicCell *cell, const char *val)
{
@ -157,7 +170,37 @@ xaccSetBasicCellValue (BasicCell *cell, const char *val)
xaccSetBasicCellValueInternal (cell, val);
}
/* ===================================================== */
gboolean
gnc_basic_cell_get_changed (BasicCell *cell)
{
if (!cell) return FALSE;
return cell->changed;
}
gboolean
gnc_basic_cell_get_conditionally_changed (BasicCell *cell)
{
if (!cell) return FALSE;
return cell->conditionally_changed;
}
void
gnc_basic_cell_set_changed (BasicCell *cell, gboolean changed)
{
if (!cell) return;
cell->changed = changed;
}
void
gnc_basic_cell_set_conditionally_changed (BasicCell *cell, gboolean changed)
{
if (!cell) return;
cell->conditionally_changed = changed;
}
void
xaccSetBasicCellBlankHelp (BasicCell *cell, const char *blank_help)
@ -189,17 +232,6 @@ xaccBasicCellGetHelp (BasicCell *cell)
/* ===================================================== */
void
xaccBasicCellSetChanged (BasicCell *cell, gboolean changed)
{
if (cell == NULL)
return;
cell->changed = changed ? GNC_CELL_CHANGED : 0;
}
/* ===================================================== */
void
xaccSetBasicCellValueInternal (BasicCell *cell, const char *value)
{

View File

@ -56,24 +56,6 @@
* classes should provide a callback here if they need
* to understand special cell formats.
*
* MEMBERS:
* The input_output member controls how the cell accepts
* input, and whether it displays its value. It is a
* a flag of OR-ed together values. Flag bits include:
*
* XACC_CELL_ALLOW_INPUT accept keyboard & mouse
* input from the user.
* XACC_CELL_ALLOW_EXACT_ONLY the cell may only be
* entered by 'exact' selection, i.e., not by
* indirect selection by, for example, tabbing.
* Currently, the only exact method of entering
* a cell is via the mouse pointer.
*
* If ALLOW_INPUT is not set, the cell is supposed to
* to only display values, but not accept user input. If
* set, then the callbacks below are used to when the
* cell is entered.
*
* USER CALLBACKS:
* The enter_cell() callback is called when the user first
* makes a move to enter a cell. This might be by clicking
@ -134,14 +116,14 @@
* callbacks that allow the programmer to perform GUI-specific
* initialization & changes.
*
* The realize() callback will be called when GUI-specific
* The gui_realize() callback will be called when GUI-specific
* initialization needs to be done. For Gnome, the second
* argument will be cast to the parent widget.
*
* The destroy() callback will be called when the GUI associated
* The gui_destroy() callback will be called when the GUI associated
* with the cell needs to be destroyed.
*
* The move() callback will be called when the GUI element needs
* The gui_move() callback will be called when the GUI element needs
* to be positioned to a new location within the table grid.
* The second argument is the virtual location the GUI
* element should be moved to.
@ -160,15 +142,13 @@
#include <gdk/gdk.h>
#include <glib.h>
#include "gnc-common.h"
#include "gnc-ui-common.h"
#include "register-common.h"
#define GNC_CELL_CHANGED 0xffffffff
typedef struct _BasicCell BasicCell;
typedef BasicCell * (*CellCreateFunc) (void);
typedef void (*CellSetValueFunc) (BasicCell *cell,
const char * new_value);
@ -196,7 +176,7 @@ typedef void (*CellLeaveFunc) (BasicCell *cell);
typedef void (*CellRealizeFunc) (BasicCell *cell, gpointer gui_handle);
typedef void (*CellMoveFunc) (BasicCell *cell, VirtualLocation virt_loc);
typedef void (*CellMoveFunc) (BasicCell *cell);
typedef void (*CellDestroyFunc) (BasicCell *cell);
@ -211,11 +191,12 @@ struct _BasicCell
gint value_len; /* length of wide chars value */
guint32 changed; /* 2^32-1 if value modified */
guint32 conditionally_changed; /* value if modified conditionally */
gboolean changed; /* true if value modified */
gboolean conditionally_changed; /* true if value modified conditionally */
/* "virtual", overloaded set-value method */
/* "virtual", overloaded methods */
CellSetValueFunc set_value;
CellDestroyFunc destroy;
/* cell-editing callbacks */
CellEnterFunc enter_cell;
@ -223,13 +204,13 @@ struct _BasicCell
CellDirectUpdateFunc direct_update;
CellLeaveFunc leave_cell;
/* private, GUI-specific callbacks */
CellRealizeFunc realize;
CellMoveFunc move;
CellDestroyFunc destroy;
CellGetHelpFunc get_help_value;
/* private, GUI-specific callbacks */
CellRealizeFunc gui_realize;
CellMoveFunc gui_move;
CellDestroyFunc gui_destroy;
/* GUI flag indicated is a popup-widget */
gboolean is_popup;
@ -240,15 +221,21 @@ struct _BasicCell
BasicCell * xaccMallocBasicCell (void);
void xaccInitBasicCell (BasicCell *bcell);
void xaccDestroyBasicCell (BasicCell *bcell);
void gnc_basic_cell_destroy (BasicCell *bcell);
const char * gnc_basic_cell_get_value (BasicCell *cell);
void xaccSetBasicCellValue (BasicCell *bcell, const char *value);
gboolean gnc_basic_cell_get_changed (BasicCell *cell);
gboolean gnc_basic_cell_get_conditionally_changed (BasicCell *cell);
void gnc_basic_cell_set_changed (BasicCell *cell, gboolean changed);
void gnc_basic_cell_set_conditionally_changed (BasicCell *cell,
gboolean changed);
void xaccSetBasicCellBlankHelp (BasicCell *bcell, const char *help);
char * xaccBasicCellGetHelp (BasicCell *bcell);
void xaccBasicCellSetChanged (BasicCell *bcell, gboolean changed);
/* for sub-class use only */
void xaccSetBasicCellValueInternal (BasicCell *bcell,
const char *value);

111
src/register/cell-factory.c Normal file
View File

@ -0,0 +1,111 @@
/********************************************************************\
* cell-factory.c -- register cell creation object *
* Copyright 2001 Free Software Foundation *
* *
* 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 "cell-factory.h"
#include "gnc-engine-util.h"
typedef struct cell_record
{
char *cell_type_name;
CellCreateFunc creator;
} CellRecord;
struct cell_factory
{
GHashTable *cell_table;
};
CellFactory *
gnc_cell_factory_new (void)
{
CellFactory *cf;
cf = g_new0 (CellFactory, 1);
cf->cell_table = g_hash_table_new (g_str_hash, g_str_equal);
return cf;
}
static void
cell_table_destroy_helper (gpointer key, gpointer value, gpointer user_data)
{
CellRecord *cr = value;
g_free (cr->cell_type_name);
g_free (cr);
}
void
gnc_cell_factory_destroy (CellFactory *cf)
{
if (!cf) return;
g_hash_table_foreach (cf->cell_table, cell_table_destroy_helper, NULL);
g_free (cf);
}
void
gnc_cell_factory_add_cell_type (CellFactory *cf,
const char *cell_type_name,
CellCreateFunc cell_creator)
{
CellRecord *cr;
g_return_if_fail (cell_type_name != NULL);
g_return_if_fail (cell_creator != NULL);
cr = g_hash_table_lookup (cf->cell_table, cell_type_name);
if (cr)
g_free (cr->cell_type_name);
else
cr = g_new0 (CellRecord, 1);
cr->cell_type_name = g_strdup (cell_type_name);
cr->creator = cell_creator;
g_hash_table_insert (cf->cell_table, cr->cell_type_name, cr);
}
BasicCell *
gnc_cell_factory_make_cell (CellFactory *cf, const char *cell_type_name)
{
CellRecord *cr;
g_return_val_if_fail (cf != NULL, NULL);
g_return_val_if_fail (cell_type_name != NULL, NULL);
cr = g_hash_table_lookup (cf->cell_table, cell_type_name);
g_return_val_if_fail (cr != NULL, NULL);
return cr->creator ();
}

View File

@ -0,0 +1,41 @@
/********************************************************************\
* cell-factory.h -- register cell creation object *
* Copyright 2001 Free Software Foundation *
* *
* 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 CELL_FACTORY_H
#define CELL_FACTORY_H
#include "basiccell.h"
typedef struct cell_factory CellFactory;
CellFactory * gnc_cell_factory_new (void);
void gnc_cell_factory_destroy (CellFactory *cf);
void gnc_cell_factory_add_cell_type (CellFactory *cf,
const char *cell_type_name,
CellCreateFunc cell_creator);
BasicCell * gnc_cell_factory_make_cell (CellFactory *cf,
const char *cell_type_name);
#endif

View File

@ -64,8 +64,6 @@ gnc_cellblock_cell_construct (gpointer _cb_cell, gpointer user_data)
cb_cell->cell = NULL;
cb_cell->cell_type = -1;
cb_cell->label = NULL;
cb_cell->sample_text = NULL;
cb_cell->alignment = CELL_ALIGN_LEFT;
cb_cell->expandable = FALSE;
@ -85,9 +83,6 @@ gnc_cellblock_cell_destroy (gpointer _cb_cell, gpointer user_data)
cb_cell->cell = NULL;
cb_cell->cell_type = -1;
g_free(cb_cell->label);
cb_cell->label = NULL;
g_free(cb_cell->sample_text);
cb_cell->sample_text = NULL;
}

View File

@ -78,8 +78,6 @@ typedef struct
BasicCell *cell; /* cell handler */
short cell_type; /* cell type from splitreg.h */
char *label; /* cell label for header and hints */
/* GUI layout information */
char *sample_text; /* sample text for sizing purposes */
CellAlignment alignment;

View File

@ -59,9 +59,8 @@ typedef struct _ComboCell
} ComboCell;
ComboCell * xaccMallocComboCell (void);
BasicCell * xaccMallocComboCell (void);
void xaccInitComboCell (ComboCell *cell);
void xaccDestroyComboCell (ComboCell *cell);
void xaccSetComboCellValue (ComboCell *cell, const char *value);

View File

@ -106,8 +106,7 @@ typedef struct _DateCell
} DateCell;
/* installs a callback to handle date recording */
DateCell * xaccMallocDateCell (void);
void xaccDestroyDateCell (DateCell *cell);
BasicCell * xaccMallocDateCell (void);
/* days are 1-31, mon is 1-12, year 1900 == 1900 */
void xaccSetDateCellValue (DateCell *cell, int day, int mon, int year);

View File

@ -36,6 +36,7 @@
#include <gnome.h>
#include "QuickFill.h"
#include "combocell.h"
#include "gnc-engine-util.h"
#include "gnc-ui-util.h"
@ -77,14 +78,15 @@ typedef struct _PopBox
static void block_list_signals (ComboCell *cell);
static void unblock_list_signals (ComboCell *cell);
static void realizeCombo (BasicCell *bcell, gpointer w);
static void moveCombo (BasicCell *bcell, VirtualLocation virt_loc);
static void destroyCombo (BasicCell *bcell);
static gboolean enterCombo (BasicCell *bcell,
int *cursor_position,
int *start_selection,
int *end_selection);
static void leaveCombo (BasicCell *bcell);
static void combo_cell_gui_realize (BasicCell *bcell, gpointer w);
static void combo_cell_gui_move (BasicCell *bcell);
static void combo_cell_gui_destroy (BasicCell *bcell);
static gboolean combo_cell_enter (BasicCell *bcell,
int *cursor_position,
int *start_selection,
int *end_selection);
static void combo_cell_leave (BasicCell *bcell);
static void combo_cell_destroy (BasicCell *bcell);
/* This static indicates the debugging module that this .o belongs to. */
static short module = MOD_GTK_REG;
@ -93,7 +95,7 @@ static gboolean auto_pop_combos = FALSE;
/* =============================================== */
ComboCell *
BasicCell *
xaccMallocComboCell (void)
{
ComboCell * cell;
@ -102,7 +104,7 @@ xaccMallocComboCell (void)
xaccInitComboCell (cell);
return cell;
return &cell->cell;
}
void
@ -114,8 +116,10 @@ xaccInitComboCell (ComboCell *cell)
cell->cell.is_popup = TRUE;
cell->cell.realize = realizeCombo;
cell->cell.destroy = destroyCombo;
cell->cell.destroy = combo_cell_destroy;
cell->cell.gui_realize = combo_cell_gui_realize;
cell->cell.gui_destroy = combo_cell_gui_destroy;
box = g_new0 (PopBox, 1);
@ -266,12 +270,12 @@ unblock_list_signals (ComboCell *cell)
/* =============================================== */
static void
destroyCombo (BasicCell *bcell)
combo_cell_gui_destroy (BasicCell *bcell)
{
PopBox *box = bcell->gui_private;
ComboCell *cell = (ComboCell *) bcell;
if (cell->cell.realize == NULL)
if (cell->cell.gui_realize == NULL)
{
if (box != NULL && box->item_list != NULL)
{
@ -281,11 +285,11 @@ destroyCombo (BasicCell *bcell)
}
/* allow the widget to be shown again */
cell->cell.realize = realizeCombo;
cell->cell.move = NULL;
cell->cell.gui_realize = combo_cell_gui_realize;
cell->cell.gui_move = NULL;
cell->cell.enter_cell = NULL;
cell->cell.leave_cell = NULL;
cell->cell.destroy = NULL;
cell->cell.gui_destroy = NULL;
}
DEBUG("combo destroyed\n");
@ -301,12 +305,13 @@ menustring_free (gpointer string, gpointer user_data)
/* =============================================== */
void
xaccDestroyComboCell (ComboCell *cell)
static void
combo_cell_destroy (BasicCell *bcell)
{
ComboCell *cell = (ComboCell *) bcell;
PopBox *box = cell->cell.gui_private;
destroyCombo(&(cell->cell));
combo_cell_gui_destroy (&(cell->cell));
if (box != NULL)
{
@ -342,9 +347,7 @@ xaccDestroyComboCell (ComboCell *cell)
}
cell->cell.gui_private = NULL;
cell->cell.realize = NULL;
xaccDestroyBasicCell(&(cell->cell));
cell->cell.gui_realize = NULL;
}
/* =============================================== */
@ -727,7 +730,7 @@ ComboHelpValue (BasicCell *bcell)
/* =============================================== */
static void
realizeCombo (BasicCell *bcell, gpointer data)
combo_cell_gui_realize (BasicCell *bcell, gpointer data)
{
GnucashSheet *sheet = data;
GnomeCanvasItem *item = sheet->item_editor;
@ -743,11 +746,11 @@ realizeCombo (BasicCell *bcell, gpointer data)
gtk_object_sink (GTK_OBJECT(box->item_list));
/* to mark cell as realized, remove the realize method */
cell->cell.realize = NULL;
cell->cell.move = moveCombo;
cell->cell.enter_cell = enterCombo;
cell->cell.leave_cell = leaveCombo;
cell->cell.destroy = destroyCombo;
cell->cell.gui_realize = NULL;
cell->cell.gui_move = combo_cell_gui_move;
cell->cell.enter_cell = combo_cell_enter;
cell->cell.leave_cell = combo_cell_leave;
cell->cell.gui_destroy = combo_cell_gui_destroy;
cell->cell.modify_verify = ComboMV;
cell->cell.direct_update = ComboDirect;
cell->cell.get_help_value = ComboHelpValue;
@ -756,7 +759,7 @@ realizeCombo (BasicCell *bcell, gpointer data)
/* =============================================== */
static void
moveCombo (BasicCell *bcell, VirtualLocation virt_loc)
combo_cell_gui_move (BasicCell *bcell)
{
PopBox *box = bcell->gui_private;
@ -822,10 +825,10 @@ popup_get_width (GnomeCanvasItem *item,
}
static gboolean
enterCombo (BasicCell *bcell,
int *cursor_position,
int *start_selection,
int *end_selection)
combo_cell_enter (BasicCell *bcell,
int *cursor_position,
int *start_selection,
int *end_selection)
{
ComboCell *cell = (ComboCell *) bcell;
PopBox *box = bcell->gui_private;
@ -862,7 +865,7 @@ enterCombo (BasicCell *bcell,
/* =============================================== */
static void
leaveCombo (BasicCell *bcell)
combo_cell_leave (BasicCell *bcell)
{
PopBox *box = bcell->gui_private;

View File

@ -67,8 +67,9 @@ static void block_picker_signals (DateCell *cell);
static void unblock_picker_signals (DateCell *cell);
static void realizeDate (BasicCell *bcell, gpointer w);
static void setDateCellValue (BasicCell *bcell, const char *value);
static void moveDate (BasicCell *bcell, VirtualLocation virt_loc);
static void destroyDate (BasicCell *bcell);
static void moveDate (BasicCell *bcell);
static void date_cell_gui_destroy (BasicCell *bcell);
static void date_cell_destroy (BasicCell *bcell);
static void DateMV (BasicCell *_cell,
const GdkWChar *change,
int change_len,
@ -192,8 +193,10 @@ xaccInitDateCell (DateCell *cell)
cell->cell.is_popup = TRUE;
cell->cell.realize = realizeDate;
cell->cell.destroy = destroyDate;
cell->cell.destroy = date_cell_destroy;
cell->cell.gui_realize = realizeDate;
cell->cell.gui_destroy = date_cell_gui_destroy;
cell->cell.modify_verify = DateMV;
cell->cell.direct_update = DateDirect;
cell->cell.set_value = setDateCellValue;
@ -219,7 +222,7 @@ xaccInitDateCell (DateCell *cell)
xaccSetBasicCellValueInternal (&cell->cell, buff);
}
DateCell *
BasicCell *
xaccMallocDateCell (void)
{
DateCell *cell;
@ -228,7 +231,7 @@ xaccMallocDateCell (void)
xaccInitDateCell (cell);
return cell;
return &cell->cell;
}
/* =============================================== */
@ -353,12 +356,12 @@ unblock_picker_signals (DateCell *cell)
/* =============================================== */
static void
destroyDate (BasicCell *bcell)
date_cell_gui_destroy (BasicCell *bcell)
{
PopBox *box = bcell->gui_private;
DateCell *cell = (DateCell *) bcell;
if (cell->cell.realize == NULL)
if (cell->cell.gui_realize == NULL)
{
if (box != NULL && box->date_picker != NULL)
{
@ -368,11 +371,11 @@ destroyDate (BasicCell *bcell)
}
/* allow the widget to be shown again */
cell->cell.realize = realizeDate;
cell->cell.move = NULL;
cell->cell.gui_realize = realizeDate;
cell->cell.gui_move = NULL;
cell->cell.enter_cell = NULL;
cell->cell.leave_cell = NULL;
cell->cell.destroy = NULL;
cell->cell.gui_destroy = NULL;
}
DEBUG ("date destroyed\n");
@ -380,19 +383,18 @@ destroyDate (BasicCell *bcell)
/* =============================================== */
void
xaccDestroyDateCell (DateCell *cell)
static void
date_cell_destroy (BasicCell *bcell)
{
DateCell *cell = (DateCell *) bcell;
PopBox *box = cell->cell.gui_private;
destroyDate (&(cell->cell));
date_cell_gui_destroy (&(cell->cell));
g_free (box);
cell->cell.gui_private = NULL;
cell->cell.realize = NULL;
xaccDestroyBasicCell (&(cell->cell));
cell->cell.gui_realize = NULL;
}
/* =============================================== */
@ -800,8 +802,8 @@ realizeDate (BasicCell *bcell, gpointer data)
gtk_object_sink (GTK_OBJECT(box->date_picker));
/* to mark cell as realized, remove the realize method */
cell->cell.realize = NULL;
cell->cell.move = moveDate;
cell->cell.gui_realize = NULL;
cell->cell.gui_move = moveDate;
cell->cell.enter_cell = enterDate;
cell->cell.leave_cell = leaveDate;
}
@ -809,7 +811,7 @@ realizeDate (BasicCell *bcell, gpointer data)
/* =============================================== */
static void
moveDate (BasicCell *bcell, VirtualLocation virt_loc)
moveDate (BasicCell *bcell)
{
PopBox *box = bcell->gui_private;

View File

@ -207,17 +207,6 @@ set_dimensions_pass_one (GnucashSheet *sheet, CellBlock *cursor,
else
width = 0;
text = cb_cell->label;
if (text)
{
int label_width;
label_width = gdk_string_width (font, text);
label_width += 2 * CELL_HPADDING;
width = MAX (width, label_width);
}
if (cb_cell->cell && cb_cell->cell->is_popup)
width += item_edit_get_toggle_offset
(cd->pixel_height);

View File

@ -159,7 +159,7 @@ NumMV (BasicCell *_cell,
}
/* ================================================ */
NumCell *
BasicCell *
xaccMallocNumCell (void)
{
NumCell *cell;
@ -168,14 +168,7 @@ xaccMallocNumCell (void)
xaccInitNumCell (cell);
return cell;
}
/* ================================================ */
void
xaccDestroyNumCell (NumCell *cell)
{
xaccDestroyBasicCell (&(cell->cell));
return &cell->cell;
}
/* ================================================ */

View File

@ -29,7 +29,7 @@
* supports a number of accelerator keys for number entry.
*
* HISTORY:
* Copyright (c) 2000 Dave Peticolas <peticola@cs.ucdavis.edu>
* Copyright (c) 2000 Dave Peticolas <dave@krondo.com>
*/
#ifndef NUM_CELL_H
@ -44,8 +44,7 @@ typedef struct _NumCell
gboolean next_num_set;
} NumCell;
NumCell * xaccMallocNumCell (void);
void xaccDestroyNumCell (NumCell *cell);
BasicCell * xaccMallocNumCell (void);
void xaccSetNumCellValue (NumCell *cell, const char *str);
gboolean xaccSetNumCellLastNum (NumCell *cell, const char *str);

View File

@ -191,7 +191,7 @@ PriceHelp (BasicCell *bcell)
/* ================================================ */
PriceCell *
BasicCell *
xaccMallocPriceCell (void)
{
PriceCell *cell;
@ -200,7 +200,7 @@ xaccMallocPriceCell (void)
xaccInitPriceCell (cell);
return cell;
return &cell->cell;
}
/* ================================================ */
@ -229,15 +229,6 @@ xaccInitPriceCell (PriceCell *cell)
/* ================================================ */
void
xaccDestroyPriceCell (PriceCell *cell)
{
cell->amount = gnc_numeric_zero ();
xaccDestroyBasicCell (&(cell->cell));
}
/* ================================================ */
static const char *
xaccPriceCellPrintValue (PriceCell *cell)
{

View File

@ -32,27 +32,13 @@
*
* By default, the PriceCell is an input/output cell.
*
* On input, this cell accepts only numeric characters
* and numeric punctuation. The punctuation accepted is *not*
* currently internationalized. Read the source for details.
*
* On output, it will display a numeric value using its current
* format string. The default format string prints two decimal
* places. The format string can be set with the
* xaccSetPriceCellFormat() method.
*
* hack alert -- implement internationalization.
*
* On output, it will display negative values in red text.
* hack alert -- the actual color (red) should be user configurable.
*
* The stored amount is stored as a double-precision floating point
* variable. This should be sufficient precision to store trillions of
* dollars with penny accuracy.
*
* HISTORY:
* Copyright (c) 1998, 1999, 2000 Linas Vepstas
* Copyright (c) 2000 Dave Peticolas
* Copyright (c) 2001 Free Software Foundation
*/
#ifndef __PRICE_CELL_C__
@ -79,8 +65,7 @@ typedef struct _PriceCell
} PriceCell;
/* installs a callback to handle price recording */
PriceCell * xaccMallocPriceCell (void);
void xaccDestroyPriceCell (PriceCell *cell);
BasicCell * xaccMallocPriceCell (void);
/* return the value of a price cell */
gnc_numeric xaccGetPriceCellValue (PriceCell *cell);

View File

@ -247,21 +247,26 @@ quick_leave (BasicCell * _cell)
/* ================================================ */
QuickFillCell *
xaccMallocQuickFillCell (void)
static void
quickfill_cell_destroy (BasicCell *bcell)
{
QuickFillCell *cell;
QuickFillCell *cell = (QuickFillCell *) bcell;
cell = g_new0 (QuickFillCell, 1);
gnc_quickfill_destroy (cell->qf);
cell->qf = NULL;
xaccInitQuickFillCell (cell);
g_free (cell->original);
cell->original = NULL;
return cell;
cell->cell.enter_cell = NULL;
cell->cell.modify_verify = NULL;
cell->cell.leave_cell = NULL;
cell->cell.set_value = NULL;
}
/* ================================================ */
void
static void
xaccInitQuickFillCell (QuickFillCell *cell)
{
xaccInitBasicCell (&(cell->cell));
@ -270,6 +275,8 @@ xaccInitQuickFillCell (QuickFillCell *cell)
cell->sort = QUICKFILL_LIFO;
cell->original = NULL;
cell->cell.destroy = quickfill_cell_destroy;
cell->cell.enter_cell = quick_enter;
cell->cell.modify_verify = quick_modify;
cell->cell.leave_cell = quick_leave;
@ -280,21 +287,16 @@ xaccInitQuickFillCell (QuickFillCell *cell)
/* ================================================ */
void
xaccDestroyQuickFillCell (QuickFillCell *cell)
BasicCell *
xaccMallocQuickFillCell (void)
{
gnc_quickfill_destroy (cell->qf);
cell->qf = NULL;
QuickFillCell *cell;
g_free (cell->original);
cell->original = NULL;
cell = g_new0 (QuickFillCell, 1);
cell->cell.enter_cell = NULL;
cell->cell.modify_verify = NULL;
cell->cell.leave_cell = NULL;
cell->cell.set_value = NULL;
xaccInitQuickFillCell (cell);
xaccDestroyBasicCell (&(cell->cell));
return &cell->cell;
}
/* ================================================ */

View File

@ -61,9 +61,7 @@ typedef struct _QuickFillCell
GdkWChar *original; /* original string entered in original case */
} QuickFillCell;
QuickFillCell * xaccMallocQuickFillCell (void);
void xaccInitQuickFillCell (QuickFillCell *cell);
void xaccDestroyQuickFillCell (QuickFillCell *cell);
BasicCell * xaccMallocQuickFillCell (void);
void xaccSetQuickFillCellValue (QuickFillCell *cell,
const char *value);

View File

@ -112,7 +112,7 @@ xaccInitRecnCell (RecnCell *cell)
cell->cell.set_value = RecnSetValue;
}
RecnCell *
BasicCell *
xaccMallocRecnCell (void)
{
RecnCell * cell;
@ -121,7 +121,7 @@ xaccMallocRecnCell (void)
xaccInitRecnCell (cell);
return cell;
return &cell->cell;
}
/* ================================================ */
@ -160,17 +160,6 @@ RecnSetValue (BasicCell *_cell, const char *value)
/* ================================================ */
void
xaccDestroyRecnCell (RecnCell *cell)
{
if (!cell)
return;
xaccDestroyBasicCell (&cell->cell);
}
/* ================================================ */
void
xaccRecnCellSetFlag (RecnCell *cell, char reconciled_flag)
{

View File

@ -57,8 +57,7 @@ typedef struct _RecnCell
gpointer confirm_data;
} RecnCell;
RecnCell * xaccMallocRecnCell (void);
void xaccDestroyRecnCell (RecnCell *cell);
BasicCell * xaccMallocRecnCell (void);
void xaccRecnCellSetFlag (RecnCell *cell, char reconciled_flag);
char xaccRecnCellGetFlag (RecnCell *cell);

View File

@ -21,8 +21,78 @@
* *
\********************************************************************/
#include "register-common.h"
#include "config.h"
#include "basiccell.h"
#include "cell-factory.h"
#include "combocell.h"
#include "datecell.h"
#include "numcell.h"
#include "pricecell.h"
#include "recncell.h"
#include "register-common.h"
#include "textcell.h"
#include "quickfillcell.h"
static gboolean register_inited = FALSE;
static CellFactory *global_factory = NULL;
void
gnc_register_init (void)
{
if (register_inited)
return;
register_inited = TRUE;
global_factory = gnc_cell_factory_new ();
gnc_register_add_cell_type (BASIC_CELL_TYPE_NAME, xaccMallocBasicCell);
gnc_register_add_cell_type (COMBO_CELL_TYPE_NAME, xaccMallocComboCell);
gnc_register_add_cell_type (DATE_CELL_TYPE_NAME, xaccMallocDateCell);
gnc_register_add_cell_type (NUM_CELL_TYPE_NAME, xaccMallocNumCell);
gnc_register_add_cell_type (PRICE_CELL_TYPE_NAME, xaccMallocPriceCell);
gnc_register_add_cell_type (RECN_CELL_TYPE_NAME, xaccMallocRecnCell);
gnc_register_add_cell_type (TEXT_CELL_TYPE_NAME, xaccMallocTextCell);
gnc_register_add_cell_type (QUICKFILL_CELL_TYPE_NAME,
xaccMallocQuickFillCell);
}
void
gnc_register_shutdown (void)
{
if (!register_inited)
return;
gnc_cell_factory_destroy (global_factory);
global_factory = NULL;
}
void
gnc_register_add_cell_type (const char *cell_type_name,
CellCreateFunc cell_creator)
{
gnc_register_init ();
gnc_cell_factory_add_cell_type (global_factory,
cell_type_name, cell_creator);
}
BasicCell *
gnc_register_make_cell (const char *cell_type_name)
{
gnc_register_init ();
return gnc_cell_factory_make_cell (global_factory, cell_type_name);
}
gboolean
virt_cell_loc_equal (VirtualCellLocation vcl1, VirtualCellLocation vcl2)

View File

@ -26,6 +26,24 @@
#include <glib.h>
#include "basiccell.h"
#define BASIC_CELL_TYPE_NAME "basic-cell"
#define COMBO_CELL_TYPE_NAME "combo-cell"
#define DATE_CELL_TYPE_NAME "date-cell"
#define NUM_CELL_TYPE_NAME "num-cell"
#define PRICE_CELL_TYPE_NAME "price-cell"
#define RECN_CELL_TYPE_NAME "recn-cell"
#define TEXT_CELL_TYPE_NAME "text-cell"
#define QUICKFILL_CELL_TYPE_NAME "quickfill-cell"
void gnc_register_init (void);
void gnc_register_shutdown (void);
void gnc_register_add_cell_type (const char *cell_type_name,
CellCreateFunc cell_creator);
BasicCell * gnc_register_make_cell (const char *cell_type_name);
/* The VirtualCellLocation structure contains the virtual
* location of a virtual cell.

View File

@ -46,41 +46,35 @@
#include "gnc-engine-util.h"
#include "messages.h"
#include "recncell.h"
#include "splitreg.h"
#include "table-allgui.h"
#include "textcell.h"
/* FIXME: these shouldn't be here */
#include "combocell.h"
#include "pricecell.h"
#include "recncell.h"
/* This static indicates the debugging module that this .o belongs to. */
static short module = MOD_REGISTER;
typedef struct cell_node
{
CellType cell_type;
BasicCell *cell;
} CellNode;
typedef struct _CellBuffer CellBuffer;
struct _CellBuffer
{
CellType cell_type;
char * value;
guint32 changed;
guint32 conditionally_changed;
};
struct _SplitRegisterBuffer
struct _RegisterBuffer
{
CellBuffer dateCell;
CellBuffer numCell;
CellBuffer descCell;
CellBuffer recnCell;
CellBuffer balanceCell;
CellBuffer actionCell;
CellBuffer xfrmCell;
CellBuffer memoCell;
CellBuffer creditCell;
CellBuffer debitCell;
CellBuffer priceCell;
CellBuffer sharesCell;
CellBuffer mxfrmCell;
CellBuffer notesCell;
CellBuffer formCreditCell;
CellBuffer formDebitCell;
GList *buffers;
};
typedef struct
@ -147,6 +141,114 @@ xaccInitSplitRegister (SplitRegister *reg,
gboolean templateMode);
static void
gnc_register_add_cell (SplitRegister *sr,
CellType cell_type,
const char *cell_type_name)
{
BasicCell *cell;
CellNode *node;
g_return_if_fail (sr != NULL);
g_return_if_fail (cell_type_name != NULL);
cell = gnc_register_make_cell (cell_type_name);
node = g_new0 (CellNode, 1);
node->cell_type = cell_type;
node->cell = cell;
sr->cells = g_list_prepend (sr->cells, node);
}
BasicCell *
gnc_register_get_cell (SplitRegister *sr, CellType cell_type)
{
GList *node;
g_return_val_if_fail (sr != NULL, NULL);
for (node = sr->cells; node; node = node->next)
{
CellNode *cn = node->data;
if (cn->cell_type == cell_type)
return cn->cell;
}
return NULL;
}
const char *
gnc_register_get_cell_value (SplitRegister *sr, CellType cell_type)
{
BasicCell *cell;
cell = gnc_register_get_cell (sr, cell_type);
if (!cell) return NULL;
return gnc_basic_cell_get_value (cell);
}
gboolean
gnc_register_get_cursor_changed (SplitRegister *sr,
gboolean include_conditional)
{
GList *node;
if (!sr) return FALSE;
for (node = sr->cells; node; node = node->next)
{
CellNode *cn = node->data;
if (gnc_basic_cell_get_changed (cn->cell))
return TRUE;
if (include_conditional &&
gnc_basic_cell_get_conditionally_changed (cn->cell))
return TRUE;
}
return FALSE;
}
gboolean
gnc_register_get_cell_changed (SplitRegister *sr,
CellType cell_type,
gboolean include_conditional)
{
BasicCell *cell;
if (!sr) return FALSE;
cell = gnc_register_get_cell (sr, cell_type);
if (!cell) return FALSE;
if (!include_conditional)
return gnc_basic_cell_get_changed (cell);
else
return (gnc_basic_cell_get_changed (cell) ||
gnc_basic_cell_get_conditionally_changed (cell));
}
void
gnc_register_clear_changes (SplitRegister *sr)
{
GList *node;
if (!sr) return;
for (node = sr->cells; node; node = node->next)
{
CellNode *cn = node->data;
gnc_basic_cell_set_changed (cn->cell, FALSE);
gnc_basic_cell_set_conditionally_changed (cn->cell, FALSE);
}
}
/* ============================================== */
/* configAction strings into the action cell */
/* hack alert -- this stuff really, really should be in a config file ... */
@ -154,95 +256,99 @@ xaccInitSplitRegister (SplitRegister *reg,
static void
configAction (SplitRegister *reg)
{
ComboCell *cell;
cell = (ComboCell *) gnc_register_get_cell (reg, ACTN_CELL);
/* setup strings in the action pull-down */
switch (reg->type)
{
case BANK_REGISTER:
/* broken ! FIXME bg */
case SEARCH_LEDGER:
xaccAddComboCellMenuItem (reg->actionCell, _("Deposit"));
xaccAddComboCellMenuItem (reg->actionCell, _("Withdraw"));
xaccAddComboCellMenuItem (reg->actionCell, _("Check"));
xaccAddComboCellMenuItem (reg->actionCell, _("Int"));
xaccAddComboCellMenuItem (reg->actionCell, _("ATM"));
xaccAddComboCellMenuItem (reg->actionCell, _("Teller"));
xaccAddComboCellMenuItem (cell, _("Deposit"));
xaccAddComboCellMenuItem (cell, _("Withdraw"));
xaccAddComboCellMenuItem (cell, _("Check"));
xaccAddComboCellMenuItem (cell, _("Int"));
xaccAddComboCellMenuItem (cell, _("ATM"));
xaccAddComboCellMenuItem (cell, _("Teller"));
/* Action: Point Of Sale */
xaccAddComboCellMenuItem (reg->actionCell, _("POS"));
xaccAddComboCellMenuItem (reg->actionCell, _("Phone"));
xaccAddComboCellMenuItem (reg->actionCell, _("Online"));
xaccAddComboCellMenuItem (cell, _("POS"));
xaccAddComboCellMenuItem (cell, _("Phone"));
xaccAddComboCellMenuItem (cell, _("Online"));
/* Action: Automatic Deposit ?!? */
xaccAddComboCellMenuItem (reg->actionCell, _("AutoDep"));
xaccAddComboCellMenuItem (reg->actionCell, _("Wire"));
xaccAddComboCellMenuItem (reg->actionCell, _("Credit"));
xaccAddComboCellMenuItem (reg->actionCell, _("Direct Debit"));
xaccAddComboCellMenuItem (reg->actionCell, _("Transfer"));
xaccAddComboCellMenuItem (cell, _("AutoDep"));
xaccAddComboCellMenuItem (cell, _("Wire"));
xaccAddComboCellMenuItem (cell, _("Credit"));
xaccAddComboCellMenuItem (cell, _("Direct Debit"));
xaccAddComboCellMenuItem (cell, _("Transfer"));
break;
case CASH_REGISTER:
xaccAddComboCellMenuItem (reg->actionCell, _("Buy"));
xaccAddComboCellMenuItem (reg->actionCell, _("Sell"));
xaccAddComboCellMenuItem (cell, _("Buy"));
xaccAddComboCellMenuItem (cell, _("Sell"));
break;
case ASSET_REGISTER:
xaccAddComboCellMenuItem (reg->actionCell, _("Buy"));
xaccAddComboCellMenuItem (reg->actionCell, _("Sell"));
xaccAddComboCellMenuItem (reg->actionCell, _("Fee"));
xaccAddComboCellMenuItem (cell, _("Buy"));
xaccAddComboCellMenuItem (cell, _("Sell"));
xaccAddComboCellMenuItem (cell, _("Fee"));
break;
case CREDIT_REGISTER:
xaccAddComboCellMenuItem (reg->actionCell, _("ATM"));
xaccAddComboCellMenuItem (reg->actionCell, _("Buy"));
xaccAddComboCellMenuItem (reg->actionCell, _("Credit"));
xaccAddComboCellMenuItem (reg->actionCell, _("Fee"));
xaccAddComboCellMenuItem (reg->actionCell, _("Int"));
xaccAddComboCellMenuItem (reg->actionCell, _("Online"));
xaccAddComboCellMenuItem (reg->actionCell, _("Sell"));
xaccAddComboCellMenuItem (cell, _("ATM"));
xaccAddComboCellMenuItem (cell, _("Buy"));
xaccAddComboCellMenuItem (cell, _("Credit"));
xaccAddComboCellMenuItem (cell, _("Fee"));
xaccAddComboCellMenuItem (cell, _("Int"));
xaccAddComboCellMenuItem (cell, _("Online"));
xaccAddComboCellMenuItem (cell, _("Sell"));
break;
case LIABILITY_REGISTER:
xaccAddComboCellMenuItem (reg->actionCell, _("Buy"));
xaccAddComboCellMenuItem (reg->actionCell, _("Sell"));
xaccAddComboCellMenuItem (reg->actionCell, _("Loan"));
xaccAddComboCellMenuItem (reg->actionCell, _("Int"));
xaccAddComboCellMenuItem (reg->actionCell, _("Payment"));
xaccAddComboCellMenuItem (cell, _("Buy"));
xaccAddComboCellMenuItem (cell, _("Sell"));
xaccAddComboCellMenuItem (cell, _("Loan"));
xaccAddComboCellMenuItem (cell, _("Int"));
xaccAddComboCellMenuItem (cell, _("Payment"));
break;
case INCOME_LEDGER:
case INCOME_REGISTER:
xaccAddComboCellMenuItem (reg->actionCell, _("Buy"));
xaccAddComboCellMenuItem (reg->actionCell, _("Sell"));
xaccAddComboCellMenuItem (reg->actionCell, _("Int"));
xaccAddComboCellMenuItem (reg->actionCell, _("Payment"));
xaccAddComboCellMenuItem (reg->actionCell, _("Rebate"));
xaccAddComboCellMenuItem (cell, _("Buy"));
xaccAddComboCellMenuItem (cell, _("Sell"));
xaccAddComboCellMenuItem (cell, _("Int"));
xaccAddComboCellMenuItem (cell, _("Payment"));
xaccAddComboCellMenuItem (cell, _("Rebate"));
break;
case EXPENSE_REGISTER:
xaccAddComboCellMenuItem (reg->actionCell, _("Buy"));
xaccAddComboCellMenuItem (reg->actionCell, _("Sell"));
xaccAddComboCellMenuItem (cell, _("Buy"));
xaccAddComboCellMenuItem (cell, _("Sell"));
break;
case GENERAL_LEDGER:
case EQUITY_REGISTER:
xaccAddComboCellMenuItem (reg->actionCell, _("Buy"));
xaccAddComboCellMenuItem (reg->actionCell, _("Sell"));
xaccAddComboCellMenuItem (reg->actionCell, _("Equity"));
xaccAddComboCellMenuItem (cell, _("Buy"));
xaccAddComboCellMenuItem (cell, _("Sell"));
xaccAddComboCellMenuItem (cell, _("Equity"));
break;
case STOCK_REGISTER:
case PORTFOLIO_LEDGER:
case CURRENCY_REGISTER:
xaccAddComboCellMenuItem (reg->actionCell, _("Buy"));
xaccAddComboCellMenuItem (reg->actionCell, _("Sell"));
xaccAddComboCellMenuItem (reg->actionCell, _("Price"));
xaccAddComboCellMenuItem (reg->actionCell, _("Fee"));
xaccAddComboCellMenuItem (cell, _("Buy"));
xaccAddComboCellMenuItem (cell, _("Sell"));
xaccAddComboCellMenuItem (cell, _("Price"));
xaccAddComboCellMenuItem (cell, _("Fee"));
/* Action: Dividend */
xaccAddComboCellMenuItem (reg->actionCell, _("Div"));
xaccAddComboCellMenuItem (reg->actionCell, _("Int"));
xaccAddComboCellMenuItem (cell, _("Div"));
xaccAddComboCellMenuItem (cell, _("Int"));
/* Action: Long Term Capital Gains */
xaccAddComboCellMenuItem (reg->actionCell, _("LTCG"));
xaccAddComboCellMenuItem (cell, _("LTCG"));
/* Action: Short Term Capital Gains */
xaccAddComboCellMenuItem (reg->actionCell, _("STCG"));
xaccAddComboCellMenuItem (reg->actionCell, _("Income"));
xaccAddComboCellMenuItem (cell, _("STCG"));
xaccAddComboCellMenuItem (cell, _("Income"));
/* Action: Distribution */
xaccAddComboCellMenuItem (reg->actionCell, _("Dist"));
xaccAddComboCellMenuItem (reg->actionCell, _("Split"));
xaccAddComboCellMenuItem (cell, _("Dist"));
xaccAddComboCellMenuItem (cell, _("Split"));
break;
default:
xaccAddComboCellMenuItem (reg->actionCell, _("Buy"));
xaccAddComboCellMenuItem (reg->actionCell, _("Sell"));
xaccAddComboCellMenuItem (cell, _("Buy"));
xaccAddComboCellMenuItem (cell, _("Sell"));
break;
}
}
@ -254,7 +360,6 @@ set_cell (SplitRegister *reg, CellBlock *cursor,
CellType cell_type, short row, short col)
{
CellBlockCell *cb_cell;
BasicCell *hcell;
sample_string *ss;
ss = &cell_sample_strings[cell_type];
@ -265,35 +370,25 @@ set_cell (SplitRegister *reg, CellBlock *cursor,
reg->cursor_header->start_col = MIN (reg->cursor_header->start_col, col);
reg->cursor_header->stop_col = MAX (reg->cursor_header->stop_col, col);
hcell = reg->header_cells[cell_type];
cb_cell = gnc_cellblock_get_cell (cursor, row, col);
cb_cell->cell = reg->cells[cell_type];
cb_cell->cell = gnc_register_get_cell (reg, cell_type);
cb_cell->cell_type = cell_type;
cb_cell->label = g_strdup (hcell->value);
cb_cell->sample_text = g_strdup (_(ss->string + ss->offset));
cb_cell->sample_text = g_strdup (_(ss->string) + ss->offset);
cb_cell->alignment = cell_alignments[cell_type];
cb_cell->expandable =
reg->cells[cell_type] == (BasicCell *) reg->descCell;
cb_cell->span =
reg->cells[cell_type] == (BasicCell *) reg->memoCell ||
reg->cells[cell_type] == (BasicCell *) reg->notesCell;
cb_cell->expandable = cell_type == DESC_CELL;
cb_cell->span = cell_type == MEMO_CELL || cell_type == NOTES_CELL;
cb_cell = gnc_cellblock_get_cell (reg->cursor_header, row, col);
if (cb_cell && (cursor == reg->cursor_ledger_single))
{
cb_cell->cell = reg->cells[cell_type];
cb_cell->cell = gnc_register_get_cell (reg, cell_type);
cb_cell->cell_type = cell_type;
cb_cell->label = g_strdup (hcell->value);
cb_cell->sample_text = g_strdup (_(ss->string + ss->offset));
cb_cell->sample_text = g_strdup (_(ss->string) + ss->offset);
cb_cell->alignment = cell_alignments[cell_type];
cb_cell->expandable =
reg->cells[cell_type] == (BasicCell *) reg->descCell;
cb_cell->span =
reg->cells[cell_type] == (BasicCell *) reg->memoCell ||
reg->cells[cell_type] == (BasicCell *) reg->notesCell;
cb_cell->expandable = cell_type == DESC_CELL;
cb_cell->span = cell_type == MEMO_CELL || cell_type == NOTES_CELL;
}
}
@ -570,11 +665,11 @@ configLayout (SplitRegister *reg)
/* ============================================== */
SplitRegister *
xaccMallocSplitRegister (SplitRegisterType type,
SplitRegisterStyle style,
gboolean use_double_line,
TableModel *model,
gboolean templateMode)
gnc_register_new (SplitRegisterType type,
SplitRegisterStyle style,
gboolean use_double_line,
TableModel *model,
gboolean templateMode)
{
SplitRegister * reg;
@ -658,10 +753,6 @@ mallocCursors (SplitRegister *reg)
/* ============================================== */
#define NEW(NAME, CN, TYPE) \
reg->CN##Cell = xaccMalloc##TYPE##Cell(); \
reg->cells[NAME##_CELL] = (BasicCell *) reg->CN##Cell;
static void
xaccInitSplitRegister (SplitRegister *reg,
SplitRegisterType type,
@ -685,40 +776,31 @@ xaccInitSplitRegister (SplitRegister *reg,
/* define the number of columns in the display, malloc the cursors */
mallocCursors (reg);
/* --------------------------- */
/* malloc the header (label) cells */
{
int i;
for (i = 0; i < CELL_TYPE_COUNT; i++)
reg->header_cells[i] = xaccMallocTextCell ();
}
/* --------------------------- */
/* malloc the workhorse cells */
reg->nullCell = xaccMallocBasicCell ();
reg->nullCell = gnc_register_make_cell (BASIC_CELL_TYPE_NAME);
NEW (DATE, date, Date);
NEW (NUM, num, Num);
NEW (DESC, desc, QuickFill);
NEW (RECN, recn, Recn);
NEW (BALN, balance, Price);
NEW (XFRM, xfrm, Combo);
NEW (ACTN, action, Combo);
NEW (MEMO, memo, QuickFill);
NEW (CRED, credit, Price);
NEW (DEBT, debit, Price);
NEW (PRIC, price, Price);
NEW (SHRS, shares, Price);
NEW (MXFRM, mxfrm, Combo);
NEW (TCRED, tcredit, Price);
NEW (TDEBT, tdebit, Price);
NEW (TSHRS, tshares, Price);
NEW (TBALN, tbalance, Price);
NEW (NOTES, notes, QuickFill);
NEW (FCRED, formCredit, QuickFill);
NEW (FDEBT, formDebit, QuickFill);
gnc_register_add_cell (reg, DATE_CELL, DATE_CELL_TYPE_NAME);
gnc_register_add_cell (reg, NUM_CELL, NUM_CELL_TYPE_NAME);
gnc_register_add_cell (reg, DESC_CELL, QUICKFILL_CELL_TYPE_NAME);
gnc_register_add_cell (reg, RECN_CELL, RECN_CELL_TYPE_NAME);
gnc_register_add_cell (reg, BALN_CELL, PRICE_CELL_TYPE_NAME);
gnc_register_add_cell (reg, XFRM_CELL, COMBO_CELL_TYPE_NAME);
gnc_register_add_cell (reg, ACTN_CELL, COMBO_CELL_TYPE_NAME);
gnc_register_add_cell (reg, MEMO_CELL, QUICKFILL_CELL_TYPE_NAME);
gnc_register_add_cell (reg, CRED_CELL, PRICE_CELL_TYPE_NAME);
gnc_register_add_cell (reg, DEBT_CELL, PRICE_CELL_TYPE_NAME);
gnc_register_add_cell (reg, PRIC_CELL, PRICE_CELL_TYPE_NAME);
gnc_register_add_cell (reg, SHRS_CELL, PRICE_CELL_TYPE_NAME);
gnc_register_add_cell (reg, MXFRM_CELL, COMBO_CELL_TYPE_NAME);
gnc_register_add_cell (reg, TCRED_CELL, PRICE_CELL_TYPE_NAME);
gnc_register_add_cell (reg, TDEBT_CELL, PRICE_CELL_TYPE_NAME);
gnc_register_add_cell (reg, TSHRS_CELL, PRICE_CELL_TYPE_NAME);
gnc_register_add_cell (reg, TBALN_CELL, PRICE_CELL_TYPE_NAME);
gnc_register_add_cell (reg, NOTES_CELL, QUICKFILL_CELL_TYPE_NAME);
gnc_register_add_cell (reg, FCRED_CELL, QUICKFILL_CELL_TYPE_NAME);
gnc_register_add_cell (reg, FDEBT_CELL, QUICKFILL_CELL_TYPE_NAME);
/* --------------------------- */
@ -733,7 +815,7 @@ xaccInitSplitRegister (SplitRegister *reg,
xaccSetBasicCellValue (reg->nullCell, "");
/* The num cell is the transaction number */
xaccSetBasicCellBlankHelp (&reg->numCell->cell,
xaccSetBasicCellBlankHelp (gnc_register_get_cell (reg, NUM_CELL),
_("Enter the transaction number, such as the "
"check number"));
@ -741,15 +823,16 @@ xaccInitSplitRegister (SplitRegister *reg,
{
const char *help = _("Enter the account to transfer from, or choose "
"one from the list");
xaccSetBasicCellBlankHelp (&reg->mxfrmCell->cell, help);
xaccSetBasicCellBlankHelp (&reg->xfrmCell->cell, help);
xaccSetBasicCellBlankHelp (gnc_register_get_cell (reg, MXFRM_CELL), help);
xaccSetBasicCellBlankHelp (gnc_register_get_cell (reg, XFRM_CELL), help);
}
{
const char *help = _("This transaction has multiple splits; "
"press the Split button to see them all");
xaccComboCellAddIgnoreString (reg->mxfrmCell,
xaccComboCellAddIgnoreString ((ComboCell *)
gnc_register_get_cell (reg, MXFRM_CELL),
_("-- Split Transaction --"), help);
}
@ -757,47 +840,48 @@ xaccInitSplitRegister (SplitRegister *reg,
const char *help = _("This transaction is a stock split; "
"press the Split button to see details");
xaccComboCellAddIgnoreString (reg->mxfrmCell,
xaccComboCellAddIgnoreString ((ComboCell *)
gnc_register_get_cell (reg, MXFRM_CELL),
_("-- Stock Split --"), help);
}
/* the action cell */
xaccComboCellSetAutoSize (reg->actionCell, TRUE);
xaccComboCellSetAutoSize ((ComboCell *)
gnc_register_get_cell (reg, ACTN_CELL), TRUE);
/* the memo cell */
xaccSetBasicCellBlankHelp (&reg->memoCell->cell,
xaccSetBasicCellBlankHelp (gnc_register_get_cell (reg, MEMO_CELL),
_("Enter a description of the split"));
/* the desc cell */
xaccSetBasicCellBlankHelp (&reg->descCell->cell,
xaccSetBasicCellBlankHelp (gnc_register_get_cell (reg, DESC_CELL),
_("Enter a description of the transaction"));
/* the notes cell */
xaccSetBasicCellBlankHelp (&reg->notesCell->cell,
xaccSetBasicCellBlankHelp (gnc_register_get_cell (reg, NOTES_CELL),
_("Enter notes for the transaction"));
/* the formula cell */
xaccSetBasicCellBlankHelp( &reg->formCreditCell->cell,
xaccSetBasicCellBlankHelp (gnc_register_get_cell (reg, FCRED_CELL),
_("Enter credit formula for real transaction"));
xaccSetBasicCellBlankHelp( &reg->formDebitCell->cell,
xaccSetBasicCellBlankHelp (gnc_register_get_cell (reg, FDEBT_CELL),
_("Enter debit formula for real transaction"));
/* Use 6 decimal places for prices */
xaccSetPriceCellFraction (reg->priceCell, 1000000);
/* Initialize price cells */
xaccSetPriceCellValue (reg->debitCell, gnc_numeric_zero ());
xaccSetPriceCellValue (reg->creditCell, gnc_numeric_zero ());
xaccSetPriceCellValue (reg->sharesCell, gnc_numeric_zero ());
xaccSetPriceCellFraction ((PriceCell *)
gnc_register_get_cell (reg, PRIC_CELL), 1000000);
/* Initialize shares and share balance cells */
xaccSetPriceCellPrintInfo
(reg->sharesCell, gnc_default_share_print_info ());
((PriceCell *) gnc_register_get_cell (reg, SHRS_CELL),
gnc_default_share_print_info ());
xaccSetPriceCellPrintInfo
(reg->tsharesCell, gnc_default_share_print_info ());
((PriceCell *) gnc_register_get_cell (reg, TSHRS_CELL),
gnc_default_share_print_info ());
/* The action cell should accept strings not in the list */
xaccComboCellSetStrict (reg->actionCell, FALSE);
xaccSetBasicCellBlankHelp (&reg->actionCell->cell,
xaccComboCellSetStrict ((ComboCell *)
gnc_register_get_cell (reg, ACTN_CELL), FALSE);
xaccSetBasicCellBlankHelp (gnc_register_get_cell (reg, ACTN_CELL),
_("Enter the type of transaction, or choose "
"one from the list"));
@ -807,12 +891,13 @@ xaccInitSplitRegister (SplitRegister *reg,
case CURRENCY_REGISTER:
case STOCK_REGISTER:
case PORTFOLIO_LEDGER:
xaccSetPriceCellPrintInfo (reg->priceCell,
xaccSetPriceCellPrintInfo ((PriceCell *)
gnc_register_get_cell (reg, PRIC_CELL),
gnc_default_price_print_info ());
xaccSetBasicCellBlankHelp (&reg->priceCell->cell,
xaccSetBasicCellBlankHelp (gnc_register_get_cell (reg, PRIC_CELL),
_("Enter the share price"));
xaccSetBasicCellBlankHelp (&reg->sharesCell->cell,
xaccSetBasicCellBlankHelp (gnc_register_get_cell (reg, SHRS_CELL),
_("Enter the number of shares bought or "
"sold"));
break;
@ -886,7 +971,7 @@ xaccConfigSplitRegister (SplitRegister *reg,
void
xaccDestroySplitRegister (SplitRegister *reg)
{
int i;
GList *node;
/* give the user a chance to clean up */
if (reg->destroy)
@ -912,60 +997,20 @@ xaccDestroySplitRegister (SplitRegister *reg)
reg->cursor_journal_double = NULL;
reg->cursor_split = NULL;
xaccDestroyBasicCell (reg->nullCell);
xaccDestroyDateCell (reg->dateCell);
xaccDestroyNumCell (reg->numCell);
xaccDestroyQuickFillCell (reg->descCell);
xaccDestroyRecnCell (reg->recnCell);
xaccDestroyPriceCell (reg->balanceCell);
xaccDestroyComboCell (reg->actionCell);
xaccDestroyComboCell (reg->xfrmCell);
xaccDestroyQuickFillCell (reg->memoCell);
xaccDestroyPriceCell (reg->creditCell);
xaccDestroyPriceCell (reg->debitCell);
xaccDestroyPriceCell (reg->priceCell);
xaccDestroyPriceCell (reg->sharesCell);
xaccDestroyComboCell (reg->mxfrmCell);
xaccDestroyPriceCell (reg->tcreditCell);
xaccDestroyPriceCell (reg->tdebitCell);
xaccDestroyPriceCell (reg->tsharesCell);
xaccDestroyPriceCell (reg->tbalanceCell);
xaccDestroyQuickFillCell (reg->notesCell);
xaccDestroyQuickFillCell (reg->formCreditCell);
xaccDestroyQuickFillCell (reg->formDebitCell);
gnc_basic_cell_destroy (reg->nullCell);
reg->nullCell = NULL;
reg->nullCell = NULL;
reg->dateCell = NULL;
reg->numCell = NULL;
reg->descCell = NULL;
reg->recnCell = NULL;
reg->balanceCell = NULL;
reg->actionCell = NULL;
reg->xfrmCell = NULL;
reg->memoCell = NULL;
reg->creditCell = NULL;
reg->debitCell = NULL;
reg->priceCell = NULL;
reg->sharesCell = NULL;
reg->mxfrmCell = NULL;
reg->tcreditCell = NULL;
reg->tdebitCell = NULL;
reg->tsharesCell = NULL;
reg->tbalanceCell = NULL;
reg->notesCell = NULL;
reg->formCreditCell = NULL;
reg->formDebitCell = NULL;
for (i = 0; i < CELL_TYPE_COUNT; i++)
for (node = reg->cells; node; node = node->next)
{
BasicCell *cell;
CellNode *cn = node->data;
cell = reg->header_cells[i];
if (cell)
xaccDestroyTextCell (cell);
reg->header_cells[i] = NULL;
gnc_basic_cell_destroy (cn->cell);
g_free (cn);
}
g_list_free (reg->cells);
reg->cells = NULL;
g_free (reg->debit_str);
g_free (reg->tdebit_str);
g_free (reg->credit_str);
@ -982,82 +1027,6 @@ xaccDestroySplitRegister (SplitRegister *reg)
/* ============================================== */
guint32
xaccSplitRegisterGetChangeFlag (SplitRegister *reg)
{
guint32 changed = 0;
/* be careful to use bitwise ands and ors to assemble bit flag */
changed |= MOD_DATE & reg->dateCell->cell.changed;
changed |= MOD_NUM & reg->numCell->cell.changed;
changed |= MOD_DESC & reg->descCell->cell.changed;
changed |= MOD_RECN & reg->recnCell->cell.changed;
changed |= MOD_ACTN & reg->actionCell->cell.changed;
changed |= MOD_XFRM & reg->xfrmCell->cell.changed;
changed |= MOD_MEMO & reg->memoCell->cell.changed;
changed |= MOD_AMNT & reg->creditCell->cell.changed;
changed |= MOD_AMNT & reg->debitCell->cell.changed;
changed |= MOD_PRIC & reg->priceCell->cell.changed;
changed |= MOD_SHRS & reg->sharesCell->cell.changed;
changed |= MOD_MXFRM & reg->mxfrmCell->cell.changed;
changed |= MOD_NOTES & reg->notesCell->cell.changed;
changed |= MOD_AMNT & reg->formCreditCell->cell.changed;
changed |= MOD_AMNT & reg->formDebitCell->cell.changed;
return changed;
}
guint32
xaccSplitRegisterGetConditionalChangeFlag (SplitRegister *reg)
{
guint32 changed = 0;
/* be careful to use bitwise ands and ors to assemble bit flag */
changed |= MOD_DATE & reg->dateCell->cell.conditionally_changed;
changed |= MOD_NUM & reg->numCell->cell.conditionally_changed;
changed |= MOD_DESC & reg->descCell->cell.conditionally_changed;
changed |= MOD_RECN & reg->recnCell->cell.conditionally_changed;
changed |= MOD_ACTN & reg->actionCell->cell.conditionally_changed;
changed |= MOD_XFRM & reg->xfrmCell->cell.conditionally_changed;
changed |= MOD_MEMO & reg->memoCell->cell.conditionally_changed;
changed |= MOD_AMNT & reg->creditCell->cell.conditionally_changed;
changed |= MOD_AMNT & reg->debitCell->cell.conditionally_changed;
changed |= MOD_PRIC & reg->priceCell->cell.conditionally_changed;
changed |= MOD_SHRS & reg->sharesCell->cell.conditionally_changed;
changed |= MOD_MXFRM & reg->mxfrmCell->cell.conditionally_changed;
changed |= MOD_NOTES & reg->notesCell->cell.conditionally_changed;
changed |= MOD_AMNT & reg->formCreditCell->cell.conditionally_changed;
changed |= MOD_AMNT & reg->formDebitCell->cell.conditionally_changed;
return changed;
}
/* ============================================== */
void
xaccSplitRegisterClearChangeFlag (SplitRegister *reg)
{
reg->dateCell->cell.changed = 0;
reg->numCell->cell.changed = 0;
reg->descCell->cell.changed = 0;
reg->recnCell->cell.changed = 0;
reg->actionCell->cell.changed = 0;
reg->xfrmCell->cell.changed = 0;
reg->memoCell->cell.changed = 0;
reg->creditCell->cell.changed = 0;
reg->debitCell->cell.changed = 0;
reg->priceCell->cell.changed = 0;
reg->sharesCell->cell.changed = 0;
reg->mxfrmCell->cell.changed = 0;
reg->notesCell->cell.changed = 0;
reg->formDebitCell->cell.changed = 0;
reg->formCreditCell->cell.changed = 0;
}
/* ============================================== */
static CursorClass
sr_cellblock_cursor_class(SplitRegister *reg, CellBlock *cursor)
{
@ -1142,14 +1111,18 @@ xaccCursorTypeToClass (CursorType cursor_type)
static CellType
sr_cell_type (SplitRegister *reg, void * cell)
{
int i;
GList *node;
if (reg == NULL)
return NO_CELL;
for (i = 0; i < CELL_TYPE_COUNT; i++)
if (cell == reg->cells[i])
return i;
for (node = reg->cells; node; node = node->next)
{
CellNode *cn = node->data;
if (cell == cn->cell)
return cn->cell_type;
}
return NO_CELL;
}
@ -1289,97 +1262,107 @@ xaccSplitRegisterGetCurrentCellLoc (SplitRegister *reg, CellType cell_type,
/* ============================================== */
SplitRegisterBuffer *
xaccMallocSplitRegisterBuffer (void)
RegisterBuffer *
gnc_register_buffer_new (void)
{
SplitRegisterBuffer *srb;
RegisterBuffer *rb;
srb = g_new0(SplitRegisterBuffer, 1);
rb = g_new0 (RegisterBuffer, 1);
return srb;
return rb;
}
/* ============================================== */
static void
destroyCellBuffer(CellBuffer *cb)
destroy_cell_buffer (CellBuffer *cb)
{
if (cb == NULL)
return;
g_free(cb->value);
g_free (cb->value);
cb->value = NULL;
g_free (cb);
}
static void
gnc_register_buffer_clear (RegisterBuffer *rb)
{
GList *node;
if (!rb) return;
for (node = rb->buffers; node; node = node->next)
{
CellBuffer *cb = node->data;
destroy_cell_buffer (cb);
}
g_list_free (rb->buffers);
rb->buffers = NULL;
}
void
xaccDestroySplitRegisterBuffer (SplitRegisterBuffer *srb)
gnc_register_buffer_destroy (RegisterBuffer *rb)
{
if (srb == NULL)
return;
if (!rb) return;
destroyCellBuffer(&srb->dateCell);
destroyCellBuffer(&srb->numCell);
destroyCellBuffer(&srb->descCell);
destroyCellBuffer(&srb->recnCell);
destroyCellBuffer(&srb->balanceCell);
destroyCellBuffer(&srb->actionCell);
destroyCellBuffer(&srb->xfrmCell);
destroyCellBuffer(&srb->memoCell);
destroyCellBuffer(&srb->creditCell);
destroyCellBuffer(&srb->debitCell);
destroyCellBuffer(&srb->priceCell);
destroyCellBuffer(&srb->sharesCell);
destroyCellBuffer(&srb->mxfrmCell);
destroyCellBuffer(&srb->notesCell);
destroyCellBuffer(&srb->formCreditCell);
destroyCellBuffer(&srb->formDebitCell);
gnc_register_buffer_clear (rb);
g_free(srb);
g_free (rb);
}
/* ============================================== */
static void
saveCell(BasicCell *bcell, CellBuffer *cb)
static CellBuffer *
save_cell (BasicCell *bcell)
{
if ((bcell == NULL) || (cb == NULL))
return;
CellBuffer *cb;
g_free(cb->value);
cb->value = g_strdup(bcell->value);
if (!bcell)
return NULL;
cb = g_new0 (CellBuffer, 1);
cb->value = g_strdup (bcell->value);
cb->changed = bcell->changed;
cb->conditionally_changed = bcell->conditionally_changed;
return cb;
}
void
xaccSplitRegisterSaveCursor(SplitRegister *sr, SplitRegisterBuffer *srb)
gnc_register_save_cursor (SplitRegister *sr, RegisterBuffer *rb)
{
if ((sr == NULL) || (srb == NULL))
GList *node;
if ((sr == NULL) || (rb == NULL))
return;
saveCell(&sr->dateCell->cell, &srb->dateCell);
saveCell(&sr->numCell->cell, &srb->numCell);
saveCell(&sr->descCell->cell, &srb->descCell);
saveCell(&sr->recnCell->cell, &srb->recnCell);
saveCell(&sr->balanceCell->cell, &srb->balanceCell);
saveCell(&sr->actionCell->cell, &srb->actionCell);
saveCell(&sr->xfrmCell->cell, &srb->xfrmCell);
saveCell(&sr->memoCell->cell, &srb->memoCell);
saveCell(&sr->creditCell->cell, &srb->creditCell);
saveCell(&sr->debitCell->cell, &srb->debitCell);
saveCell(&sr->priceCell->cell, &srb->priceCell);
saveCell(&sr->sharesCell->cell, &srb->sharesCell);
saveCell(&sr->mxfrmCell->cell, &srb->mxfrmCell);
saveCell(&sr->notesCell->cell, &srb->notesCell);
saveCell(&sr->formCreditCell->cell, &srb->formCreditCell);
saveCell(&sr->formDebitCell->cell, &srb->formDebitCell);
gnc_register_buffer_clear (rb);
for (node = sr->cells; node; node = node->next)
{
CellNode *cn = node->data;
CellBuffer *cb;
if (!gnc_basic_cell_get_changed (cn->cell) &&
!gnc_basic_cell_get_conditionally_changed (cn->cell))
continue;
cb = save_cell (cn->cell);
cb->cell_type = cn->cell_type;
rb->buffers = g_list_prepend (rb->buffers, cb);
}
}
/* ============================================== */
static void
restoreCellChanged(BasicCell *bcell, CellBuffer *cb, CellBlock *cursor)
restore_cell (BasicCell *bcell, CellBuffer *cb, CellBlock *cursor)
{
int r, c;
@ -1410,34 +1393,27 @@ restoreCellChanged(BasicCell *bcell, CellBuffer *cb, CellBlock *cursor)
}
void
xaccSplitRegisterRestoreCursorChanged(SplitRegister *sr,
SplitRegisterBuffer *srb)
gnc_register_restore_cursor (SplitRegister *sr, RegisterBuffer *rb)
{
CellBlock *cursor;
GList *node;
if ((sr == NULL) || (sr->table == NULL) || (srb == NULL))
if ((sr == NULL) || (sr->table == NULL) || (rb == NULL))
return;
cursor = sr->table->current_cursor;
if (cursor == NULL)
return;
restoreCellChanged(&sr->dateCell->cell, &srb->dateCell, cursor);
restoreCellChanged(&sr->numCell->cell, &srb->numCell, cursor);
restoreCellChanged(&sr->descCell->cell, &srb->descCell, cursor);
restoreCellChanged(&sr->recnCell->cell, &srb->recnCell, cursor);
restoreCellChanged(&sr->balanceCell->cell, &srb->balanceCell, cursor);
restoreCellChanged(&sr->actionCell->cell, &srb->actionCell, cursor);
restoreCellChanged(&sr->xfrmCell->cell, &srb->xfrmCell, cursor);
restoreCellChanged(&sr->memoCell->cell, &srb->memoCell, cursor);
restoreCellChanged(&sr->creditCell->cell, &srb->creditCell, cursor);
restoreCellChanged(&sr->debitCell->cell, &srb->debitCell, cursor);
restoreCellChanged(&sr->priceCell->cell, &srb->priceCell, cursor);
restoreCellChanged(&sr->sharesCell->cell, &srb->sharesCell, cursor);
restoreCellChanged(&sr->mxfrmCell->cell, &srb->mxfrmCell, cursor);
restoreCellChanged(&sr->notesCell->cell, &srb->notesCell, cursor);
restoreCellChanged(&sr->formCreditCell->cell, &srb->formCreditCell, cursor);
restoreCellChanged(&sr->formDebitCell->cell, &srb->formDebitCell, cursor);
for (node = rb->buffers; node; node = node->next)
{
CellBuffer *cb = node->data;
BasicCell *cell;
cell = gnc_register_get_cell (sr, cb->cell_type);
restore_cell (cell, cb, cursor);
}
}
/* keep in sync with CellType enum */
@ -1447,7 +1423,6 @@ static const char *cell_names[] =
"num",
"description",
"reconcile",
"share-balance",
"balance",
"action",
"account",
@ -1459,7 +1434,7 @@ static const char *cell_names[] =
"transfer",
"trans-credit",
"trans-debit",
"trans-share-balance",
"trans-shares",
"trans-balance",
"notes",
"credit formula",

View File

@ -44,14 +44,8 @@
#ifndef XACC_SPLITREG_H
#define XACC_SPLITREG_H
#include "basiccell.h"
#include "cellblock.h"
#include "combocell.h"
#include "datecell.h"
#include "quickfillcell.h"
#include "pricecell.h"
#include "numcell.h"
#include "recncell.h"
#include "Account.h" /* FIXME No Engine headers!!! */
#include "table-allgui.h"
/* defined register types.
@ -124,27 +118,6 @@ typedef enum
REG_STYLE_JOURNAL
} SplitRegisterStyle;
/* modified flags -- indicate which cell values have been modified by user */
typedef enum
{
MOD_NONE = 0,
MOD_DATE = 1 << 0,
MOD_NUM = 1 << 1,
MOD_DESC = 1 << 2,
MOD_RECN = 1 << 3,
MOD_ACTN = 1 << 4,
MOD_XFRM = 1 << 5,
MOD_MXFRM = 1 << 6,
MOD_MEMO = 1 << 7,
MOD_AMNT = 1 << 8,
MOD_PRIC = 1 << 9,
MOD_SHRS = 1 << 10,
MOD_NOTES = 1 << 11,
MOD_FCRED = 1 << 12,
MOD_FDEBT = 1 << 13,
MOD_ALL = 0xffff
} CellModifiedFlags;
/* Types of cursors */
typedef enum
{
@ -166,7 +139,7 @@ typedef enum
NUM_CURSOR_TYPES
} CursorType;
typedef struct _SplitRegisterBuffer SplitRegisterBuffer;
typedef struct _RegisterBuffer RegisterBuffer;
typedef struct _SplitRegister SplitRegister;
typedef void (*SplitRegisterDestroyCB) (SplitRegister *reg);
@ -186,47 +159,24 @@ struct _SplitRegister
BasicCell * nullCell;
DateCell * dateCell;
NumCell * numCell;
QuickFillCell * descCell;
RecnCell * recnCell;
PriceCell * balanceCell;
ComboCell * actionCell;
ComboCell * xfrmCell;
QuickFillCell * memoCell;
PriceCell * creditCell;
PriceCell * debitCell;
PriceCell * priceCell;
PriceCell * sharesCell;
ComboCell * mxfrmCell;
PriceCell * tcreditCell;
PriceCell * tdebitCell;
PriceCell * tsharesCell;
PriceCell * tbalanceCell;
QuickFillCell * notesCell;
QuickFillCell * formCreditCell;
QuickFillCell * formDebitCell;
SplitRegisterType type;
SplitRegisterStyle style;
gboolean use_double_line;
/* some private data; outsiders should not access this */
BasicCell *header_cells[CELL_TYPE_COUNT];
BasicCell *cells[CELL_TYPE_COUNT];
GList *cells;
/**
* A flag indicating a "template" register.
**/
gboolean template;
/**
* The template account which the transactions in a template
* splitregister will belong to.
**/
Account *templateAcct;
Account *templateAcct; /* FIXME: this should not be here! */
/* user_data allows users of this object to hang
* private data onto it */
@ -245,11 +195,11 @@ struct _SplitRegister
SplitRegister *
xaccMallocSplitRegister (SplitRegisterType type,
SplitRegisterStyle style,
gboolean use_double_line,
TableModel *model,
gboolean templateMode);
gnc_register_new (SplitRegisterType type,
SplitRegisterStyle style,
gboolean use_double_line,
TableModel *model,
gboolean templateMode);
void xaccConfigSplitRegister (SplitRegister *reg,
SplitRegisterType type,
@ -258,12 +208,16 @@ void xaccConfigSplitRegister (SplitRegister *reg,
void xaccDestroySplitRegister (SplitRegister *reg);
/* returns non-zero value if updates have been made to data */
guint32 xaccSplitRegisterGetChangeFlag (SplitRegister *reg);
guint32 xaccSplitRegisterGetConditionalChangeFlag (SplitRegister *reg);
BasicCell * gnc_register_get_cell (SplitRegister *sr, CellType cell_type);
const char * gnc_register_get_cell_value (SplitRegister *sr,
CellType cell_type);
/* Clears all change flags in the register. Does not alter values */
void xaccSplitRegisterClearChangeFlag (SplitRegister *reg);
gboolean gnc_register_get_cursor_changed (SplitRegister *sr,
gboolean include_conditional);
gboolean gnc_register_get_cell_changed (SplitRegister *sr,
CellType cell_type,
gboolean include_conditional);
void gnc_register_clear_changes (SplitRegister *sr);
/* Returns the type of the current cursor */
CursorClass xaccSplitRegisterGetCurrentCursorClass (SplitRegister *reg);
@ -294,12 +248,11 @@ gboolean xaccSplitRegisterGetCurrentCellLoc (SplitRegister *reg,
VirtualLocation *virt_loc);
/* Functions for working with split register buffers */
SplitRegisterBuffer * xaccMallocSplitRegisterBuffer (void);
void xaccDestroySplitRegisterBuffer (SplitRegisterBuffer *srb);
RegisterBuffer * gnc_register_buffer_new (void);
void gnc_register_buffer_destroy (RegisterBuffer *rb);
void xaccSplitRegisterSaveCursor(SplitRegister *sr, SplitRegisterBuffer *srb);
void xaccSplitRegisterRestoreCursorChanged(SplitRegister *sr,
SplitRegisterBuffer *srb);
void gnc_register_save_cursor (SplitRegister *sr, RegisterBuffer *srb);
void gnc_register_restore_cursor (SplitRegister *sr, RegisterBuffer *srb);
const char * xaccSplitRegisterGetCellTypeName (CellType type);
CellType xaccSplitRegisterGetCellTypeFromName (const char *name);

View File

@ -572,20 +572,11 @@ gnc_table_move_cursor_internal (Table *table,
{
BasicCell *cell = cb_cell->cell;
cell->changed = 0;
cell->conditionally_changed = 0;
cell->changed = FALSE;
cell->conditionally_changed = FALSE;
if (cell->move)
{
VirtualLocation vloc;
vloc.vcell_loc.virt_row = -1;
vloc.vcell_loc.virt_col = -1;
vloc.phys_row_offset = -1;
vloc.phys_col_offset = -1;
cell->move (cell, vloc);
}
if (cell->gui_move)
cell->gui_move (cell);
}
}
}
@ -631,8 +622,8 @@ gnc_table_move_cursor_internal (Table *table,
* the cell value. Otherwise, we'll end up putting the
* new values in the old cell locations, and that would
* lead to confusion of all sorts. */
if (do_move_gui && cell->move)
cell->move (cell, virt_loc);
if (do_move_gui && cell->gui_move)
cell->gui_move (cell);
/* OK, now copy the string value from the table at large
* into the cell handler. */
@ -647,9 +638,8 @@ gnc_table_move_cursor_internal (Table *table,
xaccSetBasicCellValue (cell, entry);
cell->changed = 0;
cell->conditionally_changed =
conditionally_changed ? GNC_CELL_CHANGED : 0;
cell->changed = FALSE;
cell->conditionally_changed = conditionally_changed;
}
}
}
@ -752,8 +742,8 @@ gnc_table_create_cursor (Table * table, CellBlock *curs)
cb_cell = gnc_cellblock_get_cell (curs, cell_row, cell_col);
if (cb_cell && cb_cell->cell && cb_cell->cell->realize)
cb_cell->cell->realize (cb_cell->cell, table->ui_data);
if (cb_cell && cb_cell->cell && cb_cell->cell->gui_realize)
cb_cell->cell->gui_realize (cb_cell->cell, table->ui_data);
}
}
@ -887,7 +877,7 @@ gnc_table_enter_update(Table *table,
can_edit = enter(cell, cursor_position, start_selection, end_selection);
if (safe_strcmp(old_value, cell->value) != 0)
cell->changed = GNC_CELL_CHANGED;
cell->changed = TRUE;
g_free (old_value);
}
@ -913,7 +903,6 @@ gnc_table_enter_update(Table *table,
void
gnc_table_leave_update(Table *table, VirtualLocation virt_loc)
{
gboolean changed = FALSE;
CellLeaveFunc leave;
CellBlockCell *cb_cell;
BasicCell *cell;
@ -951,10 +940,7 @@ gnc_table_leave_update(Table *table, VirtualLocation virt_loc)
leave (cell);
if (safe_strcmp(old_value, cell->value) != 0)
{
changed = TRUE;
cell->changed = GNC_CELL_CHANGED;
}
cell->changed = TRUE;
g_free (old_value);
}
@ -1043,7 +1029,7 @@ gnc_table_modify_update(Table *table,
if (safe_strcmp (old_value, cell->value) != 0)
{
changed = TRUE;
cell->changed = GNC_CELL_CHANGED;
cell->changed = TRUE;
}
g_free (old_value);
@ -1123,7 +1109,7 @@ gnc_table_direct_update (Table *table,
}
else
{
cell->changed = GNC_CELL_CHANGED;
cell->changed = TRUE;
*newval_ptr = cell->value;
}
}

View File

@ -92,6 +92,7 @@
#include <glib.h>
#include "gnc-common.h"
#include "register-common.h"
#include "basiccell.h"
#include "cellblock.h"

View File

@ -57,6 +57,14 @@ TextMV (struct _BasicCell *_cell,
/* ================================================ */
static void
xaccInitTextCell (BasicCell *cell)
{
cell->modify_verify = TextMV;
}
/* ================================================ */
BasicCell *
xaccMallocTextCell (void)
{
@ -68,21 +76,4 @@ xaccMallocTextCell (void)
return cell;
}
/* ================================================ */
void
xaccInitTextCell (BasicCell *cell)
{
cell->modify_verify = TextMV;
}
/* ================================================ */
void
xaccDestroyTextCell (BasicCell *cell)
{
cell->modify_verify = NULL;
xaccDestroyBasicCell (cell);
}
/* --------------- end of file ---------------------- */

View File

@ -41,8 +41,6 @@
/* installs a callback to handle text recording */
BasicCell * xaccMallocTextCell (void);
void xaccInitTextCell (BasicCell *cell);
void xaccDestroyTextCell (BasicCell *cell);
#endif /* TEXT_CELL_H */