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 "cellblock.h"
|
||||||
#include "table-allgui.h"
|
#include "table-allgui.h"
|
||||||
|
|
||||||
|
|
||||||
/* ==================================================== */
|
/* ==================================================== */
|
||||||
/* in C, we don't have templates. So cook up a $define that acts like a
|
/* in C, we don't have templates. So cook up a $define that acts like a
|
||||||
* template. This one will resize a 2D array.
|
* template. This one will resize a 2D array.
|
||||||
@ -44,9 +45,6 @@
|
|||||||
old_rows = table_rows; \
|
old_rows = table_rows; \
|
||||||
old_cols = table_cols; \
|
old_cols = table_cols; \
|
||||||
\
|
\
|
||||||
table_rows = new_rows; \
|
|
||||||
table_cols = new_cols; \
|
|
||||||
\
|
|
||||||
/* realloc to get the new table size. Note that the */ \
|
/* realloc to get the new table size. Note that the */ \
|
||||||
/* new table may be wider or slimmer, taller or shorter. */ \
|
/* new table may be wider or slimmer, taller or shorter. */ \
|
||||||
if (old_rows >= new_rows) { \
|
if (old_rows >= new_rows) { \
|
||||||
@ -139,9 +137,28 @@
|
|||||||
|
|
||||||
/* ==================================================== */
|
/* ==================================================== */
|
||||||
|
|
||||||
void
|
static Locator *
|
||||||
xaccTableResizeStringArr (Table * table, int new_phys_rows, int new_phys_cols)
|
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),
|
RESIZE_ARR ((table->num_phys_rows),
|
||||||
(table->num_phys_cols),
|
(table->num_phys_cols),
|
||||||
new_phys_rows,
|
new_phys_rows,
|
||||||
@ -149,13 +166,23 @@ xaccTableResizeStringArr (Table * table, int new_phys_rows, int new_phys_cols)
|
|||||||
(table->entries),
|
(table->entries),
|
||||||
char,
|
char,
|
||||||
(strdup ("")));
|
(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
|
/* we are done with the physical dimensions.
|
||||||
xaccTableResizeUserData (Table * table, int new_virt_rows, int new_virt_cols)
|
* 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),
|
RESIZE_ARR ((table->num_virt_rows),
|
||||||
(table->num_virt_cols),
|
(table->num_virt_cols),
|
||||||
new_virt_rows,
|
new_virt_rows,
|
||||||
@ -163,22 +190,21 @@ xaccTableResizeUserData (Table * table, int new_virt_rows, int new_virt_cols)
|
|||||||
(table->user_data),
|
(table->user_data),
|
||||||
void,
|
void,
|
||||||
(NULL));
|
(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
|
/* we are done with the virtual dimensions.
|
||||||
xaccTableCount (Table *table, CellBlock *curse)
|
* record them for posterity. */
|
||||||
{
|
table->num_virt_rows = new_virt_rows;
|
||||||
if (!table) return;
|
table->num_virt_cols = new_virt_cols;
|
||||||
if (!curse) return;
|
|
||||||
|
|
||||||
/* 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
|
#endif
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
xaccTableResizeStringArr (Table * table, int num_phys_rows, int num_phys_cols);
|
xaccTableResize (Table * table, int num_phys_rows, int num_phys_cols,
|
||||||
|
int new_virt_rows, int new_virt_cols);
|
||||||
extern void
|
|
||||||
xaccTableResizeUserData (Table * table, int new_virt_rows, int new_virt_cols);
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
xaccAddCursor (Table *table, CellBlock *curs);
|
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__ */
|
#endif /* __XACC_TABLE_ALLGUI_H__ */
|
||||||
|
|
||||||
|
@ -37,6 +37,27 @@
|
|||||||
#include "basiccell.h"
|
#include "basiccell.h"
|
||||||
#include "cellblock.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 {
|
typedef struct _Table {
|
||||||
|
|
||||||
/* The number of "physical" rows/cols is the number
|
/* The number of "physical" rows/cols is the number
|
||||||
@ -66,13 +87,15 @@ typedef struct _Table {
|
|||||||
* of dimension num_phys_rows * num_phys_cols */
|
* of dimension num_phys_rows * num_phys_cols */
|
||||||
char ***entries;
|
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;
|
void ***user_data;
|
||||||
|
|
||||||
/* protected data -- vital for the implementation,
|
/* cell blocks, of dimension num_virt_rows * num_virt_cols */
|
||||||
* but not something we want to generally expose */
|
CellBlock ***handlers;
|
||||||
Widget table_widget; /* the XbaeMatrix */
|
|
||||||
Widget next_tab_group; /* where to traverse in the end */
|
|
||||||
|
|
||||||
/* private data, caches, etc. */
|
/* private data, caches, etc. */
|
||||||
/* This is black-box stuff that no user of this class
|
/* 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_row;
|
||||||
int prev_phys_traverse_col;
|
int prev_phys_traverse_col;
|
||||||
|
|
||||||
/* temporary counters */
|
/* Motif-only date below, gui-independent data above */
|
||||||
int cnt_phys_rows;
|
|
||||||
int cnt_phys_cols;
|
/* protected data -- vital for the implementation,
|
||||||
int cnt_virt_rows;
|
* but not something we want to generally expose */
|
||||||
int cnt_virt_cols;
|
Widget table_widget; /* the XbaeMatrix */
|
||||||
|
Widget next_tab_group; /* where to traverse in the end */
|
||||||
|
|
||||||
} Table;
|
} Table;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user