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