]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/utils.mm
Update setup for OpenVMS
[wxWidgets.git] / src / osx / cocoa / utils.mm
index 48bc5c9a96732c2ff631ea075b5bb4ee4e22dc50..b8aa14190b2bc054b6fd3430bdcdf90b60c1d8cb 100644 (file)
@@ -76,12 +76,14 @@ void wxMacWakeUp()
 
 - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
 {
+    wxUnusedVar(sender);
     // let wx do this, not cocoa
     return NO;
 }
 
 - (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename;
 {
+    wxUnusedVar(sender);
     wxCFStringRef cf(wxCFRetain(filename));
     wxTheApp->MacOpenFile(cf.AsString()) ;
     return YES;
@@ -89,12 +91,14 @@ void wxMacWakeUp()
 
 - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender;
 {
+    wxUnusedVar(sender);
     wxTheApp->MacNewFile() ;
     return NO;
 }
 
 - (BOOL)application:(NSApplication *)sender printFile:(NSString *)filename
 {
+    wxUnusedVar(sender);
     wxCFStringRef cf(wxCFRetain(filename));
     wxTheApp->MacPrintFile(cf.AsString()) ;
     return YES;
@@ -109,6 +113,7 @@ void wxMacWakeUp()
 */
 - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
 {
+    wxUnusedVar(sender);
     wxWindow* win = wxTheApp->GetTopWindow() ;
     if ( win )
     {
@@ -125,6 +130,8 @@ void wxMacWakeUp()
 
 - (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag
 {
+    wxUnusedVar(flag);
+    wxUnusedVar(sender);
     wxTheApp->MacReopenApp() ;
     return NO;
 }
@@ -132,14 +139,58 @@ void wxMacWakeUp()
 - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event
     withReplyEvent:(NSAppleEventDescriptor *)replyEvent
 {
+    wxUnusedVar(replyEvent);
     NSString* url = [[event descriptorAtIndex:1] stringValue];
     wxCFStringRef cf(wxCFRetain(url));
     wxTheApp->MacOpenURL(cf.AsString()) ;
 }
 @end
 
+/* 
+    allows ShowModal to work when using sheets.
+    see include/wx/osx/cocoa/private.h for more info 
+*/
+@implementation ModalDialogDelegate
+- (id)init
+{
+    [super init];
+    sheetFinished = NO;
+    resultCode = -1;
+    return self;
+}
+
+- (BOOL)finished 
+{
+    return sheetFinished;
+}
+
+- (int)code
+{
+    return resultCode;
+}
+
+- (void)waitForSheetToFinish
+{
+    while (!sheetFinished)
+    {
+        wxSafeYield();
+    }
+}
+
+- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
+{
+    wxUnusedVar(contextInfo);
+    resultCode = returnCode;
+    sheetFinished = YES;
+    // NSAlerts don't need nor respond to orderOut
+    if ([sheet respondsToSelector:@selector(orderOut:)])
+        [sheet orderOut: self];
+}
+@end
+
 bool wxApp::DoInitGui()
 {
+    wxMacAutoreleasePool pool;
     [NSApplication sharedApplication];
 
     if (!sm_isEmbedded)
@@ -150,8 +201,8 @@ bool wxApp::DoInitGui()
         NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
         [appleEventManager setEventHandler:controller andSelector:@selector(handleGetURLEvent:withReplyEvent:)
             forEventClass:kInternetEventClass andEventID:kAEGetURL];
+        [NSApp finishLaunching];
     }
-    [NSApp finishLaunching];
     return true;
 }
 
@@ -226,14 +277,6 @@ bool wxIsBusy()
     return (gs_wxBusyCursorCount > 0);
 }
 
-void wxMacGlobalToLocal( WindowRef window , Point*pt )
-{
-}
-
-void wxMacLocalToGlobal( WindowRef window , Point*pt )
-{
-}
-
 wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const
 {
     // wxScreenDC is derived from wxWindowDC, so a screen dc will