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