Commit e18beddb authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Some border improvements.

- Use DASH_ON_OFF to correctly handle borders for cells with a background
  colour.

- Prefer Top/Left vs Bottom/Right.  This works around problems with borders
  for cells with backgrounds..  BUT does not solve it for importing.  That
  will require the next generation border code that has yet to be designed.

- A crappy implementation of double borders.  Does NOT handle cells with
  backgrounds, or the myriad intersection cases.

- Improve handling of undo and redraw for borders.

2000-02-21  Jody Goldberg <jgoldberg@home.com>

	* src/sheet.c (sheet_cursor_set) : Be religous about handing edit_pos
	  changes.

	* src/commands.c (cmd_format) : save for formats for a range 1 cell
	  thick around the selection so that borders are handled.

	* src/sheet-view.c (sheet_view_redraw_cell_region) : Redraw a border
	  around the selected region to handle thick borders */

	* src/sheet-object.c (sheet_object_canvas_event) : Ignore mouse wheel
	  events.

	* src/border.c (style_border_set_gc_dash) : Use GDK_LINE_ON_OFF_DASH
	  so that background colours show through.

	* src/sheet-style.c (sheet_range_set_border) : Prefer top vs bottom
	  and left vs right.  This will simplify drawing eventually.
parent 39d5acca
2000-02-21 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_cursor_set) : Be religous about handing edit_pos
changes.
* src/commands.c (cmd_format) : save for formats for a range 1 cell
thick around the selection so that borders are handled.
* src/sheet-view.c (sheet_view_redraw_cell_region) : Redraw a border
around the selected region to handle thick borders */
* src/sheet-object.c (sheet_object_canvas_event) : Ignore mouse wheel
events.
* src/border.c (style_border_set_gc_dash) : Use GDK_LINE_ON_OFF_DASH
so that background colours show through.
* src/sheet-style.c (sheet_range_set_border) : Prefer top vs bottom
and left vs right. This will simplify drawing eventually.
2000-02-21 Almer. S. Tigelaar. <almer1@dds.nl>
* src/dialogs/dialog-stf-csv-page.c :
......@@ -53,6 +73,11 @@
* src/print.c (sheet_print): Use gnumeric_dialog_run.
2000-02-20 Jody Goldberg <jgoldberg@home.com>
* src/border.c (style_border_draw) : It ain't perfect, but it is
better than nothing.
2000-02-20 Jody Goldberg <jgoldberg@home.com>
* src/dialogs/dialog-cell-format.c (cb_back_preview_color) : Hard code
......
2000-02-21 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_cursor_set) : Be religous about handing edit_pos
changes.
* src/commands.c (cmd_format) : save for formats for a range 1 cell
thick around the selection so that borders are handled.
* src/sheet-view.c (sheet_view_redraw_cell_region) : Redraw a border
around the selected region to handle thick borders */
* src/sheet-object.c (sheet_object_canvas_event) : Ignore mouse wheel
events.
* src/border.c (style_border_set_gc_dash) : Use GDK_LINE_ON_OFF_DASH
so that background colours show through.
* src/sheet-style.c (sheet_range_set_border) : Prefer top vs bottom
and left vs right. This will simplify drawing eventually.
2000-02-21 Almer. S. Tigelaar. <almer1@dds.nl>
* src/dialogs/dialog-stf-csv-page.c :
......@@ -53,6 +73,11 @@
* src/print.c (sheet_print): Use gnumeric_dialog_run.
2000-02-20 Jody Goldberg <jgoldberg@home.com>
* src/border.c (style_border_draw) : It ain't perfect, but it is
better than nothing.
2000-02-20 Jody Goldberg <jgoldberg@home.com>
* src/dialogs/dialog-cell-format.c (cb_back_preview_color) : Hard code
......
......@@ -177,7 +177,7 @@ style_border_set_gc_dash (GdkGC *gc, StyleBorderType const line_type)
i = line_type - 1;
if (style_border_data[i].pattern != NULL)
style = GDK_LINE_DOUBLE_DASH;
style = GDK_LINE_ON_OFF_DASH;
/* FIXME FIXME FIXME :
* We will want to Adjust the join styles eventually to get
......@@ -253,11 +253,20 @@ void
style_border_draw (GdkDrawable * drawable, const MStyleBorder* border,
int x1, int y1, int x2, int y2)
{
if (border != NULL && border->line_type != STYLE_BORDER_NONE)
gdk_draw_line (drawable,
style_border_get_gc ((MStyleBorder *)border,
drawable),
x1, y1, x2, y2);
if (border != NULL && border->line_type != STYLE_BORDER_NONE) {
GdkGC *gc = style_border_get_gc ((MStyleBorder *)border,
drawable);
gdk_draw_line (drawable, gc, x1, y1, x2, y2);
if (border->line_type == STYLE_BORDER_DOUBLE) {
static GdkGC *middle_gc = NULL;
if (middle_gc == NULL) {
middle_gc = gdk_gc_new (drawable);
gdk_gc_set_foreground (middle_gc, &gs_white);
}
gdk_draw_line (drawable, middle_gc, x1, y1, x2, y2);
}
}
}
StyleBorderOrientation
......
......@@ -36,9 +36,6 @@
*
* 3) Implement the guts of the support functions.
*
* For formatting. I'd like a range clipped list of a subset of style
* elements corresponding to those being overridden.
*
* That way undo redo just become applications of the old or the new styles.
*
* Design thoughts :
......@@ -936,12 +933,18 @@ cmd_format (CommandContext *context, Sheet *sheet,
me->old_styles = NULL;
for (l = me->selection; l; l = l->next) {
CmdFormatOldStyle *os;
Range *range = l->data;
Range range = *((Range const *)l->data);
/* Store the containing range to handle borders */
if (range.start.col > 0) range.start.col--;
if (range.start.row > 0) range.start.row--;
if (range.end.col < SHEET_MAX_COLS-1) range.end.col++;
if (range.end.row < SHEET_MAX_ROWS-1) range.end.row++;
os = g_new (CmdFormatOldStyle, 1);
os->styles = sheet_get_styles_in_range (sheet, range);
os->pos = range->start;
os->styles = sheet_get_styles_in_range (sheet, &range);
os->pos = range.start;
me->old_styles = g_slist_append (me->old_styles, os);
}
......
......@@ -27,6 +27,8 @@
#include "cell-draw.h"
#include "commands.h"
#undef PAINT_DEBUG
static GnomeCanvasItemClass *item_grid_parent_class;
/* The arguments we take */
......@@ -370,7 +372,7 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int
/* 2. the grids */
if (sheet->show_grid) {
#if 0
#if PAINT_DEBUG
fprintf (stderr, "paint : %s%d:", col_name(paint_col), paint_row+1);
#endif
col = paint_col;
......@@ -394,7 +396,7 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int
gdk_draw_line (drawable, grid_gc, 0, y_paint, width, y_paint);
}
}
#if 0
#if PAINT_DEBUG
fprintf (stderr, "%s%d\n", col_name(col-1), row);
#endif
}
......
......@@ -98,14 +98,22 @@ sheet_view_redraw_cell_region (SheetView *sheet_view, int start_col, int start_r
x = sheet_col_get_distance_pixels (sheet, gsheet->col.first, min_col);
y = sheet_row_get_distance_pixels (sheet, gsheet->row.first, first_row);
w = sheet_col_get_distance_pixels (sheet, min_col, max_col+1) + 1;
h = sheet_row_get_distance_pixels (sheet, first_row, last_row+1) + 1;
w = sheet_col_get_distance_pixels (sheet, min_col, max_col+1);
h = sheet_row_get_distance_pixels (sheet, first_row, last_row+1);
x += canvas->layout.xoffset - canvas->zoom_xofs;
y += canvas->layout.yoffset - canvas->zoom_yofs;
#if 0
fprintf (stderr, "%s%d:", col_name(min_col), first_row+1);
fprintf (stderr, "%s%d\n", col_name(max_col), last_row+1);
#endif
/* redraw a border of 1 pixel around the region to handle thick borders
* NOTE the 2nd coordinates are excluded so add 1 extra (+1border +1include) */
gnome_canvas_request_redraw (GNOME_CANVAS (gsheet),
x, y,
x+w, y+h);
x-1, y-1,
x+w+1+1, y+h+1+1);
}
void
......
......@@ -1052,7 +1052,6 @@ sheet_object_canvas_event (GnomeCanvasItem *item, GdkEvent *event, SheetObject *
event_total_y = 0;
break;
case 3:
default:
{
GtkMenu *menu;
......@@ -1062,6 +1061,9 @@ sheet_object_canvas_event (GnomeCanvasItem *item, GdkEvent *event, SheetObject *
gnumeric_popup_menu (menu, (GdkEventButton *)event);
break;
}
default:
/* Ignore mouse wheel events */
return FALSE;
}
break;
}
......
......@@ -486,7 +486,6 @@ sheet_style_attach (Sheet *sheet, Range range,
}
sheet_style_cache_flush (sheet);
/* FIXME: Need to clip range against view port */
sheet_redraw_range (sheet, &range);
}
......@@ -1038,7 +1037,7 @@ do_apply_border (Sheet *sheet, const Range *r,
{
MStyle *mstyle;
if (borders && borders [idx]) {
if (borders [idx]) {
style_border_ref (borders [idx]);
mstyle = mstyle_new ();
......@@ -1082,32 +1081,42 @@ sheet_range_set_border (Sheet *sheet,
Range r;
MStyle *mstyle;
/* 1.1 The top inner */
r = *range;
r.end.row = r.start.row;
do_apply_border (sheet, &r,
MSTYLE_BORDER_TOP,
STYLE_BORDER_TOP, borders);
/* 1.2 The top outer */
if (borders == NULL)
return;
if (borders [STYLE_BORDER_TOP]) {
/* 1.1 The top inner */
r = *range;
r.end.row = r.start.row;
do_apply_border (sheet, &r,
MSTYLE_BORDER_TOP,
STYLE_BORDER_TOP, borders);
/* 1.2 The top outer */
r.start.row--;
r.end.row = r.start.row;
if (r.start.row >= 0)
do_blank_border (sheet, &r, MSTYLE_BORDER_BOTTOM);
}
/* 2.1 The bottom inner */
r = *range;
r.start.row = r.end.row;
do_apply_border (sheet, &r,
MSTYLE_BORDER_BOTTOM,
STYLE_BORDER_BOTTOM, borders);
/* 2.2 The bottom outer */
/* 2 We prefer to paint Top of the row below */
if (borders [STYLE_BORDER_BOTTOM]) {
r.start.row++;
r.end.row = r.start.row;
if (r.start.row < SHEET_MAX_ROWS)
do_blank_border (sheet, &r, MSTYLE_BORDER_TOP);
r = *range;
r.start.row = r.end.row;
if (r.start.row < SHEET_MAX_ROWS-1) {
/* 2.1 The bottom outer */
do_blank_border (sheet, &r, MSTYLE_BORDER_BOTTOM);
/* 2.1 The bottom inner */
++r.end.row;
r.start.row = r.end.row;
do_apply_border (sheet, &r,
MSTYLE_BORDER_TOP,
STYLE_BORDER_BOTTOM, borders);
} else
do_apply_border (sheet, &r,
MSTYLE_BORDER_BOTTOM,
STYLE_BORDER_BOTTOM, borders);
}
/* 3.1 The left inner */
......@@ -1125,19 +1134,25 @@ sheet_range_set_border (Sheet *sheet,
}
/* 4.1 The right inner */
r = *range;
r.start.col = r.end.col;
do_apply_border (sheet, &r,
MSTYLE_BORDER_RIGHT,
STYLE_BORDER_RIGHT, borders);
/* 4.2 The right outer */
/* 4 We prefer to paint left of the col to the right */
if (borders [STYLE_BORDER_RIGHT]) {
r.start.col++;
r.end.col = r.start.col;
if (r.start.col < SHEET_MAX_COLS)
do_blank_border (sheet, &r, MSTYLE_BORDER_LEFT);
}
r = *range;
r.start.col = r.end.col;
if (r.start.col < SHEET_MAX_COLS-1) {
/* 2.1 The bottom outer */
do_blank_border (sheet, &r, MSTYLE_BORDER_RIGHT);
/* 2.1 The bottom inner */
++r.end.col;
r.start.col = r.end.col;
do_apply_border (sheet, &r,
MSTYLE_BORDER_LEFT,
STYLE_BORDER_RIGHT, borders);
} else
do_apply_border (sheet, &r,
MSTYLE_BORDER_RIGHT,
STYLE_BORDER_RIGHT, borders);
}
/* 5.1 The horizontal interior top */
r = *range;
......
......@@ -98,14 +98,22 @@ sheet_view_redraw_cell_region (SheetView *sheet_view, int start_col, int start_r
x = sheet_col_get_distance_pixels (sheet, gsheet->col.first, min_col);
y = sheet_row_get_distance_pixels (sheet, gsheet->row.first, first_row);
w = sheet_col_get_distance_pixels (sheet, min_col, max_col+1) + 1;
h = sheet_row_get_distance_pixels (sheet, first_row, last_row+1) + 1;
w = sheet_col_get_distance_pixels (sheet, min_col, max_col+1);
h = sheet_row_get_distance_pixels (sheet, first_row, last_row+1);
x += canvas->layout.xoffset - canvas->zoom_xofs;
y += canvas->layout.yoffset - canvas->zoom_yofs;
#if 0
fprintf (stderr, "%s%d:", col_name(min_col), first_row+1);
fprintf (stderr, "%s%d\n", col_name(max_col), last_row+1);
#endif
/* redraw a border of 1 pixel around the region to handle thick borders
* NOTE the 2nd coordinates are excluded so add 1 extra (+1border +1include) */
gnome_canvas_request_redraw (GNOME_CANVAS (gsheet),
x, y,
x+w, y+h);
x-1, y-1,
x+w+1+1, y+h+1+1);
}
void
......
......@@ -2111,14 +2111,18 @@ sheet_cursor_set (Sheet *sheet,
sheet_accept_pending_input (sheet);
/* Redraw the old edit cell */
sheet_redraw_cell_region (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);
if (sheet->cursor.edit_pos.col != edit_col ||
sheet->cursor.edit_pos.row != edit_row) {
sheet_redraw_cell_region (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);
sheet->cursor.edit_pos.col = edit_col;
sheet->cursor.edit_pos.row = edit_row;
sheet_load_cell_val (sheet);
}
sheet->cursor.edit_pos.col = edit_col;
sheet->cursor.edit_pos.row = edit_row;
sheet->cursor.base_corner.col = base_col;
sheet->cursor.base_corner.row = base_row;
sheet->cursor.move_corner.col = move_col;
......@@ -2133,7 +2137,6 @@ sheet_cursor_set (Sheet *sheet,
MAX (base_col, move_col),
MAX (base_row, move_row));
}
sheet_load_cell_val (sheet);
}
/**
......
......@@ -177,7 +177,7 @@ style_border_set_gc_dash (GdkGC *gc, StyleBorderType const line_type)
i = line_type - 1;
if (style_border_data[i].pattern != NULL)
style = GDK_LINE_DOUBLE_DASH;
style = GDK_LINE_ON_OFF_DASH;
/* FIXME FIXME FIXME :
* We will want to Adjust the join styles eventually to get
......@@ -253,11 +253,20 @@ void
style_border_draw (GdkDrawable * drawable, const MStyleBorder* border,
int x1, int y1, int x2, int y2)
{
if (border != NULL && border->line_type != STYLE_BORDER_NONE)
gdk_draw_line (drawable,
style_border_get_gc ((MStyleBorder *)border,
drawable),
x1, y1, x2, y2);
if (border != NULL && border->line_type != STYLE_BORDER_NONE) {
GdkGC *gc = style_border_get_gc ((MStyleBorder *)border,
drawable);
gdk_draw_line (drawable, gc, x1, y1, x2, y2);
if (border->line_type == STYLE_BORDER_DOUBLE) {
static GdkGC *middle_gc = NULL;
if (middle_gc == NULL) {
middle_gc = gdk_gc_new (drawable);
gdk_gc_set_foreground (middle_gc, &gs_white);
}
gdk_draw_line (drawable, middle_gc, x1, y1, x2, y2);
}
}
}
StyleBorderOrientation
......
......@@ -67,8 +67,9 @@ static void
gnumeric_dashed_canvas_line_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
int x, int y, int width, int height)
{
GnumericDashedCanvasLine *line = GNUMERIC_DASHED_CANVAS_LINE (item);
style_border_set_gc_dash (GNOME_CANVAS_LINE (item)->gc,
GNUMERIC_DASHED_CANVAS_LINE (item)->dash_style_index);
line->dash_style_index);
gnumeric_dashed_canvas_line_class->
real_draw (item, drawable, x, y, width, height);
}
......
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