File: RichTextFileHandler.xsp

package info (click to toggle)
libwx-perl 1%3A0.9932-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 4,416 kB
  • sloc: cpp: 11,044; perl: 8,596; ansic: 711; makefile: 49
file content (207 lines) | stat: -rw-r--r-- 8,085 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#############################################################################
## Name:        ext/richtext/XS/RichTextFileHandler.xsp
## Purpose:     XS++ for Wx::RichTextFileHandler
## Author:      Mattia Barbon
## Modified by:
## Created:     03/09/2007
## RCS-ID:      $Id: RichTextFileHandler.xsp 2927 2010-06-06 08:06:10Z mbarbon $
## Copyright:   (c) 2007, 2010 Mattia Barbon
## Licence:     This program is free software; you can redistribute it and/or
##              modify it under the same terms as Perl itself
#############################################################################

#include <wx/event.h>
#include <wx/richtext/richtextbuffer.h>

%module{Wx};

%file{xspp/filehandler.h};
%{

#include "cpp/v_cback.h"
#include "cpp/streams.h"

#define DEF_V_CBACK_BOOL__WXRICHTEXTBUFFER_WXINPUTSTREAM( CLASS, BASE, METHOD )\
    bool CLASS::METHOD( wxRichTextBuffer* p1, wxInputStream& p2 )            \
    {                                                                        \
        dTHX;                                                                \
        if( wxPliFCback( aTHX_ &m_callback, #METHOD ) )                      \
        {                                                                    \
            wxAutoSV stream( aTHX_ sv_newmortal() );                         \
            wxPli_stream_2_sv( aTHX_ stream, &p2, "Wx::InputStream" );       \
            wxAutoSV ret( aTHX_ wxPliCCback( aTHX_ &m_callback,              \
                                             G_SCALAR,                       \
                                             "Qs", p1, (SV*)stream ) );      \
            return SvTRUE( ret );                                            \
        } else                                                               \
            return false;                                                    \
    }

#define DEF_V_CBACK_BOOL__WXRICHTEXTBUFFER_WXOUTPUTSTREAM( CLASS, BASE, METHOD )\
    bool CLASS::METHOD( wxRichTextBuffer* p1, wxOutputStream& p2 )           \
    {                                                                        \
        dTHX;                                                                \
        if( wxPliFCback( aTHX_ &m_callback, #METHOD ) )                      \
        {                                                                    \
            wxAutoSV stream( aTHX_ sv_newmortal() );                         \
            wxPli_stream_2_sv( aTHX_ stream, &p2, "Wx::OutputStream" );      \
            wxAutoSV ret( aTHX_ wxPliCCback( aTHX_ &m_callback,              \
                                             G_SCALAR,                       \
                                             "Qs", p1, (SV*)stream ) );      \
            return SvTRUE( ret );                                            \
        } else                                                               \
            return false;                                                    \
    }

class wxPlRichTextFileHandler : public wxRichTextFileHandler
{
    WXPLI_DECLARE_V_CBACK();
public:
    wxPlRichTextFileHandler( const char* package,
                             const wxString& name = wxEmptyString,
                             const wxString& ext = wxEmptyString,
                             int type = 0 )
      : wxRichTextFileHandler( name, ext, type ),
        m_callback( "Wx::RichTextFileHandler" )
    {
        m_callback.SetSelf( wxPli_make_object( this, package ), true );
    }

    bool base_CanHandle( const wxString& filename )
        { return wxRichTextFileHandler::CanHandle( filename ); }
    bool base_CanLoad()
        { return wxRichTextFileHandler::CanLoad(); }
    bool base_CanSave()
        { return wxRichTextFileHandler::CanSave(); }

    DEC_V_CBACK_BOOL__WXSTRING( CanHandle );
    DEC_V_CBACK_BOOL__VOID( CanLoad );
    DEC_V_CBACK_BOOL__VOID( CanSave );

    bool DoLoadFile( wxRichTextBuffer *buffer, wxInputStream& stream );
    bool DoSaveFile( wxRichTextBuffer *buffer, wxOutputStream& stream );
};

DEF_V_CBACK_BOOL__WXSTRING( wxPlRichTextFileHandler,
                            wxRichTextFileHandler, CanHandle );
DEF_V_CBACK_BOOL__VOID( wxPlRichTextFileHandler,
                        wxRichTextFileHandler, CanLoad );
DEF_V_CBACK_BOOL__VOID( wxPlRichTextFileHandler,
                        wxRichTextFileHandler, CanSave );
DEF_V_CBACK_BOOL__WXRICHTEXTBUFFER_WXINPUTSTREAM( wxPlRichTextFileHandler,
                                                  wxRichTextFileHandler,
                                                  DoLoadFile );
DEF_V_CBACK_BOOL__WXRICHTEXTBUFFER_WXOUTPUTSTREAM( wxPlRichTextFileHandler,
                                                   wxRichTextFileHandler,
                                                   DoSaveFile );
%}
%file{-};

#include "xspp/filehandler.h"

%name{Wx::RichTextFileHandler} class wxRichTextFileHandler
{
    bool CanHandle( const wxString& filename ) const;
    bool CanLoad() const;
    bool CanSave() const;

    bool LoadFile( wxRichTextBuffer* buffer, SV* fh )
        %code{% wxInputStream* stream = wxPliInputStream_ctor( fh );
                RETVAL = THIS->LoadFile( buffer, *stream );
                delete stream;
                %};
    bool SaveFile( wxRichTextBuffer* buffer, SV* fh )
        %code{% wxOutputStream* stream = wxPliOutputStream_ctor( fh );
                RETVAL = THIS->SaveFile( buffer, *stream );
                delete stream;
                %};

    void SetName( const wxString& name );
    wxString GetName() const;
    void SetExtension( const wxString& ext );
    wxString GetExtension() const;
    void SetType( int type );
    int GetType();
    void SetEncoding( const wxString& encoding );
    wxString GetEncoding() const;
    bool IsVisible() const;
    void SetVisible( bool visible );
};

%name{Wx::PlRichTextFileHandler} class wxPlRichTextFileHandler
{
    wxPlRichTextFilehandler( const wxString& name = wxEmptyString,
                             const wxString& ext = wxEmptyString,
                             int type = 0 )
        %code{% RETVAL = new wxPlRichTextFileHandler( CLASS, name, ext, type );
                %};

    %name{CanHandle} bool base_CanHandle( const wxString& filename ) const;
    %name{CanLoad} bool base_CanLoad() const;
    %name{CanSave} bool base_CanSave() const;
};

#include <wx/richtext/richtextxml.h>

%typemap{wxRichTextXMLHandler*}{simple};

%name{Wx::RichTextXMLHandler} class wxRichTextXMLHandler
{
    wxRichTextXMLHandler( const wxString& name = wxT("XML"),
                          const wxString& ext = wxT("xml"),
                          int type = wxRICHTEXT_TYPE_XML );
};

#if WXPERL_W_VERSION_GE( 2, 8, 3 )

#include <wx/richtext/richtexthtml.h>

%typemap{wxRichTextHTMLHandler*}{simple};

%name{Wx::RichTextHTMLHandler} class wxRichTextHTMLHandler
{
    wxRichTextHTMLHandler( const wxString& name = wxT("HTML"),
                           const wxString& ext = wxT("html"),
                           int type = wxRICHTEXT_TYPE_HTML );

    void ClearTemporaryImageLocations();
%{
bool
wxRichTextHTMLHandler::DeleteTemporaryImages( ... )
  CASE: items == 2
    INPUT:
    CODE:
      int flags = SvIV( ST(1) );
      wxArrayString imageLocations;
      wxPli_av_2_arraystring( aTHX_ ST(2), &imageLocations );
      RETVAL = THIS->DeleteTemporaryImages( flags, imageLocations );
    OUTPUT: RETVAL
  CASE:
    CODE:
      RETVAL = THIS->DeleteTemporaryImages();
    OUTPUT:RETVAL

void
wxRichTextHTMLHandler::GetFontSizeMapping()
  PPCODE:
    PUTBACK;
    wxPli_intarray_push( aTHX_ THIS->GetFontSizeMapping() );
    SPAGAIN;

void
wxRichTextHTMLHandler::GetTemporaryImageLocations()
  PPCODE:
    PUTBACK;
    wxPli_stringarray_push( aTHX_ THIS->GetTemporaryImageLocations() );
    SPAGAIN;

%}

    const wxString& GetTempDir() const;
    void SetFileCounter( int counter );
    void SetFontSizeMapping( const wxArrayInt& fontSizeMapping );
    void SetTempDir( const wxString& tempDir );
    void SetTemporaryImageLocations( const wxArrayString& locations );
};

#endif