sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent sl@0: */ sl@0: sl@0: #include "enormouswin.h" sl@0: #include "utils.h" sl@0: sl@0: sl@0: /** sl@0: ENORMOUS WIN sl@0: */ sl@0: sl@0: //static configuration data, definitions and default assignments sl@0: TBool CEnormousWin::iEnabled = ETrue; sl@0: TBool CEnormousWin::iTransparent = ETrue; sl@0: TBool CEnormousWin::iRandomizePenStyle = EFalse; sl@0: TBool CEnormousWin::iRandomizeBrushStyle = EFalse; sl@0: sl@0: sl@0: CEnormousWin* CEnormousWin::NewLC(RWsSession& aWs, RWindowGroup* aGroup, CCompWin* aParent, CWindowGc& aGc) sl@0: { sl@0: CEnormousWin* self = new (ELeave) CEnormousWin(aWs, aGroup, aParent, aGc); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: return self; sl@0: } sl@0: sl@0: void CEnormousWin::LoadConfiguration(const MTestStepConfigurationContext* aContext) sl@0: { sl@0: aContext->GetBool(KT_WservStressParamEnabled, iEnabled); sl@0: aContext->GetBool(KT_WservStressParamTransparent, iTransparent); sl@0: aContext->GetBool(KT_WservStressParamRandomizePenStyle, iRandomizePenStyle); sl@0: aContext->GetBool(KT_WservStressParamRandomizeBrushStyle, iRandomizeBrushStyle); sl@0: } sl@0: sl@0: CEnormousWin::CEnormousWin(RWsSession& aWs, RWindowGroup* aGroup, CCompWin* aParent, CWindowGc& aGc) : sl@0: CCompWin(aWs, aGroup, aParent, aGc) sl@0: { sl@0: } sl@0: sl@0: CEnormousWin::~CEnormousWin() sl@0: { sl@0: } sl@0: sl@0: void CEnormousWin::ConstructL() sl@0: { sl@0: CCompWin::PreConstructL(iTransparent); sl@0: iRedrawWindow->EnableRedrawStore(EFalse); sl@0: TPoint pos = iPos; sl@0: pos.iX *= EScale; sl@0: pos.iY *= EScale; sl@0: SetPos(pos); sl@0: TSize size = iSize; sl@0: size.iWidth *= EScale; sl@0: size.iHeight *= EScale; sl@0: SetSize(size); sl@0: iPenStyle = iRandomizePenStyle ? GetRandomPenStyle() : CGraphicsContext::ESolidPen; sl@0: iBrushStyle = iRandomizeBrushStyle ? GetRandomBrushStyle() : CGraphicsContext::ESolidBrush; sl@0: CCompWin::PostConstructL(); sl@0: } sl@0: sl@0: void CEnormousWin::DrawBitmap(CFbsBitGc* aGc, TRect& aClip, TPoint& aOrigin) sl@0: { sl@0: aGc->Reset(); sl@0: TPoint origin = iPos + aOrigin; sl@0: aGc->SetOrigin(origin); sl@0: sl@0: TRect clip(origin, iSize); sl@0: clip.Intersection(aClip); sl@0: clip.Move(-origin); sl@0: aGc->SetClippingRect(clip); sl@0: sl@0: aGc->SetPenStyle(iPenStyle); sl@0: aGc->SetBrushStyle(iBrushStyle); sl@0: sl@0: TInt left = clip.iTl.iX / ESegmentSize; sl@0: TInt top = clip.iTl.iY / ESegmentSize; sl@0: TInt right = clip.iBr.iX / ESegmentSize + 1; sl@0: TInt bottom = clip.iBr.iY / ESegmentSize + 1; sl@0: TRgb fg; sl@0: TRgb bg; sl@0: sl@0: for (TInt y = top; y < bottom; ++y) sl@0: { sl@0: TInt g = (y * 31) & 0xFF; sl@0: for (TInt x = left; x < right; ++x) sl@0: { sl@0: TRect rect(x * ESegmentSize, y * ESegmentSize, (x + 1) * ESegmentSize, (y + 1) * ESegmentSize); sl@0: TInt r = (x * 25) & 0xFF; sl@0: TInt b = ((x + y) * 28) & 0xFF; sl@0: TInt col = ((b << 16) + (g << 8) + r) | 0x101010; sl@0: bg = col; sl@0: fg = 0xFFFFFF ^ col; sl@0: bg.SetAlpha(0xFF); sl@0: fg.SetAlpha(0xFF); sl@0: if (iTransparent && (x & y & 1)) sl@0: { sl@0: bg.SetAlpha(0x80); sl@0: fg.SetAlpha(0x80); sl@0: } sl@0: aGc->SetPenColor(fg); sl@0: aGc->SetBrushColor(bg); sl@0: aGc->DrawRect(rect); sl@0: } sl@0: } sl@0: sl@0: CCompWin::DrawBitmap(aGc, aClip, aOrigin); sl@0: } sl@0: sl@0: void CEnormousWin::Redraw(const TRect& aRect) sl@0: { sl@0: iWsGc.Activate(*iWindow); sl@0: iWsGc.Reset(); sl@0: sl@0: iWsGc.SetPenStyle(iPenStyle); sl@0: iWsGc.SetBrushStyle(iBrushStyle); sl@0: sl@0: TInt left = aRect.iTl.iX / ESegmentSize; sl@0: TInt top = aRect.iTl.iY / ESegmentSize; sl@0: TInt right = aRect.iBr.iX / ESegmentSize + 1; sl@0: TInt bottom = aRect.iBr.iY / ESegmentSize + 1; sl@0: TRgb fg; sl@0: TRgb bg; sl@0: sl@0: for (TInt y = top; y < bottom; ++y) sl@0: { sl@0: TInt g = (y * 31) & 0xFF; sl@0: for (TInt x = left; x < right; ++x) sl@0: { sl@0: TRect rect(x * ESegmentSize, y * ESegmentSize, (x + 1) * ESegmentSize, (y + 1) * ESegmentSize); sl@0: iRedrawWindow->BeginRedraw(rect); sl@0: TInt r = (x * 25) & 0xFF; sl@0: TInt b = ((x + y) * 28) & 0xFF; sl@0: TInt col = ((b << 16) + (g << 8) + r) | 0x101010; sl@0: bg = col; sl@0: fg = 0xFFFFFF ^ col; sl@0: bg.SetAlpha(0xFF); sl@0: fg.SetAlpha(0xFF); sl@0: if (iTransparent && (x & y & 1)) sl@0: { sl@0: bg.SetAlpha(0x80); sl@0: fg.SetAlpha(0x80); sl@0: } sl@0: iWsGc.SetPenColor(fg); sl@0: iWsGc.SetBrushColor(bg); sl@0: iWsGc.DrawRect(rect); sl@0: iRedrawWindow->EndRedraw(); sl@0: } sl@0: } sl@0: iWsGc.Deactivate(); sl@0: } sl@0: sl@0: void CEnormousWin::DumpDetails(RFile& aFile, TInt aDepth) sl@0: { sl@0: TBuf8<256> buf; sl@0: buf.SetLength(0); sl@0: for (TInt d = 0; d < aDepth; ++d) sl@0: { sl@0: buf.Append(_L8(" ")); sl@0: } sl@0: buf.Append(_L8("Transparent = [")); sl@0: buf.AppendNum((TInt64)iTransparent); sl@0: buf.Append(_L8("] pen_style = [")); sl@0: buf.AppendNum((TInt64)iPenStyle); sl@0: buf.Append(_L8("] brush_style = [")); sl@0: buf.AppendNum((TInt64)iBrushStyle); sl@0: buf.Append(_L8("]\r\n")); sl@0: aFile.Write(buf); sl@0: }