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