preview-grid.c 17.3 KB
Newer Older
1 2 3 4 5 6
/*
 * preview-grid.c : Preview Grid Canvas Item
 *
 * Based upon "The Grid Gnome Canvas Item" a.k.a. Item-Grid
 * (item-grid.c) Created by Miguel de Icaza (miguel@kernel.org)
 *
7
 * Author : Almer S. Tigelaar <almer@gnome.org>
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

24
#include <gnumeric-config.h>
25
#include "gnumeric.h"
26
#include "preview-grid.h"
27 28 29

#include "cell.h"
#include "cell-draw.h"
30
#include "colrow.h"
31 32
#include "pattern.h"
#include "mstyle.h"
33
#include "rendered-value.h"
34 35 36
#include "sheet-style.h"
#include "style-border.h"
#include "style-color.h"
37
#include "value.h"
Jody Goldberg's avatar
Jody Goldberg committed
38
#include "gui-gtkmarshalers.h"
39

40 41
#include <gal/util/e-util.h>

Jody Goldberg's avatar
Jody Goldberg committed
42 43 44
struct _PreviewGrid {
	GnomeCanvasItem canvas_item;

45 46 47 48 49 50 51 52 53 54
	struct { /* Gc's */
		GdkGC *fill;	/* Default background fill gc */
		GdkGC *cell;	/* Color used for the cell */
		GdkGC *empty;	/* GC used for drawing empty cells */
	} gc;
	struct { /* Defaults */
		MStyle *style;
		int     row_height;
		int     col_width;
	} def;
Jody Goldberg's avatar
Jody Goldberg committed
55 56 57 58 59 60

	gboolean gridlines;
};

typedef struct {
	GnomeCanvasItemClass parent_class;
61 62 63 64 65

	int      (* get_row_height) (PreviewGrid *pg, int row);
	int      (* get_col_width)  (PreviewGrid *pg, int col);
	MStyle * (* get_cell_style) (PreviewGrid *pg, int row, int col);
	Value *  (* get_cell_value) (PreviewGrid *pg, int row, int col);
Jody Goldberg's avatar
Jody Goldberg committed
66 67 68
} PreviewGridClass;

#define PREVIEW_GRID_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), preview_grid_get_type (), PreviewGridClass))
69 70 71 72 73 74

static GnomeCanvasItemClass *preview_grid_parent_class;

/* The arguments we take */
enum {
	ARG_0,
75 76
	
	/* Options */
77
	ARG_RENDER_GRIDLINES,
78 79
	ARG_DEFAULT_ROW_HEIGHT,
	ARG_DEFAULT_COL_WIDTH,
80 81
};

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
/* Signals */
enum {
	GET_ROW_HEIGHT,
	GET_COL_WIDTH,
	GET_CELL_STYLE,
	GET_CELL_VALUE,
	LAST_SIGNAL
};

static guint pg_signals [LAST_SIGNAL] = { 0 };

typedef gpointer (*GtkSignal_POINTER__INT_INT) (GtkObject * object,
						gint arg1,
						gint arg2,
						gpointer user_data);
97 98 99 100 101
/*****************************************************************************/

static int
pg_get_row_height (PreviewGrid *pg, int const row)
{
Jody Goldberg's avatar
Jody Goldberg committed
102
	int height;
103
	
Jody Goldberg's avatar
Jody Goldberg committed
104
	g_return_val_if_fail (row >= 0 && row < SHEET_MAX_ROWS, 1);
105 106

	gtk_signal_emit (GTK_OBJECT (pg), pg_signals [GET_ROW_HEIGHT], row, &height);
Jody Goldberg's avatar
Jody Goldberg committed
107 108 109
	if (height > 0)
		return height;
	return pg->def.row_height;
110 111 112 113 114
}

static int
pg_get_col_width (PreviewGrid *pg, int const col)
{
Jody Goldberg's avatar
Jody Goldberg committed
115
	int width;
116
	
Jody Goldberg's avatar
Jody Goldberg committed
117
	g_return_val_if_fail (col >= 0 && col < SHEET_MAX_COLS, 1);
118

119
	gtk_signal_emit (GTK_OBJECT (pg), pg_signals [GET_COL_WIDTH], col, &width);
Jody Goldberg's avatar
Jody Goldberg committed
120 121 122
	if (width > 0)
		return width;
	return pg->def.col_width;
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
}

