]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/filesys.i
Commented out the bitmap-greying code until I have time to debug it
[wxWidgets.git] / wxPython / src / filesys.i
CommitLineData
c368d904
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: filesys.i
3// Purpose: SWIG definitions of the wxFileSystem family of classes
4//
f74ff5ef 5// Author: Joerg Baumann and Robin Dunn
c368d904
RD
6//
7// Created: 25-Sept-2000
8// RCS-ID: $Id$
9// Copyright: (c) 2000 by Joerg Baumann
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13%module filesys
14
15%{
16#include "helpers.h"
17#include <wx/filesys.h>
18#include <wx/fs_inet.h>
19#include <wx/fs_mem.h>
20#include <wx/fs_zip.h>
21%}
22
23//----------------------------------------------------------------------
24
25%include typemaps.i
26%include my_typemaps.i
27
28// Import some definitions of other classes, etc.
29%import _defs.i
30%import utils.i
31%import image.i
32%import streams.i
33
34%pragma(python) code = "import wx"
35%pragma(python) code = "import string"
36
37//---------------------------------------------------------------------------
38
c368d904 39
9416aa89 40class wxFSFile : public wxObject {
c368d904
RD
41public:
42 wxFSFile(wxInputStream *stream, const wxString& loc,
43 const wxString& mimetype, const wxString& anchor,
44 wxDateTime modif);
45
46 wxInputStream *GetStream();
47 const wxString& GetMimeType();
48 const wxString& GetLocation();
49 const wxString& GetAnchor();
50 wxDateTime GetModificationTime();
51};
52
53
54// clear typemaps
55%typemap(python,in) wxInputStream *stream;
56%typemap(python,out) wxInputStream *;
57
58
59//---------------------------------------------------------------------------
60
61%{
62// wxPyFileSystemHandler will be the Python class wxFileSystemHandler and handling
63// the callback functions
64class wxPyFileSystemHandler : public wxFileSystemHandler {
65public:
66 wxPyFileSystemHandler() : wxFileSystemHandler() {}
67
68 DEC_PYCALLBACK_BOOL_STRING_pure(CanOpen);
69 DEC_PYCALLBACK_FSF_FSSTRING_pure(OpenFile);
70 DEC_PYCALLBACK_STRING_STRINGINT_pure(FindFirst);
71 DEC_PYCALLBACK_STRING__pure(FindNext);
72
73 wxString GetProtocol(const wxString& location) {
74 return wxFileSystemHandler::GetProtocol(location);
75 }
76
77 wxString GetLeftLocation(const wxString& location) {
78 return wxFileSystemHandler::GetLeftLocation(location);
79 }
80
81 wxString GetAnchor(const wxString& location) {
82 return wxFileSystemHandler::GetAnchor(location);
83 }
84
85 wxString GetRightLocation(const wxString& location) {
86 return wxFileSystemHandler::GetRightLocation(location);
87 }
88
89 wxString GetMimeTypeFromExt(const wxString& location){
90 return wxFileSystemHandler::GetMimeTypeFromExt(location);
91 }
92
93 PYPRIVATE;
94};
95
96
97IMP_PYCALLBACK_BOOL_STRING_pure(wxPyFileSystemHandler, wxFileSystemHandler, CanOpen);
98IMP_PYCALLBACK_FSF_FSSTRING_pure(wxPyFileSystemHandler, wxFileSystemHandler, OpenFile);
99IMP_PYCALLBACK_STRING_STRINGINT_pure(wxPyFileSystemHandler, wxFileSystemHandler, FindFirst);
100IMP_PYCALLBACK_STRING__pure(wxPyFileSystemHandler, wxFileSystemHandler, FindNext);
101%}
102
103
9416aa89
RD
104%name(wxCPPFileSystemHandler)class wxFileSystemHandler : public wxObject {
105 wxFileSystemHandler();
c368d904
RD
106}
107
108%name(wxFileSystemHandler)class wxPyFileSystemHandler : public wxFileSystemHandler {
109public:
110 wxPyFileSystemHandler();
111
0122b7e3
RD
112 void _setCallbackInfo(PyObject* self, PyObject* _class);
113 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFileSystemHandler)"
c368d904
RD
114
115 bool CanOpen(const wxString& location);
116 wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
117 wxString FindFirst(const wxString& spec, int flags = 0);
118 wxString FindNext();
119
120 wxString GetProtocol(const wxString& location);
121 wxString GetLeftLocation(const wxString& location);
122 wxString GetAnchor(const wxString& location);
123 wxString GetRightLocation(const wxString& location) const;
124 wxString GetMimeTypeFromExt(const wxString& location);
125};
126
127//---------------------------------------------------------------------------
128
9416aa89 129class wxFileSystem : public wxObject {
c368d904
RD
130public:
131 wxFileSystem();
132
133 void ChangePathTo(const wxString& location, bool is_dir = FALSE);
134 wxString GetPath();
135
136 wxFSFile* OpenFile(const wxString& location);
137
138 wxString FindFirst(const wxString& spec, int flags = 0);
139 wxString FindNext();
140
141 static void AddHandler(wxFileSystemHandler *handler);
142 static void CleanUpHandlers();
143};
144
145//---------------------------------------------------------------------------
146
147class wxInternetFSHandler : public wxFileSystemHandler {
148public:
149 wxInternetFSHandler();
150 bool CanOpen(const wxString& location);
151 wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
152};
153
154
155//---------------------------------------------------------------------------
156class wxZipFSHandler : public wxFileSystemHandler {
157public:
158 wxZipFSHandler();
159
160 bool CanOpen(const wxString& location);
161 wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
162 wxString FindFirst(const wxString& spec, int flags = 0);
163 wxString FindNext();
164};
165
166//---------------------------------------------------------------------------
167
168class wxMemoryFSHandler : public wxFileSystemHandler {
169public:
170 wxMemoryFSHandler();
171
172 // Remove file from memory FS and free occupied memory
173 static void RemoveFile(const wxString& filename);
174
175 bool CanOpen(const wxString& location);
176 wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
177 wxString FindFirst(const wxString& spec, int flags = 0);
178 virtual wxString FindNext();
179};
180
181
182// getting the overloaded static AddFile method right
183%inline %{
184void __wxMemoryFSHandler_AddFile_wxImage(const wxString& filename,
185 wxImage& image,
186 long type) {
187 wxMemoryFSHandler::AddFile(filename, image, type);
188}
189
190void __wxMemoryFSHandler_AddFile_wxBitmap(const wxString& filename,
191 const wxBitmap& bitmap,
192 long type) {
193 wxMemoryFSHandler::AddFile(filename, bitmap, type);
194}
195
196// void __wxMemoryFSHandler_AddFile_wxString(const wxString& filename,
197// const wxString& textdata) {
198// wxMemoryFSHandler::AddFile(filename, textdata);
199// }
200
201void __wxMemoryFSHandler_AddFile_Data(const wxString& filename,
202 PyObject* data) {
203
204 wxMemoryFSHandler::AddFile(filename,
205 (void*)PyString_AsString(data),
206 (size_t)PyString_Size(data));
207}
208%}
209
210
211// case switch for overloading
212%pragma(python) code = "
213import types
214def wxMemoryFSHandler_AddFile(filename, a, b=''):
215 if isinstance(a, wxImage):
216 __wxMemoryFSHandler_AddFile_wxImage(filename, a, b)
217 elif isinstance(a, wxBitmap):
218 __wxMemoryFSHandler_AddFile_wxBitmap(filename, a, b)
219 elif type(a) == types.StringType:
220 #__wxMemoryFSHandler_AddFile_wxString(filename, a)
221 __wxMemoryFSHandler_AddFile_Data(filename, a)
222 else: raise TypeError, 'wxImage, wxBitmap or string expected'
223"
224
225
9416aa89
RD
226//---------------------------------------------------------------------------
227
228%init %{
229 wxPyPtrTypeMap_Add("wxFileSystemHandler", "wxPyFileSystemHandler");
230%}
231
c368d904 232//---------------------------------------------------------------------------