wxmemoryfshandlerthis wxfilesystem handler can store arbitrary data in memory stream and make them accessible via url. it is particularly suitable for storing bitmaps from resources or included xpm files so that they can be used with wxhtml. filenames are prefixed with "memory:", e.g. "memory:myfile.php". example:
#ifndef __wxmsw__ #include "logo.xpm" #endif void myframe::onabout(wxcommandevent&) { wxbusycursor bcur; wxfilesystem::addhandler(new wxmemoryfshandler); wxmemoryfshandler::addfile("logo.pcx", wxbitmap(logo), wxbitmap_type_pcx); wxmemoryfshandler::addfile("about.htm", "<html><body>about: " "<img src=\"memory:logo.pcx\"></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); topsizer->add(new wxstaticline(&dlg, -1), 0, wxexpand | wxleft | wxright, 10); topsizer->add(new wxbutton(&dlg, wxid_ok, "ok"), 0, wxall | wxalign_right, 15); dlg.setautolayout(true); dlg.setsizer(topsizer); topsizer->fit(&dlg); dlg.centre(); dlg.showmodal(); wxmemoryfshandler::removefile("logo.pcx"); wxmemoryfshandler::removefile("about.htm"); }derived from include files <wx/fs_mem.h> members
wxmemoryfshandler::wxmemoryfshandler
wxmemoryfshandler::wxmemoryfshandlerwxmemoryfshandler() constructor.
wxmemoryfshandler::addfilestatic void addfile(const wxstring& filename, wximage& image, long type) static void addfile(const wxstring& filename, const wxbitmap& bitmap, long type) add file to list of files stored in memory. stored data (bitmap, text or raw data) will be copied into private memory stream and available under name "memory:" + filename. the type argument is one of wxbitmap_type_xxx constants. note that you must use a type value (aka image format) that wxwidgets can save (e.g. jpg, png, see wximage documentation)! see also
wxmemoryfshandler::addfilewithmimetypestatic void addfilewithmimetype(const wxstring& filename, const wxstring& textdata, const wxstring& mimetype) static void addfilewithmimetype(const wxstring& filename, const void* binarydata, size_t size, const wxstring& mimetype) like addfile, but lets you explicitly specify added file's mime type. this version should be used whenever you know the mime type, because it makes accessing the files faster. this function is new since wxwidgets version 2.8.5 see also
wxmemoryfshandler::removefilestatic void removefile(const wxstring& filename) remove file from memory fs and free occupied memory.
|