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