X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5c33522fca7cddc441a316f5b9fb50d7685435ba..0d19936d71032ba7658616faed3b63d4c930e5b4:/src/osx/carbon/utils.cpp?ds=sidebyside diff --git a/src/osx/carbon/utils.cpp b/src/osx/carbon/utils.cpp index 1a5c28d144..a878933818 100644 --- a/src/osx/carbon/utils.cpp +++ b/src/osx/carbon/utils.cpp @@ -144,8 +144,55 @@ wxString wxMacFindFolder( short vol, #endif // wxUSE_BASE + +// ============================================================================ +// GUI-only functions from now on +// ============================================================================ + #if wxUSE_GUI +// ---------------------------------------------------------------------------- +// Launch document with default app +// ---------------------------------------------------------------------------- + +bool wxLaunchDefaultApplication(const wxString& document, int flags) +{ + wxUnusedVar(flags); + + static const char * const OPEN_CMD = "/usr/bin/open"; + if ( wxFileExists(OPEN_CMD) && + wxExecute(wxString(OPEN_CMD) + " " + document) ) + return true; + + return false; +} + +// ---------------------------------------------------------------------------- +// Launch default browser +// ---------------------------------------------------------------------------- + +bool wxDoLaunchDefaultBrowser(const wxString& url, int flags) +{ + wxUnusedVar(flags); + wxCFRef< CFURLRef > curl( CFURLCreateWithString( kCFAllocatorDefault, + wxCFStringRef( url ), NULL ) ); + OSStatus err = LSOpenCFURLRef( curl , NULL ); + + if (err == noErr) + { + return true; + } + else + { + wxLogDebug(wxT("Browser Launch error %d"), (int) err); + return false; + } +} + +// ---------------------------------------------------------------------------- +// Miscellaneous functions +// ---------------------------------------------------------------------------- + void wxGetMousePosition( int* x, int* y ) { Point pt;