]>
Commit | Line | Data |
---|---|---|
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 | ||
40 | ||
41 | class wxPrintData : public wxObject { | |
42 | public: | |
43 | wxPrintData(); | |
44 | ~wxPrintData(); | |
45 | ||
46 | int GetNoCopies(); | |
47 | bool GetCollate(); | |
48 | int GetOrientation(); | |
49 | ||
50 | bool Ok(); | |
51 | ||
52 | const wxString& GetPrinterName(); | |
53 | bool GetColour(); | |
54 | wxDuplexMode GetDuplex(); | |
55 | wxPaperSize GetPaperId(); | |
56 | const wxSize& GetPaperSize(); | |
57 | ||
58 | int GetQuality(); | |
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); | |
69 | void SetQuality(int quality); | |
70 | ||
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); | |
95 | ||
96 | wxOutputStream* GetOutputStream(); | |
97 | void SetOutputStream(wxOutputStream* outputstream); | |
98 | ||
99 | %pythoncode { def __nonzero__(self): return self.Ok() } | |
100 | }; | |
101 | ||
102 | //--------------------------------------------------------------------------- | |
103 | ||
104 | class wxPageSetupDialogData : public wxObject { | |
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(); | |
127 | ||
128 | wxPrintData& GetPrintData(); | |
129 | // %addmethods { | |
130 | // %new wxPrintData* GetPrintData() { | |
131 | // return new wxPrintData(self->GetPrintData()); // force a copy | |
132 | // } | |
133 | // } | |
134 | ||
135 | bool Ok(); | |
136 | ||
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); | |
143 | void SetPaperId(wxPaperSize id); | |
144 | void SetPaperSize(const wxSize& size); | |
145 | void SetPrintData(const wxPrintData& printData); | |
146 | ||
147 | %pythoncode { def __nonzero__(self): return self.Ok() } | |
148 | }; | |
149 | ||
150 | ||
151 | ||
152 | class wxPageSetupDialog : public wxDialog { | |
153 | public: | |
154 | %pythonAppend wxPageSetupDialog "self._setOORInfo(self)" | |
155 | ||
156 | wxPageSetupDialog(wxWindow* parent, wxPageSetupDialogData* data = NULL); | |
157 | ||
158 | wxPageSetupDialogData& GetPageSetupData(); | |
159 | int ShowModal(); | |
160 | }; | |
161 | ||
162 | //--------------------------------------------------------------------------- | |
163 | ||
164 | ||
165 | class wxPrintDialogData : public wxObject { | |
166 | public: | |
167 | wxPrintDialogData(); | |
168 | ~wxPrintDialogData(); | |
169 | ||
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 | ||
192 | void EnablePrintToFile(bool flag); | |
193 | void EnableSelection(bool flag); | |
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 | ||
205 | ||
206 | wxPrintData& GetPrintData(); | |
207 | // %addmethods { | |
208 | // %new wxPrintData* GetPrintData() { | |
209 | // return new wxPrintData(self->GetPrintData()); // force a copy | |
210 | // } | |
211 | // } | |
212 | void SetPrintData(const wxPrintData& printData); | |
213 | ||
214 | %pythoncode { def __nonzero__(self): return self.Ok() } | |
215 | }; | |
216 | ||
217 | ||
218 | class wxPrintDialog : public wxDialog { | |
219 | public: | |
220 | %pythonAppend wxPrintDialog "self._setOORInfo(self)" | |
221 | ||
222 | wxPrintDialog(wxWindow* parent, wxPrintDialogData* data = NULL); | |
223 | ||
224 | wxPrintDialogData& GetPrintDialogData(); | |
225 | ||
226 | %newobject GetPrintDC; | |
227 | wxDC* GetPrintDC(); | |
228 | int ShowModal(); | |
229 | }; | |
230 | ||
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(); | |
251 | bool Print(wxWindow *parent, wxPyPrintout *printout, int prompt=True); | |
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 | //--------------------------------------------------------------------------- | |
262 | // Custom wxPrintout class that knows how to call python | |
263 | %{ | |
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) { | |
268 | bool hadErr = False; | |
269 | bool found; | |
270 | ||
271 | wxPyBeginBlockThreads(); | |
272 | if ((found = wxPyCBH_findCallback(m_myInst, "GetPageInfo"))) { | |
273 | PyObject* result = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); | |
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); | |
279 | else hadErr = True; | |
280 | ||
281 | val = PyTuple_GetItem(result, 1); | |
282 | if (PyInt_Check(val)) *maxPage = PyInt_AsLong(val); | |
283 | else hadErr = True; | |
284 | ||
285 | val = PyTuple_GetItem(result, 2); | |
286 | if (PyInt_Check(val)) *pageFrom = PyInt_AsLong(val); | |
287 | else hadErr = True; | |
288 | ||
289 | val = PyTuple_GetItem(result, 3); | |
290 | if (PyInt_Check(val)) *pageTo = PyInt_AsLong(val); | |
291 | else hadErr = True; | |
292 | } | |
293 | else | |
294 | hadErr = True; | |
295 | ||
296 | if (hadErr) { | |
297 | PyErr_SetString(PyExc_TypeError, "GetPageInfo should return a tuple of 4 integers."); | |
298 | PyErr_Print(); | |
299 | } | |
300 | Py_DECREF(result); | |
301 | } | |
302 | wxPyEndBlockThreads(); | |
303 | if (! found) | |
304 | wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo); | |
305 | } | |
306 | ||
307 | void wxPyPrintout::base_GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) { | |
308 | wxPrintout::GetPageInfo(minPage, maxPage, pageFrom, pageTo); | |
309 | } | |
310 | ||
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 | ||
321 | %} | |
322 | ||
323 | ||
324 | // Now define the custom class for SWIGging | |
325 | %name(Printout) class wxPyPrintout : public wxObject { | |
326 | public: | |
327 | %pythonAppend wxPyPrintout "self._setCallbackInfo(self, Printout)" | |
328 | ||
329 | wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr); | |
330 | //~wxPyPrintout(); wxPrintPreview object takes ownership... | |
331 | ||
332 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
333 | ||
334 | ||
335 | wxString GetTitle() const; | |
336 | wxDC* GetDC(); | |
337 | void SetDC(wxDC *dc); | |
338 | ||
339 | void SetPageSizePixels(int w, int h); | |
340 | DocDeclA( | |
341 | void, GetPageSizePixels(int *OUTPUT, int *OUTPUT), | |
342 | "GetPageSizePixels() -> (w, h)"); | |
343 | ||
344 | void SetPageSizeMM(int w, int h); | |
345 | DocDeclA( | |
346 | void, GetPageSizeMM(int *OUTPUT, int *OUTPUT), | |
347 | "GetPageSizeMM() -> (w, h)"); | |
348 | ||
349 | void SetPPIScreen(int x, int y); | |
350 | DocDeclA( | |
351 | void, GetPPIScreen(int *OUTPUT, int *OUTPUT), | |
352 | "GetPPIScreen() -> (x,y)"); | |
353 | ||
354 | void SetPPIPrinter(int x, int y); | |
355 | DocDeclA( | |
356 | void, GetPPIPrinter(int *OUTPUT, int *OUTPUT), | |
357 | "GetPPIPrinter() -> (x,y)"); | |
358 | ||
359 | bool IsPreview(); | |
360 | void SetIsPreview(bool p); | |
361 | ||
362 | ||
363 | bool base_OnBeginDocument(int startPage, int endPage); | |
364 | void base_OnEndDocument(); | |
365 | void base_OnBeginPrinting(); | |
366 | void base_OnEndPrinting(); | |
367 | void base_OnPreparePrinting(); | |
368 | bool base_HasPage(int page); | |
369 | DocDeclA( | |
370 | void, base_GetPageInfo(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT), | |
371 | "base_GetPageInfo() -> (minPage, maxPage, pageFrom, pageTo)"); | |
372 | }; | |
373 | ||
374 | //--------------------------------------------------------------------------- | |
375 | ||
376 | ||
377 | ||
378 | class wxPreviewCanvas: public wxScrolledWindow | |
379 | { | |
380 | public: | |
381 | %pythonAppend wxPreviewCanvas "self._setOORInfo(self)" | |
382 | ||
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); | |
389 | }; | |
390 | ||
391 | ||
392 | class wxPreviewFrame : public wxFrame { | |
393 | public: | |
394 | %pythonAppend wxPreviewFrame "self._setOORInfo(self)" | |
395 | ||
396 | wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title, | |
397 | const wxPoint& pos = wxDefaultPosition, | |
398 | const wxSize& size = wxDefaultSize, | |
399 | long style = wxDEFAULT_FRAME_STYLE, | |
400 | const wxString& name = wxPyFrameNameStr); | |
401 | ||
402 | void Initialize(); | |
403 | void CreateControlBar(); | |
404 | void CreateCanvas(); | |
405 | ||
406 | wxPreviewControlBar* GetControlBar() const; | |
407 | }; | |
408 | ||
409 | ||
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: | |
434 | %pythonAppend wxPreviewControlBar "self._setOORInfo(self)" | |
435 | ||
436 | wxPreviewControlBar(wxPrintPreview *preview, | |
437 | long buttons, | |
438 | wxWindow *parent, | |
439 | const wxPoint& pos = wxDefaultPosition, | |
440 | const wxSize& size = wxDefaultSize, | |
441 | long style = wxTAB_TRAVERSAL, | |
442 | const wxString& name = wxPyPanelNameStr); | |
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 | ||
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 | ||
511 | // Python-derivable versions of the above preview classes | |
512 | ||
513 | %{ | |
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) { \ | |
522 | bool rval=False; \ | |
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 | ||
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); | |
555 | DEC_PYCALLBACK_BOOL_PREWINDC(PaintPage); | |
556 | DEC_PYCALLBACK_BOOL_PREWINDC(DrawBlankPage); | |
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 | ||
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); | |
581 | %} | |
582 | ||
583 | ||
584 | class wxPyPrintPreview : public wxPrintPreview | |
585 | { | |
586 | public: | |
587 | %pythonAppend wxPyPrintPreview "self._setCallbackInfo(self, PyPrintPreview)" | |
588 | ||
589 | wxPyPrintPreview(wxPyPrintout* printout, | |
590 | wxPyPrintout* printoutForPrinting, | |
591 | wxPrintData* data=NULL); | |
592 | ||
593 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
594 | ||
595 | bool base_SetCurrentPage(int pageNum); | |
596 | bool base_PaintPage(wxPreviewCanvas *canvas, wxDC& dc); | |
597 | bool base_DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc); | |
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 | ||
605 | ||
606 | ||
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 | ||
621 | void SetPreviewCanvas(wxPreviewCanvas* canvas) { m_previewCanvas = canvas; } | |
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 | ||
638 | ||
639 | class wxPyPreviewFrame : public wxPreviewFrame | |
640 | { | |
641 | public: | |
642 | %pythonAppend wxPyPreviewFrame "self._setCallbackInfo(self, PyPreviewFrame); self._setOORInfo(self)" | |
643 | ||
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); | |
652 | ||
653 | void SetPreviewCanvas(wxPreviewCanvas* canvas); | |
654 | void SetControlBar(wxPreviewControlBar* bar); | |
655 | ||
656 | void base_Initialize(); | |
657 | void base_CreateCanvas(); | |
658 | void base_CreateControlBar(); | |
659 | }; | |
660 | ||
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 | ||
692 | ||
693 | class wxPyPreviewControlBar : public wxPreviewControlBar | |
694 | { | |
695 | public: | |
696 | %pythonAppend wxPyPreviewControlBar "self._setCallbackInfo(self, PyPreviewControlBar); self._setOORInfo(self)" | |
697 | ||
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); | |
707 | ||
708 | void SetPrintPreview(wxPrintPreview* preview); | |
709 | ||
710 | void base_CreateButtons(); | |
711 | void base_SetZoomControl(int zoom); | |
712 | }; | |
713 | ||
714 | ||
715 | //--------------------------------------------------------------------------- | |
716 | //--------------------------------------------------------------------------- | |
717 | %init %{ | |
718 | wxPyPtrTypeMap_Add("wxPrintout", "wxPyPrintout"); | |
719 | %} | |
720 | //--------------------------------------------------------------------------- |