printing adjustment

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58170 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2009-01-17 11:10:39 +00:00
parent f9af19d2f2
commit e158da36bd
3 changed files with 291 additions and 1 deletions

99
src/osx/cocoa/printdlg.mm Normal file
View File

@@ -0,0 +1,99 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/osx/carbon/printdlg.cpp
// Purpose: wxPrintDialog, wxPageSetupDialog
// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
// RCS-ID: $Id: printdlg.cpp 55419 2008-09-02 16:53:23Z SC $
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
#if wxUSE_PRINTING_ARCHITECTURE
#include "wx/printdlg.h"
#ifndef WX_PRECOMP
#include "wx/object.h"
#include "wx/dcprint.h"
#include "wx/msgdlg.h"
#include "wx/textctrl.h"
#include "wx/sizer.h"
#include "wx/stattext.h"
#endif
#include "wx/osx/printdlg.h"
#include "wx/osx/private/print.h"
#include "wx/osx/private.h"
IMPLEMENT_CLASS(wxOSXCocoaPrintData, wxOSXPrintData)
wxOSXCocoaPrintData::wxOSXCocoaPrintData()
{
m_macPrintInfo = [[NSPrintInfo alloc] init];
// TODO add 10.4 code
m_macPageFormat = (PMPageFormat) [m_macPrintInfo PMPageFormat];
m_macPrintSettings = (PMPrintSettings) [m_macPrintInfo PMPrintSettings];
m_macPrintSession = (PMPrintSession) [m_macPrintInfo PMPrintSession] ;
}
wxOSXCocoaPrintData::~wxOSXCocoaPrintData()
{
[m_macPrintInfo release];
}
void wxOSXCocoaPrintData::UpdateFromPMState()
{
// TODO add 10.4 code
[m_macPrintInfo updateFromPMPageFormat];
[m_macPrintInfo updateFromPMPrintSettings];
}
void wxOSXCocoaPrintData::UpdateToPMState()
{
// TODO add 10.4 code
m_macPageFormat = (PMPageFormat) [m_macPrintInfo PMPageFormat];
m_macPrintSettings = (PMPrintSettings) [m_macPrintInfo PMPrintSettings];
m_macPrintSession = (PMPrintSession) [m_macPrintInfo PMPrintSession] ;
}
int wxMacPrintDialog::ShowModal()
{
m_printDialogData.GetPrintData().ConvertToNative();
int result = wxID_CANCEL;
NSPrintPanel* panel = [NSPrintPanel printPanel];
NSPrintInfo* printInfo = ((wxOSXCocoaPrintData*)m_printDialogData.GetPrintData().GetNativeData())->GetNSPrintInfo();
if ( [panel runModalWithPrintInfo:printInfo] == NSOKButton )
{
result = wxID_OK;
m_printDialogData.GetPrintData().ConvertFromNative();
((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData );
}
return result;
}
int wxMacPageSetupDialog::ShowModal()
{
m_pageSetupData.GetPrintData().ConvertToNative();
((wxOSXCocoaPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->TransferFrom( &m_pageSetupData );
int result = wxID_CANCEL;
NSPageLayout *pageLayout = [NSPageLayout pageLayout];
NSPrintInfo* printInfo = ((wxOSXCocoaPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->GetNSPrintInfo();
if ( [pageLayout runModalWithPrintInfo:printInfo] == NSOKButton )
{
result = wxID_OK;
m_pageSetupData.GetPrintData().ConvertFromNative();
m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() );
}
return result;
}
#endif