Commit 534405d6 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

s/scg_stop_range_selection/scg_rangesel_stop/


2001-05-08  Jody Goldberg <jgoldberg@home.com>

	s/scg_stop_range_selection/scg_rangesel_stop/

	s/scg_set_cursor_bounds/scg_cursor_bound/
	s/scg_cursor_vertical_extend/scg_cursor_extend_v/
	s/scg_cursor_horizontal_extend/scg_cursor_extend_h/
	s/scg_cursor_vertical_move/scg_cursor_move_v/
	s/scg_cursor_horizontal_move/scg_cursor_move_h/
	s/scg_cursor_vertical_extend/scg_rangesel_extend_v/
	s/scg_cursor_horizontal_extend/scg_rangesel_extend_h/
	s/scg_cursor_vertical_move/scg_rangesel_move_v/
	s/scg_cursor_horizontal_move/scg_rangesel_move_h/

	* src/sheet-control-gui.[ch] : Move the rangesel info from
	  gnumeric-sheet into here in preparation for panes.
	(scg_rangesel_extend_v) : merge content from
	  gnumeric-sheet equivalent.
	(scg_rangesel_extend_h) : ditto.
	(scg_rangesel_move_v) : ditto.
	(scg_rangesel_move_h) : ditto.
	(scg_rangesel_start) : ditto.
	(scg_rangesel_stop) : ditto.
	(start_range_selection) : moved from gnumeric-sheet.
	(scg_rangesel_possible) : renamed from
	    gnumeric_sheet_can_select_expr_range.
	(scg_rangesel_changed) : renamed from scg_range_selection_changed
	  and make this the point that rationalizes the cursor points.
	(scg_cursor_bound) : renamed from scg_set_cursor_bounds
	  and make this the point that raionalizes the cursor points.
	(scg_ant) : changes to item_cursor_set_bounds.
	(scg_colrow_select) : rangesel support is now in scg.
	(scg_select_all) : ditto.

	* src/workbook-edit.c : cleanup includes.

	* src/item-grid.c (item_grid_event) : rangesel support is now in scg.
	(item_grid_button_1) : ditto.

	* src/item-cursor.h : privatize the structure and class.

	* src/item-cursor.c (cb_autofill_scroll) : changes to
	  item_cursor_set_bounds_visibly signature.
	(cb_move_cursor) : ditto.
	(item_cursor_set_bounds_visibly) : changes to item_cursor_set_bounds
	  signature.
	(item_cursor_selection_event) : ditto.
	(item_cursor_set_bounds) : simplify.

	* src/item-bar.c (is_pointer_on_division) : rangesel support is now in scg.

	* src/gnumeric-sheet.[ch] : move the rangesel logic up into scg.

2001-05-08  Jody Goldberg <jgoldberg@home.com>

	From Juan Pablo Mendoza <pablo_juan@yahoo.com>
	* src/sheet.c: (sheet_clone_colrow_info): Clone col and row
	  default size.
