Commit ddc5bfd2 authored by Morten Welinder's avatar Morten Welinder

Fix scrolling bug. Minor cleanup of new root finder.

Fix scrolling bug.
Minor cleanup of new root finder.
parent 596d0c11
1999-05-23 Morten Welinder <terra@diku.dk>
* src/gnumeric-sheet.c (gnumeric_sheet_cursor_set): Make the
scroll bar reflect the top-left corner's position. This feels
more natural.
(gnumeric_sheet_set_top_col): Compute visible ranges; do nothing
until things change.
(gnumeric_sheet_set_top_row): Ditto.
* src/dialog-goal-seek.c (gnumeric_goal_seek): Use
goal_seek_initialise.
(gnumeric_goal_seek): Trawl heavier and earlier in the middle.
(dialog_goal_seek): downcase a stray uppercase letter.
* src/goal-seek.c (goal_seek_initialise): New function.
1999-05-23 Morten Welinder <terra@diku.dk>
* src/dialog-goal-seek.c: redesign non-gui part.
......
1999-05-23 Morten Welinder <terra@diku.dk>
* src/gnumeric-sheet.c (gnumeric_sheet_cursor_set): Make the
scroll bar reflect the top-left corner's position. This feels
more natural.
(gnumeric_sheet_set_top_col): Compute visible ranges; do nothing
until things change.
(gnumeric_sheet_set_top_row): Ditto.
* src/dialog-goal-seek.c (gnumeric_goal_seek): Use
goal_seek_initialise.
(gnumeric_goal_seek): Trawl heavier and earlier in the middle.
(dialog_goal_seek): downcase a stray uppercase letter.
* src/goal-seek.c (goal_seek_initialise): New function.
1999-05-23 Morten Welinder <terra@diku.dk>
* src/dialog-goal-seek.c: redesign non-gui part.
......
1999-05-23 Morten Welinder <terra@diku.dk>
* src/gnumeric-sheet.c (gnumeric_sheet_cursor_set): Make the
scroll bar reflect the top-left corner's position. This feels
more natural.
(gnumeric_sheet_set_top_col): Compute visible ranges; do nothing
until things change.
(gnumeric_sheet_set_top_row): Ditto.
* src/dialog-goal-seek.c (gnumeric_goal_seek): Use
goal_seek_initialise.
(gnumeric_goal_seek): Trawl heavier and earlier in the middle.
(dialog_goal_seek): downcase a stray uppercase letter.
* src/goal-seek.c (goal_seek_initialise): New function.
1999-05-23 Morten Welinder <terra@diku.dk>
* src/dialog-goal-seek.c: redesign non-gui part.
......
1999-05-23 Morten Welinder <terra@diku.dk>
* src/gnumeric-sheet.c (gnumeric_sheet_cursor_set): Make the
scroll bar reflect the top-left corner's position. This feels
more natural.
(gnumeric_sheet_set_top_col): Compute visible ranges; do nothing
until things change.
(gnumeric_sheet_set_top_row): Ditto.
* src/dialog-goal-seek.c (gnumeric_goal_seek): Use
goal_seek_initialise.
(gnumeric_goal_seek): Trawl heavier and earlier in the middle.
(dialog_goal_seek): downcase a stray uppercase letter.
* src/goal-seek.c (goal_seek_initialise): New function.
1999-05-23 Morten Welinder <terra@diku.dk>
* src/dialog-goal-seek.c: redesign non-gui part.
......
......@@ -20,7 +20,7 @@
#include "utils.h"
#include "goal-seek.h"
#ifdef HAVE_IEEEFP_H
# include <ieeefp.h>
#include <ieeefp.h>
#endif
#define MAX_CELL_NAME_LEN 20
......@@ -70,10 +70,9 @@ gnumeric_goal_seek (Workbook *wb, Sheet *sheet,
GoalEvalData evaldata;
GoalSeekStatus status;
goal_seek_initialise (&seekdata);
seekdata.xmin = xmin;
seekdata.xmax = xmax;
seekdata.precision = 1e-10;
seekdata.havexpos = seekdata.havexneg = FALSE;
evaldata.xcell = change_cell;
evaldata.ycell = set_cell;
......@@ -105,31 +104,31 @@ gnumeric_goal_seek (Workbook *wb, Sheet *sheet,
goto DONE;
}
/* PLAN C: Trawl normally from left. */
/* PLAN C: Trawl normally from middle. */
{
float_t sigma, mu;
int i;
sigma = seekdata.xmax - seekdata.xmin;
mu = seekdata.xmin;
mu = (seekdata.xmax + seekdata.xmin) / 2;
for (i = 0; i < 5; i++) {
sigma /= 10;
status = goal_seek_trawl_normally (goal_seek_eval,
&seekdata, &evaldata,
mu, sigma, 20);
mu, sigma, 30);
if (status == GOAL_SEEK_OK)
goto DONE;
}
}
/* PLAN D: Trawl normally from right. */
/* PLAN D: Trawl normally from left. */
{
float_t sigma, mu;
int i;
sigma = seekdata.xmax - seekdata.xmin;
mu = seekdata.xmax;
mu = seekdata.xmin;
for (i = 0; i < 5; i++) {
sigma /= 10;
......@@ -141,13 +140,13 @@ gnumeric_goal_seek (Workbook *wb, Sheet *sheet,
}
}
/* PLAN E: Trawl normally from middle. */
/* PLAN E: Trawl normally from right. */
{
float_t sigma, mu;
int i;
sigma = seekdata.xmax - seekdata.xmin;
mu = (seekdata.xmax + seekdata.xmin) / 2;
mu = seekdata.xmax;
for (i = 0; i < 5; i++) {
sigma /= 10;
......@@ -279,17 +278,17 @@ dialog_goal_seek (Workbook *wb, Sheet *sheet)
xmin_entry = gtk_entry_new_with_max_length (MAX_CELL_NAME_LEN);
xmax_entry = gtk_entry_new_with_max_length (MAX_CELL_NAME_LEN);
set_label = gtk_label_new (_("Set Cell:"));
set_label = gtk_label_new (_("Set cell:"));
target_label = gtk_label_new (_("To value:"));
change_label = gtk_label_new (_("By changing cell:"));
xmin_label = gtk_label_new (_("To a value of at least [optional]:"));
xmax_label = gtk_label_new (_("But no bigger than [optional]:"));
gtk_misc_set_alignment (GTK_MISC(set_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC(target_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC(change_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC(xmin_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC(xmax_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC (set_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC (target_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC (change_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC (xmin_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC (xmax_label), 0, 0);
box = gtk_hbox_new (FALSE, 0);
entry_box = gtk_vbox_new (FALSE, 0);
......@@ -312,18 +311,12 @@ dialog_goal_seek (Workbook *wb, Sheet *sheet)
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG
(dialog)->vbox), box);
gtk_entry_set_text(GTK_ENTRY (set_entry), set_entry_str);
gtk_entry_set_position(GTK_ENTRY (set_entry), 0);
gtk_entry_select_region(GTK_ENTRY (set_entry), 0,
GTK_ENTRY(set_entry)->text_length);
gtk_entry_set_text (GTK_ENTRY (set_entry), set_entry_str);
focus_on_entry (set_entry);
gtk_widget_show_all (box);
} else {
gtk_entry_set_text(GTK_ENTRY (set_entry), set_entry_str);
gtk_entry_set_position(GTK_ENTRY (set_entry), 0);
gtk_entry_select_region(GTK_ENTRY (set_entry), 0,
GTK_ENTRY(set_entry)->text_length);
gtk_entry_set_text (GTK_ENTRY (set_entry), set_entry_str);
focus_on_entry (set_entry);
gtk_widget_show (dialog);
}
......
......@@ -20,7 +20,7 @@
#include "utils.h"
#include "goal-seek.h"
#ifdef HAVE_IEEEFP_H
# include <ieeefp.h>
#include <ieeefp.h>
#endif
#define MAX_CELL_NAME_LEN 20
......@@ -70,10 +70,9 @@ gnumeric_goal_seek (Workbook *wb, Sheet *sheet,
GoalEvalData evaldata;
GoalSeekStatus status;
goal_seek_initialise (&seekdata);
seekdata.xmin = xmin;
seekdata.xmax = xmax;
seekdata.precision = 1e-10;
seekdata.havexpos = seekdata.havexneg = FALSE;
evaldata.xcell = change_cell;
evaldata.ycell = set_cell;
......@@ -105,31 +104,31 @@ gnumeric_goal_seek (Workbook *wb, Sheet *sheet,
goto DONE;
}
/* PLAN C: Trawl normally from left. */
/* PLAN C: Trawl normally from middle. */
{
float_t sigma, mu;
int i;
sigma = seekdata.xmax - seekdata.xmin;
mu = seekdata.xmin;
mu = (seekdata.xmax + seekdata.xmin) / 2;
for (i = 0; i < 5; i++) {
sigma /= 10;
status = goal_seek_trawl_normally (goal_seek_eval,
&seekdata, &evaldata,
mu, sigma, 20);
mu, sigma, 30);
if (status == GOAL_SEEK_OK)
goto DONE;
}
}
/* PLAN D: Trawl normally from right. */
/* PLAN D: Trawl normally from left. */
{
float_t sigma, mu;
int i;
sigma = seekdata.xmax - seekdata.xmin;
mu = seekdata.xmax;
mu = seekdata.xmin;
for (i = 0; i < 5; i++) {
sigma /= 10;
......@@ -141,13 +140,13 @@ gnumeric_goal_seek (Workbook *wb, Sheet *sheet,
}
}
/* PLAN E: Trawl normally from middle. */
/* PLAN E: Trawl normally from right. */
{
float_t sigma, mu;
int i;
sigma = seekdata.xmax - seekdata.xmin;
mu = (seekdata.xmax + seekdata.xmin) / 2;
mu = seekdata.xmax;
for (i = 0; i < 5; i++) {
sigma /= 10;
......@@ -279,17 +278,17 @@ dialog_goal_seek (Workbook *wb, Sheet *sheet)
xmin_entry = gtk_entry_new_with_max_length (MAX_CELL_NAME_LEN);
xmax_entry = gtk_entry_new_with_max_length (MAX_CELL_NAME_LEN);
set_label = gtk_label_new (_("Set Cell:"));
set_label = gtk_label_new (_("Set cell:"));
target_label = gtk_label_new (_("To value:"));
change_label = gtk_label_new (_("By changing cell:"));
xmin_label = gtk_label_new (_("To a value of at least [optional]:"));
xmax_label = gtk_label_new (_("But no bigger than [optional]:"));
gtk_misc_set_alignment (GTK_MISC(set_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC(target_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC(change_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC(xmin_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC(xmax_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC (set_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC (target_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC (change_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC (xmin_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC (xmax_label), 0, 0);
box = gtk_hbox_new (FALSE, 0);
entry_box = gtk_vbox_new (FALSE, 0);
......@@ -312,18 +311,12 @@ dialog_goal_seek (Workbook *wb, Sheet *sheet)
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG
(dialog)->vbox), box);
gtk_entry_set_text(GTK_ENTRY (set_entry), set_entry_str);
gtk_entry_set_position(GTK_ENTRY (set_entry), 0);
gtk_entry_select_region(GTK_ENTRY (set_entry), 0,
GTK_ENTRY(set_entry)->text_length);
gtk_entry_set_text (GTK_ENTRY (set_entry), set_entry_str);
focus_on_entry (set_entry);
gtk_widget_show_all (box);
} else {
gtk_entry_set_text(GTK_ENTRY (set_entry), set_entry_str);
gtk_entry_set_position(GTK_ENTRY (set_entry), 0);
gtk_entry_select_region(GTK_ENTRY (set_entry), 0,
GTK_ENTRY(set_entry)->text_length);
gtk_entry_set_text (GTK_ENTRY (set_entry), set_entry_str);
focus_on_entry (set_entry);
gtk_widget_show (dialog);
}
......
......@@ -17,6 +17,8 @@
#include "cursors.h"
#include "utils.h"
#undef DEBUG_POSITIONS
#define CURSOR_COL(gsheet) (gsheet)->sheet_view->sheet->cursor_col
#define CURSOR_ROW(gsheet) (gsheet)->sheet_view->sheet->cursor_row
......@@ -29,7 +31,7 @@ gnumeric_sheet_destroy (GtkObject *object)
/* Add shutdown code here */
gsheet = GNUMERIC_SHEET (object);
if (GTK_OBJECT_CLASS (sheet_parent_class)->destroy)
(*GTK_OBJECT_CLASS (sheet_parent_class)->destroy)(object);
}
......@@ -39,7 +41,7 @@ gnumeric_sheet_create (SheetView *sheet_view, GtkWidget *entry)
{
GnumericSheet *gsheet;
GnomeCanvas *canvas;
gsheet = gtk_type_new (gnumeric_sheet_get_type ());
canvas = GNOME_CANVAS (gsheet);
......@@ -47,7 +49,7 @@ gnumeric_sheet_create (SheetView *sheet_view, GtkWidget *entry)
gsheet->top_col = 0;
gsheet->top_row = 0;
gsheet->entry = entry;
return gsheet;
}
......@@ -55,12 +57,12 @@ void
gnumeric_sheet_get_cell_bounds (GnumericSheet *gsheet, int col, int row, int *x, int *y, int *w, int *h)
{
Sheet *sheet;
g_return_if_fail (gsheet != NULL);
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
sheet = gsheet->sheet_view->sheet;
*x = sheet_col_get_distance (sheet, gsheet->top_col, col);
*y = sheet_row_get_distance (sheet, gsheet->top_row, row);
......@@ -82,7 +84,7 @@ gnumeric_sheet_cursor_set (GnumericSheet *gsheet, int col, int row)
{
GtkAdjustment *ha, *va;
SheetView *sheet_view;
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
sheet_view = gsheet->sheet_view;
......@@ -90,12 +92,23 @@ gnumeric_sheet_cursor_set (GnumericSheet *gsheet, int col, int row)
if (sheet_view->ha){
ha = GTK_ADJUSTMENT (sheet_view->ha);
va = GTK_ADJUSTMENT (sheet_view->va);
ha->value = col;
va->value = row;
ha->value = gsheet->top_col;
va->value = gsheet->top_row;
#ifdef DEBUG_POSITIONS
{
char *top_str = g_strdup (cell_name (gsheet->top_col, gsheet->top_row));
char *lv_str = g_strdup (cell_name (gsheet->last_visible_col, gsheet->last_visible_row));
printf ("top=%s lv=%s\n", top_str, lv_str);
g_free (top_str);
g_free (lv_str);
}
#endif
gtk_adjustment_value_changed (ha);
gtk_adjustment_value_changed (va);
}
}
/*
......@@ -184,14 +197,14 @@ move_cursor_horizontal (GnumericSheet *gsheet, int count)
{
Sheet *sheet = gsheet->sheet_view->sheet;
int new_left;
new_left = sheet->cursor_col + count;
if (new_left < 0)
new_left = 0;
if (new_left > SHEET_MAX_COLS-1)
new_left = SHEET_MAX_COLS-1;
move_cursor (gsheet, new_left, sheet->cursor_row, TRUE);
}
......@@ -214,7 +227,7 @@ move_cursor_vertical (GnumericSheet *gsheet, int count)
new_top = 0;
if (new_top > SHEET_MAX_ROWS-1)
new_top = SHEET_MAX_ROWS-1;
move_cursor (gsheet, sheet->cursor_col, new_top, TRUE);
}
......@@ -249,25 +262,25 @@ gnumeric_sheet_can_move_cursor (GnumericSheet *gsheet)
if (!gsheet->sheet_view->sheet->editing)
return FALSE;
if (gsheet->item_editor && gsheet->selecting_cell)
return TRUE;
entry = GTK_ENTRY (gsheet->entry);
cursor_pos = GTK_EDITABLE (entry)->current_pos;
if (entry->text [0] != '=')
return FALSE;
if (cursor_pos == 0)
return FALSE;
switch (entry->text [cursor_pos-1]){
case '=': case '-': case '*': case '/': case '^':
case '=': case '-': case '*': case '/': case '^':
case '+': case '&': case '(': case '%': case '!':
case ':': case ',':
return TRUE;
}
return FALSE;
}
......@@ -276,9 +289,9 @@ start_cell_selection_at (GnumericSheet *gsheet, int col, int row)
{
GnomeCanvas *canvas = GNOME_CANVAS (gsheet);
GnomeCanvasGroup *group = GNOME_CANVAS_GROUP (canvas->root);
g_return_if_fail (gsheet->selecting_cell == FALSE);
gsheet->selecting_cell = TRUE;
gsheet->selection = ITEM_CURSOR (gnome_canvas_item_new (
group,
......@@ -289,7 +302,7 @@ start_cell_selection_at (GnumericSheet *gsheet, int col, int row)
gsheet->selection->base_col = col;
gsheet->selection->base_row = row;
item_cursor_set_bounds (ITEM_CURSOR (gsheet->selection), col, row, col, row);
gsheet->sel_cursor_pos = GTK_EDITABLE (gsheet->entry)->current_pos;
gsheet->sel_text_len = 0;
}
......@@ -322,7 +335,7 @@ gnumeric_sheet_stop_cell_selection (GnumericSheet *gsheet)
if (!gsheet->selecting_cell)
return;
gsheet->selecting_cell = FALSE;
gtk_object_destroy (GTK_OBJECT (gsheet->selection));
gsheet->selection = NULL;
......@@ -339,12 +352,12 @@ gnumeric_sheet_create_editing_cursor (GnumericSheet *gsheet)
sheet = gsheet->sheet_view->sheet;
col = sheet->cursor_col;
row = sheet->cursor_row;
item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(canvas->root),
item_edit_get_type (),
"ItemEdit::Sheet", sheet,
"ItemEdit::Grid", gsheet->item_grid,
"ItemEdit::Col", col,
"ItemEdit::Col", col,
"ItemEdit::Row", row,
"ItemEdit::GtkEntry", sheet->workbook->ea_input,
NULL);
......@@ -356,7 +369,7 @@ static void
destroy_item_editor (GnumericSheet *gsheet)
{
g_return_if_fail (gsheet->item_editor);
gtk_object_destroy (GTK_OBJECT (gsheet->item_editor));
gsheet->item_editor = NULL;
}
......@@ -366,9 +379,9 @@ gnumeric_sheet_destroy_editing_cursor (GnumericSheet *gsheet)
{
g_return_if_fail (gsheet != NULL);
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
gnumeric_sheet_stop_cell_selection (gsheet);
if (!gsheet->item_editor)
return;
......@@ -428,7 +441,7 @@ void
gnumeric_sheet_selection_extend (GnumericSheet *gsheet, int col, int row)
{
ItemCursor *ic;
g_return_if_fail (gsheet != NULL);
g_return_if_fail (GNUMERIC_IS_SHEET (gsheet));
g_return_if_fail (gsheet->selecting_cell);
......@@ -454,15 +467,15 @@ void
gnumeric_sheet_selection_cursor_place (GnumericSheet *gsheet, int col, int row)
{
ItemCursor *ic;
g_return_if_fail (gsheet != NULL);
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->selection;
selection_remove_selection_string (gsheet);
item_cursor_set_bounds (ic, col, row, col, row);
selection_insert_selection_string (gsheet);
......@@ -474,7 +487,7 @@ selection_cursor_move_horizontal (GnumericSheet *gsheet, int dir)
ItemCursor *ic;
g_return_if_fail (dir == -1 || dir == 1);
if (!gsheet->selecting_cell)
start_cell_selection (gsheet);
......@@ -486,11 +499,11 @@ selection_cursor_move_horizontal (GnumericSheet *gsheet, int dir)
if (ic->end_col + 1 > (SHEET_MAX_COLS-1))
return;
}
selection_remove_selection_string (gsheet);
item_cursor_set_bounds (ic,
item_cursor_set_bounds (ic,
ic->start_col + dir,
ic->start_row,
ic->start_row,
ic->end_col + dir,
ic->end_row);
selection_insert_selection_string (gsheet);
......@@ -544,7 +557,7 @@ selection_expand_horizontal (GnumericSheet *gsheet, int dir)
if (dir == -1 && ic->start_col == ic->end_col)
return;
selection_remove_selection_string (gsheet);
item_cursor_set_bounds (ic,
ic->start_col,
......@@ -567,13 +580,13 @@ selection_expand_vertical (GnumericSheet *gsheet, int dir)
}
ic = gsheet->selection;
if (ic->end_row == SHEET_MAX_ROWS-1)
return;
if (dir == -1 && ic->start_row == ic->end_row)
return;
selection_remove_selection_string (gsheet);
item_cursor_set_bounds (ic,
ic->start_col,
......@@ -594,7 +607,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
void (*movefn_horizontal) (GnumericSheet *, int);
void (*movefn_vertical) (GnumericSheet *, int);
int cursor_move = gnumeric_sheet_can_move_cursor (gsheet);
if ((event->state & GDK_SHIFT_MASK) != 0){
if (cursor_move){
movefn_horizontal = selection_expand_horizontal;
......@@ -630,7 +643,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
* but if the editor is running we forward the events to it.
*/
if (!gsheet->item_editor){
if ((event->state & GDK_CONTROL_MASK) != 0) {
switch (event->keyval) {
......@@ -707,7 +720,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
break;
case GDK_KP_Delete:
case GDK_Delete:
case GDK_Delete:
sheet_selection_clear (sheet);
break;
......@@ -717,7 +730,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
if (gsheet->item_editor){
Cell *cell;
char *text;
sheet_accept_pending_input (sheet);
cell = sheet_cell_get (sheet,
sheet->cursor_col,
......@@ -739,7 +752,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
return 1;
}
/* fall down */
case GDK_Tab:
{
int col, row;
......@@ -749,7 +762,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
/* Figure out the direction */
direction = (event->state & GDK_SHIFT_MASK) ? 0 : 1;
horizontal = (event->keyval == GDK_Tab) ? 1 : 0;
walking_selection = sheet_selection_walk_step (
sheet, direction, horizontal,
sheet->cursor_col, sheet->cursor_row,
......@@ -761,7 +774,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
case GDK_Escape:
sheet_cancel_pending_input (sheet);
break;
case GDK_F2:
gtk_window_set_focus (GTK_WINDOW (wb->toplevel), wb->ea_input);
sheet->editing = TRUE;
......@@ -771,13 +784,13 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
if (!gsheet->item_editor){
if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0)
return 0;
if ((event->keyval >= 0x20 && event->keyval <= 0xff) ||
(event->keyval >= GDK_KP_Add && event->keyval <= GDK_KP_9))
sheet_start_editing_at_cursor (sheet);
}
gnumeric_sheet_stop_cell_selection (gsheet);
/* Forward the keystroke to the input line */
return gtk_widget_event (gsheet->entry, (GdkEvent *) event);
}
......@@ -789,7 +802,7 @@ static gint
gnumeric_sheet_key_mode_object (GnumericSheet *gsheet, GdkEventKey *event)
{
Sheet *sheet = gsheet->sheet_view->sheet;
switch (event->keyval){
case GDK_Escape:
sheet_set_mode_type (sheet, SHEET_MODE_SHEET);
......@@ -812,7 +825,7 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (widget);
Sheet *sheet = gsheet->sheet_view->sheet;
switch (sheet->mode){
case SHEET_MODE_SHEET:
return gnumeric_sheet_key_mode_sheet (gsheet, event);
......@@ -836,7 +849,7 @@ gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
GtkWidget *entry;
Sheet *sheet;
Workbook *workbook;
g_return_val_if_fail (sheet_view != NULL, NULL);
g_return_val_if_fail (IS_SHEET_VIEW (sheet_view), NULL);
g_return_val_if_fail (colbar != NULL, NULL);
......@@ -846,10 +859,10 @@ gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
sheet = sheet_view->sheet;
workbook = sheet->workbook;
entry = workbook->ea_input;
gsheet = gnumeric_sheet_create (sheet_view, entry);
/* FIXME: figure out some real size for the canvas scrolling region */
gnome_canvas_set_scroll_region (GNOME_CANVAS (gsheet), 0, 0, 1000000, 1000000);
......@@ -859,7 +872,7 @@ gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
gsheet->colbar = colbar;
gsheet->rowbar = rowbar;
/* The grid */
item = gnome_canvas_item_new (gsheet_group,
item_grid_get_type (),
......@@ -875,7 +888,7 @@ gnumeric_sheet_new (SheetView *sheet_view, ItemBar *colbar, ItemBar *rowbar)
NULL);
gsheet->item_cursor = ITEM_CURSOR (item);
item_cursor_set_bounds (gsheet->item_cursor, 0, 0, 1, 1);
widget = GTK_WIDGET (gsheet);
return widget;
......@@ -893,7 +906,7 @@ gnumeric_sheet_pattern_t gnumeric_sheet_patterns [GNUMERIC_SHEET_PATTERNS] = {
{ N_("12%"),
{ 0x01, 0x08, 0x40, 0x02, 0x10, 0x80, 0x04, 0x20 } },
{ N_("6%"),
{ 0x80, 0x00, 0x04, 0x00, 0x80, 0x00, 0x04, 0x00 } },
......@@ -929,7 +942,7 @@ gnumeric_sheet_realize (GtkWidget *widget)
GnumericSheet *gsheet = GNUMERIC_SHEET (widget);
GdkWindow *window;
int i;
if (GTK_WIDGET_CLASS (sheet_parent_class)->realize)
(*GTK_WIDGET_CLASS (sheet_parent_class)->realize)(widget);
......@@ -953,14 +966,14 @@ gnumeric_sheet_compute_visible_ranges (GnumericSheet *gsheet)
pixels = 0;
col = gsheet->top_col;
width = GTK_WIDGET (canvas)->allocation.width;
do {
ColRowInfo *ci;
int cb;
ci = sheet_col_get_info (gsheet->sheet_view->sheet, col);
cb = pixels + ci->pixels;