/**
  * Callback invoked when a loading error occurs
  */
void WebFrame::OnError(wxWebViewEvent& evt)
{   
#define WX_ERROR_CASE(type) \
    case type: \
        category = #type; \
        break;

    wxString category;
    switch (evt.GetInt())
    {
        WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_CONNECTION);
        WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_CERTIFICATE);
        WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_AUTH);
        WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_SECURITY);
        WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_NOT_FOUND);
        WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_REQUEST);
        WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_USER_CANCELLED);
        WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_OTHER);
    }

    wxLogMessage("%s", "Error; url='" + evt.GetURL() + "', error='" + category + " (" + evt.GetString() + ")'");

    //Show the info bar with an error
    m_info->ShowMessage(_("An error occurred loading ") + evt.GetURL() + "\n" +
    "'" + category + "'", wxICON_ERROR);

    UpdateState();
}
Esempio n. 2
0
void ZLauncherFrame::OnClickLink(wxWebViewEvent& evt)
{
	// Open the link on the default browser
	wxLaunchDefaultBrowser(evt.GetURL());

	// Stop navigation
	evt.Veto();
}
/**
  * Callback invoked when a page is finished loading
  */
void WebFrame::OnDocumentLoaded(wxWebViewEvent& evt)
{
    //Only notify if the document is the main frame, not a subframe
    if(evt.GetURL() == m_browser->GetCurrentURL())
    {
        wxLogMessage("%s", "Document loaded; url='" + evt.GetURL() + "'");
    }
    UpdateState();
}
/**
  * On new window, we veto to stop extra windows appearing
  */
void WebFrame::OnNewWindow(wxWebViewEvent& evt)
{
    wxLogMessage("%s", "New window; url='" + evt.GetURL() + "'");

    //If we handle new window events then just load them in this window as we
    //are a single window browser
    if(m_tools_handle_new_window->IsChecked())
        m_browser->LoadURL(evt.GetURL());

    UpdateState();
}
Esempio n. 5
0
void ViewFrame::OnNavigating(wxWebViewEvent& evt)
{
    if(!frozen) {
        return;
    }

    // veto event, to prohibit in-page links
    evt.Veto();

    // instead, load the default web-browser
    openBrowser(evt.GetURL());
}
Esempio n. 6
0
/**
  * Callback invoked when a loading error occurs
  */
void WebFrame::OnError(wxWebViewEvent& evt)
{
    wxString errorCategory;
    switch (evt.GetInt())
    {
    case  wxWEB_NAV_ERR_CONNECTION:
        errorCategory = "wxWEB_NAV_ERR_CONNECTION";
        break;

    case wxWEB_NAV_ERR_CERTIFICATE:
        errorCategory = "wxWEB_NAV_ERR_CERTIFICATE";
        break;

    case wxWEB_NAV_ERR_AUTH:
        errorCategory = "wxWEB_NAV_ERR_AUTH";
        break;

    case wxWEB_NAV_ERR_SECURITY:
        errorCategory = "wxWEB_NAV_ERR_SECURITY";
        break;

    case wxWEB_NAV_ERR_NOT_FOUND:
        errorCategory = "wxWEB_NAV_ERR_NOT_FOUND";
        break;

    case wxWEB_NAV_ERR_REQUEST:
        errorCategory = "wxWEB_NAV_ERR_REQUEST";
        break;

    case wxWEB_NAV_ERR_USER_CANCELLED:
        errorCategory = "wxWEB_NAV_ERR_USER_CANCELLED";
        break;

    case wxWEB_NAV_ERR_OTHER:
        errorCategory = "wxWEB_NAV_ERR_OTHER";
        break;
    }

    wxLogMessage("%s", "Error; url='" + evt.GetURL() + "', error='" + errorCategory + "' (" + evt.GetString() + ")");

    //Show the info bar with an error
    m_info->ShowMessage(_("An error occurred loading ") + evt.GetURL() + "\n" +
    "'" + errorCategory + "' (" + evt.GetString() + ")", wxICON_ERROR);

    UpdateState();
}
/**
  * Callback invoked when there is a request to load a new page (for instance
  * when the user clicks a link)
  */
void WebFrame::OnNavigationRequest(wxWebViewEvent& evt)
{
    if(m_info->IsShown())
    {
        m_info->Dismiss();
    }

    wxLogMessage("%s", "Navigation request to '" + evt.GetURL() + "' (target='" +
    evt.GetTarget() + "')");

    wxASSERT(m_browser->IsBusy());

    //If we don't want to handle navigation then veto the event and navigation
    //will not take place, we also need to stop the loading animation
    if(!m_tools_handle_navigation->IsChecked())
    {
        evt.Veto();
        m_toolbar->EnableTool( m_toolbar_stop->GetId(), false );
    }
    else
    {
        UpdateState();
    }
}
void mmHomePagePanel::OnLinkClicked(wxWebViewEvent& event)
{
    const wxString& url = event.GetURL();
    if (url.StartsWith("http://www.moneymanagerex.org"))
    {
        wxLaunchDefaultBrowser(url);
        event.Veto();
    }
    else if (url.Contains("#"))
    {
        wxString name = url.AfterLast('#');
        wxLogDebug("%s", name);

        //Read data from ini DB as JSON then convert it to json::Object
        wxString str = Model_Infotable::instance().GetStringInfo("NAV_TREE_STATUS", "");
        if (!(str.StartsWith("{") && str.EndsWith("}"))) str = "{}";
        std::wstringstream ss;
        ss << str.ToStdWstring();
        json::Object o;
        json::Reader::Read(o, ss);
        wxLogDebug("%s", str);

        if (name == "TOP_CATEGORIES") {
            bool entry = !json::Boolean(o[L"TOP_CATEGORIES"]);
            o[L"TOP_CATEGORIES"] = json::Boolean(entry);
        }

        std::wstringstream wss;
        json::Writer::Write(o, wss);
        wxLogDebug("%s", wss.str());
        wxLogDebug("==========================================");
        Model_Infotable::instance().Set("NAV_TREE_STATUS", wss.str());

    }

}
Esempio n. 9
0
void Viewer::OnNavigationStart(wxWebViewEvent& event) {
    wxLaunchDefaultBrowser(event.GetURL());
    event.Veto();
}
Esempio n. 10
0
void WebFrame::OnTitleChanged(wxWebViewEvent& evt)
{
    SetTitle(evt.GetString());
    wxLogMessage("%s", "Title changed; title='" + evt.GetString() + "'");
}
Esempio n. 11
0
/**
  * Callback invoked when a navigation request was accepted
  */
void WebFrame::OnNavigationComplete(wxWebViewEvent& evt)
{
    wxLogMessage("%s", "Navigation complete; url='" + evt.GetURL() + "'");
    UpdateState();
}