/**
 * pg_get_row_offset:
 * pg:
 * @y: offset
 * @row_origin: if not null the origin of the row containing pixel @y is put here
 *
 * Return value: Row containing pixel y (and origin in @row_origin)
 **/
static int
pg_get_row_offset (PreviewGrid *pg, int const y, int *row_origin)
{
	int row   = 0;
	int pixel = 0;

	g_return_val_if_fail (pg != NULL, 0);
	
	if (y < pixel) {
		if (row_origin)
			*row_origin = 1; /* there is a 1 pixel edge at the left */
		return 0;
	}

	do {
		if (y <= pixel + pg_get_row_height (pg, row)) {
			if (row_origin)
				*row_origin = pixel;
			return row;
		}
		pixel += pg_get_row_height (pg, row);
	} while (++row < SHEET_MAX_ROWS);

	if (row_origin)
		*row_origin = pixel;

	return SHEET_MAX_ROWS - 1;
}

/**
 * pg_get_col_offset:
 * @x: offset
 * @col_origin: if not null the origin of the column containing pixel @x is put here
 *
 * Return value: Column containing pixel x (and origin in @col_origin)
 **/
static int
pg_get_col_offset (PreviewGrid *pg, int const x, int *col_origin)
{
	int col   = 0;
	int pixel = 0;

	g_return_val_if_fail (pg != NULL, 0);
	
	if (x < pixel) {
		if (col_origin)
			*col_origin = 1; /* there is a 1 pixel edge */
		return 0;
	}

	do {
		if (x <= pixel + pg_get_col_width (pg, col)) {
			if (col_origin)
				*col_origin = pixel;
			return col;
		}
		pixel += pg_get_col_width (pg, col);
	} while (++col < SHEET_MAX_COLS);

	if (col_origin)
		*col_origin = pixel;

	return SHEET_MAX_COLS - 1;
}

static MStyle *
pg_get_style (PreviewGrid *pg, int const row, int const col)
{
201
	MStyle *style = NULL;
202 203 204 205

	g_return_val_if_fail (pg != NULL, 0);
	g_return_val_if_fail (row >= 0 && row < SHEET_MAX_ROWS, 0);
	g_return_val_if_fail (col >= 0 && col < SHEET_MAX_COLS, 0);
206 207

	gtk_signal_emit (GTK_OBJECT (pg), pg_signals [GET_CELL_STYLE], row, col, &style, NULL);
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
	
	/* If no style was returned, use the default style */
	if (style == NULL)
		return pg->def.style;
	else
		return style;
}

static Cell *
pg_construct_cell (PreviewGrid *pg, int const row, int const col)
{
	Cell          *cell  = NULL;
	RenderedValue *res   = NULL;
	MStyle        *style = NULL;

	g_return_val_if_fail (pg != NULL, 0);
	g_return_val_if_fail (row >= 0 && row < SHEET_MAX_ROWS, 0);
	g_return_val_if_fail (col >= 0 && col < SHEET_MAX_COLS, 0);

	/*
	 * We are going to manually replicate a cell
	 * structure here, please remember that this is not
	 * the equivalent of a real cell
	 */
	cell = g_new0 (Cell, 1);
	
	cell->row_info = g_new0 (ColRowInfo, 1);
	cell->col_info = g_new0 (ColRowInfo, 1);

	style = pg_get_style (pg, row, col);
		
	/*
	 * Eventually the row_info->pos and col_info->pos
	 * will go away
	 */
	cell->row_info->pos = row;
	cell->col_info->pos = col;
	cell->pos.row = row;
	cell->pos.col = col;

	cell->row_info->margin_a = 0;
	cell->row_info->margin_b = 0;
	cell->col_info->margin_a = 2;
	cell->col_info->margin_b = 2;

	cell->row_info->size_pixels = pg_get_row_height (pg, row);
	cell->col_info->size_pixels = pg_get_col_width  (pg, col);

256 257 258
	cell->value = NULL;
	gtk_signal_emit (GTK_OBJECT (pg), pg_signals [GET_CELL_VALUE], row, col, &cell->value, NULL);
	if (cell->value == NULL)
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
		cell->value = value_new_empty ();
		
	res = rendered_value_new (cell, style, TRUE);
	cell->rendered_value = res;

	/*
	 * Rendered value needs to know text width and height to handle
	 * alignment properly
	 */
	rendered_value_calc_size_ext (cell, style);

	return cell;
}

