]> git.saurik.com Git - wxWidgets.git/blob - src/mac/printdlg.cpp
adding the notion of cyclic group of radiobutton
[wxWidgets.git] / src / mac / printdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: printdlg.cpp
3 // Purpose: wxPrintDialog, wxPageSetupDialog
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
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
20 // Use generic page setup dialog: use your own native one if one exists.
21
22 #if !USE_SHARED_LIBRARY
23 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
24 IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
25 #endif
26
27 wxPrintDialog::wxPrintDialog()
28 {
29 m_dialogParent = NULL;
30 m_printerDC = NULL;
31 m_destroyDC = TRUE;
32 }
33
34 wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
35 {
36 Create(p, data);
37 }
38
39 wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data)
40 {
41 wxPrintDialogData data2;
42 if ( data )
43 data2 = *data;
44
45 Create(p, &data2);
46 }
47
48 bool wxPrintDialog::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 wxPrintDialog::~wxPrintDialog()
61 {
62 if (m_destroyDC && m_printerDC)
63 delete m_printerDC;
64 }
65
66 int wxPrintDialog::ShowModal()
67 {
68 int result = wxID_CANCEL ;
69 OSErr err ;
70 wxString message ;
71 ::PrOpen() ;
72 err = PrError() ;
73
74 if ( !err )
75 {
76 m_printDialogData.ConvertToNative() ;
77 if ( m_printDialogData.m_macPrintInfo && ::PrJobDialog( m_printDialogData.m_macPrintInfo ) )
78 {
79 m_printDialogData.ConvertFromNative() ;
80 result = wxID_OK ;
81 }
82
83 }
84 else
85 {
86 message.Printf( "Print Error %d", err ) ;
87 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
88 }
89 ::PrClose() ;
90
91 return result ;
92 }
93
94 wxDC *wxPrintDialog::GetPrintDC()
95 {
96 return new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
97 }
98
99 /*
100 * wxPageSetupDialog
101 */
102
103 wxPageSetupDialog::wxPageSetupDialog():
104 wxDialog()
105 {
106 m_dialogParent = NULL;
107 }
108
109 wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
110 wxDialog()
111 {
112 Create(p, data);
113 }
114
115 bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
116 {
117 m_dialogParent = p;
118
119 if (data)
120 m_pageSetupData = (*data);
121
122 return TRUE;
123 }
124
125 wxPageSetupDialog::~wxPageSetupDialog()
126 {
127 }
128
129 int wxPageSetupDialog::ShowModal()
130 {
131 int result = wxID_CANCEL ;
132 OSErr err ;
133 wxString message ;
134 ::PrOpen() ;
135 err = PrError() ;
136
137 if ( !err )
138 {
139 m_pageSetupData.ConvertToNative() ;
140 if ( m_pageSetupData.m_macPageSetupInfo && ::PrStlDialog( m_pageSetupData.m_macPageSetupInfo ) )
141 {
142 m_pageSetupData.ConvertFromNative() ;
143 result = wxID_OK ;
144 }
145
146 }
147 else
148 {
149 message.Printf( "Print Error %d", err ) ;
150 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
151 }
152 ::PrClose() ;
153
154 return result ;
155 }
156