]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msdos/mimetype.h
Use RIAA wrapper for wxSpinCtrl event disabling in wxGTK.
[wxWidgets.git] / include / wx / msdos / mimetype.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msdos/mimetype.h
3 // Purpose: classes and functions to manage MIME types
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 23.09.98
7 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
8 // Licence: wxWindows licence (part of wxExtra library)
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 wxMimeTypesManagerImpl() { }
22
23 // load all data into memory - done when it is needed for the first time
24 void Initialize(int mailcapStyles = wxMAILCAP_STANDARD,
25 const wxString& extraDir = wxEmptyString);
26
27 // and delete the data here
28 void ClearData();
29
30 // implement containing class functions
31 wxFileType *GetFileTypeFromExtension(const wxString& ext);
32 wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext) ;
33 wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
34
35 size_t EnumAllFileTypes(wxArrayString& mimetypes);
36
37 void AddFallback(const wxFileTypeInfo& ft) { m_fallbacks.Add(ft); }
38
39 // create a new filetype association
40 wxFileType *Associate(const wxFileTypeInfo& ftInfo);
41 // remove association
42 bool Unassociate(wxFileType *ft);
43
44 // create a new filetype with the given name and extension
45 wxFileType *CreateFileType(const wxString& filetype, const wxString& ext);
46
47 private:
48 wxArrayFileTypeInfo m_fallbacks;
49 };
50
51 class wxFileTypeImpl
52 {
53 public:
54 // initialization functions
55 // this is used to construct a list of mimetypes which match;
56 // if built with GetFileTypeFromMimetype index 0 has the exact match and
57 // index 1 the type / * match
58 // if built with GetFileTypeFromExtension, index 0 has the mimetype for
59 // the first extension found, index 1 for the second and so on
60
61 void Init(wxMimeTypesManagerImpl *manager, size_t index)
62 { m_manager = manager; m_index.Add(index); }
63
64 // initialize us with our file type name
65 void SetFileType(const wxString& strFileType)
66 { m_strFileType = strFileType; }
67 void SetExt(const wxString& ext)
68 { m_ext = ext; }
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 { return GetCommand(openCmd, "open"); }
79 bool GetPrintCommand(wxString *printCmd,
80 const wxFileType::MessageParameters&) const
81 { return GetCommand(printCmd, "print"); }
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 // helper function
100 bool GetCommand(wxString *command, const char *verb) const;
101
102 wxMimeTypesManagerImpl *m_manager;
103 wxArrayInt m_index; // in the wxMimeTypesManagerImpl arrays
104 wxString m_strFileType, m_ext;
105 };
106
107 #endif
108 //_MIMETYPE_H
109
110 /* vi: set cin tw=80 ts=4 sw=4: */