]> git.saurik.com Git - wxWidgets.git/blame - src/mac/printdlg.cpp
fixed bug in wxHtmlWindow: HistoryBack/Forward now correctly preserves last entry...
[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 ;
2f1ae414
SC
70 #if !TARGET_CARBON
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
SC
92 ::UMAPrClose() ;
93 #else
94 #pragma warning "TODO:Printing for carbon"
95 #endif
519cb848 96 return result ;
e9576ca5
SC
97}
98
99wxDC *wxPrintDialog::GetPrintDC()
100{
e7549107 101 return new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
e9576ca5
SC
102}
103
104/*
105 * wxPageSetupDialog
106 */
107
108wxPageSetupDialog::wxPageSetupDialog():
109 wxDialog()
110{
111 m_dialogParent = NULL;
112}
113
114wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
115 wxDialog()
116{
117 Create(p, data);
118}
119
120bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
121{
122 m_dialogParent = p;
123
124 if (data)
125 m_pageSetupData = (*data);
126
127 return TRUE;
128}
129
130wxPageSetupDialog::~wxPageSetupDialog()
131{
132}
133
134int wxPageSetupDialog::ShowModal()
135{
519cb848 136 int result = wxID_CANCEL ;
2f1ae414
SC
137#if !TARGET_CARBON
138
519cb848
SC
139 OSErr err ;
140 wxString message ;
2f1ae414 141 ::UMAPrOpen() ;
519cb848
SC
142 err = PrError() ;
143
144 if ( !err )
145 {
146 m_pageSetupData.ConvertToNative() ;
2f1ae414 147 if ( ::PrStlDialog( m_pageSetupData.GetPrintData().m_macPrintInfo ) )
519cb848
SC
148 {
149 m_pageSetupData.ConvertFromNative() ;
150 result = wxID_OK ;
151 }
152
153 }
154 else
155 {
156 message.Printf( "Print Error %d", err ) ;
157 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
158 }
2f1ae414
SC
159 ::UMAPrClose() ;
160#else
161#pragma warning "TODO:printing for carbon"
162#endif
519cb848 163 return result ;
e9576ca5
SC
164}
165