]> git.saurik.com Git - wxWidgets.git/blame - src/msdos/mimetype.cpp
Allow specification of border spacing
[wxWidgets.git] / src / msdos / mimetype.cpp
CommitLineData
81d9e625 1/////////////////////////////////////////////////////////////////////////////
127eab18 2// Name: src/msdos/mimetype.cpp
81d9e625
MW
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
81d9e625
MW
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
44class WXDLLEXPORT wxIcon;
45
127eab18
WS
46bool wxFileTypeImpl::SetCommand(const wxString& WXUNUSED(cmd),
47 const wxString& WXUNUSED(verb),
48 bool WXUNUSED(overwriteprompt))
81d9e625 49{
127eab18 50 return false;
81d9e625
MW
51}
52
127eab18
WS
53bool wxFileTypeImpl::SetDefaultIcon(const wxString& WXUNUSED(strIcon),
54 int WXUNUSED(index))
81d9e625 55{
127eab18 56 return false;
81d9e625
MW
57}
58
127eab18
WS
59bool wxFileTypeImpl::GetCommand(wxString *WXUNUSED(command),
60 const char *WXUNUSED(verb)) const
81d9e625 61{
127eab18 62 return false;
81d9e625
MW
63}
64
127eab18 65bool wxFileTypeImpl::GetExtensions(wxArrayString& WXUNUSED(extensions))
81d9e625 66{
127eab18 67 return false;
81d9e625
MW
68}
69
70bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
71{
72 if ( m_strFileType.Length() > 0 )
73 {
74 *mimeType = m_strFileType ;
127eab18 75 return true ;
81d9e625
MW
76 }
77 else
127eab18 78 return false;
81d9e625
MW
79}
80
81bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
82{
83 wxString s;
127eab18 84
81d9e625
MW
85 if (GetMimeType(&s))
86 {
87 mimeTypes.Clear();
88 mimeTypes.Add(s);
127eab18 89 return true;
81d9e625 90 }
127eab18
WS
91 else
92 return false;
81d9e625
MW
93}
94
95bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
96{
97 // no such file type or no value or incorrect icon entry
127eab18 98 return false;
81d9e625
MW
99}
100
127eab18 101bool wxFileTypeImpl::GetDescription(wxString *WXUNUSED(desc)) const
81d9e625 102{
127eab18 103 return false;
81d9e625
MW
104}
105
106size_t
127eab18
WS
107wxFileTypeImpl::GetAllCommands(wxArrayString * WXUNUSED(verbs),
108 wxArrayString * WXUNUSED(commands),
109 const wxFileType::MessageParameters& WXUNUSED(params)) const
81d9e625
MW
110{
111 wxFAIL_MSG( _T("wxFileTypeImpl::GetAllCommands() not yet implemented") );
112 return 0;
113}
114
115void
127eab18
WS
116wxMimeTypesManagerImpl::Initialize(int WXUNUSED(mailcapStyles),
117 const wxString& WXUNUSED(extraDir))
81d9e625
MW
118{
119 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Initialize() not yet implemented") );
120}
121
122void
123wxMimeTypesManagerImpl::ClearData()
124{
125 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::ClearData() not yet implemented") );
126}
127
128// extension -> file type
129wxFileType *
130wxMimeTypesManagerImpl::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
203wxFileType *
127eab18 204wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& WXUNUSED(mimeType))
81d9e625
MW
205{
206 return NULL;
207}
208
127eab18 209size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& WXUNUSED(mimetypes))
81d9e625
MW
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
217wxFileType *
127eab18 218wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& WXUNUSED(ftInfo))
81d9e625
MW
219{
220 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Associate() not yet implemented") );
221
222 return NULL;
223}
224
225bool
127eab18 226wxMimeTypesManagerImpl::Unassociate(wxFileType *WXUNUSED(ft))
81d9e625 227{
127eab18 228 return false;
81d9e625
MW
229}
230
231#endif // wxUSE_MIMETYPE