]>
Commit | Line | Data |
---|---|---|
708795b5 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/mimetype.h | |
3 | // Purpose: classes and functions to manage MIME types | |
2a6b16e3 | 4 | // Author: David Webster |
708795b5 DW |
5 | // Modified by: |
6 | // Created: 01.21.99 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: adopted from msw port -- (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
9 | // Licence: wxWindows license (part of wxExtra library) | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _MIMETYPE_IMPL_H | |
13 | #define _MIMETYPE_IMPL_H | |
14 | ||
15 | #include "wx/defs.h" | |
16 | ||
17 | #include "wx/mimetype.h" | |
18 | ||
19 | ||
20 | class WXDLLEXPORT wxFileTypeImpl | |
21 | { | |
22 | public: | |
23 | // ctor | |
24 | wxFileTypeImpl() { m_info = NULL; } | |
25 | ||
26 | // one of these Init() function must be called (ctor can't take any | |
27 | // arguments because it's common) | |
28 | ||
29 | // initialize us with our file type name and extension - in this case | |
30 | // we will read all other data from the registry | |
31 | void Init(const wxString& strFileType, const wxString& ext) | |
32 | { m_strFileType = strFileType; m_ext = ext; } | |
33 | ||
34 | // initialize us with a wxFileTypeInfo object - it contains all the | |
35 | // data | |
36 | void Init(const wxFileTypeInfo& info) | |
37 | { m_info = &info; } | |
38 | ||
39 | // implement accessor functions | |
40 | bool GetExtensions(wxArrayString& extensions); | |
41 | bool GetMimeType(wxString *mimeType) const; | |
2a6b16e3 | 42 | bool GetMimeTypes(wxArrayString& mimeTypes) const; |
a2cd9b86 | 43 | bool GetIcon(wxIcon *icon, wxString *sCommand = NULL, int *iIndex = NULL) const; |
708795b5 DW |
44 | bool GetDescription(wxString *desc) const; |
45 | bool GetOpenCommand(wxString *openCmd, | |
46 | const wxFileType::MessageParameters& params) const; | |
47 | bool GetPrintCommand(wxString *printCmd, | |
48 | const wxFileType::MessageParameters& params) const; | |
49 | ||
a2cd9b86 SN |
50 | size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands, |
51 | const wxFileType::MessageParameters& params) const; | |
52 | ||
53 | bool Unassociate(); | |
54 | ||
55 | // set an arbitrary command, ask confirmation if it already exists and | |
56 | // overwriteprompt is TRUE | |
57 | bool SetCommand(const wxString& cmd, | |
58 | const wxString& verb, | |
59 | bool overwriteprompt = TRUE); | |
60 | ||
61 | bool SetDefaultIcon(const wxString& cmd = wxEmptyString, int index = 0); | |
62 | ||
63 | // this is called by Associate | |
64 | bool SetDescription (const wxString& desc); | |
65 | ||
708795b5 DW |
66 | private: |
67 | // helper function: reads the command corresponding to the specified verb | |
68 | // from the registry (returns an empty string if not found) | |
69 | wxString GetCommand(const wxChar *verb) const; | |
70 | ||
71 | // we use either m_info or read the data from the registry if m_info == NULL | |
72 | const wxFileTypeInfo *m_info; | |
73 | wxString m_strFileType, // may be empty | |
74 | m_ext; | |
75 | }; | |
76 | ||
77 | ||
78 | ||
79 | class WXDLLEXPORT wxMimeTypesManagerImpl | |
80 | { | |
81 | public: | |
82 | // nothing to do here, we don't load any data but just go and fetch it from | |
83 | // the registry when asked for | |
84 | wxMimeTypesManagerImpl() { } | |
85 | ||
86 | // implement containing class functions | |
87 | wxFileType *GetFileTypeFromExtension(const wxString& ext); | |
a2cd9b86 | 88 | wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext); |
708795b5 DW |
89 | wxFileType *GetFileTypeFromMimeType(const wxString& mimeType); |
90 | ||
91 | size_t EnumAllFileTypes(wxArrayString& mimetypes); | |
92 | ||
a2cd9b86 | 93 | // these are NOPs under Windows |
708795b5 DW |
94 | bool ReadMailcap(const wxString& filename, bool fallback = TRUE) |
95 | { return TRUE; } | |
96 | bool ReadMimeTypes(const wxString& filename) | |
97 | { return TRUE; } | |
98 | ||
99 | void AddFallback(const wxFileTypeInfo& ft) { m_fallbacks.Add(ft); } | |
100 | ||
101 | private: | |
102 | wxArrayFileTypeInfo m_fallbacks; | |
103 | }; | |
104 | ||
105 | ||
106 | #endif | |
107 | //_MIMETYPE_IMPL_H | |
108 |