os/graphics/printingservices/printerdriversupport/src/PDRDEV.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
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 <pdrstore.h>
sl@0
    18
#include <bitdev.h>
sl@0
    19
#include <bitstd.h>
sl@0
    20
#include "PDRBODY.H"
sl@0
    21
#include "PDRSTD.H"
sl@0
    22
#include "pdrtext.h"
sl@0
    23
sl@0
    24
EXPORT_C CPdrDevice::CPdrDevice():
sl@0
    25
	CPrinterDevice(),
sl@0
    26
	iStore(NULL),
sl@0
    27
	iModel(),
sl@0
    28
	iModelInfo(NULL),
sl@0
    29
	iTypefaceStore(NULL)
sl@0
    30
	{
sl@0
    31
	__DECLARE_NAME(_S("CPdrDevice"));
sl@0
    32
	}
sl@0
    33
sl@0
    34
EXPORT_C CPdrDevice::~CPdrDevice()
sl@0
    35
	{
sl@0
    36
	DeleteControl();
sl@0
    37
	delete iModelInfo;
sl@0
    38
	delete iTypefaceStore;
sl@0
    39
	}
sl@0
    40
sl@0
    41
EXPORT_C void CPdrDevice::SelectPageSpecInTwips(const TPageSpec& aPageSpec)
sl@0
    42
	{
sl@0
    43
	CPrinterDevice::SelectPageSpecInTwips(aPageSpec);
sl@0
    44
	iTypefaceStore->SetPageOrientation(aPageSpec.iOrientation);
sl@0
    45
	}
sl@0
    46
sl@0
    47
EXPORT_C TDisplayMode CPdrDevice::DisplayMode() const
sl@0
    48
	{
sl@0
    49
	return iModelInfo->iDisplayMode;
sl@0
    50
	}
sl@0
    51
sl@0
    52
EXPORT_C TSize CPdrDevice::SizeInPixels() const
sl@0
    53
	{
sl@0
    54
	TSize size;
sl@0
    55
	size.iWidth = HorizontalTwipsToPixels(SizeInTwips().iWidth);
sl@0
    56
	size.iHeight = VerticalTwipsToPixels(SizeInTwips().iHeight);
sl@0
    57
	return size;
sl@0
    58
	}
sl@0
    59
sl@0
    60
EXPORT_C TSize CPdrDevice::SizeInTwips() const
sl@0
    61
	{
sl@0
    62
	TSize size;
sl@0
    63
	if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::EPortrait)
sl@0
    64
		{
sl@0
    65
		size = iCurrentPageSpecInTwips.iPortraitPageSize;
sl@0
    66
		}
sl@0
    67
	else if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::ELandscape)
sl@0
    68
		{
sl@0
    69
		size.iWidth = iCurrentPageSpecInTwips.iPortraitPageSize.iHeight;
sl@0
    70
		size.iHeight = iCurrentPageSpecInTwips.iPortraitPageSize.iWidth;
sl@0
    71
		}
sl@0
    72
	return size;
sl@0
    73
	}
sl@0
    74
sl@0
    75
EXPORT_C TRect CPdrDevice::PrintablePageInPixels() const
sl@0
    76
	{
sl@0
    77
	TRect rect;
sl@0
    78
	if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::EPortrait)
sl@0
    79
		{
sl@0
    80
		rect.iTl.iX = iModelInfo->iPortraitOffsetInPixels.iX;
sl@0
    81
		rect.iTl.iY = iModelInfo->iMinMarginsInPixels.iTop;
sl@0
    82
		rect.iBr.iX = SizeInPixels().iWidth-iModelInfo->iPortraitOffsetInPixels.iX;
sl@0
    83
		rect.iBr.iY = SizeInPixels().iHeight-iModelInfo->iMinMarginsInPixels.iBottom;
sl@0
    84
		}
sl@0
    85
	else if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::ELandscape)
sl@0
    86
		{
sl@0
    87
		rect.iTl.iX = iModelInfo->iLandscapeOffsetInPixels.iX;
sl@0
    88
		rect.iTl.iY = iModelInfo->iMinMarginsInPixels.iLeft;
sl@0
    89
		rect.iBr.iX = SizeInPixels().iWidth-iModelInfo->iLandscapeOffsetInPixels.iX;
sl@0
    90
		rect.iBr.iY = SizeInPixels().iHeight-iModelInfo->iMinMarginsInPixels.iRight;
sl@0
    91
		}
sl@0
    92
	return rect;
sl@0
    93
	}
sl@0
    94
sl@0
    95
EXPORT_C TInt CPdrDevice::HorizontalTwipsToPixels(TInt aTwips) const
sl@0
    96
	{
sl@0
    97
	return ((1000 * aTwips) + (KPixelSizeInTwips().iWidth / 2)) / KPixelSizeInTwips().iWidth;
sl@0
    98
	}
sl@0
    99
sl@0
   100
EXPORT_C TInt CPdrDevice::VerticalTwipsToPixels(TInt aTwips) const
sl@0
   101
	{
sl@0
   102
	return ((1000 * aTwips) + (KPixelSizeInTwips().iHeight / 2)) / KPixelSizeInTwips().iHeight;
sl@0
   103
	}
sl@0
   104
sl@0
   105
EXPORT_C TInt CPdrDevice::HorizontalPixelsToTwips(TInt aPixels) const
sl@0
   106
	{
sl@0
   107
	return ((aPixels * KPixelSizeInTwips().iWidth) + 500) / 1000;
sl@0
   108
	}
sl@0
   109
sl@0
   110
EXPORT_C TInt CPdrDevice::VerticalPixelsToTwips(TInt aPixels) const
sl@0
   111
	{
sl@0
   112
	return ((aPixels * KPixelSizeInTwips().iHeight) + 500) / 1000;
sl@0
   113
	}
sl@0
   114
sl@0
   115
/** Creates a font from those available in the printer device's 
sl@0
   116
typeface store that most closely matches a font specification. 
sl@0
   117
sl@0
   118
When the font is no longer needed, call ReleaseFont().
sl@0
   119
sl@0
   120
This function is replaced by GetNearestFontToDesignHeightInTwips()
sl@0
   121
sl@0
   122
@param aFont On return, points to the font which most closely matches the 
sl@0
   123
specified font.
sl@0
   124
@param aFontSpec An absolute font specification. Its iHeight member is 
sl@0
   125
interpreted as being in twips.
sl@0
   126
@return KErrNone if successful; otherwise, another one of the system-wide error 
sl@0
   127
codes.
sl@0
   128
@deprecated */
sl@0
   129
EXPORT_C TInt CPdrDevice::GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec)
sl@0
   130
	{
sl@0
   131
	return GetNearestFontToDesignHeightInTwips(aFont, aFontSpec);
sl@0
   132
	}
sl@0
   133
sl@0
   134
/** Creates a font from those available in the printer device's 
sl@0
   135
typeface store that most closely matches a font specification. 
sl@0
   136
sl@0
   137
When the font is no longer needed, call ReleaseFont().
sl@0
   138
sl@0
   139
This function replaces GetNearestFontInTwips()
sl@0
   140
sl@0
   141
@param aFont On return, points to the font which most closely matches the 
sl@0
   142
specified font.
sl@0
   143
@param aFontSpec An absolute font specification. Its iHeight member is 
sl@0
   144
interpreted as being in twips.
sl@0
   145
@return KErrNone if successful; otherwise, another one of the system-wide error 
sl@0
   146
codes. */
sl@0
   147
