Mercurial > projects > dstep
diff dstep/appkit/NSApplication.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 diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dstep/appkit/NSApplication.d Sun Jan 03 22:06:11 2010 +0100 @@ -0,0 +1,1022 @@ +/** + * 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.NSApplication; + +import dstep.appkit.AppKitDefines; +import dstep.appkit.NSColorPanel; +import dstep.appkit.NSDockTile; +import dstep.appkit.NSEvent; +import dstep.appkit.NSGraphicsContext; +import dstep.appkit.NSHelpManager; +import dstep.appkit.NSImage; +import dstep.appkit.NSMenu; +import dstep.appkit.NSPageLayout; +import dstep.appkit.NSPasteboard; +import dstep.appkit.NSResponder; +import dstep.appkit.NSUserInterfaceValidation; +import dstep.appkit.NSWindow; +import dstep.foundation.NSArray; +import dstep.foundation.NSDate; +import dstep.foundation.NSDictionary; +import dstep.foundation.NSError; +import dstep.foundation.NSException; +import dstep.foundation.NSNotification; +import dstep.foundation.NSObjCRuntime; +import dstep.foundation.NSString; +import dstep.internal.String; +import dstep.objc.bridge.Bridge; +import dstep.objc.objc; + +import bindings = dstep.appkit.NSApplication_bindings; + +struct _NSModalSession; +struct NSThreadPrivate; + +alias _NSModalSession* NSModalSession; +alias NSThreadPrivate _NSThreadPrivate; +alias NSUInteger NSRequestUserAttentionType; +alias NSUInteger NSApplicationDelegateReply; +alias NSUInteger NSApplicationTerminateReply; +alias NSUInteger NSApplicationPrintReply; + +extern (C) +{ + extern + { + const double NSAppKitVersionNumber; + } +} + +private +{ + NSString NSModalPanelRunLoopMode_; + NSString NSEventTrackingRunLoopMode_; + NSApplication NSApp_; + NSString NSApplicationDidBecomeActiveNotification_; + NSString NSApplicationDidHideNotification_; + NSString NSApplicationDidFinishLaunchingNotification_; + NSString NSApplicationDidResignActiveNotification_; + NSString NSApplicationDidUnhideNotification_; + NSString NSApplicationDidUpdateNotification_; + NSString NSApplicationWillBecomeActiveNotification_; + NSString NSApplicationWillHideNotification_; + NSString NSApplicationWillFinishLaunchingNotification_; + NSString NSApplicationWillResignActiveNotification_; + NSString NSApplicationWillUnhideNotification_; + NSString NSApplicationWillUpdateNotification_; + NSString NSApplicationWillTerminateNotification_; + NSString NSApplicationDidChangeScreenParametersNotification_; +} + +NSString NSModalPanelRunLoopMode () +{ + if (NSModalPanelRunLoopMode_) + return NSModalPanelRunLoopMode_; + + return NSModalPanelRunLoopMode_ = new NSString(bindings.NSModalPanelRunLoopMode); +} + +NSString NSEventTrackingRunLoopMode () +{ + if (NSEventTrackingRunLoopMode_) + return NSEventTrackingRunLoopMode_; + + return NSEventTrackingRunLoopMode_ = new NSString(bindings.NSEventTrackingRunLoopMode); +} + +NSApplication NSApp () +{ + if (NSApp_) + return NSApp_; + + return NSApp_ = new NSApplication(bindings.NSApp); +} + +NSString NSApplicationDidBecomeActiveNotification () +{ + if (NSApplicationDidBecomeActiveNotification_) + return NSApplicationDidBecomeActiveNotification_; + + return NSApplicationDidBecomeActiveNotification_ = new NSString(bindings.NSApplicationDidBecomeActiveNotification); +} + +NSString NSApplicationDidHideNotification () +{ + if (NSApplicationDidHideNotification_) + return NSApplicationDidHideNotification_; + + return NSApplicationDidHideNotification_ = new NSString(bindings.NSApplicationDidHideNotification); +} + +NSString NSApplicationDidFinishLaunchingNotification () +{ + if (NSApplicationDidFinishLaunchingNotification_) + return NSApplicationDidFinishLaunchingNotification_; + + return NSApplicationDidFinishLaunchingNotification_ = new NSString(bindings.NSApplicationDidFinishLaunchingNotification); +} + +NSString NSApplicationDidResignActiveNotification () +{ + if (NSApplicationDidResignActiveNotification_) + return NSApplicationDidResignActiveNotification_; + + return NSApplicationDidResignActiveNotification_ = new NSString(bindings.NSApplicationDidResignActiveNotification); +} + +NSString NSApplicationDidUnhideNotification () +{ + if (NSApplicationDidUnhideNotification_) + return NSApplicationDidUnhideNotification_; + + return NSApplicationDidUnhideNotification_ = new NSString(bindings.NSApplicationDidUnhideNotification); +} + +NSString NSApplicationDidUpdateNotification () +{ + if (NSApplicationDidUpdateNotification_) + return NSApplicationDidUpdateNotification_; + + return NSApplicationDidUpdateNotification_ = new NSString(bindings.NSApplicationDidUpdateNotification); +} + +NSString NSApplicationWillBecomeActiveNotification () +{ + if (NSApplicationWillBecomeActiveNotification_) + return NSApplicationWillBecomeActiveNotification_; + + return NSApplicationWillBecomeActiveNotification_ = new NSString(bindings.NSApplicationWillBecomeActiveNotification); +} + +NSString NSApplicationWillHideNotification () +{ + if (NSApplicationWillHideNotification_) + return NSApplicationWillHideNotification_; + + return NSApplicationWillHideNotification_ = new NSString(bindings.NSApplicationWillHideNotification); +} + +NSString NSApplicationWillFinishLaunchingNotification () +{ + if (NSApplicationWillFinishLaunchingNotification_) + return NSApplicationWillFinishLaunchingNotification_; + + return NSApplicationWillFinishLaunchingNotification_ = new NSString(bindings.NSApplicationWillFinishLaunchingNotification); +} + +NSString NSApplicationWillResignActiveNotification () +{ + if (NSApplicationWillResignActiveNotification_) + return NSApplicationWillResignActiveNotification_; + + return NSApplicationWillResignActiveNotification_ = new NSString(bindings.NSApplicationWillResignActiveNotification); +} + +NSString NSApplicationWillUnhideNotification () +{ + if (NSApplicationWillUnhideNotification_) + return NSApplicationWillUnhideNotification_; + + return NSApplicationWillUnhideNotification_ = new NSString(bindings.NSApplicationWillUnhideNotification); +} + +NSString NSApplicationWillUpdateNotification () +{ + if (NSApplicationWillUpdateNotification_) + return NSApplicationWillUpdateNotification_; + + return NSApplicationWillUpdateNotification_ = new NSString(bindings.NSApplicationWillUpdateNotification); +} + +NSString NSApplicationWillTerminateNotification () +{ + if (NSApplicationWillTerminateNotification_) + return NSApplicationWillTerminateNotification_; + + return NSApplicationWillTerminateNotification_ = new NSString(bindings.NSApplicationWillTerminateNotification); +} + +NSString NSApplicationDidChangeScreenParametersNotification () +{ + if (NSApplicationDidChangeScreenParametersNotification_) + return NSApplicationDidChangeScreenParametersNotification_; + + return NSApplicationDidChangeScreenParametersNotification_ = new NSString(bindings.NSApplicationDidChangeScreenParametersNotification); +} + +enum +{ + NSRunStoppedResponse = (-1000), + NSRunAbortedResponse = (-1001), + NSRunContinuesResponse = (-1002) +} + +enum +{ + NSUpdateWindowsRunLoopOrdering = 500000 +} + +enum +{ + NSCriticalRequest = 0, + NSInformationalRequest = 10 +} + +enum +{ + NSApplicationDelegateReplySuccess = 0, + NSApplicationDelegateReplyCancel = 1, + NSApplicationDelegateReplyFailure = 2 +} + +enum +{ + NSTerminateCancel = 0, + NSTerminateNow = 1, + NSTerminateLater = 2 +} + +enum +{ + NSPrintingCancelled = 0, + NSPrintingSuccess = 1, + NSPrintingFailure = 3, + NSPrintingReplyLater = 2 +} + +const TNSServicesMenu = ` + + void setServicesMenu (NSMenu aMenu) + { + return invokeObjcSelf!(void, "setServicesMenu:", NSMenu)(aMenu); + } + + NSMenu servicesMenu () + { + return invokeObjcSelf!(NSMenu, "servicesMenu"); + } + + void registerServicesMenuSendTypes (NSArray sendTypes, NSArray returnTypes) + { + return invokeObjcSelf!(void, "registerServicesMenuSendTypes:returnTypes:", NSArray, NSArray)(sendTypes, returnTypes); + } + + //mixin ObjcBindMethod!(setServicesMenu, "setServicesMenu:"); + //mixin ObjcBindMethod!(servicesMenu, "servicesMenu"); + //mixin ObjcBindMethod!(registerServicesMenuSendTypes, "registerServicesMenuSendTypes:returnTypes:"); + +`; + +const TNSServicesRequests = ` + + bool writeSelectionToPasteboard (NSPasteboard pboard, NSArray types) + { + return invokeObjcSelf!(bool, "writeSelectionToPasteboard:types:", NSPasteboard, NSArray)(pboard, types); + } + + bool readSelectionFromPasteboard (NSPasteboard pboard) + { + return invokeObjcSelf!(bool, "readSelectionFromPasteboard:", NSPasteboard)(pboard); + } + + //mixin ObjcBindMethod!(writeSelectionToPasteboard, "writeSelectionToPasteboard:types:"); + //mixin ObjcBindMethod!(readSelectionFromPasteboard, "readSelectionFromPasteboard:"); + +`; + +const TNSStandardAboutPanel = ` + + void orderFrontStandardAboutPanel (Object sender) + { + return invokeObjcSelf!(void, "orderFrontStandardAboutPanel:", Object)(sender); + } + + void orderFrontStandardAboutPanelWithOptions (NSDictionary optionsDictionary) + { + return invokeObjcSelf!(void, "orderFrontStandardAboutPanelWithOptions:", NSDictionary)(optionsDictionary); + } + + //mixin ObjcBindMethod!(orderFrontStandardAboutPanel, "orderFrontStandardAboutPanel:"); + //mixin ObjcBindMethod!(orderFrontStandardAboutPanelWithOptions, "orderFrontStandardAboutPanelWithOptions:"); + +`; + +const TNSWindowsMenu = ` + + void setWindowsMenu (NSMenu aMenu) + { + return invokeObjcSelf!(void, "setWindowsMenu:", NSMenu)(aMenu); + } + + NSMenu windowsMenu () + { + return invokeObjcSelf!(NSMenu, "windowsMenu"); + } + + void arrangeInFront (Object sender) + { + return invokeObjcSelf!(void, "arrangeInFront:", Object)(sender); + } + + void removeWindowsItem (NSWindow win) + { + return invokeObjcSelf!(void, "removeWindowsItem:", NSWindow)(win); + } + + void addWindowsItem (NSWindow win, NSString aString, bool isFilename) + { + return invokeObjcSelf!(void, "addWindowsItem:title:filename:", NSWindow, NSString, bool)(win, aString, isFilename); + } + + void changeWindowsItem (NSWindow win, NSString aString, bool isFilename) + { + return invokeObjcSelf!(void, "changeWindowsItem:title:filename:", NSWindow, NSString, bool)(win, aString, isFilename); + } + + void updateWindowsItem (NSWindow win) + { + return invokeObjcSelf!(void, "updateWindowsItem:", NSWindow)(win); + } + + void miniaturizeAll (Object sender) + { + return invokeObjcSelf!(void, "miniaturizeAll:", Object)(sender); + } + + //mixin ObjcBindMethod!(setWindowsMenu, "setWindowsMenu:"); + //mixin ObjcBindMethod!(windowsMenu, "windowsMenu"); + //mixin ObjcBindMethod!(arrangeInFront, "arrangeInFront:"); + //mixin ObjcBindMethod!(removeWindowsItem, "removeWindowsItem:"); + //mixin ObjcBindMethod!(addWindowsItem, "addWindowsItem:title:filename:"); + //mixin ObjcBindMethod!(changeWindowsItem, "changeWindowsItem:title:filename:"); + //mixin ObjcBindMethod!(updateWindowsItem, "updateWindowsItem:"); + //mixin ObjcBindMethod!(miniaturizeAll, "miniaturizeAll:"); + +`; + +const TNSApplicationDelegate = ` + + uint applicationShouldTerminate (NSApplication sender) + { + return invokeObjcSelf!(uint, "applicationShouldTerminate:", NSApplication)(sender); + } + + bool application (NSApplication sender, NSString filename) + { + return invokeObjcSelf!(bool, "application:openFile:", NSApplication, NSString)(sender, filename); + } + + void application (NSApplication sender, NSArray filenames) + { + return invokeObjcSelf!(void, "application:openFiles:", NSApplication, NSArray)(sender, filenames); + } + + bool application (NSApplication sender, NSString filename) + { + return invokeObjcSelf!(bool, "application:openTempFile:", NSApplication, NSString)(sender, filename); + } + + bool applicationShouldOpenUntitledFile (NSApplication sender) + { + return invokeObjcSelf!(bool, "applicationShouldOpenUntitledFile:", NSApplication)(sender); + } + + bool applicationOpenUntitledFile (NSApplication sender) + { + return invokeObjcSelf!(bool, "applicationOpenUntitledFile:", NSApplication)(sender); + } + + bool application (Object sender, NSString filename) + { + return invokeObjcSelf!(bool, "application:openFileWithoutUI:", Object, NSString)(sender, filename); + } + + bool application (NSApplication sender, NSString filename) + { + return invokeObjcSelf!(bool, "application:printFile:", NSApplication, NSString)(sender, filename); + } + + uint application (NSApplication application, NSArray fileNames, NSDictionary printSettings, bool showPrintPanels) + { + return invokeObjcSelf!(uint, "application:printFiles:withSettings:showPrintPanels:", NSApplication, NSArray, NSDictionary, bool)(application, fileNames, printSettings, showPrintPanels); + } + + void application (NSApplication sender, NSArray filenames) + { + return invokeObjcSelf!(void, "application:printFiles:", NSApplication, NSArray)(sender, filenames); + } + + bool applicationShouldTerminateAfterLastWindowClosed (NSApplication sender) + { + return invokeObjcSelf!(bool, "applicationShouldTerminateAfterLastWindowClosed:", NSApplication)(sender); + } + + bool applicationShouldHandleReopen (NSApplication sender, bool flag) + { + return invokeObjcSelf!(bool, "applicationShouldHandleReopen:hasVisibleWindows:", NSApplication, bool)(sender, flag); + } + + NSMenu applicationDockMenu (NSApplication sender) + { + return invokeObjcSelf!(NSMenu, "applicationDockMenu:", NSApplication)(sender); + } + + NSError application (NSApplication application, NSError error) + { + return invokeObjcSelf!(NSError, "application:willPresentError:", NSApplication, NSError)(application, error); + } + + //mixin ObjcBindMethod!(applicationShouldTerminate, "applicationShouldTerminate:"); + //mixin ObjcBindMethod!(application, "application:openFile:"); + //mixin ObjcBindMethod!(application, "application:openFiles:"); + //mixin ObjcBindMethod!(application, "application:openTempFile:"); + //mixin ObjcBindMethod!(applicationShouldOpenUntitledFile, "applicationShouldOpenUntitledFile:"); + //mixin ObjcBindMethod!(applicationOpenUntitledFile, "applicationOpenUntitledFile:"); + //mixin ObjcBindMethod!(application, "application:openFileWithoutUI:"); + //mixin ObjcBindMethod!(application, "application:printFile:"); + //mixin ObjcBindMethod!(application, "application:printFiles:withSettings:showPrintPanels:"); + //mixin ObjcBindMethod!(application, "application:printFiles:"); + //mixin ObjcBindMethod!(applicationShouldTerminateAfterLastWindowClosed, "applicationShouldTerminateAfterLastWindowClosed:"); + //mixin ObjcBindMethod!(applicationShouldHandleReopen, "applicationShouldHandleReopen:hasVisibleWindows:"); + //mixin ObjcBindMethod!(applicationDockMenu, "applicationDockMenu:"); + //mixin ObjcBindMethod!(application, "application:willPresentError:"); + +`; + +const TNSApplicationNotifications = ` + + void applicationWillFinishLaunching (NSNotification notification) + { + return invokeObjcSelf!(void, "applicationWillFinishLaunching:", NSNotification)(notification); + } + + void applicationDidFinishLaunching (NSNotification notification) + { + return invokeObjcSelf!(void, "applicationDidFinishLaunching:", NSNotification)(notification); + } + + void applicationWillHide (NSNotification notification) + { + return invokeObjcSelf!(void, "applicationWillHide:", NSNotification)(notification); + } + + void applicationDidHide (NSNotification notification) + { + return invokeObjcSelf!(void, "applicationDidHide:", NSNotification)(notification); + } + + void applicationWillUnhide (NSNotification notification) + { + return invokeObjcSelf!(void, "applicationWillUnhide:", NSNotification)(notification); + } + + void applicationDidUnhide (NSNotification notification) + { + return invokeObjcSelf!(void, "applicationDidUnhide:", NSNotification)(notification); + } + + void applicationWillBecomeActive (NSNotification notification) + { + return invokeObjcSelf!(void, "applicationWillBecomeActive:", NSNotification)(notification); + } + + void applicationDidBecomeActive (NSNotification notification) + { + return invokeObjcSelf!(void, "applicationDidBecomeActive:", NSNotification)(notification); + } + + void applicationWillResignActive (NSNotification notification) + { + return invokeObjcSelf!(void, "applicationWillResignActive:", NSNotification)(notification); + } + + void applicationDidResignActive (NSNotification notification) + { + return invokeObjcSelf!(void, "applicationDidResignActive:", NSNotification)(notification); + } + + void applicationWillUpdate (NSNotification notification) + { + return invokeObjcSelf!(void, "applicationWillUpdate:", NSNotification)(notification); + } + + void applicationDidUpdate (NSNotification notification) + { + return invokeObjcSelf!(void, "applicationDidUpdate:", NSNotification)(notification); + } + + void applicationWillTerminate (NSNotification notification) + { + return invokeObjcSelf!(void, "applicationWillTerminate:", NSNotification)(notification); + } + + void applicationDidChangeScreenParameters (NSNotification notification) + { + return invokeObjcSelf!(void, "applicationDidChangeScreenParameters:", NSNotification)(notification); + } + + //mixin ObjcBindMethod!(applicationWillFinishLaunching, "applicationWillFinishLaunching:"); + //mixin ObjcBindMethod!(applicationDidFinishLaunching, "applicationDidFinishLaunching:"); + //mixin ObjcBindMethod!(applicationWillHide, "applicationWillHide:"); + //mixin ObjcBindMethod!(applicationDidHide, "applicationDidHide:"); + //mixin ObjcBindMethod!(applicationWillUnhide, "applicationWillUnhide:"); + //mixin ObjcBindMethod!(applicationDidUnhide, "applicationDidUnhide:"); + //mixin ObjcBindMethod!(applicationWillBecomeActive, "applicationWillBecomeActive:"); + //mixin ObjcBindMethod!(applicationDidBecomeActive, "applicationDidBecomeActive:"); + //mixin ObjcBindMethod!(applicationWillResignActive, "applicationWillResignActive:"); + //mixin ObjcBindMethod!(applicationDidResignActive, "applicationDidResignActive:"); + //mixin ObjcBindMethod!(applicationWillUpdate, "applicationWillUpdate:"); + //mixin ObjcBindMethod!(applicationDidUpdate, "applicationDidUpdate:"); + //mixin ObjcBindMethod!(applicationWillTerminate, "applicationWillTerminate:"); + //mixin ObjcBindMethod!(applicationDidChangeScreenParameters, "applicationDidChangeScreenParameters:"); + +`; + +const TNSServicesHandling = ` + + void setServicesProvider (Object provider) + { + return invokeObjcSelf!(void, "setServicesProvider:", Object)(provider); + } + + Object servicesProvider () + { + return invokeObjcSelf!(Object, "servicesProvider"); + } + + //mixin ObjcBindMethod!(setServicesProvider, "setServicesProvider:"); + //mixin ObjcBindMethod!(servicesProvider, "servicesProvider"); + +`; + +class NSApplication : NSResponder, INSUserInterfaceValidations +{ + mixin (ObjcWrap); + + static NSApplication sharedApplication () + { + return invokeObjcSelfClass!(NSApplication, "sharedApplication"); + } + + void setDelegate (Object anObject) + { + return invokeObjcSelf!(void, "setDelegate:", Object)(anObject); + } + + Object delegate_ () + { + return invokeObjcSelf!(Object, "delegate"); + } + + NSGraphicsContext context () + { + return invokeObjcSelf!(NSGraphicsContext, "context"); + } + + void hide (Object sender) + { + return invokeObjcSelf!(void, "hide:", Object)(sender); + } + + void unhide (Object sender) + { + return invokeObjcSelf!(void, "unhide:", Object)(sender); + } + + void unhideWithoutActivation () + { + return invokeObjcSelf!(void, "unhideWithoutActivation"); + } + + NSWindow windowWithWindowNumber (NSInteger windowNum) + { + return invokeObjcSelf!(NSWindow, "windowWithWindowNumber:", NSInteger)(windowNum); + } + + NSWindow mainWindow () + { + return invokeObjcSelf!(NSWindow, "mainWindow"); + } + + NSWindow keyWindow () + { + return invokeObjcSelf!(NSWindow, "keyWindow"); + } + + bool isActive () + { + return invokeObjcSelf!(bool, "isActive"); + } + + bool isHidden () + { + return invokeObjcSelf!(bool, "isHidden"); + } + + bool isRunning () + { + return invokeObjcSelf!(bool, "isRunning"); + } + + void deactivate () + { + return invokeObjcSelf!(void, "deactivate"); + } + + void activateIgnoringOtherApps (bool flag) + { + return invokeObjcSelf!(void, "activateIgnoringOtherApps:", bool)(flag); + } + + void hideOtherApplications (Object sender) + { + return invokeObjcSelf!(void, "hideOtherApplications:", Object)(sender); + } + + void unhideAllApplications (Object sender) + { + return invokeObjcSelf!(void, "unhideAllApplications:", Object)(sender); + } + + void finishLaunching () + { + return invokeObjcSelf!(void, "finishLaunching"); + } + + void run () + { + return invokeObjcSelf!(void, "run"); + } + + NSInteger runModalForWindow (NSWindow theWindow) + { + return invokeObjcSelf!(NSInteger, "runModalForWindow:", NSWindow)(theWindow); + } + + void stop (Object sender) + { + return invokeObjcSelf!(void, "stop:", Object)(sender); + } + + void stopModal () + { + return invokeObjcSelf!(void, "stopModal"); + } + + void stopModalWithCode (NSInteger returnCode) + { + return invokeObjcSelf!(void, "stopModalWithCode:", NSInteger)(returnCode); + } + + void abortModal () + { + return invokeObjcSelf!(void, "abortModal"); + } + + NSWindow modalWindow () + { + return invokeObjcSelf!(NSWindow, "modalWindow"); + } + + NSModalSession beginModalSessionForWindow (NSWindow theWindow) + { + return invokeObjcSelf!(NSModalSession, "beginModalSessionForWindow:", NSWindow)(theWindow); + } + + NSInteger runModalSession (NSModalSession session) + { + return invokeObjcSelf!(NSInteger, "runModalSession:", NSModalSession)(session); + } + + void endModalSession (NSModalSession session) + { + return invokeObjcSelf!(void, "endModalSession:", NSModalSession)(session); + } + + void terminate (Object sender) + { + return invokeObjcSelf!(void, "terminate:", Object)(sender); + } + + NSInteger requestUserAttention (uint requestType) + { + return invokeObjcSelf!(NSInteger, "requestUserAttention:", uint)(requestType); + } + + void cancelUserAttentionRequest (NSInteger request) + { + return invokeObjcSelf!(void, "cancelUserAttentionRequest:", NSInteger)(request); + } + + void beginSheet (NSWindow sheet, NSWindow docWindow, Object modalDelegate, SEL didEndSelector, void* contextInfo) + { + return invokeObjcSelf!(void, "beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:", NSWindow, NSWindow, Object, SEL, void*)(sheet, docWindow, modalDelegate, didEndSelector, contextInfo); + } + + void endSheet (NSWindow sheet) + { + return invokeObjcSelf!(void, "endSheet:", NSWindow)(sheet); + } + + void endSheet (NSWindow sheet, NSInteger returnCode) + { + return invokeObjcSelf!(void, "endSheet:returnCode:", NSWindow, NSInteger)(sheet, returnCode); + } + + NSInteger runModalForWindow (NSWindow theWindow, NSWindow docWindow) + { + return invokeObjcSelf!(NSInteger, "runModalForWindow:relativeToWindow:", NSWindow, NSWindow)(theWindow, docWindow); + } + + NSModalSession beginModalSessionForWindow (NSWindow theWindow, NSWindow docWindow) + { + return invokeObjcSelf!(NSModalSession, "beginModalSessionForWindow:relativeToWindow:", NSWindow, NSWindow)(theWindow, docWindow); + } + + NSEvent nextEventMatchingMask (NSUInteger mask, NSDate expiration, NSString mode, bool deqFlag) + { + return invokeObjcSelf!(NSEvent, "nextEventMatchingMask:untilDate:inMode:dequeue:", NSUInteger, NSDate, NSString, bool)(mask, expiration, mode, deqFlag); + } + + void discardEventsMatchingMask (NSUInteger mask, NSEvent lastEvent) + { + return invokeObjcSelf!(void, "discardEventsMatchingMask:beforeEvent:", NSUInteger, NSEvent)(mask, lastEvent); + } + + void postEvent (NSEvent event, bool flag) + { + return invokeObjcSelf!(void, "postEvent:atStart:", NSEvent, bool)(event, flag); + } + + NSEvent currentEvent () + { + return invokeObjcSelf!(NSEvent, "currentEvent"); + } + + void sendEvent (NSEvent theEvent) + { + return invokeObjcSelf!(void, "sendEvent:", NSEvent)(theEvent); + } + + void preventWindowOrdering () + { + return invokeObjcSelf!(void, "preventWindowOrdering"); + } + + NSWindow makeWindowsPerform (SEL aSelector, bool flag) + { + return invokeObjcSelf!(NSWindow, "makeWindowsPerform:inOrder:", SEL, bool)(aSelector, flag); + } + + NSArray windows () + { + return invokeObjcSelf!(NSArray, "windows"); + } + + void setWindowsNeedUpdate (bool needUpdate) + { + return invokeObjcSelf!(void, "setWindowsNeedUpdate:", bool)(needUpdate); + } + + void updateWindows () + { + return invokeObjcSelf!(void, "updateWindows"); + } + + void setMainMenu (NSMenu aMenu) + { + return invokeObjcSelf!(void, "setMainMenu:", NSMenu)(aMenu); + } + + NSMenu mainMenu () + { + return invokeObjcSelf!(NSMenu, "mainMenu"); + } + + void setApplicationIconImage (NSImage image) + { + return invokeObjcSelf!(void, "setApplicationIconImage:", NSImage)(image); + } + + NSImage applicationIconImage () + { + return invokeObjcSelf!(NSImage, "applicationIconImage"); + } + + NSDockTile dockTile () + { + return invokeObjcSelf!(NSDockTile, "dockTile"); + } + + bool sendAction (SEL theAction, Object theTarget, Object sender) + { + return invokeObjcSelf!(bool, "sendAction:to:from:", SEL, Object, Object)(theAction, theTarget, sender); + } + + Object targetForAction (SEL theAction) + { + return invokeObjcSelf!(Object, "targetForAction:", SEL)(theAction); + } + + Object targetForAction (SEL theAction, Object theTarget, Object sender) + { + return invokeObjcSelf!(Object, "targetForAction:to:from:", SEL, Object, Object)(theAction, theTarget, sender); + } + + bool tryToPerform (SEL anAction, Object anObject) + { + return invokeObjcSelf!(bool, "tryToPerform:with:", SEL, Object)(anAction, anObject); + } + + Object validRequestorForSendType (NSString sendType, NSString returnType) + { + return invokeObjcSelf!(Object, "validRequestorForSendType:returnType:", NSString, NSString)(sendType, returnType); + } + + void reportException (NSException theException) + { + return invokeObjcSelf!(void, "reportException:", NSException)(theException); + } + + static void detachDrawingThread (SEL selector, Object target, Object argument) + { + return invokeObjcSelfClass!(void, "detachDrawingThread:toTarget:withObject:", SEL, Object, Object)(selector, target, argument); + } + + void replyToApplicationShouldTerminate (bool shouldTerminate) + { + return invokeObjcSelf!(void, "replyToApplicationShouldTerminate:", bool)(shouldTerminate); + } + + void replyToOpenOrPrint (uint reply) + { + return invokeObjcSelf!(void, "replyToOpenOrPrint:", uint)(reply); + } + + void orderFrontCharacterPalette (Object sender) + { + return invokeObjcSelf!(void, "orderFrontCharacterPalette:", Object)(sender); + } + + bool validateUserInterfaceItem (INSValidatedUserInterfaceItem anItem) + { + return invokeObjcSelf!(bool, "validateUserInterfaceItem:", INSValidatedUserInterfaceItem)(anItem); + } + + // NSServicesMenu + void setServicesMenu (NSMenu aMenu) + { + return invokeObjcSelf!(void, "setServicesMenu:", NSMenu)(aMenu); + } + + NSMenu servicesMenu () + { + return invokeObjcSelf!(NSMenu, "servicesMenu"); + } + + void registerServicesMenuSendTypes (NSArray sendTypes, NSArray returnTypes) + { + return invokeObjcSelf!(void, "registerServicesMenuSendTypes:returnTypes:", NSArray, NSArray)(sendTypes, returnTypes); + } + + // NSApplicationHelpExtension + void activateContextHelpMode (Object sender) + { + return invokeObjcSelf!(void, "activateContextHelpMode:", Object)(sender); + } + + void showHelp (Object sender) + { + return invokeObjcSelf!(void, "showHelp:", Object)(sender); + } + + // NSStandardAboutPanel + void orderFrontStandardAboutPanel (Object sender) + { + return invokeObjcSelf!(void, "orderFrontStandardAboutPanel:", Object)(sender); + } + + void orderFrontStandardAboutPanelWithOptions (NSDictionary optionsDictionary) + { + return invokeObjcSelf!(void, "orderFrontStandardAboutPanelWithOptions:", NSDictionary)(optionsDictionary); + } + + // NSWindowsMenu + void setWindowsMenu (NSMenu aMenu) + { + return invokeObjcSelf!(void, "setWindowsMenu:", NSMenu)(aMenu); + } + + NSMenu windowsMenu () + { + return invokeObjcSelf!(NSMenu, "windowsMenu"); + } + + void arrangeInFront (Object sender) + { + return invokeObjcSelf!(void, "arrangeInFront:", Object)(sender); + } + + void removeWindowsItem (NSWindow win) + { + return invokeObjcSelf!(void, "removeWindowsItem:", NSWindow)(win); + } + + void addWindowsItem (NSWindow win, NSString aString, bool isFilename) + { + return invokeObjcSelf!(void, "addWindowsItem:title:filename:", NSWindow, NSString, bool)(win, aString, isFilename); + } + + void changeWindowsItem (NSWindow win, NSString aString, bool isFilename) + { + return invokeObjcSelf!(void, "changeWindowsItem:title:filename:", NSWindow, NSString, bool)(win, aString, isFilename); + } + + void updateWindowsItem (NSWindow win) + { + return invokeObjcSelf!(void, "updateWindowsItem:", NSWindow)(win); + } + + void miniaturizeAll (Object sender) + { + return invokeObjcSelf!(void, "miniaturizeAll:", Object)(sender); + } + + // NSPageLayoutPanel + void runPageLayout (Object sender) + { + return invokeObjcSelf!(void, "runPageLayout:", Object)(sender); + } + + // NSServicesHandling + void setServicesProvider (Object provider) + { + return invokeObjcSelf!(void, "setServicesProvider:", Object)(provider); + } + + Object servicesProvider () + { + return invokeObjcSelf!(Object, "servicesProvider"); + } + + // NSColorPanel + void orderFrontColorPanel (Object sender) + { + return invokeObjcSelf!(void, "orderFrontColorPanel:", Object)(sender); + } +} + +bool NSShowsServicesMenuItem (NSString itemName) +{ + return Bridge.invokeObjcFunction!(bool, bindings.NSShowsServicesMenuItem, NSString)(itemName); +} + +NSInteger NSSetShowsServicesMenuItem (NSString itemName, bool enabled) +{ + return Bridge.invokeObjcFunction!(NSInteger, bindings.NSSetShowsServicesMenuItem, NSString, bool)(itemName, enabled); +} + +bool NSPerformService (NSString itemName, NSPasteboard pboard) +{ + return Bridge.invokeObjcFunction!(bool, bindings.NSPerformService, NSString, NSPasteboard)(itemName, pboard); +} + +void NSRegisterServicesProvider (Object provider, NSString name) +{ + return Bridge.invokeObjcFunction!(void, bindings.NSRegisterServicesProvider, Object, NSString)(provider, name); +} + +void NSUnregisterServicesProvider (NSString name) +{ + return Bridge.invokeObjcFunction!(void, bindings.NSUnregisterServicesProvider, NSString)(name); +} + +int NSApplicationMain (string[] args) +{ + if (args.length == 0) + return NSApplicationMain(0, null); + + char*[] cArgs; + cArgs.reserve(args.length); + + foreach (str ; args) + cArgs ~= (str ~ '\0').ptr; + + return NSApplicationMain(cArgs.length, cArgs.ptr); +} + +int NSApplicationMain () +{ + return NSApplicationMain(0, null); +} + +extern (C) +{ + int NSApplicationMain (int argc, char** argv); + bool NSApplicationLoad (); + void NSUpdateDynamicServices (); +} \ No newline at end of file