diff -r fcdfafb36fe7 -r aecbbf00d063 uifw/AvKon/src/AknPreviewPopUp.cpp --- a/uifw/AvKon/src/AknPreviewPopUp.cpp Thu Aug 19 10:11:06 2010 +0300 +++ b/uifw/AvKon/src/AknPreviewPopUp.cpp Tue Aug 31 15:28:30 2010 +0300 @@ -30,12 +30,9 @@ #include #include #include -#include + #include // for testability hooks #include -#include -#include -#include const TInt KWindowPosition = 1000; // window's position // ============================ MEMBER FUNCTIONS =============================== @@ -44,6 +41,7 @@ // CAknPreviewPopUp::NewL // ----------------------------------------------------------------------------- // +#if defined( RD_SCALABLE_UI_V2 ) || defined( RD_PREVIEW_POPUP ) CAknPreviewPopUp* CAknPreviewPopUp::NewL( CCoeControl& aContent, CAknPreviewPopUpController& aController, const TInt aStyle ) @@ -70,7 +68,6 @@ iFlags( aStyle ), iAllowUpEvent(EFalse) { - GfxTransEffect::Register( this, KGfxPreviewPopupControlUid ); } // ----------------------------------------------------------------------------- @@ -79,22 +76,7 @@ // CAknPreviewPopUp::~CAknPreviewPopUp() { - if( iIsDeleted ) - { - *iIsDeleted = ETrue ; - iIsDeleted = 0 ; - } - - if ( IsVisible() ) - { - iCloseMenu = ETrue; - iController.HidePopUp(); - } - AKNTASHOOK_REMOVE(); - - GfxTransEffect::Deregister( this ); - if ( CapturesPointer() ) { SetPointerCapture( EFalse ); @@ -132,30 +114,58 @@ iBgContext = CAknsFrameBackgroundControlContext::NewL( iFrameId, nullRect, nullRect, EFalse ); - CreateWindowL(); - EnableWindowTransparency(); - - TInt stackPriority = ECoeStackPriorityCba; - if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) ) { + + CreateWindowL(); + + // try to enable window transparency + if( CAknEnv::Static()->TransparencyEnabled() ) + { + Window().SetRequiredDisplayMode( EColor16MA ); + if ( Window().SetTransparencyAlphaChannel() == KErrNone ) + { + + Window().SetBackgroundColor( ~0 ); + } + } + + iAvkonAppUi->AddToStackL( this, ECoeStackPriorityCba, + ECoeStackFlagRefusesAllKeys | + ECoeStackFlagRefusesFocus ); + Window().SetPointerGrab( ETrue ); SetGloballyCapturing( ETrue ); + //fix for TSW error PTPA-7HNA25 Window().SetOrdinalPosition(KWindowPosition); } else { - stackPriority = ECoeStackPriorityDefault; + CreateWindowL(); + + // try to enable window transparency + if( CAknEnv::Static()->TransparencyEnabled() ) + { + Window().SetRequiredDisplayMode( EColor16MA ); + if ( Window().SetTransparencyAlphaChannel() == KErrNone ) + { + + Window().SetBackgroundColor( ~0 ); + } + } + + iAvkonAppUi->AddToStackL( this, ECoeStackPriorityDefault, + ECoeStackFlagRefusesAllKeys | + ECoeStackFlagRefusesFocus ); + Window().SetOrdinalPosition( 0, ECoeWinPriorityNormal ); } - iAvkonAppUi->AddToStackL( this, stackPriority, - ECoeStackFlagRefusesAllKeys | - ECoeStackFlagRefusesFocus ); + EnableDragEvents(); - EnableDragEvents(); SetComponentsToInheritVisibility( ETrue ); + iContent.SetBackground( this ); iContent.SetContainerWindowL( *this ); iContent.ActivateL(); @@ -171,6 +181,7 @@ SetRect( layoutRect.Rect() ); } + DrawableWindow()->EnableBackup( EWindowBackupAreaBehind ); MakeVisible( EFalse ); ActivateL(); } @@ -183,28 +194,20 @@ { if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) ) { + //fix for TSW error PTPA-7HNA25 Window().SetOrdinalPosition( 0 ); iAvkonAppUi->UpdateStackedControlFlags( this, NULL, ECoeStackFlagRefusesAllKeys ); - SetPointerCapture( ETrue ); + if ( AknLayoutUtils::PenEnabled() ) + { + SetPointerCapture( ETrue ); + } } iCloseMenu = EFalse; - TBool useTfx = !( iFlags & CAknPreviewPopUpController::EPermanentMode - || iFlags & CAknPreviewPopUpController::EFixedMode ); - - if ( useTfx && GfxTransEffect::IsRegistered( this ) ) - { - GfxTransEffect::Begin( this, KGfxControlAppearAction ); - MakeVisible( ETrue ); - GfxTransEffect::SetDemarcation( this, iPosition ); - GfxTransEffect::End( this ); - } - else - { - MakeVisible( ETrue ); - } + Window().Invalidate(); + MakeVisible( ETrue ); if( GrabbingComponent() ) { iCloseMenu = ETrue; @@ -224,28 +227,12 @@ return; } - // Skip disappear transition if the popup is either permanent, fixed or - // faded. Fading status is checked because there can't be two parallel - // effects applied to the same window. - TBool useTfx = !( iFlags & CAknPreviewPopUpController::EPermanentMode - || iFlags & CAknPreviewPopUpController::EFixedMode ) - && !Window().IsFaded(); - - if ( useTfx && GfxTransEffect::IsRegistered( this ) ) - { - GfxTransEffect::Begin( this, KGfxControlDisappearAction ); - MakeVisible( EFalse ); - GfxTransEffect::End( this ); - } - else - { - MakeVisible( EFalse ); - } - Window().ClearRedrawStore(); + MakeVisible( EFalse ); if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) ) { + //fix for TSW error PTPA-7HNA25 Window().SetOrdinalPosition( KWindowPosition ); iAvkonAppUi->UpdateStackedControlFlags( this, ECoeStackFlagRefusesAllKeys, @@ -416,6 +403,17 @@ } } +// ----------------------------------------------------------------------------- +// CAknPreviewPopUp::MakeVisible +// ----------------------------------------------------------------------------- +// +void CAknPreviewPopUp::MakeVisible( TBool aVisible ) + { + if ( aVisible != IsVisible() ) + { + CCoeControl::MakeVisible( aVisible ); + } + } // ----------------------------------------------------------------------------- // CAknPreviewPopUp::CountComponentControls @@ -525,10 +523,7 @@ // ----------------------------------------------------------------------------- // void CAknPreviewPopUp::HandlePointerEventL( const TPointerEvent& aPointerEvent ) - { - TBool isDelete = EFalse; - iIsDeleted = &isDelete; - + { if ( AknLayoutUtils::PenEnabled() ) { iCloseMenu = EFalse; @@ -536,18 +531,14 @@ { SetPointerCapture( EFalse ); } - + + CAknTouchPane* touchPane = iAvkonAppUi->TouchPane(); + // redirect pointer event to content if ( Rect().Contains( aPointerEvent.iPosition ) && IsVisible() ) { - iAllowUpEvent = ETrue; - CleanupStack::PushL( TCleanupItem( CleanLocalRef, this ) ); + iAllowUpEvent = ETrue; CCoeControl::HandlePointerEventL( aPointerEvent ); - CleanupStack::Pop(); - if( isDelete ) - { - return; - } if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) && aPointerEvent.iType == TPointerEvent::EButton1Up && IsVisible() ) { // if pointer up is already redirected to the content, but the popup is still visible, @@ -558,6 +549,26 @@ } else { + if ( touchPane ) + { + if ( touchPane->IsVisible() ) + { + // touchpane is a window-owning control -> Rect() cannot be used + TRect touchPaneRect( touchPane->Position(), touchPane->Size() ); + + if ( touchPaneRect.Contains( aPointerEvent.iParentPosition ) ) + { + TPointerEvent pointerEvent( aPointerEvent ); + + // make event's coordinates touch pane relative + pointerEvent.iPosition = aPointerEvent.iParentPosition - + touchPaneRect.iTl; + + static_cast( touchPane )->HandlePointerEventL( + pointerEvent ); + } + } + } if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) && aPointerEvent.iType != TPointerEvent::EDrag && aPointerEvent.iType != TPointerEvent::EButtonRepeat ) @@ -574,16 +585,10 @@ if ( aPointerEvent.iType != TPointerEvent::EButton1Up ) { - // popup will be hiden when EButton1Down comes. MTouchFeedback* feedback = MTouchFeedback::Instance(); if ( feedback ) { - TTouchLogicalFeedback feedbackType = ETouchFeedbackPopUp; - if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) ) - { - feedbackType = ETouchFeedbackOptionsMenuClosed; - } - feedback->InstantFeedback( feedbackType ); + feedback->InstantFeedback( ETouchFeedbackPopUp ); } iCloseMenu = ETrue; iController.HidePopUp(); @@ -607,19 +612,13 @@ } else { - // popup will be hiden when EButton1Down comes. - TTouchLogicalFeedback feedbackType = ETouchFeedbackPopUp; - if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) ) - { - feedbackType = ETouchFeedbackOptionsMenuClosed; - } feedback->InstantFeedback( this, - feedbackType, + ETouchFeedbackPopUp, aPointerEvent ); } } iCloseMenu = ETrue; - iController.HidePopUp(); + iController.HidePopUp(); } } @@ -630,13 +629,7 @@ aPointerEvent.iType == TPointerEvent::EButtonRepeat || (aPointerEvent.iType == TPointerEvent::EButton1Up && iAllowUpEvent ) ) { - CleanupStack::PushL( TCleanupItem( CleanLocalRef, this ) ); CCoeControl::HandlePointerEventL( aPointerEvent ); - CleanupStack::Pop(); - if( isDelete ) - { - return; - } } } else @@ -644,13 +637,7 @@ if ( aPointerEvent.iType == TPointerEvent::EDrag || aPointerEvent.iType == TPointerEvent::EButtonRepeat ) { - CleanupStack::PushL( TCleanupItem( CleanLocalRef, this ) ); CCoeControl::HandlePointerEventL( aPointerEvent ); - CleanupStack::Pop(); - if( isDelete ) - { - return; - } } } @@ -660,8 +647,6 @@ iAllowUpEvent = EFalse; } } - - iIsDeleted = NULL; } // ----------------------------------------------------------------------------- @@ -669,27 +654,12 @@ // ----------------------------------------------------------------------------- // TKeyResponse CAknPreviewPopUp::OfferKeyEventL( const TKeyEvent& /*aKeyEvent*/, - TEventCode aType ) + TEventCode /*aType*/ ) { - TKeyResponse ret ( EKeyWasNotConsumed ); - if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) ) { - if ( !( iFlags & CAknPreviewPopUpController::EConsumeKeys ) ) - { - iCloseMenu = ETrue; - iController.HidePopUp(); - } - else - { - if ( aType == EEventKey || aType == EEventKeyUp ) - { - iCloseMenu = ETrue; - iController.HidePopUp(); - - ret = EKeyWasConsumed; - } - } + iCloseMenu = ETrue; + iController.HidePopUp(); } if ( CapturesPointer() ) @@ -697,7 +667,7 @@ SetPointerCapture( EFalse ); } - return ret; + return EKeyWasNotConsumed; } // ----------------------------------------------------------------------------- @@ -727,16 +697,78 @@ // void CAknPreviewPopUp::Draw( const TRect& aRect ) const { - CWindowGc& gc = SystemGc(); + if( CAknEnv::Static()->TransparencyEnabled() ) + { + + CWindowGc& gc = SystemGc(); + + TRegionFix< 4 > region; + region.AddRect( Rect() ); + region.SubRect( iContent.Rect() ); + gc.SetClippingRegion( region ); + + DrawBackground( gc, aRect ); + + gc.CancelClippingRegion(); + } + else + { + CWindowGc& gc = SystemGc(); + MAknsSkinInstance* skin = AknsUtils::SkinInstance(); - TRegionFix<4> region; - region.AddRect( Rect() ); - region.SubRect( iContent.Rect() ); - gc.SetClippingRegion( region ); + if ( !AknsDrawUtils::Background( skin, iBgContext, gc, aRect ) ) + { + gc.Clear( aRect ); + } + + if ( HasHeading() ) + { + gc.SetClippingRect( aRect ); + + // heading graphics + TAknLayoutRect layoutRect; + layoutRect.LayoutRect( Rect(), + TAknWindowComponentLayout::Compose( + AknLayoutScalable_Avkon::heading_preview_pane(), + AknLayoutScalable_Avkon::bg_popup_heading_pane_cp2( 1 ) ).LayoutLine() ); + + TRect outerRect( layoutRect.Rect() ); + + layoutRect.LayoutRect( outerRect, + AknLayoutScalable_Avkon::bg_popup_heading_pane_g1() ); + + // There's no error checking since if skinned drawing fails heading + // text will be drawn on top of the background. + AknsDrawUtils::DrawFrame( skin, gc, outerRect, layoutRect.Rect(), + KAknsIIDQsnFrPopupHeading, KAknsIIDDefault ); + + // heading text + TAknLayoutText textLayout; + textLayout.LayoutText( Rect(), + TAknWindowComponentLayout::ComposeText( + AknLayoutScalable_Avkon::heading_preview_pane(), + AknLayoutScalable_Avkon::heading_preview_pane_t1( 1 ) ).LayoutLine() ); - DrawBackground( gc, aRect ); + gc.SetBrushStyle( CGraphicsContext::ENullBrush ); + + TRgb color( textLayout.Color() ); - gc.CancelClippingRegion(); + if ( iFlags & CAknPreviewPopUpController::ELayoutSubMenu ) + { + AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, + EAknsCIQsnTextColorsCG55 ); + } + else + { + AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, + EAknsCIQsnTextColorsCG19 ); + } + + textLayout.DrawText( gc, *iHeadingText, ETrue, color ); + + gc.CancelClippingRect(); + } + } } // ----------------------------------------------------------------------------- @@ -863,14 +895,6 @@ } } -// ----------------------------------------------------------------------------- -// CAknPreviewPopUp::CleanLocalRef -// ----------------------------------------------------------------------------- -// -void CAknPreviewPopUp::CleanLocalRef( TAny* aParam ) - { - static_cast( aParam )->iIsDeleted = NULL; - } +#endif // RD_SCALABLE_UI_V2 || RD_PREVIEW_POPUP // End of File -