GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit 91dc6f19 authored by Jon K Hellan's avatar Jon K Hellan Committed by Jon Kåre Hellan

Support per sheet grid color. Needed for correct XL import.

2002-02-11  Jon K Hellan  <hellan@acm.org>

	Support per sheet grid color. Needed for correct XL import.

	* src/style-color.[ch] (color_equal): Rename to style_color_equal
	and export.

	* src/style-border.[ch] (style_border_none_set_color): New
	function. Update the grid color (color of style border none) to
	the given color.

	* src/sheet-style.[ch] (sheet_style_update_grid_color): New
	function. Update the grid color to fit the given sheet.

	* src/item-grid.c (item_grid_draw): Call
	sheet_style_update_grid_color before rendering.

	* src/print-cell.c (print_cell_range): Ditto

	* src/preview-grid.c (preview_grid_draw): Call
	style_border_none_update_color before rendering.
parent e5f4e519
2002-02-11 Jon K Hellan <hellan@acm.org>
Support per sheet grid color. Needed for correct XL import.
* src/style-color.[ch] (color_equal): Rename to style_color_equal
and export.
* src/style-border.[ch] (style_border_none_set_color): New
function. Update the grid color (color of style border none) to
the given color.
* src/sheet-style.[ch] (sheet_style_update_grid_color): New
function. Update the grid color to fit the given sheet.
* src/item-grid.c (item_grid_draw): Call
sheet_style_update_grid_color before rendering.
* src/print-cell.c (print_cell_range): Ditto
* src/preview-grid.c (preview_grid_draw): Call
style_border_none_update_color before rendering.
2002-02-11 Jody Goldberg <jody@gnome.org>
* src/item-bar.c (item_bar_realize) : Use the standard cursor.
......
2002-02-11 Jon K Hellan <hellan@acm.org>
Support per sheet grid color. Needed for correct XL import.
* src/style-color.[ch] (color_equal): Rename to style_color_equal
and export.
* src/style-border.[ch] (style_border_none_set_color): New
function. Update the grid color (color of style border none) to
the given color.
* src/sheet-style.[ch] (sheet_style_update_grid_color): New
function. Update the grid color to fit the given sheet.
* src/item-grid.c (item_grid_draw): Call
sheet_style_update_grid_color before rendering.
* src/print-cell.c (print_cell_range): Ditto
* src/preview-grid.c (preview_grid_draw): Call
style_border_none_update_color before rendering.
2002-02-11 Jody Goldberg <jody@gnome.org>
* src/item-bar.c (item_bar_realize) : Use the standard cursor.
......
2002-02-11 Jon K Hellan <hellan@acm.org>
Support per sheet grid color. Needed for correct XL import.
* src/style-color.[ch] (color_equal): Rename to style_color_equal
and export.
* src/style-border.[ch] (style_border_none_set_color): New
function. Update the grid color (color of style border none) to
the given color.
* src/sheet-style.[ch] (sheet_style_update_grid_color): New
function. Update the grid color to fit the given sheet.
* src/item-grid.c (item_grid_draw): Call
sheet_style_update_grid_color before rendering.
* src/print-cell.c (print_cell_range): Ditto
* src/preview-grid.c (preview_grid_draw): Call
style_border_none_update_color before rendering.
2002-02-11 Jody Goldberg <jody@gnome.org>
* src/item-bar.c (item_bar_realize) : Use the standard cursor.
......
......@@ -328,6 +328,8 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
end_row < ig->bound.start.row || start_row > ig->bound.end.row)
return;
sheet_style_update_grid_color (sheet);
/* Fill entire region with default background (even past far edge) */
gdk_draw_rectangle (drawable, ig->gc.fill, TRUE,
draw_x, draw_y, width, height);
......
......@@ -477,6 +477,8 @@ preview_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
int *colwidths = NULL;
style_border_none_set_color (style_color_grid ());
/* Fill entire region with default background (even past far edge) */
gdk_draw_rectangle (drawable, pg->gc.fill, TRUE,
draw_x, draw_y, width, height);
......
......@@ -742,6 +742,8 @@ print_cell_range (GnomePrintContext *context,
break;
}
sheet_style_update_grid_color (sheet);
/* Get ordered list of merged regions */
merged_active = merged_active_seen = merged_used = NULL;
merged_unused = sheet_merge_get_overlap (sheet,
......
......@@ -424,7 +424,7 @@ sheet_style_init (Sheet *sheet)
g_hash_table_new (mstyle_hash, (GCompareFunc) mstyle_equal);
sheet->style_data->auto_pattern_color = g_new (StyleColor, 1);
memcpy (sheet->style_data->auto_pattern_color,
style_color_auto_pattern(), sizeof (StyleColor));
style_color_auto_pattern (), sizeof (StyleColor));
sheet->style_data->auto_pattern_color->ref_count = 1;
sheet->style_data->default_style =
sheet_style_find (sheet, mstyle_new_default ());
......@@ -515,6 +515,34 @@ sheet_style_get_auto_pattern_color (Sheet const *sheet)
return sc;
}
/**
* This function updates the color of style_border_none when the sheet to be
* rendered is known. style_border_none tells how to render the
* grid. Because the grid color may be different for different sheets, the
* functions which render the grid call this function first. The rule for
* selecting the grid color, which is the same as in Excel, is: - if the
* auto pattern color is default (which is black), the grid color is gray,
* as returned by style_color_grid (). - otherwise, the auto pattern color
* is used for the grid.
*/
void
sheet_style_update_grid_color (Sheet const *sheet)
{
StyleColor *default_auto = style_color_auto_pattern ();
StyleColor *sheet_auto = sheet_style_get_auto_pattern_color (sheet);
StyleColor *new_color;
new_color = (style_color_equal (default_auto, sheet_auto)
? style_color_grid ()
: sheet_auto);
/* Do nothing if we already have the right color */
if (style_border_none()->color != new_color)
style_border_none_set_color (new_color);
style_color_unref (sheet_auto);
style_color_unref (default_auto);
}
/****************************************************************************/
static MStyle *
......
......@@ -47,6 +47,7 @@ void sheet_style_shutdown (Sheet *sheet);
void sheet_style_set_auto_pattern_color (Sheet *sheet,
StyleColor *grid_color);
StyleColor *sheet_style_get_auto_pattern_color (Sheet const *sheet);
void sheet_style_update_grid_color (Sheet const *sheet);
MStyle const *style_list_get_style (StyleList const *l, CellPos const *pos);
void style_list_free (StyleList *l);
......
......@@ -157,6 +157,31 @@ style_border_none (void)
return none;
}
/**
* This function updates the color of style_border_none when the wanted grid
* color is known. style_border_none tells how to render the grid. Because
* the grid color may be different for different sheets, the functions which
* render the grid call this function first. The rule for selecting the
* grid color, which is the same as in Excel, is: - if the auto pattern
* color is default (which is black), the grid color is gray, as returned by
* style_color_grid (). - otherwise, the auto pattern color is used for the
* grid.
*/
void
style_border_none_set_color (StyleColor *color)
{
StyleBorder *none = style_border_none ();
StyleColor *nc;
if (color == none->color)
return;
nc = none->color;
none->color = color;
gdk_gc_set_foreground (none->gc, &none->color->color);
style_color_unref (nc);
}
/**
* style_border_fetch :
*
......
......@@ -65,6 +65,8 @@ StyleBorder *style_border_ref (StyleBorder *border);
#define style_border_is_blank(b) ((b) == NULL || (b)->line_type == STYLE_BORDER_NONE)
StyleBorder *style_border_none (void);
void style_border_none_set_color (StyleColor *color);
StyleBorder *style_border_fetch (StyleBorderType const line_type,
StyleColor *color,
StyleBorderOrientation orientation);
......
......@@ -196,12 +196,9 @@ style_color_unref (StyleColor *sc)
g_free (sc);
}
static gint
color_equal (gconstpointer v, gconstpointer v2)
gint
style_color_equal (const StyleColor *k1, const StyleColor *k2)
{
const StyleColor *k1 = (const StyleColor *) v;
const StyleColor *k2 = (const StyleColor *) v2;
if (k1->red == k2->red &&
k1->green == k2->green &&
k1->blue == k2->blue &&
......@@ -236,7 +233,8 @@ gnumeric_color_init (void)
e_color_alloc_name (NULL, "red", &gs_red);
e_color_alloc_name (NULL, "lavender",&gs_lavender);
style_color_hash = g_hash_table_new (color_hash, color_equal);
style_color_hash = g_hash_table_new (color_hash,
(GEqualFunc) style_color_equal);
color_inited = TRUE;
}
......
......@@ -26,6 +26,7 @@ StyleColor *style_color_auto_back (void);
StyleColor *style_color_auto_pattern (void);
StyleColor *style_color_ref (StyleColor *sc);
void style_color_unref (StyleColor *sc);
gint style_color_equal (const StyleColor *k1, const StyleColor *k2);
StyleColor *style_color_black (void);
StyleColor *style_color_white (void);
StyleColor *style_color_grid (void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment