workbook-view.h 3.96 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
	GnmExpr const *auto_expr;
Jody Goldberg's avatar
Jody Goldberg committed
29 30
	char	  *auto_expr_desc;
	char	  *auto_expr_value_as_string;
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
	/* Format for feedback */
Morten Welinder's avatar
Morten Welinder committed
37
	GnmStyle    *current_format;
38 39 40
};

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

#define WORKBOOK_VIEW_TYPE     (workbook_view_get_type ())
Jody Goldberg's avatar
Jody Goldberg committed
46 47 48
#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))
49 50

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

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

/* Manipulation */
Jody Goldberg's avatar
Jody Goldberg committed
67 68
void         	 wb_view_set_attribute	  (WorkbookView *wbv, char const *name,
					   char const *value);
69 70
void		 wb_view_preferred_size	  (WorkbookView *wbv,
					   int w_pixels, int h_pixels);
Jody Goldberg's avatar
Jody Goldberg committed
71
void		 wb_view_format_feedback  (WorkbookView *wbv, gboolean display);
72
void             wb_view_menus_update     (WorkbookView *wbv);
73 74
void		 wb_view_selection_desc   (WorkbookView *wbv, gboolean use_pos,
					   WorkbookControl *optional_wbc);
75 76
void		 wb_view_edit_line_set	  (WorkbookView *wbv,
					   WorkbookControl *optional_wbc);
Jody Goldberg's avatar
Jody Goldberg committed
77
void		 wb_view_auto_expr_recalc (WorkbookView *wbv, gboolean display);
78
void		 wb_view_auto_expr	  (WorkbookView *wbv,
79 80
					   char const *name,
					   char const *func_name);
Morten Welinder's avatar
Morten Welinder committed
81 82
void             wb_view_auto_expr_precision (WorkbookView *wbv,
					      gboolean use_max_precision);
83

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

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

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

113

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