]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/core/mimetype.h
Add wxMenuItem::IsCheck() and IsRadio() accessors.
[wxWidgets.git] / include / wx / osx / core / mimetype.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/core/mimetype.h
3 // Purpose: Mac implementation for wx mime-related classes
4 // Author: Neil Perkins
5 // Modified by:
6 // Created: 2010-05-15
7 // RCS-ID: $Id$
8 // Copyright: (C) 2010 Neil Perkins
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _MIMETYPE_IMPL_H
13 #define _MIMETYPE_IMPL_H
14
15 #include "wx/defs.h"
16
17 #if wxUSE_MIMETYPE
18
19 #include "wx/mimetype.h"
20 #include "wx/hashmap.h"
21 #include "wx/iconloc.h"
22
23
24 // This class implements mime type functionality for Mac OS X using UTIs and Launch Services
25 // Currently only the GetFileTypeFromXXXX public functions have been implemented
26 class WXDLLIMPEXP_BASE wxMimeTypesManagerImpl
27 {
28 public:
29
30 wxMimeTypesManagerImpl();
31 virtual ~wxMimeTypesManagerImpl();
32
33 // These functions are not needed on Mac OS X and have no-op implementations
34 void Initialize(int mailcapStyles = wxMAILCAP_STANDARD, const wxString& extraDir = wxEmptyString);
35 void ClearData();
36
37 // Functions to look up types by ext, mime or UTI
38 wxFileType *GetFileTypeFromExtension(const wxString& ext);
39 wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
40 wxFileType *GetFileTypeFromUti(const wxString& uti);
41
42 // These functions are only stubs on Mac OS X
43 size_t EnumAllFileTypes(wxArrayString& mimetypes);
44 wxFileType *Associate(const wxFileTypeInfo& ftInfo);
45 bool Unassociate(wxFileType *ft);
46
47 private:
48
49 // The work of querying the OS for type data is done in these two functions
50 void LoadTypeDataForUti(const wxString& uti);
51 void LoadDisplayDataForUti(const wxString& uti);
52
53 // These functions are pass-throughs from wxFileTypeImpl
54 bool GetExtensions(const wxString& uti, wxArrayString& extensions);
55 bool GetMimeType(const wxString& uti, wxString *mimeType);
56 bool GetMimeTypes(const wxString& uti, wxArrayString& mimeTypes);
57 bool GetIcon(const wxString& uti, wxIconLocation *iconLoc);
58 bool GetDescription(const wxString& uti, wxString *desc);
59 bool GetApplication(const wxString& uti, wxString *command);
60
61 // Structure to represent file types
62 typedef struct FileTypeData
63 {
64 wxArrayString extensions;
65 wxArrayString mimeTypes;
66 wxIconLocation iconLoc;
67 wxString application;
68 wxString description;
69 }
70 FileTypeInfo;
71
72 // Map types
73 WX_DECLARE_STRING_HASH_MAP( wxString, TagMap );
74 WX_DECLARE_STRING_HASH_MAP( FileTypeData, UtiMap );
75
76 // Data store
77 TagMap m_extMap;
78 TagMap m_mimeMap;
79 UtiMap m_utiMap;
80
81 friend class wxFileTypeImpl;
82 };
83
84
85 // This class provides the interface between wxFileType and wxMimeTypesManagerImple for Mac OS X
86 // Currently only extension, mimetype, description and icon information is available
87 // All other methods have no-op implementation
88 class WXDLLIMPEXP_BASE wxFileTypeImpl
89 {
90 public:
91
92 wxFileTypeImpl();
93 virtual ~wxFileTypeImpl();
94
95 bool GetExtensions(wxArrayString& extensions) const ;
96 bool GetMimeType(wxString *mimeType) const ;
97 bool GetMimeTypes(wxArrayString& mimeTypes) const ;
98 bool GetIcon(wxIconLocation *iconLoc) const ;
99 bool GetDescription(wxString *desc) const ;
100 bool GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const;
101
102 // These functions are only stubs on Mac OS X
103 bool GetPrintCommand(wxString *printCmd, const wxFileType::MessageParameters& params) const;
104 size_t GetAllCommands(wxArrayString *verbs, wxArrayString *commands, const wxFileType::MessageParameters& params) const;
105 bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE);
106 bool SetDefaultIcon(const wxString& strIcon = wxEmptyString, int index = 0);
107 bool Unassociate(wxFileType *ft);
108
109 private:
110
111 // All that is needed to query type info - UTI and pointer to the manager
112 wxString m_uti;
113 wxMimeTypesManagerImpl* m_manager;
114
115 friend class wxMimeTypesManagerImpl;
116 };
117
118 #endif // wxUSE_MIMETYPE
119 #endif //_MIMETYPE_IMPL_H
120
121