idlehomescreen/xmluirendering/uiengine/src/xnuiengineimpl.cpp
branchRCL_3
changeset 102 ba63c83f4716
parent 93 b01126ce0bec
equal deleted inserted replaced
93:b01126ce0bec 102:ba63c83f4716
    56 #include "xneffectmanager.h"
    56 #include "xneffectmanager.h"
    57 #include "xneditor.h"
    57 #include "xneditor.h"
    58 #include "xnbackgroundmanager.h"
    58 #include "xnbackgroundmanager.h"
    59 #include "xntexteditor.h"
    59 #include "xntexteditor.h"
    60 #include "xnrootdata.h"
    60 #include "xnrootdata.h"
    61 #include "xnviewswitcher.h"
       
    62 
    61 
    63 #ifdef _XN_PERFORMANCE_TEST_
    62 #ifdef _XN_PERFORMANCE_TEST_
    64 #include "xntimemon.h"
    63 #include "xntimemon.h"
    65 #endif
    64 #endif
    66 
    65 
    76 const TInt KXnStackPriorityKeyEventDispatcher = 55;
    75 const TInt KXnStackPriorityKeyEventDispatcher = 55;
    77 const TInt KFocusGrowValue = 3;
    76 const TInt KFocusGrowValue = 3;
    78 
    77 
    79 _LIT8( KBoxNodeName, "box" );
    78 _LIT8( KBoxNodeName, "box" );
    80 _LIT8( KButtonNodeName, "button" );
    79 _LIT8( KButtonNodeName, "button" );
       
    80 _LIT8( KWidgetNodeName, "widget" );
    81 _LIT8( KWidgetExtensionNodeName, "widgetextension" );
    81 _LIT8( KWidgetExtensionNodeName, "widgetextension" );
    82 _LIT8( KScrollableBoxNodeName, "scrollablebox" );
    82 _LIT8( KScrollableBoxNodeName, "scrollablebox" );
    83 _LIT8( KMenuBar, "menubar" );
    83 _LIT8( KMenuBar, "menubar" );
    84 _LIT8( KPopUpNodeName, "popup" );
    84 _LIT8( KPopUpNodeName, "popup" );
       
    85 _LIT8( KEditorNodeName, "texteditor" );
    85 
    86 
    86 _LIT8( KPlugin, "plugin" );
    87 _LIT8( KPlugin, "plugin" );
    87 
       
    88 _LIT8( KSplitScreenEnabledTrigger , "splitscreenenabled" );
       
    89 _LIT8( KSplitScreenDisabledTrigger, "splitscreendisabled" );
       
    90 
       
    91 
    88 
    92 // LOCAL CONSTANTS AND MACROS
    89 // LOCAL CONSTANTS AND MACROS
    93 static const TReal KIntConversionConstant = 0.5;
    90 static const TReal KIntConversionConstant = 0.5;
    94 static const TReal KIntPercentageConstant =
    91 static const TReal KIntPercentageConstant =
    95     static_cast< TReal >( 1 ) / static_cast< TReal >( 100 );
    92     static_cast< TReal >( 1 ) / static_cast< TReal >( 100 );
   289 #endif
   286 #endif
   290 
   287 
   291 // ============================= LOCAL FUNCTIONS ===============================
   288 // ============================= LOCAL FUNCTIONS ===============================
   292 
   289 
   293 // -----------------------------------------------------------------------------
   290 // -----------------------------------------------------------------------------
       
   291 // -----------------------------------------------------------------------------
       
   292 //
       
   293 CXnNode* FindPlugin( CXnNode& aNode )
       
   294     {
       
   295     CXnNode* pluginNode( NULL );
       
   296     for( CXnNode* node = &aNode; node; node = node->Parent() )
       
   297         {
       
   298         if( node->DomNode()->Name() == KPlugin )
       
   299             {
       
   300             pluginNode = node;
       
   301             break;
       
   302             }
       
   303         }
       
   304     return pluginNode;
       
   305     }
       
   306 
       
   307 // -----------------------------------------------------------------------------
   294 // GrowIfNeeded()
   308 // GrowIfNeeded()
   295 // When a plugin is focused, the focus is a bit bigger than its control 
   309 // When a plugin is focused, the focus is a bit bigger than its control 
   296 // (this is a hack fix to get focus visible with WRT widgets).
   310 // (this is a hack fix to get focus visible with WRT widgets).
   297 // Therefore we need to check if focused node is a plugin, 
   311 // Therefore we need to check if focused node is a plugin, 
   298 // or focused node has same size with its plugin, and grow dirty rect accordingly.
   312 // or focused node has same size with its plugin, and grow dirty rect accordingly.
  3167 
  3181 
  3168                 if ( !layoutUnderPrevious )
  3182                 if ( !layoutUnderPrevious )
  3169                     {
  3183                     {
  3170                     TInt width =
  3184                     TInt width =
  3171                         aNode.BorderRect().Width() + marginLeft + marginRight;
  3185                         aNode.BorderRect().Width() + marginLeft + marginRight;
  3172                     if ( aColumnMargin < marginRight )
  3186                     if ( aColumnMargin < marginLeft )
  3173                         {
  3187                         {
  3174                         width -= aColumnMargin;
  3188                         width -= aColumnMargin;
  3175                         }
  3189                         }
  3176                     else
  3190                     else
  3177                         {
  3191                         {
  3178                         width -= marginRight;
  3192                         width -= marginLeft;
  3179                         }
  3193                         }
  3180                     if ( width + aColumnWidth <= aParentRect.Width() )
  3194                     if ( width + aColumnWidth <= aParentRect.Width() )
  3181                         {
  3195                         {
  3182                         offsety = aParentRect.iTl.iY + marginTop;
  3196                         offsety = aParentRect.iTl.iY + marginTop;
  3183                         if ( aColumnMargin < marginRight )
  3197                         if ( aColumnMargin < marginLeft )
  3184                             {
  3198                             {
  3185                             offsetx = aParentRect.iBr.iX - aColumnWidth +
  3199                             offsetx = aParentRect.iBr.iX - aColumnWidth +
  3186                                 aColumnMargin - marginRight -
  3200                                 aColumnMargin - marginRight -
  3187                                 aNode.BorderRect().Width();
  3201                                 aNode.BorderRect().Width();
  3188                             }
  3202                             }
  3264                         }
  3278                         }
  3265                     if ( width + aColumnWidth <= aParentRect.Width() )
  3279                     if ( width + aColumnWidth <= aParentRect.Width() )
  3266                         {
  3280                         {
  3267                         offsety = aParentRect.iBr.iY - marginBottom -
  3281                         offsety = aParentRect.iBr.iY - marginBottom -
  3268                             aNode.BorderRect().Height();
  3282                             aNode.BorderRect().Height();
  3269                         if ( aColumnMargin < marginRight )
  3283                         if ( aColumnMargin < marginLeft )
  3270                             {
  3284                             {
  3271                             offsetx = aParentRect.iBr.iX - aColumnWidth +
  3285                             offsetx = aParentRect.iBr.iX - aColumnWidth +
  3272                                 aColumnMargin - marginRight -
  3286                                 aColumnMargin - marginRight -
  3273                                 aNode.BorderRect().Width();
  3287                                 aNode.BorderRect().Width();
  3274                             }
  3288                             }
  7084 
  7098 
  7085     CXnProperty* top = aNode.TopL();
  7099     CXnProperty* top = aNode.TopL();
  7086     if ( IsPropertyAutoL( *top ) )
  7100     if ( IsPropertyAutoL( *top ) )
  7087         {
  7101         {
  7088         TPtrC8 propertyName = top->Property()->Name();
  7102         TPtrC8 propertyName = top->Property()->Name();
  7089         autoArray.AppendL( propertyName );
  7103         autoArray.Append( propertyName );
  7090         }
  7104         }
  7091     CXnProperty* bottom = aNode.BottomL();
  7105     CXnProperty* bottom = aNode.BottomL();
  7092     if ( IsPropertyAutoL( *bottom ) )
  7106     if ( IsPropertyAutoL( *bottom ) )
  7093         {
  7107         {
  7094         TPtrC8 propertyName = bottom->Property()->Name();
  7108         TPtrC8 propertyName = bottom->Property()->Name();
  7095         autoArray.AppendL( propertyName );
  7109         autoArray.Append( propertyName );
  7096         }
  7110         }
  7097     CXnProperty* left = aNode.LeftL();
  7111     CXnProperty* left = aNode.LeftL();
  7098     if ( IsPropertyAutoL( *left ) )
  7112     if ( IsPropertyAutoL( *left ) )
  7099         {
  7113         {
  7100         TPtrC8 propertyName = left->Property()->Name();
  7114         TPtrC8 propertyName = left->Property()->Name();
  7101         autoArray.AppendL( propertyName );
  7115         autoArray.Append( propertyName );
  7102         }
  7116         }
  7103     CXnProperty* right = aNode.RightL();
  7117     CXnProperty* right = aNode.RightL();
  7104     if ( IsPropertyAutoL( *right ) )
  7118     if ( IsPropertyAutoL( *right ) )
  7105         {
  7119         {
  7106         TPtrC8 propertyName = right->Property()->Name();
  7120         TPtrC8 propertyName = right->Property()->Name();
  7107         autoArray.AppendL( propertyName );
  7121         autoArray.Append( propertyName );
  7108         }
  7122         }
  7109     CXnProperty* width = aNode.WidthL();
  7123     CXnProperty* width = aNode.WidthL();
  7110     if ( IsPropertyAutoL( *width ) )
  7124     if ( IsPropertyAutoL( *width ) )
  7111         {
  7125         {
  7112         TPtrC8 propertyName = width->Property()->Name();
  7126         TPtrC8 propertyName = width->Property()->Name();
  7113         autoArray.AppendL( propertyName );
  7127         autoArray.Append( propertyName );
  7114         }
  7128         }
  7115     if ( !width )
  7129     if ( !width )
  7116         {
  7130         {
  7117         TPtrC8 propertyName = XnPropertyNames::style::common::KWidth();
  7131         TPtrC8 propertyName = XnPropertyNames::style::common::KWidth();
  7118         autoArray.AppendL( propertyName );
  7132         autoArray.Append( propertyName );
  7119         }
  7133         }
  7120     CXnProperty* height = aNode.HeightL();
  7134     CXnProperty* height = aNode.HeightL();
  7121     if ( IsPropertyAutoL( *height ) )
  7135     if ( IsPropertyAutoL( *height ) )
  7122         {
  7136         {
  7123         TPtrC8 propertyName = height->Property()->Name();
  7137         TPtrC8 propertyName = height->Property()->Name();
  7124         autoArray.AppendL( propertyName );
  7138         autoArray.Append( propertyName );
  7125         }
  7139         }
  7126     if ( !height )
  7140     if ( !height )
  7127         {
  7141         {
  7128         TPtrC8 propertyName = XnPropertyNames::style::common::KHeight();
  7142         TPtrC8 propertyName = XnPropertyNames::style::common::KHeight();
  7129         autoArray.AppendL( propertyName );
  7143         autoArray.Append( propertyName );
  7130         }
  7144         }
  7131     CXnProperty* marginTop = aNode.MarginTopL();
  7145     CXnProperty* marginTop = aNode.MarginTopL();
  7132     if ( IsPropertyAutoL( *marginTop ) )
  7146     if ( IsPropertyAutoL( *marginTop ) )
  7133         {
  7147         {
  7134         TPtrC8 propertyName = marginTop->Property()->Name();
  7148         TPtrC8 propertyName = marginTop->Property()->Name();
  7135         autoArray.AppendL( propertyName );
  7149         autoArray.Append( propertyName );
  7136         }
  7150         }
  7137     CXnProperty* marginBottom = aNode.MarginBottomL();
  7151     CXnProperty* marginBottom = aNode.MarginBottomL();
  7138     if ( IsPropertyAutoL( *marginBottom ) )
  7152     if ( IsPropertyAutoL( *marginBottom ) )
  7139         {
  7153         {
  7140         TPtrC8 propertyName = marginBottom->Property()->Name();
  7154         TPtrC8 propertyName = marginBottom->Property()->Name();
  7141         autoArray.AppendL( propertyName );
  7155         autoArray.Append( propertyName );
  7142         }
  7156         }
  7143     CXnProperty* marginLeft = aNode.MarginLeftL();
  7157     CXnProperty* marginLeft = aNode.MarginLeftL();
  7144     if ( IsPropertyAutoL( *marginLeft ) )
  7158     if ( IsPropertyAutoL( *marginLeft ) )
  7145         {
  7159         {
  7146         TPtrC8 propertyName = marginLeft->Property()->Name();
  7160         TPtrC8 propertyName = marginLeft->Property()->Name();
  7147         autoArray.AppendL( propertyName );
  7161         autoArray.Append( propertyName );
  7148         }
  7162         }
  7149     CXnProperty* marginRight = aNode.MarginRightL();
  7163     CXnProperty* marginRight = aNode.MarginRightL();
  7150     if ( IsPropertyAutoL( *marginRight ) )
  7164     if ( IsPropertyAutoL( *marginRight ) )
  7151         {
  7165         {
  7152         TPtrC8 propertyName = marginRight->Property()->Name();
  7166         TPtrC8 propertyName = marginRight->Property()->Name();
  7153         autoArray.AppendL( propertyName );
  7167         autoArray.Append( propertyName );
  7154         }
  7168         }
  7155 
  7169 
  7156     if ( aParentDirection == XnPropertyNames::style::common::direction::KLTR )
  7170     if ( aParentDirection == XnPropertyNames::style::common::direction::KLTR )
  7157         {
  7171         {
  7158         if ( aParentBlockProgression ==
  7172         if ( aParentBlockProgression ==
  7967 
  7981 
  7968     return node;
  7982     return node;
  7969     }
  7983     }
  7970 
  7984 
  7971 // -----------------------------------------------------------------------------
  7985 // -----------------------------------------------------------------------------
  7972 // -----------------------------------------------------------------------------
       
  7973 //
       
  7974 static void ReportScreenDeviceChangedL( const CXnPluginData& aPluginData )
       
  7975     {   
       
  7976     CXnNode* node( NULL );
       
  7977     
       
  7978     if ( aPluginData.Node() )
       
  7979         {
       
  7980         node = aPluginData.Node()->LayoutNode();
       
  7981         }
       
  7982     
       
  7983     if ( !node )
       
  7984         {
       
  7985         return;        
       
  7986         }
       
  7987     
       
  7988     CXnNode* trigger( BuildScreenDeviceChangeTriggerNodeLC( *node->UiEngine() ) );
       
  7989 
       
  7990     node->ReportXuikonEventL( *trigger );
       
  7991     
       
  7992     CleanupStack::PopAndDestroy( trigger );
       
  7993     
       
  7994     RPointerArray< CXnPluginData >& plugins( aPluginData.PluginData() );
       
  7995     
       
  7996     for( TInt i = 0; i < plugins.Count(); i++ )
       
  7997         {
       
  7998         ReportScreenDeviceChangedL( *plugins[i] );
       
  7999         }     
       
  8000     }
       
  8001 
       
  8002 // -----------------------------------------------------------------------------
       
  8003 // FillFocusCandidatesL
  7986 // FillFocusCandidatesL
  8004 // -----------------------------------------------------------------------------
  7987 // -----------------------------------------------------------------------------
  8005 //
  7988 //
  8006 static void FillFocusCandidatesL( CXnNode* aParent,
  7989 static void FillFocusCandidatesL( CXnNode* aParent,
  8007     RPointerArray< CXnNode >& aArray )
  7990     RPointerArray< CXnNode >& aArray )
  8209     iViewManager.RemoveObserver( *this );
  8192     iViewManager.RemoveObserver( *this );
  8210            
  8193            
  8211     delete iEditMode;
  8194     delete iEditMode;
  8212 
  8195 
  8213     iFocusCandidateList.Reset();
  8196     iFocusCandidateList.Reset();
       
  8197 
       
  8198     if ( iRedrawRegions.Count() )
       
  8199         {
       
  8200         iRedrawRegions.ResetAndDestroy();
       
  8201         }
       
  8202 
       
  8203     iDirtyList.Reset();
  8214     }
  8204     }
  8215 
  8205 
  8216 // -----------------------------------------------------------------------------
  8206 // -----------------------------------------------------------------------------
  8217 // CXnUiEngineImpl::AppUiAdapter()
  8207 // CXnUiEngineImpl::AppUiAdapter()
  8218 // -----------------------------------------------------------------------------
  8208 // -----------------------------------------------------------------------------
  8224 
  8214 
  8225 // -----------------------------------------------------------------------------
  8215 // -----------------------------------------------------------------------------
  8226 // CXnUiEngineImpl::LayoutUIL()
  8216 // CXnUiEngineImpl::LayoutUIL()
  8227 // -----------------------------------------------------------------------------
  8217 // -----------------------------------------------------------------------------
  8228 //
  8218 //
  8229 void CXnUiEngineImpl::LayoutUIL( CXnNode* aNode )
  8219 void CXnUiEngineImpl::LayoutUIL( CXnNode* /*aNode*/ )
  8230     {
  8220     {
  8231     if( aNode )
  8221     if ( IsLayoutDisabled() )
  8232         {
       
  8233         TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *aNode );
       
  8234         if( dirtyRegion )
       
  8235             {
       
  8236             LayoutL( *dirtyRegion );
       
  8237             }
       
  8238         }
       
  8239     else
       
  8240         {
       
  8241         CXnViewData* viewData = iViewManager.ActiveAppData().ViewData( *iCurrentView );
       
  8242         if( viewData )
       
  8243             {
       
  8244             RPointerArray<TXnDirtyRegion> arr;
       
  8245             CleanupClosePushL( arr );
       
  8246             viewData->GetDirtyRegions( arr );
       
  8247             for( TInt i = 0; i < arr.Count(); i++ )
       
  8248                 {
       
  8249                 LayoutL( *arr[i] );            
       
  8250                 }
       
  8251             CleanupStack::PopAndDestroy( &arr );
       
  8252             }
       
  8253         }
       
  8254     }
       
  8255 
       
  8256 // -----------------------------------------------------------------------------
       
  8257 // CXnUiEngineImpl::LayoutUIL()
       
  8258 // -----------------------------------------------------------------------------
       
  8259 //
       
  8260 void CXnUiEngineImpl::LayoutL( TXnDirtyRegion& aRegion )
       
  8261     {
       
  8262     if ( IsLayoutDisabled( aRegion ) )
       
  8263         {     
  8222         {     
  8264         aRegion.iLayoutControl |= XnLayoutControl::ELayoutUI;
  8223         iLayoutControl |= XnLayoutControl::ELayoutUI;
  8265         return;
  8224         return;
  8266         }
  8225         }
  8267 
  8226 
  8268     aRegion.iLayoutControl &= ~XnLayoutControl::ELayoutUI;
  8227     iLayoutControl &= ~XnLayoutControl::ELayoutUI;
  8269 
  8228 
  8270     if ( aRegion.iDirtyList.Count() == 0 )
  8229     if ( iDirtyList.Count() == 0 )
  8271         {
  8230         {
  8272         // Nothing to do, layout is up-to-date
  8231         // Nothing to do, layout is up-to-date
  8273         return;
  8232         return;
  8274         }
  8233         }
  8275 
  8234 
  8276     DisableRenderUiLC();
  8235     DisableRenderUiLC();
  8277     
  8236     CXnNode* candidate( StartLayoutFromL() );
  8278     CXnNode* candidate( StartLayoutFromL( aRegion ) );
  8237     PrepareRunLayoutL();
  8279     if( !candidate )
  8238     iDirtyList.Reset();
  8280         {
       
  8281         return;
       
  8282         }
       
  8283     
       
  8284     PrepareRunLayoutL( aRegion );
       
  8285     aRegion.iDirtyList.Reset();
       
  8286 
  8239 
  8287     // Run layout until it is fully calculated
  8240     // Run layout until it is fully calculated
  8288     do
  8241     do
  8289         {
  8242         {
  8290         iLayoutPhase = RunLayoutL( aRegion, *candidate );
  8243         iLayoutPhase = RunLayoutL( candidate );
  8291         }
  8244         }
  8292     while ( iLayoutPhase != XnLayoutPhase::ENone );
  8245     while ( iLayoutPhase != XnLayoutPhase::ENone );
  8293 
  8246 
  8294     // Run these only if the current view is being layouted
  8247     CXnNode* focused( FocusedNode() );
  8295     if( iCurrentView == aRegion.iRootNode )
  8248 
  8296         {  
  8249     if ( focused && focused->IsDropped() )
  8297         CXnNode* focused( FocusedNode() );
  8250         {
  8298     
  8251         // The currently focused node is dropped, run losevisualization
  8299         if ( focused && focused->IsDropped() )
  8252         CXnNode* loseVisualisation =
  8300             {
  8253             BuildTriggerNodeLC( *iUiEngine,
  8301             // The currently focused node is dropped, run losevisualization
  8254                 XnPropertyNames::action::trigger::name::KLoseVisualisation );
  8302             CXnNode* loseVisualisation =
  8255 
  8303                 BuildTriggerNodeLC( *iUiEngine,
  8256         focused->ReportXuikonEventL( *loseVisualisation );
  8304                     XnPropertyNames::action::trigger::name::KLoseVisualisation );
  8257         CleanupStack::PopAndDestroy( loseVisualisation );
  8305     
  8258 
  8306             focused->ReportXuikonEventL( *loseVisualisation );
  8259         if ( FocusedNode() == focused )
  8307             CleanupStack::PopAndDestroy( loseVisualisation );
  8260             {
  8308     
  8261             // Remove focus as losevisualization trigger didn't
  8309             if ( FocusedNode() == focused )
  8262             // change focus from dropped node to another one
  8310                 {
  8263             SetFocusedNodeL( NULL );
  8311                 // Remove focus as losevisualization trigger didn't
  8264             }
  8312                 // change focus from dropped node to another one
  8265         }
  8313                 SetFocusedNodeL( NULL );
  8266 
  8314                 }
  8267     if ( !FocusedNode() && iAppUiAdapter.FocusShown() )
  8315             }
  8268         {
  8316     
  8269         // No focus, try if some of the focus candidates can be focused
  8317         if ( !FocusedNode() && iAppUiAdapter.FocusShown() )
  8270         RootNode()->RunFocusChangeL( iFocusCandidateList );
  8318             {
  8271         }
  8319             // No focus, try if some of the focus candidates can be focused
  8272         
  8320             RootNode()->RunFocusChangeL( iFocusCandidateList );
  8273     iFocusCandidateList.Reset();
  8321             }
  8274 
  8322             
  8275     iAppUiAdapter.EffectManager()->UiLayouted();
  8323         iFocusCandidateList.Reset();
       
  8324     
       
  8325         iAppUiAdapter.EffectManager()->UiLayouted();
       
  8326         }
       
  8327     
  8276     
  8328     // Layout is now recalculated
  8277     // Layout is now recalculated
  8329     CleanupStack::PopAndDestroy(); // anonymous
  8278     CleanupStack::PopAndDestroy(); // anonymous
  8330     }
  8279     }
  8331 
  8280 
  8332 
       
  8333 // -----------------------------------------------------------------------------
  8281 // -----------------------------------------------------------------------------
  8334 // PrepareRunLayoutL()
  8282 // PrepareRunLayoutL()
  8335 // Set dropped flags of all nodes in the tree to ENone.
  8283 // Set dropped flags of all nodes in the tree to ENone.
  8336 // -----------------------------------------------------------------------------
  8284 // -----------------------------------------------------------------------------
  8337 //
  8285 //
  8338 void CXnUiEngineImpl::PrepareRunLayoutL( TXnDirtyRegion& aDirtyRegion )
  8286 void CXnUiEngineImpl::PrepareRunLayoutL()
  8339     {
  8287     {
  8340     if ( iLayoutPhase == XnLayoutPhase::ENone )
  8288     if ( iLayoutPhase == XnLayoutPhase::ENone )
  8341         {
  8289         {
  8342         iLayoutPhase = XnLayoutPhase::ELayout;
  8290         iLayoutPhase = XnLayoutPhase::ELayout;
  8343 
  8291 
  8344         for ( TInt i = 0; i < aDirtyRegion.iDirtyList.Count(); i++ )
  8292         for ( TInt i = 0; i < iDirtyList.Count(); i++ )
  8345             {
  8293             {
  8346             CXnNode* dirty( aDirtyRegion.iDirtyList[i] );
  8294             CXnNode* dirty( iDirtyList[i] );
  8347 
  8295 
  8348             // Clear dropped flags recursively
  8296             // Clear dropped flags recursively
  8349             SetNodeDroppedL( *dirty, XnNodeLayout::ENone );
  8297             SetNodeDroppedL( *dirty, XnNodeLayout::ENone );
  8350 
  8298 
  8351             if ( SetAdaptivesL( *dirty ) )
  8299             if ( SetAdaptivesL( *dirty ) )
  8359 
  8307 
  8360 // -----------------------------------------------------------------------------
  8308 // -----------------------------------------------------------------------------
  8361 // CXnUiEngineImpl::RunLayoutL()
  8309 // CXnUiEngineImpl::RunLayoutL()
  8362 // -----------------------------------------------------------------------------
  8310 // -----------------------------------------------------------------------------
  8363 //
  8311 //
  8364 TInt CXnUiEngineImpl::RunLayoutL( TXnDirtyRegion& aDirtyRegion, CXnNode& aNode )
  8312 TInt CXnUiEngineImpl::RunLayoutL( CXnNode* aNode )
  8365     {
  8313     {
  8366     TRect clientRect( ClientRect() );
  8314     TRect clientRect( ClientRect() );
  8367     // Move it to 0, 0
  8315     // Move it to 0, 0
  8368     clientRect.Move( -clientRect.iTl.iX, -clientRect.iTl.iY );
  8316     clientRect.Move( -clientRect.iTl.iX, -clientRect.iTl.iY );
  8369 
  8317 
  8370     RPointerArray< CXnNode > laidOutList;
  8318     RPointerArray< CXnNode > laidOutList;
  8371     CleanupClosePushL( laidOutList );
  8319     CleanupClosePushL( laidOutList );
  8372 
  8320 
  8373     if ( IsNodeDisplayedL( aNode ) )
  8321     if ( IsNodeDisplayedL( *aNode ) )
  8374         {
  8322         {
  8375         if ( aNode.ViewNodeImpl() && !aNode.IsLaidOut() )
  8323         if ( aNode->ViewNodeImpl() && !aNode ->IsLaidOut() )
  8376             {
  8324             {
  8377             aNode.SetMarginRect( clientRect );
  8325             aNode->SetMarginRect( clientRect );
  8378             aNode.SetBorderRect( clientRect );
  8326             aNode->SetBorderRect( clientRect );
  8379             aNode.SetNormalFlowBorderRect( clientRect );
  8327             aNode->SetNormalFlowBorderRect( clientRect );
  8380             aNode.SetPaddingRect( clientRect );
  8328             aNode->SetPaddingRect( clientRect );
  8381             aNode.SetRect( clientRect );
  8329             aNode->SetRect( clientRect );
  8382             }
  8330             }
  8383 
  8331 
  8384         // Put areas to place
  8332         // Put areas to place
  8385         PlaceAreasL( aNode, laidOutList, iLayoutPhase,
  8333         PlaceAreasL( *aNode, laidOutList, iLayoutPhase,
  8386             *iCurrentGraphicsDevice, iHorizontalUnitInPixels,
  8334             *iCurrentGraphicsDevice, iHorizontalUnitInPixels,
  8387             iVerticalUnitInPixels );
  8335             iVerticalUnitInPixels );
  8388         }
  8336         }
  8389 
  8337 
  8390     TInt nextPhase;
  8338     TInt nextPhase;
  8394         case XnLayoutPhase::EMeasure:
  8342         case XnLayoutPhase::EMeasure:
  8395             nextPhase = XnLayoutPhase::ELayout;
  8343             nextPhase = XnLayoutPhase::ELayout;
  8396             break;
  8344             break;
  8397         case XnLayoutPhase::ELayout:
  8345         case XnLayoutPhase::ELayout:
  8398             // Layout is now calculated
  8346             // Layout is now calculated
  8399             aDirtyRegion.iRootNode->SetLaidOutL();
  8347             iCurrentView->SetLaidOutL();
  8400             aDirtyRegion.iLayoutControl &= ~XnLayoutControl::EViewDirty;
  8348             iLayoutControl &= ~XnLayoutControl::EViewDirty;
  8401             // Check nodes which dimensions are changed
  8349             // Check nodes which dimensions are changed
  8402             for ( TInt i = 0; i < laidOutList.Count(); i++ )
  8350             for ( TInt i = 0; i < laidOutList.Count(); i++ )
  8403                 {
  8351                 {
  8404                 CXnNode* node( laidOutList[i] );
  8352                 CXnNode* node( laidOutList[i] );
  8405                 if( IsSrollableBox( *node ) && node->ScrollableControl() )
  8353                 if( IsSrollableBox( *node ) && node->ScrollableControl() )
  8427                         rect = node->BorderRect();
  8375                         rect = node->BorderRect();
  8428                         }
  8376                         }
  8429                     
  8377                     
  8430                     if ( adapter->Rect() != rect )
  8378                     if ( adapter->Rect() != rect )
  8431                         {
  8379                         {
  8432                         AddToRedrawListL( aDirtyRegion, *node, rect );
  8380                         AddToRedrawListL( node, rect );
  8433                         
  8381                         
  8434                         adapter->SetRect( rect );                        
  8382                         adapter->SetRect( rect );                        
  8435 
  8383 
  8436                         CXnProperty* prop = node->GetPropertyL(
  8384                         CXnProperty* prop = node->GetPropertyL(
  8437                             XnPropertyNames::common::KSizeAware );
  8385                             XnPropertyNames::common::KSizeAware );
  8459 
  8407 
  8460 // -----------------------------------------------------------------------------
  8408 // -----------------------------------------------------------------------------
  8461 // CXnUiEngineImpl::RenderUIL()
  8409 // CXnUiEngineImpl::RenderUIL()
  8462 // -----------------------------------------------------------------------------
  8410 // -----------------------------------------------------------------------------
  8463 //
  8411 //
  8464 void CXnUiEngineImpl::RenderUIL( CXnNode* aNode )
  8412 void CXnUiEngineImpl::RenderUIL( CXnNode* /*aNode*/ )
  8465     {
  8413     {
  8466     if( aNode )
  8414     if ( IsLayoutDisabled() )
  8467         {
       
  8468         TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *aNode );
       
  8469         if( dirtyRegion )
       
  8470             {
       
  8471             RenderL( *dirtyRegion );
       
  8472             }
       
  8473         }
       
  8474     else
       
  8475         {
       
  8476         CXnViewData* viewData = iViewManager.ActiveAppData().ViewData( *iCurrentView );
       
  8477         if( viewData )
       
  8478             {
       
  8479             RPointerArray<TXnDirtyRegion> arr;
       
  8480             CleanupClosePushL( arr );
       
  8481             
       
  8482             viewData->GetDirtyRegions( arr );
       
  8483             for( TInt i = 0; i < arr.Count(); i++ )
       
  8484                 {
       
  8485                 RenderL( *arr[i] );            
       
  8486                 }
       
  8487             CleanupStack::PopAndDestroy( &arr );
       
  8488             }
       
  8489         }
       
  8490     }
       
  8491 
       
  8492 // -----------------------------------------------------------------------------
       
  8493 // CXnUiEngineImpl::RenderUIL()
       
  8494 // -----------------------------------------------------------------------------
       
  8495 //
       
  8496 void CXnUiEngineImpl::RenderL( TXnDirtyRegion& aRegion )
       
  8497     {
       
  8498     if ( IsLayoutDisabled( aRegion ) )
       
  8499         {
  8415         {
  8500         // Layout is not up-to-date
  8416         // Layout is not up-to-date
  8501         aRegion.iLayoutControl |= XnLayoutControl::ERenderUI;
  8417         iLayoutControl |= XnLayoutControl::ERenderUI;
  8502         return;
  8418         return;
  8503         }
  8419         }
  8504 
  8420     
  8505     TBool belongsToCurrentView( EFalse );
       
  8506     if( iCurrentView == aRegion.iRootNode )
       
  8507         {
       
  8508         belongsToCurrentView = ETrue;
       
  8509         }
       
  8510         
       
  8511 #ifdef _XN3_DEBUG_
  8421 #ifdef _XN3_DEBUG_
  8512     TraceTreeL( aRegion.RootNode );
  8422     TraceTreeL(iCurrentView );
  8513 #endif                          
  8423 #endif                          
  8514 
  8424 
  8515     __PRINTS("*** CXnUiEngineImpl::RenderUIL ***");
  8425     __PRINTS("*** CXnUiEngineImpl::RenderUIL ***");
  8516     
  8426     
       
  8427     for( TInt i=0; i<iRedrawRegions.Count(); i++)
       
  8428         {
       
  8429         CCoeControl* control = iRedrawRegions[i]->iControl;
       
  8430         RRegion& redrawRegion = iRedrawRegions[i]->iRegion;
  8517         
  8431         
  8518     CCoeControl* control = aRegion.iControl;
  8432         if( redrawRegion.CheckError() )
  8519     RRegion& redrawRegion = aRegion.iRegion;
  8433             {                
  8520     
       
  8521     if( redrawRegion.CheckError() )
       
  8522         {                
       
  8523         // Mark tree rendered
       
  8524         aRegion.iRootNode->SetRenderedL();
       
  8525         // Error occured during dirty set, redraw whole window
       
  8526         control->DrawNow();               
       
  8527         
       
  8528         __PRINTS("* CXnUiEngineImpl::RenderUIL - redraw region error -> full redraw ***");
       
  8529         }                                        
       
  8530     else 
       
  8531         {
       
  8532         if( !redrawRegion.IsEmpty() )                                        
       
  8533             {
       
  8534             // Mark tree rendered
  8434             // Mark tree rendered
  8535             aRegion.iRootNode->SetRenderedL();
  8435             iCurrentView->SetRenderedL();
       
  8436             // Error occured during dirty set, redraw whole window
       
  8437             control->DrawNow();               
       
  8438             
       
  8439             __PRINTS("* CXnUiEngineImpl::RenderUIL - redraw region error -> full redraw ***");
       
  8440             }                                        
       
  8441         else 
       
  8442             {
       
  8443             if( !redrawRegion.IsEmpty() )                                        
       
  8444                 {
       
  8445                 // Mark tree rendered
       
  8446                 iCurrentView->SetRenderedL();
       
  8447                                 
       
  8448                 if ( iAppUiAdapter.EffectManager()->ControlEffectActive( control ) )
       
  8449                     {
       
  8450                     // control effect is ongoing, no need to draw control yet
       
  8451                     redrawRegion.Clear();
       
  8452                     continue;
       
  8453                     }
  8536                 
  8454                 
  8537             TBool effectOngoing( EFalse );
       
  8538             if ( iAppUiAdapter.EffectManager()->ControlEffectActive( control ) &&
       
  8539                  belongsToCurrentView )
       
  8540                 {
       
  8541                 // control effect is ongoing, no need to draw control yet,
       
  8542                 // if current view in question
       
  8543                 redrawRegion.Clear();
       
  8544                 effectOngoing = ETrue;
       
  8545                 }
       
  8546             
       
  8547             if( !effectOngoing )
       
  8548                 {
       
  8549                 TInt count( redrawRegion.Count() );
  8455                 TInt count( redrawRegion.Count() );
  8550                 
  8456                 
  8551                 if( count > 2 )
  8457                 if( count > 2 )
  8552                     {
  8458                     {
  8553                     // Make bounding rect over the dirty areas
  8459                     // Make bounding rect over the dirty areas
  8562                     {
  8468                     {
  8563                     for( TInt i = 0; i < count; i++ )
  8469                     for( TInt i = 0; i < count; i++ )
  8564                         {
  8470                         {
  8565                         // Draw every dirty area separately
  8471                         // Draw every dirty area separately
  8566                         TRect redrawRect( redrawRegion[i] );
  8472                         TRect redrawRect( redrawRegion[i] );
  8567     
  8473 
  8568                         __PRINT( __DBG_FORMAT( "* CXnUiEngineImpl::RenderUIL - redrawing rect iTl.iX: %d, iTl.iY: %d, iBr.iX: %d, iBr.iY: %d" ),          
  8474                         __PRINT( __DBG_FORMAT( "* CXnUiEngineImpl::RenderUIL - redrawing rect iTl.iX: %d, iTl.iY: %d, iBr.iX: %d, iBr.iY: %d" ),          
  8569                                 redrawRect.iTl.iX, redrawRect.iTl.iY, redrawRect.iBr.iX, redrawRect.iBr.iY );                                         
  8475                                 redrawRect.iTl.iX, redrawRect.iTl.iY, redrawRect.iBr.iX, redrawRect.iBr.iY );                                         
  8570                         
  8476                         
  8571                         control->DrawNow( redrawRect );
  8477                         control->DrawNow( redrawRect );
  8572                         }
  8478                         }
  8573                     }  
  8479                     }  
  8574                 }
  8480                 }
  8575             }
  8481             else
  8576         else
  8482                 {
  8577             {
  8483                 __PRINTS("* CXnUiEngineImpl::RenderUIL - nothing to redraw ***");
  8578             __PRINTS("* CXnUiEngineImpl::RenderUIL - nothing to redraw ***");
  8484                 }
  8579             }
  8485             }  
  8580         }  
  8486         
       
  8487         redrawRegion.Clear();  
       
  8488         }
       
  8489 
       
  8490     RefreshMenuL();
       
  8491 
       
  8492     iLayoutControl &= ~XnLayoutControl::ERenderUI;
  8581     
  8493     
  8582     redrawRegion.Clear();  
  8494     iAppUiAdapter.EffectManager()->UiRendered();
  8583 
       
  8584     RefreshMenuL( &aRegion );
       
  8585 
       
  8586     aRegion.iLayoutControl &= ~XnLayoutControl::ERenderUI;
       
  8587     
       
  8588     if( belongsToCurrentView )
       
  8589         {
       
  8590         iAppUiAdapter.EffectManager()->UiRendered();
       
  8591         }
       
  8592     
  8495     
  8593     __PRINTS("*** CXnUiEngineImpl::RenderUIL - done ***");
  8496     __PRINTS("*** CXnUiEngineImpl::RenderUIL - done ***");
  8594     }
  8497     }
  8595 
  8498 
  8596 // -----------------------------------------------------------------------------
  8499 // -----------------------------------------------------------------------------
  8856     {
  8759     {
  8857     iCurrentView = iViewManager.ViewNode();
  8760     iCurrentView = iViewManager.ViewNode();
  8858 
  8761 
  8859     iControlAdapterList = &iViewManager.Controls();
  8762     iControlAdapterList = &iViewManager.Controls();
  8860     iCurrentViewControlAdapter = iCurrentView->Control();
  8763     iCurrentViewControlAdapter = iCurrentView->Control();
       
  8764     
       
  8765     iDirtyList.Reset();
       
  8766 
       
  8767     iRedrawRegions.ResetAndDestroy();
  8861        
  8768        
  8862     // Remove previous menubar and stylus popup node
  8769     // Remove previous menubar and stylus popup node
  8863     iMenuNode = NULL;
  8770     iMenuNode = NULL;
  8864     iStylusPopupNode = NULL;
  8771     iStylusPopupNode = NULL;
  8865 
  8772 
  8895             static_cast< CXnPopupControlAdapter* > 
  8802             static_cast< CXnPopupControlAdapter* > 
  8896 				( node->Control() )->SetObserver( *this );
  8803 				( node->Control() )->SetObserver( *this );
  8897             }
  8804             }
  8898         }
  8805         }
  8899 
  8806 
       
  8807     ReportScreenDeviceChangeL();
       
  8808             
  8900     SetClientRectL( iAppUiAdapter.ClientRect(), EFalse );
  8809     SetClientRectL( iAppUiAdapter.ClientRect(), EFalse );
  8901     
  8810     
  8902     RootNode()->SetDirtyL();
  8811     RootNode()->SetDirtyL();
  8903            
  8812            
  8904     ForceRenderUIL();
  8813     ForceRenderUIL();
  8905            
  8814            
  8906     TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *iCurrentView );
  8815     iLayoutControl &= ~XnLayoutControl::ERefreshMenu;
  8907     if( dirtyRegion )
       
  8908         {
       
  8909         dirtyRegion->iDirtyList.Reset();
       
  8910         dirtyRegion->iLayoutControl &= ~XnLayoutControl::ERefreshMenu;
       
  8911         }
       
  8912     }
       
  8913 
       
  8914 // -----------------------------------------------------------------------------
       
  8915 // CXnUiEngineImpl::NotifyViewLoadedL()
       
  8916 // -----------------------------------------------------------------------------
       
  8917 // 
       
  8918 void CXnUiEngineImpl::NotifyViewLoadedL( const CXnViewData& aViewData )
       
  8919     {
       
  8920     ReportScreenDeviceChangedL( aViewData );
       
  8921     }
  8816     }
  8922 
  8817 
  8923 // -----------------------------------------------------------------------------
  8818 // -----------------------------------------------------------------------------
  8924 // CXnUiEngineImpl::NotifyWidgetAdditionL()
  8819 // CXnUiEngineImpl::NotifyWidgetAdditionL()
  8925 // -----------------------------------------------------------------------------
  8820 // -----------------------------------------------------------------------------
  8926 //
  8821 //
  8927 void CXnUiEngineImpl::NotifyWidgetAdditionL(
  8822 void CXnUiEngineImpl::NotifyWidgetAdditionL(
  8928     const CXnPluginData& aPluginData )
  8823     const CXnPluginData& /*aPluginData*/ )
  8929     {
  8824     {
  8930     ReportScreenDeviceChangedL( aPluginData );
  8825     }
  8931     }
  8826 
  8932 
       
  8933 // -----------------------------------------------------------------------------
       
  8934 // CXnUiEngineImpl::NotifyViewAdditionL()
       
  8935 // -----------------------------------------------------------------------------
       
  8936 // 
       
  8937 void CXnUiEngineImpl::NotifyViewAdditionL( const CXnViewData& aViewData )
       
  8938     {
       
  8939     ReportScreenDeviceChangedL( aViewData );
       
  8940     }
       
  8941     
       
  8942 // -----------------------------------------------------------------------------
  8827 // -----------------------------------------------------------------------------
  8943 // CXnUiEngineImpl::DynInitMenuItemL()
  8828 // CXnUiEngineImpl::DynInitMenuItemL()
  8944 // -----------------------------------------------------------------------------
  8829 // -----------------------------------------------------------------------------
  8945 //
  8830 //
  8946 TBool CXnUiEngineImpl::DynInitMenuItemL( CXnNodeAppIf& aMenuItem,
  8831 TBool CXnUiEngineImpl::DynInitMenuItemL( CXnNodeAppIf& aMenuItem,
  9123 // Refresh current menu
  9008 // Refresh current menu
  9124 // -----------------------------------------------------------------------------
  9009 // -----------------------------------------------------------------------------
  9125 //
  9010 //
  9126 void CXnUiEngineImpl::RefreshMenuL()
  9011 void CXnUiEngineImpl::RefreshMenuL()
  9127     {
  9012     {
  9128     RefreshMenuL( NULL );
  9013     if ( IsLayoutDisabled() )
  9129     }
  9014         {
  9130 
  9015         return;
  9131 // -----------------------------------------------------------------------------
       
  9132 // CXnUiEngineImpl::RefreshMenuL
       
  9133 // Refresh current menu
       
  9134 // -----------------------------------------------------------------------------
       
  9135 //
       
  9136 void CXnUiEngineImpl::RefreshMenuL( TXnDirtyRegion* aDirtyRegion )
       
  9137     {
       
  9138     TXnDirtyRegion* dirtyRegion = aDirtyRegion;
       
  9139     if( !dirtyRegion )
       
  9140         {
       
  9141         dirtyRegion = FindDirtyRegionL( *iCurrentView );
       
  9142         }
  9016         }
  9143     
  9017     
  9144     if ( IsLayoutDisabled( *dirtyRegion ) )
  9018     if ( iLayoutControl & XnLayoutControl::ERefreshMenu )         
  9145         {
       
  9146         return;
       
  9147         }
       
  9148 
       
  9149     if ( dirtyRegion && 
       
  9150          dirtyRegion->iLayoutControl & XnLayoutControl::ERefreshMenu )         
       
  9151         {
  9019         {
  9152         if ( iKeyEventDispatcher )
  9020         if ( iKeyEventDispatcher )
  9153             {
  9021             {
  9154             dirtyRegion->iLayoutControl &= ~XnLayoutControl::ERefreshMenu;
  9022             iLayoutControl &= ~XnLayoutControl::ERefreshMenu;
  9155             iKeyEventDispatcher->RefreshMenuL();        
  9023             iKeyEventDispatcher->RefreshMenuL();        
  9156             }               
  9024             }               
  9157         }
  9025         }
  9158     }
  9026     }
  9159 
  9027 
  9162 // Add a dirty node. This method must be called via CXnNode SetDirtyL
  9030 // Add a dirty node. This method must be called via CXnNode SetDirtyL
  9163 // -----------------------------------------------------------------------------
  9031 // -----------------------------------------------------------------------------
  9164 //
  9032 //
  9165 void CXnUiEngineImpl::AddDirtyNodeL( CXnNode* aNode, TInt aLevel )
  9033 void CXnUiEngineImpl::AddDirtyNodeL( CXnNode* aNode, TInt aLevel )
  9166     {
  9034     {
  9167     if ( !aNode )
  9035     CXnViewData& data( iViewManager.ActiveViewData() );
  9168         {
  9036     
       
  9037     if ( !aNode || ( aNode != RootNode() && !data.Plugin( aNode->Namespace() ) ) )
       
  9038         {
       
  9039         // No node, or node doesn't belong to active view namespace
  9169         return;
  9040         return;
  9170         }    
  9041         }
  9171     
  9042 
  9172     if ( aNode == RootNode() )
  9043     if ( aNode->Type()->Type() == KMenuBar )
  9173         {
  9044         {
  9174         // Force relayout and redraw from current view
  9045         iLayoutControl |= XnLayoutControl::ERefreshMenu;
  9175         iViewManager.ActiveAppData().PluginData();
  9046         return;
  9176         if ( !iCurrentView )
  9047         }
  9177             {
  9048 
  9178             iCurrentView = iViewManager.ViewNode();
  9049     if ( iLayoutControl & XnLayoutControl::EViewDirty )
  9179             }
  9050         {
  9180 
  9051         // nothing to do
  9181         TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *iCurrentView );
  9052         return;
  9182         if( dirtyRegion )
  9053         }
  9183             {
  9054 
  9184             dirtyRegion->iRegion.Clear();        
  9055     if ( aLevel == XnDirtyLevel::ERender )
  9185             }
  9056         {
  9186         else
  9057         if( aNode == RootNode() )        
  9187             {
  9058             {
  9188             return;        
  9059             TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *iCurrentView );
  9189             }
  9060             if( dirtyRegion )
  9190         
  9061                 {
  9191         dirtyRegion->iDirtyList.Reset();
  9062                 dirtyRegion->iRegion.Clear();                
  9192         dirtyRegion->iDirtyList.AppendL( iCurrentView );
  9063                 }
  9193 
  9064             aNode = iCurrentView;        
  9194         dirtyRegion->iLayoutControl |= XnLayoutControl::EViewDirty;
  9065             }
  9195         iCurrentView->ClearRenderedAndLaidOut();
  9066 
  9196 
  9067         // Add to redraw list
  9197         // Add to draw list for redraw
  9068         AddToRedrawListL( aNode );
  9198         AddToRedrawListL( *dirtyRegion, *iCurrentView );
       
  9199         }
  9069         }
  9200     else
  9070     else
  9201         {
  9071         {
  9202         TXnDirtyRegion* dirtyRegion( FindDirtyRegionL( *aNode ) );
  9072         // Add to dirty list for relayout and redraw
  9203         if( !dirtyRegion )
  9073         AddToDirtyListL( aNode );
  9204             {
       
  9205             return;
       
  9206             }
       
  9207         
       
  9208         if ( aNode->Type()->Type() == KMenuBar )
       
  9209             {
       
  9210             dirtyRegion->iLayoutControl |= XnLayoutControl::ERefreshMenu;
       
  9211             return;
       
  9212             }
       
  9213     
       
  9214         if ( dirtyRegion->iLayoutControl & XnLayoutControl::EViewDirty )
       
  9215             {
       
  9216             // nothing to do
       
  9217             return;
       
  9218             }
       
  9219     
       
  9220         if ( aLevel == XnDirtyLevel::ERender )
       
  9221             {
       
  9222             if( aNode == RootNode() )        
       
  9223                 {
       
  9224                 TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *iCurrentView );
       
  9225                 if( dirtyRegion )
       
  9226                     {
       
  9227                     dirtyRegion->iRegion.Clear();                
       
  9228                     }
       
  9229                 aNode = iCurrentView;        
       
  9230                 }
       
  9231     
       
  9232             // Add to redraw list
       
  9233             AddToRedrawListL( *dirtyRegion, *aNode );
       
  9234             }
       
  9235         else
       
  9236             {
       
  9237             // Add to dirty list for relayout and redraw
       
  9238             AddToDirtyListL( *dirtyRegion, *aNode );
       
  9239             }    
       
  9240         }
  9074         }
  9241     }
  9075     }
  9242 
  9076 
  9243 // -----------------------------------------------------------------------------
  9077 // -----------------------------------------------------------------------------
  9244 // CXnUiEngineImpl::ScreenDeviceSize
  9078 // CXnUiEngineImpl::ScreenDeviceSize
  9288         HandleDynamicLayoutVariantSwitchL();
  9122         HandleDynamicLayoutVariantSwitchL();
  9289         }
  9123         }
  9290     else if ( aType == KAknsMessageSkinChange )
  9124     else if ( aType == KAknsMessageSkinChange )
  9291         {
  9125         {
  9292         HandleSkinChangeL();
  9126         HandleSkinChangeL();
       
  9127         }
       
  9128     else if( iCurrentViewControlAdapter )
       
  9129         {
       
  9130         iCurrentViewControlAdapter->HandleResourceChange( aType );
  9293         }
  9131         }
  9294     }
  9132     }
  9295 
  9133 
  9296 // -----------------------------------------------------------------------------
  9134 // -----------------------------------------------------------------------------
  9297 // CXnUiEngineImpl::HandleSkinChangeL
  9135 // CXnUiEngineImpl::HandleSkinChangeL
  9592 
  9430 
  9593 // -----------------------------------------------------------------------------
  9431 // -----------------------------------------------------------------------------
  9594 // CXnUiEngineImpl::IsLayoutDisabled
  9432 // CXnUiEngineImpl::IsLayoutDisabled
  9595 // -----------------------------------------------------------------------------
  9433 // -----------------------------------------------------------------------------
  9596 //
  9434 //
  9597 TBool CXnUiEngineImpl::IsLayoutDisabled( TXnDirtyRegion& aDirtyRegion )
  9435 TBool CXnUiEngineImpl::IsLayoutDisabled()
  9598     {
  9436     {
  9599     if ( !iCurrentView )
  9437     if ( !iCurrentView )
  9600         {
  9438         {
  9601         return ETrue;
  9439         return ETrue;
  9602         }
  9440         }
  9603 
  9441     
  9604     TBool retval( EFalse );
  9442     TBool retval( EFalse );
  9605     
  9443     
  9606     if ( !( aDirtyRegion.iLayoutControl & XnLayoutControl::EIgnoreState ) )
  9444     if ( !( iLayoutControl & XnLayoutControl::EIgnoreState ) )
  9607         {
  9445         {
  9608         if ( iDisableCount > 0 )
  9446         if ( iDisableCount > 0 )
  9609             {
  9447             {
  9610             retval = ETrue;
  9448             retval = ETrue;
  9611             }
  9449             }
  9617 // -----------------------------------------------------------------------------
  9455 // -----------------------------------------------------------------------------
  9618 // AddToRedrawListL
  9456 // AddToRedrawListL
  9619 // Mark Control's appearance to be redrawn
  9457 // Mark Control's appearance to be redrawn
  9620 // -----------------------------------------------------------------------------    
  9458 // -----------------------------------------------------------------------------    
  9621 //
  9459 //
  9622 void CXnUiEngineImpl::AddToRedrawListL( TXnDirtyRegion& aRegion, 
  9460 void CXnUiEngineImpl::AddToRedrawListL( CXnNode* aNode, TRect aRect )
  9623     CXnNode& aNode, TRect aRect )
       
  9624     {   
  9461     {   
  9625     CXnControlAdapter* aAdapter( aNode.Control() );
  9462     CXnControlAdapter* aAdapter( aNode->Control() );
  9626            
  9463            
  9627     if( !aAdapter ) 
  9464     if( !aAdapter ) 
  9628         {
  9465         {
  9629         return;
  9466         return;
  9630         }
  9467         }
  9631 
  9468 
  9632     if( aRect != TRect::EUninitialized )
  9469     if( aRect != TRect::EUninitialized )
  9633         {
  9470         {
  9634         // This is the new rect which will be set by layout algo
  9471         // This is the new rect which will be set by layout algo
  9635         aRegion.iRegion.AddRect( aRect );
  9472         AddRedrawRectL( aRect, *aNode );
  9636         aRegion.iRegion.Tidy();
       
  9637         }
  9473         }
  9638     
  9474     
  9639     TRect rect( aAdapter->Rect() );
  9475     TRect rect( aAdapter->Rect() );
  9640             
  9476             
  9641     if( rect == TRect::EUninitialized )
  9477     if( rect == TRect::EUninitialized )
  9642         {
  9478         {
  9643         // Don't add uninitialized rect
  9479         // Don't add uninitialized rect
  9644         return;
  9480         return;
  9645         }
  9481         }
  9646     
  9482 
  9647     GrowIfNeeded( &aNode, rect );   
  9483     /*
  9648 
  9484     if( aNode->IsStateSet( XnPropertyNames::style::common::KFocus ) )
  9649     aRegion.iRegion.AddRect( rect );        
  9485         {
  9650     aRegion.iRegion.Tidy();
  9486         const TDesC8& name( aNode->DomNode()->Name() );
       
  9487 
       
  9488         if( name == KPlugin )
       
  9489             {
       
  9490             rect.Grow( KFocusGrowValue, KFocusGrowValue );
       
  9491             }
       
  9492         else
       
  9493             {
       
  9494             TRect marginRect( aNode->MarginRect() );
       
  9495             
       
  9496             CXnNode* parent( aNode->Parent() );
       
  9497             
       
  9498             for( ; parent; parent = parent->Parent() )
       
  9499                 {
       
  9500                 if( parent->DomNode()->Name() == KPlugin )
       
  9501                     {
       
  9502                     if( parent->Rect() == marginRect )
       
  9503                         {
       
  9504                         rect.Grow( KFocusGrowValue, KFocusGrowValue );
       
  9505                         }
       
  9506                     
       
  9507                     break;
       
  9508                     } 
       
  9509                 }                
       
  9510             }
       
  9511         }
       
  9512         */
       
  9513     GrowIfNeeded(aNode, rect);    
       
  9514     AddRedrawRectL( rect, *aNode );                          
  9651     }
  9515     }
  9652 
  9516 
  9653 // -----------------------------------------------------------------------------
  9517 // -----------------------------------------------------------------------------
  9654 // AddToDirtyListL
  9518 // AddToDirtyListL
  9655 // Mark node to dirty list for relayout
  9519 // Mark node to dirty list for relayout
  9656 // -----------------------------------------------------------------------------
  9520 // -----------------------------------------------------------------------------
  9657 //
  9521 //
  9658 void CXnUiEngineImpl::AddToDirtyListL( TXnDirtyRegion& aRegion, CXnNode& aNode )
  9522 void CXnUiEngineImpl::AddToDirtyListL( CXnNode* aNode )
  9659     {
  9523     {
  9660     CXnNode* nodeToRedrawList( &aNode );
  9524     
  9661     CXnNode* nodeToDirtyList( &aNode );
  9525     if ( aNode )
  9662 
  9526         {
  9663     if ( !IsAbsoluteL( aNode ) && !IsNodeTooltip( aNode ) )
  9527         CXnNode* nodeToRedrawList( aNode );
  9664         {
  9528         CXnNode* nodeToDirtyList( aNode );
  9665         // Check adaptives in normal flow
  9529     
  9666         CXnNode* oldest( NULL );
  9530         if ( aNode == RootNode() )
  9667         CXnNode* adaptive( &aNode );
  9531             {
  9668 
  9532             // Force relayout and redraw from current view
  9669         if ( !aNode.IsAdaptive( ETrue ) )
  9533             iDirtyList.Reset();
  9670             {
  9534             if ( !iCurrentView )
  9671             adaptive = aNode.Parent();
  9535                 {
  9672             }
  9536                 iCurrentView = iViewManager.ViewNode();
  9673 
  9537                 }
  9674         for ( ; adaptive && adaptive->IsAdaptive( ETrue );
  9538             iDirtyList.AppendL( iCurrentView );
  9675             adaptive = adaptive->Parent() )
  9539             TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *iCurrentView );
  9676             {
  9540             if( dirtyRegion )
  9677             oldest = adaptive;
  9541                 {
  9678             }
  9542                 dirtyRegion->iRegion.Clear();        
  9679 
  9543                 }
  9680         // Now we have found the oldest adaptive node if present
  9544             iLayoutControl |= XnLayoutControl::EViewDirty;
  9681         if ( oldest )
  9545             nodeToDirtyList = nodeToRedrawList = iCurrentView;
  9682             {
  9546             nodeToDirtyList->ClearRenderedAndLaidOut();
  9683             nodeToRedrawList = nodeToDirtyList = adaptive;
  9547     
  9684             }
  9548             // Add to draw list for redraw
  9685         }
  9549             AddToRedrawListL( nodeToRedrawList );
  9686 
  9550             }
  9687     RPointerArray< CXnNode > dirtyList;
  9551         else
  9688     CleanupClosePushL( dirtyList );
  9552             {
  9689     TInt count( aRegion.iDirtyList.Count() );
  9553             if ( !IsAbsoluteL( *aNode ) && !IsNodeTooltip( *aNode ) )
  9690     TBool found;
  9554                 {
  9691 
  9555                 // Check adaptives in normal flow
  9692     // first, check that aNode's children are not in the dirty array
  9556                 CXnNode* oldest( NULL );
  9693     for ( TInt i = 0; i < count; ++i )
  9557                 CXnNode* adaptive( aNode );
  9694         {
  9558     
  9695         found = EFalse;
  9559                 if ( !aNode->IsAdaptive( ETrue ) )
  9696         CXnNode* candidate( aRegion.iDirtyList[i] );
  9560                     {
  9697 
  9561                     adaptive = aNode->Parent();
  9698         for ( CXnNode* node = candidate->Parent(); node && !found;
  9562                     }
  9699             node = node->Parent() )
  9563     
  9700             {
  9564                 for ( ; adaptive && adaptive->IsAdaptive( ETrue );
  9701             if ( nodeToDirtyList == node )
  9565                     adaptive = adaptive->Parent() )
  9702                 {
  9566                     {
  9703                 found = ETrue;
  9567                     oldest = adaptive;
  9704                 }
  9568                     }
  9705             }
  9569     
  9706 
  9570                 // Now we have found the oldest adaptive node if present
  9707         if ( !found )
  9571                 if ( oldest )
  9708             {
  9572                     {
  9709             // Put candidate back to list as child is not found
  9573                     nodeToRedrawList = nodeToDirtyList = adaptive;
  9710             dirtyList.AppendL( candidate );
  9574                     }
  9711             }
  9575                 }
  9712         }
  9576     
  9713 
  9577             RPointerArray< CXnNode > dirtyList;
  9714     found = EFalse;
  9578             CleanupClosePushL( dirtyList );
  9715 
  9579             TInt count( iDirtyList.Count() );
  9716     // second, check that aNode's parent is not in dirty array
  9580             TBool found;
  9717     for ( TInt i = 0; i < count && !found; ++i )
  9581     
  9718         {
  9582             // first, check that aNode's children are not in the dirty array
  9719         CXnNode* candidate( aRegion.iDirtyList[i] );
  9583             for ( TInt i = 0; i < count; ++i )
  9720 
  9584                 {
  9721         for ( CXnNode* node = nodeToDirtyList; node && !found;
  9585                 found = EFalse;
  9722             node = node->Parent() )
  9586                 CXnNode* candidate( iDirtyList[i] );
  9723             {
  9587     
  9724             if ( node == candidate )
  9588                 for ( CXnNode* node = candidate->Parent(); node && !found;
  9725                 {
  9589                     node = node->Parent() )
  9726                 found = ETrue;
  9590                     {
  9727                 }
  9591                     if ( nodeToDirtyList == node )
  9728             }
  9592                         {
  9729         }
  9593                         found = ETrue;
  9730 
  9594                         }
  9731     if ( !found && aRegion.iDirtyList.Find( nodeToDirtyList ) == KErrNotFound )
  9595                     }
  9732         {
  9596     
  9733         // Add node to dirty list as parent is neither found
  9597                 if ( !found )
  9734         dirtyList.AppendL( nodeToDirtyList );
  9598                     {
  9735         nodeToDirtyList->ClearRenderedAndLaidOut();
  9599                     // Put candidate back to list as child is not found
  9736         
  9600                     dirtyList.AppendL( candidate );
  9737         // Add to draw list for redraw
  9601                     }
  9738         AddToRedrawListL( aRegion, *nodeToRedrawList );
  9602                 }
  9739         }
  9603     
  9740 
  9604             found = EFalse;
  9741     // finally update the dirty list
  9605     
  9742     aRegion.iDirtyList.Reset();
  9606             // second, check that aNode's parent is not in dirty array
  9743     aRegion.iDirtyList = dirtyList;
  9607             for ( TInt i = 0; i < count && !found; ++i )
  9744 
  9608                 {
  9745     CleanupStack::Pop( &dirtyList );
  9609                 CXnNode* candidate( iDirtyList[i] );
       
  9610     
       
  9611                 for ( CXnNode* node = nodeToDirtyList; node && !found;
       
  9612                     node = node->Parent() )
       
  9613                     {
       
  9614                     if ( node == candidate )
       
  9615                         {
       
  9616                         found = ETrue;
       
  9617                         }
       
  9618                     }
       
  9619                 }
       
  9620     
       
  9621             if ( !found && iDirtyList.Find( nodeToDirtyList ) == KErrNotFound )
       
  9622                 {
       
  9623                 // Add node to dirty list as parent is neither found
       
  9624                 dirtyList.AppendL( nodeToDirtyList );
       
  9625                 nodeToDirtyList->ClearRenderedAndLaidOut();
       
  9626                 
       
  9627                 // Add to draw list for redraw
       
  9628                 AddToRedrawListL( nodeToRedrawList );
       
  9629                 }
       
  9630     
       
  9631             // finally update the dirty list
       
  9632             iDirtyList.Reset();
       
  9633             iDirtyList = dirtyList;
       
  9634     
       
  9635             CleanupStack::Pop( &dirtyList );
       
  9636             }
       
  9637         }
  9746     }
  9638     }
  9747 
  9639 
  9748 // -----------------------------------------------------------------------------
  9640 // -----------------------------------------------------------------------------
  9749 // CXnUiEngineImpl::SetClientRectL
  9641 // CXnUiEngineImpl::SetClientRectL
  9750 // -----------------------------------------------------------------------------
  9642 // -----------------------------------------------------------------------------
  9757         
  9649         
  9758         UpdateInternalUnits( iHorizontalUnitInPixels, iVerticalUnitInPixels,
  9650         UpdateInternalUnits( iHorizontalUnitInPixels, iVerticalUnitInPixels,
  9759             iClientRect );
  9651             iClientRect );
  9760         
  9652         
  9761         iEditMode->SetClientRect( aRect );
  9653         iEditMode->SetClientRect( aRect );
  9762 		
  9654 
  9763         CXnViewSwitcher* viewSwitcher( iAppUiAdapter.ViewSwitcher() );
       
  9764         if( viewSwitcher )
       
  9765             {
       
  9766             viewSwitcher->SizeChanged( aRect );
       
  9767             }
       
  9768     
       
  9769         if ( aDrawNow )
  9655         if ( aDrawNow )
  9770             {
  9656             {
  9771             RootNode()->SetDirtyL();
  9657             RootNode()->SetDirtyL();
  9772             iUiEngine->RenderUIL();
  9658             iUiEngine->RenderUIL();
  9773             }
  9659             }
  9803 
  9689 
  9804 // -----------------------------------------------------------------------------
  9690 // -----------------------------------------------------------------------------
  9805 // CXnUiEngineImpl::StartLayoutFromL
  9691 // CXnUiEngineImpl::StartLayoutFromL
  9806 // -----------------------------------------------------------------------------
  9692 // -----------------------------------------------------------------------------
  9807 //
  9693 //
  9808 CXnNode* CXnUiEngineImpl::StartLayoutFromL( TXnDirtyRegion& aDirtyRegion )
  9694 CXnNode* CXnUiEngineImpl::StartLayoutFromL()
  9809     {
  9695     {
  9810     CXnNode* viewNode( aDirtyRegion.iRootNode );
  9696     if ( iLayoutControl & XnLayoutControl::EViewDirty )
  9811     if( !viewNode )
  9697         {
  9812         {
  9698         return iCurrentView;
  9813         return NULL;    
       
  9814         }
       
  9815     
       
  9816     if ( aDirtyRegion.iLayoutControl & XnLayoutControl::EViewDirty )
       
  9817         {
       
  9818         return viewNode;
       
  9819         }
  9699         }
  9820 
  9700 
  9821     RPointerArray< CXnNode >parentArray;
  9701     RPointerArray< CXnNode >parentArray;
  9822     CleanupClosePushL( parentArray );
  9702     CleanupClosePushL( parentArray );
  9823     TInt dirtyCount = aDirtyRegion.iDirtyList.Count();
  9703     TInt dirtyCount = iDirtyList.Count();
  9824     CXnNode* startNode( NULL );
  9704     CXnNode* startNode( NULL );
  9825 
  9705 
  9826     for ( TInt dirtyIndex = 0; dirtyIndex < dirtyCount; dirtyIndex++ )
  9706     for ( TInt dirtyIndex = 0; dirtyIndex < dirtyCount; dirtyIndex++ )
  9827         {
  9707         {
  9828         startNode = aDirtyRegion.iDirtyList[dirtyIndex];
  9708         startNode = iDirtyList[dirtyIndex];
  9829 
  9709 
  9830         for ( ;startNode && startNode != viewNode; )
  9710         for ( ;startNode && startNode != iCurrentView; )
  9831             {
  9711             {
  9832             parentArray.Append( startNode->Parent() );
  9712             parentArray.Append( startNode->Parent() );
  9833             startNode = startNode->Parent();
  9713             startNode = startNode->Parent();
  9834             }
  9714             }
  9835         }
  9715         }
  9856             }
  9736             }
  9857         }
  9737         }
  9858 
  9738 
  9859     CleanupStack::PopAndDestroy( &parentArray );
  9739     CleanupStack::PopAndDestroy( &parentArray );
  9860 
  9740 
  9861     return viewNode;
  9741     return iCurrentView;
  9862     }
  9742     }
  9863 
  9743 
  9864 // -----------------------------------------------------------------------------
  9744 // -----------------------------------------------------------------------------
  9865 // CXnUiEngineImpl::Plugins
  9745 // CXnUiEngineImpl::Plugins
  9866 // -----------------------------------------------------------------------------
  9746 // -----------------------------------------------------------------------------
  9874 // CXnUiEngineImpl::ForceRenderUIL
  9754 // CXnUiEngineImpl::ForceRenderUIL
  9875 // -----------------------------------------------------------------------------
  9755 // -----------------------------------------------------------------------------
  9876 //
  9756 //
  9877 void CXnUiEngineImpl::ForceRenderUIL( TBool aLayoutOnly )
  9757 void CXnUiEngineImpl::ForceRenderUIL( TBool aLayoutOnly )
  9878     {
  9758     {
  9879     TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *iCurrentView );
  9759     iLayoutControl |= XnLayoutControl::EIgnoreState;
  9880     if( !dirtyRegion )
       
  9881         {
       
  9882         return;
       
  9883         }
       
  9884     
       
  9885     dirtyRegion->iLayoutControl |= XnLayoutControl::EIgnoreState;
       
  9886     
       
  9887     if ( aLayoutOnly )
  9760     if ( aLayoutOnly )
  9888         {
  9761         {
  9889         LayoutUIL();
  9762         LayoutUIL();
  9890         }
  9763         }
  9891     else
  9764     else
  9892         {
  9765         {
  9893         LayoutUIL();
  9766         LayoutUIL();
  9894         RenderUIL();
  9767         RenderUIL();
  9895         }
  9768         }
  9896     
  9769     iLayoutControl &= ~XnLayoutControl::EIgnoreState;
  9897     dirtyRegion->iLayoutControl &= ~XnLayoutControl::EIgnoreState;
       
  9898     }
  9770     }
  9899 
  9771 
  9900 // -----------------------------------------------------------------------------
  9772 // -----------------------------------------------------------------------------
  9901 // CXnUiEngineImpl::GetThemeResource
  9773 // CXnUiEngineImpl::GetThemeResource
  9902 // -----------------------------------------------------------------------------
  9774 // -----------------------------------------------------------------------------
 10040         {
  9912         {
 10041         self->iDisableCount--;
  9913         self->iDisableCount--;
 10042         
  9914         
 10043         if ( self->iDisableCount == 0 )
  9915         if ( self->iDisableCount == 0 )
 10044             {
  9916             {
 10045             TRAP_IGNORE( self->EnableRenderUiL() );            
  9917             TRAP_IGNORE(                    
 10046             }
       
 10047         }
       
 10048     }
       
 10049 
       
 10050 // -----------------------------------------------------------------------------
       
 10051 // -----------------------------------------------------------------------------
       
 10052 //               
       
 10053 void CXnUiEngineImpl::EnableRenderUiL()
       
 10054     {
       
 10055     CXnViewData* viewData = iViewManager.ActiveAppData().ViewData( *iCurrentView );
       
 10056     if( viewData )
       
 10057         {
       
 10058         RPointerArray<TXnDirtyRegion> arr;
       
 10059         CleanupClosePushL( arr );
       
 10060         
       
 10061         viewData->GetDirtyRegions( arr );
       
 10062 
       
 10063         for( TInt i = 0; i < arr.Count(); i++ )
       
 10064             {
       
 10065             TXnDirtyRegion* dirtyRegion = arr[i];
       
 10066 
       
 10067             // Is menu refresh pending?
  9918             // Is menu refresh pending?
 10068             if ( ( dirtyRegion->iLayoutControl & XnLayoutControl::ERefreshMenu ) &&
  9919             if ( ( self->iLayoutControl & XnLayoutControl::ERefreshMenu ) &&
 10069                    IsMenuDisplaying() )
  9920                    !self->IsMenuDisplaying() )
 10070                 {
  9921                 {
 10071                 // RefreshMenuL will reset the state flag
  9922                 // RefreshMenuL will reset the state flag
 10072                 RefreshMenuL( dirtyRegion );
  9923                 self->RefreshMenuL();
 10073                 }
  9924                 }
 10074             
  9925 
 10075             // Is layout pending?
  9926             // Is layout pending?
 10076             if ( dirtyRegion->iLayoutControl & XnLayoutControl::ELayoutUI )
  9927             if ( self->iLayoutControl & XnLayoutControl::ELayoutUI )
 10077                 {
  9928                 {
 10078                 LayoutL( *dirtyRegion );
  9929                 self->LayoutUIL();
 10079                 }
  9930                 }
 10080         
  9931 
 10081             // Is render pending?
  9932             // Is render pending?
 10082             if ( dirtyRegion->iLayoutControl & XnLayoutControl::ERenderUI )
  9933             if ( self->iLayoutControl & XnLayoutControl::ERenderUI )
 10083                 {
  9934                 {
 10084                 RenderL( *dirtyRegion );
  9935                 self->RenderUIL();
 10085                 }
  9936                 }
 10086             }
  9937                 );
 10087         CleanupStack::PopAndDestroy( &arr);
  9938             }
 10088         }
  9939         }
 10089     }
  9940     }
 10090                 
  9941 
       
  9942 
 10091 // -----------------------------------------------------------------------------
  9943 // -----------------------------------------------------------------------------
 10092 // -----------------------------------------------------------------------------
  9944 // -----------------------------------------------------------------------------
 10093 //
  9945 //
 10094 void CXnUiEngineImpl::ReportScreenDeviceChangeL()
  9946 void CXnUiEngineImpl::ReportScreenDeviceChangeL()
 10095     {    
  9947     {
 10096     // Notify current orientation to all views    
  9948     CXnNode* trigger( BuildScreenDeviceChangeTriggerNodeLC( *iUiEngine ) );
 10097     RPointerArray< CXnPluginData >& plugins( 
  9949     
 10098         iViewManager.ActiveAppData().PluginData() );
  9950     // Notify current orientation to iCurrentView
 10099 
  9951     iCurrentView->ReportXuikonEventL( *trigger );
 10100     for( TInt i = 0; i < plugins.Count(); i++ )
  9952 
 10101         {        
  9953     // Notify also plugins
 10102         ReportScreenDeviceChangedL( *plugins[i] );
  9954     RPointerArray<CXnNode> plugins = *Plugins();
 10103         CXnDomNode* domNode( plugins[i]->Node() );
  9955     for( TInt i=0; i<plugins.Count(); i++ )
 10104         if( domNode )
  9956         {
 10105             {
  9957         CXnNode* pluginNode = plugins[i];
 10106             CXnNode* node( domNode->LayoutNode() );
  9958         RPointerArray<CXnNode> pluginChildren = pluginNode->Children();
 10107             if( node )
  9959         for( TInt ii=0; ii<pluginChildren.Count(); ii++ )
 10108                 {
  9960             {
 10109                 node->SetDirtyL();
  9961             CXnDomNode* widgetNode = pluginChildren[ii]->DomNode();
 10110                 }
  9962             if( widgetNode && widgetNode->Name() == KWidgetNodeName )
 10111             }
  9963                 {
 10112         }
  9964                 pluginChildren[ii]->ReportXuikonEventL( *trigger );
       
  9965                 }                    
       
  9966             }
       
  9967         }
       
  9968     
       
  9969     CleanupStack::PopAndDestroy(); // trigger    
 10113     }
  9970     }
 10114 
  9971 
 10115 // -----------------------------------------------------------------------------
  9972 // -----------------------------------------------------------------------------
 10116 // CXnUiEngineImpl::HandlePartialTouchInputL()
  9973 // CXnUiEngineImpl::HandlePartialTouchInputL()
 10117 // -----------------------------------------------------------------------------
  9974 // -----------------------------------------------------------------------------
 10118 void CXnUiEngineImpl::HandlePartialTouchInputL( CXnNode* aNode, TBool aEnable )
  9975 void CXnUiEngineImpl::HandlePartialTouchInputL( CXnNode& aNode, TBool aEnable )
 10119     {    
  9976     {
 10120     CXnViewData& view( iViewManager.ActiveViewData() );
  9977     CXnNode* editorplugin = FindPlugin( aNode );
 10121 
  9978     if ( !editorplugin )
 10122     CXnNode* editor( aEnable ? aNode : iSplitScreenState.iPartialScreenEditorNode ); 
  9979         {
 10123 		      
  9980         User::Leave( KErrNotFound );
 10124     CXnPluginData* plugin( view.Plugin( editor ) );
  9981         }
 10125             
       
 10126     if ( !plugin || !editor )
       
 10127         {
       
 10128         return;
       
 10129         }
       
 10130 		
       
 10131     CXnNode* editorplugin( plugin->Owner()->LayoutNode() );    
       
 10132     
  9982     
 10133     DisableRenderUiLC();
  9983     DisableRenderUiLC();
 10134 
  9984 
 10135     if ( aEnable )    
  9985     if ( aEnable )    
 10136         {        
  9986         {        
 10137         iSplitScreenState.iPartialScreenOpen = ETrue;           
  9987         iSplitScreenState.iPartialScreenOpen = ETrue;           
 10138         iSplitScreenState.iPartialScreenEditorNode = editor;           
  9988         iSplitScreenState.iPartialScreenEditorNode = &aNode;           
 10139 
  9989 
 10140         // make sure that we always get up event
  9990         // make sure that we always get up event
 10141         CXnViewControlAdapter* control = 
  9991         CXnViewControlAdapter* control = static_cast< CXnViewControlAdapter* >(  
 10142             static_cast< CXnViewControlAdapter* >( view.ViewNode()->Control() );  
  9992             iViewManager.ActiveViewData().ViewNode()->Control() );            
 10143                                            
  9993                    
 10144         control->ResetGrabbing();  
  9994         control->ResetGrabbing();  
 10145          
  9995          
 10146         // Block progression must be bottom-to-top when partial screen is open
  9996         // Block progression must be bottom-to-top when partial screen is open
 10147         // Previous value needs to be stored first
  9997         // Previous value needs to be stored first
 10148         CXnProperty* prop( 
  9998         CXnProperty* prop( 
 10205         }
 10055         }
 10206     
 10056     
 10207     RootNode()->SetDirtyL();
 10057     RootNode()->SetDirtyL();
 10208     ForceRenderUIL();
 10058     ForceRenderUIL();
 10209     CleanupStack::PopAndDestroy();
 10059     CleanupStack::PopAndDestroy();
 10210     
 10060     }
 10211     if ( aEnable )
 10061 
 10212         {    
 10062 // -----------------------------------------------------------------------------
 10213         editor->PluginIfL().ReportTriggerEventL( 
 10063 // -----------------------------------------------------------------------------
 10214             KSplitScreenEnabledTrigger, KNullDesC8, KNullDesC8 );             
 10064 CCoeControl* CXnUiEngineImpl::WindowOwningControl( CXnNode& aNode )
 10215         }
       
 10216     else
       
 10217         {
       
 10218         editor->PluginIfL().ReportTriggerEventL( 
       
 10219             KSplitScreenDisabledTrigger, KNullDesC8, KNullDesC8 );                                  
       
 10220         }
       
 10221     }
       
 10222 
       
 10223 // -----------------------------------------------------------------------------
       
 10224 // -----------------------------------------------------------------------------
       
 10225 CXnNode* CXnUiEngineImpl::WindowOwningNode( CXnNode& aNode )
       
 10226     {
 10065     {
 10227     CXnNode* parent = &aNode;
 10066     CXnNode* parent = &aNode;
 10228     while( parent )
 10067     while( parent )
 10229         {
 10068         {
 10230         CXnControlAdapter* adapter = parent->Control();
 10069         CXnControlAdapter* adapter = parent->Control();
 10231         if( adapter )
 10070         if( adapter )
 10232             {
 10071             {
 10233             if( parent->ViewNodeImpl() && 
 10072             if( parent->ViewNodeImpl() && 
 10234                 adapter == iCurrentViewControlAdapter )
 10073                 adapter == iCurrentViewControlAdapter )
 10235                 {
 10074                 {
 10236                 return parent;
 10075                 return adapter;
 10237                 }
 10076                 }
 10238             else if( adapter->OwnsWindow() )
 10077             else if( adapter->OwnsWindow() )
 10239                 {
 10078                 {
 10240                 if( !IsNodeTooltip( *parent ) )
 10079                 if( !IsNodeTooltip( *parent ) )
 10241                     {
 10080                     {
 10242                     return parent;
 10081                     return adapter;
 10243                     }
 10082                     }
 10244                 else
 10083                 else
 10245                     {
 10084                     {
 10246                     return NULL;
 10085                     return NULL;
 10247                     }                
 10086                     }                
 10254 
 10093 
 10255 // -----------------------------------------------------------------------------
 10094 // -----------------------------------------------------------------------------
 10256 // -----------------------------------------------------------------------------
 10095 // -----------------------------------------------------------------------------
 10257 TXnDirtyRegion* CXnUiEngineImpl::FindDirtyRegionL( CXnNode& aNode )
 10096 TXnDirtyRegion* CXnUiEngineImpl::FindDirtyRegionL( CXnNode& aNode )
 10258     {
 10097     {
 10259     CXnNode* node( WindowOwningNode( aNode ) );
 10098     CCoeControl* control = WindowOwningControl( aNode );
 10260     if( !node )
 10099     if( !control )
 10261         {
 10100         {
 10262         return NULL;
 10101         return NULL;
 10263         }
 10102         }
       
 10103     for( TInt i=0; i<iRedrawRegions.Count(); i++ )
       
 10104         {
       
 10105         if( iRedrawRegions[i]->iControl == control )
       
 10106             {
       
 10107             return iRedrawRegions[i];
       
 10108             }
       
 10109         }
       
 10110     TXnDirtyRegion* region = new (ELeave) TXnDirtyRegion;
       
 10111     CleanupStack::PushL( region );
       
 10112     region->iControl = control;
       
 10113     iRedrawRegions.AppendL( region );
       
 10114     CleanupStack::Pop();
       
 10115     return region;
       
 10116     }
       
 10117 
       
 10118 // -----------------------------------------------------------------------------
       
 10119 // -----------------------------------------------------------------------------
       
 10120 void CXnUiEngineImpl::AddRedrawRectL( TRect aRect, CXnNode& aNode )
       
 10121     {
       
 10122     TXnDirtyRegion* dirtyReg = FindDirtyRegionL( aNode );
       
 10123     if( dirtyReg )
       
 10124         {
       
 10125         dirtyReg->iRegion.AddRect( aRect );        
       
 10126         dirtyReg->iRegion.Tidy();
       
 10127         }
       
 10128     }
       
 10129 
       
 10130 // -----------------------------------------------------------------------------
       
 10131 // SetEventDispatcher
       
 10132 // -----------------------------------------------------------------------------
       
 10133 void CXnUiEngineImpl::SetEventDispatcher( CXnKeyEventDispatcher* aDispatcher )
       
 10134     {
       
 10135     iKeyEventDispatcher = aDispatcher;
       
 10136     }
       
 10137 
       
 10138 // -----------------------------------------------------------------------------
       
 10139 // NotifyStatusPaneSizeChanged
       
 10140 // -----------------------------------------------------------------------------
       
 10141 void CXnUiEngineImpl::NotifyStatusPaneSizeChanged()
       
 10142     {
       
 10143     TRAP_IGNORE( iUiEngine->SetClientRectL( iAppUiAdapter.ClientRect(), EFalse ) );
       
 10144     }
 10264     
 10145     
 10265     CCoeControl* control( node->Control() );  
       
 10266     if( !control )
       
 10267         {
       
 10268         return NULL;
       
 10269         }
       
 10270 
       
 10271     TXnDirtyRegion* region( NULL );
       
 10272     CXnViewData* viewData = iViewManager.ActiveAppData().ViewData( *node );
       
 10273     if( viewData )
       
 10274         {
       
 10275         region = viewData->DirtyRegionL( *node );
       
 10276         }
       
 10277     
       
 10278     return region;
       
 10279     }
       
 10280 
       
 10281 // -----------------------------------------------------------------------------
       
 10282 // SetEventDispatcher
       
 10283 // -----------------------------------------------------------------------------
       
 10284 void CXnUiEngineImpl::SetEventDispatcher( CXnKeyEventDispatcher* aDispatcher )
       
 10285     {
       
 10286     iKeyEventDispatcher = aDispatcher;
       
 10287     }
       
 10288 
       
 10289 // -----------------------------------------------------------------------------
       
 10290 // NotifyStatusPaneSizeChanged
       
 10291 // -----------------------------------------------------------------------------
       
 10292 void CXnUiEngineImpl::NotifyStatusPaneSizeChanged()
       
 10293     {
       
 10294     TRAP_IGNORE( iUiEngine->SetClientRectL( iAppUiAdapter.ClientRect(), EFalse ) );
       
 10295     }
       
 10296     
       
 10297 // -----------------------------------------------------------------------------
 10146 // -----------------------------------------------------------------------------
 10298 // NotifyResourceChanged
 10147 // NotifyResourceChanged
 10299 // -----------------------------------------------------------------------------
 10148 // -----------------------------------------------------------------------------
 10300 void CXnUiEngineImpl::NotifyResourceChanged( TInt aType )
 10149 void CXnUiEngineImpl::NotifyResourceChanged( TInt aType )
 10301     {
 10150     {
 10303     }
 10152     }
 10304 
 10153 
 10305 // -----------------------------------------------------------------------------
 10154 // -----------------------------------------------------------------------------
 10306 // EnablePartialTouchInput 
 10155 // EnablePartialTouchInput 
 10307 // -----------------------------------------------------------------------------
 10156 // -----------------------------------------------------------------------------
 10308 void CXnUiEngineImpl::EnablePartialTouchInput( CXnNode* aNode, TBool aEnable )
 10157 void CXnUiEngineImpl::EnablePartialTouchInput( CXnNode& aNode, TBool aEnable )
 10309     {
 10158     {
 10310     if( aEnable && !iSplitScreenState.iPartialScreenOpen ||
 10159     if( aEnable && !iSplitScreenState.iPartialScreenOpen ||
 10311         !aEnable && iSplitScreenState.iPartialScreenOpen )
 10160         !aEnable && iSplitScreenState.iPartialScreenOpen )
 10312         {
 10161         {
 10313         TRAP_IGNORE( HandlePartialTouchInputL( aNode, aEnable ) );
 10162         TRAP_IGNORE( HandlePartialTouchInputL( aNode, aEnable ) );
 10379 // CXnUiEngineImpl::IsTextEditorActive()
 10228 // CXnUiEngineImpl::IsTextEditorActive()
 10380 // -----------------------------------------------------------------------------
 10229 // -----------------------------------------------------------------------------
 10381 //               
 10230 //               
 10382 TBool CXnUiEngineImpl::IsTextEditorActive()
 10231 TBool CXnUiEngineImpl::IsTextEditorActive()
 10383     {
 10232     {
 10384     if( iKeyEventDispatcher )         
 10233     if( iSplitScreenState.iPartialScreenOpen )
 10385         {
 10234         {
 10386         return iKeyEventDispatcher->IsTextEditorActive();         
 10235         return ETrue;
 10387         }
 10236         }
 10388     
 10237     CXnNode* focusedNode = FocusedNode();
       
 10238     if( focusedNode )
       
 10239         {
       
 10240         if( focusedNode->Type()->Type() == KEditorNodeName )
       
 10241             {
       
 10242             return ETrue;
       
 10243             }
       
 10244         }
 10389     return EFalse;
 10245     return EFalse;
 10390     }
 10246     }
 10391 
 10247 
 10392 // End of file
 10248 // End of file