Update contrib.
1 // Copyright (c) 1997-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.
22 EXPORT_C CPrinterDevice* NewPrinterDeviceL()
24 CGeneralPrinterDevice* device = new(ELeave) CGeneralPrinterDevice;
28 CGeneralPrinterDevice::CGeneralPrinterDevice():
31 __DECLARE_NAME(_S("CGeneralDevice"));
34 CGeneralPrinterDevice::~CGeneralPrinterDevice()
38 TInt CGeneralPrinterDevice::CreateContext(CGraphicsContext*& aGC)
40 __ASSERT_DEBUG(iControl, Panic(EGeneralPrinterControlDoesNotExist));
41 CPdrControl* control = (CPdrControl*)iControl;
42 return control->CreateContext(aGC);
45 TSize CGeneralPrinterDevice::KPixelSizeInTwips() const
47 return TSize(iModelInfo->iKPixelWidthInTwips, iModelInfo->iKPixelHeightInTwips);
50 void CGeneralPrinterDevice::CreateControlL(CPrinterPort* aPrinterPort)
52 __ASSERT_ALWAYS(aPrinterPort, Panic(EGeneralPrinterRequiresPrinterPort));
53 __ASSERT_ALWAYS(!iControl, Panic(EGeneralPrinterControlAlreadyExists));
54 __ASSERT_DEBUG(iCurrentPageSpecInTwips.iPortraitPageSize.iWidth && iCurrentPageSpecInTwips.iPortraitPageSize.iHeight, Panic(EGeneralPrinterPageSpecNotSet));
55 iControl = CGeneralPrinterControl::NewL(this, aPrinterPort, *iStore, iModelInfo->iResourcesStreamId);
58 CGeneralPrinterControl* CGeneralPrinterControl::NewL(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort, CStreamStore& aStore, TStreamId aResourcesStreamId)
60 CGeneralPrinterControl* control = new(ELeave) CGeneralPrinterControl(aPdrDevice, aPrinterPort);
61 CleanupStack::PushL(control);
62 control->ConstructL(aStore, aResourcesStreamId);
67 CGeneralPrinterControl::~CGeneralPrinterControl()
71 CGeneralPrinterControl::CGeneralPrinterControl(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort):
72 CPdrControl(aPdrDevice, aPrinterPort)
74 __DECLARE_NAME(_S("CGeneralPrinterControl"));
77 void CGeneralPrinterControl::ConstructL(CStreamStore& aStore, TStreamId aResourcesStreamId)
79 if((iPdrDevice->CurrentPageSpecInTwips().iOrientation == TPageSpec::ELandscape)
80 && (iPdrDevice->Flags() & EGeneralLandscapeNotAvailable))
81 User::Leave(KErrNotSupported);
82 CPdrControl::ConstructL(aStore, aResourcesStreamId);
84 const TRect rect = iPdrDevice->PrintablePageInPixels();
85 const TSize size(0,0);
86 iBandedDevice = CBandedDevice::NewL(rect, size, iPdrDevice->DisplayMode(), EBandingTopToBottom, 0);
88 iPageText = CPageText::NewL();
91 void CGeneralPrinterControl::OutputTextL(const TPoint& aPoint, TInt aWidthInPixels, const TTextFormat& /*aTextFormat*/, const TDesC8& aString)
93 MoveByL(aPoint - iPosition);
94 iPageBuffer->AddBytesL(aString);
95 iPosition.iX += aWidthInPixels;
98 void CGeneralPrinterControl::OutputBandL()
100 TInt numentries = iPageText->NumEntries();
101 iPosition = iPdrDevice->OffsetInPixels();
102 for(TInt i = 0; i < numentries; i++)
104 CPageTextEntry* entry = (*iPageText)[i]; //!!
105 OutputTextL(entry->iDrawPos, entry->iTextWidthInPixels, *entry->iTextFormat, entry->iText->Des());