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