]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_printfw.i
Don't override methods that are in wxControlWithItems
[wxWidgets.git] / wxPython / src / _printfw.i
CommitLineData
bb0054cd 1/////////////////////////////////////////////////////////////////////////////
d14a1e28
RD
2// Name: _????.i
3// Purpose: SWIG interface for wx????
bb0054cd
RD
4//
5// Author: Robin Dunn
6//
d14a1e28 7// Created: 9-Aug-2003
bb0054cd 8// RCS-ID: $Id$
d14a1e28 9// Copyright: (c) 2003 by Total Control Software
bb0054cd
RD
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
d14a1e28 13// Not a %module
bb0054cd 14
bb0054cd 15
d14a1e28
RD
16//---------------------------------------------------------------------------
17%newgroup
bb0054cd 18
137b5242 19%{
d14a1e28
RD
20#include "wx/wxPython/printfw.h"
21
137b5242
RD
22%}
23
b2dc1044
RD
24MAKE_CONST_WXSTRING2(PrintoutTitleStr, wxT("Printout"));
25MAKE_CONST_WXSTRING2(PreviewCanvasNameStr, wxT("previewcanvas"));
26
bb0054cd 27
d14a1e28 28//---------------------------------------------------------------------------
bb0054cd 29
1fded56b
RD
30enum wxPrintMode
31{
32 wxPRINT_MODE_NONE = 0,
33 wxPRINT_MODE_PREVIEW = 1, // Preview in external application
34 wxPRINT_MODE_FILE = 2, // Print to file
4cc5453b
RD
35 wxPRINT_MODE_PRINTER = 3, // Send to printer
36 wxPRINT_MODE_STREAM = 4 // Send postscript data into a stream
1fded56b
RD
37};
38
3077d123
RD
39enum wxPrintBin
40{
41 wxPRINTBIN_DEFAULT,
42
43 wxPRINTBIN_ONLYONE,
44 wxPRINTBIN_LOWER,
45 wxPRINTBIN_MIDDLE,
46 wxPRINTBIN_MANUAL,
47 wxPRINTBIN_ENVELOPE,
48 wxPRINTBIN_ENVMANUAL,
49 wxPRINTBIN_AUTO,
50 wxPRINTBIN_TRACTOR,
51 wxPRINTBIN_SMALLFMT,
52 wxPRINTBIN_LARGEFMT,
53 wxPRINTBIN_LARGECAPACITY,
54 wxPRINTBIN_CASSETTE,
55 wxPRINTBIN_FORMSOURCE,
56
57 wxPRINTBIN_USER,
58};
bb0054cd
RD
59
60
9416aa89 61class wxPrintData : public wxObject {
bb0054cd 62public:
356f3c65 63 %nokwargs wxPrintData;
bb0054cd 64 wxPrintData();
356f3c65
RD
65 wxPrintData(const wxPrintData& data); // for making copies
66
bb0054cd
RD
67 ~wxPrintData();
68
69 int GetNoCopies();
70 bool GetCollate();
71 int GetOrientation();
72
b7fc54be
RD
73 bool Ok();
74
bb0054cd
RD
75 const wxString& GetPrinterName();
76 bool GetColour();
77 wxDuplexMode GetDuplex();
78 wxPaperSize GetPaperId();
79 const wxSize& GetPaperSize();
80
b2dc1044 81 int GetQuality();
3077d123 82 wxPrintBin GetBin();
7aada1e0 83 wxPrintMode GetPrintMode() const;
3077d123 84
bb0054cd
RD
85 void SetNoCopies(int v);
86 void SetCollate(bool flag);
87 void SetOrientation(int orient);
88
89 void SetPrinterName(const wxString& name);
90 void SetColour(bool colour);
91 void SetDuplex(wxDuplexMode duplex);
92 void SetPaperId(wxPaperSize sizeId);
93 void SetPaperSize(const wxSize& sz);
b2dc1044 94 void SetQuality(int quality);
3077d123 95 void SetBin(wxPrintBin bin);
7aada1e0
RD
96 void SetPrintMode(wxPrintMode printMode);
97
98 wxString GetFilename() const;
99 void SetFilename( const wxString &filename );
100
101 %pythoncode { def __nonzero__(self): return self.Ok() }
102
103
104 // NOTE: These are now inside of #if WXWIN_COMPATIBILITY_2_4, so be
105 // prepared to remove them...
106
926bb76c
RD
107 // PostScript-specific data
108 const wxString& GetPrinterCommand();
109 const wxString& GetPrinterOptions();
110 const wxString& GetPreviewCommand();
926bb76c
RD
111 const wxString& GetFontMetricPath();
112 double GetPrinterScaleX();
113 double GetPrinterScaleY();
114 long GetPrinterTranslateX();
115 long GetPrinterTranslateY();
926bb76c
RD
116 void SetPrinterCommand(const wxString& command);
117 void SetPrinterOptions(const wxString& options);
118 void SetPreviewCommand(const wxString& command);
926bb76c
RD
119 void SetFontMetricPath(const wxString& path);
120 void SetPrinterScaleX(double x);
121 void SetPrinterScaleY(double y);
122 void SetPrinterScaling(double x, double y);
123 void SetPrinterTranslateX(long x);
124 void SetPrinterTranslateY(long y);
125 void SetPrinterTranslation(long x, long y);
4cc5453b 126
eedf876b
RD
127};
128
129//---------------------------------------------------------------------------
130
9416aa89 131class wxPageSetupDialogData : public wxObject {
bb0054cd 132public:
356f3c65 133 %nokwargs wxPageSetupDialogData;
bb0054cd 134 wxPageSetupDialogData();
356f3c65 135 wxPageSetupDialogData(const wxPageSetupDialogData& data); // for making copies
e5bc90ee 136 wxPageSetupDialogData(const wxPrintData& data);
bb0054cd
RD
137 ~wxPageSetupDialogData();
138
139 void EnableHelp(bool flag);
140 void EnableMargins(bool flag);
141 void EnableOrientation(bool flag);
142 void EnablePaper(bool flag);
143 void EnablePrinter(bool flag);
e5bc90ee 144
bb0054cd
RD
145 bool GetDefaultMinMargins();
146 bool GetEnableMargins();
147 bool GetEnableOrientation();
148 bool GetEnablePaper();
149 bool GetEnablePrinter();
150 bool GetEnableHelp();
151 bool GetDefaultInfo();
152 wxPoint GetMarginTopLeft();
153 wxPoint GetMarginBottomRight();
154 wxPoint GetMinMarginTopLeft();
155 wxPoint GetMinMarginBottomRight();
156 wxPaperSize GetPaperId();
157 wxSize GetPaperSize();
d14a1e28
RD
158
159 wxPrintData& GetPrintData();
b7fc54be
RD
160
161 bool Ok();
162
bb0054cd
RD
163 void SetDefaultInfo(bool flag);
164 void SetDefaultMinMargins(bool flag);
165 void SetMarginTopLeft(const wxPoint& pt);
166 void SetMarginBottomRight(const wxPoint& pt);
167 void SetMinMarginTopLeft(const wxPoint& pt);
168 void SetMinMarginBottomRight(const wxPoint& pt);
3ca6a5f0 169 void SetPaperId(wxPaperSize id);
bb0054cd 170 void SetPaperSize(const wxSize& size);
e5bc90ee 171
bb0054cd 172 void SetPrintData(const wxPrintData& printData);
1fded56b 173
e5bc90ee
RD
174 // Use paper size defined in this object to set the wxPrintData
175 // paper id
176 void CalculateIdFromPaperSize();
177
178 // Use paper id in wxPrintData to set this object's paper size
179 void CalculatePaperSizeFromId();
180
d14a1e28 181 %pythoncode { def __nonzero__(self): return self.Ok() }
bb0054cd
RD
182};
183
184
d14a1e28 185
32bf5e4a
RD
186// NOTE: Contrary to it's name, this class doesn't derive from wxDialog. It
187// is a facade in front of a platform-specific (native dialog) provided by the
188// wxPrintFactory.
189
ab1f7d2a
RD
190MustHaveApp(wxPageSetupDialog);
191
32bf5e4a
RD
192class wxPageSetupDialog : public wxObject
193{
bb0054cd 194public:
d14a1e28 195 wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
bb0054cd
RD
196
197 wxPageSetupDialogData& GetPageSetupData();
32bf5e4a 198 wxPageSetupDialogData& GetPageSetupDialogData();
bb0054cd
RD
199 int ShowModal();
200};
201
d14a1e28 202//---------------------------------------------------------------------------
bb0054cd
RD
203
204
9416aa89 205class wxPrintDialogData : public wxObject {
bb0054cd 206public:
d88d4683 207 %nokwargs wxPrintDialogData;
bb0054cd 208 wxPrintDialogData();
e5bc90ee
RD
209 wxPrintDialogData(const wxPrintData& printData);
210 wxPrintDialogData(const wxPrintDialogData& printData); // for making copies
bb0054cd
RD
211 ~wxPrintDialogData();
212
1fded56b
RD
213 int GetFromPage() const;
214 int GetToPage() const;
215 int GetMinPage() const;
216 int GetMaxPage() const;
217 int GetNoCopies() const;
218 bool GetAllPages() const;
219 bool GetSelection() const;
220 bool GetCollate() const;
221 bool GetPrintToFile() const;
7aada1e0
RD
222
223 // WXWIN_COMPATIBILITY_2_4
1fded56b 224 bool GetSetupDialog() const;
7aada1e0 225 void SetSetupDialog(bool flag);
1fded56b
RD
226
227 void SetFromPage(int v);
228 void SetToPage(int v);
229 void SetMinPage(int v);
230 void SetMaxPage(int v);
231 void SetNoCopies(int v);
232 void SetAllPages(bool flag);
233 void SetSelection(bool flag);
234 void SetCollate(bool flag);
235 void SetPrintToFile(bool flag);
1fded56b 236
bb0054cd
RD
237 void EnablePrintToFile(bool flag);
238 void EnableSelection(bool flag);
1fded56b
RD
239 void EnablePageNumbers(bool flag);
240 void EnableHelp(bool flag);
241
242 bool GetEnablePrintToFile() const;
243 bool GetEnableSelection() const;
244 bool GetEnablePageNumbers() const;
245 bool GetEnableHelp() const;
246
247 // Is this data OK for showing the print dialog?
248 bool Ok() const;
249
d14a1e28
RD
250
251 wxPrintData& GetPrintData();
bb0054cd 252 void SetPrintData(const wxPrintData& printData);
1fded56b 253
d14a1e28 254 %pythoncode { def __nonzero__(self): return self.Ok() }
bb0054cd
RD
255};
256
257
6b9f434e 258
ab1f7d2a
RD
259MustHaveApp(wxPrintDialog);
260
d14a1e28 261
6b9f434e
RD
262// NOTE: Contrary to it's name, this class doesn't derive from wxDialog. It
263// is a facade in front of a platform-specific (native dialog) provided by the
264// wxPrintFactory.
265
266class wxPrintDialog : public wxObject {
267public:
bb0054cd
RD
268 wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
269
7aada1e0
RD
270 // TODO?: wxPrintDialog(wxWindow *parent, wxPrintData* data);
271
272 virtual int ShowModal();
273
274 virtual wxPrintDialogData& GetPrintDialogData();
275 virtual wxPrintData& GetPrintData();
d14a1e28
RD
276
277 %newobject GetPrintDC;
7aada1e0
RD
278 virtual wxDC *GetPrintDC();
279
bb0054cd
RD
280};
281
d14a1e28
RD
282
283//---------------------------------------------------------------------------
284//---------------------------------------------------------------------------
285
286
287enum wxPrinterError
288{
289 wxPRINTER_NO_ERROR = 0,
290 wxPRINTER_CANCELLED,
291 wxPRINTER_ERROR
292};
293
294
ab1f7d2a
RD
295MustHaveApp(wxPrinter);
296
d14a1e28
RD
297class wxPrinter : public wxObject {
298public:
299 wxPrinter(wxPrintDialogData* data = NULL);
300 ~wxPrinter();
301
6b9f434e
RD
302 virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPyPrintout *printout);
303 virtual void ReportError(wxWindow *parent, wxPyPrintout *printout, const wxString& message);
7aada1e0
RD
304
305 virtual bool Setup(wxWindow *parent);
6b9f434e 306 virtual bool Print(wxWindow *parent, wxPyPrintout *printout, bool prompt = true);
7aada1e0
RD
307 virtual wxDC* PrintDialog(wxWindow *parent);
308
309 virtual wxPrintDialogData& GetPrintDialogData() const;
d14a1e28 310
7aada1e0 311 bool GetAbort();
d14a1e28
RD
312 static wxPrinterError GetLastError();
313};
314
315
316//---------------------------------------------------------------------------
6b9f434e
RD
317// Custom wxPrintout class that knows how to call python, See implementation in
318// include/sx/wxPython/printfw.h
319
bb0054cd 320%{
2abc0a0f 321
6b9f434e 322IMPLEMENT_ABSTRACT_CLASS(wxPyPrintout, wxPrintout);
2abc0a0f
RD
323
324// Since this one would be tough and ugly to do with the Macros...
325void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
a72f4631 326 bool hadErr = false;
19a97bd6 327 bool found;
2abc0a0f 328
da32eb53 329 bool blocked = wxPyBeginBlockThreads();
d14a1e28
RD
330 if ((found = wxPyCBH_findCallback(m_myInst, "GetPageInfo"))) {
331 PyObject* result = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
2abc0a0f
RD
332 if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
333 PyObject* val;
334
335 val = PyTuple_GetItem(result, 0);
336 if (PyInt_Check(val)) *minPage = PyInt_AsLong(val);
a72f4631 337 else hadErr = true;
2abc0a0f
RD
338
339 val = PyTuple_GetItem(result, 1);
340 if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val);
a72f4631 341 else hadErr = true;
2abc0a0f
RD
342
343 val = PyTuple_GetItem(result, 2);
344 if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val);
a72f4631 345 else hadErr = true;
2abc0a0f
RD
346
347 val = PyTuple_GetItem(result, 3);
348 if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val);
a72f4631 349 else hadErr = true;
bb0054cd
RD
350 }
351 else
a72f4631 352 hadErr = true;
1afc06c2 353
2abc0a0f
RD
354 if (hadErr) {
355 PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
356 PyErr_Print();
357 }
358 Py_DECREF(result);
bb0054cd 359 }
da32eb53 360 wxPyEndBlockThreads(blocked);
19a97bd6 361 if (! found)
bb0054cd 362 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
2abc0a0f
RD
363}
364
365void wxPyPrintout::base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
366 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
367}
368
1afc06c2
RD
369
370IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument);
371IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument);
372IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnBeginPrinting);
373IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndPrinting);
374IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnPreparePrinting);
375IMP_PYCALLBACK_BOOL_INT_pure(wxPyPrintout, wxPrintout, OnPrintPage);
376IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage);
377
378
bb0054cd
RD
379%}
380
381
ab1f7d2a
RD
382MustHaveApp(wxPyPrintout);
383
bb0054cd 384// Now define the custom class for SWIGging
1b8c7ba6
RD
385%rename(Printout) wxPyPrintout;
386class wxPyPrintout : public wxObject {
bb0054cd 387public:
2b9048c5 388 %pythonAppend wxPyPrintout "self._setCallbackInfo(self, Printout)"
bb0054cd 389
d14a1e28
RD
390 wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr);
391 //~wxPyPrintout(); wxPrintPreview object takes ownership...
392
0122b7e3 393 void _setCallbackInfo(PyObject* self, PyObject* _class);
bb0054cd 394
d14a1e28
RD
395
396 wxString GetTitle() const;
bb0054cd 397 wxDC* GetDC();
d14a1e28
RD
398 void SetDC(wxDC *dc);
399
d14a1e28 400 void SetPageSizePixels(int w, int h);
322913ce
RD
401 DocDeclA(
402 void, GetPageSizePixels(int *OUTPUT, int *OUTPUT),
403 "GetPageSizePixels() -> (w, h)");
d14a1e28
RD
404
405 void SetPageSizeMM(int w, int h);
322913ce
RD
406 DocDeclA(
407 void, GetPageSizeMM(int *OUTPUT, int *OUTPUT),
408 "GetPageSizeMM() -> (w, h)");
d14a1e28
RD
409
410 void SetPPIScreen(int x, int y);
322913ce
RD
411 DocDeclA(
412 void, GetPPIScreen(int *OUTPUT, int *OUTPUT),
413 "GetPPIScreen() -> (x,y)");
d14a1e28
RD
414
415 void SetPPIPrinter(int x, int y);
322913ce
RD
416 DocDeclA(
417 void, GetPPIPrinter(int *OUTPUT, int *OUTPUT),
418 "GetPPIPrinter() -> (x,y)");
d14a1e28 419
bb0054cd 420 bool IsPreview();
d14a1e28 421 void SetIsPreview(bool p);
bb0054cd 422
d14a1e28 423
bb0054cd
RD
424 bool base_OnBeginDocument(int startPage, int endPage);
425 void base_OnEndDocument();
426 void base_OnBeginPrinting();
427 void base_OnEndPrinting();
428 void base_OnPreparePrinting();
bb0054cd 429 bool base_HasPage(int page);
322913ce
RD
430 DocDeclA(
431 void, base_GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
432 "base_GetPageInfo() -> (minPage, maxPage, pageFrom, pageTo)");
bb0054cd
RD
433};
434
d14a1e28 435//---------------------------------------------------------------------------
1fded56b 436
1fded56b 437
1fded56b 438
ab1f7d2a
RD
439MustHaveApp(wxPreviewCanvas);
440
d14a1e28 441class wxPreviewCanvas: public wxScrolledWindow
1fded56b
RD
442{
443public:
2b9048c5 444 %pythonAppend wxPreviewCanvas "self._setOORInfo(self)"
bb0054cd 445
d14a1e28
RD
446 wxPreviewCanvas(wxPrintPreview *preview,
447 wxWindow *parent,
448 const wxPoint& pos = wxDefaultPosition,
449 const wxSize& size = wxDefaultSize,
450 long style = 0,
451 const wxString& name = wxPyPreviewCanvasNameStr);
bb0054cd
RD
452};
453
bb0054cd 454
ab1f7d2a
RD
455MustHaveApp(wxPreviewFrame);
456
bb0054cd
RD
457class wxPreviewFrame : public wxFrame {
458public:
2b9048c5 459 %pythonAppend wxPreviewFrame "self._setOORInfo(self)"
d14a1e28 460
bb0054cd 461 wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
b68dc582
RD
462 const wxPoint& pos = wxDefaultPosition,
463 const wxSize& size = wxDefaultSize,
bb0054cd 464 long style = wxDEFAULT_FRAME_STYLE,
137b5242 465 const wxString& name = wxPyFrameNameStr);
bb0054cd 466
bb0054cd 467 void Initialize();
1fded56b
RD
468 void CreateControlBar();
469 void CreateCanvas();
3ef86e32
RD
470
471 wxPreviewControlBar* GetControlBar() const;
1fded56b
RD
472};
473
474
1fded56b
RD
475
476enum {
477 wxPREVIEW_PRINT,
478 wxPREVIEW_PREVIOUS,
479 wxPREVIEW_NEXT,
480 wxPREVIEW_ZOOM,
481 wxPREVIEW_FIRST,
482 wxPREVIEW_LAST,
483 wxPREVIEW_GOTO,
484 wxPREVIEW_DEFAULT,
485
486 wxID_PREVIEW_CLOSE,
487 wxID_PREVIEW_NEXT,
488 wxID_PREVIEW_PREVIOUS,
489 wxID_PREVIEW_PRINT,
490 wxID_PREVIEW_ZOOM,
491 wxID_PREVIEW_FIRST,
492 wxID_PREVIEW_LAST,
493 wxID_PREVIEW_GOTO
494};
495
ab1f7d2a
RD
496MustHaveApp(wxPreviewControlBar);
497
1fded56b
RD
498class wxPreviewControlBar: public wxPanel
499{
500public:
2b9048c5 501 %pythonAppend wxPreviewControlBar "self._setOORInfo(self)"
d14a1e28 502
1fded56b
RD
503 wxPreviewControlBar(wxPrintPreview *preview,
504 long buttons,
505 wxWindow *parent,
506 const wxPoint& pos = wxDefaultPosition,
507 const wxSize& size = wxDefaultSize,
3ef86e32 508 long style = wxTAB_TRAVERSAL,
1fded56b 509 const wxString& name = wxPyPanelNameStr);
1fded56b
RD
510
511 int GetZoomControl();
512 void SetZoomControl(int zoom);
513 wxPrintPreview* GetPrintPreview();
514
515 void OnNext();
516 void OnPrevious();
517 void OnFirst();
518 void OnLast();
519 void OnGoto();
520};
521
522
d14a1e28
RD
523
524//---------------------------------------------------------------------------
525
ab1f7d2a
RD
526MustHaveApp(wxPrintPreview);
527
d14a1e28
RD
528class wxPrintPreview : public wxObject {
529public:
d88d4683 530 %nokwargs wxPrintPreview;
d14a1e28
RD
531 wxPrintPreview(wxPyPrintout* printout,
532 wxPyPrintout* printoutForPrinting,
d88d4683
RD
533 wxPrintDialogData *data=NULL);
534 wxPrintPreview(wxPyPrintout* printout,
535 wxPyPrintout* printoutForPrinting,
536 wxPrintData* data);
d14a1e28
RD
537
538 virtual bool SetCurrentPage(int pageNum);
539 int GetCurrentPage();
540
541 void SetPrintout(wxPyPrintout *printout);
542 wxPyPrintout *GetPrintout();
543 wxPyPrintout *GetPrintoutForPrinting();
544
545 void SetFrame(wxFrame *frame);
546 void SetCanvas(wxPreviewCanvas *canvas);
547
548 virtual wxFrame *GetFrame();
549 virtual wxPreviewCanvas *GetCanvas();
550
551 // The preview canvas should call this from OnPaint
552 virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
553
554 // This draws a blank page onto the preview canvas
555 virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
556
557 // This is called by wxPrintPreview to render a page into a wxMemoryDC.
558 virtual bool RenderPage(int pageNum);
559
560 // Adjusts the scrollbars for the current scale
561 virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
562
563 wxPrintDialogData& GetPrintDialogData();
564
565 virtual void SetZoom(int percent);
566 int GetZoom();
567
568 int GetMaxPage();
569 int GetMinPage();
570
571 bool Ok();
572 void SetOk(bool ok);
573
574 virtual bool Print(bool interactive);
575 virtual void DetermineScaling();
576
577 %pythoncode { def __nonzero__(self): return self.Ok() }
578};
579
580
581
582//---------------------------------------------------------------------------
583
1fded56b
RD
584// Python-derivable versions of the above preview classes
585
586%{
3ef86e32 587
a72f4631
RD
588#define DEC_PYCALLBACK_BOOL_PREWINDC(CBNAME) \
589 bool CBNAME(wxPreviewCanvas* a, wxDC& b); \
3ef86e32
RD
590 bool base_##CBNAME(wxPreviewCanvas* a, wxDC& b)
591
592
a72f4631
RD
593#define IMP_PYCALLBACK_BOOL_PREWINDC(CLASS, PCLASS, CBNAME) \
594 bool CLASS::CBNAME(wxPreviewCanvas* a, wxDC& b) { \
595 bool rval=false; \
596 bool found; \
597 bool blocked = wxPyBeginBlockThreads(); \
598 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
599 PyObject* win = wxPyMake_wxObject(a,false); \
600 PyObject* dc = wxPyMake_wxObject(&b,false); \
601 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc)); \
602 Py_DECREF(win); \
603 Py_DECREF(dc); \
604 } \
605 wxPyEndBlockThreads(blocked); \
606 if (! found) \
607 rval = PCLASS::CBNAME(a, b); \
608 return rval; \
609 } \
610 bool CLASS::base_##CBNAME(wxPreviewCanvas* a, wxDC& b) { \
611 return PCLASS::CBNAME(a, b); \
3ef86e32
RD
612 }
613
614
615
616
1fded56b
RD
617class wxPyPrintPreview : public wxPrintPreview
618{
619 DECLARE_CLASS(wxPyPrintPreview)
620public:
d88d4683
RD
621 wxPyPrintPreview(wxPyPrintout* printout,
622 wxPyPrintout* printoutForPrinting,
623 wxPrintDialogData* data=NULL)
624 : wxPrintPreview(printout, printoutForPrinting, data)
625 {}
1fded56b
RD
626 wxPyPrintPreview(wxPyPrintout* printout,
627 wxPyPrintout* printoutForPrinting,
628 wxPrintData* data=NULL)
629 : wxPrintPreview(printout, printoutForPrinting, data)
630 {}
631
632 DEC_PYCALLBACK_BOOL_INT(SetCurrentPage);
3ef86e32
RD
633 DEC_PYCALLBACK_BOOL_PREWINDC(PaintPage);
634 DEC_PYCALLBACK_BOOL_PREWINDC(DrawBlankPage);
1fded56b
RD
635 DEC_PYCALLBACK_BOOL_INT(RenderPage);
636 DEC_PYCALLBACK_VOID_INT(SetZoom);
637 DEC_PYCALLBACK_BOOL_BOOL(Print);
638 DEC_PYCALLBACK_VOID_(DetermineScaling);
639
640 PYPRIVATE;
641};
642
643// Stupid renamed classes... Fix this in 2.5...
644#if defined(__WXMSW__)
645IMPLEMENT_CLASS( wxPyPrintPreview, wxWindowsPrintPreview );
646#elif defined(__WXMAC__)
647IMPLEMENT_CLASS( wxPyPrintPreview, wxMacPrintPreview );
648#else
649IMPLEMENT_CLASS( wxPyPrintPreview, wxPostScriptPrintPreview );
650#endif
651
3ef86e32
RD
652IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, SetCurrentPage);
653IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, PaintPage);
654IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, DrawBlankPage);
655IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, RenderPage);
656IMP_PYCALLBACK_VOID_INT (wxPyPrintPreview, wxPrintPreview, SetZoom);
657IMP_PYCALLBACK_BOOL_BOOL (wxPyPrintPreview, wxPrintPreview, Print);
658IMP_PYCALLBACK_VOID_ (wxPyPrintPreview, wxPrintPreview, DetermineScaling);
1fded56b
RD
659%}
660
661
ab1f7d2a
RD
662MustHaveApp(wxPyPrintPreview);
663
1fded56b
RD
664class wxPyPrintPreview : public wxPrintPreview
665{
666public:
2b9048c5 667 %pythonAppend wxPyPrintPreview "self._setCallbackInfo(self, PyPrintPreview)"
d88d4683
RD
668 %nokwargs wxPyPrintPreview;
669 wxPyPrintPreview(wxPyPrintout* printout,
670 wxPyPrintout* printoutForPrinting,
671 wxPrintDialogData* data=NULL);
1fded56b
RD
672 wxPyPrintPreview(wxPyPrintout* printout,
673 wxPyPrintout* printoutForPrinting,
d88d4683 674 wxPrintData* data);
1fded56b
RD
675
676 void _setCallbackInfo(PyObject* self, PyObject* _class);
d14a1e28 677
1fded56b 678 bool base_SetCurrentPage(int pageNum);
3ef86e32
RD
679 bool base_PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
680 bool base_DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
1fded56b
RD
681 bool base_RenderPage(int pageNum);
682 void base_SetZoom(int percent);
683 bool base_Print(bool interactive);
684 void base_DetermineScaling();
685};
686
687
bb0054cd 688
bb0054cd 689
1fded56b
RD
690%{
691class wxPyPreviewFrame : public wxPreviewFrame
692{
693 DECLARE_CLASS(wxPyPreviewFrame);
694public:
695 wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
696 const wxString& title,
697 const wxPoint& pos = wxDefaultPosition,
698 const wxSize& size = wxDefaultSize,
699 long style = wxDEFAULT_FRAME_STYLE,
700 const wxString& name = wxPyFrameNameStr)
701 : wxPreviewFrame(preview, parent, title, pos, size, style, name)
702 {}
703
3ef86e32 704 void SetPreviewCanvas(wxPreviewCanvas* canvas) { m_previewCanvas = canvas; }
1fded56b
RD
705 void SetControlBar(wxPreviewControlBar* bar) { m_controlBar = bar; }
706
707 DEC_PYCALLBACK_VOID_(Initialize);
708 DEC_PYCALLBACK_VOID_(CreateCanvas);
709 DEC_PYCALLBACK_VOID_(CreateControlBar);
710
711 PYPRIVATE;
712};
713
714IMPLEMENT_CLASS(wxPyPreviewFrame, wxPreviewFrame);
715
716IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, Initialize);
717IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateCanvas);
718IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateControlBar);
719%}
720
d14a1e28 721
ab1f7d2a
RD
722MustHaveApp(wxPyPreviewFrame);
723
1fded56b
RD
724class wxPyPreviewFrame : public wxPreviewFrame
725{
726public:
2b9048c5 727 %pythonAppend wxPyPreviewFrame "self._setCallbackInfo(self, PyPreviewFrame); self._setOORInfo(self)"
d14a1e28 728
1fded56b
RD
729 wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
730 const wxString& title,
731 const wxPoint& pos = wxDefaultPosition,
732 const wxSize& size = wxDefaultSize,
733 long style = wxDEFAULT_FRAME_STYLE,
734 const wxString& name = wxPyFrameNameStr);
735
736 void _setCallbackInfo(PyObject* self, PyObject* _class);
1fded56b 737
3ef86e32 738 void SetPreviewCanvas(wxPreviewCanvas* canvas);
1fded56b
RD
739 void SetControlBar(wxPreviewControlBar* bar);
740
741 void base_Initialize();
742 void base_CreateCanvas();
743 void base_CreateControlBar();
bb0054cd
RD
744};
745
1fded56b
RD
746
747
748
749%{
750class wxPyPreviewControlBar : public wxPreviewControlBar
751{
752 DECLARE_CLASS(wxPyPreviewControlBar);
753public:
754 wxPyPreviewControlBar(wxPrintPreview *preview,
755 long buttons,
756 wxWindow *parent,
757 const wxPoint& pos = wxDefaultPosition,
758 const wxSize& size = wxDefaultSize,
759 long style = 0,
760 const wxString& name = wxPyPanelNameStr)
761 : wxPreviewControlBar(preview, buttons, parent, pos, size, style, name)
762 {}
763
764 void SetPrintPreview(wxPrintPreview* preview) { m_printPreview = preview; }
765
766 DEC_PYCALLBACK_VOID_(CreateButtons);
767 DEC_PYCALLBACK_VOID_INT(SetZoomControl);
768
769 PYPRIVATE;
770};
771
772IMPLEMENT_CLASS(wxPyPreviewControlBar, wxPreviewControlBar);
773IMP_PYCALLBACK_VOID_(wxPyPreviewControlBar, wxPreviewControlBar, CreateButtons);
774IMP_PYCALLBACK_VOID_INT(wxPyPreviewControlBar, wxPreviewControlBar, SetZoomControl);
775%}
776
d14a1e28 777
ab1f7d2a
RD
778MustHaveApp(wxPyPreviewControlBar);
779
1fded56b
RD
780class wxPyPreviewControlBar : public wxPreviewControlBar
781{
782public:
2b9048c5 783 %pythonAppend wxPyPreviewControlBar "self._setCallbackInfo(self, PyPreviewControlBar); self._setOORInfo(self)"
d14a1e28 784
1fded56b
RD
785 wxPyPreviewControlBar(wxPrintPreview *preview,
786 long buttons,
787 wxWindow *parent,
788 const wxPoint& pos = wxDefaultPosition,
789 const wxSize& size = wxDefaultSize,
790 long style = 0,
791 const wxString& name = wxPyPanelNameStr);
792
793 void _setCallbackInfo(PyObject* self, PyObject* _class);
1fded56b
RD
794
795 void SetPrintPreview(wxPrintPreview* preview);
796
797 void base_CreateButtons();
798 void base_SetZoomControl(int zoom);
799};
800
d14a1e28
RD
801//---------------------------------------------------------------------------
802//---------------------------------------------------------------------------
9416aa89
RD
803%init %{
804 wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
805%}
d14a1e28 806//---------------------------------------------------------------------------