]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_printfw.i
added a test to check how exception handling works with Win32 SEH; corrected copyright
[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
bb0054cd
RD
136 ~wxPageSetupDialogData();
137
138 void EnableHelp(bool flag);
139 void EnableMargins(bool flag);
140 void EnableOrientation(bool flag);
141 void EnablePaper(bool flag);
142 void EnablePrinter(bool flag);
143 bool GetDefaultMinMargins();
144 bool GetEnableMargins();
145 bool GetEnableOrientation();
146 bool GetEnablePaper();
147 bool GetEnablePrinter();
148 bool GetEnableHelp();
149 bool GetDefaultInfo();
150 wxPoint GetMarginTopLeft();
151 wxPoint GetMarginBottomRight();
152 wxPoint GetMinMarginTopLeft();
153 wxPoint GetMinMarginBottomRight();
154 wxPaperSize GetPaperId();
155 wxSize GetPaperSize();
d14a1e28
RD
156
157 wxPrintData& GetPrintData();
158// %addmethods {
159// %new wxPrintData* GetPrintData() {
160// return new wxPrintData(self->GetPrintData()); // force a copy
161// }
162// }
b7fc54be
RD
163
164 bool Ok();
165
bb0054cd
RD
166 void SetDefaultInfo(bool flag);
167 void SetDefaultMinMargins(bool flag);
168 void SetMarginTopLeft(const wxPoint& pt);
169 void SetMarginBottomRight(const wxPoint& pt);
170 void SetMinMarginTopLeft(const wxPoint& pt);
171 void SetMinMarginBottomRight(const wxPoint& pt);
3ca6a5f0 172 void SetPaperId(wxPaperSize id);
bb0054cd
RD
173 void SetPaperSize(const wxSize& size);
174 void SetPrintData(const wxPrintData& printData);
1fded56b 175
d14a1e28 176 %pythoncode { def __nonzero__(self): return self.Ok() }
bb0054cd
RD
177};
178
179
d14a1e28 180
32bf5e4a
RD
181// NOTE: Contrary to it's name, this class doesn't derive from wxDialog. It
182// is a facade in front of a platform-specific (native dialog) provided by the
183// wxPrintFactory.
184
ab1f7d2a
RD
185MustHaveApp(wxPageSetupDialog);
186
32bf5e4a
RD
187class wxPageSetupDialog : public wxObject
188{
bb0054cd 189public:
d14a1e28 190 wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
bb0054cd
RD
191
192 wxPageSetupDialogData& GetPageSetupData();
32bf5e4a 193 wxPageSetupDialogData& GetPageSetupDialogData();
bb0054cd
RD
194 int ShowModal();
195};
196
d14a1e28 197//---------------------------------------------------------------------------
bb0054cd
RD
198
199
9416aa89 200class wxPrintDialogData : public wxObject {
bb0054cd 201public:
d88d4683 202 %nokwargs wxPrintDialogData;
bb0054cd 203 wxPrintDialogData();
356f3c65 204 wxPrintDialogData(const wxPrintData& printData); // for making copies
bb0054cd
RD
205 ~wxPrintDialogData();
206
1fded56b
RD
207 int GetFromPage() const;
208 int GetToPage() const;
209 int GetMinPage() const;
210 int GetMaxPage() const;
211 int GetNoCopies() const;
212 bool GetAllPages() const;
213 bool GetSelection() const;
214 bool GetCollate() const;
215 bool GetPrintToFile() const;
7aada1e0
RD
216
217 // WXWIN_COMPATIBILITY_2_4
1fded56b 218 bool GetSetupDialog() const;
7aada1e0 219 void SetSetupDialog(bool flag);
1fded56b
RD
220
221 void SetFromPage(int v);
222 void SetToPage(int v);
223 void SetMinPage(int v);
224 void SetMaxPage(int v);
225 void SetNoCopies(int v);
226 void SetAllPages(bool flag);
227 void SetSelection(bool flag);
228 void SetCollate(bool flag);
229 void SetPrintToFile(bool flag);
1fded56b 230
bb0054cd
RD
231 void EnablePrintToFile(bool flag);
232 void EnableSelection(bool flag);
1fded56b
RD
233 void EnablePageNumbers(bool flag);
234 void EnableHelp(bool flag);
235
236 bool GetEnablePrintToFile() const;
237 bool GetEnableSelection() const;
238 bool GetEnablePageNumbers() const;
239 bool GetEnableHelp() const;
240
241 // Is this data OK for showing the print dialog?
242 bool Ok() const;
243
d14a1e28
RD
244
245 wxPrintData& GetPrintData();
bb0054cd 246 void SetPrintData(const wxPrintData& printData);
1fded56b 247
d14a1e28 248 %pythoncode { def __nonzero__(self): return self.Ok() }
bb0054cd
RD
249};
250
251
6b9f434e 252
ab1f7d2a
RD
253MustHaveApp(wxPrintDialog);
254
d14a1e28 255
6b9f434e
RD
256// NOTE: Contrary to it's name, this class doesn't derive from wxDialog. It
257// is a facade in front of a platform-specific (native dialog) provided by the
258// wxPrintFactory.
259
260class wxPrintDialog : public wxObject {
261public:
bb0054cd
RD
262 wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
263
7aada1e0
RD
264 // TODO?: wxPrintDialog(wxWindow *parent, wxPrintData* data);
265
266 virtual int ShowModal();
267
268 virtual wxPrintDialogData& GetPrintDialogData();
269 virtual wxPrintData& GetPrintData();
d14a1e28
RD
270
271 %newobject GetPrintDC;
7aada1e0
RD
272 virtual wxDC *GetPrintDC();
273
bb0054cd
RD
274};
275
d14a1e28
RD
276
277//---------------------------------------------------------------------------
278//---------------------------------------------------------------------------
279
280
281enum wxPrinterError
282{
283 wxPRINTER_NO_ERROR = 0,
284 wxPRINTER_CANCELLED,
285 wxPRINTER_ERROR
286};
287
288
ab1f7d2a
RD
289MustHaveApp(wxPrinter);
290
d14a1e28
RD
291class wxPrinter : public wxObject {
292public:
293 wxPrinter(wxPrintDialogData* data = NULL);
294 ~wxPrinter();
295
6b9f434e
RD
296 virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPyPrintout *printout);
297 virtual void ReportError(wxWindow *parent, wxPyPrintout *printout, const wxString& message);
7aada1e0
RD
298
299 virtual bool Setup(wxWindow *parent);
6b9f434e 300 virtual bool Print(wxWindow *parent, wxPyPrintout *printout, bool prompt = true);
7aada1e0
RD
301 virtual wxDC* PrintDialog(wxWindow *parent);
302
303 virtual wxPrintDialogData& GetPrintDialogData() const;
d14a1e28 304
7aada1e0 305 bool GetAbort();
d14a1e28
RD
306 static wxPrinterError GetLastError();
307};
308
309
310//---------------------------------------------------------------------------
6b9f434e
RD
311// Custom wxPrintout class that knows how to call python, See implementation in
312// include/sx/wxPython/printfw.h
313
bb0054cd 314%{
2abc0a0f 315
6b9f434e 316IMPLEMENT_ABSTRACT_CLASS(wxPyPrintout, wxPrintout);
2abc0a0f
RD
317
318// Since this one would be tough and ugly to do with the Macros...
319void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
a72f4631 320 bool hadErr = false;
19a97bd6 321 bool found;
2abc0a0f 322
da32eb53 323 bool blocked = wxPyBeginBlockThreads();
d14a1e28
RD
324 if ((found = wxPyCBH_findCallback(m_myInst, "GetPageInfo"))) {
325 PyObject* result = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
2abc0a0f
RD
326 if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
327 PyObject* val;
328
329 val = PyTuple_GetItem(result, 0);
330 if (PyInt_Check(val)) *minPage = PyInt_AsLong(val);
a72f4631 331 else hadErr = true;
2abc0a0f
RD
332
333 val = PyTuple_GetItem(result, 1);
334 if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val);
a72f4631 335 else hadErr = true;
2abc0a0f
RD
336
337 val = PyTuple_GetItem(result, 2);
338 if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val);
a72f4631 339 else hadErr = true;
2abc0a0f
RD
340
341 val = PyTuple_GetItem(result, 3);
342 if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val);
a72f4631 343 else hadErr = true;
bb0054cd
RD
344 }
345 else
a72f4631 346 hadErr = true;
1afc06c2 347
2abc0a0f
RD
348 if (hadErr) {
349 PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
350 PyErr_Print();
351 }
352 Py_DECREF(result);
bb0054cd 353 }
da32eb53 354 wxPyEndBlockThreads(blocked);
19a97bd6 355 if (! found)
bb0054cd 356 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
2abc0a0f
RD
357}
358
359void wxPyPrintout::base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
360 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
361}
362
1afc06c2
RD
363
364IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument);
365IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument);
366IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnBeginPrinting);
367IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndPrinting);
368IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnPreparePrinting);
369IMP_PYCALLBACK_BOOL_INT_pure(wxPyPrintout, wxPrintout, OnPrintPage);
370IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage);
371
372
bb0054cd
RD
373%}
374
375
ab1f7d2a
RD
376MustHaveApp(wxPyPrintout);
377
bb0054cd 378// Now define the custom class for SWIGging
1b8c7ba6
RD
379%rename(Printout) wxPyPrintout;
380class wxPyPrintout : public wxObject {
bb0054cd 381public:
2b9048c5 382 %pythonAppend wxPyPrintout "self._setCallbackInfo(self, Printout)"
bb0054cd 383
d14a1e28
RD
384 wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr);
385 //~wxPyPrintout(); wxPrintPreview object takes ownership...
386
0122b7e3 387 void _setCallbackInfo(PyObject* self, PyObject* _class);
bb0054cd 388
d14a1e28
RD
389
390 wxString GetTitle() const;
bb0054cd 391 wxDC* GetDC();
d14a1e28
RD
392 void SetDC(wxDC *dc);
393
d14a1e28 394 void SetPageSizePixels(int w, int h);
322913ce
RD
395 DocDeclA(
396 void, GetPageSizePixels(int *OUTPUT, int *OUTPUT),
397 "GetPageSizePixels() -> (w, h)");
d14a1e28
RD
398
399 void SetPageSizeMM(int w, int h);
322913ce
RD
400 DocDeclA(
401 void, GetPageSizeMM(int *OUTPUT, int *OUTPUT),
402 "GetPageSizeMM() -> (w, h)");
d14a1e28
RD
403
404 void SetPPIScreen(int x, int y);
322913ce
RD
405 DocDeclA(
406 void, GetPPIScreen(int *OUTPUT, int *OUTPUT),
407 "GetPPIScreen() -> (x,y)");
d14a1e28
RD
408
409 void SetPPIPrinter(int x, int y);
322913ce
RD
410 DocDeclA(
411 void, GetPPIPrinter(int *OUTPUT, int *OUTPUT),
412 "GetPPIPrinter() -> (x,y)");
d14a1e28 413
bb0054cd 414 bool IsPreview();
d14a1e28 415 void SetIsPreview(bool p);
bb0054cd 416
d14a1e28 417
bb0054cd
RD
418 bool base_OnBeginDocument(int startPage, int endPage);
419 void base_OnEndDocument();
420 void base_OnBeginPrinting();
421 void base_OnEndPrinting();
422 void base_OnPreparePrinting();
bb0054cd 423 bool base_HasPage(int page);
322913ce
RD
424 DocDeclA(
425 void, base_GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
426 "base_GetPageInfo() -> (minPage, maxPage, pageFrom, pageTo)");
bb0054cd
RD
427};
428
d14a1e28 429//---------------------------------------------------------------------------
1fded56b 430
1fded56b 431
1fded56b 432
ab1f7d2a
RD
433MustHaveApp(wxPreviewCanvas);
434
d14a1e28 435class wxPreviewCanvas: public wxScrolledWindow
1fded56b
RD
436{
437public:
2b9048c5 438 %pythonAppend wxPreviewCanvas "self._setOORInfo(self)"
bb0054cd 439
d14a1e28
RD
440 wxPreviewCanvas(wxPrintPreview *preview,
441 wxWindow *parent,
442 const wxPoint& pos = wxDefaultPosition,
443 const wxSize& size = wxDefaultSize,
444 long style = 0,
445 const wxString& name = wxPyPreviewCanvasNameStr);
bb0054cd
RD
446};
447
bb0054cd 448
ab1f7d2a
RD
449MustHaveApp(wxPreviewFrame);
450
bb0054cd
RD
451class wxPreviewFrame : public wxFrame {
452public:
2b9048c5 453 %pythonAppend wxPreviewFrame "self._setOORInfo(self)"
d14a1e28 454
bb0054cd 455 wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
b68dc582
RD
456 const wxPoint& pos = wxDefaultPosition,
457 const wxSize& size = wxDefaultSize,
bb0054cd 458 long style = wxDEFAULT_FRAME_STYLE,
137b5242 459 const wxString& name = wxPyFrameNameStr);
bb0054cd 460
bb0054cd 461 void Initialize();
1fded56b
RD
462 void CreateControlBar();
463 void CreateCanvas();
3ef86e32
RD
464
465 wxPreviewControlBar* GetControlBar() const;
1fded56b
RD
466};
467
468
1fded56b
RD
469
470enum {
471 wxPREVIEW_PRINT,
472 wxPREVIEW_PREVIOUS,
473 wxPREVIEW_NEXT,
474 wxPREVIEW_ZOOM,
475 wxPREVIEW_FIRST,
476 wxPREVIEW_LAST,
477 wxPREVIEW_GOTO,
478 wxPREVIEW_DEFAULT,
479
480 wxID_PREVIEW_CLOSE,
481 wxID_PREVIEW_NEXT,
482 wxID_PREVIEW_PREVIOUS,
483 wxID_PREVIEW_PRINT,
484 wxID_PREVIEW_ZOOM,
485 wxID_PREVIEW_FIRST,
486 wxID_PREVIEW_LAST,
487 wxID_PREVIEW_GOTO
488};
489
ab1f7d2a
RD
490MustHaveApp(wxPreviewControlBar);
491
1fded56b
RD
492class wxPreviewControlBar: public wxPanel
493{
494public:
2b9048c5 495 %pythonAppend wxPreviewControlBar "self._setOORInfo(self)"
d14a1e28 496
1fded56b
RD
497 wxPreviewControlBar(wxPrintPreview *preview,
498 long buttons,
499 wxWindow *parent,
500 const wxPoint& pos = wxDefaultPosition,
501 const wxSize& size = wxDefaultSize,
3ef86e32 502 long style = wxTAB_TRAVERSAL,
1fded56b 503 const wxString& name = wxPyPanelNameStr);
1fded56b
RD
504
505 int GetZoomControl();
506 void SetZoomControl(int zoom);
507 wxPrintPreview* GetPrintPreview();
508
509 void OnNext();
510 void OnPrevious();
511 void OnFirst();
512 void OnLast();
513 void OnGoto();
514};
515
516
d14a1e28
RD
517
518//---------------------------------------------------------------------------
519
ab1f7d2a
RD
520MustHaveApp(wxPrintPreview);
521
d14a1e28
RD
522class wxPrintPreview : public wxObject {
523public:
d88d4683 524 %nokwargs wxPrintPreview;
d14a1e28
RD
525 wxPrintPreview(wxPyPrintout* printout,
526 wxPyPrintout* printoutForPrinting,
d88d4683
RD
527 wxPrintDialogData *data=NULL);
528 wxPrintPreview(wxPyPrintout* printout,
529 wxPyPrintout* printoutForPrinting,
530 wxPrintData* data);
d14a1e28
RD
531
532 virtual bool SetCurrentPage(int pageNum);
533 int GetCurrentPage();
534
535 void SetPrintout(wxPyPrintout *printout);
536 wxPyPrintout *GetPrintout();
537 wxPyPrintout *GetPrintoutForPrinting();
538
539 void SetFrame(wxFrame *frame);
540 void SetCanvas(wxPreviewCanvas *canvas);
541
542 virtual wxFrame *GetFrame();
543 virtual wxPreviewCanvas *GetCanvas();
544
545 // The preview canvas should call this from OnPaint
546 virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
547
548 // This draws a blank page onto the preview canvas
549 virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
550
551 // This is called by wxPrintPreview to render a page into a wxMemoryDC.
552 virtual bool RenderPage(int pageNum);
553
554 // Adjusts the scrollbars for the current scale
555 virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
556
557 wxPrintDialogData& GetPrintDialogData();
558
559 virtual void SetZoom(int percent);
560 int GetZoom();
561
562 int GetMaxPage();
563 int GetMinPage();
564
565 bool Ok();
566 void SetOk(bool ok);
567
568 virtual bool Print(bool interactive);
569 virtual void DetermineScaling();
570
571 %pythoncode { def __nonzero__(self): return self.Ok() }
572};
573
574
575
576//---------------------------------------------------------------------------
577
1fded56b
RD
578// Python-derivable versions of the above preview classes
579
580%{
3ef86e32 581
a72f4631
RD
582#define DEC_PYCALLBACK_BOOL_PREWINDC(CBNAME) \
583 bool CBNAME(wxPreviewCanvas* a, wxDC& b); \
3ef86e32
RD
584 bool base_##CBNAME(wxPreviewCanvas* a, wxDC& b)
585
586
a72f4631
RD
587#define IMP_PYCALLBACK_BOOL_PREWINDC(CLASS, PCLASS, CBNAME) \
588 bool CLASS::CBNAME(wxPreviewCanvas* a, wxDC& b) { \
589 bool rval=false; \
590 bool found; \
591 bool blocked = wxPyBeginBlockThreads(); \
592 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
593 PyObject* win = wxPyMake_wxObject(a,false); \
594 PyObject* dc = wxPyMake_wxObject(&b,false); \
595 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc)); \
596 Py_DECREF(win); \
597 Py_DECREF(dc); \
598 } \
599 wxPyEndBlockThreads(blocked); \
600 if (! found) \
601 rval = PCLASS::CBNAME(a, b); \
602 return rval; \
603 } \
604 bool CLASS::base_##CBNAME(wxPreviewCanvas* a, wxDC& b) { \
605 return PCLASS::CBNAME(a, b); \
3ef86e32
RD
606 }
607
608
609
610
1fded56b
RD
611class wxPyPrintPreview : public wxPrintPreview
612{
613 DECLARE_CLASS(wxPyPrintPreview)
614public:
d88d4683
RD
615 wxPyPrintPreview(wxPyPrintout* printout,
616 wxPyPrintout* printoutForPrinting,
617 wxPrintDialogData* data=NULL)
618 : wxPrintPreview(printout, printoutForPrinting, data)
619 {}
1fded56b
RD
620 wxPyPrintPreview(wxPyPrintout* printout,
621 wxPyPrintout* printoutForPrinting,
622 wxPrintData* data=NULL)
623 : wxPrintPreview(printout, printoutForPrinting, data)
624 {}
625
626 DEC_PYCALLBACK_BOOL_INT(SetCurrentPage);
3ef86e32
RD
627 DEC_PYCALLBACK_BOOL_PREWINDC(PaintPage);
628 DEC_PYCALLBACK_BOOL_PREWINDC(DrawBlankPage);
1fded56b
RD
629 DEC_PYCALLBACK_BOOL_INT(RenderPage);
630 DEC_PYCALLBACK_VOID_INT(SetZoom);
631 DEC_PYCALLBACK_BOOL_BOOL(Print);
632 DEC_PYCALLBACK_VOID_(DetermineScaling);
633
634 PYPRIVATE;
635};
636
637// Stupid renamed classes... Fix this in 2.5...
638#if defined(__WXMSW__)
639IMPLEMENT_CLASS( wxPyPrintPreview, wxWindowsPrintPreview );
640#elif defined(__WXMAC__)
641IMPLEMENT_CLASS( wxPyPrintPreview, wxMacPrintPreview );
642#else
643IMPLEMENT_CLASS( wxPyPrintPreview, wxPostScriptPrintPreview );
644#endif
645
3ef86e32
RD
646IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, SetCurrentPage);
647IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, PaintPage);
648IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, DrawBlankPage);
649IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, RenderPage);
650IMP_PYCALLBACK_VOID_INT (wxPyPrintPreview, wxPrintPreview, SetZoom);
651IMP_PYCALLBACK_BOOL_BOOL (wxPyPrintPreview, wxPrintPreview, Print);
652IMP_PYCALLBACK_VOID_ (wxPyPrintPreview, wxPrintPreview, DetermineScaling);
1fded56b
RD
653%}
654
655
ab1f7d2a
RD
656MustHaveApp(wxPyPrintPreview);
657
1fded56b
RD
658class wxPyPrintPreview : public wxPrintPreview
659{
660public:
2b9048c5 661 %pythonAppend wxPyPrintPreview "self._setCallbackInfo(self, PyPrintPreview)"
d88d4683
RD
662 %nokwargs wxPyPrintPreview;
663 wxPyPrintPreview(wxPyPrintout* printout,
664 wxPyPrintout* printoutForPrinting,
665 wxPrintDialogData* data=NULL);
1fded56b
RD
666 wxPyPrintPreview(wxPyPrintout* printout,
667 wxPyPrintout* printoutForPrinting,
d88d4683 668 wxPrintData* data);
1fded56b
RD
669
670 void _setCallbackInfo(PyObject* self, PyObject* _class);
d14a1e28 671
1fded56b 672 bool base_SetCurrentPage(int pageNum);
3ef86e32
RD
673 bool base_PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
674 bool base_DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
1fded56b
RD
675 bool base_RenderPage(int pageNum);
676 void base_SetZoom(int percent);
677 bool base_Print(bool interactive);
678 void base_DetermineScaling();
679};
680
681
bb0054cd 682
bb0054cd 683
1fded56b
RD
684%{
685class wxPyPreviewFrame : public wxPreviewFrame
686{
687 DECLARE_CLASS(wxPyPreviewFrame);
688public:
689 wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
690 const wxString& title,
691 const wxPoint& pos = wxDefaultPosition,
692 const wxSize& size = wxDefaultSize,
693 long style = wxDEFAULT_FRAME_STYLE,
694 const wxString& name = wxPyFrameNameStr)
695 : wxPreviewFrame(preview, parent, title, pos, size, style, name)
696 {}
697
3ef86e32 698 void SetPreviewCanvas(wxPreviewCanvas* canvas) { m_previewCanvas = canvas; }
1fded56b
RD
699 void SetControlBar(wxPreviewControlBar* bar) { m_controlBar = bar; }
700
701 DEC_PYCALLBACK_VOID_(Initialize);
702 DEC_PYCALLBACK_VOID_(CreateCanvas);
703 DEC_PYCALLBACK_VOID_(CreateControlBar);
704
705 PYPRIVATE;
706};
707
708IMPLEMENT_CLASS(wxPyPreviewFrame, wxPreviewFrame);
709
710IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, Initialize);
711IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateCanvas);
712IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateControlBar);
713%}
714
d14a1e28 715
ab1f7d2a
RD
716MustHaveApp(wxPyPreviewFrame);
717
1fded56b
RD
718class wxPyPreviewFrame : public wxPreviewFrame
719{
720public:
2b9048c5 721 %pythonAppend wxPyPreviewFrame "self._setCallbackInfo(self, PyPreviewFrame); self._setOORInfo(self)"
d14a1e28 722
1fded56b
RD
723 wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
724 const wxString& title,
725 const wxPoint& pos = wxDefaultPosition,
726 const wxSize& size = wxDefaultSize,
727 long style = wxDEFAULT_FRAME_STYLE,
728 const wxString& name = wxPyFrameNameStr);
729
730 void _setCallbackInfo(PyObject* self, PyObject* _class);
1fded56b 731
3ef86e32 732 void SetPreviewCanvas(wxPreviewCanvas* canvas);
1fded56b
RD
733 void SetControlBar(wxPreviewControlBar* bar);
734
735 void base_Initialize();
736 void base_CreateCanvas();
737 void base_CreateControlBar();
bb0054cd
RD
738};
739
1fded56b
RD
740
741
742
743%{
744class wxPyPreviewControlBar : public wxPreviewControlBar
745{
746 DECLARE_CLASS(wxPyPreviewControlBar);
747public:
748 wxPyPreviewControlBar(wxPrintPreview *preview,
749 long buttons,
750 wxWindow *parent,
751 const wxPoint& pos = wxDefaultPosition,
752 const wxSize& size = wxDefaultSize,
753 long style = 0,
754 const wxString& name = wxPyPanelNameStr)
755 : wxPreviewControlBar(preview, buttons, parent, pos, size, style, name)
756 {}
757
758 void SetPrintPreview(wxPrintPreview* preview) { m_printPreview = preview; }
759
760 DEC_PYCALLBACK_VOID_(CreateButtons);
761 DEC_PYCALLBACK_VOID_INT(SetZoomControl);
762
763 PYPRIVATE;
764};
765
766IMPLEMENT_CLASS(wxPyPreviewControlBar, wxPreviewControlBar);
767IMP_PYCALLBACK_VOID_(wxPyPreviewControlBar, wxPreviewControlBar, CreateButtons);
768IMP_PYCALLBACK_VOID_INT(wxPyPreviewControlBar, wxPreviewControlBar, SetZoomControl);
769%}
770
d14a1e28 771
ab1f7d2a
RD
772MustHaveApp(wxPyPreviewControlBar);
773
1fded56b
RD
774class wxPyPreviewControlBar : public wxPreviewControlBar
775{
776public:
2b9048c5 777 %pythonAppend wxPyPreviewControlBar "self._setCallbackInfo(self, PyPreviewControlBar); self._setOORInfo(self)"
d14a1e28 778
1fded56b
RD
779 wxPyPreviewControlBar(wxPrintPreview *preview,
780 long buttons,
781 wxWindow *parent,
782 const wxPoint& pos = wxDefaultPosition,
783 const wxSize& size = wxDefaultSize,
784 long style = 0,
785 const wxString& name = wxPyPanelNameStr);
786
787 void _setCallbackInfo(PyObject* self, PyObject* _class);
1fded56b
RD
788
789 void SetPrintPreview(wxPrintPreview* preview);
790
791 void base_CreateButtons();
792 void base_SetZoomControl(int zoom);
793};
794
d14a1e28
RD
795//---------------------------------------------------------------------------
796//---------------------------------------------------------------------------
9416aa89
RD
797%init %{
798 wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
799%}
d14a1e28 800//---------------------------------------------------------------------------