]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/mimetmac.cpp
Patch by David Brinegar to fix menubar updating after modal dialog shown
[wxWidgets.git] / src / mac / carbon / mimetmac.cpp
CommitLineData
7dc3cc31
VS
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>
65571936 9// Licence: wxWindows licence (part of wxExtra library)
7dc3cc31
VS
10/////////////////////////////////////////////////////////////////////////////
11
3d1a4878 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
7dc3cc31
VS
13#pragma implementation "mimetype.h"
14#endif
15
16// for compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20 #pragma hdrstop
21#endif
22
7dc3cc31
VS
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
43class WXDLLEXPORT wxIcon;
44
f040060e
GD
45bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt)
46{
47 return FALSE;
48}
49
50bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index)
51{
52 return FALSE;
53}
7dc3cc31 54
7dc3cc31
VS
55bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
56{
57 return FALSE;
58}
59
60// @@ this function is half implemented
61bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
62{
63 return FALSE;
64}
65
66bool 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
4d2976ad
VS
77bool 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
da0766ab 91bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
7dc3cc31
VS
92{
93 // no such file type or no value or incorrect icon entry
94 return FALSE;
95}
96
97bool wxFileTypeImpl::GetDescription(wxString *desc) const
98{
99 return FALSE;
100}
101
f040060e
GD
102size_t
103wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
e40298d5 104 const wxFileType::MessageParameters& params) const
007ae8d0 105{
0fe3b231 106 wxFAIL_MSG( _T("wxFileTypeImpl::GetAllCommands() not yet implemented") );
f040060e
GD
107 return 0;
108}
109
110void
111wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extraDir)
112{
0fe3b231 113 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Initialize() not yet implemented") );
f040060e
GD
114}
115
116void
117wxMimeTypesManagerImpl::ClearData()
118{
0fe3b231 119 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::ClearData() not yet implemented") );
007ae8d0
GD
120}
121
7dc3cc31
VS
122// extension -> file type
123wxFileType *
124wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
125{
126 wxString ext = e ;
127 ext = ext.Lower() ;
427ff662 128 if ( ext == wxT("txt") )
7dc3cc31
VS
129 {
130 wxFileType *fileType = new wxFileType;
427ff662 131 fileType->m_impl->SetFileType(wxT("text/text"));
7dc3cc31
VS
132 fileType->m_impl->SetExt(ext);
133 return fileType;
134 }
427ff662 135 else if ( ext == wxT("htm") || ext == wxT("html") )
7dc3cc31
VS
136 {
137 wxFileType *fileType = new wxFileType;
427ff662 138 fileType->m_impl->SetFileType(wxT("text/html"));
7dc3cc31
VS
139 fileType->m_impl->SetExt(ext);
140 return fileType;
141 }
427ff662 142 else if ( ext == wxT("gif") )
7dc3cc31
VS
143 {
144 wxFileType *fileType = new wxFileType;
427ff662 145 fileType->m_impl->SetFileType(wxT("image/gif"));
7dc3cc31
VS
146 fileType->m_impl->SetExt(ext);
147 return fileType;
148 }
427ff662 149 else if ( ext == wxT("png" ))
7dc3cc31
VS
150 {
151 wxFileType *fileType = new wxFileType;
427ff662 152 fileType->m_impl->SetFileType(wxT("image/png"));
7dc3cc31
VS
153 fileType->m_impl->SetExt(ext);
154 return fileType;
155 }
427ff662 156 else if ( ext == wxT("jpg" )|| ext == wxT("jpeg") )
7dc3cc31
VS
157 {
158 wxFileType *fileType = new wxFileType;
427ff662 159 fileType->m_impl->SetFileType(wxT("image/jpeg"));
7dc3cc31
VS
160 fileType->m_impl->SetExt(ext);
161 return fileType;
162 }
427ff662 163 else if ( ext == wxT("bmp") )
7dc3cc31
VS
164 {
165 wxFileType *fileType = new wxFileType;
427ff662 166 fileType->m_impl->SetFileType(wxT("image/bmp"));
7dc3cc31
VS
167 fileType->m_impl->SetExt(ext);
168 return fileType;
169 }
427ff662 170 else if ( ext == wxT("tif") || ext == wxT("tiff") )
7dc3cc31
VS
171 {
172 wxFileType *fileType = new wxFileType;
427ff662 173 fileType->m_impl->SetFileType(wxT("image/tiff"));
7dc3cc31
VS
174 fileType->m_impl->SetExt(ext);
175 return fileType;
176 }
427ff662 177 else if ( ext == wxT("xpm") )
7dc3cc31
VS
178 {
179 wxFileType *fileType = new wxFileType;
427ff662 180 fileType->m_impl->SetFileType(wxT("image/xpm"));
7dc3cc31
VS
181 fileType->m_impl->SetExt(ext);
182 return fileType;
183 }
427ff662 184 else if ( ext == wxT("xbm") )
7dc3cc31
VS
185 {
186 wxFileType *fileType = new wxFileType;
427ff662 187 fileType->m_impl->SetFileType(wxT("image/xbm"));
7dc3cc31
VS
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
197wxFileType *
198wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
199{
200 return NULL;
201}
202
203size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
204{
0fe3b231
GD
205 // VZ: don't know anything about this for Mac
206 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::EnumAllFileTypes() not yet implemented") );
7dc3cc31
VS
207
208 return 0;
209}
210
007ae8d0
GD
211wxFileType *
212wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
213{
0fe3b231 214 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Associate() not yet implemented") );
007ae8d0
GD
215
216 return NULL;
217}
f040060e
GD
218
219bool
220wxMimeTypesManagerImpl::Unassociate(wxFileType *ft)
221{
222 return FALSE;
223}
224