Mercurial > projects > dwt-mac
diff dwt/internal/cocoa/NSRunLoop.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | 8b48be5454ce |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/cocoa/NSRunLoop.d Sat Aug 09 17:00:02 2008 +0200 @@ -0,0 +1,127 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * + * Port to the D Programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> + *******************************************************************************/ +module dwt.internal.cocoa.NSRunLoop; + +import dwt.internal.cocoa.CFRunLoopRef; +import dwt.internal.cocoa.id; +import dwt.internal.cocoa.NSArray; +import dwt.internal.cocoa.NSDate; +import dwt.internal.cocoa.NSInteger; +import dwt.internal.cocoa.NSObject; +import dwt.internal.cocoa.NSPort; +import dwt.internal.cocoa.NSString; +import dwt.internal.cocoa.NSTimer; +import dwt.internal.cocoa.OS; +import objc = dwt.internal.objc.runtime; + +public class NSRunLoop : NSObject +{ + + public this () + { + super(); + } + + public this (objc.id id) + { + super(id); + } + + public void acceptInputForMode (NSString mode, NSDate limitDate) + { + OS.objc_msgSend(this.id, OS.sel_acceptInputForMode_1beforeDate_1, mode !is null ? mode.id : null, limitDate !is null ? limitDate.id : null); + } + + public void addPort (NSPort aPort, NSString mode) + { + OS.objc_msgSend(this.id, OS.sel_addPort_1forMode_1, aPort !is null ? aPort.id : null, mode !is null ? mode.id : null); + } + + public void addTimer (NSTimer timer, NSString mode) + { + OS.objc_msgSend(this.id, OS.sel_addTimer_1forMode_1, timer !is null ? timer.id : null, mode !is null ? mode.id : null); + } + + public void cancelPerformSelector (objc.SEL aSelector, id target, id arg) + { + OS.objc_msgSend(this.id, OS.sel_cancelPerformSelector_1target_1argument_1, aSelector, target !is null ? target.id : null, + arg !is null ? arg.id : null); + } + + public void cancelPerformSelectorsWithTarget (id target) + { + OS.objc_msgSend(this.id, OS.sel_cancelPerformSelectorsWithTarget_1, target !is null ? target.id : null); + } + + public void configureAsServer () + { + OS.objc_msgSend(this.id, OS.sel_configureAsServer); + } + + public NSString currentMode () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_currentMode); + return result !is null ? new NSString(result) : null; + } + + public static NSRunLoop currentRunLoop () + { + objc.id result = OS.objc_msgSend(OS.class_NSRunLoop, OS.sel_currentRunLoop); + return result !is null ? new NSRunLoop(result) : null; + } + + public CFRunLoopRef getCFRunLoop () + { + return OS.objc_msgSend(this.id, OS.sel_getCFRunLoop); + } + + public NSDate limitDateForMode (NSString mode) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_limitDateForMode_1, mode !is null ? mode.id : null); + return result !is null ? new NSDate(result) : null; + } + + public static NSRunLoop mainRunLoop () + { + objc.id result = OS.objc_msgSend(OS.class_NSRunLoop, OS.sel_mainRunLoop); + return result !is null ? new NSRunLoop(result) : null; + } + + public void performSelector (objc.SEL aSelector, id target, id arg, NSUInteger order, NSArray modes) + { + OS.objc_msgSend(this.id, OS.sel_performSelector_1target_1argument_1order_1modes_1, aSelector, target !is null ? target.id : null, + arg !is null ? arg.id : null, order, modes !is null ? modes.id : null); + } + + public void removePort (NSPort aPort, NSString mode) + { + OS.objc_msgSend(this.id, OS.sel_removePort_1forMode_1, aPort !is null ? aPort.id : null, mode !is null ? mode.id : null); + } + + public void run () + { + OS.objc_msgSend(this.id, OS.sel_run); + } + + public bool runMode (NSString mode, NSDate limitDate) + { + return OS.objc_msgSend(this.id, OS.sel_runMode_1beforeDate_1, mode !is null ? mode.id : null, limitDate !is null ? limitDate.id : null) !is null; + } + + public void runUntilDate (NSDate limitDate) + { + OS.objc_msgSend(this.id, OS.sel_runUntilDate_1, limitDate !is null ? limitDate.id : null); + } + +}