parent c4f2b99a
...@@ -8,6 +8,8 @@ release, and longer term bugs. ...@@ -8,6 +8,8 @@ release, and longer term bugs.
Release Critical Release Critical
---------------- ----------------
- col/row resize when zoomed
- Performance regression: navigating and (say) selecting an area in, - Performance regression: navigating and (say) selecting an area in,
for example, statfuns.xls takes an embarrassingly long time. for example, statfuns.xls takes an embarrassingly long time.
......
...@@ -24,11 +24,16 @@ Jody: ...@@ -24,11 +24,16 @@ Jody:
* Support fractions. * Support fractions.
* Fix printing of borders. * Fix printing of borders.
* Improve checking for array/merged region division. * Improve checking for array/merged region division.
* Prep for frozen panes.
Jon Kåre: Jon Kåre:
* New architecture for selecting cell ranges into dialogs. * New architecture for selecting cell ranges into dialogs.
* Fix dialog placement. * Fix dialog placement.
Juan Pablo Mendoza:
* Improve col and row sizing when cloning a cell.
* Catch many bugs with merged regions.
Morten: Morten:
* Changed a large number of dirty diapers. * Changed a large number of dirty diapers.
* Plugged gnumeric leaks too. * Plugged gnumeric leaks too.
......
2001-05-08 Jody Goldberg <jgoldberg@home.com>
* python.c (string_from_exception) : suppress warning.
2001-03-17 Jody Goldberg <jgoldberg@home.com> 2001-03-17 Jody Goldberg <jgoldberg@home.com>
* Release 0.64 * Release 0.64
......
...@@ -76,7 +76,7 @@ string_from_exception () ...@@ -76,7 +76,7 @@ string_from_exception ()
if (!svalue) if (!svalue)
goto cleanup; goto cleanup;
if (pos + 3 < sizeof buf) if (pos + 3 < (int)sizeof(buf))
snprintf (buf + pos , sizeof buf - pos , ": %s", snprintf (buf + pos , sizeof buf - pos , ": %s",
PyString_AsString (svalue)); PyString_AsString (svalue));
} }
......
2001-05-08 Jody Goldberg <jgoldberg@home.com>
* dialog-advanced-filter.c : cleanup includes.
2001-05-06 Morten Welinder <terra@diku.dk> 2001-05-06 Morten Welinder <terra@diku.dk>
* dialog-cell-sort.c (order_box_get_text, string_pos_in_list): * dialog-cell-sort.c (order_box_get_text, string_pos_in_list):
......
...@@ -10,15 +10,11 @@ ...@@ -10,15 +10,11 @@
#include <gnome.h> #include <gnome.h>
#include <glade/glade.h> #include <glade/glade.h>
#include "gnumeric.h" #include "gnumeric.h"
#include "gnumeric-util.h" #include "sheet.h"
#include "func-util.h"
#include "gnumeric-sheet.h"
#include "dialogs.h"
#include "workbook.h"
#include "workbook-control.h"
#include "func.h"
#include "cell.h" #include "cell.h"
#include "ranges.h" #include "ranges.h"
#include "func-util.h"
#include "gnumeric-util.h"
#include "analysis-tools.h" #include "analysis-tools.h"
#define OK 0 #define OK 0
......
This diff is collapsed.
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#define GNUMERIC_SHEET_FACTOR_X 1000000 #define GNUMERIC_SHEET_FACTOR_X 1000000
#define GNUMERIC_SHEET_FACTOR_Y 2000000 #define GNUMERIC_SHEET_FACTOR_Y 2000000
/* FIXME : standardize names (gnm_canvas_ ?) */
struct _GnumericSheet { struct _GnumericSheet {
GnomeCanvas canvas; GnomeCanvas canvas;
...@@ -21,67 +22,34 @@ struct _GnumericSheet { ...@@ -21,67 +22,34 @@ struct _GnumericSheet {
} row, col, row_offset, col_offset; } row, col, row_offset, col_offset;
ItemGrid *item_grid; ItemGrid *item_grid;
ItemCursor *item_cursor;
ItemEdit *item_editor; ItemEdit *item_editor;
ItemCursor *item_cursor;
/* ItemCursor *sel_cursor;
* This flag keeps track of a cell selector
* (ie, when the user uses the cursor keys
* to select a cell for an expression).
*/
gboolean selecting_cell;
int sel_cursor_pos;
int sel_text_len;
ItemCursor *sel_cursor;
/* Input context for dead key support */ /* Input context for dead key support */
GdkIC *ic; GdkIC *ic;
GdkICAttr *ic_attr; GdkICAttr *ic_attr;
}; };
GtkType gnumeric_sheet_get_type (void); GtkType gnumeric_sheet_get_type (void);
GtkWidget *gnumeric_sheet_new (SheetControlGUI *sheet);
GtkWidget *gnumeric_sheet_new (SheetControlGUI *sheet);
void gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_first_row); void gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_first_row);
void gnumeric_sheet_set_left_col (GnumericSheet *gsheet, int new_first_col); void gnumeric_sheet_set_left_col (GnumericSheet *gsheet, int new_first_col);
gboolean gnumeric_sheet_can_select_expr_range (GnumericSheet *gsheet); int gnumeric_sheet_find_col (GnumericSheet *gsheet, int x, int *col_origin);
void gnumeric_sheet_set_cursor_bounds (GnumericSheet *gsheet, int gnumeric_sheet_find_row (GnumericSheet *gsheet, int y, int *row_origin);
int start_col, int start_row,
int end_col, int end_row); void gnumeric_sheet_create_editor (GnumericSheet *gsheet);
void gsheet_compute_visible_region (GnumericSheet *gsheet, void gnumeric_sheet_stop_editing (GnumericSheet *gsheet);
gboolean const full_recompute); void gnumeric_sheet_cursor_bound (GnumericSheet *gsheet, Range const *r);
void gnumeric_sheet_make_cell_visible (GnumericSheet *gsheet, void gnumeric_sheet_rangesel_bound (GnumericSheet *gsheet, Range const *r);
int col, int row, void gnumeric_sheet_rangesel_start (GnumericSheet *gsheet, int col, int row);
gboolean const force_scroll); void gnumeric_sheet_rangesel_stop (GnumericSheet *gsheet);
void gnumeric_sheet_create_editor (GnumericSheet *gsheet);
void gnumeric_sheet_stop_editing (GnumericSheet *gsheet); void gsheet_compute_visible_region (GnumericSheet *gsheet,
gboolean const full_recompute);
/* Managing the selection of cell ranges when editing a formula */ void gnumeric_sheet_make_cell_visible (GnumericSheet *gsheet,
int col, int row,
void gnumeric_sheet_start_range_selection (GnumericSheet *gsheet, gboolean const force_scroll);
int col, int row);
void gnumeric_sheet_stop_range_selection (GnumericSheet *gsheet);
void gnumeric_sheet_rangesel_cursor_bounds (GnumericSheet *gsheet,
int base_col, int base_row,
int move_col, int move_row);
void gnumeric_sheet_rangesel_cursor_extend (GnumericSheet *gsheet,
int col, int row);
void gnumeric_sheet_rangesel_horizontal_move (
GnumericSheet *gsheet, int dir, gboolean jump_to_boundaries);
void gnumeric_sheet_rangesel_vertical_move (
GnumericSheet *gsheet, int dir, gboolean jump_to_boundaries);
void gnumeric_sheet_rangesel_horizontal_extend (
GnumericSheet *gsheet, int n, gboolean jump_to_boundaries);
void gnumeric_sheet_rangesel_vertical_extend (
GnumericSheet *gsheet, int n, gboolean jump_to_boundaries);
int gnumeric_sheet_find_col (GnumericSheet *item_grid,
int x, int *col_origin);
int gnumeric_sheet_find_row (GnumericSheet *item_grid,
int y, int *row_origin);
typedef struct {
GnomeCanvasClass parent_class;
} GnumericSheetClass;
#endif /* GNUMERIC_GNUMERIC_SHEET_H */ #endif /* GNUMERIC_GNUMERIC_SHEET_H */
This diff is collapsed.
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#define GNUMERIC_SHEET_FACTOR_X 1000000 #define GNUMERIC_SHEET_FACTOR_X 1000000
#define GNUMERIC_SHEET_FACTOR_Y 2000000 #define GNUMERIC_SHEET_FACTOR_Y 2000000
/* FIXME : standardize names (gnm_canvas_ ?) */
struct _GnumericSheet { struct _GnumericSheet {
GnomeCanvas canvas; GnomeCanvas canvas;
...@@ -21,67 +22,34 @@ struct _GnumericSheet { ...@@ -21,67 +22,34 @@ struct _GnumericSheet {
} row, col, row_offset, col_offset; } row, col, row_offset, col_offset;
ItemGrid *item_grid; ItemGrid *item_grid;
ItemCursor *item_cursor;
ItemEdit *item_editor; ItemEdit *item_editor;
ItemCursor *item_cursor;
/* ItemCursor *sel_cursor;
* This flag keeps track of a cell selector
* (ie, when the user uses the cursor keys
* to select a cell for an expression).
*/
gboolean selecting_cell;
int sel_cursor_pos;
int sel_text_len;
ItemCursor *sel_cursor;
/* Input context for dead key support */ /* Input context for dead key support */
GdkIC *ic; GdkIC *ic;
GdkICAttr *ic_attr; GdkICAttr *ic_attr;
}; };
GtkType gnumeric_sheet_get_type (void); GtkType gnumeric_sheet_get_type (void);
GtkWidget *gnumeric_sheet_new (SheetControlGUI *sheet);
GtkWidget *gnumeric_sheet_new (SheetControlGUI *sheet);
void gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_first_row); void gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_first_row);
void gnumeric_sheet_set_left_col (GnumericSheet *gsheet, int new_first_col); void gnumeric_sheet_set_left_col (GnumericSheet *gsheet, int new_first_col);
gboolean gnumeric_sheet_can_select_expr_range (GnumericSheet *gsheet); int gnumeric_sheet_find_col (GnumericSheet *gsheet, int x, int *col_origin);
void gnumeric_sheet_set_cursor_bounds (GnumericSheet *gsheet, int gnumeric_sheet_find_row (GnumericSheet *gsheet, int y, int *row_origin);
int start_col, int start_row,
int end_col, int end_row); void gnumeric_sheet_create_editor (GnumericSheet *gsheet);
void gsheet_compute_visible_region (GnumericSheet *gsheet, void gnumeric_sheet_stop_editing (GnumericSheet *gsheet);
gboolean const full_recompute); void gnumeric_sheet_cursor_bound (GnumericSheet *gsheet, Range const *r);
void gnumeric_sheet_make_cell_visible (GnumericSheet *gsheet, void gnumeric_sheet_rangesel_bound (GnumericSheet *gsheet, Range const *r);
int col, int row, void gnumeric_sheet_rangesel_start (GnumericSheet *gsheet, int col, int row);
gboolean const force_scroll); void gnumeric_sheet_rangesel_stop (GnumericSheet *gsheet);
void gnumeric_sheet_create_editor (GnumericSheet *gsheet);
void gnumeric_sheet_stop_editing (GnumericSheet *gsheet); void gsheet_compute_visible_region (GnumericSheet *gsheet,
gboolean const full_recompute);
/* Managing the selection of cell ranges when editing a formula */ void gnumeric_sheet_make_cell_visible (GnumericSheet *gsheet,
int col, int row,
void gnumeric_sheet_start_range_selection (GnumericSheet *gsheet, gboolean const force_scroll);
int col, int row);
void gnumeric_sheet_stop_range_selection (GnumericSheet *gsheet);
void gnumeric_sheet_rangesel_cursor_bounds (GnumericSheet *gsheet,
int base_col, int base_row,
int move_col, int move_row);
void gnumeric_sheet_rangesel_cursor_extend (GnumericSheet *gsheet,
int col, int row);
void gnumeric_sheet_rangesel_horizontal_move (
GnumericSheet *gsheet, int dir, gboolean jump_to_boundaries);
void gnumeric_sheet_rangesel_vertical_move (
GnumericSheet *gsheet, int dir, gboolean jump_to_boundaries);
void gnumeric_sheet_rangesel_horizontal_extend (
GnumericSheet *gsheet, int n, gboolean jump_to_boundaries);
void gnumeric_sheet_rangesel_vertical_extend (
GnumericSheet *gsheet, int n, gboolean jump_to_boundaries);
int gnumeric_sheet_find_col (GnumericSheet *item_grid,
int x, int *col_origin);
int gnumeric_sheet_find_row (GnumericSheet *item_grid,
int y, int *row_origin);
typedef struct {
GnomeCanvasClass parent_class;
} GnumericSheetClass;
#endif /* GNUMERIC_GNUMERIC_SHEET_H */ #endif /* GNUMERIC_GNUMERIC_SHEET_H */
...@@ -529,7 +529,6 @@ item_bar_translate (GnomeCanvasItem *item, double dx, double dy) ...@@ -529,7 +529,6 @@ item_bar_translate (GnomeCanvasItem *item, double dx, double dy)
static ColRowInfo * static ColRowInfo *
is_pointer_on_division (ItemBar const *item_bar, int pos, int *the_total, int *the_element) is_pointer_on_division (ItemBar const *item_bar, int pos, int *the_total, int *the_element)
{ {
GnumericSheet * const gsheet = GNUMERIC_SHEET (item_bar->scg->canvas);
Sheet *sheet = item_bar->scg->sheet; Sheet *sheet = item_bar->scg->sheet;
ColRowInfo *cri; ColRowInfo *cri;
int i, total = 0; int i, total = 0;
...@@ -555,11 +554,11 @@ is_pointer_on_division (ItemBar const *item_bar, int pos, int *the_total, int *t ...@@ -555,11 +554,11 @@ is_pointer_on_division (ItemBar const *item_bar, int pos, int *the_total, int *t
total += cri->size_pixels; total += cri->size_pixels;
/* TODO : This is more expensive than it needs to be. /* TODO : This is more expensive than it needs to be.
* We should really set a flag (in gsheet ?) and adjust * We should really set a flag (in scg ?) and adjust
* it as the cursor in the entry is moved. The current * it as the cursor in the entry is moved. The current
* approach recalculates the state every time. * approach recalculates the state every time.
*/ */
if (!gnumeric_sheet_can_select_expr_range (gsheet) && if (!scg_rangesel_possible (item_bar->scg) &&
(total - 4 < pos) && (pos < total + 4)) { (total - 4 < pos) && (pos < total + 4)) {
if (the_total) if (the_total)
*the_total = total; *the_total = total;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "ranges.h" #include "ranges.h"
#include <gal/widgets/e-cursors.h> #include <gal/widgets/e-cursors.h>
static GnomeCanvasItem *item_cursor_parent_class; #define ITEM_CURSOR_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), item_cursor_get_type (), ItemCursorClass))
#define AUTO_HANDLE_SPACE 4 #define AUTO_HANDLE_SPACE 4
#define CLIP_SAFETY_MARGIN (AUTO_HANDLE_SPACE + 5) #define CLIP_SAFETY_MARGIN (AUTO_HANDLE_SPACE + 5)
...@@ -34,7 +34,48 @@ static GnomeCanvasItem *item_cursor_parent_class; ...@@ -34,7 +34,48 @@ static GnomeCanvasItem *item_cursor_parent_class;
((item->auto_fill_handle_at_top && ((y) < (item)->canvas_item.y1 + 6)) || \ ((item->auto_fill_handle_at_top && ((y) < (item)->canvas_item.y1 + 6)) || \
((y) > (item)->canvas_item.y2 - 6))) ((y) > (item)->canvas_item.y2 - 6)))
/* The argument we take */ struct _ItemCursor {
GnomeCanvasItem canvas_item;
SheetControlGUI *scg;
Range pos;
/* Offset of dragging cell from top left of pos */
int col_delta, row_delta;
/* Tip for movement */
GtkWidget *tip;
ItemCursorStyle style;
GdkGC *gc;
int state;
int animation_timer;
/*
* For the autofill mode:
* Where the action started (base_x, base_y) and the
* width and heigth of the selection when the autofill
* started.
*/
CellPos base;
int base_x, base_y;
int base_cols, base_rows;
/* Cached values of the last bounding box information used */
int cached_x, cached_y, cached_w, cached_h;
int visible:1;
int use_color:1;
/* Location of auto fill handle */
int auto_fill_handle_at_top:1;
int drag_button;
GdkPixmap *stipple;
GdkColor color;
};
static GnomeCanvasItem *item_cursor_parent_class;
enum { enum {
ARG_0, ARG_0,
ARG_SHEET_CONTROL_GUI, /* The SheetControlGUI * argument */ ARG_SHEET_CONTROL_GUI, /* The SheetControlGUI * argument */
...@@ -437,46 +478,15 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in ...@@ -437,46 +478,15 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in
} }
gboolean gboolean
item_cursor_set_bounds (ItemCursor *ic, item_cursor_set_bounds (ItemCursor *ic, Range const *new_bound)
int base_col, int base_row,
int move_col, int move_row)
{ {
Range r;
g_return_val_if_fail (IS_ITEM_CURSOR (ic), FALSE); g_return_val_if_fail (IS_ITEM_CURSOR (ic), FALSE);
g_return_val_if_fail (range_is_sane (new_bound), FALSE);
/* Nothing changed */ if (range_equal (&ic->pos, new_bound))
if (ic->base_corner.col == base_col &&
ic->base_corner.row == base_row &&
ic->move_corner.col == move_col &&
ic->move_corner.row == move_row)
return FALSE; return FALSE;
if (base_col <= move_col) { ic->pos = *new_bound;
r.start.col = base_col;
r.end.col = move_col;
} else {
r.end.col = base_col;
r.start.col = move_col;
}
if (base_row <= move_row) {
r.start.row = base_row;
r.end.row = move_row;
} else {
r.end.row = base_row;
r.start.row = move_row;
}
g_return_val_if_fail (r.start.col >= 0, FALSE);
g_return_val_if_fail (r.start.row >= 0, FALSE);
g_return_val_if_fail (r.end.col < SHEET_MAX_COLS, FALSE);
g_return_val_if_fail (r.end.row < SHEET_MAX_ROWS, FALSE);
ic->pos = r;
ic->base_corner.col = base_col;
ic->base_corner.row = base_row;
ic->move_corner.col = move_col;
ic->move_corner.row = move_row;
gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (ic)); gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (ic));
...@@ -652,9 +662,7 @@ item_cursor_selection_event (GnomeCanvasItem *item, GdkEvent *event) ...@@ -652,9 +662,7 @@ item_cursor_selection_event (GnomeCanvasItem *item, GdkEvent *event)
ITEM_CURSOR (new_item)->row_delta = d_row; ITEM_CURSOR (new_item)->row_delta = d_row;
} }
if (item_cursor_set_bounds (ITEM_CURSOR (new_item), if (item_cursor_set_bounds (ITEM_CURSOR (new_item), &ic->pos))
ic->base_corner.col, ic->base_corner.row,
ic->move_corner.col, ic->move_corner.row))
gnome_canvas_update_now (canvas); gnome_canvas_update_now (canvas);
gnome_canvas_item_grab ( gnome_canvas_item_grab (
...@@ -966,11 +974,12 @@ item_cursor_do_drop (ItemCursor *ic, GdkEventButton *event) ...@@ -966,11 +974,12 @@ item_cursor_do_drop (ItemCursor *ic, GdkEventButton *event)
static void static void
item_cursor_set_bounds_visibly (ItemCursor *item_cursor, item_cursor_set_bounds_visibly (ItemCursor *item_cursor,
int visible_col,int visible_row, int visible_col,int visible_row,
int start_col, int start_row, CellPos const *corner,
int end_col, int end_row) int end_col, int end_row)
{ {
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (item_cursor); GnomeCanvasItem *item = GNOME_CANVAS_ITEM (item_cursor);
GnumericSheet *gsheet = GNUMERIC_SHEET (item->canvas); GnumericSheet *gsheet = GNUMERIC_SHEET (item->canvas);
Range r;
/* /*
* FIXME FIXME FIXME * FIXME FIXME FIXME
...@@ -980,7 +989,8 @@ item_cursor_set_bounds_visibly (ItemCursor *item_cursor, ...@@ -980,7 +989,8 @@ item_cursor_set_bounds_visibly (ItemCursor *item_cursor,
* We are forced to make the region visible before we move the cursor. * We are forced to make the region visible before we move the cursor.
*/ */
gnumeric_sheet_make_cell_visible (gsheet, visible_col, visible_row, FALSE); 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)) range_init (&r, corner->col, corner->row, end_col, end_row);
if (item_cursor_set_bounds (item_cursor, &r))
gnome_canvas_update_now (GNOME_CANVAS (gsheet)); gnome_canvas_update_now (GNOME_CANVAS (gsheet));
} }
...@@ -1038,18 +1048,19 @@ cb_move_cursor (SheetControlGUI *scg, int col, int row, gpointer user_data) ...@@ -1038,18 +1048,19 @@ cb_move_cursor (SheetControlGUI *scg, int col, int row, gpointer user_data)
ItemCursor *item_cursor = user_data; ItemCursor *item_cursor = user_data;
int const w = (item_cursor->pos.end.col - item_cursor->pos.start.col); 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 const h = (item_cursor->pos.end.row - item_cursor->pos.start.row);
int corner_left = col - item_cursor->col_delta; CellPos corner;
int corner_top = row - item_cursor->row_delta;
corner.col = col - item_cursor->col_delta;
if (corner_left < 0) if (corner.col < 0)
corner_left = 0; corner.col = 0;
else if (corner_left >= (SHEET_MAX_COLS - w)) else if (corner.col >= (SHEET_MAX_COLS - w))
corner_left = SHEET_MAX_COLS - w - 1; corner.col = SHEET_MAX_COLS - w - 1;
if (corner_top < 0) corner.row = row - item_cursor->row_delta;
corner_top = 0; if (corner.row < 0)
else if (corner_top >= (SHEET_MAX_ROWS - h)) corner.row = 0;
corner_top = SHEET_MAX_ROWS - h - 1; else if (corner.row >= (SHEET_MAX_ROWS - h))
corner.row = SHEET_MAX_ROWS - h - 1;
#if 0 #if 0
/* /*
...@@ -1060,9 +1071,8 @@ cb_move_cursor (SheetControlGUI *scg, int col, int row, gpointer user_data) ...@@ -1060,9 +1071,8 @@ cb_move_cursor (SheetControlGUI *scg, int col, int row, gpointer user_data)
#endif #endif
/* Make target cell visible, and adjust the cursor size */ /* Make target cell visible, and adjust the cursor size */
item_cursor_set_bounds_visibly (item_cursor, col, row, item_cursor_set_bounds_visibly (item_cursor, col, row, &corner,
corner_left, corner_top, corner.row + w, corner.row + h);
corner_left + w, corner_top + h);
return FALSE; return FALSE;
} }
...@@ -1166,9 +1176,7 @@ cb_autofill_scroll (SheetControlGUI *scg, int col, int row, gpointer user_data) ...@@ -1166,9 +1176,7 @@ cb_autofill_scroll (SheetControlGUI *scg, int col, int row, gpointer user_data)
col = item_cursor->base.col; col = item_cursor->base.col;
item_cursor_set_bounds_visibly (item_cursor, col, row, item_cursor_set_bounds_visibly (item_cursor, col, row,
item_cursor->base.col, &item_cursor->base, right, bottom);
item_cursor->base.row,
right, bottom);
return FALSE; return FALSE;
} }
...@@ -1315,6 +1323,10 @@ item_cursor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) ...@@ -1315,6 +1323,10 @@ item_cursor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
} }
} }
typedef struct {
GnomeCanvasItemClass parent_class;
} ItemCursorClass;
/* /*
* ItemCursor class initialization * ItemCursor class initialization
*/ */
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "gui-gnumeric.h" #include "gui-gnumeric.h"
#define ITEM_CURSOR(obj) (GTK_CHECK_CAST((obj), item_cursor_get_type (), ItemCursor)) #define ITEM_CURSOR(obj) (GTK_CHECK_CAST((obj), item_cursor_get_type (), ItemCursor))
#define ITEM_CURSOR_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), item_cursor_get_type (), ItemCursorClass))
#define IS_ITEM_CURSOR(o) (GTK_CHECK_TYPE((o), item_cursor_get_type ())) #define IS_ITEM_CURSOR(o) (GTK_CHECK_TYPE((o), item_cursor_get_type ()))
typedef enum { typedef enum {
...@@ -16,61 +15,10 @@ typedef enum { ...@@ -16,61 +15,10 @@ typedef enum {
ITEM_CURSOR_BLOCK ITEM_CURSOR_BLOCK
} ItemCursorStyle; } ItemCursorStyle;
struct _ItemCursor {
GnomeCanvasItem canvas_item;
SheetControlGUI *scg;
Range pos;
CellPos base_corner; /* Corner remains static when rubber banding */
CellPos move_corner; /* Corner to move when extending */
/* Offset of dragging cell from top left of pos */
int col_delta, row_delta;
/* Tip for movement */
GtkWidget *tip;
ItemCursorStyle style;
GdkGC *gc;
int state;
int animation_timer;
/*
* For the autofill mode:
* Where the action started (base_x, base_y) and the
* width and heigth of the selection when the autofill
* started.
*/
CellPos base;
int base_x, base_y;
int base_cols, base_rows;
/* Cached values of the last bounding box information used */
int cached_x, cached_y, cached_w, cached_h;
int visible:1;
int use_color:1;
/* Location of auto fill handle */
int auto_fill_handle_at_top:1;
int drag_button;
GdkPixmap *stipple;
GdkColor color;
};
GtkType item_cursor_get_type (void); GtkType item_cursor_get_type (void);
typedef struct { gboolean item_cursor_set_bounds (ItemCursor *ic, Range const *new_bound);
GnomeCanvasItemClass parent_class; void item_cursor_set_visibility (ItemCursor *ic, gboolean visible);
} ItemCursorClass; void item_cursor_reposition (ItemCursor *ic);
gboolean item_cursor_set_bounds (ItemCursor *item_cursor,
int base_col, int base_row,
int move_col, int move_row);
void item_cursor_set_visibility (ItemCursor *item_cursor,
gboolean const visible);
void item_cursor_reposition (ItemCursor *item_cursor);
#endif /* GNUMERIC_ITEM_CURSOR_H */ #endif /* GNUMERIC_ITEM_CURSOR_H */
...@@ -117,11 +117,11 @@ point_is_inside_range (ItemEdit *item_edit, const char *text, Range *range) ...@@ -117,11 +117,11 @@ point_is_inside_range (ItemEdit *item_edit, const char *text, Range *range)
} }
static void static void
entry_create_feedback_range (ItemEdit *item_edit, Range *range) entry_create_feedback_range (ItemEdit *item_edit, Range *r)
{ {
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (item_edit); GnomeCanvasItem *item = GNOME_CANVAS_ITEM (item_edit);
if (!item_edit->feedback_cursor){ if (!item_edit->feedback_cursor)
item_edit->feedback_cursor = gnome_canvas_item_new ( item_edit->feedback_cursor = gnome_canvas_item_new (
GNOME_CANVAS_GROUP (item->canvas->root), GNOME_CANVAS_GROUP (item->canvas->root),
item_cursor_get_type (), item_cursor_get_type (),
...@@ -129,12 +129,8 @@ entry_create_feedback_range (ItemEdit *item_edit, Range *range) ...@@ -129,12 +129,8 @@ entry_create_feedback_range (ItemEdit *item_edit, Range *range)
"Style", ITEM_CURSOR_BLOCK, "Style", ITEM_CURSOR_BLOCK,
"Color", "red", "Color", "red",
NULL); NULL);
}
item_cursor_set_bounds ( item_cursor_set_bounds (ITEM_CURSOR (item_edit->feedback_cursor), r);
ITEM_CURSOR (item_edit->feedback_cursor),
range->start.col, range->start.row,
range->end.col, range->end.row);
} }
static void static void
......
...@@ -744,13 +744,12 @@ item_grid_button_1 (SheetControlGUI *scg, GdkEventButton *event, ...@@ -744,13 +744,12 @@ item_grid_button_1 (SheetControlGUI *scg, GdkEventButton *event,
if (!workbook_edit_has_guru (scg->wbcg)) if (!workbook_edit_has_guru (scg->wbcg))
scg_mode_edit (scg); scg_mode_edit (scg);
} else } else
wb_control_gui_focus_cur_sheet (gsheet->scg->wbcg); wb_control_gui_focus_cur_sheet (scg->wbcg);
/* /* If we were already selecting a range of cells for a formula,