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