]>
git.saurik.com Git - wxWidgets.git/blob - interface/fs_mem.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxMemoryFSHandler
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxMemoryFSHandler
13 This wxFileSystem handler can store arbitrary data in memory stream and make
14 them accessible via an URL.
16 It is particularly suitable for storing bitmaps from resources or included XPM
17 files so that they can be used with wxHTML.
19 Filenames are prefixed with @c "memory:", e.g. @c "memory:myfile.html".
28 void MyFrame::OnAbout(wxCommandEvent&)
31 wxFileSystem::AddHandler(new wxMemoryFSHandler);
32 wxMemoryFSHandler::AddFile("logo.pcx", wxBITMAP(logo), wxBITMAP_TYPE_PCX);
33 wxMemoryFSHandler::AddFile("about.htm",
35 "<img src=\"memory:logo.pcx\"></body></html>");
37 wxDialog dlg(this, -1, wxString(_("About")));
40 topsizer = new wxBoxSizer(wxVERTICAL);
41 html = new wxHtmlWindow(&dlg, -1, wxDefaultPosition,
42 wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
44 html->LoadPage("memory:about.htm");
45 html->SetSize(html->GetInternalRepresentation()->GetWidth(),
46 html->GetInternalRepresentation()->GetHeight());
47 topsizer->Add(html, 1, wxALL, 10);
48 topsizer->Add(new wxStaticLine(&dlg, -1), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
49 topsizer->Add(new wxButton(&dlg, wxID_OK, "Ok"),
50 0, wxALL | wxALIGN_RIGHT, 15);
51 dlg.SetAutoLayout(true);
52 dlg.SetSizer(topsizer);
57 wxMemoryFSHandler::RemoveFile("logo.pcx");
58 wxMemoryFSHandler::RemoveFile("about.htm");
65 @see wxMemoryFSHandler::AddFileWithMimeType
67 class wxMemoryFSHandler
: public wxFileSystemHandler
77 Adds a file to the list of the files stored in memory.
79 Stored data (bitmap, text or raw data) will be copied into private memory
80 stream and available under name @c "memory:" + @e filename.
82 @note you must use a @a type value (aka image format) that wxWidgets
83 can save (e.g. JPG, PNG, see wxImage documentation)!
85 @see AddFileWithMimeType()
87 static void AddFile(const wxString
& filename
, wxImage
& image
, wxBitmapType type
);
88 static void AddFile(const wxString
& filename
, const wxBitmap
& bitmap
, wxBitmapType type
);
93 Like AddFile(), but lets you explicitly specify added file's MIME type.
95 This version should be used whenever you know the MIME type, because it
96 makes accessing the files faster.
102 static void AddFileWithMimeType(const wxString
& filename
,
103 const wxString
& textdata
,
104 const wxString
& mimetype
);
105 static void AddFileWithMimeType(const wxString
& filename
,
106 const void* binarydata
,
108 const wxString
& mimetype
);
112 Removes a file from memory FS and frees the occupied memory.
114 static void RemoveFile(const wxString
& filename
);