EXPORT_C TInt CPdrDevice::GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec)
sl@0
   148
	{
sl@0
   149
	return iTypefaceStore->GetNearestFontToDesignHeightInTwips(aFont, aFontSpec);
sl@0
   150
	}
sl@0
   151
sl@0
   152
/** This call is defined because it had to be - it appeared as an abstract virtual in
sl@0
   153
the base class. But it should never actually get called for this class. */
sl@0
   154
EXPORT_C TInt CPdrDevice::GetNearestFontToMaxHeightInTwips(CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/, TInt /*aMaxHeight*/)
sl@0
   155
	{
sl@0
   156
	return KErrNotSupported;
sl@0
   157
	}
sl@0
   158
sl@0
   159
EXPORT_C TInt CPdrDevice::NumTypefaces() const
sl@0
   160
	{
sl@0
   161
	return iTypefaceStore->NumTypefaces();
sl@0
   162
	}
sl@0
   163
sl@0
   164
EXPORT_C void CPdrDevice::TypefaceSupport(TTypefaceSupport& aTypefaceSupport, TInt aTypefaceIndex) const
sl@0
   165
	{
sl@0
   166
	iTypefaceStore->TypefaceSupport(aTypefaceSupport, aTypefaceIndex);
sl@0
   167
	}
sl@0
   168
sl@0
   169
EXPORT_C TInt CPdrDevice::FontHeightInTwips(TInt aTypefaceIndex, TInt aHeightIndex) const
sl@0
   170
	{
sl@0
   171
	return iTypefaceStore->FontHeightInTwips(aTypefaceIndex, aHeightIndex);
sl@0
   172
	}
sl@0
   173
sl@0
   174
EXPORT_C void CPdrDevice::PaletteAttributes(TBool& aModifiable, TInt& aNumEntries) const
sl@0
   175
	{
sl@0
   176
	aModifiable = EFalse;
sl@0
   177
	aNumEntries = 0;
sl@0
   178
	}
sl@0
   179
sl@0
   180
EXPORT_C void CPdrDevice::SetPalette(CPalette* /*aPalette*/)
sl@0
   181
	{
sl@0
   182
	}
sl@0
   183
	
sl@0
   184
EXPORT_C TInt CPdrDevice::GetPalette(CPalette*& /*aPalette*/) const
sl@0
   185
	{
sl@0
   186
	return KErrNotSupported;
sl@0
   187
	}
sl@0
   188
sl@0
   189
EXPORT_C TPrinterModelEntry CPdrDevice::Model() const
sl@0
   190
	{
sl@0
   191
	return iModel.iEntry;
sl@0
   192
	}
sl@0
   193
sl@0
   194
EXPORT_C TInt CPdrDevice::Flags() const
sl@0
   195
	{
sl@0
   196
	return iModelInfo->iFlags;
sl@0
   197
	}
sl@0
   198
sl@0
   199
EXPORT_C TInt CPdrDevice::SetModel(const TPrinterModelHeader& aModel, CStreamStore& aStore)
sl@0
   200
	{
sl@0
   201
	iModel = aModel;
sl@0
   202
	iStore = &aStore;
sl@0
   203
	TRAPD(ret, DoSetModelL());
sl@0
   204
	return ret;
sl@0
   205
	}
sl@0
   206
sl@0
   207
EXPORT_C void CPdrDevice::ReleaseFont(CFont* aFont)
sl@0
   208
	{
sl@0
   209
	iTypefaceStore->ReleaseFont(aFont);
sl@0
   210
	}
sl@0
   211
sl@0
   212
EXPORT_C TPoint CPdrDevice::OffsetInPixels()
sl@0
   213
	{
sl@0
   214
	TPoint offset;
sl@0
   215
	if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::EPortrait)
sl@0
   216
		offset = iModelInfo->iPortraitOffsetInPixels;
sl@0
   217
	else if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::ELandscape)
sl@0
   218
		offset = iModelInfo->iLandscapeOffsetInPixels;
sl@0
   219
	return offset;
sl@0
   220
	}
sl@0
   221
sl@0
   222
EXPORT_C TSize CPdrDevice::KPixelSizeInTwips() const
sl@0
   223
	{
sl@0
   224
	TSize size; 
sl@0
   225
	if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::EPortrait)
sl@0
   226
		size = TSize(iModelInfo->iKPixelWidthInTwips, iModelInfo->iKPixelHeightInTwips);
sl@0
   227
	else if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::ELandscape)
sl@0
   228
		size = TSize(iModelInfo->iKPixelHeightInTwips, iModelInfo->iKPixelWidthInTwips);
sl@0
   229
	return size;
sl@0
   230
	}
sl@0
   231
sl@0
   232
void CPdrDevice::DoSetModelL()
sl@0
   233
	{
sl@0
   234
	RStoreReadStream stream;
sl@0
   235
	stream.OpenLC(*iStore, iModel.iModelDataStreamId);
sl@0
   236
	iModelInfo = new(ELeave) CPdrModelInfo();
sl@0
   237
	iModelInfo->InternalizeL(stream);
sl@0
   238
	CleanupStack::PopAndDestroy();
sl@0
   239
	iTypefaceStore = CPdrTypefaceStore::NewL(*iStore, iModelInfo->iNumTypefaceFonts, iModelInfo->iTypefaceFontsEntryList, iCurrentPageSpecInTwips.iOrientation, iModelInfo->iKPixelHeightInTwips, this);
sl@0
   240
	}
sl@0
   241
sl@0
   242
EXPORT_C CPdrControl::CPdrControl(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort):
sl@0
   243
	CPrinterControl(aPrinterPort),
sl@0
   244
	iPdrDevice(aPdrDevice),
sl@0
   245
	iPageBuffer(NULL),
sl@0
   246
	iResources(NULL),
sl@0
   247
	iBandedDevice(NULL),
sl@0
   248
	iPageText(NULL),
sl@0
   249
	iBandIndex(0),
sl@0
   250
	iEntryIndex(0),
sl@0
   251
	iPosition(iPdrDevice->OffsetInPixels()),
sl@0
   252
	iTextFormat()
sl@0
   253
	{
sl@0
   254
	__DECLARE_NAME(_S("CPdrControl"));
sl@0
   255
	}
sl@0
   256
sl@0
   257
EXPORT_C CPdrControl::~CPdrControl()
sl@0
   258
	{
sl@0
   259
	delete iPageBuffer;
sl@0
   260
	delete iResources;
sl@0
   261
	delete iBandedDevice;
sl@0
   262
	delete iPageText;
sl@0
   263
	}
sl@0
   264
sl@0
   265
EXPORT_C TInt CPdrControl::CreateContext(CGraphicsContext*& aGC)
sl@0
   266
	{
sl@0
   267
	__ASSERT_DEBUG(iState == EPrinting, Panic(EPdrNotPrinting));
sl@0
   268
	TRAPD(ret, aGC = CPdrGc::NewL(iPdrDevice));
sl@0
   269
	return ret;
sl@0
   270
	}
sl@0
   271
sl@0
   272
EXPORT_C TInt CPdrControl::BandsPerPage()
sl@0
   273
	{
sl@0
   274
	TInt numbands = {iBandedDevice ? iBandedDevice->NumBands() + 1 : 1};
sl@0
   275
	return numbands;
sl@0
   276
	}
sl@0
   277
sl@0
   278
