]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/app.cpp
ryan's QT implementation
[wxWidgets.git] / src / mac / carbon / app.cpp
index 966003d5f9309d268f62a2e982a5c366a7d8ceaf..9e29f7961c8359ff1204b354f7afb30000c48879 100644 (file)
@@ -304,7 +304,37 @@ void wxApp::MacNewFile()
 
 void wxApp::MacReopenApp()
 {
-    // eventually check for open docs, if none, call MacNewFile
+    // HIG says :
+    // if there is no open window -> create a new one
+    // if all windows are hidden -> show the first
+    // if some windows are not hidden -> do nothing
+    
+    wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
+    if ( node == NULL )
+    {  
+        MacNewFile() ;
+    }
+    else
+    {
+        wxTopLevelWindow* firstIconized = NULL ;
+        while (node)
+        {
+            wxTopLevelWindow* win = (wxTopLevelWindow*) node->GetData();
+            if ( win->IsIconized() == false )
+            {
+                firstIconized = NULL ;
+                break ;
+            }
+            else
+            {
+                if ( firstIconized == NULL )
+                    firstIconized = win ;
+            }
+            node = node->GetNext();
+        }
+        if ( firstIconized )
+            firstIconized->Iconize( false ) ;
+    }
 }
 
 //----------------------------------------------------------------------
@@ -600,6 +630,20 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
     wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
 #endif
 
+#if TARGET_API_MAC_OSX
+    // these might be the startup dirs, set them to the 'usual' dir containing the app bundle
+    wxString startupCwd = wxGetCwd() ;
+    if ( startupCwd == wxT("/") || startupCwd.Right(15) == wxT("/Contents/MacOS") )
+    {
+        CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle() ) ;
+        CFURLRef urlParent = CFURLCreateCopyDeletingLastPathComponent( kCFAllocatorDefault , url ) ;
+        CFRelease( url ) ;
+        CFStringRef path = CFURLCopyFileSystemPath ( urlParent , kCFURLPOSIXPathStyle ) ;
+        CFRelease( urlParent ) ;
+        wxString cwd = wxMacCFStringHolder(path).AsString(wxLocale::GetSystemEncoding());       
+        wxSetWorkingDirectory( cwd ) ;
+    }
+#endif
 
     wxMacCreateNotifierTable() ;