sl@0
|
1 |
// Copyright (c) 1997-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 <banddev.h>
|
sl@0
|
17 |
#include "GNRLSTD.H"
|
sl@0
|
18 |
#include "GENERAL.H"
|
sl@0
|
19 |
#include "pdrtext.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
|
sl@0
|
22 |
EXPORT_C CPrinterDevice* NewPrinterDeviceL()
|
sl@0
|
23 |
{
|
sl@0
|
24 |
CGeneralPrinterDevice* device = new(ELeave) CGeneralPrinterDevice;
|
sl@0
|
25 |
return device;
|
sl@0
|
26 |
}
|
sl@0
|
27 |
|
sl@0
|
28 |
CGeneralPrinterDevice::CGeneralPrinterDevice():
|
sl@0
|
29 |
CPdrDevice()
|
sl@0
|
30 |
{
|
sl@0
|
31 |
__DECLARE_NAME(_S("CGeneralDevice"));
|
sl@0
|
32 |
}
|
sl@0
|
33 |
|
sl@0
|
34 |
CGeneralPrinterDevice::~CGeneralPrinterDevice()
|
sl@0
|
35 |
{
|
sl@0
|
36 |
}
|
sl@0
|
37 |
|
sl@0
|
38 |
TInt CGeneralPrinterDevice::CreateContext(CGraphicsContext*& aGC)
|
sl@0
|
39 |
{
|
sl@0
|
40 |
__ASSERT_DEBUG(iControl, Panic(EGeneralPrinterControlDoesNotExist));
|
sl@0
|
41 |
CPdrControl* control = (CPdrControl*)iControl;
|
sl@0
|
42 |
return control->CreateContext(aGC);
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
TSize CGeneralPrinterDevice::KPixelSizeInTwips() const
|
sl@0
|
46 |
{
|
sl@0
|
47 |
return TSize(iModelInfo->iKPixelWidthInTwips, iModelInfo->iKPixelHeightInTwips);
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
void CGeneralPrinterDevice::CreateControlL(CPrinterPort* aPrinterPort)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
__ASSERT_ALWAYS(aPrinterPort, Panic(EGeneralPrinterRequiresPrinterPort));
|
sl@0
|
53 |
__ASSERT_ALWAYS(!iControl, Panic(EGeneralPrinterControlAlreadyExists));
|
sl@0
|
54 |
__ASSERT_DEBUG(iCurrentPageSpecInTwips.iPortraitPageSize.iWidth && iCurrentPageSpecInTwips.iPortraitPageSize.iHeight, Panic(EGeneralPrinterPageSpecNotSet));
|
sl@0
|
55 |
iControl = CGeneralPrinterControl::NewL(this, aPrinterPort, *iStore, iModelInfo->iResourcesStreamId);
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
CGeneralPrinterControl* CGeneralPrinterControl::NewL(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort, CStreamStore& aStore, TStreamId aResourcesStreamId)
|
sl@0
|
59 |
{
|
sl@0
|
60 |
CGeneralPrinterControl* control = new(ELeave) CGeneralPrinterControl(aPdrDevice, aPrinterPort);
|
sl@0
|
61 |
CleanupStack::PushL(control);
|
sl@0
|
62 |
control->ConstructL(aStore, aResourcesStreamId);
|
sl@0
|
63 |
CleanupStack::Pop();
|
sl@0
|
64 |
return control;
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
CGeneralPrinterControl::~CGeneralPrinterControl()
|
sl@0
|
68 |
{
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
CGeneralPrinterControl::CGeneralPrinterControl(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort):
|
sl@0
|
72 |
CPdrControl(aPdrDevice, aPrinterPort)
|
sl@0
|
73 |
{
|
sl@0
|
74 |
__DECLARE_NAME(_S("CGeneralPrinterControl"));
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
void CGeneralPrinterControl::ConstructL(CStreamStore& aStore, TStreamId aResourcesStreamId)
|
sl@0
|
78 |
{
|
sl@0
|
79 |
if((iPdrDevice->CurrentPageSpecInTwips().iOrientation == TPageSpec::ELandscape)
|
sl@0
|
80 |
&& (iPdrDevice->Flags() & EGeneralLandscapeNotAvailable))
|
sl@0
|
81 |
User::Leave(KErrNotSupported);
|
sl@0
|
82 |
CPdrControl::ConstructL(aStore, aResourcesStreamId);
|
sl@0
|
83 |
|
sl@0
|
84 |
const TRect rect = iPdrDevice->PrintablePageInPixels();
|
sl@0
|
85 |
const TSize size(0,0);
|
sl@0
|
86 |
iBandedDevice = CBandedDevice::NewL(rect, size, iPdrDevice->DisplayMode(), EBandingTopToBottom, 0);
|
sl@0
|
87 |
|
sl@0
|
88 |
iPageText = CPageText::NewL();
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
void CGeneralPrinterControl::OutputTextL(const TPoint& aPoint, TInt aWidthInPixels, const TTextFormat& /*aTextFormat*/, const TDesC8& aString)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
MoveByL(aPoint - iPosition);
|
sl@0
|
94 |
iPageBuffer->AddBytesL(aString);
|
sl@0
|
95 |
iPosition.iX += aWidthInPixels;
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
void CGeneralPrinterControl::OutputBandL()
|
sl@0
|
99 |
{
|
sl@0
|
100 |
TInt numentries = iPageText->NumEntries();
|
sl@0
|
101 |
iPosition = iPdrDevice->OffsetInPixels();
|
sl@0
|
102 |
for(TInt i = 0; i < numentries; i++)
|
sl@0
|
103 |
{
|
sl@0
|
104 |
CPageTextEntry* entry = (*iPageText)[i]; //!!
|
sl@0
|
105 |
OutputTextL(entry->iDrawPos, entry->iTextWidthInPixels, *entry->iTextFormat, entry->iText->Des());
|
sl@0
|
106 |
} //!!
|
sl@0
|
107 |
iPageText->Reset();
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|