rename single-cell to basic-cell

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@427 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-01-14 06:02:25 +00:00
parent 9ca5ea0999
commit 1911c33a0a
16 changed files with 88 additions and 86 deletions

View File

@ -25,7 +25,7 @@ LIBXMHTML= ../lib/XmHTML-1.1.0/src/libXmHTML.a
LIBXBAE = ../../lib/Xbae-4.6.2-linas/libXbae.a LIBXBAE = ../../lib/Xbae-4.6.2-linas/libXbae.a
LIBCOMBO = ../lib/ComboBox-1.33/libComboBox.a LIBCOMBO = ../lib/ComboBox-1.33/libComboBox.a
###################################################################### ######################################################################
SRCS = cell.c datecell.c main.c pricecell.c single.c recncell.c \ SRCS = basiccell.c cellblock.c datecell.c main.c pricecell.c recncell.c \
table.c textcell.c table.c textcell.c
OBJS = ${SRCS:.c=.o} $(LIBXBAE) OBJS = ${SRCS:.c=.o} $(LIBXBAE)
###################################################################### ######################################################################

View File

@ -2,17 +2,17 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "single.h" #include "basiccell.h"
SingleCell * xaccMallocSingleCell (void) BasicCell * xaccMallocBasicCell (void)
{ {
SingleCell * cell; BasicCell * cell;
cell = (SingleCell *) malloc (sizeof (SingleCell)); cell = (BasicCell *) malloc (sizeof (BasicCell));
xaccInitSingleCell (cell); xaccInitBasicCell (cell);
return cell; return cell;
} }
void xaccInitSingleCell (SingleCell *cell) void xaccInitBasicCell (BasicCell *cell)
{ {
cell->type = 0; cell->type = 0;
cell->row = 0; cell->row = 0;
@ -26,7 +26,7 @@ void xaccInitSingleCell (SingleCell *cell)
cell->block = NULL; cell->block = NULL;
} }
void xaccSetSingleCellValue (SingleCell *cell, char *val) void xaccSetBasicCellValue (BasicCell *cell, char *val)
{ {
if (cell->value) free (cell->value); if (cell->value) free (cell->value);

View File

@ -1,9 +1,10 @@
/* /*
* single.h * basiccell.h
*/ */
#ifndef __XACC_SINGLE_H__ #ifndef __XACC_BASIC_CELL_H__
#define __XACC_SINGLE_H__ #define __XACC_BASIC_CELL_H__
/* cell types */ /* cell types */
enum { enum {
DATE, DATE,
@ -52,7 +53,7 @@ enum {
* to worry about garbage collection. * to worry about garbage collection.
*/ */
typedef struct _SingleCell { typedef struct _BasicCell {
short type; /* cell type */ short type; /* cell type */
short row; /* relative row position */ short row; /* relative row position */
@ -63,23 +64,23 @@ typedef struct _SingleCell {
/* private data */ /* private data */
char * value; /* current value */ char * value; /* current value */
const char * (*enter_cell) (struct _SingleCell *, const char * (*enter_cell) (struct _BasicCell *,
const char * current); const char * current);
const char * (*modify_verify) (struct _SingleCell *, const char * (*modify_verify) (struct _BasicCell *,
const char *old, const char *old,
const char *add, const char *add,
const char *new); const char *new);
const char * (*leave_cell) (struct _SingleCell *, const char * (*leave_cell) (struct _BasicCell *,
const char * current); const char * current);
struct _CellBlock *block; /* back-pointer to parent container */ struct _CellBlock *block; /* back-pointer to parent container */
} SingleCell; } BasicCell;
SingleCell * xaccMallocSingleCell (void); BasicCell * xaccMallocBasicCell (void);
void xaccInitSingleCell (SingleCell *); void xaccInitBasicCell (BasicCell *);
void xaccSetSingleCellValue (SingleCell *, char *); void xaccSetBasicCellValue (BasicCell *, char *);
#endif /* __XACC_SINGLE_H__ */ #endif /* __XACC_BASIC_CELL_H__ */
/* ------------------ end of file ---------------------- */ /* ------------------ end of file ---------------------- */

View File

@ -1,6 +1,6 @@
#include <stdlib.h> #include <stdlib.h>
#include "cell.h" #include "cellblock.h"
CellBlock * xaccMallocCellBlock (int numrows, int numcols) CellBlock * xaccMallocCellBlock (int numrows, int numcols)
{ {
@ -38,9 +38,9 @@ xaccInitCellBlock (CellBlock *arr, int numrows, int numcols)
/* malloc new cell array */ /* malloc new cell array */
arr->cells = (SingleCell ***) malloc (numrows * sizeof (SingleCell **)); arr->cells = (BasicCell ***) malloc (numrows * sizeof (BasicCell **));
for (i=0; i<numrows; i++) { for (i=0; i<numrows; i++) {
(arr->cells)[i] = (SingleCell **) malloc (numcols * sizeof (SingleCell *)); (arr->cells)[i] = (BasicCell **) malloc (numcols * sizeof (BasicCell *));
} }
/* free old widths, alignments */ /* free old widths, alignments */
@ -59,7 +59,7 @@ xaccInitCellBlock (CellBlock *arr, int numrows, int numcols)
/* =================================================== */ /* =================================================== */
void void
xaccAddCell (CellBlock *arr, SingleCell *cell, int row, int col) xaccAddCell (CellBlock *arr, BasicCell *cell, int row, int col)
{ {
if (!arr) return; if (!arr) return;
if (!cell) return; if (!cell) return;

View File

@ -1,8 +1,8 @@
#ifndef __XACC_CELL_H__ #ifndef __XACC_CELL_BLOCK_H__
#define __XACC_CELL_H__ #define __XACC_CELL_BLOCK_H__
#include "single.h" #include "basiccell.h"
/* a cell array is a traversal group for one entry in the register */ /* a cell array is a traversal group for one entry in the register */
@ -11,7 +11,7 @@ typedef struct _CellBlock {
short numRows; short numRows;
short numCols; short numCols;
SingleCell ***cells; /* row-col array */ BasicCell ***cells; /* row-col array */
/* private, utility cahced data */ /* private, utility cahced data */
short *widths; /* column widths */ short *widths; /* column widths */
@ -25,6 +25,6 @@ CellBlock * xaccMallocCellBlock (int numrows, int numcols);
void xaccInitCellBlock (CellBlock *, int numrows, int numcols); void xaccInitCellBlock (CellBlock *, int numrows, int numcols);
/* add a cell to the array */ /* add a cell to the array */
void xaccAddCell (CellBlock *, SingleCell *, int row, int col); void xaccAddCell (CellBlock *, BasicCell *, int row, int col);
#endif __XACC_CELL_H__ #endif __XACC_CELL_BLOCK_H__

View File

@ -2,8 +2,8 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include "basiccell.h"
#include "datecell.h" #include "datecell.h"
#include "single.h"
#define DATE_SEP '/' #define DATE_SEP '/'
@ -122,7 +122,7 @@ xaccValidateDate (struct tm *date, int recur)
/* ================================================ */ /* ================================================ */
static const char * static const char *
DateEnter (struct _SingleCell *_cell, const char * curr) DateEnter (struct _BasicCell *_cell, const char * curr)
{ {
DateCell *cell = (DateCell *) _cell; DateCell *cell = (DateCell *) _cell;
@ -136,7 +136,7 @@ DateEnter (struct _SingleCell *_cell, const char * curr)
/* ================================================ */ /* ================================================ */
static const char * static const char *
DateMV (struct _SingleCell *_cell, DateMV (struct _BasicCell *_cell,
const char *oldval, const char *oldval,
const char *change, const char *change,
const char *newval) const char *newval)
@ -247,7 +247,7 @@ DateMV (struct _SingleCell *_cell,
/* ================================================ */ /* ================================================ */
static const char * static const char *
DateLeave (struct _SingleCell *_cell, const char * curr) DateLeave (struct _BasicCell *_cell, const char * curr)
{ {
DateCell *cell = (DateCell *) _cell; DateCell *cell = (DateCell *) _cell;
char buff[30]; char buff[30];
@ -285,7 +285,7 @@ xaccInitDateCell (DateCell *cell)
struct tm *now; struct tm *now;
char buff[30]; char buff[30];
xaccInitSingleCell (&(cell->cell)); xaccInitBasicCell (&(cell->cell));
/* default value is today's date */ /* default value is today's date */
time (&secs); time (&secs);

View File

@ -3,10 +3,10 @@
#define __XACC_DATE_CELL_C__ #define __XACC_DATE_CELL_C__
#include <time.h> #include <time.h>
#include "single.h" #include "basiccell.h"
typedef struct _DateCell { typedef struct _DateCell {
SingleCell cell; BasicCell cell;
struct tm date; struct tm date;
} DateCell; } DateCell;

View File

@ -3,6 +3,7 @@
#include <Xm/Form.h> #include <Xm/Form.h>
#include <Xm/MainW.h> #include <Xm/MainW.h>
#include "basiccell.h"
#include "datecell.h" #include "datecell.h"
#include "pricecell.h" #include "pricecell.h"
#include "table.h" #include "table.h"
@ -36,10 +37,10 @@ typedef struct _BasicRegister {
Table * table; Table * table;
CellBlock * cursor; CellBlock * cursor;
CellBlock * header; CellBlock * header;
SingleCell * dateCell; BasicCell * dateCell;
SingleCell * descCell; BasicCell * descCell;
SingleCell * memoCell; BasicCell * memoCell;
SingleCell * recnCell; BasicCell * recnCell;
PriceCell * creditCell; PriceCell * creditCell;
PriceCell * debitCell; PriceCell * debitCell;
@ -64,49 +65,49 @@ void xaccInitBasicRegister (BasicRegister *reg)
{ {
Table * table; Table * table;
CellBlock *curs, *header; CellBlock *curs, *header;
SingleCell *cell; BasicCell *cell;
/* define the header */ /* define the header */
header = xaccMallocCellBlock (1, MAX_COLS); header = xaccMallocCellBlock (1, MAX_COLS);
reg->header = header; reg->header = header;
cell = (SingleCell *) xaccMallocDateCell(); cell = (BasicCell *) xaccMallocDateCell();
cell->width = 11; cell->width = 11;
xaccAddCell (header, cell, 0, DATE_CELL_C); xaccAddCell (header, cell, 0, DATE_CELL_C);
xaccSetSingleCellValue (cell, "Date"); xaccSetBasicCellValue (cell, "Date");
cell = xaccMallocTextCell(); cell = xaccMallocTextCell();
cell->width = 19; cell->width = 19;
xaccAddCell (header, cell, 0, DESC_CELL_C); xaccAddCell (header, cell, 0, DESC_CELL_C);
xaccSetSingleCellValue (cell, "Description"); xaccSetBasicCellValue (cell, "Description");
cell = xaccMallocRecnCell(); cell = xaccMallocRecnCell();
cell->width = 1; cell->width = 1;
xaccAddCell (header, cell, 0, RECN_CELL_C); xaccAddCell (header, cell, 0, RECN_CELL_C);
xaccSetSingleCellValue (cell, "R"); xaccSetBasicCellValue (cell, "R");
cell = (SingleCell *) xaccMallocPriceCell(); cell = (BasicCell *) xaccMallocPriceCell();
cell->width = 9; cell->width = 9;
xaccAddCell (header, cell, 0, CRED_CELL_C); xaccAddCell (header, cell, 0, CRED_CELL_C);
xaccSetSingleCellValue (cell, "Credit"); xaccSetBasicCellValue (cell, "Credit");
cell = (SingleCell *) xaccMallocPriceCell(); cell = (BasicCell *) xaccMallocPriceCell();
cell->width = 9; cell->width = 9;
xaccAddCell (header, cell, 0, DEBT_CELL_C); xaccAddCell (header, cell, 0, DEBT_CELL_C);
xaccSetSingleCellValue (cell, "Debit"); xaccSetBasicCellValue (cell, "Debit");
cell = (SingleCell *) xaccMallocPriceCell(); cell = (BasicCell *) xaccMallocPriceCell();
cell->width = 9; cell->width = 9;
xaccAddCell (header, cell, 0, BALN_CELL_C); xaccAddCell (header, cell, 0, BALN_CELL_C);
xaccSetSingleCellValue (cell, "Balance"); xaccSetBasicCellValue (cell, "Balance");
/* --------------------------- */ /* --------------------------- */
curs = xaccMallocCellBlock (2, MAX_COLS); curs = xaccMallocCellBlock (2, MAX_COLS);
reg->cursor = curs; reg->cursor = curs;
cell = (SingleCell *) xaccMallocDateCell(); cell = (BasicCell *) xaccMallocDateCell();
cell->width = 9; cell->width = 9;
xaccAddCell (curs, cell, DATE_CELL_R, DATE_CELL_C); xaccAddCell (curs, cell, DATE_CELL_R, DATE_CELL_C);
reg->dateCell = cell; reg->dateCell = cell;

View File

@ -1,8 +1,8 @@
#include <string.h> #include <string.h>
#include "basiccell.h"
#include "pricecell.h" #include "pricecell.h"
#include "single.h"
#define DECIMAL_PT '.' #define DECIMAL_PT '.'
@ -11,7 +11,7 @@
* decimal point in them */ * decimal point in them */
static const char * static const char *
PriceMV (struct _SingleCell *_cell, PriceMV (struct _BasicCell *_cell,
const char * oldval, const char * oldval,
const char *change, const char *change,
const char *newval) const char *newval)
@ -53,10 +53,10 @@ xaccMallocPriceCell (void)
void void
xaccInitPriceCell (PriceCell *cell) xaccInitPriceCell (PriceCell *cell)
{ {
xaccInitSingleCell( &(cell->cell)); xaccInitBasicCell( &(cell->cell));
cell->amount = 0.0; cell->amount = 0.0;
xaccSetSingleCellValue ( &(cell->cell), "0.0"); xaccSetBasicCellValue ( &(cell->cell), "0.0");
cell->cell.modify_verify = PriceMV; cell->cell.modify_verify = PriceMV;
} }

View File

@ -1,11 +1,11 @@
#ifndef __XACC_PRICE_C__ #ifndef __XACC_PRICE_CELL_C__
#define __XACC_PRICE_C__ #define __XACC_PRICE_CELL_C__
#include "single.h" #include "basiccell.h"
typedef struct _PriceCell { typedef struct _PriceCell {
SingleCell cell; BasicCell cell;
double amount; double amount;
} PriceCell; } PriceCell;
@ -13,6 +13,6 @@ typedef struct _PriceCell {
PriceCell * xaccMallocPriceCell (void); PriceCell * xaccMallocPriceCell (void);
void xaccInitPriceCell (PriceCell *); void xaccInitPriceCell (PriceCell *);
#endif /* __XACC_PRICE_C__ */ #endif /* __XACC_PRICE_CELL_C__ */
/* --------------- end of file ---------------------- */ /* --------------- end of file ---------------------- */

View File

@ -2,8 +2,8 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include "basiccell.h"
#include "recncell.h" #include "recncell.h"
#include "single.h"
/* hack alert -- temp defs should include Transaction.h */ /* hack alert -- temp defs should include Transaction.h */
#define NREC 'n' #define NREC 'n'
@ -12,7 +12,7 @@
/* ================================================ */ /* ================================================ */
static const char * static const char *
ToggleRecn (struct _SingleCell *_cell, const char *cur_val) ToggleRecn (struct _BasicCell *_cell, const char *cur_val)
{ {
char buff[2]; char buff[2];
@ -28,11 +28,11 @@ ToggleRecn (struct _SingleCell *_cell, const char *cur_val)
/* ================================================ */ /* ================================================ */
SingleCell * BasicCell *
xaccMallocRecnCell (void) xaccMallocRecnCell (void)
{ {
SingleCell *cell; BasicCell *cell;
cell = xaccMallocSingleCell(); cell = xaccMallocBasicCell();
xaccInitRecnCell (cell); xaccInitRecnCell (cell);
return cell; return cell;
} }
@ -40,7 +40,7 @@ xaccMallocRecnCell (void)
/* ================================================ */ /* ================================================ */
void void
xaccInitRecnCell (SingleCell *cell) xaccInitRecnCell (BasicCell *cell)
{ {
char buff[2]; char buff[2];

View File

@ -2,11 +2,11 @@
#ifndef __XACC_RECN_CELL_C__ #ifndef __XACC_RECN_CELL_C__
#define __XACC_RECN_CELL_C__ #define __XACC_RECN_CELL_C__
#include "single.h" #include "basiccell.h"
/* installs a callback to handle reconcile flag */ /* installs a callback to handle reconcile flag */
SingleCell * xaccMallocRecnCell (void); BasicCell * xaccMallocRecnCell (void);
void xaccInitRecnCell (SingleCell *); void xaccInitRecnCell (BasicCell *);
#endif /* __XACC_RECN_CELL_C__ */ #endif /* __XACC_RECN_CELL_C__ */

View File

@ -3,7 +3,7 @@
#include <Xbae/Matrix.h> #include <Xbae/Matrix.h>
#include "cell.h" #include "cellblock.h"
#include "table.h" #include "table.h"
static void enterCB (Widget mw, XtPointer cd, XtPointer cb); static void enterCB (Widget mw, XtPointer cd, XtPointer cb);
@ -243,7 +243,7 @@ enterCB (Widget mw, XtPointer cd, XtPointer cb)
XbaeMatrixEnterCellCallbackStruct *cbs; XbaeMatrixEnterCellCallbackStruct *cbs;
int row, col; int row, col;
int rel_row, rel_col; int rel_row, rel_col;
const char * (*enter) (struct _SingleCell *, const char *); const char * (*enter) (struct _BasicCell *, const char *);
table = (Table *) cd; table = (Table *) cd;
arr = table->cursor; arr = table->cursor;
@ -296,7 +296,7 @@ modifyCB (Widget mw, XtPointer cd, XtPointer cb)
XbaeMatrixModifyVerifyCallbackStruct *cbs; XbaeMatrixModifyVerifyCallbackStruct *cbs;
int row, col; int row, col;
int rel_row, rel_col; int rel_row, rel_col;
const char * (*mv) (struct _SingleCell *, const char * (*mv) (struct _BasicCell *,
const char *, const char *,
const char *, const char *,
const char *); const char *);
@ -386,7 +386,7 @@ leaveCB (Widget mw, XtPointer cd, XtPointer cb)
XbaeMatrixLeaveCellCallbackStruct *cbs; XbaeMatrixLeaveCellCallbackStruct *cbs;
int row, col; int row, col;
int rel_row, rel_col; int rel_row, rel_col;
const char * (*leave) (struct _SingleCell *, const char *); const char * (*leave) (struct _BasicCell *, const char *);
char * newval; char * newval;
table = (Table *) cd; table = (Table *) cd;

View File

@ -3,8 +3,8 @@
#define __XACC_TABLE_H__ #define __XACC_TABLE_H__
#include <Xm/Xm.h> #include <Xm/Xm.h>
#include "cell.h" #include "basiccell.h"
#include "single.h" #include "cellblock.h"
/* the table is the complete, displayed table. */ /* the table is the complete, displayed table. */
/* It consists of a header, followed by a simple /* It consists of a header, followed by a simple

View File

@ -1,15 +1,15 @@
#include <string.h> #include <string.h>
#include "basiccell.h"
#include "textcell.h" #include "textcell.h"
#include "single.h"
/* ================================================ */ /* ================================================ */
/* by definition, all text is valid text. So accept /* by definition, all text is valid text. So accept
* all modifications */ * all modifications */
static const char * static const char *
TextMV (struct _SingleCell *_cell, TextMV (struct _BasicCell *_cell,
const char *oldval, const char *oldval,
const char *change, const char *change,
const char *newval) const char *newval)
@ -19,11 +19,11 @@ TextMV (struct _SingleCell *_cell,
/* ================================================ */ /* ================================================ */
SingleCell * BasicCell *
xaccMallocTextCell (void) xaccMallocTextCell (void)
{ {
SingleCell *cell; BasicCell *cell;
cell = xaccMallocSingleCell(); cell = xaccMallocBasicCell();
xaccInitTextCell (cell); xaccInitTextCell (cell);
return cell; return cell;
} }
@ -31,7 +31,7 @@ xaccMallocTextCell (void)
/* ================================================ */ /* ================================================ */
void void
xaccInitTextCell (SingleCell *cell) xaccInitTextCell (BasicCell *cell)
{ {
if (cell->value) free (cell->value); if (cell->value) free (cell->value);
cell->value = strdup (""); cell->value = strdup ("");

View File

@ -2,11 +2,11 @@
#ifndef __XACC_TEXT_CELL_C__ #ifndef __XACC_TEXT_CELL_C__
#define __XACC_TEXT_CELL_C__ #define __XACC_TEXT_CELL_C__
#include "single.h" #include "basiccell.h"
/* installs a callback to handle text recording */ /* installs a callback to handle text recording */
SingleCell * xaccMallocTextCell (void); BasicCell * xaccMallocTextCell (void);
void xaccInitTextCell (SingleCell *); void xaccInitTextCell (BasicCell *);
#endif /* __XACC_TEXT_CELL_C__ */ #endif /* __XACC_TEXT_CELL_C__ */