sheet.h 3.3 KB
Newer Older
Arturo Espinosa's avatar
Arturo Espinosa committed
1 2
#ifndef SHEET_H
#define SHEET_H
3 4 5 6 7 8

typedef GList ColStyleList;

struct Workbook;

typedef struct {
Arturo Espinosa's avatar
Arturo Espinosa committed
9 10
	GtkWidget  *toplevel;
	GtkWidget  *notebook;
11 12 13 14 15 16
	GtkWidget  *table;

	/* Edit area */
	GtkWidget  *ea_status;
	GtkWidget  *ea_button_box;
	GtkWidget  *ea_input;
Arturo Espinosa's avatar
Arturo Espinosa committed
17 18 19 20 21
	
	Style      style;
	GHashTable *sheets;	/* keeps a list of the Sheets on this workbook */
} Workbook;

22 23 24 25 26 27
typedef struct {
	int        base_col, base_row;
	int        start_col, start_row;
	int        end_col, end_row;
} SheetSelection;

Arturo Espinosa's avatar
Arturo Espinosa committed
28 29
typedef struct {
	Workbook   *parent_workbook;
30
	GtkWidget  *toplevel, *col_canvas, *row_canvas;
Arturo Espinosa's avatar
Arturo Espinosa committed
31
	GtkWidget  *sheet_view;
32 33 34
	GnomeCanvasItem *col_item, *row_item;
	
	double     last_zoom_factor_used;
35 36 37
	char       *name;
		   
	Style      style;
38

39
	ColRowInfo default_col_style;
40
	GList      *cols_info;
41

42
	ColRowInfo default_row_style;
43 44
	GList      *rows_info;
	void       *contents;
45 46 47 48 49 50 51 52 53

	GList      *selections;

	/* Scrolling information */
	GtkWidget  *vs, *hs;	/* The scrollbars */
	GtkObject  *va, *ha;    /* The adjustments */
	
	int        max_col_used;
	int        max_row_used;
54 55
} Sheet;

56 57
typedef  void (*sheet_col_row_callback)(Sheet *sheet, ColRowInfo *ci, void *user_data);

58 59 60 61 62 63 64 65 66 67 68
Sheet      *sheet_new                 (Workbook *wb, char *name);
void        sheet_destroy             (Sheet *sheet);
void        sheet_foreach_col         (Sheet *sheet, sheet_col_row_callback, void *user_data);
void        sheet_foreach_row         (Sheet *sheet, sheet_col_row_callback, void *user_data);
void        sheet_set_zoom_factor     (Sheet *sheet, double factor);
void        sheet_get_cell_bounds     (Sheet *sheet, ColType col, RowType row, int *x, int *y, int *w, int *h);

/* Selection management */
void        sheet_selection_append    (Sheet *sheet, int col, int row);
void        sheet_selection_extend_to (Sheet *sheet, int col, int row);
void        sheet_selection_clear     (Sheet *sheet);
69

70 71
int         sheet_selection_is_cell_selected (Sheet *sheet, int col, int row);
					 
Arturo Espinosa's avatar
Arturo Espinosa committed
72
/* Create new ColRowInfos from the default sheet style */
73 74
ColRowInfo *sheet_col_new             (Sheet *sheet);
ColRowInfo *sheet_row_new             (Sheet *sheet);
Arturo Espinosa's avatar
Arturo Espinosa committed
75 76

/* Duplicates the information of a col/row */
77
ColRowInfo *sheet_duplicate_colrow    (ColRowInfo *original);
Arturo Espinosa's avatar
Arturo Espinosa committed
78 79

/* Retrieve information from a col/row */
80 81
ColRowInfo *sheet_col_get_info        (Sheet *sheet, int col);
ColRowInfo *sheet_row_get_info        (Sheet *sheet, int row);
Arturo Espinosa's avatar
Arturo Espinosa committed
82 83

/* Add a ColRowInfo to the Sheet */
84 85
void        sheet_col_add             (Sheet *sheet, ColRowInfo *cp);
void        sheet_row_add             (Sheet *sheet, ColRowInfo *cp);
Arturo Espinosa's avatar
Arturo Espinosa committed
86 87

/* Measure distances in pixels from one col/row to another */
88 89
int         sheet_col_get_distance    (Sheet *sheet, int from_col, int to_col);
int         sheet_row_get_distance    (Sheet *sheet, int from_row, int to_row);
Arturo Espinosa's avatar
Arturo Espinosa committed
90 91

/* Sets the width/height of a column row in terms of pixels */
92 93
void        sheet_col_set_width       (Sheet *sheet, int col, int width);
void        sheet_row_set_height      (Sheet *sheet, int row, int width);
Arturo Espinosa's avatar
Arturo Espinosa committed
94

95 96 97
Workbook   *workbook_new              (void);
Workbook   *workbook_new_with_sheets  (int sheet_count);
void        workbook_attach_sheet     (Workbook *, Sheet *);
Arturo Espinosa's avatar
Arturo Espinosa committed
98

99 100 101 102
/*
 * Callback routine: invoked when the first view ItemGrid
 * is realized to allocate the default styles
 */
103
void     workbook_realized            (Workbook *, GdkWindow *);
104

105
#endif