/**
sl@0
   279
 @return EMoreOnPage if more to print on the current page,
sl@0
   280
 otherwise ENoMoreOnPage.
sl@0
   281
*/
sl@0
   282
EXPORT_C CPrinterControl::TMoreOnPage CPdrControl::QueueGetBand(TRequestStatus& aStatus, TBandAttributes& aBand)
sl@0
   283
	{
sl@0
   284
	TMoreOnPage moreonpage = ENoMoreOnPage;
sl@0
   285
sl@0
   286
	TRAPD(ret, DoQueueGetBandL());
sl@0
   287
	if (ret != KErrNone)
sl@0
   288
		{
sl@0
   289
		TRequestStatus* status = &aStatus;
sl@0
   290
		User::RequestComplete(status, ret);
sl@0
   291
		}
sl@0
   292
	else
sl@0
   293
		{
sl@0
   294
		if (IsGraphicsBand())
sl@0
   295
			{
sl@0
   296
			aBand.iRect = iBandedDevice->BandRect();
sl@0
   297
			aBand.iTextIsIgnored = ETrue;
sl@0
   298
			aBand.iGraphicsIsIgnored = EFalse;
sl@0
   299
			aBand.iFirstBandOnPage = EFalse;
sl@0
   300
			}
sl@0
   301
		else
sl@0
   302
			{
sl@0
   303
			aBand.iRect = iPdrDevice->PrintablePageInPixels();
sl@0
   304
			aBand.iTextIsIgnored = EFalse;
sl@0
   305
			aBand.iGraphicsIsIgnored = ETrue;
sl@0
   306
			aBand.iFirstBandOnPage = ETrue;
sl@0
   307
			}
sl@0
   308
		if (iBandIndex == (BandsPerPage() - 1))
sl@0
   309
			moreonpage = ENoMoreOnPage;
sl@0
   310
		else
sl@0
   311
			moreonpage = EMoreOnPage;
sl@0
   312
		iPageBuffer->StartFlush(aStatus);
sl@0
   313
		}
sl@0
   314
	return moreonpage;
sl@0
   315
	}
sl@0
   316
sl@0
   317
EXPORT_C void CPdrControl::QueueEndPrint(TRequestStatus& aStatus)
sl@0
   318
	{
sl@0
   319
	TRAPD(ret, DoQueueEndPrintL());
sl@0
   320
	iState = ENotPrinting;
sl@0
   321
	if (ret != KErrNone)
sl@0
   322
		{
sl@0
   323
		TRequestStatus* status = &aStatus;
sl@0
   324
		User::RequestComplete(status, ret);
sl@0
   325
		}
sl@0
   326
	else
sl@0
   327
		iPageBuffer->StartFlush(aStatus);
sl@0
   328
	}
sl@0
   329
sl@0
   330
/**
sl@0
   331
 Tidy up synchronously in a short time.
sl@0
   332
*/
sl@0
   333
EXPORT_C void CPdrControl::AbortPrint() // tidy up synchronously in a short time, return success code
sl@0
   334
	{
sl@0
   335
	iPageBuffer->Cancel(); // dont call DoCancel()
sl@0
   336
	iState = ENotPrinting;
sl@0
   337
	}
sl@0
   338
sl@0
   339
EXPORT_C void CPdrControl::DrawTextL(const TPoint& aPoint, const TFontUnderline aUnderlineStyle, const TFontStrikethrough aStrikethroughStyle, const TRgb& aColor, const CInfoFont* aFont, const TDesC& aString)
sl@0
   340
	{
sl@0
   341
	__ASSERT_DEBUG(iState == EPrinting,Panic(EPdrNotPrinting));
sl@0
   342
	if (iPageText)
sl@0
   343
		iPageText->AddEntryL(aPoint, aUnderlineStyle, aStrikethroughStyle, aColor, aFont, aString);
sl@0
   344
	else
sl@0
   345
		{
sl@0
   346
		HBufC8* string = aFont->TranslateStringL(aString);
sl@0
   347
		CleanupStack::PushL(string);
sl@0
   348
		TTextFormat textformat(aUnderlineStyle, aStrikethroughStyle, aColor, aFont->CommandString(), aFont->FontSpecInTwips().iFontStyle);
sl@0
   349
		OutputTextL(aPoint + TPoint(0, aFont->BaselineOffsetInPixels()), aFont->MeasureText(aString), textformat,string->Des());
sl@0
   350
		CleanupStack::PopAndDestroy();
sl@0
   351
		}
sl@0
   352
	}
sl@0
   353
sl@0
   354
EXPORT_C TBool CPdrControl::IsGraphicsBand() const
sl@0
   355
	{
sl@0
   356
	return iBandIndex;
sl@0
   357
	}
sl@0
   358
sl@0
   359
EXPORT_C void CPdrControl::MoveToL(const TPoint& aPoint) 
sl@0
   360
	{
sl@0
   361
	// PCL, at least, treats move command strings with an explicit
sl@0
   362
	// sign as being relative, so if the offset is negative then
sl@0
   363
	// set the absolute position to zero first.
sl@0
   364
sl@0
   365
	TPoint offset = iPdrDevice->OffsetInPixels();
sl@0
   366
	TCommandString des;
sl@0
   367
	if (aPoint.iX - iPosition.iX)
sl@0
   368
		{
sl@0
   369
		if (aPoint.iX - iPosition.iX < 0)
sl@0
   370
			{
sl@0
   371
			des.Format(iResources->ResourceString(EPdrSetXPos), 0);
sl@0
   372
			iPageBuffer->AddBytesL(des);
sl@0
   373
			}
sl@0
   374
sl@0
   375
		des.Format(iResources->ResourceString(EPdrSetXPos), aPoint.iX - offset.iX);
sl@0
   376
		iPageBuffer->AddBytesL(des);
sl@0
   377
		}
sl@0
   378
	if (aPoint.iY - iPosition.iY)
sl@0
   379
		{
sl@0
   380
		if (aPoint.iY - iPosition.iY < 0)
sl@0
   381
			{
sl@0
   382
			des.Format(iResources->ResourceString(EPdrSetYPos), 0);
sl@0
   383
			iPageBuffer->AddBytesL(des);
sl@0
   384
			}
sl@0
   385
sl@0
   386
		des.Format(iResources->ResourceString(EPdrSetYPos), aPoint.iY - offset.iY);
sl@0
   387
		iPageBuffer->AddBytesL(des);
sl@0
   388
		}
sl@0
   389
	iPosition = aPoint;
sl@0
   390
	}
sl@0
   391
sl@0
   392
