windowing/windowserver/stdgraphic/wsgraphicdrawerngacontext.cpp
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2008-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 #define SYMBIAN_GRAPHICS_GCE
       
    17 
       
    18 #include "wsgraphicdrawercontext.h"
       
    19 #include "stdgraphictestdrawer.h"
       
    20 #include <graphics/wsgraphicscontext.h>
       
    21 
       
    22 MWsGraphicDrawerContext* CWsGraphicDrawerNgaContext::NewL()
       
    23 	{
       
    24 	return new(ELeave) CWsGraphicDrawerNgaContext();
       
    25 	}
       
    26 
       
    27 void CWsGraphicDrawerNgaContext::Destroy()
       
    28 	{
       
    29 	delete this;
       
    30 	}
       
    31 
       
    32 MWsClient& CWsGraphicDrawerNgaContext::Client(MWsGc& aGc)
       
    33 	{
       
    34 	return aGc.Client();
       
    35 	}
       
    36 
       
    37 MWsScreen& CWsGraphicDrawerNgaContext::Screen(MWsGc& aGc)
       
    38 	{
       
    39 	return aGc.Screen();
       
    40 	}
       
    41 
       
    42 const TTime& CWsGraphicDrawerNgaContext::Now(MWsGc& aGc) const
       
    43 	{
       
    44 	return aGc.Now();
       
    45 	}
       
    46 
       
    47 void CWsGraphicDrawerNgaContext::ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow)
       
    48 	{
       
    49 	aGc.ScheduleAnimation(aRect, aFromNow);
       
    50 	}
       
    51 
       
    52 void CWsGraphicDrawerNgaContext::ScheduleAnimation(MWsGc& aGc, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop)
       
    53 	{
       
    54 	aGc.ScheduleAnimation(aRect, aFromNow, aFreq, aStop);
       
    55 	}
       
    56 
       
    57 void CWsGraphicDrawerNgaContext::SetGcOrigin(MWsGc& aGc, const TPoint& aOrigin)
       
    58 	{
       
    59 	aGc.SetGcOrigin(aOrigin);
       
    60 	}
       
    61 
       
    62 TInt CWsGraphicDrawerNgaContext::Push(MWsGc& aGc) const
       
    63 	{
       
    64 	MWsGraphicsContext* context = aGc.ObjectInterface<MWsGraphicsContext>();
       
    65 	if (context)
       
    66 		{
       
    67 		return context->Push();
       
    68 		}
       
    69 	return KErrNotSupported;
       
    70 	}
       
    71 
       
    72 void CWsGraphicDrawerNgaContext::Pop(MWsGc& aGc) const
       
    73 	{
       
    74 	MWsGraphicsContext* context = aGc.ObjectInterface<MWsGraphicsContext>();
       
    75 	if (context)
       
    76 		{
       
    77 		context->Pop();
       
    78 		}
       
    79 	}
       
    80 
       
    81 void CWsGraphicDrawerNgaContext::DrawBitmap(MWsGc& aGc, const TPoint& aDestPos, const CFbsBitmap* aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap* aMaskBitmap) const
       
    82 	{
       
    83 	MWsGraphicsContext* context = aGc.ObjectInterface<MWsGraphicsContext>();
       
    84 	if (context)
       
    85 		{
       
    86 		if (aMaskBitmap)
       
    87 			{
       
    88 			context->BitBltMasked(aDestPos, *aSourceBitmap, aSourceRect, *aMaskBitmap, EFalse);
       
    89 			}
       
    90 		else
       
    91 			{
       
    92 			context->BitBlt(aDestPos, *aSourceBitmap, aSourceRect);
       
    93 			}
       
    94 		}
       
    95 	}
       
    96 
       
    97 void CWsGraphicDrawerNgaContext::DrawFrameRate(MWsGc& aGc, const TRect& aRect, const CFrameRate& aFps) const
       
    98 	{
       
    99 	MWsGraphicsContext* context = aGc.ObjectInterface<MWsGraphicsContext>();
       
   100 	if (context)
       
   101 		{
       
   102 		context->SetDrawMode(MWsGraphicsContext::EDrawModePEN);
       
   103 		context->SetPenStyle(MWsGraphicsContext::ENullPen);
       
   104 		context->SetBrushStyle(MWsGraphicsContext::ENullBrush);
       
   105 
       
   106 		if ((aFps.CountSamples() > 1) && context->HasFont())
       
   107 			{
       
   108 			TBuf<20> buf;
       
   109 			buf.AppendNum(aFps.Fps());
       
   110 			context->SetPenColor(KRgbRed);
       
   111 			context->DrawText(buf,NULL,TPoint(aRect.iTl.iX,aRect.iBr.iY));
       
   112 			}
       
   113 		}
       
   114 	}