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