view dstep/foundation/NSUndoManager.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 89f3c3ef1fd2
children b9de51448c6b
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.NSUndoManager;

import dstep.foundation.NSArray;
import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSObject;
import dstep.foundation.NSString;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;



import bindings = dstep.foundation.NSUndoManager_bindings;

private
{
	NSString NSUndoManagerCheckpointNotification_;
	NSString NSUndoManagerWillUndoChangeNotification_;
	NSString NSUndoManagerWillRedoChangeNotification_;
	NSString NSUndoManagerDidUndoChangeNotification_;
	NSString NSUndoManagerDidRedoChangeNotification_;
	NSString NSUndoManagerDidOpenUndoGroupNotification_;
	NSString NSUndoManagerWillCloseUndoGroupNotification_;
}

NSString NSUndoManagerCheckpointNotification ()
{
	if (NSUndoManagerCheckpointNotification_)
		return NSUndoManagerCheckpointNotification_;
		
	return NSUndoManagerCheckpointNotification_ = new NSString(bindings.NSUndoManagerCheckpointNotification);
}

NSString NSUndoManagerWillUndoChangeNotification ()
{
	if (NSUndoManagerWillUndoChangeNotification_)
		return NSUndoManagerWillUndoChangeNotification_;
		
	return NSUndoManagerWillUndoChangeNotification_ = new NSString(bindings.NSUndoManagerWillUndoChangeNotification);
}

NSString NSUndoManagerWillRedoChangeNotification ()
{
	if (NSUndoManagerWillRedoChangeNotification_)
		return NSUndoManagerWillRedoChangeNotification_;
		
	return NSUndoManagerWillRedoChangeNotification_ = new NSString(bindings.NSUndoManagerWillRedoChangeNotification);
}

NSString NSUndoManagerDidUndoChangeNotification ()
{
	if (NSUndoManagerDidUndoChangeNotification_)
		return NSUndoManagerDidUndoChangeNotification_;
		
	return NSUndoManagerDidUndoChangeNotification_ = new NSString(bindings.NSUndoManagerDidUndoChangeNotification);
}

NSString NSUndoManagerDidRedoChangeNotification ()
{
	if (NSUndoManagerDidRedoChangeNotification_)
		return NSUndoManagerDidRedoChangeNotification_;
		
	return NSUndoManagerDidRedoChangeNotification_ = new NSString(bindings.NSUndoManagerDidRedoChangeNotification);
}

NSString NSUndoManagerDidOpenUndoGroupNotification ()
{
	if (NSUndoManagerDidOpenUndoGroupNotification_)
		return NSUndoManagerDidOpenUndoGroupNotification_;
		
	return NSUndoManagerDidOpenUndoGroupNotification_ = new NSString(bindings.NSUndoManagerDidOpenUndoGroupNotification);
}

NSString NSUndoManagerWillCloseUndoGroupNotification ()
{
	if (NSUndoManagerWillCloseUndoGroupNotification_)
		return NSUndoManagerWillCloseUndoGroupNotification_;
		
	return NSUndoManagerWillCloseUndoGroupNotification_ = new NSString(bindings.NSUndoManagerWillCloseUndoGroupNotification);
}

enum
{
	NSUndoCloseGroupingRunLoopOrdering = 350000
}

class NSUndoManager : NSObject
{
	mixin (ObjcWrap);
	
	this ()
	{
		super(typeof(this).alloc.init.objcObject);
	}
	
	typeof(this) init ()
	{
		return invokeObjcSelf!(typeof(this), "init");
	}
	
	void beginUndoGrouping ()
	{
		return invokeObjcSelf!(void, "beginUndoGrouping");
	}

	void endUndoGrouping ()
	{
		return invokeObjcSelf!(void, "endUndoGrouping");
	}

	NSInteger groupingLevel ()
	{
		return invokeObjcSelf!(NSInteger, "groupingLevel");
	}

	void disableUndoRegistration ()
	{
		return invokeObjcSelf!(void, "disableUndoRegistration");
	}

	void enableUndoRegistration ()
	{
		return invokeObjcSelf!(void, "enableUndoRegistration");
	}

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

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

	void setGroupsByEvent (bool groupsByEvent)
	{
		return invokeObjcSelf!(void, "setGroupsByEvent:", bool)(groupsByEvent);
	}

	void setLevelsOfUndo (NSUInteger levels)
	{
		return invokeObjcSelf!(void, "setLevelsOfUndo:", NSUInteger)(levels);
	}

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

	void setRunLoopModes (NSArray runLoopModes)
	{
		return invokeObjcSelf!(void, "setRunLoopModes:", NSArray)(runLoopModes);
	}

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

	void undo ()
	{
		return invokeObjcSelf!(void, "undo");
	}

	void redo ()
	{
		return invokeObjcSelf!(void, "redo");
	}

	void undoNestedGroup ()
	{
		return invokeObjcSelf!(void, "undoNestedGroup");
	}

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

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

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

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

	void removeAllActions ()
	{
		return invokeObjcSelf!(void, "removeAllActions");
	}

	void removeAllActionsWithTarget (Object target)
	{
		return invokeObjcSelf!(void, "removeAllActionsWithTarget:", Object)(target);
	}

	void registerUndoWithTarget (Object target, SEL selector, Object anObject)
	{
		return invokeObjcSelf!(void, "registerUndoWithTarget:selector:object:", Object, SEL, Object)(target, selector, anObject);
	}

	Object prepareWithInvocationTarget (Object target)
	{
		return invokeObjcSelf!(Object, "prepareWithInvocationTarget:", Object)(target);
	}

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

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

	void setActionName (NSString actionName)
	{
		return invokeObjcSelf!(void, "setActionName:", NSString)(actionName);
	}

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

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

	NSString undoMenuTitleForUndoActionName (NSString actionName)
	{
		return invokeObjcSelf!(NSString, "undoMenuTitleForUndoActionName:", NSString)(actionName);
	}

	NSString redoMenuTitleForUndoActionName (NSString actionName)
	{
		return invokeObjcSelf!(NSString, "redoMenuTitleForUndoActionName:", NSString)(actionName);
	}
}