uifw/AvKon/src/AknPreviewPopUp.cpp
branchRCL_3
changeset 19 aecbbf00d063
parent 18 fcdfafb36fe7
child 20 d48ab3b357f1
equal deleted inserted replaced
18:fcdfafb36fe7 19:aecbbf00d063
    28 #include <aknbutton.h>
    28 #include <aknbutton.h>
    29 #include <vwsdef.h>
    29 #include <vwsdef.h>
    30 #include <aknview.h>
    30 #include <aknview.h>
    31 #include <apgwgnam.h>
    31 #include <apgwgnam.h>
    32 #include <aknlayoutscalable_avkon.cdl.h>
    32 #include <aknlayoutscalable_avkon.cdl.h>
    33 #include <akntransitionutils.h>
    33 
    34 #include <AknTasHook.h> // for testability hooks
    34 #include <AknTasHook.h> // for testability hooks
    35 #include <touchfeedback.h>
    35 #include <touchfeedback.h>
    36 #include <gfxtranseffect/gfxtranseffect.h>
       
    37 #include <akntranseffect.h>
       
    38 #include <akntransitionutils.h>
       
    39 const TInt KWindowPosition = 1000;             // window's position
    36 const TInt KWindowPosition = 1000;             // window's position
    40 
    37 
    41 // ============================ MEMBER FUNCTIONS ===============================
    38 // ============================ MEMBER FUNCTIONS ===============================
    42 
    39 
    43 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
    44 // CAknPreviewPopUp::NewL
    41 // CAknPreviewPopUp::NewL
    45 // -----------------------------------------------------------------------------
    42 // -----------------------------------------------------------------------------
    46 //
    43 //
       
    44 #if defined( RD_SCALABLE_UI_V2 ) || defined( RD_PREVIEW_POPUP )
    47 CAknPreviewPopUp* CAknPreviewPopUp::NewL( CCoeControl& aContent,
    45 CAknPreviewPopUp* CAknPreviewPopUp::NewL( CCoeControl& aContent,
    48         CAknPreviewPopUpController& aController,
    46         CAknPreviewPopUpController& aController,
    49         const TInt aStyle )
    47         const TInt aStyle )
    50     {
    48     {
    51     CAknPreviewPopUp* self = new ( ELeave ) CAknPreviewPopUp( aContent, 
    49     CAknPreviewPopUp* self = new ( ELeave ) CAknPreviewPopUp( aContent, 
    68     : iContent( aContent ),
    66     : iContent( aContent ),
    69       iController( aController ),
    67       iController( aController ),
    70       iFlags( aStyle ),
    68       iFlags( aStyle ),
    71       iAllowUpEvent(EFalse)
    69       iAllowUpEvent(EFalse)
    72     {
    70     {
    73     GfxTransEffect::Register( this, KGfxPreviewPopupControlUid );
       
    74     }
    71     }
    75 
    72 
    76 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    77 // CAknPreviewPopUp::~CAknPreviewPopUp
    74 // CAknPreviewPopUp::~CAknPreviewPopUp
    78 // -----------------------------------------------------------------------------
    75 // -----------------------------------------------------------------------------
    79 //
    76 //
    80 CAknPreviewPopUp::~CAknPreviewPopUp()
    77 CAknPreviewPopUp::~CAknPreviewPopUp()
    81     {
    78     {
    82     if( iIsDeleted )
       
    83         {
       
    84     	*iIsDeleted = ETrue ;
       
    85         iIsDeleted = 0 ;
       
    86         }
       
    87 
       
    88     if ( IsVisible() )
       
    89         {
       
    90         iCloseMenu = ETrue;
       
    91         iController.HidePopUp();
       
    92         }
       
    93 		
       
    94     AKNTASHOOK_REMOVE();
    79     AKNTASHOOK_REMOVE();
    95     
       
    96     GfxTransEffect::Deregister( this );
       
    97 
       
    98     if ( CapturesPointer() )
    80     if ( CapturesPointer() )
    99         {
    81         {
   100         SetPointerCapture( EFalse );
    82         SetPointerCapture( EFalse );
   101         }
    83         }
   102 
    84 
   130     
   112     
   131     TRect nullRect( 0,0,0,0 );
   113     TRect nullRect( 0,0,0,0 );
   132     iBgContext = CAknsFrameBackgroundControlContext::NewL(
   114     iBgContext = CAknsFrameBackgroundControlContext::NewL(
   133         iFrameId, nullRect, nullRect, EFalse );
   115         iFrameId, nullRect, nullRect, EFalse );
   134 
   116 
   135     CreateWindowL();
       
   136     EnableWindowTransparency();
       
   137     
       
   138     TInt stackPriority = ECoeStackPriorityCba;
       
   139     
       
   140     if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) )
   117     if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) )
   141         {
   118         {
       
   119         
       
   120         CreateWindowL();
       
   121         
       
   122         // try to enable window transparency
       
   123         if( CAknEnv::Static()->TransparencyEnabled() )
       
   124             {
       
   125             Window().SetRequiredDisplayMode( EColor16MA );
       
   126             if ( Window().SetTransparencyAlphaChannel() == KErrNone )
       
   127                 {
       
   128                 
       
   129                 Window().SetBackgroundColor( ~0 );
       
   130                 }
       
   131             }
       
   132 
       
   133         iAvkonAppUi->AddToStackL( this, ECoeStackPriorityCba,
       
   134                                   ECoeStackFlagRefusesAllKeys |
       
   135                                   ECoeStackFlagRefusesFocus );
       
   136 
   142         Window().SetPointerGrab( ETrue );
   137         Window().SetPointerGrab( ETrue );
   143         SetGloballyCapturing( ETrue );
   138         SetGloballyCapturing( ETrue );
       
   139         //fix for TSW error PTPA-7HNA25
   144         Window().SetOrdinalPosition(KWindowPosition);
   140         Window().SetOrdinalPosition(KWindowPosition);
   145         }
   141         }
   146     else
   142     else
   147         {
   143         {
   148         stackPriority = ECoeStackPriorityDefault;
   144         CreateWindowL();
       
   145 
       
   146         // try to enable window transparency
       
   147         if( CAknEnv::Static()->TransparencyEnabled() )
       
   148             {
       
   149             Window().SetRequiredDisplayMode( EColor16MA );
       
   150             if ( Window().SetTransparencyAlphaChannel() == KErrNone )
       
   151                 {
       
   152                 
       
   153                 Window().SetBackgroundColor( ~0 );
       
   154                 }
       
   155             }
       
   156         
       
   157         iAvkonAppUi->AddToStackL( this, ECoeStackPriorityDefault,
       
   158                                   ECoeStackFlagRefusesAllKeys |
       
   159                                   ECoeStackFlagRefusesFocus );
       
   160                                   
   149         Window().SetOrdinalPosition( 0, ECoeWinPriorityNormal );
   161         Window().SetOrdinalPosition( 0, ECoeWinPriorityNormal );
   150         }
   162         }
   151 
   163 
   152     iAvkonAppUi->AddToStackL( this, stackPriority,
       
   153                               ECoeStackFlagRefusesAllKeys |
       
   154                               ECoeStackFlagRefusesFocus );
       
   155 
       
   156     EnableDragEvents();
   164     EnableDragEvents();
       
   165 
   157     SetComponentsToInheritVisibility( ETrue );
   166     SetComponentsToInheritVisibility( ETrue );
       
   167 
   158 
   168 
   159     iContent.SetBackground( this );
   169     iContent.SetBackground( this );
   160     iContent.SetContainerWindowL( *this );
   170     iContent.SetContainerWindowL( *this );
   161     iContent.ActivateL();
   171     iContent.ActivateL();
   162 
   172 
   169         layoutRect.LayoutRect( appWindow, AknLayoutScalable_Avkon::popup_preview_fixed_window().LayoutLine() );
   179         layoutRect.LayoutRect( appWindow, AknLayoutScalable_Avkon::popup_preview_fixed_window().LayoutLine() );
   170         
   180         
   171         SetRect( layoutRect.Rect() );
   181         SetRect( layoutRect.Rect() );
   172         }
   182         }
   173 
   183 
       
   184     DrawableWindow()->EnableBackup( EWindowBackupAreaBehind );
   174     MakeVisible( EFalse );   
   185     MakeVisible( EFalse );   
   175     ActivateL();
   186     ActivateL();
   176     }
   187     }
   177 
   188 
   178 // -----------------------------------------------------------------------------
   189 // -----------------------------------------------------------------------------
   181 //
   192 //
   182 void CAknPreviewPopUp::Show()
   193 void CAknPreviewPopUp::Show()
   183     {
   194     {
   184     if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) )
   195     if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) )
   185         {
   196         {
       
   197         //fix for TSW error PTPA-7HNA25
   186         Window().SetOrdinalPosition( 0 );
   198         Window().SetOrdinalPosition( 0 );
   187         iAvkonAppUi->UpdateStackedControlFlags( this, NULL,
   199         iAvkonAppUi->UpdateStackedControlFlags( this, NULL,
   188                                                 ECoeStackFlagRefusesAllKeys );
   200                                                 ECoeStackFlagRefusesAllKeys );
   189 
   201 
   190         SetPointerCapture( ETrue );
   202         if ( AknLayoutUtils::PenEnabled() )
       
   203             {
       
   204             SetPointerCapture( ETrue );
       
   205             }
   191         }
   206         }
   192 
   207 
   193     iCloseMenu = EFalse; 
   208     iCloseMenu = EFalse; 
   194     TBool useTfx = !( iFlags & CAknPreviewPopUpController::EPermanentMode 
   209     Window().Invalidate();
   195             || iFlags & CAknPreviewPopUpController::EFixedMode );
   210     MakeVisible( ETrue );
   196     
       
   197     if ( useTfx && GfxTransEffect::IsRegistered( this ) )
       
   198         {
       
   199         GfxTransEffect::Begin( this, KGfxControlAppearAction );
       
   200         MakeVisible( ETrue );
       
   201         GfxTransEffect::SetDemarcation( this, iPosition );
       
   202         GfxTransEffect::End( this );
       
   203         }
       
   204     else
       
   205         {
       
   206         MakeVisible( ETrue );
       
   207         }
       
   208     if( GrabbingComponent() )
   211     if( GrabbingComponent() )
   209         {
   212         {
   210         iCloseMenu = ETrue;
   213         iCloseMenu = ETrue;
   211         }
   214         }
   212     iController.NotifyObservers( MAknPreviewPopUpObserver::EPreviewPopUpShown );
   215     iController.NotifyObservers( MAknPreviewPopUpObserver::EPreviewPopUpShown );
   222             !( iFlags & CAknPreviewPopUpController::EPermanentMode ) ) )
   225             !( iFlags & CAknPreviewPopUpController::EPermanentMode ) ) )
   223         {
   226         {
   224         return; 
   227         return; 
   225         }
   228         }
   226 
   229 
   227     // Skip disappear transition if the popup is either permanent, fixed or
       
   228     // faded. Fading status is checked because there can't be two parallel
       
   229     // effects applied to the same window.
       
   230     TBool useTfx = !( iFlags & CAknPreviewPopUpController::EPermanentMode 
       
   231             || iFlags & CAknPreviewPopUpController::EFixedMode ) 
       
   232                     && !Window().IsFaded();
       
   233     
       
   234     if ( useTfx && GfxTransEffect::IsRegistered( this ) )
       
   235         {
       
   236         GfxTransEffect::Begin( this, KGfxControlDisappearAction );
       
   237         MakeVisible( EFalse );
       
   238         GfxTransEffect::End( this );
       
   239         }
       
   240     else
       
   241         {
       
   242         MakeVisible( EFalse );
       
   243         }
       
   244 
       
   245     Window().ClearRedrawStore();
   230     Window().ClearRedrawStore();
       
   231     MakeVisible( EFalse );
   246 
   232 
   247     if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) )
   233     if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) )
   248         {
   234         {
       
   235         //fix for TSW error PTPA-7HNA25
   249         Window().SetOrdinalPosition( KWindowPosition );
   236         Window().SetOrdinalPosition( KWindowPosition );
   250         iAvkonAppUi->UpdateStackedControlFlags( this,
   237         iAvkonAppUi->UpdateStackedControlFlags( this,
   251                                                 ECoeStackFlagRefusesAllKeys,
   238                                                 ECoeStackFlagRefusesAllKeys,
   252                                                 ECoeStackFlagRefusesAllKeys );
   239                                                 ECoeStackFlagRefusesAllKeys );
   253         }
   240         }
   414 
   401 
   415         AknsDrawUtils::Background( skin, cc, this, aGc, aRect ); 
   402         AknsDrawUtils::Background( skin, cc, this, aGc, aRect ); 
   416         }
   403         }
   417     }
   404     }
   418 
   405 
       
   406 // -----------------------------------------------------------------------------
       
   407 // CAknPreviewPopUp::MakeVisible
       
   408 // -----------------------------------------------------------------------------
       
   409 //
       
   410 void CAknPreviewPopUp::MakeVisible( TBool aVisible )
       
   411     {
       
   412     if ( aVisible != IsVisible() )
       
   413         {
       
   414         CCoeControl::MakeVisible( aVisible );
       
   415         }
       
   416     }
   419     
   417     
   420 // -----------------------------------------------------------------------------
   418 // -----------------------------------------------------------------------------
   421 // CAknPreviewPopUp::CountComponentControls
   419 // CAknPreviewPopUp::CountComponentControls
   422 // -----------------------------------------------------------------------------
   420 // -----------------------------------------------------------------------------
   423 //
   421 //
   523 // -----------------------------------------------------------------------------
   521 // -----------------------------------------------------------------------------
   524 // CAknPreviewPopUp::HandlePointerEventL
   522 // CAknPreviewPopUp::HandlePointerEventL
   525 // -----------------------------------------------------------------------------
   523 // -----------------------------------------------------------------------------
   526 //
   524 //
   527 void CAknPreviewPopUp::HandlePointerEventL( const TPointerEvent& aPointerEvent )
   525 void CAknPreviewPopUp::HandlePointerEventL( const TPointerEvent& aPointerEvent )
   528     {   
   526     {
   529 	TBool isDelete = EFalse; 
       
   530 	iIsDeleted = &isDelete;
       
   531 	
       
   532     if ( AknLayoutUtils::PenEnabled() )
   527     if ( AknLayoutUtils::PenEnabled() )
   533         {
   528         {
   534         iCloseMenu = EFalse;
   529         iCloseMenu = EFalse;
   535         if ( aPointerEvent.iType == TPointerEvent::EButton1Up && !IsVisible() )
   530         if ( aPointerEvent.iType == TPointerEvent::EButton1Up && !IsVisible() )
   536             {
   531             {
   537             SetPointerCapture( EFalse );
   532             SetPointerCapture( EFalse );
   538             }
   533             }
   539 
   534     
       
   535         CAknTouchPane* touchPane = iAvkonAppUi->TouchPane();
       
   536         
   540         // redirect pointer event to content
   537         // redirect pointer event to content
   541         if ( Rect().Contains( aPointerEvent.iPosition ) && IsVisible() )
   538         if ( Rect().Contains( aPointerEvent.iPosition ) && IsVisible() )
   542             {
   539             {
   543             iAllowUpEvent = ETrue;         
   540             iAllowUpEvent = ETrue;
   544             CleanupStack::PushL( TCleanupItem( CleanLocalRef, this ) );
       
   545             CCoeControl::HandlePointerEventL( aPointerEvent );
   541             CCoeControl::HandlePointerEventL( aPointerEvent );
   546             CleanupStack::Pop();
       
   547             if( isDelete )
       
   548             	{
       
   549             	return;
       
   550             	}
       
   551             if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) && aPointerEvent.iType == TPointerEvent::EButton1Up && IsVisible() )
   542             if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) && aPointerEvent.iType == TPointerEvent::EButton1Up && IsVisible() )
   552                 {
   543                 {
   553             	  // if pointer up is already redirected to the content, but the popup is still visible,
   544             	  // if pointer up is already redirected to the content, but the popup is still visible,
   554             	  // then the original timeout has already happened and we need to reset the timer.
   545             	  // then the original timeout has already happened and we need to reset the timer.
   555             	  // TSW Error EJZG-7JR3PC.
   546             	  // TSW Error EJZG-7JR3PC.
   556             	  iController.ResetTimer();
   547             	  iController.ResetTimer();
   557                 }
   548                 }
   558             }
   549             }
   559         else
   550         else
   560             {
   551             {
       
   552             if ( touchPane )
       
   553                 {
       
   554                 if ( touchPane->IsVisible() )
       
   555                     {
       
   556                     // touchpane is a window-owning control -> Rect() cannot be used
       
   557                     TRect touchPaneRect( touchPane->Position(), touchPane->Size() );
       
   558                 
       
   559                     if ( touchPaneRect.Contains( aPointerEvent.iParentPosition ) )
       
   560                         {
       
   561                         TPointerEvent pointerEvent( aPointerEvent );
       
   562                     
       
   563                         // make event's coordinates touch pane relative
       
   564                         pointerEvent.iPosition = aPointerEvent.iParentPosition - 
       
   565                                                  touchPaneRect.iTl;
       
   566                     
       
   567                         static_cast<CCoeControl*>( touchPane )->HandlePointerEventL( 
       
   568                                                                     pointerEvent );
       
   569                         }
       
   570                     }
       
   571                 }
   561             if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) && 
   572             if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) && 
   562                 aPointerEvent.iType != TPointerEvent::EDrag &&
   573                 aPointerEvent.iType != TPointerEvent::EDrag &&
   563                 aPointerEvent.iType != TPointerEvent::EButtonRepeat )
   574                 aPointerEvent.iType != TPointerEvent::EButtonRepeat )
   564                 {
   575                 {
   565                 
   576                 
   572                     // All other events outside popup's rect (mainly down)
   583                     // All other events outside popup's rect (mainly down)
   573                     // hides the popup
   584                     // hides the popup
   574                     
   585                     
   575                     if ( aPointerEvent.iType != TPointerEvent::EButton1Up )
   586                     if ( aPointerEvent.iType != TPointerEvent::EButton1Up )
   576                         {
   587                         {
   577                         // popup will be hiden when EButton1Down comes.
       
   578                         MTouchFeedback* feedback = MTouchFeedback::Instance();
   588                         MTouchFeedback* feedback = MTouchFeedback::Instance();
   579                         if ( feedback )
   589                         if ( feedback )
   580                             {
   590                             {
   581                             TTouchLogicalFeedback feedbackType = ETouchFeedbackPopUp;
   591                             feedback->InstantFeedback( ETouchFeedbackPopUp );
   582                             if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) )
       
   583                                 {
       
   584                                 feedbackType = ETouchFeedbackOptionsMenuClosed;
       
   585                                 }
       
   586                             feedback->InstantFeedback( feedbackType );
       
   587                             }        
   592                             }        
   588                         iCloseMenu = ETrue; 
   593                         iCloseMenu = ETrue; 
   589                         iController.HidePopUp(); 
   594                         iController.HidePopUp(); 
   590                         }
   595                         }
   591                     else if ( IsVisible() )
   596                     else if ( IsVisible() )
   605                                                        ETouchFeedbackVibra,
   610                                                        ETouchFeedbackVibra,
   606                                                        aPointerEvent );
   611                                                        aPointerEvent );
   607                             }
   612                             }
   608                         else
   613                         else
   609                             {
   614                             {
   610                             // popup will be hiden when EButton1Down comes.
       
   611                             TTouchLogicalFeedback feedbackType = ETouchFeedbackPopUp;
       
   612                             if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) )
       
   613                                 {
       
   614                                 feedbackType = ETouchFeedbackOptionsMenuClosed;
       
   615                                 }
       
   616                             feedback->InstantFeedback( this,
   615                             feedback->InstantFeedback( this,
   617                                                        feedbackType,
   616                                                        ETouchFeedbackPopUp,
   618                                                        aPointerEvent );
   617                                                        aPointerEvent );
   619                             }
   618                             }
   620                         }
   619                         }
   621                     iCloseMenu = ETrue;
   620                     iCloseMenu = ETrue;
   622                     iController.HidePopUp();
   621                     iController.HidePopUp();    
   623                     }          
   622                     }          
   624                 }
   623                 }
   625                 
   624                 
   626             // If EDontClose flag is on, also button up is forwarded for base class    
   625             // If EDontClose flag is on, also button up is forwarded for base class    
   627             if ( iFlags & CAknPreviewPopUpController::EDontClose )
   626             if ( iFlags & CAknPreviewPopUpController::EDontClose )
   628                 {
   627                 {
   629                 if ( aPointerEvent.iType == TPointerEvent::EDrag || 
   628                 if ( aPointerEvent.iType == TPointerEvent::EDrag || 
   630                     aPointerEvent.iType == TPointerEvent::EButtonRepeat ||
   629                     aPointerEvent.iType == TPointerEvent::EButtonRepeat ||
   631                     (aPointerEvent.iType == TPointerEvent::EButton1Up && iAllowUpEvent ) )
   630                     (aPointerEvent.iType == TPointerEvent::EButton1Up && iAllowUpEvent ) )
   632                     {
   631                     {
   633                     CleanupStack::PushL( TCleanupItem( CleanLocalRef, this ) );
       
   634                     CCoeControl::HandlePointerEventL( aPointerEvent );
   632                     CCoeControl::HandlePointerEventL( aPointerEvent );
   635                     CleanupStack::Pop();
       
   636                     if( isDelete )
       
   637                     	{
       
   638                     	return;
       
   639                     	}
       
   640                     }
   633                     }
   641                 }
   634                 }
   642             else
   635             else
   643                 {
   636                 {
   644                 if ( aPointerEvent.iType == TPointerEvent::EDrag || 
   637                 if ( aPointerEvent.iType == TPointerEvent::EDrag || 
   645                     aPointerEvent.iType == TPointerEvent::EButtonRepeat )
   638                     aPointerEvent.iType == TPointerEvent::EButtonRepeat )
   646                     {
   639                     {
   647                     CleanupStack::PushL( TCleanupItem( CleanLocalRef, this ) );
       
   648                     CCoeControl::HandlePointerEventL( aPointerEvent );
   640                     CCoeControl::HandlePointerEventL( aPointerEvent );
   649                     CleanupStack::Pop();
       
   650                     if( isDelete )
       
   651                     	{
       
   652                     	return;
       
   653                     	}
       
   654                     }
   641                     }
   655                 }
   642                 }
   656                 
   643                 
   657             }
   644             }
   658         if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   645         if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   659             {
   646             {
   660             iAllowUpEvent = EFalse;
   647             iAllowUpEvent = EFalse;
   661             }
   648             }
   662         }
   649         }
   663        
       
   664     iIsDeleted = NULL;
       
   665     }
   650     }
   666     
   651     
   667 // -----------------------------------------------------------------------------
   652 // -----------------------------------------------------------------------------
   668 // CAknPreviewPopUp::OfferKeyEventL
   653 // CAknPreviewPopUp::OfferKeyEventL
   669 // -----------------------------------------------------------------------------
   654 // -----------------------------------------------------------------------------
   670 //
   655 //
   671 TKeyResponse CAknPreviewPopUp::OfferKeyEventL( const TKeyEvent& /*aKeyEvent*/,
   656 TKeyResponse CAknPreviewPopUp::OfferKeyEventL( const TKeyEvent& /*aKeyEvent*/,
   672                                                TEventCode aType )
   657                                                TEventCode /*aType*/ )
   673     {
   658     {
   674     TKeyResponse ret ( EKeyWasNotConsumed );
       
   675 
       
   676     if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) )
   659     if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) )
   677         {
   660         {
   678         if ( !( iFlags & CAknPreviewPopUpController::EConsumeKeys ) )
   661         iCloseMenu = ETrue; 
   679             {
   662         iController.HidePopUp();
   680             iCloseMenu = ETrue;
   663         }
   681             iController.HidePopUp();
   664 
       
   665     if ( CapturesPointer() )
       
   666         {
       
   667         SetPointerCapture( EFalse );
       
   668         }
       
   669 
       
   670     return EKeyWasNotConsumed;
       
   671     }
       
   672     
       
   673 // -----------------------------------------------------------------------------
       
   674 // CAknPreviewPopUp::MopSupplyObject
       
   675 // -----------------------------------------------------------------------------
       
   676 //
       
   677 TTypeUid::Ptr CAknPreviewPopUp::MopSupplyObject( TTypeUid aId )
       
   678     {
       
   679     if ( aId.iUid == MAknsControlContext::ETypeId )
       
   680         {
       
   681         if ( iBgContext )
       
   682             {
       
   683             return MAknsControlContext::SupplyMopObject( aId, iBgContext );
   682             }
   684             }
   683         else
   685         else
   684             {
   686             {
   685             if ( aType == EEventKey || aType == EEventKeyUp )
       
   686                 {
       
   687                 iCloseMenu = ETrue;
       
   688                 iController.HidePopUp();
       
   689 
       
   690                 ret = EKeyWasConsumed;
       
   691                 }
       
   692             }
       
   693         }
       
   694 
       
   695     if ( CapturesPointer() )
       
   696         {
       
   697         SetPointerCapture( EFalse );
       
   698         }
       
   699 
       
   700     return ret;
       
   701     }
       
   702     
       
   703 // -----------------------------------------------------------------------------
       
   704 // CAknPreviewPopUp::MopSupplyObject
       
   705 // -----------------------------------------------------------------------------
       
   706 //
       
   707 TTypeUid::Ptr CAknPreviewPopUp::MopSupplyObject( TTypeUid aId )
       
   708     {
       
   709     if ( aId.iUid == MAknsControlContext::ETypeId )
       
   710         {
       
   711         if ( iBgContext )
       
   712             {
       
   713             return MAknsControlContext::SupplyMopObject( aId, iBgContext );
       
   714             }
       
   715         else
       
   716             {
       
   717             return TTypeUid::Null();
   687             return TTypeUid::Null();
   718             }
   688             }
   719         }
   689         }
   720         
   690         
   721     return CCoeControl::MopSupplyObject( aId );
   691     return CCoeControl::MopSupplyObject( aId );
   725 // CAknPreviewPopUp::Draw
   695 // CAknPreviewPopUp::Draw
   726 // -----------------------------------------------------------------------------
   696 // -----------------------------------------------------------------------------
   727 //
   697 //
   728 void CAknPreviewPopUp::Draw( const TRect& aRect ) const
   698 void CAknPreviewPopUp::Draw( const TRect& aRect ) const
   729     {
   699     {
   730     CWindowGc& gc = SystemGc();
   700     if( CAknEnv::Static()->TransparencyEnabled() )
   731 
   701         {
   732     TRegionFix<4> region;
   702     
   733     region.AddRect( Rect() );
   703         CWindowGc& gc = SystemGc();
   734     region.SubRect( iContent.Rect() );
   704 
   735     gc.SetClippingRegion( region );
   705         TRegionFix< 4 > region;
   736 
   706         region.AddRect( Rect() );
   737     DrawBackground( gc, aRect );
   707         region.SubRect( iContent.Rect() );
   738 
   708         gc.SetClippingRegion( region );
   739     gc.CancelClippingRegion();
   709     
       
   710         DrawBackground( gc, aRect );
       
   711 
       
   712         gc.CancelClippingRegion();
       
   713         }
       
   714     else
       
   715         {
       
   716         CWindowGc& gc = SystemGc();
       
   717         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   718 
       
   719         if ( !AknsDrawUtils::Background( skin, iBgContext, gc, aRect ) )
       
   720             {
       
   721             gc.Clear( aRect );
       
   722             }
       
   723     
       
   724         if ( HasHeading() )
       
   725             {
       
   726             gc.SetClippingRect( aRect );
       
   727         
       
   728             // heading graphics
       
   729             TAknLayoutRect layoutRect;
       
   730             layoutRect.LayoutRect( Rect(),
       
   731                 TAknWindowComponentLayout::Compose( 
       
   732                 AknLayoutScalable_Avkon::heading_preview_pane(),
       
   733                 AknLayoutScalable_Avkon::bg_popup_heading_pane_cp2( 1 ) ).LayoutLine() );
       
   734         
       
   735             TRect outerRect( layoutRect.Rect() );
       
   736         
       
   737             layoutRect.LayoutRect( outerRect, 
       
   738                 AknLayoutScalable_Avkon::bg_popup_heading_pane_g1() );
       
   739             
       
   740             // There's no error checking since if skinned drawing fails heading 
       
   741             // text will be drawn on top of the background.
       
   742             AknsDrawUtils::DrawFrame( skin, gc, outerRect, layoutRect.Rect(), 
       
   743                 KAknsIIDQsnFrPopupHeading, KAknsIIDDefault );
       
   744         
       
   745             // heading text                               
       
   746             TAknLayoutText textLayout;
       
   747             textLayout.LayoutText( Rect(),
       
   748                 TAknWindowComponentLayout::ComposeText(
       
   749                 AknLayoutScalable_Avkon::heading_preview_pane(),
       
   750                 AknLayoutScalable_Avkon::heading_preview_pane_t1( 1 ) ).LayoutLine() );
       
   751 
       
   752             gc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
   753             
       
   754             TRgb color( textLayout.Color() );
       
   755 
       
   756             if ( iFlags & CAknPreviewPopUpController::ELayoutSubMenu )
       
   757                 {
       
   758                 AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors,
       
   759                      EAknsCIQsnTextColorsCG55 );
       
   760                 }
       
   761             else
       
   762                 {
       
   763                 AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors,
       
   764                      EAknsCIQsnTextColorsCG19 );
       
   765                 }
       
   766         
       
   767             textLayout.DrawText( gc, *iHeadingText, ETrue, color );
       
   768         
       
   769             gc.CancelClippingRect();
       
   770             }
       
   771         }
   740     }
   772     }
   741 
   773 
   742 // -----------------------------------------------------------------------------
   774 // -----------------------------------------------------------------------------
   743 // CAknPreviewPopUp::CenterLayout
   775 // CAknPreviewPopUp::CenterLayout
   744 // -----------------------------------------------------------------------------
   776 // -----------------------------------------------------------------------------
   861         
   893         
   862         aGc.CancelClippingRect();
   894         aGc.CancelClippingRect();
   863         }   
   895         }   
   864     }
   896     }
   865 
   897 
   866 // -----------------------------------------------------------------------------
   898 #endif // RD_SCALABLE_UI_V2 || RD_PREVIEW_POPUP
   867 // CAknPreviewPopUp::CleanLocalRef
       
   868 // -----------------------------------------------------------------------------
       
   869 //
       
   870 void CAknPreviewPopUp::CleanLocalRef( TAny* aParam )
       
   871     {
       
   872     static_cast<CAknPreviewPopUp*>( aParam )->iIsDeleted = NULL;
       
   873     }
       
   874 
   899 
   875 //  End of File  
   900 //  End of File  
   876