|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "PDRVSTD.H" |
|
17 |
|
18 #include <fbs.h> |
|
19 #include <banddev.h> |
|
20 #include "PRINTDRV.H" |
|
21 #include "pdrtext.h" |
|
22 |
|
23 |
|
24 EXPORT_C CPrinterDevice* NewPrinterDeviceL() |
|
25 { |
|
26 CPrintDrvDevice* device = new(ELeave) CPrintDrvDevice; |
|
27 return device; |
|
28 } |
|
29 |
|
30 CPrintDrvDevice::CPrintDrvDevice() |
|
31 { |
|
32 __DECLARE_NAME( _S( "CPrintDrvDevice" ) ); |
|
33 } |
|
34 |
|
35 CPrintDrvDevice::~CPrintDrvDevice() |
|
36 { |
|
37 } |
|
38 |
|
39 TInt CPrintDrvDevice::CreateContext( CGraphicsContext*& aGc ) |
|
40 { |
|
41 __ASSERT_DEBUG( iControl, Panic( EPrintDrvControlDoesNotExist ) ); |
|
42 CPdrControl* control = (CPdrControl*) iControl; |
|
43 return control->CreateContext( aGc ); |
|
44 } |
|
45 |
|
46 void CPrintDrvDevice::CreateControlL(CPrinterPort* aPrinterPort) |
|
47 { |
|
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 ); |
|
52 } |
|
53 |
|
54 CPrintDrvControl* CPrintDrvControl::NewL( CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort, CStreamStore& aStore, TStreamId aResourcesStreamId ) |
|
55 { |
|
56 CPrintDrvControl* control = new(ELeave) CPrintDrvControl( aPdrDevice, aPrinterPort ); |
|
57 CleanupStack::PushL( control ); |
|
58 control->ConstructL( aStore, aResourcesStreamId ); |
|
59 CleanupStack::Pop(); |
|
60 return control; |
|
61 } |
|
62 |
|
63 CPrintDrvControl::~CPrintDrvControl() |
|
64 { |
|
65 delete iScanLine; |
|
66 } |
|
67 |
|
68 CPrintDrvControl::CPrintDrvControl( CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort ): |
|
69 CPdrControl( aPdrDevice, aPrinterPort ) |
|
70 { |
|
71 } |
|
72 |
|
73 void CPrintDrvControl::ConstructL( CStreamStore& aStore, TStreamId aResourcesStreamId ) |
|
74 { |
|
75 CPdrControl::ConstructL( aStore, aResourcesStreamId ); |
|
76 TRect rect = iPdrDevice->PrintablePageInPixels(); |
|
77 TSize size; |
|
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() ) ); |
|
82 } |
|
83 |
|
84 void CPrintDrvControl::OutputTextL( const TPoint& aPoint, TInt aWidthInPixels, const TTextFormat& aTextFormat, const TDesC8& aString ) |
|
85 { |
|
86 CPdrControl::OutputTextL( aPoint, aWidthInPixels, aTextFormat, aString ); |
|
87 CommandL( EPdrResource1 ); |
|
88 } |
|
89 |
|
90 void CPrintDrvControl::OutputBandL() |
|
91 { |
|
92 TRect bandrect = iBandedDevice->BandRect(); |
|
93 TSize size = bandrect.Size(); |
|
94 CommandL( EPdrBitmapStart ); |
|
95 for ( TInt i = 0; i<size.iHeight; i++ ) |
|
96 { |
|
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 ); |
|
102 } |
|
103 CommandL( EPdrBitmapEnd ); |
|
104 } |
|
105 |