os/graphics/printingservices/printerdriversupport/tps/PRINTDRV.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/printingservices/printerdriversupport/tps/PRINTDRV.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,105 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "PDRVSTD.H"
    1.20 +
    1.21 +#include <fbs.h>
    1.22 +#include <banddev.h>
    1.23 +#include "PRINTDRV.H"
    1.24 +#include "pdrtext.h"
    1.25 +
    1.26 +
    1.27 +EXPORT_C CPrinterDevice* NewPrinterDeviceL()
    1.28 +	{
    1.29 +	CPrintDrvDevice* device = new(ELeave) CPrintDrvDevice;
    1.30 +	return device;
    1.31 +	}
    1.32 +
    1.33 +CPrintDrvDevice::CPrintDrvDevice()
    1.34 +	{
    1.35 +	__DECLARE_NAME( _S( "CPrintDrvDevice" ) );
    1.36 +	}
    1.37 +
    1.38 +CPrintDrvDevice::~CPrintDrvDevice()
    1.39 +	{
    1.40 +	}
    1.41 +
    1.42 +TInt CPrintDrvDevice::CreateContext( CGraphicsContext*& aGc )
    1.43 +	{
    1.44 +	__ASSERT_DEBUG( iControl, Panic( EPrintDrvControlDoesNotExist ) );
    1.45 +	CPdrControl* control = (CPdrControl*) iControl;
    1.46 +	return control->CreateContext( aGc );
    1.47 +	}
    1.48 +
    1.49 +void CPrintDrvDevice::CreateControlL(CPrinterPort* aPrinterPort)
    1.50 +	{
    1.51 +	__ASSERT_ALWAYS( aPrinterPort, Panic( EPrintDrvRequiresPrinterPort ) );
    1.52 +	__ASSERT_ALWAYS( !iControl, Panic( EPrintDrvControlAlreadyExists ) );
    1.53 +	__ASSERT_DEBUG( iCurrentPageSpecInTwips.iPortraitPageSize.iWidth && iCurrentPageSpecInTwips.iPortraitPageSize.iHeight, Panic( EPrintDrvPageSpecNotSet ) );
    1.54 +	iControl = CPrintDrvControl::NewL( this, aPrinterPort, *iStore, iModelInfo->iResourcesStreamId );
    1.55 +	}
    1.56 +
    1.57 +CPrintDrvControl* CPrintDrvControl::NewL( CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort, CStreamStore& aStore, TStreamId aResourcesStreamId )
    1.58 +	{
    1.59 +	CPrintDrvControl* control = new(ELeave) CPrintDrvControl( aPdrDevice, aPrinterPort );
    1.60 +	CleanupStack::PushL( control );
    1.61 +	control->ConstructL( aStore, aResourcesStreamId );
    1.62 +	CleanupStack::Pop();
    1.63 +	return control;
    1.64 +	}
    1.65 +
    1.66 +CPrintDrvControl::~CPrintDrvControl()
    1.67 +	{
    1.68 +	delete iScanLine;
    1.69 +	}
    1.70 +
    1.71 +CPrintDrvControl::CPrintDrvControl( CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort ):
    1.72 +	CPdrControl( aPdrDevice, aPrinterPort )
    1.73 +	{
    1.74 +	}
    1.75 +
    1.76 +void CPrintDrvControl::ConstructL( CStreamStore& aStore, TStreamId aResourcesStreamId )
    1.77 +	{
    1.78 +	CPdrControl::ConstructL( aStore, aResourcesStreamId );
    1.79 +	TRect rect = iPdrDevice->PrintablePageInPixels();
    1.80 +	TSize size;
    1.81 +	size.iWidth = iPdrDevice->HorizontalPixelsToTwips( 1000 );
    1.82 +	size.iHeight = iPdrDevice->VerticalPixelsToTwips( 1000 );
    1.83 +	iBandedDevice = CBandedDevice::NewL( rect, size, iPdrDevice->DisplayMode(), EBandingTopToBottom );
    1.84 +	iScanLine = HBufC8::NewL( CFbsBitmap::ScanLineLength( iBandedDevice->BandBitmap()->SizeInPixels().iWidth, iPdrDevice->DisplayMode() ) );
    1.85 +	}
    1.86 +
    1.87 +void CPrintDrvControl::OutputTextL( const TPoint& aPoint, TInt aWidthInPixels, const TTextFormat& aTextFormat, const TDesC8& aString )
    1.88 +	{
    1.89 +	CPdrControl::OutputTextL( aPoint, aWidthInPixels, aTextFormat, aString ); 
    1.90 +	CommandL( EPdrResource1 );
    1.91 +	}
    1.92 +
    1.93 +void CPrintDrvControl::OutputBandL()
    1.94 +	{
    1.95 +	TRect bandrect = iBandedDevice->BandRect();
    1.96 +	TSize size = bandrect.Size();
    1.97 +	CommandL( EPdrBitmapStart );
    1.98 +	for ( TInt i = 0; i<size.iHeight; i++ )
    1.99 +		{
   1.100 +		CommandL( EPdrScanLine );
   1.101 +//		TPtr8 ptr = iScanLine->Des();
   1.102 +//		iBandedDevice->BandBitmap()->GetScanLine( ptr, TPoint( 0, i ), size.iWidth, iPdrDevice->DisplayMode() );
   1.103 +//		iPageBuffer->AddBytesL( ptr );
   1.104 +		CommandL( EPdrEndScanLine );
   1.105 +		}
   1.106 +	CommandL( EPdrBitmapEnd );
   1.107 +	}
   1.108 +