view dstep/foundation/NSAppleEventManager.d @ 15:7ff919f595d5

Added the Foundation framework, again
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:31:48 +0200
parents 89f3c3ef1fd2
children 19885b43130e
line wrap: on
line source

/**
 * Copyright: Copyright (c) 2009 Jacob Carlborg.
 * Authors: Jacob Carlborg
 * Version: Initial created: Aug 3, 2009 
 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
 */
module dstep.foundation.NSAppleEventManager;

import dstep.applicationservices.ApplicationServices;
import dstep.foundation.NSAppleEventDescriptor;
import dstep.foundation.NSObject;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc : id;

import bindings = dstep.foundation.NSAppleEventManager_bindings;

alias __NSAppleEventManagerSuspension* NSAppleEventManagerSuspensionID;

extern (C)
{
	extern
	{
		const double NSAppleEventTimeOutDefault;
		const double NSAppleEventTimeOutNone;
	}
}

NSString NSAppleEventManagerWillProcessFirstEventNotification;

static this ()
{
	NSAppleEventManagerWillProcessFirstEventNotification = new NSString(bindings.NSAppleEventManagerWillProcessFirstEventNotification);
}

class NSAppleEventManager : NSObject
{
	mixin ObjcWrap;

	static NSAppleEventManager sharedAppleEventManager ()
	{
		return invokeObjcSelfClass!(NSAppleEventManager, "sharedAppleEventManager");
	}

	void setEventHandler (Object handler, SEL handleEventSelector, uint eventClass, uint eventID)
	{
		return invokeObjcSelf!(void, "setEventHandler:andSelector:forEventClass:andEventID:", Object, SEL, uint, uint)(handler, handleEventSelector, eventClass, eventID);
	}

	void removeEventHandlerForEventClass (uint eventClass, uint eventID)
	{
		return invokeObjcSelf!(void, "removeEventHandlerForEventClass:andEventID:", uint, uint)(eventClass, eventID);
	}

	short dispatchRawAppleEvent (AppleEvent* theAppleEvent, AppleEvent* theReply, int handlerRefCon)
	{
		return invokeObjcSelf!(short, "dispatchRawAppleEvent:withRawReply:handlerRefCon:", AppleEvent*, AppleEvent*, int)(theAppleEvent, theReply, handlerRefCon);
	}

	NSAppleEventDescriptor currentAppleEvent ()
	{
		return invokeObjcSelf!(NSAppleEventDescriptor, "currentAppleEvent");
	}

	NSAppleEventDescriptor currentReplyAppleEvent ()
	{
		return invokeObjcSelf!(NSAppleEventDescriptor, "currentReplyAppleEvent");
	}

	NSAppleEventManagerSuspensionID suspendCurrentAppleEvent ()
	{
		return invokeObjcSelf!(NSAppleEventManagerSuspensionID, "suspendCurrentAppleEvent");
	}

	NSAppleEventDescriptor appleEventForSuspensionID (NSAppleEventManagerSuspensionID suspensionID)
	{
		return invokeObjcSelf!(NSAppleEventDescriptor, "appleEventForSuspensionID:", NSAppleEventManagerSuspensionID)(suspensionID);
	}

	NSAppleEventDescriptor replyAppleEventForSuspensionID (NSAppleEventManagerSuspensionID suspensionID)
	{
		return invokeObjcSelf!(NSAppleEventDescriptor, "replyAppleEventForSuspensionID:", NSAppleEventManagerSuspensionID)(suspensionID);
	}

	void setCurrentAppleEventAndReplyEventWithSuspensionID (NSAppleEventManagerSuspensionID suspensionID)
	{
		return invokeObjcSelf!(void, "setCurrentAppleEventAndReplyEventWithSuspensionID:", NSAppleEventManagerSuspensionID)(suspensionID);
	}

	void resumeWithSuspensionID (NSAppleEventManagerSuspensionID suspensionID)
	{
		return invokeObjcSelf!(void, "resumeWithSuspensionID:", NSAppleEventManagerSuspensionID)(suspensionID);
	}
}