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