view dstep/appkit/NSDocumentController.d @ 22:f8a3b67adfcb

Removed duplicated methods
author Jacob Carlborg <doob@me.com>
date Tue, 09 Feb 2010 18:02:03 +0100
parents 19885b43130e
children b9de51448c6b
line wrap: on
line source

/**
 * Copyright: Copyright (c) 2009 Jacob Carlborg.
 * Authors: Jacob Carlborg
 * Version: Initial created: Sep 24, 2009 
 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
 */
module dstep.appkit.NSDocumentController;

import dstep.foundation.NSArray;
import dstep.appkit.NSDocument;
import dstep.appkit.NSMenuItem;
import dstep.appkit.NSNibDeclarations;
import dstep.appkit.NSOpenPanel;
import dstep.appkit.NSUserInterfaceValidation;
import dstep.appkit.NSWindow;
import dstep.foundation.NSCoder;
import dstep.foundation.NSDate;
import dstep.foundation.NSError;
import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSObject;
import dstep.foundation.NSString;
import dstep.foundation.NSURL;
import dstep.foundation.NSZone;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;

class NSDocumentController : NSObject, INSCoding, INSUserInterfaceValidations
{
	mixin (ObjcWrap);
	
	this (NSCoder aDecoder)
	{
		super(typeof(this).alloc.initWithCoder(aDecoder).objcObject);
	}
	
	void encodeWithCoder (NSCoder aCoder)
	{
		return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
	}
	
