Commit 37876eb7 authored by Jon K Hellan's avatar Jon K Hellan Committed by Jon Kåre Hellan

Previous attempt to commit failed. Trying again.

2001-05-30  Jon K Hellan  <hellan@acm.org>

	Previous attempt to commit failed. Trying again.

	* src/sheet-control-gui-priv.h: New file. Implementation details
	for SheetControlGUI and methods directly accessible from the GUI
	layer.

	* src/Makefile.am: Add sheet-control-gui-priv.h

	* src/sheet-control-gui.h: Move struct _SheetControlGUI to
	sheet-control-gui-priv.h. Remove declarations of methods which
	have been made virtual.

	* src/sheet-control-gui.c: Include sheet-control-gui-priv.h instead
	of sheet-control-gui.h.
	Casts and temp variables because:
	- virtual scg methods now take a SheetControl parameter.
        - sheet member now lives in SheetControl.
	Make following methods static - externally available only as
	virtual SheetControl method: scg_redraw_all,
	scg_redraw_cell_region, scg_redraw_headers, scg_update_cursor_pos,
	scg_resize, scg_unant, scg_ant, scg_cursor_bound,
	scg_compute_visible_region, scg_make_cell_visible. Initialize
	class object with these as virtual methods together with
	scg_set_zoom_factor, scg_adjust_preferences, scg_scrollbar_config
	and scg_mode_edit.  Rename context_menu_hander (sic!) to
	context_menu_handler.

	*src/sheet-control.c (SC_VIRTUAL_FULL): Fix typo.
	(sc_destroy): Comment out unused variable.
	(sheet_control_init_state): Rename to sc_init_state.
	(sc_sheet): New accessor - returns sheet attribute.
	(sc_invalidate_sheet): New function - sets sheet attribute to
	NULL.
	(resize, set_zoom_factor, redraw_all, redraw_cell_region,
	redraw_headers, ant, unant, adjust_preferences, update_cursor_pos,
	scrollbar_config, mode_edit, compute_visible_region,
	make_cell_visible, cursor_bound): New virtual methods.

	* src/sheet-control.h: Declare new methods in sheet-control.c

	* src/selection.c: Use sc_redraw_cell_region, sc_redraw_headers
	instead of scg methods.

	* src/sheet.c (sheet_unant): Use sc_unant instead o scg_unant.
	(sheet_ant): Use sc_ant instead of scg_ant.
	(sheet_redraw_all): Use sc_redraw_all instead of scg_redraw_all.
	(sheet_redraw_all): Use sc_redraw_headers instead of
	scg_redraw_headers.
	(sheet_new_scg): Use sc_cursor_bound instead of scg_cursor_bound.
	(sheet_detach_scg): Rename to sheet_detach_control. Change
	parameter from SheetControlGUI to SheetControl. Use sc_sheet and
	sc_invalidate_sheet instead of direct attribute access.
	(sheet_set_zoom_factor): Use sc_set_zoom_factor instead of
	scg_set_zoom_factor.
	(sheet_update_only_grid): Use sc_compute_visible_region instead of
	scg_compute_visible_region.
	(sheet_col_row_gutter): Use sc_resize instead of scg_resize.
	(sheet_redraw_cell_region, sheet_redraw_partial_row,
	sheet_redraw_cell): Use sc_redraw_cell_region instead of
	scg_redraw_cell_region.
	(sheet_make_cell_visible): Use sc_make_cell_visible instead of
	scg_make_cell_visible.
	(sheet_cursor_set): Use sc_cursor_bound instead of
	scg_cursor_bound.
	(sheet_update_cursor_pos): Use sc_update_cursor_pos instead of
	scg_update_cursor_pos.
	(sheet_scrollbar_config): Use sc_scrollbar_config instead of
	scg_scrollbar_config.
	(sheet_adjust_preferences): Use sc_adjust_preferences, sc_resize
	and sc_redraw_all instead of scg_adjust_preferences, scg_resize
	and scg_redraw_all.

	* src/sheet.h (SHEET_FOREACH_CONTROL): Take list of SheetControls
	instead of SheetControlGUIs.

	* src/workbook.c (workbook_sheet_detach): Use sc_mode_edit instead
	of scg_mode_edit.

	* src/embeddable-grid.h: Include sheet-control-gui-priv.h instead
	of sheet-control-gui.h.

	* src/sheet-object-graphic.c: Ditto.

	* src/gnumeric-sheet.c: Include sheet-control-gui-priv.h instead
	of sheet-control-gui.h.
	Casts and temp variables because:
	- virtual scg methods now take a SheetControl parameter.
        - sheet now lives in SheetControl.

	* src/item-bar.c: Ditto.

	* src/item-cursor.c: Ditto.

	* src/item-edit.c: Ditto.

	* src/item-grid.c: Ditto.

	* src/sheet-object-cell-comment.c: Ditto.

	* src/sheet-object-cell-container.c: Ditto.

	* src/sheet-object-item.c: Ditto.

	* src/sheet-object-widget.c: Ditto.

	* src/workbook-control-gui.c: Ditto.

	* src/workbook-object-toolbar.c: Ditto, but don't include
	sheet-control-gui-priv.h

	* src/sheet-object.c (sheet_object_realize): Cast control to
	SheetControlGUI.
