]> git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/mimetmac.cpp
linking commands on the individual window level, otherwise built-in handlers override...
[wxWidgets.git] / src / mac / classic / mimetmac.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: mac/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
31 #include "wx/log.h"
32 #include "wx/file.h"
33 #include "wx/intl.h"
34 #include "wx/dynarray.h"
35 #include "wx/confbase.h"
36
37 #include "wx/mac/mimetype.h"
38
39 // other standard headers
40 #include <ctype.h>
41
42 // in case we're compiling in non-GUI mode
43 class WXDLLEXPORT wxIcon;
44
45 bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt)
46 {
47 return false;
48 }
49
50 bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index)
51 {
52 return false;
53 }
54
55 bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
56 {
57 return false;
58 }
59
60 // @@ this function is half implemented
61 bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
62 {
63 return false;
64 }
65
66 bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
67 {
68 if ( m_strFileType.Length() > 0 )
69 {
70 *mimeType = m_strFileType ;
71 return true ;
72 }
73 else
74 return false;
75 }
76
77 bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
78 {
79 wxString s;
80
81 if (GetMimeType(&s))
82 {
83 mimeTypes.Clear();
84 mimeTypes.Add(s);
85 return true;
86 }
87 else
88 return false;
89 }
90
91 bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
92 {
93 // no such file type or no value or incorrect icon entry
94 return false;
95 }
96
97 bool wxFileTypeImpl::GetDescription(wxString *desc) const
98 {
99 return false;
100 }
101
102 size_t
103 wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
104 const wxFileType::MessageParameters& params) const
105 {
106 wxFAIL_MSG( _T("wxFileTypeImpl::GetAllCommands() not yet implemented") );
107 return 0;
108 }
109
110 void
111 wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extraDir)
112 {
113 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Initialize() not yet implemented") );
114 }
115
116 void
117 wxMimeTypesManagerImpl::ClearData()
118 {
119 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::ClearData() not yet implemented") );
120 }
121
122 // extension -> file type
123 wxFileType *
124 wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
125 {
126 wxString ext = e ;
127 ext = ext.Lower() ;
128 if ( ext == wxT("txt") )
129 {
130 wxFileType *fileType = new wxFileType;
131 fileType->m_impl->SetFileType(wxT("text/text"));
132 fileType->m_impl->SetExt(ext);
133 return fileType;
134 }
135 else if ( ext == wxT("htm") || ext == wxT("html") )
136 {
137 wxFileType *fileType = new wxFileType;
138 fileType->m_impl->SetFileType(wxT("text/html"));
139 fileType->m_impl->SetExt(ext);
140 return fileType;
141 }
142 else if ( ext == wxT("gif") )
143 {
144 wxFileType *fileType = new wxFileType;
145 fileType->m_impl->SetFileType(wxT("image/gif"));
146 fileType->m_impl->SetExt(ext);
147 return fileType;
148 }
149 else if ( ext == wxT("png" ))
150 {
151 wxFileType *fileType = new wxFileType;
152 fileType->m_impl->SetFileType(wxT("image/png"));
153 fileType->m_impl->SetExt(ext);
154 return fileType;
155 }
156 else if ( ext == wxT("jpg" )|| ext == wxT("jpeg") )
157 {
158 wxFileType *fileType = new wxFileType;
159 fileType->m_impl->SetFileType(wxT("image/jpeg"));
160 fileType->m_impl->SetExt(ext);
161 return fileType;
162 }
163 else if ( ext == wxT("bmp") )
164 {
165 wxFileType *fileType = new wxFileType;
166 fileType->m_impl->SetFileType(wxT("image/bmp"));
167 fileType->m_impl->SetExt(ext);
168 return fileType;
169 }
170 else if ( ext == wxT("tif") || ext == wxT("tiff") )
171 {
172 wxFileType *fileType = new wxFileType;
173 fileType->m_impl->SetFileType(wxT("image/tiff"));
174 fileType->m_impl->SetExt(ext);
175 return fileType;
176 }
177 else if ( ext == wxT("xpm") )
178 {
179 wxFileType *fileType = new wxFileType;
180 fileType->m_impl->SetFileType(wxT("image/xpm"));
181 fileType->m_impl->SetExt(ext);
182 return fileType;
183 }
184 else if ( ext == wxT("xbm") )
185 {
186 wxFileType *fileType = new wxFileType;
187 fileType->m_impl->SetFileType(wxT("image/xbm"));
188 fileType->m_impl->SetExt(ext);
189 return fileType;
190 }
191
192 // unknown extension
193 return NULL;
194 }
195
196 // MIME type -> extension -> file type
197 wxFileType *
198 wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
199 {
200 return NULL;
201 }
202
203 size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
204 {
205 // VZ: don't know anything about this for Mac
206 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::EnumAllFileTypes() not yet implemented") );
207
208 return 0;
209 }
210
211 wxFileType *
212 wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
213 {
214 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Associate() not yet implemented") );
215
216 return NULL;
217 }
218
219 bool
220 wxMimeTypesManagerImpl::Unassociate(wxFileType *ft)
221 {
222 return false;
223 }
224