workbook-view.h 3.61 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"
5
#include "file.h"
Jody Goldberg's avatar
Jody Goldberg committed
6
#include <glib-object.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 31
	char	  *auto_expr_desc;
	char	  *auto_expr_value_as_string;

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

Jody Goldberg's avatar
Jody Goldberg committed
35 36
	/* Format for feedback */
	MStyle    *current_format;
37 38 39
};

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

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

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

/* Information */
56 57 58
Workbook	*wb_view_workbook	  (WorkbookView const *wbv);
Sheet		*wb_view_cur_sheet	  (WorkbookView const *wbv);
SheetView	*wb_view_cur_sheet_view	  (WorkbookView const *wbv);
59
void		 wb_view_sheet_focus	  (WorkbookView *wbv, Sheet *sheet);
Jody Goldberg's avatar
Jody Goldberg committed
60
void		 wb_view_sheet_add	  (WorkbookView *wbv, Sheet *new_sheet);
61
gboolean	 wb_view_is_protected	  (WorkbookView *wbv, gboolean check_sheet);
62 63

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

Jody Goldberg's avatar
Jody Goldberg committed
80
/* I/O routines */
Jody Goldberg's avatar
Jody Goldberg committed
81 82 83
gboolean wb_view_save_as     (WorkbookView *wbv, GnumFileSaver *fs,
			      char const *file_name, CommandContext *context);
gboolean wb_view_save        (WorkbookView *wbv, CommandContext *context);
Jody Goldberg's avatar
Jody Goldberg committed
84 85 86 87 88 89

gboolean wb_view_open_input  (GsfInput *input,
			      WorkbookControl *wbc,
			      gboolean display_errors,
                              GnumFileOpener const *fo);
/* convenience wrapper */
90 91 92 93
gboolean wb_view_open        (char const *file_name,
			      WorkbookControl *wbc,
			      gboolean display_errors,
                              GnumFileOpener const *fo);
Jody Goldberg's avatar
Jody Goldberg committed
94

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

107

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