parent 32d52b23
......@@ -201,6 +201,7 @@ GNUMERIC_BASE_SOURCES = \
sheet-control-priv.h \
sheet-control-gui.c \
sheet-control-gui.h \
sheet-control-gui-priv.h \
solver-lp.c \
solver.h \
sort.c \
......
......@@ -4,7 +4,7 @@
#include <bonobo/bonobo-embeddable.h>
#include "idl/Gnumeric.h"
#include "sheet-control-gui.h"
#include "sheet-control-gui-priv.h"
#define EMBEDDABLE_GRID_TYPE (embeddable_grid_get_type ())
#define EMBEDDABLE_GRID(o) (GTK_CHECK_CAST ((o), EMBEDDABLE_GRID_TYPE, EmbeddableGrid))
......
......@@ -12,7 +12,7 @@
#include "item-cursor.h"
#include "item-edit.h"
#include "item-grid.h"
#include "sheet-control-gui.h"
#include "sheet-control-gui-priv.h"
#include "gnumeric-util.h"
#include "style-color.h"
#include "selection.h"
......@@ -51,7 +51,8 @@ gnumeric_sheet_destroy (GtkObject *object)
static gint
gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
{
Sheet *sheet = gsheet->scg->sheet;
SheetControl *sc = (SheetControl *) gsheet->scg;
Sheet *sheet = sc->sheet;
WorkbookControlGUI *wbcg = gsheet->scg->wbcg;
gboolean const jump_to_bounds = event->state & GDK_CONTROL_MASK;
int state = gnumeric_filter_modifiers (event->state);
......@@ -227,7 +228,7 @@ gnumeric_sheet_key_mode_object (GnumericSheet *gsheet, GdkEventKey *event)
switch (event->keyval) {
case GDK_Escape:
scg_mode_edit (scg);
scg_mode_edit ((SheetControl *) scg);
application_clipboard_unant ();
break;
......@@ -258,7 +259,7 @@ static gint
gnumeric_sheet_key_release (GtkWidget *widget, GdkEventKey *event)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (widget);
SheetControlGUI *scg = gsheet->scg;
SheetControl *sc = (SheetControl *) gsheet->scg;
/*
* The status_region normally displays the current edit_pos
......@@ -267,10 +268,10 @@ gnumeric_sheet_key_release (GtkWidget *widget, GdkEventKey *event)
* is released, or the mouse button is release we need to reset
* to displaying the edit pos.
*/
if (scg->current_object == NULL &&
if (gsheet->scg->current_object == NULL &&
(event->keyval == GDK_Shift_L || event->keyval == GDK_Shift_R))
wb_view_selection_desc (wb_control_view (
WORKBOOK_CONTROL (gsheet->scg->wbcg)), TRUE, NULL);
sc->wbc), TRUE, NULL);
return (*GTK_WIDGET_CLASS (gsheet_parent_class)->key_release_event)(widget, event);
}
......@@ -373,7 +374,8 @@ gnumeric_sheet_filenames_dropped (GtkWidget *widget,
GnumericSheet *gsheet)
{
GList *names, *tmp_list;
WorkbookControl *wbc = WORKBOOK_CONTROL (gsheet->scg->wbcg);
SheetControl *sc = (SheetControl *) gsheet->scg;
WorkbookControl *wbc = sc->wbc;
names = gnome_uri_list_extract_filenames ((char *)selection_data->data);
......@@ -384,7 +386,7 @@ gnumeric_sheet_filenames_dropped (GtkWidget *widget,
#ifdef ENABLE_BONOBO
/* If it wasn't a workbook, see if we have a control for it */
SheetObject *so = sheet_object_container_new_file (
gsheet->scg->sheet, file_name);
sc->sheet, file_name);
if (so != NULL)
scg_mode_create_object (gsheet->scg, so);
#else
......@@ -392,7 +394,7 @@ gnumeric_sheet_filenames_dropped (GtkWidget *widget,
msg = g_strdup_printf (_("File \"%s\" has unknown format."),
file_name);
gnumeric_error_read (COMMAND_CONTEXT (wbc), msg);
gnumeric_error_read (COMMAND_CONTEXT (sc->wbc), msg);
g_free (msg);
#endif
}
......@@ -686,7 +688,7 @@ gnumeric_sheet_set_left_col (GnumericSheet *gsheet, int new_first_col)
int
gnumeric_sheet_find_col (GnumericSheet *gsheet, int x, int *col_origin)
{
Sheet *sheet = gsheet->scg->sheet;
Sheet *sheet = ((SheetControl *) gsheet->scg)->sheet;
int col = gsheet->col.first;
int pixel = gsheet->col_offset.first;
......@@ -730,7 +732,7 @@ gnumeric_sheet_find_col (GnumericSheet *gsheet, int x, int *col_origin)
int
gnumeric_sheet_find_row (GnumericSheet *gsheet, int y, int *row_origin)
{
Sheet *sheet = gsheet->scg->sheet;
Sheet *sheet = ((SheetControl *) gsheet->scg)->sheet;
int row = gsheet->row.first;
int pixel = gsheet->row_offset.first;
......@@ -815,8 +817,7 @@ gnumeric_sheet_rangesel_start (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;
SheetControl *sc = (SheetControl *) gsheet->scg;
Range r;
g_return_if_fail (gsheet->sel_cursor == NULL);
......@@ -824,7 +825,7 @@ gnumeric_sheet_rangesel_start (GnumericSheet *gsheet, int col, int row)
/* 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)))
if (sc->sheet != wb_control_cur_sheet (sc->wbc))
item_cursor_set_visibility (gsheet->item_cursor, FALSE);
tmp = gnome_canvas_item_new (group,
......@@ -870,7 +871,7 @@ gsheet_compute_visible_region (GnumericSheet *gsheet,
gboolean const full_recompute)
{
SheetControlGUI const * const scg = gsheet->scg;
Sheet const * const sheet = scg->sheet;
Sheet const * const sheet = ((SheetControl *) scg)->sheet;
GnomeCanvas *canvas = GNOME_CANVAS (gsheet);
int pixels, col, row, width, height;
......@@ -956,7 +957,7 @@ gsheet_compute_visible_region (GnumericSheet *gsheet,
}
/* Update the scrollbar sizes */
scg_scrollbar_config (scg);
scg_scrollbar_config (SHEET_CONTROL (scg));
/* Force the cursor to update its bounds relative to the new visible region */
item_cursor_reposition (gsheet->item_cursor);
......@@ -992,7 +993,7 @@ gnumeric_sheet_make_cell_visible (GnumericSheet *gsheet, int col, int row,
g_return_if_fail (col < SHEET_MAX_COLS);
g_return_if_fail (row < SHEET_MAX_ROWS);
sheet = gsheet->scg->sheet;
sheet = ((SheetControl *) gsheet->scg)->sheet;
canvas = GNOME_CANVAS (gsheet);
/* Find the new gsheet->col.first */
......
......@@ -12,7 +12,7 @@
#include "item-cursor.h"
#include "item-edit.h"
#include "item-grid.h"
#include "sheet-control-gui.h"
#include "sheet-control-gui-priv.h"
#include "gnumeric-util.h"
#include "style-color.h"
#include "selection.h"
......@@ -51,7 +51,8 @@ gnumeric_sheet_destroy (GtkObject *object)
static gint
gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
{
Sheet *sheet = gsheet->scg->sheet;
SheetControl *sc = (SheetControl *) gsheet->scg;
Sheet *sheet = sc->sheet;
WorkbookControlGUI *wbcg = gsheet->scg->wbcg;
gboolean const jump_to_bounds = event->state & GDK_CONTROL_MASK;
int state = gnumeric_filter_modifiers (event->state);
......@@ -227,7 +228,7 @@ gnumeric_sheet_key_mode_object (GnumericSheet *gsheet, GdkEventKey *event)
switch (event->keyval) {
case GDK_Escape:
scg_mode_edit (scg);
scg_mode_edit ((SheetControl *) scg);
application_clipboard_unant ();
break;
......@@ -258,7 +259,7 @@ static gint
gnumeric_sheet_key_release (GtkWidget *widget, GdkEventKey *event)
{
GnumericSheet *gsheet = GNUMERIC_SHEET (widget);
SheetControlGUI *scg = gsheet->scg;
SheetControl *sc = (SheetControl *) gsheet->scg;
/*
* The status_region normally displays the current edit_pos
......@@ -267,10 +268,10 @@ gnumeric_sheet_key_release (GtkWidget *widget, GdkEventKey *event)
* is released, or the mouse button is release we need to reset
* to displaying the edit pos.
*/
if (scg->current_object == NULL &&
if (gsheet->scg->current_object == NULL &&
(event->keyval == GDK_Shift_L || event->keyval == GDK_Shift_R))
wb_view_selection_desc (wb_control_view (
WORKBOOK_CONTROL (gsheet->scg->wbcg)), TRUE, NULL);
sc->wbc), TRUE, NULL);
return (*GTK_WIDGET_CLASS (gsheet_parent_class)->key_release_event)(widget, event);
}
......@@ -373,7 +374,8 @@ gnumeric_sheet_filenames_dropped (GtkWidget *widget,
GnumericSheet *gsheet)
{
GList *names, *tmp_list;
WorkbookControl *wbc = WORKBOOK_CONTROL (gsheet->scg->wbcg);
SheetControl *sc = (SheetControl *) gsheet->scg;
WorkbookControl *wbc = sc->wbc;
names = gnome_uri_list_extract_filenames ((char *)selection_data->data);
......@@ -384,7 +386,7 @@ gnumeric_sheet_filenames_dropped (GtkWidget *widget,
#ifdef ENABLE_BONOBO
/* If it wasn't a workbook, see if we have a control for it */
SheetObject *so = sheet_object_container_new_file (
gsheet->scg->sheet, file_name);
sc->sheet, file_name);
if (so != NULL)
scg_mode_create_object (gsheet->scg, so);
#else
......@@ -392,7 +394,7 @@ gnumeric_sheet_filenames_dropped (GtkWidget *widget,
msg = g_strdup_printf (_("File \"%s\" has unknown format."),
file_name);
gnumeric_error_read (COMMAND_CONTEXT (wbc), msg);
gnumeric_error_read (COMMAND_CONTEXT (sc->wbc), msg);
g_free (msg);
#endif
}
......@@ -686,7 +688,7 @@ gnumeric_sheet_set_left_col (GnumericSheet *gsheet, int new_first_col)
int
gnumeric_sheet_find_col (GnumericSheet *gsheet, int x, int *col_origin)
{
Sheet *sheet = gsheet->scg->sheet;
Sheet *sheet = ((SheetControl *) gsheet->scg)->sheet;
int col = gsheet->col.first;
int pixel = gsheet->col_offset.first;
......@@ -730,7 +732,7 @@ gnumeric_sheet_find_col (GnumericSheet *gsheet, int x, int *col_origin)
int
gnumeric_sheet_find_row (GnumericSheet *gsheet, int y, int *row_origin)
{
Sheet *sheet = gsheet->scg->sheet;
Sheet *sheet = ((SheetControl *) gsheet->scg)->sheet;
int row = gsheet->row.first;
int pixel = gsheet->row_offset.first;
......@@ -815,8 +817,7 @@ gnumeric_sheet_rangesel_start (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;
SheetControl *sc = (SheetControl *) gsheet->scg;
Range r;
g_return_if_fail (gsheet->sel_cursor == NULL);
......@@ -824,7 +825,7 @@ gnumeric_sheet_rangesel_start (GnumericSheet *gsheet, int col, int row)
/* 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)))
if (sc->sheet != wb_control_cur_sheet (sc->wbc))
item_cursor_set_visibility (gsheet->item_cursor, FALSE);
tmp = gnome_canvas_item_new (group,
......@@ -870,7 +871,7 @@ gsheet_compute_visible_region (GnumericSheet *gsheet,
gboolean const full_recompute)
{
SheetControlGUI const * const scg = gsheet->scg;
Sheet const * const sheet = scg->sheet;
Sheet const * const sheet = ((SheetControl *) scg)->sheet;
GnomeCanvas *canvas = GNOME_CANVAS (gsheet);
int pixels, col, row, width, height;
......@@ -956,7 +957,7 @@ gsheet_compute_visible_region (GnumericSheet *gsheet,
}
/* Update the scrollbar sizes */
scg_scrollbar_config (scg);
scg_scrollbar_config (SHEET_CONTROL (scg));
/* Force the cursor to update its bounds relative to the new visible region */
item_cursor_reposition (gsheet->item_cursor);
......@@ -992,7 +993,7 @@ gnumeric_sheet_make_cell_visible (GnumericSheet *gsheet, int col, int row,
g_return_if_fail (col < SHEET_MAX_COLS);
g_return_if_fail (row < SHEET_MAX_ROWS);
sheet = gsheet->scg->sheet;
sheet = ((SheetControl *) gsheet->scg)->sheet;
canvas = GNOME_CANVAS (gsheet);
/* Find the new gsheet->col.first */
......
......@@ -13,7 +13,7 @@
#include "item-debug.h"
#include "style.h"
#include "sheet.h"
#include "sheet-control-gui.h"
#include "sheet-control-gui-priv.h"
#include "application.h"
#include "selection.h"
#include "gnumeric-sheet.h"
......@@ -93,7 +93,7 @@ compute_pixels_from_indent (Sheet const *sheet, int indent, gboolean const horiz
int
item_bar_calc_size (ItemBar *ib)
{
Sheet const *sheet = ib->scg->sheet;
Sheet const *sheet = ((SheetControl *) ib->scg)->sheet;
double const zoom_factor = sheet->last_zoom_factor_used;
double const res = application_dpi_to_pixels ();
StyleFont * const normal_font =
......@@ -265,7 +265,7 @@ item_bar_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int w
{
ItemBar const *item_bar = ITEM_BAR (item);
SheetControlGUI const *scg = item_bar->scg;
Sheet const *sheet = scg->sheet;
Sheet const *sheet = ((SheetControl *) scg)->sheet;
GnumericSheet const *gsheet = GNUMERIC_SHEET (scg->canvas);
GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (item)->canvas);
ColRowInfo const *cri;
......@@ -529,7 +529,7 @@ item_bar_translate (GnomeCanvasItem *item, double dx, double dy)
static ColRowInfo *
is_pointer_on_division (ItemBar const *item_bar, int pos, int *the_total, int *the_element)
{
Sheet *sheet = item_bar->scg->sheet;
Sheet *sheet = ((SheetControl *) item_bar->scg)->sheet;
ColRowInfo *cri;
int i, total = 0;
......@@ -611,7 +611,7 @@ static void
item_bar_start_resize (ItemBar *ib)
{
SheetControlGUI const * const scg = ib->scg;
Sheet const * const sheet = scg->sheet;
Sheet const * const sheet = ((SheetControl *) scg)->sheet;
double const zoom = sheet->last_zoom_factor_used; /* * res / 72.; */
GnumericSheet const * const gsheet = GNUMERIC_SHEET (scg->canvas);
GnomeCanvas const * const canvas = GNOME_CANVAS (gsheet);
......@@ -713,7 +713,8 @@ cb_extend_selection (SheetControlGUI *scg, int col, int row, gpointer user_data)
static gint
outline_button_press (ItemBar const *ib, int element, int pixel)
{
Sheet * const sheet = ib->scg->sheet;
SheetControl *sc = (SheetControl *) ib->scg;
Sheet * const sheet = sc->sheet;
int inc, step;
if (ib->is_col_header) {
......@@ -727,7 +728,7 @@ outline_button_press (ItemBar const *ib, int element, int pixel)
step = pixel / inc;
cmd_colrow_outline_change (WORKBOOK_CONTROL (ib->scg->wbcg), sheet,
cmd_colrow_outline_change (sc->wbc, sheet,
ib->is_col_header, element, step);
return TRUE;
}
......@@ -738,7 +739,8 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
ColRowInfo *cri;
GnomeCanvas * const canvas = item->canvas;
ItemBar * const item_bar = ITEM_BAR (item);
Sheet * const sheet = item_bar->scg->sheet;
SheetControl *sc = (SheetControl *) item_bar->scg;
Sheet * const sheet = sc->sheet;
GnumericSheet * const gsheet = GNUMERIC_SHEET (item_bar->scg->canvas);
WorkbookControlGUI * const wbcg = item_bar->scg->wbcg;
gboolean const is_cols = item_bar->is_col_header;
......@@ -843,7 +845,7 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
return FALSE;
if (!wbcg_edit_has_guru (wbcg))
scg_mode_edit (item_bar->scg);
scg_mode_edit (sc);
gnome_canvas_w2c (canvas, e->button.x, e->button.y, &x, &y);
if (is_cols) {
......
......@@ -12,7 +12,7 @@
#define GNUMERIC_ITEM "CURSOR"
#include "item-debug.h"
#include "gnumeric-sheet.h"
#include "sheet-control-gui.h"
#include "sheet-control-gui-priv.h"
#include "style-color.h"
#include "clipboard.h"
#include "selection.h"
......@@ -682,7 +682,8 @@ item_cursor_selection_event (GnomeCanvasItem *item, GdkEvent *event)
}
case GDK_2BUTTON_PRESS: {
Sheet *sheet = ic->scg->sheet;
SheetControl *sc = (SheetControl *) ic->scg;
Sheet *sheet = sc->sheet;
int final_col = ic->pos.end.col;
int final_row = ic->pos.end.col;
......@@ -744,7 +745,7 @@ item_cursor_selection_event (GnomeCanvasItem *item, GdkEvent *event)
}
/* fill the row/column */
cmd_autofill (WORKBOOK_CONTROL (ic->scg->wbcg), sheet,
cmd_autofill (sc->wbc, sheet,
ic->pos.start.col, ic->pos.start.row,
ic->pos.end.col - ic->pos.start.col + 1,
ic->pos.end.row - ic->pos.start.row + 1,
......@@ -802,12 +803,12 @@ item_cursor_target_region_ok (ItemCursor *ic)
int v;
GtkWidget *message;
GnomeCanvasItem *gci = GNOME_CANVAS_ITEM (ic);
SheetControlGUI *scg = ic->scg;
SheetControl *sc = (SheetControl *) ic->scg;
g_return_val_if_fail (gci != NULL, FALSE);
g_return_val_if_fail (gci->canvas != NULL, FALSE);
if (sheet_is_region_empty_or_selected (scg->sheet, &ic->pos))
if (sheet_is_region_empty_or_selected (sc->sheet, &ic->pos))
return TRUE;
message = gnome_message_box_new (
......@@ -818,7 +819,7 @@ item_cursor_target_region_ok (ItemCursor *ic)
GNOME_STOCK_BUTTON_YES,
GNOME_STOCK_BUTTON_NO,
NULL);
v = gnumeric_dialog_run (scg->wbcg, GNOME_DIALOG (message));
v = gnumeric_dialog_run (ic->scg->wbcg, GNOME_DIALOG (message));
if (v == 0)
return TRUE;
......@@ -840,7 +841,9 @@ typedef enum {
static void
item_cursor_do_action (ItemCursor *item_cursor, ActionType action, guint32 time)
{
SheetControl *sc;
Sheet *sheet;
WorkbookControl *wbc;
PasteTarget pt;
if (action == ACTION_NONE || !item_cursor_target_region_ok (item_cursor)) {
......@@ -850,38 +853,44 @@ item_cursor_do_action (ItemCursor *item_cursor, ActionType action, guint32 time)
g_return_if_fail (item_cursor != NULL);
sheet = item_cursor->scg->sheet;
sc = (SheetControl *) item_cursor->scg;
sheet = sc->sheet;
wbc = sc->wbc;
switch (action) {
case ACTION_COPY_CELLS:
if (!sheet_selection_copy (WORKBOOK_CONTROL (item_cursor->scg->wbcg), sheet))
if (!sheet_selection_copy (wbc, sheet))
break;
cmd_paste (WORKBOOK_CONTROL (item_cursor->scg->wbcg),
paste_target_init (&pt, sheet, &item_cursor->pos, PASTE_ALL_TYPES),
cmd_paste (wbc,
paste_target_init (&pt, sheet, &item_cursor->pos,
PASTE_ALL_TYPES),
time);
break;
case ACTION_MOVE_CELLS:
if (!sheet_selection_cut (WORKBOOK_CONTROL (item_cursor->scg->wbcg), sheet))
if (!sheet_selection_cut (sc->wbc, sheet))
break;
cmd_paste (WORKBOOK_CONTROL (item_cursor->scg->wbcg),
paste_target_init (&pt, sheet, &item_cursor->pos, PASTE_ALL_TYPES),
cmd_paste (wbc,
paste_target_init (&pt, sheet, &item_cursor->pos,
PASTE_ALL_TYPES),
time);
break;
case ACTION_COPY_FORMATS:
if (!sheet_selection_copy (WORKBOOK_CONTROL (item_cursor->scg->wbcg), sheet))
if (!sheet_selection_copy (wbc, sheet))
break;
cmd_paste (WORKBOOK_CONTROL (item_cursor->scg->wbcg),
paste_target_init (&pt, sheet, &item_cursor->pos, PASTE_FORMATS),
cmd_paste (wbc,
paste_target_init (&pt, sheet, &item_cursor->pos,
PASTE_FORMATS),
time);
break;
case ACTION_COPY_VALUES:
if (!sheet_selection_copy (WORKBOOK_CONTROL (item_cursor->scg->wbcg), sheet))
if (!sheet_selection_copy (wbc, sheet))
break;
cmd_paste (WORKBOOK_CONTROL (item_cursor->scg->wbcg),
paste_target_init (&pt, sheet, &item_cursor->pos, PASTE_AS_VALUES),
cmd_paste (wbc,
paste_target_init (&pt, sheet, &item_cursor->pos,
PASTE_AS_VALUES),
time);
break;
......@@ -955,7 +964,7 @@ static void
item_cursor_do_drop (ItemCursor *ic, GdkEventButton *event)
{
/* Only do the operation if something moved */
Sheet const *sheet = ic->scg->sheet;
Sheet const *sheet = ((SheetControl *) ic->scg)->sheet;
Range const *target = selection_first_range (sheet, NULL, NULL);
if (range_equal (target, &ic->pos)) {
......@@ -1183,10 +1192,11 @@ static gint
item_cursor_autofill_event (GnomeCanvasItem *item, GdkEvent *event)
{
ItemCursor *item_cursor = ITEM_CURSOR (item);
SheetControl *sc = (SheetControl *) item_cursor->scg;
switch (event->type){
case GDK_BUTTON_RELEASE: {
Sheet *sheet = item_cursor->scg->sheet;
scg_stop_sliding (item_cursor->scg);
/*
......@@ -1199,7 +1209,7 @@ item_cursor_autofill_event (GnomeCanvasItem *item, GdkEvent *event)
gdk_flush ();
wbcg_edit_finish (item_cursor->scg->wbcg, TRUE);
cmd_autofill (WORKBOOK_CONTROL (item_cursor->scg->wbcg), sheet,
cmd_autofill (sc->wbc, sc->sheet,
item_cursor->base.col, item_cursor->base.row,
item_cursor->base_cols+1, item_cursor->base_rows+1,
item_cursor->pos.end.col, item_cursor->pos.end.row);
......
......@@ -22,7 +22,7 @@
#define GNUMERIC_ITEM "EDIT"
#include "item-debug.h"
#include "gnumeric-sheet.h"
#include "sheet-control-gui.h"
#include "sheet-control-gui-priv.h"
#include "sheet.h"
#include "sheet-style.h"
#include "value.h"
......@@ -85,6 +85,7 @@ static gboolean
point_is_inside_range (ItemEdit *item_edit, const char *text, Range *range)
{
Value *v;
Sheet *sheet = ((SheetControl *) item_edit->scg)->sheet;
int text_len, cursor_pos, scan;
if ((text = gnumeric_char_start_expr_p (text)) == NULL)
......@@ -103,14 +104,14 @@ point_is_inside_range (ItemEdit *item_edit, const char *text, Range *range)
if (scan > 0 && text [scan-1] == '!')
return FALSE;
if ((v = range_parse (item_edit->scg->sheet, &text [scan], FALSE)) != NULL)
if ((v = range_parse (sheet, &text [scan], FALSE)) != NULL)
return setup_range_from_value (range, v);
if (scan == cursor_pos && scan > 0)
scan--;
scan_at (text, &scan);
if ((v = range_parse (item_edit->scg->sheet, &text [scan], FALSE)) != NULL)
if ((v = range_parse (sheet, &text [scan], FALSE)) != NULL)
return setup_range_from_value (range, v);
return FALSE;
......@@ -213,7 +214,8 @@ item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
{
GtkWidget *canvas = GTK_WIDGET (item->canvas);
ItemEdit *item_edit = ITEM_EDIT (item);
ColRowInfo const *ci = sheet_col_get_info (item_edit->scg->sheet,
SheetControl *sc = (SheetControl *) item_edit->scg;
ColRowInfo const *ci = sheet_col_get_info (sc->sheet,
item_edit->pos.col);
int const left_pos = ((int)item->x1) + ci->margin_a - x;
......@@ -290,7 +292,7 @@ static void
recalc_spans (GnomeCanvasItem *item)
{
ItemEdit *item_edit = ITEM_EDIT (item);
Sheet *sheet = item_edit->scg->sheet;
Sheet *sheet = ((SheetControl *) item_edit->scg)->sheet;
GdkFont *font = item_edit->font;
char const *start = wbcg_edit_get_display_text (item_edit->scg->wbcg);
char const *text = start;
......@@ -512,7 +514,7 @@ item_edit_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
g_return_if_fail (item_edit->scg == NULL);
item_edit->scg = GTK_VALUE_POINTER (*arg);
sheet = item_edit->scg->sheet;
sheet = ((SheetControl *) item_edit->scg)->sheet;
item_edit->entry = GTK_ENTRY (wbcg_get_entry (item_edit->scg->wbcg));
item_edit->pos = sheet->edit_pos;
......
......@@ -18,7 +18,7 @@
#include "workbook-view.h"
#include "workbook-control.h"
#include "workbook-control-gui-priv.h"
#include "sheet-control-gui.h"
#include "sheet-control-gui-priv.h"
#include "sheet.h"
#include "sheet-style.h"
#include "sheet-merge.h"
......@@ -155,7 +155,7 @@ item_grid_draw_merged_range (GdkDrawable *drawable, ItemGrid *ig,
{
int l, r, t, b, last;
GdkGC *gc = ig->gc.empty;
Sheet const *sheet = ig->scg->sheet;
Sheet const *sheet = ((SheetControl *) ig->scg)->sheet;
Cell const *cell = sheet_cell_get (sheet, range->start.col, range->start.row);
/* load style from corner which may not be visible */
......@@ -221,7 +221,7 @@ item_grid_draw_background (GdkDrawable *drawable, ItemGrid *ig,
{
GdkGC *gc = ig->gc.empty;
SheetControlGUI const *scg = ig->scg;
Sheet const *sheet = scg->sheet;
Sheet const *sheet = ((SheetControl *) scg)->sheet;
gboolean const is_selected =
scg->current_object == NULL && scg->new_object == NULL &&
!(sheet->edit_pos.col == col && sheet->edit_pos.row == row) &&
......@@ -250,7 +250,7 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
{
GnomeCanvas *canvas = item->canvas;
GnumericSheet *gsheet = GNUMERIC_SHEET (canvas);
Sheet const *sheet = gsheet->scg->sheet;
Sheet const *sheet = ((SheetControl *) gsheet->scg)->sheet;
Cell const * const edit_cell = gsheet->scg->wbcg->editing_cell;
ItemGrid *ig = ITEM_GRID (item);
ColRowInfo const *ri = NULL, *next_ri = NULL;
......@@ -659,6 +659,7 @@ cb_obj_create_button_release (GnumericSheet *gsheet, GdkEventButton *event,
double pts [4];
SheetObject *so;
SheetControlGUI *scg;
Sheet *sheet;
g_return_val_if_fail (gsheet != NULL, 1);
g_return_val_if_fail (closure != NULL, -1);
......@@ -667,7 +668,8 @@ cb_obj_create_button_release (GnumericSheet *gsheet, GdkEventButton *event,
scg = closure->scg;
so = scg->new_object;
sheet_set_dirty (scg->sheet, TRUE);
sheet = ((SheetControl *) scg)->sheet;
sheet_set_dirty (sheet, TRUE);
/* If there has been some motion use the press and release coords */
if (closure->has_been_sized) {
......@@ -693,7 +695,7 @@ cb_obj_create_button_release (GnumericSheet *gsheet, GdkEventButton *event,
scg_object_calc_position (scg, so, pts);
if (!sheet_object_rubber_band_directly (so)) {
sheet_object_set_sheet (so, scg->sheet);
sheet_object_set_sheet (so, sheet);
gtk_object_destroy (GTK_OBJECT (closure->item));
closure->item = NULL;
}
......@@ -755,7 +757,7 @@ sheet_object_begin_creation (GnumericSheet *gsheet, GdkEventButton *event)
points [1] = points [3] = event->y;
scg_object_calc_position (scg, so, points);
sheet_object_set_sheet (so, scg->sheet);
sheet_object_set_sheet (so, ((SheetControl *) scg)->sheet);
closure->item = NULL;
}
......@@ -777,6 +779,8 @@ item_grid_button_1 (SheetControlGUI *scg, GdkEventButton *event,
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (ig);
GnomeCanvas *canvas = item->canvas;
GnumericSheet *gsheet = GNUMERIC_SHEET (canvas);
SheetControl *sc = (SheetControl *) scg;
Sheet *sheet = sc->sheet;
/* Range check first */
if (col >= SHEET_MAX_COLS)
......@@ -793,7 +797,7 @@ item_grid_button_1 (SheetControlGUI *scg, GdkEventButton *event,
*/
if (scg->current_object != NULL) {
if (!wbcg_edit_has_guru (scg->wbcg))
scg_mode_edit (scg);
scg_mode_edit (sc);
} else
wb_control_gui_focus_cur_sheet (scg->wbcg);
......@@ -839,17 +843,17 @@ item_grid_button_1 (SheetControlGUI *scg, GdkEventButton *event,
return 1;
if (!(event->state & (GDK_CONTROL_MASK|GDK_SHIFT_MASK)))
sheet_selection_reset (scg->sheet);
sheet_selection_reset (sheet);
ig->selecting = ITEM_GRID_SELECTING_CELL_RANGE;
if ((event->state & GDK_SHIFT_MASK) && scg->sheet->selections)
sheet_selection_extend_to (scg->sheet, col, row);
if ((event->state & GDK_SHIFT_MASK) && sheet->selections)
sheet_selection_extend_to (sheet, col, row);
else {
sheet_selection_add (scg->sheet, col, row);
sheet_make_cell_visible (scg->sheet, col, row);
sheet_selection_add (sheet, col, row);
sheet_make_cell_visible (sheet, col, row);
}
sheet_update (scg->sheet);
sheet_update (sheet);
gnome_canvas_item_grab (item,
GDK_POINTER_MOTION_MASK |
......@@ -886,7 +890,7 @@ drag_start (GtkWidget *widget, GdkEvent *event, Sheet *sheet)
static gboolean
cb_extend_cell_range (SheetControlGUI *scg, int col, int row, gpointer ignored)
{
sheet_selection_extend_to (scg->sheet, col, row);
sheet_selection_extend_to (((SheetControl *) scg)->sheet, col, row);
return TRUE;
}
......@@ -904,7 +908,8 @@ item_grid_event (GnomeCanvasItem *item, GdkEvent *event)
ItemGrid *ig = ITEM_GRID (item);
GnumericSheet *gsheet = GNUMERIC_SHEET (canvas);
SheetControlGUI *scg = ig->scg;
Sheet *sheet = scg->sheet;
SheetControl *sc = (SheetControl *) scg;
Sheet *sheet = sc->sheet;
int col, row, x, y, left, top, width, height;
switch (event->type){
......@@ -932,8 +937,8 @@ item_grid_event (GnomeCanvasItem *item, GdkEvent *event)
sheet->edit_pos.col,
sheet->edit_pos.row);
wb_view_selection_desc (wb_control_view (
WORKBOOK_CONTROL (scg->wbcg)), TRUE, NULL);
wb_view_selection_desc (
wb_control_view (sc->wbc), TRUE, NULL);
ig->selecting = ITEM_GRID_NO_SELECTION;
gnome_canvas_item_ungrab (item, event->button.time);
......
......@@ -181,10 +181,10 @@ sheet_selection_redraw (Sheet const *sheet)
Range const *r = sel->data;
SHEET_FOREACH_CONTROL (sheet, control,
scg_redraw_cell_region (control,
sc_redraw_cell_region (control,
r->start.col, r->start.row,
</