From 67bfbd0735c3fd2b6c7b41db4d6356ece5ac9ec8 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Mon, 12 Jan 1998 10:24:34 +0000 Subject: [PATCH] add reconcile abilities git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@415 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/register/Makefile | 2 +- src/register/main.c | 35 ++++++++++++++++++++++---- src/register/recncell.c | 56 +++++++++++++++++++++++++++++++++++++++++ src/register/recncell.h | 13 ++++++++++ src/register/table.c | 4 +++ 5 files changed, 104 insertions(+), 6 deletions(-) create mode 100644 src/register/recncell.c create mode 100644 src/register/recncell.h diff --git a/src/register/Makefile b/src/register/Makefile index 2d5ab207f7..bd2ebbd5e0 100644 --- a/src/register/Makefile +++ b/src/register/Makefile @@ -24,7 +24,7 @@ LIBXMHTML= ../lib/XmHTML-1.1.0/src/libXmHTML.a LIBXBAE = ../../lib/Xbae-4.6.2-linas/libXbae.a LIBCOMBO = ../lib/ComboBox-1.33/libComboBox.a ###################################################################### -SRCS = cell.c datecell.c main.c price.c single.c table.c textcell.c +SRCS = cell.c datecell.c main.c price.c single.c recncell.c table.c textcell.c OBJS = ${SRCS:.c=.o} $(LIBXBAE) ###################################################################### diff --git a/src/register/main.c b/src/register/main.c index f661384f6c..59be9b9bb8 100644 --- a/src/register/main.c +++ b/src/register/main.c @@ -6,6 +6,7 @@ #include "datecell.h" #include "price.h" #include "table.h" +#include "recncell.h" #include "textcell.h" #define DATE_CELL_C 0 @@ -17,12 +18,20 @@ #define MEMO_CELL_C 2 #define MEMO_CELL_R 1 -#define CRED_CELL_C 3 +#define RECN_CELL_C 3 +#define RECN_CELL_R 0 + +#define CRED_CELL_C 4 #define CRED_CELL_R 0 -#define DEBT_CELL_C 4 +#define DEBT_CELL_C 5 #define DEBT_CELL_R 0 +#define BALN_CELL_C 6 +#define BALN_CELL_R 0 + +#define MAX_COLS 7 + typedef struct _BasicRegister { Table * table; CellBlock * cursor; @@ -30,6 +39,7 @@ typedef struct _BasicRegister { SingleCell * dateCell; SingleCell * descCell; SingleCell * memoCell; + SingleCell * recnCell; PriceCell * creditCell; PriceCell * debitCell; @@ -58,7 +68,7 @@ void xaccInitBasicRegister (BasicRegister *reg) /* define the header */ - header = xaccMallocCellBlock (1, 10); + header = xaccMallocCellBlock (1, MAX_COLS); reg->header = header; cell = xaccMallocDateCell(); @@ -71,6 +81,11 @@ void xaccInitBasicRegister (BasicRegister *reg) xaccAddCell (header, cell, 0, DESC_CELL_C); xaccSetSingleCellValue (cell, "Description"); + cell = xaccMallocRecnCell(); + cell->width = 1; + xaccAddCell (header, cell, 0, RECN_CELL_C); + xaccSetSingleCellValue (cell, "R"); + cell = (SingleCell *) xaccMallocPriceCell(); cell->width = 9; xaccAddCell (header, cell, 0, CRED_CELL_C); @@ -81,9 +96,14 @@ void xaccInitBasicRegister (BasicRegister *reg) xaccAddCell (header, cell, 0, DEBT_CELL_C); xaccSetSingleCellValue (cell, "Debit"); + cell = (SingleCell *) xaccMallocPriceCell(); + cell->width = 9; + xaccAddCell (header, cell, 0, BALN_CELL_C); + xaccSetSingleCellValue (cell, "Balance"); + /* --------------------------- */ - curs = xaccMallocCellBlock (2, 10); + curs = xaccMallocCellBlock (2, MAX_COLS); reg->cursor = curs; cell = xaccMallocDateCell(); @@ -101,6 +121,11 @@ void xaccInitBasicRegister (BasicRegister *reg) xaccAddCell (curs, cell, MEMO_CELL_R, MEMO_CELL_C); reg->memoCell = cell; + cell = xaccMallocRecnCell(); + cell->width = 1; + xaccAddCell (curs, cell, RECN_CELL_R, RECN_CELL_C); + reg->memoCell = cell; + reg->creditCell = xaccMallocPriceCell(); reg->creditCell->cell.width = 9; xaccAddCell (curs, &(reg->creditCell->cell), CRED_CELL_R, CRED_CELL_C); @@ -112,7 +137,7 @@ void xaccInitBasicRegister (BasicRegister *reg) table = xaccMallocTable (0, 0); table -> header = header; xaccSetCursor (table, curs); - xaccInitTable (table, 15, 1); + xaccInitTable (table, 5, 1); reg->table = table; } diff --git a/src/register/recncell.c b/src/register/recncell.c new file mode 100644 index 0000000000..f5719287cc --- /dev/null +++ b/src/register/recncell.c @@ -0,0 +1,56 @@ + +#include +#include + +#include "recncell.h" +#include "single.h" + +/* hack alert -- temp defs should include Transaction.h */ +#define NREC 'n' +#define CREC 'y' + +/* ================================================ */ + +static const char * +ToggleRecn (const char *cur_val) +{ + char buff[2]; + + if (NREC == cur_val[0]) { + buff[0] = CREC; + } else { + buff[0] = NREC; + } + buff[1] = 0x0; + + return strdup (buff); +} + +/* ================================================ */ + +SingleCell * +xaccMallocRecnCell (void) +{ + SingleCell *cell; + cell = xaccMallocSingleCell(); + xaccInitRecnCell (cell); + return cell; +} + +/* ================================================ */ + +void +xaccInitRecnCell (SingleCell *cell) +{ + char buff[2]; + + buff[0] = NREC; + buff[1] = 0x0; + + if (cell->value) free (cell->value); + cell ->value = strdup (buff); + + cell->enter_cell = ToggleRecn; +} + +/* --------------- end of file ---------------------- */ diff --git a/src/register/recncell.h b/src/register/recncell.h new file mode 100644 index 0000000000..e8e959e5cc --- /dev/null +++ b/src/register/recncell.h @@ -0,0 +1,13 @@ + +#ifndef __XACC_RECN_CELL_C__ +#define __XACC_RECN_CELL_C__ + +#include "single.h" + +/* installs a callback to handle reconcile flag */ +SingleCell * xaccMallocRecnCell (void); +void xaccInitRecnCell (SingleCell *); + +#endif /* __XACC_RECN_CELL_C__ */ + +/* --------------- end of file ---------------------- */ diff --git a/src/register/table.c b/src/register/table.c index 8e13c660f1..a23d365192 100644 --- a/src/register/table.c +++ b/src/register/table.c @@ -273,6 +273,10 @@ enterCB (Widget mw, XtPointer cd, XtPointer cb) table->entries[row][col] = (char *) retval; XbaeMatrixSetCell (mw, row, col, (char *) retval); XbaeMatrixRefreshCell (mw, row, col); + + /* don't map a text widget */ + cbs->map = False; + cbs->doit = False; } } }