Commit 1c9eb792 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Cursors now use timer based scrolling too.

2000-06-09  Jody Goldberg <jgoldberg@home.com>

	* src/item-cursor.c (item_cursor_update) : Change sheet -> sheet-view.
	(item_cursor_set_bounds) : Add a short circuit test and return TRUE
	  if things changed.
	(item_cursor_selection_event) : Take a SheetView.
	(item_cursor_target_region_ok) : sheet -> sheet-view
	(item_cursor_do_action) : Ditto.
	(item_cursor_set_arg) : Ditto.
	(item_cursor_class_init) : Ditto.
	(item_cursor_set_bounds_visibly) : Make the cell visible before
	  changing the bounds.
	(cb_move_cursor) : New function.
	(cb_autofill_scroll) : New function.
	(item_cursor_handle_motion) : New function.
	(item_cursor_drag_event) : Enable timer based scrolling.
	(item_cursor_autofill_event) : Ditto.

	* src/gnumeric-sheet.c (start_cell_selection_at) : item-cursor takes a
	  sheet-view rather than a sheet.
	(gnumeric_sheet_new) : Ditto. Only update if the bounds changed.

	* src/item-edit.c : Take a SheetView rather than a Sheet.

	* src/sheet-view.c (sheet_view_start_sliding) : Return a flag
	  indicating whether or not the timer has been triggered.

	* src/border.c (LineDotPattern) : Fixed const.
