add implementation

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@397 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-01-09 02:28:36 +00:00
parent b17c29bba4
commit fd868aa714
2 changed files with 69 additions and 13 deletions

View File

@ -1,23 +1,53 @@
#include <Xm/Xm.h> #include <stdlib.h>
#include "single.h" #include "cell.h"
typedef struct _CellArray { CellArray * xaccMallocCellArray (int numrows, int numcols)
{
short numRows; CellArray *arr;
short numCols; arr = (CellArray *) malloc (sizeof (CellArray *));
SingleCell **cells; /* row-col array */ arr->cells = NULL;
xaccInitCellArray (arr, numrows, numcols);
Widget reg; /* the XbaeMatrix */ return arr;
} CellArray; }
/* =================================================== */
CellArray * xaccMallocCellArray (void); void
void xaccInitCellArray (CellArray *, int numrows, int numcols); xaccInitCellArray (CellArray *arr, int numrows, int numcols)
void xaccDestroyCellArray (CellArray *); {
int i;
/* add a cell to the array */ arr->numRows = numrows;
void xaccAddCell (SingleCell *); arr->numCols = numcols;
if (arr->cells) {
for (i=0; i<numrows; i++) {
if (arr->cells[i]) free (arr->cells[i]);
}
free (arr->cells);
}
arr->cells = (SingleCell ***) malloc (numrows * sizeof (SingleCell **));
for (i=0; i<numrows; i++) {
arr->cells[i] = (SingleCell **) malloc (numcols * sizeof (SingleCell *));
}
}
/* =================================================== */
void
xaccAddCell (CellArray *arr, SingleCell *cell)
{
int i,j;
i = cell->row;
j = cell->col;
arr->cells[i][j] = cell;
}
/* --------------- end of file ----------------- */

26
src/register/cellblock.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef __XACC_CELL_H__
#define __XACC_CELL_H__
#include <Xm/Xm.h>
#include "single.h"
typedef struct _CellArray {
short numRows;
short numCols;
SingleCell ***cells; /* row-col array */
Widget reg; /* the XbaeMatrix */
} CellArray;
CellArray * xaccMallocCellArray (int numrows, int numcols);
void xaccInitCellArray (CellArray *, int numrows, int numcols);
void xaccDestroyCellArray (CellArray *);
/* add a cell to the array */
void xaccAddCell (CellArray *, SingleCell *);
#endif __XACC_CELL_H__