File: RichTextPrinting.xsp

package info (click to toggle)
libwx-perl 1%3A0.9928-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,300 kB
  • ctags: 2,322
  • sloc: cpp: 11,044; perl: 8,646; ansic: 710; makefile: 48
file content (202 lines) | stat: -rw-r--r-- 7,650 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
#############################################################################
## Name:        ext/richtext/XS/RichTextPrinting.xsp
## Purpose:     XS++ for Wx::RichTextPrinting
## Author:      Mark Dootson
## Modified by:
## Created:     10/04/2010
## RCS-ID:      $Id: RichTextPrinting.xsp 3293 2012-05-16 20:02:24Z mdootson $
## Copyright:   (c) 2010 Mark Dootson
## Licence:     This program is free software; you can redistribute it and/or
##              modify it under the same terms as Perl itself
#############################################################################

#if WXPERL_W_VERSION_GE( 2, 8, 0 )

#include <wx/richtext/richtextprint.h>

%module{Wx};

%name{Wx::RichTextPrintout} class wxRichTextPrintout : public %name{Wx::Printout} wxPrintout
{

public:

    wxRichTextPrintout(const wxString& title = wxT("Printout"));
 
    %name{Destroy} ~wxRichTextPrintout()
        %code%{ delete THIS; %};

    /// The buffer to print
    void SetRichTextBuffer(wxRichTextBuffer* buffer);

    wxRichTextBuffer* GetRichTextBuffer() const ;

    /// Set/get header/footer data
    void SetHeaderFooterData(const wxRichTextHeaderFooterData& data) ;
    const wxRichTextHeaderFooterData& GetHeaderFooterData() const ;

    /// Sets margins in 10ths of millimetre. Defaults to 1 inch for margins.
    void SetMargins(int top = 254, int bottom = 254, int left = 254, int right = 254);

    /// Calculate scaling and rectangles, setting the device context scaling
    void CalculateScaling(wxDC* dc, wxRect& textRect, wxRect& headerRect, wxRect& footerRect);

    // wxPrintout virtual functions
    virtual bool OnPrintPage(int page);
    virtual bool HasPage(int page);
    //virtual void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
    virtual bool OnBeginDocument(int startPage, int endPage);
    virtual void OnPreparePrinting();
};

%{

void
wxRichTextPrintout::GetPageInfo()
  PREINIT:
    int minPage, maxPage, pageFrom, pageTo;
  PPCODE:
    THIS->wxRichTextPrintout::GetPageInfo( &minPage, &maxPage, &pageFrom, &pageTo );
    EXTEND( SP, 4 );
    PUSHs( sv_2mortal( newSViv( minPage ) ) );
    PUSHs( sv_2mortal( newSViv( maxPage ) ) );
    PUSHs( sv_2mortal( newSViv( pageFrom ) ) );
    PUSHs( sv_2mortal( newSViv( pageTo ) ) );

%}

