summaryrefslogtreecommitdiff
path: root/tikzit/src/gtk/Application.h
blob: c17a5233821f192333e52bc4f26ef739005c49da (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
/*
 * Copyright 2012  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 "InputDelegate.h"

@class Application;
@class Configuration;
@class ContextWindow;
@class Preambles;
@class PreambleEditor;
@class PreviewWindow;
@class SettingsDialog;
@class StyleManager;
@class TikzDocument;
@class ToolBox;
@class Window;
@protocol Tool;

extern Application* app;

/**
 * Manages the main application window
 */
@interface Application: NSObject {
    // the main application configuration
    Configuration     *configFile;
    // maintains the known (user-defined) styles
    StyleManager      *styleManager;
    // maintains the preambles used for previews
    Preambles         *preambles;
    // the last-accessed folders (for open and save dialogs)
    NSString          *lastOpenFolder;
    NSString          *lastSaveAsFolder;

    ToolBox           *toolBox;
    PreambleEditor    *preambleWindow;
    PreviewWindow     *previewWindow;
    ContextWindow     *contextWindow;
    SettingsDialog    *settingsDialog;

    // the open windows (array of Window*)
    NSMutableArray    *openWindows;

    // tools
    id<Tool>           activeTool;
    NSArray           *tools;
}

/**
 * The main application configuration file
 */
@property (readonly) Configuration *mainConfiguration;

/**
 * The app-wide style manager instance
 */
@property (readonly) StyleManager *styleManager;

/**
 * The app-wide preambles registry
 */
@property (readonly) Preambles *preambles;

/**
 * The tools
 */
@property (readonly) NSArray  *tools;

/**
 * The currently-selected tool
 */
@property (assign)   id<Tool>  activeTool;

/**
 * The folder last actively chosen by a user for opening a file
 */
@property (copy) NSString *lastOpenFolder;

/**
 * The folder last actively chosen by a user for saving a file
 */
@property (copy) NSString *lastSaveAsFolder;

/**
 * The application instance.
 */
+ (Application*) app;

/**
 * Starts the application with a single window containing an empty file
 */
- (id) init;
/**
 * Starts the application with the given files open
 */
- (id) initWithFiles:(NSArray*)files;

/**
 * Loads a new, empty document in a new window
 */
- (void) newWindow;
/**
 * Loads an existing document from a file in a new window
 *
 * @param doc  the document the new window should show
 */
- (void) newWindowWithDocument:(TikzDocument*)doc;
/**
 * Quit the application, confirming with the user if there are
 * changes to any open documents.
 */
- (void) quit;

/**
 * Show the dialog for editing preambles.
 */
- (void) presentPreamblesEditor;
/**
 * Show the context-aware window
 */
- (void) presentContextWindow;
/**
 * Show or update the preview window.
 */
- (void) presentPreviewForDocument:(TikzDocument*)doc;
/**
 * Show or update the preview window without it grabbing focus
 */
- (void) previewDocument:(TikzDocument*)doc;
/**
 * Show the settings dialog.
 */
- (void) presentSettingsDialog;

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

/**
 * @result YES if key event was processed, NO otherwise
 */
- (BOOL) activateToolForKey:(unsigned int)keyVal withMask:(InputMask)mask;

@end

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