uifw/AvKon/src/AknPreviewPopUp.cpp
changeset 14 3320e4e6e8bb
parent 0 2f259fa3e83a
equal deleted inserted replaced
0:2f259fa3e83a 14:3320e4e6e8bb
    31 #include <apgwgnam.h>
    31 #include <apgwgnam.h>
    32 #include <aknlayoutscalable_avkon.cdl.h>
    32 #include <aknlayoutscalable_avkon.cdl.h>
    33 
    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 <akntransitionutils.h>
       
    38 const TInt KWindowPosition = 1000;             // window's position
    36 const TInt KWindowPosition = 1000;             // window's position
    39 
    37 
    40 // ============================ MEMBER FUNCTIONS ===============================
    38 // ============================ MEMBER FUNCTIONS ===============================
    41 
    39 
    42 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
    43 // CAknPreviewPopUp::NewL
    41 // CAknPreviewPopUp::NewL
    44 // -----------------------------------------------------------------------------
    42 // -----------------------------------------------------------------------------
    45 //
    43 //
       
    44 #if defined( RD_SCALABLE_UI_V2 ) || defined( RD_PREVIEW_POPUP )
    46 CAknPreviewPopUp* CAknPreviewPopUp::NewL( CCoeControl& aContent,
    45 CAknPreviewPopUp* CAknPreviewPopUp::NewL( CCoeControl& aContent,
    47         CAknPreviewPopUpController& aController,
    46         CAknPreviewPopUpController& aController,
    48         const TInt aStyle )
    47         const TInt aStyle )
    49     {
    48     {
    50     CAknPreviewPopUp* self = new ( ELeave ) CAknPreviewPopUp( aContent, 
    49     CAknPreviewPopUp* self = new ( ELeave ) CAknPreviewPopUp( aContent, 
    67     : iContent( aContent ),
    66     : iContent( aContent ),
    68       iController( aController ),
    67       iController( aController ),
    69       iFlags( aStyle ),
    68       iFlags( aStyle ),
    70       iAllowUpEvent(EFalse)
    69       iAllowUpEvent(EFalse)
    71     {
    70     {
    72     GfxTransEffect::Register( this, KGfxPreviewPopupControlUid );
       
    73     }
    71     }
    74 
    72 
    75 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    76 // CAknPreviewPopUp::~CAknPreviewPopUp
    74 // CAknPreviewPopUp::~CAknPreviewPopUp
    77 // -----------------------------------------------------------------------------
    75 // -----------------------------------------------------------------------------
    78 //
    76 //
    79 CAknPreviewPopUp::~CAknPreviewPopUp()
    77 CAknPreviewPopUp::~CAknPreviewPopUp()
    80     {
    78     {
    81     AKNTASHOOK_REMOVE();
    79     AKNTASHOOK_REMOVE();
    82 
       
    83     GfxTransEffect::Deregister( this );
       
    84 
       
    85     if ( CapturesPointer() )
    80     if ( CapturesPointer() )
    86         {
    81         {
    87         SetPointerCapture( EFalse );
    82         SetPointerCapture( EFalse );
    88         }
    83         }
    89 
    84 
   117     
   112     
   118     TRect nullRect( 0,0,0,0 );
   113     TRect nullRect( 0,0,0,0 );
   119     iBgContext = CAknsFrameBackgroundControlContext::NewL(
   114     iBgContext = CAknsFrameBackgroundControlContext::NewL(
   120         iFrameId, nullRect, nullRect, EFalse );
   115         iFrameId, nullRect, nullRect, EFalse );
   121 
   116 
   122     CreateWindowL();
       
   123     EnableWindowTransparency();
       
   124     
       
   125     TInt stackPriority = ECoeStackPriorityCba;
       
   126     
       
   127     if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) )
   117     if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) )
   128         {
   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 
   129         Window().SetPointerGrab( ETrue );
   137         Window().SetPointerGrab( ETrue );
   130         SetGloballyCapturing( ETrue );
   138         SetGloballyCapturing( ETrue );
       
   139         //fix for TSW error PTPA-7HNA25
   131         Window().SetOrdinalPosition(KWindowPosition);
   140         Window().SetOrdinalPosition(KWindowPosition);
   132         }
   141         }
   133     else
   142     else
   134         {
   143         {
   135         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                                   
   136         Window().SetOrdinalPosition( 0, ECoeWinPriorityNormal );
   161         Window().SetOrdinalPosition( 0, ECoeWinPriorityNormal );
   137         }
   162         }
   138 
   163 
   139     iAvkonAppUi->AddToStackL( this, stackPriority,
       
   140                               ECoeStackFlagRefusesAllKeys |
       
   141                               ECoeStackFlagRefusesFocus );
       
   142 
       
   143     EnableDragEvents();
   164     EnableDragEvents();
       
   165 
   144     SetComponentsToInheritVisibility( ETrue );
   166     SetComponentsToInheritVisibility( ETrue );
       
   167 
   145 
   168 
   146     iContent.SetBackground( this );
   169     iContent.SetBackground( this );
   147     iContent.SetContainerWindowL( *this );
   170     iContent.SetContainerWindowL( *this );
   148     iContent.ActivateL();
   171     iContent.ActivateL();
   149 
   172 
   156         layoutRect.LayoutRect( appWindow, AknLayoutScalable_Avkon::popup_preview_fixed_window().LayoutLine() );
   179         layoutRect.LayoutRect( appWindow, AknLayoutScalable_Avkon::popup_preview_fixed_window().LayoutLine() );
   157         
   180         
   158         SetRect( layoutRect.Rect() );
   181         SetRect( layoutRect.Rect() );
   159         }
   182         }
   160 
   183 
       
   184     DrawableWindow()->EnableBackup( EWindowBackupAreaBehind );
   161     MakeVisible( EFalse );   
   185     MakeVisible( EFalse );   
   162     ActivateL();
   186     ActivateL();
   163     }
   187     }
   164 
   188 
   165 // -----------------------------------------------------------------------------
   189 // -----------------------------------------------------------------------------
   168 //
   192 //
   169 void CAknPreviewPopUp::Show()
   193 void CAknPreviewPopUp::Show()
   170     {
   194     {
   171     if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) )
   195     if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) )
   172         {
   196         {
       
   197         //fix for TSW error PTPA-7HNA25
   173         Window().SetOrdinalPosition( 0 );
   198         Window().SetOrdinalPosition( 0 );
   174         iAvkonAppUi->UpdateStackedControlFlags( this, NULL,
   199         iAvkonAppUi->UpdateStackedControlFlags( this, NULL,
   175                                                 ECoeStackFlagRefusesAllKeys );
   200                                                 ECoeStackFlagRefusesAllKeys );
   176 
   201 
   177         SetPointerCapture( ETrue );
   202         if ( AknLayoutUtils::PenEnabled() )
       
   203             {
       
   204             SetPointerCapture( ETrue );
       
   205             }
   178         }
   206         }
   179 
   207 
   180     iCloseMenu = EFalse; 
   208     iCloseMenu = EFalse; 
   181     TBool useTfx = !( iFlags & CAknPreviewPopUpController::EPermanentMode 
   209     Window().Invalidate();
   182             || iFlags & CAknPreviewPopUpController::EFixedMode );
   210     MakeVisible( ETrue );
   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() )
   211     if( GrabbingComponent() )
   196         {
   212         {
   197         iCloseMenu = ETrue;
   213         iCloseMenu = ETrue;
   198         }
   214         }
   199     iController.NotifyObservers( MAknPreviewPopUpObserver::EPreviewPopUpShown );
   215     iController.NotifyObservers( MAknPreviewPopUpObserver::EPreviewPopUpShown );
   209             !( iFlags & CAknPreviewPopUpController::EPermanentMode ) ) )
   225             !( iFlags & CAknPreviewPopUpController::EPermanentMode ) ) )
   210         {
   226         {
   211         return; 
   227         return; 
   212         }
   228         }
   213 
   229 
   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();
   230     Window().ClearRedrawStore();
       
   231     MakeVisible( EFalse );
   229 
   232 
   230     if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) )
   233     if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) )
   231         {
   234         {
       
   235         //fix for TSW error PTPA-7HNA25
   232         Window().SetOrdinalPosition( KWindowPosition );
   236         Window().SetOrdinalPosition( KWindowPosition );
   233         iAvkonAppUi->UpdateStackedControlFlags( this,
   237         iAvkonAppUi->UpdateStackedControlFlags( this,
   234                                                 ECoeStackFlagRefusesAllKeys,
   238                                                 ECoeStackFlagRefusesAllKeys,
   235                                                 ECoeStackFlagRefusesAllKeys );
   239                                                 ECoeStackFlagRefusesAllKeys );
   236         }
   240         }
   397 
   401 
   398         AknsDrawUtils::Background( skin, cc, this, aGc, aRect ); 
   402         AknsDrawUtils::Background( skin, cc, this, aGc, aRect ); 
   399         }
   403         }
   400     }
   404     }
   401 
   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     }
   402     
   417     
   403 // -----------------------------------------------------------------------------
   418 // -----------------------------------------------------------------------------
   404 // CAknPreviewPopUp::CountComponentControls
   419 // CAknPreviewPopUp::CountComponentControls
   405 // -----------------------------------------------------------------------------
   420 // -----------------------------------------------------------------------------
   406 //
   421 //
   514         iCloseMenu = EFalse;
   529         iCloseMenu = EFalse;
   515         if ( aPointerEvent.iType == TPointerEvent::EButton1Up && !IsVisible() )
   530         if ( aPointerEvent.iType == TPointerEvent::EButton1Up && !IsVisible() )
   516             {
   531             {
   517             SetPointerCapture( EFalse );
   532             SetPointerCapture( EFalse );
   518             }
   533             }
   519 
   534     
       
   535         CAknTouchPane* touchPane = iAvkonAppUi->TouchPane();
       
   536         
   520         // redirect pointer event to content
   537         // redirect pointer event to content
   521         if ( Rect().Contains( aPointerEvent.iPosition ) && IsVisible() )
   538         if ( Rect().Contains( aPointerEvent.iPosition ) && IsVisible() )
   522             {
   539             {
   523             iAllowUpEvent = ETrue;
   540             iAllowUpEvent = ETrue;
   524             CCoeControl::HandlePointerEventL( aPointerEvent );
   541             CCoeControl::HandlePointerEventL( aPointerEvent );
   530             	  iController.ResetTimer();
   547             	  iController.ResetTimer();
   531                 }
   548                 }
   532             }
   549             }
   533         else
   550         else
   534             {
   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                 }
   535             if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) && 
   572             if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) && 
   536                 aPointerEvent.iType != TPointerEvent::EDrag &&
   573                 aPointerEvent.iType != TPointerEvent::EDrag &&
   537                 aPointerEvent.iType != TPointerEvent::EButtonRepeat )
   574                 aPointerEvent.iType != TPointerEvent::EButtonRepeat )
   538                 {
   575                 {
   539                 
   576                 
   658 // CAknPreviewPopUp::Draw
   695 // CAknPreviewPopUp::Draw
   659 // -----------------------------------------------------------------------------
   696 // -----------------------------------------------------------------------------
   660 //
   697 //
   661 void CAknPreviewPopUp::Draw( const TRect& aRect ) const
   698 void CAknPreviewPopUp::Draw( const TRect& aRect ) const
   662     {
   699     {
   663     CWindowGc& gc = SystemGc();
   700     if( CAknEnv::Static()->TransparencyEnabled() )
   664 
   701         {
   665     TRegionFix<4> region;
   702     
   666     region.AddRect( Rect() );
   703         CWindowGc& gc = SystemGc();
   667     region.SubRect( iContent.Rect() );
   704 
   668     gc.SetClippingRegion( region );
   705         TRegionFix< 4 > region;
   669 
   706         region.AddRect( Rect() );
   670     DrawBackground( gc, aRect );
   707         region.SubRect( iContent.Rect() );
   671 
   708         gc.SetClippingRegion( region );
   672     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         }
   673     }
   772     }
   674 
   773 
   675 // -----------------------------------------------------------------------------
   774 // -----------------------------------------------------------------------------
   676 // CAknPreviewPopUp::CenterLayout
   775 // CAknPreviewPopUp::CenterLayout
   677 // -----------------------------------------------------------------------------
   776 // -----------------------------------------------------------------------------
   794         
   893         
   795         aGc.CancelClippingRect();
   894         aGc.CancelClippingRect();
   796         }   
   895         }   
   797     }
   896     }
   798 
   897 
       
   898 #endif // RD_SCALABLE_UI_V2 || RD_PREVIEW_POPUP
       
   899 
   799 //  End of File  
   900 //  End of File  
   800