static void
pg_destruct_cell (Cell *cell)
{
	g_return_if_fail (cell != NULL);
	
	value_release (cell->value);
	rendered_value_destroy (cell->rendered_value);

	g_free (cell->col_info);
	g_free (cell->row_info);
	
	g_free (cell);
}
/*****************************************************************************/

288 289 290
/**
 * preview_grid_destroy:
 * @object: a Preview grid
291
 *
292 293 294 295 296
 * Destroy handler
 **/
static void
preview_grid_destroy (GtkObject *object)
{
297
	PreviewGrid *pg;
298

299
	pg = PREVIEW_GRID (object);
300 301 302 303 304 305 306 307

	if (GTK_OBJECT_CLASS (preview_grid_parent_class)->destroy)
		(*GTK_OBJECT_CLASS (preview_grid_parent_class)->destroy)(object);
}

/**
 * preview_grid_realize:
 * @item: a PreviewGrid
308
 *
309 310 311 312 313
 * Realize handler
 **/
static void
preview_grid_realize (GnomeCanvasItem *item)
{
314 315 316
	GdkWindow   *window;
	GtkStyle    *style;
	PreviewGrid *pg;
317 318 319 320

	if (GNOME_CANVAS_ITEM_CLASS (preview_grid_parent_class)->realize)
		(*GNOME_CANVAS_ITEM_CLASS (preview_grid_parent_class)->realize)(item);

321
	pg = PREVIEW_GRID (item);
322 323 324 325 326 327 328 329 330 331 332
	window = GTK_WIDGET (item->canvas)->window;

	/* Set the default background color of the canvas itself to white.
	 * This makes the redraws when the canvas scrolls flicker less.
	 */
	style = gtk_style_copy (GTK_WIDGET (item->canvas)->style);
	style->bg [GTK_STATE_NORMAL] = gs_white;
	gtk_widget_set_style (GTK_WIDGET (item->canvas), style);
	gtk_style_unref (style);

	/* Configure the default grid gc */
333 334 335
	pg->gc.fill  = gdk_gc_new (window);
	pg->gc.cell  = gdk_gc_new (window);
	pg->gc.empty = gdk_gc_new (window);
336

337 338 339 340 341
	gdk_gc_set_foreground (pg->gc.fill, &gs_white);
	gdk_gc_set_background (pg->gc.fill, &gs_light_gray);

	/* Initialize hard-coded defaults */
	pg->def.style = mstyle_new_default ();
342 343 344 345 346
}

/**
 * preview_grid_unrealize:
 * @item: a PreviewGrid
347
 *
348 349 350 351 352
 * Unrealize handler
 **/
static void
preview_grid_unrealize (GnomeCanvasItem *item)
{
353 354 355 356 357 358 359 360 361 362 363
	PreviewGrid *pg = PREVIEW_GRID (item);

	gdk_gc_unref (pg->gc.fill);
	gdk_gc_unref (pg->gc.cell);
	gdk_gc_unref (pg->gc.empty);
	pg->gc.fill  = 0;
	pg->gc.cell  = 0;
	pg->gc.empty = 0;

	mstyle_unref (pg->def.style);
	
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
	if (GNOME_CANVAS_ITEM_CLASS (preview_grid_parent_class)->unrealize)
		(*GNOME_CANVAS_ITEM_CLASS (preview_grid_parent_class)->unrealize)(item);
}

/**
 * preview_grid_update:
 *
 * Update handler
 **/
static void
preview_grid_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
{
	if (GNOME_CANVAS_ITEM_CLASS (preview_grid_parent_class)->update)
		(* GNOME_CANVAS_ITEM_CLASS (preview_grid_parent_class)->update) (item, affine, clip_path, flags);

	item->x1 = 0;
	item->y1 = 0;
	item->x2 = INT_MAX;
	item->y2 = INT_MAX;
}

/**
 * preview_grid_draw_background:
387
 *
388 389 390
 * Draw cell background
 **/
