os/graphics/graphicsdeviceinterface/directgdi/test/tcontext_directgdi.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2007-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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include "tcontextbase.h"
    17 #include <graphics/directgdicontext.h>
    18 #include <graphics/directgdidriver.h>
    19 #include <e32base.h>
    20 
    21 CTestDirectGdiContext::CTestDirectGdiContext()
    22 	{
    23 
    24 	}
    25 
    26 CTestDirectGdiContext* CTestDirectGdiContext::NewL()
    27 	{
    28 	CTestDirectGdiContext* self = new(ELeave) CTestDirectGdiContext;
    29 	CleanupStack::PushL(self);
    30 	self->ConstructL();
    31 	CleanupStack::Pop();
    32 	return self;
    33 	}
    34 
    35 void CTestDirectGdiContext::ConstructL()
    36 	{
    37 	iGdiDriver = CDirectGdiDriver::Static();
    38 	if (iGdiDriver==NULL)
    39 		User::Leave(KErrNotFound);
    40 	TInt result = iGdiDriver->Open();
    41 	if (result != KErrNone)
    42 		User::Leave(result);
    43 
    44 	iGc = CDirectGdiContext::NewL(*iGdiDriver);
    45 	if (iGc==NULL)
    46 		User::Leave(KErrNotFound);
    47 	}
    48 
    49 CTestDirectGdiContext::~CTestDirectGdiContext()
    50 	{
    51 	delete iGc;
    52 	if(iGdiDriver)
    53 		{
    54 		iGdiDriver->Close();
    55 		}	
    56 	}
    57 
    58 void CTestDirectGdiContext::SetOrigin(const TPoint& aOrigin)
    59 	{
    60 	iGc->SetOrigin(aOrigin);
    61 	}
    62 
    63 void CTestDirectGdiContext::SetClippingRegion(const TRegion& aRegion)
    64 	{
    65 	iGc->SetClippingRegion(aRegion);
    66 	}
    67 
    68 void CTestDirectGdiContext::ResetClippingRegion()
    69 	{
    70 	iGc->ResetClippingRegion();
    71 	}
    72 
    73 void CTestDirectGdiContext::SetDrawMode(DirectGdi::TDrawMode aMode)
    74 	{
    75 	iGc->SetDrawMode(aMode);
    76 	}
    77 
    78 void CTestDirectGdiContext::SetPenColor(const TRgb& aColor)
    79 	{
    80 	iGc->SetPenColor(aColor);
    81 	}
    82 
    83 void CTestDirectGdiContext::SetPenStyle(DirectGdi::TPenStyle aStyle)
    84 	{
    85 	iGc->SetPenStyle(aStyle);
    86 	}
    87 
    88 void CTestDirectGdiContext::SetPenSize(const TSize& aSize)
    89 	{
    90 	iGc->SetPenSize(aSize);
    91 	}
    92 
    93 void CTestDirectGdiContext::SetTextShadowColor(const TRgb& aColor)
    94 	{
    95 	iGc->SetTextShadowColor(aColor);
    96 	}
    97 
    98 void CTestDirectGdiContext::SetBrushColor(const TRgb& aColor)
    99 	{
   100 	iGc->SetBrushColor(aColor);
   101 	}
   102 
   103 void CTestDirectGdiContext::SetBrushStyle(DirectGdi::TBrushStyle aStyle)
   104 	{
   105 	iGc->SetBrushStyle(aStyle);
   106 	}
   107 
   108 void CTestDirectGdiContext::SetBrushOrigin(const TPoint& aOrigin)
   109 	{
   110 	iGc->SetBrushOrigin(aOrigin);
   111 	}
   112 
   113 void CTestDirectGdiContext::SetBrushPattern(const CFbsBitmap& aPattern)
   114 	{
   115 	iGc->SetBrushPattern(aPattern);
   116 	}
   117 
   118 void CTestDirectGdiContext::SetBrushPattern(TInt aHandle)
   119 	{
   120 	iGc->SetBrushPattern(aHandle);
   121 	}
   122 
   123 void CTestDirectGdiContext::ResetBrushPattern()
   124 	{
   125 	iGc->ResetBrushPattern();
   126 	}
   127 
   128 void CTestDirectGdiContext::SetFont(const CFont* aFont)
   129 	{
   130 	iGc->SetFont(aFont);
   131 	}
   132 
   133 void CTestDirectGdiContext::ResetFont()
   134 	{
   135 	iGc->ResetFont();
   136 	}
   137 
   138 void CTestDirectGdiContext::Reset()
   139 	{
   140 	iGc->Reset();
   141 	}
   142 
   143 TRgb CTestDirectGdiContext::BrushColor()
   144 	{
   145 	return iGc->BrushColor();
   146 	}
   147 
   148 TRgb CTestDirectGdiContext::PenColor()
   149 	{
   150 	return iGc->PenColor();
   151 	}
   152 
   153 TRgb CTestDirectGdiContext::TextShadowColor()
   154 	{
   155 	return iGc->TextShadowColor();
   156 	}
   157 
   158 void CTestDirectGdiContext::Clear(const TRect& aRect)
   159 	{
   160 	iGc->Clear(aRect);
   161 	}
   162 
   163 void CTestDirectGdiContext::Clear()
   164 	{
   165 	iGc->Clear();
   166 	}
   167 
   168 void CTestDirectGdiContext::MoveTo(const TPoint& aPoint)
   169 	{
   170 	iGc->MoveTo(aPoint);
   171 	}
   172 
   173 void CTestDirectGdiContext::MoveBy(const TPoint& aVector)
   174 	{
   175 	iGc->MoveBy(aVector);
   176 	}
   177 
   178 void CTestDirectGdiContext::Plot(const TPoint& aPoint)
   179 	{
   180 	iGc->Plot(aPoint);
   181 	}
   182 
   183 void CTestDirectGdiContext::DrawLine(const TPoint& aStart, const TPoint& aEnd)
   184 	{
   185 	iGc->DrawLine(aStart, aEnd);
   186 	}
   187 
   188 void CTestDirectGdiContext::DrawLineTo(const TPoint& aPoint)
   189 	{
   190 	iGc->DrawLineTo(aPoint);
   191 	}
   192 
   193 void CTestDirectGdiContext::DrawLineBy(const TPoint& aVector)
   194 	{
   195 	iGc->DrawLineBy(aVector);
   196 	}
   197 
   198 void CTestDirectGdiContext::DrawRect(const TRect& aRect)
   199 	{
   200 	iGc->DrawRect(aRect);
   201 	}
   202 
   203 void CTestDirectGdiContext::DrawRoundRect(const TRect& aRect,
   204 		const TSize& aCornerSize)
   205 	{
   206 	iGc->DrawRoundRect(aRect, aCornerSize);
   207 	}
   208 
   209 void CTestDirectGdiContext::DrawPolyLine(const CArrayFix<TPoint>& aPointList)
   210 	{
   211 	TArray<TPoint> array = aPointList.Array();
   212 	iGc->DrawPolyLine(array);
   213 	}
   214 
   215 void CTestDirectGdiContext::DrawPolyLineNoEndPoint(const CArrayFix<TPoint>& aPointList)
   216 	{
   217 	TArray<TPoint> array = aPointList.Array();
   218 	iGc->DrawPolyLineNoEndPoint(array);
   219 	}
   220 
   221 void CTestDirectGdiContext::DrawPolygon(const CArrayFix<TPoint>& aPoints,
   222 		DirectGdi::TFillRule aRule)
   223 	{
   224 	TArray<TPoint> array = aPoints.Array();
   225 	iGc->DrawPolygon(array, aRule);
   226 	}
   227 
   228 void CTestDirectGdiContext::DrawArc(const TRect& aRect, const TPoint& aStart,
   229 		const TPoint& aEnd)
   230 	{
   231 	iGc->DrawArc(aRect, aStart, aEnd);
   232 	}
   233 
   234 void CTestDirectGdiContext::DrawPie(const TRect& aRect, const TPoint& aStart,
   235 		const TPoint& aEnd)
   236 	{
   237 	iGc->DrawPie(aRect, aStart, aEnd);
   238 	}
   239 
   240 void CTestDirectGdiContext::DrawEllipse(const TRect& aRect)
   241 	{
   242 	iGc->DrawEllipse(aRect);
   243 	}
   244 
   245 void CTestDirectGdiContext::BitBlt(const TPoint& aPoint,
   246 		const CFbsBitmap& aBitmap)
   247 	{
   248 	iGc->BitBlt(aPoint, aBitmap);
   249 	}
   250 
   251 void CTestDirectGdiContext::DrawBitmap(const TRect& aDestRect,
   252 		const CFbsBitmap& aSource)
   253 	{
   254 	iGc->DrawBitmap(aDestRect, aSource);
   255 	}
   256 
   257 void CTestDirectGdiContext::BitBlt(const TPoint& aDestPos,
   258 		const CFbsBitmap& aBitmap, const TRect& aSrcRect)
   259 	{
   260 	iGc->BitBlt(aDestPos, aBitmap, aSrcRect);
   261 	}
   262 
   263 void CTestDirectGdiContext::BitBltMasked(const TPoint& aDestPos,
   264 		const CFbsBitmap& aBitmap, const TRect& aSrcRect,
   265 		const CFbsBitmap& aMask, TBool aInvertMask)
   266 	{
   267 	iGc->BitBltMasked(aDestPos, aBitmap, aSrcRect, aMask, aInvertMask);
   268 	}
   269 
   270 void CTestDirectGdiContext::BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aBitmap, 
   271 		const TRect& aSourceRect, const CFbsBitmap& aAlpha, 
   272 		const TPoint& aAlphaPos)
   273 	{
   274 	iGc->BitBltMasked(aDestPos, aBitmap, aSourceRect, aAlpha, aAlphaPos);
   275 	}
   276 
   277 void CTestDirectGdiContext::DrawBitmap(const TRect& aDestRect,
   278 		const CFbsBitmap& aBitmap, const TRect& aSrcRect)
   279 	{
   280 	iGc->DrawBitmap(aDestRect, aBitmap, aSrcRect);
   281 	}
   282 
   283 void CTestDirectGdiContext::DrawBitmapMasked(const TRect& aDestRect,
   284 		const CFbsBitmap& aBitmap, const TRect& aSrcRect,
   285 		const CFbsBitmap& aMask, TBool aInvertMask)
   286 	{
   287 	iGc->DrawBitmapMasked(aDestRect, aBitmap, aSrcRect, aMask, aInvertMask);
   288 	}
   289 
   290 void CTestDirectGdiContext::CopyRect(const TPoint& aOffset, const TRect& aRect)
   291 	{
   292 	iGc->CopyRect(aOffset, aRect);
   293 	}
   294 
   295 TBool CTestDirectGdiContext::HasBrushPattern() const
   296 	{
   297 	return iGc->HasBrushPattern();
   298 	}
   299 
   300 TBool CTestDirectGdiContext::HasFont() const
   301 	{
   302 	return iGc->HasFont();
   303 	}
   304 
   305 void CTestDirectGdiContext::ExternalizeL(RWriteStream& aWriteStream)
   306 	{
   307 	iGc->ExternalizeL(aWriteStream);
   308 	}
   309 
   310 void CTestDirectGdiContext::InternalizeL(RReadStream& aReadStream)
   311 	{
   312 	iGc->InternalizeL(aReadStream);
   313 	}
   314 
   315 void CTestDirectGdiContext::SetCharJustification(TInt aExcessWidth,
   316 		TInt aNumGaps)
   317 	{
   318 	iGc->SetCharJustification(aExcessWidth, aNumGaps);
   319 	}
   320 
   321 void CTestDirectGdiContext::SetWordJustification(TInt aExcessWidth,
   322 		TInt aNumChars)
   323 	{
   324 	iGc->SetWordJustification(aExcessWidth, aNumChars);
   325 	}
   326 
   327 void CTestDirectGdiContext::SetUnderlineStyle(DirectGdi::TFontUnderline aUnderlineStyle)
   328 	{
   329 	iGc->SetUnderlineStyle((aUnderlineStyle));
   330 	}
   331 
   332 void CTestDirectGdiContext::SetStrikethroughStyle(DirectGdi::TFontStrikethrough aStrikethroughStyle)
   333 	{
   334 	iGc->SetStrikethroughStyle(aStrikethroughStyle);
   335 	}
   336 
   337 void CTestDirectGdiContext::UpdateJustification(const TDesC& aText, const DirectGdi::TTextParameters* aParam)
   338 	{
   339 	iGc->UpdateJustification(aText, aParam);
   340 	}
   341 
   342 void CTestDirectGdiContext::UpdateJustificationVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, TBool aUp)
   343 	{
   344 	iGc->UpdateJustificationVertical(aText, aParam, aUp);
   345 	}
   346 
   347 void CTestDirectGdiContext::SetFontNoDuplicate(const CFont* aFont)
   348 	{
   349 	iGc->SetFontNoDuplicate((CDirectGdiFont*)aFont);
   350 	}
   351 
   352 TInt CTestDirectGdiContext::Activate(RDirectGdiImageTarget& aTarget)
   353 	{
   354 	return iGc->Activate(aTarget);
   355 	}
   356 
   357 
   358 void CTestDirectGdiContext::NoJustifyAutoUpdate()
   359 	{
   360 	iGc->NoJustifyAutoUpdate();
   361 	}
   362 
   363 void CTestDirectGdiContext::SetJustifyAutoUpdate()
   364 	{
   365 	iGc->SetJustifyAutoUpdate();
   366 	}
   367 
   368 TInt CTestDirectGdiContext::GetError()
   369 	{
   370 	return iGdiDriver->GetError();
   371 	}
   372 
   373 // text drawing
   374 void CTestDirectGdiContext::DrawText(const TDesC& aText, const DirectGdi::TTextParameters* aParam)
   375 	{
   376 	iGc->DrawText(aText, aParam);
   377 	}
   378 
   379 void CTestDirectGdiContext::DrawText(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TPoint& aPosition)
   380 	{
   381 	iGc->DrawText(aText, aParam, aPosition);
   382 	}
   383 
   384 void CTestDirectGdiContext::DrawText(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect& aBox)
   385 	{
   386 	iGc->DrawText(aText, aParam, aBox);
   387 	}
   388 
   389 void CTestDirectGdiContext::DrawText(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect& aBox, TInt aBaselineOffset, 
   390 			DirectGdi::TTextAlign aAlignment, TInt aMargin)
   391 	{
   392 	iGc->DrawText(aText, aParam, aBox, aBaselineOffset, aAlignment, aMargin);
   393 	}
   394 
   395 void CTestDirectGdiContext::DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, TBool aUp)
   396 	{
   397 	iGc->DrawTextVertical(aText, aParam, aUp);
   398 	}
   399 
   400 void CTestDirectGdiContext::DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TPoint& aPosition, TBool aUp)
   401 	{
   402 	iGc->DrawTextVertical(aText, aParam, aPosition, aUp);
   403 	}
   404 
   405 void CTestDirectGdiContext::DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect& aBox, TBool aUp)
   406 	{
   407 	iGc->DrawTextVertical(aText, aParam, aBox, aUp);
   408 	}
   409 
   410 void CTestDirectGdiContext::DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect& aBox, TInt aBaselineOffset, 
   411 			TBool aUp, DirectGdi::TTextAlign aVerticalAlignment, TInt aMargin)
   412 	{
   413 	iGc->DrawTextVertical(aText, aParam, aBox, aBaselineOffset, aUp, aVerticalAlignment, aMargin);
   414 	}
   415 
   416 void CTestDirectGdiContext::DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect& aBox, TInt aBaselineOffset, 
   417 		TInt aTextWidth, TBool aUp, DirectGdi::TTextAlign aVerticalAlignment, TInt aMargin)
   418 	{
   419 	iGc->DrawTextVertical(aText, aParam, aBox, aBaselineOffset, aTextWidth, aUp, aVerticalAlignment, aMargin);
   420 	}
   421 
   422 void CTestDirectGdiContext::DrawResource(const TPoint& aPos, 
   423 										const TDrawableSourceAndEquivRotatedBmps& aSource, 
   424 										DirectGdi::TGraphicsRotation aRotation)
   425 	{
   426 	iGc->DrawResource(aPos, *(aSource.iDrawableSrc), aRotation);
   427 	}
   428 
   429 void CTestDirectGdiContext::DrawResource(const TRect& aDestRect, 
   430 										const TDrawableSourceAndEquivRotatedBmps& aSource,
   431 										DirectGdi::TGraphicsRotation aRotation)
   432 	{
   433 	iGc->DrawResource(aDestRect, *(aSource.iDrawableSrc), aRotation);
   434 	}
   435 
   436 void CTestDirectGdiContext::DrawResource(const TRect& aDestRect, 
   437 										const TDrawableSourceAndEquivRotatedBmps& aSource, 
   438 										const TRect& aSrcRect,
   439 										DirectGdi::TGraphicsRotation aRotation)
   440 	{
   441 	iGc->DrawResource(aDestRect, *(aSource.iDrawableSrc), aSrcRect, aRotation);
   442 	}
   443 
   444 void CTestDirectGdiContext::DrawResource(const TRect& aDestRect, 
   445 										const TDrawableSourceAndEquivRotatedBmps& aSource, 
   446 										const TDesC8& aParam)
   447 	{
   448 	iGc->DrawResource(aDestRect, *(aSource.iDrawableSrc), aParam);
   449 	}
   450 
   451 TInt CTestDirectGdiContext::GetInterface(TUid aInterfaceId, TAny*& aInterface)
   452 	{
   453 	return iGc->GetInterface(aInterfaceId, aInterface);
   454 	}
   455 
   456 void CTestDirectGdiContext::CopySettings(const CTContextBase& aGc)
   457 	{
   458 	CTestDirectGdiContext* gc = (CTestDirectGdiContext*)&aGc;
   459 	iGc->CopySettings(*(gc->iGc));
   460 	}