view dstep/appkit/NSInputServer.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.NSInputServer;

import dstep.foundation.NSGeometry;
import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSObject;
import dstep.foundation.NSRange;
import dstep.foundation.NSString;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;

class NSInputServer : NSObject, INSInputServiceProvider, INSInputServerMouseTracker
{
	mixin (ObjcWrap);

	NSInputServer initWithDelegate (Object aDelegate, NSString name)
	{
		id result = invokeObjcSelf!(id, "initWithDelegate:name:", Object, NSString)(aDelegate, name);
		return result is this.objcObject ? this : (result !is null ? new NSInputServer(result) : null);
	}

	this (Object aDelegate, NSString name)
	{
		super(NSInputServer.alloc.initWithDelegate(aDelegate, name).objcObject);
	}

	void insertText (Object aString, Object sender)
	{
		return invokeObjcSelf!(void, "insertText:client:", Object, Object)(aString, sender);
	}

	void doCommandBySelector (SEL aSelector, Object sender)
	{
		return invokeObjcSelf!(void, "doCommandBySelector:client:", SEL, Object)(aSelector, sender);
	}

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

	void markedTextSelectionChanged (NSRange newSel, Object sender)
	{
		return invokeObjcSelf!(void, "markedTextSelectionChanged:client:", NSRange, Object)(newSel, sender);
	}

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

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

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

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

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

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

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

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

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

	void activeConversationWillChange (Object sender, NSInteger oldConversation)
	{
		return invokeObjcSelf!(void, "activeConversationWillChange:fromOldConversation:", Object, NSInteger)(sender, oldConversation);
	}

	void activeConversationChanged (Object sender, NSInteger newConversation)
	{
		return invokeObjcSelf!(void, "activeConversationChanged:toNewConversation:", Object, NSInteger)(sender, newConversation);
	}

	bool mouseDownOnCharacterIndex (NSUInteger theIndex, NSPoint thePoint, NSUInteger theFlags, Object sender)
	{
		return invokeObjcSelf!(bool, "mouseDownOnCharacterIndex:atCoordinate:withModifier:client:", NSUInteger, NSPoint, NSUInteger, Object)(theIndex, thePoint, theFlags, sender);
	}

	bool mouseDraggedOnCharacterIndex (NSUInteger theIndex, NSPoint thePoint, NSUInteger theFlags, Object sender)
	{
		return invokeObjcSelf!(bool, "mouseDraggedOnCharacterIndex:atCoordinate:withModifier:client:", NSUInteger, NSPoint, NSUInteger, Object)(theIndex, thePoint, theFlags, sender);
	}

	void mouseUpOnCharacterIndex (NSUInteger theIndex, NSPoint thePoint, NSUInteger theFlags, Object sender)
	{
		return invokeObjcSelf!(void, "mouseUpOnCharacterIndex:atCoordinate:withModifier:client:", NSUInteger, NSPoint, NSUInteger, Object)(theIndex, thePoint, theFlags, sender);
	}
}

interface INSInputServiceProvider
{
	void insertText (Object aString, Object sender);
	void doCommandBySelector (SEL aSelector, Object sender);
	void markedTextAbandoned (Object sender);
	void markedTextSelectionChanged (NSRange newSel, Object sender);
	void terminate (Object sender);
	bool canBeDisabled ();
	bool wantsToInterpretAllKeystrokes ();
	bool wantsToHandleMouseEvents ();
	bool wantsToDelayTextChangeNotifications ();
	void inputClientBecomeActive (Object sender);
	void inputClientResignActive (Object sender);
	void inputClientEnabled (Object sender);
	void inputClientDisabled (Object sender);
	void activeConversationWillChange (Object sender, NSInteger oldConversation);
	void activeConversationChanged (Object sender, NSInteger newConversation);
}

interface INSInputServerMouseTracker
{
	bool mouseDownOnCharacterIndex (NSUInteger theIndex, NSPoint thePoint, NSUInteger theFlags, Object sender);
	bool mouseDraggedOnCharacterIndex (NSUInteger theIndex, NSPoint thePoint, NSUInteger theFlags, Object sender);
	void mouseUpOnCharacterIndex (NSUInteger theIndex, NSPoint thePoint, NSUInteger theFlags, Object sender);
}