]> git.saurik.com Git - wxWidgets.git/blob - src/msdos/mimetype.cpp
Allow specification of border spacing
[wxWidgets.git] / src / msdos / mimetype.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msdos/mimetype.cpp
3 // Purpose: classes and functions to manage MIME types
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 23.09.98
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence (part of wxExtra library)
10 /////////////////////////////////////////////////////////////////////////////
11
12 // for compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include "wx/defs.h"
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/string.h"
25 #if wxUSE_GUI
26 #include "wx/icon.h"
27 #endif
28 #endif //WX_PRECOMP
29
30 #if wxUSE_MIMETYPE
31
32 #include "wx/log.h"
33 #include "wx/file.h"
34 #include "wx/intl.h"
35 #include "wx/dynarray.h"
36 #include "wx/confbase.h"
37
38 #include "wx/msdos/mimetype.h"
39
40 // other standard headers
41 #include <ctype.h>
42
43 // in case we're compiling in non-GUI mode
44 class WXDLLEXPORT wxIcon;
45
46 bool wxFileTypeImpl::SetCommand(const wxString& WXUNUSED(cmd),
47 const wxString& WXUNUSED(verb),
48 bool WXUNUSED(overwriteprompt))
49 {
50 return false;
51 }
52
53 bool wxFileTypeImpl::SetDefaultIcon(const wxString& WXUNUSED(strIcon),
54 int WXUNUSED(index))
55 {
56 return false;
57 }
58
59 bool wxFileTypeImpl::GetCommand(wxString *WXUNUSED(command),
60 const char *WXUNUSED(verb)) const
61 {
62 return false;
63 }
64
65 bool wxFileTypeImpl::GetExtensions(wxArrayString& WXUNUSED(extensions))
66 {
67 return false;
68 }
69
70 bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
71 {
72 if ( m_strFileType.Length() > 0 )
73 {
74 *mimeType = m_strFileType ;
75 return true ;
76 }
77 else
78 return false;
79 }
80
81 bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
82 {
83 wxString s;
84
85 if (GetMimeType(&s))
86 {
87 mimeTypes.Clear();
88 mimeTypes.Add(s);
89 return true;
90 }
91 else
92 return false;
93 }
94
95 bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
96 {
97 // no such file type or no value or incorrect icon entry
98 return false;
99 }
100
101 bool wxFileTypeImpl::GetDescription(wxString *WXUNUSED(desc)) const
102 {
103 return false;
104 }
105
106 size_t
107 wxFileTypeImpl::GetAllCommands(wxArrayString * WXUNUSED(verbs),
108 wxArrayString * WXUNUSED(commands),
109 const wxFileType::MessageParameters& WXUNUSED(params)) const
110 {
111 wxFAIL_MSG( _T("wxFileTypeImpl::GetAllCommands() not yet implemented") );
112 return 0;
113 }
114
115 void
116 wxMimeTypesManagerImpl::Initialize(int WXUNUSED(mailcapStyles),
117 const wxString& WXUNUSED(extraDir))
118 {
119 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Initialize() not yet implemented") );
120 }
121
122 void
123 wxMimeTypesManagerImpl::ClearData()
124 {
125 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::ClearData() not yet implemented") );
126 }
127
128 // extension -> file type
129 wxFileType *
130 wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
131 {
132 wxString ext = e ;
133 ext = ext.Lower() ;
134 if ( ext == wxT("txt") )
135 {
136 wxFileType *fileType = new wxFileType;
137 fileType->m_impl->SetFileType(wxT("text/text"));
138 fileType->m_impl->SetExt(ext);
139 return fileType;
140 }
141 else if ( ext == wxT("htm") || ext == wxT("html") )
142 {
143 wxFileType *fileType = new wxFileType;
144 fileType->m_impl->SetFileType(wxT("text/html"));
145 fileType->m_impl->SetExt(ext);
146 return fileType;
147 }
148 else if ( ext == wxT("gif") )
149 {
150 wxFileType *fileType = new wxFileType;
151 fileType->m_impl->SetFileType(wxT("image/gif"));
152 fileType->m_impl->SetExt(ext);
153 return fileType;
154 }
155 else if ( ext == wxT("png" ))
156 {
157 wxFileType *fileType = new wxFileType;
158 fileType->m_impl->SetFileType(wxT("image/png"));
159 fileType->m_impl->SetExt(ext);
160 return fileType;
161 }
162 else if ( ext == wxT("jpg" )|| ext == wxT("jpeg") )
163 {
164 wxFileType *fileType = new wxFileType;
165 fileType->m_impl->SetFileType(wxT("image/jpeg"));
166 fileType->m_impl->SetExt(ext);
167 return fileType;
168 }
169 else if ( ext == wxT("bmp") )
170 {
171 wxFileType *fileType = new wxFileType;
172 fileType->m_impl->SetFileType(wxT("image/bmp"));
173 fileType->m_impl->SetExt(ext);
174 return fileType;
175 }
176 else if ( ext == wxT("tif") || ext == wxT("tiff") )
177 {
178 wxFileType *fileType = new wxFileType;
179 fileType->m_impl->SetFileType(wxT("image/tiff"));
180 fileType->m_impl->SetExt(ext);
181 return fileType;
182 }
183 else if ( ext == wxT("xpm") )
184 {
185 wxFileType *fileType = new wxFileType;
186 fileType->m_impl->SetFileType(wxT("image/xpm"));
187 fileType->m_impl->SetExt(ext);
188 return fileType;
189 }
190 else if ( ext == wxT("xbm") )
191 {
192 wxFileType *fileType = new wxFileType;
193 fileType->m_impl->SetFileType(wxT("image/xbm"));
194 fileType->m_impl->SetExt(ext);
195 return fileType;
196 }
197
198 // unknown extension
199 return NULL;
200 }
201
202 // MIME type -> extension -> file type
203 wxFileType *
204 wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& WXUNUSED(mimeType))
205 {
206 return NULL;
207 }
208
209 size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& WXUNUSED(mimetypes))
210 {
211 // VZ: don't know anything about this for Mac
212 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::EnumAllFileTypes() not yet implemented") );
213
214 return 0;
215 }
216
217 wxFileType *
218 wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& WXUNUSED(ftInfo))
219 {
220 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Associate() not yet implemented") );
221
222 return NULL;
223 }
224
225 bool
226 wxMimeTypesManagerImpl::Unassociate(wxFileType *WXUNUSED(ft))
227 {
228 return false;
229 }
230
231 #endif // wxUSE_MIMETYPE