]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/mimetype.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / msw / mimetype.h
CommitLineData
7dc3cc31 1/////////////////////////////////////////////////////////////////////////////
4d2976ad 2// Name: wx/msw/mimetype.h
7dc3cc31
VS
3// Purpose: classes and functions to manage MIME types
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 23.09.98
7dc3cc31 7// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 8// Licence: wxWindows licence (part of wxExtra library)
7dc3cc31
VS
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _MIMETYPE_IMPL_H
12#define _MIMETYPE_IMPL_H
13
7dc3cc31
VS
14#include "wx/defs.h"
15
1e6feb95
VZ
16#if wxUSE_MIMETYPE
17
7dc3cc31
VS
18#include "wx/mimetype.h"
19
a6c65e88
VZ
20// ----------------------------------------------------------------------------
21// wxFileTypeImpl is the MSW version of wxFileType, this is a private class
22// and is never used directly by the application
23// ----------------------------------------------------------------------------
7dc3cc31 24
bddd7a8d 25class WXDLLIMPEXP_BASE wxFileTypeImpl
7dc3cc31
VS
26{
27public:
28 // ctor
a6c65e88 29 wxFileTypeImpl() { }
7dc3cc31
VS
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
c7ce8392 36 void Init(const wxString& strFileType, const wxString& ext);
7dc3cc31 37
7dc3cc31
VS
38 // implement accessor functions
39 bool GetExtensions(wxArrayString& extensions);
40 bool GetMimeType(wxString *mimeType) const;
4d2976ad 41 bool GetMimeTypes(wxArrayString& mimeTypes) const;
da0766ab 42 bool GetIcon(wxIconLocation *iconLoc) const;
7dc3cc31
VS
43 bool GetDescription(wxString *desc) const;
44 bool GetOpenCommand(wxString *openCmd,
45 const wxFileType::MessageParameters& params) const;
46 bool GetPrintCommand(wxString *printCmd,
47 const wxFileType::MessageParameters& params) const;
48
c7ce8392
VZ
49 size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
50 const wxFileType::MessageParameters& params) const;
51
a6c65e88
VZ
52 bool Unassociate();
53
2b813b73 54 // set an arbitrary command, ask confirmation if it already exists and
598ddd96 55 // overwriteprompt is true
2b813b73
VZ
56 bool SetCommand(const wxString& cmd,
57 const wxString& verb,
598ddd96 58 bool overwriteprompt = true);
2b813b73 59
c7ce8392
VZ
60 bool SetDefaultIcon(const wxString& cmd = wxEmptyString, int index = 0);
61
2b813b73
VZ
62 // this is called by Associate
63 bool SetDescription (const wxString& desc);
c7ce8392 64
7dc3cc31
VS
65private:
66 // helper function: reads the command corresponding to the specified verb
67 // from the registry (returns an empty string if not found)
e0a050e3 68 wxString GetCommand(const wxString& verb) const;
7dc3cc31 69
c7ce8392
VZ
70 // get the registry path for the given verb
71 wxString GetVerbPath(const wxString& verb) const;
72
73 // check that the registry key for our extension exists, create it if it
598ddd96 74 // doesn't, return false if this failed
c7ce8392
VZ
75 bool EnsureExtKeyExists();
76
7dc3cc31
VS
77 wxString m_strFileType, // may be empty
78 m_ext;
2b813b73
VZ
79
80 // these methods are not publicly accessible (as wxMimeTypesManager
81 // doesn't know about them), and should only be called by Unassociate
82
83 bool RemoveOpenCommand();
84 bool RemoveCommand(const wxString& verb);
85 bool RemoveMimeType();
86 bool RemoveDefaultIcon();
87 bool RemoveDescription();
7dc3cc31
VS
88};
89
bddd7a8d 90class WXDLLIMPEXP_BASE wxMimeTypesManagerImpl
7dc3cc31
VS
91{
92public:
93 // nothing to do here, we don't load any data but just go and fetch it from
94 // the registry when asked for
95 wxMimeTypesManagerImpl() { }
96
97 // implement containing class functions
98 wxFileType *GetFileTypeFromExtension(const wxString& ext);
2b813b73 99 wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext);
7dc3cc31
VS
100 wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
101
102 size_t EnumAllFileTypes(wxArrayString& mimetypes);
103
a6c65e88
VZ
104 // create a new filetype association
105 wxFileType *Associate(const wxFileTypeInfo& ftInfo);
7dc3cc31 106
c7ce8392
VZ
107 // create a new filetype with the given name and extension
108 wxFileType *CreateFileType(const wxString& filetype, const wxString& ext);
7dc3cc31
VS
109};
110
1e6feb95 111#endif // wxUSE_MIMETYPE
7dc3cc31
VS
112
113#endif
114 //_MIMETYPE_IMPL_H
115