2003-07-31 23:52:10 +00:00
|
|
|
/*
|
|
|
|
NSDocumentController.h
|
|
|
|
|
|
|
|
The document controller class
|
|
|
|
|
|
|
|
Copyright (C) 1999 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Carl Lindberg <Carl.Lindberg@hbo.com>
|
|
|
|
Date: 1999
|
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-10-29 21:16:17 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
2003-07-31 23:52:10 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-10 04:01:49 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
2007-10-29 21:16:17 +00:00
|
|
|
|
2003-07-31 23:52:10 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-10-29 21:16:17 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
2003-07-31 23:52:10 +00:00
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2003-07-31 23:52:10 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
2007-10-29 21:16:17 +00:00
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
2006-11-06 13:58:37 +00:00
|
|
|
Boston, MA 02110-1301, USA.
|
2003-07-31 23:52:10 +00:00
|
|
|
*/
|
2007-10-29 21:16:17 +00:00
|
|
|
|
2003-07-31 23:52:10 +00:00
|
|
|
#ifndef _GNUstep_H_NSDocumentController
|
|
|
|
#define _GNUstep_H_NSDocumentController
|
2006-11-06 13:58:37 +00:00
|
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
2003-07-31 23:52:10 +00:00
|
|
|
|
2009-10-19 10:03:03 +00:00
|
|
|
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
2003-07-31 23:52:10 +00:00
|
|
|
|
2010-03-24 22:41:21 +00:00
|
|
|
#import <Foundation/NSObject.h>
|
|
|
|
#import <AppKit/NSNibDeclarations.h>
|
|
|
|
#import <AppKit/NSUserInterfaceValidation.h>
|
2003-07-31 23:52:10 +00:00
|
|
|
|
2007-01-17 12:09:41 +00:00
|
|
|
@class NSArray;
|
|
|
|
@class NSError;
|
|
|
|
@class NSMutableArray;
|
2003-07-31 23:52:10 +00:00
|
|
|
@class NSURL;
|
2007-01-17 12:09:41 +00:00
|
|
|
@class NSString;
|
|
|
|
|
2003-07-31 23:52:10 +00:00
|
|
|
@class NSDocument;
|
2010-05-12 08:17:26 +00:00
|
|
|
@class NSMenu;
|
2007-01-17 12:09:41 +00:00
|
|
|
@class NSMenuItem;
|
|
|
|
@class NSOpenPanel;
|
|
|
|
@class NSWindow;
|
2003-07-31 23:52:10 +00:00
|
|
|
|
2008-12-25 13:21:22 +00:00
|
|
|
@interface NSDocumentController : NSObject <NSCoding>
|
2003-07-31 23:52:10 +00:00
|
|
|
{
|
|
|
|
@private
|
|
|
|
NSMutableArray *_documents;
|
2007-01-17 12:09:41 +00:00
|
|
|
NSMutableArray *_recent_documents;
|
2009-10-19 10:03:03 +00:00
|
|
|
NSArray *_types; // from info.plist with key NSTypes
|
2007-01-17 12:09:41 +00:00
|
|
|
NSTimeInterval _autosavingDelay;
|
|
|
|
struct __controller_flags {
|
|
|
|
unsigned int should_create_ui:1;
|
|
|
|
unsigned int RESERVED:31;
|
|
|
|
} _controller_flags;
|
2010-05-12 08:17:26 +00:00
|
|
|
NSMenu *_recent_documents_menu;
|
2003-07-31 23:52:10 +00:00
|
|
|
}
|
|
|
|
|
2009-10-19 10:03:03 +00:00
|
|
|
+ (id) sharedDocumentController;
|
2003-07-31 23:52:10 +00:00
|
|
|
|
|
|
|
/*" document creation "*/
|
|
|
|
// doesn't create the windowControllers
|
2009-10-19 10:03:03 +00:00
|
|
|
- (id) makeUntitledDocumentOfType: (NSString*)type;
|
|
|
|
- (id) makeDocumentWithContentsOfFile: (NSString*)fileName
|
|
|
|
ofType: (NSString*)type;
|
2003-07-31 23:52:10 +00:00
|
|
|
// creates window controllers
|
2009-10-19 10:03:03 +00:00
|
|
|
- (id) openUntitledDocumentOfType: (NSString*)type
|
|
|
|
display: (BOOL)display;
|
|
|
|
- (id) openDocumentWithContentsOfFile: (NSString*)fileName
|
|
|
|
display: (BOOL)display;
|
|
|
|
|
|
|
|
- (id) makeDocumentWithContentsOfURL: (NSURL*)url
|
|
|
|
ofType: (NSString*)type;
|
|
|
|
- (id) openDocumentWithContentsOfURL: (NSURL*)url
|
|
|
|
display: (BOOL)display;
|
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
|
|
|
- (id) makeDocumentForURL: (NSURL*)url
|
|
|
|
withContentsOfURL: (NSURL*)contents
|
|
|
|
ofType: (NSString*)type
|
|
|
|
error: (NSError**)err;
|
|
|
|
- (id) makeDocumentWithContentsOfURL: (NSURL*)url
|
|
|
|
ofType: (NSString*)type
|
|
|
|
error: (NSError**)err;
|
|
|
|
- (id) makeUntitledDocumentOfType: (NSString*)type
|
|
|
|
error: (NSError**)err;
|
|
|
|
- (id) openDocumentWithContentsOfURL: (NSURL*)url
|
|
|
|
display: (BOOL)flag
|
|
|
|
error: (NSError**)err;
|
|
|
|
- (id) openUntitledDocumentAndDisplay: (BOOL)flag
|
|
|
|
error: (NSError**)err;
|
|
|
|
- (BOOL) reopenDocumentForURL: (NSURL*)url
|
|
|
|
withContentsOfURL: (NSURL*)contents
|
|
|
|
error: (NSError**)err;
|
|
|
|
- (BOOL) presentError: (NSError*)err;
|
|
|
|
- (void) presentError: (NSError*)err
|
|
|
|
modalForWindow: (NSWindow*)win
|
|
|
|
delegate: (id)delegate
|
|
|
|
didPresentSelector: (SEL)sel
|
|
|
|
contextInfo: (void*)context;
|
|
|
|
- (NSError*) willPresentError: (NSError*)err;
|
2007-01-17 12:09:41 +00:00
|
|
|
#endif
|
2016-07-12 08:41:17 +00:00
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
|
|
|
|
DEFINE_BLOCK_TYPE(GSCompletionBlock1, void, NSDocument*, BOOL, NSError*);
|
|
|
|
DEFINE_BLOCK_TYPE(GSCompletionBlock2, void, NSArray*);
|
|
|
|
|
|
|
|
- (id) duplicateDocumentWithContentsOfURL: (NSURL*)url
|
|
|
|
copying: (BOOL)duplicateByCopying
|
|
|
|
displayName: (NSString*)displayNameOrNil
|
|
|
|
error: (NSError**)outError;
|
|
|
|
- (void) openDocumentWithContentsOfURL: (NSURL*)url
|
|
|
|
display: (BOOL)displayDocument
|
|
|
|
completionHandler: (GSCompletionBlock1)completionHandler;
|
|
|
|
- (void) reopenDocumentForURL: (NSURL*)urlOrNil
|
|
|
|
withContentsOfURL: (NSURL*)contentsURL
|
|
|
|
display: (BOOL)displayDocument
|
|
|
|
completionHandler: (GSCompletionBlock1)completionHandler;
|
|
|
|
- (void) beginOpenPanelWithCompletionHandler: (GSCompletionBlock2)completionHandler;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_8, GS_API_LATEST)
|
|
|
|
DEFINE_BLOCK_TYPE(GSCompletionBlock3, void, NSInteger);
|
|
|
|
|
|
|
|
- (void) beginOpenPanel: (NSOpenPanel*)openPanel
|
|
|
|
forTypes: (NSArray*)inTypes
|
|
|
|
completionHandler: (GSCompletionBlock3)completionHandler;
|
|
|
|
#endif
|
2003-07-31 23:52:10 +00:00
|
|
|
|
|
|
|
/*" With or without UI "*/
|
2009-10-19 10:03:03 +00:00
|
|
|
- (BOOL) shouldCreateUI;
|
|
|
|
- (void) setShouldCreateUI: (BOOL)flag;
|
2003-07-31 23:52:10 +00:00
|
|
|
|
|
|
|
/*" Actions "*/
|
2009-10-19 10:03:03 +00:00
|
|
|
- (IBAction) saveAllDocuments: (id)sender;
|
|
|
|
- (IBAction) openDocument: (id)sender;
|
|
|
|
- (IBAction) newDocument: (id)sender;
|
|
|
|
- (IBAction) clearRecentDocuments: (id)sender;
|
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
2008-12-25 13:21:22 +00:00
|
|
|
- (NSUInteger) maximumRecentDocumentCount;
|
2007-08-03 11:27:41 +00:00
|
|
|
#endif
|
2003-07-31 23:52:10 +00:00
|
|
|
|
|
|
|
/*" Recent Documents "*/
|
2009-10-19 10:03:03 +00:00
|
|
|
- (void) noteNewRecentDocument: (NSDocument*)aDocument;
|
|
|
|
- (void) noteNewRecentDocumentURL: (NSURL*)anURL;
|
|
|
|
- (NSArray*) recentDocumentURLs;
|
2003-07-31 23:52:10 +00:00
|
|
|
|
|
|
|
/*" Open panel "*/
|
2009-10-19 10:03:03 +00:00
|
|
|
- (NSArray*) URLsFromRunningOpenPanel;
|
|
|
|
- (NSArray*) fileNamesFromRunningOpenPanel;
|
|
|
|
- (NSInteger) runModalOpenPanel: (NSOpenPanel*)openPanel
|
|
|
|
forTypes: (NSArray*)openableFileExtensions;
|
2003-07-31 23:52:10 +00:00
|
|
|
|
|
|
|
/*" Document management "*/
|
2009-10-19 10:03:03 +00:00
|
|
|
- (void) addDocument: (NSDocument*)document;
|
|
|
|
- (void) removeDocument: (NSDocument*)document;
|
|
|
|
- (BOOL) closeAllDocuments;
|
|
|
|
- (void) closeAllDocumentsWithDelegate: (id)delegate
|
|
|
|
didCloseAllSelector: (SEL)didAllCloseSelector
|
|
|
|
contextInfo: (void*)contextInfo;
|
|
|
|
- (BOOL) reviewUnsavedDocumentsWithAlertTitle: (NSString*)title
|
|
|
|
cancellable: (BOOL)cancellable;
|
|
|
|
- (void) reviewUnsavedDocumentsWithAlertTitle: (NSString*)title
|
|
|
|
cancellable: (BOOL)cancellable
|
|
|
|
delegate: (id)delegate
|
|
|
|
didReviewAllSelector: (SEL)didReviewAllSelector
|
|
|
|
contextInfo: (void*)contextInfo;
|
|
|
|
- (NSArray*) documents;
|
|
|
|
- (BOOL) hasEditedDocuments;
|
|
|
|
- (id) currentDocument;
|
|
|
|
- (NSString*) currentDirectory;
|
|
|
|
- (id) documentForWindow: (NSWindow*)window;
|
|
|
|
- (id) documentForFileName: (NSString*)fileName;
|
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
|
|
|
- (id) documentForURL: (NSURL*)url;
|
2007-01-17 12:09:41 +00:00
|
|
|
#endif
|
2003-07-31 23:52:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*" Menu validation "*/
|
2009-10-19 10:03:03 +00:00
|
|
|
- (BOOL) validateMenuItem: (NSMenuItem*)anItem;
|
|
|
|
- (BOOL) validateUserInterfaceItem: (id <NSValidatedUserInterfaceItem>)anItem;
|
2003-07-31 23:52:10 +00:00
|
|
|
|
|
|
|
/*" Types and extensions "*/
|
2009-10-19 10:03:03 +00:00
|
|
|
- (NSString*) displayNameForType: (NSString*)type;
|
|
|
|
- (NSString*) typeFromFileExtension: (NSString*)fileExtension;
|
|
|
|
- (NSArray*) fileExtensionsFromType: (NSString*)type;
|
|
|
|
- (Class) documentClassForType: (NSString*)type;
|
|
|
|
|
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
|
|
|
/** Returns the first type found for which the application has an editor
|
|
|
|
* role.
|
|
|
|
*/
|
|
|
|
- (NSString*) defaultType;
|
|
|
|
|
|
|
|
/** Returns the names of the NSDocument subclasses handling documents
|
|
|
|
* in this application. This will be nil or empty if this is not a document
|
|
|
|
* based application.
|
|
|
|
*/
|
|
|
|
- (NSArray*) documentClassNames;
|
|
|
|
|
|
|
|
- (NSString*) typeForContentsOfURL: (NSURL*)url
|
|
|
|
error: (NSError**)err;
|
2007-01-17 12:09:41 +00:00
|
|
|
#endif
|
|
|
|
|
2009-10-19 10:03:03 +00:00
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
2007-01-17 12:09:41 +00:00
|
|
|
/* Autosaving */
|
2009-10-19 10:03:03 +00:00
|
|
|
- (NSTimeInterval) autosavingDelay;
|
|
|
|
- (void) setAutosavingDelay: (NSTimeInterval)autosavingDelay;
|
2007-01-17 12:09:41 +00:00
|
|
|
#endif
|
2003-07-31 23:52:10 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
2006-11-06 13:58:37 +00:00
|
|
|
#endif // GS_API_MACOSX
|
2003-07-31 23:52:10 +00:00
|
|
|
|
|
|
|
#endif // _GNUstep_H_NSDocumentController
|