]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_printfw.i
remove unneeded include
[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
499 void FitThisSizeToPaper(const wxSize& imageSize);
500 void FitThisSizeToPage(const wxSize& imageSize);
501 void FitThisSizeToPageMargins(const wxSize& imageSize, const wxPageSetupDialogData& pageSetupData);
502 void MapScreenSizeToPaper();
503 void MapScreenSizeToPage();
504 void MapScreenSizeToPageMargins(const wxPageSetupDialogData& pageSetupData);
505 void MapScreenSizeToDevice();
506
507 wxRect GetLogicalPaperRect() const;
508 wxRect GetLogicalPageRect() const;
509 wxRect GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSetupData) const;
510
511 void SetLogicalOrigin(wxCoord x, wxCoord y);
512 void OffsetLogicalOrigin(wxCoord xoff, wxCoord yoff);
513
514
515 void SetPageSizePixels(int w, int h);
516 DocDeclA(
517 void, GetPageSizePixels(int *OUTPUT, int *OUTPUT),
518 "GetPageSizePixels() -> (w, h)");
519
520 void SetPageSizeMM(int w, int h);
521 DocDeclA(
522 void, GetPageSizeMM(int *OUTPUT, int *OUTPUT),
523 "GetPageSizeMM() -> (w, h)");
524
525 void SetPPIScreen(int x, int y);
526 DocDeclA(
527 void, GetPPIScreen(int *OUTPUT, int *OUTPUT),
528 "GetPPIScreen() -> (x,y)");
529
530 void SetPPIPrinter(int x, int y);
531 DocDeclA(
532 void, GetPPIPrinter(int *OUTPUT, int *OUTPUT),
533 "GetPPIPrinter() -> (x,y)");
534
535 void SetPaperRectPixels(const wxRect& paperRectPixels);
536 wxRect GetPaperRectPixels() const;
537
538 bool IsPreview();
539 void SetIsPreview(bool p);
540
541
542 bool OnBeginDocument(int startPage, int endPage);
543 void OnEndDocument();
544 void OnBeginPrinting();
545 void OnEndPrinting();
546 void OnPreparePrinting();
547 bool HasPage(int page);
548 DocDeclA(
549 void, GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
550 "GetPageInfo() -> (minPage, maxPage, pageFrom, pageTo)");
551
552 %MAKE_BASE_FUNC(Printout, OnBeginDocument);
553 %MAKE_BASE_FUNC(Printout, OnEndDocument);
554 %MAKE_BASE_FUNC(Printout, OnBeginPrinting);
555 %MAKE_BASE_FUNC(Printout, OnEndPrinting);
556 %MAKE_BASE_FUNC(Printout, OnPreparePrinting);
557 %MAKE_BASE_FUNC(Printout, GetPageInfo);
558
559
560 %property(DC, GetDC, SetDC, doc="See `GetDC` and `SetDC`");
561 %property(PPIPrinter, GetPPIPrinter, SetPPIPrinter, doc="See `GetPPIPrinter` and `SetPPIPrinter`");
562 %property(PPIScreen, GetPPIScreen, SetPPIScreen, doc="See `GetPPIScreen` and `SetPPIScreen`");
563 %property(PageSizeMM, GetPageSizeMM, SetPageSizeMM, doc="See `GetPageSizeMM` and `SetPageSizeMM`");
564 %property(PageSizePixels, GetPageSizePixels, SetPageSizePixels, doc="See `GetPageSizePixels` and `SetPageSizePixels`");
565 %property(Title, GetTitle, doc="See `GetTitle`");
566 };
567
568 //---------------------------------------------------------------------------
569
570
571
572 MustHaveApp(wxPreviewCanvas);
573
574 class wxPreviewCanvas: public wxScrolledWindow
575 {
576 public:
577 %pythonAppend wxPreviewCanvas "self._setOORInfo(self)"
578
579 wxPreviewCanvas(wxPrintPreview *preview,
580 wxWindow *parent,
581 const wxPoint& pos = wxDefaultPosition,
582 const wxSize& size = wxDefaultSize,
583 long style = 0,
584 const wxString& name = wxPyPreviewCanvasNameStr);
585 };
586
587
588 MustHaveApp(wxPreviewFrame);
589
590 class wxPreviewFrame : public wxFrame {
591 public:
592 %disownarg(wxPrintPreview*);
593
594 %pythonAppend wxPreviewFrame "self._setOORInfo(self)"
595 wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
596 const wxPoint& pos = wxDefaultPosition,
597 const wxSize& size = wxDefaultSize,
598 long style = wxDEFAULT_FRAME_STYLE,
599 const wxString& name = wxPyFrameNameStr);
600
601 %cleardisown(wxPrintPreview*);
602
603 void Initialize();
604 void CreateControlBar();
605 void CreateCanvas();
606
607 wxPreviewControlBar* GetControlBar() const;
608
609 %property(ControlBar, GetControlBar, doc="See `GetControlBar`");
610 };
611
612
613
614 enum {
615 wxPREVIEW_PRINT,
616 wxPREVIEW_PREVIOUS,
617 wxPREVIEW_NEXT,
618 wxPREVIEW_ZOOM,
619 wxPREVIEW_FIRST,
620 wxPREVIEW_LAST,
621 wxPREVIEW_GOTO,
622 wxPREVIEW_DEFAULT,
623
624 wxID_PREVIEW_CLOSE,
625 wxID_PREVIEW_NEXT,
626 wxID_PREVIEW_PREVIOUS,
627 wxID_PREVIEW_PRINT,
628 wxID_PREVIEW_ZOOM,
629 wxID_PREVIEW_FIRST,
630 wxID_PREVIEW_LAST,
631 wxID_PREVIEW_GOTO
632 };
633
634 MustHaveApp(wxPreviewControlBar);
635
636 class wxPreviewControlBar: public wxPanel
637 {
638 public:
639 %pythonAppend wxPreviewControlBar "self._setOORInfo(self)"
640
641 wxPreviewControlBar(wxPrintPreview *preview,
642 long buttons,
643 wxWindow *parent,
644 const wxPoint& pos = wxDefaultPosition,
645 const wxSize& size = wxDefaultSize,
646 long style = wxTAB_TRAVERSAL,
647 const wxString& name = wxPyPanelNameStr);
648
649 int GetZoomControl();
650 void SetZoomControl(int zoom);
651 wxPrintPreview* GetPrintPreview();
652
653 void OnNext();
654 void OnPrevious();
655 void OnFirst();
656 void OnLast();
657 void OnGoto();
658
659 %property(PrintPreview, GetPrintPreview, doc="See `GetPrintPreview`");
660 %property(ZoomControl, GetZoomControl, SetZoomControl, doc="See `GetZoomControl` and `SetZoomControl`");
661 };
662
663
664
665 //---------------------------------------------------------------------------
666
667 MustHaveApp(wxPrintPreview);
668
669 class wxPrintPreview : public wxObject {
670 public:
671 %disownarg(wxPyPrintout*);
672
673 %nokwargs wxPrintPreview;
674 wxPrintPreview(wxPyPrintout* printout,
675 wxPyPrintout* printoutForPrinting,
676 wxPrintDialogData *data=NULL);
677 wxPrintPreview(wxPyPrintout* printout,
678 wxPyPrintout* printoutForPrinting,
679 wxPrintData* data);
680
681 ~wxPrintPreview();
682
683 virtual bool SetCurrentPage(int pageNum);
684 int GetCurrentPage();
685
686 void SetPrintout(wxPyPrintout *printout);
687 wxPyPrintout *GetPrintout();
688 wxPyPrintout *GetPrintoutForPrinting();
689
690 %cleardisown(wxPyPrintout*);
691
692 void SetFrame(wxFrame *frame);
693 void SetCanvas(wxPreviewCanvas *canvas);
694
695 virtual wxFrame *GetFrame();
696 virtual wxPreviewCanvas *GetCanvas();
697
698 // The preview canvas should call this from OnPaint
699 virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
700
701 // This draws a blank page onto the preview canvas
702 virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
703
704 // This is called by wxPrintPreview to render a page into a wxMemoryDC.
705 virtual bool RenderPage(int pageNum);
706
707 // Adjusts the scrollbars for the current scale
708 virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
709
710 wxPrintDialogData& GetPrintDialogData();
711
712 virtual void SetZoom(int percent);
713 int GetZoom();
714
715 int GetMaxPage();
716 int GetMinPage();
717
718 bool IsOk();
719 %pythoncode { Ok = IsOk }
720 void SetOk(bool ok);
721
722 virtual bool Print(bool interactive);
723 virtual void DetermineScaling();
724
725 %pythoncode { def __nonzero__(self): return self.IsOk() }
726
727 %property(Canvas, GetCanvas, SetCanvas, doc="See `GetCanvas` and `SetCanvas`");
728 %property(CurrentPage, GetCurrentPage, SetCurrentPage, doc="See `GetCurrentPage` and `SetCurrentPage`");
729 %property(Frame, GetFrame, SetFrame, doc="See `GetFrame` and `SetFrame`");
730 %property(MaxPage, GetMaxPage, doc="See `GetMaxPage`");
731 %property(MinPage, GetMinPage, doc="See `GetMinPage`");
732 %property(PrintDialogData, GetPrintDialogData, doc="See `GetPrintDialogData`");
733 %property(Printout, GetPrintout, SetPrintout, doc="See `GetPrintout` and `SetPrintout`");
734 %property(PrintoutForPrinting, GetPrintoutForPrinting, doc="See `GetPrintoutForPrinting`");
735 %property(Zoom, GetZoom, SetZoom, doc="See `GetZoom` and `SetZoom`");
736 };
737
738
739
740 //---------------------------------------------------------------------------
741
742 // Python-derivable versions of the above preview classes
743
744 %{
745
746 #define DEC_PYCALLBACK_BOOL_PREWINDC(CBNAME) \
747 bool CBNAME(wxPreviewCanvas* a, wxDC& b)
748
749
750 #define IMP_PYCALLBACK_BOOL_PREWINDC(CLASS, PCLASS, CBNAME) \
751 bool CLASS::CBNAME(wxPreviewCanvas* a, wxDC& b) { \
752 bool rval=false; \
753 bool found; \
754 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
755 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
756 PyObject* win = wxPyMake_wxObject(a,false); \
757 PyObject* dc = wxPyMake_wxObject(&b,false); \
758 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc)); \
759 Py_DECREF(win); \
760 Py_DECREF(dc); \
761 } \
762 wxPyEndBlockThreads(blocked); \
763 if (! found) \
764 rval = PCLASS::CBNAME(a, b); \
765 return rval; \
766 }
767
768
769
770
771 class wxPyPrintPreview : public wxPrintPreview
772 {
773 DECLARE_CLASS(wxPyPrintPreview)
774 public:
775 wxPyPrintPreview(wxPyPrintout* printout,
776 wxPyPrintout* printoutForPrinting,
777 wxPrintDialogData* data=NULL)
778 : wxPrintPreview(printout, printoutForPrinting, data)
779 {}
780 wxPyPrintPreview(wxPyPrintout* printout,
781 wxPyPrintout* printoutForPrinting,
782 wxPrintData* data)
783 : wxPrintPreview(printout, printoutForPrinting, data)
784 {}
785
786 DEC_PYCALLBACK_BOOL_INT(SetCurrentPage);
787 DEC_PYCALLBACK_BOOL_PREWINDC(PaintPage);
788 DEC_PYCALLBACK_BOOL_PREWINDC(DrawBlankPage);
789 DEC_PYCALLBACK_BOOL_INT(RenderPage);
790 DEC_PYCALLBACK_VOID_INT(SetZoom);
791 DEC_PYCALLBACK_BOOL_BOOL(Print);
792 DEC_PYCALLBACK_VOID_(DetermineScaling);
793
794 PYPRIVATE;
795 };
796
797 // Stupid renamed classes... Fix this in 2.5...
798 #if defined(__WXMSW__)
799 IMPLEMENT_CLASS( wxPyPrintPreview, wxWindowsPrintPreview );
800 #elif defined(__WXMAC__)
801 IMPLEMENT_CLASS( wxPyPrintPreview, wxMacPrintPreview );
802 #else
803 IMPLEMENT_CLASS( wxPyPrintPreview, wxPostScriptPrintPreview );
804 #endif
805
806 IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, SetCurrentPage);
807 IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, PaintPage);
808 IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, DrawBlankPage);
809 IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, RenderPage);
810 IMP_PYCALLBACK_VOID_INT (wxPyPrintPreview, wxPrintPreview, SetZoom);
811 IMP_PYCALLBACK_BOOL_BOOL (wxPyPrintPreview, wxPrintPreview, Print);
812 IMP_PYCALLBACK_VOID_ (wxPyPrintPreview, wxPrintPreview, DetermineScaling);
813 %}
814
815
816 MustHaveApp(wxPyPrintPreview);
817
818 class wxPyPrintPreview : public wxPrintPreview
819 {
820 public:
821 %disownarg(wxPyPrintout*);
822
823 %pythonAppend wxPyPrintPreview "self._setCallbackInfo(self, PyPrintPreview)"
824 %nokwargs wxPyPrintPreview;
825 wxPyPrintPreview(wxPyPrintout* printout,
826 wxPyPrintout* printoutForPrinting,
827 wxPrintDialogData* data=NULL);
828 wxPyPrintPreview(wxPyPrintout* printout,
829 wxPyPrintout* printoutForPrinting,
830 wxPrintData* data);
831
832 %cleardisown(wxPyPrintout*);
833
834 void _setCallbackInfo(PyObject* self, PyObject* _class);
835
836 bool SetCurrentPage(int pageNum);
837 bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
838 bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
839 bool RenderPage(int pageNum);
840 void SetZoom(int percent);
841 bool Print(bool interactive);
842 void DetermineScaling();
843
844 %MAKE_BASE_FUNC(PyPrintPreview, SetCurrentPage);
845 %MAKE_BASE_FUNC(PyPrintPreview, PaintPage);
846 %MAKE_BASE_FUNC(PyPrintPreview, DrawBlankPage);
847 %MAKE_BASE_FUNC(PyPrintPreview, RenderPage);
848 %MAKE_BASE_FUNC(PyPrintPreview, SetZoom);
849 %MAKE_BASE_FUNC(PyPrintPreview, Print);
850 %MAKE_BASE_FUNC(PyPrintPreview, DetermineScaling);
851 };
852
853
854
855
856 %{
857 class wxPyPreviewFrame : public wxPreviewFrame
858 {
859 DECLARE_CLASS(wxPyPreviewFrame)
860 public:
861 wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
862 const wxString& title,
863 const wxPoint& pos = wxDefaultPosition,
864 const wxSize& size = wxDefaultSize,
865 long style = wxDEFAULT_FRAME_STYLE,
866 const wxString& name = wxPyFrameNameStr)
867 : wxPreviewFrame(preview, parent, title, pos, size, style, name)
868 {}
869
870 void SetPreviewCanvas(wxPreviewCanvas* canvas) { m_previewCanvas = canvas; }
871 void SetControlBar(wxPreviewControlBar* bar) { m_controlBar = bar; }
872
873 DEC_PYCALLBACK_VOID_(Initialize);
874 DEC_PYCALLBACK_VOID_(CreateCanvas);
875 DEC_PYCALLBACK_VOID_(CreateControlBar);
876
877 PYPRIVATE;
878 };
879
880 IMPLEMENT_CLASS(wxPyPreviewFrame, wxPreviewFrame);
881
882 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, Initialize);
883 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateCanvas);
884 IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateControlBar);
885 %}
886
887
888 MustHaveApp(wxPyPreviewFrame);
889
890 class wxPyPreviewFrame : public wxPreviewFrame
891 {
892 public:
893 %pythonAppend wxPyPreviewFrame "self._setCallbackInfo(self, PyPreviewFrame); self._setOORInfo(self)"
894
895 wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent,
896 const wxString& title,
897 const wxPoint& pos = wxDefaultPosition,
898 const wxSize& size = wxDefaultSize,
899 long style = wxDEFAULT_FRAME_STYLE,
900 const wxString& name = wxPyFrameNameStr);
901
902 void _setCallbackInfo(PyObject* self, PyObject* _class);
903
904 void SetPreviewCanvas(wxPreviewCanvas* canvas);
905 void SetControlBar(wxPreviewControlBar* bar);
906
907 void Initialize();
908 void CreateCanvas();
909 void CreateControlBar();
910
911 %MAKE_BASE_FUNC(PyPreviewFrame, Initialize);
912 %MAKE_BASE_FUNC(PyPreviewFrame, CreateCanvas);
913 %MAKE_BASE_FUNC(PyPreviewFrame, CreateControlBar);
914 };
915
916
917
918
919 %{
920 class wxPyPreviewControlBar : public wxPreviewControlBar
921 {
922 DECLARE_CLASS(wxPyPreviewControlBar)
923 public:
924 wxPyPreviewControlBar(wxPrintPreview *preview,
925 long buttons,
926 wxWindow *parent,
927 const wxPoint& pos = wxDefaultPosition,
928 const wxSize& size = wxDefaultSize,
929 long style = 0,
930 const wxString& name = wxPyPanelNameStr)
931 : wxPreviewControlBar(preview, buttons, parent, pos, size, style, name)
932 {}
933
934 void SetPrintPreview(wxPrintPreview* preview) { m_printPreview = preview; }
935
936 DEC_PYCALLBACK_VOID_(CreateButtons);
937 DEC_PYCALLBACK_VOID_INT(SetZoomControl);
938
939 PYPRIVATE;
940 };
941
942 IMPLEMENT_CLASS(wxPyPreviewControlBar, wxPreviewControlBar);
943 IMP_PYCALLBACK_VOID_(wxPyPreviewControlBar, wxPreviewControlBar, CreateButtons);
944 IMP_PYCALLBACK_VOID_INT(wxPyPreviewControlBar, wxPreviewControlBar, SetZoomControl);
945 %}
946
947
948 MustHaveApp(wxPyPreviewControlBar);
949
950 class wxPyPreviewControlBar : public wxPreviewControlBar
951 {
952 public:
953 %pythonAppend wxPyPreviewControlBar "self._setCallbackInfo(self, PyPreviewControlBar); self._setOORInfo(self)"
954
955 wxPyPreviewControlBar(wxPrintPreview *preview,
956 long buttons,
957 wxWindow *parent,
958 const wxPoint& pos = wxDefaultPosition,
959 const wxSize& size = wxDefaultSize,
960 long style = 0,
961 const wxString& name = wxPyPanelNameStr);
962
963 void _setCallbackInfo(PyObject* self, PyObject* _class);
964
965 void SetPrintPreview(wxPrintPreview* preview);
966
967 void CreateButtons();
968 void SetZoomControl(int zoom);
969
970 %MAKE_BASE_FUNC(PreviewControlBar, CreateButtons);
971 %MAKE_BASE_FUNC(PreviewControlBar, SetZoomControl);
972 };
973
974 //---------------------------------------------------------------------------
975 //---------------------------------------------------------------------------
976 %init %{
977 wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout");
978 %}
979 //---------------------------------------------------------------------------