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" |
|
65 |
64 |
66 _LIT8(KScrollableBoxNodeName, "scrollablebox"); |
65 _LIT8(KScrollableBoxNodeName, "scrollablebox"); |
67 _LIT8( KView, "view" ); |
66 _LIT8( KView, "view" ); |
68 |
67 |
69 // Constants |
68 // Constants |
206 static TBool CreateGestureHelperL( CXnNode& aNode ); |
205 static TBool CreateGestureHelperL( CXnNode& aNode ); |
207 static TInt AccessResourceFileL( |
206 static TInt AccessResourceFileL( |
208 CXnResource& aResource, RFile& aFile, RFs& aFsSession ); |
207 CXnResource& aResource, RFile& aFile, RFs& aFsSession ); |
209 static void DrawFocusAppearance( CXnNode& aNode, CWindowGc& aGc ); |
208 static void DrawFocusAppearance( CXnNode& aNode, CWindowGc& aGc ); |
210 static CXnDomNode* HasHoldTrigger( CXnDomNode* aNode ); |
209 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 // ----------------------------------------------------------------------------- |
3417 // Calculates scaled bitmap size (rect) |
3441 // Calculates scaled bitmap size (rect) |
3418 // ----------------------------------------------------------------------------- |
3442 // ----------------------------------------------------------------------------- |
3419 // |
3443 // |
3420 void CalculateScaledBitmapRect( TSize& aScaledSize, const TSize& aDrawSize, |
3444 void CalculateScaledBitmapRect( TSize& aScaledSize, const TSize& aDrawSize, |
3421 const TSize& aImageSize ) |
3445 const TSize& aImageSize ) |
3774 XnPropertyNames::common::KLongTap ) ); |
3798 XnPropertyNames::common::KLongTap ) ); |
3775 |
3799 |
3776 if ( prop && prop->StringValue() == XnPropertyNames::KTrue ) |
3800 if ( prop && prop->StringValue() == XnPropertyNames::KTrue ) |
3777 { |
3801 { |
3778 CXnUiEngine* engine( node->UiEngine() ); |
3802 CXnUiEngine* engine( node->UiEngine() ); |
3779 CXnAppUiAdapter& appui( engine->AppUiAdapter() ); |
3803 CXnAppUiAdapter& appui( engine->AppUiAdapter() ); |
3780 |
3804 |
3781 appui.ViewAdapter().CloseAllPopupsL(); |
3805 CancelFocusRefusalL( *engine ); |
3782 |
3806 |
3783 appui.HideFocus(); |
3807 appui.HideFocus(); |
3784 |
3808 |
3785 if ( !menuBar ) |
3809 if ( !menuBar ) |
3786 { |
3810 { |
3838 // Handle pointer events |
3862 // Handle pointer events |
3839 // ----------------------------------------------------------------------------- |
3863 // ----------------------------------------------------------------------------- |
3840 // |
3864 // |
3841 TBool CXnControlAdapterImpl::HandlePointerEventL( |
3865 TBool CXnControlAdapterImpl::HandlePointerEventL( |
3842 const TPointerEvent& aPointerEvent ) |
3866 const TPointerEvent& aPointerEvent ) |
3843 { |
3867 { |
3844 const TPointerEvent& event( aPointerEvent ); |
3868 const TPointerEvent& event( aPointerEvent ); |
3845 |
3869 |
3846 CXnNode* node( &iNode.Node() ); |
3870 CXnNode* node( &iNode.Node() ); |
3847 CXnUiEngine* engine( node->UiEngine() ); |
3871 CXnUiEngine* engine( node->UiEngine() ); |
3848 |
3872 |
3920 { |
3944 { |
3921 iLongtap = EFalse; |
3945 iLongtap = EFalse; |
3922 node->HideTooltipsL(); |
3946 node->HideTooltipsL(); |
3923 |
3947 |
3924 if ( !menuBar ) |
3948 if ( !menuBar ) |
|
3949 { |
|
3950 CancelFocusRefusalL( *engine ); |
|
3951 } |
|
3952 |
|
3953 if ( !menuBar && !engine->FocusedNode() ) |
3925 { |
3954 { |
3926 // save starting point |
3955 // save starting point |
3927 iButtonDownStartPoint = event.iPosition; |
3956 iButtonDownStartPoint = event.iPosition; |
3928 // Require focus to be shown |
3957 // Require focus to be shown |
3929 engine->AppUiAdapter().ShowFocus(); |
3958 engine->AppUiAdapter().ShowFocus(); |
3989 // Leaving draw function. |
4018 // Leaving draw function. |
3990 // ----------------------------------------------------------------------------- |
4019 // ----------------------------------------------------------------------------- |
3991 // |
4020 // |
3992 void CXnControlAdapterImpl::DoDrawL( const TRect& aRect, CWindowGc& aGc ) const |
4021 void CXnControlAdapterImpl::DoDrawL( const TRect& aRect, CWindowGc& aGc ) const |
3993 { |
4022 { |
3994 if( !iComponent ) |
|
3995 { |
|
3996 return; |
|
3997 } |
|
3998 CXnNode& node = iComponent->Node()->Node(); |
4023 CXnNode& node = iComponent->Node()->Node(); |
3999 |
4024 |
4000 DrawBordersL( aRect, node, aGc ); |
4025 DrawBordersL( aRect, node, aGc ); |
4001 |
4026 |
4002 const_cast< CXnControlAdapterImpl* >( this )->DrawBackgroundDataL( aRect, node, aGc ); |
4027 const_cast< CXnControlAdapterImpl* >( this )->DrawBackgroundDataL( aRect, node, aGc ); |
4003 |
4028 |
4004 if ( node.IsStateSet( XnPropertyNames::style::common::KFocus ) ) |
4029 if ( iAdapter->IsFocused() ) |
4005 { |
4030 { |
4006 CXnProperty* prop( node.GetPropertyL( |
4031 DrawFocusAppearance( node, aGc ); |
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 } |
|
4017 } |
4032 } |
4018 |
4033 |
4019 // Draw plus sign for empty plugins in edit mode. |
4034 // Draw plus sign for empty plugins in edit mode. |
4020 if( node.UiEngine()->EditMode()->EditState() ) |
4035 if( node.UiEngine()->EditMode()->EditState() ) |
4021 { |
4036 { |
4022 CXnControlAdapterImpl* adapter = const_cast< CXnControlAdapterImpl* >( this ); |
4037 const_cast< CXnControlAdapterImpl* >( this )->DrawPlusSign( node, aGc ); |
4023 TBool editstate = iNode.IsEditState(); |
|
4024 |
|
4025 if( editstate ) |
|
4026 { |
|
4027 adapter->DrawPlusSign( node, aGc ); |
|
4028 } |
|
4029 } |
4038 } |
4030 |
4039 |
4031 if ( iAnimation ) |
4040 if ( iAnimation ) |
4032 { |
4041 { |
4033 TRect rect = iComponent->Node()->Rect(); |
4042 TRect rect = iComponent->Node()->Rect(); |
4309 // DrawBackgroundImageL |
4318 // DrawBackgroundImageL |
4310 // Draws the background image |
4319 // Draws the background image |
4311 // ----------------------------------------------------------------------------- |
4320 // ----------------------------------------------------------------------------- |
4312 // |
4321 // |
4313 void CXnControlAdapterImpl::DrawBackgroundImageL( |
4322 void CXnControlAdapterImpl::DrawBackgroundImageL( |
4314 const TRect& /*aRect*/, |
4323 const TRect& aRect, |
4315 CXnNode& aNode, |
4324 CXnNode& aNode, |
4316 CWindowGc& aGc, |
4325 CWindowGc& aGc, |
4317 CFbsBitmap* aBitmap, |
4326 CFbsBitmap* aBitmap, |
4318 CFbsBitmap* aMask ) |
4327 CFbsBitmap* aMask ) |
4319 { |
4328 { |
4400 TRect newRect = TRect( |
4409 TRect newRect = TRect( |
4401 rect.iTl, |
4410 rect.iTl, |
4402 TPoint( |
4411 TPoint( |
4403 rect.iTl.iX + imageRect.Width(), |
4412 rect.iTl.iX + imageRect.Width(), |
4404 rect.iTl.iY + imageRect.Height() ) ); |
4413 rect.iTl.iY + imageRect.Height() ) ); |
4405 //aGc.SetClippingRect( aRect ); |
4414 aGc.SetClippingRect( aRect ); |
4406 |
4415 |
4407 if ( aMask ) |
4416 if ( aMask ) |
4408 { |
4417 { |
4409 aGc.DrawBitmapMasked( newRect, |
4418 aGc.DrawBitmapMasked( newRect, |
4410 aBitmap, |
4419 aBitmap, |
4417 TRect newRect = TRect( |
4426 TRect newRect = TRect( |
4418 rect.iTl, |
4427 rect.iTl, |
4419 TPoint( |
4428 TPoint( |
4420 rect.iTl.iX + imageRect.Width(), |
4429 rect.iTl.iX + imageRect.Width(), |
4421 rect.iTl.iY + imageRect.Height() ) ); |
4430 rect.iTl.iY + imageRect.Height() ) ); |
4422 //aGc.SetClippingRect( aRect ); |
4431 aGc.SetClippingRect( aRect ); |
4423 |
4432 |
4424 aGc.DrawBitmap( newRect, aBitmap, bitmapRect ); |
4433 aGc.DrawBitmap( newRect, aBitmap, bitmapRect ); |
4425 } |
4434 } |
4426 |
4435 |
4427 aGc.CancelClippingRect(); |
4436 aGc.CancelClippingRect(); |
5721 } |
5730 } |
5722 else if ( type == EAknTouchGestureFwFlickRight ) |
5731 else if ( type == EAknTouchGestureFwFlickRight ) |
5723 { |
5732 { |
5724 swipe = &XnPropertyNames::action::trigger::name::swipe::direction::KRight; |
5733 swipe = &XnPropertyNames::action::trigger::name::swipe::direction::KRight; |
5725 } |
5734 } |
5726 |
5735 |
5727 if ( swipe && iGestureDestination ) |
5736 if ( swipe && iGestureDestination ) |
5728 { |
5737 { |
5729 CXnUiEngine* engine = iNode.Node().UiEngine(); |
5738 CXnUiEngine* engine = iNode.Node().UiEngine(); |
|
5739 if ( iGestureDestination == &iNode.Node() ) |
|
5740 { |
|
5741 CancelFocusRefusalL( *engine ); |
|
5742 } |
5730 |
5743 |
5731 // Remove focus |
5744 // Remove focus |
5732 engine->AppUiAdapter().HideFocus(); |
5745 engine->AppUiAdapter().HideFocus(); |
5733 |
5746 |
5734 if ( ( engine->AppUiAdapter().ViewSwitcher() != NULL ) && |
5747 CXnNode* trigger( BuildSwipeTriggerNodeLC( *engine, *swipe ) ); |
5735 ( engine->AppUiAdapter().ViewSwitcher()->FingerFollowSupported() ) && |
5748 iGestureDestination->ReportXuikonEventL( *trigger ); |
5736 ( !iGestureDestination || iGestureDestination == &iNode.Node() ) ) |
5749 CleanupStack::PopAndDestroy( trigger ); |
5737 { |
5750 |
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 } |
|
5746 CXnAppUiAdapter& appui( engine->AppUiAdapter() ); |
5751 CXnAppUiAdapter& appui( engine->AppUiAdapter() ); |
5747 CXnViewData& data( appui.ViewManager().ActiveViewData() ); |
5752 CXnViewData& data( appui.ViewManager().ActiveViewData() ); |
5748 |
5753 |
5749 CXnViewControlAdapter* control = |
5754 CXnViewControlAdapter* control = |
5750 static_cast< CXnViewControlAdapter* >( data.ViewNode()->Control() ); |
5755 static_cast< CXnViewControlAdapter* >( data.ViewNode()->Control() ); |
5752 control->ResetGrabbing(); |
5757 control->ResetGrabbing(); |
5753 } |
5758 } |
5754 } |
5759 } |
5755 } |
5760 } |
5756 |
5761 |
5757 // ----------------------------------------------------------------------------- |
|
5758 // ----------------------------------------------------------------------------- |
|
5759 // |
|
5760 TBool CXnControlAdapterImpl::IsWidgetGestureDest() |
|
5761 { |
|
5762 return ( !iGestureDestination || iGestureDestination != &iNode.Node() ); |
|
5763 } |
|
5764 |
5762 |
5765 // ============================= TIconProvider =============================== |
5763 // ============================= TIconProvider =============================== |
5766 |
5764 |
5767 // ----------------------------------------------------------------------------- |
5765 // ----------------------------------------------------------------------------- |
5768 // Constructor |
5766 // Constructor |