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