idlehomescreen/xmluirendering/uiengine/src/xneditmode.cpp
branchRCL_3
changeset 11 ff572dfe6d86
parent 9 f966699dea19
child 12 9674c1a575e9
equal deleted inserted replaced
9:f966699dea19 11:ff572dfe6d86
    16 */
    16 */
    17 
    17 
    18 // System includes
    18 // System includes
    19 #include <AknUtils.h>
    19 #include <AknUtils.h>
    20 #include <gulgcmap.h>
    20 #include <gulgcmap.h>
    21 #include <akntitle.h>
       
    22 #include <barsread.h>
    21 #include <barsread.h>
    23 #include <xnuiengine.rsg>
       
    24 
    22 
    25 #ifdef RD_TACTILE_FEEDBACK
    23 #ifdef RD_TACTILE_FEEDBACK
    26 #include <touchfeedback.h>
    24 #include <touchfeedback.h>
    27 #endif // RD_TACTILE_FEEDBACK
    25 #endif // RD_TACTILE_FEEDBACK
    28 
    26 
    40 #include "xnpopupcontroladapter.h"
    38 #include "xnpopupcontroladapter.h"
    41 #include "xnfocuscontrol.h"
    39 #include "xnfocuscontrol.h"
    42 #include "xneditor.h"
    40 #include "xneditor.h"
    43 #include "xntype.h"
    41 #include "xntype.h"
    44 #include "xnmenu.h"
    42 #include "xnmenu.h"
       
    43 #include "xnbackgroundmanager.h"
    45 
    44 
    46 #include "xneditmode.h"
    45 #include "xneditmode.h"
    47 
    46 
    48 // Constants
    47 // Constants
    49 _LIT8( KMenu, "menu" );
    48 _LIT8( KMenu, "menu" );
   356         {
   355         {
   357         bg.DrawableWindow()->SetPointerGrab( EFalse );
   356         bg.DrawableWindow()->SetPointerGrab( EFalse );
   358         
   357         
   359         Window().SetOrdinalPosition( 0 );
   358         Window().SetOrdinalPosition( 0 );
   360         Window().SetPointerGrab( ETrue );
   359         Window().SetPointerGrab( ETrue );
   361         Window().ClaimPointerGrab();               
   360         Window().ClaimPointerGrab();      
       
   361         
       
   362         TRAP_IGNORE( appui.HandleEnterEditModeL( ETrue ) );                                
   362         }
   363         }
   363     else
   364     else
   364         {
   365         {
   365         Window().SetPointerGrab( EFalse );
   366         Window().SetPointerGrab( EFalse );
   366         
   367         
   367         bg.DrawableWindow()->SetPointerGrab( ETrue );               
   368         bg.DrawableWindow()->SetPointerGrab( ETrue );
   368         }
   369         
       
   370         TRAP_IGNORE( appui.HandleEnterEditModeL( EFalse ) );                                                
       
   371         }
       
   372     
       
   373     // Update background
       
   374     appui.ViewAdapter().BgManager().DrawNow();
   369     }
   375     }
   370 
   376 
   371 // -----------------------------------------------------------------------------
   377 // -----------------------------------------------------------------------------
   372 // CXnEditMode::HandlePointerEventL
   378 // CXnEditMode::HandlePointerEventL
   373 //
   379 //
   481         {        
   487         {        
   482         iDragged = EFalse;
   488         iDragged = EFalse;
   483                
   489                
   484         if ( node )
   490         if ( node )
   485             {
   491             {
   486             CXnPluginData& plugin( iUiEngine.ViewManager()->
   492             CXnPluginData* plugin( iUiEngine.ViewManager()->
   487                     ActiveViewData().Plugin( node ) );
   493                     ActiveViewData().Plugin( node ) );
   488             
   494             
   489             if ( plugin.Occupied() )
   495             if ( plugin && plugin->Occupied() )
   490                 {
   496                 {
   491                 StartDragL( *node );
   497                 StartDragL( *node );
   492                                   
   498                                   
   493                 iDrawPos = iDraggingNode->BorderRect().iTl;
   499                 iDrawPos = iDraggingNode->BorderRect().iTl;
   494                 
   500                 
   540             }
   546             }
   541         }
   547         }
   542     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   548     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   543         {
   549         {
   544 #ifdef RD_TACTILE_FEEDBACK                
   550 #ifdef RD_TACTILE_FEEDBACK                
   545         Feedback( ETouchFeedbackBasic );
   551         MTouchFeedback* feedback( MTouchFeedback::Instance() );
       
   552         feedback->InstantFeedback( this,ETouchFeedbackBasic, 
       
   553     		                       ETouchFeedbackVibra,
       
   554     		                       aPointerEvent );
   546 #endif
   555 #endif
   547         // Cancel
   556         // Cancel
   548         if ( !iTargetNode || !iDraggingNode ||                 
   557         if ( !iTargetNode || !iDraggingNode ||                 
   549              iDraggingNode == iTargetNode ||
   558              iDraggingNode == iTargetNode ||
   550              !iTargetNode->MarginRect().Contains( aPointerEvent.iPosition ) )
   559              !iTargetNode->MarginRect().Contains( aPointerEvent.iPosition ) )
   561             
   570             
   562             UpdateScreen();
   571             UpdateScreen();
   563                         
   572                         
   564             if ( node && !iDragged )
   573             if ( node && !iDragged )
   565                 {
   574                 {
   566                 CXnPluginData& plugin( iUiEngine.ViewManager()->
   575                 CXnPluginData* plugin( iUiEngine.ViewManager()->
   567                         ActiveViewData().Plugin( node ) );
   576                         ActiveViewData().Plugin( node ) );
   568 
   577 
   569                 if ( plugin.Occupied() )
   578                 if ( plugin && plugin->Occupied() )
   570                     {
   579                     {
   571                     CXnNode* popup( iUiEngine.StylusPopupNode() );
   580                     CXnNode* popup( iUiEngine.StylusPopupNode() );
   572                     
   581                     
   573                     if ( popup )
   582                     if ( popup )
   574                         {
   583                         {
   635         CXnNode* focused( iUiEngine.FocusedNode() );
   644         CXnNode* focused( iUiEngine.FocusedNode() );
   636         
   645         
   637         if ( focused && ( aKeyEvent.iScanCode == EStdKeyDevice3 ||
   646         if ( focused && ( aKeyEvent.iScanCode == EStdKeyDevice3 ||
   638             aKeyEvent.iScanCode == EStdKeyEnter ) )
   647             aKeyEvent.iScanCode == EStdKeyEnter ) )
   639             {
   648             {
   640             CXnPluginData& plugin( iUiEngine.ViewManager()->
   649             CXnPluginData* plugin( iUiEngine.ViewManager()->
   641                     ActiveViewData().Plugin( focused ) );
   650                     ActiveViewData().Plugin( focused ) );
   642             
   651             
   643             if ( plugin.Occupied() )
   652             if ( plugin && plugin->Occupied() )
   644                 {
   653                 {
   645                 // Open context menu
   654                 // Open context menu
   646                 CXnNode* menubar( iUiEngine.MenuBarNode() );
   655                 CXnNode* menubar( iUiEngine.MenuBarNode() );
   647                 
   656                 
   648                 if ( menubar )
   657                 if ( menubar )
   704 // -----------------------------------------------------------------------------
   713 // -----------------------------------------------------------------------------
   705 //
   714 //
   706 void CXnEditMode::StartDragL( CXnNode& aNode )
   715 void CXnEditMode::StartDragL( CXnNode& aNode )
   707     {  
   716     {  
   708     CXnControlAdapter* control( aNode.Control() );
   717     CXnControlAdapter* control( aNode.Control() );
   709     
   718         
   710     TRect rect( control->Rect() );
   719     TRect rect( control->Rect() );
   711     
   720     
   712     // Clear first with alpha 
   721     // Clear first with alpha 
   713     TRgb rgb( TRgb::Color16MA( 0 ) );
   722     TRgb rgb( TRgb::Color16MA( 0 ) );
   714     rgb.SetAlpha( 64 );
   723     rgb.SetAlpha( 64 );
   723     iState = CXnEditMode::EShootContent;
   732     iState = CXnEditMode::EShootContent;
   724         
   733         
   725     CWindowGc* gc( control->CustomGc() );
   734     CWindowGc* gc( control->CustomGc() );
   726             
   735             
   727     control->SetCustomGc( iMapGc );
   736     control->SetCustomGc( iMapGc );
   728     
   737 
       
   738     TBool focusStateChanged( EFalse );
       
   739     
       
   740     if( aNode.IsStateSet( XnPropertyNames::style::common::KFocus ) )
       
   741         {        
       
   742         aNode.UnsetStateL( XnPropertyNames::style::common::KFocus );
       
   743         focusStateChanged = ETrue;
       
   744         }
       
   745 
   729     control->DrawNow( rect );
   746     control->DrawNow( rect );
   730         
   747 
   731     control->SetCustomGc( gc );
   748     control->SetCustomGc( gc );
   732            
   749 
       
   750     if( focusStateChanged )
       
   751         {
       
   752         aNode.SetStateL( XnPropertyNames::style::common::KFocus );
       
   753         iUiEngine.RenderUIL( &aNode );
       
   754         }
       
   755 
   733     if ( iWidget->SizeInPixels() != rect.Size() )
   756     if ( iWidget->SizeInPixels() != rect.Size() )
   734         {
   757         {
   735         iWidget->Resize( rect.Size() );
   758         iWidget->Resize( rect.Size() );
   736         }
   759         }
   737     
   760     
   795     {    
   818     {    
   796     // Enter to edit mode
   819     // Enter to edit mode
   797     if ( aState == CXnEditMode::EDragAndDrop )
   820     if ( aState == CXnEditMode::EDragAndDrop )
   798         {               
   821         {               
   799         iState = aState;
   822         iState = aState;
   800         
   823                 
   801         iUiEngine.AppUiAdapter().HandleEnterEditModeL( ETrue );
       
   802         SetStatusPaneTitleL( ETrue );
       
   803         
       
   804         MakeVisible( ETrue );               
   824         MakeVisible( ETrue );               
   805         }
   825         }
   806 
   826 
   807     // Exit from edit mode
   827     // Exit from edit mode
   808     else if ( aState == CXnEditMode::ENone )
   828     else if ( aState == CXnEditMode::ENone )
   809         {                
   829         {                
   810         iDraggingNode = NULL;
   830         iDraggingNode = NULL;
   811         iTargetNode = NULL;
   831         iTargetNode = NULL;
   812         
   832         
   813         iState = aState;
   833         iState = aState;
   814         
   834                 
   815         SetStatusPaneTitleL( EFalse );
       
   816                
       
   817         iUiEngine.AppUiAdapter().HandleEnterEditModeL( EFalse );
       
   818         
       
   819         MakeVisible( EFalse );
   835         MakeVisible( EFalse );
   820         }   
   836         }   
   821     }
   837     }
   822 
   838 
   823 // -----------------------------------------------------------------------------
   839 // -----------------------------------------------------------------------------
   829     {
   845     {
   830     return iState;
   846     return iState;
   831     }
   847     }
   832 
   848 
   833 // -----------------------------------------------------------------------------
   849 // -----------------------------------------------------------------------------
   834 // CXnEditMode::SetStatusPaneTitleL( TBool aEdit )
       
   835 // -----------------------------------------------------------------------------
       
   836 //
       
   837 void CXnEditMode::SetStatusPaneTitleL( TBool aEdit )
       
   838     {
       
   839     TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle );
       
   840     CEikStatusPaneBase::TPaneCapabilities subPaneTitle = 
       
   841         iUiEngine.AppUiAdapter().StatusPane()->PaneCapabilities( titlePaneUid );
       
   842     if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() )
       
   843         {
       
   844         CAknTitlePane* title = static_cast< CAknTitlePane* >( 
       
   845             iUiEngine.AppUiAdapter().StatusPane()->ControlL( titlePaneUid ) );
       
   846         if( aEdit )
       
   847             {
       
   848             TResourceReader reader;
       
   849             CEikonEnv::Static()->CreateResourceReaderLC(
       
   850                 reader, R_QTN_HS_TITLE_EDITMODE );
       
   851             title->SetFromResourceL( reader );
       
   852             CleanupStack::PopAndDestroy(); // reader internal state
       
   853             }
       
   854         else
       
   855             {
       
   856             title->SetTextL( KNullDesC );
       
   857             }
       
   858 
       
   859         }
       
   860     }
       
   861 
       
   862 // -----------------------------------------------------------------------------
       
   863 // CXnEditMode::StopDraggingL()
   850 // CXnEditMode::StopDraggingL()
   864 // -----------------------------------------------------------------------------
   851 // -----------------------------------------------------------------------------
   865 //
   852 //
   866 void CXnEditMode::StopDraggingL()
   853 void CXnEditMode::StopDraggingL()
   867     {
   854     {