]> git.saurik.com Git - wxWidgets.git/blame - src/osx/cocoa/printdlg.mm
fixing build
[wxWidgets.git] / src / osx / cocoa / printdlg.mm
CommitLineData
e158da36 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/osx/cocoa/printdlg.mm
e158da36
SC
3// Purpose: wxPrintDialog, wxPageSetupDialog
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
a9a4f229 7// RCS-ID: $Id$
e158da36
SC
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
27#include "wx/osx/printdlg.h"
28#include "wx/osx/private/print.h"
29#include "wx/osx/private.h"
30
31IMPLEMENT_CLASS(wxOSXCocoaPrintData, wxOSXPrintData)
32
33wxOSXCocoaPrintData::wxOSXCocoaPrintData()
34{
35 m_macPrintInfo = [[NSPrintInfo alloc] init];
36 // TODO add 10.4 code
37 m_macPageFormat = (PMPageFormat) [m_macPrintInfo PMPageFormat];
38 m_macPrintSettings = (PMPrintSettings) [m_macPrintInfo PMPrintSettings];
39 m_macPrintSession = (PMPrintSession) [m_macPrintInfo PMPrintSession] ;
fc2f6088 40 PMGetPageFormatPaper(m_macPageFormat, &m_macPaper);
e158da36
SC
41}
42
43wxOSXCocoaPrintData::~wxOSXCocoaPrintData()
44{
45 [m_macPrintInfo release];
46}
47
48void wxOSXCocoaPrintData::UpdateFromPMState()
49{
50 // TODO add 10.4 code
51 [m_macPrintInfo updateFromPMPageFormat];
52 [m_macPrintInfo updateFromPMPrintSettings];
53}
54
55void wxOSXCocoaPrintData::UpdateToPMState()
56{
57 // TODO add 10.4 code
58 m_macPageFormat = (PMPageFormat) [m_macPrintInfo PMPageFormat];
59 m_macPrintSettings = (PMPrintSettings) [m_macPrintInfo PMPrintSettings];
60 m_macPrintSession = (PMPrintSession) [m_macPrintInfo PMPrintSession] ;
61}
62
63int wxMacPrintDialog::ShowModal()
64{
65 m_printDialogData.GetPrintData().ConvertToNative();
66
67 int result = wxID_CANCEL;
03647350 68
e158da36
SC
69 NSPrintPanel* panel = [NSPrintPanel printPanel];
70 NSPrintInfo* printInfo = ((wxOSXCocoaPrintData*)m_printDialogData.GetPrintData().GetNativeData())->GetNSPrintInfo();
9d5cfd0e 71 if ( (NSInteger)[panel runModalWithPrintInfo:printInfo] == NSOKButton )
e158da36
SC
72 {
73 result = wxID_OK;
74 m_printDialogData.GetPrintData().ConvertFromNative();
75 ((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData );
76 }
77
78 return result;
79}
80
81int wxMacPageSetupDialog::ShowModal()
82{
83 m_pageSetupData.GetPrintData().ConvertToNative();
84 ((wxOSXCocoaPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->TransferFrom( &m_pageSetupData );
85
86 int result = wxID_CANCEL;
87
88 NSPageLayout *pageLayout = [NSPageLayout pageLayout];
89 NSPrintInfo* printInfo = ((wxOSXCocoaPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->GetNSPrintInfo();
90 if ( [pageLayout runModalWithPrintInfo:printInfo] == NSOKButton )
91 {
92 result = wxID_OK;
93 m_pageSetupData.GetPrintData().ConvertFromNative();
94 m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() );
95 }
03647350 96
e158da36
SC
97 return result;
98}
99
100#endif