EXPORT_C void CPdrControl::MoveByL(const TPoint& aVector) 
sl@0
   393
	{
sl@0
   394
	TCommandString resource;
sl@0
   395
	TCommandString des;
sl@0
   396
	TPoint vector = aVector;
sl@0
   397
	if (vector.iX)
sl@0
   398
		{
sl@0
   399
		if (aVector.iX < 0)
sl@0
   400
			{
sl@0
   401
			CommandL(EPdrCarriageReturn);
sl@0
   402
			vector.iX += iPosition.iX - iPdrDevice->OffsetInPixels().iX;
sl@0
   403
			}
sl@0
   404
		resource.Copy(iResources->ResourceString(EPdrIncrementXPos));
sl@0
   405
		__ASSERT_DEBUG(resource.Length() >= 2, Panic(EPdrBadResourceString));
sl@0
   406
		if (resource[0] == '*')
sl@0
   407
			{
sl@0
   408
			for (; vector.iX > 0; vector.iX--)
sl@0
   409
				iPageBuffer->AddBytesL(resource.Mid(1));
sl@0
   410
			}
sl@0
   411
		else
sl@0
   412
			{
sl@0
   413
			des.Format(resource, vector.iX);
sl@0
   414
			iPageBuffer->AddBytesL(des);
sl@0
   415
			}
sl@0
   416
		}
sl@0
   417
	resource.Copy(iResources->ResourceString(EPdrIncrementYPos));
sl@0
   418
	if (vector.iY)
sl@0
   419
		{
sl@0
   420
		__ASSERT_DEBUG(resource.Length() >= 2, Panic(EPdrBadResourceString));
sl@0
   421
		if (resource[0] == '*')
sl@0
   422
			{
sl@0
   423
			for (; vector.iY > 0; vector.iY--)
sl@0
   424
				iPageBuffer->AddBytesL(resource.Mid(1));
sl@0
   425
			}
sl@0
   426
		else
sl@0
   427
			{
sl@0
   428
			des.Format(resource, vector.iY);
sl@0
   429
			iPageBuffer->AddBytesL(des);
sl@0
   430
			}
sl@0
   431
		}
sl@0
   432
	iPosition += aVector;
sl@0
   433
	}
sl@0
   434
sl@0
   435
EXPORT_C void CPdrControl::OutputTextL(const TPoint& aPoint, TInt aWidthInPixels, const TTextFormat& aTextFormat, const TDesC8& aString)
sl@0
   436
	{
sl@0
   437
	__ASSERT_DEBUG(iState == EPrinting,Panic(EPdrNotPrinting));
sl@0
   438
sl@0
   439
	if (iTextFormat.iFontString.Compare(aTextFormat.iFontString))
sl@0
   440
		iPageBuffer->AddBytesL(aTextFormat.iFontString);
sl@0
   441
sl@0
   442
	if (iTextFormat.iFontStyle.Posture() != aTextFormat.iFontStyle.Posture())
sl@0
   443
		SetFontPostureL(aTextFormat.iFontStyle.Posture());
sl@0
   444
sl@0
   445
	if (iTextFormat.iFontStyle.StrokeWeight() != aTextFormat.iFontStyle.StrokeWeight())
sl@0
   446
		SetFontStrokeWeightL(aTextFormat.iFontStyle.StrokeWeight());
sl@0
   447
sl@0
   448
	if (iTextFormat.iColor != aTextFormat.iColor)
sl@0
   449
		SetTextColorL(aTextFormat.iColor);
sl@0
   450
sl@0
   451
	iTextFormat = aTextFormat;
sl@0
   452
sl@0
   453
	MoveToL(aPoint);
sl@0
   454
sl@0
   455
	if (aTextFormat.iUnderlineStyle == EUnderlineOn)
sl@0
   456
		CommandL(EPdrUnderlineOn);
sl@0
   457
sl@0
   458
	if (aTextFormat.iStrikethroughStyle == EStrikethroughOn)
sl@0
   459
		CommandL(EPdrStrikethroughOn);
sl@0
   460
sl@0
   461
	iPageBuffer->AddBytesL(aString);
sl@0
   462
sl@0
   463
	iPosition.iX += aWidthInPixels;
sl@0
   464
sl@0
   465
	if (aTextFormat.iUnderlineStyle == EUnderlineOn)
sl@0
   466
		CommandL(EPdrUnderlineOff);
sl@0
   467
sl@0
   468
	if (aTextFormat.iStrikethroughStyle == EStrikethroughOn)
sl@0
   469
		CommandL(EPdrStrikethroughOff);
sl@0
   470
	}
sl@0
   471
sl@0
   472
EXPORT_C void CPdrControl::DoQueueGetBandL()
sl@0
   473
	{
sl@0
   474
	if (iState == ENotPrinting)
sl@0
   475
		{
sl@0
   476
		iState = EPrinting;
sl@0
   477
		iBandIndex = 0;
sl@0
   478
		if (iBandedDevice)
sl@0
   479
			iBandedDevice->Reset();
sl@0
   480
		CommandL(EPdrReset);
sl@0
   481
		SetPageSizeL();
sl@0
   482
		CommandL(EPdrPreAmble);
sl@0
   483
		SetPageOrientationL();
sl@0
   484
		SetTextColorL(KRgbBlack);	
sl@0
   485
		}
sl@0
   486
 	else 
sl@0
   487
		{
sl@0
   488
		OutputBandL();
sl@0
   489
		if (iBandIndex == (BandsPerPage() - 1))
sl@0
   490
			{
sl@0
   491
			iBandIndex = 0;
sl@0
   492
			iEntryIndex = 0;
sl@0
   493
			if (iPageText)
sl@0
   494
				iPageText->Reset(); 
sl@0
   495
			CommandL(EPdrNewPage);
sl@0
   496
			iPosition = iPdrDevice->OffsetInPixels();
sl@0
   497
			}
sl@0
   498
		else
sl@0
   499
			iBandIndex = iBandedDevice->NextBand() + 1;
sl@0
   500
		}
sl@0
   501
	}
sl@0
   502
sl@0
   503
EXPORT_C void CPdrControl::DoQueueEndPrintL()
sl@0
   504
	{
sl@0
   505
	OutputBandL();
sl@0
   506
	CommandL(EPdrPostAmble);
sl@0
   507
	}
sl@0
   508
sl@0
   509
EXPORT_C void CPdrControl::ConstructL(CStreamStore& aStore, TStreamId aStreamId)
sl@0
   510
	{
sl@0
   511
	__ASSERT_ALWAYS(iPrinterPort, Panic(EPdrRequiresPrinterPort));
sl@0
   512
	iPageBuffer = CPageBuffer::NewL(iPrinterPort);
sl@0
   513
	iResources = new(ELeave) CPdrResources();
sl@0
   514
	iResources->RestoreL(aStore, aStreamId);
sl@0
   515
	}
sl@0
   516
sl@0
   517
EXPORT_C void CPdrControl::SetPageSizeL()
sl@0
   518
	{
sl@0
   519
	}
sl@0
   520
	 
sl@0
   521
EXPORT_C void CPdrControl::SetPageOrientationL()
sl@0
   522
	{
sl@0
   523
	TPageSpec::TPageOrientation orientation = iPdrDevice->CurrentPageSpecInTwips().iOrientation;
sl@0
   524
	if (orientation == TPageSpec::EPortrait)
sl@0
   525
		CommandL(EPdrPortrait);
sl@0
   526
	else
sl@0
   527
		CommandL(EPdrLandscape);
sl@0
   528
	}
sl@0
   529
sl@0
   530
EXPORT_C void CPdrControl::SetFontStrokeWeightL(const TFontStrokeWeight aStrokeWeight)
sl@0
   531
	{
sl@0
   532
	if (aStrokeWeight == EStrokeWeightNormal)
sl@0
   533
		CommandL(EPdrBoldOff);
sl@0
   534
	else 
sl@0
   535
		CommandL(EPdrBoldOn);
sl@0
   536
	}
sl@0
   537
sl@0
   538
EXPORT_C void CPdrControl::SetFontPostureL(const TFontPosture aPosture)
sl@0
   539
	{
sl@0
   540
	if (aPosture == EPostureUpright)
sl@0
   541
		CommandL(EPdrItalicOff);
sl@0
   542
	else 
sl@0
   543
		CommandL(EPdrItalicOn);
sl@0
   544
	}
