]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msdos/mimetype.h
wxMSW compilation fix for wxCompositeWindow.
[wxWidgets.git] / include / wx / msdos / mimetype.h
CommitLineData
7b0786bf 1/////////////////////////////////////////////////////////////////////////////
3c15a151 2// Name: wx/msdos/mimetype.h
7b0786bf
MW
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 licence (part of wxExtra library)
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _MIMETYPE_IMPL_H
13#define _MIMETYPE_IMPL_H
14
7b0786bf
MW
15#include "wx/defs.h"
16#include "wx/mimetype.h"
17
18
19class wxMimeTypesManagerImpl
20{
21public :
22 wxMimeTypesManagerImpl() { }
3c15a151 23
7b0786bf
MW
24 // load all data into memory - done when it is needed for the first time
25 void Initialize(int mailcapStyles = wxMAILCAP_STANDARD,
26 const wxString& extraDir = wxEmptyString);
27
28 // and delete the data here
29 void ClearData();
30
31 // implement containing class functions
32 wxFileType *GetFileTypeFromExtension(const wxString& ext);
33 wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext) ;
34 wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
35
36 size_t EnumAllFileTypes(wxArrayString& mimetypes);
37
7b0786bf
MW
38 void AddFallback(const wxFileTypeInfo& ft) { m_fallbacks.Add(ft); }
39
40 // create a new filetype association
41 wxFileType *Associate(const wxFileTypeInfo& ftInfo);
42 // remove association
43 bool Unassociate(wxFileType *ft);
44
45 // create a new filetype with the given name and extension
46 wxFileType *CreateFileType(const wxString& filetype, const wxString& ext);
47
48private:
49 wxArrayFileTypeInfo m_fallbacks;
50};
51
52class wxFileTypeImpl
53{
54public:
55 // initialization functions
56 // this is used to construct a list of mimetypes which match;
57 // if built with GetFileTypeFromMimetype index 0 has the exact match and
58 // index 1 the type / * match
59 // if built with GetFileTypeFromExtension, index 0 has the mimetype for
60 // the first extension found, index 1 for the second and so on
3c15a151 61
7b0786bf
MW
62 void Init(wxMimeTypesManagerImpl *manager, size_t index)
63 { m_manager = manager; m_index.Add(index); }
64
65 // initialize us with our file type name
66 void SetFileType(const wxString& strFileType)
67 { m_strFileType = strFileType; }
68 void SetExt(const wxString& ext)
69 { m_ext = ext; }
70
71 // implement accessor functions
72 bool GetExtensions(wxArrayString& extensions);
73 bool GetMimeType(wxString *mimeType) const;
74 bool GetMimeTypes(wxArrayString& mimeTypes) const;
75 bool GetIcon(wxIconLocation *iconLoc) const;
76 bool GetDescription(wxString *desc) const;
77 bool GetOpenCommand(wxString *openCmd,
78 const wxFileType::MessageParameters&) const
79 { return GetCommand(openCmd, "open"); }
80 bool GetPrintCommand(wxString *printCmd,
81 const wxFileType::MessageParameters&) const
82 { return GetCommand(printCmd, "print"); }
83
84 size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
85 const wxFileType::MessageParameters& params) const;
86
87 // remove the record for this file type
88 // probably a mistake to come here, use wxMimeTypesManager.Unassociate (ft) instead
89 bool Unassociate(wxFileType *ft)
90 {
91 return m_manager->Unassociate(ft);
92 }
93
94 // set an arbitrary command, ask confirmation if it already exists and
95 // overwriteprompt is TRUE
96 bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE);
97 bool SetDefaultIcon(const wxString& strIcon = wxEmptyString, int index = 0);
98
99 private:
100 // helper function
101 bool GetCommand(wxString *command, const char *verb) const;
3c15a151 102
7b0786bf
MW
103 wxMimeTypesManagerImpl *m_manager;
104 wxArrayInt m_index; // in the wxMimeTypesManagerImpl arrays
105 wxString m_strFileType, m_ext;
106};
107
108#endif
109 //_MIMETYPE_H
110
111/* vi: set cin tw=80 ts=4 sw=4: */