]> git.saurik.com Git - wxWidgets.git/blame - src/mac/printdlg.cpp
usleep() prototype added for solaris
[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"
519cb848 17#include "wx/mac/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
27wxPrintDialog::wxPrintDialog():
28 wxDialog()
29{
30 m_dialogParent = NULL;
e9576ca5
SC
31}
32
33wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data):
34 wxDialog()
35{
36 Create(p, data);
37}
38
39bool wxPrintDialog::Create(wxWindow *p, wxPrintData* data)
40{
41 m_dialogParent = p;
e9576ca5
SC
42
43 if ( data )
44 m_printData = *data;
45
46 return TRUE;
47}
48
49wxPrintDialog::~wxPrintDialog()
50{
e9576ca5
SC
51}
52
53int wxPrintDialog::ShowModal()
54{
519cb848
SC
55 int result = wxID_CANCEL ;
56 OSErr err ;
57 wxString message ;
58 ::PrOpen() ;
59 err = PrError() ;
60
61 if ( !err )
62 {
63 m_printData.ConvertToNative() ;
64 if ( m_printData.macPrintInfo && ::PrJobDialog( m_printData.macPrintInfo ) )
65 {
66 m_printData.ConvertFromNative() ;
67 result = wxID_OK ;
68 }
69
70 }
71 else
72 {
73 message.Printf( "Print Error %d", err ) ;
74 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
75 }
76 ::PrClose() ;
77
78 return result ;
e9576ca5
SC
79}
80
81wxDC *wxPrintDialog::GetPrintDC()
82{
519cb848 83 return new wxPrinterDC( m_printData ) ;
e9576ca5
SC
84}
85
86/*
87 * wxPageSetupDialog
88 */
89
90wxPageSetupDialog::wxPageSetupDialog():
91 wxDialog()
92{
93 m_dialogParent = NULL;
94}
95
96wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
97 wxDialog()
98{
99 Create(p, data);
100}
101
102bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
103{
104 m_dialogParent = p;
105
106 if (data)
107 m_pageSetupData = (*data);
108
109 return TRUE;
110}
111
112wxPageSetupDialog::~wxPageSetupDialog()
113{
114}
115
116int wxPageSetupDialog::ShowModal()
117{
519cb848
SC
118 int result = wxID_CANCEL ;
119 OSErr err ;
120 wxString message ;
121 ::PrOpen() ;
122 err = PrError() ;
123
124 if ( !err )
125 {
126 m_pageSetupData.ConvertToNative() ;
127 if ( m_pageSetupData.m_macPageSetupInfo && ::PrStlDialog( m_pageSetupData.m_macPageSetupInfo ) )
128 {
129 m_pageSetupData.ConvertFromNative() ;
130 result = wxID_OK ;
131 }
132
133 }
134 else
135 {
136 message.Printf( "Print Error %d", err ) ;
137 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
138 }
139 ::PrClose() ;
140
141 return result ;
e9576ca5
SC
142}
143