]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/mimetype.h
support mac on little endian systems
[wxWidgets.git] / include / wx / mac / carbon / mimetype.h
CommitLineData
8cf73271
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/mac/mimetype.h
c9e227f4
RN
3// Purpose: Mac Carbon implementation for wx mime-related classes
4// Author: Ryan Norton
8cf73271 5// Modified by:
c9e227f4 6// Created: 04/16/2005
8cf73271 7// RCS-ID: $Id$
c9e227f4
RN
8// Copyright: (c) 2005 Ryan Norton (<wxprojects@comcast.net>)
9// Licence: wxWindows licence
8cf73271
SC
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _MIMETYPE_IMPL_H
13#define _MIMETYPE_IMPL_H
14
15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "mimetype.h"
17#endif
18
19#include "wx/defs.h"
20#include "wx/mimetype.h"
21
22
23class wxMimeTypesManagerImpl
24{
25public :
c9e227f4
RN
26 //kinda kooky but in wxMimeTypesManager::EnsureImpl it doesn't call
27 //intialize, so we do it ourselves
28 wxMimeTypesManagerImpl() : m_hIC(NULL) { Initialize(); }
29 ~wxMimeTypesManagerImpl() { ClearData(); }
8cf73271
SC
30
31 // load all data into memory - done when it is needed for the first time
32 void Initialize(int mailcapStyles = wxMAILCAP_STANDARD,
33 const wxString& extraDir = wxEmptyString);
34
35 // and delete the data here
36 void ClearData();
37
38 // implement containing class functions
39 wxFileType *GetFileTypeFromExtension(const wxString& ext);
40 wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext) ;
41 wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
42
43 size_t EnumAllFileTypes(wxArrayString& mimetypes);
44
45 // this are NOPs under MacOS
46 bool ReadMailcap(const wxString& WXUNUSED(filename), bool WXUNUSED(fallback) = TRUE) { return TRUE; }
47 bool ReadMimeTypes(const wxString& WXUNUSED(filename)) { return TRUE; }
48
49 void AddFallback(const wxFileTypeInfo& ft) { m_fallbacks.Add(ft); }
50
51 // create a new filetype association
52 wxFileType *Associate(const wxFileTypeInfo& ftInfo);
53 // remove association
54 bool Unassociate(wxFileType *ft);
c9e227f4 55
8cf73271
SC
56private:
57 wxArrayFileTypeInfo m_fallbacks;
c9e227f4
RN
58 void* m_hIC;
59 void** m_hDatabase;
60 long m_lCount;
61
d6799e00
RN
62 void* pReserved1;
63 void* pReserved2;
64 void* pReserved3;
65 void* pReserved4;
66 void* pReserved5;
67 void* pReserved6;
68
c9e227f4 69 friend class wxFileTypeImpl;
8cf73271
SC
70};
71
72class wxFileTypeImpl
73{
74public:
c9e227f4
RN
75 //kind of nutty, but mimecmn.cpp creates one with an empty new
76 wxFileTypeImpl() : m_manager(NULL) {}
77 ~wxFileTypeImpl() {} //for those broken compilers
8cf73271 78
8cf73271
SC
79 // implement accessor functions
80 bool GetExtensions(wxArrayString& extensions);
81 bool GetMimeType(wxString *mimeType) const;
82 bool GetMimeTypes(wxArrayString& mimeTypes) const;
83 bool GetIcon(wxIconLocation *iconLoc) const;
84 bool GetDescription(wxString *desc) const;
85 bool GetOpenCommand(wxString *openCmd,
c9e227f4 86 const wxFileType::MessageParameters&) const;
8cf73271 87 bool GetPrintCommand(wxString *printCmd,
c9e227f4 88 const wxFileType::MessageParameters&) const;
8cf73271
SC
89
90 size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
91 const wxFileType::MessageParameters& params) const;
92
93 // remove the record for this file type
94 // probably a mistake to come here, use wxMimeTypesManager.Unassociate (ft) instead
95 bool Unassociate(wxFileType *ft)
96 {
97 return m_manager->Unassociate(ft);
98 }
99
100 // set an arbitrary command, ask confirmation if it already exists and
101 // overwriteprompt is TRUE
102 bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE);
103 bool SetDefaultIcon(const wxString& strIcon = wxEmptyString, int index = 0);
104
105 private:
c9e227f4
RN
106 void Init(wxMimeTypesManagerImpl *manager, long lIndex)
107 { m_manager=(manager); m_lIndex=(lIndex); }
108
8cf73271 109 // helper function
c9e227f4 110 wxString GetCommand(const wxString& verb) const;
8cf73271
SC
111
112 wxMimeTypesManagerImpl *m_manager;
c9e227f4
RN
113 long m_lIndex;
114
d6799e00
RN
115 void* pReserved1;
116 void* pReserved2;
117 void* pReserved3;
118 void* pReserved4;
119 void* pReserved5;
120 void* pReserved6;
121
c9e227f4 122 friend class wxMimeTypesManagerImpl;
8cf73271
SC
123};
124
125#endif
126 //_MIMETYPE_H