File: Preview.xs

package info (click to toggle)
libwx-perl 0.9702-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,240 kB
  • ctags: 1,812
  • sloc: cpp: 8,988; perl: 6,366; makefile: 38; ansic: 1
file content (312 lines) | stat: -rwxr-xr-x 11,634 bytes parent folder | download
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
#############################################################################
## Name:        ext/print/XS/Preview.xs
## Purpose:     XS for Wx::PreviewCanvas, Frame & ControlBar
## Author:      Mattia Barbon
## Modified by:
## Created:     02/06/2001
## RCS-ID:      $Id: Preview.xs 2057 2007-06-18 23:03:00Z mbarbon $
## Copyright:   (c) 2001-2002, 2004-2006 Mattia Barbon
## Licence:     This program is free software; you can redistribute it and/or
##              modify it under the same terms as Perl itself
#############################################################################

%module{Wx};

%typemap{wxPreviewControlBar*}{simple};
%typemap{wxPlPreviewControlBar*}{simple};
%typemap{wxPreviewFrame*}{simple};
%typemap{wxPlPreviewFrame*}{simple};
%typemap{wxPrintPreviewBase*}{simple};
%typemap{wxPrintPreview*}{simple};
%typemap{wxPreviewCanvas*}{simple};

#include <wx/print.h>

