]>
Commit | Line | Data |
---|---|---|
6762286d | 1 | ///////////////////////////////////////////////////////////////////////////// |
233f5738 | 2 | // Name: wx/osx/carbon/mimetype.h |
6762286d SC |
3 | // Purpose: Mac Carbon implementation for wx mime-related classes |
4 | // Author: Ryan Norton | |
5 | // Modified by: | |
6 | // Created: 04/16/2005 | |
6762286d SC |
7 | // Copyright: (c) 2005 Ryan Norton (<wxprojects@comcast.net>) |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _MIMETYPE_IMPL_H | |
12 | #define _MIMETYPE_IMPL_H | |
13 | ||
14 | #include "wx/defs.h" | |
15 | #include "wx/mimetype.h" | |
16 | ||
17 | ||
18 | class wxMimeTypesManagerImpl | |
19 | { | |
20 | public : | |
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(); } | |
25 | ||
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); | |
29 | ||
30 | // and delete the data here | |
31 | void ClearData(); | |
32 | ||
33 | // implement containing class functions | |
34 | wxFileType *GetFileTypeFromExtension(const wxString& ext); | |
35 | wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext) ; | |
36 | wxFileType *GetFileTypeFromMimeType(const wxString& mimeType); | |
37 | ||
38 | size_t EnumAllFileTypes(wxArrayString& mimetypes); | |
39 | ||
40 | void AddFallback(const wxFileTypeInfo& ft) { m_fallbacks.Add(ft); } | |
41 | ||
42 | // create a new filetype association | |
43 | wxFileType *Associate(const wxFileTypeInfo& ftInfo); | |
44 | // remove association | |
45 | bool Unassociate(wxFileType *ft); | |
46 | ||
47 | private: | |
48 | wxArrayFileTypeInfo m_fallbacks; | |
49 | void* m_hIC; | |
50 | void** m_hDatabase; | |
51 | long m_lCount; | |
52 | ||
53 | void* pReserved1; | |
54 | void* pReserved2; | |
55 | void* pReserved3; | |
56 | void* pReserved4; | |
57 | void* pReserved5; | |
58 | void* pReserved6; | |
59 | ||
60 | friend class wxFileTypeImpl; | |
61 | }; | |
62 | ||
63 | class wxFileTypeImpl | |
64 | { | |
65 | public: | |
66 | //kind of nutty, but mimecmn.cpp creates one with an empty new | |
67 | wxFileTypeImpl() : m_manager(NULL) {} | |
68 | ~wxFileTypeImpl() {} //for those broken compilers | |
69 | ||
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; | |
80 | ||
81 | size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands, | |
82 | const wxFileType::MessageParameters& params) const; | |
83 | ||
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) | |
87 | { | |
88 | return m_manager->Unassociate(ft); | |
89 | } | |
90 | ||
91 | // set an arbitrary command, ask confirmation if it already exists and | |
92 | // overwriteprompt is TRUE | |
8e6efd1f | 93 | bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = true); |
6762286d SC |
94 | bool SetDefaultIcon(const wxString& strIcon = wxEmptyString, int index = 0); |
95 | ||
96 | private: | |
97 | void Init(wxMimeTypesManagerImpl *manager, long lIndex) | |
98 | { m_manager=(manager); m_lIndex=(lIndex); } | |
99 | ||
100 | // helper function | |
101 | wxString GetCommand(const wxString& verb) const; | |
102 | ||
103 | wxMimeTypesManagerImpl *m_manager; | |
104 | long m_lIndex; | |
105 | ||
106 | void* pReserved1; | |
107 | void* pReserved2; | |
108 | void* pReserved3; | |
109 | void* pReserved4; | |
110 | void* pReserved5; | |
111 | void* pReserved6; | |
112 | ||
113 | friend class wxMimeTypesManagerImpl; | |
114 | }; | |
115 | ||
5c6eb3a8 | 116 | #endif |
6762286d | 117 | //_MIMETYPE_H |