gnumeric-canvas.c 2.15 KB
Newer Older
1 2 3 4 5 6 7
#ifdef HAVE_CONFIG_H
#   include <config.h>
#endif

#include <gnome.h>
#include "gnumeric.h"
#include "gnumeric-sheet.h"
8 9 10 11 12 13

/* Signals emited by the Gnumeric Sheet widget */
enum {
	GNUMERIC_SHEET_LAST_SIGNAL
};

Arturo Espinosa's avatar
Arturo Espinosa committed
14 15 16 17
enum {
	ITEM_SHEET_LAST_SIGNAL
};

18
static guint sheet_signals [GNUMERIC_SHEET_LAST_SIGNAL] = { 0 };
Arturo Espinosa's avatar
Arturo Espinosa committed
19
static guint item_signals  [ITEM_SHEET_LAST_SIGNAL] = { 0 };
20 21

static GnomeCanvasClass *sheet_parent_class;
Arturo Espinosa's avatar
Arturo Espinosa committed
22
static GtkObjectClass *item_parent_class;
23 24 25 26 27 28 29

static void
gnumeric_sheet_destroy (GtkObject *object)
{
	GnumericSheet *gsheet;

	/* Add shutdown code here */
Arturo Espinosa's avatar
Arturo Espinosa committed
30 31
	gsheet = GNUMERIC_SHEET (object);
	
32 33 34 35
	if (GTK_OBJECT_CLASS (sheet_parent_class)->destroy)
		(*GTK_OBJECT_CLASS (sheet_parent_class)->destroy)(object);
}

Arturo Espinosa's avatar
Arturo Espinosa committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
GtkWidget *
gnumeric_sheet_new (Sheet *sheet)
{
	GnumericSheet *gsheet;
	GnomeCanvas   *canvas;
	
	gsheet = gtk_type_new (gnumeric_sheet_get_type ());
	canvas = GNOME_CANVAS (gsheet);

	canvas->visual = gtk_widget_get_default_visual ();
	canvas->colormap = gtk_widget_get_default_colormap ();
	canvas->cc   = gdk_color_context_new (canvas->visual, canvas->colormap);
	canvas->root = gnome_canvas_group_new (canvas);
	
	gsheet->sheet   = sheet;
	gsheet->top_col = 0;
	gsheet->top_row = 0;

	return GTK_WIDGET (gsheet);
}

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;
	
	sheet_parent_class = gtk_type_class (gnome_canvas_get_type());

	/* Method override */
	object_class->destroy = gnumeric_sheet_destroy;
}

74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
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) NULL,
			NULL, /* reserved 1 */
			NULL, /* reserved 2 */
			(GtkClassInitFunc) NULL
		};

Arturo Espinosa's avatar
Arturo Espinosa committed
91
		gnumeric_sheet_type = gtk_type_unique (gnome_canvas_get_type (), &gnumeric_sheet_info);
92 93 94 95 96
	}

	return gnumeric_sheet_type;
}