static void
391
preview_grid_draw_background (GdkDrawable *drawable, PreviewGrid const *pg, MStyle const *mstyle,
392 393
			      int col, int row, int x, int y, int w, int h)
{
394
	GdkGC *gc = pg->gc.empty;
395
	
396 397
	if (gnumeric_background_set_gc (mstyle, gc, pg->canvas_item.canvas, FALSE))
		/* Fill the entire cell (API excludes far pixel) */
398
		gdk_draw_rectangle (drawable, gc, TRUE, x, y, w+1, h+1);
399 400

	style_border_draw_diag (mstyle, drawable, x, y, x+w, y+h);
401 402 403 404
}

#define border_null(b)	((b) == none || (b) == NULL)
static void
405
pg_style_get_row (PreviewGrid *pg, StyleRow *sr)
406 407 408 409 410 411 412 413
{
	StyleBorder const *top, *bottom, *none = style_border_none ();
	StyleBorder const *left, *right;
	int const end = sr->end_col, row = sr->row;
	int col = sr->start_col;

	sr->vertical [col] = none;
	while (col <= end) {
414 415 416
		MStyle const * style = pg_get_style (pg, row, col);

		sr->styles [col] = style;
417 418 419 420 421 422 423

		top = mstyle_get_border (style, MSTYLE_BORDER_TOP);
		bottom = mstyle_get_border (style, MSTYLE_BORDER_BOTTOM);
		left = mstyle_get_border (style, MSTYLE_BORDER_LEFT);
		right = mstyle_get_border (style, MSTYLE_BORDER_RIGHT);

		/* Cancel grids if there is a background */
424
		if (sr->hide_grid || mstyle_get_pattern (style) > 0) {
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
			if (top == none)
				top = NULL;
			if (bottom == none)
				bottom = NULL;
			if (left == none)
				left = NULL;
			if (right == none)
				right = NULL;
		}
		if (top != none && border_null (sr->top [col]))
			sr->top [col] = top;
		sr->bottom [col] = bottom;

		if (left != none && border_null (sr->vertical [col]))
			sr->vertical [col] = left;
		sr->vertical [++col] = right;
	}
442 443 444 445
}

/**
 * preview_grid_draw:
446
 *
447 448 449 450 451 452
 * Draw Handler
 *
 * NOTE :
 * The drawing routine does not support spanning.
 **/
static void
453 454
preview_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
		   int draw_x, int draw_y, int width, int height)
