mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
whoa, I think this may finally be the design we are looking for
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@650 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
73c1d13cb6
commit
7002e07cda
@ -30,6 +30,7 @@
|
||||
#include "cellblock.h"
|
||||
#include "table-allgui.h"
|
||||
|
||||
|
||||
/* ==================================================== */
|
||||
/* in C, we don't have templates. So cook up a $define that acts like a
|
||||
* template. This one will resize a 2D array.
|
||||
@ -44,9 +45,6 @@
|
||||
old_rows = table_rows; \
|
||||
old_cols = table_cols; \
|
||||
\
|
||||
table_rows = new_rows; \
|
||||
table_cols = new_cols; \
|
||||
\
|
||||
/* realloc to get the new table size. Note that the */ \
|
||||
/* new table may be wider or slimmer, taller or shorter. */ \
|
||||
if (old_rows >= new_rows) { \
|
||||
@ -139,9 +137,28 @@
|
||||
|
||||
/* ==================================================== */
|
||||
|
||||
void
|
||||
xaccTableResizeStringArr (Table * table, int new_phys_rows, int new_phys_cols)
|
||||
static Locator *
|
||||
xaccMallocLocator (void)
|
||||
{
|
||||
Locator *loc;
|
||||
loc = (Locator *) malloc (sizeof (Locator));
|
||||
loc->phys_row_offset = -1;
|
||||
loc->phys_col_offset = -1;
|
||||
loc->virt_row = -1;
|
||||
loc->virt_col = -1;
|
||||
|
||||
return (loc);
|
||||
}
|
||||
|
||||
/* ==================================================== */
|
||||
|
||||
void
|
||||
xaccTableResize (Table * table,
|
||||
int new_phys_rows, int new_phys_cols,
|
||||
int new_virt_rows, int new_virt_cols)
|
||||
{
|
||||
|
||||
/* resize the string data array */
|
||||
RESIZE_ARR ((table->num_phys_rows),
|
||||
(table->num_phys_cols),
|
||||
new_phys_rows,
|
||||
@ -149,13 +166,23 @@ xaccTableResizeStringArr (Table * table, int new_phys_rows, int new_phys_cols)
|
||||
(table->entries),
|
||||
char,
|
||||
(strdup ("")));
|
||||
}
|
||||
|
||||
/* ==================================================== */
|
||||
/* resize the locator array */
|
||||
RESIZE_ARR ((table->num_phys_rows),
|
||||
(table->num_phys_cols),
|
||||
new_phys_rows,
|
||||
new_phys_cols,
|
||||
(table->locators),
|
||||
Locator,
|
||||
(xaccMallocLocator ()));
|
||||
|
||||
void
|
||||
xaccTableResizeUserData (Table * table, int new_virt_rows, int new_virt_cols)
|
||||
{
|
||||
/* we are done with the physical dimensions.
|
||||
* record them for posterity. */
|
||||
table->num_phys_rows = new_phys_rows;
|
||||
table->num_phys_cols = new_phys_cols;
|
||||
|
||||
|
||||
/* resize the user-data hooks */
|
||||
RESIZE_ARR ((table->num_virt_rows),
|
||||
(table->num_virt_cols),
|
||||
new_virt_rows,
|
||||
@ -163,22 +190,21 @@ xaccTableResizeUserData (Table * table, int new_virt_rows, int new_virt_cols)
|
||||
(table->user_data),
|
||||
void,
|
||||
(NULL));
|
||||
}
|
||||
|
||||
/* ==================================================== */
|
||||
/* resize the handler array */
|
||||
RESIZE_ARR ((table->num_virt_rows),
|
||||
(table->num_virt_cols),
|
||||
new_virt_rows,
|
||||
new_virt_cols,
|
||||
(table->handlers),
|
||||
CellBlock,
|
||||
(NULL));
|
||||
|
||||
void
|
||||
xaccTableCount (Table *table, CellBlock *curse)
|
||||
{
|
||||
if (!table) return;
|
||||
if (!curse) return;
|
||||
/* we are done with the virtual dimensions.
|
||||
* record them for posterity. */
|
||||
table->num_virt_rows = new_virt_rows;
|
||||
table->num_virt_cols = new_virt_cols;
|
||||
|
||||
/* increment rows */
|
||||
table->cnt_phys_rows += curse->numRows;
|
||||
table->cnt_virt_rows ++;
|
||||
|
||||
/* copy columns */
|
||||
table->cnt_phys_cols = curse->numCols;
|
||||
}
|
||||
|
||||
/* ==================================================== */
|
||||
|
@ -42,17 +42,12 @@
|
||||
#endif
|
||||
|
||||
extern void
|
||||
xaccTableResizeStringArr (Table * table, int num_phys_rows, int num_phys_cols);
|
||||
|
||||
extern void
|
||||
xaccTableResizeUserData (Table * table, int new_virt_rows, int new_virt_cols);
|
||||
xaccTableResize (Table * table, int num_phys_rows, int num_phys_cols,
|
||||
int new_virt_rows, int new_virt_cols);
|
||||
|
||||
extern void
|
||||
xaccAddCursor (Table *table, CellBlock *curs);
|
||||
|
||||
/* count the number of phys rows we'll need, in prep for the malloc */
|
||||
extern void
|
||||
xaccTableCount (Table *table, CellBlock *curs);
|
||||
|
||||
#endif /* __XACC_TABLE_ALLGUI_H__ */
|
||||
|
||||
|
@ -37,6 +37,27 @@
|
||||
#include "basiccell.h"
|
||||
#include "cellblock.h"
|
||||
|
||||
/* the Locator structure is used provide a mapping from
|
||||
* the physical array of cells to the logical array of
|
||||
* virtual cell blocks.
|
||||
*
|
||||
* There is one instance of Locator for each physical cell.
|
||||
* The virt_row and virt_col members identify the corresponding
|
||||
* cellblock/virtual cell that this physical cell is a member of.
|
||||
* The two phys_offsets provide the location of the physical cell
|
||||
* as an offset from the cell block origin. That is, the offsets
|
||||
* should never be less than zero, or greater than the size of
|
||||
* the cell block.
|
||||
*/
|
||||
struct _Locator {
|
||||
short phys_row_offset;
|
||||
short phys_col_offset;
|
||||
short virt_row;
|
||||
short virt_col;
|
||||
};
|
||||
|
||||
typedef struct _Locator Locator;
|
||||
|
||||
typedef struct _Table {
|
||||
|
||||
/* The number of "physical" rows/cols is the number
|
||||
@ -66,13 +87,15 @@ typedef struct _Table {
|
||||
* of dimension num_phys_rows * num_phys_cols */
|
||||
char ***entries;
|
||||
|
||||
/* user hooks, of dimension num_rows * num_cols */
|
||||
/* handler locators for each cell,
|
||||
* of dimension num_phys_rows * num_phys_cols */
|
||||
Locator ***locators;
|
||||
|
||||
/* user hooks, of dimension num_virt_rows * num_virt_cols */
|
||||
void ***user_data;
|
||||
|
||||
/* protected data -- vital for the implementation,
|
||||
* but not something we want to generally expose */
|
||||
Widget table_widget; /* the XbaeMatrix */
|
||||
Widget next_tab_group; /* where to traverse in the end */
|
||||
/* cell blocks, of dimension num_virt_rows * num_virt_cols */
|
||||
CellBlock ***handlers;
|
||||
|
||||
/* private data, caches, etc. */
|
||||
/* This is black-box stuff that no user of this class
|
||||
@ -87,11 +110,12 @@ typedef struct _Table {
|
||||
int prev_phys_traverse_row;
|
||||
int prev_phys_traverse_col;
|
||||
|
||||
/* temporary counters */
|
||||
int cnt_phys_rows;
|
||||
int cnt_phys_cols;
|
||||
int cnt_virt_rows;
|
||||
int cnt_virt_cols;
|
||||
/* Motif-only date below, gui-independent data above */
|
||||
|
||||
/* protected data -- vital for the implementation,
|
||||
* but not something we want to generally expose */
|
||||
Widget table_widget; /* the XbaeMatrix */
|
||||
Widget next_tab_group; /* where to traverse in the end */
|
||||
|
||||
} Table;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user