Commit fab1b64a authored by Jody Goldberg's avatar Jody Goldberg

Fix some of the selection problems.

parent 859fc276
1999-09-04 Jody Goldberg <jgoldberg@home.com>
* src/dialogs/dialog-paste-special.c : Fix typo.
1999-09-03 Jody Goldberg <jgoldberg@home.com>
* src/sheet.[ch] (sheet_cursor_move) : Add flags to optionally manage
the selection when moving, taking care to handle case where we do
not actually move.
(sheet_select_all) : Manage the selection locally.
* src/corba-sheet.c (Sheet_cursor_move) : Have sheet_cursor_move
manage selection.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet) : Ditto for
Ctrl-Home.
* src/item-grid.c (item_grid_button_1) : Handle selections locally.
* src/sheet-view.c (sheet_view_col_selection_changed) : Manage
selections locally, and jump to the current row in the selected
column, not 0.
(sheet_view_row_selection_changed) : Manage
selections locally, and jump to the current row in the selected
column, not 0.
(horizontal_scroll_event, vertical_scroll_event) : Emulate XL. It
does not move the cursor while scrolling.
(sheet_view_scrollbar_display) : Make static.
(sheet_view_construct) : Partial fix for bug 1820. Scroll by 1 when
left clicking on the trough.
* workbook.c (wb_edit_key_pressed) : Use sheet_cursor_move to manage
the selection.
1999-09-05 Miguel de Icaza <miguel@gnu.org>
* src/dialogs/dialog-cell-format.c (create_background_radio,
......
1999-09-04 Jody Goldberg <jgoldberg@home.com>
* src/dialogs/dialog-paste-special.c : Fix typo.
1999-09-03 Jody Goldberg <jgoldberg@home.com>
* src/sheet.[ch] (sheet_cursor_move) : Add flags to optionally manage
the selection when moving, taking care to handle case where we do
not actually move.
(sheet_select_all) : Manage the selection locally.
* src/corba-sheet.c (Sheet_cursor_move) : Have sheet_cursor_move
manage selection.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet) : Ditto for
Ctrl-Home.
* src/item-grid.c (item_grid_button_1) : Handle selections locally.
* src/sheet-view.c (sheet_view_col_selection_changed) : Manage
selections locally, and jump to the current row in the selected
column, not 0.
(sheet_view_row_selection_changed) : Manage
selections locally, and jump to the current row in the selected
column, not 0.
(horizontal_scroll_event, vertical_scroll_event) : Emulate XL. It
does not move the cursor while scrolling.
(sheet_view_scrollbar_display) : Make static.
(sheet_view_construct) : Partial fix for bug 1820. Scroll by 1 when
left clicking on the trough.
* workbook.c (wb_edit_key_pressed) : Use sheet_cursor_move to manage
the selection.
1999-09-05 Miguel de Icaza <miguel@gnu.org>
* src/dialogs/dialog-cell-format.c (create_background_radio,
......
......@@ -104,7 +104,7 @@ Sheet_cursor_move (PortableServer_Servant servant, const CORBA_long col, const C
verify_col (col);
verify_row (row);
sheet_cursor_move (sheet, col, row);
sheet_cursor_move (sheet, col, row, TRUE, TRUE);
}
static void
......
......@@ -113,11 +113,8 @@ gnumeric_sheet_cursor_set (GnumericSheet *gsheet, int col, int row)
/*
* gnumeric_sheet_set_selection:
* @gsheet: The sheet name
* @start_col: The starting column.
* @start_row: The starting row
* @end_col: The end column
* @end_row: The end row
* @gsheet: The sheet name
* @ss: The selection
*
* Set the current selection to cover the inclusive area delimited by
* start_col, start_row, end_col and end_row. The actual cursor is
......@@ -758,7 +755,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
case GDK_Home:
if ((event->state & GDK_CONTROL_MASK) != 0){
sheet_make_cell_visible (sheet, 0, 0);
sheet_cursor_move (sheet, 0, 0);
sheet_cursor_move (sheet, 0, 0, TRUE, TRUE);
break;
} else
(*movefn_horizontal)(gsheet, -CURSOR_COL(gsheet), FALSE);
......
......@@ -113,11 +113,8 @@ gnumeric_sheet_cursor_set (GnumericSheet *gsheet, int col, int row)
/*
* gnumeric_sheet_set_selection:
* @gsheet: The sheet name
* @start_col: The starting column.
* @start_row: The starting row
* @end_col: The end column
* @end_row: The end row
* @gsheet: The sheet name
* @ss: The selection
*
* Set the current selection to cover the inclusive area delimited by
* start_col, start_row, end_col and end_row. The actual cursor is
......@@ -758,7 +755,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
case GDK_Home:
if ((event->state & GDK_CONTROL_MASK) != 0){
sheet_make_cell_visible (sheet, 0, 0);
sheet_cursor_move (sheet, 0, 0);
sheet_cursor_move (sheet, 0, 0, TRUE, TRUE);
break;
} else
(*movefn_horizontal)(gsheet, -CURSOR_COL(gsheet), FALSE);
......
......@@ -736,7 +736,8 @@ item_grid_button_1 (Sheet *sheet, GdkEvent *event, ItemGrid *item_grid, int col,
if (!(event->button.state & GDK_SHIFT_MASK)) {
sheet_make_cell_visible (sheet, col, row);
sheet_cursor_move (sheet, col, row);
/* Handle the selection localy */
sheet_cursor_move (sheet, col, row, FALSE, FALSE);
}
if (!(event->button.state & (GDK_CONTROL_MASK|GDK_SHIFT_MASK)))
......
......@@ -223,9 +223,11 @@ sheet_view_col_selection_changed (ItemBar *item_bar, int column, int modifiers,
end_col, SHEET_MAX_ROWS-1);
return;
}
sheet_cursor_move (sheet, column, 0);
sheet_cursor_move (sheet, column, sheet->cursor_row, FALSE, FALSE);
if (!(modifiers & GDK_CONTROL_MASK))
sheet_selection_reset_only (sheet);
sheet_selection_append_range (sheet,
column, 0,
column, 0,
......@@ -276,7 +278,8 @@ sheet_view_row_selection_changed (ItemBar *item_bar, int row, int modifiers, She
SHEET_MAX_COLS-1, end_row);
return;
}
sheet_cursor_move (sheet, 0, row);
sheet_cursor_move (sheet, sheet->cursor_col, row, FALSE, FALSE);
if (!(modifiers & GDK_CONTROL_MASK))
sheet_selection_reset_only (sheet);
......@@ -387,7 +390,6 @@ horizontal_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet
else if (event->type == GDK_BUTTON_RELEASE)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
SheetSelection *ss = sheet_view->sheet->selections->data;
int col;
gtk_widget_destroy (gtk_widget_get_toplevel (sheet_view->tip));
......@@ -396,12 +398,7 @@ horizontal_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet
col = GTK_ADJUSTMENT (sheet_view->ha)->value;
gnumeric_sheet_set_top_col (gsheet, col);
if (sheet_view->sheet->cursor_col != col ||
sheet_view->sheet->cursor_row != ss->start_row) {
sheet_cursor_move (sheet_view->sheet, col, ss->start_row);
sheet_selection_append (sheet_view->sheet, col, ss->start_row);
}
/* NOTE : Excel does not move the cursor, just scrolls the sheet. */
}
return FALSE;
......@@ -419,7 +416,6 @@ vertical_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet_v
else if (event->type == GDK_BUTTON_RELEASE)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
SheetSelection *ss = sheet_view->sheet->selections->data;
int row;
gtk_widget_destroy (gtk_widget_get_toplevel (sheet_view->tip));
......@@ -428,11 +424,7 @@ vertical_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet_v
row = GTK_ADJUSTMENT (sheet_view->va)->value;
gnumeric_sheet_set_top_row (gsheet, row);
if (sheet_view->sheet->cursor_col != ss->start_col ||
sheet_view->sheet->cursor_row != row) {
sheet_cursor_move (sheet_view->sheet, ss->start_col, row);
sheet_selection_append (sheet_view->sheet, ss->start_col, row);
}
/* NOTE : Excel does not move the cursor, just scrolls the sheet. */
}
return FALSE;
......@@ -521,8 +513,9 @@ sheet_view_construct (SheetView *sheet_view)
GTK_SIGNAL_FUNC (button_select_all), sheet_view);
/* Scroll bars and their adjustments */
sheet_view->va = gtk_adjustment_new (0.0, 0.0, sheet->max_row_used, 1.0, 0.0, 1.0);
sheet_view->ha = gtk_adjustment_new (0.0, 0.0, sheet->max_col_used, 1.0, 0.0, 1.0);
/* FIXME : The step_inc, page_inc, and page_size should be related to the page size, not 1 */
sheet_view->va = gtk_adjustment_new (0.0, 0.0, sheet->max_row_used, 1.0, 1.0, 1.0);
sheet_view->ha = gtk_adjustment_new (0.0, 0.0, sheet->max_col_used, 1.0, 1.0, 1.0);
sheet_view->hs = gtk_hscrollbar_new (GTK_ADJUSTMENT (sheet_view->ha));
sheet_view->vs = gtk_vscrollbar_new (GTK_ADJUSTMENT (sheet_view->va));
......@@ -575,7 +568,7 @@ sheet_view_set_header_visibility (SheetView *sheet_view,
}
}
void
static void
sheet_view_scrollbar_display (SheetView *sheet_view,
gboolean show_col_scrollbar,
gboolean show_row_scrollbar)
......
......@@ -223,9 +223,11 @@ sheet_view_col_selection_changed (ItemBar *item_bar, int column, int modifiers,
end_col, SHEET_MAX_ROWS-1);
return;
}
sheet_cursor_move (sheet, column, 0);
sheet_cursor_move (sheet, column, sheet->cursor_row, FALSE, FALSE);
if (!(modifiers & GDK_CONTROL_MASK))
sheet_selection_reset_only (sheet);
sheet_selection_append_range (sheet,
column, 0,
column, 0,
......@@ -276,7 +278,8 @@ sheet_view_row_selection_changed (ItemBar *item_bar, int row, int modifiers, She
SHEET_MAX_COLS-1, end_row);
return;
}
sheet_cursor_move (sheet, 0, row);
sheet_cursor_move (sheet, sheet->cursor_col, row, FALSE, FALSE);
if (!(modifiers & GDK_CONTROL_MASK))
sheet_selection_reset_only (sheet);
......@@ -387,7 +390,6 @@ horizontal_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet
else if (event->type == GDK_BUTTON_RELEASE)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
SheetSelection *ss = sheet_view->sheet->selections->data;
int col;
gtk_widget_destroy (gtk_widget_get_toplevel (sheet_view->tip));
......@@ -396,12 +398,7 @@ horizontal_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet
col = GTK_ADJUSTMENT (sheet_view->ha)->value;
gnumeric_sheet_set_top_col (gsheet, col);
if (sheet_view->sheet->cursor_col != col ||
sheet_view->sheet->cursor_row != ss->start_row) {
sheet_cursor_move (sheet_view->sheet, col, ss->start_row);
sheet_selection_append (sheet_view->sheet, col, ss->start_row);
}
/* NOTE : Excel does not move the cursor, just scrolls the sheet. */
}
return FALSE;
......@@ -419,7 +416,6 @@ vertical_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet_v
else if (event->type == GDK_BUTTON_RELEASE)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
SheetSelection *ss = sheet_view->sheet->selections->data;
int row;
gtk_widget_destroy (gtk_widget_get_toplevel (sheet_view->tip));
......@@ -428,11 +424,7 @@ vertical_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet_v
row = GTK_ADJUSTMENT (sheet_view->va)->value;
gnumeric_sheet_set_top_row (gsheet, row);
if (sheet_view->sheet->cursor_col != ss->start_col ||
sheet_view->sheet->cursor_row != row) {
sheet_cursor_move (sheet_view->sheet, ss->start_col, row);
sheet_selection_append (sheet_view->sheet, ss->start_col, row);
}
/* NOTE : Excel does not move the cursor, just scrolls the sheet. */
}
return FALSE;
......@@ -521,8 +513,9 @@ sheet_view_construct (SheetView *sheet_view)
GTK_SIGNAL_FUNC (button_select_all), sheet_view);
/* Scroll bars and their adjustments */
sheet_view->va = gtk_adjustment_new (0.0, 0.0, sheet->max_row_used, 1.0, 0.0, 1.0);
sheet_view->ha = gtk_adjustment_new (0.0, 0.0, sheet->max_col_used, 1.0, 0.0, 1.0);
/* FIXME : The step_inc, page_inc, and page_size should be related to the page size, not 1 */
sheet_view->va = gtk_adjustment_new (0.0, 0.0, sheet->max_row_used, 1.0, 1.0, 1.0);
sheet_view->ha = gtk_adjustment_new (0.0, 0.0, sheet->max_col_used, 1.0, 1.0, 1.0);
sheet_view->hs = gtk_hscrollbar_new (GTK_ADJUSTMENT (sheet_view->ha));
sheet_view->vs = gtk_vscrollbar_new (GTK_ADJUSTMENT (sheet_view->va));
......@@ -575,7 +568,7 @@ sheet_view_set_header_visibility (SheetView *sheet_view,
}
}
void
static void
sheet_view_scrollbar_display (SheetView *sheet_view,
gboolean show_col_scrollbar,
gboolean show_row_scrollbar)
......
......@@ -293,7 +293,7 @@ sheet_set_zoom_factor (Sheet *sheet, double factor)
/* First, the default styles */
sheet_compute_col_row_new_size (sheet, &sheet->default_row_style, NULL);
sheet_compute_col_row_new_size (sheet, &sheet->default_col_style, NULL);
sheet_compute_col_row_new_size (sheet, &sheet->default_col_style, NULL);
/* Then every column and row */
sheet_foreach_col (sheet, sheet_compute_col_row_new_size, NULL);
......@@ -516,9 +516,9 @@ sheet_row_info_set_height (Sheet *sheet, ColRowInfo *ri, int height, gboolean he
/**
* sheet_row_set_height:
* @sheet: The sheet
* @row: The row
* @height: The desired height
* @sheet: The sheet
* @row: The row
* @height: The desired height
* @height_set_by_user: TRUE if this was done by a user (ie, user manually
* set the width)
*
......@@ -549,9 +549,9 @@ sheet_row_set_height (Sheet *sheet, int row, int height, gboolean height_set_by_
/**
* sheet_row_set_internal_height:
* @sheet: The sheet
* @row: The row
* @height: The desired height
* @sheet: The sheet
* @row: The row
* @height: The desired height
*
* Sets the height of a row in terms of the internal required space (the total
* size of the row will include the margins.
......@@ -1292,7 +1292,7 @@ sheet_select_all (Sheet *sheet)
sheet_selection_reset_only (sheet);
sheet_make_cell_visible (sheet, 0, 0);
sheet_cursor_move (sheet, 0, 0);
sheet_cursor_move (sheet, 0, 0, FALSE, FALSE);
sheet_selection_append_range (sheet, 0, 0, 0, 0,
SHEET_MAX_COLS-1, SHEET_MAX_ROWS-1);
......@@ -2319,10 +2319,10 @@ sheet_cell_foreach_range (Sheet *sheet, int only_existing,
static Value *
fail_if_not_selected (Sheet *sheet, int col, int row, Cell *cell, void *user_data)
{
if (!sheet_selection_is_cell_selected (sheet, col, row))
return value_terminate();
else
return NULL;
if (!sheet_selection_is_cell_selected (sheet, col, row))
return value_terminate();
else
return NULL;
}
/**
......@@ -3762,9 +3762,9 @@ sheet_style_attach (Sheet *sheet, int start_col, int start_row, int end_col, int
/**
* sheet_style_compute:
* @sheet: Which sheet we are looking up
* @col: column
* @row: row
* @sheet: Which sheet we are looking up
* @col: column
* @row: row
* @non_default: A pointer where we store the attributes
* the cell has which are not part of the
* default style.
......@@ -3820,16 +3820,34 @@ sheet_make_cell_visible (Sheet *sheet, int col, int row)
}
}
/**
* sheet_cursor_move:
* @sheet: Which sheet's cursor to move
* @col: destination column
* @row: destination row
* @clear_selection: Clear the old selection if we move.
* @add_dest_to_selection: Add the new cursor location to the
* selection if we move.
*
* Adjusts the cursor location for the specified sheet, optionaly
* clearing the old selection and adding the new cursor to the selection.
* Be careful when manging the selection when the 'move' returns to the
* current location.
*/
void
sheet_cursor_move (Sheet *sheet, int col, int row)
sheet_cursor_move (Sheet *sheet, int col, int row,
gboolean clear_selection, gboolean add_dest_to_selection)
{
GList *l;
int old_row, old_col;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
sheet_accept_pending_input (sheet);
old_row = sheet->cursor_col;
old_col = sheet->cursor_row;
sheet->cursor_col = col;
sheet->cursor_row = row;
......@@ -3840,6 +3858,13 @@ sheet_cursor_move (Sheet *sheet, int col, int row)
gnumeric_sheet_set_cursor_bounds (gsheet, col, row, col, row);
}
sheet_load_cell_val (sheet);
if (old_row != row || old_col != col) {
if (clear_selection)
sheet_selection_reset_only (sheet);
if (add_dest_to_selection)
sheet_selection_append (sheet, col, row);
}
}
void
......@@ -3867,13 +3892,12 @@ sheet_cursor_set (Sheet *sheet, int base_col, int base_row, int start_col, int s
end_col, end_row);
}
sheet_load_cell_val (sheet);
}
/**
* sheet_fill_selection_with:
* @sheet: Which sheet we are operating on.
* @str: The text to fill the selection with.
* @sheet: Which sheet we are operating on.
* @str: The text to fill the selection with.
* @is_array: A flag to differentiate between filling and array formulas.
*
* Checks to ensure that none of the ranges being filled contain a subset of
......
......@@ -163,7 +163,8 @@ void sheet_cursor_set (Sheet *sheet,
int base_col, int base_row,
int start_col, int start_row,
int end_col, int end_row);
void sheet_cursor_move (Sheet *sheet, int col, int row);
void sheet_cursor_move (Sheet *sheet, int col, int row,
gboolean clear_selection, gboolean add_dest_to_selection);
void sheet_make_cell_visible (Sheet *sheet, int col, int row);
/* Selection management */
......
......@@ -1412,7 +1412,7 @@ workbook_parse_and_jump (Workbook *wb, const char *text)
#endif
sheet_make_cell_visible (sheet, col, row);
sheet_cursor_move (sheet, col, row);
sheet_cursor_move (sheet, col, row, TRUE, TRUE);
return TRUE;
}
}
......
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