Commit 4a320299 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Some work on range selection

2001-01-04  Jody Goldberg <jgoldberg@home.com>

	* src/item-cursor.c (item_cursor_event) : animated cursors can no be
	  dragged or resized.   NOTE : This introduces a small bug while
	  fixing another.  The animated cursor is frequently drawn on top of
	  the current selection cursor when it is first created.  As such the
	  selection cursor does not receive all the events it should.
	  Ideally the canvas would pass ignored events to the widget below, but
	  that is not going to happen.  We can not just forward the events to
	  the other cursor because it may have moved.  We would need to ensure
	  that we only forward things in the areas that are overlapping.  Which
	  is not easy.
	(item_cursor_set_spin_base) : delete.

	* src/item-grid.c (item_grid_button_1) : support shift-extending a
	  range selection cursor.

	* src/workbook-view.c (wb_view_selection_desc) : Add some safety.

	* src/gnumeric-sheet.c (gnumeric_sheet_rangesel_cursor_extend) :
	  Intelligently handle extension to full rows/cols and rename from
	  gnumeric_sheet_selection_extend.
	(start_cell_selection_at) : no need to set the base a second time.
	(gnumeric_sheet_rangesel_cursor_bounds) : rename from
	  gnumeric_sheet_selection_cursor_place and allow the specification of
	  base and move coords.
	(gnumeric_sheet_selection_cursor_base) : delete.

	* src/item-bar.c (is_pointer_on_division) : no resizing while range
	  selecting.
	(get_element_from_pixel) : delete dead code.

2001-01-03  Jody Goldberg <jgoldberg@home.com>

	* src/item-bar.c (item_bar_event) : Call scg_colrow_select directly.
	  and convert from using 'is_vertical' to 'is_cols' which is the
	  convention everywhere else.
	(cb_extend_selection) : ditto.
	(colrow_tip_setlabel) : ditto.
	(item_bar_marshal) : delete.
	(get_row_name) : fortify a bit.

	* src/sheet-control-gui.c (scg_colrow_select) : merge together from
	  sheet_view_{col,row}_selection_changed and rewrite.
	(sheet_view_construct) : remove handlers for the item-bar signal.

	* src/commands.c (cmd_autofill_redo) : check for array violations.
	  Clear the target range.  This will allow entire arrays to be filled.
	(cmd_autofill) : Use the area that we will be filling rather.  Excude
	  the area that will not change.

	* src/sheet.c (sheet_{col,row}_get_info) : simplify.

	* src/selection.c (walk_boundaries) : don't walk into hidden cols/rows.
