]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/mimetype.h
wxHelpController now wxCHMHelpController on Windows
[wxWidgets.git] / include / wx / mac / carbon / mimetype.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/mimetype.h
3 // Purpose: Mac Carbon implementation for wx mime-related classes
4 // Author: Ryan Norton
5 // Modified by:
6 // Created: 04/16/2005
7 // RCS-ID: $Id$
8 // Copyright: (c) 2005 Ryan Norton (<wxprojects@comcast.net>)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _MIMETYPE_IMPL_H
13 #define _MIMETYPE_IMPL_H
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "mimetype.h"
17 #endif
18
19 #include "wx/defs.h"
20 #include "wx/mimetype.h"
21
22
23 class wxMimeTypesManagerImpl
24 {
25 public :
26 //kinda kooky but in wxMimeTypesManager::EnsureImpl it doesn't call
27 //intialize, so we do it ourselves
28 wxMimeTypesManagerImpl() : m_hIC(NULL) { Initialize(); }
29 ~wxMimeTypesManagerImpl() { ClearData(); }
30
31 // load all data into memory - done when it is needed for the first time
32 void Initialize(int mailcapStyles = wxMAILCAP_STANDARD,
33 const wxString& extraDir = wxEmptyString);
34
35 // and delete the data here
36 void ClearData();
37
38 // implement containing class functions
39 wxFileType *GetFileTypeFromExtension(const wxString& ext);
40 wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext) ;
41 wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
42
43 size_t EnumAllFileTypes(wxArrayString& mimetypes);
44
45 // this are NOPs under MacOS
46 bool ReadMailcap(const wxString& WXUNUSED(filename), bool WXUNUSED(fallback) = TRUE) { return TRUE; }
47 bool ReadMimeTypes(const wxString& WXUNUSED(filename)) { return TRUE; }
48
49 void AddFallback(const wxFileTypeInfo& ft) { m_fallbacks.Add(ft); }
50
51 // create a new filetype association
52 wxFileType *Associate(const wxFileTypeInfo& ftInfo);
53 // remove association
54 bool Unassociate(wxFileType *ft);
55
56 private:
57 wxArrayFileTypeInfo m_fallbacks;
58 void* m_hIC;
59 void** m_hDatabase;
60 long m_lCount;
61
62 friend class wxFileTypeImpl;
63 };
64
65 class wxFileTypeImpl
66 {
67 public:
68 //kind of nutty, but mimecmn.cpp creates one with an empty new
69 wxFileTypeImpl() : m_manager(NULL) {}
70 ~wxFileTypeImpl() {} //for those broken compilers
71
72 // implement accessor functions
73 bool GetExtensions(wxArrayString& extensions);
74 bool GetMimeType(wxString *mimeType) const;
75 bool GetMimeTypes(wxArrayString& mimeTypes) const;
76 bool GetIcon(wxIconLocation *iconLoc) const;
77 bool GetDescription(wxString *desc) const;
78 bool GetOpenCommand(wxString *openCmd,
79 const wxFileType::MessageParameters&) const;
80 bool GetPrintCommand(wxString *printCmd,
81 const wxFileType::MessageParameters&) const;
82
83 size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
84 const wxFileType::MessageParameters& params) const;
85
86 // remove the record for this file type
87 // probably a mistake to come here, use wxMimeTypesManager.Unassociate (ft) instead
88 bool Unassociate(wxFileType *ft)
89 {
90 return m_manager->Unassociate(ft);
91 }
92
93 // set an arbitrary command, ask confirmation if it already exists and
94 // overwriteprompt is TRUE
95 bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE);
96 bool SetDefaultIcon(const wxString& strIcon = wxEmptyString, int index = 0);
97
98 private:
99 void Init(wxMimeTypesManagerImpl *manager, long lIndex)
100 { m_manager=(manager); m_lIndex=(lIndex); }
101
102 // helper function
103 wxString GetCommand(const wxString& verb) const;
104
105 wxMimeTypesManagerImpl *m_manager;
106 long m_lIndex;
107
108 friend class wxMimeTypesManagerImpl;
109 };
110
111 #endif
112 //_MIMETYPE_H