windowing/windowserver/tcontaindrawer/simpledrawer.cpp
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     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 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code
       
    20 */
       
    21 
       
    22 #include "simpledrawer.h"
       
    23 #include "wsgraphicdrawercontext.h"
       
    24 #include <s32mem.h>
       
    25 #include <s32strm.h>
       
    26 
       
    27 // CWsGraphicDrawer	
       
    28 CWsSimpleGraphicDrawer* CWsSimpleGraphicDrawer::NewL()
       
    29 	{
       
    30 	return new(ELeave) CWsSimpleGraphicDrawer;	
       
    31 	}
       
    32 	
       
    33 CWsSimpleGraphicDrawer::~CWsSimpleGraphicDrawer()
       
    34 	{
       
    35 	if (iContext)
       
    36 		{
       
    37 		iContext->Destroy();
       
    38 		iContext = NULL;
       
    39 		}
       
    40 	}
       
    41 
       
    42 void CWsSimpleGraphicDrawer::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/)
       
    43 	{
       
    44 	BaseConstructL(aEnv, aId, aOwner);
       
    45  	// default color
       
    46 	iColor = KRgbBlue;
       
    47  	}
       
    48 
       
    49 void CWsSimpleGraphicDrawer::HandleMessage(const TDesC8& aData)
       
    50 	{
       
    51 	TInt red = aData[0];
       
    52 	TInt green = aData[1];
       
    53 	TInt blue = aData[2];
       
    54 	TRgb color(red, green, blue);
       
    55 	DoUpdateColor(color);
       
    56 	}
       
    57 
       
    58 void CWsSimpleGraphicDrawer::BaseConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner)
       
    59 	{
       
    60 	CWsGraphicDrawer::BaseConstructL(aEnv, aId, aOwner);
       
    61 	if (!(aEnv.Screen(0)->ResolveObjectInterface(KMWsCompositionContext) || aEnv.Screen(0)->ResolveObjectInterface(KMWsScene)))
       
    62 		{
       
    63 		iContext = CWsGraphicDrawerNonNgaContext::NewL();
       
    64 		}
       
    65 	else
       
    66 		{
       
    67 		iContext = CWsGraphicDrawerNgaContext::NewL();
       
    68 		}
       
    69 	}
       
    70 
       
    71 void CWsSimpleGraphicDrawer::DoUpdateColor(TRgb aColor)
       
    72 	{
       
    73 	iColor = aColor;
       
    74 	// Invalidate the redrawing
       
    75 	Invalidate();
       
    76 	}
       
    77 
       
    78 void CWsSimpleGraphicDrawer::DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& /*aData*/) const
       
    79 	{
       
    80 	iContext->DrawEllipse(aGc, aRect, iColor);
       
    81 	}
       
    82 	
       
    83 // First contained (child) drawer
       
    84 CWsInvisibleGraphicDrawer1* CWsInvisibleGraphicDrawer1::NewL()
       
    85 	{
       
    86 	return new(ELeave) CWsInvisibleGraphicDrawer1;	
       
    87 	}
       
    88 	
       
    89 CWsInvisibleGraphicDrawer1::~CWsInvisibleGraphicDrawer1()
       
    90 	{
       
    91 	}
       
    92 
       
    93 void CWsInvisibleGraphicDrawer1::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/)
       
    94 	{
       
    95 	BaseConstructL(aEnv, aId, aOwner);
       
    96 	// default color
       
    97 	iColor = KRgbYellow;
       
    98 	}
       
    99 
       
   100 // Second contained (child) drawer
       
   101 CWsInvisibleGraphicDrawer2* CWsInvisibleGraphicDrawer2::NewL()
       
   102 	{
       
   103 	return new(ELeave) CWsInvisibleGraphicDrawer2;	
       
   104 	}
       
   105 	
       
   106 CWsInvisibleGraphicDrawer2::~CWsInvisibleGraphicDrawer2()
       
   107 	{
       
   108 	}
       
   109 
       
   110 void CWsInvisibleGraphicDrawer2::ConstructL(MWsGraphicDrawerEnvironment& aEnv, const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/)
       
   111 	{
       
   112 	BaseConstructL(aEnv, aId, aOwner);
       
   113 	// default color
       
   114 	iColor = KRgbCyan;
       
   115 	}