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