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.
Release Critical
----------------
- col/row resize when zoomed
- Performance regression: navigating and (say) selecting an area in,
for example, statfuns.xls takes an embarrassingly long time.
......
......@@ -24,11 +24,16 @@ Jody:
* Support fractions.
* Fix printing of borders.
* Improve checking for array/merged region division.
* Prep for frozen panes.
Jon Kåre:
* New architecture for selecting cell ranges into dialogs.
* Fix dialog placement.
Juan Pablo Mendoza:
* Improve col and row sizing when cloning a cell.
* Catch many bugs with merged regions.
Morten:
* Changed a large number of dirty diapers.
* 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>
* Release 0.64
......
......@@ -76,7 +76,7 @@ string_from_exception ()
if (!svalue)
goto cleanup;
if (pos + 3 < sizeof buf)
if (pos + 3 < (int)sizeof(buf))
snprintf (buf + pos , sizeof buf - pos , ": %s",
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>
* dialog-cell-sort.c (order_box_get_text, string_pos_in_list):
......
......@@ -10,15 +10,11 @@
#include <gnome.h>
#include <glade/glade.h>
#include "gnumeric.h"
#include "gnumeric-util.h"
#include "func-util.h"
#include "gnumeric-sheet.h"
#include "dialogs.h"
#include "workbook.h"
#include "workbook-control.h"
#include "func.h"
#include "sheet.h"
#include "cell.h"
#include "ranges.h"
#include "func-util.h"
#include "gnumeric-util.h"
#include "analysis-tools.h"
#define OK 0
......
/* vim: set sw=8: */
/*
* The Gnumeric Sheet widget.
*
......@@ -44,290 +45,6 @@ gnumeric_sheet_destroy (GtkObject *object)
(*GTK_OBJECT_CLASS (gsheet_parent_class)->destroy)(object);
}
void
gnumeric_sheet_set_cursor_bounds (GnumericSheet *gsheet,
int start_col, int start_row,
int end_col, int end_row)
{
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
item_cursor_set_bounds (
gsheet->item_cursor,
start_col, start_row,
end_col, end_row);
}
/*
* gnumeric_sheet_can_select_expr_range
* @gsheet: the object
*
* Returns true if the cursor keys should be used to select
* a cell range (if the cursor is in a spot in the expression
* where it makes sense to have a cell reference), false if not.
*/
gboolean
gnumeric_sheet_can_select_expr_range (GnumericSheet *gsheet)
{
WorkbookControlGUI const *wbcg;
g_return_val_if_fail (GNUMERIC_IS_SHEET (gsheet), FALSE);
wbcg = gsheet->scg->wbcg;
if (workbook_edit_entry_redirect_p (wbcg))
return TRUE;
if (!wbcg->editing)
return FALSE;
if (gsheet->selecting_cell)
return TRUE;
return workbook_editing_expr (wbcg);
}
static void
start_range_selection_at (GnumericSheet *gsheet, int col, int row)
{
GnomeCanvas *canvas = GNOME_CANVAS (gsheet);
GnomeCanvasItem *tmp;
GnomeCanvasGroup *group = GNOME_CANVAS_GROUP (canvas->root);
Sheet *sheet = gsheet->scg->sheet;
WorkbookControlGUI *wbcg = gsheet->scg->wbcg;
g_return_if_fail (gsheet->selecting_cell == FALSE);
/* Hide the primary cursor while the range selection cursor is visible
* and we are selecting on a different sheet than the expr being edited
*/
if (sheet != wb_control_cur_sheet (WORKBOOK_CONTROL (wbcg)))
item_cursor_set_visibility (gsheet->item_cursor, FALSE);
gsheet->selecting_cell = TRUE;
tmp = gnome_canvas_item_new (group,
item_cursor_get_type (),
"SheetControlGUI", gsheet->scg,
"Style", ITEM_CURSOR_ANTED, NULL);
gsheet->sel_cursor = ITEM_CURSOR (tmp);
item_cursor_set_bounds (gsheet->sel_cursor, col, row, col, row);
/* If we are selecting a range on a different sheet this may be NULL */
if (gsheet->item_editor)
item_edit_disable_highlight (ITEM_EDIT (gsheet->item_editor));
gsheet->sel_cursor_pos = GTK_EDITABLE (workbook_get_entry_logical (wbcg))->current_pos;
gsheet->sel_text_len = 0;
}
static void
start_range_selection (GnumericSheet *gsheet)
{
Sheet *sheet = gsheet->scg->sheet;
start_range_selection_at (gsheet,
sheet->edit_pos_real.col,
sheet->edit_pos_real.row);
}
void
gnumeric_sheet_start_range_selection (GnumericSheet *gsheet, int col, int row)
{
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
if (gsheet->selecting_cell)
return;
start_range_selection_at (gsheet, col, row);
}
void
gnumeric_sheet_stop_range_selection (GnumericSheet *gsheet)
{
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
if (!gsheet->selecting_cell)
return;
gsheet->selecting_cell = FALSE;
gtk_object_destroy (GTK_OBJECT (gsheet->sel_cursor));
gsheet->sel_cursor = NULL;
/* If we are selecting a range on a different sheet this may be NULL */
if (gsheet->item_editor)
item_edit_enable_highlight (ITEM_EDIT (gsheet->item_editor));
/* Make the primary cursor visible again */
item_cursor_set_visibility (gsheet->item_cursor, TRUE);
}
void
gnumeric_sheet_create_editor (GnumericSheet *gsheet)
{
GnomeCanvas *canvas = GNOME_CANVAS (gsheet);
GnomeCanvasItem *item;
g_return_if_fail (gsheet->item_editor == NULL);
item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (canvas->root),
item_edit_get_type (),
"ItemEdit::SheetControlGUI", gsheet->scg,
NULL);
gsheet->item_editor = ITEM_EDIT (item);
}
void
gnumeric_sheet_stop_editing (GnumericSheet *gsheet)
{
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
if (gsheet->item_editor != NULL) {
gtk_object_destroy (GTK_OBJECT (gsheet->item_editor));
gsheet->item_editor = NULL;
}
}
/**
* gnumeric_sheet_rangesel_cursor_extend :
*
* @gsheet :
* @col :
* @row :
*
* Extend the range selection cursor. If col < 0 then extend to full
*/
void
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);
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;
item_cursor_set_bounds (ic, base_col, base_row, col, row);
}
/*
* Invoked by Item-Grid to place the selection cursor on a specific
* spot.
*/
void
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);
ic = gsheet->sel_cursor;
item_cursor_set_bounds (ic, base_col, base_row, move_col, move_row);
}
void
gnumeric_sheet_rangesel_horizontal_move (GnumericSheet *gsheet, int dir,
gboolean jump_to_boundaries)
{
ItemCursor *ic;
int col, row;
g_return_if_fail (dir == -1 || dir == 1);
if (!gsheet->selecting_cell)
start_range_selection (gsheet);
ic = gsheet->sel_cursor;
row = ic->base_corner.row;
col = sheet_find_boundary_horizontal (gsheet->scg->sheet,
ic->base_corner.col, row, row, dir, jump_to_boundaries);
item_cursor_set_bounds (ic, col, row, col, row);
gnumeric_sheet_make_cell_visible (gsheet, col, row, FALSE);
}
void
gnumeric_sheet_rangesel_vertical_move (GnumericSheet *gsheet, int dir,
gboolean jump_to_boundaries)
{
ItemCursor *ic;
int col, row;
g_return_if_fail (dir == -1 || dir == 1);
if (!gsheet->selecting_cell)
start_range_selection (gsheet);
ic = gsheet->sel_cursor;
col = ic->base_corner.col;
row = sheet_find_boundary_vertical (gsheet->scg->sheet,
col, ic->base_corner.row, col, dir, jump_to_boundaries);
item_cursor_set_bounds (ic, col, row, col, row);
gnumeric_sheet_make_cell_visible (gsheet, col, row, FALSE);
}
void
gnumeric_sheet_rangesel_horizontal_extend (GnumericSheet *gsheet, int n,
gboolean jump_to_boundaries)
{
ItemCursor *ic;
int new_col;
g_return_if_fail (n == -1 || n == 1);
if (!gsheet->selecting_cell) {
scg_rangesel_horizontal_move (gsheet->scg, n,
jump_to_boundaries);
return;
}
ic = gsheet->sel_cursor;
new_col = sheet_find_boundary_horizontal (gsheet->scg->sheet,
ic->move_corner.col, ic->move_corner.row,
ic->base_corner.row, n, jump_to_boundaries);
item_cursor_set_bounds (ic,
ic->base_corner.col, ic->base_corner.row,
new_col, ic->move_corner.row);
gnumeric_sheet_make_cell_visible (gsheet,
ic->move_corner.col, ic->move_corner.row, FALSE);
}
void
gnumeric_sheet_rangesel_vertical_extend (GnumericSheet *gsheet, int n,
gboolean jump_to_boundaries)
{
ItemCursor *ic;
int new_row;
g_return_if_fail (n == -1 || n == 1);
if (!gsheet->selecting_cell) {
scg_rangesel_vertical_move (gsheet->scg, n,
jump_to_boundaries);
return;
}
ic = gsheet->sel_cursor;
new_row = sheet_find_boundary_vertical (gsheet->scg->sheet,
ic->move_corner.col, ic->move_corner.row,
ic->base_corner.col, n, jump_to_boundaries);
item_cursor_set_bounds (ic,
ic->base_corner.col, ic->base_corner.row,
ic->move_corner.col, new_row);
gnumeric_sheet_make_cell_visible (gsheet,
ic->move_corner.col, ic->move_corner.row, FALSE);
}
/*
* key press event handler for the gnumeric sheet for the sheet mode
*/
......@@ -347,10 +64,8 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
(event->state & (GDK_SHIFT_MASK|GDK_CONTROL_MASK)))
return FALSE;
if (gnumeric_sheet_can_select_expr_range (gsheet)) {
/* Ignore a few keys (to avoid the selection cursor to be
* killed in some cases
*/
if (scg_rangesel_possible (gsheet->scg)) {
/* Ignore a few keys to avoid killing range selection cursor */
switch (event->keyval) {
case GDK_Shift_L: case GDK_Shift_R:
case GDK_Alt_L: case GDK_Alt_R:
......@@ -359,19 +74,19 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
}
if (event->state & GDK_SHIFT_MASK) {
movefn_horizontal = scg_rangesel_horizontal_extend;
movefn_vertical = scg_rangesel_vertical_extend;
movefn_horizontal = scg_rangesel_extend_h;
movefn_vertical = scg_rangesel_extend_v;
} else {
movefn_horizontal = scg_rangesel_horizontal_move;
movefn_vertical = scg_rangesel_vertical_move;
movefn_horizontal = scg_rangesel_move_h;
movefn_vertical = scg_rangesel_move_v;
}
} else {
if (event->state & GDK_SHIFT_MASK) {
movefn_horizontal = scg_cursor_horizontal_extend;
movefn_vertical = scg_cursor_vertical_extend;
movefn_horizontal = scg_cursor_extend_h;
movefn_vertical = scg_cursor_extend_v;
} else {
movefn_horizontal = scg_cursor_horizontal_move;
movefn_vertical = scg_cursor_vertical_move;
movefn_horizontal = scg_cursor_move_h;
movefn_vertical = scg_cursor_move_v;
}
}
......@@ -431,7 +146,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
case GDK_KP_Home:
case GDK_Home:
if ((event->state & GDK_CONTROL_MASK) != 0)
scg_move_cursor (gsheet->scg, 0, 0, TRUE);
scg_cursor_move (gsheet->scg, 0, 0, TRUE);
else
(*movefn_horizontal)(
gsheet->scg, -sheet->edit_pos.col, FALSE);
......@@ -502,7 +217,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
workbook_start_editing_at_cursor (wbcg, TRUE, TRUE);
}
scg_stop_range_selection (gsheet->scg, FALSE);
scg_rangesel_stop (gsheet->scg, FALSE);
/* Forward the keystroke to the input line */
return gtk_widget_event (GTK_WIDGET (workbook_get_entry_logical (wbcg)),
......@@ -699,66 +414,6 @@ gnumeric_sheet_filenames_dropped (GtkWidget *widget,
}
}
GtkWidget *
gnumeric_sheet_new (SheetControlGUI *scg)
{
static GtkTargetEntry const drag_types[] = {
{ "text/uri-list", 0, 0 },
};
static gint const n_drag_types = sizeof (drag_types) / sizeof (drag_types [0]);
GnomeCanvasItem *item;
GnumericSheet *gsheet;
GnomeCanvasGroup *gsheet_group;
GtkWidget *widget;
g_return_val_if_fail (IS_SHEET_CONTROL_GUI (scg), NULL);
gsheet = gtk_type_new (gnumeric_sheet_get_type ());
gsheet_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (gsheet)->root);
widget = GTK_WIDGET (gsheet);
gsheet->scg = scg;
gsheet->row.first = gsheet->row.last_full = gsheet->row.last_visible = 0;
gsheet->col.first = gsheet->col.last_full = gsheet->col.last_visible = 0;
gsheet->row_offset.first = gsheet->row_offset.last_full = gsheet->row_offset.last_visible = 0;
gsheet->col_offset.first = gsheet->col_offset.last_full = gsheet->col_offset.last_visible = 0;
/* FIXME: figure out some real size for the canvas scrolling region */
gnome_canvas_set_scroll_region (GNOME_CANVAS (gsheet), 0, 0,
GNUMERIC_SHEET_FACTOR_X, GNUMERIC_SHEET_FACTOR_Y);
/* The grid */
item = gnome_canvas_item_new (gsheet_group,
item_grid_get_type (),
"ItemGrid::SheetControlGUI", scg,
NULL);
gsheet->item_grid = ITEM_GRID (item);
/* The cursor */
item = gnome_canvas_item_new (gsheet_group,
item_cursor_get_type (),
"ItemCursor::SheetControlGUI", scg,
NULL);
gsheet->item_cursor = ITEM_CURSOR (item);
item_cursor_set_bounds (gsheet->item_cursor, 0, 0, 0, 0); /* A1 */
/* Setup a test of Drag and Drop */
gtk_signal_connect (GTK_OBJECT (widget),
"drag_data_get",
GTK_SIGNAL_FUNC (gnumeric_sheet_drag_data_get), NULL);
gtk_drag_dest_set (widget,
GTK_DEST_DEFAULT_ALL,
drag_types, n_drag_types,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (widget),
"drag_data_received",
GTK_SIGNAL_FUNC (gnumeric_sheet_filenames_dropped),
widget);
return widget;
}
static void
gnumeric_sheet_realize (GtkWidget *widget)
{
......@@ -820,45 +475,442 @@ gnumeric_sheet_unrealize (GtkWidget *widget)
(*GTK_WIDGET_CLASS (gsheet_parent_class)->unrealize)(widget);
}
/*
* gsheet_compute_visible_region : Keeps the top left col/row the same and
* recalculates the visible boundaries.
*
* @full_recompute :
* if TRUE recompute the pixel offsets of the top left row/col
* else assumes that the pixel offsets of the top left have not changed.
*/
void
gsheet_compute_visible_region (GnumericSheet *gsheet,
gboolean const full_recompute)
static void
gnumeric_sheet_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
SheetControlGUI const * const scg = gsheet->scg;
Sheet const * const sheet = scg->sheet;
GnomeCanvas *canvas = GNOME_CANVAS (gsheet);
int pixels, col, row, width, height;
/* When col/row sizes change we need to do a full recompute */
if (full_recompute) {
gsheet->col_offset.first =
scg_colrow_distance_get (scg, TRUE, 0, gsheet->col.first);
gnome_canvas_scroll_to (scg->col_item->canvas,
gsheet->col_offset.first, 0);
gsheet->row_offset.first =
scg_colrow_distance_get (scg, FALSE, 0, gsheet->row.first);
gnome_canvas_scroll_to (scg->row_item->canvas,
0, gsheet->row_offset.first);
(*GTK_WIDGET_CLASS (gsheet_parent_class)->size_allocate)(widget, allocation);
gnome_canvas_scroll_to (GNOME_CANVAS (gsheet),
gsheet->col_offset.first,
gsheet->row_offset.first);
}
gsheet_compute_visible_region (GNUMERIC_SHEET (widget), FALSE);
}
/* Find out the last visible col and the last full visible column */
pixels = 0;
col = gsheet->col.first;
width = GTK_WIDGET (canvas)->allocation.width;
typedef struct {
GnomeCanvasClass parent_class;
} GnumericSheetClass;
do {
static void
gnumeric_sheet_class_init (GnumericSheetClass *Class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GnomeCanvasClass *canvas_class;
object_class = (GtkObjectClass *) Class;
widget_class = (GtkWidgetClass *) Class;
canvas_class = (GnomeCanvasClass *) Class;
gsheet_parent_class = gtk_type_class (gnome_canvas_get_type ());
/* Method override */
object_class->destroy = gnumeric_sheet_destroy;
widget_class->realize = gnumeric_sheet_realize;
widget_class->unrealize = gnumeric_sheet_unrealize;
widget_class->size_allocate = gnumeric_sheet_size_allocate;
widget_class->key_press_event = gnumeric_sheet_key_press;
widget_class->key_release_event = gnumeric_sheet_key_release;
widget_class->button_release_event = gnumeric_sheet_button_release;
widget_class->focus_in_event = gnumeric_sheet_focus_in;
widget_class->focus_out_event = gnumeric_sheet_focus_out;
}
static void
gnumeric_sheet_init (GnumericSheet *gsheet)
{
GnomeCanvas *canvas = GNOME_CANVAS (gsheet);
gsheet->ic = NULL;
gsheet->ic_attr = NULL;
GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS);
GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_DEFAULT);
}
GtkType
gnumeric_sheet_get_type (void)
{
static GtkType gnumeric_sheet_type = 0;
if (!gnumeric_sheet_type) {
GtkTypeInfo gnumeric_sheet_info = {
"GnumericSheet",
sizeof (GnumericSheet),
sizeof (GnumericSheetClass),
(GtkClassInitFunc) gnumeric_sheet_class_init,
(GtkObjectInitFunc) gnumeric_sheet_init,
NULL, /* reserved 1 */
NULL, /* reserved 2 */
(GtkClassInitFunc) NULL
};
gnumeric_sheet_type = gtk_type_unique (gnome_canvas_get_type (), &gnumeric_sheet_info);
}
return gnumeric_sheet_type;
}
GtkWidget *
gnumeric_sheet_new (SheetControlGUI *scg)
{
static GtkTargetEntry const drag_types[] = {
{ "text/uri-list", 0, 0 },
};
static gint const n_drag_types = sizeof (drag_types) / sizeof (drag_types [0]);
GnomeCanvasItem *item;
GnumericSheet *gsheet;
GnomeCanvasGroup *gsheet_group;
GtkWidget *widget;
Range r;
g_return_val_if_fail (IS_SHEET_CONTROL_GUI (scg), NULL);
gsheet = gtk_type_new (gnumeric_sheet_get_type ());
gsheet_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (gsheet)->root);
widget = GTK_WIDGET (gsheet);
gsheet->scg = scg;
gsheet->row.first = gsheet->row.last_full = gsheet->row.last_visible = 0;
gsheet->col.first = gsheet->col.last_full = gsheet->col.last_visible = 0;
gsheet->row_offset.first = gsheet->row_offset.last_full = gsheet->row_offset.last_visible = 0;
gsheet->col_offset.first = gsheet->col_offset.last_full = gsheet->col_offset.last_visible = 0;
/* FIXME: figure out some real size for the canvas scrolling region */
gnome_canvas_set_scroll_region (GNOME_CANVAS (gsheet), 0, 0,
GNUMERIC_SHEET_FACTOR_X, GNUMERIC_SHEET_FACTOR_Y);
/* The grid */
item = gnome_canvas_item_new (gsheet_group,
item_grid_get_type (),
"ItemGrid::SheetControlGUI", scg,
NULL);
gsheet->item_grid = ITEM_GRID (item);
/* The cursor */
item = gnome_canvas_item_new (gsheet_group,
item_cursor_get_type (),
"ItemCursor::SheetControlGUI", scg,
NULL);
gsheet->item_cursor = ITEM_CURSOR (item);
gnumeric_sheet_cursor_bound (gsheet, range_init (&r, 0, 0, 0, 0)); /* A1 */
/* Setup a test of Drag and Drop */
gtk_signal_connect (GTK_OBJECT (widget),
"drag_data_get",
GTK_SIGNAL_FUNC (gnumeric_sheet_drag_data_get), NULL);
gtk_drag_dest_set (widget,
GTK_DEST_DEFAULT_ALL,
drag_types, n_drag_types,
GDK_ACTION_COPY);
gtk_signal_connect (GTK_OBJECT (widget),
"drag_data_received",
GTK_SIGNAL_FUNC (gnumeric_sheet_filenames_dropped),
widget);
return widget;
}
static int
gnumeric_sheet_bar_set_top_row (GnumericSheet *gsheet, int new_first_row)
{
GnomeCanvas *rowc;
int row_offset;
int x;
g_return_val_if_fail (gsheet != NULL, 0);
g_return_val_if_fail (gsheet->item_grid != NULL, 0);
g_return_val_if_fail (0 <= new_first_row && new_first_row < SHEET_MAX_ROWS, 0);
rowc = gsheet->scg->row_item->canvas;
row_offset = gsheet->row_offset.first +=
scg_colrow_distance_get (gsheet->scg, FALSE, gsheet->row.first, new_first_row);
gsheet->row.first = new_first_row;
/* Scroll the row headers */
gnome_canvas_get_scroll_offsets (rowc, &x, NULL);
gnome_canvas_scroll_to (rowc, x, row_offset);
return row_offset;
}
void
gnumeric_sheet_set_top_row (GnumericSheet *gsheet, int new_first_row)
{
g_return_if_fail (gsheet != NULL);
g_return_if_fail (0 <= new_first_row && new_first_row < SHEET_MAX_ROWS);
if (gsheet->row.first != new_first_row) {
int x;
GnomeCanvas * const canvas = GNOME_CANVAS(gsheet);
int const y_offset =
gnumeric_sheet_bar_set_top_row (gsheet, new_first_row);
gsheet_compute_visible_region (gsheet, FALSE);
/* Scroll the cell canvas */
gnome_canvas_get_scroll_offsets (canvas, &x, NULL);
gnome_canvas_scroll_to (canvas, x, y_offset);
}
}
static int
gnumeric_sheet_bar_set_left_col (GnumericSheet *gsheet, int new_first_col)
{
GnomeCanvas *colc;
int col_offset;
int y;
g_return_val_if_fail (gsheet != NULL, 0);
g_return_val_if_fail (gsheet->item_grid != NULL, 0);
g_return_val_if_fail (0 <= new_first_col && new_first_col < SHEET_MAX_COLS, 0);
colc = gsheet->scg->col_item->canvas;
col_offset = gsheet->col_offset.first +=
scg_colrow_distance_get (gsheet->scg, TRUE, gsheet->col.first, new_first_col);
gsheet->col.first = new_first_col;
/* Scroll the column headers */
gnome_canvas_get_scroll_offsets (colc, NULL, &y);
gnome_canvas_scroll_to (colc, col_offset, y);
return col_offset;
}
void
gnumeric_sheet_set_left_col (GnumericSheet *gsheet, int new_first_col)