summaryrefslogtreecommitdiff
path: root/tikzit/src/linux/MainWindow.h
blob: 8d3c5831e609398122ca8bf550114ea200c820e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*
 * Copyright 2011  Alex Merry <dev@randomguy3.me.uk>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#import "TZFoundation.h"
#import <gtk/gtk.h>
#import "WidgetSurface.h"

@class Configuration;
@class GraphRenderer;
@class GraphInputHandler;
@class Menu;
@class StylesPalette;
@class StyleManager;
@class PropertyPane;
@class Preambles;
@class PreambleEditor;
@class PreviewWindow;
@class TikzDocument;

/**
 * Manages the main application window
 */
@interface MainWindow: NSObject {
    // the main application configuration
    Configuration *configFile;
    // maintains the known (user-defined) styles
    StyleManager      *styleManager;
    // maintains the preambles used for previews
    Preambles         *preambles;

    // GTK+ widgets
    GtkWindow         *mainWindow;
    GtkTextBuffer     *tikzBuffer;
    GtkStatusbar      *statusBar;
    GtkPaned          *propsPane;
    GtkPaned          *stylesPane;
    GtkPaned          *graphPane;
    GtkWidget         *tikzDisp;

    // Classes that manage parts of the window
    // (or other windows)
    Menu              *menu;
    GraphRenderer     *renderer;
    GraphInputHandler *inputHandler;
    StylesPalette     *stylesPalette;
    PropertyPane      *propertyPane;
    PreambleEditor    *preambleWindow;
    PreviewWindow     *previewWindow;

    WidgetSurface     *surface;

    // state variables
    BOOL               suppressTikzUpdates;
    BOOL               hasParseError;
    // the last-accessed folder (for open and save dialogs)
    NSString          *lastFolder;
    // the open (active) document
    TikzDocument      *document;
}

/**
 * Create and show the main window.
 */
- (id) init;

/**
 * Open a file, asking the user which file to open
 */
- (void) openFile;
/**
 * Save the active document to the path it was opened from
 * or last saved to, or ask the user where to save it.
 */
- (void) saveActiveDocument;
/**
 * Save the active document, asking the user where to save it.
 */
- (void) saveActiveDocumentAs;
/**
 * Save the active document as a shape, asking the user what to name it.
 */
- (void) saveActiveDocumentAsShape;
/**
 * Quit the application, confirming with the user if there are
 * changes to an open document.
 */
- (void) quit;
/**
 * If there are changes to an open document, ask the user if they
 * want to quit the application, discarding those changes.
 *
 * @result  YES if there are no unsaved changes or the user is happy
 *          to discard any unsaved changes, NO if the application
 *          should not quit.
 */
- (BOOL) askCanQuit;

/**
 * Cut the current selection to the clipboard.
 */
- (void) cut;
/**
 * Copy the current selection to the clipboard.
 */
- (void) copy;
/**
 * Paste from the clipboard to the appropriate place.
 */
- (void) paste;

/**
 * Show the dialog for editing preambles.
 */
- (void) editPreambles;
/**
 * Show or update the preview window.
 */
- (void) showPreview;

/**
 * The graph input handler
 */
- (GraphInputHandler*) graphInputHandler;
/**
 * The GTK+ window that this class manages.
 */
- (GtkWindow*) gtkWindow;
/**
 * The main application configuration file
 */
- (Configuration*) mainConfiguration;
/**
 * The menu for the window.
 */
- (Menu*) menu;

/**
 * The document the user is currently editing
 */
- (TikzDocument*) activeDocument;

/**
 * Loads a new, empty document as the active document
 */
- (void) loadEmptyDocument;
/**
 * Loads an existing document from a file as the active document
 *
 * @param path  the path to the tikz file containing the document
 */
- (void) loadDocumentFromFile:(NSString*)path;

/**
 * Present an error to the user
 *
 * (currently just outputs it on the command line)
 *
 * @param error  the error to present
 */
- (void) presentError:(NSError*)error;
/**
 * Present an error to the user
 *
 * (currently just outputs it on the command line)
 *
 * @param error    the error to present
 * @param message  a message to display with the error
 */
- (void) presentError:(NSError*)error withMessage:(NSString*)message;
/**
 * Present an error to the user
 *
 * (currently just outputs it on the command line)
 *
 * @param error  the error to present
 */
- (void) presentGError:(GError*)error;
/**
 * Present an error to the user
 *
 * (currently just outputs it on the command line)
 *
 * @param error    the error to present
 * @param message  a message to display with the error
 */
- (void) presentGError:(GError*)error withMessage:(NSString*)message;

/**
 * Save the application configuration to disk
 *
 * Should be called just before the application exits
 */
- (void) saveConfiguration;

- (void) zoomIn;
- (void) zoomOut;
- (void) zoomReset;

@end

// vim:ft=objc:ts=8:et:sts=4:sw=4