|
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 #include "backedupwin.h" |
|
23 #include "utils.h" |
|
24 |
|
25 |
|
26 //static configuration data, definitions and default assignments |
|
27 TBool CBackedupWin::iEnabled = ETrue; |
|
28 TBool CBackedupWin::iRandomizePenStyle = EFalse; |
|
29 TBool CBackedupWin::iRandomizeBrushStyle = EFalse; |
|
30 |
|
31 |
|
32 /** |
|
33 BACKED UP WIN |
|
34 */ |
|
35 CBackedupWin * CBackedupWin::NewLC(RWsSession& aWs, RWindowGroup* aGroup, CCompWin* aParent, CWindowGc& aGc) |
|
36 { |
|
37 CBackedupWin* self = new (ELeave) CBackedupWin(aWs, aGroup, aParent, aGc); |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL(); |
|
40 return self; |
|
41 } |
|
42 |
|
43 void CBackedupWin::LoadConfiguration(const MTestStepConfigurationContext* aContext) |
|
44 { |
|
45 aContext->GetBool(KT_WservStressParamEnabled, iEnabled); |
|
46 aContext->GetBool(KT_WservStressParamRandomizePenStyle, iRandomizePenStyle); |
|
47 aContext->GetBool(KT_WservStressParamRandomizeBrushStyle, iRandomizeBrushStyle); |
|
48 } |
|
49 |
|
50 CBackedupWin::CBackedupWin(RWsSession& aWs, RWindowGroup* aGroup, CCompWin* aParent, CWindowGc& aGc) : |
|
51 CCompWin(aWs, aGroup, aParent, aGc) |
|
52 { |
|
53 } |
|
54 |
|
55 CBackedupWin::~CBackedupWin() |
|
56 { |
|
57 if (iBkWsGc) |
|
58 { |
|
59 iBkWsGc->Deactivate(); |
|
60 delete iBkWsGc; |
|
61 } |
|
62 } |
|
63 |
|
64 void CBackedupWin::ConstructL() |
|
65 { |
|
66 CCompWin::PreConstructL(EFalse, ETrue); |
|
67 iBgColor = TRnd::rnd(); |
|
68 iFgColor = TRnd::rnd(); |
|
69 //backedup window does not support transparency |
|
70 iBgColor.SetAlpha(0xFF); |
|
71 iFgColor.SetAlpha(0xFF); |
|
72 |
|
73 iPenStyle = iRandomizePenStyle ? GetRandomPenStyle() : CGraphicsContext::ESolidPen; |
|
74 iBrushStyle = iRandomizeBrushStyle ? GetRandomBrushStyle() : CGraphicsContext::ESolidBrush; |
|
75 CCompWin::PostConstructL(); |
|
76 |
|
77 CWsScreenDevice* dev = static_cast<CWsScreenDevice*>(iWsGc.Device()); |
|
78 iBkWsGc = new (ELeave) CWindowGc(dev); |
|
79 User::LeaveIfError(iBkWsGc->Construct()); |
|
80 iBkWsGc->Activate(*iWindow); |
|
81 Redraw(TRect(iSize)); |
|
82 } |
|
83 |
|
84 void CBackedupWin::SetSize(const TSize & aSize) |
|
85 { |
|
86 CCompWin::SetSize(aSize); |
|
87 } |
|
88 |
|
89 void CBackedupWin::DrawBitmap(CFbsBitGc* aGc, TRect& aClip, TPoint& aOrigin) |
|
90 { |
|
91 aGc->Reset(); |
|
92 TPoint origin = iPos + aOrigin; |
|
93 aGc->SetOrigin(origin); |
|
94 |
|
95 TRect clip(origin, iSize); |
|
96 clip.Intersection(aClip); |
|
97 clip.Move(-origin); |
|
98 aGc->SetClippingRect(clip); |
|
99 aGc->SetBrushColor(KRgbWhite); |
|
100 aGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
101 aGc->Clear(TRect(iSize)); |
|
102 aGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
103 |
|
104 aGc->SetPenStyle(iPenStyle); |
|
105 aGc->SetBrushStyle(iBrushStyle); |
|
106 aGc->SetPenColor(iFgColor); |
|
107 aGc->SetBrushColor(iBgColor); |
|
108 aGc->DrawRect(TRect(iSize)); |
|
109 aGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
110 aGc->SetBrushColor(iFgColor); |
|
111 aGc->DrawRect(TRect(iSize.iWidth / 2 - 10, 0, iSize.iWidth / 2 + 10, iSize.iHeight)); |
|
112 aGc->DrawRect(TRect(0, iSize.iHeight / 2 - 10, iSize.iWidth, iSize.iHeight / 2 + 10)); |
|
113 |
|
114 CCompWin::DrawBitmap(aGc, aClip, aOrigin); |
|
115 } |
|
116 |
|
117 void CBackedupWin::Redraw(const TRect&) |
|
118 { |
|
119 if (iBkWsGc) |
|
120 { |
|
121 iBkWsGc->Reset(); |
|
122 iBkWsGc->SetPenStyle(iPenStyle); |
|
123 iBkWsGc->SetBrushStyle(iBrushStyle); |
|
124 iBkWsGc->SetPenColor(iFgColor); |
|
125 iBkWsGc->SetBrushColor(iBgColor); |
|
126 iBkWsGc->DrawRect(TRect(iSize)); |
|
127 iBkWsGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
128 iBkWsGc->SetBrushColor(iFgColor); |
|
129 iBkWsGc->DrawRect(TRect(iSize.iWidth / 2 - 10, 0, iSize.iWidth / 2 + 10, iSize.iHeight)); |
|
130 iBkWsGc->DrawRect(TRect(0, iSize.iHeight / 2 - 10, iSize.iWidth, iSize.iHeight / 2 + 10)); |
|
131 } |
|
132 } |
|
133 |
|
134 void CBackedupWin::DumpDetails(RFile& aFile, TInt aDepth) |
|
135 { |
|
136 TBuf8<256> buf; |
|
137 buf.SetLength(0); |
|
138 for (TInt d = 0; d < aDepth; ++d) |
|
139 { |
|
140 buf.Append(_L8(" ")); |
|
141 } |
|
142 buf.Append(_L8("pen_style = [")); |
|
143 buf.AppendNum((TInt64)iPenStyle); |
|
144 buf.Append(_L8("] brush_style = [")); |
|
145 buf.AppendNum((TInt64)iBrushStyle); |
|
146 buf.Append(_L8("] FgColor = [")); |
|
147 buf.AppendNum(iFgColor.Value()); |
|
148 buf.Append(_L8("] BgColor = [")); |
|
149 buf.AppendNum(iBgColor.Value()); |
|
150 buf.Append(_L8("]\r\n")); |
|
151 aFile.Write(buf); |
|
152 } |