mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
get rid of width and alignment attricutes in cells, & handle that stuff
differently git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1073 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
c46acc98ab
commit
7eea03c6f1
@ -46,10 +46,10 @@ BasicCell * xaccMallocBasicCell (void)
|
||||
void xaccInitBasicCell (BasicCell *cell)
|
||||
{
|
||||
cell->input_output = XACC_CELL_ALLOW_ALL;
|
||||
cell->width = 0;
|
||||
cell->alignment = 0;
|
||||
cell->bg_color = 0xffffff; /* white */
|
||||
cell->fg_color = 0x0; /* black */
|
||||
cell->use_bg_color = 0; /* ignore the color */
|
||||
cell->use_fg_color = 0; /* ignore the color */
|
||||
cell->value = 0x0;
|
||||
cell->changed = 0;
|
||||
cell->set_value = NULL;
|
||||
|
@ -170,19 +170,21 @@ typedef unsigned int uint32;
|
||||
|
||||
struct _BasicCell {
|
||||
|
||||
short width; /* column width, in chars, not pixels */
|
||||
short alignment; /* column text alignment */
|
||||
char input_output; /* zero if output-only */
|
||||
|
||||
/* hack alert -- may want to redesign color to used named color strings. */
|
||||
/* cell attributes */
|
||||
/* hack alert -- may want to redesign color to use named color strings. */
|
||||
uint32 bg_color; /* background color, ARGB format */
|
||||
uint32 fg_color; /* forground (text) color ARGB format */
|
||||
short use_fg_color; /* if 0, above is ignored */
|
||||
short use_bg_color; /* if 0, above is ignored */
|
||||
|
||||
/* hack alert -- add support for e.g. bold fonts !?!?! italic fonts ?? */
|
||||
|
||||
/* ==================================================== */
|
||||
char * value; /* current value */
|
||||
unsigned int changed; /* 2^32-1 if value modified */
|
||||
|
||||
char input_output; /* zero if output-only */
|
||||
|
||||
/* "virtual", overloaded set-value method */
|
||||
void (*set_value) (BasicCell *,
|
||||
const char * new_value);
|
||||
|
@ -159,23 +159,6 @@ xaccDestroyCellBlock (CellBlock *arr)
|
||||
|
||||
/* =================================================== */
|
||||
|
||||
void
|
||||
xaccAddCell (CellBlock *arr, BasicCell *cell, int row, int col)
|
||||
{
|
||||
if (!arr) return;
|
||||
if (!cell) return;
|
||||
|
||||
/* avoid embarrasement if cell incorrectly specified */
|
||||
if ((0 > row) || (0 > col)) return;
|
||||
if ((row >= arr->numRows) || (col >= arr->numCols)) return;
|
||||
|
||||
arr->cells[row][col] = cell;
|
||||
arr->widths[col] = cell->width;
|
||||
arr->alignments[col] = cell->alignment;
|
||||
}
|
||||
|
||||
/* =================================================== */
|
||||
|
||||
void
|
||||
xaccNextRight (CellBlock *arr, int row, int col,
|
||||
int next_row, int next_col)
|
||||
|
@ -78,6 +78,10 @@ struct _CellBlock {
|
||||
uint32 active_bg_color;
|
||||
uint32 passive_bg_color;
|
||||
|
||||
/* other attributes */
|
||||
short *widths; /* column widths */
|
||||
unsigned char *alignments; /* column text alignments */
|
||||
|
||||
short **right_traverse_r;
|
||||
short **right_traverse_c;
|
||||
/* the above arrays have dimension of numRows*numCols.
|
||||
@ -104,10 +108,6 @@ struct _CellBlock {
|
||||
* wants it to be. Handy for stuff.
|
||||
*/
|
||||
|
||||
/* private, cached utility data */
|
||||
short *widths; /* column widths */
|
||||
unsigned char *alignments; /* column text alignments */
|
||||
|
||||
};
|
||||
|
||||
typedef struct _CellBlock CellBlock;
|
||||
@ -116,9 +116,6 @@ CellBlock * xaccMallocCellBlock (int numrows, int numcols);
|
||||
void xaccInitCellBlock (CellBlock *, int numrows, int numcols);
|
||||
void xaccDestroyCellBlock (CellBlock *);
|
||||
|
||||
/* add a cell to the array */
|
||||
void xaccAddCell (CellBlock *, BasicCell *, int row, int col);
|
||||
|
||||
/* define next cell to traverse to */
|
||||
void xaccNextRight (CellBlock *, int row, int col,
|
||||
int next_row, int next_col);
|
||||
|
@ -112,6 +112,7 @@ xaccInitPriceCell (PriceCell *cell)
|
||||
|
||||
SET ( &(cell->cell), "");
|
||||
|
||||
cell->cell.use_fg_color = 1;
|
||||
cell->cell.modify_verify = PriceMV;
|
||||
cell->cell.set_value = PriceSetValue;
|
||||
}
|
||||
|
@ -448,13 +448,16 @@ SplitRegister * xaccMallocSplitRegister (int type)
|
||||
{ \
|
||||
BasicCell *hcell; \
|
||||
hcell = xaccMallocTextCell(); \
|
||||
hcell->width = NAME##_CELL_W; \
|
||||
if (1 == reg->num_header_rows) { \
|
||||
xaccAddCell (header, hcell, 0, NAME##_CELL_C); \
|
||||
} else { \
|
||||
xaccAddCell (header, hcell, NAME##_CELL_R, NAME##_CELL_C); \
|
||||
} \
|
||||
xaccSetBasicCellValue (hcell, reg->labels[NAME##_CELL]); \
|
||||
\
|
||||
if ((0<=NAME##_CELL_R) && (0<=NAME##_CELL_C)) { \
|
||||
header->widths[NAME##_CELL_C] = NAME##_CELL_W; \
|
||||
if (1 == reg->num_header_rows) { \
|
||||
header->cells[0][NAME##_CELL_C] = hcell; \
|
||||
} else { \
|
||||
header->cells[NAME##_CELL_R][NAME##_CELL_C] = hcell; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
/* BASIC & FANCY macros initialize cells in the register */
|
||||
@ -465,15 +468,17 @@ SplitRegister * xaccMallocSplitRegister (int type)
|
||||
|
||||
|
||||
#define FANCY(CN,CT,CL) { \
|
||||
/* reg->CN##Cell = xaccMalloc##CT##Cell(); */ \
|
||||
reg->CN##Cell->cell.width = CL##_CELL_W; \
|
||||
xaccAddCell (curs, &(reg->CN##Cell->cell), CL##_CELL_R, CL##_CELL_C); \
|
||||
if ((0<=CL##_CELL_R) && (0<=CL##_CELL_C)) { \
|
||||
curs->widths[CL##_CELL_C] = CL##_CELL_W; \
|
||||
curs->cells [CL##_CELL_R][CL##_CELL_C] = &(reg->CN##Cell->cell);\
|
||||
} \
|
||||
}
|
||||
|
||||
#define BASIC(CN,CT,CL) { \
|
||||
/* reg->CN##Cell = xaccMalloc##CT##Cell(); */ \
|
||||
reg->CN##Cell->width = CL##_CELL_W; \
|
||||
xaccAddCell (curs, reg->CN##Cell, CL##_CELL_R, CL##_CELL_C); \
|
||||
if ((0<=CL##_CELL_R) && (0<=CL##_CELL_C)) { \
|
||||
curs->widths[CL##_CELL_C] = CL##_CELL_W; \
|
||||
curs->cells [CL##_CELL_R][CL##_CELL_C] = reg->CN##Cell; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* ============================================== */
|
||||
@ -500,10 +505,9 @@ configCursors (SplitRegister *reg)
|
||||
*/
|
||||
|
||||
reg -> nullTransCell -> input_output = XACC_CELL_ALLOW_NONE;
|
||||
reg -> nullTransCell -> width = 1;
|
||||
xaccSetBasicCellValue (reg->nullTransCell, "");
|
||||
for (i=0; i<reg->num_cols; i++) {
|
||||
xaccAddCell (curs, reg->nullTransCell, 0, i);
|
||||
curs->cells[0][i] = reg->nullTransCell;
|
||||
}
|
||||
|
||||
FANCY (date, Date, DATE);
|
||||
@ -524,22 +528,6 @@ configCursors (SplitRegister *reg)
|
||||
curs->active_bg_color = 0xffdddd; /* pale red */
|
||||
curs->passive_bg_color = 0xccccff; /* pale blue */
|
||||
|
||||
/* Need to declare the cell backgrounds as well, otherwise,
|
||||
* the cell default will override ehte cursor
|
||||
*/
|
||||
reg->dateCell -> cell.bg_color = 0xccccff;
|
||||
reg->numCell -> bg_color = 0xccccff;
|
||||
reg->xfrmTransCell -> cell.bg_color = 0xccccff;
|
||||
reg->descCell -> cell.bg_color = 0xccccff;
|
||||
reg->recnCell -> bg_color = 0xccccff;
|
||||
reg->creditTransCell-> cell.bg_color = 0xccccff;
|
||||
reg->debitTransCell -> cell.bg_color = 0xccccff;
|
||||
reg->priceTransCell -> cell.bg_color = 0xccccff;
|
||||
reg->valueTransCell -> cell.bg_color = 0xccccff;
|
||||
reg->shrsCell -> cell.bg_color = 0xccccff;
|
||||
reg->balanceCell->cell.bg_color = 0xccccff;
|
||||
reg->nullTransCell -> bg_color = 0xccccff;
|
||||
|
||||
/* --------------------------- */
|
||||
/* define the ledger cursor that handles splits */
|
||||
/* the cursor is 1 row tall */
|
||||
@ -551,10 +539,9 @@ configCursors (SplitRegister *reg)
|
||||
*/
|
||||
|
||||
reg -> nullSplitCell -> input_output = XACC_CELL_ALLOW_NONE;
|
||||
reg -> nullSplitCell -> width = 1;
|
||||
xaccSetBasicCellValue (reg->nullSplitCell, "");
|
||||
for (i=0; i<reg->num_cols; i++) {
|
||||
xaccAddCell (curs, reg->nullSplitCell, 0, i);
|
||||
curs->cells[0][i] = reg->nullSplitCell;
|
||||
}
|
||||
|
||||
FANCY (xfrm, Combo, XFRM);
|
||||
|
@ -354,8 +354,12 @@ doMoveCursor (Table *table, int new_phys_row, int new_phys_col, int do_move_gui)
|
||||
table->bg_colors[i+r_origin][j+c_origin] = curs->passive_bg_color;
|
||||
cell = curs->cells[i][j];
|
||||
if (cell) {
|
||||
table->bg_colors[i+r_origin][j+c_origin] = cell->bg_color;
|
||||
table->fg_colors[i+r_origin][j+c_origin] = cell->fg_color;
|
||||
if (cell->use_bg_color) {
|
||||
table->bg_colors[i+r_origin][j+c_origin] = cell->bg_color;
|
||||
}
|
||||
if (cell->use_fg_color) {
|
||||
table->fg_colors[i+r_origin][j+c_origin] = cell->fg_color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -469,12 +473,12 @@ doMoveCursor (Table *table, int new_phys_row, int new_phys_col, int do_move_gui)
|
||||
cell->changed = 0;
|
||||
}
|
||||
|
||||
/* umm, a right now, we'll let the active cursor color override the
|
||||
* individual cell defaults, but for now this is an experiment.
|
||||
*
|
||||
* table->bg_colors[i+phys_row_origin][j+phys_col_origin] = cell->bg_color;
|
||||
* table->fg_colors[i+phys_row_origin][j+phys_col_origin] = cell->fg_color;
|
||||
*/
|
||||
if (cell->use_bg_color) {
|
||||
table->bg_colors[i+phys_row_origin][j+phys_col_origin] = cell->bg_color;
|
||||
}
|
||||
if (cell->use_fg_color) {
|
||||
table->fg_colors[i+phys_row_origin][j+phys_col_origin] = cell->fg_color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user