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> 2001-07-20 James LewisMoss <jimdres@mindspring.com>
* src/gnome/top-level.c (gnucash_ui_init): remove the \n's frome * 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_deallocator = xaccMLGUIDFree;
model.cell_data_copy = xaccMLGUIDCopy; model.cell_data_copy = xaccMLGUIDCopy;
ld->reg = xaccMallocSplitRegister (reg_type, style, FALSE, &model, ld->reg = gnc_register_new (reg_type, style, FALSE, &model, templateMode);
templateMode);
xaccSRSetData (ld->reg, ld, xaccSRSetData (ld->reg, ld,
xaccLedgerDisplayParent, xaccLedgerDisplayParent,
xaccLedgerDisplaySetHelp); xaccLedgerDisplaySetHelp);

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -76,8 +76,8 @@ BasicCellHelpValue(BasicCell *cell)
static void static void
xaccClearBasicCell (BasicCell *cell) xaccClearBasicCell (BasicCell *cell)
{ {
cell->changed = 0; cell->changed = FALSE;
cell->conditionally_changed = 0; cell->conditionally_changed = FALSE;
cell->value = NULL; cell->value = NULL;
cell->value_w = NULL; cell->value_w = NULL;
@ -89,9 +89,9 @@ xaccClearBasicCell (BasicCell *cell)
cell->modify_verify = NULL; cell->modify_verify = NULL;
cell->direct_update = NULL; cell->direct_update = NULL;
cell->leave_cell = NULL; cell->leave_cell = NULL;
cell->realize = NULL; cell->gui_realize = NULL;
cell->move = NULL; cell->gui_move = NULL;
cell->destroy = NULL; cell->gui_destroy = NULL;
cell->get_help_value = NULL; cell->get_help_value = NULL;
cell->is_popup = FALSE; cell->is_popup = FALSE;
@ -114,11 +114,14 @@ xaccInitBasicCell (BasicCell *cell)
/* ===================================================== */ /* ===================================================== */
void void
xaccDestroyBasicCell (BasicCell *cell) gnc_basic_cell_destroy (BasicCell *cell)
{ {
/* give any gui elements a chance to clean up */
if (cell->destroy) 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 */ /* free up data strings */
g_free (cell->value); 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 void
xaccSetBasicCellValue (BasicCell *cell, const char *val) xaccSetBasicCellValue (BasicCell *cell, const char *val)
{ {
@ -157,7 +170,37 @@ xaccSetBasicCellValue (BasicCell *cell, const char *val)
xaccSetBasicCellValueInternal (cell, 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 void
xaccSetBasicCellBlankHelp (BasicCell *cell, const char *blank_help) 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 void
xaccSetBasicCellValueInternal (BasicCell *cell, const char *value) xaccSetBasicCellValueInternal (BasicCell *cell, const char *value)
{ {

View File

@ -56,24 +56,6 @@
* classes should provide a callback here if they need * classes should provide a callback here if they need
* to understand special cell formats. * 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: * USER CALLBACKS:
* The enter_cell() callback is called when the user first * The enter_cell() callback is called when the user first
* makes a move to enter a cell. This might be by clicking * 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 * callbacks that allow the programmer to perform GUI-specific
* initialization & changes. * 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 * initialization needs to be done. For Gnome, the second
* argument will be cast to the parent widget. * 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. * 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. * to be positioned to a new location within the table grid.
* The second argument is the virtual location the GUI * The second argument is the virtual location the GUI
* element should be moved to. * element should be moved to.
@ -160,15 +142,13 @@
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <glib.h> #include <glib.h>
#include "gnc-common.h"
#include "gnc-ui-common.h" #include "gnc-ui-common.h"
#include "register-common.h"
#define GNC_CELL_CHANGED 0xffffffff
typedef struct _BasicCell BasicCell; typedef struct _BasicCell BasicCell;
typedef BasicCell * (*CellCreateFunc) (void);
typedef void (*CellSetValueFunc) (BasicCell *cell, typedef void (*CellSetValueFunc) (BasicCell *cell,
const char * new_value); const char * new_value);
@ -196,7 +176,7 @@ typedef void (*CellLeaveFunc) (BasicCell *cell);
typedef void (*CellRealizeFunc) (BasicCell *cell, gpointer gui_handle); 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); typedef void (*CellDestroyFunc) (BasicCell *cell);
@ -211,11 +191,12 @@ struct _BasicCell
gint value_len; /* length of wide chars value */ gint value_len; /* length of wide chars value */
guint32 changed; /* 2^32-1 if value modified */ gboolean changed; /* true if value modified */
guint32 conditionally_changed; /* value if modified conditionally */ gboolean conditionally_changed; /* true if value modified conditionally */
/* "virtual", overloaded set-value method */ /* "virtual", overloaded methods */
CellSetValueFunc set_value; CellSetValueFunc set_value;
CellDestroyFunc destroy;
/* cell-editing callbacks */ /* cell-editing callbacks */
CellEnterFunc enter_cell; CellEnterFunc enter_cell;
@ -223,13 +204,13 @@ struct _BasicCell
CellDirectUpdateFunc direct_update; CellDirectUpdateFunc direct_update;
CellLeaveFunc leave_cell; CellLeaveFunc leave_cell;
/* private, GUI-specific callbacks */
CellRealizeFunc realize;
CellMoveFunc move;
CellDestroyFunc destroy;
CellGetHelpFunc get_help_value; CellGetHelpFunc get_help_value;
/* private, GUI-specific callbacks */
CellRealizeFunc gui_realize;
CellMoveFunc gui_move;
CellDestroyFunc gui_destroy;
/* GUI flag indicated is a popup-widget */ /* GUI flag indicated is a popup-widget */
gboolean is_popup; gboolean is_popup;
@ -240,15 +221,21 @@ struct _BasicCell
BasicCell * xaccMallocBasicCell (void); BasicCell * xaccMallocBasicCell (void);
void xaccInitBasicCell (BasicCell *bcell); 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); 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); void xaccSetBasicCellBlankHelp (BasicCell *bcell, const char *help);
char * xaccBasicCellGetHelp (BasicCell *bcell); char * xaccBasicCellGetHelp (BasicCell *bcell);
void xaccBasicCellSetChanged (BasicCell *bcell, gboolean changed);
/* for sub-class use only */ /* for sub-class use only */
void xaccSetBasicCellValueInternal (BasicCell *bcell, void xaccSetBasicCellValueInternal (BasicCell *bcell,
const char *value); 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 = NULL;
cb_cell->cell_type = -1; cb_cell->cell_type = -1;
cb_cell->label = NULL;
cb_cell->sample_text = NULL; cb_cell->sample_text = NULL;
cb_cell->alignment = CELL_ALIGN_LEFT; cb_cell->alignment = CELL_ALIGN_LEFT;
cb_cell->expandable = FALSE; 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 = NULL;
cb_cell->cell_type = -1; cb_cell->cell_type = -1;
g_free(cb_cell->label);
cb_cell->label = NULL;
g_free(cb_cell->sample_text); g_free(cb_cell->sample_text);
cb_cell->sample_text = NULL; cb_cell->sample_text = NULL;
} }

View File

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

View File

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

View File

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

View File

@ -36,6 +36,7 @@
#include <gnome.h> #include <gnome.h>
#include "QuickFill.h"
#include "combocell.h" #include "combocell.h"
#include "gnc-engine-util.h" #include "gnc-engine-util.h"
#include "gnc-ui-util.h" #include "gnc-ui-util.h"
@ -77,14 +78,15 @@ typedef struct _PopBox
static void block_list_signals (ComboCell *cell); static void block_list_signals (ComboCell *cell);
static void unblock_list_signals (ComboCell *cell); static void unblock_list_signals (ComboCell *cell);
static void realizeCombo (BasicCell *bcell, gpointer w); static void combo_cell_gui_realize (BasicCell *bcell, gpointer w);
static void moveCombo (BasicCell *bcell, VirtualLocation virt_loc); static void combo_cell_gui_move (BasicCell *bcell);
static void destroyCombo (BasicCell *bcell); static void combo_cell_gui_destroy (BasicCell *bcell);
static gboolean enterCombo (BasicCell *bcell, static gboolean combo_cell_enter (BasicCell *bcell,
int *cursor_position, int *cursor_position,
int *start_selection, int *start_selection,
int *end_selection); int *end_selection);
static void leaveCombo (BasicCell *bcell); 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. */ /* This static indicates the debugging module that this .o belongs to. */
static short module = MOD_GTK_REG; static short module = MOD_GTK_REG;
@ -93,7 +95,7 @@ static gboolean auto_pop_combos = FALSE;
/* =============================================== */ /* =============================================== */
ComboCell * BasicCell *
xaccMallocComboCell (void) xaccMallocComboCell (void)
{ {
ComboCell * cell; ComboCell * cell;
@ -102,7 +104,7 @@ xaccMallocComboCell (void)
xaccInitComboCell (cell); xaccInitComboCell (cell);
return cell; return &cell->cell;
} }
void void
@ -114,8 +116,10 @@ xaccInitComboCell (ComboCell *cell)
cell->cell.is_popup = TRUE; cell->cell.is_popup = TRUE;
cell->cell.realize = realizeCombo; cell->cell.destroy = combo_cell_destroy;
cell->cell.destroy = destroyCombo;
cell->cell.gui_realize = combo_cell_gui_realize;
cell->cell.gui_destroy = combo_cell_gui_destroy;
box = g_new0 (PopBox, 1); box = g_new0 (PopBox, 1);
@ -266,12 +270,12 @@ unblock_list_signals (ComboCell *cell)
/* =============================================== */ /* =============================================== */
static void static void
destroyCombo (BasicCell *bcell) combo_cell_gui_destroy (BasicCell *bcell)
{ {
PopBox *box = bcell->gui_private; PopBox *box = bcell->gui_private;
ComboCell *cell = (ComboCell *) bcell; ComboCell *cell = (ComboCell *) bcell;
if (cell->cell.realize == NULL) if (cell->cell.gui_realize == NULL)
{ {
if (box != NULL && box->item_list != NULL) if (box != NULL && box->item_list != NULL)
{ {
@ -281,11 +285,11 @@ destroyCombo (BasicCell *bcell)
} }
/* allow the widget to be shown again */ /* allow the widget to be shown again */
cell->cell.realize = realizeCombo; cell->cell.gui_realize = combo_cell_gui_realize;
cell->cell.move = NULL; cell->cell.gui_move = NULL;
cell->cell.enter_cell = NULL; cell->cell.enter_cell = NULL;
cell->cell.leave_cell = NULL; cell->cell.leave_cell = NULL;
cell->cell.destroy = NULL; cell->cell.gui_destroy = NULL;
} }
DEBUG("combo destroyed\n"); DEBUG("combo destroyed\n");
@ -301,12 +305,13 @@ menustring_free (gpointer string, gpointer user_data)
/* =============================================== */ /* =============================================== */
void static void
xaccDestroyComboCell (ComboCell *cell) combo_cell_destroy (BasicCell *bcell)
{ {
ComboCell *cell = (ComboCell *) bcell;
PopBox *box = cell->cell.gui_private; PopBox *box = cell->cell.gui_private;
destroyCombo(&(cell->cell)); combo_cell_gui_destroy (&(cell->cell));
if (box != NULL) if (box != NULL)
{ {
@ -342,9 +347,7 @@ xaccDestroyComboCell (ComboCell *cell)
} }
cell->cell.gui_private = NULL; cell->cell.gui_private = NULL;
cell->cell.realize = NULL; cell->cell.gui_realize = NULL;
xaccDestroyBasicCell(&(cell->cell));
} }
/* =============================================== */ /* =============================================== */
@ -727,7 +730,7 @@ ComboHelpValue (BasicCell *bcell)
/* =============================================== */ /* =============================================== */
static void static void
realizeCombo (BasicCell *bcell, gpointer data) combo_cell_gui_realize (BasicCell *bcell, gpointer data)
{ {
GnucashSheet *sheet = data; GnucashSheet *sheet = data;
GnomeCanvasItem *item = sheet->item_editor; GnomeCanvasItem *item = sheet->item_editor;
@ -743,11 +746,11 @@ realizeCombo (BasicCell *bcell, gpointer data)
gtk_object_sink (GTK_OBJECT(box->item_list)); gtk_object_sink (GTK_OBJECT(box->item_list));
/* to mark cell as realized, remove the realize method */ /* to mark cell as realized, remove the realize method */
cell->cell.realize = NULL; cell->cell.gui_realize = NULL;
cell->cell.move = moveCombo; cell->cell.gui_move = combo_cell_gui_move;
cell->cell.enter_cell = enterCombo; cell->cell.enter_cell = combo_cell_enter;
cell->cell.leave_cell = leaveCombo; cell->cell.leave_cell = combo_cell_leave;
cell->cell.destroy = destroyCombo; cell->cell.gui_destroy = combo_cell_gui_destroy;
cell->cell.modify_verify = ComboMV; cell->cell.modify_verify = ComboMV;
cell->cell.direct_update = ComboDirect; cell->cell.direct_update = ComboDirect;
cell->cell.get_help_value = ComboHelpValue; cell->cell.get_help_value = ComboHelpValue;
@ -756,7 +759,7 @@ realizeCombo (BasicCell *bcell, gpointer data)
/* =============================================== */ /* =============================================== */
static void static void
moveCombo (BasicCell *bcell, VirtualLocation virt_loc) combo_cell_gui_move (BasicCell *bcell)
{ {
PopBox *box = bcell->gui_private; PopBox *box = bcell->gui_private;
@ -822,10 +825,10 @@ popup_get_width (GnomeCanvasItem *item,
} }
static gboolean static gboolean
enterCombo (BasicCell *bcell, combo_cell_enter (BasicCell *bcell,
int *cursor_position, int *cursor_position,
int *start_selection, int *start_selection,
int *end_selection) int *end_selection)
{ {
ComboCell *cell = (ComboCell *) bcell; ComboCell *cell = (ComboCell *) bcell;
PopBox *box = bcell->gui_private; PopBox *box = bcell->gui_private;
@ -862,7 +865,7 @@ enterCombo (BasicCell *bcell,
/* =============================================== */ /* =============================================== */
static void static void
leaveCombo (BasicCell *bcell) combo_cell_leave (BasicCell *bcell)
{ {
PopBox *box = bcell->gui_private; 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 unblock_picker_signals (DateCell *cell);
static void realizeDate (BasicCell *bcell, gpointer w); static void realizeDate (BasicCell *bcell, gpointer w);
static void setDateCellValue (BasicCell *bcell, const char *value); static void setDateCellValue (BasicCell *bcell, const char *value);
static void moveDate (BasicCell *bcell, VirtualLocation virt_loc); static void moveDate (BasicCell *bcell);
static void destroyDate (BasicCell *bcell); static void date_cell_gui_destroy (BasicCell *bcell);
static void date_cell_destroy (BasicCell *bcell);
static void DateMV (BasicCell *_cell, static void DateMV (BasicCell *_cell,
const GdkWChar *change, const GdkWChar *change,
int change_len, int change_len,
@ -192,8 +193,10 @@ xaccInitDateCell (DateCell *cell)
cell->cell.is_popup = TRUE; cell->cell.is_popup = TRUE;
cell->cell.realize = realizeDate; cell->cell.destroy = date_cell_destroy;
cell->cell.destroy = destroyDate;
cell->cell.gui_realize = realizeDate;
cell->cell.gui_destroy = date_cell_gui_destroy;
cell->cell.modify_verify = DateMV; cell->cell.modify_verify = DateMV;
cell->cell.direct_update = DateDirect; cell->cell.direct_update = DateDirect;
cell->cell.set_value = setDateCellValue; cell->cell.set_value = setDateCellValue;
@ -219,7 +222,7 @@ xaccInitDateCell (DateCell *cell)
xaccSetBasicCellValueInternal (&cell->cell, buff); xaccSetBasicCellValueInternal (&cell->cell, buff);
} }
DateCell * BasicCell *
xaccMallocDateCell (void) xaccMallocDateCell (void)
{ {
DateCell *cell; DateCell *cell;
@ -228,7 +231,7 @@ xaccMallocDateCell (void)
xaccInitDateCell (cell); xaccInitDateCell (cell);
return cell; return &cell->cell;
} }
/* =============================================== */ /* =============================================== */
@ -353,12 +356,12 @@ unblock_picker_signals (DateCell *cell)
/* =============================================== */ /* =============================================== */
static void static void
destroyDate (BasicCell *bcell) date_cell_gui_destroy (BasicCell *bcell)
{ {
PopBox *box = bcell->gui_private; PopBox *box = bcell->gui_private;
DateCell *cell = (DateCell *) bcell; DateCell *cell = (DateCell *) bcell;
if (cell->cell.realize == NULL) if (cell->cell.gui_realize == NULL)
{ {
if (box != NULL && box->date_picker != NULL) if (box != NULL && box->date_picker != NULL)
{ {
@ -368,11 +371,11 @@ destroyDate (BasicCell *bcell)
} }
/* allow the widget to be shown again */ /* allow the widget to be shown again */
cell->cell.realize = realizeDate; cell->cell.gui_realize = realizeDate;
cell->cell.move = NULL; cell->cell.gui_move = NULL;
cell->cell.enter_cell = NULL; cell->cell.enter_cell = NULL;
cell->cell.leave_cell = NULL; cell->cell.leave_cell = NULL;
cell->cell.destroy = NULL; cell->cell.gui_destroy = NULL;
} }
DEBUG ("date destroyed\n"); DEBUG ("date destroyed\n");
@ -380,19 +383,18 @@ destroyDate (BasicCell *bcell)
/* =============================================== */ /* =============================================== */
void static void
xaccDestroyDateCell (DateCell *cell) date_cell_destroy (BasicCell *bcell)
{ {
DateCell *cell = (DateCell *) bcell;
PopBox *box = cell->cell.gui_private; PopBox *box = cell->cell.gui_private;
destroyDate (&(cell->cell)); date_cell_gui_destroy (&(cell->cell));
g_free (box); g_free (box);
cell->cell.gui_private = NULL; cell->cell.gui_private = NULL;
cell->cell.realize = NULL; cell->cell.gui_realize = NULL;
xaccDestroyBasicCell (&(cell->cell));
} }
/* =============================================== */ /* =============================================== */
@ -800,8 +802,8 @@ realizeDate (BasicCell *bcell, gpointer data)
gtk_object_sink (GTK_OBJECT(box->date_picker)); gtk_object_sink (GTK_OBJECT(box->date_picker));
/* to mark cell as realized, remove the realize method */ /* to mark cell as realized, remove the realize method */
cell->cell.realize = NULL; cell->cell.gui_realize = NULL;
cell->cell.move = moveDate; cell->cell.gui_move = moveDate;
cell->cell.enter_cell = enterDate; cell->cell.enter_cell = enterDate;
cell->cell.leave_cell = leaveDate; cell->cell.leave_cell = leaveDate;
} }
@ -809,7 +811,7 @@ realizeDate (BasicCell *bcell, gpointer data)
/* =============================================== */ /* =============================================== */
static void static void
moveDate (BasicCell *bcell, VirtualLocation virt_loc) moveDate (BasicCell *bcell)
{ {
PopBox *box = bcell->gui_private; PopBox *box = bcell->gui_private;

View File

@ -207,17 +207,6 @@ set_dimensions_pass_one (GnucashSheet *sheet, CellBlock *cursor,
else else
width = 0; 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) if (cb_cell->cell && cb_cell->cell->is_popup)
width += item_edit_get_toggle_offset width += item_edit_get_toggle_offset
(cd->pixel_height); (cd->pixel_height);

View File

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

View File

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

View File

@ -32,27 +32,13 @@
* *
* By default, the PriceCell is an input/output cell. * 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. * On output, it will display negative values in red text.
* hack alert -- the actual color (red) should be user configurable. * 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: * HISTORY:
* Copyright (c) 1998, 1999, 2000 Linas Vepstas * Copyright (c) 1998, 1999, 2000 Linas Vepstas
* Copyright (c) 2000 Dave Peticolas * Copyright (c) 2000 Dave Peticolas
* Copyright (c) 2001 Free Software Foundation
*/ */
#ifndef __PRICE_CELL_C__ #ifndef __PRICE_CELL_C__
@ -79,8 +65,7 @@ typedef struct _PriceCell
} PriceCell; } PriceCell;
/* installs a callback to handle price recording */ /* installs a callback to handle price recording */
PriceCell * xaccMallocPriceCell (void); BasicCell * xaccMallocPriceCell (void);
void xaccDestroyPriceCell (PriceCell *cell);
/* return the value of a price cell */ /* return the value of a price cell */
gnc_numeric xaccGetPriceCellValue (PriceCell *cell); gnc_numeric xaccGetPriceCellValue (PriceCell *cell);

View File

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

View File

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

View File

@ -112,7 +112,7 @@ xaccInitRecnCell (RecnCell *cell)
cell->cell.set_value = RecnSetValue; cell->cell.set_value = RecnSetValue;
} }
RecnCell * BasicCell *
xaccMallocRecnCell (void) xaccMallocRecnCell (void)
{ {
RecnCell * cell; RecnCell * cell;
@ -121,7 +121,7 @@ xaccMallocRecnCell (void)
xaccInitRecnCell (cell); 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 void
xaccRecnCellSetFlag (RecnCell *cell, char reconciled_flag) xaccRecnCellSetFlag (RecnCell *cell, char reconciled_flag)
{ {

View File

@ -57,8 +57,7 @@ typedef struct _RecnCell
gpointer confirm_data; gpointer confirm_data;
} RecnCell; } RecnCell;
RecnCell * xaccMallocRecnCell (void); BasicCell * xaccMallocRecnCell (void);
void xaccDestroyRecnCell (RecnCell *cell);
void xaccRecnCellSetFlag (RecnCell *cell, char reconciled_flag); void xaccRecnCellSetFlag (RecnCell *cell, char reconciled_flag);
char xaccRecnCellGetFlag (RecnCell *cell); 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 gboolean
virt_cell_loc_equal (VirtualCellLocation vcl1, VirtualCellLocation vcl2) virt_cell_loc_equal (VirtualCellLocation vcl1, VirtualCellLocation vcl2)

View File

@ -26,6 +26,24 @@
#include <glib.h> #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 /* The VirtualCellLocation structure contains the virtual
* location of a virtual cell. * location of a virtual cell.

View File

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

View File

@ -44,14 +44,8 @@
#ifndef XACC_SPLITREG_H #ifndef XACC_SPLITREG_H
#define XACC_SPLITREG_H #define XACC_SPLITREG_H
#include "basiccell.h" #include "Account.h" /* FIXME No Engine headers!!! */
#include "cellblock.h"
#include "combocell.h"
#include "datecell.h"
#include "quickfillcell.h"
#include "pricecell.h"
#include "numcell.h"
#include "recncell.h"
#include "table-allgui.h" #include "table-allgui.h"
/* defined register types. /* defined register types.
@ -124,27 +118,6 @@ typedef enum
REG_STYLE_JOURNAL REG_STYLE_JOURNAL
} SplitRegisterStyle; } 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 */ /* Types of cursors */
typedef enum typedef enum
{ {
@ -166,7 +139,7 @@ typedef enum
NUM_CURSOR_TYPES NUM_CURSOR_TYPES
} CursorType; } CursorType;
typedef struct _SplitRegisterBuffer SplitRegisterBuffer; typedef struct _RegisterBuffer RegisterBuffer;
typedef struct _SplitRegister SplitRegister; typedef struct _SplitRegister SplitRegister;
typedef void (*SplitRegisterDestroyCB) (SplitRegister *reg); typedef void (*SplitRegisterDestroyCB) (SplitRegister *reg);
@ -186,47 +159,24 @@ struct _SplitRegister
BasicCell * nullCell; 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; SplitRegisterType type;
SplitRegisterStyle style; SplitRegisterStyle style;
gboolean use_double_line; gboolean use_double_line;
/* some private data; outsiders should not access this */ /* some private data; outsiders should not access this */
BasicCell *header_cells[CELL_TYPE_COUNT]; GList *cells;
BasicCell *cells[CELL_TYPE_COUNT];
/** /**
* A flag indicating a "template" register. * A flag indicating a "template" register.
**/ **/
gboolean template; gboolean template;
/** /**
* The template account which the transactions in a template * The template account which the transactions in a template
* splitregister will belong to. * splitregister will belong to.
**/ **/
Account *templateAcct; Account *templateAcct; /* FIXME: this should not be here! */
/* user_data allows users of this object to hang /* user_data allows users of this object to hang
* private data onto it */ * private data onto it */
@ -245,11 +195,11 @@ struct _SplitRegister
SplitRegister * SplitRegister *
xaccMallocSplitRegister (SplitRegisterType type, gnc_register_new (SplitRegisterType type,
SplitRegisterStyle style, SplitRegisterStyle style,
gboolean use_double_line, gboolean use_double_line,
TableModel *model, TableModel *model,
gboolean templateMode); gboolean templateMode);
void xaccConfigSplitRegister (SplitRegister *reg, void xaccConfigSplitRegister (SplitRegister *reg,
SplitRegisterType type, SplitRegisterType type,
@ -258,12 +208,16 @@ void xaccConfigSplitRegister (SplitRegister *reg,
void xaccDestroySplitRegister (SplitRegister *reg); void xaccDestroySplitRegister (SplitRegister *reg);
/* returns non-zero value if updates have been made to data */ BasicCell * gnc_register_get_cell (SplitRegister *sr, CellType cell_type);
guint32 xaccSplitRegisterGetChangeFlag (SplitRegister *reg); const char * gnc_register_get_cell_value (SplitRegister *sr,
guint32 xaccSplitRegisterGetConditionalChangeFlag (SplitRegister *reg); CellType cell_type);
/* Clears all change flags in the register. Does not alter values */ gboolean gnc_register_get_cursor_changed (SplitRegister *sr,
void xaccSplitRegisterClearChangeFlag (SplitRegister *reg); 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 */ /* Returns the type of the current cursor */
CursorClass xaccSplitRegisterGetCurrentCursorClass (SplitRegister *reg); CursorClass xaccSplitRegisterGetCurrentCursorClass (SplitRegister *reg);
@ -294,12 +248,11 @@ gboolean xaccSplitRegisterGetCurrentCellLoc (SplitRegister *reg,
VirtualLocation *virt_loc); VirtualLocation *virt_loc);
/* Functions for working with split register buffers */ /* Functions for working with split register buffers */
SplitRegisterBuffer * xaccMallocSplitRegisterBuffer (void); RegisterBuffer * gnc_register_buffer_new (void);
void xaccDestroySplitRegisterBuffer (SplitRegisterBuffer *srb); void gnc_register_buffer_destroy (RegisterBuffer *rb);
void xaccSplitRegisterSaveCursor(SplitRegister *sr, SplitRegisterBuffer *srb); void gnc_register_save_cursor (SplitRegister *sr, RegisterBuffer *srb);
void xaccSplitRegisterRestoreCursorChanged(SplitRegister *sr, void gnc_register_restore_cursor (SplitRegister *sr, RegisterBuffer *srb);
SplitRegisterBuffer *srb);
const char * xaccSplitRegisterGetCellTypeName (CellType type); const char * xaccSplitRegisterGetCellTypeName (CellType type);
CellType xaccSplitRegisterGetCellTypeFromName (const char *name); CellType xaccSplitRegisterGetCellTypeFromName (const char *name);

View File

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

View File

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

View File

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

View File

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