workbook-view.h 3.8 KB
Newer Older
Jody Goldberg's avatar
Jody Goldberg committed
1 2 3
#ifndef GNUMERIC_WORKBOOK_VIEW_H
#define GNUMERIC_WORKBOOK_VIEW_H

4
#include "gnumeric.h"
Jody Goldberg's avatar
Jody Goldberg committed
5
#include <glib-object.h>
6
#include <gsf/gsf.h>
7 8

struct _WorkbookView {
9
	GObject  base;
10 11 12 13

	Workbook *wb;
	GPtrArray *wb_controls;

14 15
	Sheet	  *current_sheet;	/* convenience */
	SheetView *current_sheet_view;
Jody Goldberg's avatar
Jody Goldberg committed
16 17

	/* preferences */
18 19 20
	gboolean   show_horizontal_scrollbar;
	gboolean   show_vertical_scrollbar;
	gboolean   show_notebook_tabs;
21
	gboolean   do_auto_completion;
22
	gboolean   is_protected;
23 24 25

	/* Non-normative size information */
	int preferred_width, preferred_height;
Jody Goldberg's avatar
Jody Goldberg committed
26 27

	/* The auto-expression */
28 29
	GnmFunc   *auto_expr_func;
	char	  *auto_expr_descr;
30
	char	  *auto_expr_text;
Morten Welinder's avatar
Morten Welinder committed
31
	gboolean  auto_expr_use_max_precision;
Jody Goldberg's avatar
Jody Goldberg committed
32

33 34 35
	/* selection */
	char	  *selection_description;

Jody Goldberg's avatar
Jody Goldberg committed
36 37 38
	/* Style for feedback */
	GnmStyle const	*current_style;
	SheetObject	*validation_combo;
39 40 41
};

typedef struct {
Jody Goldberg's avatar
Jody Goldberg committed
42
	GObjectClass   gtk_object_class;
43 44 45 46
	void (*sheet_entered) (Sheet *sheet);
} WorkbookViewClass;

#define WORKBOOK_VIEW_TYPE     (workbook_view_get_type ())
Jody Goldberg's avatar
Jody Goldberg committed
47 48 49
#define WORKBOOK_VIEW(obj)     (G_TYPE_CHECK_INSTANCE_CAST ((obj), WORKBOOK_VIEW_TYPE, WorkbookView))
#define WORKBOOK_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), WORKBOOK_VIEW_TYPE, WorkbookViewClass))
#define IS_WORKBOOK_VIEW(o)    (G_TYPE_CHECK_INSTANCE_TYPE ((o), WORKBOOK_VIEW_TYPE))
50 51

/* Lifecycle */
Jody Goldberg's avatar
Jody Goldberg committed
52
GType		 workbook_view_get_type	  (void);
53
WorkbookView	*workbook_view_new	  (Workbook *optional_workbook);
54
void		 wb_view_attach_control	  (WorkbookView *wbv, WorkbookControl *wbc);
55
void		 wb_view_detach_control	  (WorkbookControl *wbc);
56
void             wb_view_detach_from_workbook (WorkbookView *wbv);
57 58

/* Information */
59 60
GODoc		*wb_view_get_doc	  (WorkbookView const *wbv);
Workbook	*wb_view_get_workbook	  (WorkbookView const *wbv);
61
int		 wb_view_get_index_in_wb  (WorkbookView const *wbv);
62 63
Sheet		*wb_view_cur_sheet	  (WorkbookView const *wbv);
SheetView	*wb_view_cur_sheet_view	  (WorkbookView const *wbv);
64
void		 wb_view_sheet_focus	  (WorkbookView *wbv, Sheet *sheet);
Jody Goldberg's avatar
Jody Goldberg committed
65
void		 wb_view_sheet_add	  (WorkbookView *wbv, Sheet *new_sheet);
66
gboolean	 wb_view_is_protected	  (WorkbookView *wbv, gboolean check_sheet);
67 68

/* Manipulation */
Jody Goldberg's avatar
Jody Goldberg committed
69 70
void         	 wb_view_set_attribute	  (WorkbookView *wbv, char const *name,
					   char const *value);
71 72
void		 wb_view_preferred_size	  (WorkbookView *wbv,
					   int w_pixels, int h_pixels);
Jody Goldberg's avatar
Jody Goldberg committed
73
void		 wb_view_style_feedback   (WorkbookView *wbv);
74
void             wb_view_menus_update     (WorkbookView *wbv);
75 76
void		 wb_view_selection_desc   (WorkbookView *wbv, gboolean use_pos,
					   WorkbookControl *optional_wbc);
77 78
void		 wb_view_edit_line_set	  (WorkbookView *wbv,
					   WorkbookControl *optional_wbc);
79
void		 wb_view_auto_expr_recalc (WorkbookView *wbv);
80

Jody Goldberg's avatar
Jody Goldberg committed
81
/* I/O routines */
Jody Goldberg's avatar
Jody Goldberg committed
82
gboolean wb_view_save_as (WorkbookView *wbv, GOFileSaver *fs,
83 84
			  char const *file_name, GOCmdContext *cc);
gboolean wb_view_save	 (WorkbookView *wbv, GOCmdContext *cc);
85 86
void	 wbv_save_to_output (WorkbookView *wbv, GOFileSaver const *fs,
			     GsfOutput *output, IOContext *io_context);
87
gboolean wb_view_sendto	 (WorkbookView *wbv, GOCmdContext *cc);
Jody Goldberg's avatar
Jody Goldberg committed
88

Jody Goldberg's avatar
Jody Goldberg committed
89
WorkbookView *wb_view_new_from_input  (GsfInput *input,
Jody Goldberg's avatar
Jody Goldberg committed
90
				       GOFileOpener const *optional_format,
91 92
				       IOContext *io_context,
				       gchar const *optional_encoding);
93
WorkbookView *wb_view_new_from_uri  (char const *uri,
Jody Goldberg's avatar
Jody Goldberg committed
94
				     GOFileOpener const *optional_format,
95
				     IOContext *io_context,
96
				     gchar const *optional_encoding);
Jody Goldberg's avatar
Jody Goldberg committed
97

98 99
#define WORKBOOK_VIEW_FOREACH_CONTROL(wbv, control, code)			\
do {										\
100 101
	int jNd;								\
	GPtrArray *wb_controls = (wbv)->wb_controls;				\
102
	if (wb_controls != NULL) /* Reverse is important during destruction */	\
103
		for (jNd = wb_controls->len; jNd-- > 0 ;) {			\
104
			WorkbookControl *control =				\
105
				g_ptr_array_index (wb_controls, jNd);		\
106 107 108
			code							\
		}								\
} while (0)
109

110

Jody Goldberg's avatar
Jody Goldberg committed
111
#endif /* GNUMERIC_WORKBOOK_VIEW_H */