Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / ext / print / cpp / printout.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        ext/print/cpp/printout.h
3 // Purpose:     c++ wrapper for wxPrintout
4 // Author:      Mattia Barbon
5 // Modified by:
6 // Created:     02/06/2001
7 // RCS-ID:      $Id: printout.h 2057 2007-06-18 23:03:00Z mbarbon $
8 // Copyright:   (c) 2001-2002, 2004 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 /////////////////////////////////////////////////////////////////////////////
12
13 #include "cpp/v_cback.h"
14
15 class wxPlPrintout:public wxPrintout
16 {
17     WXPLI_DECLARE_DYNAMIC_CLASS( wxPlPrintout );
18     WXPLI_DECLARE_V_CBACK();
19 public:
20     wxPlPrintout( const char* package, const wxString& title );
21
22     void GetPageInfo( int* minPage, int* maxPage, int* pageFrom, int* pageTo );
23
24     DEC_V_CBACK_BOOL__INT( HasPage );
25     DEC_V_CBACK_BOOL__INT_INT( OnBeginDocument );
26     DEC_V_CBACK_VOID__VOID( OnEndDocument );
27     DEC_V_CBACK_VOID__VOID( OnBeginPrinting );
28     DEC_V_CBACK_VOID__VOID( OnEndPrinting );
29     DEC_V_CBACK_VOID__VOID( OnPreparePrinting );
30     DEC_V_CBACK_BOOL__INT( OnPrintPage );
31 };
32
33 inline wxPlPrintout::wxPlPrintout( const char* package, const wxString& title )
34     :wxPrintout( title ),
35      m_callback( "Wx::PlPrintout" )
36 {
37     m_callback.SetSelf( wxPli_make_object( this, package ), true );
38 }
39
40 WXPLI_IMPLEMENT_DYNAMIC_CLASS( wxPlPrintout, wxPrintout );
41
42 DEF_V_CBACK_BOOL__INT( wxPlPrintout, wxPrintout, HasPage );
43 DEF_V_CBACK_BOOL__INT_INT( wxPlPrintout, wxPrintout, OnBeginDocument );
44 DEF_V_CBACK_VOID__VOID( wxPlPrintout, wxPrintout, OnEndDocument );
45 DEF_V_CBACK_VOID__VOID( wxPlPrintout, wxPrintout, OnBeginPrinting );
46 DEF_V_CBACK_VOID__VOID( wxPlPrintout, wxPrintout, OnEndPrinting );
47 DEF_V_CBACK_VOID__VOID( wxPlPrintout, wxPrintout, OnPreparePrinting );
48 DEF_V_CBACK_BOOL__INT_pure( wxPlPrintout, wxPrintout, OnPrintPage );
49
50 void wxPlPrintout::GetPageInfo( int* minPage, int* maxPage,
51                                 int* pageFrom, int* pageTo )
52 {
53     dTHX;
54     if( wxPliVirtualCallback_FindCallback( aTHX_ &m_callback, "GetPageInfo" ) )
55     {
56         dSP;
57
58         ENTER;
59         SAVETMPS;
60
61         PUSHMARK( SP );
62         XPUSHs( m_callback.GetSelf() );
63         PUTBACK;
64
65         SV* method = sv_2mortal( newRV_inc( (SV*) m_callback.GetMethod() ) );
66         int items = call_sv( method, G_ARRAY );
67
68         if( items != 4 )
69         {
70             croak( "wxPlPrintout::GetPageInfo, expected 4 values, got %i",
71                    items );
72         }
73
74         SPAGAIN;
75         SV* tmp;
76         // pop in reverse order...
77         tmp = POPs; *pageTo = SvIV( tmp );
78         tmp = POPs; *pageFrom = SvIV( tmp );
79         tmp = POPs; *maxPage = SvIV( tmp );
80         tmp = POPs; *minPage = SvIV( tmp );
81         PUTBACK;
82
83         FREETMPS;
84         LEAVE;
85     } else
86         wxPrintout::GetPageInfo( minPage, maxPage, pageFrom, pageTo );
87 }