]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/printdlg.cpp
Used when the Apparence Manager is not installed
[wxWidgets.git] / src / mac / carbon / 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
SC
18#include "wx/dcprint.h"
19
20// Use generic page setup dialog: use your own native one if one exists.
e9576ca5
SC
21
22#if !USE_SHARED_LIBRARY
23IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
24IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
25#endif
26
e7549107 27wxPrintDialog::wxPrintDialog()
e9576ca5
SC
28{
29 m_dialogParent = NULL;
e7549107
SC
30 m_printerDC = NULL;
31 m_destroyDC = TRUE;
e9576ca5
SC
32}
33
e7549107 34wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
e9576ca5
SC
35{
36 Create(p, data);
37}
38
e7549107
SC
39wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data)
40{
41 wxPrintDialogData data2;
42 if ( data )
43 data2 = *data;
44
45 Create(p, &data2);
46}
47
48bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
e9576ca5
SC
49{
50 m_dialogParent = p;
e7549107
SC
51 m_printerDC = NULL;
52 m_destroyDC = TRUE;
e9576ca5
SC
53
54 if ( data )
e7549107 55 m_printDialogData = *data;
e9576ca5
SC
56
57 return TRUE;
58}
59
60wxPrintDialog::~wxPrintDialog()
61{
e7549107
SC
62 if (m_destroyDC && m_printerDC)
63 delete m_printerDC;
e9576ca5
SC
64}
65
66int wxPrintDialog::ShowModal()
67{
519cb848
SC
68 int result = wxID_CANCEL ;
69 OSErr err ;
70 wxString message ;
71 ::PrOpen() ;
72 err = PrError() ;
73
74 if ( !err )
75 {
e7549107
SC
76 m_printDialogData.ConvertToNative() ;
77 if ( m_printDialogData.m_macPrintInfo && ::PrJobDialog( m_printDialogData.m_macPrintInfo ) )
519cb848 78 {
e7549107 79 m_printDialogData.ConvertFromNative() ;
519cb848
SC
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 ;
e9576ca5
SC
92}
93
94wxDC *wxPrintDialog::GetPrintDC()
95{
e7549107 96 return new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
e9576ca5
SC
97}
98
99/*
100 * wxPageSetupDialog
101 */
102
103wxPageSetupDialog::wxPageSetupDialog():
104 wxDialog()
105{
106 m_dialogParent = NULL;
107}
108
109wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
110 wxDialog()
111{
112 Create(p, data);
113}
114
115bool 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
125wxPageSetupDialog::~wxPageSetupDialog()
126{
127}
128
129int wxPageSetupDialog::ShowModal()
130{
519cb848
SC
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 ;
e9576ca5
SC
155}
156