sl@0
   545
sl@0
   546
EXPORT_C void CPdrControl::SetTextColorL(const TRgb& /*aColor*/) 
sl@0
   547
	{
sl@0
   548
	}
sl@0
   549
sl@0
   550
EXPORT_C void CPdrControl::CommandL(const TInt anId) 
sl@0
   551
	{
sl@0
   552
	iPageBuffer->AddBytesL(iResources->ResourceString(anId));
sl@0
   553
	}
sl@0
   554
sl@0
   555
void CPdrGc::ConstructL()
sl@0
   556
	{
sl@0
   557
	if (PdrControl()->BandedDevice())
sl@0
   558
		{
sl@0
   559
		User::LeaveIfError(PdrControl()->BandedDevice()->CreateContext((CGraphicsContext*&)iBandedGc));
sl@0
   560
		TFontSpec spec;
sl@0
   561
		User::LeaveIfError(PdrControl()->BandedDevice()->GetNearestFontToDesignHeightInTwips((CFont*&)iFbsFont, spec));
sl@0
   562
		iBandedGc->UseFont(iFbsFont);
sl@0
   563
		}
sl@0
   564
	}
sl@0
   565
sl@0
   566
CPdrGc::CPdrGc(CPdrDevice* aDevice):
sl@0
   567
	iPdrDevice(aDevice),
sl@0
   568
	iBandedGc(NULL),
sl@0
   569
	iFbsFont(NULL),
sl@0
   570
	iBandedFont(NULL),
sl@0
   571
	iFont(NULL),
sl@0
   572
	iOrigin(0, 0),
sl@0
   573
	iPosition(0, 0),
sl@0
   574
	iUnderlineStyle(EUnderlineOff),
sl@0
   575
	iStrikethroughStyle(EStrikethroughOff),
sl@0
   576
	iClippingRect(iPdrDevice->PrintablePageInPixels()),
sl@0
   577
	iWordExcessWidthInPixels(0),
sl@0
   578
	iNumGaps(0),
sl@0
   579
	iCharExcessWidthInPixels(0),
sl@0
   580
	iNumChars(0),
sl@0
   581
	iPenColor(KRgbBlack)
sl@0
   582
	{
sl@0
   583
	}
sl@0
   584
sl@0
   585
CPdrGc* CPdrGc::NewL(CPdrDevice* aDevice)
sl@0
   586
	{
sl@0
   587
	CPdrGc* gc = new(ELeave) CPdrGc(aDevice);
sl@0
   588
	CleanupStack::PushL(gc);
sl@0
   589
	gc->ConstructL();
sl@0
   590
	CleanupStack::Pop();
sl@0
   591
	return gc;
sl@0
   592
	}
sl@0
   593
sl@0
   594
EXPORT_C CPdrGc::~CPdrGc()
sl@0
   595
	{
sl@0
   596
	if (iBandedGc)
sl@0
   597
		{
sl@0
   598
		if (iBandedGc->IsFontUsed())
sl@0
   599
			{
sl@0
   600
			iBandedGc->DiscardFont();
sl@0
   601
			iBandedFont = NULL;
sl@0
   602
			}
sl@0
   603
		delete iBandedGc;
sl@0
   604
		PdrControl()->BandedDevice()->ReleaseFont(iFbsFont);
sl@0
   605
		}
sl@0
   606
	}
sl@0
   607
sl@0
   608
EXPORT_C CGraphicsDevice* CPdrGc::Device() const
sl@0
   609
	{
sl@0
   610
	return iPdrDevice;
sl@0
   611
	}
sl@0
   612
sl@0
   613
EXPORT_C void CPdrGc::SetOrigin(const TPoint& aPos)
sl@0
   614
	{
sl@0
   615
	if (!PdrControl()->IsGraphicsBand())
sl@0
   616
		iOrigin = aPos;
sl@0
   617
	TPoint pos = PdrControl()->BandedDevice()->FullOriginToBandOrigin(aPos);
sl@0
   618
	iBandedGc->SetOrigin(pos);
sl@0
   619
	}
sl@0
   620
sl@0
   621
EXPORT_C void CPdrGc::SetDrawMode(TDrawMode aDrawingMode)
sl@0
   622
	{
sl@0
   623
	iBandedGc->SetDrawMode(aDrawingMode);
sl@0
   624
	}
sl@0
   625
sl@0
   626
EXPORT_C void CPdrGc::SetClippingRect(const TRect& aRect)
sl@0
   627
	{
sl@0
   628
	if (!PdrControl()->IsGraphicsBand())
sl@0
   629
		{
sl@0
   630
		iClippingRect = aRect;
sl@0
   631
		iClippingRect.Move(TPoint(0, 0) + iOrigin);	//  Recorded in original coordinates
sl@0
   632
		}
sl@0
   633
	iBandedGc->SetClippingRect(aRect);
sl@0
   634
	}
sl@0
   635
sl@0
   636
EXPORT_C void CPdrGc::CancelClippingRect()
sl@0
   637
	{
sl@0
   638
	if (!PdrControl()->IsGraphicsBand())
sl@0
   639
		iClippingRect = iPdrDevice->PrintablePageInPixels();
sl@0
   640
	iBandedGc->CancelClippingRect();
sl@0
   641
	}
sl@0
   642
sl@0
   643
EXPORT_C void CPdrGc::Reset()
sl@0
   644
	{
sl@0
   645
	if (iBandedGc->IsFontUsed())
sl@0
   646
		{
sl@0
   647
		iBandedGc->DiscardFont();
sl@0
   648
		iBandedFont = NULL;
sl@0
   649
		}
sl@0
   650
	iBandedGc->Reset();
sl@0
   651
	iBandedGc->UseFont(iFbsFont);
sl@0
   652
	SetOrigin(TPoint(0, 0));
sl@0
   653
	CancelClippingRect();
sl@0
   654
	}
sl@0
   655
sl@0
   656
EXPORT_C void CPdrGc::UseFont(const CFont* aFont)
sl@0
   657
	{
sl@0
   658
	if (aFont->TypeUid() == TUid::Uid(KCInfoFontUidVal))
sl@0
   659
		{
sl@0
   660
		iFont = (CInfoFont*)aFont;
sl@0
   661
		iPrintTextUsingBitmaps = EFalse;
sl@0
   662
		// We may have to use bitmaps - so set the font up in the bitmap gc as well
sl@0
   663
		if (iBandedGc->IsFontUsed())
sl@0
   664
			iBandedGc->DiscardFont();
sl@0
   665
		iBandedFont = iFont->RealFont();
sl@0
   666
		iBandedGc->UseFont(iBandedFont);
sl@0
   667
		}
sl@0
   668
	else 
sl@0
   669
		{
sl@0
   670
		if (iBandedGc->IsFontUsed())
sl@0
   671
			{
sl@0
   672
			iBandedGc->DiscardFont();
sl@0
   673
			iBandedFont = NULL;
sl@0
   674
			}
sl@0
   675
		iBandedGc->UseFont(aFont);
sl@0
   676
		iPrintTextUsingBitmaps = ETrue;
sl@0
   677
		}
sl@0
   678
	}
sl@0
   679
sl@0
   680
EXPORT_C void CPdrGc::DiscardFont()
sl@0
   681
	{
sl@0
   682
	iFont = NULL;
sl@0
   683
	if (iBandedFont)
sl@0
   684
		{
sl@0
   685
		iBandedGc->DiscardFont();
sl@0
   686
		iBandedFont = NULL;
sl@0
   687
		iBandedGc->UseFont(iFbsFont);
sl@0
   688
		}
sl@0
   689
	}
