X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/66ac04006071ae2043c483ae93f8d4fa6888f33f..e0dec8753abaf97e006ea1185bfb6775b28df0a8:/samples/webview/webview.cpp?ds=sidebyside diff --git a/samples/webview/webview.cpp b/samples/webview/webview.cpp index 6c0773b6fe..b15b1d8119 100644 --- a/samples/webview/webview.cpp +++ b/samples/webview/webview.cpp @@ -32,9 +32,11 @@ #include "wx/settings.h" #include "wx/webview.h" #include "wx/webviewarchivehandler.h" +#include "wx/webviewfshandler.h" #include "wx/infobar.h" #include "wx/filesys.h" #include "wx/fs_arc.h" +#include "wx/fs_mem.h" #ifndef wxHAS_IMAGES_IN_RESOURCES #include "../sample.xpm" @@ -136,6 +138,7 @@ public: void OnDeleteSelection(wxCommandEvent& evt); void OnSelectAll(wxCommandEvent& evt); void OnLoadScheme(wxCommandEvent& evt); + void OnUseMemoryFS(wxCommandEvent& evt); void OnFind(wxCommandEvent& evt); void OnFindDone(wxCommandEvent& evt); void OnFindText(wxCommandEvent& evt); @@ -213,6 +216,27 @@ bool WebApp::OnInit() if ( !wxApp::OnInit() ) return false; + //Required for virtual file system archive and memory support + wxFileSystem::AddHandler(new wxArchiveFSHandler); + wxFileSystem::AddHandler(new wxMemoryFSHandler); + + // Create the memory files + wxImage::AddHandler(new wxPNGHandler); + wxMemoryFSHandler::AddFile("logo.png", + wxBitmap(wxlogo_xpm), wxBITMAP_TYPE_PNG); + wxMemoryFSHandler::AddFile("page1.htm", + "
Some text about Page 2.
"); + wxMemoryFSHandler::AddFile("page2.htm", + "Page 1 was better.
"); + wxMemoryFSHandler::AddFile("test.css", "h1 {color: red;}"); + WebFrame *frame = new WebFrame(m_url); frame->Show(); @@ -222,9 +246,6 @@ bool WebApp::OnInit() WebFrame::WebFrame(const wxString& url) : wxFrame(NULL, wxID_ANY, "wxWebView Sample") { - //Required from virtual file system archive support - wxFileSystem::AddHandler(new wxArchiveFSHandler); - // set the frame icon SetIcon(wxICON(sample)); SetTitle("wxWebView Sample"); @@ -309,6 +330,8 @@ WebFrame::WebFrame(const wxString& url) : //We register the wxfs:// protocol for testing purposes m_browser->RegisterHandler(wxSharedPtr