%file{cpp/previewcontrolbar.h};
%{
#include "cpp/v_cback.h"

// void METH(int)
#define DEC_V_CBACK_VOID__INT_( METHOD, CONST ) \
    void METHOD( int ) CONST

#define DEF_V_CBACK_VOID__INT_( CLASS, CALLBASE, METHOD, CONST )\
    void CLASS::METHOD( int p1 ) CONST                                       \
    {                                                                        \
        dTHX;                                                                \
        if( wxPliFCback( aTHX_ &m_callback, #METHOD ) )                      \
        {                                                                    \
            wxPliCCback( aTHX_ &m_callback, G_SCALAR|G_DISCARD, "i", p1 );   \
        } else                                                               \
            CALLBASE;                                                        \
    }

#define DEC_V_CBACK_VOID__INT( METHOD ) \
    DEC_V_CBACK_VOID__INT_( METHOD, wxPli_NOCONST )

#define DEF_V_CBACK_VOID__INT( CLASS, BASE, METHOD ) \
    DEF_V_CBACK_VOID__INT_( CLASS, BASE::METHOD(p1), METHOD, wxPli_NOCONST )

#define DEF_V_CBACK_VOID__INT_pure( CLASS, BASE, METHOD ) \
    DEF_V_CBACK_VOID__INT_( CLASS, return, METHOD, wxPli_NOCONST )

class wxPlPreviewControlBar : public wxPreviewControlBar
{
    WXPLI_DECLARE_DYNAMIC_CLASS( wxPlPreviewControlBar );
    WXPLI_DECLARE_V_CBACK();
public:
    wxPlPreviewControlBar( const char* package, wxPrintPreviewBase *preview,
                           long buttons, wxWindow *parent,
                           const wxPoint& pos = wxDefaultPosition,
                           const wxSize& size = wxDefaultSize,
                           long style = wxTAB_TRAVERSAL,
                           const wxString& name = wxPanelNameStr )
        : wxPreviewControlBar( preview, buttons, parent, pos, size,
                               style, name ),
          m_callback( "Wx::PlPreviewControlBar" )
    {
        m_callback.SetSelf( wxPli_make_object( this, package ), true );
    }

    DEC_V_CBACK_VOID__VOID( CreateButtons );
    DEC_V_CBACK_VOID__INT( SetZoomControl );
    DEC_V_CBACK_INT__VOID( GetZoomControl );

    wxButton* GetCloseButton()        { return m_closeButton; }
    wxButton* GetNextPageButton()     { return m_nextPageButton; }
    wxButton* GetPreviousPageButton() { return m_previousPageButton; }
    wxButton* GetPrintButton()        { return m_printButton; }
    wxButton* GetFirstPageButton()    { return m_firstPageButton; }
    wxButton* GetLastPageButton()     { return m_lastPageButton; }
    wxButton* GetGotoPageButton()     { return m_gotoPageButton; }
    wxChoice* GetZoomChoice()         { return m_zoomControl; }
    long      GetButtonFlags()        { return m_buttonFlags; }

    void SetCloseButton( wxButton* b )        { m_closeButton = b; }
    void SetNextPageButton( wxButton* b )     { m_nextPageButton = b; }
    void SetPreviousPageButton( wxButton* b ) { m_previousPageButton = b; }
    void SetPrintButton( wxButton* b )        { m_printButton = b; }
    void SetFirstPageButton( wxButton* b )    { m_firstPageButton = b; }
    void SetLastPageButton( wxButton* b )     { m_lastPageButton = b; }
    void SetGotoPageButton( wxButton* b )     { m_gotoPageButton = b; }
    void SetZoomChoice( wxChoice * c )        { m_zoomControl = c; }
    void SetButtonFlags( long f )             { m_buttonFlags = f; }
};

WXPLI_IMPLEMENT_DYNAMIC_CLASS( wxPlPreviewControlBar, wxPreviewControlBar );

DEF_V_CBACK_VOID__VOID( wxPlPreviewControlBar, wxPreviewControlBar, CreateButtons );
DEF_V_CBACK_VOID__INT( wxPlPreviewControlBar, wxPreviewControlBar, SetZoomControl );
DEF_V_CBACK_INT__VOID( wxPlPreviewControlBar, wxPreviewControlBar, GetZoomControl );

%}
%file{-};

%file{cpp/previewframe.h};
%{
#include "cpp/v_cback.h"

class wxPlPreviewFrame : public wxPreviewFrame
{
    WXPLI_DECLARE_DYNAMIC_CLASS( wxPlPreviewFrame );
    WXPLI_DECLARE_V_CBACK();
public: 
#if WXPERL_W_VERSION_GE( 2, 5, 3 )
    wxPlPreviewFrame( const char* package, wxPrintPreviewBase *preview,
                      wxWindow *parent,
                      const wxString& title = wxT("Print Preview"),
                      const wxPoint& pos = wxDefaultPosition,
                      const wxSize& size = wxDefaultSize,
                      long style = wxDEFAULT_FRAME_STYLE,
                      const wxString& name = wxFrameNameStr )
        : wxPreviewFrame( preview, parent, title, pos, size, style, name ),
          m_callback( "Wx::PlPreviewFrame" )
    {
        m_callback.SetSelf( wxPli_make_object( this, package ), true );
    }
#else
    wxPlPreviewFrame( const char* package, wxPrintPreviewBase *preview,
                      wxFrame *parent,
                      const wxString& title = wxT("Print Preview"),
                      const wxPoint& pos = wxDefaultPosition,
                      const wxSize& size = wxDefaultSize,
                      long style = wxDEFAULT_FRAME_STYLE,
                      const wxString& name = wxFrameNameStr )
        : wxPreviewFrame( preview, parent, title, pos, size, style, name ),
          m_callback( "Wx::PlPreviewFrame" )
    {
        m_callback.SetSelf( wxPli_make_object( this, package ), true );
    }
#endif

#if WXPERL_W_VERSION_GE( 2, 5, 3 )
    wxPreviewCanvas*     GetPreviewCanvas()     { return m_previewCanvas; }
#else
    wxWindow*            GetPreviewCanvas()     { return m_previewCanvas; }
#endif
    wxPreviewControlBar* GetPreviewControlBar() { return m_controlBar; }
    wxPrintPreviewBase*  GetPrintPreview()      { return m_printPreview; }

#if WXPERL_W_VERSION_GE( 2, 5, 3 )
    void SetPreviewCanvas( wxPreviewCanvas* p )       { m_previewCanvas = p; }
#else
    void SetPreviewCanvas( wxWindow* p )              { m_previewCanvas = p; }
#endif
    void SetPreviewControlBar( wxPreviewControlBar* p ) { m_controlBar = p; }
    void SetPrintPreview( wxPrintPreviewBase* p )       { m_printPreview = p; }

    DEC_V_CBACK_VOID__VOID( Initialize );
    DEC_V_CBACK_VOID__VOID( CreateCanvas );
    DEC_V_CBACK_VOID__VOID( CreateControlBar );
};

WXPLI_IMPLEMENT_DYNAMIC_CLASS( wxPlPreviewFrame, wxPreviewFrame );

DEF_V_CBACK_VOID__VOID( wxPlPreviewFrame, wxPreviewFrame, Initialize );
DEF_V_CBACK_VOID__VOID( wxPlPreviewFrame, wxPreviewFrame, CreateCanvas );
DEF_V_CBACK_VOID__VOID( wxPlPreviewFrame, wxPreviewFrame, CreateControlBar );
%}
%file{-};

#include "cpp/previewframe.h"
#include "cpp/previewcontrolbar.h"

%name{Wx::PreviewControlBar} class wxPreviewControlBar
{
    wxPreviewControlBar( wxPrintPreview* preview, long buttons,
                         wxWindow* parent, wxPoint pos = wxDefaultPosition,
                         wxSize size = wxDefaultSize,
                         long style = wxTAB_TRAVERSAL,
                         wxString name = wxPanelNameStr );

    void CreateButtons();
    wxPrintPreviewBase* GetPrintPreview();
    int GetZoomControl();
    void SetZoomControl( int zoom );

    void OnNext();
    void OnPrevious();
    void OnFirst();
    void OnLast();
    void OnGoto();
#if WXPERL_W_VERSION_GE( 2, 5, 3 )
    void OnPrint();
#endif
};

%{
#define CreateButtons wxPreviewControlBar::CreateButtons
%}

%name{Wx::PlPreviewControlBar} class wxPlPreviewControlBar
{
    wxPlPreviewControlBar( wxPrintPreview* preview, long buttons,
                           wxWindow* parent,
                           wxPoint pos = wxDefaultPosition,
                           wxSize size = wxDefaultSize,
                           long style = wxTAB_TRAVERSAL,
                           wxString name = wxPanelNameStr )
        %code{% RETVAL = new wxPlPreviewControlBar
                    ( CLASS, preview, buttons, parent, pos, size,
                      style, name );
             %};

    void CreateButtons();
};

%{
#undef CreateButtons
%}

%name{Wx::PreviewFrame} class wxPreviewFrame
{
#if WXPERL_W_VERSION_GE( 2, 5, 3 )
    wxPreviewFrame( wxPrintPreview* preview, wxWindow* parent,
                    wxString title, wxPoint pos = wxDefaultPosition,
                    wxSize size = wxDefaultSize,
                    long style = wxDEFAULT_FRAME_STYLE,
                    wxString name = wxFrameNameStr );
#else
    wxPreviewFrame( wxPrintPreview* preview, wxFrame* parent,
                    wxString title, wxPoint pos = wxDefaultPosition,
                    wxSize size = wxDefaultSize,
                    long style = wxDEFAULT_FRAME_STYLE,
                    wxString name = wxFrameNameStr );
#endif

    void Initialize();
    void CreateCanvas();
    void CreateControlBar();

#if WXPERL_W_VERSION_GE( 2, 5, 4 )
    wxPreviewControlBar* GetControlBar() const;
#endif
};

%{
#define Initialize wxPreviewFrame::Initialize
#define CreateCanvas wxPreviewFrame::CreateCanvas
#define CreateControlBar wxPreviewFrame::CreateControlBar
%}

%name{Wx::PlPreviewFrame} class wxPlPreviewFrame
{
#if WXPERL_W_VERSION_GE( 2, 5, 3 )
    wxPlPreviewFrame( wxPrintPreview* preview, wxWindow* parent,
                      wxString title, wxPoint pos = wxDefaultPosition,
                      wxSize size = wxDefaultSize,
                      long style = wxDEFAULT_FRAME_STYLE,
                      wxString name = wxFrameNameStr )
        %code{% RETVAL = new wxPlPreviewFrame
                    ( CLASS, preview, parent, title, pos, size, style, name );
             %};
#else
    wxPlPreviewFrame( wxPrintPreview* preview, wxFrame* parent,
                      wxString title, wxPoint pos = wxDefaultPosition,
                      wxSize size = wxDefaultSize,
                      long style = wxDEFAULT_FRAME_STYLE,
                      wxString name = wxFrameNameStr )
        %code{% RETVAL = new wxPlPreviewFrame
                    ( CLASS, preview, parent, title, pos, size, style, name );
             %};
#endif

#if WXPERL_W_VERSION_GE( 2, 5, 3 )
    wxPreviewCanvas*     GetPreviewCanvas();
#else
    wxWindow*            GetPreviewCanvas();
#endif
    wxPreviewControlBar* GetPreviewControlBar();
    wxPrintPreviewBase*  GetPrintPreview();

#if WXPERL_W_VERSION_GE( 2, 5, 3 )
    void SetPreviewCanvas( wxPreviewCanvas* p );
#else
    void SetPreviewCanvas( wxWindow* p );
#endif
    void SetPreviewControlBar( wxPreviewControlBar* p );
    void SetPrintPreview( wxPrintPreviewBase* p );

    void Initialize();
    void CreateCanvas();
    void CreateControlBar();
};

%{
#undef Initialize
#undef CreateCanvas
#undef CreateControlBar
%}

%{
MODULE=Wx PACKAGE=Wx::PreviewCanvas

wxPreviewCanvas*
wxPreviewCanvas::new( preview, parent, pos = wxDefaultPosition, size = wxDefaultSize, style = 0, name = wxT("canvas") )
    wxPrintPreview* preview
    wxWindow* parent
    wxPoint pos
    wxSize size
    long style
    wxString name
%}