Commit e9842a3c authored by Michael Meeks's avatar Michael Meeks

Fiddled with patterns,

made range_contains a macro for _big_ speedup,
parent f2c19f5f
......@@ -10,8 +10,8 @@ Plugin system:
Number formatting code:
Chris Lahey
Excel file loading code:
Michael Meeks (michael@imaginator.com)
Excel Import / Export, Styles & other engine bits.
Michael Meeks (mmeeks@gnu.org)
Financial functions code:
Vladimir Vuksan <vuksan@veus.hr>
......@@ -33,3 +33,6 @@ Original CSV code:
Engine & Excel enhancements:
Jody Goldberg <jgoldberg@home.com>
Bug killer par excelence,
Morten Welinder <terra@diku.dk>
No preview for this file type
No preview for this file type
......@@ -244,4 +244,4 @@ Office 2000 and 'explorer' compatibility.
* Have a 'merged cell' structure that can be overridden
* have a 'user-set' feature for 'merge cells'
* Store merges as ( ranges a la. styles ) or GPtrArray's
linked from the leftmost existing cell.
\ No newline at end of file
linked from the leftmost existing cell.
......@@ -416,7 +416,7 @@ search_cell_deps (gpointer key, gpointer value, gpointer closure)
if (!range_contains (range, c->col, c->row))
return;
for (l = deprange->cell_list; l; l = l->next){
for (l = deprange->cell_list; l; l = l->next) {
Cell *cell = l->data;
c->list = g_list_prepend (c->list, cell);
......
......@@ -42,6 +42,7 @@ static GSList *background_radio_list;
static GtkWidget *foreground_cs;
static GtkWidget *background_cs;
static PatternSelector *pattern_selector;
/* Points to the first cell in the selection */
static Cell *first_cell;
......@@ -599,9 +600,9 @@ create_foreground_radio (GtkWidget *prop_win)
}
static GtkWidget *
create_background_radio (GtkWidget *prop_win)
create_background_radio (GtkWidget *prop_win, MStyle *mstyle)
{
GtkWidget *frame, *table, *r1, *r2, *r3, *r4, *p;
GtkWidget *frame, *table, *r1, *r2, *r3, *r4;
int e = GTK_FILL | GTK_EXPAND;
frame = gtk_frame_new (_("Background configuration"));
......@@ -628,7 +629,11 @@ create_background_radio (GtkWidget *prop_win)
make_color_picker_notify (background_cs, prop_win);
/* Create the pattern preview */
p = pattern_selector_new (0);
/* if (mstyle_is_element_set (mstyle, MSTYLE_PATTERN))
pattern_selector = PATTERN_SELECTOR (pattern_selector_new (
mstyle_get_pattern (mstyle)));
else*/
pattern_selector = PATTERN_SELECTOR (pattern_selector_new (0));
gtk_table_attach (GTK_TABLE (table), r1, 0, 1, 0, 1, e, 0, 4, 2);
gtk_table_attach (GTK_TABLE (table), r2, 0, 1, 1, 2, e, 0, 4, 2);
......@@ -636,7 +641,8 @@ create_background_radio (GtkWidget *prop_win)
gtk_table_attach (GTK_TABLE (table), r4, 0, 1, 4, 5, e, 0, 4, 2);
gtk_table_attach (GTK_TABLE (table), background_cs, 1, 2, 1, 2, 0, 0, 4, 2);
gtk_table_attach (GTK_TABLE (table), p, 0, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (pattern_selector), 0, 2, 3, 4,
GTK_FILL | GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
return frame;
}
......@@ -662,7 +668,7 @@ set_color_picker_from_style (GnomeColorPicker *cp, const StyleColor *col)
static GtkWidget *
create_coloring_page (GtkWidget *prop_win,
MStyle *style,
MStyle *mstyle,
GtkWidget **focus_widget)
{
GtkTable *t;
......@@ -672,21 +678,21 @@ create_coloring_page (GtkWidget *prop_win,
t = (GtkTable *) gtk_table_new (0, 0, 0);
fore = create_foreground_radio (prop_win);
back = create_background_radio (prop_win);
back = create_background_radio (prop_win, mstyle);
if (mstyle_is_element_set (style, MSTYLE_COLOR_FORE) &&
!mstyle_is_element_conflict (style, MSTYLE_COLOR_FORE)) {
if (mstyle_is_element_set (mstyle, MSTYLE_COLOR_FORE) &&
!mstyle_is_element_conflict (mstyle, MSTYLE_COLOR_FORE)) {
gtk_radio_button_select (foreground_radio_list, 1);
set_color_picker_from_style (GNOME_COLOR_PICKER (foreground_cs),
mstyle_get_color (style, MSTYLE_COLOR_FORE));
mstyle_get_color (mstyle, MSTYLE_COLOR_FORE));
} else
gtk_radio_button_select (foreground_radio_list, 2);
if (mstyle_is_element_set (style, MSTYLE_COLOR_BACK) &&
!mstyle_is_element_conflict (style, MSTYLE_COLOR_BACK)) {
if (mstyle_is_element_set (mstyle, MSTYLE_COLOR_BACK) &&
!mstyle_is_element_conflict (mstyle, MSTYLE_COLOR_BACK)) {
gtk_radio_button_select (background_radio_list, 1);
set_color_picker_from_style (GNOME_COLOR_PICKER (background_cs),
mstyle_get_color (style, MSTYLE_COLOR_BACK));
mstyle_get_color (mstyle, MSTYLE_COLOR_BACK));
} else
gtk_radio_button_select (background_radio_list, 3);
......@@ -704,7 +710,7 @@ create_coloring_page (GtkWidget *prop_win,
}
static void
apply_coloring_format (Sheet *sheet, MStyle *style)
apply_coloring_format (Sheet *sheet, MStyle *mstyle)
{
double rd, gd, bd, ad;
gushort fore_change = FALSE, back_change = FALSE;
......@@ -719,7 +725,7 @@ apply_coloring_format (Sheet *sheet, MStyle *style)
* case 0 means no foreground
*/
case 0:
mstyle_unset_element (style, MSTYLE_COLOR_FORE);
mstyle_unset_element (mstyle, MSTYLE_COLOR_FORE);
fore_change = FALSE;
break;
/*
......@@ -742,14 +748,13 @@ apply_coloring_format (Sheet *sheet, MStyle *style)
/*
* Now, the background
* FIXME: What is going on with the cell patterns?
*/
switch (gtk_radio_group_get_selected (background_radio_list)) {
/*
* case 0 means no background
*/
case 0:
mstyle_unset_element (style, MSTYLE_COLOR_BACK);
mstyle_unset_element (mstyle, MSTYLE_COLOR_BACK);
back_change = FALSE;
break;
......@@ -773,7 +778,8 @@ apply_coloring_format (Sheet *sheet, MStyle *style)
back_green = 0xffff;
back_blue = 0xffff;
g_warning ("Pattern rendering unimplemented");
if (pattern_selector)
mstyle_set_pattern (mstyle, pattern_selector->selected_item);
back_change = TRUE;
break;
/*
......@@ -785,11 +791,11 @@ apply_coloring_format (Sheet *sheet, MStyle *style)
}
if (fore_change)
mstyle_set_color (style, MSTYLE_COLOR_FORE,
mstyle_set_color (mstyle, MSTYLE_COLOR_FORE,
style_color_new (fore_red, fore_green, fore_blue));
if (back_change)
mstyle_set_color (style, MSTYLE_COLOR_BACK,
mstyle_set_color (mstyle, MSTYLE_COLOR_BACK,
style_color_new (back_red, back_green, back_blue));
}
......
......@@ -416,7 +416,7 @@ search_cell_deps (gpointer key, gpointer value, gpointer closure)
if (!range_contains (range, c->col, c->row))
return;
for (l = deprange->cell_list; l; l = l->next){
for (l = deprange->cell_list; l; l = l->next) {
Cell *cell = l->data;
c->list = g_list_prepend (c->list, cell);
......
......@@ -252,6 +252,24 @@ item_grid_draw_border (GdkDrawable *drawable, MStyle *mstyle,
x+w, y+h, x, y);
}
static void
item_grid_set_gc_stipple (GdkGC *gc, MStyle *mstyle)
{
GdkPixmap *stipple;
int p = mstyle_get_pattern (mstyle) - 1;
/* if (p == 0)*/
return;
stipple = gdk_pixmap_create_from_data (NULL, gnumeric_sheet_patterns
[p].pattern, 8, 8, 1,
&mstyle_get_color (mstyle, MSTYLE_COLOR_FORE)->color,
&mstyle_get_color (mstyle, MSTYLE_COLOR_BACK)->color);
gdk_gc_set_stipple (gc, stipple);
gdk_gc_set_fill (gc, GDK_STIPPLED);
}
/*
* Draw a cell. It gets pixel level coordinates
*
......@@ -286,23 +304,14 @@ item_grid_draw_cell (GdkDrawable *drawable, ItemGrid *item_grid, Cell *cell, int
w = cell->col->pixels;
h = cell->row->pixels;
if (mstyle_is_element_set (mstyle, MSTYLE_PATTERN)) {
#if 0
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (item_grid);
int p = mstyle_get_pattern (mstyle) - 1;
/*
* Next two lines are commented since the pattern display code of the cell
* have not been tested (written?)
*/
gdk_gc_set_stipple (gc, GNUMERIC_SHEET (item->canvas)->patterns [p]);
gdk_gc_set_fill (gc, GDK_STIPPLED);
#endif
/* if (mstyle_is_element_set (mstyle, MSTYLE_PATTERN)) {
item_grid_set_gc_stipple (gc, mstyle);
gdk_draw_rectangle (drawable, gc, TRUE,
x1, y1, w, h);
gdk_gc_set_fill (gc, GDK_SOLID);
gdk_gc_set_stipple (gc, NULL);
}
}*/
/* Draw cell contents BEFORE border */
count = cell_draw (cell, item_grid->sheet_view, gc, drawable, x1, y1);
......@@ -320,19 +329,27 @@ item_grid_paint_empty_cell (GdkDrawable *drawable, ItemGrid *item_grid,
int x, int y)
{
MStyle *mstyle;
GdkGC *gc = item_grid->empty_gc;
mstyle = sheet_style_compute (item_grid->sheet, col, row);
/* if (style->valid_flags & (STYLE_PATTERN | STYLE_FORE_COLOR)) {
FIXME: set the GC here
/* if (mstyle_is_element_set (mstyle, MSTYLE_PATTERN)) {
item_grid_set_gc_stipple (gc, mstyle);
gdk_draw_rectangle (drawable, gc, TRUE,
x + ci->margin_a, y + ri->margin_b,
ci->pixels - ci->margin_b,
ri->pixels - ri->margin_b);
gdk_gc_set_fill (gc, GDK_SOLID);
gdk_gc_set_stipple (gc, NULL);
}*/
if (mstyle_is_element_set (mstyle, MSTYLE_COLOR_BACK) &&
mstyle_get_color (mstyle, MSTYLE_COLOR_BACK)) {
gdk_gc_set_foreground (item_grid->empty_gc,
gdk_gc_set_foreground (gc,
&mstyle_get_color (mstyle, MSTYLE_COLOR_BACK)->color);
gdk_draw_rectangle (
drawable, item_grid->empty_gc, TRUE,
drawable, gc, TRUE,
x + ci->margin_a, y + ri->margin_b,
ci->pixels - ci->margin_b,
ri->pixels - ri->margin_b);
......
......@@ -786,8 +786,8 @@ mstyle_set_pattern (MStyle *st, int pattern)
{
g_return_if_fail (st != NULL);
/* MSTYLE_ELEMENTS (st) [MSTYLE_PATTERN].type = MSTYLE_PATTERN;
MSTYLE_ELEMENTS (st) [MSTYLE_PATTERN].u.pattern = pattern; */
MSTYLE_ELEMENTS (st) [MSTYLE_PATTERN].type = MSTYLE_PATTERN;
MSTYLE_ELEMENTS (st) [MSTYLE_PATTERN].u.pattern = pattern;
}
int
......
......@@ -241,28 +241,6 @@ range_list_foreach_area (Sheet *sheet, GSList *ranges,
}
}
/**
* range_contains:
* @range: range to operate on
* @col: column,
* @row: row co-ordinate
*
* Determine if a range contains a col,row co-ordinate.
*
* Return value: TRUE if co-ordinate contained.
**/
gboolean inline
range_contains (Range const *range, int col, int row)
{
if ((row <= range->end.row) &&
(row >= range->start.row) &&
(col >= range->start.col) &&
(col <= range->end.col))
return TRUE;
return FALSE;
}
/**
* range_adjacent:
* @a: First range
......
......@@ -6,6 +6,25 @@
#include "cell.h"
#include "style.h"
#define range_equal(a,b) (((Range *)(a))->start.row == ((Range *)(b))->start.row && \
((Range *)(a))->end.row == ((Range *)(b))->end.row && \
((Range *)(a))->start.col == ((Range *)(b))->start.col && \
((Range *)(a))->end.col == ((Range *)(b))->end.col)
/**
* range_contains:
* @r: range to operate on
* @x: column,
* @y: row co-ordinate
*
* Determine if a range contains a col,row co-ordinate.
*
* Return value: TRUE if co-ordinate contained.
**/
#define range_contains(r,x,y) (((y) <= ((Range *)(r))->end.row) && \
((y) >= ((Range *)(r))->start.row) && \
((x) >= ((Range *)(r))->start.col) && \
((x) <= ((Range *)(r))->end.col))
gboolean range_parse (Sheet *sheet, const char *range, Value **v);
GSList *range_list_parse (Sheet *sheet, const char *cell_name_str);
void range_list_destroy (GSList *ranges);
......@@ -29,7 +48,6 @@ void ranges_set_style (Sheet *sheet, GSList *ranges,
gboolean range_is_singleton (Range const *r);
gboolean range_overlap (Range const *a, Range const *b);
gboolean range_contains (Range const *range, int col, int row);
gboolean range_adjacent (Range const *a, Range const *b);
Range range_merge (Range const *a, Range const *b);
void range_clip (Range *clipped, Range const *master,
......
......@@ -15,10 +15,6 @@ typedef struct {
typedef struct {
CellPos start, end;
} Range;
#define range_equal(a,b) (((Range *)(a))->start.row == ((Range *)(b))->start.row && \
((Range *)(a))->end.row == ((Range *)(b))->end.row && \
((Range *)(a))->start.col == ((Range *)(b))->start.col && \
((Range *)(a))->end.col == ((Range *)(b))->end.col)
typedef struct {
int dummy;
......
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