]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/carbon/mimetype.h
give a name to the enum to make it easier to reference it in docs; wxFSVolume shouldn...
[wxWidgets.git] / include / wx / osx / carbon / mimetype.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/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 #include "wx/defs.h"
16 #include "wx/mimetype.h"
17
18
19 class wxMimeTypesManagerImpl
20 {
21 public :
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(); }
26
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);
30
31 // and delete the data here
32 void ClearData();
33
34 // implement containing class functions
35 wxFileType *GetFileTypeFromExtension(const wxString& ext);
36 wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext) ;
37 wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
38
39 size_t EnumAllFileTypes(wxArrayString& mimetypes);
40
41 void AddFallback(const wxFileTypeInfo& ft) { m_fallbacks.Add(ft); }
42
43 // create a new filetype association
44 wxFileType *Associate(const wxFileTypeInfo& ftInfo);
45 // remove association
46 bool Unassociate(wxFileType *ft);
47
48 private:
49 wxArrayFileTypeInfo m_fallbacks;
50 void* m_hIC;
51 void** m_hDatabase;
52 long m_lCount;
53
54 void* pReserved1;
55 void* pReserved2;
56 void* pReserved3;
57 void* pReserved4;
58 void* pReserved5;
59 void* pReserved6;
60
61 friend class wxFileTypeImpl;
62 };
63
64 class wxFileTypeImpl
65 {
66 public:
67 //kind of nutty, but mimecmn.cpp creates one with an empty new
68 wxFileTypeImpl() : m_manager(NULL) {}
69 ~wxFileTypeImpl() {} //for those broken compilers
70
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;
81
82 size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
83 const wxFileType::MessageParameters& params) const;
84
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)
88 {
89 return m_manager->Unassociate(ft);
90 }
91
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);
96
97 private:
98 void Init(wxMimeTypesManagerImpl *manager, long lIndex)
99 { m_manager=(manager); m_lIndex=(lIndex); }
100
101 // helper function
102 wxString GetCommand(const wxString& verb) const;
103
104 wxMimeTypesManagerImpl *m_manager;
105 long m_lIndex;
106
107 void* pReserved1;
108 void* pReserved2;
109 void* pReserved3;
110 void* pReserved4;
111 void* pReserved5;
112 void* pReserved6;
113
114 friend class wxMimeTypesManagerImpl;
115 };
116
117 #endif
118 //_MIMETYPE_H