]> git.saurik.com Git - wxWidgets.git/blob - src/mac/printdlg.cpp
fixed menu accelerators
[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/mac/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 wxDialog()
29 {
30 m_dialogParent = NULL;
31 }
32
33 wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data):
34 wxDialog()
35 {
36 Create(p, data);
37 }
38
39 bool wxPrintDialog::Create(wxWindow *p, wxPrintData* data)
40 {
41 m_dialogParent = p;
42
43 if ( data )
44 m_printData = *data;
45
46 return TRUE;
47 }
48
49 wxPrintDialog::~wxPrintDialog()
50 {
51 }
52
53 int wxPrintDialog::ShowModal()
54 {
55 int result = wxID_CANCEL ;
56 OSErr err ;
57 wxString message ;
58 ::PrOpen() ;
59 err = PrError() ;
60
61 if ( !err )
62 {
63 m_printData.ConvertToNative() ;
64 if ( m_printData.macPrintInfo && ::PrJobDialog( m_printData.macPrintInfo ) )
65 {
66 m_printData.ConvertFromNative() ;
67 result = wxID_OK ;
68 }
69
70 }
71 else
72 {
73 message.Printf( "Print Error %d", err ) ;
74 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
75 }
76 ::PrClose() ;
77
78 return result ;
79 }
80
81 wxDC *wxPrintDialog::GetPrintDC()
82 {
83 return new wxPrinterDC( m_printData ) ;
84 }
85
86 /*
87 * wxPageSetupDialog
88 */
89
90 wxPageSetupDialog::wxPageSetupDialog():
91 wxDialog()
92 {
93 m_dialogParent = NULL;
94 }
95
96 wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
97 wxDialog()
98 {
99 Create(p, data);
100 }
101
102 bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
103 {
104 m_dialogParent = p;
105
106 if (data)
107 m_pageSetupData = (*data);
108
109 return TRUE;
110 }
111
112 wxPageSetupDialog::~wxPageSetupDialog()
113 {
114 }
115
116 int wxPageSetupDialog::ShowModal()
117 {
118 int result = wxID_CANCEL ;
119 OSErr err ;
120 wxString message ;
121 ::PrOpen() ;
122 err = PrError() ;
123
124 if ( !err )
125 {
126 m_pageSetupData.ConvertToNative() ;
127 if ( m_pageSetupData.m_macPageSetupInfo && ::PrStlDialog( m_pageSetupData.m_macPageSetupInfo ) )
128 {
129 m_pageSetupData.ConvertFromNative() ;
130 result = wxID_OK ;
131 }
132
133 }
134 else
135 {
136 message.Printf( "Print Error %d", err ) ;
137 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
138 }
139 ::PrClose() ;
140
141 return result ;
142 }
143