view dstep/appkit/NSOpenPanel.d @ 16:19885b43130e

Huge update, the bridge actually works now
author Jacob Carlborg <doob@me.com>
date Sun, 03 Jan 2010 22:06:11 +0100
parents
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.NSOpenPanel;

import dstep.appkit.NSSavePanel;
import dstep.foundation.NSArray;
import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSString;
import dstep.appkit.NSWindow;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;

const TNSOpenPanelRuntime = `

	void beginSheetForDirectory (NSString path, NSString name, NSArray fileTypes, NSWindow docWindow, Object delegate_, SEL didEndSelector, void* contextInfo)
	{
		return invokeObjcSelf!(void, "beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:", NSString, NSString, NSArray, NSWindow, Object, SEL, void*)(path, name, fileTypes, docWindow, delegate_, didEndSelector, contextInfo);
	}

	void beginForDirectory (NSString path, NSString name, NSArray fileTypes, Object delegate_, SEL didEndSelector, void* contextInfo)
	{
		return invokeObjcSelf!(void, "beginForDirectory:file:types:modelessDelegate:didEndSelector:contextInfo:", NSString, NSString, NSArray, Object, SEL, void*)(path, name, fileTypes, delegate_, didEndSelector, contextInfo);
	}

	NSInteger runModalForDirectory (NSString path, NSString name, NSArray fileTypes)
	{
		return invokeObjcSelf!(NSInteger, "runModalForDirectory:file:types:", NSString, NSString, NSArray)(path, name, fileTypes);
	}

	NSInteger runModalForTypes (NSArray fileTypes)
	{
		return invokeObjcSelf!(NSInteger, "runModalForTypes:", NSArray)(fileTypes);
	}

	//mixin ObjcBindMethod!(beginSheetForDirectory, "beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:");
	//mixin ObjcBindMethod!(beginForDirectory, "beginForDirectory:file:types:modelessDelegate:didEndSelector:contextInfo:");
	//mixin ObjcBindMethod!(runModalForDirectory, "runModalForDirectory:file:types:");
	//mixin ObjcBindMethod!(runModalForTypes, "runModalForTypes:");

`;

class NSOpenPanel : NSSavePanel
{
	mixin (ObjcWrap);

	static NSOpenPanel openPanel ()
	{
		return invokeObjcSelfClass!(NSOpenPanel, "openPanel");
	}

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

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

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

	void setResolvesAliases (bool flag)
	{
		return invokeObjcSelf!(void, "setResolvesAliases:", bool)(flag);
	}

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

	void setCanChooseDirectories (bool flag)
	{
		return invokeObjcSelf!(void, "setCanChooseDirectories:", bool)(flag);
	}

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

	void setAllowsMultipleSelection (bool flag)
	{
		return invokeObjcSelf!(void, "setAllowsMultipleSelection:", bool)(flag);
	}

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

	void setCanChooseFiles (bool flag)
	{
		return invokeObjcSelf!(void, "setCanChooseFiles:", bool)(flag);
	}
	
	// NSOpenPanelRuntime
	void beginSheetForDirectory (NSString path, NSString name, NSArray fileTypes, NSWindow docWindow, Object delegate_, SEL didEndSelector, void* contextInfo)
	{
		return invokeObjcSelf!(void, "beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:", NSString, NSString, NSArray, NSWindow, Object, SEL, void*)(path, name, fileTypes, docWindow, delegate_, didEndSelector, contextInfo);
	}

	void beginForDirectory (NSString path, NSString name, NSArray fileTypes, Object delegate_, SEL didEndSelector, void* contextInfo)
	{
		return invokeObjcSelf!(void, "beginForDirectory:file:types:modelessDelegate:didEndSelector:contextInfo:", NSString, NSString, NSArray, Object, SEL, void*)(path, name, fileTypes, delegate_, didEndSelector, contextInfo);
	}

	NSInteger runModalForDirectory (NSString path, NSString name, NSArray fileTypes)
	{
		return invokeObjcSelf!(NSInteger, "runModalForDirectory:file:types:", NSString, NSString, NSArray)(path, name, fileTypes);
	}

	NSInteger runModalForTypes (NSArray fileTypes)
	{
		return invokeObjcSelf!(NSInteger, "runModalForTypes:", NSArray)(fileTypes);
	}
}