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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "tcontextbase.h"
17 #include <graphics/directgdicontext.h>
18 #include <graphics/directgdidriver.h>
21 CTestDirectGdiContext::CTestDirectGdiContext()
26 CTestDirectGdiContext* CTestDirectGdiContext::NewL()
28 CTestDirectGdiContext* self = new(ELeave) CTestDirectGdiContext;
29 CleanupStack::PushL(self);
35 void CTestDirectGdiContext::ConstructL()
37 iGdiDriver = CDirectGdiDriver::Static();
39 User::Leave(KErrNotFound);
40 TInt result = iGdiDriver->Open();
41 if (result != KErrNone)
44 iGc = CDirectGdiContext::NewL(*iGdiDriver);
46 User::Leave(KErrNotFound);
49 CTestDirectGdiContext::~CTestDirectGdiContext()
58 void CTestDirectGdiContext::SetOrigin(const TPoint& aOrigin)
60 iGc->SetOrigin(aOrigin);
63 void CTestDirectGdiContext::SetClippingRegion(const TRegion& aRegion)
65 iGc->SetClippingRegion(aRegion);
68 void CTestDirectGdiContext::ResetClippingRegion()
70 iGc->ResetClippingRegion();
73 void CTestDirectGdiContext::SetDrawMode(DirectGdi::TDrawMode aMode)
75 iGc->SetDrawMode(aMode);
78 void CTestDirectGdiContext::SetPenColor(const TRgb& aColor)
80 iGc->SetPenColor(aColor);
83 void CTestDirectGdiContext::SetPenStyle(DirectGdi::TPenStyle aStyle)
85 iGc->SetPenStyle(aStyle);
88 void CTestDirectGdiContext::SetPenSize(const TSize& aSize)
90 iGc->SetPenSize(aSize);
93 void CTestDirectGdiContext::SetTextShadowColor(const TRgb& aColor)
95 iGc->SetTextShadowColor(aColor);
98 void CTestDirectGdiContext::SetBrushColor(const TRgb& aColor)
100 iGc->SetBrushColor(aColor);
103 void CTestDirectGdiContext::SetBrushStyle(DirectGdi::TBrushStyle aStyle)
105 iGc->SetBrushStyle(aStyle);
108 void CTestDirectGdiContext::SetBrushOrigin(const TPoint& aOrigin)
110 iGc->SetBrushOrigin(aOrigin);
113 void CTestDirectGdiContext::SetBrushPattern(const CFbsBitmap& aPattern)
115 iGc->SetBrushPattern(aPattern);
118 void CTestDirectGdiContext::SetBrushPattern(TInt aHandle)
120 iGc->SetBrushPattern(aHandle);
123 void CTestDirectGdiContext::ResetBrushPattern()
125 iGc->ResetBrushPattern();
128 void CTestDirectGdiContext::SetFont(const CFont* aFont)
133 void CTestDirectGdiContext::ResetFont()
138 void CTestDirectGdiContext::Reset()
143 TRgb CTestDirectGdiContext::BrushColor()
145 return iGc->BrushColor();
148 TRgb CTestDirectGdiContext::PenColor()
150 return iGc->PenColor();
153 TRgb CTestDirectGdiContext::TextShadowColor()
155 return iGc->TextShadowColor();
158 void CTestDirectGdiContext::Clear(const TRect& aRect)
163 void CTestDirectGdiContext::Clear()
168 void CTestDirectGdiContext::MoveTo(const TPoint& aPoint)
173 void CTestDirectGdiContext::MoveBy(const TPoint& aVector)
175 iGc->MoveBy(aVector);
178 void CTestDirectGdiContext::Plot(const TPoint& aPoint)
183 void CTestDirectGdiContext::DrawLine(const TPoint& aStart, const TPoint& aEnd)
185 iGc->DrawLine(aStart, aEnd);
188 void CTestDirectGdiContext::DrawLineTo(const TPoint& aPoint)
190 iGc->DrawLineTo(aPoint);
193 void CTestDirectGdiContext::DrawLineBy(const TPoint& aVector)
195 iGc->DrawLineBy(aVector);
198 void CTestDirectGdiContext::DrawRect(const TRect& aRect)
200 iGc->DrawRect(aRect);
203 void CTestDirectGdiContext::DrawRoundRect(const TRect& aRect,
204 const TSize& aCornerSize)
206 iGc->DrawRoundRect(aRect, aCornerSize);
209 void CTestDirectGdiContext::DrawPolyLine(const CArrayFix<TPoint>& aPointList)
211 TArray<TPoint> array = aPointList.Array();
212 iGc->DrawPolyLine(array);
215 void CTestDirectGdiContext::DrawPolyLineNoEndPoint(const CArrayFix<TPoint>& aPointList)
217 TArray<TPoint> array = aPointList.Array();
218 iGc->DrawPolyLineNoEndPoint(array);
221 void CTestDirectGdiContext::DrawPolygon(const CArrayFix<TPoint>& aPoints,
222 DirectGdi::TFillRule aRule)
224 TArray<TPoint> array = aPoints.Array();
225 iGc->DrawPolygon(array, aRule);
228 void CTestDirectGdiContext::DrawArc(const TRect& aRect, const TPoint& aStart,
231 iGc->DrawArc(aRect, aStart, aEnd);
234 void CTestDirectGdiContext::DrawPie(const TRect& aRect, const TPoint& aStart,
237 iGc->DrawPie(aRect, aStart, aEnd);
240 void CTestDirectGdiContext::DrawEllipse(const TRect& aRect)
242 iGc->DrawEllipse(aRect);
245 void CTestDirectGdiContext::BitBlt(const TPoint& aPoint,
246 const CFbsBitmap& aBitmap)
248 iGc->BitBlt(aPoint, aBitmap);
251 void CTestDirectGdiContext::DrawBitmap(const TRect& aDestRect,
252 const CFbsBitmap& aSource)
254 iGc->DrawBitmap(aDestRect, aSource);
257 void CTestDirectGdiContext::BitBlt(const TPoint& aDestPos,
258 const CFbsBitmap& aBitmap, const TRect& aSrcRect)
260 iGc->BitBlt(aDestPos, aBitmap, aSrcRect);
263 void CTestDirectGdiContext::BitBltMasked(const TPoint& aDestPos,
264 const CFbsBitmap& aBitmap, const TRect& aSrcRect,
265 const CFbsBitmap& aMask, TBool aInvertMask)
267 iGc->BitBltMasked(aDestPos, aBitmap, aSrcRect, aMask, aInvertMask);
270 void CTestDirectGdiContext::BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aBitmap,
271 const TRect& aSourceRect, const CFbsBitmap& aAlpha,
272 const TPoint& aAlphaPos)
274 iGc->BitBltMasked(aDestPos, aBitmap, aSourceRect, aAlpha, aAlphaPos);
277 void CTestDirectGdiContext::DrawBitmap(const TRect& aDestRect,
278 const CFbsBitmap& aBitmap, const TRect& aSrcRect)
280 iGc->DrawBitmap(aDestRect, aBitmap, aSrcRect);
283 void CTestDirectGdiContext::DrawBitmapMasked(const TRect& aDestRect,
284 const CFbsBitmap& aBitmap, const TRect& aSrcRect,
285 const CFbsBitmap& aMask, TBool aInvertMask)
287 iGc->DrawBitmapMasked(aDestRect, aBitmap, aSrcRect, aMask, aInvertMask);
290 void CTestDirectGdiContext::CopyRect(const TPoint& aOffset, const TRect& aRect)
292 iGc->CopyRect(aOffset, aRect);
295 TBool CTestDirectGdiContext::HasBrushPattern() const
297 return iGc->HasBrushPattern();
300 TBool CTestDirectGdiContext::HasFont() const
302 return iGc->HasFont();
305 void CTestDirectGdiContext::ExternalizeL(RWriteStream& aWriteStream)
307 iGc->ExternalizeL(aWriteStream);
310 void CTestDirectGdiContext::InternalizeL(RReadStream& aReadStream)
312 iGc->InternalizeL(aReadStream);
315 void CTestDirectGdiContext::SetCharJustification(TInt aExcessWidth,
318 iGc->SetCharJustification(aExcessWidth, aNumGaps);
321 void CTestDirectGdiContext::SetWordJustification(TInt aExcessWidth,
324 iGc->SetWordJustification(aExcessWidth, aNumChars);
327 void CTestDirectGdiContext::SetUnderlineStyle(DirectGdi::TFontUnderline aUnderlineStyle)
329 iGc->SetUnderlineStyle((aUnderlineStyle));
332 void CTestDirectGdiContext::SetStrikethroughStyle(DirectGdi::TFontStrikethrough aStrikethroughStyle)
334 iGc->SetStrikethroughStyle(aStrikethroughStyle);
337 void CTestDirectGdiContext::UpdateJustification(const TDesC& aText, const DirectGdi::TTextParameters* aParam)
339 iGc->UpdateJustification(aText, aParam);
342 void CTestDirectGdiContext::UpdateJustificationVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, TBool aUp)
344 iGc->UpdateJustificationVertical(aText, aParam, aUp);
347 void CTestDirectGdiContext::SetFontNoDuplicate(const CFont* aFont)
349 iGc->SetFontNoDuplicate((CDirectGdiFont*)aFont);
352 TInt CTestDirectGdiContext::Activate(RDirectGdiImageTarget& aTarget)
354 return iGc->Activate(aTarget);
358 void CTestDirectGdiContext::NoJustifyAutoUpdate()
360 iGc->NoJustifyAutoUpdate();
363 void CTestDirectGdiContext::SetJustifyAutoUpdate()
365 iGc->SetJustifyAutoUpdate();
368 TInt CTestDirectGdiContext::GetError()
370 return iGdiDriver->GetError();
374 void CTestDirectGdiContext::DrawText(const TDesC& aText, const DirectGdi::TTextParameters* aParam)
376 iGc->DrawText(aText, aParam);
379 void CTestDirectGdiContext::DrawText(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TPoint& aPosition)
381 iGc->DrawText(aText, aParam, aPosition);
384 void CTestDirectGdiContext::DrawText(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect& aBox)
386 iGc->DrawText(aText, aParam, aBox);
389 void CTestDirectGdiContext::DrawText(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect& aBox, TInt aBaselineOffset,
390 DirectGdi::TTextAlign aAlignment, TInt aMargin)
392 iGc->DrawText(aText, aParam, aBox, aBaselineOffset, aAlignment, aMargin);
395 void CTestDirectGdiContext::DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, TBool aUp)
397 iGc->DrawTextVertical(aText, aParam, aUp);
400 void CTestDirectGdiContext::DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TPoint& aPosition, TBool aUp)
402 iGc->DrawTextVertical(aText, aParam, aPosition, aUp);
405 void CTestDirectGdiContext::DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect& aBox, TBool aUp)
407 iGc->DrawTextVertical(aText, aParam, aBox, aUp);
410 void CTestDirectGdiContext::DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect& aBox, TInt aBaselineOffset,
411 TBool aUp, DirectGdi::TTextAlign aVerticalAlignment, TInt aMargin)
413 iGc->DrawTextVertical(aText, aParam, aBox, aBaselineOffset, aUp, aVerticalAlignment, aMargin);
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)
419 iGc->DrawTextVertical(aText, aParam, aBox, aBaselineOffset, aTextWidth, aUp, aVerticalAlignment, aMargin);
422 void CTestDirectGdiContext::DrawResource(const TPoint& aPos,
423 const TDrawableSourceAndEquivRotatedBmps& aSource,
424 DirectGdi::TGraphicsRotation aRotation)
426 iGc->DrawResource(aPos, *(aSource.iDrawableSrc), aRotation);
429 void CTestDirectGdiContext::DrawResource(const TRect& aDestRect,
430 const TDrawableSourceAndEquivRotatedBmps& aSource,
431 DirectGdi::TGraphicsRotation aRotation)
433 iGc->DrawResource(aDestRect, *(aSource.iDrawableSrc), aRotation);
436 void CTestDirectGdiContext::DrawResource(const TRect& aDestRect,
437 const TDrawableSourceAndEquivRotatedBmps& aSource,
438 const TRect& aSrcRect,
439 DirectGdi::TGraphicsRotation aRotation)
441 iGc->DrawResource(aDestRect, *(aSource.iDrawableSrc), aSrcRect, aRotation);
444 void CTestDirectGdiContext::DrawResource(const TRect& aDestRect,
445 const TDrawableSourceAndEquivRotatedBmps& aSource,
446 const TDesC8& aParam)
448 iGc->DrawResource(aDestRect, *(aSource.iDrawableSrc), aParam);
451 TInt CTestDirectGdiContext::GetInterface(TUid aInterfaceId, TAny*& aInterface)
453 return iGc->GetInterface(aInterfaceId, aInterface);
456 void CTestDirectGdiContext::CopySettings(const CTContextBase& aGc)
458 CTestDirectGdiContext* gc = (CTestDirectGdiContext*)&aGc;
459 iGc->CopySettings(*(gc->iGc));