sl@0
   690
sl@0
   691
EXPORT_C void CPdrGc::SetPenColor(const TRgb& aColor)
sl@0
   692
	{
sl@0
   693
	if (!PdrControl()->IsGraphicsBand())
sl@0
   694
		iPenColor = aColor;
sl@0
   695
	iBandedGc->SetPenColor(aColor);
sl@0
   696
	}
sl@0
   697
sl@0
   698
EXPORT_C void CPdrGc::SetPenStyle(TPenStyle aPenStyle)
sl@0
   699
	{
sl@0
   700
	iBandedGc->SetPenStyle(aPenStyle);
sl@0
   701
	}
sl@0
   702
sl@0
   703
EXPORT_C void CPdrGc::SetPenSize(const TSize& aSize)
sl@0
   704
	{
sl@0
   705
	iBandedGc->SetPenSize(aSize);
sl@0
   706
	}
sl@0
   707
sl@0
   708
EXPORT_C void CPdrGc::SetBrushColor(const TRgb& aColor)
sl@0
   709
	{
sl@0
   710
	if (PdrControl()->IsGraphicsBand())
sl@0
   711
		iBandedGc->SetBrushColor(aColor);
sl@0
   712
	}
sl@0
   713
sl@0
   714
EXPORT_C void CPdrGc::SetBrushStyle(TBrushStyle aBrushStyle)
sl@0
   715
	{
sl@0
   716
	if (PdrControl()->IsGraphicsBand())
sl@0
   717
		iBandedGc->SetBrushStyle(aBrushStyle);
sl@0
   718
	}
sl@0
   719
sl@0
   720
EXPORT_C void CPdrGc::SetBrushOrigin(const TPoint& aOrigin)
sl@0
   721
	{
sl@0
   722
	if (PdrControl()->IsGraphicsBand())
sl@0
   723
		iBandedGc->SetBrushOrigin(aOrigin);
sl@0
   724
	}
sl@0
   725
sl@0
   726
EXPORT_C void CPdrGc::UseBrushPattern(const CFbsBitmap* aBitmap)
sl@0
   727
	{
sl@0
   728
	if (PdrControl()->IsGraphicsBand())
sl@0
   729
		iBandedGc->UseBrushPattern(aBitmap);
sl@0
   730
	}
sl@0
   731
sl@0
   732
EXPORT_C void CPdrGc::DiscardBrushPattern()
sl@0
   733
	{
sl@0
   734
	if (PdrControl()->IsGraphicsBand())
sl@0
   735
		iBandedGc->DiscardBrushPattern();
sl@0
   736
	}
sl@0
   737
sl@0
   738
EXPORT_C void CPdrGc::SetUnderlineStyle(TFontUnderline aUnderlineStyle)
sl@0
   739
	{
sl@0
   740
	if (!PdrControl()->IsGraphicsBand())
sl@0
   741
		iUnderlineStyle = aUnderlineStyle;
sl@0
   742
	iBandedGc->SetUnderlineStyle(aUnderlineStyle);
sl@0
   743
	}
sl@0
   744
sl@0
   745
EXPORT_C void CPdrGc::SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle)
sl@0
   746
	{
sl@0
   747
	if (!PdrControl()->IsGraphicsBand())
sl@0
   748
		iStrikethroughStyle = aStrikethroughStyle;
sl@0
   749
	iBandedGc->SetStrikethroughStyle(aStrikethroughStyle);
sl@0
   750
	}
sl@0
   751
sl@0
   752
EXPORT_C void CPdrGc::SetWordJustification(TInt aExcessWidth,TInt aNumGaps)
sl@0
   753
	{
sl@0
   754
	if (!PdrControl()->IsGraphicsBand())
sl@0
   755
		{
sl@0
   756
		iWordExcessWidthInPixels = aExcessWidth;
sl@0
   757
		iNumGaps = aNumGaps;
sl@0
   758
		}
sl@0
   759
	iBandedGc->SetWordJustification(aExcessWidth, aNumGaps);
sl@0
   760
	}
sl@0
   761
sl@0
   762
EXPORT_C void CPdrGc::SetCharJustification(TInt aExcessWidth,TInt aNumChars)
sl@0
   763
	{
sl@0
   764
	if (!PdrControl()->IsGraphicsBand())
sl@0
   765
		{
sl@0
   766
		iCharExcessWidthInPixels = aExcessWidth;
sl@0
   767
		iNumChars = aNumChars;
sl@0
   768
		}
sl@0
   769
	iBandedGc->SetCharJustification(aExcessWidth, aNumChars);
sl@0
   770
	}
sl@0
   771
sl@0
   772
EXPORT_C void CPdrGc::MoveTo(const TPoint& aPoint)
sl@0
   773
	{
sl@0
   774
	if (!PdrControl()->IsGraphicsBand())
sl@0
   775
		iPosition = aPoint;
sl@0
   776
	iBandedGc->MoveTo(aPoint);
sl@0
   777
	}
sl@0
   778
sl@0
   779
EXPORT_C void CPdrGc::MoveBy(const TPoint& aVector)
sl@0
   780
	{
sl@0
   781
	if (!PdrControl()->IsGraphicsBand())
sl@0
   782
		iPosition += aVector;
sl@0
   783
	iBandedGc->MoveBy(aVector);
sl@0
   784
	}
sl@0
   785
sl@0
   786
EXPORT_C void CPdrGc::Plot(const TPoint& aPoint)
sl@0
   787
	{
sl@0
   788
	if (PdrControl()->IsGraphicsBand())
sl@0
   789
		iBandedGc->Plot(aPoint);
sl@0
   790
	}
sl@0
   791
sl@0
   792
EXPORT_C void CPdrGc::DrawArc(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd)
sl@0
   793
	{
sl@0
   794
	if (PdrControl()->IsGraphicsBand())
sl@0
   795
		iBandedGc->DrawArc(aRect, aStart, aEnd);
sl@0
   796
	}
sl@0
   797
sl@0
   798
EXPORT_C void CPdrGc::DrawLine(const TPoint& aPoint1,const TPoint& aPoint2)
sl@0
   799
	{
sl@0
   800
	if (PdrControl()->IsGraphicsBand())
sl@0
   801
		iBandedGc->DrawLine(aPoint1, aPoint2);
sl@0
   802
	}
sl@0
   803
sl@0
   804
EXPORT_C void CPdrGc::DrawLineTo(const TPoint& aPoint)
sl@0
   805
	{
sl@0
   806
	if (PdrControl()->IsGraphicsBand())
sl@0
   807
		iBandedGc->DrawLineTo(aPoint);
sl@0
   808
	}
sl@0
   809
sl@0
   810
EXPORT_C void CPdrGc::DrawLineBy(const TPoint& aVector)
sl@0
   811
	{
sl@0
   812
	if (PdrControl()->IsGraphicsBand())
sl@0
   813
		iBandedGc->DrawLineBy(aVector);
sl@0
   814
	}
sl@0
   815
sl@0
   816
EXPORT_C void CPdrGc::DrawPolyLine(const CArrayFix<TPoint>* aPointList)
sl@0
   817
	{
sl@0
   818
	if (PdrControl()->IsGraphicsBand())
sl@0
   819
		iBandedGc->DrawPolyLine(aPointList);
sl@0
   820
	}
