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