455
{
456
 	PreviewGrid *pg = PREVIEW_GRID (item);
457 458 459 460 461 462 463 464
 
 	/* To ensure that far and near borders get drawn we pretend to draw +-2
 	 * pixels around the target area which would include the surrounding
 	 * borders if necessary */
 	/* TODO : there is an opportunity to speed up the redraw loop by only
 	 * painting the borders of the edges and not the content.
 	 * However, that feels like more hassle that it is worth.  Look into this someday.
 	 */
465
 	int x, y, col, row, n;
466 467
 	int const start_col = pg_get_col_offset (pg, draw_x - 2, &x);
 	int end_col         = pg_get_col_offset (pg, draw_x + width + 2, NULL);
468
 	int const diff_x    = draw_x - x;
469 470
 	int start_row       = pg_get_row_offset (pg, draw_y - 2, &y);
 	int end_row         = pg_get_row_offset (pg, draw_y + height + 2, NULL);
471 472
 	int const diff_y    = draw_y - y;

473 474 475 476 477 478 479
	StyleRow sr, next_sr;
	MStyle const **styles;
	StyleBorder const **borders, **prev_vert;
	StyleBorder const *none = pg->gridlines ? style_border_none () : NULL;

	int *colwidths = NULL;

480 481
	style_border_none_set_color (style_color_grid ());

482
 	/* Fill entire region with default background (even past far edge) */
483
 	gdk_draw_rectangle (drawable, pg->gc.fill, TRUE,
484
 			    draw_x, draw_y, width, height);
485 486 487 488 489 490 491 492

	/*
	 * allocate a single blob of memory for all 8 arrays of pointers.
	 * 	- 6 arrays of n StyleBorder const *
	 * 	- 2 arrays of n MStyle const *
	 */
	n = end_col - start_col + 3; /* 1 before, 1 after, 1 fencepost */
	style_row_init (&prev_vert, &sr, &next_sr, start_col, end_col,
493
			g_alloca (n * 8 * sizeof (gpointer)), !pg->gridlines);
494 495 496

	/* load up the styles for the first row */
	next_sr.row = sr.row = row = start_row;
497
	pg_style_get_row (pg, &sr);
498 499 500 501 502

	/* Collect the column widths */	
	colwidths = g_alloca (n * sizeof (int));
	colwidths -= start_col;
	for (col = start_col; col <= end_col; col++)
503
		colwidths[col] = pg_get_col_width (pg, col);
504 505

	for (y = -diff_y; row <= end_row; row = sr.row = next_sr.row) {
506
 		int row_height = pg_get_row_height (pg, row);
507
 			
508 509 510 511 512
		if (++next_sr.row > end_row) {
			for (col = start_col ; col <= end_col; ++col)
				next_sr.vertical [col] =
				next_sr.bottom [col] = none;
		} else
513
			pg_style_get_row (pg, &next_sr);
514 515

		for (col = start_col, x = -diff_x; col <= end_col; col++) {
516
 			Cell         *cell  = pg_construct_cell (pg, row, col);
517 518 519
			MStyle const *style = sr.styles [col];

 			preview_grid_draw_background (drawable, pg,
520
 						      style, col, row, x, y,
521
 						      colwidths [col], row_height);
522
 
523
			if (!cell_is_blank (cell))
524
				cell_draw (cell, style, pg->gc.cell, drawable,
525
					   x, y, -1, -1, -1);
526

527
			pg_destruct_cell (cell);
528
 			x += colwidths [col];
529 530
 		}

531
		style_borders_row_draw (prev_vert, &sr,
532 533 534 535 536 537 538 539 540
					drawable, -diff_x, y, y+row_height,
					colwidths, TRUE);

		/* roll the pointers */
		borders = prev_vert; prev_vert = sr.vertical;
		sr.vertical = next_sr.vertical; next_sr.vertical = borders;
		borders = sr.top; sr.top = sr.bottom;
		sr.bottom = next_sr.top = next_sr.bottom; next_sr.bottom = borders;
		styles = sr.styles; sr.styles = next_sr.styles; next_sr.styles = styles;
541 542 543
		 
		y += row_height;
 	}
544 545 546 547
}

/**
 * preview_grid_point:
548
 *
549
 * Point Handler
550
 *
551 552 553 554 555 556 557 558 559 560 561 562 563
 * Return value: point
 **/
static double
preview_grid_point (GnomeCanvasItem *item, double x, double y, int cx, int cy,
		    GnomeCanvasItem **actual_item)
{
	*actual_item = item;
	return 0.0;
}

/**
 * preview_grid_init:
 * @preview_grid: a PreviewGrid
564
 *
565 566 567 568 569 570 571 572 573 574 575
 * Instance initialization
 **/
static void
preview_grid_init (PreviewGrid *preview_grid)
{
	GnomeCanvasItem *item = GNOME_CANVAS_ITEM (preview_grid);

	item->x1 = 0;
	item->y1 = 0;
	item->x2 = 0;
	item->y2 = 0;
576 577 578 579 580

	/* Some sensible hardcoded defaults */
	preview_grid->gridlines      = FALSE;
	preview_grid->def.col_width  = 64;
	preview_grid->def.row_height = 17;
581 582 583 584
}

/**
 * preview_grid_set_arg:
585
 *
586 587 588 589 590 591
 * Callback to set arguments
 **/
static void
preview_grid_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
{
	GnomeCanvasItem *item;
592
	PreviewGrid *pg;
593 594

	item = GNOME_CANVAS_ITEM (o);
595
	pg = PREVIEW_GRID (o);
596 597 598

	switch (arg_id){
	case ARG_RENDER_GRIDLINES :
599 600 601 602 603 604 605 606 607 608
		pg->gridlines = GTK_VALUE_BOOL (*arg);
		break;
	case ARG_DEFAULT_ROW_HEIGHT :
		pg->def.row_height = GTK_VALUE_INT (*arg);
		break;
	case ARG_DEFAULT_COL_WIDTH :
		pg->def.col_width = GTK_VALUE_INT (*arg);
		break;
	default :
		g_warning ("Unknown argument");
609 610 611 612 613 614 615
		break;
	}
}

/**
 * preview_grid_class_init:
 * @preview_grid_class: a PreviewGrid
616
 *
617 618 619 620 621
 * PreviewGrid class initialization
 **/
