windowing/windowserver/test/t_stress/src/crpwin.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 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent
       
    20 */
       
    21  
       
    22 
       
    23 #include "crpwin.h"
       
    24 
       
    25 /*******************************************************************************
       
    26 Client side of the crp used by CCrpWin
       
    27 *******************************************************************************/
       
    28 
       
    29 	
       
    30 CCrpClient * CCrpClient::NewL()
       
    31 	{
       
    32 	CCrpClient * self = new (ELeave) CCrpClient();
       
    33 	CleanupStack::PushL(self);
       
    34 	self->ConstructL();
       
    35 	CleanupStack::Pop(self);
       
    36 	return self;
       
    37 	}
       
    38 	
       
    39 void CCrpClient::DrawCrp(CWindowGc& aGc,const TRect& aRect)
       
    40 	{
       
    41 	aGc.DrawWsGraphic(Id(),aRect);
       
    42 	CWsGraphic::Flush();
       
    43 	}
       
    44 
       
    45 CCrpClient::~CCrpClient()
       
    46 	{
       
    47 	}
       
    48 	
       
    49 CCrpClient::CCrpClient()
       
    50 	{
       
    51 	}
       
    52 	
       
    53 void CCrpClient::ConstructL()
       
    54 	{
       
    55 	BaseConstructL(TUid::Uid(0xa0005923),KNullDesC8()); //lint !e569 Loss of information (arg. no. 1) (32 bits to 31 bits)
       
    56 	}
       
    57 	
       
    58 void CCrpClient::HandleMessage(const TDesC8& /*aData*/)
       
    59 	{
       
    60 	}
       
    61 		
       
    62 void CCrpClient::OnReplace()
       
    63 	{
       
    64 	__DEBUGGER();
       
    65 	}
       
    66 	
       
    67 
       
    68 
       
    69 
       
    70 /**
       
    71 CRP WIN
       
    72 */
       
    73 
       
    74 
       
    75 //static configuration data, definitions and default assignments
       
    76 TBool CCrpWin::iEnabled = ETrue;
       
    77 TBool CCrpWin::iTransparent = ETrue;
       
    78 
       
    79 
       
    80 CCrpWin* CCrpWin::NewLC(RWsSession& aWs, RWindowGroup* aGroup, CCompWin* aParent, CWindowGc& aGc)
       
    81 	{
       
    82 	CCrpWin* self = new (ELeave) CCrpWin(aWs, aGroup, aParent, aGc);
       
    83 	CleanupStack::PushL(self);
       
    84 	self->ConstructL();
       
    85 	return self;
       
    86 	}
       
    87 
       
    88 void CCrpWin::LoadConfiguration(const MTestStepConfigurationContext* aContext)
       
    89 	{
       
    90 	aContext->GetBool(KT_WservStressParamEnabled, iEnabled);
       
    91 	aContext->GetBool(KT_WservStressParamTransparent, iTransparent);
       
    92 	}
       
    93 
       
    94 CCrpWin::~CCrpWin()
       
    95     {
       
    96 	delete iCrp;
       
    97     }
       
    98 
       
    99 void CCrpWin::SetSize(const TSize & aSize)
       
   100 	{
       
   101 	CCompWin::SetSize(aSize);
       
   102 	}
       
   103 		
       
   104 void CCrpWin::Redraw(const TRect& aRect)
       
   105     {
       
   106     iWsGc.Activate(*iWindow);
       
   107     iWsGc.Reset();
       
   108 
       
   109     iRedrawWindow->BeginRedraw(aRect);
       
   110     if(iCrp)
       
   111     	{
       
   112 	    iCrp->DrawCrp(iWsGc,iSize);
       
   113 	    }
       
   114     iRedrawWindow->EndRedraw();
       
   115 
       
   116     iWsGc.Deactivate();
       
   117     } 
       
   118 
       
   119 void CCrpWin::DrawBitmap(CFbsBitGc* aGc, TRect& aClip, TPoint& aOrigin)
       
   120     {
       
   121     aGc->Reset();
       
   122 	TPoint origin = iPos + aOrigin;
       
   123 	aGc->SetOrigin(origin);
       
   124 	
       
   125 	TRect clip(origin, iSize);
       
   126 	clip.Intersection(aClip);
       
   127 	clip.Move(-origin);
       
   128 	aGc->SetClippingRect(clip);
       
   129     
       
   130     TRect windowRect(origin,iSize);
       
   131     windowRect.Move(-origin);
       
   132     
       
   133     aGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
       
   134 	aGc->SetPenColor(TRgb(255,0,0));
       
   135 	aGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
   136 	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   137 	aGc->SetBrushColor(TRgb(255,0,0));
       
   138 	aGc->DrawRect(windowRect);
       
   139 	aGc->SetBrushColor(TRgb(0,0,255));
       
   140 	aGc->DrawEllipse(windowRect);
       
   141 	
       
   142 	CCompWin::DrawBitmap(aGc, aClip, aOrigin);
       
   143     }
       
   144 	
       
   145 CCrpWin::CCrpWin(RWsSession& aWs, RWindowGroup* aGroup, CCompWin* aParent, CWindowGc& aGc) :
       
   146 	CCompWin(aWs, aGroup, aParent, aGc)
       
   147     {
       
   148     }
       
   149 
       
   150 void CCrpWin::ConstructL()
       
   151     {
       
   152     CCompWin::PreConstructL(iTransparent);
       
   153     iCrp = CCrpClient::NewL();
       
   154     CCompWin::PostConstructL();
       
   155     }
       
   156 
       
   157 void CCrpWin::DumpDetails(RFile& aFile, TInt aDepth)
       
   158 	{
       
   159 	TBuf8<256> buf;
       
   160 	buf.SetLength(0);
       
   161 	for (TInt d = 0; d < aDepth; ++d)
       
   162 		{
       
   163 		buf.Append(_L8("  "));
       
   164 		}
       
   165 	buf.Append(_L8("Transparent = ["));
       
   166 	buf.AppendNum((TInt64)iTransparent);
       
   167 	buf.Append(_L8("]\r\n"));
       
   168 	aFile.Write(buf);
       
   169 	}
       
   170 
       
   171