2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: fs_mem.h
|
|
|
|
// Purpose: documentation for wxMemoryFSHandler class
|
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxMemoryFSHandler
|
|
|
|
@wxheader{fs_mem.h}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
|
|
This wxFileSystem handler can store arbitrary
|
2008-03-08 08:52:38 -05:00
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Filenames are prefixed with "memory:", e.g. "memory:myfile.html".
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Example:
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@code
|
|
|
|
#ifndef __WXMSW__
|
|
|
|
#include "logo.xpm"
|
|
|
|
#endif
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
void MyFrame::OnAbout(wxCommandEvent&)
|
|
|
|
{
|
|
|
|
wxBusyCursor bcur;
|
|
|
|
wxFileSystem::AddHandler(new wxMemoryFSHandler);
|
|
|
|
wxMemoryFSHandler::AddFile("logo.pcx", wxBITMAP(logo), wxBITMAP_TYPE_PCX);
|
2008-03-08 09:43:31 -05:00
|
|
|
wxMemoryFSHandler::AddFile("about.htm",
|
2008-03-08 08:52:38 -05:00
|
|
|
"htmlbodyAbout: "
|
|
|
|
"img src=\"memory:logo.pcx\"/body/html");
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
wxDialog dlg(this, -1, wxString(_("About")));
|
|
|
|
wxBoxSizer *topsizer;
|
|
|
|
wxHtmlWindow *html;
|
|
|
|
topsizer = new wxBoxSizer(wxVERTICAL);
|
2008-03-08 09:43:31 -05:00
|
|
|
html = new wxHtmlWindow(, -1, wxDefaultPosition,
|
2008-03-08 08:52:38 -05:00
|
|
|
wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
|
|
|
|
html-SetBorders(0);
|
|
|
|
html-LoadPage("memory:about.htm");
|
2008-03-08 09:43:31 -05:00
|
|
|
html-SetSize(html-GetInternalRepresentation()-GetWidth(),
|
2008-03-08 08:52:38 -05:00
|
|
|
html-GetInternalRepresentation()-GetHeight());
|
|
|
|
topsizer-Add(html, 1, wxALL, 10);
|
|
|
|
topsizer-Add(new wxStaticLine(, -1), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
|
2008-03-08 09:43:31 -05:00
|
|
|
topsizer-Add(new wxButton(, wxID_OK, "Ok"),
|
2008-03-08 08:52:38 -05:00
|
|
|
0, wxALL | wxALIGN_RIGHT, 15);
|
|
|
|
dlg.SetAutoLayout(@true);
|
|
|
|
dlg.SetSizer(topsizer);
|
|
|
|
topsizer-Fit();
|
|
|
|
dlg.Centre();
|
|
|
|
dlg.ShowModal();
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
wxMemoryFSHandler::RemoveFile("logo.pcx");
|
|
|
|
wxMemoryFSHandler::RemoveFile("about.htm");
|
|
|
|
}
|
|
|
|
@endcode
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
|
|
|
@category{FIXME}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@seealso
|
|
|
|
wxMemoryFSHandler::AddFileWithMimeType
|
|
|
|
*/
|
|
|
|
class wxMemoryFSHandler : public wxFileSystemHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
|
|
|
wxMemoryFSHandler();
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Add file to list of files stored in memory. Stored
|
2008-03-08 08:52:38 -05:00
|
|
|
data (bitmap, text or raw data)
|
2008-03-08 09:43:31 -05:00
|
|
|
will be copied into private memory stream and available under
|
2008-03-08 08:52:38 -05:00
|
|
|
name "memory:" + @e filename.
|
|
|
|
|
|
|
|
The @e type argument is one of @c wxBITMAP_TYPE_XXX constants.
|
|
|
|
Note that you must use a @e type value (aka image format)
|
|
|
|
that wxWidgets can save (e.g. JPG, PNG, see wxImage
|
|
|
|
documentation)!
|
|
|
|
|
|
|
|
@sa AddFileWithMimeType()
|
|
|
|
*/
|
|
|
|
static void AddFile(const wxString& filename, wxImage& image,
|
|
|
|
long type);
|
2008-03-08 09:43:31 -05:00
|
|
|
static void AddFile(const wxString& filename,
|
|
|
|
const wxBitmap& bitmap,
|
|
|
|
long type);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
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
|
|
|
|
|
|
|
|
@sa AddFile()
|
|
|
|
*/
|
|
|
|
static void AddFileWithMimeType(const wxString& filename,
|
|
|
|
const wxString& textdata,
|
|
|
|
const wxString& mimetype);
|
2008-03-08 09:43:31 -05:00
|
|
|
static void AddFileWithMimeType(const wxString& filename,
|
|
|
|
const void* binarydata,
|
|
|
|
size_t size,
|
|
|
|
const wxString& mimetype);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Remove file from memory FS and free occupied memory.
|
|
|
|
*/
|
|
|
|
static void RemoveFile(const wxString& filename);
|
|
|
|
};
|