|
1 /* |
|
2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation for CFepUiLayoutRootCtrl |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "peninputlayoutrootctrl.h" |
|
20 #include "peninputlayouthwrwnd.h" |
|
21 #include "peninputlayoutbutton.h" |
|
22 #include "peninputlayouteditareabase.h" |
|
23 #include "peninputlayout.h" |
|
24 #include "peninputlayoutcursor.h" |
|
25 #include <peninputcmd.h> |
|
26 #include <AknsConstants.h> |
|
27 #include <AknsUtils.h> |
|
28 const TInt KRootControlId = -1; |
|
29 |
|
30 // ======== MEMBER FUNCTIONS ======== |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CFepUiLayoutRootCtrl::NewL |
|
34 // class factory function |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CFepUiLayoutRootCtrl* CFepUiLayoutRootCtrl::NewL(CFepUiLayout* aUiLayout) |
|
38 { |
|
39 CFepUiLayoutRootCtrl* ctrl = new(ELeave) CFepUiLayoutRootCtrl(aUiLayout); |
|
40 CleanupStack::PushL(ctrl); |
|
41 ctrl->ConstructL(); |
|
42 CleanupStack::Pop(ctrl); |
|
43 return ctrl; |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CFepUiLayoutRootCtrl::ConstructL |
|
48 // 2nd phase constructor |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 void CFepUiLayoutRootCtrl::ConstructL() |
|
52 { |
|
53 BaseConstructL(this); |
|
54 //set it not ready to avoid unnessary drawing. Ready is set afer InitControl |
|
55 SetReady(EFalse); |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CFepUiLayoutRootCtrl::~CFepUiLayoutRootCtrl |
|
60 // Destructor |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CFepUiLayoutRootCtrl::~CFepUiLayoutRootCtrl() |
|
64 { |
|
65 //CFepUiBaseCtrl* ctrl; |
|
66 //free all control. iCtrlList keeps all controls for root control. |
|
67 /*for(TInt i = iCtrlList.Count()-1; i >= 0;i--) |
|
68 { |
|
69 ctrl = iCtrlList[i]; |
|
70 delete ctrl; |
|
71 } |
|
72 iCtrlList.Reset();*/ |
|
73 //No need to close others, CControlGroup will do that. |
|
74 iCtrlRegionAwareList.Close(); |
|
75 iCtrlOverlappingAwareList.Close(); |
|
76 //iNonHwrStartPtRegion.Close(); |
|
77 delete iWindowGc; |
|
78 delete iCursor; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // CFepUiLayoutRootCtrl::CFepUiLayoutRootCtrl |
|
83 // Constructor |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 CFepUiLayoutRootCtrl::CFepUiLayoutRootCtrl(CFepUiLayout* aUiLayout): |
|
87 CControlGroup(aUiLayout,KRootControlId) |
|
88 { |
|
89 SetControlType(ECtrlWndBasedCtrl|ControlType()); |
|
90 SetMaskBkCol(KTransparentColor); |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CFepUiLayoutRootCtrl::HandleEventL |
|
95 // handle event from window server |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 TBool CFepUiLayoutRootCtrl::HandleEventL(TEventType aType, const TAny* aData) |
|
99 { |
|
100 |
|
101 CFepUiBaseCtrl* ctrl = NULL; |
|
102 |
|
103 switch(aType) |
|
104 { |
|
105 case ERawEvent: |
|
106 { |
|
107 TRawEvent event=*((TRawEvent*)aData); |
|
108 switch(event.Type()) |
|
109 { |
|
110 case TRawEvent::EPointerMove: |
|
111 { |
|
112 TPoint point = event.Pos() - UiLayout()->Position (); |
|
113 |
|
114 //if captured |
|
115 if(iPointerCaptureCtrl) |
|
116 { |
|
117 ctrl = iPointerCaptureCtrl->HandlePointerMoveEventL(point); |
|
118 break; |
|
119 } |
|
120 |
|
121 //won't handle move event if no pointer down happens |
|
122 if(!iCtrlWithPointerDown) |
|
123 return EFalse; |
|
124 |
|
125 ctrl = HandlePointerMoveEventL(point); |
|
126 } |
|
127 break; |
|
128 |
|
129 case TRawEvent::EButton1Down: |
|
130 { |
|
131 |
|
132 TPoint point1 = event.Pos() - UiLayout()->Position (); |
|
133 //if captured |
|
134 if(iPointerCaptureCtrl) |
|
135 { |
|
136 ctrl = iPointerCaptureCtrl->HandlePointerDownEventL(point1); |
|
137 break; |
|
138 } |
|
139 |
|
140 ctrl = HandlePointerDownEventL(point1); |
|
141 } |
|
142 break; |
|
143 |
|
144 case TRawEvent::EButton1Up: |
|
145 { |
|
146 |
|
147 TPoint point = event.Pos() - UiLayout()->Position (); |
|
148 if(iPointerCaptureCtrl) |
|
149 { |
|
150 ctrl = iPointerCaptureCtrl->HandlePointerUpEventL(point); |
|
151 } |
|
152 else |
|
153 ctrl = HandlePointerUpEventL(point); |
|
154 iCtrlWithPointerDown = NULL; |
|
155 } |
|
156 break; |
|
157 |
|
158 default: |
|
159 break; |
|
160 } |
|
161 } |
|
162 break; |
|
163 |
|
164 case EPointerEvent: |
|
165 { |
|
166 TPointerEvent pt= *((TPointerEvent*)aData); |
|
167 TPoint point = pt.iPosition; |
|
168 |
|
169 //same as raw event |
|
170 if(TPointerEvent::EButton1Down == pt.iType) |
|
171 { |
|
172 if(iPointerCaptureCtrl) |
|
173 { |
|
174 ctrl = iPointerCaptureCtrl->HandlePointerDownEventL(point); |
|
175 break; |
|
176 } |
|
177 |
|
178 ctrl = HandlePointerDownEventL(point); |
|
179 } |
|
180 else |
|
181 { |
|
182 if(TPointerEvent::EButton1Up == pt.iType) |
|
183 { |
|
184 if(iPointerCaptureCtrl) |
|
185 { |
|
186 ctrl = iPointerCaptureCtrl->HandlePointerUpEventL(point); |
|
187 iCtrlWithPointerDown = NULL; |
|
188 break; |
|
189 } |
|
190 ctrl = HandlePointerUpEventL(point); |
|
191 } |
|
192 else |
|
193 { |
|
194 if(TPointerEvent::EDrag == pt.iType || |
|
195 TPointerEvent::EMove == pt.iType) |
|
196 { |
|
197 //if captured |
|
198 if(iPointerCaptureCtrl) |
|
199 { |
|
200 ctrl = iPointerCaptureCtrl->HandlePointerMoveEventL(point); |
|
201 break; |
|
202 } |
|
203 |
|
204 //won't handle move event if no pointer down happens |
|
205 if(!iCtrlWithPointerDown) |
|
206 return NULL; |
|
207 |
|
208 ctrl = HandlePointerMoveEventL(point); |
|
209 } |
|
210 } |
|
211 } |
|
212 |
|
213 |
|
214 } |
|
215 break; |
|
216 |
|
217 default: |
|
218 break; |
|
219 } |
|
220 |
|
221 if(iPointerDownCanceled) |
|
222 { |
|
223 iCtrlWithPointerDown = NULL; |
|
224 iPointerLeft = EFalse; |
|
225 } |
|
226 return ctrl ? ETrue : EFalse; |
|
227 |
|
228 } |
|
229 // --------------------------------------------------------------------------- |
|
230 // CFepUiLayoutRootCtrl::SetPointerDownCtrl |
|
231 // Set pointer down control. |
|
232 // (other items were commented in a header). |
|
233 // --------------------------------------------------------------------------- |
|
234 // |
|
235 void CFepUiLayoutRootCtrl::SetPointerDownCtrlL(CFepUiBaseCtrl* aCtrl) |
|
236 { |
|
237 //set pointer down canceling flag |
|
238 iPointerDownCanceled = EFalse; |
|
239 if(!aCtrl) // Pointer down and up in different control |
|
240 { |
|
241 if(iCtrlWithPointerDown) |
|
242 { |
|
243 //cancel the pointer down event for the control which has pen down operation |
|
244 iCtrlWithPointerDown->CancelPointerDownL(); |
|
245 iPointerDownCanceled = ETrue; |
|
246 } |
|
247 } |
|
248 else |
|
249 iCtrlWithPointerDown = aCtrl; |
|
250 } |
|
251 |
|
252 // --------------------------------------------------------------------------- |
|
253 // CFepUiLayoutRootCtrl::RequireRegionUpdateL |
|
254 // Register the control to be region change awared |
|
255 // (other items were commented in a header). |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 EXPORT_C void CFepUiLayoutRootCtrl::RequireRegionUpdateL(CFepUiBaseCtrl* aCtrl, |
|
259 TBool aRequiredFlag) |
|
260 { |
|
261 TInt ctrlIdx = iCtrlRegionAwareList.Find(aCtrl); |
|
262 if(aRequiredFlag) |
|
263 { |
|
264 if(KErrNotFound != ctrlIdx) |
|
265 return; //already there |
|
266 |
|
267 /*for(i =0; i < iCtrlRegionAwareList.Count(); i++) |
|
268 { |
|
269 if(aCtrl == iCtrlRegionAwareList[i]) |
|
270 return; |
|
271 }*/ |
|
272 iCtrlRegionAwareList.AppendL(aCtrl); |
|
273 if(aCtrl->Ready()) |
|
274 { |
|
275 //calculate the region for the first time |
|
276 aCtrl->UpdateValidRegion(NULL,EFalse); |
|
277 } |
|
278 //otherwise do this during layout initialization |
|
279 } |
|
280 else |
|
281 { |
|
282 if(KErrNotFound == ctrlIdx) |
|
283 return; |
|
284 |
|
285 iCtrlRegionAwareList.Remove(ctrlIdx); |
|
286 /* |
|
287 for(i =0; i < iCtrlRegionAwareList.Count(); i++) |
|
288 { |
|
289 if(aCtrl == iCtrlRegionAwareList[i]) |
|
290 { |
|
291 iCtrlRegionAwareList.Remove(i); |
|
292 //TRect rect = aCtrl->Rect(); |
|
293 //aCtrl->SetRect(rect); //restore the region |
|
294 } |
|
295 }*/ |
|
296 } |
|
297 } |
|
298 |
|
299 // --------------------------------------------------------------------------- |
|
300 // CFepUiLayoutRootCtrl::DrawRect |
|
301 // Draw layout content within a rect |
|
302 // (other items were commented in a header). |
|
303 // --------------------------------------------------------------------------- |
|
304 // |
|
305 void CFepUiLayoutRootCtrl::DrawRect(const TRect& aRect,TBool aDrawFrameFlag) |
|
306 { |
|
307 const TSize KFramePenSize(2,2); |
|
308 |
|
309 if(aDrawFrameFlag) //only draw frame |
|
310 { |
|
311 |
|
312 DrawOpaqueMaskBackground(); |
|
313 |
|
314 DrawBackground(); |
|
315 } |
|
316 else |
|
317 { |
|
318 CControlGroup::ReDrawRect(aRect); |
|
319 } |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 } |
|
325 // --------------------------------------------------------------------------- |
|
326 // CFepUiLayoutRootCtrl::RemoveControl |
|
327 // Remove a control to layout |
|
328 // --------------------------------------------------------------------------- |
|
329 // |
|
330 void CFepUiLayoutRootCtrl::RemoveControl(CFepUiBaseCtrl* aControl) |
|
331 { |
|
332 if(!aControl) |
|
333 return; |
|
334 /* |
|
335 TBool bFound = EFalse; |
|
336 if(aControl == iActiveCtrl) |
|
337 iActiveCtrl = NULL; |
|
338 for(TInt i = 0; i < iCtrlList.Count(); i++) |
|
339 { |
|
340 if(iCtrlList[i] == aControl) |
|
341 { |
|
342 bFound = ETrue; |
|
343 iCtrlList.Remove(i); |
|
344 DoRegionUpdateForCtrls(); |
|
345 delete aControl; |
|
346 } |
|
347 } |
|
348 if(!bFound) //not found, the control must member of one control group |
|
349 { |
|
350 for(TInt i = 0; i < iCtrlList.Count(); i++) |
|
351 { |
|
352 if(iCtrlList[i]->IsKindOfControl(ECtrlControlGroup)) |
|
353 { |
|
354 static_cast<CControlGroup*>(iCtrlList[i])-> |
|
355 RemoveControl(aControl); |
|
356 } |
|
357 } |
|
358 }*/ |
|
359 aControl->RemoveEventObserver(UiLayout()); |
|
360 CControlGroup::RemoveControl(aControl); |
|
361 |
|
362 //DoRegionUpdateForCtrls(); |
|
363 } |
|
364 |
|
365 |
|
366 // --------------------------------------------------------------------------- |
|
367 // CFepUiLayoutRootCtrl::RemoveControl |
|
368 // Remove a control to layout |
|
369 // --------------------------------------------------------------------------- |
|
370 // |
|
371 void CFepUiLayoutRootCtrl::RemoveControl(CCoeControl* aControl) |
|
372 { |
|
373 CFepUiBaseCtrl* foundedCtrl = Find(aControl); |
|
374 RemoveControl(foundedCtrl); |
|
375 } |
|
376 |
|
377 |
|
378 // ----------------------------------------------------------------------------- |
|
379 // CFepUiLayoutRootCtrl::SetRect |
|
380 // Set layout rect |
|
381 // ----------------------------------------------------------------------------- |
|
382 // |
|
383 void CFepUiLayoutRootCtrl::SetRect(const TRect& aRect) |
|
384 { |
|
385 iRect = aRect; |
|
386 |
|
387 DoRegionUpdateForCtrls(); |
|
388 /* for(TInt i =0; i < iCtrlRegionAwareList.Count(); i++) |
|
389 { |
|
390 //re-calculate the valid region |
|
391 iCtrlRegionAwareList[i]->UpdateValidRegion(NULL,EFalse); |
|
392 } */ |
|
393 } |
|
394 |
|
395 |
|
396 // --------------------------------------------------------------------------- |
|
397 // CFepUiLayoutRootCtrl::UpdateValidRegion |
|
398 // Update control's valid region after one control Hiden or shown. |
|
399 // (other items were commented in a header). |
|
400 // --------------------------------------------------------------------------- |
|
401 // |
|
402 void CFepUiLayoutRootCtrl::UpdateValidRegion(CFepUiBaseCtrl* aCtrl, |
|
403 TBool aRemoveFlag) |
|
404 { |
|
405 //CControlGroup::UpdateValidRegion(aCtrl,aRemoveFlag); |
|
406 //if(!aCtrl) |
|
407 if(Ready()) |
|
408 { |
|
409 //ask all region aware control to update the region |
|
410 for(TInt i =0; i < iCtrlRegionAwareList.Count(); i++) |
|
411 { |
|
412 //re-calculate the valid region |
|
413 iCtrlRegionAwareList[i]->UpdateValidRegion(NULL,EFalse); |
|
414 } |
|
415 } |
|
416 |
|
417 //only check shadow rect when aCtrl is not NULL |
|
418 if(aCtrl) |
|
419 { |
|
420 for(TInt i = 0; i < iCtrlOverlappingAwareList.Count(); ++i) |
|
421 { |
|
422 iCtrlOverlappingAwareList[i]->UpdateValidRegion(aCtrl,aRemoveFlag); |
|
423 } |
|
424 //pop up window will be handled dynamically |
|
425 if(!aCtrl->IsKindOfControl(ECtrlPopupWindow) && |
|
426 !aCtrl->ShadowRect().IsEmpty()) |
|
427 { |
|
428 TSize s(iShadowRect.Size()); |
|
429 if(aCtrl->ShadowRect().Width() > s.iWidth) |
|
430 s.iWidth = aCtrl->ShadowRect().Width(); |
|
431 |
|
432 if(aCtrl->ShadowRect().Height() > s.iHeight) |
|
433 s.iHeight = aCtrl->ShadowRect().Height(); |
|
434 |
|
435 if(s != iShadowRect.Size()) |
|
436 { |
|
437 UiLayout()->LayoutOwner()->LayoutSizeChanged(s); |
|
438 } |
|
439 } |
|
440 |
|
441 //update iNonHwrStartPtRegion for full screen hwr |
|
442 if(!aCtrl->IsKindOfControl(ECtrlTransparentHwrWnd)) |
|
443 { |
|
444 CalculateNonHwrStartPtArea(); |
|
445 } |
|
446 } |
|
447 else |
|
448 { |
|
449 CalculateNonHwrStartPtArea(); |
|
450 } |
|
451 CalculateClipRegion(); |
|
452 } |
|
453 |
|
454 // --------------------------------------------------------------------------- |
|
455 // CFepUiLayoutRootCtrl::InitControl |
|
456 // Initialize the layout |
|
457 // --------------------------------------------------------------------------- |
|
458 // |
|
459 TRect CFepUiLayoutRootCtrl::InitControl() |
|
460 { |
|
461 TInt i=0; |
|
462 TInt count = iCtrlList.Count(); |
|
463 CFepUiBaseCtrl* ctrl; |
|
464 |
|
465 //check whether there is pop up window, move it to last |
|
466 //if pop up window is encapsulated by some control group, it can't be found here. |
|
467 for(i = 0; i < count; i++) |
|
468 { |
|
469 if(iCtrlList[i]->IsKindOfControl(ECtrlPopupWindow)) |
|
470 { |
|
471 ctrl = iCtrlList[i]; |
|
472 iCtrlList.Remove(i); |
|
473 iCtrlList.Append(ctrl); |
|
474 i--; |
|
475 count--;//The last one is pop wnd, no need to check. |
|
476 } |
|
477 } |
|
478 |
|
479 //check and calc the shadow rect |
|
480 TBool bHasShadow = EFalse; |
|
481 if(iShadowRect.IsEmpty()) |
|
482 { |
|
483 |
|
484 for(i = 0; i < iCtrlList.Count(); i++) |
|
485 { |
|
486 //pop up window doesn't affect our layout rect, ignore it. |
|
487 if(!iCtrlList[i]->IsKindOfControl(ECtrlPopupWindow)) |
|
488 { |
|
489 iShadowRect = iCtrlList[i]->ShadowRect(); |
|
490 bHasShadow = ETrue; |
|
491 break; |
|
492 } |
|
493 } |
|
494 } |
|
495 |
|
496 bHasShadow = !iShadowRect.IsEmpty(); |
|
497 |
|
498 TSize s(iRect.Size()); |
|
499 |
|
500 if(bHasShadow) |
|
501 { |
|
502 for(i = 0; i < iCtrlList.Count(); i++) |
|
503 { |
|
504 if(!iCtrlList[i]->IsKindOfControl(ECtrlPopupWindow) && |
|
505 !iCtrlList[i]->ShadowRect().IsEmpty()) |
|
506 { |
|
507 iShadowRect.BoundingRect(iCtrlList[i]->ShadowRect()); |
|
508 } |
|
509 } |
|
510 |
|
511 if(iRect.Width() < iShadowRect.Width()) |
|
512 s.iWidth = iShadowRect.Width(); |
|
513 |
|
514 if(iRect.Height() < iShadowRect.Height()) |
|
515 s.iHeight = iShadowRect.Height(); |
|
516 iRect.SetRect(TPoint(0,0),s); |
|
517 |
|
518 iLayoutPos = iShadowRect.iTl; |
|
519 //move iShadowAreaRect if needed |
|
520 |
|
521 //iShadowRect need be kept as SetShadowAreaRect will change iShadowRect |
|
522 if(ShadowAreaRect(KShadowBmpTl).iTl != TPoint(0,0)) |
|
523 { |
|
524 TPoint offset = -ShadowAreaRect(KShadowBmpTl).iTl; |
|
525 for (TInt i = 0; i < KShadowBitmapTotalNum; i ++) |
|
526 { |
|
527 iShadowAreaRect[i].Move(offset); |
|
528 } |
|
529 } |
|
530 //The layout shadow rect starts from TPoint(0,0); |
|
531 iShadowRect.Move(-iLayoutPos); |
|
532 |
|
533 s = iShadowRect.Size(); |
|
534 } |
|
535 else |
|
536 { |
|
537 iLayoutPos = iRect.iTl; |
|
538 iRect.Move(-iLayoutPos); |
|
539 } |
|
540 |
|
541 iNonHwrStartPtRegion.Clear(); |
|
542 /* |
|
543 iNonHwrStartPtRegion.AddRect(iRect); |
|
544 |
|
545 //find HWR window and remove it from the region |
|
546 CFepUiBaseCtrl* hwrWnd = ControlForKindOfType(ECtrlTransparentHwrWnd); |
|
547 TInt index = 0; |
|
548 while(hwrWnd) |
|
549 { |
|
550 iNonHwrStartPtRegion.SubRegion(hwrWnd->Region()); |
|
551 //find next hwr window |
|
552 hwrWnd = ControlForKindOfType(ECtrlTransparentHwrWnd,++index); |
|
553 } |
|
554 */ |
|
555 |
|
556 CalculateNonHwrStartPtArea(); |
|
557 const TRegion& t = RootControl()->NonHwrStartingPtRegion(); |
|
558 TInt n = t.Count(); |
|
559 const TRect* r =t.RectangleList(); |
|
560 |
|
561 RegisterICFEditor(); |
|
562 //check each control group, whether there is background control, |
|
563 //adjust pos if necessary |
|
564 AdjustBkCtrlPos(); |
|
565 //now it's ready to be drawn |
|
566 SetReady(ETrue); |
|
567 |
|
568 UpdateValidRegion(NULL,EFalse); |
|
569 return TRect(iLayoutPos,s); |
|
570 } |
|
571 |
|
572 // --------------------------------------------------------------------------- |
|
573 // CFepUiLayoutRootCtrl::CapturePointer |
|
574 // Capture pointer |
|
575 // (other items were commented in a header). |
|
576 // --------------------------------------------------------------------------- |
|
577 // |
|
578 CFepUiBaseCtrl* CFepUiLayoutRootCtrl::CapturePointer(CFepUiBaseCtrl* aCtrl, |
|
579 TBool aFlag) |
|
580 { |
|
581 CFepUiBaseCtrl* ctrl = iPointerCaptureCtrl; |
|
582 if(aFlag) |
|
583 { |
|
584 if( iPointerCaptureCtrl && aCtrl && |
|
585 iPointerCaptureCtrl->ControlId() == aCtrl->ControlId() ) |
|
586 { |
|
587 return ctrl; |
|
588 } |
|
589 |
|
590 iPointerCaptureCtrl = aCtrl; |
|
591 if(iCtrlWithPointerDown && ! aCtrl->PointerDown()) |
|
592 { |
|
593 //if someone else has pointer down, we must cancel the down event. |
|
594 TRAP_IGNORE(iCtrlWithPointerDown->CancelPointerDownL()); |
|
595 iCtrlWithPointerDown = NULL; |
|
596 } |
|
597 } |
|
598 else |
|
599 { |
|
600 if(!iPointerCaptureCtrl && !aFlag) |
|
601 return NULL; |
|
602 if (aCtrl == iPointerCaptureCtrl) |
|
603 { |
|
604 iPointerCaptureCtrl = NULL; |
|
605 } |
|
606 } |
|
607 //signal the owner that pointer needs be captured |
|
608 TInt captureCtrl = (TInt)(iPointerCaptureCtrl); |
|
609 |
|
610 TBuf<8> buf; |
|
611 buf.Append((const TUint16 *)(&aFlag), sizeof(TBool)/sizeof(TUint16)); |
|
612 buf.Append((const TUint16 *)(&captureCtrl), sizeof(TInt)/sizeof(TUint16)); |
|
613 UiLayout()->SignalOwner(ESignalCapturePointer,buf); |
|
614 |
|
615 |
|
616 return ctrl; |
|
617 } |
|
618 |
|
619 |
|
620 // --------------------------------------------------------------------------- |
|
621 // CFepUiLayoutRootCtrl::HandleControlEvent |
|
622 // Handle control event. |
|
623 // (other items were commented in a header). |
|
624 // --------------------------------------------------------------------------- |
|
625 // |
|
626 void CFepUiLayoutRootCtrl::HandleControlEvent(TInt aEventType, CFepUiBaseCtrl* aCtrl, |
|
627 const TDesC& /*aEventData*/) |
|
628 { |
|
629 CFepUiBaseCtrl* ctrl; |
|
630 switch(aEventType) |
|
631 { |
|
632 case EEventDraggingStart: |
|
633 { |
|
634 for(TInt i = 0; i < iCtrlList.Count(); i++) |
|
635 { |
|
636 iCtrlList[i]->OnLayoutDraggingStart(); |
|
637 } |
|
638 } |
|
639 break; |
|
640 case EEventDraggingEnd: |
|
641 { |
|
642 for(TInt i = 0; i < iCtrlList.Count(); i++) |
|
643 { |
|
644 iCtrlList[i]->OnLayoutDraggingEnd(); |
|
645 } |
|
646 } |
|
647 break; |
|
648 case EEventRegionUpdated: |
|
649 { |
|
650 //now find the hwr wwindow |
|
651 for(TInt i = 0; i < iCtrlList.Count(); i++) |
|
652 { |
|
653 ctrl = iCtrlList[i]; |
|
654 if(ctrl->IsKindOfControl(ECtrlHwrWnd)) |
|
655 { |
|
656 static_cast<CHwrWndBase*>(ctrl)->UpdateRegion(aCtrl); |
|
657 } |
|
658 } |
|
659 } |
|
660 break; |
|
661 |
|
662 default: |
|
663 break; |
|
664 } |
|
665 } |
|
666 |
|
667 // --------------------------------------------------------------------------- |
|
668 // CFepUiLayoutRootCtrl::HandlePositionChange |
|
669 // Handle layout position change |
|
670 // (other items were commented in a header). |
|
671 // --------------------------------------------------------------------------- |
|
672 // |
|
673 TBool CFepUiLayoutRootCtrl::HandlePositionChange(const TPoint& aOffset) |
|
674 { |
|
675 const TPoint KZeroOffset(0,0); |
|
676 if(aOffset != KZeroOffset) |
|
677 { |
|
678 TPoint pos = UiLayout()->Position() + aOffset; |
|
679 UiLayout()->SetLayoutPos(pos); |
|
680 } |
|
681 return ETrue; //if layout process the event, the no control will process it. |
|
682 } |
|
683 |
|
684 // --------------------------------------------------------------------------- |
|
685 // CFepUiLayoutRootCtrl::GetInputContextFieldMaxLen |
|
686 // Get the max editor length of the input context field |
|
687 // (other items were commented in a header). |
|
688 // --------------------------------------------------------------------------- |
|
689 // |
|
690 TInt CFepUiLayoutRootCtrl::GetInputContextFieldMaxLen() |
|
691 { |
|
692 TInt len = 0; |
|
693 //find the input context area control. At any time there is only one editor |
|
694 //area control in the layout. |
|
695 CFepUiBaseCtrl* ctrl = ControlForKindOfType(ECtrlEditAreaBase); |
|
696 if(ctrl) |
|
697 { |
|
698 len = static_cast<CFepLayoutEditAreaBase*>(ctrl)-> |
|
699 GetEditorFieldMaxLen(); |
|
700 } |
|
701 |
|
702 return len; |
|
703 } |
|
704 |
|
705 // --------------------------------------------------------------------------- |
|
706 // CFepUiLayoutRootCtrl::IsValidDestination |
|
707 // Test whether the rect conflicts with other controls |
|
708 // (other items were commented in a header). |
|
709 // --------------------------------------------------------------------------- |
|
710 // |
|
711 TBool CFepUiLayoutRootCtrl::IsValidDestination(const TRect& aRect, |
|
712 CDragBar* aDragBar, |
|
713 TBool& aVInfo, |
|
714 TBool& aHInfo) |
|
715 { |
|
716 aVInfo = EFalse; |
|
717 aHInfo = EFalse; |
|
718 if(!Rect().Contains(aRect.iTl) || !Rect().Contains(aRect.iBr)) //outside of the ui layout |
|
719 return EFalse; |
|
720 |
|
721 CFepUiBaseCtrl* ctrl; |
|
722 |
|
723 for(TInt i = iCtrlList.Count()-1; i >= 0;i--) |
|
724 { |
|
725 ctrl = iCtrlList[i]; |
|
726 TBool bIsDragingComponent = EFalse; |
|
727 if(aDragBar) |
|
728 { |
|
729 if(aDragBar->IsDraggingComponent(ctrl)) |
|
730 bIsDragingComponent = ETrue; |
|
731 } |
|
732 |
|
733 |
|
734 if(!bIsDragingComponent && aRect.Intersects(ctrl->Rect())) //conflicts with others |
|
735 { |
|
736 //is the control one of the dragbar component. |
|
737 |
|
738 if(!ctrl->AllowOverlap()) |
|
739 { |
|
740 //if the control not allow overlapping, then it's invalid pos |
|
741 return EFalse; |
|
742 } |
|
743 |
|
744 } |
|
745 } |
|
746 |
|
747 return ETrue; |
|
748 } |
|
749 // --------------------------------------------------------------------------- |
|
750 // CFepUiLayoutRootCtrl::HandlePointerDownEventL |
|
751 // Handle pointer down event |
|
752 // (other items were commented in a header). |
|
753 // --------------------------------------------------------------------------- |
|
754 // |
|
755 CFepUiBaseCtrl* CFepUiLayoutRootCtrl::HandlePointerDownEventL( |
|
756 const TPoint& aPoint) |
|
757 { |
|
758 return CControlGroup::HandlePointerDownEventL(aPoint); |
|
759 } |
|
760 |
|
761 // --------------------------------------------------------------------------- |
|
762 // CFepUiLayoutRootCtrl::HandlePointerUpEventL |
|
763 // Handle pointer up event |
|
764 // (other items were commented in a header). |
|
765 // --------------------------------------------------------------------------- |
|
766 // |
|
767 CFepUiBaseCtrl* CFepUiLayoutRootCtrl::HandlePointerUpEventL( |
|
768 const TPoint& aPoint) |
|
769 { |
|
770 CFepUiBaseCtrl* ctrl = CControlGroup::HandlePointerUpEventL(aPoint); |
|
771 if(!ctrl && iCtrlWithPointerDown) |
|
772 { |
|
773 iCtrlWithPointerDown->CancelPointerDownL(); |
|
774 iCtrlWithPointerDown = NULL; |
|
775 } |
|
776 |
|
777 return ctrl; |
|
778 } |
|
779 |
|
780 // --------------------------------------------------------------------------- |
|
781 // CFepUiLayoutRootCtrl::HandlePointerMoveEventL |
|
782 // Handle pointer move event |
|
783 // (other items were commented in a header). |
|
784 // --------------------------------------------------------------------------- |
|
785 // |
|
786 CFepUiBaseCtrl* CFepUiLayoutRootCtrl::HandlePointerMoveEventL( |
|
787 const TPoint& aPoint) |
|
788 { |
|
789 CFepUiBaseCtrl* ctrl = CControlGroup::HandlePointerMoveEventL(aPoint); |
|
790 //Moving outside of layout |
|
791 if(!ctrl && iCtrlWithPointerDown && !iPointerLeft) |
|
792 { |
|
793 iCtrlWithPointerDown->HandlePointerLeave(aPoint); |
|
794 iPointerLeft = ETrue; |
|
795 } |
|
796 // Moving back from outside of layout to current control |
|
797 if(ctrl == iCtrlWithPointerDown && iPointerLeft && iCtrlWithPointerDown) |
|
798 { |
|
799 iCtrlWithPointerDown->HandlePointerEnter(aPoint); |
|
800 iPointerLeft = EFalse; |
|
801 } |
|
802 |
|
803 return ctrl; |
|
804 } |
|
805 |
|
806 // ----------------------------------------------------------------------------- |
|
807 // CFepUiLayoutRootCtrl::Draw |
|
808 // Draw the control |
|
809 // (other items were commented in a header). |
|
810 // ----------------------------------------------------------------------------- |
|
811 // |
|
812 void CFepUiLayoutRootCtrl::Draw() |
|
813 { |
|
814 |
|
815 if(!AbleToDraw()) |
|
816 return; |
|
817 |
|
818 CControlGroup::Draw(); |
|
819 |
|
820 if(!iShadowRect.IsEmpty()) |
|
821 { |
|
822 iShadowShown = ETrue; |
|
823 DrawShadow(); |
|
824 } |
|
825 |
|
826 UpdateArea(iRect, EFalse); |
|
827 } |
|
828 |
|
829 // --------------------------------------------------------------------------- |
|
830 // CFepUiLayoutRootCtrl::DrawFrame |
|
831 // Draw moving frame |
|
832 // (other items were commented in a header). |
|
833 // --------------------------------------------------------------------------- |
|
834 // |
|
835 TRect CFepUiLayoutRootCtrl::DrawFrame(const TRect& aFrameRect, TBool aDrawFlag) |
|
836 { |
|
837 |
|
838 //clear shadow when moving |
|
839 TBool updateShadowArea = EFalse; |
|
840 TRect dirtyRect; |
|
841 if(iShadowShown) |
|
842 { |
|
843 ClearRect(iShadowRect); |
|
844 iShadowShown = EFalse; |
|
845 updateShadowArea = ETrue; |
|
846 } |
|
847 |
|
848 |
|
849 TRect bmpRect; |
|
850 TPoint bmpPos; |
|
851 |
|
852 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
853 |
|
854 //draw mask background |
|
855 TRgb maskPenCol = aDrawFlag ? TRgb(KOpaqueColor) : TRgb(KTransparentColor); |
|
856 DrawBackgroundToDevice(aFrameRect,MaskBitmapDevice(), 0, |
|
857 //TRgb(KTransparentColor), TRgb(KOpaqueColor),EFalse); |
|
858 TRgb(KTransparentColor), maskPenCol,EFalse); |
|
859 |
|
860 //draw background |
|
861 TRgb penCor = aDrawFlag ? KRgbBlack : KRgbWhite; |
|
862 TAknsQsnOtherColorsIndex clrIndex; |
|
863 clrIndex = EAknsCIQsnOtherColorsCG9; |
|
864 |
|
865 if ( AknsUtils::AvkonSkinEnabled() ) |
|
866 { |
|
867 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
868 penCor, KAknsIIDQsnTextColors, clrIndex ); |
|
869 } |
|
870 |
|
871 DrawBackgroundToDevice(aFrameRect,BitmapDevice(),0,TRgb(KRgbWhite),penCor,EFalse); |
|
872 |
|
873 gc->RectDrawnTo(dirtyRect); |
|
874 |
|
875 if(updateShadowArea) |
|
876 return iShadowRect; |
|
877 else |
|
878 return dirtyRect; |
|
879 } |
|
880 |
|
881 // --------------------------------------------------------------------------- |
|
882 // CFepUiLayoutRootCtrl::OnDeActivate |
|
883 // Response to layout de activation event |
|
884 // (other items were commented in a header). |
|
885 // --------------------------------------------------------------------------- |
|
886 // |
|
887 EXPORT_C void CFepUiLayoutRootCtrl::OnDeActivate() |
|
888 { |
|
889 if ( iPointerCaptureCtrl ) |
|
890 { |
|
891 if(iPointerCaptureCtrl->PointerDown()) |
|
892 { |
|
893 TRAP_IGNORE(iPointerCaptureCtrl->CancelPointerDownL()); |
|
894 } |
|
895 |
|
896 //CFepLayoutMultiLineIcf::CancelPointerDownL may set iPointerCaptureCtrl to be NULL |
|
897 if ( iPointerCaptureCtrl ) |
|
898 { |
|
899 iPointerCaptureCtrl->CapturePointer(EFalse); |
|
900 iPointerCaptureCtrl = NULL; |
|
901 } |
|
902 } |
|
903 iPointerDownCanceled = EFalse; |
|
904 CControlGroup::OnDeActivate(); |
|
905 } |
|
906 |
|
907 // --------------------------------------------------------------------------- |
|
908 // CFepUiLayoutRootCtrl::OnActivate |
|
909 // Response to layout activation event |
|
910 // (other items were commented in a header). |
|
911 // --------------------------------------------------------------------------- |
|
912 // |
|
913 EXPORT_C void CFepUiLayoutRootCtrl::OnActivate() |
|
914 { |
|
915 CControlGroup::OnActivate(); |
|
916 } |
|
917 void CFepUiLayoutRootCtrl::DoRegionUpdateForCtrls() |
|
918 { |
|
919 CFepUiBaseCtrl* ctrl; |
|
920 for(TInt i = 0; i< iCtrlRegionAwareList.Count(); i++) |
|
921 { |
|
922 ctrl = iCtrlRegionAwareList[i]; |
|
923 if(ctrl->Ready()) |
|
924 ctrl->UpdateValidRegion(NULL,EFalse); |
|
925 } |
|
926 |
|
927 } |
|
928 |
|
929 void CFepUiLayoutRootCtrl::RegisterICFEditor() |
|
930 { |
|
931 TInt index = 0; |
|
932 while(ETrue) |
|
933 { |
|
934 CFepUiBaseCtrl* ctrl = ControlForKindOfType(ECtrlEditAreaBase,index++); |
|
935 if(!ctrl) |
|
936 break; |
|
937 iCtrlOverlappingAwareList.Append(ctrl); |
|
938 } |
|
939 } |
|
940 |
|
941 CWindowToBitmapMappingGc* CFepUiLayoutRootCtrl::GetRWindowGcL() |
|
942 { |
|
943 if(!iWindowGc) |
|
944 { |
|
945 CWsScreenDevice *screenDevice = CCoeEnv::Static()->ScreenDevice(); |
|
946 CFbsBitGc* gc = static_cast<CFbsBitGc*>(UiLayout()->LayoutOwner()->BitmapContext()); |
|
947 iWindowGc = CWindowToBitmapMappingGc::NewL(*screenDevice,*gc); |
|
948 } |
|
949 return iWindowGc; |
|
950 } |
|
951 |
|
952 // ----------------------------------------------------------------------------- |
|
953 // CFepUiLayoutRootCtrl::OnResourceChange |
|
954 // Handle system resource change |
|
955 // (other items were commented in a header). |
|
956 // ----------------------------------------------------------------------------- |
|
957 // |
|
958 void CFepUiLayoutRootCtrl::HandleResourceChange(TInt aType) |
|
959 { |
|
960 CControlGroup::HandleResourceChange(aType); |
|
961 } |
|
962 |
|
963 // ----------------------------------------------------------------------------- |
|
964 // CFepUiLayoutRootCtrl::GraphicDeviceSizeChanged |
|
965 // Handle graphic device size change event |
|
966 // (other items were commented in a header). |
|
967 // ----------------------------------------------------------------------------- |
|
968 // |
|
969 void CFepUiLayoutRootCtrl::GraphicDeviceSizeChanged() |
|
970 { |
|
971 CControlGroup::GraphicDeviceSizeChanged(); |
|
972 } |
|
973 |
|
974 CFepUiCursor* CFepUiLayoutRootCtrl::CreateCursor() |
|
975 { |
|
976 CFepUiCursor* cursor = NULL; |
|
977 TRAP_IGNORE(cursor = CreateCursorL()); |
|
978 return cursor; |
|
979 } |
|
980 |
|
981 CFepUiCursor* CFepUiLayoutRootCtrl::CreateCursorL() |
|
982 { |
|
983 if(!iCursor) |
|
984 { |
|
985 const TInt KCursorId = -1; |
|
986 iCursor = CFepUiCursor::NewL(TRect(0,0,0,0),UiLayout(),KCursorId); |
|
987 } |
|
988 |
|
989 return iCursor; |
|
990 } |
|
991 |
|
992 void CFepUiLayoutRootCtrl::InsertToPopList(CFepUiBaseCtrl* aCtrl) |
|
993 { |
|
994 TInt idx = iPopCtrlList.Find(aCtrl); |
|
995 if(idx == KErrNotFound) |
|
996 { |
|
997 iPopCtrlList.Insert(aCtrl,0); |
|
998 idx = 0; |
|
999 } |
|
1000 //move to desired position |
|
1001 |
|
1002 for(TInt i = idx + 1; i < iPopCtrlList.Count(); ++i) |
|
1003 { |
|
1004 if(aCtrl->OrderPos() <= iPopCtrlList[i]->OrderPos()) |
|
1005 { |
|
1006 iPopCtrlList[i - 1] = iPopCtrlList[i]; |
|
1007 } |
|
1008 else |
|
1009 { |
|
1010 iPopCtrlList[i - 1] = aCtrl; |
|
1011 break; |
|
1012 } |
|
1013 } |
|
1014 } |
|
1015 |
|
1016 TBool CFepUiLayoutRootCtrl::ClipCursorForCtrlNeeded(CFepUiBaseCtrl* aCtrl, |
|
1017 const TBool aBringToTopFlag, |
|
1018 TInt& aCursorIndex) |
|
1019 { |
|
1020 TBool bNeedClip = EFalse; |
|
1021 TBool bNeedClipBack = EFalse; |
|
1022 |
|
1023 if(aCtrl->IsOnTopOf(iCursor)) |
|
1024 { |
|
1025 if(aBringToTopFlag) |
|
1026 { |
|
1027 bNeedClip = ETrue; |
|
1028 } |
|
1029 else |
|
1030 { |
|
1031 bNeedClipBack = ETrue; |
|
1032 } |
|
1033 } |
|
1034 else |
|
1035 { |
|
1036 //otherwise, we need to find the index in the same control group. |
|
1037 CFepUiBaseCtrl* cursor = iCursor->iEditor; |
|
1038 CFepUiBaseCtrl* overlapCtrl = aCtrl; |
|
1039 CControlGroup* cursorParent = static_cast<CControlGroup*>(cursor->ParentCtrl()); |
|
1040 CControlGroup* overlapCtrlParent = static_cast<CControlGroup*>(overlapCtrl->ParentCtrl()); |
|
1041 |
|
1042 if(cursorParent != overlapCtrlParent) |
|
1043 { |
|
1044 //find out the nest level counting starts from root control |
|
1045 TInt cursorLev = cursorParent->GetNestedLevel(); |
|
1046 //find out the nest level counting starts from root control |
|
1047 TInt overlapCtrlLev = overlapCtrlParent->GetNestedLevel(); |
|
1048 |
|
1049 if(cursorLev > overlapCtrlLev) |
|
1050 { |
|
1051 for(TInt i = 0 ; i < cursorLev - overlapCtrlLev; ++i) |
|
1052 { |
|
1053 cursor = cursorParent; |
|
1054 cursorParent = static_cast<CControlGroup*>(cursor->ParentCtrl()); |
|
1055 } |
|
1056 } |
|
1057 |
|
1058 if(overlapCtrlLev > cursorLev) |
|
1059 { |
|
1060 for(TInt i = 0 ; i < overlapCtrlLev - cursorLev; ++i) |
|
1061 { |
|
1062 overlapCtrl = overlapCtrlParent; |
|
1063 overlapCtrlParent = static_cast<CControlGroup*>(overlapCtrl->ParentCtrl()); |
|
1064 } |
|
1065 } |
|
1066 |
|
1067 //now we are in the same nest level, loop until parent is the same |
|
1068 while(cursorParent != overlapCtrlParent) |
|
1069 { |
|
1070 cursor = cursorParent; |
|
1071 overlapCtrl = overlapCtrlParent; |
|
1072 cursorParent = static_cast<CControlGroup*>(cursor->ParentCtrl()); |
|
1073 overlapCtrlParent = static_cast<CControlGroup*>(overlapCtrl->ParentCtrl()); |
|
1074 } |
|
1075 |
|
1076 } |
|
1077 |
|
1078 aCursorIndex = cursorParent->GetIdx(cursor); |
|
1079 TInt overlapCtrlInd= overlapCtrlParent->GetIdx(overlapCtrl); |
|
1080 if(aBringToTopFlag && overlapCtrlInd > aCursorIndex ) |
|
1081 { |
|
1082 bNeedClip = ETrue; |
|
1083 } |
|
1084 else if(!aBringToTopFlag && overlapCtrlInd < aCursorIndex) |
|
1085 { |
|
1086 bNeedClipBack = ETrue; |
|
1087 } |
|
1088 } |
|
1089 |
|
1090 if(aBringToTopFlag) |
|
1091 { |
|
1092 return bNeedClip; |
|
1093 } |
|
1094 else |
|
1095 { |
|
1096 return bNeedClipBack; |
|
1097 } |
|
1098 } |
|
1099 |
|
1100 void CFepUiLayoutRootCtrl::BringToTopInGroup(CFepUiBaseCtrl* aCtrl) |
|
1101 { |
|
1102 if(aCtrl->ParentCtrl() == this) |
|
1103 CControlGroup::BringToTopInGroup(aCtrl); |
|
1104 else |
|
1105 { |
|
1106 //If a control has no parent, it's added to the pop list. |
|
1107 if(aCtrl->OrderPos() != EOrderFront) |
|
1108 { |
|
1109 aCtrl->SetOrdinalPos(EOrderFront); |
|
1110 } |
|
1111 InsertToPopList(aCtrl); |
|
1112 } |
|
1113 |
|
1114 |
|
1115 if(iCursor) |
|
1116 { |
|
1117 //set cursor valid/clip region |
|
1118 TInt cursorIndex = 0; |
|
1119 if(aCtrl->Overlapped(iCursor) && ClipCursorForCtrlNeeded(aCtrl, ETrue, cursorIndex)) |
|
1120 { |
|
1121 iCursor->ResetValidClipRegion(); |
|
1122 iCursor->UpdateValidRegion(aCtrl,EFalse); |
|
1123 } |
|
1124 } |
|
1125 } |
|
1126 |
|
1127 void CFepUiLayoutRootCtrl::BringToBackInGroup(CFepUiBaseCtrl* aCtrl) |
|
1128 { |
|
1129 if(aCtrl->ParentCtrl() == this) |
|
1130 { |
|
1131 CControlGroup::BringToBackInGroup(aCtrl); |
|
1132 } |
|
1133 else |
|
1134 { |
|
1135 TInt idx = iPopCtrlList.Find(aCtrl); |
|
1136 if(idx == KErrNotFound) |
|
1137 return; |
|
1138 |
|
1139 //move to desired position |
|
1140 for(TInt i = idx -1 ; i >= 0 ; --i) |
|
1141 { |
|
1142 if(aCtrl->OrderPos() >= iPopCtrlList[i]->OrderPos()) |
|
1143 { |
|
1144 iPopCtrlList[i+1] = iPopCtrlList[i]; |
|
1145 } |
|
1146 else |
|
1147 { |
|
1148 iPopCtrlList[i+1] = aCtrl; |
|
1149 break; |
|
1150 } |
|
1151 } |
|
1152 |
|
1153 } |
|
1154 |
|
1155 if(iCursor) |
|
1156 { |
|
1157 TInt cursorIndex = 0; |
|
1158 if(aCtrl->Overlapped(iCursor) && ClipCursorForCtrlNeeded(aCtrl, EFalse, cursorIndex)) |
|
1159 { |
|
1160 // Reset the clip region, which overlap the cursor |
|
1161 iCursor->ResetValidClipRegion(); |
|
1162 for(TInt i = cursorIndex + 1; i < iCtrlList.Count(); i++) |
|
1163 { |
|
1164 if(!iCtrlList[i]->Hiden()) |
|
1165 iCursor->UpdateValidRegion(iCtrlList[i],EFalse); |
|
1166 } |
|
1167 for(TInt j = 0 ; j < iPopCtrlList.Count(); ++j) |
|
1168 { |
|
1169 if(!iPopCtrlList[j]->Hiden()) |
|
1170 iCursor->UpdateValidRegion(iPopCtrlList[j],EFalse); |
|
1171 } |
|
1172 } |
|
1173 } |
|
1174 } |