void TrackPropDlg::OnHyperLinkClick( wxHyperlinkEvent &event ) { if( m_toggleBtnEdit->GetValue() ) { m_pEditedLink = (wxHyperlinkCtrl*) event.GetEventObject(); OnEditLink( event ); event.Skip( false ); return; } // Windows has trouble handling local file URLs with embedded anchor points, e.g file://testfile.html#point1 // The trouble is with the wxLaunchDefaultBrowser with verb "open" // Workaround is to probe the registry to get the default browser, and open directly // // But, we will do this only if the URL contains the anchor point charater '#' // What a hack...... #ifdef __WXMSW__ wxString cc = event.GetURL(); if( cc.Find( _T("#") ) != wxNOT_FOUND ) { wxRegKey RegKey( wxString( _T("HKEY_CLASSES_ROOT\\HTTP\\shell\\open\\command") ) ); if( RegKey.Exists() ) { wxString command_line; RegKey.QueryValue( wxString( _T("") ), command_line ); // Remove " command_line.Replace( wxString( _T("\"") ), wxString( _T("") ) ); // Strip arguments int l = command_line.Find( _T(".exe") ); if( wxNOT_FOUND == l ) l = command_line.Find( _T(".EXE") ); if( wxNOT_FOUND != l ) { wxString cl = command_line.Mid( 0, l + 4 ); cl += _T(" "); cc.Prepend( _T("\"") ); cc.Append( _T("\"") ); cl += cc; wxExecute( cl ); // Async, so Fire and Forget... } } } else event.Skip(); #else wxString url = event.GetURL(); url.Replace(_T(" "), _T("%20") ); ::wxLaunchDefaultBrowser(url); // event.Skip(); #endif }
//------------------------------------------------------------------------------ void WelcomePanel::OnOpenHelpLink(wxHyperlinkEvent& event) { // if link is a keyword (no slashes or periods), use help controller // otherwise, assume it is a URL and use the default browser wxString link = event.GetURL(); #ifdef DEBUG_WELCOME_HELP MessageInterface::ShowMessage("WelcomePanel::OnOpenHelpLink, url = %s\n", link.c_str()); #endif if ((GmatAppData::Instance()->GetMainFrame()->GetHelpController() == NULL) || link.Contains("\\") || link.Contains("/") || link.Contains(":") ) ::wxLaunchDefaultBrowser(link); else GmatAppData::Instance()->GetMainFrame()->GetHelpController()->DisplaySection(link); }
//------------------------------------------------------------------------------ void WelcomePanel::OnOpenSampleScript(wxHyperlinkEvent& event) { std::string sampleDir = event.GetURL().WX_TO_STD_STRING; std::string appFullPath = GmatFileUtil::GetApplicationPath(); std::string appDir = GmatFileUtil::ParsePathName(appFullPath, true); std::string sampleFullPath = sampleDir; if (GmatFileUtil::IsPathRelative(sampleDir)) sampleFullPath = appDir + sampleDir; sampleFullPath = GmatStringUtil::Replace(sampleFullPath, "\\", "/"); #ifdef DEBUG_SAMPLE_SCRIPT MessageInterface::ShowMessage ("WelcomePanel::OnOpenSampleScript() entered\n sampleDir='%s'\n appDir=%s'\n" " sampleFullPath='%s'\n", sampleDir.c_str(), appDir.c_str(), sampleFullPath.c_str()); #endif if (GmatFileUtil::DoesDirectoryExist(sampleFullPath + "/", false)) { wxString samplePath = wxString(sampleFullPath.c_str()); wxFileDialog dialog(this, _T("Choose a file"), samplePath, _T(""), _T("*.*")); if (dialog.ShowModal() == wxID_OK) { wxString scriptfile; scriptfile = dialog.GetPath().c_str(); #ifdef DEBUG_SAMPLE_SCRIPT MessageInterface::ShowMessage(" scriptfile='%s'\n", scriptfile.c_str()); #endif GmatAppData::Instance()->GetMainFrame()->OpenRecentScript(scriptfile, event); } } else { MessageInterface::PopupMessage (Gmat::WARNING_, "Cannot open samples directory, '%s'\n", sampleFullPath.c_str()); } }
//------------------------------------------------------------------------------ void WelcomePanel::OnOpenRecentScript(wxHyperlinkEvent& event) { GmatAppData::Instance()->GetMainFrame()->OpenRecentScript(event.GetURL(), event, false); GmatAppData::Instance()->GetMainFrame()->CloseWelcomePanel(); // **** }