]>
Commit | Line | Data |
---|---|---|
bb0054cd | 1 | ///////////////////////////////////////////////////////////////////////////// |
d14a1e28 RD |
2 | // Name: _????.i |
3 | // Purpose: SWIG interface for wx???? | |
bb0054cd RD |
4 | // |
5 | // Author: Robin Dunn | |
6 | // | |
d14a1e28 | 7 | // Created: 9-Aug-2003 |
bb0054cd | 8 | // RCS-ID: $Id$ |
d14a1e28 | 9 | // Copyright: (c) 2003 by Total Control Software |
bb0054cd RD |
10 | // Licence: wxWindows license |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
d14a1e28 | 13 | // Not a %module |
bb0054cd | 14 | |
bb0054cd | 15 | |
d14a1e28 RD |
16 | //--------------------------------------------------------------------------- |
17 | %newgroup | |
bb0054cd | 18 | |
137b5242 | 19 | %{ |
d14a1e28 RD |
20 | #include "wx/wxPython/printfw.h" |
21 | ||
137b5242 RD |
22 | %} |
23 | ||
b2dc1044 RD |
24 | MAKE_CONST_WXSTRING2(PrintoutTitleStr, wxT("Printout")); |
25 | MAKE_CONST_WXSTRING2(PreviewCanvasNameStr, wxT("previewcanvas")); | |
26 | ||
bb0054cd | 27 | |
d14a1e28 | 28 | //--------------------------------------------------------------------------- |
bb0054cd | 29 | |
1fded56b RD |
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 | }; | |
37 | ||
bb0054cd RD |
38 | |
39 | ||
9416aa89 | 40 | class wxPrintData : public wxObject { |
bb0054cd RD |
41 | public: |
42 | wxPrintData(); | |
43 | ~wxPrintData(); | |
44 | ||
45 | int GetNoCopies(); | |
46 | bool GetCollate(); | |
47 | int GetOrientation(); | |
48 | ||
b7fc54be RD |
49 | bool Ok(); |
50 | ||
bb0054cd RD |
51 | const wxString& GetPrinterName(); |
52 | bool GetColour(); | |
53 | wxDuplexMode GetDuplex(); | |
54 | wxPaperSize GetPaperId(); | |
55 | const wxSize& GetPaperSize(); | |
56 | ||
b2dc1044 | 57 | int GetQuality(); |
bb0054cd RD |
58 | |
59 | void SetNoCopies(int v); | |
60 | void SetCollate(bool flag); | |
61 | void SetOrientation(int orient); | |
62 | ||
63 | void SetPrinterName(const wxString& name); | |
64 | void SetColour(bool colour); | |
65 | void SetDuplex(wxDuplexMode duplex); | |
66 | void SetPaperId(wxPaperSize sizeId); | |
67 | void SetPaperSize(const wxSize& sz); | |
b2dc1044 | 68 | void SetQuality(int quality); |
bb0054cd | 69 | |
926bb76c RD |
70 | // PostScript-specific data |
71 | const wxString& GetPrinterCommand(); | |
72 | const wxString& GetPrinterOptions(); | |
73 | const wxString& GetPreviewCommand(); | |
74 | const wxString& GetFilename(); | |
75 | const wxString& GetFontMetricPath(); | |
76 | double GetPrinterScaleX(); | |
77 | double GetPrinterScaleY(); | |
78 | long GetPrinterTranslateX(); | |
79 | long GetPrinterTranslateY(); | |
80 | wxPrintMode GetPrintMode(); | |
81 | ||
82 | void SetPrinterCommand(const wxString& command); | |
83 | void SetPrinterOptions(const wxString& options); | |
84 | void SetPreviewCommand(const wxString& command); | |
85 | void SetFilename(const wxString& filename); | |
86 | void SetFontMetricPath(const wxString& path); | |
87 | void SetPrinterScaleX(double x); | |
88 | void SetPrinterScaleY(double y); | |
89 | void SetPrinterScaling(double x, double y); | |
90 | void SetPrinterTranslateX(long x); | |
91 | void SetPrinterTranslateY(long y); | |
92 | void SetPrinterTranslation(long x, long y); | |
93 | void SetPrintMode(wxPrintMode printMode); | |
bb0054cd | 94 | |
d14a1e28 | 95 | %pythoncode { def __nonzero__(self): return self.Ok() } |
eedf876b RD |
96 | }; |
97 | ||
98 | //--------------------------------------------------------------------------- | |
99 | ||
9416aa89 | 100 | class wxPageSetupDialogData : public wxObject { |
bb0054cd RD |
101 | public: |
102 | wxPageSetupDialogData(); | |
103 | ~wxPageSetupDialogData(); | |
104 | ||
105 | void EnableHelp(bool flag); | |
106 | void EnableMargins(bool flag); | |
107 | void EnableOrientation(bool flag); | |
108 | void EnablePaper(bool flag); | |
109 | void EnablePrinter(bool flag); | |
110 | bool GetDefaultMinMargins(); | |
111 | bool GetEnableMargins(); | |
112 | bool GetEnableOrientation(); | |
113 | bool GetEnablePaper(); | |
114 | bool GetEnablePrinter(); | |
115 | bool GetEnableHelp(); | |
116 | bool GetDefaultInfo(); | |
117 | wxPoint GetMarginTopLeft(); | |
118 | wxPoint GetMarginBottomRight(); | |
119 | wxPoint GetMinMarginTopLeft(); | |
120 | wxPoint GetMinMarginBottomRight(); | |
121 | wxPaperSize GetPaperId(); | |
122 | wxSize GetPaperSize(); | |
d14a1e28 RD |
123 | |
124 | wxPrintData& GetPrintData(); | |
125 | // %addmethods { | |
126 | // %new wxPrintData* GetPrintData() { | |
127 | // return new wxPrintData(self->GetPrintData()); // force a copy | |
128 | // } | |
129 | // } | |
b7fc54be RD |
130 | |
131 | bool Ok(); | |
132 | ||
bb0054cd RD |
133 | void SetDefaultInfo(bool flag); |
134 | void SetDefaultMinMargins(bool flag); | |
135 | void SetMarginTopLeft(const wxPoint& pt); | |
136 | void SetMarginBottomRight(const wxPoint& pt); | |
137 | void SetMinMarginTopLeft(const wxPoint& pt); | |
138 | void SetMinMarginBottomRight(const wxPoint& pt); | |
3ca6a5f0 | 139 | void SetPaperId(wxPaperSize id); |
bb0054cd RD |
140 | void SetPaperSize(const wxSize& size); |
141 | void SetPrintData(const wxPrintData& printData); | |
1fded56b | 142 | |
d14a1e28 | 143 | %pythoncode { def __nonzero__(self): return self.Ok() } |
bb0054cd RD |
144 | }; |
145 | ||
146 | ||
d14a1e28 | 147 | |
bb0054cd RD |
148 | class wxPageSetupDialog : public wxDialog { |
149 | public: | |
d14a1e28 | 150 | %addtofunc wxPageSetupDialog "self._setOORInfo(self)" |
bb0054cd | 151 | |
d14a1e28 | 152 | wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL); |
bb0054cd RD |
153 | |
154 | wxPageSetupDialogData& GetPageSetupData(); | |
155 | int ShowModal(); | |
156 | }; | |
157 | ||
d14a1e28 | 158 | //--------------------------------------------------------------------------- |
bb0054cd RD |
159 | |
160 | ||
9416aa89 | 161 | class wxPrintDialogData : public wxObject { |
bb0054cd RD |
162 | public: |
163 | wxPrintDialogData(); | |
164 | ~wxPrintDialogData(); | |
165 | ||
1fded56b RD |
166 | int GetFromPage() const; |
167 | int GetToPage() const; | |
168 | int GetMinPage() const; | |
169 | int GetMaxPage() const; | |
170 | int GetNoCopies() const; | |
171 | bool GetAllPages() const; | |
172 | bool GetSelection() const; | |
173 | bool GetCollate() const; | |
174 | bool GetPrintToFile() const; | |
175 | bool GetSetupDialog() const; | |
176 | ||
177 | void SetFromPage(int v); | |
178 | void SetToPage(int v); | |
179 | void SetMinPage(int v); | |
180 | void SetMaxPage(int v); | |
181 | void SetNoCopies(int v); | |
182 | void SetAllPages(bool flag); | |
183 | void SetSelection(bool flag); | |
184 | void SetCollate(bool flag); | |
185 | void SetPrintToFile(bool flag); | |
186 | void SetSetupDialog(bool flag); | |
187 | ||
bb0054cd RD |
188 | void EnablePrintToFile(bool flag); |
189 | void EnableSelection(bool flag); | |
1fded56b RD |
190 | void EnablePageNumbers(bool flag); |
191 | void EnableHelp(bool flag); | |
192 | ||
193 | bool GetEnablePrintToFile() const; | |
194 | bool GetEnableSelection() const; | |
195 | bool GetEnablePageNumbers() const; | |
196 | bool GetEnableHelp() const; | |
197 | ||
198 | // Is this data OK for showing the print dialog? | |
199 | bool Ok() const; | |
200 | ||
d14a1e28 RD |
201 | |
202 | wxPrintData& GetPrintData(); | |
203 | // %addmethods { | |
204 | // %new wxPrintData* GetPrintData() { | |
205 | // return new wxPrintData(self->GetPrintData()); // force a copy | |
206 | // } | |
207 | // } | |
bb0054cd | 208 | void SetPrintData(const wxPrintData& printData); |
1fded56b | 209 | |
d14a1e28 | 210 | %pythoncode { def __nonzero__(self): return self.Ok() } |
bb0054cd RD |
211 | }; |
212 | ||
213 | ||
214 | class wxPrintDialog : public wxDialog { | |
215 | public: | |
d14a1e28 RD |
216 | %addtofunc wxPrintDialog "self._setOORInfo(self)" |
217 | ||
bb0054cd RD |
218 | wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL); |
219 | ||
bb0054cd | 220 | wxPrintDialogData& GetPrintDialogData(); |
d14a1e28 RD |
221 | |
222 | %newobject GetPrintDC; | |
223 | wxDC* GetPrintDC(); | |
bb0054cd RD |
224 | int ShowModal(); |
225 | }; | |
226 | ||
d14a1e28 RD |
227 | |
228 | //--------------------------------------------------------------------------- | |
229 | //--------------------------------------------------------------------------- | |
230 | ||
231 | ||
232 | enum wxPrinterError | |
233 | { | |
234 | wxPRINTER_NO_ERROR = 0, | |
235 | wxPRINTER_CANCELLED, | |
236 | wxPRINTER_ERROR | |
237 | }; | |
238 | ||
239 | ||
240 | class wxPrinter : public wxObject { | |
241 | public: | |
242 | wxPrinter(wxPrintDialogData* data = NULL); | |
243 | ~wxPrinter(); | |
244 | ||
245 | void CreateAbortWindow(wxWindow* parent, wxPyPrintout* printout); | |
246 | wxPrintDialogData& GetPrintDialogData(); | |
dd9f7fea | 247 | bool Print(wxWindow *parent, wxPyPrintout *printout, int prompt=True); |
d14a1e28 RD |
248 | wxDC* PrintDialog(wxWindow *parent); |
249 | void ReportError(wxWindow *parent, wxPyPrintout *printout, const wxString& message); | |
250 | bool Setup(wxWindow *parent); | |
251 | bool GetAbort(); | |
252 | ||
253 | static wxPrinterError GetLastError(); | |
254 | }; | |
255 | ||
256 | ||
257 | //--------------------------------------------------------------------------- | |
bb0054cd RD |
258 | // Custom wxPrintout class that knows how to call python |
259 | %{ | |
2abc0a0f RD |
260 | |
261 | ||
262 | // Since this one would be tough and ugly to do with the Macros... | |
263 | void wxPyPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) { | |
dd9f7fea | 264 | bool hadErr = False; |
19a97bd6 | 265 | bool found; |
2abc0a0f | 266 | |
4268f798 | 267 | wxPyBeginBlockThreads(); |
d14a1e28 RD |
268 | if ((found = wxPyCBH_findCallback(m_myInst, "GetPageInfo"))) { |
269 | PyObject* result = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); | |
2abc0a0f RD |
270 | if (result && PyTuple_Check(result) && PyTuple_Size(result) == 4) { |
271 | PyObject* val; | |
272 | ||
273 | val = PyTuple_GetItem(result, 0); | |
274 | if (PyInt_Check(val)) *minPage = PyInt_AsLong(val); | |
dd9f7fea | 275 | else hadErr = True; |
2abc0a0f RD |
276 | |
277 | val = PyTuple_GetItem(result, 1); | |
278 | if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val); | |
dd9f7fea | 279 | else hadErr = True; |
2abc0a0f RD |
280 | |
281 | val = PyTuple_GetItem(result, 2); | |
282 | if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val); | |
dd9f7fea | 283 | else hadErr = True; |
2abc0a0f RD |
284 | |
285 | val = PyTuple_GetItem(result, 3); | |
286 | if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val); | |
dd9f7fea | 287 | else hadErr = True; |
bb0054cd RD |
288 | } |
289 | else | |
dd9f7fea | 290 | hadErr = True; |
1afc06c2 | 291 | |
2abc0a0f RD |
292 | if (hadErr) { |
293 | PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers."); | |
294 | PyErr_Print(); | |
295 | } | |
296 | Py_DECREF(result); | |
bb0054cd | 297 | } |
4268f798 | 298 | wxPyEndBlockThreads(); |
19a97bd6 | 299 | if (! found) |
bb0054cd | 300 | wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo); |
2abc0a0f RD |
301 | } |
302 | ||
303 | void wxPyPrintout::base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) { | |
304 | wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo); | |
305 | } | |
306 | ||
1afc06c2 RD |
307 | |
308 | IMP_PYCALLBACK_BOOL_INTINT(wxPyPrintout, wxPrintout, OnBeginDocument); | |
309 | IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndDocument); | |
310 | IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnBeginPrinting); | |
311 | IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnEndPrinting); | |
312 | IMP_PYCALLBACK__(wxPyPrintout, wxPrintout, OnPreparePrinting); | |
313 | IMP_PYCALLBACK_BOOL_INT_pure(wxPyPrintout, wxPrintout, OnPrintPage); | |
314 | IMP_PYCALLBACK_BOOL_INT(wxPyPrintout, wxPrintout, HasPage); | |
315 | ||
316 | ||
bb0054cd RD |
317 | %} |
318 | ||
319 | ||
320 | // Now define the custom class for SWIGging | |
d14a1e28 | 321 | %name(Printout) class wxPyPrintout : public wxObject { |
bb0054cd | 322 | public: |
d14a1e28 | 323 | %addtofunc wxPyPrintout "self._setCallbackInfo(self, Printout)" |
bb0054cd | 324 | |
d14a1e28 RD |
325 | wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr); |
326 | //~wxPyPrintout(); wxPrintPreview object takes ownership... | |
327 | ||
0122b7e3 | 328 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
bb0054cd | 329 | |
d14a1e28 RD |
330 | |
331 | wxString GetTitle() const; | |
bb0054cd | 332 | wxDC* GetDC(); |
d14a1e28 RD |
333 | void SetDC(wxDC *dc); |
334 | ||
d14a1e28 | 335 | void SetPageSizePixels(int w, int h); |
322913ce RD |
336 | DocDeclA( |
337 | void, GetPageSizePixels(int *OUTPUT, int *OUTPUT), | |
338 | "GetPageSizePixels() -> (w, h)"); | |
d14a1e28 RD |
339 | |
340 | void SetPageSizeMM(int w, int h); | |
322913ce RD |
341 | DocDeclA( |
342 | void, GetPageSizeMM(int *OUTPUT, int *OUTPUT), | |
343 | "GetPageSizeMM() -> (w, h)"); | |
d14a1e28 RD |
344 | |
345 | void SetPPIScreen(int x, int y); | |
322913ce RD |
346 | DocDeclA( |
347 | void, GetPPIScreen(int *OUTPUT, int *OUTPUT), | |
348 | "GetPPIScreen() -> (x,y)"); | |
d14a1e28 RD |
349 | |
350 | void SetPPIPrinter(int x, int y); | |
322913ce RD |
351 | DocDeclA( |
352 | void, GetPPIPrinter(int *OUTPUT, int *OUTPUT), | |
353 | "GetPPIPrinter() -> (x,y)"); | |
d14a1e28 | 354 | |
bb0054cd | 355 | bool IsPreview(); |
d14a1e28 | 356 | void SetIsPreview(bool p); |
bb0054cd | 357 | |
d14a1e28 | 358 | |
bb0054cd RD |
359 | bool base_OnBeginDocument(int startPage, int endPage); |
360 | void base_OnEndDocument(); | |
361 | void base_OnBeginPrinting(); | |
362 | void base_OnEndPrinting(); | |
363 | void base_OnPreparePrinting(); | |
bb0054cd | 364 | bool base_HasPage(int page); |
322913ce RD |
365 | DocDeclA( |
366 | void, base_GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT), | |
367 | "base_GetPageInfo() -> (minPage, maxPage, pageFrom, pageTo)"); | |
bb0054cd RD |
368 | }; |
369 | ||
d14a1e28 | 370 | //--------------------------------------------------------------------------- |
1fded56b | 371 | |
1fded56b | 372 | |
1fded56b | 373 | |
d14a1e28 | 374 | class wxPreviewCanvas: public wxScrolledWindow |
1fded56b RD |
375 | { |
376 | public: | |
fd3f2efe | 377 | %addtofunc wxPreviewCanvas "self._setOORInfo(self)" |
bb0054cd | 378 | |
d14a1e28 RD |
379 | wxPreviewCanvas(wxPrintPreview *preview, |
380 | wxWindow *parent, | |
381 | const wxPoint& pos = wxDefaultPosition, | |
382 | const wxSize& size = wxDefaultSize, | |
383 | long style = 0, | |
384 | const wxString& name = wxPyPreviewCanvasNameStr); | |
bb0054cd RD |
385 | }; |
386 | ||
bb0054cd RD |
387 | |
388 | class wxPreviewFrame : public wxFrame { | |
389 | public: | |
fd3f2efe | 390 | %addtofunc wxPreviewFrame "self._setOORInfo(self)" |
d14a1e28 | 391 | |
bb0054cd | 392 | wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title, |
b68dc582 RD |
393 | const wxPoint& pos = wxDefaultPosition, |
394 | const wxSize& size = wxDefaultSize, | |
bb0054cd | 395 | long style = wxDEFAULT_FRAME_STYLE, |
137b5242 | 396 | const wxString& name = wxPyFrameNameStr); |
bb0054cd | 397 | |
bb0054cd | 398 | void Initialize(); |
1fded56b RD |
399 | void CreateControlBar(); |
400 | void CreateCanvas(); | |
3ef86e32 RD |
401 | |
402 | wxPreviewControlBar* GetControlBar() const; | |
1fded56b RD |
403 | }; |
404 | ||
405 | ||
1fded56b RD |
406 | |
407 | enum { | |
408 | wxPREVIEW_PRINT, | |
409 | wxPREVIEW_PREVIOUS, | |
410 | wxPREVIEW_NEXT, | |
411 | wxPREVIEW_ZOOM, | |
412 | wxPREVIEW_FIRST, | |
413 | wxPREVIEW_LAST, | |
414 | wxPREVIEW_GOTO, | |
415 | wxPREVIEW_DEFAULT, | |
416 | ||
417 | wxID_PREVIEW_CLOSE, | |
418 | wxID_PREVIEW_NEXT, | |
419 | wxID_PREVIEW_PREVIOUS, | |
420 | wxID_PREVIEW_PRINT, | |
421 | wxID_PREVIEW_ZOOM, | |
422 | wxID_PREVIEW_FIRST, | |
423 | wxID_PREVIEW_LAST, | |
424 | wxID_PREVIEW_GOTO | |
425 | }; | |
426 | ||
427 | class wxPreviewControlBar: public wxPanel | |
428 | { | |
429 | public: | |
fd3f2efe | 430 | %addtofunc wxPreviewControlBar "self._setOORInfo(self)" |
d14a1e28 | 431 | |
1fded56b RD |
432 | wxPreviewControlBar(wxPrintPreview *preview, |
433 | long buttons, | |
434 | wxWindow *parent, | |
435 | const wxPoint& pos = wxDefaultPosition, | |
436 | const wxSize& size = wxDefaultSize, | |
3ef86e32 | 437 | long style = wxTAB_TRAVERSAL, |
1fded56b | 438 | const wxString& name = wxPyPanelNameStr); |
1fded56b RD |
439 | |
440 | int GetZoomControl(); | |
441 | void SetZoomControl(int zoom); | |
442 | wxPrintPreview* GetPrintPreview(); | |
443 | ||
444 | void OnNext(); | |
445 | void OnPrevious(); | |
446 | void OnFirst(); | |
447 | void OnLast(); | |
448 | void OnGoto(); | |
449 | }; | |
450 | ||
451 | ||
d14a1e28 RD |
452 | |
453 | //--------------------------------------------------------------------------- | |
454 | ||
455 | class wxPrintPreview : public wxObject { | |
456 | public: | |
457 | wxPrintPreview(wxPyPrintout* printout, | |
458 | wxPyPrintout* printoutForPrinting, | |
459 | wxPrintData* data=NULL); | |
460 | ||
461 | virtual bool SetCurrentPage(int pageNum); | |
462 | int GetCurrentPage(); | |
463 | ||
464 | void SetPrintout(wxPyPrintout *printout); | |
465 | wxPyPrintout *GetPrintout(); | |
466 | wxPyPrintout *GetPrintoutForPrinting(); | |
467 | ||
468 | void SetFrame(wxFrame *frame); | |
469 | void SetCanvas(wxPreviewCanvas *canvas); | |
470 | ||
471 | virtual wxFrame *GetFrame(); | |
472 | virtual wxPreviewCanvas *GetCanvas(); | |
473 | ||
474 | // The preview canvas should call this from OnPaint | |
475 | virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc); | |
476 | ||
477 | // This draws a blank page onto the preview canvas | |
478 | virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc); | |
479 | ||
480 | // This is called by wxPrintPreview to render a page into a wxMemoryDC. | |
481 | virtual bool RenderPage(int pageNum); | |
482 | ||
483 | // Adjusts the scrollbars for the current scale | |
484 | virtual void AdjustScrollbars(wxPreviewCanvas *canvas); | |
485 | ||
486 | wxPrintDialogData& GetPrintDialogData(); | |
487 | ||
488 | virtual void SetZoom(int percent); | |
489 | int GetZoom(); | |
490 | ||
491 | int GetMaxPage(); | |
492 | int GetMinPage(); | |
493 | ||
494 | bool Ok(); | |
495 | void SetOk(bool ok); | |
496 | ||
497 | virtual bool Print(bool interactive); | |
498 | virtual void DetermineScaling(); | |
499 | ||
500 | %pythoncode { def __nonzero__(self): return self.Ok() } | |
501 | }; | |
502 | ||
503 | ||
504 | ||
505 | //--------------------------------------------------------------------------- | |
506 | ||
1fded56b RD |
507 | // Python-derivable versions of the above preview classes |
508 | ||
509 | %{ | |
3ef86e32 RD |
510 | |
511 | #define DEC_PYCALLBACK_BOOL_PREWINDC(CBNAME) \ | |
512 | bool CBNAME(wxPreviewCanvas* a, wxDC& b); \ | |
513 | bool base_##CBNAME(wxPreviewCanvas* a, wxDC& b) | |
514 | ||
515 | ||
516 | #define IMP_PYCALLBACK_BOOL_PREWINDC(CLASS, PCLASS, CBNAME) \ | |
517 | bool CLASS::CBNAME(wxPreviewCanvas* a, wxDC& b) { \ | |
dd9f7fea | 518 | bool rval=False; \ |
3ef86e32 RD |
519 | bool found; \ |
520 | wxPyBeginBlockThreads(); \ | |
521 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
522 | PyObject* win = wxPyMake_wxObject(a); \ | |
523 | PyObject* dc = wxPyMake_wxObject(&b); \ | |
524 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\ | |
525 | Py_DECREF(win); \ | |
526 | Py_DECREF(dc); \ | |
527 | } \ | |
528 | wxPyEndBlockThreads(); \ | |
529 | if (! found) \ | |
530 | rval = PCLASS::CBNAME(a, b); \ | |
531 | return rval; \ | |
532 | } \ | |
533 | bool CLASS::base_##CBNAME(wxPreviewCanvas* a, wxDC& b) { \ | |
534 | return PCLASS::CBNAME(a, b); \ | |
535 | } | |
536 | ||
537 | ||
538 | ||
539 | ||
1fded56b RD |
540 | class wxPyPrintPreview : public wxPrintPreview |
541 | { | |
542 | DECLARE_CLASS(wxPyPrintPreview) | |
543 | public: | |
544 | wxPyPrintPreview(wxPyPrintout* printout, | |
545 | wxPyPrintout* printoutForPrinting, | |
546 | wxPrintData* data=NULL) | |
547 | : wxPrintPreview(printout, printoutForPrinting, data) | |
548 | {} | |
549 | ||
550 | DEC_PYCALLBACK_BOOL_INT(SetCurrentPage); | |
3ef86e32 RD |
551 | DEC_PYCALLBACK_BOOL_PREWINDC(PaintPage); |
552 | DEC_PYCALLBACK_BOOL_PREWINDC(DrawBlankPage); | |
1fded56b RD |
553 | DEC_PYCALLBACK_BOOL_INT(RenderPage); |
554 | DEC_PYCALLBACK_VOID_INT(SetZoom); | |
555 | DEC_PYCALLBACK_BOOL_BOOL(Print); | |
556 | DEC_PYCALLBACK_VOID_(DetermineScaling); | |
557 | ||
558 | PYPRIVATE; | |
559 | }; | |
560 | ||
561 | // Stupid renamed classes... Fix this in 2.5... | |
562 | #if defined(__WXMSW__) | |
563 | IMPLEMENT_CLASS( wxPyPrintPreview, wxWindowsPrintPreview ); | |
564 | #elif defined(__WXMAC__) | |
565 | IMPLEMENT_CLASS( wxPyPrintPreview, wxMacPrintPreview ); | |
566 | #else | |
567 | IMPLEMENT_CLASS( wxPyPrintPreview, wxPostScriptPrintPreview ); | |
568 | #endif | |
569 | ||
3ef86e32 RD |
570 | IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, SetCurrentPage); |
571 | IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, PaintPage); | |
572 | IMP_PYCALLBACK_BOOL_PREWINDC(wxPyPrintPreview, wxPrintPreview, DrawBlankPage); | |
573 | IMP_PYCALLBACK_BOOL_INT (wxPyPrintPreview, wxPrintPreview, RenderPage); | |
574 | IMP_PYCALLBACK_VOID_INT (wxPyPrintPreview, wxPrintPreview, SetZoom); | |
575 | IMP_PYCALLBACK_BOOL_BOOL (wxPyPrintPreview, wxPrintPreview, Print); | |
576 | IMP_PYCALLBACK_VOID_ (wxPyPrintPreview, wxPrintPreview, DetermineScaling); | |
1fded56b RD |
577 | %} |
578 | ||
579 | ||
580 | class wxPyPrintPreview : public wxPrintPreview | |
581 | { | |
582 | public: | |
d14a1e28 RD |
583 | %addtofunc wxPyPrintPreview "self._setCallbackInfo(self, PyPrintPreview)" |
584 | ||
1fded56b RD |
585 | wxPyPrintPreview(wxPyPrintout* printout, |
586 | wxPyPrintout* printoutForPrinting, | |
587 | wxPrintData* data=NULL); | |
588 | ||
589 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
d14a1e28 | 590 | |
1fded56b | 591 | bool base_SetCurrentPage(int pageNum); |
3ef86e32 RD |
592 | bool base_PaintPage(wxPreviewCanvas *canvas, wxDC& dc); |
593 | bool base_DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc); | |
1fded56b RD |
594 | bool base_RenderPage(int pageNum); |
595 | void base_SetZoom(int percent); | |
596 | bool base_Print(bool interactive); | |
597 | void base_DetermineScaling(); | |
598 | }; | |
599 | ||
600 | ||
bb0054cd | 601 | |
bb0054cd | 602 | |
1fded56b RD |
603 | %{ |
604 | class wxPyPreviewFrame : public wxPreviewFrame | |
605 | { | |
606 | DECLARE_CLASS(wxPyPreviewFrame); | |
607 | public: | |
608 | wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent, | |
609 | const wxString& title, | |
610 | const wxPoint& pos = wxDefaultPosition, | |
611 | const wxSize& size = wxDefaultSize, | |
612 | long style = wxDEFAULT_FRAME_STYLE, | |
613 | const wxString& name = wxPyFrameNameStr) | |
614 | : wxPreviewFrame(preview, parent, title, pos, size, style, name) | |
615 | {} | |
616 | ||
3ef86e32 | 617 | void SetPreviewCanvas(wxPreviewCanvas* canvas) { m_previewCanvas = canvas; } |
1fded56b RD |
618 | void SetControlBar(wxPreviewControlBar* bar) { m_controlBar = bar; } |
619 | ||
620 | DEC_PYCALLBACK_VOID_(Initialize); | |
621 | DEC_PYCALLBACK_VOID_(CreateCanvas); | |
622 | DEC_PYCALLBACK_VOID_(CreateControlBar); | |
623 | ||
624 | PYPRIVATE; | |
625 | }; | |
626 | ||
627 | IMPLEMENT_CLASS(wxPyPreviewFrame, wxPreviewFrame); | |
628 | ||
629 | IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, Initialize); | |
630 | IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateCanvas); | |
631 | IMP_PYCALLBACK_VOID_(wxPyPreviewFrame, wxPreviewFrame, CreateControlBar); | |
632 | %} | |
633 | ||
d14a1e28 | 634 | |
1fded56b RD |
635 | class wxPyPreviewFrame : public wxPreviewFrame |
636 | { | |
637 | public: | |
d14a1e28 RD |
638 | %addtofunc wxPyPreviewFrame "self._setCallbackInfo(self, PyPreviewFrame); self._setOORInfo(self)" |
639 | ||
1fded56b RD |
640 | wxPyPreviewFrame(wxPrintPreview* preview, wxFrame* parent, |
641 | const wxString& title, | |
642 | const wxPoint& pos = wxDefaultPosition, | |
643 | const wxSize& size = wxDefaultSize, | |
644 | long style = wxDEFAULT_FRAME_STYLE, | |
645 | const wxString& name = wxPyFrameNameStr); | |
646 | ||
647 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
1fded56b | 648 | |
3ef86e32 | 649 | void SetPreviewCanvas(wxPreviewCanvas* canvas); |
1fded56b RD |
650 | void SetControlBar(wxPreviewControlBar* bar); |
651 | ||
652 | void base_Initialize(); | |
653 | void base_CreateCanvas(); | |
654 | void base_CreateControlBar(); | |
bb0054cd RD |
655 | }; |
656 | ||
1fded56b RD |
657 | |
658 | ||
659 | ||
660 | %{ | |
661 | class wxPyPreviewControlBar : public wxPreviewControlBar | |
662 | { | |
663 | DECLARE_CLASS(wxPyPreviewControlBar); | |
664 | public: | |
665 | wxPyPreviewControlBar(wxPrintPreview *preview, | |
666 | long buttons, | |
667 | wxWindow *parent, | |
668 | const wxPoint& pos = wxDefaultPosition, | |
669 | const wxSize& size = wxDefaultSize, | |
670 | long style = 0, | |
671 | const wxString& name = wxPyPanelNameStr) | |
672 | : wxPreviewControlBar(preview, buttons, parent, pos, size, style, name) | |
673 | {} | |
674 | ||
675 | void SetPrintPreview(wxPrintPreview* preview) { m_printPreview = preview; } | |
676 | ||
677 | DEC_PYCALLBACK_VOID_(CreateButtons); | |
678 | DEC_PYCALLBACK_VOID_INT(SetZoomControl); | |
679 | ||
680 | PYPRIVATE; | |
681 | }; | |
682 | ||
683 | IMPLEMENT_CLASS(wxPyPreviewControlBar, wxPreviewControlBar); | |
684 | IMP_PYCALLBACK_VOID_(wxPyPreviewControlBar, wxPreviewControlBar, CreateButtons); | |
685 | IMP_PYCALLBACK_VOID_INT(wxPyPreviewControlBar, wxPreviewControlBar, SetZoomControl); | |
686 | %} | |
687 | ||
d14a1e28 | 688 | |
1fded56b RD |
689 | class wxPyPreviewControlBar : public wxPreviewControlBar |
690 | { | |
691 | public: | |
d14a1e28 RD |
692 | %addtofunc wxPyPreviewControlBar "self._setCallbackInfo(self, PyPreviewControlBar); self._setOORInfo(self)" |
693 | ||
1fded56b RD |
694 | wxPyPreviewControlBar(wxPrintPreview *preview, |
695 | long buttons, | |
696 | wxWindow *parent, | |
697 | const wxPoint& pos = wxDefaultPosition, | |
698 | const wxSize& size = wxDefaultSize, | |
699 | long style = 0, | |
700 | const wxString& name = wxPyPanelNameStr); | |
701 | ||
702 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
1fded56b RD |
703 | |
704 | void SetPrintPreview(wxPrintPreview* preview); | |
705 | ||
706 | void base_CreateButtons(); | |
707 | void base_SetZoomControl(int zoom); | |
708 | }; | |
709 | ||
710 | ||
d14a1e28 RD |
711 | //--------------------------------------------------------------------------- |
712 | //--------------------------------------------------------------------------- | |
9416aa89 RD |
713 | %init %{ |
714 | wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout"); | |
715 | %} | |
d14a1e28 | 716 | //--------------------------------------------------------------------------- |