	typeof(this) initWithCoder (NSCoder aDecoder)
	{
		return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder);
	}

	static Object sharedDocumentController ()
	{
		return invokeObjcSelfClass!(Object, "sharedDocumentController");
	}

	NSDocumentController init ()
	{
		id result = invokeObjcSelf!(id, "init");
		return result is this.objcObject ? this : (result !is null ? new NSDocumentController(result) : null);
	}

	this ()
	{
		super(NSDocumentController.alloc.init.objcObject);
	}

	NSArray documents ()
	{
		return invokeObjcSelf!(NSArray, "documents");
	}

	Object currentDocument ()
	{
		return invokeObjcSelf!(Object, "currentDocument");
	}

	NSString currentDirectory ()
	{
		return invokeObjcSelf!(NSString, "currentDirectory");
	}

	Object documentForURL (NSURL absoluteURL)
	{
		return invokeObjcSelf!(Object, "documentForURL:", NSURL)(absoluteURL);
	}

	Object documentForWindow (NSWindow window)
	{
		return invokeObjcSelf!(Object, "documentForWindow:", NSWindow)(window);
	}

	void addDocument (NSDocument document)
	{
		return invokeObjcSelf!(void, "addDocument:", NSDocument)(document);
	}

	void removeDocument (NSDocument document)
	{
		return invokeObjcSelf!(void, "removeDocument:", NSDocument)(document);
	}

	void newDocument (Object sender)
	{
		return invokeObjcSelf!(void, "newDocument:", Object)(sender);
	}

	Object openUntitledDocumentAndDisplay (bool displayDocument, ref NSError outError)
	{
		id error;
		
		if (outError)
			error = new objc_object;
		
		Object result = invokeObjcSelf!(Object, "openUntitledDocumentAndDisplay:error:", bool, id*)(displayDocument, &error);
		
		if (error)
			outError = new NSError(error);
		
		return result;
	}

	Object makeUntitledDocumentOfType (NSString typeName, ref NSError outError)
	{
		id error;
		
		if (outError)
			error = new objc_object;
		
		Object result = invokeObjcSelf!(Object, "makeUntitledDocumentOfType:error:", NSString, id*)(typeName, &error);
		
		if (error)
			outError = new NSError(error);
		
		return result;
	}

	void openDocument (Object sender)
	{
		return invokeObjcSelf!(void, "openDocument:", Object)(sender);
	}

	NSArray URLsFromRunningOpenPanel ()
	{
		return invokeObjcSelf!(NSArray, "URLsFromRunningOpenPanel");
	}

	NSInteger runModalOpenPanel (NSOpenPanel openPanel, NSArray types)
	{
		return invokeObjcSelf!(NSInteger, "runModalOpenPanel:forTypes:", NSOpenPanel, NSArray)(openPanel, types);
	}

	Object openDocumentWithContentsOfURL (NSURL absoluteURL, bool displayDocument, ref NSError outError)
	{
		id error;
		
		if (outError)
			error = new objc_object;
		
		Object result = invokeObjcSelf!(Object, "openDocumentWithContentsOfURL:display:error:", NSURL, bool, id*)(absoluteURL, displayDocument, &error);
		
		if (error)
			outError = new NSError(error);
		
		return result;
	}

	Object makeDocumentWithContentsOfURL (NSURL absoluteURL, NSString typeName, ref NSError outError)
	{
		id error;
		
		if (outError)
			error = new objc_object;
		
		Object result = invokeObjcSelf!(Object, "makeDocumentWithContentsOfURL:ofType:error:", NSURL, NSString, id*)(absoluteURL, typeName, &error);
		
		if (error)
			outError = new NSError(error);
		
		return result;
	}

	bool reopenDocumentForURL (NSURL absoluteDocumentURL, NSURL absoluteDocumentContentsURL, ref NSError outError)
	{
		id error;
		
		if (outError)
			error = new objc_object;
		
		bool result = invokeObjcSelf!(bool, "reopenDocumentForURL:withContentsOfURL:error:", NSURL, NSURL, id*)(absoluteDocumentURL, absoluteDocumentContentsURL, &error);
		
		if (error)
			outError = new NSError(error);
		
		return result;
	}

	Object makeDocumentForURL (NSURL absoluteDocumentURL, NSURL absoluteDocumentContentsURL, NSString typeName, ref NSError outError)
	{
		id error;
		
		if (outError)
			error = new objc_object;
		
		Object result = invokeObjcSelf!(Object, "makeDocumentForURL:withContentsOfURL:ofType:error:", NSURL, NSURL, NSString, id*)(absoluteDocumentURL, absoluteDocumentContentsURL, typeName, &error);
		
		if (error)
			outError = new NSError(error);
		
		return result;
	}

	void setAutosavingDelay (double autosavingDelay)
	{
		return invokeObjcSelf!(void, "setAutosavingDelay:", double)(autosavingDelay);
	}

	double autosavingDelay ()
	{
		return invokeObjcSelf!(double, "autosavingDelay");
	}

	void saveAllDocuments (Object sender)
	{
		return invokeObjcSelf!(void, "saveAllDocuments:", Object)(sender);
	}

	bool hasEditedDocuments ()
	{
		return invokeObjcSelf!(bool, "hasEditedDocuments");
	}

	void reviewUnsavedDocumentsWithAlertTitle (NSString title, bool cancellable, Object delegate_, SEL didReviewAllSelector, void* contextInfo)
	{
		return invokeObjcSelf!(void, "reviewUnsavedDocumentsWithAlertTitle:cancellable:delegate:didReviewAllSelector:contextInfo:", NSString, bool, Object, SEL, void*)(title, cancellable, delegate_, didReviewAllSelector, contextInfo);
	}

	void closeAllDocumentsWithDelegate (Object delegate_, SEL didCloseAllSelector, void* contextInfo)
	{
		return invokeObjcSelf!(void, "closeAllDocumentsWithDelegate:didCloseAllSelector:contextInfo:", Object, SEL, void*)(delegate_, didCloseAllSelector, contextInfo);
	}

	void presentError (NSError error, NSWindow window, Object delegate_, SEL didPresentSelector, void* contextInfo)
	{
		return invokeObjcSelf!(void, "presentError:modalForWindow:delegate:didPresentSelector:contextInfo:", NSError, NSWindow, Object, SEL, void*)(error, window, delegate_, didPresentSelector, contextInfo);
	}

	bool presentError (NSError error)
	{
		return invokeObjcSelf!(bool, "presentError:", NSError)(error);
	}

	NSError willPresentError (NSError error)
	{
		return invokeObjcSelf!(NSError, "willPresentError:", NSError)(error);
	}

	NSUInteger maximumRecentDocumentCount ()
	{
		return invokeObjcSelf!(NSUInteger, "maximumRecentDocumentCount");
	}

	void clearRecentDocuments (Object sender)
	{
		return invokeObjcSelf!(void, "clearRecentDocuments:", Object)(sender);
	}

	void noteNewRecentDocument (NSDocument document)
	{
		return invokeObjcSelf!(void, "noteNewRecentDocument:", NSDocument)(document);
	}

	void noteNewRecentDocumentURL (NSURL absoluteURL)
	{
		return invokeObjcSelf!(void, "noteNewRecentDocumentURL:", NSURL)(absoluteURL);
	}

	NSArray recentDocumentURLs ()
	{
		return invokeObjcSelf!(NSArray, "recentDocumentURLs");
	}

	NSString defaultType ()
	{
		return invokeObjcSelf!(NSString, "defaultType");
	}

	NSString typeForContentsOfURL (NSURL inAbsoluteURL, ref NSError outError)
	{
		id error;
		
		if (outError)
			error = new objc_object;
		
		NSString result = invokeObjcSelf!(NSString, "typeForContentsOfURL:error:", NSURL, id*)(inAbsoluteURL, &error);
		
		if (error)
			outError = new NSError(error);
		
		return result;
	}

	NSArray documentClassNames ()
	{
		return invokeObjcSelf!(NSArray, "documentClassNames");
	}

	Class documentClassForType (NSString typeName)
	{
		return invokeObjcSelf!(Class, "documentClassForType:", NSString)(typeName);
	}

	NSString displayNameForType (NSString typeName)
	{
		return invokeObjcSelf!(NSString, "displayNameForType:", NSString)(typeName);
	}

	bool validateUserInterfaceItem (INSValidatedUserInterfaceItem anItem)
	{
		return invokeObjcSelf!(bool, "validateUserInterfaceItem:", INSValidatedUserInterfaceItem)(anItem);
	}
}