|
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 base control |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <AknIconUtils.h> |
|
20 #include "peninputlayouttimer.h" |
|
21 #include "peninputlayoutbasecontrol.h" |
|
22 #include "peninputlayoutbutton.h" |
|
23 #include "peninputlayouthwrwnd.h" |
|
24 #include "peninputlayoutcandidatewnd.h" |
|
25 #include "peninputlayoutrootctrl.h" |
|
26 #include "peninputlayout.h" |
|
27 #include <coecntrl.h> |
|
28 |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // Implementation of Class CFepUiBaseCtrl |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // CFepUiBaseCtrl::CFepUiBaseCtrl |
|
36 // C++ default constructor |
|
37 // (other items were commented in a header). |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 EXPORT_C CFepUiBaseCtrl::CFepUiBaseCtrl(const TRect& aRect,CFepUiLayout* aUiLayout, |
|
41 TInt aControlId): |
|
42 iPointerLeft(EFalse), |
|
43 iRect(aRect), |
|
44 iShadowRect(TRect(0,0,0,0)), |
|
45 iResourceId(-1), |
|
46 iBorderColor(KRgbBlack), |
|
47 iUpdateFlagEnabled(ETrue), |
|
48 iControlId(aControlId), |
|
49 iControlType( ECtrlBaseCtrl), |
|
50 iBackgroundCol( KRgbWhite), |
|
51 iMaskBkCol(KOpaqueColor), |
|
52 iPenColor(KRgbBlack), |
|
53 iHiden(EFalse), |
|
54 iPointerDown(EFalse), |
|
55 iReady( EFalse), |
|
56 iIsActive(EFalse), |
|
57 iAllowOverlap(EFalse), |
|
58 iUiLayout(aUiLayout), |
|
59 iOwnWndCtrl(ETrue), |
|
60 iOrdinalPos(EOrderNomal) |
|
61 { |
|
62 #ifdef RD_TACTILE_FEEDBACK |
|
63 iReservered1 = reinterpret_cast<TInt>(new CFepUiBaseCtrlExtension(ETouchFeedbackNone)); |
|
64 #endif // RD_TACTILE_FEEDBACK |
|
65 iPenSize.SetSize(1,1); |
|
66 iBorderSize.SetSize(KDefaultFrameWidth,KDefaultFrameWidth); |
|
67 iValidRegion.AddRect(iRect); |
|
68 iClipRegion.AddRect(iRect); |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CFepUiBaseCtrl::CFepUiBaseCtrl |
|
73 // C++ constructor |
|
74 // (other items were commented in a header). |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 CFepUiBaseCtrl::CFepUiBaseCtrl(CCoeControl* aControl, CFepUiLayout* aUiLayout, |
|
78 TBool aOwnership) |
|
79 : iPointerLeft(EFalse), |
|
80 //iRect(aRect), |
|
81 iShadowRect(TRect(0,0,0,0)), |
|
82 iWndControl(aControl), |
|
83 iBorderColor(KRgbBlack), |
|
84 //iControlId(aControlId), |
|
85 iControlType( ECtrlBaseCtrl|ECtrlWndBasedCtrl), |
|
86 iBackgroundCol( KRgbWhite), |
|
87 iMaskBkCol(KOpaqueColor), |
|
88 iPenColor(KRgbBlack), |
|
89 iHiden(EFalse), |
|
90 iPointerDown(EFalse), |
|
91 iReady( EFalse), |
|
92 iIsActive(EFalse), |
|
93 iAllowOverlap(EFalse), |
|
94 iUiLayout(aUiLayout), |
|
95 iOwnWndCtrl(aOwnership) |
|
96 { |
|
97 #ifdef RD_TACTILE_FEEDBACK |
|
98 iReservered1 = reinterpret_cast<TInt>(new CFepUiBaseCtrlExtension(ETouchFeedbackNone)); |
|
99 #endif // RD_TACTILE_FEEDBACK |
|
100 iRect = aControl->Rect(); |
|
101 iControlId = aControl->UniqueHandle(); |
|
102 iValidRegion.AddRect(iRect); |
|
103 iClipRegion.AddRect(iRect); |
|
104 } |
|
105 // --------------------------------------------------------------------------- |
|
106 // CFepUiBaseCtrl::~CFepUiBaseCtrl |
|
107 // C++ destructor |
|
108 // (other items were commented in a header). |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 EXPORT_C CFepUiBaseCtrl::~CFepUiBaseCtrl() |
|
112 { |
|
113 iEventObserverList.Close(); |
|
114 iValidRegion.Close(); |
|
115 iClipRegion.Close(); |
|
116 iClipRegionWithoutLockedArea.Clear(); |
|
117 iClipRegionWithoutLockedArea.Close(); |
|
118 delete iBackgroundBmp; |
|
119 delete iBkMaskBmp; |
|
120 //delete [] iEventData; |
|
121 for(TInt i = 0; i< 2*KShadowBitmapTotalNum; i++) |
|
122 delete iShadowBmp[i]; |
|
123 |
|
124 if(iOwnWndCtrl) |
|
125 delete iWndControl; |
|
126 |
|
127 #ifdef RD_TACTILE_FEEDBACK |
|
128 //de-register the area for tactile feedback |
|
129 //if(aUiLayout) //there must be aUiLayout |
|
130 UiLayout()->DeRegisterFeedbackArea(reinterpret_cast<TInt>(this), Rect()); |
|
131 delete reinterpret_cast<CFepUiBaseCtrlExtension*>(iReservered1); |
|
132 #endif // RD_TACTILE_FEEDBACK |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // CFepUiBaseCtrl::BaseConstructL |
|
137 // Handle UI event |
|
138 // (other items were commented in a header). |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 EXPORT_C void CFepUiBaseCtrl::BaseConstructL() |
|
142 { |
|
143 __ASSERT_DEBUG(iUiLayout,User::Leave(EUiLayoutNotReady)); |
|
144 |
|
145 iRootCtrl = iUiLayout->RootControl(); |
|
146 iLayoutOwner = iUiLayout->LayoutOwner(); |
|
147 |
|
148 //__ASSERT_DEBUG(iLayoutOwner,User::Leave(EUiLayoutOwnerNotReady)); |
|
149 |
|
150 iReady = ETrue; |
|
151 |
|
152 for(TInt i = 0; i< 2*KShadowBitmapTotalNum; i++) |
|
153 iShadowBmp[i] = NULL; |
|
154 __ASSERT_DEBUG(iControlType != ECtrlBaseCtrl, |
|
155 User::Leave(EUiLayoutBadControlType)); |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // CFepUiBaseCtrl::BaseConstructL |
|
160 // Handle UI event |
|
161 // (other items were commented in a header). |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 void CFepUiBaseCtrl::BaseConstructL(CFepUiLayoutRootCtrl* aRoot) |
|
165 { |
|
166 iRootCtrl = aRoot; |
|
167 iLayoutOwner = iUiLayout->LayoutOwner(); |
|
168 |
|
169 __ASSERT_DEBUG(iLayoutOwner,User::Leave(EUiLayoutOwnerNotReady)); |
|
170 iReady = ETrue; |
|
171 |
|
172 for(TInt i = 0; i< 2*KShadowBitmapTotalNum; i++) |
|
173 iShadowBmp[i] = NULL; |
|
174 __ASSERT_DEBUG(iControlType != ECtrlBaseCtrl, |
|
175 User::Leave(EUiLayoutBadControlType)); |
|
176 } |
|
177 |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // Set tactile feedback type |
|
181 // Advanced Tactile feedback REQ417-47932 |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 EXPORT_C void CFepUiBaseCtrl::SetTactileFeedbackType(TInt aTactileType) |
|
185 { |
|
186 #ifdef RD_TACTILE_FEEDBACK |
|
187 reinterpret_cast<CFepUiBaseCtrlExtension*>(iReservered1)->SetTactileFeedbackType(aTactileType); |
|
188 #endif // RD_TACTILE_FEEDBACK |
|
189 } |
|
190 |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // CFepUiBaseCtrl::CapturePointer |
|
194 // Capture or release the pointer |
|
195 // (other items were commented in a header). |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 EXPORT_C CFepUiBaseCtrl* CFepUiBaseCtrl::CapturePointer(TBool aFlag) |
|
199 { |
|
200 return RootControl()->CapturePointer(this,aFlag); |
|
201 } |
|
202 |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // CFepUiBaseCtrl::Clear |
|
206 // Clear the whole control area |
|
207 // (other items were commented in a header). |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 EXPORT_C void CFepUiBaseCtrl::Clear() |
|
211 { |
|
212 if(iShadowRect.Size().iWidth > iRect.Size().iWidth || |
|
213 iShadowRect.Size().iHeight > iRect.Size().iHeight) |
|
214 ClearRect(iShadowRect); |
|
215 else |
|
216 ClearRect(iRect); |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // CFepUiBaseCtrl::DrawBackgroundToDevice |
|
221 // Draw background to a device |
|
222 // (other items were commented in a header). |
|
223 // --------------------------------------------------------------------------- |
|
224 // |
|
225 void CFepUiBaseCtrl::DrawBackgroundToDevice(const TRect aRect,CFbsDevice *aDevice, |
|
226 CFbsBitmap* aBmp, const TRgb& aBrushCol, |
|
227 const TRgb& aPenCol,TBool aBmpStretchFlag) |
|
228 { |
|
229 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
230 gc->Activate( aDevice); |
|
231 if(aBmp) |
|
232 { |
|
233 DrawBitmap(aRect,aBmp,aBmpStretchFlag); |
|
234 } |
|
235 else |
|
236 { |
|
237 gc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
238 gc->SetBrushColor( aBrushCol); |
|
239 gc->SetPenSize(iBorderSize); |
|
240 gc->SetPenColor( aPenCol); |
|
241 gc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
242 gc->DrawRect(aRect); |
|
243 } |
|
244 |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // CFepUiBaseCtrl::DrawBackground |
|
249 // Draw background |
|
250 // (other items were commented in a header). |
|
251 // --------------------------------------------------------------------------- |
|
252 // |
|
253 EXPORT_C void CFepUiBaseCtrl::DrawBackground(TBool aBmpStretchFlag) |
|
254 { |
|
255 DrawBackgroundToDevice(iRect,BitmapDevice(), iBackgroundBmp, iBackgroundCol, |
|
256 iBorderColor, aBmpStretchFlag); |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // CFepUiBaseCtrl::DrawBackground |
|
261 // Draw background |
|
262 // (other items were commented in a header). |
|
263 // --------------------------------------------------------------------------- |
|
264 // |
|
265 EXPORT_C void CFepUiBaseCtrl::DrawBackground(const TRect aRect, TBool /*aBmpStretchFlag*/) |
|
266 { |
|
267 if( !AbleToDraw() ) |
|
268 { |
|
269 return; |
|
270 } |
|
271 TRect rtDraw = Rect(); |
|
272 rtDraw.Intersection( aRect ); |
|
273 if( rtDraw.IsEmpty() ) |
|
274 { |
|
275 return; |
|
276 } |
|
277 |
|
278 //draw mask |
|
279 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
280 gc->Activate( MaskBitmapDevice() ); |
|
281 gc->SetClippingRect( rtDraw ); |
|
282 |
|
283 gc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
284 gc->SetBrushColor( iMaskBkCol); |
|
285 gc->SetPenSize(iBorderSize); |
|
286 gc->SetPenColor( iMaskBkCol); |
|
287 gc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
288 gc->DrawRect(rtDraw); |
|
289 //draw foreground |
|
290 gc->Activate( BitmapDevice() ); |
|
291 gc->SetClippingRect( rtDraw ); |
|
292 |
|
293 if(!BackgroundBmp()) |
|
294 { |
|
295 gc->SetBrushColor( iBackgroundCol ); |
|
296 gc->SetPenColor( iPenColor ); |
|
297 gc->SetPenSize(iBorderSize); |
|
298 gc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
299 gc->DrawRect( Rect() ); |
|
300 } |
|
301 else |
|
302 { |
|
303 // ----- draw bitmaps ----- |
|
304 if(BkMaskBmp()) |
|
305 { |
|
306 TRect bmpRect(TPoint(0,0),BkMaskBmp()->SizeInPixels()); |
|
307 gc->DrawBitmapMasked( Rect(), BackgroundBmp(),bmpRect,BkMaskBmp(),EFalse); |
|
308 } |
|
309 else |
|
310 { |
|
311 gc->DrawBitmap( Rect(),BackgroundBmp()); |
|
312 } |
|
313 } |
|
314 } |
|
315 |
|
316 // --------------------------------------------------------------------------- |
|
317 // CFepUiBaseCtrl::DrawMaskBackground |
|
318 // Draw mask background |
|
319 // (other items were commented in a header). |
|
320 // --------------------------------------------------------------------------- |
|
321 // |
|
322 EXPORT_C void CFepUiBaseCtrl::DrawMaskBackground(TBool aBmpStretchFlag) |
|
323 { |
|
324 DrawBackgroundToDevice(iRect,MaskBitmapDevice(), iBkMaskBmp, iMaskBkCol, |
|
325 iBorderColor,aBmpStretchFlag); |
|
326 } |
|
327 |
|
328 // --------------------------------------------------------------------------- |
|
329 // CFepUiBaseCtrl::DrawOpaqueMaskBackground |
|
330 // Draw opaque mask background |
|
331 // (other items were commented in a header). |
|
332 // --------------------------------------------------------------------------- |
|
333 // |
|
334 EXPORT_C void CFepUiBaseCtrl::DrawOpaqueMaskBackground(TBool aBmpStretchFlag) |
|
335 { |
|
336 const TRgb KOpaqueMask = TRgb(KOpaqueColor); |
|
337 DrawBackgroundToDevice(iRect,MaskBitmapDevice(), iBkMaskBmp, KOpaqueMask, |
|
338 KOpaqueMask,aBmpStretchFlag); |
|
339 } |
|
340 |
|
341 // --------------------------------------------------------------------------- |
|
342 // CFepUiBaseCtrl::DrawOpaqueMaskBackground |
|
343 // Draw opaque mask background |
|
344 // (other items were commented in a header). |
|
345 // --------------------------------------------------------------------------- |
|
346 // |
|
347 EXPORT_C void CFepUiBaseCtrl::DrawOpaqueMaskBackground(const TRect aRect, TBool aBmpStretchFlag) |
|
348 { |
|
349 const TRgb KOpaqueMask = TRgb(KOpaqueColor); |
|
350 DrawBackgroundToDevice(aRect, MaskBitmapDevice(), iBkMaskBmp, |
|
351 KOpaqueMask, KOpaqueMask, aBmpStretchFlag); |
|
352 } |
|
353 |
|
354 // --------------------------------------------------------------------------- |
|
355 // CFepUiBaseCtrl::DrawTransparentMaskBackground |
|
356 // Draw transparent mask background |
|
357 // (other items were commented in a header). |
|
358 // --------------------------------------------------------------------------- |
|
359 // |
|
360 EXPORT_C void CFepUiBaseCtrl::DrawTransparentMaskBackground(const TRect& aRect, |
|
361 TBool aBmpStretchFlag) |
|
362 { |
|
363 const TRgb KOpaqueMask = TRgb(KTransparentColor); |
|
364 DrawBackgroundToDevice(aRect, MaskBitmapDevice(), iBkMaskBmp, KTransparentColor, |
|
365 KTransparentColor, aBmpStretchFlag); |
|
366 } |
|
367 |
|
368 // --------------------------------------------------------------------------- |
|
369 // CFepUiBaseCtrl::ClearRect |
|
370 // Clear a rect in control |
|
371 // (other items were commented in a header). |
|
372 // --------------------------------------------------------------------------- |
|
373 // |
|
374 EXPORT_C void CFepUiBaseCtrl::ClearRect(const TRect& aRect) |
|
375 { |
|
376 if(!AbleToDraw()) |
|
377 return; |
|
378 TRect r = iRect; |
|
379 r.BoundingRect(iShadowRect); |
|
380 r.Intersection(aRect); |
|
381 //only clears the rect belongs to this control |
|
382 if(!r.IsEmpty()) |
|
383 { |
|
384 DrawBackgroundToDevice(r,BitmapDevice(),NULL,KRgbWhite,KRgbWhite,EFalse); |
|
385 DrawTransparentMaskBackground(r); |
|
386 return; |
|
387 } |
|
388 } |
|
389 |
|
390 // --------------------------------------------------------------------------- |
|
391 // CFepUiBaseCtrl::BringToTop |
|
392 // Show the control and brings to top most in current control group |
|
393 // (other items were commented in a header). |
|
394 // --------------------------------------------------------------------------- |
|
395 // |
|
396 EXPORT_C void CFepUiBaseCtrl::BringToTop() |
|
397 { |
|
398 CControlGroup* grp = RootControl(); |
|
399 if(ParentCtrl()) |
|
400 grp = static_cast<CControlGroup*>(ParentCtrl()); |
|
401 grp->BringToTopInGroup(this); |
|
402 } |
|
403 |
|
404 // --------------------------------------------------------------------------- |
|
405 // CFepUiBaseCtrl::BringToBack |
|
406 // Bring the control to the back |
|
407 // --------------------------------------------------------------------------- |
|
408 // |
|
409 EXPORT_C void CFepUiBaseCtrl::BringToBack() |
|
410 { |
|
411 CControlGroup* grp = RootControl(); |
|
412 if(ParentCtrl()) |
|
413 grp = static_cast<CControlGroup*>(ParentCtrl()); |
|
414 grp->BringToBackInGroup(this); |
|
415 } |
|
416 // --------------------------------------------------------------------------- |
|
417 // CFepUiBaseCtrl::Hide |
|
418 // Hide the control |
|
419 // (other items were commented in a header). |
|
420 // --------------------------------------------------------------------------- |
|
421 // |
|
422 EXPORT_C void CFepUiBaseCtrl::Hide(TBool aFlag) |
|
423 { |
|
424 if(iHiden == aFlag) |
|
425 return; |
|
426 |
|
427 iHiden = aFlag; |
|
428 |
|
429 if(!iReady) |
|
430 return; |
|
431 |
|
432 if(iHiden) |
|
433 { |
|
434 TBool needClear; |
|
435 if(!iParentCtrl) |
|
436 { |
|
437 needClear = ETrue; |
|
438 } |
|
439 else |
|
440 { |
|
441 //no need to clear again if group is alreay hiden. There won't be the case |
|
442 // that a group is hiden but sub control is shown. |
|
443 needClear = iParentCtrl->Hiden() ? EFalse : ETrue; |
|
444 } |
|
445 if(needClear) |
|
446 { |
|
447 /*Hide a control should remove its old image, however in fact, the clear sounds reduntant, as each |
|
448 control inside one group, and the background will be redrawn when ReDrawRect() is called, so in |
|
449 order to ensure performance, comments it now*/ |
|
450 /*iHiden = EFalse; |
|
451 Clear(); |
|
452 iHiden = ETrue; |
|
453 */ |
|
454 //must redraw the cleared rect as it may clear overlapped control also. |
|
455 iUiLayout->RootControl()->ReDrawRect(Rect()); |
|
456 UpdateArea(iRect, EFalse); |
|
457 } |
|
458 } |
|
459 else |
|
460 { |
|
461 if(!iParentCtrl || !iParentCtrl->Hiden()) |
|
462 { |
|
463 Draw(); |
|
464 UpdateArea(iRect,EFalse); |
|
465 } |
|
466 } |
|
467 |
|
468 //rect in layout might be changed, update it. |
|
469 //RootControl()->UpdateValidRegion(this,aFlag); |
|
470 if(iParentCtrl) |
|
471 iParentCtrl->UpdateValidRegion(this,aFlag); |
|
472 |
|
473 //report size chage event |
|
474 ReportEvent(EEventSizeChanged); |
|
475 |
|
476 |
|
477 #ifdef RD_TACTILE_FEEDBACK |
|
478 if(IsKindOfControl(ECtrlTactileFeedback)) |
|
479 { |
|
480 if(aFlag) |
|
481 UiLayout()->DeRegisterFeedbackArea(reinterpret_cast<TInt>(this),Rect()); |
|
482 else if (iReady) |
|
483 UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(this),Rect(),TactileFeedbackType()); |
|
484 } |
|
485 #endif |
|
486 |
|
487 } |
|
488 |
|
489 // --------------------------------------------------------------------------- |
|
490 // CFepUiBaseCtrl::SetBackgroundBitmapL |
|
491 // Set back ground bitmap |
|
492 // (other items were commented in a header). |
|
493 // --------------------------------------------------------------------------- |
|
494 // |
|
495 EXPORT_C void CFepUiBaseCtrl::SetBackgroundBitmapL(CFbsBitmap* aBmp) |
|
496 { |
|
497 if(!aBmp) |
|
498 return; |
|
499 /* |
|
500 if(IsKindOfControl(ECtrlButton)) |
|
501 { |
|
502 //special handling to button as button does not use iBackgroundBmp directly. |
|
503 return; |
|
504 } |
|
505 */ |
|
506 delete iBackgroundBmp; |
|
507 iBackgroundBmp = aBmp; |
|
508 } |
|
509 |
|
510 // --------------------------------------------------------------------------- |
|
511 // CFepUiBaseCtrl::SetBackgroundMaskBitmapL |
|
512 // Set back ground mask bitmap |
|
513 // (other items were commented in a header). |
|
514 // --------------------------------------------------------------------------- |
|
515 // |
|
516 EXPORT_C void CFepUiBaseCtrl::SetBackgroundMaskBitmapL(CFbsBitmap* aBmp) |
|
517 { |
|
518 if(!aBmp) |
|
519 return; |
|
520 /* |
|
521 if(IsKindOfControl(ECtrlButton)) |
|
522 { |
|
523 //special handling to button as button does not use iBackgroundBmp directly. |
|
524 return; |
|
525 }*/ |
|
526 delete iBkMaskBmp; |
|
527 iBkMaskBmp = aBmp; |
|
528 } |
|
529 |
|
530 // --------------------------------------------------------------------------- |
|
531 // CFepUiBaseCtrl::Contains |
|
532 // Check whether the point is in control region |
|
533 // (other items were commented in a header). |
|
534 // --------------------------------------------------------------------------- |
|
535 // |
|
536 EXPORT_C TBool CFepUiBaseCtrl::Contains(const TPoint& aPt) |
|
537 { |
|
538 return iRect.Contains(aPt); |
|
539 //return iValidRegion.Contains(aPt); |
|
540 } |
|
541 |
|
542 // --------------------------------------------------------------------------- |
|
543 // CFepUiBaseCtrl::SetRect |
|
544 // Set the control rect |
|
545 // (other items were commented in a header). |
|
546 // --------------------------------------------------------------------------- |
|
547 // |
|
548 EXPORT_C void CFepUiBaseCtrl::SetRect(const TRect& aRect) |
|
549 { |
|
550 if(iRect == aRect) |
|
551 return; |
|
552 TRect oldRect = iRect; |
|
553 iRect = aRect; |
|
554 iValidRegion.Clear(); |
|
555 iClipRegion.Clear(); |
|
556 iValidRegion.AddRect(iRect); |
|
557 iClipRegion.AddRect(iRect); |
|
558 if(iParentCtrl && iParentCtrl->IsKindOfControl(ECtrlControlGroup)) |
|
559 { |
|
560 iParentCtrl->UpdateValidRegion(this,EFalse); |
|
561 //iParentCtrl->UpdateClipRegion(this); |
|
562 } |
|
563 |
|
564 if(iWndControl) |
|
565 iWndControl->SetRect(iRect); |
|
566 ReportEvent(EEventSizeChanged); |
|
567 |
|
568 #ifdef RD_TACTILE_FEEDBACK |
|
569 if(IsKindOfControl(ECtrlTactileFeedback) && !Hiden()) |
|
570 { |
|
571 UiLayout()->ChangeFeedbackArea(reinterpret_cast<TInt>(this),iRect,oldRect); |
|
572 } |
|
573 #endif |
|
574 } |
|
575 |
|
576 // --------------------------------------------------------------------------- |
|
577 // CFepUiBaseCtrl::SetShadowRect |
|
578 // Set the control shadow rect |
|
579 // --------------------------------------------------------------------------- |
|
580 // |
|
581 EXPORT_C void CFepUiBaseCtrl::SetShadowRect(const TRect& aRect) |
|
582 { |
|
583 iShadowRect = aRect; |
|
584 //calculate the shadow area rect |
|
585 TRect shadowAreaRect; |
|
586 if(!iRect.IsEmpty()) |
|
587 { |
|
588 for (TInt i = 0; i < KShadowBitmapTotalNum; i ++) |
|
589 { |
|
590 switch (i) |
|
591 { |
|
592 case KShadowBmpTl: |
|
593 iShadowAreaRect[i] = TRect( iShadowRect.iTl, iRect.iTl ); |
|
594 break; |
|
595 case KShadowBmpTr: |
|
596 iShadowAreaRect[i] = TRect( iRect.iBr.iX, iShadowRect.iTl.iY, |
|
597 iShadowRect.iBr.iX, iRect.iTl.iY ); |
|
598 break; |
|
599 case KShadowBmpBl: |
|
600 iShadowAreaRect[i] = TRect( iShadowRect.iTl.iX, iRect.iBr.iY, |
|
601 iRect.iTl.iX, iShadowRect.iBr.iY ); |
|
602 break; |
|
603 case KShadowBmpBr: |
|
604 iShadowAreaRect[i] = TRect( iRect.iBr, iShadowRect.iBr ); |
|
605 break; |
|
606 case KShadowBmpTm: |
|
607 iShadowAreaRect[i] = TRect( iRect.iTl.iX, iShadowRect.iTl.iY, |
|
608 iRect.iBr.iX, iRect.iTl.iY ); |
|
609 break; |
|
610 case KShadowBmpBm: |
|
611 iShadowAreaRect[i] = TRect( iRect.iTl.iX, iRect.iBr.iY, |
|
612 iRect.iBr.iX, iShadowRect.iBr.iY ); |
|
613 break; |
|
614 case KShadowBmpLm: |
|
615 iShadowAreaRect[i] = TRect( iShadowRect.iTl.iX, iRect.iTl.iY, |
|
616 iRect.iTl.iX, iRect.iBr.iY ); |
|
617 break; |
|
618 case KShadowBmpRm: |
|
619 iShadowAreaRect[i] = TRect( iRect.iBr.iX, iRect.iTl.iY, |
|
620 iShadowRect.iBr.iX, iRect.iBr.iY ); |
|
621 break; |
|
622 default: |
|
623 break; |
|
624 } |
|
625 } |
|
626 } |
|
627 else |
|
628 { |
|
629 //empty the shadow area since we can't calculate it right now. |
|
630 for (TInt i = 0; i < KShadowBitmapTotalNum; i ++) |
|
631 { |
|
632 iShadowAreaRect[i].SetRect(0,0,0,0); |
|
633 } |
|
634 } |
|
635 |
|
636 RootControl()->UpdateValidRegion(this,EFalse); |
|
637 if(iShadowRect.Size().iWidth > UiLayout()->Rect().Size().iWidth || |
|
638 iShadowRect.Size().iHeight > UiLayout()->Rect().Size().iHeight) |
|
639 { |
|
640 UiLayout()->LayoutOwner()->LayoutSizeChanged(iShadowRect.Size()); |
|
641 } |
|
642 } |
|
643 // CFepUiBaseCtrl::AddEventObserver |
|
644 // Add a event observer |
|
645 // (other items were commented in a header). |
|
646 // --------------------------------------------------------------------------- |
|
647 // |
|
648 EXPORT_C void CFepUiBaseCtrl::AddEventObserver(MEventObserver* aObserver) |
|
649 { |
|
650 if(!aObserver) |
|
651 return; |
|
652 //add only when it's not an observer |
|
653 if(KErrNotFound == iEventObserverList.Find(aObserver)) |
|
654 iEventObserverList.Append(aObserver); |
|
655 } |
|
656 |
|
657 // --------------------------------------------------------------------------- |
|
658 // CFepUiBaseCtrl::RemoveEventObserver |
|
659 // remove a event observer |
|
660 // (other items were commented in a header). |
|
661 // --------------------------------------------------------------------------- |
|
662 // |
|
663 EXPORT_C void CFepUiBaseCtrl::RemoveEventObserver(MEventObserver* aObserver) |
|
664 { |
|
665 TInt index = iEventObserverList.Find(aObserver); |
|
666 if(KErrNotFound != index) |
|
667 iEventObserverList.Remove(index); |
|
668 } |
|
669 |
|
670 // --------------------------------------------------------------------------- |
|
671 // CFepUiBaseCtrl::ReportEvent |
|
672 // Report event to observer |
|
673 // (other items were commented in a header). |
|
674 // --------------------------------------------------------------------------- |
|
675 // |
|
676 EXPORT_C void CFepUiBaseCtrl::ReportEvent(TInt aEventType, const TDesC& aEventData) |
|
677 { |
|
678 for(TInt i = 0; i < iEventObserverList.Count(); i++) |
|
679 { |
|
680 iEventObserverList[i]->HandleControlEvent(aEventType,this,aEventData); |
|
681 } |
|
682 } |
|
683 |
|
684 TBool CFepUiBaseCtrl::CompareOrderInSameGroup(CFepUiBaseCtrl* aCtrl) |
|
685 { |
|
686 return IsOnTopOf(aCtrl); |
|
687 } |
|
688 |
|
689 TBool CFepUiBaseCtrl::CompareOrder(CFepUiBaseCtrl* aCtrl) |
|
690 { |
|
691 return IsOnTopOf(aCtrl); |
|
692 } |
|
693 |
|
694 TBool CFepUiBaseCtrl::IsOnTopOf(CFepUiBaseCtrl* aCtrl) |
|
695 { |
|
696 __ASSERT_DEBUG(aCtrl,EUiNullParam); |
|
697 |
|
698 return OrderPos() < aCtrl->OrderPos(); |
|
699 } |
|
700 |
|
701 |
|
702 TBool CFepUiBaseCtrl::Overlapped(CFepUiBaseCtrl* aCtrl) |
|
703 { |
|
704 return iRect.Intersects(aCtrl->Rect()); |
|
705 } |
|
706 // --------------------------------------------------------------------------- |
|
707 // CFepUiBaseCtrl::UpdateValidRegion |
|
708 // Update control's valid region when other control show or hide. |
|
709 // (other items were commented in a header). |
|
710 // --------------------------------------------------------------------------- |
|
711 // |
|
712 EXPORT_C void CFepUiBaseCtrl::UpdateValidRegion(CFepUiBaseCtrl* /*aCtrl*/,TBool /*aRemoveFlag*/) |
|
713 { |
|
714 if(!iUpdateFlagEnabled) |
|
715 return; |
|
716 iValidRegion.Clear(); |
|
717 iValidRegion.AddRect(iRect); |
|
718 return; |
|
719 } |
|
720 |
|
721 // --------------------------------------------------------------------------- |
|
722 // CFepUiBaseCtrl::Move |
|
723 // Move control and component's rect |
|
724 // (other items were commented in a header). |
|
725 // --------------------------------------------------------------------------- |
|
726 // |
|
727 EXPORT_C void CFepUiBaseCtrl::Move(const TPoint& aOffset) |
|
728 { |
|
729 TRect oldRect = iRect; |
|
730 iShadowRect.Move(aOffset); |
|
731 iRect.Move(aOffset); |
|
732 if(iWndControl) |
|
733 iWndControl->SetRect(iRect); |
|
734 iValidRegion.Clear(); |
|
735 iValidRegion.AddRect(iRect); |
|
736 if(iParentCtrl && iUpdateFlagEnabled) |
|
737 iParentCtrl->UpdateValidRegion(this,EFalse); |
|
738 for (TInt i = 0; i < KShadowBitmapTotalNum; i ++) |
|
739 { |
|
740 iShadowAreaRect[i].Move(aOffset); |
|
741 } |
|
742 |
|
743 #ifdef RD_TACTILE_FEEDBACK |
|
744 if(IsKindOfControl(ECtrlTactileFeedback) && !Hiden()) |
|
745 { |
|
746 UiLayout()->ChangeFeedbackArea(reinterpret_cast<TInt>(this),iRect,oldRect); |
|
747 } |
|
748 #endif |
|
749 } |
|
750 |
|
751 // --------------------------------------------------------------------------- |
|
752 // CFepUiBaseCtrl::SetActive |
|
753 // Set control active |
|
754 // (other items were commented in a header). |
|
755 // --------------------------------------------------------------------------- |
|
756 // |
|
757 EXPORT_C void CFepUiBaseCtrl::SetActive(TBool aFlag) |
|
758 { |
|
759 iIsActive = aFlag; |
|
760 } |
|
761 |
|
762 // --------------------------------------------------------------------------- |
|
763 // CFepUiBaseCtrl::HandlePointerDownEventL |
|
764 // Handle pointer down event |
|
765 // (other items were commented in a header). |
|
766 // --------------------------------------------------------------------------- |
|
767 // |
|
768 EXPORT_C CFepUiBaseCtrl* CFepUiBaseCtrl::HandlePointerDownEventL(const TPoint& aPoint) |
|
769 { |
|
770 iPointerDown = ETrue; |
|
771 if(iWndControl) |
|
772 { |
|
773 TPointerEvent event; |
|
774 event.iType = TPointerEvent::EButton1Down; |
|
775 event.iPosition = aPoint; |
|
776 event.iModifiers = 0; |
|
777 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
778 gc->Activate( BitmapDevice() ); |
|
779 |
|
780 iWndControl->HandlePointerEventL(event); |
|
781 } |
|
782 return this; |
|
783 } |
|
784 |
|
785 // --------------------------------------------------------------------------- |
|
786 // CFepUiBaseCtrl::HandlePointerUpEventL |
|
787 // Handle pointer up event |
|
788 // (other items were commented in a header). |
|
789 // --------------------------------------------------------------------------- |
|
790 // |
|
791 EXPORT_C CFepUiBaseCtrl* CFepUiBaseCtrl::HandlePointerUpEventL( |
|
792 const TPoint& aPoint) |
|
793 { |
|
794 iPointerDown = EFalse; |
|
795 if(iWndControl) |
|
796 { |
|
797 TPointerEvent event; |
|
798 event.iType = TPointerEvent::EButton1Up; |
|
799 event.iPosition = aPoint; |
|
800 event.iModifiers = 0; |
|
801 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
802 gc->Activate( BitmapDevice() ); |
|
803 |
|
804 iWndControl->HandlePointerEventL(event); |
|
805 Draw(); |
|
806 } |
|
807 |
|
808 return this; |
|
809 } |
|
810 |
|
811 // --------------------------------------------------------------------------- |
|
812 // CFepUiBaseCtrl::HandlePointerMoveEventL |
|
813 // Handle pointer move event |
|
814 // (other items were commented in a header). |
|
815 // --------------------------------------------------------------------------- |
|
816 // |
|
817 EXPORT_C CFepUiBaseCtrl* CFepUiBaseCtrl::HandlePointerMoveEventL( |
|
818 const TPoint& aPoint) |
|
819 { |
|
820 //do nothing if not a CCoeControl |
|
821 if(iWndControl) |
|
822 { |
|
823 TPointerEvent event; |
|
824 if(iPointerDown) |
|
825 event.iType = TPointerEvent::EDrag; //drag event |
|
826 else |
|
827 event.iType = TPointerEvent::EMove; //move event |
|
828 event.iPosition = aPoint; |
|
829 event.iModifiers = 0; |
|
830 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
831 gc->Activate( BitmapDevice() ); |
|
832 |
|
833 iWndControl->HandlePointerEventL(event); |
|
834 Draw(); |
|
835 } |
|
836 |
|
837 return this; |
|
838 } |
|
839 |
|
840 // --------------------------------------------------------------------------- |
|
841 // CFepUiBaseCtrl::CancelPointerDownL |
|
842 // Cancel pointer down event |
|
843 // (other items were commented in a header). |
|
844 // --------------------------------------------------------------------------- |
|
845 // |
|
846 EXPORT_C void CFepUiBaseCtrl::CancelPointerDownL() |
|
847 { |
|
848 if (PointerDown()) |
|
849 { |
|
850 iPointerDown = EFalse; |
|
851 iPointerLeft = EFalse; |
|
852 //HandlePointerLeave(TPoint(0, 0)); |
|
853 ReportEvent(EEventButtonDownCanceled); |
|
854 Draw(); |
|
855 UpdateArea(Rect(), EFalse); |
|
856 } |
|
857 } |
|
858 |
|
859 // --------------------------------------------------------------------------- |
|
860 // CFepUiBaseCtrl::HandlePositionChange |
|
861 // Draw control's frame when control moving |
|
862 // (other items were commented in a header). |
|
863 // --------------------------------------------------------------------------- |
|
864 // |
|
865 EXPORT_C TBool CFepUiBaseCtrl::HandlePositionChange(const TPoint& aOffset) |
|
866 { |
|
867 TRect rect = iRect; |
|
868 |
|
869 Move(aOffset); |
|
870 rect.BoundingRect(iRect); |
|
871 Draw(); |
|
872 |
|
873 UpdateArea(rect,EFalse); |
|
874 |
|
875 return EFalse ;//let others handle the event |
|
876 } |
|
877 |
|
878 // ----------------------------------------------------------------------------- |
|
879 // CFepUiBaseCtrl::MovingArea |
|
880 // Return observer's moving area |
|
881 // ----------------------------------------------------------------------------- |
|
882 // |
|
883 EXPORT_C const TRect& CFepUiBaseCtrl::MovingArea() |
|
884 { |
|
885 return iRect; |
|
886 } |
|
887 |
|
888 // ----------------------------------------------------------------------------- |
|
889 // CFepUiBaseCtrl::IsFepBaseControl |
|
890 // ----------------------------------------------------------------------------- |
|
891 // |
|
892 EXPORT_C TBool CFepUiBaseCtrl::IsFepBaseControl() |
|
893 { |
|
894 return ETrue; |
|
895 } |
|
896 |
|
897 // --------------------------------------------------------------------------- |
|
898 // CFepUiBaseCtrl::DrawBitmap |
|
899 // Draw bitmap |
|
900 // (other items were commented in a header). |
|
901 // --------------------------------------------------------------------------- |
|
902 // |
|
903 EXPORT_C void CFepUiBaseCtrl::DrawBitmap(const CFbsBitmap* aBitmap,TBool aStretchFlag) |
|
904 { |
|
905 TRect bmpRect(TPoint(0,0),aBitmap->SizeInPixels()); |
|
906 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
907 if(aStretchFlag && Rect() != bmpRect) |
|
908 { |
|
909 gc->DrawBitmap(Rect(),aBitmap); |
|
910 } |
|
911 else |
|
912 { |
|
913 gc->BitBlt(Rect().iTl,aBitmap,bmpRect); |
|
914 } |
|
915 } |
|
916 |
|
917 // --------------------------------------------------------------------------- |
|
918 // CFepUiBaseCtrl::DrawBitmap |
|
919 // Draw bitmap |
|
920 // (other items were commented in a header). |
|
921 // --------------------------------------------------------------------------- |
|
922 // |
|
923 EXPORT_C void CFepUiBaseCtrl::DrawBitmap(const TRect aRect,const CFbsBitmap* aBitmap, |
|
924 TBool aStretchFlag) |
|
925 { |
|
926 TRect bmpRect(TPoint(0,0),aBitmap->SizeInPixels()); |
|
927 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
928 if(aStretchFlag && aRect != bmpRect) |
|
929 { |
|
930 gc->DrawBitmap(aRect,aBitmap); |
|
931 } |
|
932 else |
|
933 { |
|
934 gc->BitBlt(aRect.iTl,aBitmap,bmpRect); |
|
935 } |
|
936 } |
|
937 |
|
938 // --------------------------------------------------------------------------- |
|
939 // CFepUiBaseCtrl::UpdateArea |
|
940 // Update layout area |
|
941 // (other items were commented in a header). |
|
942 // --------------------------------------------------------------------------- |
|
943 // |
|
944 EXPORT_C void CFepUiBaseCtrl::UpdateArea(const TRect& aRect,TBool aUpdateFlag) |
|
945 { |
|
946 if( !Hiden() && ParentCtrl() && (this != UiLayout()->LockareaOwner()) ) |
|
947 static_cast<CControlGroup*>(ParentCtrl())->UpdateAreaInGrp(this,aRect,aUpdateFlag); |
|
948 else |
|
949 { |
|
950 iUiLayout->UpdateArea(this,aRect,aUpdateFlag); |
|
951 } |
|
952 } |
|
953 |
|
954 |
|
955 // --------------------------------------------------------------------------- |
|
956 // CFepUiBaseCtrl::UpdateAreaImmed |
|
957 // Update layout area immediately |
|
958 // (other items were commented in a header). |
|
959 // --------------------------------------------------------------------------- |
|
960 // |
|
961 EXPORT_C void CFepUiBaseCtrl::UpdateAreaImmed(const TRect& aRect,TBool aUpdateFlag) |
|
962 { |
|
963 if( !Hiden() && ParentCtrl() && (this != UiLayout()->LockareaOwner()) ) |
|
964 { |
|
965 static_cast<CControlGroup*>(ParentCtrl())->UpdateAreaInGrpImmed(this,aRect,aUpdateFlag); |
|
966 } |
|
967 else |
|
968 { |
|
969 iUiLayout->UpdateArea(this,aRect,aUpdateFlag,ETrue); |
|
970 } |
|
971 } |
|
972 // --------------------------------------------------------------------------- |
|
973 // CFepUiBaseCtrl::RequireRegionUpdateL |
|
974 // Register the control to be region change awared |
|
975 // (other items were commented in a header). |
|
976 // --------------------------------------------------------------------------- |
|
977 // |
|
978 EXPORT_C void CFepUiBaseCtrl::RequireRegionUpdateL(TBool aRequiredFlag) |
|
979 { |
|
980 iRootCtrl->RequireRegionUpdateL(this,aRequiredFlag); |
|
981 } |
|
982 |
|
983 |
|
984 // --------------------------------------------------------------------------- |
|
985 // CFepUiBaseCtrl::HandlePointerLeave |
|
986 // Handle pointer leave event |
|
987 // --------------------------------------------------------------------------- |
|
988 // |
|
989 EXPORT_C void CFepUiBaseCtrl::HandlePointerLeave(const TPoint& /*aPt*/) |
|
990 { |
|
991 iPointerDown = EFalse; |
|
992 iPointerLeft = ETrue; |
|
993 //report event |
|
994 ReportEvent(EEventPointerLeftControl); |
|
995 Draw(); |
|
996 } |
|
997 |
|
998 // --------------------------------------------------------------------------- |
|
999 // CFepUiBaseCtrl::HandlePointerEnter |
|
1000 // Handle pointer enter event |
|
1001 // --------------------------------------------------------------------------- |
|
1002 // |
|
1003 EXPORT_C void CFepUiBaseCtrl::HandlePointerEnter(const TPoint& aPt) |
|
1004 { |
|
1005 iPointerDown = ETrue; |
|
1006 iPointerLeft = EFalse; |
|
1007 TRAP_IGNORE(HandlePointerMoveEventL(aPt)); |
|
1008 //report event |
|
1009 ReportEvent(EEventPointerEnterControl); |
|
1010 } |
|
1011 |
|
1012 // --------------------------------------------------------------------------- |
|
1013 // CFepUiBaseCtrl::ReDrawRect |
|
1014 // Re draw control rect |
|
1015 // --------------------------------------------------------------------------- |
|
1016 // |
|
1017 EXPORT_C void CFepUiBaseCtrl::ReDrawRect(const TRect& /*aRect*/) |
|
1018 { |
|
1019 Draw(); |
|
1020 } |
|
1021 |
|
1022 |
|
1023 |
|
1024 // --------------------------------------------------------------------------- |
|
1025 // CFepUiBaseCtrl::DrawShadowBitmap |
|
1026 // Draw shadow |
|
1027 // --------------------------------------------------------------------------- |
|
1028 |
|
1029 void CFepUiBaseCtrl::DrawShadowBitmap(const TRect& aRect,TInt aIndex) |
|
1030 { |
|
1031 CFbsBitmap* bmp = iShadowBmp[aIndex]; |
|
1032 |
|
1033 if(!bmp) |
|
1034 return; |
|
1035 |
|
1036 //shadow bitmap is always opaque |
|
1037 //mask bitmaps |
|
1038 CFbsBitmap* maskbmp = iShadowBmp[aIndex + KShadowBitmapTotalNum]; |
|
1039 |
|
1040 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
1041 if (maskbmp) |
|
1042 { |
|
1043 gc->Activate( MaskBitmapDevice() ); |
|
1044 |
|
1045 //clear the rect |
|
1046 gc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1047 gc->SetBrushColor( TRgb(KTransparentColor) );//transparency |
|
1048 gc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1049 gc->DrawRect(aRect); |
|
1050 |
|
1051 gc->DrawRect( aRect ); |
|
1052 if ((aRect.Size() != bmp->SizeInPixels()) || |
|
1053 (aRect.Size() != maskbmp->SizeInPixels())) |
|
1054 { |
|
1055 AknIconUtils::SetSize(bmp, aRect.Size(), EAspectRatioNotPreserved); |
|
1056 AknIconUtils::SetSize(maskbmp, aRect.Size(), EAspectRatioNotPreserved); |
|
1057 } |
|
1058 gc->DrawBitmap(aRect, maskbmp, maskbmp->SizeInPixels()); |
|
1059 |
|
1060 gc->Activate(BitmapDevice()); |
|
1061 |
|
1062 gc->DrawBitmap(aRect, bmp, bmp->SizeInPixels()); |
|
1063 } |
|
1064 |
|
1065 else |
|
1066 { |
|
1067 gc->Activate( MaskBitmapDevice() ); |
|
1068 |
|
1069 //clear the rect |
|
1070 gc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1071 gc->SetBrushColor( TRgb(KOpaqueColor) );//non transparency |
|
1072 gc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1073 gc->DrawRect(aRect); |
|
1074 if (aRect.Size() != bmp->SizeInPixels()) |
|
1075 { |
|
1076 AknIconUtils::SetSize(bmp, aRect.Size(), EAspectRatioNotPreserved); |
|
1077 } |
|
1078 |
|
1079 gc->Activate(BitmapDevice()); |
|
1080 gc->DrawBitmap(aRect, bmp, bmp->SizeInPixels()); |
|
1081 } |
|
1082 |
|
1083 } |
|
1084 |
|
1085 // --------------------------------------------------------------------------- |
|
1086 // CFepUiBaseCtrl::DrawShadow |
|
1087 // Draw shadow |
|
1088 // --------------------------------------------------------------------------- |
|
1089 // |
|
1090 EXPORT_C void CFepUiBaseCtrl::DrawShadow() |
|
1091 { |
|
1092 for (TInt i = 0; i < KShadowBitmapTotalNum; i ++) |
|
1093 { |
|
1094 DrawShadowBitmap(iShadowAreaRect[i], i); |
|
1095 } |
|
1096 } |
|
1097 |
|
1098 // --------------------------------------------------------------------------- |
|
1099 // CFepUiBaseCtrl::OnDeActivate |
|
1100 // Response to layout de activation event |
|
1101 // (other items were commented in a header). |
|
1102 // --------------------------------------------------------------------------- |
|
1103 // |
|
1104 EXPORT_C void CFepUiBaseCtrl::OnDeActivate() |
|
1105 { |
|
1106 iReady= EFalse; |
|
1107 if(iPointerDown) |
|
1108 { |
|
1109 TRAP_IGNORE(CancelPointerDownL()); |
|
1110 iPointerDown = EFalse; |
|
1111 } |
|
1112 iPointerLeft = EFalse; |
|
1113 if(iWndControl && !Hiden()) |
|
1114 iWndControl->MakeVisible(EFalse); |
|
1115 } |
|
1116 |
|
1117 // --------------------------------------------------------------------------- |
|
1118 // CFepUiBaseCtrl::OnActivate |
|
1119 // Response to layout activation event |
|
1120 // (other items were commented in a header). |
|
1121 // --------------------------------------------------------------------------- |
|
1122 // |
|
1123 EXPORT_C void CFepUiBaseCtrl::OnActivate() |
|
1124 { |
|
1125 //do nothing |
|
1126 iReady= ETrue; |
|
1127 if(iWndControl && !Hiden()) |
|
1128 iWndControl->MakeVisible(ETrue); |
|
1129 } |
|
1130 |
|
1131 // --------------------------------------------------------------------------- |
|
1132 // CFepUiBaseCtrl::OnLayoutDraggingStart |
|
1133 // Response to layout dragging start event |
|
1134 // (other items were commented in a header). |
|
1135 // --------------------------------------------------------------------------- |
|
1136 // |
|
1137 EXPORT_C void CFepUiBaseCtrl::OnLayoutDraggingStart() |
|
1138 { |
|
1139 //do nothing |
|
1140 } |
|
1141 |
|
1142 // --------------------------------------------------------------------------- |
|
1143 // CFepUiBaseCtrl::OnLayoutDraggingEnd |
|
1144 // Response to layout dragging end event |
|
1145 // (other items were commented in a header). |
|
1146 // --------------------------------------------------------------------------- |
|
1147 // |
|
1148 EXPORT_C void CFepUiBaseCtrl::OnLayoutDraggingEnd() |
|
1149 { |
|
1150 //do nothing |
|
1151 } |
|
1152 |
|
1153 // --------------------------------------------------------------------------- |
|
1154 // Set shadow area rect |
|
1155 // --------------------------------------------------------------------------- |
|
1156 // |
|
1157 EXPORT_C void CFepUiBaseCtrl::SetShadowAreaRect(const TRect& aRect, |
|
1158 TShadowBitmapIndex aIndex) |
|
1159 { |
|
1160 iShadowAreaRect[aIndex] = aRect; |
|
1161 if(iShadowRect.IsEmpty()) |
|
1162 iShadowRect = aRect; |
|
1163 else |
|
1164 iShadowRect.BoundingRect(aRect); |
|
1165 |
|
1166 if(iShadowRect.Size().iWidth > UiLayout()->Rect().Size().iWidth || |
|
1167 iShadowRect.Size().iHeight > UiLayout()->Rect().Size().iHeight) |
|
1168 { |
|
1169 UiLayout()->LayoutOwner()->LayoutSizeChanged(iShadowRect.Size()); |
|
1170 } |
|
1171 } |
|
1172 |
|
1173 |
|
1174 // --------------------------------------------------------------------------- |
|
1175 // CFepUiBaseCtrl::Draw |
|
1176 // Draw control |
|
1177 // --------------------------------------------------------------------------- |
|
1178 // |
|
1179 EXPORT_C void CFepUiBaseCtrl::Draw() |
|
1180 { |
|
1181 //only draw when it's window based control |
|
1182 if(iWndControl && AbleToDraw()) |
|
1183 { |
|
1184 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
1185 |
|
1186 DrawOpaqueMaskBackground(); |
|
1187 gc->Activate( BitmapDevice() ); |
|
1188 //gc->SetClippingRegion(&ClipRegion()); |
|
1189 iWndControl->DrawNow(); |
|
1190 gc->CancelClipping(); |
|
1191 UpdateArea(iRect, EFalse); |
|
1192 } |
|
1193 } |
|
1194 |
|
1195 // --------------------------------------------------------------------------- |
|
1196 // CFepUiBaseCtrl::ConstructFromResourceL |
|
1197 // handle resource change |
|
1198 // --------------------------------------------------------------------------- |
|
1199 // |
|
1200 EXPORT_C void CFepUiBaseCtrl::ConstructFromResourceL() |
|
1201 { |
|
1202 // do nothing |
|
1203 } |
|
1204 |
|
1205 // --------------------------------------------------------------------------- |
|
1206 // CFepUiBaseCtrl::SetResourceId |
|
1207 // Set resurce Id |
|
1208 // --------------------------------------------------------------------------- |
|
1209 // |
|
1210 EXPORT_C void CFepUiBaseCtrl::SetResourceId(TInt32 aResId) |
|
1211 { |
|
1212 iResourceId = aResId; |
|
1213 } |
|
1214 |
|
1215 // --------------------------------------------------------------------------- |
|
1216 // Set shadow bitmap |
|
1217 // --------------------------------------------------------------------------- |
|
1218 // |
|
1219 EXPORT_C void CFepUiBaseCtrl::SetShadowBmp(CFbsBitmap* aBmp, |
|
1220 CFbsBitmap* aMaskBmp,TShadowBitmapIndex aIndex) |
|
1221 { |
|
1222 //remove previous one |
|
1223 delete iShadowBmp[aIndex]; |
|
1224 delete iShadowBmp[aIndex+KShadowBitmapTotalNum]; |
|
1225 iShadowBmp[aIndex] = aBmp; |
|
1226 iShadowBmp[aIndex+KShadowBitmapTotalNum] = aMaskBmp; |
|
1227 } |
|
1228 |
|
1229 EXPORT_C TBool CFepUiBaseCtrl::AbleToDraw() |
|
1230 { |
|
1231 return UiLayout()->LayoutReady() && Ready() && !WholeHiden() && Rect().Size() != TSize(0,0); |
|
1232 } |
|
1233 |
|
1234 // --------------------------------------------------------------------------- |
|
1235 // Get extension |
|
1236 // --------------------------------------------------------------------------- |
|
1237 // |
|
1238 EXPORT_C TInt CFepUiBaseCtrl::Extension_(TUint aExtensionId, TAny *&a0, TAny *a1) |
|
1239 { |
|
1240 //not implemented, use CBase's |
|
1241 return CBase::Extension_(aExtensionId, a0, a1); |
|
1242 } |
|
1243 |
|
1244 // --------------------------------------------------------------------------- |
|
1245 // CFepUiBaseCtrl::WholeHiden |
|
1246 // Return if hiden all controls |
|
1247 // (other items were commented in a header). |
|
1248 // --------------------------------------------------------------------------- |
|
1249 // |
|
1250 EXPORT_C TBool CFepUiBaseCtrl::WholeHiden() |
|
1251 { |
|
1252 if ( Hiden() ) |
|
1253 { |
|
1254 return ETrue; |
|
1255 } |
|
1256 |
|
1257 CFepUiBaseCtrl* parentCtrl = ParentCtrl(); |
|
1258 while( parentCtrl ) |
|
1259 { |
|
1260 if ( parentCtrl->Hiden() ) |
|
1261 { |
|
1262 return ETrue; |
|
1263 } |
|
1264 parentCtrl = parentCtrl->ParentCtrl(); |
|
1265 } |
|
1266 return EFalse; |
|
1267 } |
|
1268 |
|
1269 // --------------------------------------------------------------------------- |
|
1270 // CFepUiBaseCtrl::ValidClipRegion |
|
1271 // Get the clipping region |
|
1272 // (other items were commented in a header). |
|
1273 // --------------------------------------------------------------------------- |
|
1274 // |
|
1275 EXPORT_C const TRegion& CFepUiBaseCtrl::ValidClipRegion() |
|
1276 { |
|
1277 iClipRegionWithoutLockedArea.Clear(); |
|
1278 iClipRegionWithoutLockedArea.Copy(iClipRegion); |
|
1279 /***********************************************************************/ |
|
1280 /*!!!! Seems a problem here, what if this area is locked by myself? */ |
|
1281 /***********************************************************************/ |
|
1282 iClipRegionWithoutLockedArea.SubRect(UiLayout()->LockedArea()); |
|
1283 return iClipRegionWithoutLockedArea; |
|
1284 } |
|
1285 |
|
1286 // ----------------------------------------------------------------------------- |
|
1287 // CFepUiBaseCtrl::OnResourceChange |
|
1288 // Handle system resource change |
|
1289 // (other items were commented in a header). |
|
1290 // ----------------------------------------------------------------------------- |
|
1291 // |
|
1292 EXPORT_C void CFepUiBaseCtrl::HandleResourceChange(TInt aType) |
|
1293 { |
|
1294 if(iWndControl) |
|
1295 iWndControl->HandleResourceChange(aType); |
|
1296 } |
|
1297 // ----------------------------------------------------------------------------- |
|
1298 // CFepUiBaseCtrl::GraphicDeviceSizeChanged |
|
1299 // Handle pen UI graphic device size change event |
|
1300 // (other items were commented in a header). |
|
1301 // ----------------------------------------------------------------------------- |
|
1302 // |
|
1303 EXPORT_C void CFepUiBaseCtrl::GraphicDeviceSizeChanged() |
|
1304 { |
|
1305 //do nothing |
|
1306 } |
|
1307 |
|
1308 |
|
1309 // --------------------------------------------------------------------------- |
|
1310 // CFepUiBaseCtrl::SimulatePointerEvent |
|
1311 // Simulates an internal pointer event |
|
1312 // --------------------------------------------------------------------------- |
|
1313 // |
|
1314 EXPORT_C void CFepUiBaseCtrl::SimulateRawEvent(const TRawEvent& aEvent) |
|
1315 { |
|
1316 TRAP_IGNORE(RootControl()->HandleEventL(ERawEvent,&aEvent)); |
|
1317 } |
|
1318 |
|
1319 |
|
1320 EXPORT_C void CFepUiBaseCtrl::SetParent(CFepUiBaseCtrl* aParent) |
|
1321 { |
|
1322 //parent control must be type of control group. |
|
1323 if(aParent) |
|
1324 { |
|
1325 __ASSERT_DEBUG(aParent->IsKindOfControl(ECtrlControlGroup),EUiLayoutBadParentType); |
|
1326 } |
|
1327 iParentCtrl = aParent; |
|
1328 } |
|
1329 |
|
1330 EXPORT_C void CFepUiBaseCtrl::SetOrdinalPos(TInt aPos) |
|
1331 { |
|
1332 iOrdinalPos = aPos; |
|
1333 } |
|
1334 |
|
1335 EXPORT_C TInt CFepUiBaseCtrl::AbsOrderPos() |
|
1336 { |
|
1337 TInt order = OrderPos(); |
|
1338 if(ParentCtrl()) |
|
1339 order += ParentCtrl()->AbsOrderPos(); |
|
1340 return order; |
|
1341 } |
|
1342 |
|
1343 |
|
1344 |
|
1345 // --------------------------------------------------------------------------- |
|
1346 // CFepUiBaseCtrl::CFepUiBaseCtrlExtension |
|
1347 // |
|
1348 // --------------------------------------------------------------------------- |
|
1349 // |
|
1350 |
|
1351 CFepUiBaseCtrl::CFepUiBaseCtrlExtension::CFepUiBaseCtrlExtension(TInt aTactileType) |
|
1352 { |
|
1353 #ifdef RD_TACTILE_FEEDBACK |
|
1354 iTactileType = aTactileType; |
|
1355 #endif // RD_TACTILE_FEEDBACK |
|
1356 } |
|
1357 |
|
1358 void CFepUiBaseCtrl::CFepUiBaseCtrlExtension::SetTactileFeedbackType(TInt aTactileType) |
|
1359 { |
|
1360 #ifdef RD_TACTILE_FEEDBACK |
|
1361 iTactileType = aTactileType; |
|
1362 #endif // RD_TACTILE_FEEDBACK |
|
1363 } |
|
1364 |
|
1365 EXPORT_C TInt CFepUiBaseCtrl::CFepUiBaseCtrlExtension::TactileFeedbackType() |
|
1366 { |
|
1367 #ifdef RD_TACTILE_FEEDBACK |
|
1368 return iTactileType; |
|
1369 #else |
|
1370 return 0; |
|
1371 #endif // RD_TACTILE_FEEDBACK |
|
1372 } |
|
1373 |