]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_printfw.i
removed spaces; added WXDLLEXPORTs; make overlay classes non copiable
[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 IsOk();
74 %pythoncode { Ok = IsOk }
75
76 const wxString& GetPrinterName();
77 bool GetColour();
78 wxDuplexMode GetDuplex();
79 wxPaperSize GetPaperId();
80 const wxSize& GetPaperSize();
81
82 int GetQuality();
83 wxPrintBin GetBin();
84 wxPrintMode GetPrintMode() const;
85
86 void SetNoCopies(int v);
87 void SetCollate(bool flag);
88 void SetOrientation(int orient);
89
90 void SetPrinterName(const wxString& name);
91 void SetColour(bool colour);
92 void SetDuplex(wxDuplexMode duplex);
93 void SetPaperId(wxPaperSize sizeId);
94 void SetPaperSize(const wxSize& sz);
95 void SetQuality(int quality);
96 void SetBin(wxPrintBin bin);
97 void SetPrintMode(wxPrintMode printMode);
98
99 wxString GetFilename() const;
100 void SetFilename( const wxString &filename );
101
102 %pythoncode { def __nonzero__(self): return self.IsOk() }
103
104 //char* GetPrivData() const;
105 //int GetPrivDataLen() const;
106 //void SetPrivData( char *privData, int len );
107
108 %extend {
109 PyObject* GetPrivData() {
110 PyObject* data;
111 wxPyBlock_t blocked = wxPyBeginBlockThreads();
112 data = PyString_FromStringAndSize(self->GetPrivData(),
113 self->GetPrivDataLen());
114 wxPyEndBlockThreads(blocked);
115 return data;
116 }
117
118 void SetPrivData(PyObject* data) {
119 if (! PyString_Check(data)) {
120 wxPyBLOCK_THREADS(PyErr_SetString(PyExc_TypeError,
121 "Expected string object"));
122 return /* NULL */ ;
123 }
124
125 wxPyBlock_t blocked = wxPyBeginBlockThreads();
126 self->SetPrivData(PyString_AS_STRING(data), PyString_GET_SIZE(data));
127 wxPyEndBlockThreads(blocked);
128 }
129 }
130
131
132 // NOTE: These are now inside of #if WXWIN_COMPATIBILITY_2_4, so be
133 // prepared to remove them...
134
135 // PostScript-specific data
136 // WXWIN_COMPATIBILITY_2_4
137 #if 0
138 const wxString& GetPrinterCommand();
139 const wxString& GetPrinterOptions();
140 const wxString& GetPreviewCommand();
141 const wxString& GetFontMetricPath();
142 double GetPrinterScaleX();
143 double GetPrinterScaleY();
144 long GetPrinterTranslateX();
145 long GetPrinterTranslateY();
146 void SetPrinterCommand(const wxString& command);
147 void SetPrinterOptions(const wxString& options);
148 void SetPreviewCommand(const wxString& command);
149 void SetFontMetricPath(const wxString& path);
150 void SetPrinterScaleX(double x);
151 void SetPrinterScaleY(double y);
152 void SetPrinterScaling(double x, double y);
153 void SetPrinterTranslateX(long x);
154 void SetPrinterTranslateY(long y);
155 void SetPrinterTranslation(long x, long y);
156 #endif
157
158 %property(Bin, GetBin, SetBin, doc="See `GetBin` and `SetBin`");
159 %property(Collate, GetCollate, SetCollate, doc="See `GetCollate` and `SetCollate`");
160 %property(Colour, GetColour, SetColour, doc="See `GetColour` and `SetColour`");
161 %property(Duplex, GetDuplex, SetDuplex, doc="See `GetDuplex` and `SetDuplex`");
162 %property(Filename, GetFilename, SetFilename, doc="See `GetFilename` and `SetFilename`");
163 %property(NoCopies, GetNoCopies, SetNoCopies, doc="See `GetNoCopies` and `SetNoCopies`");
164 %property(Orientation, GetOrientation, SetOrientation, doc="See `GetOrientation` and `SetOrientation`");
165 %property(PaperId, GetPaperId, SetPaperId, doc="See `GetPaperId` and `SetPaperId`");
166 %property(PaperSize, GetPaperSize, SetPaperSize, doc="See `GetPaperSize` and `SetPaperSize`");
167 %property(PrintMode, GetPrintMode, SetPrintMode, doc="See `GetPrintMode` and `SetPrintMode`");
168 %property(PrinterName, GetPrinterName, SetPrinterName, doc="See `GetPrinterName` and `SetPrinterName`");
169 %property(PrivData, GetPrivData, SetPrivData, doc="See `GetPrivData` and `SetPrivData`");
170 %property(Quality, GetQuality, SetQuality, doc="See `GetQuality` and `SetQuality`");
171 };
172
173 //---------------------------------------------------------------------------
174
175 class wxPageSetupDialogData : public wxObject {
176 public:
177 %nokwargs wxPageSetupDialogData;
178 wxPageSetupDialogData();
179 wxPageSetupDialogData(const wxPageSetupDialogData& data); // for making copies
180 wxPageSetupDialogData(const wxPrintData& data);
181 ~wxPageSetupDialogData();
182
183 void EnableHelp(bool flag);
184 void EnableMargins(bool flag);
185 void EnableOrientation(bool flag);
186 void EnablePaper(bool flag);
187 void EnablePrinter(bool flag);
188
189 bool GetDefaultMinMargins();
190 bool GetEnableMargins();
191 bool GetEnableOrientation();
192 bool GetEnablePaper();
193 bool GetEnablePrinter();
194 bool GetEnableHelp();
195 bool GetDefaultInfo();
196 wxPoint GetMarginTopLeft();
197 wxPoint GetMarginBottomRight();
198 wxPoint GetMinMarginTopLeft();
199 wxPoint GetMinMarginBottomRight();
200 wxPaperSize GetPaperId();
201 wxSize GetPaperSize();
202
203 wxPrintData& GetPrintData();
204
205 bool IsOk();
206 %pythoncode { Ok = IsOk }
207
208 void SetDefaultInfo(bool flag);
209 void SetDefaultMinMargins(bool flag);
210 void SetMarginTopLeft(const wxPoint& pt);
211 void SetMarginBottomRight(const wxPoint& pt);
212 void SetMinMarginTopLeft(const wxPoint& pt);
213 void SetMinMarginBottomRight(const wxPoint& pt);
214 void SetPaperId(wxPaperSize id);
215 void SetPaperSize(const wxSize& size);
216
217 void SetPrintData(const wxPrintData& printData);
218
219 // Use paper size defined in this object to set the wxPrintData
220 // paper id
221 void CalculateIdFromPaperSize();
222
223 // Use paper id in wxPrintData to set this object's paper size
224 void CalculatePaperSizeFromId();
225
226 %pythoncode { def __nonzero__(self): return self.IsOk() }
227
228 %property(DefaultInfo, GetDefaultInfo, SetDefaultInfo, doc="See `GetDefaultInfo` and `SetDefaultInfo`");
229 %property(DefaultMinMargins, GetDefaultMinMargins, SetDefaultMinMargins, doc="See `GetDefaultMinMargins` and `SetDefaultMinMargins`");
230
231 // %property(EnableHelp, GetEnableHelp, doc="See `GetEnableHelp`");
232 // %property(EnableMargins, GetEnableMargins, doc="See `GetEnableMargins`");
233 // %property(EnableOrientation, GetEnableOrientation, doc="See `GetEnableOrientation`");
234 // %property(EnablePaper, GetEnablePaper, doc="See `GetEnablePaper`");
235 // %property(EnablePrinter, GetEnablePrinter, doc="See `GetEnablePrinter`");
236
237 %property(MarginBottomRight, GetMarginBottomRight, SetMarginBottomRight, doc="See `GetMarginBottomRight` and `SetMarginBottomRight`");
238 %property(MarginTopLeft, GetMarginTopLeft, SetMarginTopLeft, doc="See `GetMarginTopLeft` and `SetMarginTopLeft`");
239 %property(MinMarginBottomRight, GetMinMarginBottomRight, SetMinMarginBottomRight, doc="See `GetMinMarginBottomRight` and `SetMinMarginBottomRight`");
240 %property(MinMarginTopLeft, GetMinMarginTopLeft, SetMinMarginTopLeft, doc="See `GetMinMarginTopLeft` and `SetMinMarginTopLeft`");
241 %property(PaperId, GetPaperId, SetPaperId, doc="See `GetPaperId` and `SetPaperId`");
242 %property(PaperSize, GetPaperSize, SetPaperSize, doc="See `GetPaperSize` and `SetPaperSize`");
243 %property(PrintData, GetPrintData, SetPrintData, doc="See `GetPrintData` and `SetPrintData`");
244
245 };
246
247
248
249 // NOTE: Contrary to it's name, this class doesn't derive from wxDialog. It
250 // is a facade in front of a platform-specific (native dialog) provided by the
251 // wxPrintFactory.
252
253 MustHaveApp(wxPageSetupDialog);
254
255 class wxPageSetupDialog : public wxObject
256 {
257 public:
258 wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL);
259 ~wxPageSetupDialog();
260
261 wxPageSetupDialogData& GetPageSetupData();
262 wxPageSetupDialogData& GetPageSetupDialogData();
263 int ShowModal();
264
265 %pythoncode { def Destroy(self): pass }
266
267 %property(PageSetupData, GetPageSetupData, doc="See `GetPageSetupData`");
268 %property(PageSetupDialogData, GetPageSetupDialogData, doc="See `GetPageSetupDialogData`");
269
270 };
271
272 //---------------------------------------------------------------------------
273
274
275 class wxPrintDialogData : public wxObject {
276 public:
277 %nokwargs wxPrintDialogData;
278 wxPrintDialogData();
279 wxPrintDialogData(const wxPrintData& printData);
280 wxPrintDialogData(const wxPrintDialogData& printData); // for making copies
281 ~wxPrintDialogData();
282
283 int GetFromPage() const;
284 int GetToPage() const;
285 int GetMinPage() const;
286 int GetMaxPage() const;
287 int GetNoCopies() const;
288 bool GetAllPages() const;
289 bool GetSelection() const;
290 bool GetCollate() const;
291 bool GetPrintToFile() const;
292
293 // WXWIN_COMPATIBILITY_2_4
294 #if 0
295 bool GetSetupDialog() const;
296 void SetSetupDialog(bool flag);
297 #endif
298 void SetFromPage(int v);
299 void SetToPage(int v);
300 void SetMinPage(int v);
301 void SetMaxPage(int v);
302 void SetNoCopies(int v);
303 void SetAllPages(bool flag);
304 void SetSelection(bool flag);
305 void SetCollate(bool flag);
306 void SetPrintToFile(bool flag);
307
308 void EnablePrintToFile(bool flag);
309 void EnableSelection(bool flag);
310 void EnablePageNumbers(bool flag);
311 void EnableHelp(bool flag);
312
313 bool GetEnablePrintToFile() const;
314 bool GetEnableSelection() const;
315 bool GetEnablePageNumbers() const;
316 bool GetEnableHelp() const;
317
318 // Is this data OK for showing the print dialog?
319 bool IsOk() const;
320 %pythoncode { Ok = IsOk }
321
322
323 wxPrintData& GetPrintData();
324 void SetPrintData(const wxPrintData& printData);
325
326 %pythoncode { def __nonzero__(self): return self.IsOk() }
327
328 %property(AllPages, GetAllPages, SetAllPages, doc="See `GetAllPages` and `SetAllPages`");
329 %property(Collate, GetCollate, SetCollate, doc="See `GetCollate` and `SetCollate`");
330 // %property(EnableHelp, GetEnableHelp, doc="See `GetEnableHelp`");
331 // %property(EnablePageNumbers, GetEnablePageNumbers, doc="See `GetEnablePageNumbers`");
332 // %property(EnablePrintToFile, GetEnablePrintToFile, doc="See `GetEnablePrintToFile`");
333 // %property(EnableSelection, GetEnableSelection, doc="See `GetEnableSelection`");
334 %property(FromPage, GetFromPage, SetFromPage, doc="See `GetFromPage` and `SetFromPage`");
335 %property(MaxPage, GetMaxPage, SetMaxPage, doc="See `GetMaxPage` and `SetMaxPage`");
336 %property(MinPage, GetMinPage, SetMinPage, doc="See `GetMinPage` and `SetMinPage`");
337 %property(NoCopies, GetNoCopies, SetNoCopies, doc="See `GetNoCopies` and `SetNoCopies`");
338 %property(PrintData, GetPrintData, SetPrintData, doc="See `GetPrintData` and `SetPrintData`");
339 %property(PrintToFile, GetPrintToFile, SetPrintToFile, doc="See `GetPrintToFile` and `SetPrintToFile`");
340 %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`");
341 %property(ToPage, GetToPage, SetToPage, doc="See `GetToPage` and `SetToPage`");
342 };
343
344
345
346 MustHaveApp(wxPrintDialog);
347
348
349 // NOTE: Contrary to it's name, this class doesn't derive from wxDialog. It
350 // is a facade in front of a platform-specific (native dialog) provided by the
351 // wxPrintFactory.
352
353 class wxPrintDialog : public wxObject {
354 public:
355 wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL);
356
357 // TODO?: wxPrintDialog(wxWindow *parent, wxPrintData* data);
358
359 ~wxPrintDialog();
360
361 virtual int ShowModal();
362
363 virtual wxPrintDialogData& GetPrintDialogData();
364 virtual wxPrintData& GetPrintData();
365
366 %newobject GetPrintDC;
367 virtual wxDC *GetPrintDC();
368
369 %pythoncode { def Destroy(self): pass }
370
371 %property(PrintDC, GetPrintDC, doc="See `GetPrintDC`");
372 %property(PrintData, GetPrintData, doc="See `GetPrintData`");
373 %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
374 };
375
376
377 //---------------------------------------------------------------------------
378 //---------------------------------------------------------------------------
379
380
381 enum wxPrinterError
382 {
383 wxPRINTER_NO_ERROR = 0,
384 wxPRINTER_CANCELLED,
385 wxPRINTER_ERROR
386 };
387
388
389 MustHaveApp(wxPrinter);
390
391 class wxPrinter : public wxObject {
392 public:
393 wxPrinter(wxPrintDialogData* data = NULL);
394 ~wxPrinter();
395
396 virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPyPrintout *printout);
397 virtual void ReportError(wxWindow *parent, wxPyPrintout *printout, const wxString& message);
398
399 virtual bool Setup(wxWindow *parent);
400 virtual bool Print(wxWindow *parent, wxPyPrintout *printout, bool prompt = true);
401 virtual wxDC* PrintDialog(wxWindow *parent);
402
403 virtual wxPrintDialogData& GetPrintDialogData() const;
404
405 bool GetAbort();
406 static wxPrinterError GetLastError();
407
408 %property(Abort, GetAbort, doc="See `GetAbort`");
409 %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
410 };
411
412
413 //---------------------------------------------------------------------------
414 // Custom wxPrintout class that knows how to call python, See implementation in
415 // include/sx/wxPython/printfw.h
416
417 %{
418
419 IMPLEMENT_ABSTRACT_CLASS(wxPyPrintout, wxPrintout);
420
421 // Since this one would be tough and ugly to do with the Macros...
422 void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) {
423 bool hadErr = false;
424 bool found;
425
426 wxPyBlock_t blocked = wxPyBeginBlockThreads();
427 if ((found = wxPyCBH_findCallback(m_myInst, "GetPageInfo"))) {
428 PyObject* result = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
429 if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) {
430 PyObject* val;
431
432 val = PyTuple_GetItem(result, 0);
433 if (PyInt_Check(val)) *minPage = PyInt_AsLong(val);
434 else hadErr = true;
435
436 val = PyTuple_GetItem(result, 1);
437 if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val);
438 else hadErr = true;
439
440 val = PyTuple_GetItem(result, 2);
441 if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val);
442 else hadErr = true;
443
444 val = PyTuple_GetItem(result, 3);
445 if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val);
446 else hadErr = true;
447 }
448 else
449 hadErr = true;
450
451 if (hadErr) {
452 PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers.");
453 PyErr_Print();
454 }
455 Py_DECREF(result);
456 }
457 wxPyEndBlockThreads(blocked);
458 if (! found)
459 wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo);
460 }
461
462
463
464 IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument);
465 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument);
466 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnBeginPrinting);
467 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndPrinting);
468 IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnPreparePrinting);
469 IMP_PYCALLBACK_BOOL_INT_pure(wxPyPrintout, wxPrintout, OnPrintPage);
470 IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage);
471
472
473 %}
474
475
476 MustHaveApp(wxPyPrintout);
477
478 // Now define the custom class for SWIGging
479 %rename(Printout) wxPyPrintout;
480 class wxPyPrintout : public wxObject {
481 public:
482 %pythonAppend wxPyPrintout "self._setCallbackInfo(self, Printout)"
483 %typemap(out) wxPyPrintout*; // turn off this typemap
484
485 wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr);
486 ~wxPyPrintout();
487
488 // Turn it back on again
489 %typemap(out) wxPyPrintout* { $result = wxPyMake_wxObject($1, $owner); }
490
491 void _setCallbackInfo(PyObject* self, PyObject* _class);
492
493
494 wxString GetTitle() const;
495 wxDC* GetDC();
496 void SetDC(wxDC *dc);
497
498 void SetPageSizePixels(int w, int h);
499 DocDeclA(
500 void, GetPageSizePixels(int *OUTPUT, int *OUTPUT),
501 "GetPageSizePixels() -> (w, h)");
502
503 void SetPageSizeMM(int w, int h);
504 DocDeclA(
505 void, GetPageSizeMM(int *OUTPUT, int *OUTPUT),
506 "GetPageSizeMM() -> (w, h)");
507
508 void SetPPIScreen(int x, int y);
509 DocDeclA(
510 void, GetPPIScreen(int *OUTPUT, int *OUTPUT),
511 "GetPPIScreen() -> (x,y)");
512
513 void SetPPIPrinter(int x, int y);
514 DocDeclA(
515 void, GetPPIPrinter(int *OUTPUT, int *OUTPUT),
516 "GetPPIPrinter() -> (x,y)");
517
518 bool IsPreview();
519 void SetIsPreview(bool p);
520
521
522 bool OnBeginDocument(int startPage, int endPage);
523 void OnEndDocument();
524 void OnBeginPrinting();
525 void OnEndPrinting();
526 void OnPreparePrinting();
527 bool HasPage(int page);
528 DocDeclA(
529 void, GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
530 "GetPageInfo() -> (minPage, maxPage, pageFrom, pageTo)");
531
532 %MAKE_BASE_FUNC(Printout, OnBeginDocument);
533 %MAKE_BASE_FUNC(Printout, OnEndDocument);
534 %MAKE_BASE_FUNC(Printout, OnBeginPrinting);
535 %MAKE_BASE_FUNC(Printout, OnEndPrinting);
536 %MAKE_BASE_FUNC(Printout, OnPreparePrinting);
537 %MAKE_BASE_FUNC(Printout, GetPageInfo);
538
539
540 %property(DC, GetDC, SetDC, doc="See `GetDC` and `SetDC`");
541 %property(PPIPrinter, GetPPIPrinter, SetPPIPrinter, doc="See `GetPPIPrinter` and `SetPPIPrinter`");
542 %property(PPIScreen, GetPPIScreen, SetPPIScreen, doc="See `GetPPIScreen` and `SetPPIScreen`");
543 %property(PageSizeMM, GetPageSizeMM, SetPageSizeMM, doc="See `GetPageSizeMM` and `SetPageSizeMM`");
544 %property(PageSizePixels, GetPageSizePixels, SetPageSizePixels, doc="See `GetPageSizePixels` and `SetPageSizePixels`");
545 %property(Title, GetTitle, doc="See `GetTitle`");
546 };
547
548 //---------------------------------------------------------------------------
549
550
551
552 MustHaveApp(wxPreviewCanvas);
553
554 class wxPreviewCanvas: public wxScrolledWindow
555 {
556 public:
557 %pythonAppend wxPreviewCanvas "self._setOORInfo(self)"
558
559 wxPreviewCanvas(wxPrintPreview *preview,
560 wxWindow *parent,
561 const wxPoint& pos = wxDefaultPosition,
562 const wxSize& size = wxDefaultSize,
563 long style = 0,
564 const wxString& name = wxPyPreviewCanvasNameStr);
565 };
566
567
568 MustHaveApp(wxPreviewFrame);
569
570 class wxPreviewFrame : public wxFrame {
571 public:
572 %disownarg(wxPrintPreview*);
573
574 %pythonAppend wxPreviewFrame "self._setOORInfo(self)"
575 wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
576 const wxPoint& pos = wxDefaultPosition,
577 const wxSize& size = wxDefaultSize,
578 long style = wxDEFAULT_FRAME_STYLE,
579 const wxString& name = wxPyFrameNameStr);
580
581 %cleardisown(wxPrintPreview*);
582
583 void Initialize();
584 void CreateControlBar();
585 void CreateCanvas();
586
587 wxPreviewControlBar* GetControlBar() const;
588
589 %property(ControlBar, GetControlBar, doc="See `GetControlBar`");
590 };
591
592
593
594 enum {
595 wxPREVIEW_PRINT,
596 wxPREVIEW_PREVIOUS,
597 wxPREVIEW_NEXT,
598 wxPREVIEW_ZOOM,
599 wxPREVIEW_FIRST,
600 wxPREVIEW_LAST,
601 wxPREVIEW_GOTO,
602 wxPREVIEW_DEFAULT,
603
604 wxID_PREVIEW_CLOSE,
605 wxID_PREVIEW_NEXT,
606 wxID_PREVIEW_PREVIOUS,
607 wxID_PREVIEW_PRINT,
608 wxID_PREVIEW_ZOOM,
609 wxID_PREVIEW_FIRST,
610 wxID_PREVIEW_LAST,
611 wxID_PREVIEW_GOTO
612 };
613
614 MustHaveApp(wxPreviewControlBar);
615
616 class wxPreviewControlBar: public wxPanel
617 {
618 public:
619 %pythonAppend wxPreviewControlBar "self._setOORInfo(self)"
620
621 wxPreviewControlBar(wxPrintPreview *preview,
622 long buttons,
623 wxWindow *parent,
624 const wxPoint& pos = wxDefaultPosition,
625 const wxSize& size = wxDefaultSize,
626 long style = wxTAB_TRAVERSAL,
627 const wxString& name = wxPyPanelNameStr);
628
629 int GetZoomControl();
630 void SetZoomControl(int zoom);
631 wxPrintPreview* GetPrintPreview();
632
633 void OnNext();
634 void OnPrevious();
635 void OnFirst();
636 void OnLast();
637 void OnGoto();
638
639 %property(PrintPreview, GetPrintPreview, doc="See `GetPrintPreview`");
640 %property(ZoomControl, GetZoomControl, SetZoomControl, doc="See `GetZoomControl` and `SetZoomControl`");
641 };
642
643
644
645 //---------------------------------------------------------------------------
646
647 MustHaveApp(wxPrintPreview);
648
649 class wxPrintPreview : public wxObject {
650 public:
651 %disownarg(wxPyPrintout*);
652
653 %nokwargs wxPrintPreview;
654 wxPrintPreview(wxPyPrintout* printout,
655 wxPyPrintout* printoutForPrinting,
656 wxPrintDialogData *data=NULL);
657 wxPrintPreview(wxPyPrintout* printout,
658 wxPyPrintout* printoutForPrinting,
659 wxPrintData* data);
660
661 ~wxPrintPreview();
662
663 virtual bool SetCurrentPage(int pageNum);
664 int GetCurrentPage();
665
666 void SetPrintout(wxPyPrintout *printout);
667 wxPyPrintout *GetPrintout();
668 wxPyPrintout *GetPrintoutForPrinting();
669
670 %cleardisown(wxPyPrintout*);
671
672 void SetFrame(wxFrame *frame);
673 void SetCanvas(wxPreviewCanvas *canvas);
674
675 virtual wxFrame *GetFrame();
676 virtual wxPreviewCanvas *GetCanvas();
677
678 // The preview canvas should call this from OnPaint
679 virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
680
681 // This draws a blank page onto the preview canvas
682 virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
683
684 // This is called by wxPrintPreview to render a page into a wxMemoryDC.
685 virtual bool RenderPage(int pageNum);
686
687 // Adjusts the scrollbars for the current scale
688 virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
689
690 wxPrintDialogData& GetPrintDialogData();
691
692 virtual void SetZoom(int percent);
693 int GetZoom();
694
695 int GetMaxPage();
696 int GetMinPage();
697
698 bool IsOk();
699 %pythoncode { Ok = IsOk }
700 void SetOk(bool ok);
701
702 virtual bool Print(bool interactive);
703 virtual void DetermineScaling();
704
705 %pythoncode { def __nonzero__(self): return self.IsOk() }
706
707 %property(Canvas, GetCanvas, SetCanvas, doc="See `GetCanvas` and `SetCanvas`");
708 %property(CurrentPage, GetCurrentPage, SetCurrentPage, doc="See `GetCurrentPage` and `SetCurrentPage`");
709 %property(Frame, GetFrame, SetFrame, doc="See `GetFrame` and `SetFrame`");
710 %property(MaxPage, GetMaxPage, doc="See `GetMaxPage`");
711 %property(MinPage, GetMinPage, doc="See `GetMinPage`");
712 %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
713 %property(Printout, GetPrintout, SetPrintout, doc="See `GetPrintout` and `SetPrintout`");
714 %property(PrintoutForPrinting, GetPrintoutForPrinting, doc="See `GetPrintoutForPrinting`");
715 %property(Zoom, GetZoom, SetZoom, doc="See `GetZoom` and `SetZoom`");
716 };
717
718
719
720 //---------------------------------------------------------------------------
721
722 // Python-derivable versions of the above preview classes
723
724 %{
725
726 #define DEC_PYCALLBACK_BOOL_PREWINDC(CBNAME) \
727 bool CBNAME(wxPreviewCanvas* a, wxDC& b)
728
729
730 #define IMP_PYCALLBACK_BOOL_PREWINDC(CLASS, PCLASS, CBNAME) \
731 bool CLASS::CBNAME(wxPreviewCanvas* a, wxDC& b) { \
732 bool rval=false; \
733 bool found; \
734 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
735 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
736 PyObject* win = wxPyMake_wxObject(a,false); \
737 PyObject* dc = wxPyMake_wxObject(&b,false); \
738 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc)); \
739 Py_DECREF(win); \
740 Py_DECREF(dc); \
741 } \
742 wxPyEndBlockThreads(blocked); \
743 if (! found) \
744 rval = PCLASS::CBNAME(a, b); \
745 return rval; \
746 }
747
748
749
750
751 class wxPyPrintPreview : public wxPrintPreview
752 {
753 DECLARE_CLASS(wxPyPrintPreview)
754 public:
755 wxPyPrintPreview(wxPyPrintout* printout,
756 wxPyPrintout* printoutForPrinting,
757 wxPrintDialogData* data=NULL)
758 : wxPrintPreview(printout, printoutForPrinting, data)
759 {}
760 wxPyPrintPreview(wxPyPrintout* printout,
761 wxPyPrintout* printoutForPrinting,
762 wxPrintData* data)
763 : wxPrintPreview(printout, printoutForPrinting, data)
764 {}
765
766 DEC_PYCALLBACK_BOOL_INT(SetCurrentPage);
767 DEC_PYCALLBACK_BOOL_PREWINDC(PaintPage);
768 DEC_PYCALLBACK_BOOL_PREWINDC(DrawBlankPage);
769 DEC_PYCALLBACK_BOOL_INT(RenderPage);
770 DEC_PYCALLBACK_VOID_INT(SetZoom);
771 DEC_PYCALLBACK_BOOL_BOOL(Print);
772 DEC_PYCALLBACK_VOID_(DetermineScaling);
773
774 PYPRIVATE;
775 };
776
777 // Stupid renamed classes... Fix this in 2.5...
778 #if defined(__WXMSW__)
779 IMPLEMENT_CLASS( wxPyPrintPreview, wxWindowsPrintPreview );
780 #elif defined(__WXMAC__)
781 IMPLEMENT_CLASS( wxPyPrintPreview, wxMacPrintPreview );
782 #else
783 IMPLEMENT_CLASS( wxPyPrintPreview, wxPostScriptPrintPreview );
784 #endif
785
786 IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, SetCurrentPage);
787 IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, PaintPage);
788 IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, DrawBlankPage);
789 IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, RenderPage);
790 IMP_PYCALLBACK_VOID_INT (wxPyPrintPreview, wxPrintPreview, SetZoom);
791 IMP_PYCALLBACK_BOOL_BOOL (wxPyPrintPreview, wxPrintPreview, Print);
792 IMP_PYCALLBACK_VOID_ (wxPyPrintPreview, wxPrintPreview, DetermineScaling);
793 %}
794
795
796 MustHaveApp(wxPyPrintPreview);
797
798 class wxPyPrintPreview : public wxPrintPreview
799 {
800 public:
801 %disownarg(wxPyPrintout*);
802
803 %pythonAppend wxPyPrintPreview "self._setCallbackInfo(self, PyPrintPreview)"
804 %nokwargs wxPyPrintPreview;
805 wxPyPrintPreview(wxPyPrintout* printout,
806 wxPyPrintout* printoutForPrinting,
807 wxPrintDialogData* data=NULL);
808 wxPyPrintPreview(wxPyPrintout* printout,
809 wxPyPrintout* printoutForPrinting,
810 wxPrintData* data);
811
812 %cleardisown(wxPyPrintout*);
813
814 void _setCallbackInfo(PyObject* self, PyObject* _class);
815
816 bool SetCurrentPage(int pageNum);
817 bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
818 bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
819 bool RenderPage(int pageNum);
820 void SetZoom(int percent);
821 bool Print(bool interactive);
822 void DetermineScaling();
823
824 %MAKE_BASE_FUNC(PyPrintPreview, SetCurrentPage);
825 %MAKE_BASE_FUNC(PyPrintPreview, PaintPage);
826 %MAKE_BASE_FUNC(PyPrintPreview, DrawBlankPage);
827 %MAKE_BASE_FUNC(PyPrintPreview, RenderPage);
828 %MAKE_BASE_FUNC(PyPrintPreview, SetZoom);
829 %MAKE_BASE_FUNC(PyPrintPreview, Print);
830 %MAKE_BASE_FUNC(PyPrintPreview, DetermineScaling);
831 };
832
833
834
835
836 %{
837 class wxPyPreviewFrame : public wxPreviewFrame
838 {
839 DECLARE_CLASS(wxPyPreviewFrame)
840 public:
841 wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
842 const wxString& title,
843 const wxPoint& pos = wxDefaultPosition,
844 const wxSize& size = wxDefaultSize,
845 long style = wxDEFAULT_FRAME_STYLE,
846 const wxString& name = wxPyFrameNameStr)
847 : wxPreviewFrame(preview, parent, title, pos, size, style, name)
848 {}
849
850 void SetPreviewCanvas(wxPreviewCanvas* canvas) { m_previewCanvas = canvas; }
851 void SetControlBar(wxPreviewControlBar* bar) { m_controlBar = bar; }
852
853 DEC_PYCALLBACK_VOID_(Initialize);
854 DEC_PYCALLBACK_VOID_(CreateCanvas);
855 DEC_PYCALLBACK_VOID_(CreateControlBar);
856
857 PYPRIVATE;
858 };
859
860 IMPLEMENT_CLASS(wxPyPreviewFrame, wxPreviewFrame);
861
862 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, Initialize);
863 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateCanvas);
864 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateControlBar);
865 %}
866
867
868 MustHaveApp(wxPyPreviewFrame);
869
870 class wxPyPreviewFrame : public wxPreviewFrame
871 {
872 public:
873 %pythonAppend wxPyPreviewFrame "self._setCallbackInfo(self, PyPreviewFrame); self._setOORInfo(self)"
874
875 wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
876 const wxString& title,
877 const wxPoint& pos = wxDefaultPosition,
878 const wxSize& size = wxDefaultSize,
879 long style = wxDEFAULT_FRAME_STYLE,
880 const wxString& name = wxPyFrameNameStr);
881
882 void _setCallbackInfo(PyObject* self, PyObject* _class);
883
884 void SetPreviewCanvas(wxPreviewCanvas* canvas);
885 void SetControlBar(wxPreviewControlBar* bar);
886
887 void Initialize();
888 void CreateCanvas();
889 void CreateControlBar();
890
891 %MAKE_BASE_FUNC(PyPreviewFrame, Initialize);
892 %MAKE_BASE_FUNC(PyPreviewFrame, CreateCanvas);
893 %MAKE_BASE_FUNC(PyPreviewFrame, CreateControlBar);
894 };
895
896
897
898
899 %{
900 class wxPyPreviewControlBar : public wxPreviewControlBar
901 {
902 DECLARE_CLASS(wxPyPreviewControlBar)
903 public:
904 wxPyPreviewControlBar(wxPrintPreview *preview,
905 long buttons,
906 wxWindow *parent,
907 const wxPoint& pos = wxDefaultPosition,
908 const wxSize& size = wxDefaultSize,
909 long style = 0,
910 const wxString& name = wxPyPanelNameStr)
911 : wxPreviewControlBar(preview, buttons, parent, pos, size, style, name)
912 {}
913
914 void SetPrintPreview(wxPrintPreview* preview) { m_printPreview = preview; }
915
916 DEC_PYCALLBACK_VOID_(CreateButtons);
917 DEC_PYCALLBACK_VOID_INT(SetZoomControl);
918
919 PYPRIVATE;
920 };
921
922 IMPLEMENT_CLASS(wxPyPreviewControlBar, wxPreviewControlBar);
923 IMP_PYCALLBACK_VOID_(wxPyPreviewControlBar, wxPreviewControlBar, CreateButtons);
924 IMP_PYCALLBACK_VOID_INT(wxPyPreviewControlBar, wxPreviewControlBar, SetZoomControl);
925 %}
926
927
928 MustHaveApp(wxPyPreviewControlBar);
929
930 class wxPyPreviewControlBar : public wxPreviewControlBar
931 {
932 public:
933 %pythonAppend wxPyPreviewControlBar "self._setCallbackInfo(self, PyPreviewControlBar); self._setOORInfo(self)"
934
935 wxPyPreviewControlBar(wxPrintPreview *preview,
936 long buttons,
937 wxWindow *parent,
938 const wxPoint& pos = wxDefaultPosition,
939 const wxSize& size = wxDefaultSize,
940 long style = 0,
941 const wxString& name = wxPyPanelNameStr);
942
943 void _setCallbackInfo(PyObject* self, PyObject* _class);
944
945 void SetPrintPreview(wxPrintPreview* preview);
946
947 void CreateButtons();
948 void SetZoomControl(int zoom);
949
950 %MAKE_BASE_FUNC(PreviewControlBar, CreateButtons);
951 %MAKE_BASE_FUNC(PreviewControlBar, SetZoomControl);
952 };
953
954 //---------------------------------------------------------------------------
955 //---------------------------------------------------------------------------
956 %init %{
957 wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
958 %}
959 //---------------------------------------------------------------------------