]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/printdlg.cpp
use correct scale when drawing
[wxWidgets.git] / src / osx / carbon / printdlg.cpp
CommitLineData
489468fe 1/////////////////////////////////////////////////////////////////////////////
524c47aa 2// Name: src/osx/carbon/printdlg.cpp
489468fe
SC
3// Purpose: wxPrintDialog, wxPageSetupDialog
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#if wxUSE_PRINTING_ARCHITECTURE
15
16#include "wx/printdlg.h"
17
18#ifndef WX_PRECOMP
19 #include "wx/object.h"
20 #include "wx/dcprint.h"
21 #include "wx/msgdlg.h"
22 #include "wx/textctrl.h"
23 #include "wx/sizer.h"
24 #include "wx/stattext.h"
25#endif
26
1f0c8f31
SC
27#include "wx/osx/printdlg.h"
28#include "wx/osx/private/print.h"
29#include "wx/osx/private.h"
489468fe 30#include "wx/statline.h"
691745ab 31#include "wx/modalhook.h"
489468fe 32
489468fe
SC
33int wxMacPrintDialog::ShowModal()
34{
691745ab 35 WX_HOOK_MODAL_DIALOG();
643e9cf9 36
489468fe 37 m_printDialogData.GetPrintData().ConvertToNative();
c347101b 38 ((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData );
489468fe
SC
39
40 int result = wxID_CANCEL;
03647350 41
489468fe
SC
42 OSErr err = noErr;
43 Boolean accepted;
c347101b 44 wxOSXPrintData* nativeData = (wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData();
445e564f 45 wxDialog::OSXBeginModalDialog();
c347101b
SC
46 err = PMSessionPrintDialog(nativeData->GetPrintSession(), nativeData->GetPrintSettings(),
47 nativeData->GetPageFormat(), &accepted );
445e564f 48 wxDialog::OSXEndModalDialog();
489468fe
SC
49
50 if ((err == noErr) && !accepted)
51 {
52 // user clicked Cancel button
53 err = kPMCancel;
54 }
55
56 if (err == noErr)
57 {
58 result = wxID_OK;
59 }
60
61 if ((err != noErr) && (err != kPMCancel))
62 {
63 wxString message;
64
65 message.Printf( wxT("Print Error %d"), err );
66 wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK );
67 dialog.ShowModal();
68 }
69
70 if (result == wxID_OK)
71 {
72 m_printDialogData.GetPrintData().ConvertFromNative();
c347101b 73 ((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData );
489468fe 74 }
489468fe
SC
75 return result;
76}
489468fe 77
489468fe
SC
78int wxMacPageSetupDialog::ShowModal()
79{
691745ab 80 WX_HOOK_MODAL_DIALOG();
643e9cf9 81
489468fe 82 m_pageSetupData.GetPrintData().ConvertToNative();
c347101b
SC
83 wxOSXPrintData* nativeData = (wxOSXPrintData*)m_pageSetupData.GetPrintData().GetNativeData();
84 nativeData->TransferFrom( &m_pageSetupData );
489468fe
SC
85
86 int result = wxID_CANCEL;
489468fe
SC
87 OSErr err = noErr;
88 Boolean accepted;
89
445e564f 90 wxDialog::OSXBeginModalDialog();
c347101b 91 err = PMSessionPageSetupDialog( nativeData->GetPrintSession(), nativeData->GetPageFormat(),
489468fe 92 &accepted );
445e564f 93 wxDialog::OSXEndModalDialog();
489468fe
SC
94
95 if ((err == noErr) && !accepted)
96 {
97 // user clicked Cancel button
98 err = kPMCancel;
99 }
100
101 // If the user did not cancel, flatten and save the PageFormat object
102 // with our document.
103 if (err == noErr)
104 {
105 result = wxID_OK;
106 }
107
108 if ((err != noErr) && (err != kPMCancel))
109 {
110 wxString message;
111
112 message.Printf( wxT("Print Error %d"), err );
113 wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK );
114 dialog.ShowModal();
115 }
116
117 if (result == wxID_OK)
118 {
119 m_pageSetupData.GetPrintData().ConvertFromNative();
120 m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() );
c347101b 121 nativeData->TransferTo( &m_pageSetupData );
489468fe 122 }
489468fe
SC
123 return result;
124}
489468fe
SC
125
126#endif