Commit 74a4e90c authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

move the bounds checking into the scg. (gnm_canvas_button_release) : move

2001-10-31  Jody Goldberg <jgoldberg@home.com>

	* src/gnumeric-canvas.c (gnm_canvas_key_mode_sheet) : move the bounds
	  checking into the scg.
	(gnm_canvas_button_release) : move this from here.
	* src/workbook-control-gui.c (cb_scroll_wheel_support) : to here.
parent 198c9571
2001-10-30 Jody Goldberg <jgoldberg@home.com>
2001-10-31 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-canvas.c (gnm_canvas_key_mode_sheet) : move the bounds
checking into the scg.
(gnm_canvas_button_release) : move this from here.
* src/workbook-control-gui.c (cb_scroll_wheel_support) : to here.
* src/func.c (tokenized_help_new) : don't include the trailing
newlines.
......
......@@ -12,6 +12,7 @@ Jody:
* Fix non-bonobo View menu
* Fix sheet extent calculation new complex objects.
* Improve formula guru.
* Support scrollwheel in a larger area.
Jukka:
* Documented the advanced filter.
......
2001-10-30 Jody Goldberg <jgoldberg@home.com>
2001-10-31 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-canvas.c (gnm_canvas_key_mode_sheet) : move the bounds
checking into the scg.
(gnm_canvas_button_release) : move this from here.
* src/workbook-control-gui.c (cb_scroll_wheel_support) : to here.
* src/func.c (tokenized_help_new) : don't include the trailing
newlines.
......
2001-10-30 Jody Goldberg <jgoldberg@home.com>
2001-10-31 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-canvas.c (gnm_canvas_key_mode_sheet) : move the bounds
checking into the scg.
(gnm_canvas_button_release) : move this from here.
* src/workbook-control-gui.c (cb_scroll_wheel_support) : to here.
* src/func.c (tokenized_help_new) : don't include the trailing
newlines.
......
2001-10-30 Jody Goldberg <jgoldberg@home.com>
2001-10-31 Jody Goldberg <jgoldberg@home.com>
* src/gnumeric-canvas.c (gnm_canvas_key_mode_sheet) : move the bounds
checking into the scg.
(gnm_canvas_button_release) : move this from here.
* src/workbook-control-gui.c (cb_scroll_wheel_support) : to here.
* src/func.c (tokenized_help_new) : don't include the trailing
newlines.
......
......@@ -16,7 +16,6 @@
#include "parse-util.h"
#include "ranges.h"
#include "sheet.h"
#include "sheet-private.h"
#include "application.h"
#include "workbook-view.h"
#include "workbook-edit.h"
......@@ -50,7 +49,6 @@ gnm_canvas_key_mode_sheet (GnumericCanvas *gcanvas, GdkEventKey *event)
WorkbookControlGUI *wbcg = gcanvas->scg->wbcg;
gboolean const jump_to_bounds = event->state & GDK_CONTROL_MASK;
int state = gnumeric_filter_modifiers (event->state);
Range const * const bound = &sheet->priv->unhidden_region;
void (*movefn) (SheetControlGUI *, int n,
gboolean jump, gboolean horiz);
......@@ -133,45 +131,33 @@ gnm_canvas_key_mode_sheet (GnumericCanvas *gcanvas, GdkEventKey *event)
switch (event->keyval) {
case GDK_KP_Left:
case GDK_Left:
if (event->state & GDK_MOD5_MASK) { /* Scroll Lock */
int left = gcanvas->first.col - 1;
if (left < bound->start.col)
left = bound->start.col;
scg_set_left_col (gcanvas->scg, left);
} else
if (event->state & GDK_MOD5_MASK) /* Scroll Lock */
scg_set_left_col (gcanvas->scg, gcanvas->first.col - 1);
else
(*movefn) (gcanvas->scg, -1, jump_to_bounds, TRUE);
break;
case GDK_KP_Right:
case GDK_Right:
if (event->state & GDK_MOD5_MASK) { /* Scroll Lock */
int left = gcanvas->first.col + 1;
if (left > bound->end.col)
left = bound->end.col;
scg_set_left_col (gcanvas->scg, left);
} else
if (event->state & GDK_MOD5_MASK) /* Scroll Lock */
scg_set_left_col (gcanvas->scg, gcanvas->first.col + 1);
else
(*movefn) (gcanvas->scg, 1, jump_to_bounds, TRUE);
break;
case GDK_KP_Up:
case GDK_Up:
if (event->state & GDK_MOD5_MASK) { /* Scroll Lock */
int top = gcanvas->first.row - 1;
if (top < bound->start.row)
top = bound->start.row;
scg_set_top_row (gcanvas->scg, top);
} else
if (event->state & GDK_MOD5_MASK) /* Scroll Lock */
scg_set_top_row (gcanvas->scg, gcanvas->first.row - 1);
else
(*movefn) (gcanvas->scg, -1, jump_to_bounds, FALSE);
break;
case GDK_KP_Down:
case GDK_Down:
if (event->state & GDK_MOD5_MASK) { /* Scroll Lock */
int top = gcanvas->first.row + 1;
if (top > bound->end.row)
top = bound->end.row;
scg_set_top_row (gcanvas->scg, top);
} else
if (event->state & GDK_MOD5_MASK) /* Scroll Lock */
scg_set_top_row (gcanvas->scg, gcanvas->first.row + 1);
else
(*movefn) (gcanvas->scg, 1, jump_to_bounds, FALSE);
break;
......@@ -221,11 +207,8 @@ gnm_canvas_key_mode_sheet (GnumericCanvas *gcanvas, GdkEventKey *event)
if (event->state & GDK_MOD5_MASK) { /* Scroll Lock */
int new_col = sheet->edit_pos.col - (gcanvas->last_full.col - gcanvas->first.col);
int new_row = sheet->edit_pos.row - (gcanvas->last_full.row - gcanvas->first.row);
if (new_col > 0)
scg_set_left_col (gcanvas->scg, new_col);
if (new_row > 0)
scg_set_top_row (gcanvas->scg, new_row);
scg_set_left_col (gcanvas->scg, new_col);
scg_set_top_row (gcanvas->scg, new_row);
} else {
Range r = sheet_get_extent (sheet, FALSE);
......@@ -408,45 +391,6 @@ gnm_canvas_key_release (GtkWidget *widget, GdkEventKey *event)
return (*GTK_WIDGET_CLASS (gcanvas_parent_class)->key_release_event)(widget, event);
}
static gint
gnm_canvas_button_release (GtkWidget *widget, GdkEventButton *button)
{
GnumericCanvas *current = GNUMERIC_CANVAS (widget);
/* scroll always operates on pane 0 */
GnumericCanvas *gcanvas = scg_pane (current->scg, 0);
if (button->button != 4 && button->button != 5)
return (*GTK_WIDGET_CLASS (gcanvas_parent_class)->button_release_event)(widget, button);
/* Roll Up or Left */
/* Roll Down or Right */
if ((button->state & GDK_MOD1_MASK)) {
int col = (gcanvas->last_full.col - gcanvas->first.col) / 4;
if (col < 1)
col = 1;
if (button->button == 4)
col = gcanvas->first.col - col;
else
col = gcanvas->first.col + col;
if (0 <= col && col <= SHEET_MAX_COLS-1)
scg_set_left_col (gcanvas->scg, col);
} else {
int row = (gcanvas->last_full.row - gcanvas->first.row) / 4;
if (row < 1)
row = 1;
if (button->button == 4)
row = gcanvas->first.row - row;
else
row = gcanvas->first.row + row;
if (0 <= row && row <= SHEET_MAX_ROWS-1)
scg_set_top_row (gcanvas->scg, row);
}
return TRUE;
}
/* Focus in handler for the canvas */
static gint
gnm_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event)
......@@ -660,7 +604,6 @@ gnm_canvas_class_init (GnumericCanvasClass *Class)
widget_class->size_allocate = gnm_canvas_size_allocate;
widget_class->key_press_event = gnm_canvas_key_press;
widget_class->key_release_event = gnm_canvas_key_release;
widget_class->button_release_event = gnm_canvas_button_release;
widget_class->focus_in_event = gnm_canvas_focus_in;
widget_class->focus_out_event = gnm_canvas_focus_out;
}
......
......@@ -12,6 +12,7 @@
#define GNUMERIC_ITEM "SCG"
#include "item-debug.h"
#include "sheet.h"
#include "sheet-private.h"
#include "sheet-merge.h"
#include "workbook.h"
#include "workbook-view.h"
......@@ -617,10 +618,20 @@ gnm_canvas_set_left_col (GnumericCanvas *gcanvas, int new_first_col)
void
scg_set_left_col (SheetControlGUI *scg, int col)
{
Sheet const *sheet;
Range const *bound;
g_return_if_fail (IS_SHEET_CONTROL_GUI (scg));
sheet = scg->sheet_control.sheet;
bound = &sheet->priv->unhidden_region;
if (col < bound->start.col)
col = bound->start.col;
else if (col > bound->end.col)
col = bound->end.col;
if (scg->active_panes > 1) {
int right = scg->sheet_control.sheet->unfrozen_top_left.col;
int right = sheet->unfrozen_top_left.col;
if (col < right)
col = right;
gnm_canvas_set_left_col (scg_pane (scg, 3), col);
......@@ -666,10 +677,20 @@ gnm_canvas_set_top_row (GnumericCanvas *gcanvas, int new_first_row)
void
scg_set_top_row (SheetControlGUI *scg, int row)
{
Sheet const *sheet;
Range const *bound;
g_return_if_fail (IS_SHEET_CONTROL_GUI (scg));
sheet = scg->sheet_control.sheet;
bound = &sheet->priv->unhidden_region;
if (row < bound->start.row)
row = bound->start.row;
else if (row > bound->end.row)
row = bound->end.row;
if (scg->active_panes > 1) {
int bottom = scg->sheet_control.sheet->unfrozen_top_left.row;
int bottom = sheet->unfrozen_top_left.row;
if (row < bottom)
row = bottom;
gnm_canvas_set_top_row (scg_pane (scg, 1), row);
......
......@@ -3450,22 +3450,38 @@ wbcg_destroy (GtkObject *obj)
}
static gboolean
cb_scroll_wheel_support (GtkWidget *w, GdkEventButton *event,
WorkbookControlGUI *wb)
{
/* FIXME : now that we have made the split this is no longer true. */
/* This is a stub routine to handle scroll wheel events
* Unfortunately the toplevel window is currently owned by the workbook
* rather than a workbook-view so we cannot really scroll things
* unless we scrolled all the views at once which is ugly.
*/
#if 0
if (event->button == 4)
puts("up");
else if (event->button == 5)
puts("down");
#endif
return FALSE;
cb_scroll_wheel_support (GtkWidget *ignored, GdkEventButton *button,
WorkbookControlGUI *wbcg)
{
/* scroll always operates on pane 0 */
SheetControlGUI *scg = wb_control_gui_cur_sheet (wbcg);
GnumericCanvas *gcanvas = scg_pane (scg, 0);
if (button->button != 4 && button->button != 5)
return FALSE;
/* Roll Up or Left */
/* Roll Down or Right */
if ((button->state & GDK_MOD1_MASK)) {
int col = (gcanvas->last_full.col - gcanvas->first.col) / 4;
if (col < 1)
col = 1;
if (button->button == 4)
col = gcanvas->first.col - col;
else
col = gcanvas->first.col + col;
scg_set_left_col (gcanvas->scg, col);
} else {
int row = (gcanvas->last_full.row - gcanvas->first.row) / 4;
if (row < 1)
row = 1;
if (button->button == 4)
row = gcanvas->first.row - row;
else
row = gcanvas->first.row + row;
scg_set_top_row (gcanvas->scg, row);
}
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