1 #############################################################################
2 ## Name: ext/richtext/XS/RichTextFileHandler.xsp
3 ## Purpose: XS++ for Wx::RichTextFileHandler
4 ## Author: Mattia Barbon
7 ## RCS-ID: $Id: RichTextFileHandler.xsp 2229 2007-09-05 22:21:15Z mbarbon $
8 ## Copyright: (c) 2007 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 #############################################################################
14 #include <wx/richtext/richtextbuffer.h>
18 %file{cpp/filehandler.h};
21 #include "cpp/v_cback.h"
22 #include "cpp/streams.h"
24 #define DEF_V_CBACK_BOOL__WXRICHTEXTBUFFER_WXINPUTSTREAM( CLASS, BASE, METHOD )\
25 bool CLASS::METHOD( wxRichTextBuffer* p1, wxInputStream& p2 ) \
28 if( wxPliFCback( aTHX_ &m_callback, #METHOD ) ) \
30 wxAutoSV stream( aTHX_ sv_newmortal() ); \
31 wxPli_stream_2_sv( aTHX_ stream, &p2, "Wx::InputStream" ); \
32 wxAutoSV ret( aTHX_ wxPliCCback( aTHX_ &m_callback, \
34 "Qs", p1, (SV*)stream ) ); \
35 return SvTRUE( ret ); \
40 #define DEF_V_CBACK_BOOL__WXRICHTEXTBUFFER_WXOUTPUTSTREAM( CLASS, BASE, METHOD )\
41 bool CLASS::METHOD( wxRichTextBuffer* p1, wxOutputStream& p2 ) \
44 if( wxPliFCback( aTHX_ &m_callback, #METHOD ) ) \
46 wxAutoSV stream( aTHX_ sv_newmortal() ); \
47 wxPli_stream_2_sv( aTHX_ stream, &p2, "Wx::OutputStream" ); \
48 wxAutoSV ret( aTHX_ wxPliCCback( aTHX_ &m_callback, \
50 "Qs", p1, (SV*)stream ) ); \
51 return SvTRUE( ret ); \
56 class wxPlRichTextFileHandler : public wxRichTextFileHandler
58 WXPLI_DECLARE_V_CBACK();
60 wxPlRichTextFileHandler( const char* package,
61 const wxString& name = wxEmptyString,
62 const wxString& ext = wxEmptyString,
64 : wxRichTextFileHandler( name, ext, type ),
65 m_callback( "Wx::RichTextFileHandler" )
67 m_callback.SetSelf( wxPli_make_object( this, package ), true );
70 bool base_CanHandle( const wxString& filename )
71 { return wxRichTextFileHandler::CanHandle( filename ); }
73 { return wxRichTextFileHandler::CanLoad(); }
75 { return wxRichTextFileHandler::CanSave(); }
77 DEC_V_CBACK_BOOL__WXSTRING( CanHandle );
78 DEC_V_CBACK_BOOL__VOID( CanLoad );
79 DEC_V_CBACK_BOOL__VOID( CanSave );
81 bool DoLoadFile( wxRichTextBuffer *buffer, wxInputStream& stream );
82 bool DoSaveFile( wxRichTextBuffer *buffer, wxOutputStream& stream );
85 DEF_V_CBACK_BOOL__WXSTRING( wxPlRichTextFileHandler,
86 wxRichTextFileHandler, CanHandle );
87 DEF_V_CBACK_BOOL__VOID( wxPlRichTextFileHandler,
88 wxRichTextFileHandler, CanLoad );
89 DEF_V_CBACK_BOOL__VOID( wxPlRichTextFileHandler,
90 wxRichTextFileHandler, CanSave );
91 DEF_V_CBACK_BOOL__WXRICHTEXTBUFFER_WXINPUTSTREAM( wxPlRichTextFileHandler,
92 wxRichTextFileHandler,
94 DEF_V_CBACK_BOOL__WXRICHTEXTBUFFER_WXOUTPUTSTREAM( wxPlRichTextFileHandler,
95 wxRichTextFileHandler,
100 #include "cpp/filehandler.h"
102 %name{Wx::RichTextFileHandler} class wxRichTextFileHandler
104 bool CanHandle( const wxString& filename ) const;
105 bool CanLoad() const;
106 bool CanSave() const;
108 bool LoadFile( wxRichTextBuffer* buffer, SV* fh )
109 %code{% wxInputStream* stream = wxPliInputStream_ctor( fh );
110 RETVAL = THIS->LoadFile( buffer, *stream );
113 bool SaveFile( wxRichTextBuffer* buffer, SV* fh )
114 %code{% wxOutputStream* stream = wxPliOutputStream_ctor( fh );
115 RETVAL = THIS->SaveFile( buffer, *stream );
119 void SetName( const wxString& name );
120 wxString GetName() const;
121 void SetExtension( const wxString& ext );
122 wxString GetExtension() const;
123 void SetType( int type );
125 void SetEncoding( const wxString& encoding );
126 wxString GetEncoding() const;
127 bool IsVisible() const;
128 void SetVisible( bool visible );
131 %name{Wx::PlRichTextFileHandler} class wxPlRichTextFileHandler
133 wxPlRichTextFilehandler( const wxString& name = wxEmptyString,
134 const wxString& ext = wxEmptyString,
136 %code{% RETVAL = new wxPlRichTextFileHandler( CLASS, name, ext, type );
139 %name{CanHandle} bool base_CanHandle( const wxString& filename ) const;
140 %name{CanLoad} bool base_CanLoad() const;
141 %name{CanSave} bool base_CanSave() const;
144 #include <wx/richtext/richtextxml.h>
146 %typemap{wxRichTextXMLHandler*}{simple};
148 %name{Wx::RichTextXMLHandler} class wxRichTextXMLHandler
150 wxRichTextXMLHandler( const wxString& name = wxT("XML"),
151 const wxString& ext = wxT("xml"),
152 int type = wxRICHTEXT_TYPE_XML );
155 #if WXPERL_W_VERSION_GE( 2, 8, 3 )
157 #include <wx/richtext/richtexthtml.h>
159 %typemap{wxRichTextHTMLHandler*}{simple};
161 %name{Wx::RichTextHTMLHandler} class wxRichTextHTMLHandler
163 wxRichTextHTMLHandler( const wxString& name = wxT("HTML"),
164 const wxString& ext = wxT("html"),
165 int type = wxRICHTEXT_TYPE_HTML );
167 void ClearTemporaryImageLocations();
170 wxRichTextHTMLHandler::DeleteTemporaryImages( ... )
174 int flags = SvIV( ST(1) );
175 wxArrayString imageLocations;
176 wxPli_av_2_arraystring( aTHX_ ST(2), &imageLocations );
177 RETVAL = THIS->DeleteTemporaryImages( flags, imageLocations );
181 RETVAL = THIS->DeleteTemporaryImages();
185 wxRichTextHTMLHandler::GetFontSizeMapping()
188 wxPli_intarray_push( aTHX_ THIS->GetFontSizeMapping() );
192 wxRichTextHTMLHandler::GetTemporaryImageLocations()
195 wxPli_stringarray_push( aTHX_ THIS->GetTemporaryImageLocations() );
200 const wxString& GetTempDir() const;
201 void SetFileCounter( int counter );
202 void SetFontSizeMapping( const wxArrayInt& fontSizeMapping );
203 void SetTempDir( const wxString& tempDir );
204 void SetTemporaryImageLocations( const wxArrayString& locations );