1 #ifndef _GNM_WORKBOOK_CONTROL_H_
2 # define _GNM_WORKBOOK_CONTROL_H_
3 
4 #include <gnumeric.h>
5 #include <validation.h>
6 #include <glib-object.h>
7 
8 G_BEGIN_DECLS
9 
10 #define GNM_WBC_TYPE     (workbook_control_get_type ())
11 #define GNM_WBC(obj)     (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNM_WBC_TYPE, WorkbookControl))
12 #define GNM_IS_WBC(o)	  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNM_WBC_TYPE))
13 
14 GType workbook_control_get_type    (void);
15 void  wb_control_set_view	   (WorkbookControl *wbc,
16 				    WorkbookView *optional_view,
17 				    Workbook *optional_wb);
18 void  wb_control_init_state	   (WorkbookControl *wbc);
19 
20 /* Create a new control of the same form */
21 WorkbookControl *workbook_control_new_wrapper (WorkbookControl *wbc,
22                                                WorkbookView *wbv, Workbook *wb,
23                                                void *extra);
24 
25 void wb_control_style_feedback	     (WorkbookControl *wbc, GnmStyle const *changes);
26 void wb_control_edit_line_set        (WorkbookControl *wbc, char const *text);
27 void wb_control_selection_descr_set  (WorkbookControl *wbc, char const *text);
28 
29 void wb_control_sheet_add	     (WorkbookControl *wbc, SheetView *sv);
30 void wb_control_sheet_remove	     (WorkbookControl *wbc, Sheet *sheet);
31 void wb_control_sheet_focus	     (WorkbookControl *wbc, Sheet *sheet);
32 void wb_control_sheet_remove_all     (WorkbookControl *wbc);
33 
34 void wb_control_undo_redo_truncate   (WorkbookControl *wbc, int n, gboolean is_undo);
35 void wb_control_undo_redo_pop	     (WorkbookControl *wbc, gboolean is_undo);
36 void wb_control_undo_redo_push	     (WorkbookControl *wbc, gboolean is_undo,
37 				      char const *text, gpointer key);
38 void wb_control_undo_redo_labels     (WorkbookControl *wbc,
39 				      char const *undo, char const *redo);
40 int  wb_control_validation_msg	     (WorkbookControl *wbc, ValidationStyle v,
41 				      char const *title, char const *msg);
42 
43 /* Menu state update flags, use them to specify which menu items to update */
44 enum {
45 	MS_INSERT_COLS      = 1 << 0,
46 	MS_INSERT_ROWS      = 1 << 1,
47 	MS_INSERT_CELLS     = 1 << 2,
48 	MS_SHOWHIDE_DETAIL  = 1 << 3,
49 	MS_PASTE_SPECIAL    = 1 << 4,
50 	MS_PRINT_SETUP      = 1 << 5,
51 	MS_SEARCH_REPLACE   = 1 << 6,
52 	MS_DEFINE_NAME      = 1 << 7,
53 	MS_CONSOLIDATE      = 1 << 8,
54 	MS_FREEZE_VS_THAW   = 1 << 9,
55 	MS_ADD_VS_REMOVE_FILTER = 1 << 10,
56 	MS_SHOW_PRINTAREA   = 1 << 11,
57 	MS_PAGE_BREAKS      = 1 << 12,
58 	MS_SELECT_OBJECT    = 1 << 13,
59 	MS_FILTER_STATE_CHANGED = 1 << 14,
60 	MS_COMMENT_LINKS_RANGE  = 1 << 15,
61 	MS_COMMENT_LINKS    = 1 << 16,
62 	MS_FILE_EXPORT_IMPORT = 1 << 17
63 };
64 
65 #define MS_ALL \
66     (MS_INSERT_COLS | MS_INSERT_ROWS | MS_INSERT_CELLS |		    \
67      MS_SHOWHIDE_DETAIL | MS_PASTE_SPECIAL |				    \
68      MS_PRINT_SETUP | MS_SEARCH_REPLACE | MS_DEFINE_NAME | MS_CONSOLIDATE | \
69      MS_FREEZE_VS_THAW | MS_ADD_VS_REMOVE_FILTER | MS_SHOW_PRINTAREA |      \
70      MS_PAGE_BREAKS | MS_SELECT_OBJECT | MS_FILTER_STATE_CHANGED | MS_FILE_EXPORT_IMPORT)
71 #define MS_GURU_MENU_ITEMS \
72     (MS_PRINT_SETUP | MS_SEARCH_REPLACE | MS_DEFINE_NAME | MS_CONSOLIDATE)
73 
74 void wb_control_menu_state_update	(WorkbookControl *wbc, int flags);
75 void wb_control_update_action_sensitivity (WorkbookControl *wbc);
76 
77 void wb_control_paste_from_selection (WorkbookControl *wbc,
78 				      GnmPasteTarget const *pt);
79 gboolean wb_control_claim_selection  (WorkbookControl *wbc);
80 
81 WorkbookView *wb_control_view		(WorkbookControl const *wbc);
82 Workbook     *wb_control_get_workbook	(WorkbookControl const *wbc);
83 GODoc	     *wb_control_get_doc	(WorkbookControl const *wbc);
84 Sheet        *wb_control_cur_sheet	(WorkbookControl const *wbc);
85 SheetView    *wb_control_cur_sheet_view	(WorkbookControl const *wbc);
86 
87 gboolean      wb_control_parse_and_jump (WorkbookControl *wbc, char const *text);
88 gboolean      wb_control_jump (WorkbookControl *wbc, Sheet *sheet, const GnmRangeRef *r);
89 
90 typedef enum {
91 	navigator_top,
92 	navigator_bottom,
93 	navigator_last,
94 	navigator_first
95 } wb_control_navigator_t;
96 
97 void wb_control_navigate_to_cell (WorkbookControl *wbc, wb_control_navigator_t to);
98 
99 
100 G_END_DECLS
101 
102 #endif /* _GNM_WORKBOOK_CONTROL_H_ */
103