Ejemplo n.º 1
0
void MyFrame::OnShowContextMenu(wxWebEvent& evt)
{
    wxMenu menuPopup;

    wxString href = evt.GetHref();
    if (!href.IsEmpty())
    {
        menuPopup.Append(ID_OpenHref, _("&Open"));
        menuPopup.AppendSeparator();
        m_uri_href = href;
    }
    else
    {
        menuPopup.Append(ID_GoBack, _("&Back"));
        menuPopup.Append(ID_GoForward, _("&Forward"));
        menuPopup.Append(ID_Reload, _("&Reload"));
        menuPopup.Append(ID_Stop, _("&Stop"));
        menuPopup.AppendSeparator();
    }

    menuPopup.Append(ID_Cut, _("Cu&t"));
    menuPopup.Append(ID_Copy, _("&Copy"));
    menuPopup.Append(ID_CopyLink, _("Copy &Link"));
    menuPopup.Append(ID_Paste, _("&Paste"));
    menuPopup.Append(ID_SelectAll, _("Select &All"));

    wxPoint pt_mouse = ::wxGetMousePosition();
    pt_mouse = m_browser->ScreenToClient(pt_mouse);
    PopupMenu(&menuPopup, pt_mouse);
}
Ejemplo n.º 2
0
void MyFrame::OnLocationChange(wxWebEvent& evt)
{
    // set the url bar
    SetUrlBarValue(evt.GetString());

    // set the DOM content loaded flag to false
    // until the DOM is safely loaded
    m_dom_contentloaded = false;
}
Ejemplo n.º 3
0
void wxWebPanelBase::OnLocationChange(wxWebEvent& evt)
{
    // set the url bar
#ifdef HAVE_URL_BAR
    SetUrlBarValue(evt.GetString());
#endif

    // set the DOM content loaded flag to false
    // until the DOM is safely loaded
    m_dom_contentloaded = false;
}
Ejemplo n.º 4
0
void MyFrame::OnStatusChange(wxWebEvent& evt)
{
    // wxEVT_WEB_STATUSCHANGE is received when the status text
    // changes when a web page is loading
    
    wxStatusBar* status_bar = GetStatusBar();
    status_bar->SetStatusText(evt.GetString());

    // note: the status bar text is reset when
    // all the content is finished loading, in
    // OnDOMContentLoaded()
}
Ejemplo n.º 5
0
void MyFrame::OnStatusText(wxWebEvent& evt)
{
    // wxEVT_WEB_STATUSTEXT is received when somebody hovers
    // the mouse over a link and the status text should
    // be updated
    
    wxString status_text = evt.GetString();
    if (status_text.Length() == 0)
        status_text = _("Ready");

    wxStatusBar* status_bar = GetStatusBar();
    status_bar->SetStatusText(status_text);
}
Ejemplo n.º 6
0
void wxWebPanelBase::OnStatusChange(wxWebEvent& evt)
{
    // wxEVT_WEB_STATUSCHANGE is received when the status text
    // changes when a web page is loading
    if (SetStatusBarIsEnabled())
	{
		wxStatusBar* status_bar = m_containing_frame -> GetStatusBar();
		if (NULL != status_bar)
			status_bar->SetStatusText(evt.GetString());
	}
    // note: the status bar text is reset when
    // all the content is finished loading, in
    // OnDOMContentLoaded()
}
Ejemplo n.º 7
0
void MyFrame::OnInitDownload(wxWebEvent& evt)
{
    // TODO: add download status indicator and option
    // to open content in the browser

    // note: this handler gets called when content is
    // available to download; the content can be handled
    // as follows:
    //   evt.SetDownloadAction(wxWEB_DOWNLOAD_OPEN);   // open content
    //   evt.SetDownloadAction(wxWEB_DOWNLOAD_SAVEAS); // save content
    //   evt.SetDownloadAction(wxWEB_DOWNLOAD_CANCEL); // cancel the operation

    // here, we'll allow the user to download it or cancel
    // the operation

    // get the filename
    wxString filename = evt.GetFilename();
    wxMessageDialog dlg(this,
                        wxString::Format(wxT("Would you like to download %s?"), (const wxChar*)filename.c_str()),
                        wxT("Download File"),
                        wxYES_NO);

    int result = dlg.ShowModal();

    switch (result)
    {
        case wxID_YES:
            {
                wxString filter;
                filter += _("All Files");
                filter += wxT(" (*.*)|*.*");

                wxFileDialog dlg(this,
                         _("Save As"),
                         wxT(""),
                         filename,
                         filter,
                         wxFD_SAVE | wxFD_OVERWRITE_PROMPT);

                if (dlg.ShowModal() != wxID_OK)
                {
                    evt.SetDownloadAction(wxWEB_DOWNLOAD_CANCEL);
                    return;
                }

                wxWebProgressBase* listener = new wxWebProgressBase;
                evt.SetDownloadAction(wxWEB_DOWNLOAD_SAVEAS);
                evt.SetDownloadTarget(dlg.GetPath());
                evt.SetDownloadListener(listener);
            }
            break;

        case wxID_NO:
            evt.SetDownloadAction(wxWEB_DOWNLOAD_CANCEL);
            break;
    }
}
Ejemplo n.º 8
0
void MyFrame::OnStateChange(wxWebEvent& evt)
{
    // clear the status bar hear since OnStatusChange() doesn't 
    // contain an empty string and we don't want "stuck" text in 
    // the statusbar
    int state = evt.GetState();    
    wxString status_text = _("Ready");
    wxStatusBar* status_bar = GetStatusBar();

    if ((state & wxWEB_STATE_STOP) && (state & wxWEB_STATE_IS_REQUEST))
        status_bar->SetStatusText(status_text);

    if ((state & wxWEB_STATE_STOP) && (state & wxWEB_STATE_IS_REQUEST))
        status_bar->SetStatusText(status_text);
}
Ejemplo n.º 9
0
void MyFrame::OnShouldHandleContent(wxWebEvent& evt)
{
    // note: this handler gets called when a content
    // type needs to be handled and allows us to determine
    // whether or not we want to handle the content type
    // or let the browser handle it

    // for example, by default, we'll let the browser handle
    // all content types, except XML

    // get the content type
    wxString input_content_type = evt.GetContentType();
    if (input_content_type == wxT("application/xml"))
    {
        // we have an XML content; don't let the browser
        // handle this, since we'll do it ourselves
        evt.SetShouldHandle(false);
        
        // TODO: custom XML handling
        return;
    }

    evt.Skip();
}
Ejemplo n.º 10
0
void wxWebPanelBase::OnStatusText(wxWebEvent& evt)
{
    // wxEVT_WEB_STATUSTEXT is received when somebody hovers
    // the mouse over a link and the status text should
    // be updated
    if (SetStatusBarIsEnabled())
	{
		wxString status_text = evt.GetString();
		if (status_text.Length() == 0)
			status_text = _("Ready");

		wxStatusBar* status_bar = m_containing_frame -> GetStatusBar();
		if (NULL != status_bar)
			status_bar->SetStatusText(status_text);
	}
}
Ejemplo n.º 11
0
void wxWebPanelBase::PopulatePopupMenu(wxMenu& menuPopup, const wxWebEvent& evt)
{
	using namespace wxwc_util;

	wxString href = evt.GetHref();
    if (!href.IsEmpty())
    {
		static const menu_item_info link_items[] = {
			{ ID_OpenHref, wxTRANSLATE("&Open"), wxART_FOLDER_OPEN },
			{ ID_CopyLink, wxTRANSLATE("Copy &Link"), wxART_COPY },
			{ ID_OpenHrefInDefault, wxTRANSLATE("Open Link in &Default browser") }
		};
        populate_menu(menuPopup, link_items, sizeof(link_items) / sizeof(link_items[0]));
        m_uri_href = href;
    }
    else
    {
        static const menu_item_info navigation_items[] = {
			{ wxID_BACKWARD, NULL, wxART_GO_BACK },
			{ wxID_FORWARD, NULL, wxART_GO_FORWARD },
			{ wxID_REFRESH, wxTRANSLATE("&Reload"), wxART_REDO },
			{ wxID_STOP, wxTRANSLATE("&Stop loading"), wxART_CROSS_MARK },
		};
		populate_menu(menuPopup, navigation_items, sizeof(navigation_items) / sizeof(navigation_items[0]));
        
    }

	static const menu_item_info generic_items[] = {
		{ wxID_SEPARATOR, NULL, NULL },
		{ wxID_CUT, NULL, wxART_CUT },
		{ wxID_COPY, NULL, wxART_COPY },
		
		{ wxID_PASTE, NULL, wxART_PASTE },
		{ wxID_SELECTALL, wxTRANSLATE("Select &All"), NULL },
		{ wxID_SEPARATOR, NULL, NULL },
		{ wxID_ZOOM_IN, wxTRANSLATE("Larger &Text"), wxART_LIST_VIEW },
		{ wxID_ZOOM_OUT, wxTRANSLATE("&Smaller Text"), wxART_REPORT_VIEW },
		{ wxID_ZOOM_100, wxTRANSLATE("&Normal Text"), NULL },
	};

	populate_menu(menuPopup, generic_items, sizeof(generic_items) / sizeof(generic_items[0]));
}
Ejemplo n.º 12
0
void wxWebPanelBase::OnStateChange(wxWebEvent& evt)
{
    // clear the status bar hear since OnStatusChange() doesn't 
    // contain an empty string and we don't want "stuck" text in 
    // the statusbar
    int state = evt.GetState();  
	if (SetStatusBarIsEnabled())
	{
		wxStatusBar* status_bar = m_containing_frame -> GetStatusBar();
		if (NULL != status_bar)
		{
			wxString status_text = _("Ready");
   

			if ((state & wxWEB_STATE_STOP) && (state & wxWEB_STATE_IS_REQUEST))
				status_bar->SetStatusText(status_text);

			if ((state & wxWEB_STATE_STOP) && (state & wxWEB_STATE_IS_REQUEST))
				status_bar->SetStatusText(status_text);
		}
	}
}
Ejemplo n.º 13
0
void MyFrame::OnTitleChange(wxWebEvent& evt)
{
    SetTitle(evt.GetString());
}
Ejemplo n.º 14
0
void PreviewDlg::OnWebTitleChange(wxWebEvent& evt) {
	const wxString title = evt.GetString();
	OnTitleChange(title);
}
Ejemplo n.º 15
0
void wxWebPanelBase::OnTitleChange(wxWebEvent& evt)
{
	if (SetTitleBarIsEnabled())
		m_containing_frame -> SetTitle(evt.GetString());
}