idlehomescreen/xmluirendering/uiengine/src/xncontroladapterimpl.cpp
branchRCL_3
changeset 35 3321d3e205b6
parent 34 5456b4e8b3a8
equal deleted inserted replaced
34:5456b4e8b3a8 35:3321d3e205b6
    59 #include "xnpanic.h"
    59 #include "xnpanic.h"
    60 #include "xnviewdata.h"
    60 #include "xnviewdata.h"
    61 #include "xnscrollablecontroladapter.h"
    61 #include "xnscrollablecontroladapter.h"
    62 #include "xnfocuscontrol.h"
    62 #include "xnfocuscontrol.h"
    63 #include "xneditmode.h"
    63 #include "xneditmode.h"
       
    64 #include "xnviewswitcher.h"
    64 
    65 
    65 _LIT8(KScrollableBoxNodeName, "scrollablebox");
    66 _LIT8(KScrollableBoxNodeName, "scrollablebox");
    66 _LIT8( KView, "view" );
    67 _LIT8( KView, "view" );
    67 
    68 
    68 // Constants
    69 // Constants
   205 static TBool CreateGestureHelperL( CXnNode& aNode );
   206 static TBool CreateGestureHelperL( CXnNode& aNode );
   206 static TInt AccessResourceFileL(
   207 static TInt AccessResourceFileL(
   207     CXnResource& aResource, RFile& aFile, RFs& aFsSession );
   208     CXnResource& aResource, RFile& aFile, RFs& aFsSession );
   208 static void DrawFocusAppearance( CXnNode& aNode, CWindowGc& aGc );
   209 static void DrawFocusAppearance( CXnNode& aNode, CWindowGc& aGc );
   209 static CXnDomNode* HasHoldTrigger( CXnDomNode* aNode );
   210 static CXnDomNode* HasHoldTrigger( CXnDomNode* aNode );
   210 static void CancelFocusRefusalL( CXnUiEngine& aUiEngine );
       
   211     
   211     
   212 // ============================= LOCAL FUNCTIONS ===============================
   212 // ============================= LOCAL FUNCTIONS ===============================
   213 // -----------------------------------------------------------------------------
   213 // -----------------------------------------------------------------------------
   214 // -----------------------------------------------------------------------------
   214 // -----------------------------------------------------------------------------
   215 // 
   215 // 
  3412 
  3412 
  3413     return NULL;
  3413     return NULL;
  3414     }
  3414     }
  3415 
  3415 
  3416 // -----------------------------------------------------------------------------
  3416 // -----------------------------------------------------------------------------
  3417 // CancelFocusRefusalL
       
  3418 // Cancels focus refusal
       
  3419 // -----------------------------------------------------------------------------
       
  3420 //
       
  3421 static void CancelFocusRefusalL( CXnUiEngine& aUiEngine )
       
  3422     {
       
  3423     CXnNode* focused( aUiEngine.FocusedNode() );
       
  3424     
       
  3425     if ( focused )
       
  3426         {
       
  3427         CXnControlAdapter* control( focused->Control() );
       
  3428         
       
  3429         if ( control && control->RefusesFocusLoss() )
       
  3430             {
       
  3431             focused->HideTooltipsL();
       
  3432             
       
  3433             // It is now time to give up holding focus
       
  3434             focused->UnsetStateL( 
       
  3435                 XnPropertyNames::style::common::KFocus );
       
  3436             }
       
  3437         }    
       
  3438     }
       
  3439 
       
  3440 // -----------------------------------------------------------------------------
       
  3441 // Calculates scaled bitmap size (rect)
  3417 // Calculates scaled bitmap size (rect)
  3442 // -----------------------------------------------------------------------------
  3418 // -----------------------------------------------------------------------------
  3443 //
  3419 //
  3444 void CalculateScaledBitmapRect( TSize& aScaledSize, const TSize& aDrawSize,
  3420 void CalculateScaledBitmapRect( TSize& aScaledSize, const TSize& aDrawSize,
  3445     const TSize& aImageSize )    
  3421     const TSize& aImageSize )    
  3688          aKeyEvent.iCode == EKeyEnter )
  3664          aKeyEvent.iCode == EKeyEnter )
  3689         {
  3665         {
  3690         if ( aType == EEventKeyDown )
  3666         if ( aType == EEventKeyDown )
  3691             {            
  3667             {            
  3692             iLongtap = EFalse;
  3668             iLongtap = EFalse;
  3693             
  3669                         
  3694             if ( aKeyEvent.iScanCode == EStdKeyDevice3 ||
       
  3695                  aKeyEvent.iCode == EKeyEnter )
       
  3696                 {
       
  3697                 if ( node->IsStateSet( XnPropertyNames::style::common::KFocus ) )
       
  3698                     {
       
  3699                     // Set "pressed down"
       
  3700                     node->SetStateL( 
       
  3701                         XnPropertyNames::style::common::KPressedDown );
       
  3702                     
       
  3703                     node->UiEngine()->RenderUIL();
       
  3704                     }                
       
  3705                 }
       
  3706             
       
  3707             _LIT8( KDown, "3" ); // EEventKeyDown == 3
  3670             _LIT8( KDown, "3" ); // EEventKeyDown == 3
  3708             
  3671             
  3709             CXnNode* keydown( BuildTriggerNodeL( *engine,                
  3672             CXnNode* keydown( BuildTriggerNodeL( *engine,                
  3710                 XnPropertyNames::action::trigger::name::KActivate,
  3673                 XnPropertyNames::action::trigger::name::KActivate,
  3711                 XnPropertyNames::action::trigger::name::keyevent::KEventType, KDown ) );                
  3674                 XnPropertyNames::action::trigger::name::keyevent::KEventType, KDown ) );                
  3763                     node->ReportXuikonEventL( *keyup );
  3726                     node->ReportXuikonEventL( *keyup );
  3764                     
  3727                     
  3765                     CleanupStack::PopAndDestroy( keyup );                    
  3728                     CleanupStack::PopAndDestroy( keyup );                    
  3766                     }
  3729                     }
  3767                 }
  3730                 }
  3768             
  3731                         
  3769             if ( aKeyEvent.iScanCode == EStdKeyDevice3 ||
       
  3770                  aKeyEvent.iCode == EKeyEnter )
       
  3771                 {
       
  3772                 // Reset "pressed down"
       
  3773                 node->UnsetStateL( 
       
  3774                     XnPropertyNames::style::common::KPressedDown );
       
  3775                 
       
  3776                 node->UiEngine()->RenderUIL();
       
  3777                 }                                    
       
  3778             
       
  3779             iLongtap = EFalse;
  3732             iLongtap = EFalse;
  3780             }
  3733             }
  3781         }
  3734         }
  3782     else
  3735     else
  3783         {
  3736         {
  3821             XnPropertyNames::common::KLongTap ) );
  3774             XnPropertyNames::common::KLongTap ) );
  3822 
  3775 
  3823         if ( prop && prop->StringValue() == XnPropertyNames::KTrue )
  3776         if ( prop && prop->StringValue() == XnPropertyNames::KTrue )
  3824             {                        
  3777             {                        
  3825             CXnUiEngine* engine( node->UiEngine() );
  3778             CXnUiEngine* engine( node->UiEngine() );
  3826             CXnAppUiAdapter& appui( engine->AppUiAdapter() );
  3779             CXnAppUiAdapter& appui( engine->AppUiAdapter() );           
  3827 
  3780             
  3828             CancelFocusRefusalL( *engine );
  3781             appui.ViewAdapter().CloseAllPopupsL();
  3829             
  3782             
  3830             appui.HideFocus();
  3783             appui.HideFocus();
  3831 
  3784 
  3832             if ( !menuBar )
  3785             if ( !menuBar )
  3833                 {
  3786                 {
  3885 // Handle pointer events
  3838 // Handle pointer events
  3886 // -----------------------------------------------------------------------------
  3839 // -----------------------------------------------------------------------------
  3887 //
  3840 //
  3888 TBool CXnControlAdapterImpl::HandlePointerEventL(
  3841 TBool CXnControlAdapterImpl::HandlePointerEventL(
  3889     const TPointerEvent& aPointerEvent )
  3842     const TPointerEvent& aPointerEvent )
  3890     {    
  3843     {
  3891     const TPointerEvent& event( aPointerEvent );
  3844     const TPointerEvent& event( aPointerEvent );
  3892     
  3845     
  3893     CXnNode* node( &iNode.Node() );
  3846     CXnNode* node( &iNode.Node() );
  3894     CXnUiEngine* engine( node->UiEngine() );
  3847     CXnUiEngine* engine( node->UiEngine() );
  3895     
  3848     
  3967         {
  3920         {
  3968         iLongtap = EFalse;
  3921         iLongtap = EFalse;
  3969         node->HideTooltipsL();
  3922         node->HideTooltipsL();
  3970         
  3923         
  3971         if ( !menuBar )
  3924         if ( !menuBar )
  3972             {
       
  3973             CancelFocusRefusalL( *engine );
       
  3974             }
       
  3975                         
       
  3976         if ( !menuBar && !engine->FocusedNode() )
       
  3977             {
  3925             {
  3978             // save starting point
  3926             // save starting point
  3979             iButtonDownStartPoint = event.iPosition;
  3927             iButtonDownStartPoint = event.iPosition;
  3980             // Require focus to be shown
  3928             // Require focus to be shown
  3981             engine->AppUiAdapter().ShowFocus();                
  3929             engine->AppUiAdapter().ShowFocus();                
  4041 // Leaving draw function.
  3989 // Leaving draw function.
  4042 // -----------------------------------------------------------------------------
  3990 // -----------------------------------------------------------------------------
  4043 //
  3991 //
  4044 void CXnControlAdapterImpl::DoDrawL( const TRect& aRect, CWindowGc& aGc ) const
  3992 void CXnControlAdapterImpl::DoDrawL( const TRect& aRect, CWindowGc& aGc ) const
  4045     {
  3993     {
       
  3994     if( !iComponent )
       
  3995         {
       
  3996         return;
       
  3997         }
  4046     CXnNode& node = iComponent->Node()->Node();
  3998     CXnNode& node = iComponent->Node()->Node();
  4047         
  3999         
  4048     DrawBordersL( aRect, node, aGc );
  4000     DrawBordersL( aRect, node, aGc );
  4049 
  4001 
  4050     const_cast< CXnControlAdapterImpl* >( this )->DrawBackgroundDataL( aRect, node, aGc );
  4002     const_cast< CXnControlAdapterImpl* >( this )->DrawBackgroundDataL( aRect, node, aGc );
  4051     
  4003     
  4052     if ( iAdapter->IsFocused() )
  4004     if ( node.IsStateSet( XnPropertyNames::style::common::KFocus ) )
  4053         {
  4005         {
  4054         DrawFocusAppearance( node, aGc );
  4006         CXnProperty* prop( node.GetPropertyL( 
       
  4007             XnPropertyNames::common::KFocusAppearance ) );
       
  4008                                         
       
  4009         if ( prop && prop->StringValue() == XnPropertyNames::KNone )
       
  4010             {
       
  4011             // Current element refuses to draw focus appearance            
       
  4012             }
       
  4013         else
       
  4014             {
       
  4015             DrawFocusAppearance( node, aGc );        
       
  4016             }
  4055         }
  4017         }
  4056     
  4018     
  4057     // Draw plus sign for empty plugins in edit mode.
  4019     // Draw plus sign for empty plugins in edit mode.
  4058     if( node.UiEngine()->EditMode()->EditState() )
  4020     if( node.UiEngine()->EditMode()->EditState() )
  4059         {
  4021         {
  4060         const_cast< CXnControlAdapterImpl* >( this )->DrawPlusSign( node, aGc );
  4022         CXnControlAdapterImpl* adapter = const_cast< CXnControlAdapterImpl* >( this );    
       
  4023         TBool editstate = iNode.IsEditState();
       
  4024 
       
  4025         if( editstate )
       
  4026             {
       
  4027             adapter->DrawPlusSign( node, aGc );
       
  4028             }
  4061         }
  4029         }
  4062     
  4030     
  4063     if ( iAnimation )
  4031     if ( iAnimation )
  4064         {
  4032         {
  4065         TRect rect = iComponent->Node()->Rect();
  4033         TRect rect = iComponent->Node()->Rect();
  4300                 else // draw background skin graphics without mask
  4268                 else // draw background skin graphics without mask
  4301                     {
  4269                     {
  4302 	                TRect paddingRect = aRect;
  4270 	                TRect paddingRect = aRect;
  4303                     TRect shrunkRect = paddingRect;
  4271                     TRect shrunkRect = paddingRect;
  4304 
  4272 
  4305                     shrunkRect.Shrink(
  4273                     if ( itemID == KAknsIIDQsnFrPopupSub )
  4306                         KSkinGfxInnerRectShrink,
  4274                         {
  4307                         KSkinGfxInnerRectShrink );
  4275                         shrunkRect.Shrink(
       
  4276                             KSkinGfxInnerRectShrink + 2,
       
  4277                             KSkinGfxInnerRectShrink + 2 );                    
       
  4278                         }
       
  4279                     else
       
  4280                         {
       
  4281                         shrunkRect.Shrink(
       
  4282                             KSkinGfxInnerRectShrink,
       
  4283                             KSkinGfxInnerRectShrink );                    
       
  4284                         }
  4308 
  4285 
  4309                     CAknsFrameBackgroundControlContext* frameContext =
  4286                     CAknsFrameBackgroundControlContext* frameContext =
  4310                         CAknsFrameBackgroundControlContext::NewL(
  4287                         CAknsFrameBackgroundControlContext::NewL(
  4311                         itemID, paddingRect, shrunkRect, EFalse );
  4288                         itemID, paddingRect, shrunkRect, EFalse );
  4312 
  4289 
  4332 // DrawBackgroundImageL
  4309 // DrawBackgroundImageL
  4333 // Draws the background image
  4310 // Draws the background image
  4334 // -----------------------------------------------------------------------------
  4311 // -----------------------------------------------------------------------------
  4335 //
  4312 //
  4336 void CXnControlAdapterImpl::DrawBackgroundImageL(
  4313 void CXnControlAdapterImpl::DrawBackgroundImageL(
  4337     const TRect& aRect,
  4314     const TRect& /*aRect*/,
  4338     CXnNode& aNode,
  4315     CXnNode& aNode,
  4339     CWindowGc& aGc,
  4316     CWindowGc& aGc,
  4340     CFbsBitmap* aBitmap,
  4317     CFbsBitmap* aBitmap,
  4341     CFbsBitmap* aMask )
  4318     CFbsBitmap* aMask )
  4342     {
  4319     {
  4423         TRect newRect = TRect(
  4400         TRect newRect = TRect(
  4424             rect.iTl,
  4401             rect.iTl,
  4425             TPoint(
  4402             TPoint(
  4426                 rect.iTl.iX + imageRect.Width(),
  4403                 rect.iTl.iX + imageRect.Width(),
  4427                 rect.iTl.iY + imageRect.Height() ) );
  4404                 rect.iTl.iY + imageRect.Height() ) );
  4428         aGc.SetClippingRect( aRect );
  4405         //aGc.SetClippingRect( aRect );
  4429 
  4406 
  4430         if ( aMask )
  4407         if ( aMask )
  4431             {           
  4408             {           
  4432             aGc.DrawBitmapMasked( newRect, 
  4409             aGc.DrawBitmapMasked( newRect, 
  4433                 aBitmap, 
  4410                 aBitmap, 
  4440             TRect newRect = TRect(
  4417             TRect newRect = TRect(
  4441                 rect.iTl,
  4418                 rect.iTl,
  4442                 TPoint(
  4419                 TPoint(
  4443                     rect.iTl.iX + imageRect.Width(),
  4420                     rect.iTl.iX + imageRect.Width(),
  4444                     rect.iTl.iY + imageRect.Height() ) );
  4421                     rect.iTl.iY + imageRect.Height() ) );
  4445             aGc.SetClippingRect( aRect );
  4422             //aGc.SetClippingRect( aRect );
  4446 
  4423 
  4447             aGc.DrawBitmap( newRect, aBitmap, bitmapRect );
  4424             aGc.DrawBitmap( newRect, aBitmap, bitmapRect );
  4448             }
  4425             }
  4449 
  4426 
  4450         aGc.CancelClippingRect();
  4427         aGc.CancelClippingRect();
  5744             }
  5721             }
  5745         else if ( type == EAknTouchGestureFwFlickRight )
  5722         else if ( type == EAknTouchGestureFwFlickRight )
  5746             {
  5723             {
  5747             swipe = &XnPropertyNames::action::trigger::name::swipe::direction::KRight;
  5724             swipe = &XnPropertyNames::action::trigger::name::swipe::direction::KRight;
  5748             }
  5725             }
  5749 
  5726         
  5750         if ( swipe && iGestureDestination )
  5727         if ( swipe && iGestureDestination )
  5751             {
  5728             {
  5752             CXnUiEngine* engine = iNode.Node().UiEngine();
  5729             CXnUiEngine* engine = iNode.Node().UiEngine();
  5753             if ( iGestureDestination == &iNode.Node() )
       
  5754                 {
       
  5755                 CancelFocusRefusalL( *engine );
       
  5756                 }
       
  5757             
  5730             
  5758             // Remove focus
  5731             // Remove focus
  5759             engine->AppUiAdapter().HideFocus();
  5732             engine->AppUiAdapter().HideFocus();
  5760 
  5733 
  5761             CXnNode* trigger( BuildSwipeTriggerNodeLC( *engine, *swipe ) );
  5734             if ( ( engine->AppUiAdapter().ViewSwitcher() != NULL ) &&
  5762             iGestureDestination->ReportXuikonEventL( *trigger );
  5735                 ( engine->AppUiAdapter().ViewSwitcher()->FingerFollowSupported() ) && 
  5763             CleanupStack::PopAndDestroy( trigger );
  5736                 ( !iGestureDestination || iGestureDestination == &iNode.Node() ) )
  5764             
  5737                 {
       
  5738                 engine->AppUiAdapter().ViewSwitcher()->TouchGesture( type );
       
  5739                 }
       
  5740             else if ( iGestureDestination )
       
  5741                 {
       
  5742                 CXnNode* trigger( BuildSwipeTriggerNodeLC( *engine, *swipe ) );
       
  5743                 iGestureDestination->ReportXuikonEventL( *trigger );
       
  5744                 CleanupStack::PopAndDestroy( trigger );
       
  5745                 }
  5765             CXnAppUiAdapter& appui( engine->AppUiAdapter() );
  5746             CXnAppUiAdapter& appui( engine->AppUiAdapter() );
  5766             CXnViewData& data( appui.ViewManager().ActiveViewData() );
  5747             CXnViewData& data( appui.ViewManager().ActiveViewData() );
  5767             
  5748             
  5768             CXnViewControlAdapter* control = 
  5749             CXnViewControlAdapter* control = 
  5769                 static_cast< CXnViewControlAdapter* >( data.ViewNode()->Control() );
  5750                 static_cast< CXnViewControlAdapter* >( data.ViewNode()->Control() );
  5771             control->ResetGrabbing();
  5752             control->ResetGrabbing();
  5772             }
  5753             }
  5773         }
  5754         }
  5774     }
  5755     }
  5775 
  5756 
       
  5757 // -----------------------------------------------------------------------------
       
  5758 // -----------------------------------------------------------------------------
       
  5759 //
       
  5760 TBool CXnControlAdapterImpl::IsWidgetGestureDest()
       
  5761     {
       
  5762     return ( !iGestureDestination || iGestureDestination != &iNode.Node() );
       
  5763     }
  5776 
  5764 
  5777 // ============================= TIconProvider ===============================
  5765 // ============================= TIconProvider ===============================
  5778 
  5766 
  5779 // -----------------------------------------------------------------------------
  5767 // -----------------------------------------------------------------------------
  5780 // Constructor
  5768 // Constructor