sl@0
   821
sl@0
   822
EXPORT_C void CPdrGc::DrawPolyLine(const TPoint* aPointList,TInt aNumPoints)
sl@0
   823
	{
sl@0
   824
	if (PdrControl()->IsGraphicsBand())
sl@0
   825
		iBandedGc->DrawPolyLine(aPointList, aNumPoints);
sl@0
   826
	}
sl@0
   827
sl@0
   828
EXPORT_C void CPdrGc::DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd)
sl@0
   829
	{
sl@0
   830
	if (PdrControl()->IsGraphicsBand())
sl@0
   831
		iBandedGc->DrawPie(aRect, aStart, aEnd);
sl@0
   832
	}
sl@0
   833
sl@0
   834
EXPORT_C void CPdrGc::DrawEllipse(const TRect& aRect)
sl@0
   835
	{
sl@0
   836
	if (PdrControl()->IsGraphicsBand())
sl@0
   837
		iBandedGc->DrawEllipse(aRect);
sl@0
   838
	}
sl@0
   839
sl@0
   840
EXPORT_C void CPdrGc::DrawRect(const TRect& aRect)
sl@0
   841
	{
sl@0
   842
	if (PdrControl()->IsGraphicsBand())
sl@0
   843
		iBandedGc->DrawRect(aRect);
sl@0
   844
	}
sl@0
   845
sl@0
   846
EXPORT_C void CPdrGc::DrawRoundRect(const TRect& aRect,const TSize& aCornerSize)
sl@0
   847
	{
sl@0
   848
	if (PdrControl()->IsGraphicsBand())
sl@0
   849
		iBandedGc->DrawRoundRect(aRect, aCornerSize);
sl@0
   850
	}
sl@0
   851
sl@0
   852
EXPORT_C TInt CPdrGc::DrawPolygon(const CArrayFix<TPoint>* aPointList, TFillRule aFillRule)
sl@0
   853
	{
sl@0
   854
	TInt ret = KErrNone;
sl@0
   855
	if (PdrControl()->IsGraphicsBand())
sl@0
   856
		ret = iBandedGc->DrawPolygon(aPointList, aFillRule);
sl@0
   857
	return ret;
sl@0
   858
	}
sl@0
   859
sl@0
   860
EXPORT_C TInt CPdrGc::DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule)
sl@0
   861
	{
sl@0
   862
	TInt ret = KErrNone;
sl@0
   863
	if (PdrControl()->IsGraphicsBand())
sl@0
   864
		ret = iBandedGc->DrawPolygon(aPointList, aNumPoints, aFillRule);
sl@0
   865
	return ret;
sl@0
   866
	}
sl@0
   867
sl@0
   868
EXPORT_C void CPdrGc::DrawBitmap(const TPoint& aTopLeft, const CFbsBitmap* aSource)
sl@0
   869
	{
sl@0
   870
	if (PdrControl()->IsGraphicsBand())
sl@0
   871
		iBandedGc->DrawBitmap(aTopLeft, aSource);
sl@0
   872
	}
sl@0
   873
sl@0
   874
EXPORT_C void CPdrGc::DrawBitmap(const TRect& aDestRect, const CFbsBitmap* aSource)
sl@0
   875
	{
sl@0
   876
	if (PdrControl()->IsGraphicsBand())
sl@0
   877
		iBandedGc->DrawBitmap(aDestRect, aSource);
sl@0
   878
	}
sl@0
   879
sl@0
   880
EXPORT_C void CPdrGc::DrawBitmap(const TRect& aDestRect, const CFbsBitmap* aSource, const TRect& aSourceRect)
sl@0
   881
	{
sl@0
   882
	if (PdrControl()->IsGraphicsBand())
sl@0
   883
		iBandedGc->DrawBitmap(aDestRect, aSource, aSourceRect);
sl@0
   884
	}
sl@0
   885
sl@0
   886
EXPORT_C void CPdrGc::DrawBitmapMasked(const TRect& /*aDestRect*/,const CFbsBitmap* /*aBitmap*/,const TRect& /*aSourceRect*/,const CFbsBitmap* /*aMaskBitmap*/,TBool /*aInvertMask*/)
sl@0
   887
	{}
sl@0
   888
sl@0
   889
EXPORT_C void CPdrGc::DrawBitmapMasked(const TRect& /*aDestRect*/,const CWsBitmap* /*aBitmap*/,const TRect& /*aSourceRect*/,const CWsBitmap* /*aMaskBitmap*/,TBool /*aInvertMask*/)
sl@0
   890
	{}
sl@0
   891
		
sl@0
   892
EXPORT_C void CPdrGc::MapColors(const TRect& /*aRect*/,const TRgb* /*aColors*/,TInt /*aNumPairs*/,TBool /*aMapForwards*/)
sl@0
   893
	{
sl@0
   894
	}
sl@0
   895
sl@0
   896
EXPORT_C TInt CPdrGc::SetClippingRegion(const TRegion &/*aRegion*/)
sl@0
   897
	{	
sl@0
   898
		return KErrNone;
sl@0
   899
	}
sl@0
   900
sl@0
   901
EXPORT_C void CPdrGc::CancelClippingRegion()
sl@0
   902
	{}
sl@0
   903
sl@0
   904
EXPORT_C void CPdrGc::DrawTextVertical(const TDesC& /*aText*/,const TPoint& /*aPos*/,TBool /*aUp*/)
sl@0
   905
	{}
sl@0
   906
	
sl@0
   907
EXPORT_C void CPdrGc::DrawTextVertical(const TDesC& /*aText*/,const TRect& /*aBox*/,TInt /*aBaselineOffset*/,TBool /*aUp*/,TTextAlign /*aVert*/,TInt /*aMargin*/)
sl@0
   908
	{}
sl@0
   909
sl@0
   910
EXPORT_C TInt CPdrGc::AlphaBlendBitmaps(const TPoint& /*aDestPt*/, const CFbsBitmap* /*aSrcBmp*/, const TRect& /*aSrcRect*/, const CFbsBitmap* /*aAlphaBmp*/, const TPoint& /*aAlphaPt*/) 
sl@0
   911
	{
sl@0
   912
		return KErrNone;
sl@0
   913
	}
sl@0
   914
	
sl@0
   915
EXPORT_C TInt CPdrGc::AlphaBlendBitmaps(const TPoint& /*aDestPt*/, const CWsBitmap* /*aSrcBmp*/,  const TRect& /*aSrcRect*/, const CWsBitmap*  /*aAlphaBmp*/, const TPoint& /*aAlphaPt*/)
sl@0
   916
	{
sl@0
   917
		return KErrNone;
sl@0
   918
	}
sl@0
   919
sl@0
   920
CPdrControl* CPdrGc::PdrControl() const 
sl@0
   921
{
sl@0
   922
	return ((CPdrControl*) iPdrDevice->iControl);
sl@0
   923
}
sl@0
   924
sl@0
   925
/**
sl@0
   926
@deprecated Interface is deprecated because it is unsafe as it may leave. It is available for backward compatibility reasons only.
sl@0
   927
@see CPdrGc::DrawTextL
sl@0
   928
*/
sl@0
   929
sl@0
   930
EXPORT_C void CPdrGc::DrawText(const TDesC& aString, const TPoint& aPosition)
sl@0
   931
	{
sl@0
   932
	TRAP_IGNORE(DrawTextL(aString, aPosition));
sl@0
   933
	}
sl@0
   934
sl@0
   935
