Update contrib.
1 // Copyright (c) 1996-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.
14 // Interface code for animated DLL's GC
20 #include "playbackgc.h"
24 CWsAnimGc::CWsAnimGc() : iUserActive(EFalse), iUseDrawingRegion(EFalse)
26 __DECLARE_NAME(_S("CWsAnimGc"));
29 void CWsAnimGc::SetDrawingRegions(const TRegion *aRegion)
33 iDrawingRegion.Copy(*aRegion);
34 iDrawingRegion.Offset(iWin->Origin());
36 iDrawingRegion.Intersect(*iBaseRegion);
37 iDrawingRegion.Tidy();
38 iGc->SetClippingRegion(iDrawingRegion);
39 iUseDrawingRegion=ETrue;
42 void CWsAnimGc::Activate(CWsClientWindow *aWindow, CWsAnim *aWsAnim, const TRegion *aRegion, CFbsBitGc *aGc)
44 iOwningWsAnim=aWsAnim;
46 iOwningWsAnim->Panic();
48 iBaseRegion=aRegion ? aRegion : &iWin->VisibleRegion();
55 void CWsAnimGc::Deactivate()
57 if (iUseDrawingRegion)
59 iDrawingRegion.Close();
61 iUseDrawingRegion=EFalse;
69 TBool CWsAnimGc::IsActive() const
71 return (iUserActive || (iGc != NULL));
74 void CWsAnimGc::UserActivate(CWsClientWindow *aWindow, CWsAnim *aWsAnim)
79 iOwningWsAnim->Panic();
81 iOwningWsAnim=aWsAnim;
86 void CWsAnimGc::UserDeactivate()
90 if (iWin && iOwningWsAnim)
92 TRegionFix<1> animRegion(iOwningWsAnim->BestRect());
93 iWin->ScheduleRegionUpdate(&animRegion);
100 void CWsAnimGc::AnimDeleted(CWsAnim *aWsAnim)
102 if (iOwningWsAnim==aWsAnim)
106 CGraphicsDevice* CWsAnimGc::Device() const
109 iOwningWsAnim->Panic(EWservPanicAnimLeave);
111 return iGc ? iGc->Device() : NULL;
114 void CWsAnimGc::SetClippingRect(const TRect& aRect)
117 iOwningWsAnim->Panic(EWservPanicAnimLeave);
122 iClippingRect.Intersection(TRect(iWin->Size()));
123 iGc->SetClippingRect(iClippingRect);
127 TInt CWsAnimGc::SetClippingRegion(const TRegion &aRegion)
128 //This function is virtual and so cannot have an 'L' at the end of it's name
131 User::Leave(KErrGeneral);
134 SetDrawingRegions(&aRegion);
138 void CWsAnimGc::CancelClippingRegion()
141 iOwningWsAnim->Panic(EWservPanicAnimLeave);
145 iDrawingRegion.Clear();
146 iUseDrawingRegion=EFalse;
147 iGc->SetClippingRegion(iBaseRegion);
151 void CWsAnimGc::CancelClippingRect()
154 iOwningWsAnim->Panic(EWservPanicAnimLeave);
158 iClippingRect=TRect(iWin->Size());
159 iGc->SetClippingRect(iClippingRect);
163 void CWsAnimGc::SetDrawMode(TDrawMode aDrawingMode)
166 iOwningWsAnim->Panic(EWservPanicAnimLeave);
169 iGc->SetDrawMode(aDrawingMode);
172 void CWsAnimGc::UseFont(const CFont *aFont)
175 iFont=(CAnimFbsFont *)aFont;
178 iOwningWsAnim->Panic(EWservPanicAnimLeave);
180 iGc->UseFontNoDuplicate(iFont);
183 void CWsAnimGc::DiscardFont()
187 iOwningWsAnim->Panic(EWservPanicAnimLeave);
192 void CWsAnimGc::SetUnderlineStyle(TFontUnderline aUnderlineStyle)
195 iOwningWsAnim->Panic(EWservPanicAnimLeave);
197 iGc->SetUnderlineStyle(aUnderlineStyle);
200 void CWsAnimGc::SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle)
203 iOwningWsAnim->Panic(EWservPanicAnimLeave);
205 iGc->SetStrikethroughStyle(aStrikethroughStyle);
208 void CWsAnimGc::SetWordJustification(TInt aExcessWidth,TInt aNumGaps)
211 iOwningWsAnim->Panic(EWservPanicAnimLeave);
213 iGc->SetWordJustification(aExcessWidth,aNumGaps);
216 void CWsAnimGc::SetCharJustification(TInt aExcessWidth,TInt aNumChars)
219 iOwningWsAnim->Panic(EWservPanicAnimLeave);
221 iGc->SetCharJustification(aExcessWidth,aNumChars);
224 void CWsAnimGc::SetPenColor(const TRgb &aColor)
227 iOwningWsAnim->Panic(EWservPanicAnimLeave);
229 iGc->SetPenColor(aColor);
232 void CWsAnimGc::SetPenStyle(TPenStyle aPenStyle)
235 iOwningWsAnim->Panic(EWservPanicAnimLeave);
237 iGc->SetPenStyle(aPenStyle);
240 void CWsAnimGc::SetPenSize(const TSize& aSize)
243 iOwningWsAnim->Panic(EWservPanicAnimLeave);
245 iGc->SetPenSize(aSize);
248 void CWsAnimGc::SetBrushColor(const TRgb &aColor)
251 iOwningWsAnim->Panic(EWservPanicAnimLeave);
253 iGc->SetBrushColor(aColor);
256 void CWsAnimGc::SetBrushStyle(TBrushStyle aBrushStyle)
259 iOwningWsAnim->Panic(EWservPanicAnimLeave);
261 iGc->SetBrushStyle(aBrushStyle);
264 void CWsAnimGc::SetBrushOrigin(const TPoint &aOrigin)
267 iOwningWsAnim->Panic(EWservPanicAnimLeave);
269 iGc->SetBrushOrigin(aOrigin);
272 void CWsAnimGc::UseBrushPattern(const CFbsBitmap *aBitmap)
275 iOwningWsAnim->Panic(EWservPanicAnimLeave);
277 iGc->UseBrushPattern(aBitmap);
280 void CWsAnimGc::DiscardBrushPattern()
283 iOwningWsAnim->Panic(EWservPanicAnimLeave);
285 iGc->DiscardBrushPattern();
288 void CWsAnimGc::SetFaded(TBool aFaded)
291 iOwningWsAnim->Panic(EWservPanicAnimLeave);
293 iGc->SetFaded(aFaded);
296 void CWsAnimGc::SetFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap)
299 iOwningWsAnim->Panic(EWservPanicAnimLeave);
301 iGc->SetFadingParameters(aBlackMap,aWhiteMap);
305 // Drawing commands //
308 void CWsAnimGc::DrawArc(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd)
311 iOwningWsAnim->Panic(EWservPanicAnimLeave);
313 iGc->DrawArc(aRect,aStart,aEnd);
316 void CWsAnimGc::DrawPie(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd)
319 iOwningWsAnim->Panic(EWservPanicAnimLeave);
321 iGc->DrawPie(aRect,aStart,aEnd);
324 void CWsAnimGc::DrawLine(const TPoint &aPoint1,const TPoint &aPoint2)
327 iOwningWsAnim->Panic(EWservPanicAnimLeave);
329 iGc->DrawLine(aPoint1, aPoint2);
332 void CWsAnimGc::DrawLineTo(const TPoint &aPoint)
335 iOwningWsAnim->Panic(EWservPanicAnimLeave);
337 iGc->DrawLineTo(aPoint);
340 void CWsAnimGc::DrawLineBy(const TPoint &aPoint)
343 iOwningWsAnim->Panic(EWservPanicAnimLeave);
345 iGc->DrawLineBy(aPoint);
348 void CWsAnimGc::DrawEllipse(const TRect &aRect)
351 iOwningWsAnim->Panic(EWservPanicAnimLeave);
353 iGc->DrawEllipse(aRect);
356 void CWsAnimGc::DrawRect(const TRect &aRect)
359 iOwningWsAnim->Panic(EWservPanicAnimLeave);
361 iGc->DrawRect(aRect);
364 void CWsAnimGc::DrawRoundRect(const TRect &aRect,const TSize &aCornerSize)
367 iOwningWsAnim->Panic(EWservPanicAnimLeave);
369 iGc->DrawRoundRect(aRect, aCornerSize);
372 void CWsAnimGc::Clear(const TRect &aRect)
375 iOwningWsAnim->Panic(EWservPanicAnimLeave);
380 void CWsAnimGc::Clear()
383 iOwningWsAnim->Panic(EWservPanicAnimLeave);
388 void CWsAnimGc::BitBlt(const TPoint &aPoint,const CFbsBitmap *aBitmap)
391 iOwningWsAnim->Panic(EWservPanicAnimLeave);
393 iGc->BitBlt(aPoint, aBitmap);
396 void CWsAnimGc::BitBlt(const TPoint &aDestination,const CFbsBitmap *aBitmap,const TRect &aSource)
399 iOwningWsAnim->Panic(EWservPanicAnimLeave);
401 iGc->BitBlt(aDestination, aBitmap, aSource);
404 void CWsAnimGc::BitBltMasked(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask)
407 iOwningWsAnim->Panic(EWservPanicAnimLeave);
409 iGc->BitBltMasked(aPoint, aBitmap, aSourceRect, aMaskBitmap, aInvertMask);
412 void CWsAnimGc::DrawBitmap(const TPoint &aTopLeft, const CFbsBitmap *aSource)
415 iOwningWsAnim->Panic(EWservPanicAnimLeave);
417 iGc->DrawBitmap(aTopLeft, aSource);
420 void CWsAnimGc::DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aSource)
423 iOwningWsAnim->Panic(EWservPanicAnimLeave);
425 iGc->DrawBitmap(aDestRect, aSource);
428 void CWsAnimGc::DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aSource, const TRect &aSrcRect)
431 iOwningWsAnim->Panic(EWservPanicAnimLeave);
433 iGc->DrawBitmap(aDestRect, aSource, aSrcRect);
436 void CWsAnimGc::DrawBitmapMasked(const TRect &aDestRect, const CFbsBitmap *aBitmap, const TRect &aSrcRect, const CFbsBitmap* aMaskBitmap, TBool aInvertMask)
439 iOwningWsAnim->Panic(EWservPanicAnimLeave);
441 iGc->DrawBitmapMasked(aDestRect, aBitmap, aSrcRect, aMaskBitmap, aInvertMask);
444 void CWsAnimGc::DrawBitmapMasked(const TRect& aDestRect,const CWsBitmap* aBitmap,const TRect& aSrcRect,const CWsBitmap* aMaskBitmap, TBool aInvertMask)
447 iOwningWsAnim->Panic(EWservPanicAnimLeave);
449 iGc->DrawBitmapMasked(aDestRect, aBitmap, aSrcRect, aMaskBitmap, aInvertMask);
452 void CWsAnimGc::DrawPolyLine(const TPoint* aPointList,TInt aNumPoints)
455 iOwningWsAnim->Panic(EWservPanicAnimLeave);
457 iGc->DrawPolyLine(aPointList, aNumPoints);
460 void CWsAnimGc::DrawPolyLine(const CArrayFix<TPoint> *aPointList)
463 iOwningWsAnim->Panic(EWservPanicAnimLeave);
465 iGc->DrawPolyLine(aPointList);
468 TInt CWsAnimGc::DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule)
470 TInt result = KErrNone;
472 iOwningWsAnim->Panic(EWservPanicAnimLeave);
474 result = iGc->DrawPolygon(aPointList, aNumPoints, aFillRule);
478 TInt CWsAnimGc::DrawPolygon(const CArrayFix<TPoint> *aPointList,TFillRule aFillRule)
480 TInt result = KErrNone;
482 iOwningWsAnim->Panic(EWservPanicAnimLeave);
484 result = iGc->DrawPolygon(aPointList, aFillRule);
488 void CWsAnimGc::DrawText(const TDesC &aString,const TPoint &aPosition)
491 iOwningWsAnim->Panic(EWservPanicNoFont);
493 iGc->DrawText(aString, aPosition);
496 void CWsAnimGc::DrawText(const TDesC &aString,const TRect &aBox,TInt aBaselineOffset,TTextAlign aHoriz,TInt aLeftMrg)
499 iOwningWsAnim->Panic(EWservPanicNoFont);
501 iGc->DrawText(aString, aBox, aBaselineOffset, aHoriz, aLeftMrg);
504 void CWsAnimGc::MoveTo(const TPoint &aPoint)
507 iOwningWsAnim->Panic(EWservPanicAnimLeave);
512 void CWsAnimGc::MoveBy(const TPoint &aPoint)
515 iOwningWsAnim->Panic(EWservPanicAnimLeave);
520 void CWsAnimGc::Plot(const TPoint &aPoint)
523 iOwningWsAnim->Panic(EWservPanicAnimLeave);
528 void CWsAnimGc::SetOrigin(const TPoint &aPoint)
531 iOwningWsAnim->Panic(EWservPanicAnimLeave);
533 iGc->SetOrigin(iWin->Origin() + aPoint);
536 void CWsAnimGc::CopyRect(const TPoint& aOffset,const TRect& aRect)
539 iOwningWsAnim->Panic(EWservPanicAnimLeave);
541 iGc->CopyRect(aOffset, aRect);
544 void CWsAnimGc::Reset()
548 iOwningWsAnim->Panic(EWservPanicAnimLeave);
551 SetOrigin(TPoint(0,0));
552 CancelClippingRect();
553 CancelClippingRegion();
556 void CWsAnimGc::CloseCurrentFont()
566 @see CBitmapContext::AlphaBlendBitmaps()*/
567 TInt CWsAnimGc::AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt)
569 TInt result = KErrNone;
571 iOwningWsAnim->Panic(EWservPanicAnimLeave);
573 result = iGc->AlphaBlendBitmaps(aDestPt, aSrcBmp, aSrcRect, aAlphaBmp, aAlphaPt);
577 /*Body stub implementation. The alternate AlphaBlendBitmap function using CFbsBitmaps should instead be used*/
578 TInt CWsAnimGc::AlphaBlendBitmaps(const TPoint& /*aDestPt*/, const CWsBitmap* /*aSrcBmp*/, const TRect& /*aSrcRect*/, const CWsBitmap* /*aAlphaBmp*/, const TPoint& /*aAlphaPt*/)
584 @see CGraphicsContext::MapColors()*/
585 void CWsAnimGc::MapColors(const TRect &aRect,const TRgb *aColors,TInt aNumPairs,TBool aMapForwards)
588 iOwningWsAnim->Panic(EWservPanicAnimLeave);
590 iGc->MapColors(aRect, aColors, aNumPairs, aMapForwards);
594 @see CGraphicsContext::DrawTextVertical()*/
595 void CWsAnimGc::DrawTextVertical(const TDesC& aText,const TPoint& aPos,TBool aUp)
598 iOwningWsAnim->Panic(EWservPanicNoFont);
600 iGc->DrawTextVertical(aText, aPos, aUp);
604 @see CGraphicsContext::DrawTextVertical()*/
605 void CWsAnimGc::DrawTextVertical(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert,TInt aMargin)
608 iOwningWsAnim->Panic(EWservPanicNoFont);
610 iGc->DrawTextVertical(aText, aBox, aBaselineOffset, aUp, aVert, aMargin);