%name{Wx::RichTextPrinting} class wxRichTextPrinting : public wxObject
{
    wxRichTextPrinting(  wxString name = wxT("Printing"), wxWindow *parentWindow = NULL );

    ~wxRichTextPrinting()
        %code%{  wxPli_thread_sv_unregister( aTHX_ "Wx::RichTextPrinting", THIS, ST(0) );
                 delete THIS; %};

%{
static void
wxRichTextPrinting::CLONE()
  CODE:
    wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
%}

    bool PreviewFile(const wxString& richTextFile);
    bool PreviewBuffer(const wxRichTextBuffer& buffer);

#if WXPERL_W_VERSION_GE( 2, 9, 4 )
    bool PrintFile(const wxString& richTextFile, bool showPrintDialog = true ); 
    bool PrintBuffer(const wxRichTextBuffer& buffer, bool showPrintDialog = true ); 
#else
    bool PrintFile(const wxString& richTextFile);
    bool PrintBuffer(const wxRichTextBuffer& buffer);
#endif

    void PageSetup();

    void SetHeaderFooterData(const wxRichTextHeaderFooterData& data);
    const wxRichTextHeaderFooterData& GetHeaderFooterData() const;

    void SetHeaderText(const wxString& text, wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL, wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);
    wxString GetHeaderText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN, wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
    void SetFooterText(const wxString& text, wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL, wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);
    wxString GetFooterText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN, wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;

    void SetShowOnFirstPage(bool show);

    void SetHeaderFooterFont(const wxFont& font);
    void SetHeaderFooterTextColour(const wxColour& font);

    wxPrintData *GetPrintData();
    void SetPrintData(const wxPrintData& printData);
    
    wxPageSetupDialogData *GetPageSetupData() const;
    void SetPageSetupData(const wxPageSetupDialogData& pageSetupData);

    void SetRichTextBufferPreview(wxRichTextBuffer* buffer)
        %code%{ THIS->SetRichTextBufferPreview(buffer); %}
        %cleanup%{ wxPli_object_set_deleteable( aTHX_ ST(0), false ); %};
         
    wxRichTextBuffer* GetRichTextBufferPreview() const
        %code%{ RETVAL = THIS->GetRichTextBufferPreview(); %}
        %cleanup%{ wxPli_object_set_deleteable( aTHX_ ST(0), false ); %};

    void SetRichTextBufferPrinting(wxRichTextBuffer* buffer)
        %code%{ THIS->SetRichTextBufferPrinting(buffer); %}
        %cleanup%{ wxPli_object_set_deleteable( aTHX_ ST(0), false ); %};    
    
    wxRichTextBuffer* GetRichTextBufferPrinting() const
        %code%{ RETVAL = THIS->GetRichTextBufferPrinting(); %}
        %cleanup%{ wxPli_object_set_deleteable( aTHX_ ST(0), false ); %};

    void SetParentWindow(wxWindow* parent);
    wxWindow* GetParentWindow() const;

    void SetTitle(const wxString& title);
    const wxString& GetTitle() const;

    void SetPreviewRect(const wxRect& rect);
    const wxRect& GetPreviewRect() const;
    
};


%name{Wx::RichTextHeaderFooterData} class wxRichTextHeaderFooterData : public wxObject
{

    %name{newDefault} wxRichTextHeaderFooterData();
    %name{newCopy} wxRichTextHeaderFooterData(const wxRichTextHeaderFooterData& data);

    ~wxRichTextPrinting()
        %code%{  wxPli_thread_sv_unregister( aTHX_ "Wx::RichTextHeaderFooterData", THIS, ST(0) );
                 delete THIS; %};

%{
static void
wxRichTextPrinting::CLONE()
  CODE:
    wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
%}

    // void Init();
    // void Copy(const wxRichTextHeaderFooterData& data);

    void SetHeaderText(const wxString& text, wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL, wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);
    wxString GetHeaderText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN, wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;

    void SetFooterText(const wxString& text, wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL, wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);
    wxString GetFooterText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN, wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;

    void SetText(const wxString& text, int headerFooter, wxRichTextOddEvenPage page, wxRichTextPageLocation location);
    wxString GetText(int headerFooter, wxRichTextOddEvenPage page, wxRichTextPageLocation location) const;

    void SetMargins(int headerMargin, int footerMargin);
    int GetHeaderMargin();
    int GetFooterMargin();

    void SetShowOnFirstPage(bool showOnFirstPage);
    bool GetShowOnFirstPage() const;
    void Clear();
    
    void SetFont(const wxFont& font);
    const wxFont& GetFont() const;

    void SetTextColour(const wxColour& col);
    const wxColour& GetTextColour() const;
    
};

## DECLARE_OVERLOAD( wrth, Wx::RichTextHeaderFooterData )

%{
void
wxRichTextHeaderFooterData::new( ... )
  PPCODE:
    BEGIN_OVERLOAD()
        MATCH_VOIDM_REDISP( newDefault )
        MATCH_REDISP( wxPliOvl_wrth, newCopy )
    END_OVERLOAD( Wx::RichTextHeaderFooterData::new )

%}

#endif