1 #############################################################################
2 ## Name: XS/MimeTypes.xsp
3 ## Purpose: XS++ for wxMimeTypesManager and related classes
4 ## Author: Mattia Barbon
7 ## RCS-ID: $Id: MimeTypes.xsp 2564 2009-05-17 13:02:16Z mbarbon $
8 ## Copyright: (c) 2005-2009 Mattia Barbon
9 ## Licence: This program is free software; you can redistribute it and/or
10 ## modify it under the same terms as Perl itself
11 #############################################################################
17 #include <wx/mimetype.h>
20 %typemap{wxMimeTypesManager*}{simple};
21 %typemap{wxFileType*}{simple};
22 %typemap{wxIconLocation*}{simple};
23 %typemap{wxFileTypeInfo*}{simple};
24 %typemap{const wxFileTypeInfo*}{parsed}{%wxFileTypeInfo*%};
26 #if WXPERL_W_VERSION_GE( 2, 5, 2 )
28 %name{Wx::IconLocation} class wxIconLocation
35 %name{Wx::FileTypeInfo} class wxFileTypeInfo
38 void SetIcon( const wxString& iconFile, int iconIndex = 0 );
39 void SetShortDesc( const wxString& shortDesc );
41 const wxString& GetMimeType() const;
42 const wxString& GetOpenCommand() const;
43 const wxString& GetPrintCommand() const;
44 const wxString& GetShortDesc() const;
45 const wxString& GetDescription() const;
46 int GetExtensionsCount() const;
47 const wxString& GetIconFile();
48 int GetIconIndex() const;
53 wxFileTypeInfo::new( strings )
57 wxFileTypeInfo::GetExtensions()
59 const wxArrayString& extensions = THIS->GetExtensions();
61 wxPli_stringarray_push( aTHX_ extensions );
66 %name{Wx::FileType} class wxFileType
72 wxFileType::GetMimeTypes()
74 wxArrayString mimeTypes;
76 bool ok = THIS->GetMimeTypes( mimeTypes );
80 wxPli_stringarray_push( aTHX_ mimeTypes );
87 wxFileType::GetMimeType()
91 bool ok = THIS->GetMimeType( &mimeType );
94 XPUSHs( wxPli_wxString_2_sv( aTHX_ mimeType, sv_newmortal() ) );
100 wxFileType::GetExtensions()
102 wxArrayString extensions;
104 bool ok = THIS->GetExtensions( extensions );
108 wxPli_stringarray_push( aTHX_ extensions );
115 wxFileType::GetIcon()
117 #if WXPERL_W_VERSION_GE( 2, 5, 2 )
118 wxIconLocation iconLoc;
123 bool ok = THIS->GetIcon( &iconLoc );
126 #if WXPERL_W_VERSION_GE( 2, 5, 2 )
127 XPUSHs( wxPli_non_object_2_sv( aTHX_ sv_newmortal(),
128 new wxIconLocation( iconLoc ),
129 "Wx::IconLocation" ) );
131 XPUSHs( wxPli_non_object_2_sv( aTHX_ sv_newmortal(),
132 new wxIcon( iconLoc ),
140 wxFileType::GetDescription()
144 bool ok = THIS->GetDescription( &desc );
147 XPUSHs( wxPli_wxString_2_sv( aTHX_ desc, sv_newmortal() ) );
153 wxFileType::GetOpenCommand( file, mimeType = wxEmptyString )
159 bool ok = THIS->GetOpenCommand( &command,
160 wxFileType::MessageParameters
161 ( file, mimeType ) );
163 XPUSHs( wxPli_wxString_2_sv( aTHX_ command, sv_newmortal() ) );
168 wxFileType::GetPrintCommand( file, mimeType = wxEmptyString )
174 bool ok = THIS->GetPrintCommand( &command,
175 wxFileType::MessageParameters
176 ( file, mimeType ) );
178 XPUSHs( wxPli_wxString_2_sv( aTHX_ command, sv_newmortal() ) );
184 %name{Wx::MimeTypesManager} class wxMimeTypesManager
186 wxMimeTypesManager();
190 wxMimeTypesManager::CLONE()
192 wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
195 ~wxMimeTypesManager()
196 %code{% wxPli_thread_sv_unregister( aTHX_ "Wx::MimeTypesManager", THIS, ST(0) );
200 void AddFallbacks( const wxFileTypeInfo *fallbacks );
201 wxFileType* GetFileTypeFromExtension( const wxString& extension );
202 wxFileType* GetFileTypeFromMimeType( const wxString& mimeType );
203 bool IsOfType( const wxString& mimeType, const wxString& wildcard );
204 #if WXPERL_W_VERSION_LT( 2, 9, 0 )
205 bool ReadMailcap( const wxString& filename, bool fallback = false );
206 bool ReadMimeTypes( const wxString& filename );
211 #endif // wxUSE_MIMETYPE