From 63064decfdb1fbe3e31ff3d23d59173d26dc8a22 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Thu, 3 Dec 1998 16:10:04 +0000 Subject: [PATCH] New functions to set the sheet top column and row respectively. 1998-12-02 Miguel de Icaza * src/gnumeric-sheet.c (gnumeric_sheet_set_top_row, gnumeric_sheet_set_top_col): New functions to set the sheet top column and row respectively. (gnumeric_sheet_bar_set_top_row, gnumeric_sheet_bar_set_top_col): Renamed from their old names to reflect their actual action. * src/item-cursor.c (item_cursor_autofill_event): Do not pass negative numbers to item_grid_find_col and item_grid_find_row. * src/item-grid.c (item_grid_find_row, item_grid_find_col): Check for possitive numbers. I think the right fix is to accept negative numbers and find the column even if the number is negative instead of this ugly restriction. --- ChangeLog-1999-07-09 | 7 +++++++ ChangeLog-2000-02-23 | 7 +++++++ OChangeLog-1999-07-09 | 7 +++++++ OChangeLog-2000-02-23 | 7 +++++++ src/gnumeric-canvas.c | 38 ++++++++++++++++++++++++++++++++------ src/gnumeric-canvas.h | 4 ++-- src/gnumeric-sheet.c | 38 ++++++++++++++++++++++++++++++++------ src/gnumeric-sheet.h | 4 ++-- src/sheet-control-gui.c | 6 ++++-- src/sheet-view.c | 6 ++++-- 10 files changed, 104 insertions(+), 20 deletions(-) diff --git a/ChangeLog-1999-07-09 b/ChangeLog-1999-07-09 index cae5651a6..3c27438d5 100644 --- a/ChangeLog-1999-07-09 +++ b/ChangeLog-1999-07-09 @@ -1,5 +1,12 @@ 1998-12-02 Miguel de Icaza + * src/gnumeric-sheet.c (gnumeric_sheet_set_top_row, + gnumeric_sheet_set_top_col): New functions to set the sheet top + column and row respectively. + + (gnumeric_sheet_bar_set_top_row, gnumeric_sheet_bar_set_top_col): + Renamed from their old names to reflect their actual action. + * src/item-cursor.c (item_cursor_autofill_event): Do not pass negative numbers to item_grid_find_col and item_grid_find_row. diff --git a/ChangeLog-2000-02-23 b/ChangeLog-2000-02-23 index cae5651a6..3c27438d5 100644 --- a/ChangeLog-2000-02-23 +++ b/ChangeLog-2000-02-23 @@ -1,5 +1,12 @@ 1998-12-02 Miguel de Icaza + * src/gnumeric-sheet.c (gnumeric_sheet_set_top_row, + gnumeric_sheet_set_top_col): New functions to set the sheet top + column and row respectively. + + (gnumeric_sheet_bar_set_top_row, gnumeric_sheet_bar_set_top_col): + Renamed from their old names to reflect their actual action. + * src/item-cursor.c (item_cursor_autofill_event): Do not pass negative numbers to item_grid_find_col and item_grid_find_row. diff --git a/OChangeLog-1999-07-09 b/OChangeLog-1999-07-09 index cae5651a6..3c27438d5 100644 --- a/OChangeLog-1999-07-09 +++ b/OChangeLog-1999-07-09 @@ -1,5 +1,12 @@ 1998-12-02 Miguel de Icaza + * src/gnumeric-sheet.c (gnumeric_sheet_set_top_row, + gnumeric_sheet_set_top_col): New functions to set the sheet top + column and row respectively. + + (gnumeric_sheet_bar_set_top_row, gnumeric_sheet_bar_set_top_col): + Renamed from their old names to reflect their actual action. + * src/item-cursor.c (item_cursor_autofill_event): Do not pass negative numbers to item_grid_find_col and item_grid_find_row. diff --git a/OChangeLog-2000-02-23 b/OChangeLog-2000-02-23 index cae5651a6..3c27438d5 100644 --- a/OChangeLog-2000-02-23 +++ b/OChangeLog-2000-02-23 @@ -1,5 +1,12 @@ 1998-12-02 Miguel de Icaza + * src/gnumeric-sheet.c (gnumeric_sheet_set_top_row, + gnumeric_sheet_set_top_col): New functions to set the sheet top + column and row respectively. + + (gnumeric_sheet_bar_set_top_row, gnumeric_sheet_bar_set_top_col): + Renamed from their old names to reflect their actual action. + * src/item-cursor.c (item_cursor_autofill_event): Do not pass negative numbers to item_grid_find_col and item_grid_find_row. diff --git a/src/gnumeric-canvas.c b/src/gnumeric-canvas.c index 62457f9a1..551befcb7 100644 --- a/src/gnumeric-canvas.c +++ b/src/gnumeric-canvas.c @@ -991,8 +991,8 @@ gnumeric_sheet_compute_visible_ranges (GnumericSheet *gsheet) } while (pixels < canvas->height); } -int -gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_top_row) +static int +gnumeric_sheet_bar_set_top_row (GnumericSheet *gsheet, int new_top_row) { GnomeCanvas *rowc; Sheet *sheet; @@ -1013,8 +1013,21 @@ gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_top_row) return row_distance; } -int -gnumeric_sheet_set_top_col (GnumericSheet *gsheet, int new_top_col) +void +gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_top_row) +{ + int distance, x; + + g_return_if_fail (gsheet != NULL); + g_return_if_fail (new_top_row >= 0 && new_top_row <= SHEET_MAX_ROWS-1); + + distance = gnumeric_sheet_bar_set_top_row (gsheet, new_top_row); + gnome_canvas_get_scroll_offsets (GNOME_CANVAS (gsheet), &x, NULL); + gnome_canvas_scroll_to (GNOME_CANVAS (gsheet), x, distance); +} + +static int +gnumeric_sheet_bar_set_top_col (GnumericSheet *gsheet, int new_top_col) { GnomeCanvas *colc; Sheet *sheet; @@ -1036,6 +1049,19 @@ gnumeric_sheet_set_top_col (GnumericSheet *gsheet, int new_top_col) return col_distance; } +void +gnumeric_sheet_set_top_col (GnumericSheet *gsheet, int new_top_col) +{ + int distance, y; + + g_return_if_fail (gsheet != NULL); + g_return_if_fail (new_top_col >= 0 && new_top_col <= SHEET_MAX_COLS-1); + + distance = gnumeric_sheet_bar_set_top_col (gsheet, new_top_col); + gnome_canvas_get_scroll_offsets (GNOME_CANVAS (gsheet), NULL, &y); + gnome_canvas_scroll_to (GNOME_CANVAS (gsheet), distance, y); +} + void gnumeric_sheet_make_cell_visible (GnumericSheet *gsheet, int col, int row) { @@ -1100,12 +1126,12 @@ gnumeric_sheet_make_cell_visible (GnumericSheet *gsheet, int col, int row) gnome_canvas_get_scroll_offsets (GNOME_CANVAS (gsheet), &col_distance, &row_distance); if (gsheet->top_col != new_top_col){ - col_distance = gnumeric_sheet_set_top_col (gsheet, new_top_col); + col_distance = gnumeric_sheet_bar_set_top_col (gsheet, new_top_col); did_change = 1; } if (gsheet->top_row != new_top_row){ - row_distance = gnumeric_sheet_set_top_row (gsheet, new_top_row); + row_distance = gnumeric_sheet_bar_set_top_row (gsheet, new_top_row); did_change = 1; } diff --git a/src/gnumeric-canvas.h b/src/gnumeric-canvas.h index eac9a6aed..6c733fe2c 100644 --- a/src/gnumeric-canvas.h +++ b/src/gnumeric-canvas.h @@ -59,8 +59,8 @@ GtkType gnumeric_sheet_get_type (void); GtkWidget *gnumeric_sheet_new (SheetView *sheet, ItemBar *colbar, ItemBar *rowbar); void gnumeric_sheet_set_selection (GnumericSheet *gsheet, SheetSelection *ss); -int gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_top_row); -int gnumeric_sheet_set_top_col (GnumericSheet *gsheet, int new_top_col); +void gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_top_row); +void gnumeric_sheet_set_top_col (GnumericSheet *gsheet, int new_top_col); void gnumeric_sheet_cursor_set (GnumericSheet *gsheet, int col, int row); void gnumeric_sheet_move_cursor (GnumericSheet *gsheet, diff --git a/src/gnumeric-sheet.c b/src/gnumeric-sheet.c index 62457f9a1..551befcb7 100644 --- a/src/gnumeric-sheet.c +++ b/src/gnumeric-sheet.c @@ -991,8 +991,8 @@ gnumeric_sheet_compute_visible_ranges (GnumericSheet *gsheet) } while (pixels < canvas->height); } -int -gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_top_row) +static int +gnumeric_sheet_bar_set_top_row (GnumericSheet *gsheet, int new_top_row) { GnomeCanvas *rowc; Sheet *sheet; @@ -1013,8 +1013,21 @@ gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_top_row) return row_distance; } -int -gnumeric_sheet_set_top_col (GnumericSheet *gsheet, int new_top_col) +void +gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_top_row) +{ + int distance, x; + + g_return_if_fail (gsheet != NULL); + g_return_if_fail (new_top_row >= 0 && new_top_row <= SHEET_MAX_ROWS-1); + + distance = gnumeric_sheet_bar_set_top_row (gsheet, new_top_row); + gnome_canvas_get_scroll_offsets (GNOME_CANVAS (gsheet), &x, NULL); + gnome_canvas_scroll_to (GNOME_CANVAS (gsheet), x, distance); +} + +static int +gnumeric_sheet_bar_set_top_col (GnumericSheet *gsheet, int new_top_col) { GnomeCanvas *colc; Sheet *sheet; @@ -1036,6 +1049,19 @@ gnumeric_sheet_set_top_col (GnumericSheet *gsheet, int new_top_col) return col_distance; } +void +gnumeric_sheet_set_top_col (GnumericSheet *gsheet, int new_top_col) +{ + int distance, y; + + g_return_if_fail (gsheet != NULL); + g_return_if_fail (new_top_col >= 0 && new_top_col <= SHEET_MAX_COLS-1); + + distance = gnumeric_sheet_bar_set_top_col (gsheet, new_top_col); + gnome_canvas_get_scroll_offsets (GNOME_CANVAS (gsheet), NULL, &y); + gnome_canvas_scroll_to (GNOME_CANVAS (gsheet), distance, y); +} + void gnumeric_sheet_make_cell_visible (GnumericSheet *gsheet, int col, int row) { @@ -1100,12 +1126,12 @@ gnumeric_sheet_make_cell_visible (GnumericSheet *gsheet, int col, int row) gnome_canvas_get_scroll_offsets (GNOME_CANVAS (gsheet), &col_distance, &row_distance); if (gsheet->top_col != new_top_col){ - col_distance = gnumeric_sheet_set_top_col (gsheet, new_top_col); + col_distance = gnumeric_sheet_bar_set_top_col (gsheet, new_top_col); did_change = 1; } if (gsheet->top_row != new_top_row){ - row_distance = gnumeric_sheet_set_top_row (gsheet, new_top_row); + row_distance = gnumeric_sheet_bar_set_top_row (gsheet, new_top_row); did_change = 1; } diff --git a/src/gnumeric-sheet.h b/src/gnumeric-sheet.h index eac9a6aed..6c733fe2c 100644 --- a/src/gnumeric-sheet.h +++ b/src/gnumeric-sheet.h @@ -59,8 +59,8 @@ GtkType gnumeric_sheet_get_type (void); GtkWidget *gnumeric_sheet_new (SheetView *sheet, ItemBar *colbar, ItemBar *rowbar); void gnumeric_sheet_set_selection (GnumericSheet *gsheet, SheetSelection *ss); -int gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_top_row); -int gnumeric_sheet_set_top_col (GnumericSheet *gsheet, int new_top_col); +void gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_top_row); +void gnumeric_sheet_set_top_col (GnumericSheet *gsheet, int new_top_col); void gnumeric_sheet_cursor_set (GnumericSheet *gsheet, int col, int row); void gnumeric_sheet_move_cursor (GnumericSheet *gsheet, diff --git a/src/sheet-control-gui.c b/src/sheet-control-gui.c index de332f9c8..2ebb24ef6 100644 --- a/src/sheet-control-gui.c +++ b/src/sheet-control-gui.c @@ -387,7 +387,7 @@ horizontal_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet { GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view); SheetSelection *ss = sheet_view->sheet->selections->data; - int col; + int col, distance; gtk_widget_destroy (gtk_widget_get_toplevel (sheet_view->tip)); sheet_view->tip = NULL; @@ -396,6 +396,7 @@ horizontal_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet gnumeric_sheet_set_top_col (gsheet, col); sheet_cursor_move (sheet_view->sheet, col, ss->start_row); + sheet_selection_append (sheet_view->sheet, col, ss->start_row); } return FALSE; @@ -414,7 +415,7 @@ vertical_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet_v { GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view); SheetSelection *ss = sheet_view->sheet->selections->data; - int row; + int row, distance; gtk_widget_destroy (gtk_widget_get_toplevel (sheet_view->tip)); sheet_view->tip = NULL; @@ -423,6 +424,7 @@ vertical_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet_v gnumeric_sheet_set_top_row (gsheet, row); sheet_cursor_move (sheet_view->sheet, ss->start_col, row); + sheet_selection_append (sheet_view->sheet, ss->start_col, row); } return FALSE; diff --git a/src/sheet-view.c b/src/sheet-view.c index de332f9c8..2ebb24ef6 100644 --- a/src/sheet-view.c +++ b/src/sheet-view.c @@ -387,7 +387,7 @@ horizontal_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet { GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view); SheetSelection *ss = sheet_view->sheet->selections->data; - int col; + int col, distance; gtk_widget_destroy (gtk_widget_get_toplevel (sheet_view->tip)); sheet_view->tip = NULL; @@ -396,6 +396,7 @@ horizontal_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet gnumeric_sheet_set_top_col (gsheet, col); sheet_cursor_move (sheet_view->sheet, col, ss->start_row); + sheet_selection_append (sheet_view->sheet, col, ss->start_row); } return FALSE; @@ -414,7 +415,7 @@ vertical_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet_v { GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view); SheetSelection *ss = sheet_view->sheet->selections->data; - int row; + int row, distance; gtk_widget_destroy (gtk_widget_get_toplevel (sheet_view->tip)); sheet_view->tip = NULL; @@ -423,6 +424,7 @@ vertical_scroll_event (GtkScrollbar *scroll, GdkEvent *event, SheetView *sheet_v gnumeric_sheet_set_top_row (gsheet, row); sheet_cursor_move (sheet_view->sheet, ss->start_col, row); + sheet_selection_append (sheet_view->sheet, ss->start_col, row); } return FALSE; -- GitLab