Add generic wxFileSystem support to wxWebView using wxWebViewFSHandler.
Closes #14623. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72461 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
them accessible via an URL.
|
||||
|
||||
It is particularly suitable for storing bitmaps from resources or included XPM
|
||||
files so that they can be used with wxHTML.
|
||||
files so that they can be used with wxHTML or wxWebView.
|
||||
|
||||
Filenames are prefixed with @c "memory:", e.g. @c "memory:myfile.html".
|
||||
|
||||
@@ -26,24 +26,30 @@
|
||||
|
||||
void MyFrame::OnAbout(wxCommandEvent&)
|
||||
{
|
||||
wxBusyCursor bcur;
|
||||
wxFileSystem::AddHandler(new wxMemoryFSHandler);
|
||||
wxMemoryFSHandler::AddFile("logo.pcx", wxBITMAP(logo), wxBITMAP_TYPE_PCX);
|
||||
wxMemoryFSHandler::AddFile("logo.png", wxBITMAP(logo), wxBITMAP_TYPE_PNG);
|
||||
wxMemoryFSHandler::AddFile("about.htm",
|
||||
"<html><body>About: "
|
||||
"<img src=\"memory:logo.pcx\"></body></html>");
|
||||
"<img src=\"memory:logo.png\"></body></html>");
|
||||
|
||||
wxDialog dlg(this, -1, wxString(_("About")));
|
||||
wxBoxSizer *topsizer;
|
||||
wxHtmlWindow *html;
|
||||
topsizer = new wxBoxSizer(wxVERTICAL);
|
||||
html = new wxHtmlWindow(&dlg, -1, wxDefaultPosition,
|
||||
wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
|
||||
html->SetBorders(0);
|
||||
html->LoadPage("memory:about.htm");
|
||||
html->SetSize(html->GetInternalRepresentation()->GetWidth(),
|
||||
html->GetInternalRepresentation()->GetHeight());
|
||||
topsizer->Add(html, 1, wxALL, 10);
|
||||
#ifdef USE_WEBVIEW
|
||||
wxWebView* browser = wxWebView::New(&dlg, wxID_ANY, wxWebViewDefaultURLStr,
|
||||
wxDefaultPosition, wxSize(380, 160));
|
||||
browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewFSHandler("memory")));
|
||||
browser->LoadURL("memory:about.htm");
|
||||
#else // Use wxHtml
|
||||
wxHtmlWindow *browser;
|
||||
browser = new wxHtmlWindow(&dlg, -1, wxDefaultPosition,
|
||||
wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
|
||||
browser->SetBorders(0);
|
||||
browser->LoadPage("memory:about.htm");
|
||||
browser->SetSize(browser->GetInternalRepresentation()->GetWidth(),
|
||||
browser->GetInternalRepresentation()->GetHeight());
|
||||
#endif
|
||||
topsizer->Add(browser, 1, wxALL, 10);
|
||||
topsizer->Add(new wxStaticLine(&dlg, -1), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
|
||||
topsizer->Add(new wxButton(&dlg, wxID_OK, "Ok"),
|
||||
0, wxALL | wxALIGN_RIGHT, 15);
|
||||
@@ -53,7 +59,7 @@
|
||||
dlg.Centre();
|
||||
dlg.ShowModal();
|
||||
|
||||
wxMemoryFSHandler::RemoveFile("logo.pcx");
|
||||
wxMemoryFSHandler::RemoveFile("logo.png");
|
||||
wxMemoryFSHandler::RemoveFile("about.htm");
|
||||
}
|
||||
@endcode
|
||||
|
@@ -231,10 +231,13 @@ public:
|
||||
wxFSFile which represents the given url. You can then register your handler
|
||||
with RegisterHandler() it will be called for all pages and resources.
|
||||
|
||||
wxWebFileHandler is provided to allow the navigation of pages inside a zip
|
||||
archive. It overrides the @c file scheme and provides support for the
|
||||
standard @c file syntax as well as paths to archives of the form
|
||||
@c file:///C:/example/docs.zip;protocol=zip/main.htm
|
||||
wxWebViewFSHandler is provided to access the virtual file system encapsulated by
|
||||
wxFileSystem. The wxMemoryFSHandler documentation gives an example of how this
|
||||
may be used.
|
||||
|
||||
wxWebViewArchiveHandler is provided to allow the navigation of pages inside a zip
|
||||
archive. It supports paths of the form:
|
||||
@c scheme:///C:/example/docs.zip;protocol=zip/main.htm
|
||||
|
||||
@beginEventEmissionTable{wxWebViewEvent}
|
||||
@event{EVT_WEB_VIEW_NAVIGATING(id, func)}
|
||||
@@ -607,13 +610,13 @@ public:
|
||||
@param flags The flags for the search.
|
||||
@return If search phrase was not found in combination with the flags
|
||||
then @c wxNOT_FOUND is returned. If called for the first time
|
||||
with search phrase then the total number of results will be
|
||||
with search phrase then the total number of results will be
|
||||
returned. Then for every time its called with the same search
|
||||
phrase it will return the number of the current match.
|
||||
@note This function will restart the search if the flags
|
||||
@c wxWEB_VIEW_FIND_ENTIRE_WORD or @c wxWEB_VIEW_FIND_MATCH_CASE
|
||||
are changed, since this will require a new search. To reset the
|
||||
search, for example reseting the highlights call the function
|
||||
search, for example reseting the highlights call the function
|
||||
with an empty search phrase. This always returns @c wxNOT_FOUND
|
||||
on the OSX WebKit backend.
|
||||
@since 2.9.5
|
||||
|
32
interface/wx/webviewfshandler.h
Normal file
32
interface/wx/webviewfshandler.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: webviewfshandler.h
|
||||
// Purpose: interface of wxWebViewFSHandler
|
||||
// Author: wxWidgets team
|
||||
// RCS-ID: $Id$
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
@class wxWebViewFSHandler
|
||||
|
||||
A wxWebView file system handler to support standard wxFileSystem protocols
|
||||
of the form <code> example:page.htm </code> The handler allows wxWebView to
|
||||
use wxFileSystem in a similar fashion to its use with wxHtml.
|
||||
|
||||
The wxMemoryFSHandler documentation gives an example of how it may be used.
|
||||
|
||||
@since 2.9.5
|
||||
@library{wxwebview}
|
||||
@category{webview}
|
||||
|
||||
@see wxWebView, wxWebViewHandler, wxWebViewArchiveHandler
|
||||
*/
|
||||
class wxWebViewFSHandler : public wxWebViewHandler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Constructor.
|
||||
*/
|
||||
wxWebViewFSHandler(const wxString& scheme);
|
||||
virtual wxFSFile* GetFile(const wxString &uri);
|
||||
};
|
Reference in New Issue
Block a user