Update contrib.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
24 EXPORT_C CPrinterDevice* NewPrinterDeviceL()
26 CPrintDrvDevice* device = new(ELeave) CPrintDrvDevice;
30 CPrintDrvDevice::CPrintDrvDevice()
32 __DECLARE_NAME( _S( "CPrintDrvDevice" ) );
35 CPrintDrvDevice::~CPrintDrvDevice()
39 TInt CPrintDrvDevice::CreateContext( CGraphicsContext*& aGc )
41 __ASSERT_DEBUG( iControl, Panic( EPrintDrvControlDoesNotExist ) );
42 CPdrControl* control = (CPdrControl*) iControl;
43 return control->CreateContext( aGc );
46 void CPrintDrvDevice::CreateControlL(CPrinterPort* aPrinterPort)
48 __ASSERT_ALWAYS( aPrinterPort, Panic( EPrintDrvRequiresPrinterPort ) );
49 __ASSERT_ALWAYS( !iControl, Panic( EPrintDrvControlAlreadyExists ) );
50 __ASSERT_DEBUG( iCurrentPageSpecInTwips.iPortraitPageSize.iWidth && iCurrentPageSpecInTwips.iPortraitPageSize.iHeight, Panic( EPrintDrvPageSpecNotSet ) );
51 iControl = CPrintDrvControl::NewL( this, aPrinterPort, *iStore, iModelInfo->iResourcesStreamId );
54 CPrintDrvControl* CPrintDrvControl::NewL( CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort, CStreamStore& aStore, TStreamId aResourcesStreamId )
56 CPrintDrvControl* control = new(ELeave) CPrintDrvControl( aPdrDevice, aPrinterPort );
57 CleanupStack::PushL( control );
58 control->ConstructL( aStore, aResourcesStreamId );
63 CPrintDrvControl::~CPrintDrvControl()
68 CPrintDrvControl::CPrintDrvControl( CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort ):
69 CPdrControl( aPdrDevice, aPrinterPort )
73 void CPrintDrvControl::ConstructL( CStreamStore& aStore, TStreamId aResourcesStreamId )
75 CPdrControl::ConstructL( aStore, aResourcesStreamId );
76 TRect rect = iPdrDevice->PrintablePageInPixels();
78 size.iWidth = iPdrDevice->HorizontalPixelsToTwips( 1000 );
79 size.iHeight = iPdrDevice->VerticalPixelsToTwips( 1000 );
80 iBandedDevice = CBandedDevice::NewL( rect, size, iPdrDevice->DisplayMode(), EBandingTopToBottom );
81 iScanLine = HBufC8::NewL( CFbsBitmap::ScanLineLength( iBandedDevice->BandBitmap()->SizeInPixels().iWidth, iPdrDevice->DisplayMode() ) );
84 void CPrintDrvControl::OutputTextL( const TPoint& aPoint, TInt aWidthInPixels, const TTextFormat& aTextFormat, const TDesC8& aString )
86 CPdrControl::OutputTextL( aPoint, aWidthInPixels, aTextFormat, aString );
87 CommandL( EPdrResource1 );
90 void CPrintDrvControl::OutputBandL()
92 TRect bandrect = iBandedDevice->BandRect();
93 TSize size = bandrect.Size();
94 CommandL( EPdrBitmapStart );
95 for ( TInt i = 0; i<size.iHeight; i++ )
97 CommandL( EPdrScanLine );
98 // TPtr8 ptr = iScanLine->Des();
99 // iBandedDevice->BandBitmap()->GetScanLine( ptr, TPoint( 0, i ), size.iWidth, iPdrDevice->DisplayMode() );
100 // iPageBuffer->AddBytesL( ptr );
101 CommandL( EPdrEndScanLine );
103 CommandL( EPdrBitmapEnd );