Don't cache cell colors in the styles -- always get them from the Table.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3025 57a11ea4-9604-0410-9ed3-97b8803252fd
zzzoldreleases/1.6
Dave Peticolas 26 years ago
parent 2bba3b8d26
commit b26500bf50

@ -273,7 +273,8 @@ draw_cell (GnucashGrid *grid, int block,
gdk_gc_set_background (grid->gc, &gn_white);
sheet_block = gnucash_sheet_get_block (grid->sheet, virt_loc.vcell_loc);
sheet_block = gnucash_sheet_get_block (grid->sheet,
virt_loc.vcell_loc);
argb = gnc_table_get_bg_color_virtual (table, virt_loc);
bg_color = gnucash_color_argb_to_gdk (argb);

@ -66,19 +66,28 @@ gnucash_header_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
SheetBlockStyle *style = header->style;
SheetBlockStyle *header_style;
CellDimensions *cd;
VirtualLocation virt_loc;
Table *table = header->sheet->table;
int i, j;
int xpaint, ypaint;
int w = 0, h = 0;
gchar *text;
GdkFont *font;
CellStyle *cs;
GdkColor *bg_color;
guint32 argb;
header_style = header->sheet->cursor_styles[GNUCASH_CURSOR_HEADER];
cs = gnucash_style_get_cell_style (header_style, 0, 0);
virt_loc.vcell_loc.virt_row = 0;
virt_loc.vcell_loc.virt_col = 0;
virt_loc.phys_row_offset = 0;
virt_loc.phys_col_offset = 0;
argb = gnc_table_get_bg_color_virtual (table, virt_loc);
bg_color = gnucash_color_argb_to_gdk (argb);
/* Assume all cells have the same color */
gdk_gc_set_foreground(header->gc, cs->inactive_bg_color);
gdk_gc_set_foreground(header->gc, bg_color);
gdk_draw_rectangle(drawable, header->gc, TRUE, 0, 0, width, height);
gdk_gc_set_line_attributes (header->gc, 1, GDK_LINE_SOLID, -1, -1);

@ -94,23 +94,21 @@ static void item_edit_show_combo_toggle (ItemEdit *item_edit,
* Returns the coordinates for the editor bounding box
*/
void
item_edit_get_pixel_coords (ItemEdit *item_edit, int *x, int *y,
int *w, int *h)
item_edit_get_pixel_coords (ItemEdit *item_edit,
int *x, int *y,
int *w, int *h)
{
GnucashSheet *sheet = item_edit->sheet;
VirtualCellLocation vcell_loc = { item_edit->virt_row,
item_edit->virt_col };
int xd, yd, save;
int xd, yd;
gnome_canvas_get_scroll_offsets (GNOME_CANVAS(sheet), NULL, &yd);
save = yd;
gnucash_sheet_block_pixel_origin (sheet, item_edit->virt_loc.vcell_loc,
&xd, &yd);
gnucash_sheet_block_pixel_origin (sheet, vcell_loc, &xd, &yd);
gnucash_sheet_style_get_cell_pixel_rel_coords (item_edit->style,
item_edit->cell_row,
item_edit->cell_col,
x, y, w, h);
gnucash_sheet_style_get_cell_pixel_rel_coords
(item_edit->style,
item_edit->virt_loc.phys_row_offset,
item_edit->virt_loc.phys_col_offset,
x, y, w, h);
*x += xd;
*y += yd;
@ -124,6 +122,7 @@ item_edit_draw_info(ItemEdit *item_edit, int x, int y, TextDrawInfo *info)
SheetBlockStyle *style;
GtkEditable *editable;
CellStyle *cs;
Table *table;
int text_len, total_width;
int pre_cursor_width;
@ -132,16 +131,20 @@ item_edit_draw_info(ItemEdit *item_edit, int x, int y, TextDrawInfo *info)
int start_pos, end_pos;
int toggle_space, cursor_pos;
int xoffset;
guint32 argb;
style = item_edit->style;
table = item_edit->sheet->table;
info->font = GNUCASH_GRID(item_edit->sheet->grid)->normal_font;
cs = gnucash_style_get_cell_style (style,
item_edit->cell_row,
item_edit->cell_col);
item_edit->virt_loc.phys_row_offset,
item_edit->virt_loc.phys_col_offset);
info->bg_color = cs->active_bg_color;
argb = gnc_table_get_bg_color_virtual (table, item_edit->virt_loc);
info->bg_color = gnucash_color_argb_to_gdk (argb);
info->fg_color = &gn_black;
info->bg_color2 = &gn_dark_gray;
@ -224,7 +227,8 @@ item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
TextDrawInfo info;
/* be sure we're valid */
if (item_edit->virt_row < 0 || item_edit->virt_col < 0)
if (item_edit->virt_loc.vcell_loc.virt_row < 0 ||
item_edit->virt_loc.vcell_loc.virt_col < 0)
return;
/* Get the measurements for drawing */
@ -391,10 +395,10 @@ item_edit_init (ItemEdit *item_edit)
item_edit->gc = NULL;
item_edit->style = NULL;
item_edit->virt_col = -1;
item_edit->virt_row = -1;
item_edit->cell_col = -1;
item_edit->cell_row = -1;
item_edit->virt_loc.vcell_loc.virt_row = -1;
item_edit->virt_loc.vcell_loc.virt_col = -1;
item_edit->virt_loc.phys_row_offset = -1;
item_edit->virt_loc.phys_col_offset = -1;
}
@ -479,10 +483,7 @@ item_edit_set_cursor_pos (ItemEdit *item_edit,
o_x = cd->origin_x;
o_y = cd->origin_y;
if ( (virt_loc.vcell_loc.virt_row != item_edit->virt_row) ||
(virt_loc.vcell_loc.virt_col != item_edit->virt_col) ||
(cell_row != item_edit->cell_row) ||
(cell_col != item_edit->cell_col) )
if (!virt_loc_equal (virt_loc, item_edit->virt_loc))
return FALSE;
editable = GTK_EDITABLE (item_edit->editor);
@ -491,9 +492,10 @@ item_edit_set_cursor_pos (ItemEdit *item_edit,
GtkJustification align;
CellStyle *cs;
cs = gnucash_style_get_cell_style (item_edit->style,
item_edit->cell_row,
item_edit->cell_col);
cs = gnucash_style_get_cell_style
(item_edit->style,
item_edit->virt_loc.phys_row_offset,
item_edit->virt_loc.phys_col_offset);
align = cs->alignment;
@ -594,25 +596,22 @@ item_edit_configure (ItemEdit *item_edit)
{
GnucashSheet *sheet = item_edit->sheet;
GnucashItemCursor *cursor;
VirtualCellLocation vcell_loc;
cursor = GNUCASH_ITEM_CURSOR
(GNUCASH_CURSOR(sheet->cursor)->cursor[GNUCASH_CURSOR_BLOCK]);
item_edit->virt_row = cursor->row;
item_edit->virt_col = cursor->col;
vcell_loc.virt_row = cursor->row;
vcell_loc.virt_col = cursor->col;
item_edit->virt_loc.vcell_loc.virt_row = cursor->row;
item_edit->virt_loc.vcell_loc.virt_col = cursor->col;
item_edit->style = gnucash_sheet_get_style (item_edit->sheet,
vcell_loc);
item_edit->style =
gnucash_sheet_get_style (item_edit->sheet,
item_edit->virt_loc.vcell_loc);
cursor = GNUCASH_ITEM_CURSOR
(GNUCASH_CURSOR(sheet->cursor)->cursor[GNUCASH_CURSOR_CELL]);
item_edit->cell_row = cursor->row;
item_edit->cell_col = cursor->col;
item_edit->virt_loc.phys_row_offset = cursor->row;
item_edit->virt_loc.phys_col_offset = cursor->col;
item_edit_update (GNOME_CANVAS_ITEM(item_edit), NULL, NULL, 0);
}

@ -77,7 +77,7 @@ typedef struct
GdkGC *gc;
/* Where are we */
int cell_col, cell_row, virt_col, virt_row;
VirtualLocation virt_loc;
SheetBlockStyle *style;
} ItemEdit;

@ -1771,9 +1771,9 @@ gnucash_sheet_get_block (GnucashSheet *sheet, VirtualCellLocation vcell_loc)
}
/* This fills up a block from the table; it sets the style, sizes the
entries matrix, and sets the entries. */
void
/* This fills up a block from the table; it sets the style and returns
* true if the style changed. */
gboolean
gnucash_sheet_block_set_from_table (GnucashSheet *sheet,
VirtualCellLocation vcell_loc)
{
@ -1785,7 +1785,7 @@ gnucash_sheet_block_set_from_table (GnucashSheet *sheet,
style = gnucash_sheet_get_style_from_table (sheet, vcell_loc);
if (block == NULL)
return;
return FALSE;
table = sheet->table;
@ -1806,7 +1806,11 @@ gnucash_sheet_block_set_from_table (GnucashSheet *sheet,
sheet->height += block->style->dimensions->height;
gnucash_style_ref(block->style);
return TRUE;
}
return FALSE;
}
@ -1954,7 +1958,7 @@ gnucash_sheet_resize (GnucashSheet *sheet)
}
void
gnucash_sheet_table_load (GnucashSheet *sheet)
gnucash_sheet_recompute_block_offsets (GnucashSheet *sheet)
{
Table *table;
SheetBlock *block;
@ -1970,14 +1974,6 @@ gnucash_sheet_table_load (GnucashSheet *sheet)
table = sheet->table;
num_virt_rows = table->num_virt_rows;
gtk_layout_freeze (GTK_LAYOUT(sheet));
gnucash_sheet_stop_editing (sheet);
/* resize the sheet */
gnucash_sheet_resize (sheet);
/* fill it up */
height = 0;
block = NULL;
for (i = 0; i < table->num_virt_rows; i++) {
@ -1986,8 +1982,6 @@ gnucash_sheet_table_load (GnucashSheet *sheet)
for (j = 0; j < table->num_virt_cols; j++) {
VirtualCellLocation vcell_loc = { i, j };
gnucash_sheet_block_set_from_table (sheet, vcell_loc);
block = gnucash_sheet_get_block (sheet, vcell_loc);
block->origin_x = width;
@ -1999,6 +1993,38 @@ gnucash_sheet_table_load (GnucashSheet *sheet)
if (i > 0)
height += block->style->dimensions->height;
}
}
void
gnucash_sheet_table_load (GnucashSheet *sheet)
{
Table *table;
gint num_virt_rows;
gint i, j;
g_return_if_fail (sheet != NULL);
g_return_if_fail (GNUCASH_IS_SHEET(sheet));
g_return_if_fail (sheet->table != NULL);
table = sheet->table;
num_virt_rows = table->num_virt_rows;
gtk_layout_freeze (GTK_LAYOUT(sheet));
gnucash_sheet_stop_editing (sheet);
/* resize the sheet */
gnucash_sheet_resize (sheet);
/* fill it up */
for (i = 0; i < table->num_virt_rows; i++)
for (j = 0; j < table->num_virt_cols; j++) {
VirtualCellLocation vcell_loc = { i, j };
gnucash_sheet_block_set_from_table (sheet, vcell_loc);
}
gnucash_sheet_recompute_block_offsets (sheet);
gnucash_sheet_set_scroll_region (sheet);

@ -145,6 +145,8 @@ GtkWidget *gnucash_sheet_new (Table *table);
void gnucash_sheet_table_load (GnucashSheet *sheet);
void gnucash_sheet_recompute_block_offsets (GnucashSheet *sheet);
GtkType gnucash_register_get_type (void);
/* this already has scrollbars attached */
@ -176,8 +178,8 @@ void gnucash_sheet_cursor_set (GnucashSheet *gsheet, VirtualLocation virt_loc);
const char * gnucash_sheet_modify_current_cell(GnucashSheet *sheet,
const gchar *new_text);
void gnucash_sheet_block_set_from_table (GnucashSheet *sheet,
VirtualCellLocation vcell_loc);
gboolean gnucash_sheet_block_set_from_table (GnucashSheet *sheet,
VirtualCellLocation vcell_loc);
void gnucash_sheet_set_scroll_region (GnucashSheet *sheet);

@ -516,14 +516,6 @@ gnucash_sheet_style_recompile(SheetBlockStyle *style, SplitRegister *sr,
g_free(cs->label);
cs->label = g_strdup(label);
cs->active_bg_color =
gnucash_color_argb_to_gdk
(cursor->active_bg_color);
cs->inactive_bg_color =
gnucash_color_argb_to_gdk
(cursor->passive_bg_color);
switch (cb_cell->alignment) {
case CELL_ALIGN_RIGHT:
cs->alignment = GTK_JUSTIFY_RIGHT;
@ -625,8 +617,6 @@ cell_style_construct (gpointer _cs, gpointer user_data)
CellStyle *cs = _cs;
cs->label = NULL;
cs->active_bg_color = NULL;
cs->inactive_bg_color = NULL;
}
static void

@ -63,8 +63,6 @@ typedef struct
{
gchar *label;
GtkJustification alignment;
GdkColor *active_bg_color;
GdkColor *inactive_bg_color;
int border;
} CellStyle;

@ -151,7 +151,8 @@ typedef struct _SplitRegister SplitRegister;
typedef void (*SplitRegisterDestroyCB) (SplitRegister *reg);
struct _SplitRegister {
struct _SplitRegister
{
/* the table itself that implements the underlying GUI. */
Table * table;

@ -272,7 +272,9 @@ gnc_table_get_bg_color_virtual (Table *table, VirtualLocation virt_loc)
bg_color = vcell->cellblock->active_bg_color;
else
{
if (table->alternate_bg_colors)
if (virt_loc.vcell_loc.virt_row == 0)
bg_color = vcell->cellblock->passive_bg_color;
else if (table->alternate_bg_colors)
{
if ((virt_loc.vcell_loc.virt_row % 2) == 1)
bg_color = vcell->cellblock->passive_bg_color;

@ -218,8 +218,13 @@ gnc_table_refresh_cursor_gui (Table * table,
sheet = GNUCASH_SHEET(table->ui_data);
gnucash_sheet_cursor_set_from_table (sheet, do_scroll);
gnucash_sheet_block_set_from_table (sheet, vcell_loc);
gnucash_sheet_redraw_block (sheet, vcell_loc);
if (gnucash_sheet_block_set_from_table (sheet, vcell_loc))
{
gnucash_sheet_recompute_block_offsets (sheet);
gnucash_sheet_redraw_all (sheet);
}
else
gnucash_sheet_redraw_block (sheet, vcell_loc);
}
/* ================== end of file ======================= */

Loading…
Cancel
Save