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