Commit 63064dec authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

New functions to set the sheet top column and row respectively.

1998-12-02  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* 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.
parent 05c897f5
1998-12-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
* 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.
......
1998-12-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
* 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.
......
1998-12-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
* 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.
......
1998-12-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
* 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.
......
......@@ -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;
}
......
......@@ -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,
......
......@@ -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;
}
......
......@@ -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,
......
......@@ -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;
......
......@@ -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;
......
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