]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/mimetype.h
Added a SetFont method that behaves like SetLabel does with respect to
[wxWidgets.git] / include / wx / msw / mimetype.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/mimetype.h
3 // Purpose: classes and functions to manage MIME types
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 23.09.98
7 // RCS-ID: $Id$
8 // Copyright: (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 #ifdef __GNUG__
16 #pragma interface "mimetype.h"
17 #endif
18
19 #include "wx/defs.h"
20
21 #include "wx/mimetype.h"
22
23 // ----------------------------------------------------------------------------
24 // wxFileTypeImpl is the MSW version of wxFileType, this is a private class
25 // and is never used directly by the application
26 // ----------------------------------------------------------------------------
27
28 class WXDLLEXPORT wxFileTypeImpl
29 {
30 public:
31 // ctor
32 wxFileTypeImpl() { }
33
34 // one of these Init() function must be called (ctor can't take any
35 // arguments because it's common)
36
37 // initialize us with our file type name and extension - in this case
38 // we will read all other data from the registry
39 void Init(const wxString& strFileType, const wxString& ext);
40
41 // implement accessor functions
42 bool GetExtensions(wxArrayString& extensions);
43 bool GetMimeType(wxString *mimeType) const;
44 bool GetMimeTypes(wxArrayString& mimeTypes) const;
45 bool GetIcon(wxIcon *icon, wxString *sCommand = NULL, int *iIndex = NULL) const;
46 bool GetDescription(wxString *desc) const;
47 bool GetOpenCommand(wxString *openCmd,
48 const wxFileType::MessageParameters& params) const;
49 bool GetPrintCommand(wxString *printCmd,
50 const wxFileType::MessageParameters& params) const;
51
52 size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
53 const wxFileType::MessageParameters& params) const;
54
55 bool Unassociate();
56
57 // these methods are not publicly accessible (as wxMimeTypesManager
58 // doesn't know about them), and generally not very useful - they could be
59 // removed in the (near) future
60 bool SetCommand(const wxString& cmd, const wxString& verb,
61 bool overwriteprompt = true);
62 bool SetMimeType(const wxString& mimeType);
63 bool SetDefaultIcon(const wxString& cmd = wxEmptyString, int index = 0);
64
65 bool RemoveOpenCommand();
66 bool RemoveCommand(const wxString& verb);
67 bool RemoveMimeType();
68 bool RemoveDefaultIcon();
69
70 private:
71 // helper function: reads the command corresponding to the specified verb
72 // from the registry (returns an empty string if not found)
73 wxString GetCommand(const wxChar *verb) const;
74
75 // get the registry path for the given verb
76 wxString GetVerbPath(const wxString& verb) const;
77
78 // check that the registry key for our extension exists, create it if it
79 // doesn't, return FALSE if this failed
80 bool EnsureExtKeyExists();
81
82 wxString m_strFileType, // may be empty
83 m_ext;
84 };
85
86 class WXDLLEXPORT wxMimeTypesManagerImpl
87 {
88 public:
89 // nothing to do here, we don't load any data but just go and fetch it from
90 // the registry when asked for
91 wxMimeTypesManagerImpl() { }
92
93 // implement containing class functions
94 wxFileType *GetFileTypeFromExtension(const wxString& ext);
95 wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext) ;
96 wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
97
98 size_t EnumAllFileTypes(wxArrayString& mimetypes);
99
100 // this are NOPs under Windows
101 bool ReadMailcap(const wxString& filename, bool fallback = TRUE)
102 { return TRUE; }
103 bool ReadMimeTypes(const wxString& filename)
104 { return TRUE; }
105
106 // create a new filetype association
107 wxFileType *Associate(const wxFileTypeInfo& ftInfo);
108
109 // create a new filetype with the given name and extension
110 wxFileType *CreateFileType(const wxString& filetype, const wxString& ext);
111 };
112
113
114 #endif
115 //_MIMETYPE_IMPL_H
116