sheet.c 1.27 KB
Newer Older
Arturo Espinosa's avatar
Arturo Espinosa committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <gnome.h>
#include "gnumeric.h"
#include "gnumeric-sheet.h"

Sheet *
sheet_new (Workbook *wb, char *name)
{
	Sheet *sheet;

	sheet = g_new0 (Sheet, 1);
	sheet->parent_workbook = wb;
	sheet->name = g_strdup (name);
	sheet->sheet_view = gnumeric_sheet_new (sheet);
	gtk_widget_show (sheet->sheet_view);
	
	return sheet;
}

19 20 21 22 23 24
ColInfo *
sheet_get_col_info (Sheet *sheet, int col)
{
	static ColInfo c;

	c.col   = col;
25
	c.width = (col + 1) * 15;
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
	c.style = NULL;

	return &c;
}

RowInfo *
sheet_get_row_info (Sheet *sheet, int row)
{
	static RowInfo r;

	/* Just a stub for now */
	r.row    = row;
	r.height = 20;
	r.style  = NULL;

	return &r;
}

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 74 75 76 77 78
/*
 * Return the number of pixels between from_col to to_col
 */
int
sheet_col_get_distance (Sheet *sheet, int from_col, int to_col)
{
	ColInfo *ci;
	int pixels = 0, i;

	g_assert (from_col <= to_col);
	
	for (i = from_col; i < to_col; i++){
		ci = sheet_get_col_info (sheet, i);
		pixels += ci->width;
	}
	return pixels;
}

/*
 * Return the number of pixels between from_row to to_row
 */
int
sheet_row_get_distance (Sheet *sheet, int from_row, int to_row)
{
	RowInfo *ri;
	int pixels = 0, i;

	g_assert (from_row <= to_row);
	
	for (i = from_row; i < to_row; i++){
		ri = sheet_get_row_info (sheet, i);
		pixels += ri->height;
	}
	return pixels;
}