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