1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/carbon/mimetype.h
3 // Purpose: Mac Carbon implementation for wx mime-related classes
7 // Copyright: (c) 2005 Ryan Norton (<wxprojects@comcast.net>)
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _MIMETYPE_IMPL_H
12 #define _MIMETYPE_IMPL_H
15 #include "wx/mimetype.h"
18 class wxMimeTypesManagerImpl
21 //kinda kooky but in wxMimeTypesManager::EnsureImpl it doesn't call
22 //intialize, so we do it ourselves
23 wxMimeTypesManagerImpl() : m_hIC(NULL
) { Initialize(); }
24 ~wxMimeTypesManagerImpl() { ClearData(); }
26 // load all data into memory - done when it is needed for the first time
27 void Initialize(int mailcapStyles
= wxMAILCAP_STANDARD
,
28 const wxString
& extraDir
= wxEmptyString
);
30 // and delete the data here
33 // implement containing class functions
34 wxFileType
*GetFileTypeFromExtension(const wxString
& ext
);
35 wxFileType
*GetOrAllocateFileTypeFromExtension(const wxString
& ext
) ;
36 wxFileType
*GetFileTypeFromMimeType(const wxString
& mimeType
);
38 size_t EnumAllFileTypes(wxArrayString
& mimetypes
);
40 void AddFallback(const wxFileTypeInfo
& ft
) { m_fallbacks
.Add(ft
); }
42 // create a new filetype association
43 wxFileType
*Associate(const wxFileTypeInfo
& ftInfo
);
45 bool Unassociate(wxFileType
*ft
);
48 wxArrayFileTypeInfo m_fallbacks
;
60 friend class wxFileTypeImpl
;
66 //kind of nutty, but mimecmn.cpp creates one with an empty new
67 wxFileTypeImpl() : m_manager(NULL
) {}
68 ~wxFileTypeImpl() {} //for those broken compilers
70 // implement accessor functions
71 bool GetExtensions(wxArrayString
& extensions
);
72 bool GetMimeType(wxString
*mimeType
) const;
73 bool GetMimeTypes(wxArrayString
& mimeTypes
) const;
74 bool GetIcon(wxIconLocation
*iconLoc
) const;
75 bool GetDescription(wxString
*desc
) const;
76 bool GetOpenCommand(wxString
*openCmd
,
77 const wxFileType::MessageParameters
&) const;
78 bool GetPrintCommand(wxString
*printCmd
,
79 const wxFileType::MessageParameters
&) const;
81 size_t GetAllCommands(wxArrayString
* verbs
, wxArrayString
* commands
,
82 const wxFileType::MessageParameters
& params
) const;
84 // remove the record for this file type
85 // probably a mistake to come here, use wxMimeTypesManager.Unassociate (ft) instead
86 bool Unassociate(wxFileType
*ft
)
88 return m_manager
->Unassociate(ft
);
91 // set an arbitrary command, ask confirmation if it already exists and
92 // overwriteprompt is TRUE
93 bool SetCommand(const wxString
& cmd
, const wxString
& verb
, bool overwriteprompt
= true);
94 bool SetDefaultIcon(const wxString
& strIcon
= wxEmptyString
, int index
= 0);
97 void Init(wxMimeTypesManagerImpl
*manager
, long lIndex
)
98 { m_manager
=(manager
); m_lIndex
=(lIndex
); }
101 wxString
GetCommand(const wxString
& verb
) const;
103 wxMimeTypesManagerImpl
*m_manager
;
113 friend class wxMimeTypesManagerImpl
;