fontservices/textbase/tgdi/TGraphicsContext.cpp
changeset 45 662fa7de7023
equal deleted inserted replaced
41:ea44a32a96bc 45:662fa7de7023
       
     1 // Copyright (c) 2002-2010 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 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent Internal Symbian test code
       
    20 */
       
    21 
       
    22 #include "TTYPES.H"
       
    23 #include "TGraphicsContext.h"
       
    24 
       
    25 
       
    26 
       
    27 // Utility functions to show contents of test data using test.Printf
       
    28 
       
    29 extern void PrintTestData (const TDesC& aTitle , const TDesC16& aDataBuffer);
       
    30 
       
    31 extern void PrintTestData(const TDesC& aTitle, const TText16* aDataBuffer, const TInt aSize);
       
    32 
       
    33 
       
    34 
       
    35 
       
    36 _LIT(KTestFontName, "Non Functional Test Font");
       
    37 
       
    38 
       
    39 CTestPalette2::~CTestPalette2()
       
    40 	{
       
    41 	iArray = 0; //avoid attempting to deallocate iArray in ~CPalette
       
    42 	iNumEntries = 0;
       
    43 	}
       
    44 
       
    45 //
       
    46 //
       
    47 // CTestGraphicsDevice
       
    48 //
       
    49 //
       
    50 CTestGraphicsDevice* CTestGraphicsDevice::NewL(TSize aSizeInPixels)
       
    51 	{
       
    52 	CTestGraphicsDevice* theDevice = new (ELeave) CTestGraphicsDevice(aSizeInPixels);
       
    53 	CleanupStack::PushL(theDevice);
       
    54 	theDevice->iPalette = new (ELeave) CTestPalette2;
       
    55 	theDevice->iPalette->SetEntry(0, KRgbBlack);
       
    56 	theDevice->iPalette->SetEntry(1, KRgbWhite);
       
    57 	theDevice->iPalette->SetEntry(2, KRgbMagenta);
       
    58 	theDevice->iPalette->SetEntry(3, KRgbCyan);
       
    59 	
       
    60 	CleanupStack::Pop(theDevice);
       
    61 	return theDevice;
       
    62 	}
       
    63 
       
    64 CTestGraphicsDevice::CTestGraphicsDevice(TSize aSizeInPixels)
       
    65 	: iSize(aSizeInPixels),
       
    66 	iHorizontalTwipsToPixels(40),
       
    67 	iVerticalTwipsToPixels(40)
       
    68 	{
       
    69 	}
       
    70 CTestGraphicsDevice::~CTestGraphicsDevice()
       
    71 	{
       
    72 	delete iPalette;
       
    73 	}
       
    74 
       
    75 void CTestGraphicsDevice::SetHorizontalTwipsToPixels(TInt aTwipsToPixels)
       
    76 	{
       
    77 	iHorizontalTwipsToPixels = aTwipsToPixels;
       
    78 	}
       
    79 
       
    80 void CTestGraphicsDevice::SetVerticalTwipsToPixels(TInt aTwipsToPixels)
       
    81 	{
       
    82 	iVerticalTwipsToPixels = aTwipsToPixels;
       
    83 	}
       
    84 
       
    85 TDisplayMode CTestGraphicsDevice::DisplayMode() const
       
    86 	{
       
    87 	return EColor16M;
       
    88 	}
       
    89 
       
    90 TSize CTestGraphicsDevice::SizeInPixels() const
       
    91 	{
       
    92 	return iSize;
       
    93 	}
       
    94 
       
    95 TSize CTestGraphicsDevice::SizeInTwips() const
       
    96 	{
       
    97 	return TSize(iSize.iWidth * iHorizontalTwipsToPixels,
       
    98 		iSize.iHeight * iVerticalTwipsToPixels);
       
    99 	}
       
   100 
       
   101 TInt CTestGraphicsDevice::CreateContext(CGraphicsContext*& aGC)
       
   102 	{
       
   103 	CGraphicsContext* r = new CTestGraphicsContext(this);
       
   104 	if (!r)
       
   105 		return KErrNoMemory;
       
   106 	aGC = r;
       
   107 	return KErrNone;
       
   108 	}
       
   109 
       
   110 TInt CTestGraphicsDevice::NumTypefaces() const
       
   111 	{
       
   112 	return 1;
       
   113 	}
       
   114 
       
   115 void CTestGraphicsDevice::TypefaceSupport(TTypefaceSupport& aTypefaceSupport, TInt aTypefaceIndex) const
       
   116 	{
       
   117 	// The only font we have at the moment is 10 pixels * 12 pixels for every character
       
   118 	__ASSERT_ALWAYS(aTypefaceIndex == 0,
       
   119 		CTestGraphicsContext::Panic(CTestGraphicsContext::ETypefaceIndexOutOfRange));
       
   120 	aTypefaceSupport.iIsScalable = EFalse;
       
   121 	aTypefaceSupport.iMaxHeightInTwips = iVerticalTwipsToPixels * 12;
       
   122 	aTypefaceSupport.iMinHeightInTwips = iVerticalTwipsToPixels * 10;
       
   123 	aTypefaceSupport.iNumHeights = 1;
       
   124 	aTypefaceSupport.iTypeface.iName = KTestFontName;
       
   125 	aTypefaceSupport.iTypeface.SetIsProportional(ETrue); // a bit of a lie
       
   126 	aTypefaceSupport.iTypeface.SetIsSerif(EFalse);
       
   127 	aTypefaceSupport.iTypeface.SetIsSymbol(EFalse);
       
   128 	}
       
   129 
       
   130 TInt CTestGraphicsDevice::FontHeightInTwips(TInt aTypefaceIndex, TInt aHeightIndex) const
       
   131 	{
       
   132 	// The only font we have at the moment is 10 pixels * 12 pixels for every character
       
   133 	__ASSERT_ALWAYS(aTypefaceIndex == 0,
       
   134 		CTestGraphicsContext::Panic(CTestGraphicsContext::ETypefaceIndexOutOfRange));
       
   135 	return iVerticalTwipsToPixels * FontHeightInPixels(aTypefaceIndex, aHeightIndex);
       
   136 	}
       
   137 
       
   138 void CTestGraphicsDevice::PaletteAttributes(TBool& aModifiable, TInt& aNumEntries) const
       
   139 	{
       
   140 	aModifiable = ETrue;
       
   141 	aNumEntries = 4;
       
   142 	}
       
   143 
       
   144 void CTestGraphicsDevice::SetPalette(CPalette* aPalette)
       
   145 	{
       
   146 	for (TInt i = 0; i != CTestPalette2::KNumEntries; ++i)
       
   147 		{
       
   148 		TRgb col = aPalette->GetEntry(i);
       
   149 		iPalette -> SetEntry(i, col);
       
   150 		}
       
   151 	}
       
   152 
       
   153 TInt CTestGraphicsDevice::GetPalette(CPalette*& aPalette) const
       
   154 	{
       
   155 	aPalette =  const_cast<CTestPalette2*>(iPalette);
       
   156 	return KErrNone;
       
   157 	}
       
   158 
       
   159 void CTestGraphicsDevice::GetPixel(TRgb& aColor, const TPoint&) const
       
   160 	{
       
   161 	aColor = KRgbWhite;
       
   162 	}
       
   163 
       
   164 void CTestGraphicsDevice::GetScanLine(TDes8&, const TPoint&, TInt, TDisplayMode) const
       
   165 	{
       
   166 	__ASSERT_DEBUG(0, CTestGraphicsContext::Panic(CTestGraphicsContext::EUnimplemented));
       
   167 	}
       
   168 
       
   169 TInt CTestGraphicsDevice::AddFile(const TDesC&, TInt&)
       
   170 	{
       
   171 	return KErrNotSupported;
       
   172 	}
       
   173 
       
   174 void CTestGraphicsDevice::RemoveFile(TInt)
       
   175 	{
       
   176 	}
       
   177 
       
   178 TInt CTestGraphicsDevice::GetNearestFontInPixels(CFont*& aFont, const TFontSpec& aFontSpec)
       
   179 	{
       
   180 	return GetNearestFontToDesignHeightInPixels(aFont, aFontSpec);
       
   181 	}
       
   182 
       
   183 TInt CTestGraphicsDevice::GetNearestFontToDesignHeightInPixels(CFont*& aFont, const TFontSpec& /*aFontSpec*/)
       
   184 	{
       
   185 	CTestFont* font = new CTestFont();
       
   186 	if (!font)
       
   187 		return KErrNoMemory;
       
   188 	aFont = font;
       
   189 	return KErrNone;
       
   190 	}
       
   191 
       
   192 TInt CTestGraphicsDevice::GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& /*aFontSpec*/, TInt /*aMaxHeight*/)
       
   193 	{
       
   194 	CTestFont* font = new CTestFont();
       
   195 	if (!font)
       
   196 		return KErrNoMemory;
       
   197 	aFont = font;
       
   198 	return KErrNone;
       
   199 	}
       
   200 
       
   201 TInt CTestGraphicsDevice::FontHeightInPixels(TInt, TInt) const
       
   202 	{
       
   203 	return 12;
       
   204 	}
       
   205 
       
   206 TInt CTestGraphicsDevice::HorizontalTwipsToPixels(TInt aTwips) const
       
   207 	{
       
   208 	return aTwips / iHorizontalTwipsToPixels;
       
   209 	}
       
   210 
       
   211 TInt CTestGraphicsDevice::VerticalTwipsToPixels(TInt aTwips) const
       
   212 	{
       
   213 	return aTwips / iVerticalTwipsToPixels;
       
   214 	}
       
   215 
       
   216 TInt CTestGraphicsDevice::HorizontalPixelsToTwips(TInt aPixels) const
       
   217 	{
       
   218 	return aPixels * iHorizontalTwipsToPixels;
       
   219 	}
       
   220 
       
   221 TInt CTestGraphicsDevice::VerticalPixelsToTwips(TInt aPixels) const
       
   222 	{
       
   223 	return aPixels * iVerticalTwipsToPixels;
       
   224 	}
       
   225 
       
   226 TInt CTestGraphicsDevice::GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec)
       
   227 	{
       
   228 	return GetNearestFontToDesignHeightInTwips(aFont, aFontSpec);
       
   229 	}
       
   230 
       
   231 TInt CTestGraphicsDevice::GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec)
       
   232 	{
       
   233 	TFontSpec fontSpec = aFontSpec;
       
   234 	fontSpec.iHeight = VerticalTwipsToPixels(fontSpec.iHeight);
       
   235 	return GetNearestFontToDesignHeightInPixels(aFont, fontSpec);
       
   236 	}
       
   237 
       
   238 TInt CTestGraphicsDevice::GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight)
       
   239 	{
       
   240 	TFontSpec fontSpec = aFontSpec;
       
   241 	fontSpec.iHeight = VerticalTwipsToPixels(fontSpec.iHeight);
       
   242 	return GetNearestFontToMaxHeightInPixels(aFont, fontSpec, VerticalTwipsToPixels(aMaxHeight));
       
   243 	}
       
   244 
       
   245 void CTestGraphicsDevice::ReleaseFont(CFont* aFont)
       
   246 	{
       
   247 	__ASSERT_ALWAYS(aFont->TypeUid() == TUid::Uid(12345),
       
   248 		CTestGraphicsContext::Panic(CTestGraphicsContext::EUnknownFont));
       
   249 	delete static_cast<CTestFont*>(aFont);
       
   250 	}
       
   251 
       
   252 //
       
   253 //
       
   254 // CTestGraphicsContext
       
   255 //
       
   256 //
       
   257 void CTestGraphicsContext::Panic(TInt aReason)
       
   258 	{
       
   259 	User::Panic(_L("CTestGC"), aReason);
       
   260 	}
       
   261 
       
   262 CTestGraphicsContext::CTestGraphicsContext(CTestGraphicsDevice* aGd)
       
   263 	: iGd(aGd), iDrawMode(EDrawModePEN), iPenSize(1,1)
       
   264 	{
       
   265 	}
       
   266 
       
   267 CTestGraphicsContext::~CTestGraphicsContext()
       
   268 	{
       
   269 	iLineArray.Reset();
       
   270 	}
       
   271 void CTestGraphicsContext::AddRectToDrawnArea(const TRect& aRect)
       
   272 	{
       
   273 	if (iDrawnArea.IsEmpty())
       
   274 		iDrawnArea = aRect;
       
   275 	else
       
   276 		iDrawnArea.BoundingRect(aRect);
       
   277 	// only one condition at the moment
       
   278 	if (iDrawMode == EDrawModeXOR)
       
   279 		{
       
   280 		if (iAreaDrawnWithCondition.IsEmpty())
       
   281 			iAreaDrawnWithCondition = aRect;
       
   282 		else
       
   283 			iAreaDrawnWithCondition.BoundingRect(aRect);
       
   284 		}
       
   285 	}
       
   286 
       
   287 void CTestGraphicsContext::AddPointToDrawnArea(const TPoint& aPoint)
       
   288 	{
       
   289 	AddRectToDrawnArea(TRect(aPoint, iPenSize));
       
   290 	}
       
   291 
       
   292 CGraphicsDevice* CTestGraphicsContext::Device() const
       
   293 	{
       
   294 	return iGd;
       
   295 	}
       
   296 
       
   297 void CTestGraphicsContext::SetOrigin(const TPoint& aPos)
       
   298 	{
       
   299 	iOrigin = aPos;
       
   300 	}
       
   301 
       
   302 void CTestGraphicsContext::SetDrawMode(TDrawMode aDrawingMode)
       
   303 	{
       
   304 	iDrawMode = aDrawingMode;
       
   305 	}
       
   306 
       
   307 void CTestGraphicsContext::SetClippingRect(const TRect& /*aRect*/)
       
   308 	{
       
   309 	}
       
   310 
       
   311 void CTestGraphicsContext::CancelClippingRect()
       
   312 	{
       
   313 	}
       
   314 
       
   315 void CTestGraphicsContext::Reset()
       
   316 	{
       
   317 	iDrawMode = EDrawModePEN;
       
   318 	iFont = 0;
       
   319 	iPenSize.iWidth = 1;
       
   320 	iPenSize.iHeight = 1;
       
   321 	}
       
   322 
       
   323 void CTestGraphicsContext::UseFont(const CFont* aFont)
       
   324 	{
       
   325 	iFont = aFont;
       
   326 	}
       
   327 
       
   328 void CTestGraphicsContext::DiscardFont()
       
   329 	{
       
   330 	iFont = 0;
       
   331 	}
       
   332 
       
   333 void CTestGraphicsContext::SetUnderlineStyle(TFontUnderline /*UnderlineStyle*/)
       
   334 	{
       
   335 	}
       
   336 
       
   337 void CTestGraphicsContext::SetStrikethroughStyle(TFontStrikethrough /*aStrikethroughStyle*/)
       
   338 	{
       
   339 	}
       
   340 
       
   341 void CTestGraphicsContext::SetWordJustification(TInt /*aExcessWidth*/,TInt /*aNumGaps*/)
       
   342 	{
       
   343 	}
       
   344 
       
   345 void CTestGraphicsContext::SetCharJustification(TInt /*aExcessWidth*/,TInt /*aNumChars*/)
       
   346 	{
       
   347 	}
       
   348 
       
   349 void CTestGraphicsContext::SetPenColor(const TRgb& aColor)
       
   350 	{
       
   351 	CPalette* palette;
       
   352 	iGd->GetPalette(palette);
       
   353 	iPenColorIndex = palette->NearestIndex(aColor);
       
   354 	}
       
   355 
       
   356 void CTestGraphicsContext::SetPenStyle(TPenStyle /*aPenStyle*/)
       
   357 	{
       
   358 	}
       
   359 
       
   360 void CTestGraphicsContext::SetPenSize(const TSize& aSize)
       
   361 	{
       
   362 	iPenSize = aSize;
       
   363 	}
       
   364 
       
   365 void CTestGraphicsContext::SetBrushColor(const TRgb& /*aColor*/)
       
   366 	{
       
   367 	}
       
   368 
       
   369 void CTestGraphicsContext::SetBrushStyle(TBrushStyle /*aBrushStyle*/)
       
   370 	{
       
   371 	}
       
   372 
       
   373 void CTestGraphicsContext::SetBrushOrigin(const TPoint& /*aOrigin*/)
       
   374 	{
       
   375 	}
       
   376 
       
   377 void CTestGraphicsContext::UseBrushPattern(const CFbsBitmap* /*aBitmap*/)
       
   378 	{
       
   379 	}
       
   380 
       
   381 void CTestGraphicsContext::DiscardBrushPattern()
       
   382 	{
       
   383 	}
       
   384 
       
   385 void CTestGraphicsContext::MoveTo(const TPoint& aPoint)
       
   386 	{
       
   387 	iCurrentPos = iOrigin + aPoint;
       
   388 	}
       
   389 
       
   390 void CTestGraphicsContext::MoveBy(const TPoint& aVector)
       
   391 	{
       
   392 	iCurrentPos += aVector;
       
   393 	}
       
   394 
       
   395 void CTestGraphicsContext::Plot(const TPoint& aPoint)
       
   396 	{
       
   397 	iCurrentPos = iOrigin + aPoint;
       
   398 	AddPointToDrawnArea(iCurrentPos);
       
   399 	}
       
   400 
       
   401 void CTestGraphicsContext::DrawArc(const TRect& aRect,const TPoint& /*aStart*/,const TPoint& aEnd)
       
   402 	{
       
   403 	TRect r = aRect;
       
   404 	r.Move(iOrigin);
       
   405 	AddRectToDrawnArea(r);
       
   406 	iCurrentPos = iOrigin + aEnd;
       
   407 	}
       
   408 
       
   409 void CTestGraphicsContext::DrawLine(const TPoint& aPoint1,const TPoint& aPoint2)
       
   410 	{
       
   411 	AddPointToDrawnArea(iOrigin + aPoint1);
       
   412 	iCurrentPos = iOrigin + aPoint2;
       
   413 	AddPointToDrawnArea(iCurrentPos);
       
   414 	}
       
   415 
       
   416 void CTestGraphicsContext::DrawLineTo(const TPoint& aPoint)
       
   417 	{
       
   418 	AddPointToDrawnArea(iCurrentPos);
       
   419 	iCurrentPos = iOrigin + aPoint;
       
   420 	AddPointToDrawnArea(iCurrentPos);
       
   421 	}
       
   422 
       
   423 void CTestGraphicsContext::DrawLineBy(const TPoint& aVector)
       
   424 	{
       
   425 	AddPointToDrawnArea(iCurrentPos);
       
   426 	iCurrentPos += aVector;
       
   427 	AddPointToDrawnArea(iCurrentPos);
       
   428 	}
       
   429 
       
   430 void CTestGraphicsContext::DrawPolyLine(const CArrayFix<TPoint>* aPointList)
       
   431 	{
       
   432 	TInt num = aPointList->Count();
       
   433 	while (num--)
       
   434 		{
       
   435 		iCurrentPos = iOrigin + (*aPointList)[num - 1];
       
   436 		AddPointToDrawnArea(iCurrentPos);
       
   437 		}
       
   438 	}
       
   439 
       
   440 void CTestGraphicsContext::DrawPolyLine(const TPoint* aPointList,TInt aNumPoints)
       
   441 	{
       
   442 	while (aNumPoints--)
       
   443 		{
       
   444 		iCurrentPos = iOrigin + aPointList[aNumPoints - 1];
       
   445 		AddPointToDrawnArea(iCurrentPos);
       
   446 		}
       
   447 	}
       
   448 
       
   449 void CTestGraphicsContext::DrawPie(const TRect& aRect,
       
   450 	const TPoint& /*aStart*/, const TPoint& aEnd)
       
   451 	{
       
   452 	TRect r = aRect;
       
   453 	r.Move(iOrigin);
       
   454 	AddRectToDrawnArea(r);
       
   455 	iCurrentPos = iOrigin + aEnd;
       
   456 	}
       
   457 
       
   458 void CTestGraphicsContext::DrawEllipse(const TRect& aRect)
       
   459 	{
       
   460 	TRect r = aRect;
       
   461 	r.Move(iOrigin);
       
   462 	AddRectToDrawnArea(r);
       
   463 	}
       
   464 
       
   465 void CTestGraphicsContext::DrawRect(const TRect& aRect)
       
   466 	{
       
   467 	TRect r = aRect;
       
   468 	r.Move(iOrigin);
       
   469 	AddRectToDrawnArea(r);
       
   470 	}
       
   471 
       
   472 void CTestGraphicsContext::DrawRoundRect(const TRect& aRect,const TSize& aCornerSize)
       
   473 	{
       
   474 	TRect r = aRect;
       
   475 	r.Move(iOrigin);
       
   476 	r.Grow(aCornerSize);
       
   477 	AddRectToDrawnArea(r);
       
   478 	}
       
   479 
       
   480 TInt CTestGraphicsContext::DrawPolygon(const CArrayFix<TPoint>* aPointList,TFillRule /*aFillRule*/)
       
   481 	{
       
   482 	TInt num = aPointList->Count();
       
   483 	while (num--)
       
   484 		{
       
   485 		iCurrentPos = iOrigin + (*aPointList)[num - 1];
       
   486 		AddPointToDrawnArea(iCurrentPos);
       
   487 		}
       
   488 	return KErrNone;
       
   489 	}
       
   490 
       
   491 TInt CTestGraphicsContext::DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule /*aFillRule*/)
       
   492 	{
       
   493 	while (aNumPoints--)
       
   494 		{
       
   495 		iCurrentPos = iOrigin + aPointList[aNumPoints - 1];
       
   496 		AddPointToDrawnArea(iCurrentPos);
       
   497 		}
       
   498 	return KErrNone;
       
   499 	}
       
   500 
       
   501 void CTestGraphicsContext::DrawBitmap(const TPoint& /*aTopLeft*/,const CFbsBitmap* /*aSource*/)
       
   502 	{
       
   503 	}
       
   504 
       
   505 void CTestGraphicsContext::DrawBitmap(const TRect& /*aDestRect*/,const CFbsBitmap* /*aSource*/)
       
   506 	{
       
   507 	}
       
   508 
       
   509 void CTestGraphicsContext::DrawBitmap(const TRect& /*aDestRect*/,const CFbsBitmap* /*aSource*/,const TRect& /*aSourceRect*/)
       
   510 	{
       
   511 	}
       
   512 
       
   513 void CTestGraphicsContext::DrawBitmapMasked(const TRect& /*aDestRect*/,const CFbsBitmap* /*aBitmap*/,const TRect& /*aSourceRect*/,const CFbsBitmap* /*aMaskBitmap*/,TBool /*aInvertMask*/)
       
   514 	{}
       
   515 	
       
   516 void CTestGraphicsContext::DrawBitmapMasked(const TRect& /*aDestRect*/,const CWsBitmap* /*aBitmap*/,const TRect& /*aSourceRect*/,const CWsBitmap* /*aMaskBitmap*/,TBool /*aInvertMask*/)
       
   517 	{
       
   518 	}
       
   519 
       
   520 void CTestGraphicsContext::MapColors(const TRect &/*aRect*/,const TRgb */*aColors*/,TInt /*aNumPairs*/,TBool /*aMapForwards*/)
       
   521 	{}
       
   522 	
       
   523 TInt CTestGraphicsContext::SetClippingRegion(const TRegion &/*aRegion*/)
       
   524 	{
       
   525 		return KErrNone;
       
   526 	}	
       
   527 	
       
   528 void CTestGraphicsContext::CancelClippingRegion()
       
   529 	{}
       
   530 	
       
   531 void CTestGraphicsContext::DrawTextVertical(const TDesC& /*aText*/,const TPoint& /*aPos*/,TBool /*aUp*/)
       
   532 	{}
       
   533 	
       
   534 void CTestGraphicsContext::DrawTextVertical(const TDesC& /*aText*/,const TRect& /*aBox*/,TInt /*aBaselineOffset*/,TBool /*aUp*/,TTextAlign /*aVert*/,TInt /*aMargin*/)
       
   535 	{}
       
   536 	
       
   537 /**
       
   538  *
       
   539  * DrawText - merely add line "drawn" to collection
       
   540  *
       
   541  */
       
   542 
       
   543 
       
   544 void CTestGraphicsContext::DrawText(const TDesC& aText,const TPoint& aPosition)
       
   545 	{
       
   546 
       
   547 #ifdef PRINT_DRAWTEXT_LINES
       
   548 
       
   549 	_LIT(KDrawTextFormat, "DrawText called for position %d,%d:");
       
   550 	_LIT(KDrawTextTitle, "Text being drawn");
       
   551 		test.Printf(KDrawTextFormat, aPosition.iX, aPosition.iY);
       
   552 		PrintTestData(KDrawTextTitle, aText);
       
   553 
       
   554 #endif /* PRINT_DRAWTEXT_LINES */
       
   555 	
       
   556 	TTestGCDisplayLine thisLine;
       
   557 	thisLine.Set(aPosition, aText);
       
   558 	iLineArray.Append(thisLine);
       
   559 
       
   560 	}
       
   561 
       
   562 void CTestGraphicsContext::DrawText(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,
       
   563 	TTextAlign /*aAlignment*/, TInt aLeftMargin)
       
   564 	{
       
   565 	TPoint pos(aBox.iBr.iX + aLeftMargin, aBox.iTl.iY + aBaselineOffset);
       
   566 	pos += iOrigin;
       
   567 	DrawText(aText, pos);
       
   568 	}
       
   569 
       
   570 void CTestGraphicsContext::DrawText(const TDesC& aText, const TPoint& aPosition,
       
   571 	const TDrawTextParam&)
       
   572 	{
       
   573 	DrawText(aText, aPosition);
       
   574 	}
       
   575 
       
   576 //
       
   577 //
       
   578 // CTestFont
       
   579 //
       
   580 //
       
   581 TUid CTestFont::DoTypeUid() const
       
   582 	{
       
   583 	return TUid::Uid(12345);
       
   584 	}
       
   585 
       
   586 TInt CTestFont::DoHeightInPixels() const
       
   587 	{
       
   588 	return 12;
       
   589 	}
       
   590 
       
   591 TInt CTestFont::DoAscentInPixels() const
       
   592 	{
       
   593 	return 10;
       
   594 	}
       
   595 
       
   596 TInt CTestFont::DoCharWidthInPixels(TChar aChar) const
       
   597 	{
       
   598 	switch (aChar)
       
   599 		{
       
   600 	case 0x200C:
       
   601 	case 0x200D:
       
   602 	case 0x200E:
       
   603 	case 0x200F:
       
   604 	case 0x202A:
       
   605 	case 0x202B:
       
   606 	case 0x202C:
       
   607 	case 0x202D:
       
   608 	case 0x202E:
       
   609 	case 0xFFFF:
       
   610 		return 0;
       
   611 	default:
       
   612 		return 10;
       
   613 		}
       
   614 	}
       
   615 
       
   616 TInt CTestFont::DoTextWidthInPixels(const TDesC& aText) const
       
   617 	{
       
   618 	TInt total = 0;
       
   619 	const TText* p = aText.Ptr();
       
   620 	const TText* end = p + aText.Length();
       
   621 	for (;p != end; ++p)
       
   622 		total += CharWidthInPixels(*p);
       
   623 	return total;
       
   624 	}
       
   625 
       
   626 TInt CTestFont::DoBaselineOffsetInPixels() const
       
   627 	{
       
   628 	return 10;
       
   629 	}
       
   630 
       
   631 TInt CTestFont::DoTextCount(const TDesC& aText,TInt aWidthInPixels) const
       
   632 	{
       
   633 	TInt excess;
       
   634 	return DoTextCount(aText, aWidthInPixels, excess);
       
   635 	}
       
   636 
       
   637 TInt CTestFont::DoTextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const
       
   638 	{
       
   639 	aExcessWidthInPixels = aWidthInPixels;
       
   640 	const TText* start = aText.Ptr();
       
   641 	const TText* end = start + aText.Length();
       
   642 	const TText* p = start;
       
   643 	TInt width;
       
   644 	while (p != end
       
   645 		&& (width = CharWidthInPixels(*p)) <= aExcessWidthInPixels)
       
   646 		{
       
   647 		aExcessWidthInPixels -= width;
       
   648 		++p;
       
   649 		}
       
   650 	return p - start;
       
   651 	}
       
   652 
       
   653 TInt CTestFont::DoMaxCharWidthInPixels() const
       
   654 	{
       
   655 	return 10;
       
   656 	}
       
   657 
       
   658 TInt CTestFont::DoMaxNormalCharWidthInPixels() const
       
   659 	{
       
   660 	return 10;
       
   661 	}
       
   662 
       
   663 TFontSpec CTestFont::DoFontSpecInTwips() const
       
   664 	{
       
   665 	return TFontSpec(KTestFontName, 12);
       
   666 	}
       
   667 
       
   668 CFont::TCharacterDataAvailability 
       
   669  CTestFont::DoGetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,
       
   670  	const TUint8*& aBitmap, TSize& aBitmapSize) const
       
   671    	{
       
   672  	TInt width;
       
   673    	switch (aCode)
       
   674    		{
       
   675    	case 0x001B:
       
   676  		// ESC character should cause this fault; no character data available.
       
   677    		return CFont::ENoCharacterData;
       
   678  	case 'W':
       
   679  		// We want 'W' to have side-bearings
       
   680  		CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
       
   681  		width = aMetrics.Width();
       
   682  		aMetrics.SetHorizBearingX(-1);
       
   683  		aMetrics.SetWidth(width + 2);
       
   684  		return CFont::ECharacterWidthOnly ;
       
   685  	case 0x0648:
       
   686  		// Arabic Waw-- has massive left side-bearing
       
   687  		CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
       
   688  		width = aMetrics.Width();
       
   689  		aMetrics.SetHorizBearingX(-5);
       
   690  		aMetrics.SetWidth(width + 5);
       
   691  		return CFont::ECharacterWidthOnly ;
       
   692 	case 'X':
       
   693 		// We want 'X' to have a left side-bearing only
       
   694 		CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
       
   695 		aMetrics.SetHorizBearingX(-1);
       
   696 		return CFont::ECharacterWidthOnly ;
       
   697 	case 0x05EA:
       
   698 		// We want Hebrew Tav to have a +ve left side-bearing
       
   699 		CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
       
   700 		aMetrics.SetHorizBearingX(1);
       
   701 		return CFont::ECharacterWidthOnly ;
       
   702 	case 0x304B:
       
   703 		// We want Hiragana Ka to have a top end-bearing
       
   704 		CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
       
   705 		aMetrics.SetVertBearingY(-1);
       
   706 		return CFont::EAllCharacterData ;
       
   707 	case 0x0020:
       
   708 		CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
       
   709 		aMetrics.SetWidth(0);
       
   710 		aMetrics.SetHeight(0);
       
   711 		aMetrics.SetVertAdvance(0);
       
   712 		return CFont::ECharacterWidthOnly ;	
       
   713 	default:
       
   714 		return CFont::DoGetCharacterData(aCode, aMetrics, aBitmap, aBitmapSize);
       
   715 		}
       
   716 	}