]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/printdlg.cpp
initial implementation for MSW
[wxWidgets.git] / src / mac / carbon / printdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: printdlg.cpp
3 // Purpose: wxPrintDialog, wxPageSetupDialog
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "printdlg.h"
14 #endif
15
16 #include "wx/object.h"
17 #include "wx/printdlg.h"
18 #include "wx/dcprint.h"
19 #include "wx/msgdlg.h"
20 #include "wx/mac/private/print.h"
21
22 // Use generic page setup dialog: use your own native one if one exists.
23
24 IMPLEMENT_DYNAMIC_CLASS(wxMacPrintDialog, wxPrintDialogBase)
25 IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
26
27 wxMacPrintDialog::wxMacPrintDialog()
28 {
29 m_dialogParent = NULL;
30 m_printerDC = NULL;
31 m_destroyDC = TRUE;
32 }
33
34 wxMacPrintDialog::wxMacPrintDialog(wxWindow *p, wxPrintDialogData* data)
35 {
36 Create(p, data);
37 }
38
39 wxMacPrintDialog::wxMacPrintDialog(wxWindow *p, wxPrintData* data)
40 {
41 wxPrintDialogData data2;
42 if ( data )
43 data2 = *data;
44
45 Create(p, &data2);
46 }
47
48 bool wxMacPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
49 {
50 m_dialogParent = p;
51 m_printerDC = NULL;
52 m_destroyDC = TRUE;
53
54 if ( data )
55 m_printDialogData = *data;
56
57 return TRUE;
58 }
59
60 wxMacPrintDialog::~wxMacPrintDialog()
61 {
62 if (m_destroyDC && m_printerDC) {
63 delete m_printerDC;
64 m_printerDC = NULL;
65 }
66 }
67
68 int wxMacPrintDialog::ShowModal()
69 {
70 m_printDialogData.ConvertToNative() ;
71 int result = m_printDialogData.GetPrintData().m_nativePrintData->ShowPrintDialog() ;
72 if ( result == wxID_OK )
73 m_printDialogData.ConvertFromNative() ;
74
75 return result ;
76 }
77
78 wxDC *wxMacPrintDialog::GetPrintDC()
79 {
80 return new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
81 }
82
83 /*
84 * wxPageSetupDialog
85 */
86
87 wxPageSetupDialog::wxPageSetupDialog():
88 wxDialog()
89 {
90 m_dialogParent = NULL;
91 }
92
93 wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
94 wxDialog()
95 {
96 Create(p, data);
97 }
98
99 bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
100 {
101 m_dialogParent = p;
102
103 if (data)
104 m_pageSetupData = (*data);
105
106 return TRUE;
107 }
108
109 wxPageSetupDialog::~wxPageSetupDialog()
110 {
111 }
112
113 int wxPageSetupDialog::ShowModal()
114 {
115 m_pageSetupData.ConvertToNative() ;
116 int result = m_pageSetupData.GetPrintData().m_nativePrintData->ShowPageSetupDialog() ;
117 if (result == wxID_OK )
118 m_pageSetupData.ConvertFromNative() ;
119
120 return result ;
121 }
122