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