X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5526e819eca4465ed5520d49bccfebc6a28045e0..33b494d643e42a2e2963987cbc3637f4593ea43a:/samples/html/virtual/virtual.cpp diff --git a/samples/html/virtual/virtual.cpp b/samples/html/virtual/virtual.cpp index 99e848ee55..a34298dc02 100644 --- a/samples/html/virtual/virtual.cpp +++ b/samples/html/virtual/virtual.cpp @@ -10,7 +10,7 @@ #endif // For compilers that support precompilation, includes "wx/wx.h". -#include +#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop @@ -19,17 +19,17 @@ // for all others, include the necessary headers (this file is usually all you // need because it includes almost all "standard" wxWindows headers #ifndef WX_PRECOMP - #include + #include "wx/wx.h" #endif -#include +#include "wx/html/htmlwin.h" // new handler class: -#include -#include +#include "wx/wfstream.h" +#include "wx/mstream.h" @@ -54,7 +54,7 @@ wxFSFile* MyVFS::OpenFile(wxFileSystem& fs, const wxString& location) { wxFSFile *f; wxInputStream *str; - char *buf = (char*)malloc(1024); + static char buf[1024]; sprintf(buf, "

You're in Node %s

" "Where do you want to go?

" @@ -63,8 +63,15 @@ wxFSFile* MyVFS::OpenFile(wxFileSystem& fs, const wxString& location) "sub-3
" "
", location.GetData(), location.GetData(), location.GetData(), location.GetData()); + + // NB: There's a terrible hack involved: we fill 'buf' with new data every + // time this method is called and return new wxMemoryInputStream pointing to it. + // This won't work as soon as there are 2+ myVFS files opened. Fortunately, + // this won't happen because wxHTML keeps only one "page" file opened at the + // time. str = new wxMemoryInputStream(buf, strlen(buf)); - f = new wxFSFile(str, location, "text/html", wxEmptyString); + f = new wxFSFile(str, location, "text/html", wxEmptyString, wxDateTime::Today()); + return f; } @@ -196,7 +203,7 @@ wxHtmlWindow *html; // ... and attach this menu bar to the frame SetMenuBar(menuBar); - CreateStatusBar(1); + CreateStatusBar(2); html = new wxHtmlWindow(this); html -> SetRelatedFrame(this, "VFS Demo: '%s'");