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