]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/utilscmn.cpp
no real changes, just refactor to remove some code duplication in wxToolBarTool
[wxWidgets.git] / src / common / utilscmn.cpp
index 0c46279c199c7428a10e86efc5d9a8d4a8e8e22c..57f68bc3407b2a360ec3bca01a02827fad32ad26 100644 (file)
@@ -937,11 +937,16 @@ void wxQsort(void *const pbase, size_t total_elems,
 // Launch document with default app
 // ----------------------------------------------------------------------------
 
-bool wxLaunchDefaultApplication(const wxString &document, int flags)
+bool wxLaunchDefaultApplication(const wxStringdocument, int flags)
 {
     wxUnusedVar(flags);
-    
-#ifdef __UNIX__
+
+#ifdef __WXMAC__
+    static const char * const OPEN_CMD = "/usr/bin/open";
+    if ( wxFileExists(OPEN_CMD) &&
+            wxExecute(wxString(OPEN_CMD) + " " + document) )
+        return true;
+#elif defined(__UNIX__)
     // Our best best is to use xdg-open from freedesktop.org cross-desktop
     // compatibility suite xdg-utils
     // (see http://portland.freedesktop.org/wiki/) -- this is installed on
@@ -954,9 +959,21 @@ bool wxLaunchDefaultApplication(const wxString &document, int flags)
         if ( wxExecute(xdg_open + " " + document) )
             return true;
     }
+#elif defined(__WXMSW__)
+    const INT_PTR result = (INT_PTR)::ShellExecute
+                                      (
+                                        NULL,           // parent window
+                                        _T("open"),
+                                        document,
+                                        NULL,           // parameters
+                                        NULL,           // working directory
+                                        SW_SHOWDEFAULT
+                                      );
+    if ( result > 32 )
+        return true;
 #endif
 
-   return false;
+    return false;
 }
 
 // ----------------------------------------------------------------------------
@@ -968,7 +985,7 @@ bool wxLaunchDefaultApplication(const wxString &document, int flags)
 bool wxCocoaLaunchDefaultBrowser(const wxString& url, int flags);
 #endif
 
-bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags)
+static bool DoLaunchDefaultBrowser(const wxString& urlOrig, int flags)
 {
     wxUnusedVar(flags);
 
@@ -1176,6 +1193,15 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags)
     return false;
 }
 
+bool wxLaunchDefaultBrowser(const wxString& url, int flags)
+{
+    if ( flags & wxBROWSER_NOBUSYCURSOR )
+        return DoLaunchDefaultBrowser(url, flags);
+
+    wxBusyCursor bc;
+    return DoLaunchDefaultBrowser(url, flags);
+}
+
 // ----------------------------------------------------------------------------
 // Menu accelerators related functions
 // ----------------------------------------------------------------------------
@@ -1492,8 +1518,8 @@ wxString wxGetPasswordFromUser(const wxString& message,
 
 #if wxUSE_COLOURDLG
 
-wxColour wxGetColourFromUser(wxWindow *parent, 
-                             const wxColour& colInit, 
+wxColour wxGetColourFromUser(wxWindow *parent,
+                             const wxColour& colInit,
                              const wxString& caption,
                              wxColourData *ptrData)
 {