]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/fs_mem.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxMemoryFSHandler
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxMemoryFSHandler
12 This wxFileSystem handler can store arbitrary data in memory stream and make
13 them accessible via an URL.
15 It is particularly suitable for storing bitmaps from resources or included XPM
16 files so that they can be used with wxHTML or wxWebView.
18 Filenames are prefixed with @c "memory:", e.g. @c "memory:myfile.html".
27 void MyFrame::OnAbout(wxCommandEvent&)
29 wxFileSystem::AddHandler(new wxMemoryFSHandler);
30 wxMemoryFSHandler::AddFile("logo.png", wxBITMAP(logo), wxBITMAP_TYPE_PNG);
31 wxMemoryFSHandler::AddFile("about.htm",
33 "<img src=\"memory:logo.png\"></body></html>");
35 wxDialog dlg(this, -1, wxString(_("About")));
37 topsizer = new wxBoxSizer(wxVERTICAL);
39 wxWebView* browser = wxWebView::New(&dlg, wxID_ANY, wxWebViewDefaultURLStr,
40 wxDefaultPosition, wxSize(380, 160));
41 browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewFSHandler("memory")));
42 browser->LoadURL("memory:about.htm");
44 wxHtmlWindow *browser;
45 browser = new wxHtmlWindow(&dlg, -1, wxDefaultPosition,
46 wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
47 browser->SetBorders(0);
48 browser->LoadPage("memory:about.htm");
49 browser->SetSize(browser->GetInternalRepresentation()->GetWidth(),
50 browser->GetInternalRepresentation()->GetHeight());
52 topsizer->Add(browser, 1, wxALL, 10);
53 topsizer->Add(new wxStaticLine(&dlg, -1), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
54 topsizer->Add(new wxButton(&dlg, wxID_OK, "Ok"),
55 0, wxALL | wxALIGN_RIGHT, 15);
56 dlg.SetAutoLayout(true);
57 dlg.SetSizer(topsizer);
62 wxMemoryFSHandler::RemoveFile("logo.png");
63 wxMemoryFSHandler::RemoveFile("about.htm");
70 @see wxMemoryFSHandler::AddFileWithMimeType
72 class wxMemoryFSHandler
: public wxFileSystemHandler
82 Adds a file to the list of the files stored in memory.
84 Stored data (bitmap, text or raw data) will be copied into private memory
85 stream and available under name @c "memory:" + @e filename.
87 @note you must use a @a type value (aka image format) that wxWidgets
88 can save (e.g. JPG, PNG, see wxImage documentation)!
90 @see AddFileWithMimeType()
92 static void AddFile(const wxString
& filename
, wxImage
& image
, wxBitmapType type
);
93 static void AddFile(const wxString
& filename
, const wxBitmap
& bitmap
, wxBitmapType type
);
98 Like AddFile(), but lets you explicitly specify added file's MIME type.
100 This version should be used whenever you know the MIME type, because it
101 makes accessing the files faster.
107 static void AddFileWithMimeType(const wxString
& filename
,
108 const wxString
& textdata
,
109 const wxString
& mimetype
);
110 static void AddFileWithMimeType(const wxString
& filename
,
111 const void* binarydata
,
113 const wxString
& mimetype
);
117 Removes a file from memory FS and frees the occupied memory.
119 static void RemoveFile(const wxString
& filename
);