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