parent befddaa1
......@@ -7,17 +7,17 @@ Release Critical
- Selection in the font name combo is partly broken. Manually entering a value
does not change the selected entry.
- Changing an expression name that is in use causes a crash.
- The max row/col canvas scroll size is still hard coded.
- Saving xml should not rely on changing the textdomain to disable translation
of TRUE/FALSE.
Long term breakage
------------------
- The max row/col canvas scroll size is still hard coded.
- Increase/Decrease precision toolbar buttons should look at the displayed
precision for the edit cell and assign the changed value to the entire
selection. Not individually adjusting each non-blank cell's precision.
This would mirror the application of bold/italic/underline
- Moreover, the above buttons ought to work. Try "44", click $, then add
and remove decimals.
......@@ -40,8 +40,6 @@ Long term breakage
- Names : Sheet local vs workbook local vs application global (does that exist ?)
: addresses not changing with row/col ins/del.
- Cursor autoscroll should use the timer mechanism from sheet-view.
- Underline should scale with font size. (Say, min (1, font->descent/4?)
gnome-print has a function we could use for printing which returns the
underline thickness.
......
2000-06-09 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_update) : Change sheet -> sheet-view.
(item_cursor_set_bounds) : Add a short circuit test and return TRUE
if things changed.
(item_cursor_selection_event) : Take a SheetView.
(item_cursor_target_region_ok) : sheet -> sheet-view
(item_cursor_do_action) : Ditto.
(item_cursor_set_arg) : Ditto.
(item_cursor_class_init) : Ditto.
(item_cursor_set_bounds_visibly) : Make the cell visible before
changing the bounds.
(cb_move_cursor) : New function.
(cb_autofill_scroll) : New function.
(item_cursor_handle_motion) : New function.
(item_cursor_drag_event) : Enable timer based scrolling.
(item_cursor_autofill_event) : Ditto.
* src/gnumeric-sheet.c (start_cell_selection_at) : item-cursor takes a
sheet-view rather than a sheet.
(gnumeric_sheet_new) : Ditto. Only update if the bounds changed.
* src/item-edit.c : Take a SheetView rather than a Sheet.
* src/sheet-view.c (sheet_view_start_sliding) : Return a flag
indicating whether or not the timer has been triggered.
* src/border.c (LineDotPattern) : Fixed const.
2000-06-08 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_compute_visible_ranges) :
......
2000-06-09 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_update) : Change sheet -> sheet-view.
(item_cursor_set_bounds) : Add a short circuit test and return TRUE
if things changed.
(item_cursor_selection_event) : Take a SheetView.
(item_cursor_target_region_ok) : sheet -> sheet-view
(item_cursor_do_action) : Ditto.
(item_cursor_set_arg) : Ditto.
(item_cursor_class_init) : Ditto.
(item_cursor_set_bounds_visibly) : Make the cell visible before
changing the bounds.
(cb_move_cursor) : New function.
(cb_autofill_scroll) : New function.
(item_cursor_handle_motion) : New function.
(item_cursor_drag_event) : Enable timer based scrolling.
(item_cursor_autofill_event) : Ditto.
* src/gnumeric-sheet.c (start_cell_selection_at) : item-cursor takes a
sheet-view rather than a sheet.
(gnumeric_sheet_new) : Ditto. Only update if the bounds changed.
* src/item-edit.c : Take a SheetView rather than a Sheet.
* src/sheet-view.c (sheet_view_start_sliding) : Return a flag
indicating whether or not the timer has been triggered.
* src/border.c (LineDotPattern) : Fixed const.
2000-06-08 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_compute_visible_ranges) :
......
2000-06-09 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_update) : Change sheet -> sheet-view.
(item_cursor_set_bounds) : Add a short circuit test and return TRUE
if things changed.
(item_cursor_selection_event) : Take a SheetView.
(item_cursor_target_region_ok) : sheet -> sheet-view
(item_cursor_do_action) : Ditto.
(item_cursor_set_arg) : Ditto.
(item_cursor_class_init) : Ditto.
(item_cursor_set_bounds_visibly) : Make the cell visible before
changing the bounds.
(cb_move_cursor) : New function.
(cb_autofill_scroll) : New function.
(item_cursor_handle_motion) : New function.
(item_cursor_drag_event) : Enable timer based scrolling.
(item_cursor_autofill_event) : Ditto.
* src/gnumeric-sheet.c (start_cell_selection_at) : item-cursor takes a
sheet-view rather than a sheet.
(gnumeric_sheet_new) : Ditto. Only update if the bounds changed.
* src/item-edit.c : Take a SheetView rather than a Sheet.
* src/sheet-view.c (sheet_view_start_sliding) : Return a flag
indicating whether or not the timer has been triggered.
* src/border.c (LineDotPattern) : Fixed const.
2000-06-08 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_compute_visible_ranges) :
......
2000-06-09 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_update) : Change sheet -> sheet-view.
(item_cursor_set_bounds) : Add a short circuit test and return TRUE
if things changed.
(item_cursor_selection_event) : Take a SheetView.
(item_cursor_target_region_ok) : sheet -> sheet-view
(item_cursor_do_action) : Ditto.
(item_cursor_set_arg) : Ditto.
(item_cursor_class_init) : Ditto.
(item_cursor_set_bounds_visibly) : Make the cell visible before
changing the bounds.
(cb_move_cursor) : New function.
(cb_autofill_scroll) : New function.
(item_cursor_handle_motion) : New function.
(item_cursor_drag_event) : Enable timer based scrolling.
(item_cursor_autofill_event) : Ditto.
* src/gnumeric-sheet.c (start_cell_selection_at) : item-cursor takes a
sheet-view rather than a sheet.
(gnumeric_sheet_new) : Ditto. Only update if the bounds changed.
* src/item-edit.c : Take a SheetView rather than a Sheet.
* src/sheet-view.c (sheet_view_start_sliding) : Return a flag
indicating whether or not the timer has been triggered.
* src/border.c (LineDotPattern) : Fixed const.
2000-06-08 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_compute_visible_ranges) :
......
2000-06-09 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_update) : Change sheet -> sheet-view.
(item_cursor_set_bounds) : Add a short circuit test and return TRUE
if things changed.
(item_cursor_selection_event) : Take a SheetView.
(item_cursor_target_region_ok) : sheet -> sheet-view
(item_cursor_do_action) : Ditto.
(item_cursor_set_arg) : Ditto.
(item_cursor_class_init) : Ditto.
(item_cursor_set_bounds_visibly) : Make the cell visible before
changing the bounds.
(cb_move_cursor) : New function.
(cb_autofill_scroll) : New function.
(item_cursor_handle_motion) : New function.
(item_cursor_drag_event) : Enable timer based scrolling.
(item_cursor_autofill_event) : Ditto.
* src/gnumeric-sheet.c (start_cell_selection_at) : item-cursor takes a
sheet-view rather than a sheet.
(gnumeric_sheet_new) : Ditto. Only update if the bounds changed.
* src/item-edit.c : Take a SheetView rather than a Sheet.
* src/sheet-view.c (sheet_view_start_sliding) : Return a flag
indicating whether or not the timer has been triggered.
* src/border.c (LineDotPattern) : Fixed const.
2000-06-08 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_compute_visible_ranges) :
......
2000-06-09 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_update) : Change sheet -> sheet-view.
(item_cursor_set_bounds) : Add a short circuit test and return TRUE
if things changed.
(item_cursor_selection_event) : Take a SheetView.
(item_cursor_target_region_ok) : sheet -> sheet-view
(item_cursor_do_action) : Ditto.
(item_cursor_set_arg) : Ditto.
(item_cursor_class_init) : Ditto.
(item_cursor_set_bounds_visibly) : Make the cell visible before
changing the bounds.
(cb_move_cursor) : New function.
(cb_autofill_scroll) : New function.
(item_cursor_handle_motion) : New function.
(item_cursor_drag_event) : Enable timer based scrolling.
(item_cursor_autofill_event) : Ditto.
* src/gnumeric-sheet.c (start_cell_selection_at) : item-cursor takes a
sheet-view rather than a sheet.
(gnumeric_sheet_new) : Ditto. Only update if the bounds changed.
* src/item-edit.c : Take a SheetView rather than a Sheet.
* src/sheet-view.c (sheet_view_start_sliding) : Return a flag
indicating whether or not the timer has been triggered.
* src/border.c (LineDotPattern) : Fixed const.
2000-06-08 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_compute_visible_ranges) :
......
2000-06-09 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_update) : Change sheet -> sheet-view.
(item_cursor_set_bounds) : Add a short circuit test and return TRUE
if things changed.
(item_cursor_selection_event) : Take a SheetView.
(item_cursor_target_region_ok) : sheet -> sheet-view
(item_cursor_do_action) : Ditto.
(item_cursor_set_arg) : Ditto.
(item_cursor_class_init) : Ditto.
(item_cursor_set_bounds_visibly) : Make the cell visible before
changing the bounds.
(cb_move_cursor) : New function.
(cb_autofill_scroll) : New function.
(item_cursor_handle_motion) : New function.
(item_cursor_drag_event) : Enable timer based scrolling.
(item_cursor_autofill_event) : Ditto.
* src/gnumeric-sheet.c (start_cell_selection_at) : item-cursor takes a
sheet-view rather than a sheet.
(gnumeric_sheet_new) : Ditto. Only update if the bounds changed.
* src/item-edit.c : Take a SheetView rather than a Sheet.
* src/sheet-view.c (sheet_view_start_sliding) : Return a flag
indicating whether or not the timer has been triggered.
* src/border.c (LineDotPattern) : Fixed const.
2000-06-08 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-sheet.c (gnumeric_sheet_compute_visible_ranges) :
......
......@@ -11,8 +11,8 @@
#include "color.h"
struct LineDotPattern {
gint const elements;
const unsigned char * const pattern;
gint const elements;
unsigned char * const pattern;
double * const pattern_d;
};
......
......@@ -283,7 +283,7 @@ start_cell_selection_at (GnumericSheet *gsheet, int col, int row)
gsheet->sel_cursor = ITEM_CURSOR (gnome_canvas_item_new (
group,
item_cursor_get_type (),
"Sheet", sheet,
"SheetView", gsheet->sheet_view,
"Grid", gsheet->item_grid,
"Style", ITEM_CURSOR_ANTED, NULL));
item_cursor_set_spin_base (gsheet->sel_cursor, col, row);
......@@ -949,7 +949,7 @@ gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
/* The cursor */
item = gnome_canvas_item_new (gsheet_group,
item_cursor_get_type (),
"ItemCursor::Sheet", sheet,
"ItemCursor::SheetView", sheet_view,
"ItemCursor::Grid", gsheet->item_grid,
NULL);
gsheet->item_cursor = ITEM_CURSOR (item);
......
......@@ -283,7 +283,7 @@ start_cell_selection_at (GnumericSheet *gsheet, int col, int row)
gsheet->sel_cursor = ITEM_CURSOR (gnome_canvas_item_new (
group,
item_cursor_get_type (),
"Sheet", sheet,
"SheetView", gsheet->sheet_view,
"Grid", gsheet->item_grid,
"Style", ITEM_CURSOR_ANTED, NULL));
item_cursor_set_spin_base (gsheet->sel_cursor, col, row);
......@@ -949,7 +949,7 @@ gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
/* The cursor */
item = gnome_canvas_item_new (gsheet_group,
item_cursor_get_type (),
"ItemCursor::Sheet", sheet,
"ItemCursor::SheetView", sheet_view,
"ItemCursor::Grid", gsheet->item_grid,
NULL);
gsheet->item_cursor = ITEM_CURSOR (item);
......
......@@ -32,7 +32,7 @@ static GnomeCanvasItem *item_cursor_parent_class;
/* The argument we take */
enum {
ARG_0,
ARG_SHEET, /* The Sheet * argument */
ARG_SHEETVIEW, /* The SheetView * argument */
ARG_ITEM_GRID, /* The ItemGrid * argument */
ARG_STYLE, /* The style type */
ARG_COLOR, /* The optional color */
......@@ -146,7 +146,7 @@ item_cursor_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, in
{
ItemCursor *item_cursor = ITEM_CURSOR (item);
GnumericSheet *gsheet = GNUMERIC_SHEET (item->canvas);
Sheet *sheet = item_cursor->sheet;
Sheet *sheet = item_cursor->sheet_view->sheet;
int x, y, w, h, extra;
......@@ -430,21 +430,25 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in
}
}
void
gboolean
item_cursor_set_bounds (ItemCursor *item_cursor, int start_col, int start_row, int end_col, int end_row)
{
GnomeCanvasItem *item;
g_return_if_fail (start_col <= end_col);
g_return_if_fail (start_row <= end_row);
g_return_if_fail (start_col >= 0);
g_return_if_fail (end_col >= 0);
g_return_if_fail (end_col < SHEET_MAX_COLS);
g_return_if_fail (end_row < SHEET_MAX_ROWS);
g_return_if_fail (IS_ITEM_CURSOR (item_cursor));
/* Redraw the old area */
item = GNOME_CANVAS_ITEM (item_cursor);
g_return_val_if_fail (start_col <= end_col, FALSE);
g_return_val_if_fail (start_row <= end_row, FALSE);
g_return_val_if_fail (start_col >= 0, FALSE);
g_return_val_if_fail (start_row >= 0, FALSE);
g_return_val_if_fail (end_col < SHEET_MAX_COLS, FALSE);
g_return_val_if_fail (end_row < SHEET_MAX_ROWS, FALSE);
g_return_val_if_fail (IS_ITEM_CURSOR (item_cursor), FALSE);
/* Nothing changed */
if (item_cursor->pos.start.col == start_col &&
item_cursor->pos.end.col == end_col &&
item_cursor->pos.start.row == start_row &&
item_cursor->pos.end.row == end_row)
return FALSE;
/* Move to the new area */
item_cursor->pos.start.col = start_col;
......@@ -453,7 +457,10 @@ item_cursor_set_bounds (ItemCursor *item_cursor, int start_col, int start_row, i
item_cursor->pos.end.row = end_row;
/* Request an update */
item = GNOME_CANVAS_ITEM (item_cursor);
gnome_canvas_item_request_update (item);
return TRUE;
}
/**
......@@ -578,7 +585,7 @@ item_cursor_selection_event (GnomeCanvasItem *item, GdkEvent *event)
new_item = gnome_canvas_item_new (
group,
item_cursor_get_type (),
"ItemCursor::Sheet", ic->sheet,
"ItemCursor::SheetView", ic->sheet_view,
"ItemCursor::Grid", ic->item_grid,
"ItemCursor::Style", style,
NULL);
......@@ -625,12 +632,11 @@ item_cursor_selection_event (GnomeCanvasItem *item, GdkEvent *event)
ITEM_CURSOR (new_item)->row_delta = d_row;
}
item_cursor_set_bounds (
ITEM_CURSOR (new_item),
ic->pos.start.col, ic->pos.start.row,
ic->pos.end.col, ic->pos.end.row);
if (item_cursor_set_bounds (ITEM_CURSOR (new_item),
ic->pos.start.col, ic->pos.start.row,
ic->pos.end.col, ic->pos.end.row))
gnome_canvas_update_now (canvas);
gnome_canvas_update_now (canvas);
gnome_canvas_item_grab (
new_item,
GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
......@@ -654,7 +660,7 @@ item_cursor_target_region_ok (ItemCursor *item_cursor)
int v;
v = sheet_is_region_empty_or_selected (
item_cursor->sheet,
item_cursor->sheet_view->sheet,
item_cursor->pos.start.col, item_cursor->pos.start.row,
item_cursor->pos.end.col, item_cursor->pos.end.row);
......@@ -670,7 +676,7 @@ item_cursor_target_region_ok (ItemCursor *item_cursor)
GNOME_STOCK_BUTTON_NO,
NULL);
window = gtk_widget_get_toplevel (GTK_WIDGET (canvas));
v = gnumeric_dialog_run (item_cursor->sheet->workbook, GNOME_DIALOG (message));
v = gnumeric_dialog_run (item_cursor->sheet_view->sheet->workbook, GNOME_DIALOG (message));
if (v == 0)
return TRUE;
......@@ -692,7 +698,7 @@ typedef enum {
static void
item_cursor_do_action (ItemCursor *item_cursor, ActionType action, guint32 time)
{
Sheet *sheet = item_cursor->sheet;
Sheet *sheet = item_cursor->sheet_view->sheet;
Workbook *wb = sheet->workbook;
PasteTarget pt;
......@@ -788,11 +794,16 @@ item_cursor_set_bounds_visibly (ItemCursor *item_cursor,
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (item_cursor);
GnumericSheet *gsheet = GNUMERIC_SHEET (item->canvas);
item_cursor_set_bounds (item_cursor, start_col, start_row, end_col, end_row);
gnumeric_sheet_make_cell_visible (gsheet,
visible_col, visible_row, FALSE);
gnome_canvas_update_now (GNOME_CANVAS (gsheet));
/*
* FIXME FIXME FIXME
* Ideally we would update the bounds BEFORE we scroll,
* this would decrease the flicker. Unfortunately, our optimization
* of clipping the cursor to the currently visible region is getting in the way.
* We are forced to make the region visible before we move the cursor.
*/
gnumeric_sheet_make_cell_visible (gsheet, visible_col, visible_row, FALSE);
if (item_cursor_set_bounds (item_cursor, start_col, start_row, end_col, end_row))
gnome_canvas_update_now (GNOME_CANVAS (gsheet));
}
void
......@@ -852,18 +863,92 @@ item_cursor_tip_setlabel (ItemCursor *item_cursor)
}
#endif
static gboolean
cb_move_cursor (SheetView *sheet_view, int col, int row, gpointer user_data)
{
ItemCursor *item_cursor = user_data;
int const w = (item_cursor->pos.end.col - item_cursor->pos.start.col);
int const h = (item_cursor->pos.end.row - item_cursor->pos.start.row);
int corner_left = col - item_cursor->col_delta;
int corner_top = row - item_cursor->row_delta;
if (corner_left < 0)
corner_left = 0;
else if (corner_left >= (SHEET_MAX_COLS - w))
corner_left = SHEET_MAX_COLS - w;
if (corner_top < 0)
corner_top = 0;
else if (corner_top >= (SHEET_MAX_ROWS - h))
corner_top = SHEET_MAX_ROWS - h;
#if 0
/*
* Leave this disabled until GtkLayout correctly handles
* Windows with SaveUnder set. (Speak to quartic for details).
*/
item_cursor_tip_setlabel (item_cursor);
#endif
/* Make target cell visible, and adjust the cursor size */
item_cursor_set_bounds_visibly (item_cursor, col, row,
corner_left, corner_top,
corner_left + w, corner_top + h);
return FALSE;
}
static void
item_cursor_handle_motion (ItemCursor *item_cursor, GdkEvent *event,
SheetViewSlideHandler slide_handler)
{
GnomeCanvas *canvas = GNOME_CANVAS_ITEM (item_cursor)->canvas;
GnumericSheet *gsheet = GNUMERIC_SHEET (canvas);
int x, y;
int left, top;
int width, height;
int col, row;
gnome_canvas_w2c (canvas, event->button.x, event->button.y, &x, &y);
gnome_canvas_get_scroll_offsets (canvas, &left, &top);
width = GTK_WIDGET (canvas)->allocation.width;
height = GTK_WIDGET (canvas)->allocation.height;
col = gnumeric_sheet_find_col (gsheet, x, NULL);
row = gnumeric_sheet_find_row (gsheet, y, NULL);
if (x < left || y < top || x >= left + width || y >= top + height) {
int dx = 0, dy = 0;
if (x < left)
dx = x - left;
else if (x >= left + width)
dx = x - width - left;
if (y < top)
dy = y - top;
else if (y >= top + height)
dy = y - height - top;
if (sheet_view_start_sliding (item_cursor->sheet_view,
slide_handler, item_cursor,
col, row, dx, dy))
return;
}
sheet_view_stop_sliding (item_cursor->sheet_view);
(*slide_handler) (item_cursor->sheet_view, col, row, item_cursor);
}
static gint
item_cursor_drag_event (GnomeCanvasItem *item, GdkEvent *event)
{
GnomeCanvas *canvas = GNOME_CANVAS_ITEM (item)->canvas;
GnumericSheet *gsheet = GNUMERIC_SHEET (canvas);
ItemCursor *item_cursor = ITEM_CURSOR (item);
int x, y, w, h;
int col, row;
int corner_left, corner_top;
switch (event->type){
case GDK_BUTTON_RELEASE:
sheet_view_stop_sliding (item_cursor->sheet_view);
gnome_canvas_item_ungrab (item, event->button.time);
item_cursor_do_drop (item_cursor, (GdkEventButton *) event);
......@@ -882,38 +967,7 @@ item_cursor_drag_event (GnomeCanvasItem *item, GdkEvent *event)
return TRUE;
case GDK_MOTION_NOTIFY:
gnome_canvas_w2c (canvas, event->button.x, event->button.y, &x, &y);
if (x < 0)
x = 0;
if (y < 0)
y = 0;
col = gnumeric_sheet_find_col (gsheet, x, NULL);
corner_left = col - item_cursor->col_delta;
row = gnumeric_sheet_find_row (gsheet, y, NULL);
corner_top = row - item_cursor->row_delta;
w = (item_cursor->pos.end.col - item_cursor->pos.start.col);
h = (item_cursor->pos.end.row - item_cursor->pos.start.row);
if (corner_left < 0 || corner_left + w >= SHEET_MAX_COLS)
return TRUE;
if (corner_top < 0 || corner_top + h >= SHEET_MAX_ROWS)
return TRUE;
item_cursor_set_bounds_visibly (item_cursor, col, row,
corner_left,
corner_top,
corner_left + w,
corner_top + h);
#if 0
/*
* Leave this disabled until GtkLayout correctly handles
* Windows with SaveUnder set. (Speak to quartic for details).
*/
item_cursor_tip_setlabel (item_cursor);
#endif
item_cursor_handle_motion (item_cursor, event, &cb_move_cursor);
return TRUE;
default:
......@@ -921,18 +975,47 @@ item_cursor_drag_event (GnomeCanvasItem *item, GdkEvent *event)
}
}
static gboolean
cb_autofill_scroll (SheetView *sheet_view, int col, int row, gpointer user_data)
{
ItemCursor *item_cursor = user_data;
int bottom = item_cursor->base_row + item_cursor->base_rows;
int right = item_cursor->base_col + item_cursor->base_cols;
/* Autofill by row or by col, NOT both. */
if ((right - col) > (bottom - row)){
/* FIXME : We do not support inverted auto-fill */
if (bottom < row)
bottom = row;
} else {
/* FIXME : We do not support inverted auto-fill */
if (right < col)
right = col;
}
/* Do not auto scroll past the start */
if (row < item_cursor->base_row)
row = item_cursor->base_row;
if (col < item_cursor->base_col)
col = item_cursor->base_col;
item_cursor_set_bounds_visibly (item_cursor, col, row,
item_cursor->base_col,
item_cursor->base_row,
right, bottom);
return FALSE;
}
static gint
item_cursor_autofill_event (GnomeCanvasItem *item, GdkEvent *event)
{
GnomeCanvas *canvas = item->canvas;
GnumericSheet *gsheet = GNUMERIC_SHEET (canvas);
ItemCursor *item_cursor = ITEM_CURSOR (item);
int col, row, x, y;
switch (event->type){
case GDK_BUTTON_RELEASE: {
Sheet *sheet = item_cursor->sheet;
Sheet *sheet = item_cursor->sheet_view->sheet;
sheet_view_stop_sliding (item_cursor->sheet_view);
/*
* We flush after the ungrab, to have the ungrab take
......@@ -955,40 +1038,7 @@ item_cursor_autofill_event (GnomeCanvasItem *item, GdkEvent *event)
}
case GDK_MOTION_NOTIFY:
gnome_canvas_w2c (canvas, event->button.x, event->button.y, &x, &y);
if (x < 0)
x = 0;
if (y < 0)
y = 0;
col = gnumeric_sheet_find_col (gsheet, x, NULL);
row = gnumeric_sheet_find_row (gsheet, y, NULL);
/* Autofill by row or by col, NOT both. */
if ((item_cursor->base_x - x) > (item_cursor->base_y - y)){
/* FIXME : We do not support inverted auto-fill */
int bound = item_cursor->base_row + item_cursor->base_rows;
if (row > bound)
bound = row;
item_cursor_set_bounds_visibly (
item_cursor, col, row,
item_cursor->base_col, item_cursor->base_row,
item_cursor->base_col + item_cursor->base_cols,
bound);
} else {
/* FIXME : We do not support inverted auto-fill */
int bound = item_cursor->base_col + item_cursor->base_cols;
if (col > bound)
bound = col;
item_cursor_set_bounds_visibly (
item_cursor, col, row,
item_cursor->base_col, item_cursor->base_row,
bound,
item_cursor->base_row + item_cursor->base_rows);
}
item_cursor_handle_motion (item_cursor, event, &cb_autofill_scroll);
return TRUE;
default:
......@@ -1054,8 +1104,8 @@ item_cursor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
item_cursor = ITEM_CURSOR (o);
switch (arg_id){
case ARG_SHEET:
item_cursor->sheet = GTK_VALUE_POINTER (*arg);
case ARG_SHEETVIEW:
item_cursor->sheet_view = GTK_VALUE_POINTER (*arg);
break;
case ARG_ITEM_GRID:
item_cursor->item_grid = GTK_VALUE_POINTER (*arg);
......@@ -1091,8 +1141,8 @@ item_cursor_class_init (ItemCursorClass *item_cursor_class)
object_class = (GtkObjectClass *) item_cursor_class;
item_class = (GnomeCanvasItemClass *) item_cursor_class;
gtk_object_add_arg_type ("ItemCursor::Sheet", GTK_TYPE_POINTER,
GTK_ARG_WRITABLE, ARG_SHEET);
gtk_object_add_arg_type ("ItemCursor::SheetView", GTK_TYPE_POINTER,
GTK_ARG_WRITABLE, ARG_SHEETVIEW);
gtk_object_add_arg_type ("ItemCursor::Grid", GTK_TYPE_POINTER,
GTK_ARG_WRITABLE, ARG_ITEM_GRID);
gtk_object_add_arg_type ("ItemCursor::Style", GTK_TYPE_INT,
......
......@@ -20,7 +20,7 @@ typedef enum {
typedef struct {
GnomeCanvasItem canvas_item;
Sheet *sheet;
SheetView *sheet_view;
ItemGrid *item_grid; /* A copy of our "parent" grid */
Range pos;
......@@ -67,7 +67,7 @@ typedef struct {
GnomeCanvasItemClass parent_class;
} ItemCursorClass;
void item_cursor_set_bounds (ItemCursor *item_cursor,
gboolean item_cursor_set_bounds (ItemCursor *item_cursor,
int start_col, int start_row,
int end_col, int end_row);
......
......@@ -92,14 +92,14 @@ point_is_inside_range (ItemEdit *item_edit, const char *text, Range *range)
scan = cursor_pos;
scan_at (text, &scan);
if ((v = range_parse (item_edit->sheet, &text [scan], FALSE)) != NULL)
if ((v = range_parse (item_edit->sheet_view->sheet, &text [scan], FALSE)) != NULL)
return setup_range_from_value (range, v);
if (scan == cursor_pos && scan > 0)
scan--;
scan_at (text, &scan);
if ((v = range_parse (item_edit->sheet, &text [scan], FALSE)) != NULL)
if ((v = range_parse (item_edit->sheet_view->sheet, &text [scan], FALSE)) != NULL)
return setup_range_from_value (range, v);
return FALSE;
......@@ -114,7 +114,7 @@ entry_create_feedback_range (ItemEdit *item_edit, Range *range)
item_edit->feedback_cursor = gnome_canvas_item_new (
GNOME_CANVAS_GROUP (item->canvas->root),
item_cursor_get_type (),
"Sheet", item_edit->sheet,
"SheetView", item_edit->sheet_view,
"Grid", item_edit->item_grid,
"Style", ITEM_CURSOR_BLOCK,
"Color", "red",
......@@ -184,7 +184,7 @@ item_edit_draw_text (ItemEdit *item_edit, GdkDrawable *drawable, GtkStyle *style
}
if (text_length > 0){
if (workbook_auto_completing (item_edit->sheet->workbook)){