mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
more step towards implementing cell colors
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@919 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
7420a8bd6b
commit
76d34a47f0
@ -362,6 +362,12 @@ void xaccInitSplitRegister (SplitRegister *reg, int type)
|
|||||||
FANCY (desc, QuickFill, DESC);
|
FANCY (desc, QuickFill, DESC);
|
||||||
FANCY (balance, Price, BALN);
|
FANCY (balance, Price, BALN);
|
||||||
|
|
||||||
|
/* set the color of the cells in the transaction cursor */
|
||||||
|
reg->descCell->cell.bg_color = 0xccccff;
|
||||||
|
reg->balanceCell->cell.bg_color = 0xccccff;
|
||||||
|
reg->dateCell->cell.bg_color = 0xccccff;
|
||||||
|
reg->numCell->bg_color = 0xccccff;
|
||||||
|
|
||||||
/* --------------------------- */
|
/* --------------------------- */
|
||||||
/* define the ledger cursor that handles splits */
|
/* define the ledger cursor that handles splits */
|
||||||
/* the cursor is 1 row tall */
|
/* the cursor is 1 row tall */
|
||||||
|
@ -122,113 +122,30 @@ xaccSetTableSize (Table * table, int phys_rows, int phys_cols,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ==================================================== */
|
/* ==================================================== */
|
||||||
/* in C, we don't have templates. So cook up a $define that acts like a
|
|
||||||
* template. This one will resize a 2D array.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define RESIZE_ARR(table_rows,table_cols,new_rows,new_cols,arr,type,null_val,free_cell_op) \
|
#define NOOP(x) /* a big old no-op */
|
||||||
|
#define FREEUP(x) { if(x) free(x); }
|
||||||
|
|
||||||
|
#define FREE_ARR(arrname,freeup,killval) \
|
||||||
{ \
|
{ \
|
||||||
int old_rows, old_cols; \
|
|
||||||
int i,j; \
|
int i,j; \
|
||||||
\
|
/* free the arrname */ \
|
||||||
/* save old table size */ \
|
if (table->arrname) { \
|
||||||
old_rows = table_rows; \
|
for (i=0; i<table->num_phys_rows; i++) { \
|
||||||
old_cols = table_cols; \
|
if (table->arrname[i]) { \
|
||||||
if (0 > old_rows) old_rows = 0; \
|
for (j=0; j<table->num_phys_cols; j++) { \
|
||||||
if (0 > old_cols) old_cols = 0; \
|
freeup (table->arrname[i][j]); \
|
||||||
\
|
table->arrname[i][j] = killval; \
|
||||||
/* 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) { \
|
|
||||||
if (old_cols >= new_cols) { \
|
|
||||||
\
|
|
||||||
/* if we are here, new table has fewer cols */ \
|
|
||||||
/* simply truncate columns */ \
|
|
||||||
for (i=0; i<new_rows; i++) { \
|
|
||||||
for (j=new_cols; j<old_cols; j++) { \
|
|
||||||
free_cell_op (arr[i][j]); \
|
|
||||||
arr[i][j] = 0x0; /* plain null, not null_val */ \
|
|
||||||
} \
|
} \
|
||||||
|
free (table->arrname[i]); \
|
||||||
} \
|
} \
|
||||||
} else { \
|
table->arrname[i] = NULL; \
|
||||||
\
|
|
||||||
/* if we are here, the new table has more */ \
|
|
||||||
/* columns. Realloc the columns. */ \
|
|
||||||
for (i=0; i<new_rows; i++) { \
|
|
||||||
type *old_row; \
|
|
||||||
\
|
|
||||||
old_row = arr[i]; \
|
|
||||||
arr[i] = (type *) malloc (new_cols * sizeof (type)); \
|
|
||||||
for (j=0; j<old_cols; j++) { \
|
|
||||||
arr[i][j] = old_row[j]; \
|
|
||||||
} \
|
|
||||||
for (j=old_cols; j<new_cols; j++) { \
|
|
||||||
arr[i][j] = null_val; \
|
|
||||||
} \
|
|
||||||
free (old_row); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
/* new table has fewer rows. Simply truncate the rows */ \
|
|
||||||
for (i=new_rows; i<old_rows; i++) { \
|
|
||||||
for (j=0; j<old_cols; j++) { \
|
|
||||||
free_cell_op (arr[i][j]); \
|
|
||||||
} \
|
|
||||||
free (arr[i]); \
|
|
||||||
arr[i] = NULL; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
} else { \
|
|
||||||
type **old_entries; \
|
|
||||||
\
|
|
||||||
/* if we are here, there are more new than old rows */ \
|
|
||||||
if (old_cols >= new_cols) { \
|
|
||||||
\
|
|
||||||
/* new table has fewer columns. */ \
|
|
||||||
/* Simply truncate the columns */ \
|
|
||||||
for (i=0; i<old_rows; i++) { \
|
|
||||||
for (j=new_cols; j<old_cols; j++) { \
|
|
||||||
free_cell_op (arr[i][j]); \
|
|
||||||
arr[i][j] = 0x0; /* plain null, not null_val */ \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} else { \
|
|
||||||
\
|
|
||||||
/* if we are here, the new table has more */ \
|
|
||||||
/* columns. Realloc the columns. */ \
|
|
||||||
for (i=0; i<old_rows; i++) { \
|
|
||||||
type *old_row; \
|
|
||||||
\
|
|
||||||
old_row = arr[i]; \
|
|
||||||
arr[i] = (type *) malloc (new_cols * sizeof (type)); \
|
|
||||||
for (j=0; j<old_cols; j++) { \
|
|
||||||
arr[i][j] = old_row[j]; \
|
|
||||||
} \
|
|
||||||
for (j=old_cols; j<new_cols; j++) { \
|
|
||||||
arr[i][j] = null_val; \
|
|
||||||
} \
|
|
||||||
free (old_row); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
/* now, add all new rows */ \
|
|
||||||
old_entries = arr; \
|
|
||||||
arr = (type **) malloc (new_rows * sizeof (type *)); \
|
|
||||||
for (i=0; i<old_rows; i++) { \
|
|
||||||
arr[i] = old_entries[i]; \
|
|
||||||
} \
|
|
||||||
if (old_entries) free (old_entries); \
|
|
||||||
\
|
|
||||||
for (i=old_rows; i<new_rows; i++) { \
|
|
||||||
arr[i] = (type *) malloc (new_cols * sizeof (type)); \
|
|
||||||
for (j=0; j<new_cols; j++) { \
|
|
||||||
arr[i][j] = null_val; \
|
|
||||||
} \
|
|
||||||
} \
|
} \
|
||||||
|
free (table->arrname); \
|
||||||
} \
|
} \
|
||||||
|
table->arrname = NULL; \
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ==================================================== */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xaccFreeTableEntries (Table * table)
|
xaccFreeTableEntries (Table * table)
|
||||||
@ -236,38 +153,15 @@ xaccFreeTableEntries (Table * table)
|
|||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
/* free the entries */
|
/* free the entries */
|
||||||
if (table->entries) {
|
FREE_ARR (entries, FREEUP, NULL);
|
||||||
for (i=0; i<table->num_phys_rows; i++) {
|
|
||||||
if (table->entries[i]) {
|
|
||||||
for (j=0; j<table->num_phys_cols; j++) {
|
|
||||||
if (table->entries[i][j]) free (table->entries[i][j]);
|
|
||||||
table->entries[i][j] = NULL;
|
|
||||||
}
|
|
||||||
free (table->entries[i]);
|
|
||||||
}
|
|
||||||
table->entries[i] = NULL;
|
|
||||||
}
|
|
||||||
free (table->entries);
|
|
||||||
}
|
|
||||||
table->entries = NULL;
|
|
||||||
|
|
||||||
/* free the locators */
|
/* free the locators */
|
||||||
if (table->locators) {
|
FREE_ARR (locators, FREEUP, NULL);
|
||||||
for (i=0; i<table->num_phys_rows; i++) {
|
|
||||||
if (table->locators[i]) {
|
/* free the foreground and background color arrays */
|
||||||
for (j=0; j<table->num_phys_cols; j++) {
|
FREE_ARR (bg_colors, NOOP, 0xffffff);
|
||||||
if (table->locators[i][j]) free (table->locators[i][j]);
|
FREE_ARR (bg_colors, NOOP, 0x0);
|
||||||
table->locators[i][j] = NULL;
|
|
||||||
}
|
|
||||||
free (table->locators[i]);
|
|
||||||
}
|
|
||||||
table->locators[i] = NULL;
|
|
||||||
}
|
|
||||||
free (table->locators);
|
|
||||||
}
|
|
||||||
table->locators = NULL;
|
|
||||||
|
|
||||||
/* hack alert -- incomplete -- also do colors */
|
|
||||||
/* null out user data and handlers */
|
/* null out user data and handlers */
|
||||||
for (i=0; i<table->num_virt_rows; i++) {
|
for (i=0; i<table->num_virt_rows; i++) {
|
||||||
for (j=0; j<table->num_virt_cols; j++) {
|
for (j=0; j<table->num_virt_cols; j++) {
|
||||||
@ -308,7 +202,7 @@ xaccTableResize (Table * table,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* resize the string data array */
|
/* resize the string data array */
|
||||||
RESIZE_ARR ((table->num_phys_rows),
|
XACC_RESIZE_ARRAY ((table->num_phys_rows),
|
||||||
(table->num_phys_cols),
|
(table->num_phys_cols),
|
||||||
new_phys_rows,
|
new_phys_rows,
|
||||||
new_phys_cols,
|
new_phys_cols,
|
||||||
@ -318,7 +212,7 @@ xaccTableResize (Table * table,
|
|||||||
free);
|
free);
|
||||||
|
|
||||||
/* resize the locator array */
|
/* resize the locator array */
|
||||||
RESIZE_ARR ((table->num_phys_rows),
|
XACC_RESIZE_ARRAY ((table->num_phys_rows),
|
||||||
(table->num_phys_cols),
|
(table->num_phys_cols),
|
||||||
new_phys_rows,
|
new_phys_rows,
|
||||||
new_phys_cols,
|
new_phys_cols,
|
||||||
@ -328,50 +222,55 @@ xaccTableResize (Table * table,
|
|||||||
free);
|
free);
|
||||||
|
|
||||||
/* resize the bg color array (white background) */
|
/* resize the bg color array (white background) */
|
||||||
RESIZE_ARR ((table->num_phys_rows),
|
XACC_RESIZE_ARRAY ((table->num_phys_rows),
|
||||||
(table->num_phys_cols),
|
(table->num_phys_cols),
|
||||||
new_phys_rows,
|
new_phys_rows,
|
||||||
new_phys_cols,
|
new_phys_cols,
|
||||||
(table->bg_colors),
|
(table->bg_colors),
|
||||||
int,
|
int,
|
||||||
(0xffffff), /* white */
|
(0xffffff), /* white */
|
||||||
(int)); /* no-op */
|
NOOP); /* no-op */
|
||||||
|
|
||||||
/* resize the foreground color array (black text) */
|
/* resize the foreground color array (black text) */
|
||||||
RESIZE_ARR ((table->num_phys_rows),
|
XACC_RESIZE_ARRAY ((table->num_phys_rows),
|
||||||
(table->num_phys_cols),
|
(table->num_phys_cols),
|
||||||
new_phys_rows,
|
new_phys_rows,
|
||||||
new_phys_cols,
|
new_phys_cols,
|
||||||
(table->fg_colors),
|
(table->fg_colors),
|
||||||
int,
|
int,
|
||||||
(0x0), /* black */
|
(0x0), /* black */
|
||||||
(int)); /* no-op */
|
NOOP); /* no-op */
|
||||||
|
|
||||||
/* 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 the user-data hooks */
|
||||||
RESIZE_ARR ((table->num_virt_rows),
|
XACC_RESIZE_ARRAY ((table->num_virt_rows),
|
||||||
(table->num_virt_cols),
|
(table->num_virt_cols),
|
||||||
new_virt_rows,
|
new_virt_rows,
|
||||||
new_virt_cols,
|
new_virt_cols,
|
||||||
(table->user_data),
|
(table->user_data),
|
||||||
void *,
|
void *,
|
||||||
(NULL),
|
(NULL),
|
||||||
(void *)); /* no-op */
|
NOOP); /* no-op */
|
||||||
|
|
||||||
/* resize the handler array */
|
/* resize the handler array */
|
||||||
RESIZE_ARR ((table->num_virt_rows),
|
XACC_RESIZE_ARRAY ((table->num_virt_rows),
|
||||||
(table->num_virt_cols),
|
(table->num_virt_cols),
|
||||||
new_virt_rows,
|
new_virt_rows,
|
||||||
new_virt_cols,
|
new_virt_cols,
|
||||||
(table->handlers),
|
(table->handlers),
|
||||||
CellBlock *,
|
CellBlock *,
|
||||||
(NULL),
|
(NULL),
|
||||||
(CellBlock *)); /* no-op */
|
NOOP); /* no-op */
|
||||||
|
|
||||||
|
/* call the "derived" class resize method */
|
||||||
|
TABLE_PRIVATE_DATA_RESIZE (table,
|
||||||
|
new_phys_rows, new_phys_cols,
|
||||||
|
new_virt_rows, 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;
|
||||||
|
|
||||||
/* we are done with the virtual dimensions.
|
/* we are done with the virtual dimensions.
|
||||||
* record them for posterity. */
|
* record them for posterity. */
|
||||||
|
@ -192,7 +192,7 @@ void xaccCommitCursor (Table *);
|
|||||||
|
|
||||||
/* hack alert --
|
/* hack alert --
|
||||||
* for all practical purposes, RefreshHeader is identical
|
* for all practical purposes, RefreshHeader is identical
|
||||||
* tp CommitCursor(), except that it acts on cellblock 0,0.
|
* to CommitCursor(), except that it acts on cellblock 0,0.
|
||||||
* it should probably be made obsolete.
|
* it should probably be made obsolete.
|
||||||
*/
|
*/
|
||||||
void xaccRefreshHeader (Table *);
|
void xaccRefreshHeader (Table *);
|
||||||
@ -208,6 +208,119 @@ void xaccRefreshHeader (Table *);
|
|||||||
void
|
void
|
||||||
xaccVerifyCursorPosition (Table *table, int phys_row, int phys_col);
|
xaccVerifyCursorPosition (Table *table, int phys_row, int phys_col);
|
||||||
|
|
||||||
|
/* ==================================================== */
|
||||||
|
/*
|
||||||
|
* In C, we don't have things like C++ templates.
|
||||||
|
* So cook up a #define that acts like a template.
|
||||||
|
* This one will resize a 2D array in a reasonably
|
||||||
|
* efficient manner.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define XACC_RESIZE_ARRAY(table_rows,table_cols,new_rows,new_cols,arr,type,null_val,free_cell_op) \
|
||||||
|
{ \
|
||||||
|
int old_rows, old_cols; \
|
||||||
|
int i,j; \
|
||||||
|
\
|
||||||
|
/* save old table size */ \
|
||||||
|
old_rows = table_rows; \
|
||||||
|
old_cols = table_cols; \
|
||||||
|
if (0 > old_rows) old_rows = 0; \
|
||||||
|
if (0 > old_cols) old_cols = 0; \
|
||||||
|
\
|
||||||
|
/* 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) { \
|
||||||
|
if (old_cols >= new_cols) { \
|
||||||
|
\
|
||||||
|
/* if we are here, new table has fewer cols */ \
|
||||||
|
/* simply truncate columns */ \
|
||||||
|
for (i=0; i<new_rows; i++) { \
|
||||||
|
for (j=new_cols; j<old_cols; j++) { \
|
||||||
|
free_cell_op (arr[i][j]); \
|
||||||
|
arr[i][j] = 0x0; /* plain null, not null_val */ \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} else { \
|
||||||
|
\
|
||||||
|
/* if we are here, the new table has more */ \
|
||||||
|
/* columns. Realloc the columns. */ \
|
||||||
|
for (i=0; i<new_rows; i++) { \
|
||||||
|
type *old_row; \
|
||||||
|
\
|
||||||
|
old_row = arr[i]; \
|
||||||
|
arr[i] = (type *) malloc (new_cols * sizeof (type)); \
|
||||||
|
for (j=0; j<old_cols; j++) { \
|
||||||
|
arr[i][j] = old_row[j]; \
|
||||||
|
} \
|
||||||
|
for (j=old_cols; j<new_cols; j++) { \
|
||||||
|
arr[i][j] = null_val; \
|
||||||
|
} \
|
||||||
|
free (old_row); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
/* new table has fewer rows. Simply truncate the rows */ \
|
||||||
|
for (i=new_rows; i<old_rows; i++) { \
|
||||||
|
for (j=0; j<old_cols; j++) { \
|
||||||
|
free_cell_op (arr[i][j]); \
|
||||||
|
} \
|
||||||
|
free (arr[i]); \
|
||||||
|
arr[i] = NULL; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
} else { \
|
||||||
|
type **old_entries; \
|
||||||
|
\
|
||||||
|
/* if we are here, there are more new than old rows */ \
|
||||||
|
if (old_cols >= new_cols) { \
|
||||||
|
\
|
||||||
|
/* new table has fewer columns. */ \
|
||||||
|
/* Simply truncate the columns */ \
|
||||||
|
for (i=0; i<old_rows; i++) { \
|
||||||
|
for (j=new_cols; j<old_cols; j++) { \
|
||||||
|
free_cell_op (arr[i][j]); \
|
||||||
|
arr[i][j] = 0x0; /* plain null, not null_val */ \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} else { \
|
||||||
|
\
|
||||||
|
/* if we are here, the new table has more */ \
|
||||||
|
/* columns. Realloc the columns. */ \
|
||||||
|
for (i=0; i<old_rows; i++) { \
|
||||||
|
type *old_row; \
|
||||||
|
\
|
||||||
|
old_row = arr[i]; \
|
||||||
|
arr[i] = (type *) malloc (new_cols * sizeof (type)); \
|
||||||
|
for (j=0; j<old_cols; j++) { \
|
||||||
|
arr[i][j] = old_row[j]; \
|
||||||
|
} \
|
||||||
|
for (j=old_cols; j<new_cols; j++) { \
|
||||||
|
arr[i][j] = null_val; \
|
||||||
|
} \
|
||||||
|
free (old_row); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
/* now, add all new rows */ \
|
||||||
|
old_entries = arr; \
|
||||||
|
arr = (type **) malloc (new_rows * sizeof (type *)); \
|
||||||
|
for (i=0; i<old_rows; i++) { \
|
||||||
|
arr[i] = old_entries[i]; \
|
||||||
|
} \
|
||||||
|
if (old_entries) free (old_entries); \
|
||||||
|
\
|
||||||
|
for (i=old_rows; i<new_rows; i++) { \
|
||||||
|
arr[i] = (type *) malloc (new_cols * sizeof (type)); \
|
||||||
|
for (j=0; j<new_cols; j++) { \
|
||||||
|
arr[i][j] = null_val; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==================================================== */
|
||||||
|
|
||||||
#endif /* __XACC_TABLE_ALLGUI_H__ */
|
#endif /* __XACC_TABLE_ALLGUI_H__ */
|
||||||
|
|
||||||
/* ================== end of file ======================= */
|
/* ================== end of file ======================= */
|
||||||
|
@ -95,6 +95,9 @@
|
|||||||
g_free(table->prev_entry_text); table->prev_entry_text = NULL; \
|
g_free(table->prev_entry_text); table->prev_entry_text = NULL; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* nothing to resize */
|
||||||
|
#define TABLE_PRIVATE_DATA_RESIZE(table)
|
||||||
|
|
||||||
typedef struct _Table Table;
|
typedef struct _Table Table;
|
||||||
|
|
||||||
/* create the GtkWidget */
|
/* create the GtkWidget */
|
||||||
|
@ -480,6 +480,9 @@ SetupColorTable (Table *table)
|
|||||||
XColor * colors;
|
XColor * colors;
|
||||||
int i, ncolors;
|
int i, ncolors;
|
||||||
|
|
||||||
|
/* if already initialized, do nothing */
|
||||||
|
if (0 != table->ncolors) return;
|
||||||
|
|
||||||
/* get the number of colors in our colormap */
|
/* get the number of colors in our colormap */
|
||||||
dpy = XtDisplay (table->table_widget);
|
dpy = XtDisplay (table->table_widget);
|
||||||
win = XtWindow (table->table_widget);
|
win = XtWindow (table->table_widget);
|
||||||
@ -655,25 +658,104 @@ GetColormapIndex (Table *table, int argb)
|
|||||||
|
|
||||||
/* ==================================================== */
|
/* ==================================================== */
|
||||||
|
|
||||||
|
#define NOOP(x) /* do nothing */
|
||||||
|
|
||||||
|
void
|
||||||
|
xaccMotifResizeTable (Table * table,
|
||||||
|
int new_phys_rows, int new_phys_cols,
|
||||||
|
int new_virt_rows, int new_virt_cols)
|
||||||
|
|
||||||
|
{
|
||||||
|
XACC_RESIZE_ARRAY ((table->num_phys_rows),
|
||||||
|
(table->num_phys_cols),
|
||||||
|
new_phys_rows,
|
||||||
|
new_phys_cols,
|
||||||
|
(table->bg_hues),
|
||||||
|
Pixel,
|
||||||
|
1,
|
||||||
|
NOOP);
|
||||||
|
|
||||||
|
XACC_RESIZE_ARRAY ((table->num_phys_rows),
|
||||||
|
(table->num_phys_cols),
|
||||||
|
new_phys_rows,
|
||||||
|
new_phys_cols,
|
||||||
|
(table->fg_hues),
|
||||||
|
Pixel,
|
||||||
|
0,
|
||||||
|
NOOP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==================================================== */
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccRefreshTableGUI (Table * table)
|
xaccRefreshTableGUI (Table * table)
|
||||||
{
|
{
|
||||||
|
int iphys, jphys;
|
||||||
|
int bg_cache, fg_cache;
|
||||||
|
Pixel bg_cache_val, fg_cache_val;
|
||||||
|
Pixel white, black;
|
||||||
|
|
||||||
{int i;
|
{int i;
|
||||||
printf (" refresh numphysrows=%d numphyscols=%d \n", table->num_phys_rows,table->num_phys_cols);
|
printf (" refresh numphysrows=%d numphyscols=%d \n", table->num_phys_rows,table->num_phys_cols);
|
||||||
for (i=0; i<table->num_phys_rows; i++) {
|
for (i=0; i<table->num_phys_rows; i++) {
|
||||||
printf ("cell %d act:%s descr: %s \n", i, table->entries[i][2],
|
printf ("cell %d color: 0x%x act:%s descr: %s \n", i, table->bg_colors[i][3], table->entries[i][2],
|
||||||
table->entries[i][3]);
|
table->entries[i][3]);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
/* make sure that the color table is initialized.
|
||||||
|
* it would be slightly more efficient if we called
|
||||||
|
* this from a realize method, but we don't have one
|
||||||
|
* of these handy.
|
||||||
|
*/
|
||||||
|
SetupColorTable (table);
|
||||||
|
|
||||||
|
black = GetColormapIndex (table, 0x0);
|
||||||
|
fg_cache = 0x0;
|
||||||
|
fg_cache_val = black;
|
||||||
|
|
||||||
|
white = GetColormapIndex (table, 0xffffff);
|
||||||
|
bg_cache = 0xffffff;
|
||||||
|
bg_cache_val = white;
|
||||||
|
|
||||||
|
for (iphys=0; iphys<table->num_phys_rows; iphys++)
|
||||||
|
{
|
||||||
|
for (jphys = 0; jphys < table->num_phys_cols; jphys++)
|
||||||
|
{
|
||||||
|
/* fill in the colormap entry that is the equivalent
|
||||||
|
* of th requested background color */
|
||||||
|
if (0xffffff == table->bg_colors[iphys][jphys]) {
|
||||||
|
table->bg_hues[iphys][jphys] = white;
|
||||||
|
} else
|
||||||
|
if (bg_cache == table->bg_colors[iphys][jphys]) {
|
||||||
|
table->bg_hues[iphys][jphys] = bg_cache_val;
|
||||||
|
} else {
|
||||||
|
bg_cache = table->bg_colors[iphys][jphys];
|
||||||
|
bg_cache_val = GetColormapIndex (table, bg_cache);
|
||||||
|
table->bg_hues[iphys][jphys] = bg_cache_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* fill in the colormap entry that is the equivalent
|
||||||
|
* of th requested foreground color */
|
||||||
|
if (0xffffff == table->fg_colors[iphys][jphys]) {
|
||||||
|
table->fg_hues[iphys][jphys] = white;
|
||||||
|
} else
|
||||||
|
if (fg_cache == table->fg_colors[iphys][jphys]) {
|
||||||
|
table->fg_hues[iphys][jphys] = fg_cache_val;
|
||||||
|
} else {
|
||||||
|
fg_cache = table->fg_colors[iphys][jphys];
|
||||||
|
fg_cache_val = GetColormapIndex (table, fg_cache);
|
||||||
|
table->fg_hues[iphys][jphys] = fg_cache_val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
XtVaSetValues (table->table_widget, XmNrows, table->num_phys_rows,
|
XtVaSetValues (table->table_widget, XmNrows, table->num_phys_rows,
|
||||||
XmNcolumns, table->num_phys_cols,
|
XmNcolumns, table->num_phys_cols,
|
||||||
XmNcells, table->entries,
|
XmNcells, table->entries,
|
||||||
/* XmNcellBackgrounds, table->?? */
|
XmNcellBackgrounds, table->bg_hues,
|
||||||
|
XmNcolors, table->fg_hues,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|
||||||
SetupColorTable (table);
|
|
||||||
{Pixel p=GetColormapIndex (table,0x99ee33);
|
|
||||||
printf ("its %d\n", p); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================== end of file ======================= */
|
/* ================== end of file ======================= */
|
||||||
|
@ -53,8 +53,10 @@
|
|||||||
/* Motif specific private data */ \
|
/* Motif specific private data */ \
|
||||||
Widget table_widget; /* the XbaeMatrix */ \
|
Widget table_widget; /* the XbaeMatrix */ \
|
||||||
Widget next_tab_group; /* where to traverse in the end */ \
|
Widget next_tab_group; /* where to traverse in the end */ \
|
||||||
unsigned int ncolors; /* number of colors in colormap */ \
|
unsigned int ncolors; /* number of colors in colormap */ \
|
||||||
XColor *colors; /* colormap entries */
|
XColor *colors; /* colormap entries */ \
|
||||||
|
Pixel **bg_hues; /* background cell colors */ \
|
||||||
|
Pixel **fg_hues; /* foreground (text) cell colors */
|
||||||
|
|
||||||
|
|
||||||
#define TABLE_PRIVATE_DATA_INIT(table) { \
|
#define TABLE_PRIVATE_DATA_INIT(table) { \
|
||||||
@ -62,17 +64,26 @@
|
|||||||
table->next_tab_group = 0; \
|
table->next_tab_group = 0; \
|
||||||
table->ncolors = 0; \
|
table->ncolors = 0; \
|
||||||
table->colors = 0x0; \
|
table->colors = 0x0; \
|
||||||
|
table->bg_hues = 0x0; \
|
||||||
|
table->fg_hues = 0x0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
/* hack alert -- shouldn't destroy get rid of the widget? */
|
/* hack alert -- shouldn't destroy get rid of the widget? */
|
||||||
|
/* hack alert -- I think destroy should unmalloc colors ?? */
|
||||||
#define TABLE_PRIVATE_DATA_DESTROY(table)
|
#define TABLE_PRIVATE_DATA_DESTROY(table)
|
||||||
|
|
||||||
|
#define TABLE_PRIVATE_DATA_RESIZE xaccMotifResizeTable
|
||||||
|
|
||||||
typedef struct _Table Table;
|
typedef struct _Table Table;
|
||||||
|
|
||||||
/* create the widget */
|
/* create the widget */
|
||||||
Widget xaccCreateTable (Table *, Widget parent, char * name);
|
Widget xaccCreateTable (Table *, Widget parent, char * name);
|
||||||
void xaccNextTabGroup (Table *, Widget);
|
void xaccNextTabGroup (Table *, Widget);
|
||||||
|
|
||||||
|
void xaccMotifResizeTable (Table * table,
|
||||||
|
int new_phys_rows, int new_phys_cols,
|
||||||
|
int new_virt_rows, int new_virt_cols);
|
||||||
|
|
||||||
/* redraw the table GUI */
|
/* redraw the table GUI */
|
||||||
void xaccRefreshTableGUI (Table *);
|
void xaccRefreshTableGUI (Table *);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user