parent 44b667ad
......@@ -12,11 +12,11 @@ Release Critical
- autofill should not fill in the invisible areas.
- the selection cursor is confused by making selection via the item-bars
- Fix Borders
Long term breakage
------------------
- Fix Borders
- Entering "=1e11111" yields "Syntax Error", not "overflow".
In general parsing needs better error messages.
......
2001-01-04 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_event) : animated cursors can no be
dragged or resized. NOTE : This introduces a small bug while
fixing another. The animated cursor is frequently drawn on top of
the current selection cursor when it is first created. As such the
selection cursor does not receive all the events it should.
Ideally the canvas would pass ignored events to the widget below, but
that is not going to happen. We can not just forward the events to
the other cursor because it may have moved. We would need to ensure
that we only forward things in the areas that are overlapping. Which
is not easy.
(item_cursor_set_spin_base) : delete.
* src/item-grid.c (item_grid_button_1) : support shift-extending a
range selection cursor.
* src/workbook-view.c (wb_view_selection_desc) : Add some safety.
* src/gnumeric-sheet.c (gnumeric_sheet_rangesel_cursor_extend) :
Intelligently handle extension to full rows/cols and rename from
gnumeric_sheet_selection_extend.
(start_cell_selection_at) : no need to set the base a second time.
(gnumeric_sheet_rangesel_cursor_bounds) : rename from
gnumeric_sheet_selection_cursor_place and allow the specification of
base and move coords.
(gnumeric_sheet_selection_cursor_base) : delete.
* src/item-bar.c (is_pointer_on_division) : no resizing while range
selecting.
(get_element_from_pixel) : delete dead code.
2001-01-03 Jody Goldberg <jgoldberg@home.com>
* src/item-bar.c (item_bar_event) : Call scg_colrow_select directly.
and convert from using 'is_vertical' to 'is_cols' which is the
convention everywhere else.
(cb_extend_selection) : ditto.
(colrow_tip_setlabel) : ditto.
(item_bar_marshal) : delete.
(get_row_name) : fortify a bit.
* src/sheet-control-gui.c (scg_colrow_select) : merge together from
sheet_view_{col,row}_selection_changed and rewrite.
(sheet_view_construct) : remove handlers for the item-bar signal.
* src/commands.c (cmd_autofill_redo) : check for array violations.
Clear the target range. This will allow entire arrays to be filled.
(cmd_autofill) : Use the area that we will be filling rather. Excude
......
......@@ -4,6 +4,7 @@ Jody:
* Undo, persistance, cursor handling, and printing for merged cells
* Fix inverted objects
* Fix stupid memory corruption problem in the applix importer.
* Improve range selection for expressions.
Jon Kåre:
* Improve file save dialog.
......
2001-01-04 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_event) : animated cursors can no be
dragged or resized. NOTE : This introduces a small bug while
fixing another. The animated cursor is frequently drawn on top of
the current selection cursor when it is first created. As such the
selection cursor does not receive all the events it should.
Ideally the canvas would pass ignored events to the widget below, but
that is not going to happen. We can not just forward the events to
the other cursor because it may have moved. We would need to ensure
that we only forward things in the areas that are overlapping. Which
is not easy.
(item_cursor_set_spin_base) : delete.
* src/item-grid.c (item_grid_button_1) : support shift-extending a
range selection cursor.
* src/workbook-view.c (wb_view_selection_desc) : Add some safety.
* src/gnumeric-sheet.c (gnumeric_sheet_rangesel_cursor_extend) :
Intelligently handle extension to full rows/cols and rename from
gnumeric_sheet_selection_extend.
(start_cell_selection_at) : no need to set the base a second time.
(gnumeric_sheet_rangesel_cursor_bounds) : rename from
gnumeric_sheet_selection_cursor_place and allow the specification of
base and move coords.
(gnumeric_sheet_selection_cursor_base) : delete.
* src/item-bar.c (is_pointer_on_division) : no resizing while range
selecting.
(get_element_from_pixel) : delete dead code.
2001-01-03 Jody Goldberg <jgoldberg@home.com>
* src/item-bar.c (item_bar_event) : Call scg_colrow_select directly.
and convert from using 'is_vertical' to 'is_cols' which is the
convention everywhere else.
(cb_extend_selection) : ditto.
(colrow_tip_setlabel) : ditto.
(item_bar_marshal) : delete.
(get_row_name) : fortify a bit.
* src/sheet-control-gui.c (scg_colrow_select) : merge together from
sheet_view_{col,row}_selection_changed and rewrite.
(sheet_view_construct) : remove handlers for the item-bar signal.
* src/commands.c (cmd_autofill_redo) : check for array violations.
Clear the target range. This will allow entire arrays to be filled.
(cmd_autofill) : Use the area that we will be filling rather. Excude
......
2001-01-04 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_event) : animated cursors can no be
dragged or resized. NOTE : This introduces a small bug while
fixing another. The animated cursor is frequently drawn on top of
the current selection cursor when it is first created. As such the
selection cursor does not receive all the events it should.
Ideally the canvas would pass ignored events to the widget below, but
that is not going to happen. We can not just forward the events to
the other cursor because it may have moved. We would need to ensure
that we only forward things in the areas that are overlapping. Which
is not easy.
(item_cursor_set_spin_base) : delete.
* src/item-grid.c (item_grid_button_1) : support shift-extending a
range selection cursor.
* src/workbook-view.c (wb_view_selection_desc) : Add some safety.
* src/gnumeric-sheet.c (gnumeric_sheet_rangesel_cursor_extend) :
Intelligently handle extension to full rows/cols and rename from
gnumeric_sheet_selection_extend.
(start_cell_selection_at) : no need to set the base a second time.
(gnumeric_sheet_rangesel_cursor_bounds) : rename from
gnumeric_sheet_selection_cursor_place and allow the specification of
base and move coords.
(gnumeric_sheet_selection_cursor_base) : delete.
* src/item-bar.c (is_pointer_on_division) : no resizing while range
selecting.
(get_element_from_pixel) : delete dead code.
2001-01-03 Jody Goldberg <jgoldberg@home.com>
* src/item-bar.c (item_bar_event) : Call scg_colrow_select directly.
and convert from using 'is_vertical' to 'is_cols' which is the
convention everywhere else.
(cb_extend_selection) : ditto.
(colrow_tip_setlabel) : ditto.
(item_bar_marshal) : delete.
(get_row_name) : fortify a bit.
* src/sheet-control-gui.c (scg_colrow_select) : merge together from
sheet_view_{col,row}_selection_changed and rewrite.
(sheet_view_construct) : remove handlers for the item-bar signal.
* src/commands.c (cmd_autofill_redo) : check for array violations.
Clear the target range. This will allow entire arrays to be filled.
(cmd_autofill) : Use the area that we will be filling rather. Excude
......
2001-01-04 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_event) : animated cursors can no be
dragged or resized. NOTE : This introduces a small bug while
fixing another. The animated cursor is frequently drawn on top of
the current selection cursor when it is first created. As such the
selection cursor does not receive all the events it should.
Ideally the canvas would pass ignored events to the widget below, but
that is not going to happen. We can not just forward the events to
the other cursor because it may have moved. We would need to ensure
that we only forward things in the areas that are overlapping. Which
is not easy.
(item_cursor_set_spin_base) : delete.
* src/item-grid.c (item_grid_button_1) : support shift-extending a
range selection cursor.
* src/workbook-view.c (wb_view_selection_desc) : Add some safety.
* src/gnumeric-sheet.c (gnumeric_sheet_rangesel_cursor_extend) :
Intelligently handle extension to full rows/cols and rename from
gnumeric_sheet_selection_extend.
(start_cell_selection_at) : no need to set the base a second time.
(gnumeric_sheet_rangesel_cursor_bounds) : rename from
gnumeric_sheet_selection_cursor_place and allow the specification of
base and move coords.
(gnumeric_sheet_selection_cursor_base) : delete.
* src/item-bar.c (is_pointer_on_division) : no resizing while range
selecting.
(get_element_from_pixel) : delete dead code.
2001-01-03 Jody Goldberg <jgoldberg@home.com>
* src/item-bar.c (item_bar_event) : Call scg_colrow_select directly.
and convert from using 'is_vertical' to 'is_cols' which is the
convention everywhere else.
(cb_extend_selection) : ditto.
(colrow_tip_setlabel) : ditto.
(item_bar_marshal) : delete.
(get_row_name) : fortify a bit.
* src/sheet-control-gui.c (scg_colrow_select) : merge together from
sheet_view_{col,row}_selection_changed and rewrite.
(sheet_view_construct) : remove handlers for the item-bar signal.
* src/commands.c (cmd_autofill_redo) : check for array violations.
Clear the target range. This will allow entire arrays to be filled.
(cmd_autofill) : Use the area that we will be filling rather. Excude
......
2001-01-04 Jody Goldberg <jgoldberg@home.com>
* src/item-cursor.c (item_cursor_event) : animated cursors can no be
dragged or resized. NOTE : This introduces a small bug while
fixing another. The animated cursor is frequently drawn on top of
the current selection cursor when it is first created. As such the
selection cursor does not receive all the events it should.
Ideally the canvas would pass ignored events to the widget below, but
that is not going to happen. We can not just forward the events to
the other cursor because it may have moved. We would need to ensure
that we only forward things in the areas that are overlapping. Which
is not easy.
(item_cursor_set_spin_base) : delete.
* src/item-grid.c (item_grid_button_1) : support shift-extending a
range selection cursor.
* src/workbook-view.c (wb_view_selection_desc) : Add some safety.
* src/gnumeric-sheet.c (gnumeric_sheet_rangesel_cursor_extend) :
Intelligently handle extension to full rows/cols and rename from
gnumeric_sheet_selection_extend.
(start_cell_selection_at) : no need to set the base a second time.
(gnumeric_sheet_rangesel_cursor_bounds) : rename from
gnumeric_sheet_selection_cursor_place and allow the specification of
base and move coords.
(gnumeric_sheet_selection_cursor_base) : delete.
* src/item-bar.c (is_pointer_on_division) : no resizing while range
selecting.
(get_element_from_pixel) : delete dead code.
2001-01-03 Jody Goldberg <jgoldberg@home.com>
* src/item-bar.c (item_bar_event) : Call scg_colrow_select directly.
and convert from using 'is_vertical' to 'is_cols' which is the
convention everywhere else.
(cb_extend_selection) : ditto.
(colrow_tip_setlabel) : ditto.
(item_bar_marshal) : delete.
(get_row_name) : fortify a bit.
* src/sheet-control-gui.c (scg_colrow_select) : merge together from
sheet_view_{col,row}_selection_changed and rewrite.
(sheet_view_construct) : remove handlers for the item-bar signal.
* src/commands.c (cmd_autofill_redo) : check for array violations.
Clear the target range. This will allow entire arrays to be filled.
(cmd_autofill) : Use the area that we will be filling rather. Excude
......
......@@ -272,7 +272,6 @@ start_cell_selection_at (GnumericSheet *gsheet, int col, int row)
"SheetControlGUI", gsheet->scg,
"Grid", gsheet->item_grid,
"Style", ITEM_CURSOR_ANTED, NULL));
item_cursor_set_spin_base (gsheet->sel_cursor, col, row);
item_cursor_set_bounds (ITEM_CURSOR (gsheet->sel_cursor), col, row, col, row);
/* If we are selecting a range on a different sheet this may be NULL */
......@@ -354,25 +353,38 @@ gnumeric_sheet_stop_editing (GnumericSheet *gsheet)
}
}
/*
* Invoked by Item-Grid to extend the cursor selection
/**
* gnumeric_sheet_rangesel_cursor_extend :
*
* @gsheet :
* @col :
* @row :
*
* Extend the range selection cursor. If col < 0 then extend to full
*/
void
gnumeric_sheet_selection_extend (GnumericSheet *gsheet, int col, int row)
gnumeric_sheet_rangesel_cursor_extend (GnumericSheet *gsheet, int col, int row)
{
ItemCursor *ic;
int base_col, base_row;
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
g_return_if_fail (gsheet->selecting_cell);
g_return_if_fail (col < SHEET_MAX_COLS);
g_return_if_fail (row < SHEET_MAX_ROWS);
ic = gsheet->sel_cursor;
if (col < 0) {
base_col = 0;
col = SHEET_MAX_COLS - 1;
} else
base_col = ic->base_corner.col;
if (row < 0) {
base_row = 0;
row = SHEET_MAX_ROWS - 1;
} else
base_row = ic->base_corner.row;
selection_remove_selection_string (gsheet);
item_cursor_set_bounds (ic,
ic->base_corner.col, ic->base_corner.row,
col, row);
item_cursor_set_bounds (ic, base_col, base_row, col, row);
selection_insert_selection_string (gsheet);
}
......@@ -381,36 +393,21 @@ gnumeric_sheet_selection_extend (GnumericSheet *gsheet, int col, int row)
* spot.
*/
void
gnumeric_sheet_selection_cursor_place (GnumericSheet *gsheet, int col, int row)
gnumeric_sheet_rangesel_cursor_bounds (GnumericSheet *gsheet,
int base_col, int base_row,
int move_col, int move_row)
{
ItemCursor *ic;
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
g_return_if_fail (gsheet->selecting_cell);
g_return_if_fail (col < SHEET_MAX_COLS);
g_return_if_fail (row < SHEET_MAX_ROWS);
ic = gsheet->sel_cursor;
selection_remove_selection_string (gsheet);
item_cursor_set_bounds (ic, col, row, col, row);
item_cursor_set_bounds (ic, base_col, base_row, move_col, move_row);
selection_insert_selection_string (gsheet);
}
void
gnumeric_sheet_selection_cursor_base (GnumericSheet *gsheet, int col, int row)
{
ItemCursor *ic;
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
g_return_if_fail (gsheet->selecting_cell);
g_return_if_fail (col < SHEET_MAX_COLS);
g_return_if_fail (row < SHEET_MAX_ROWS);
ic = gsheet->sel_cursor;
item_cursor_set_spin_base (ic, col, row);
}
static void
rangesel_horizontal_move (GnumericSheet *gsheet, int dir, gboolean jump_to_boundaries)
{
......
......@@ -62,11 +62,10 @@ void gnumeric_sheet_start_cell_selection (GnumericSheet *gsheet,
int col, int row);
void gnumeric_sheet_stop_cell_selection (GnumericSheet *gsheet,
gboolean const clear_string);
void gnumeric_sheet_selection_cursor_place (GnumericSheet *gsheet,
int col, int row);
void gnumeric_sheet_selection_cursor_base (GnumericSheet *gsheet,
int col, int row);
void gnumeric_sheet_selection_extend (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);
int gnumeric_sheet_find_col (GnumericSheet *item_grid,
......
......@@ -272,7 +272,6 @@ start_cell_selection_at (GnumericSheet *gsheet, int col, int row)
"SheetControlGUI", gsheet->scg,
"Grid", gsheet->item_grid,
"Style", ITEM_CURSOR_ANTED, NULL));
item_cursor_set_spin_base (gsheet->sel_cursor, col, row);
item_cursor_set_bounds (ITEM_CURSOR (gsheet->sel_cursor), col, row, col, row);
/* If we are selecting a range on a different sheet this may be NULL */
......@@ -354,25 +353,38 @@ gnumeric_sheet_stop_editing (GnumericSheet *gsheet)
}
}
/*
* Invoked by Item-Grid to extend the cursor selection
/**
* gnumeric_sheet_rangesel_cursor_extend :
*
* @gsheet :
* @col :
* @row :
*
* Extend the range selection cursor. If col < 0 then extend to full
*/
void
gnumeric_sheet_selection_extend (GnumericSheet *gsheet, int col, int row)
gnumeric_sheet_rangesel_cursor_extend (GnumericSheet *gsheet, int col, int row)
{
ItemCursor *ic;
int base_col, base_row;
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
g_return_if_fail (gsheet->selecting_cell);
g_return_if_fail (col < SHEET_MAX_COLS);
g_return_if_fail (row < SHEET_MAX_ROWS);
ic = gsheet->sel_cursor;
if (col < 0) {
base_col = 0;
col = SHEET_MAX_COLS - 1;
} else
base_col = ic->base_corner.col;
if (row < 0) {
base_row = 0;
row = SHEET_MAX_ROWS - 1;
} else
base_row = ic->base_corner.row;
selection_remove_selection_string (gsheet);
item_cursor_set_bounds (ic,
ic->base_corner.col, ic->base_corner.row,
col, row);
item_cursor_set_bounds (ic, base_col, base_row, col, row);
selection_insert_selection_string (gsheet);
}
......@@ -381,36 +393,21 @@ gnumeric_sheet_selection_extend (GnumericSheet *gsheet, int col, int row)
* spot.
*/
void
gnumeric_sheet_selection_cursor_place (GnumericSheet *gsheet, int col, int row)
gnumeric_sheet_rangesel_cursor_bounds (GnumericSheet *gsheet,
int base_col, int base_row,
int move_col, int move_row)
{
ItemCursor *ic;
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
g_return_if_fail (gsheet->selecting_cell);
g_return_if_fail (col < SHEET_MAX_COLS);
g_return_if_fail (row < SHEET_MAX_ROWS);
ic = gsheet->sel_cursor;
selection_remove_selection_string (gsheet);
item_cursor_set_bounds (ic, col, row, col, row);
item_cursor_set_bounds (ic, base_col, base_row, move_col, move_row);
selection_insert_selection_string (gsheet);
}
void
gnumeric_sheet_selection_cursor_base (GnumericSheet *gsheet, int col, int row)
{
ItemCursor *ic;
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
g_return_if_fail (gsheet->selecting_cell);
g_return_if_fail (col < SHEET_MAX_COLS);
g_return_if_fail (row < SHEET_MAX_ROWS);
ic = gsheet->sel_cursor;
item_cursor_set_spin_base (ic, col, row);
}
static void
rangesel_horizontal_move (GnumericSheet *gsheet, int dir, gboolean jump_to_boundaries)
{
......
......@@ -62,11 +62,10 @@ void gnumeric_sheet_start_cell_selection (GnumericSheet *gsheet,
int col, int row);
void gnumeric_sheet_stop_cell_selection (GnumericSheet *gsheet,
gboolean const clear_string);
void gnumeric_sheet_selection_cursor_place (GnumericSheet *gsheet,
int col, int row);
void gnumeric_sheet_selection_cursor_base (GnumericSheet *gsheet,
int col, int row);
void gnumeric_sheet_selection_extend (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);
int gnumeric_sheet_find_col (GnumericSheet *item_grid,
......
......@@ -20,12 +20,6 @@
#include "application.h"
#include "style.h"
/* Marshal forward declarations */
static void item_bar_marshal (GtkObject *,
GtkSignalFunc,
gpointer,
GtkArg *);
/* The signal signatures */
typedef void (*ItemBarSignal1) (GtkObject *, gint arg1, gpointer data);
typedef void (*ItemBarSignal2) (GtkObject *, gint arg1, gint arg2, gpointer data);
......@@ -48,7 +42,6 @@ typedef void (*ItemBarSignal2) (GtkObject *, gint arg1, gint arg2, gpointer data
/* The signals we emit */
enum {
SELECTION_CHANGED,
LAST_SIGNAL
};
static guint item_bar_signals [LAST_SIGNAL] = { 0 };
......@@ -180,9 +173,9 @@ get_row_name (int n)
{
static char x [4 * sizeof (int)];
g_assert (n >= 0 && n < SHEET_MAX_ROWS);
g_return_val_if_fail (n >= 0 && n < SHEET_MAX_ROWS, "0");
sprintf (x, "%d", n + 1);
snprintf (x, sizeof (x)-1, "%d", n + 1);
return x;
}
......@@ -350,6 +343,7 @@ item_bar_translate (GnomeCanvasItem *item, double dx, double dy)
static ColRowInfo *
is_pointer_on_division (ItemBar *item_bar, int pos, int *the_total, int *the_element)
{
GnumericSheet * const gsheet = GNUMERIC_SHEET (item_bar->scg->canvas);
ColRowInfo *cri;
Sheet *sheet;
int i, total;
......@@ -370,7 +364,14 @@ is_pointer_on_division (ItemBar *item_bar, int pos, int *the_total, int *the_ele
if (cri->visible) {
total += cri->size_pixels;
if ((total - 4 < pos) && (pos < total + 4)) {
/* TODO : This is more expensive than it needs to be.
* We should really set a flag (in gsheet ?) and adjust
* it as the cursor in the entry is moved. The current
* approach recalculates the state every time.
*/
if (!gnumeric_sheet_can_select_expr_range (gsheet) &&
(total - 4 < pos) && (pos < total + 4)) {
if (the_total)
*the_total = total;
if (the_element)
......@@ -398,7 +399,7 @@ set_cursor (ItemBar *item_bar, int pos)
if (!canvas->window)
return;
if (is_pointer_on_division (item_bar, pos, NULL, NULL))
if (is_pointer_on_division (item_bar, pos, NULL, NULL) != NULL)
gdk_window_set_cursor (canvas->window, item_bar->change_cursor);
else
gdk_window_set_cursor (canvas->window, item_bar->normal_cursor);
......@@ -463,46 +464,17 @@ item_bar_start_resize (ItemBar *bar)
bar->resize_start = GTK_OBJECT (item);
}
static int
get_element_from_pixel (ItemBar *item_bar, int pos)
{
ColRowInfo *cri;
Sheet *sheet;
int i, total;
total = 0;
sheet = item_bar->scg->sheet;
for (i = item_bar->first_element; total < pos; i++){
if (item_bar->orientation == GTK_ORIENTATION_VERTICAL){
if (i >= SHEET_MAX_ROWS)
return i-1;
cri = sheet_row_get_info (sheet, i);
} else {
if (i >= SHEET_MAX_COLS)
return i-1;
cri = sheet_col_get_info (sheet, i);
}
if (cri->visible) {
total += cri->size_pixels;
if (total > pos)
return i;
}
}
return i;
}
static void
colrow_tip_setlabel (ItemBar *item_bar, gboolean const is_vertical, int size_pixels)
colrow_tip_setlabel (ItemBar *item_bar, gboolean const is_cols, int size_pixels)
{
if (item_bar->tip) {
char *buffer;
double const scale = 72. / application_display_dpi_get (is_vertical);
if (is_vertical)
buffer = g_strdup_printf (_("Height: %.2f pts (%d pixels)"),
double const scale = 72. / application_display_dpi_get (!is_cols);
if (is_cols)
buffer = g_strdup_printf (_("Width: %.2f pts (%d pixels)"),
scale*size_pixels, size_pixels);
else
buffer = g_strdup_printf (_("Width: %.2f pts (%d pixels)"),
buffer = g_strdup_printf (_("Height: %.2f pts (%d pixels)"),
scale*size_pixels, size_pixels);
gtk_label_set_text (GTK_LABEL (item_bar->tip), buffer);
g_free(buffer);
......@@ -539,10 +511,8 @@ static gboolean
cb_extend_selection (SheetControlGUI *scg, int col, int row, gpointer user_data)
{
ItemBar * const item_bar = user_data;
gboolean const is_vertical = (item_bar->orientation == GTK_ORIENTATION_VERTICAL);
gtk_signal_emit (GTK_OBJECT (item_bar),
item_bar_signals [SELECTION_CHANGED],
is_vertical ? row : col, 0);
gboolean const is_cols = (item_bar->orientation != GTK_ORIENTATION_VERTICAL);
scg_colrow_select (item_bar->scg, is_cols, is_cols ? col : row, GDK_SHIFT_MASK);
return TRUE;
}
......@@ -554,13 +524,13 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
ItemBar * const item_bar = ITEM_BAR (item);
Sheet * const sheet = item_bar->scg->sheet;
GnumericSheet * const gsheet = GNUMERIC_SHEET (item_bar->scg->canvas);
gboolean const is_vertical = (item_bar->orientation == GTK_ORIENTATION_VERTICAL);
gboolean const is_cols = (item_bar->orientation != GTK_ORIENTATION_VERTICAL);
#if 0
/*
* handle the zoom from the item-grid canvas, the resolution scaling is
* handled elsewhere
*/
double const res = application_display_dpi_get (is_vertical);
double const res = application_display_dpi_get (!is_cols);
#endif
double const zoom = sheet->last_zoom_factor_used; /* * res / 72.; */
int pos, start, element;
......@@ -571,18 +541,12 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
*/
switch (e->type){
case GDK_ENTER_NOTIFY:
if (is_vertical)
pos = e->crossing.y;
else
pos = e->crossing.x;
pos = (is_cols) ? e->crossing.x : e->crossing.y;
set_cursor (item_bar, pos);
break;
case GDK_MOTION_NOTIFY:
if (is_vertical)
pos = e->motion.y;
else
pos = e->motion.x;
pos = (is_cols) ? e->motion.x : e->motion.y;
/* Do col/row resizing or incremental marking */
if (item_bar->resize_pos != -1) {
......@@ -605,14 +569,14 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
item_bar->resize_width = npos;
colrow_tip_setlabel (item_bar, is_vertical, item_bar->resize_width);
colrow_tip_setlabel (item_bar, is_cols, item_bar->resize_width);
resize_guide = GNOME_CANVAS_ITEM (item_bar->resize_guide);
points = item_bar->resize_points;
if (is_vertical)
points->coords [1] = points->coords [3] = pos / zoom;
else
if (is_cols)
points->coords [0] = points->coords [2] = pos / zoom;
else
points->coords [1] = points->coords [3] = pos / zoom;
gnome_canvas_item_set (resize_guide, "points", points, NULL);
......@@ -620,14 +584,8 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
gnome_canvas_request_redraw (
canvas, 0, 0, INT_MAX, INT_MAX);
} else if (ITEM_BAR_IS_SELECTING (item_bar)) {
} else if (item_bar->start_selection != -1) {
int x, y, left, top, width, height, col, row;
element = get_element_from_pixel (item_bar, pos);
gtk_signal_emit (
GTK_OBJECT (item),
item_bar_signals [SELECTION_CHANGED],
element, 0);
gnome_canvas_w2c (canvas, e->motion.x, e->motion.y, &x, &y);
gnome_canvas_get_scroll_offsets (canvas, &left, &top);
......@@ -638,19 +596,21 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
col = gnumeric_sheet_find_col (gsheet, x, NULL);
row = gnumeric_sheet_find_row (gsheet, y, NULL);
scg_colrow_select (item_bar->scg, is_cols, is_cols ? col : row,
GDK_SHIFT_MASK);
if (x < left || y < top || x >= left + width || y >= top + height) {
int dx = 0, dy = 0;
if (is_vertical) {
if (y < top)
dy = y - top;
else if (y >= top + height)
dy = y - height - top;
} else {
if (is_cols) {
if (x < left)
dx = x - left;
else if (x >= left + width)
dx = x - width - left;
} else {
if (y < top)
dy = y - top;
else if (y >= top + height)
dy = y - height - top;
}
sheet_view_start_sliding (item_bar->scg,
......@@ -671,18 +631,14 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
scg_mode_edit (item_bar->scg);
if (is_vertical)
pos = e->button.y;
else
pos = e->button.x;
pos = (is_cols) ? e->button.x : e->button.y;
cri = is_pointer_on_division (item_bar, pos, &start, &element);
if (is_vertical) {
if (element > SHEET_MAX_ROWS-1)
if (is_cols) {
if (element > SHEET_MAX_COLS-1)
break;
} else {
if (element > SHEET_MAX_COLS-1)
if (element > SHEET_MAX_ROWS-1)
break;
}
......@@ -690,14 +646,13 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
/* If the selection does not contain the current row/col
* then clear the selection and add it.