]> git.saurik.com Git - wxWidgets.git/blame - src/mac/printdlg.cpp
Some minor clean-ups to the wxScrolledWindow code.
[wxWidgets.git] / src / mac / printdlg.cpp
CommitLineData
e9576ca5
SC
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"
e7549107 17#include "wx/printdlg.h"
e9576ca5 18#include "wx/dcprint.h"
2f1ae414 19#include "wx/mac/uma.h"
e9576ca5
SC
20
21// Use generic page setup dialog: use your own native one if one exists.
e9576ca5 22
2f1ae414 23#if !USE_SHARED_LIBRARY
e9576ca5
SC
24IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
25IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
2f1ae414 26#endif
e9576ca5 27
e7549107 28wxPrintDialog::wxPrintDialog()
e9576ca5
SC
29{
30 m_dialogParent = NULL;
e7549107
SC
31 m_printerDC = NULL;
32 m_destroyDC = TRUE;
e9576ca5
SC
33}
34
e7549107 35wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
e9576ca5
SC
36{
37 Create(p, data);
38}
39
e7549107
SC
40wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data)
41{
42 wxPrintDialogData data2;
43 if ( data )
44 data2 = *data;
45
46 Create(p, &data2);
47}
48
49bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
e9576ca5
SC
50{
51 m_dialogParent = p;
e7549107
SC
52 m_printerDC = NULL;
53 m_destroyDC = TRUE;
e9576ca5
SC
54
55 if ( data )
e7549107 56 m_printDialogData = *data;
e9576ca5
SC
57
58 return TRUE;
59}
60
61wxPrintDialog::~wxPrintDialog()
62{
e7549107
SC
63 if (m_destroyDC && m_printerDC)
64 delete m_printerDC;
e9576ca5
SC
65}
66
67int wxPrintDialog::ShowModal()
68{
519cb848 69 int result = wxID_CANCEL ;
03e11df5 70#if !TARGET_CARBON
2f1ae414 71
519cb848
SC
72 OSErr err ;
73 wxString message ;
2f1ae414 74 ::UMAPrOpen() ;
519cb848
SC
75 err = PrError() ;
76
77 if ( !err )
78 {
e7549107 79 m_printDialogData.ConvertToNative() ;
2f1ae414 80 if ( ::PrJobDialog( m_printDialogData.GetPrintData().m_macPrintInfo ) )
519cb848 81 {
e7549107 82 m_printDialogData.ConvertFromNative() ;
519cb848
SC
83 result = wxID_OK ;
84 }
85
86 }
87 else
88 {
89 message.Printf( "Print Error %d", err ) ;
90 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
91 }
2f1ae414 92 ::UMAPrClose() ;
03e11df5
GD
93#else
94 #if __UNIX__
95 #warning "TODO:Printing for carbon"
96 #else
97 #pragma warning "TODO:Printing for carbon"
98 #endif
99#endif
519cb848 100 return result ;
e9576ca5
SC
101}
102
103wxDC *wxPrintDialog::GetPrintDC()
104{
e7549107 105 return new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
e9576ca5
SC
106}
107
108/*
109 * wxPageSetupDialog
110 */
111
112wxPageSetupDialog::wxPageSetupDialog():
113 wxDialog()
114{
115 m_dialogParent = NULL;
116}
117
118wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
119 wxDialog()
120{
121 Create(p, data);
122}
123
124bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
125{
126 m_dialogParent = p;
127
128 if (data)
129 m_pageSetupData = (*data);
130
131 return TRUE;
132}
133
134wxPageSetupDialog::~wxPageSetupDialog()
135{
136}
137
138int wxPageSetupDialog::ShowModal()
139{
519cb848 140 int result = wxID_CANCEL ;
2f1ae414
SC
141#if !TARGET_CARBON
142
519cb848
SC
143 OSErr err ;
144 wxString message ;
2f1ae414 145 ::UMAPrOpen() ;
519cb848
SC
146 err = PrError() ;
147
148 if ( !err )
149 {
150 m_pageSetupData.ConvertToNative() ;
2f1ae414 151 if ( ::PrStlDialog( m_pageSetupData.GetPrintData().m_macPrintInfo ) )
519cb848
SC
152 {
153 m_pageSetupData.ConvertFromNative() ;
154 result = wxID_OK ;
155 }
156
157 }
158 else
159 {
160 message.Printf( "Print Error %d", err ) ;
161 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
162 }
2f1ae414
SC
163 ::UMAPrClose() ;
164#else
03e11df5
GD
165 #if __UNIX__
166 #warning "TODO:Printing for carbon"
167 #else
168 #pragma warning "TODO:Printing for carbon"
169 #endif
2f1ae414 170#endif
519cb848 171 return result ;
e9576ca5
SC
172}
173