|
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 <eikstart.h> |
|
23 #include <e32cmn.h> |
|
24 #include "twindowposition.h" |
|
25 |
|
26 TPoint KWindowPosition(0,0); |
|
27 TPoint windowPosition; |
|
28 |
|
29 // |
|
30 // CCoeConD |
|
31 // |
|
32 void CCoeConD::ConstructL(const CCoeControl& aParent) |
|
33 { |
|
34 CreateWindowL(&aParent); |
|
35 } |
|
36 |
|
37 // |
|
38 // CCoeConC |
|
39 // |
|
40 CCoeConC::CCoeConC(CCoeConB& aParent) : iParent(aParent) |
|
41 { |
|
42 } |
|
43 |
|
44 void CCoeConC::ConstructL() |
|
45 { |
|
46 //C is window owning |
|
47 //ViewPort |
|
48 iCoeConD = new (ELeave) CCoeConD; |
|
49 iCoeConD->ConstructL(iParent); |
|
50 CreateWindowL(iCoeConD); |
|
51 //ViewPort |
|
52 SetParent(&iParent); |
|
53 SetComponentsToInheritVisibility(); |
|
54 CopyControlContextFrom(&iParent); |
|
55 } |
|
56 |
|
57 CCoeConC::~CCoeConC() |
|
58 { |
|
59 if (iCoeConD) |
|
60 delete iCoeConD; |
|
61 } |
|
62 |
|
63 void CCoeConC::Draw(const TRect& aRect) const |
|
64 { |
|
65 CWindowGc& gc = SystemGc(); |
|
66 gc.SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
67 gc.SetBrushColor(TRgb(150,250,20)); |
|
68 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
69 gc.DrawRect(aRect); |
|
70 windowPosition.SetXY(aRect.iTl.iX, aRect.iTl.iY); |
|
71 } |
|
72 |
|
73 void CCoeConC::SetViewPortRect(TRect aRect ) |
|
74 { |
|
75 iCoeConD->SetRect(aRect); |
|
76 } |
|
77 |
|
78 TInt CCoeConC::CountComponentControls() const |
|
79 { |
|
80 return 1; |
|
81 } |
|
82 |
|
83 CCoeControl* CCoeConC::ComponentControl(TInt aIndex ) const |
|
84 { |
|
85 if( aIndex == 0 ) |
|
86 { |
|
87 return iCoeConD; |
|
88 } |
|
89 else |
|
90 { |
|
91 return NULL; |
|
92 } |
|
93 } |
|
94 |
|
95 // |
|
96 // |
|
97 // CCoeConB |
|
98 // |
|
99 // |
|
100 CCoeConB::CCoeConB():CCoeControl() |
|
101 { |
|
102 } |
|
103 |
|
104 void CCoeConB::ConstructL(CCoeControl* aParent) |
|
105 { |
|
106 //B is non-window-owning control |
|
107 TPoint pos(0,10); |
|
108 TSize sizeB(480,50); |
|
109 iCoeConC = new (ELeave) CCoeConC(*this); |
|
110 iCoeConC->ConstructL(); |
|
111 SetComponentsToInheritVisibility(); |
|
112 iCoeConC->SetViewPortRect(Rect()); |
|
113 iCoeConC->SetSize(sizeB); |
|
114 SetParent(aParent); |
|
115 ActivateL(); |
|
116 } |
|
117 |
|
118 CCoeConB::~CCoeConB() |
|
119 { |
|
120 if (iCoeConC) |
|
121 delete iCoeConC; |
|
122 } |
|
123 |
|
124 void CCoeConB::Draw(const TRect& aRect) const |
|
125 { |
|
126 CWindowGc& gc = SystemGc(); |
|
127 gc.SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
128 gc.SetBrushColor(TRgb(200,200,40)); |
|
129 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
130 gc.DrawRect(aRect); |
|
131 } |
|
132 |
|
133 TInt CCoeConB::CountComponentControls() const |
|
134 { |
|
135 return 1; |
|
136 } |
|
137 |
|
138 CCoeControl* CCoeConB::ComponentControl(TInt aIndex ) const |
|
139 { |
|
140 if( aIndex == 0 ) |
|
141 { |
|
142 return iCoeConC; |
|
143 } |
|
144 else |
|
145 { |
|
146 return NULL; |
|
147 } |
|
148 } |
|
149 |
|
150 // |
|
151 // |
|
152 // CCoeConTestView - control 'A' |
|
153 // |
|
154 // |
|
155 CCoeConTestView::CCoeConTestView():CCoeControl() |
|
156 { |
|
157 } |
|
158 |
|
159 void CCoeConTestView::ConstructL(const TRect& /*aRect*/) |
|
160 { |
|
161 CreateWindowL(); //A is window owning |
|
162 TPoint pos(0,10); |
|
163 TSize sizeB(480,100); |
|
164 SetPosition(pos); |
|
165 iCoeControlB = new (ELeave) CCoeConB(); |
|
166 //Swap order here need to set container window first |
|
167 iCoeControlB->SetContainerWindowL(Window()); |
|
168 iCoeControlB->SetExtent(pos,sizeB); |
|
169 iCoeControlB->ConstructL(this); |
|
170 ActivateL(); |
|
171 } |
|
172 |
|
173 CCoeConTestView::~CCoeConTestView() |
|
174 { |
|
175 if (iCoeControlB) |
|
176 delete iCoeControlB; |
|
177 } |
|
178 |
|
179 void CCoeConTestView::Draw(const TRect& aRect) const |
|
180 { |
|
181 // Draw main application window |
|
182 CWindowGc& gc = SystemGc(); |
|
183 gc.SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
184 gc.SetBrushColor(TRgb(200,200,200)); |
|
185 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
186 gc.DrawRect(aRect); |
|
187 } |
|
188 |
|
189 void CCoeConTestView::DrawCoeConB() const |
|
190 { |
|
191 // Draw the window owning and non-window owning controls |
|
192 iCoeControlB->DrawNow(); |
|
193 TInt exitReason; |
|
194 if (windowPosition == KWindowPosition) |
|
195 { |
|
196 exitReason = KErrNone; |
|
197 } |
|
198 else |
|
199 { |
|
200 exitReason = KErrWindowPosDoesNotMatch; |
|
201 } |
|
202 RProcess().Terminate(exitReason); |
|
203 } |
|
204 |
|
205 TInt CCoeConTestView::CountComponentControls() const |
|
206 { |
|
207 return 1; |
|
208 } |
|
209 |
|
210 CCoeControl* CCoeConTestView::ComponentControl(TInt aIndex) const |
|
211 { |
|
212 if (aIndex == 0) |
|
213 { |
|
214 return iCoeControlB; |
|
215 } |
|
216 else |
|
217 { |
|
218 return NULL; |
|
219 } |
|
220 |
|
221 } |
|
222 /* |
|
223 void CCoeConTestView::ClearScr() |
|
224 { |
|
225 CWindowGc& gc = SystemGc(); |
|
226 gc.SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
227 gc.SetBrushColor(TRgb(200,200,200)); |
|
228 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
229 gc.Clear(); |
|
230 } |
|
231 */ |
|
232 // |
|
233 // |
|
234 // CCoeConTestAppUi |
|
235 // |
|
236 // |
|
237 CCoeConTestAppUi::CCoeConTestAppUi() : CTestAppUi(NULL, KNullDesC) |
|
238 { |
|
239 } |
|
240 |
|
241 void CCoeConTestAppUi::ConstructL() |
|
242 { |
|
243 CTestAppUi::ConstructL(); |
|
244 iAppView = new(ELeave) CCoeConTestView; |
|
245 iAppView->ConstructL(ClientRect()); |
|
246 AutoTestManager().StartAutoTest(); |
|
247 } |
|
248 |
|
249 CCoeConTestAppUi::~CCoeConTestAppUi() |
|
250 { |
|
251 if (iAppView) |
|
252 { |
|
253 delete iAppView; |
|
254 } |
|
255 } |
|
256 |
|
257 void CCoeConTestAppUi::TestWindowPosition() |
|
258 { |
|
259 iAppView->DrawCoeConB(); |
|
260 } |
|
261 |
|
262 void CCoeConTestAppUi::RunTestStepL(TInt aNumStep) |
|
263 { |
|
264 switch(aNumStep) |
|
265 { |
|
266 case 1: |
|
267 { |
|
268 TRAPD(err, TestWindowPosition()); |
|
269 if (err == KErrNone) |
|
270 { |
|
271 AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass); |
|
272 } |
|
273 else |
|
274 { |
|
275 AutoTestManager().FinishAllTestCases(CAutoTestManager::EFailed); |
|
276 } |
|
277 break; |
|
278 } |
|
279 default: |
|
280 break; |
|
281 } |
|
282 } |
|
283 |
|
284 // |
|
285 // |
|
286 // CCoeConTestDocument |
|
287 // |
|
288 // |
|
289 CCoeConTestDocument::CCoeConTestDocument(CEikApplication& aApp) |
|
290 : CEikDocument(aApp) |
|
291 { |
|
292 } |
|
293 |
|
294 CEikAppUi* CCoeConTestDocument::CreateAppUiL() |
|
295 { |
|
296 return new(ELeave) CCoeConTestAppUi; |
|
297 } |
|
298 |
|
299 // |
|
300 // |
|
301 // CCoeConTestApp |
|
302 // |
|
303 // |
|
304 TUid CCoeConTestApp::AppDllUid() const |
|
305 { |
|
306 return KUidCoeControlTestApp; |
|
307 } |
|
308 |
|
309 CApaDocument* CCoeConTestApp::CreateDocumentL() |
|
310 { |
|
311 return new(ELeave) CCoeConTestDocument(*this); |
|
312 } |
|
313 |
|
314 LOCAL_C CApaApplication* NewApplication() |
|
315 { |
|
316 return new CCoeConTestApp; |
|
317 } |
|
318 |
|
319 GLDEF_C TInt E32Main() |
|
320 { |
|
321 return EikStart::RunApplication(NewApplication); |
|
322 } |