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