|
1 /* |
|
2 * Copyright (c) 2005-2009 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: View part of the preview pop-up component. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "AknPreviewPopUp.h" |
|
21 #include <AknPreviewPopUpObserver.h> |
|
22 #include <AknPreviewPopUpController.h> |
|
23 #include <AknUtils.h> |
|
24 #include <AknsDrawUtils.h> |
|
25 #include <aknViewAppUi.h> |
|
26 #include <AknsFrameBackgroundControlContext.h> |
|
27 #include <akntouchpane.h> |
|
28 #include <aknbutton.h> |
|
29 #include <vwsdef.h> |
|
30 #include <aknview.h> |
|
31 #include <apgwgnam.h> |
|
32 #include <aknlayoutscalable_avkon.cdl.h> |
|
33 |
|
34 #include <AknTasHook.h> // for testability hooks |
|
35 #include <touchfeedback.h> |
|
36 #include <gfxtranseffect/gfxtranseffect.h> |
|
37 #include <akntransitionutils.h> |
|
38 const TInt KWindowPosition = 1000; // window's position |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS =============================== |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CAknPreviewPopUp::NewL |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CAknPreviewPopUp* CAknPreviewPopUp::NewL( CCoeControl& aContent, |
|
47 CAknPreviewPopUpController& aController, |
|
48 const TInt aStyle ) |
|
49 { |
|
50 CAknPreviewPopUp* self = new ( ELeave ) CAknPreviewPopUp( aContent, |
|
51 aController, |
|
52 aStyle ); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 CleanupStack::Pop( self ); |
|
56 AKNTASHOOK_ADDL( self, "CAknPreviewPopUp" ); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CAknPreviewPopUp::CAknPreviewPopUp |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CAknPreviewPopUp::CAknPreviewPopUp( CCoeControl& aContent, |
|
65 CAknPreviewPopUpController& aController, |
|
66 const TInt aStyle ) |
|
67 : iContent( aContent ), |
|
68 iController( aController ), |
|
69 iFlags( aStyle ), |
|
70 iAllowUpEvent(EFalse) |
|
71 { |
|
72 GfxTransEffect::Register( this, KGfxPreviewPopupControlUid ); |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CAknPreviewPopUp::~CAknPreviewPopUp |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 CAknPreviewPopUp::~CAknPreviewPopUp() |
|
80 { |
|
81 AKNTASHOOK_REMOVE(); |
|
82 |
|
83 GfxTransEffect::Deregister( this ); |
|
84 |
|
85 if ( CapturesPointer() ) |
|
86 { |
|
87 SetPointerCapture( EFalse ); |
|
88 } |
|
89 |
|
90 if ( iAvkonAppUi ) |
|
91 { |
|
92 iAvkonAppUi->RemoveFromStack( this ); |
|
93 } |
|
94 |
|
95 delete iBgContext; |
|
96 delete iHeadingText; |
|
97 delete iClosingIcon; |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CAknPreviewPopUp::ConstructL |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CAknPreviewPopUp::ConstructL() |
|
105 { |
|
106 // set skin ids |
|
107 if ( iFlags & CAknPreviewPopUpController::ELayoutSubMenu ) |
|
108 { |
|
109 iFrameId = KAknsIIDQsnFrPopupSub; |
|
110 iCenterId = KAknsIIDQsnFrPopupCenterSubmenu; |
|
111 } |
|
112 else |
|
113 { |
|
114 iFrameId = KAknsIIDQsnFrPopupPreview; |
|
115 iCenterId = KAknsIIDDefault; |
|
116 } |
|
117 |
|
118 TRect nullRect( 0,0,0,0 ); |
|
119 iBgContext = CAknsFrameBackgroundControlContext::NewL( |
|
120 iFrameId, nullRect, nullRect, EFalse ); |
|
121 |
|
122 CreateWindowL(); |
|
123 EnableWindowTransparency(); |
|
124 |
|
125 TInt stackPriority = ECoeStackPriorityCba; |
|
126 |
|
127 if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) ) |
|
128 { |
|
129 Window().SetPointerGrab( ETrue ); |
|
130 SetGloballyCapturing( ETrue ); |
|
131 Window().SetOrdinalPosition(KWindowPosition); |
|
132 } |
|
133 else |
|
134 { |
|
135 stackPriority = ECoeStackPriorityDefault; |
|
136 Window().SetOrdinalPosition( 0, ECoeWinPriorityNormal ); |
|
137 } |
|
138 |
|
139 iAvkonAppUi->AddToStackL( this, stackPriority, |
|
140 ECoeStackFlagRefusesAllKeys | |
|
141 ECoeStackFlagRefusesFocus ); |
|
142 |
|
143 EnableDragEvents(); |
|
144 SetComponentsToInheritVisibility( ETrue ); |
|
145 |
|
146 iContent.SetBackground( this ); |
|
147 iContent.SetContainerWindowL( *this ); |
|
148 iContent.ActivateL(); |
|
149 |
|
150 if ( iFlags & CAknPreviewPopUpController::EFixedMode ) |
|
151 { |
|
152 TRect appWindow; |
|
153 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, appWindow ); |
|
154 |
|
155 TAknLayoutRect layoutRect; |
|
156 layoutRect.LayoutRect( appWindow, AknLayoutScalable_Avkon::popup_preview_fixed_window().LayoutLine() ); |
|
157 |
|
158 SetRect( layoutRect.Rect() ); |
|
159 } |
|
160 |
|
161 MakeVisible( EFalse ); |
|
162 ActivateL(); |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CAknPreviewPopUp::Show |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void CAknPreviewPopUp::Show() |
|
170 { |
|
171 if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) ) |
|
172 { |
|
173 Window().SetOrdinalPosition( 0 ); |
|
174 iAvkonAppUi->UpdateStackedControlFlags( this, NULL, |
|
175 ECoeStackFlagRefusesAllKeys ); |
|
176 |
|
177 SetPointerCapture( ETrue ); |
|
178 } |
|
179 |
|
180 iCloseMenu = EFalse; |
|
181 TBool useTfx = !( iFlags & CAknPreviewPopUpController::EPermanentMode |
|
182 || iFlags & CAknPreviewPopUpController::EFixedMode ); |
|
183 |
|
184 if ( useTfx && GfxTransEffect::IsRegistered( this ) ) |
|
185 { |
|
186 GfxTransEffect::Begin( this, KGfxControlAppearAction ); |
|
187 MakeVisible( ETrue ); |
|
188 GfxTransEffect::SetDemarcation( this, iPosition ); |
|
189 GfxTransEffect::End( this ); |
|
190 } |
|
191 else |
|
192 { |
|
193 MakeVisible( ETrue ); |
|
194 } |
|
195 if( GrabbingComponent() ) |
|
196 { |
|
197 iCloseMenu = ETrue; |
|
198 } |
|
199 iController.NotifyObservers( MAknPreviewPopUpObserver::EPreviewPopUpShown ); |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CAknPreviewPopUp::Hide |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 void CAknPreviewPopUp::Hide() |
|
207 { |
|
208 if ( !IsVisible() || ( GrabbingComponent() && !iCloseMenu && |
|
209 !( iFlags & CAknPreviewPopUpController::EPermanentMode ) ) ) |
|
210 { |
|
211 return; |
|
212 } |
|
213 |
|
214 TBool useTfx = !( iFlags & CAknPreviewPopUpController::EPermanentMode |
|
215 || iFlags & CAknPreviewPopUpController::EFixedMode ); |
|
216 |
|
217 if ( useTfx && GfxTransEffect::IsRegistered( this ) ) |
|
218 { |
|
219 GfxTransEffect::Begin( this, KGfxControlDisappearAction ); |
|
220 MakeVisible( EFalse ); |
|
221 GfxTransEffect::End( this ); |
|
222 } |
|
223 else |
|
224 { |
|
225 MakeVisible( EFalse ); |
|
226 } |
|
227 |
|
228 Window().ClearRedrawStore(); |
|
229 |
|
230 if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) ) |
|
231 { |
|
232 Window().SetOrdinalPosition( KWindowPosition ); |
|
233 iAvkonAppUi->UpdateStackedControlFlags( this, |
|
234 ECoeStackFlagRefusesAllKeys, |
|
235 ECoeStackFlagRefusesAllKeys ); |
|
236 } |
|
237 |
|
238 if ( CapturesPointer() ) |
|
239 { |
|
240 SetPointerCapture( EFalse ); |
|
241 } |
|
242 |
|
243 iController.NotifyObservers( MAknPreviewPopUpObserver::EPreviewPopUpHidden ); |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CAknPreviewPopUp::Flags |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 TInt CAknPreviewPopUp::Flags() const |
|
251 { |
|
252 return iFlags; |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CAknPreviewPopUp::SetHeadingTextL |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 void CAknPreviewPopUp::SetHeadingTextL( const TDesC& aText ) |
|
260 { |
|
261 delete iHeadingText; |
|
262 iHeadingText = NULL; |
|
263 |
|
264 if ( aText.Length() > 0 ) |
|
265 { |
|
266 iHeadingText = aText.AllocL(); |
|
267 CreateClosingIconL(); |
|
268 } |
|
269 else |
|
270 { |
|
271 if ( iClosingIcon ) |
|
272 { |
|
273 delete iClosingIcon; |
|
274 iClosingIcon = NULL; |
|
275 } |
|
276 } |
|
277 SetSize( MinimumSize() ); |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CAknPreviewPopUp::MinimumSize |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 TSize CAknPreviewPopUp::MinimumSize() |
|
285 { |
|
286 TSize size; |
|
287 |
|
288 if ( iFlags & CAknPreviewPopUpController::EFixedMode ) |
|
289 { |
|
290 TRect appWindow; |
|
291 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, appWindow ); |
|
292 |
|
293 TAknLayoutRect layoutRect; |
|
294 layoutRect.LayoutRect( appWindow, AknLayoutScalable_Avkon::popup_preview_fixed_window().LayoutLine() ); |
|
295 |
|
296 size = layoutRect.Rect().Size(); |
|
297 } |
|
298 else |
|
299 { |
|
300 TSize contentSize( iContent.MinimumSize() ); |
|
301 TSize headingSize; |
|
302 |
|
303 // heading |
|
304 if ( HasHeading() ) |
|
305 { |
|
306 TRect rect( 0, 0, 100, 100 ); // dummy rect to calculate heading |
|
307 TAknLayoutRect layoutRect; |
|
308 layoutRect.LayoutRect( rect, AknLayoutScalable_Avkon::heading_preview_pane().LayoutLine() ); |
|
309 |
|
310 headingSize.iHeight = layoutRect.Rect().Height() + layoutRect.Rect().iTl.iY; |
|
311 } |
|
312 |
|
313 size = contentSize + headingSize; |
|
314 // If size is empty return it now so the size won't be increased below |
|
315 if ( size == TSize() ) |
|
316 { |
|
317 return size; |
|
318 } |
|
319 // frame borders |
|
320 TAknWindowComponentLayout center( CenterLayout() ); |
|
321 size.iWidth += center.LayoutLine().il + center.LayoutLine().ir; |
|
322 size.iHeight += center.LayoutLine().it + center.LayoutLine().ib; |
|
323 } |
|
324 |
|
325 return size; |
|
326 } |
|
327 |
|
328 // ----------------------------------------------------------------------------- |
|
329 // CAknPreviewPopUp::HandleResourceChange |
|
330 // ----------------------------------------------------------------------------- |
|
331 // |
|
332 void CAknPreviewPopUp::HandleResourceChange( TInt aType ) |
|
333 { |
|
334 CCoeControl::HandleResourceChange( aType ); |
|
335 |
|
336 switch ( aType ) |
|
337 { |
|
338 case KAknsMessageSkinChange: |
|
339 if ( iClosingIcon ) |
|
340 { |
|
341 delete iClosingIcon; |
|
342 iClosingIcon = NULL; |
|
343 TRAP_IGNORE( CreateClosingIconL() ); |
|
344 } |
|
345 break; |
|
346 |
|
347 case KEikDynamicLayoutVariantSwitch: |
|
348 if ( iFlags & CAknPreviewPopUpController::EFixedMode ) |
|
349 { |
|
350 TRect appWindow; |
|
351 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, appWindow ); |
|
352 |
|
353 TAknLayoutRect layoutRect; |
|
354 layoutRect.LayoutRect( appWindow, AknLayoutScalable_Avkon::popup_preview_fixed_window().LayoutLine() ); |
|
355 |
|
356 SetRect( layoutRect.Rect() ); |
|
357 } |
|
358 else |
|
359 { |
|
360 SetSize( MinimumSize() ); |
|
361 } |
|
362 break; |
|
363 |
|
364 default: |
|
365 break; |
|
366 } |
|
367 } |
|
368 |
|
369 // ----------------------------------------------------------------------------- |
|
370 // CAknPreviewPopUp::HandleControlEventL |
|
371 // ----------------------------------------------------------------------------- |
|
372 // |
|
373 void CAknPreviewPopUp::HandleControlEventL( CCoeControl* aControl, |
|
374 TCoeEvent aEventType ) |
|
375 { |
|
376 if ( aControl == iClosingIcon && aEventType == EEventStateChanged ) |
|
377 { |
|
378 Hide(); |
|
379 } |
|
380 } |
|
381 |
|
382 // ----------------------------------------------------------------------------- |
|
383 // CAknPreviewPopUp::Draw |
|
384 // ----------------------------------------------------------------------------- |
|
385 // |
|
386 void CAknPreviewPopUp::Draw( CWindowGc& aGc, const CCoeControl& /*aControl*/, |
|
387 const TRect& aRect ) const |
|
388 { |
|
389 if( CAknEnv::Static()->TransparencyEnabled() ) |
|
390 { |
|
391 DrawBackground( aGc, aRect ); |
|
392 } |
|
393 else |
|
394 { |
|
395 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
396 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
397 |
|
398 AknsDrawUtils::Background( skin, cc, this, aGc, aRect ); |
|
399 } |
|
400 } |
|
401 |
|
402 |
|
403 // ----------------------------------------------------------------------------- |
|
404 // CAknPreviewPopUp::CountComponentControls |
|
405 // ----------------------------------------------------------------------------- |
|
406 // |
|
407 TInt CAknPreviewPopUp::CountComponentControls() const |
|
408 { |
|
409 if ( !iClosingIcon ) |
|
410 { |
|
411 return 1; // iContent |
|
412 } |
|
413 |
|
414 return 2; // iContent, iClosingIcon |
|
415 } |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
|
418 // CAknPreviewPopUp::ComponentControl |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 CCoeControl* CAknPreviewPopUp::ComponentControl( TInt aIndex ) const |
|
422 { |
|
423 switch ( aIndex ) |
|
424 { |
|
425 case 0: |
|
426 return &iContent; |
|
427 |
|
428 case 1: |
|
429 return iClosingIcon; |
|
430 |
|
431 default: |
|
432 return NULL; |
|
433 } |
|
434 } |
|
435 |
|
436 // ----------------------------------------------------------------------------- |
|
437 // CAknPreviewPopUp::SizeChanged |
|
438 // ----------------------------------------------------------------------------- |
|
439 // |
|
440 void CAknPreviewPopUp::SizeChanged() |
|
441 { |
|
442 TRect rect( Rect() ); |
|
443 TAknLayoutRect layoutRect; |
|
444 TAknWindowComponentLayout center( CenterLayout() ); |
|
445 |
|
446 layoutRect.LayoutRect( rect, center.LayoutLine() ); |
|
447 iBgContext->SetFrameRects( rect, layoutRect.Rect() ); |
|
448 |
|
449 if ( iFlags & CAknPreviewPopUpController::EFixedMode ) |
|
450 { |
|
451 if ( iFlags & CAknPreviewPopUpController::EExcludeFrames ) |
|
452 { |
|
453 rect = layoutRect.Rect(); |
|
454 |
|
455 if ( HasHeading() ) |
|
456 { |
|
457 layoutRect.LayoutRect( Rect(), AknLayoutScalable_Avkon::heading_preview_pane().LayoutLine() ); |
|
458 rect.iTl.iY = layoutRect.Rect().iBr.iY; |
|
459 } |
|
460 } |
|
461 |
|
462 iContent.SetRect( rect ); |
|
463 } |
|
464 else |
|
465 { |
|
466 // content |
|
467 TPoint contentPosition; |
|
468 contentPosition.iX = center.LayoutLine().il; |
|
469 |
|
470 if ( HasHeading() ) |
|
471 { |
|
472 TAknLayoutRect layoutRect; |
|
473 layoutRect.LayoutRect( rect, AknLayoutScalable_Avkon::heading_preview_pane().LayoutLine() ); |
|
474 contentPosition.iY = layoutRect.Rect().iBr.iY; |
|
475 } |
|
476 else |
|
477 { |
|
478 contentPosition.iY = center.LayoutLine().it; |
|
479 } |
|
480 |
|
481 TSize contentSize( iContent.MinimumSize() ); |
|
482 TSize maximumSize( Abs( layoutRect.Rect().iBr.iX - contentPosition.iX ), |
|
483 Abs( layoutRect.Rect().iBr.iY - contentPosition.iY ) ); |
|
484 |
|
485 if ( maximumSize.iWidth > contentSize.iWidth || |
|
486 maximumSize.iHeight > contentSize.iHeight ) |
|
487 { |
|
488 contentSize = maximumSize; |
|
489 } |
|
490 |
|
491 iContent.SetExtent( contentPosition, contentSize ); |
|
492 } |
|
493 |
|
494 // closing icon |
|
495 if ( iClosingIcon ) |
|
496 { |
|
497 layoutRect.LayoutRect( Rect(), TAknWindowComponentLayout::Compose( |
|
498 AknLayoutScalable_Avkon::heading_preview_pane(), |
|
499 AknLayoutScalable_Avkon::heading_preview_pane_g1() ).LayoutLine() ); |
|
500 |
|
501 iClosingIcon->SetRect( layoutRect.Rect() ); |
|
502 } |
|
503 DrawDeferred(); |
|
504 } |
|
505 |
|
506 // ----------------------------------------------------------------------------- |
|
507 // CAknPreviewPopUp::HandlePointerEventL |
|
508 // ----------------------------------------------------------------------------- |
|
509 // |
|
510 void CAknPreviewPopUp::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
511 { |
|
512 if ( AknLayoutUtils::PenEnabled() ) |
|
513 { |
|
514 iCloseMenu = EFalse; |
|
515 if ( aPointerEvent.iType == TPointerEvent::EButton1Up && !IsVisible() ) |
|
516 { |
|
517 SetPointerCapture( EFalse ); |
|
518 } |
|
519 |
|
520 // redirect pointer event to content |
|
521 if ( Rect().Contains( aPointerEvent.iPosition ) && IsVisible() ) |
|
522 { |
|
523 iAllowUpEvent = ETrue; |
|
524 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
525 if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) && aPointerEvent.iType == TPointerEvent::EButton1Up && IsVisible() ) |
|
526 { |
|
527 // if pointer up is already redirected to the content, but the popup is still visible, |
|
528 // then the original timeout has already happened and we need to reset the timer. |
|
529 // TSW Error EJZG-7JR3PC. |
|
530 iController.ResetTimer(); |
|
531 } |
|
532 } |
|
533 else |
|
534 { |
|
535 if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) && |
|
536 aPointerEvent.iType != TPointerEvent::EDrag && |
|
537 aPointerEvent.iType != TPointerEvent::EButtonRepeat ) |
|
538 { |
|
539 |
|
540 // handle here mainly up and down events outside popup rect |
|
541 if ( iFlags & CAknPreviewPopUpController::EDontClose ) |
|
542 { |
|
543 // If EDontClose flag is on: |
|
544 // Up event outside popup's rect don't close popup, |
|
545 // but resets timer to give more time for popup |
|
546 // All other events outside popup's rect (mainly down) |
|
547 // hides the popup |
|
548 |
|
549 if ( aPointerEvent.iType != TPointerEvent::EButton1Up ) |
|
550 { |
|
551 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
552 if ( feedback ) |
|
553 { |
|
554 feedback->InstantFeedback( ETouchFeedbackPopUp ); |
|
555 } |
|
556 iCloseMenu = ETrue; |
|
557 iController.HidePopUp(); |
|
558 } |
|
559 else if ( IsVisible() ) |
|
560 { |
|
561 iController.ResetTimer(); |
|
562 } |
|
563 } |
|
564 else |
|
565 { |
|
566 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
567 if ( feedback ) |
|
568 { |
|
569 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
570 { |
|
571 feedback->InstantFeedback( this, |
|
572 ETouchFeedbackPopUp, |
|
573 ETouchFeedbackVibra, |
|
574 aPointerEvent ); |
|
575 } |
|
576 else |
|
577 { |
|
578 feedback->InstantFeedback( this, |
|
579 ETouchFeedbackPopUp, |
|
580 aPointerEvent ); |
|
581 } |
|
582 } |
|
583 iCloseMenu = ETrue; |
|
584 iController.HidePopUp(); |
|
585 } |
|
586 } |
|
587 |
|
588 // If EDontClose flag is on, also button up is forwarded for base class |
|
589 if ( iFlags & CAknPreviewPopUpController::EDontClose ) |
|
590 { |
|
591 if ( aPointerEvent.iType == TPointerEvent::EDrag || |
|
592 aPointerEvent.iType == TPointerEvent::EButtonRepeat || |
|
593 (aPointerEvent.iType == TPointerEvent::EButton1Up && iAllowUpEvent ) ) |
|
594 { |
|
595 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
596 } |
|
597 } |
|
598 else |
|
599 { |
|
600 if ( aPointerEvent.iType == TPointerEvent::EDrag || |
|
601 aPointerEvent.iType == TPointerEvent::EButtonRepeat ) |
|
602 { |
|
603 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
604 } |
|
605 } |
|
606 |
|
607 } |
|
608 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
609 { |
|
610 iAllowUpEvent = EFalse; |
|
611 } |
|
612 } |
|
613 } |
|
614 |
|
615 // ----------------------------------------------------------------------------- |
|
616 // CAknPreviewPopUp::OfferKeyEventL |
|
617 // ----------------------------------------------------------------------------- |
|
618 // |
|
619 TKeyResponse CAknPreviewPopUp::OfferKeyEventL( const TKeyEvent& /*aKeyEvent*/, |
|
620 TEventCode /*aType*/ ) |
|
621 { |
|
622 if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) ) |
|
623 { |
|
624 iCloseMenu = ETrue; |
|
625 iController.HidePopUp(); |
|
626 } |
|
627 |
|
628 if ( CapturesPointer() ) |
|
629 { |
|
630 SetPointerCapture( EFalse ); |
|
631 } |
|
632 |
|
633 return EKeyWasNotConsumed; |
|
634 } |
|
635 |
|
636 // ----------------------------------------------------------------------------- |
|
637 // CAknPreviewPopUp::MopSupplyObject |
|
638 // ----------------------------------------------------------------------------- |
|
639 // |
|
640 TTypeUid::Ptr CAknPreviewPopUp::MopSupplyObject( TTypeUid aId ) |
|
641 { |
|
642 if ( aId.iUid == MAknsControlContext::ETypeId ) |
|
643 { |
|
644 if ( iBgContext ) |
|
645 { |
|
646 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
647 } |
|
648 else |
|
649 { |
|
650 return TTypeUid::Null(); |
|
651 } |
|
652 } |
|
653 |
|
654 return CCoeControl::MopSupplyObject( aId ); |
|
655 } |
|
656 |
|
657 // ----------------------------------------------------------------------------- |
|
658 // CAknPreviewPopUp::Draw |
|
659 // ----------------------------------------------------------------------------- |
|
660 // |
|
661 void CAknPreviewPopUp::Draw( const TRect& aRect ) const |
|
662 { |
|
663 CWindowGc& gc = SystemGc(); |
|
664 |
|
665 TRegionFix<4> region; |
|
666 region.AddRect( Rect() ); |
|
667 region.SubRect( iContent.Rect() ); |
|
668 gc.SetClippingRegion( region ); |
|
669 |
|
670 DrawBackground( gc, aRect ); |
|
671 |
|
672 gc.CancelClippingRegion(); |
|
673 } |
|
674 |
|
675 // ----------------------------------------------------------------------------- |
|
676 // CAknPreviewPopUp::CenterLayout |
|
677 // ----------------------------------------------------------------------------- |
|
678 // |
|
679 TAknWindowComponentLayout CAknPreviewPopUp::CenterLayout() |
|
680 { |
|
681 if ( iFlags & CAknPreviewPopUpController::ELayoutSubMenu ) |
|
682 { |
|
683 return AknLayoutScalable_Avkon::bg_popup_sub_pane_g1(); |
|
684 } |
|
685 |
|
686 return AknLayoutScalable_Avkon::bg_popup_preview_window_pane_g1(); |
|
687 } |
|
688 |
|
689 // ----------------------------------------------------------------------------- |
|
690 // CAknPreviewPopUp::CreateClosingIconL |
|
691 // ----------------------------------------------------------------------------- |
|
692 // |
|
693 void CAknPreviewPopUp::CreateClosingIconL() |
|
694 { |
|
695 if ( !iClosingIcon && AknLayoutUtils::PenEnabled() && |
|
696 !( iFlags & CAknPreviewPopUpController::EPermanentMode ) ) |
|
697 { |
|
698 iClosingIcon = CAknButton::NewL( KNullDesC, 0, 0, 0, 0, 0, 0, 0, 0, |
|
699 KNullDesC, KNullDesC, 0, 0, |
|
700 KAknsIIDQgnIndiTpIdle ); |
|
701 |
|
702 iClosingIcon->SetContainerWindowL( *this ); |
|
703 iClosingIcon->SetObserver( this ); |
|
704 iClosingIcon->SetIconScaleMode( EAspectRatioPreserved ); |
|
705 iClosingIcon->ActivateL(); |
|
706 } |
|
707 else if ( iClosingIcon && !AknLayoutUtils::PenEnabled() ) |
|
708 { |
|
709 delete iClosingIcon; |
|
710 iClosingIcon = NULL; |
|
711 } |
|
712 } |
|
713 |
|
714 // ----------------------------------------------------------------------------- |
|
715 // CAknPreviewPopUp::HasHeading |
|
716 // ----------------------------------------------------------------------------- |
|
717 // |
|
718 TBool CAknPreviewPopUp::HasHeading() const |
|
719 { |
|
720 if ( !iHeadingText ) |
|
721 { |
|
722 return EFalse; |
|
723 } |
|
724 |
|
725 if ( *iHeadingText == KNullDesC ) |
|
726 { |
|
727 return EFalse; |
|
728 } |
|
729 |
|
730 return ETrue; |
|
731 } |
|
732 |
|
733 // ----------------------------------------------------------------------------- |
|
734 // CAknPreviewPopUp::DrawBackground |
|
735 // ----------------------------------------------------------------------------- |
|
736 // |
|
737 void CAknPreviewPopUp::DrawBackground( CWindowGc& aGc, const TRect& aRect ) const |
|
738 { |
|
739 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
740 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
741 |
|
742 TBool drawn = AknsDrawUtils::Background( skin, cc, this, aGc, aRect, |
|
743 KAknsDrawParamNoClearUnderImage ); |
|
744 |
|
745 if ( !drawn ) |
|
746 { |
|
747 aGc.Clear( aRect ); |
|
748 } |
|
749 |
|
750 if ( HasHeading() ) |
|
751 { |
|
752 aGc.SetClippingRect( aRect ); |
|
753 |
|
754 // heading graphics |
|
755 TAknLayoutRect layoutRect; |
|
756 layoutRect.LayoutRect( Rect(), |
|
757 TAknWindowComponentLayout::Compose( |
|
758 AknLayoutScalable_Avkon::heading_preview_pane(), |
|
759 AknLayoutScalable_Avkon::bg_popup_heading_pane_cp2( 1 ) ).LayoutLine() ); |
|
760 |
|
761 TRect outerRect( layoutRect.Rect() ); |
|
762 |
|
763 layoutRect.LayoutRect( outerRect, |
|
764 AknLayoutScalable_Avkon::bg_popup_heading_pane_g1() ); |
|
765 |
|
766 // There's no error checking since if skinned drawing fails heading |
|
767 // text will be drawn on top of the background. |
|
768 AknsDrawUtils::DrawFrame( skin, aGc, outerRect, layoutRect.Rect(), |
|
769 KAknsIIDQsnFrPopupHeading, KAknsIIDDefault ); |
|
770 |
|
771 // heading text |
|
772 TAknLayoutText textLayout; |
|
773 textLayout.LayoutText( Rect(), |
|
774 TAknWindowComponentLayout::ComposeText( |
|
775 AknLayoutScalable_Avkon::heading_preview_pane(), |
|
776 AknLayoutScalable_Avkon::heading_preview_pane_t1( 1 ) ).LayoutLine() ); |
|
777 |
|
778 aGc.SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
779 |
|
780 TRgb color( textLayout.Color() ); |
|
781 |
|
782 if ( iFlags & CAknPreviewPopUpController::ELayoutSubMenu ) |
|
783 { |
|
784 AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, |
|
785 EAknsCIQsnTextColorsCG55 ); |
|
786 } |
|
787 else |
|
788 { |
|
789 AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, |
|
790 EAknsCIQsnTextColorsCG19 ); |
|
791 } |
|
792 |
|
793 textLayout.DrawText( aGc, *iHeadingText, ETrue, color ); |
|
794 |
|
795 aGc.CancelClippingRect(); |
|
796 } |
|
797 } |
|
798 |
|
799 // End of File |
|
800 |