static void
preview_grid_class_init (PreviewGridClass *preview_grid_class)
{
Jody Goldberg's avatar
Jody Goldberg committed
622
	GtkObjectClass  *klass;
623 624 625 626
	GnomeCanvasItemClass *item_class;

	preview_grid_parent_class = gtk_type_class (gnome_canvas_item_get_type ());

Jody Goldberg's avatar
Jody Goldberg committed
627
	klass = (GtkObjectClass *) preview_grid_class;
628
	item_class = (GnomeCanvasItemClass *) preview_grid_class;
629

630
	/* Manipulation */
631 632
	gtk_object_add_arg_type ("PreviewGrid::RenderGridlines", GTK_TYPE_BOOL,
				 GTK_ARG_WRITABLE, ARG_RENDER_GRIDLINES);
633 634 635 636
	gtk_object_add_arg_type ("PreviewGrid::DefaultRowHeight", GTK_TYPE_INT,
				 GTK_ARG_WRITABLE, ARG_DEFAULT_ROW_HEIGHT);
	gtk_object_add_arg_type ("PreviewGrid::DefaultColWidth", GTK_TYPE_INT,
				 GTK_ARG_WRITABLE, ARG_DEFAULT_COL_WIDTH);
637

Jody Goldberg's avatar
Jody Goldberg committed
638 639
	klass->set_arg = preview_grid_set_arg;
	klass->destroy = preview_grid_destroy;
640 641 642 643 644

	/* GnomeCanvasItem method overrides */
	item_class->update      = preview_grid_update;
	item_class->realize     = preview_grid_realize;
	item_class->unrealize   = preview_grid_unrealize;
645

646 647
	item_class->draw        = preview_grid_draw;
	item_class->point       = preview_grid_point;
648

649 650 651 652 653
	/* Create all the signals */
	pg_signals [GET_ROW_HEIGHT] =
		gtk_signal_new (
			"get_row_height",
			GTK_RUN_LAST,
Jody Goldberg's avatar
Jody Goldberg committed
654
			GTK_CLASS_TYPE (klass),
655
			GTK_SIGNAL_OFFSET (PreviewGridClass, get_row_height),
Jody Goldberg's avatar
Jody Goldberg committed
656
			gnm__INT__INT,
657 658 659 660 661
			GTK_TYPE_INT, 1, GTK_TYPE_INT);
	pg_signals [GET_COL_WIDTH] =
		gtk_signal_new (
			"get_col_width",
			GTK_RUN_LAST,
Jody Goldberg's avatar
Jody Goldberg committed
662
			GTK_CLASS_TYPE (klass),
663
			GTK_SIGNAL_OFFSET (PreviewGridClass, get_col_width),
Jody Goldberg's avatar
Jody Goldberg committed
664
			gnm__INT__INT,
665 666 667 668 669
			GTK_TYPE_INT, 1, GTK_TYPE_INT);
	pg_signals [GET_CELL_STYLE] =
		gtk_signal_new (
			"get_cell_style",
			GTK_RUN_LAST,
Jody Goldberg's avatar
Jody Goldberg committed
670
			GTK_CLASS_TYPE (klass),
671
			GTK_SIGNAL_OFFSET (PreviewGridClass, get_cell_value),
Jody Goldberg's avatar
Jody Goldberg committed
672
			gnm__POINTER__INT_INT,
673 674 675 676 677
			GTK_TYPE_POINTER, 2, GTK_TYPE_INT, GTK_TYPE_INT);
	pg_signals [GET_CELL_VALUE] =
		gtk_signal_new (
			"get_cell_value",
			GTK_RUN_LAST,
Jody Goldberg's avatar
Jody Goldberg committed
678
			GTK_CLASS_TYPE (klass),
679
			GTK_SIGNAL_OFFSET (PreviewGridClass, get_cell_value),
Jody Goldberg's avatar
Jody Goldberg committed
680
			gnm__POINTER__INT_INT,
681
			GTK_TYPE_POINTER, 2, GTK_TYPE_INT, GTK_TYPE_INT);
682 683
}

684 685
E_MAKE_TYPE (preview_grid, "PreviewGrid", PreviewGrid,
	     preview_grid_class_init, preview_grid_init, GNOME_TYPE_CANVAS_ITEM);