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