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.
24 EXPORT_C CPdrDevice::CPdrDevice():
31 __DECLARE_NAME(_S("CPdrDevice"));
34 EXPORT_C CPdrDevice::~CPdrDevice()
38 delete iTypefaceStore;
41 EXPORT_C void CPdrDevice::SelectPageSpecInTwips(const TPageSpec& aPageSpec)
43 CPrinterDevice::SelectPageSpecInTwips(aPageSpec);
44 iTypefaceStore->SetPageOrientation(aPageSpec.iOrientation);
47 EXPORT_C TDisplayMode CPdrDevice::DisplayMode() const
49 return iModelInfo->iDisplayMode;
52 EXPORT_C TSize CPdrDevice::SizeInPixels() const
55 size.iWidth = HorizontalTwipsToPixels(SizeInTwips().iWidth);
56 size.iHeight = VerticalTwipsToPixels(SizeInTwips().iHeight);
60 EXPORT_C TSize CPdrDevice::SizeInTwips() const
63 if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::EPortrait)
65 size = iCurrentPageSpecInTwips.iPortraitPageSize;
67 else if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::ELandscape)
69 size.iWidth = iCurrentPageSpecInTwips.iPortraitPageSize.iHeight;
70 size.iHeight = iCurrentPageSpecInTwips.iPortraitPageSize.iWidth;
75 EXPORT_C TRect CPdrDevice::PrintablePageInPixels() const
78 if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::EPortrait)
80 rect.iTl.iX = iModelInfo->iPortraitOffsetInPixels.iX;
81 rect.iTl.iY = iModelInfo->iMinMarginsInPixels.iTop;
82 rect.iBr.iX = SizeInPixels().iWidth-iModelInfo->iPortraitOffsetInPixels.iX;
83 rect.iBr.iY = SizeInPixels().iHeight-iModelInfo->iMinMarginsInPixels.iBottom;
85 else if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::ELandscape)
87 rect.iTl.iX = iModelInfo->iLandscapeOffsetInPixels.iX;
88 rect.iTl.iY = iModelInfo->iMinMarginsInPixels.iLeft;
89 rect.iBr.iX = SizeInPixels().iWidth-iModelInfo->iLandscapeOffsetInPixels.iX;
90 rect.iBr.iY = SizeInPixels().iHeight-iModelInfo->iMinMarginsInPixels.iRight;
95 EXPORT_C TInt CPdrDevice::HorizontalTwipsToPixels(TInt aTwips) const
97 return ((1000 * aTwips) + (KPixelSizeInTwips().iWidth / 2)) / KPixelSizeInTwips().iWidth;
100 EXPORT_C TInt CPdrDevice::VerticalTwipsToPixels(TInt aTwips) const
102 return ((1000 * aTwips) + (KPixelSizeInTwips().iHeight / 2)) / KPixelSizeInTwips().iHeight;
105 EXPORT_C TInt CPdrDevice::HorizontalPixelsToTwips(TInt aPixels) const
107 return ((aPixels * KPixelSizeInTwips().iWidth) + 500) / 1000;
110 EXPORT_C TInt CPdrDevice::VerticalPixelsToTwips(TInt aPixels) const
112 return ((aPixels * KPixelSizeInTwips().iHeight) + 500) / 1000;
115 /** Creates a font from those available in the printer device's
116 typeface store that most closely matches a font specification.
118 When the font is no longer needed, call ReleaseFont().
120 This function is replaced by GetNearestFontToDesignHeightInTwips()
122 @param aFont On return, points to the font which most closely matches the
124 @param aFontSpec An absolute font specification. Its iHeight member is
125 interpreted as being in twips.
126 @return KErrNone if successful; otherwise, another one of the system-wide error
129 EXPORT_C TInt CPdrDevice::GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec)
131 return GetNearestFontToDesignHeightInTwips(aFont, aFontSpec);
134 /** Creates a font from those available in the printer device's
135 typeface store that most closely matches a font specification.
137 When the font is no longer needed, call ReleaseFont().
139 This function replaces GetNearestFontInTwips()
141 @param aFont On return, points to the font which most closely matches the
143 @param aFontSpec An absolute font specification. Its iHeight member is
144 interpreted as being in twips.
145 @return KErrNone if successful; otherwise, another one of the system-wide error
147 EXPORT_C TInt CPdrDevice::GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec)
149 return iTypefaceStore->GetNearestFontToDesignHeightInTwips(aFont, aFontSpec);
152 /** This call is defined because it had to be - it appeared as an abstract virtual in
153 the base class. But it should never actually get called for this class. */
154 EXPORT_C TInt CPdrDevice::GetNearestFontToMaxHeightInTwips(CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/, TInt /*aMaxHeight*/)
156 return KErrNotSupported;
159 EXPORT_C TInt CPdrDevice::NumTypefaces() const
161 return iTypefaceStore->NumTypefaces();
164 EXPORT_C void CPdrDevice::TypefaceSupport(TTypefaceSupport& aTypefaceSupport, TInt aTypefaceIndex) const
166 iTypefaceStore->TypefaceSupport(aTypefaceSupport, aTypefaceIndex);
169 EXPORT_C TInt CPdrDevice::FontHeightInTwips(TInt aTypefaceIndex, TInt aHeightIndex) const
171 return iTypefaceStore->FontHeightInTwips(aTypefaceIndex, aHeightIndex);
174 EXPORT_C void CPdrDevice::PaletteAttributes(TBool& aModifiable, TInt& aNumEntries) const
176 aModifiable = EFalse;
180 EXPORT_C void CPdrDevice::SetPalette(CPalette* /*aPalette*/)
184 EXPORT_C TInt CPdrDevice::GetPalette(CPalette*& /*aPalette*/) const
186 return KErrNotSupported;
189 EXPORT_C TPrinterModelEntry CPdrDevice::Model() const
191 return iModel.iEntry;
194 EXPORT_C TInt CPdrDevice::Flags() const
196 return iModelInfo->iFlags;
199 EXPORT_C TInt CPdrDevice::SetModel(const TPrinterModelHeader& aModel, CStreamStore& aStore)
203 TRAPD(ret, DoSetModelL());
207 EXPORT_C void CPdrDevice::ReleaseFont(CFont* aFont)
209 iTypefaceStore->ReleaseFont(aFont);
212 EXPORT_C TPoint CPdrDevice::OffsetInPixels()
215 if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::EPortrait)
216 offset = iModelInfo->iPortraitOffsetInPixels;
217 else if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::ELandscape)
218 offset = iModelInfo->iLandscapeOffsetInPixels;
222 EXPORT_C TSize CPdrDevice::KPixelSizeInTwips() const
225 if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::EPortrait)
226 size = TSize(iModelInfo->iKPixelWidthInTwips, iModelInfo->iKPixelHeightInTwips);
227 else if (iCurrentPageSpecInTwips.iOrientation == TPageSpec::ELandscape)
228 size = TSize(iModelInfo->iKPixelHeightInTwips, iModelInfo->iKPixelWidthInTwips);
232 void CPdrDevice::DoSetModelL()
234 RStoreReadStream stream;
235 stream.OpenLC(*iStore, iModel.iModelDataStreamId);
236 iModelInfo = new(ELeave) CPdrModelInfo();
237 iModelInfo->InternalizeL(stream);
238 CleanupStack::PopAndDestroy();
239 iTypefaceStore = CPdrTypefaceStore::NewL(*iStore, iModelInfo->iNumTypefaceFonts, iModelInfo->iTypefaceFontsEntryList, iCurrentPageSpecInTwips.iOrientation, iModelInfo->iKPixelHeightInTwips, this);
242 EXPORT_C CPdrControl::CPdrControl(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort):
243 CPrinterControl(aPrinterPort),
244 iPdrDevice(aPdrDevice),
251 iPosition(iPdrDevice->OffsetInPixels()),
254 __DECLARE_NAME(_S("CPdrControl"));
257 EXPORT_C CPdrControl::~CPdrControl()
261 delete iBandedDevice;
265 EXPORT_C TInt CPdrControl::CreateContext(CGraphicsContext*& aGC)
267 __ASSERT_DEBUG(iState == EPrinting, Panic(EPdrNotPrinting));
268 TRAPD(ret, aGC = CPdrGc::NewL(iPdrDevice));
272 EXPORT_C TInt CPdrControl::BandsPerPage()
274 TInt numbands = {iBandedDevice ? iBandedDevice->NumBands() + 1 : 1};
279 @return EMoreOnPage if more to print on the current page,
280 otherwise ENoMoreOnPage.
282 EXPORT_C CPrinterControl::TMoreOnPage CPdrControl::QueueGetBand(TRequestStatus& aStatus, TBandAttributes& aBand)
284 TMoreOnPage moreonpage = ENoMoreOnPage;
286 TRAPD(ret, DoQueueGetBandL());
289 TRequestStatus* status = &aStatus;
290 User::RequestComplete(status, ret);
294 if (IsGraphicsBand())
296 aBand.iRect = iBandedDevice->BandRect();
297 aBand.iTextIsIgnored = ETrue;
298 aBand.iGraphicsIsIgnored = EFalse;
299 aBand.iFirstBandOnPage = EFalse;
303 aBand.iRect = iPdrDevice->PrintablePageInPixels();
304 aBand.iTextIsIgnored = EFalse;
305 aBand.iGraphicsIsIgnored = ETrue;
306 aBand.iFirstBandOnPage = ETrue;
308 if (iBandIndex == (BandsPerPage() - 1))
309 moreonpage = ENoMoreOnPage;
311 moreonpage = EMoreOnPage;
312 iPageBuffer->StartFlush(aStatus);
317 EXPORT_C void CPdrControl::QueueEndPrint(TRequestStatus& aStatus)
319 TRAPD(ret, DoQueueEndPrintL());
320 iState = ENotPrinting;
323 TRequestStatus* status = &aStatus;
324 User::RequestComplete(status, ret);
327 iPageBuffer->StartFlush(aStatus);
331 Tidy up synchronously in a short time.
333 EXPORT_C void CPdrControl::AbortPrint() // tidy up synchronously in a short time, return success code
335 iPageBuffer->Cancel(); // dont call DoCancel()
336 iState = ENotPrinting;
339 EXPORT_C void CPdrControl::DrawTextL(const TPoint& aPoint, const TFontUnderline aUnderlineStyle, const TFontStrikethrough aStrikethroughStyle, const TRgb& aColor, const CInfoFont* aFont, const TDesC& aString)
341 __ASSERT_DEBUG(iState == EPrinting,Panic(EPdrNotPrinting));
343 iPageText->AddEntryL(aPoint, aUnderlineStyle, aStrikethroughStyle, aColor, aFont, aString);
346 HBufC8* string = aFont->TranslateStringL(aString);
347 CleanupStack::PushL(string);
348 TTextFormat textformat(aUnderlineStyle, aStrikethroughStyle, aColor, aFont->CommandString(), aFont->FontSpecInTwips().iFontStyle);
349 OutputTextL(aPoint + TPoint(0, aFont->BaselineOffsetInPixels()), aFont->MeasureText(aString), textformat,string->Des());
350 CleanupStack::PopAndDestroy();
354 EXPORT_C TBool CPdrControl::IsGraphicsBand() const
359 EXPORT_C void CPdrControl::MoveToL(const TPoint& aPoint)
361 // PCL, at least, treats move command strings with an explicit
362 // sign as being relative, so if the offset is negative then
363 // set the absolute position to zero first.
365 TPoint offset = iPdrDevice->OffsetInPixels();
367 if (aPoint.iX - iPosition.iX)
369 if (aPoint.iX - iPosition.iX < 0)
371 des.Format(iResources->ResourceString(EPdrSetXPos), 0);
372 iPageBuffer->AddBytesL(des);
375 des.Format(iResources->ResourceString(EPdrSetXPos), aPoint.iX - offset.iX);
376 iPageBuffer->AddBytesL(des);
378 if (aPoint.iY - iPosition.iY)
380 if (aPoint.iY - iPosition.iY < 0)
382 des.Format(iResources->ResourceString(EPdrSetYPos), 0);
383 iPageBuffer->AddBytesL(des);
386 des.Format(iResources->ResourceString(EPdrSetYPos), aPoint.iY - offset.iY);
387 iPageBuffer->AddBytesL(des);
392 EXPORT_C void CPdrControl::MoveByL(const TPoint& aVector)
394 TCommandString resource;
396 TPoint vector = aVector;
401 CommandL(EPdrCarriageReturn);
402 vector.iX += iPosition.iX - iPdrDevice->OffsetInPixels().iX;
404 resource.Copy(iResources->ResourceString(EPdrIncrementXPos));
405 __ASSERT_DEBUG(resource.Length() >= 2, Panic(EPdrBadResourceString));
406 if (resource[0] == '*')
408 for (; vector.iX > 0; vector.iX--)
409 iPageBuffer->AddBytesL(resource.Mid(1));
413 des.Format(resource, vector.iX);
414 iPageBuffer->AddBytesL(des);
417 resource.Copy(iResources->ResourceString(EPdrIncrementYPos));
420 __ASSERT_DEBUG(resource.Length() >= 2, Panic(EPdrBadResourceString));
421 if (resource[0] == '*')
423 for (; vector.iY > 0; vector.iY--)
424 iPageBuffer->AddBytesL(resource.Mid(1));
428 des.Format(resource, vector.iY);
429 iPageBuffer->AddBytesL(des);
432 iPosition += aVector;
435 EXPORT_C void CPdrControl::OutputTextL(const TPoint& aPoint, TInt aWidthInPixels, const TTextFormat& aTextFormat, const TDesC8& aString)
437 __ASSERT_DEBUG(iState == EPrinting,Panic(EPdrNotPrinting));
439 if (iTextFormat.iFontString.Compare(aTextFormat.iFontString))
440 iPageBuffer->AddBytesL(aTextFormat.iFontString);
442 if (iTextFormat.iFontStyle.Posture() != aTextFormat.iFontStyle.Posture())
443 SetFontPostureL(aTextFormat.iFontStyle.Posture());
445 if (iTextFormat.iFontStyle.StrokeWeight() != aTextFormat.iFontStyle.StrokeWeight())
446 SetFontStrokeWeightL(aTextFormat.iFontStyle.StrokeWeight());
448 if (iTextFormat.iColor != aTextFormat.iColor)
449 SetTextColorL(aTextFormat.iColor);
451 iTextFormat = aTextFormat;
455 if (aTextFormat.iUnderlineStyle == EUnderlineOn)
456 CommandL(EPdrUnderlineOn);
458 if (aTextFormat.iStrikethroughStyle == EStrikethroughOn)
459 CommandL(EPdrStrikethroughOn);
461 iPageBuffer->AddBytesL(aString);
463 iPosition.iX += aWidthInPixels;
465 if (aTextFormat.iUnderlineStyle == EUnderlineOn)
466 CommandL(EPdrUnderlineOff);
468 if (aTextFormat.iStrikethroughStyle == EStrikethroughOn)
469 CommandL(EPdrStrikethroughOff);
472 EXPORT_C void CPdrControl::DoQueueGetBandL()
474 if (iState == ENotPrinting)
479 iBandedDevice->Reset();
482 CommandL(EPdrPreAmble);
483 SetPageOrientationL();
484 SetTextColorL(KRgbBlack);
489 if (iBandIndex == (BandsPerPage() - 1))
495 CommandL(EPdrNewPage);
496 iPosition = iPdrDevice->OffsetInPixels();
499 iBandIndex = iBandedDevice->NextBand() + 1;
503 EXPORT_C void CPdrControl::DoQueueEndPrintL()
506 CommandL(EPdrPostAmble);
509 EXPORT_C void CPdrControl::ConstructL(CStreamStore& aStore, TStreamId aStreamId)
511 __ASSERT_ALWAYS(iPrinterPort, Panic(EPdrRequiresPrinterPort));
512 iPageBuffer = CPageBuffer::NewL(iPrinterPort);
513 iResources = new(ELeave) CPdrResources();
514 iResources->RestoreL(aStore, aStreamId);
517 EXPORT_C void CPdrControl::SetPageSizeL()
521 EXPORT_C void CPdrControl::SetPageOrientationL()
523 TPageSpec::TPageOrientation orientation = iPdrDevice->CurrentPageSpecInTwips().iOrientation;
524 if (orientation == TPageSpec::EPortrait)
525 CommandL(EPdrPortrait);
527 CommandL(EPdrLandscape);
530 EXPORT_C void CPdrControl::SetFontStrokeWeightL(const TFontStrokeWeight aStrokeWeight)
532 if (aStrokeWeight == EStrokeWeightNormal)
533 CommandL(EPdrBoldOff);
535 CommandL(EPdrBoldOn);
538 EXPORT_C void CPdrControl::SetFontPostureL(const TFontPosture aPosture)
540 if (aPosture == EPostureUpright)
541 CommandL(EPdrItalicOff);
543 CommandL(EPdrItalicOn);
546 EXPORT_C void CPdrControl::SetTextColorL(const TRgb& /*aColor*/)
550 EXPORT_C void CPdrControl::CommandL(const TInt anId)
552 iPageBuffer->AddBytesL(iResources->ResourceString(anId));
555 void CPdrGc::ConstructL()
557 if (PdrControl()->BandedDevice())
559 User::LeaveIfError(PdrControl()->BandedDevice()->CreateContext((CGraphicsContext*&)iBandedGc));
561 User::LeaveIfError(PdrControl()->BandedDevice()->GetNearestFontToDesignHeightInTwips((CFont*&)iFbsFont, spec));
562 iBandedGc->UseFont(iFbsFont);
566 CPdrGc::CPdrGc(CPdrDevice* aDevice):
574 iUnderlineStyle(EUnderlineOff),
575 iStrikethroughStyle(EStrikethroughOff),
576 iClippingRect(iPdrDevice->PrintablePageInPixels()),
577 iWordExcessWidthInPixels(0),
579 iCharExcessWidthInPixels(0),
585 CPdrGc* CPdrGc::NewL(CPdrDevice* aDevice)
587 CPdrGc* gc = new(ELeave) CPdrGc(aDevice);
588 CleanupStack::PushL(gc);
594 EXPORT_C CPdrGc::~CPdrGc()
598 if (iBandedGc->IsFontUsed())
600 iBandedGc->DiscardFont();
604 PdrControl()->BandedDevice()->ReleaseFont(iFbsFont);
608 EXPORT_C CGraphicsDevice* CPdrGc::Device() const
613 EXPORT_C void CPdrGc::SetOrigin(const TPoint& aPos)
615 if (!PdrControl()->IsGraphicsBand())
617 TPoint pos = PdrControl()->BandedDevice()->FullOriginToBandOrigin(aPos);
618 iBandedGc->SetOrigin(pos);
621 EXPORT_C void CPdrGc::SetDrawMode(TDrawMode aDrawingMode)
623 iBandedGc->SetDrawMode(aDrawingMode);
626 EXPORT_C void CPdrGc::SetClippingRect(const TRect& aRect)
628 if (!PdrControl()->IsGraphicsBand())
630 iClippingRect = aRect;
631 iClippingRect.Move(TPoint(0, 0) + iOrigin); // Recorded in original coordinates
633 iBandedGc->SetClippingRect(aRect);
636 EXPORT_C void CPdrGc::CancelClippingRect()
638 if (!PdrControl()->IsGraphicsBand())
639 iClippingRect = iPdrDevice->PrintablePageInPixels();
640 iBandedGc->CancelClippingRect();
643 EXPORT_C void CPdrGc::Reset()
645 if (iBandedGc->IsFontUsed())
647 iBandedGc->DiscardFont();
651 iBandedGc->UseFont(iFbsFont);
652 SetOrigin(TPoint(0, 0));
653 CancelClippingRect();
656 EXPORT_C void CPdrGc::UseFont(const CFont* aFont)
658 if (aFont->TypeUid() == TUid::Uid(KCInfoFontUidVal))
660 iFont = (CInfoFont*)aFont;
661 iPrintTextUsingBitmaps = EFalse;
662 // We may have to use bitmaps - so set the font up in the bitmap gc as well
663 if (iBandedGc->IsFontUsed())
664 iBandedGc->DiscardFont();
665 iBandedFont = iFont->RealFont();
666 iBandedGc->UseFont(iBandedFont);
670 if (iBandedGc->IsFontUsed())
672 iBandedGc->DiscardFont();
675 iBandedGc->UseFont(aFont);
676 iPrintTextUsingBitmaps = ETrue;
680 EXPORT_C void CPdrGc::DiscardFont()
685 iBandedGc->DiscardFont();
687 iBandedGc->UseFont(iFbsFont);
691 EXPORT_C void CPdrGc::SetPenColor(const TRgb& aColor)
693 if (!PdrControl()->IsGraphicsBand())
695 iBandedGc->SetPenColor(aColor);
698 EXPORT_C void CPdrGc::SetPenStyle(TPenStyle aPenStyle)
700 iBandedGc->SetPenStyle(aPenStyle);
703 EXPORT_C void CPdrGc::SetPenSize(const TSize& aSize)
705 iBandedGc->SetPenSize(aSize);
708 EXPORT_C void CPdrGc::SetBrushColor(const TRgb& aColor)
710 if (PdrControl()->IsGraphicsBand())
711 iBandedGc->SetBrushColor(aColor);
714 EXPORT_C void CPdrGc::SetBrushStyle(TBrushStyle aBrushStyle)
716 if (PdrControl()->IsGraphicsBand())
717 iBandedGc->SetBrushStyle(aBrushStyle);
720 EXPORT_C void CPdrGc::SetBrushOrigin(const TPoint& aOrigin)
722 if (PdrControl()->IsGraphicsBand())
723 iBandedGc->SetBrushOrigin(aOrigin);
726 EXPORT_C void CPdrGc::UseBrushPattern(const CFbsBitmap* aBitmap)
728 if (PdrControl()->IsGraphicsBand())
729 iBandedGc->UseBrushPattern(aBitmap);
732 EXPORT_C void CPdrGc::DiscardBrushPattern()
734 if (PdrControl()->IsGraphicsBand())
735 iBandedGc->DiscardBrushPattern();
738 EXPORT_C void CPdrGc::SetUnderlineStyle(TFontUnderline aUnderlineStyle)
740 if (!PdrControl()->IsGraphicsBand())
741 iUnderlineStyle = aUnderlineStyle;
742 iBandedGc->SetUnderlineStyle(aUnderlineStyle);
745 EXPORT_C void CPdrGc::SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle)
747 if (!PdrControl()->IsGraphicsBand())
748 iStrikethroughStyle = aStrikethroughStyle;
749 iBandedGc->SetStrikethroughStyle(aStrikethroughStyle);
752 EXPORT_C void CPdrGc::SetWordJustification(TInt aExcessWidth,TInt aNumGaps)
754 if (!PdrControl()->IsGraphicsBand())
756 iWordExcessWidthInPixels = aExcessWidth;
759 iBandedGc->SetWordJustification(aExcessWidth, aNumGaps);
762 EXPORT_C void CPdrGc::SetCharJustification(TInt aExcessWidth,TInt aNumChars)
764 if (!PdrControl()->IsGraphicsBand())
766 iCharExcessWidthInPixels = aExcessWidth;
767 iNumChars = aNumChars;
769 iBandedGc->SetCharJustification(aExcessWidth, aNumChars);
772 EXPORT_C void CPdrGc::MoveTo(const TPoint& aPoint)
774 if (!PdrControl()->IsGraphicsBand())
776 iBandedGc->MoveTo(aPoint);
779 EXPORT_C void CPdrGc::MoveBy(const TPoint& aVector)
781 if (!PdrControl()->IsGraphicsBand())
782 iPosition += aVector;
783 iBandedGc->MoveBy(aVector);
786 EXPORT_C void CPdrGc::Plot(const TPoint& aPoint)
788 if (PdrControl()->IsGraphicsBand())
789 iBandedGc->Plot(aPoint);
792 EXPORT_C void CPdrGc::DrawArc(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd)
794 if (PdrControl()->IsGraphicsBand())
795 iBandedGc->DrawArc(aRect, aStart, aEnd);
798 EXPORT_C void CPdrGc::DrawLine(const TPoint& aPoint1,const TPoint& aPoint2)
800 if (PdrControl()->IsGraphicsBand())
801 iBandedGc->DrawLine(aPoint1, aPoint2);
804 EXPORT_C void CPdrGc::DrawLineTo(const TPoint& aPoint)
806 if (PdrControl()->IsGraphicsBand())
807 iBandedGc->DrawLineTo(aPoint);
810 EXPORT_C void CPdrGc::DrawLineBy(const TPoint& aVector)
812 if (PdrControl()->IsGraphicsBand())
813 iBandedGc->DrawLineBy(aVector);
816 EXPORT_C void CPdrGc::DrawPolyLine(const CArrayFix<TPoint>* aPointList)
818 if (PdrControl()->IsGraphicsBand())
819 iBandedGc->DrawPolyLine(aPointList);
822 EXPORT_C void CPdrGc::DrawPolyLine(const TPoint* aPointList,TInt aNumPoints)
824 if (PdrControl()->IsGraphicsBand())
825 iBandedGc->DrawPolyLine(aPointList, aNumPoints);
828 EXPORT_C void CPdrGc::DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd)
830 if (PdrControl()->IsGraphicsBand())
831 iBandedGc->DrawPie(aRect, aStart, aEnd);
834 EXPORT_C void CPdrGc::DrawEllipse(const TRect& aRect)
836 if (PdrControl()->IsGraphicsBand())
837 iBandedGc->DrawEllipse(aRect);
840 EXPORT_C void CPdrGc::DrawRect(const TRect& aRect)
842 if (PdrControl()->IsGraphicsBand())
843 iBandedGc->DrawRect(aRect);
846 EXPORT_C void CPdrGc::DrawRoundRect(const TRect& aRect,const TSize& aCornerSize)
848 if (PdrControl()->IsGraphicsBand())
849 iBandedGc->DrawRoundRect(aRect, aCornerSize);
852 EXPORT_C TInt CPdrGc::DrawPolygon(const CArrayFix<TPoint>* aPointList, TFillRule aFillRule)
855 if (PdrControl()->IsGraphicsBand())
856 ret = iBandedGc->DrawPolygon(aPointList, aFillRule);
860 EXPORT_C TInt CPdrGc::DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule)
863 if (PdrControl()->IsGraphicsBand())
864 ret = iBandedGc->DrawPolygon(aPointList, aNumPoints, aFillRule);
868 EXPORT_C void CPdrGc::DrawBitmap(const TPoint& aTopLeft, const CFbsBitmap* aSource)
870 if (PdrControl()->IsGraphicsBand())
871 iBandedGc->DrawBitmap(aTopLeft, aSource);
874 EXPORT_C void CPdrGc::DrawBitmap(const TRect& aDestRect, const CFbsBitmap* aSource)
876 if (PdrControl()->IsGraphicsBand())
877 iBandedGc->DrawBitmap(aDestRect, aSource);
880 EXPORT_C void CPdrGc::DrawBitmap(const TRect& aDestRect, const CFbsBitmap* aSource, const TRect& aSourceRect)
882 if (PdrControl()->IsGraphicsBand())
883 iBandedGc->DrawBitmap(aDestRect, aSource, aSourceRect);
886 EXPORT_C void CPdrGc::DrawBitmapMasked(const TRect& /*aDestRect*/,const CFbsBitmap* /*aBitmap*/,const TRect& /*aSourceRect*/,const CFbsBitmap* /*aMaskBitmap*/,TBool /*aInvertMask*/)
889 EXPORT_C void CPdrGc::DrawBitmapMasked(const TRect& /*aDestRect*/,const CWsBitmap* /*aBitmap*/,const TRect& /*aSourceRect*/,const CWsBitmap* /*aMaskBitmap*/,TBool /*aInvertMask*/)
892 EXPORT_C void CPdrGc::MapColors(const TRect& /*aRect*/,const TRgb* /*aColors*/,TInt /*aNumPairs*/,TBool /*aMapForwards*/)
896 EXPORT_C TInt CPdrGc::SetClippingRegion(const TRegion &/*aRegion*/)
901 EXPORT_C void CPdrGc::CancelClippingRegion()
904 EXPORT_C void CPdrGc::DrawTextVertical(const TDesC& /*aText*/,const TPoint& /*aPos*/,TBool /*aUp*/)
907 EXPORT_C void CPdrGc::DrawTextVertical(const TDesC& /*aText*/,const TRect& /*aBox*/,TInt /*aBaselineOffset*/,TBool /*aUp*/,TTextAlign /*aVert*/,TInt /*aMargin*/)
910 EXPORT_C TInt CPdrGc::AlphaBlendBitmaps(const TPoint& /*aDestPt*/, const CFbsBitmap* /*aSrcBmp*/, const TRect& /*aSrcRect*/, const CFbsBitmap* /*aAlphaBmp*/, const TPoint& /*aAlphaPt*/)
915 EXPORT_C TInt CPdrGc::AlphaBlendBitmaps(const TPoint& /*aDestPt*/, const CWsBitmap* /*aSrcBmp*/, const TRect& /*aSrcRect*/, const CWsBitmap* /*aAlphaBmp*/, const TPoint& /*aAlphaPt*/)
920 CPdrControl* CPdrGc::PdrControl() const
922 return ((CPdrControl*) iPdrDevice->iControl);
926 @deprecated Interface is deprecated because it is unsafe as it may leave. It is available for backward compatibility reasons only.
927 @see CPdrGc::DrawTextL
930 EXPORT_C void CPdrGc::DrawText(const TDesC& aString, const TPoint& aPosition)
932 TRAP_IGNORE(DrawTextL(aString, aPosition));
935 EXPORT_C void CPdrGc::DrawTextL(const TDesC& aString, const TPoint& aPosition)
937 if (!iPrintTextUsingBitmaps)
939 TInt firstCharNot = 0;
941 __ASSERT_DEBUG(iFont, Panic(EPdrNoFontInUse));
942 if (iFont->AllCharsInFontRepertoire(aString, firstCharNot, length))
944 iPosition = aPosition;
946 TPtrC ptr; // Checks to see iWordExcessWidthInPixels > 0 to avoid panic in JustificationInPixels()
947 for (TInt i = 0; (i < aString.Length()) && iNumGaps && iWordExcessWidthInPixels; i++)
949 if (aString[i] == ' ')
951 ptr.Set(aString.Mid(start, i - start + 1));
952 if (!PdrControl()->IsGraphicsBand())
954 PdrControl()->DrawTextL(iPosition + iOrigin, iUnderlineStyle, iStrikethroughStyle, iPenColor, iFont, ptr);
956 iPosition += TPoint(iFont->MeasureText(ptr) + JustificationInPixels(iWordExcessWidthInPixels, iNumGaps), 0);
960 if (start < aString.Length())
962 ptr.Set(aString.Mid(start));
963 if (!PdrControl()->IsGraphicsBand())
965 PdrControl()->DrawTextL(iPosition + iOrigin, iUnderlineStyle, iStrikethroughStyle, iPenColor, iFont, ptr);
967 iPosition += TPoint(iFont->MeasureText(ptr), 0);
972 if (firstCharNot > 0)
973 { // Take text substring and draw it
975 ptr.Set(aString.Mid(0, firstCharNot));
976 DrawText(ptr, aPosition);
977 // Whole string wasn't text so there must be some (bitmap) string left
978 // Update drawing position
979 TPoint position = iPosition;
980 // Take rest of string and try again
981 ptr.Set(aString.Mid(firstCharNot));
982 DrawText(ptr, position);
985 { // Take bitmap substring and draw it
987 ptr.Set(aString.Mid(0, length));
988 if (PdrControl()->IsGraphicsBand())
990 iPrintTextUsingBitmaps = ETrue;
991 DrawText(ptr, aPosition);
992 iPrintTextUsingBitmaps = EFalse;
994 if (length < aString.Length())
996 // There must be some (text) string left
997 // Update drawing position
998 iPosition = aPosition;
1001 // Checks to see iWordExcessWidthInPixels > 0 to avoid panic in JustificationInPixels()
1002 for (TInt i = 0; (i < ptr.Length()) && iNumGaps && iWordExcessWidthInPixels; i++)
1006 ptr2.Set(ptr.Mid(start, i - start + 1));
1007 iPosition += TPoint(iFont->MeasureText(ptr2) + JustificationInPixels(iWordExcessWidthInPixels, iNumGaps), 0);
1011 if (start < ptr.Length())
1013 ptr2.Set(ptr.Mid(start));
1014 iPosition += TPoint(iFont->MeasureText(ptr2), 0);
1016 TPoint position = iPosition;
1017 // Take rest of string and try again
1018 ptr.Set(aString.Mid(length));
1019 DrawText(ptr, position);
1026 if (PdrControl()->IsGraphicsBand())
1027 iBandedGc->DrawText(aString, aPosition);
1031 EXPORT_C void CPdrGc::DrawText(const TDesC& aString, const TRect& aBox, TInt aBaselineOffset, TTextAlign aHoriz, TInt aLeftMrg)
1033 if (!iPrintTextUsingBitmaps)
1035 __ASSERT_DEBUG(iFont, Panic(EPdrNoFontInUse));
1036 if (!PdrControl()->IsGraphicsBand())
1038 TInt width = iFont->MeasureText(aString);
1040 pos.iY = aBox.iTl.iY + aBaselineOffset;
1041 if (aHoriz == ELeft)
1042 pos.iX = aBox.iTl.iX + aLeftMrg;
1043 else if (aHoriz == ERight)
1044 pos.iX = aBox.iBr.iX - aLeftMrg - width;
1045 else if (aHoriz == ECenter)
1046 pos.iX = (aBox.iTl.iX + aBox.iBr.iX - width) / 2;
1047 DrawText(aString, pos);
1050 iBandedGc->DrawText(KNullDesC, aBox, aBaselineOffset, aHoriz, aLeftMrg);
1054 if (PdrControl()->IsGraphicsBand())
1055 iBandedGc->DrawText(aString, aBox, aBaselineOffset, aHoriz, aLeftMrg);