]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/classic/mimetype.h
Revert last change, which made it impossible to set a custom text color and then...
[wxWidgets.git] / include / wx / mac / classic / mimetype.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/mimetype.h
3 // Purpose: classes and functions to manage MIME types
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 23.09.98
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence (part of wxExtra library)
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 wxMimeTypesManagerImpl() { }
23 #ifdef __DARWIN__
24 ~wxMimeTypesManagerImpl() { }
25 #endif
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 // this are NOPs under MacOS
42 bool ReadMailcap(const wxString& WXUNUSED(filename), bool WXUNUSED(fallback) = TRUE) { return TRUE; }
43 bool ReadMimeTypes(const wxString& WXUNUSED(filename)) { return TRUE; }
44
45 void AddFallback(const wxFileTypeInfo& ft) { m_fallbacks.Add(ft); }
46
47 // create a new filetype association
48 wxFileType *Associate(const wxFileTypeInfo& ftInfo);
49 // remove association
50 bool Unassociate(wxFileType *ft);
51
52 // create a new filetype with the given name and extension
53 wxFileType *CreateFileType(const wxString& filetype, const wxString& ext);
54
55 private:
56 wxArrayFileTypeInfo m_fallbacks;
57 };
58
59 class wxFileTypeImpl
60 {
61 public:
62 // initialization functions
63 // this is used to construct a list of mimetypes which match;
64 // if built with GetFileTypeFromMimetype index 0 has the exact match and
65 // index 1 the type / * match
66 // if built with GetFileTypeFromExtension, index 0 has the mimetype for
67 // the first extension found, index 1 for the second and so on
68
69 void Init(wxMimeTypesManagerImpl *manager, size_t index)
70 { m_manager = manager; m_index.Add(index); }
71
72 // initialize us with our file type name
73 void SetFileType(const wxString& strFileType)
74 { m_strFileType = strFileType; }
75 void SetExt(const wxString& ext)
76 { m_ext = ext; }
77
78 // implement accessor functions
79 bool GetExtensions(wxArrayString& extensions);
80 bool GetMimeType(wxString *mimeType) const;
81 bool GetMimeTypes(wxArrayString& mimeTypes) const;
82 bool GetIcon(wxIconLocation *iconLoc) const;
83 bool GetDescription(wxString *desc) const;
84 bool GetOpenCommand(wxString *openCmd,
85 const wxFileType::MessageParameters&) const
86 { return GetCommand(openCmd, "open"); }
87 bool GetPrintCommand(wxString *printCmd,
88 const wxFileType::MessageParameters&) const
89 { return GetCommand(printCmd, "print"); }
90
91 size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
92 const wxFileType::MessageParameters& params) const;
93
94 // remove the record for this file type
95 // probably a mistake to come here, use wxMimeTypesManager.Unassociate (ft) instead
96 bool Unassociate(wxFileType *ft)
97 {
98 return m_manager->Unassociate(ft);
99 }
100
101 // set an arbitrary command, ask confirmation if it already exists and
102 // overwriteprompt is TRUE
103 bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE);
104 bool SetDefaultIcon(const wxString& strIcon = wxEmptyString, int index = 0);
105
106 private:
107 // helper function
108 bool GetCommand(wxString *command, const char *verb) const;
109
110 wxMimeTypesManagerImpl *m_manager;
111 wxArrayInt m_index; // in the wxMimeTypesManagerImpl arrays
112 wxString m_strFileType, m_ext;
113 };
114
115 #endif
116 //_MIMETYPE_H
117
118 /* vi: set cin tw=80 ts=4 sw=4: */