sl@0
|
1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "PDRVSTD.H"
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <fbs.h>
|
sl@0
|
19 |
#include <banddev.h>
|
sl@0
|
20 |
#include "PRINTDRV.H"
|
sl@0
|
21 |
#include "pdrtext.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
|
sl@0
|
24 |
EXPORT_C CPrinterDevice* NewPrinterDeviceL()
|
sl@0
|
25 |
{
|
sl@0
|
26 |
CPrintDrvDevice* device = new(ELeave) CPrintDrvDevice;
|
sl@0
|
27 |
return device;
|
sl@0
|
28 |
}
|
sl@0
|
29 |
|
sl@0
|
30 |
CPrintDrvDevice::CPrintDrvDevice()
|
sl@0
|
31 |
{
|
sl@0
|
32 |
__DECLARE_NAME( _S( "CPrintDrvDevice" ) );
|
sl@0
|
33 |
}
|
sl@0
|
34 |
|
sl@0
|
35 |
CPrintDrvDevice::~CPrintDrvDevice()
|
sl@0
|
36 |
{
|
sl@0
|
37 |
}
|
sl@0
|
38 |
|
sl@0
|
39 |
TInt CPrintDrvDevice::CreateContext( CGraphicsContext*& aGc )
|
sl@0
|
40 |
{
|
sl@0
|
41 |
__ASSERT_DEBUG( iControl, Panic( EPrintDrvControlDoesNotExist ) );
|
sl@0
|
42 |
CPdrControl* control = (CPdrControl*) iControl;
|
sl@0
|
43 |
return control->CreateContext( aGc );
|
sl@0
|
44 |
}
|
sl@0
|
45 |
|
sl@0
|
46 |
void CPrintDrvDevice::CreateControlL(CPrinterPort* aPrinterPort)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
__ASSERT_ALWAYS( aPrinterPort, Panic( EPrintDrvRequiresPrinterPort ) );
|
sl@0
|
49 |
__ASSERT_ALWAYS( !iControl, Panic( EPrintDrvControlAlreadyExists ) );
|
sl@0
|
50 |
__ASSERT_DEBUG( iCurrentPageSpecInTwips.iPortraitPageSize.iWidth && iCurrentPageSpecInTwips.iPortraitPageSize.iHeight, Panic( EPrintDrvPageSpecNotSet ) );
|
sl@0
|
51 |
iControl = CPrintDrvControl::NewL( this, aPrinterPort, *iStore, iModelInfo->iResourcesStreamId );
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
CPrintDrvControl* CPrintDrvControl::NewL( CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort, CStreamStore& aStore, TStreamId aResourcesStreamId )
|
sl@0
|
55 |
{
|
sl@0
|
56 |
CPrintDrvControl* control = new(ELeave) CPrintDrvControl( aPdrDevice, aPrinterPort );
|
sl@0
|
57 |
CleanupStack::PushL( control );
|
sl@0
|
58 |
control->ConstructL( aStore, aResourcesStreamId );
|
sl@0
|
59 |
CleanupStack::Pop();
|
sl@0
|
60 |
return control;
|
sl@0
|
61 |
}
|
sl@0
|
62 |
|
sl@0
|
63 |
CPrintDrvControl::~CPrintDrvControl()
|
sl@0
|
64 |
{
|
sl@0
|
65 |
delete iScanLine;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
CPrintDrvControl::CPrintDrvControl( CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort ):
|
sl@0
|
69 |
CPdrControl( aPdrDevice, aPrinterPort )
|
sl@0
|
70 |
{
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
void CPrintDrvControl::ConstructL( CStreamStore& aStore, TStreamId aResourcesStreamId )
|
sl@0
|
74 |
{
|
sl@0
|
75 |
CPdrControl::ConstructL( aStore, aResourcesStreamId );
|
sl@0
|
76 |
TRect rect = iPdrDevice->PrintablePageInPixels();
|
sl@0
|
77 |
TSize size;
|
sl@0
|
78 |
size.iWidth = iPdrDevice->HorizontalPixelsToTwips( 1000 );
|
sl@0
|
79 |
size.iHeight = iPdrDevice->VerticalPixelsToTwips( 1000 );
|
sl@0
|
80 |
iBandedDevice = CBandedDevice::NewL( rect, size, iPdrDevice->DisplayMode(), EBandingTopToBottom );
|
sl@0
|
81 |
iScanLine = HBufC8::NewL( CFbsBitmap::ScanLineLength( iBandedDevice->BandBitmap()->SizeInPixels().iWidth, iPdrDevice->DisplayMode() ) );
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
void CPrintDrvControl::OutputTextL( const TPoint& aPoint, TInt aWidthInPixels, const TTextFormat& aTextFormat, const TDesC8& aString )
|
sl@0
|
85 |
{
|
sl@0
|
86 |
CPdrControl::OutputTextL( aPoint, aWidthInPixels, aTextFormat, aString );
|
sl@0
|
87 |
CommandL( EPdrResource1 );
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
void CPrintDrvControl::OutputBandL()
|
sl@0
|
91 |
{
|
sl@0
|
92 |
TRect bandrect = iBandedDevice->BandRect();
|
sl@0
|
93 |
TSize size = bandrect.Size();
|
sl@0
|
94 |
CommandL( EPdrBitmapStart );
|
sl@0
|
95 |
for ( TInt i = 0; i<size.iHeight; i++ )
|
sl@0
|
96 |
{
|
sl@0
|
97 |
CommandL( EPdrScanLine );
|
sl@0
|
98 |
// TPtr8 ptr = iScanLine->Des();
|
sl@0
|
99 |
// iBandedDevice->BandBitmap()->GetScanLine( ptr, TPoint( 0, i ), size.iWidth, iPdrDevice->DisplayMode() );
|
sl@0
|
100 |
// iPageBuffer->AddBytesL( ptr );
|
sl@0
|
101 |
CommandL( EPdrEndScanLine );
|
sl@0
|
102 |
}
|
sl@0
|
103 |
CommandL( EPdrBitmapEnd );
|
sl@0
|
104 |
}
|
sl@0
|
105 |
|