]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/printdlg.cpp
Use system default font for all platforms
[wxWidgets.git] / src / mac / printdlg.cpp
... / ...
CommitLineData
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/printdlg.h"
18#include "wx/dcprint.h"
19
20// Use generic page setup dialog: use your own native one if one exists.
21
22IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
23IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
24
25wxPrintDialog::wxPrintDialog()
26{
27 m_dialogParent = NULL;
28 m_printerDC = NULL;
29 m_destroyDC = TRUE;
30}
31
32wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
33{
34 Create(p, data);
35}
36
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)
47{
48 m_dialogParent = p;
49 m_printerDC = NULL;
50 m_destroyDC = TRUE;
51
52 if ( data )
53 m_printDialogData = *data;
54
55 return TRUE;
56}
57
58wxPrintDialog::~wxPrintDialog()
59{
60 if (m_destroyDC && m_printerDC)
61 delete m_printerDC;
62}
63
64int wxPrintDialog::ShowModal()
65{
66 int result = wxID_CANCEL ;
67 OSErr err ;
68 wxString message ;
69 ::PrOpen() ;
70 err = PrError() ;
71
72 if ( !err )
73 {
74 m_printDialogData.ConvertToNative() ;
75 if ( m_printDialogData.m_macPrintInfo && ::PrJobDialog( m_printDialogData.m_macPrintInfo ) )
76 {
77 m_printDialogData.ConvertFromNative() ;
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 ;
90}
91
92wxDC *wxPrintDialog::GetPrintDC()
93{
94 return new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
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{
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 ;
153}
154