EXPORT_C void CPdrGc::DrawTextL(const TDesC& aString, const TPoint& aPosition)
sl@0
   936
	{
sl@0
   937
	if (!iPrintTextUsingBitmaps)
sl@0
   938
		{
sl@0
   939
		TInt firstCharNot = 0;
sl@0
   940
		TInt length = 0;
sl@0
   941
		__ASSERT_DEBUG(iFont, Panic(EPdrNoFontInUse));
sl@0
   942
		if (iFont->AllCharsInFontRepertoire(aString, firstCharNot, length))
sl@0
   943
			{
sl@0
   944
			iPosition = aPosition;
sl@0
   945
			TInt start = 0;
sl@0
   946
			TPtrC ptr;  // Checks to see iWordExcessWidthInPixels > 0 to avoid panic in JustificationInPixels()
sl@0
   947
			for (TInt i = 0; (i < aString.Length()) && iNumGaps && iWordExcessWidthInPixels; i++)
sl@0
   948
				{
sl@0
   949
				if (aString[i] == ' ')
sl@0
   950
					{
sl@0
   951
					ptr.Set(aString.Mid(start, i - start + 1));
sl@0
   952
					if (!PdrControl()->IsGraphicsBand())
sl@0
   953
						{
sl@0
   954
						PdrControl()->DrawTextL(iPosition + iOrigin, iUnderlineStyle, iStrikethroughStyle, iPenColor, iFont, ptr);
sl@0
   955
						}
sl@0
   956
					iPosition += TPoint(iFont->MeasureText(ptr) + JustificationInPixels(iWordExcessWidthInPixels, iNumGaps), 0);
sl@0
   957
					start = i + 1;
sl@0
   958
					}
sl@0
   959
				}
sl@0
   960
			if (start < aString.Length())
sl@0
   961
				{
sl@0
   962
				ptr.Set(aString.Mid(start));
sl@0
   963
				if (!PdrControl()->IsGraphicsBand())
sl@0
   964
					{
sl@0
   965
					PdrControl()->DrawTextL(iPosition + iOrigin, iUnderlineStyle, iStrikethroughStyle, iPenColor, iFont, ptr);
sl@0
   966
					}
sl@0
   967
				iPosition += TPoint(iFont->MeasureText(ptr), 0);
sl@0
   968
				}
sl@0
   969
			}
sl@0
   970
		else
sl@0
   971
			{
sl@0
   972
			if (firstCharNot > 0)
sl@0
   973
				{	// Take text substring and draw it
sl@0
   974
				TPtrC ptr;
sl@0
   975
				ptr.Set(aString.Mid(0, firstCharNot));
sl@0
   976
				DrawText(ptr, aPosition);
sl@0
   977
				// Whole string wasn't text so there must be some (bitmap) string left
sl@0
   978
				// Update drawing position
sl@0
   979
				TPoint position = iPosition;
sl@0
   980
				// Take rest of string and try again
sl@0
   981
				ptr.Set(aString.Mid(firstCharNot));
sl@0
   982
				DrawText(ptr, position);
sl@0
   983
				}
sl@0
   984
			else
sl@0
   985
				{	// Take bitmap substring and draw it
sl@0
   986
				TPtrC ptr;
sl@0
   987
				ptr.Set(aString.Mid(0, length));
sl@0
   988
				if (PdrControl()->IsGraphicsBand())
sl@0
   989
					{
sl@0
   990
					iPrintTextUsingBitmaps = ETrue;
sl@0
   991
					DrawText(ptr, aPosition);
sl@0
   992
					iPrintTextUsingBitmaps = EFalse;
sl@0
   993
					}
sl@0
   994
				if (length < aString.Length())
sl@0
   995
					{
sl@0
   996
					// There must be some (text) string left
sl@0
   997
					// Update drawing position
sl@0
   998
					iPosition = aPosition;
sl@0
   999
					TPtrC ptr2;
sl@0
  1000
					TInt start = 0;
sl@0
  1001
					// Checks to see iWordExcessWidthInPixels > 0 to avoid panic in JustificationInPixels()
sl@0
  1002
					for (TInt i = 0; (i < ptr.Length()) && iNumGaps && iWordExcessWidthInPixels; i++)
sl@0
  1003
						{
sl@0
  1004
						if (ptr[i] == ' ')
sl@0
  1005
							{
sl@0
  1006
							ptr2.Set(ptr.Mid(start, i - start + 1));
sl@0
  1007
							iPosition += TPoint(iFont->MeasureText(ptr2) + JustificationInPixels(iWordExcessWidthInPixels, iNumGaps), 0);
sl@0
  1008
							start = i + 1;
sl@0
  1009
							}
sl@0
  1010
						}
sl@0
  1011
					if (start < ptr.Length())
sl@0
  1012
						{
sl@0
  1013
						ptr2.Set(ptr.Mid(start));
sl@0
  1014
						iPosition += TPoint(iFont->MeasureText(ptr2), 0);
sl@0
  1015
						}
sl@0
  1016
					TPoint position = iPosition;
sl@0
  1017
					// Take rest of string and try again
sl@0
  1018
					ptr.Set(aString.Mid(length));
sl@0
  1019
					DrawText(ptr, position);
sl@0
  1020
					}
sl@0
  1021
				}
sl@0
  1022
			}
sl@0
  1023
		}
sl@0
  1024
	else
sl@0
  1025
		{
sl@0
  1026
		if (PdrControl()->IsGraphicsBand())
sl@0
  1027
			iBandedGc->DrawText(aString, aPosition);
sl@0
  1028
		}
sl@0
  1029
	}
sl@0
  1030
sl@0
  1031
EXPORT_C void CPdrGc::DrawText(const TDesC& aString, const TRect& aBox, TInt aBaselineOffset, TTextAlign aHoriz, TInt aLeftMrg)
sl@0
  1032
	{
sl@0
  1033
	if (!iPrintTextUsingBitmaps)
sl@0
  1034
		{
sl@0
  1035
		__ASSERT_DEBUG(iFont, Panic(EPdrNoFontInUse));
sl@0
  1036
		if (!PdrControl()->IsGraphicsBand())
sl@0
  1037
			{
sl@0
  1038
			TInt width = iFont->MeasureText(aString);
sl@0
  1039
			TPoint pos;
sl@0
  1040
			pos.iY = aBox.iTl.iY + aBaselineOffset;
sl@0
  1041
			if (aHoriz == ELeft)
sl@0
  1042
				pos.iX = aBox.iTl.iX + aLeftMrg;
sl@0
  1043
			else if (aHoriz == ERight)
sl@0
  1044
				pos.iX = aBox.iBr.iX - aLeftMrg - width;
sl@0
  1045
			else if (aHoriz == ECenter)
sl@0
  1046
				pos.iX = (aBox.iTl.iX + aBox.iBr.iX - width) / 2;
sl@0
  1047
			DrawText(aString, pos);
sl@0
  1048
			}
sl@0
  1049
		else
sl@0
  1050
			iBandedGc->DrawText(KNullDesC, aBox, aBaselineOffset, aHoriz, aLeftMrg);
sl@0
  1051
		}
sl@0
  1052
	else
sl@0
  1053
		{
sl@0
  1054
		if (PdrControl()->IsGraphicsBand())
sl@0
  1055
			iBandedGc->DrawText(aString, aBox, aBaselineOffset, aHoriz, aLeftMrg);
sl@0
  1056
		}
sl@0
  1057
	}