workbook-view.h 4.19 KB
Newer Older
1 2 3
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef _GNM_WORKBOOK_VIEW_H_
# define _GNM_WORKBOOK_VIEW_H_
Jody Goldberg's avatar
Jody Goldberg committed
4

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

9 10
G_BEGIN_DECLS

11
struct _WorkbookView {
12
	GObject  base;
13 14 15 16

	Workbook *wb;
	GPtrArray *wb_controls;

17 18
	Sheet	  *current_sheet;	/* convenience */
	SheetView *current_sheet_view;
Jody Goldberg's avatar
Jody Goldberg committed
19 20

	/* preferences */
21 22 23
	gboolean   show_horizontal_scrollbar;
	gboolean   show_vertical_scrollbar;
	gboolean   show_notebook_tabs;
24
	gboolean   show_function_cell_markers;
25
	gboolean   show_extension_markers;
26
	gboolean   do_auto_completion;
27
	gboolean   is_protected;
28 29 30

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

	/* The auto-expression */
33 34
	GnmFunc   *auto_expr_func;
	char	  *auto_expr_descr;
35
	char	  *auto_expr_text;
36
	PangoAttrList *auto_expr_attrs;
Morten Welinder's avatar
Morten Welinder committed
37
	gboolean  auto_expr_use_max_precision;
38 39
	Sheet *auto_expr_sheet;
	GnmCellPos auto_expr_cell;
Jody Goldberg's avatar
Jody Goldberg committed
40

41 42 43
	/* selection */
	char	  *selection_description;

Jody Goldberg's avatar
Jody Goldberg committed
44 45
	/* Style for feedback */
	GnmStyle const	*current_style;
Jody Goldberg's avatar
Jody Goldberg committed
46
	SheetObject	*in_cell_combo;	/* validation or data slicer */
47 48 49
};

typedef struct {
50
	GObjectClass   base_class;
51 52 53 54
	void (*sheet_entered) (Sheet *sheet);
} WorkbookViewClass;

#define WORKBOOK_VIEW_TYPE     (workbook_view_get_type ())
Jody Goldberg's avatar
Jody Goldberg committed
55 56 57
#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))
58 59

/* Lifecycle */
Jody Goldberg's avatar
Jody Goldberg committed
60
GType		 workbook_view_get_type	  (void);
61
WorkbookView	*workbook_view_new	  (Workbook *optional_workbook);
62
void		 wb_view_attach_control	  (WorkbookView *wbv, WorkbookControl *wbc);
63
void		 wb_view_detach_control	  (WorkbookControl *wbc);
64
void             wb_view_detach_from_workbook (WorkbookView *wbv);
65 66

/* Information */
67 68
GODoc		*wb_view_get_doc	  (WorkbookView const *wbv);
Workbook	*wb_view_get_workbook	  (WorkbookView const *wbv);
69
int		 wb_view_get_index_in_wb  (WorkbookView const *wbv);
70 71
Sheet		*wb_view_cur_sheet	  (WorkbookView const *wbv);
SheetView	*wb_view_cur_sheet_view	  (WorkbookView const *wbv);
72
void		 wb_view_sheet_focus	  (WorkbookView *wbv, Sheet *sheet);
Jody Goldberg's avatar
Jody Goldberg committed
73
void		 wb_view_sheet_add	  (WorkbookView *wbv, Sheet *new_sheet);
74
gboolean	 wb_view_is_protected	  (WorkbookView *wbv, gboolean check_sheet);
75 76

/* Manipulation */
Jody Goldberg's avatar
Jody Goldberg committed
77
void        	 wb_view_set_attribute	  (WorkbookView *wbv, char const *name,
Jody Goldberg's avatar
Jody Goldberg committed
78
					   char const *value);
79 80
void		 wb_view_preferred_size	  (WorkbookView *wbv,
					   int w_pixels, int h_pixels);
Jody Goldberg's avatar
Jody Goldberg committed
81
void		 wb_view_style_feedback   (WorkbookView *wbv);
82
void             wb_view_menus_update     (WorkbookView *wbv);
83 84
void		 wb_view_selection_desc   (WorkbookView *wbv, gboolean use_pos,
					   WorkbookControl *optional_wbc);
85 86
void		 wb_view_edit_line_set	  (WorkbookView *wbv,
					   WorkbookControl *optional_wbc);
87
void		 wb_view_auto_expr_recalc (WorkbookView *wbv);
88

Jody Goldberg's avatar
Jody Goldberg committed
89
/* I/O routines */
Jody Goldberg's avatar
Jody Goldberg committed
90
gboolean wb_view_save_as (WorkbookView *wbv, GOFileSaver *fs,
91 92
			  char const *file_name, GOCmdContext *cc);
gboolean wb_view_save	 (WorkbookView *wbv, GOCmdContext *cc);
93
void	 wbv_save_to_output (WorkbookView *wbv, GOFileSaver const *fs,
94
			     GsfOutput *output, GOIOContext *io_context);
95
void     wb_view_save_to_uri (WorkbookView *wbv, GOFileSaver const *fs,
96
			      char const *uri, GOIOContext *io_context);
Jody Goldberg's avatar
Jody Goldberg committed
97

98 99 100 101 102
WorkbookView *wb_view_new_from_input (GsfInput *input,
				      const char *optional_uri,
				      GOFileOpener const *optional_format,
				      GOIOContext *io_context,
				      gchar const *optional_encoding);
103
WorkbookView *wb_view_new_from_uri  (char const *uri,
Jody Goldberg's avatar
Jody Goldberg committed
104
				     GOFileOpener const *optional_format,
105
				     GOIOContext *io_context,
106
				     gchar const *optional_encoding);
Jody Goldberg's avatar
Jody Goldberg committed
107

108 109
#define WORKBOOK_VIEW_FOREACH_CONTROL(wbv, control, code)			\
do {										\
110 111
	int jNd;								\
	GPtrArray *wb_controls = (wbv)->wb_controls;				\
112
	if (wb_controls != NULL) /* Reverse is important during destruction */	\
113
		for (jNd = wb_controls->len; jNd-- > 0 ;) {			\
114
			WorkbookControl *control =				\
115
				g_ptr_array_index (wb_controls, jNd);		\
116 117 118
			code							\
		}								\
} while (0)
119

120

121 122 123
G_END_DECLS

#endif /* _GNM_WORKBOOK_VIEW_H_ */