taskswitcher/taskswitcherui/taskswitcherapp/src/tsfastswaparea.cpp
branchRCL_3
changeset 19 79311d856354
parent 18 d05a55b217df
child 23 7be2816dbabd
equal deleted inserted replaced
18:d05a55b217df 19:79311d856354
   101 //
   101 //
   102 CTsFastSwapArea::CTsFastSwapArea(CCoeControl& aParent,
   102 CTsFastSwapArea::CTsFastSwapArea(CCoeControl& aParent,
   103     CTsDeviceState& aDeviceState,
   103     CTsDeviceState& aDeviceState,
   104     CTsEventControler& aEventHandler) :
   104     CTsEventControler& aEventHandler) :
   105     iParent(aParent), iDeviceState(aDeviceState), iEvtHandler(aEventHandler),
   105     iParent(aParent), iDeviceState(aDeviceState), iEvtHandler(aEventHandler),
   106     iIgnoreLayoutSwitch(EFalse)
   106     iIgnoreLayoutSwitch(EFalse), iWidgetClosingCount(0)
   107     {
   107     {
   108     // no implementation required
   108     // no implementation required
   109     }
   109     }
   110 
   110 
   111 // -----------------------------------------------------------------------------
   111 // -----------------------------------------------------------------------------
   235     TAknLayoutRect gridItem = rects[1];
   235     TAknLayoutRect gridItem = rects[1];
   236     TAknLayoutRect gridImage = rects[2];
   236     TAknLayoutRect gridImage = rects[2];
   237     TAknLayoutRect gridNextItem = rects[3];
   237     TAknLayoutRect gridNextItem = rects[3];
   238     CleanupStack::PopAndDestroy(&rects);
   238     CleanupStack::PopAndDestroy(&rects);
   239     
   239     
   240     TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
       
   241     iGrid->SetRect(gridAppPane.Rect());
   240     iGrid->SetRect(gridAppPane.Rect());
       
   241     
       
   242     TInt variety;
       
   243     TBool disable = GetVariety(variety);
       
   244     if ( disable )
       
   245         {
       
   246         TRAP_IGNORE(static_cast<CTsAppUi*>(iEikonEnv->AppUi())->RequestPopUpL());
       
   247         }
   242     TAknLayoutScalableParameterLimits gridParams = 
   248     TAknLayoutScalableParameterLimits gridParams = 
   243         AknLayoutScalable_Apps::cell_tport_appsw_pane_ParamLimits( variety );
   249         AknLayoutScalable_Apps::cell_tport_appsw_pane_ParamLimits( variety );
   244     TPoint empty( ELayoutEmpty, ELayoutEmpty );
   250     TPoint empty( ELayoutEmpty, ELayoutEmpty );
   245     
   251     
   246     // Setup bitmap layout
   252     // Setup bitmap layout
   291     // Update item drawer
   297     // Update item drawer
   292     iGrid->UpdateItemDrawerLayoutDataL();
   298     iGrid->UpdateItemDrawerLayoutDataL();
   293     
   299     
   294     // Update state
   300     // Update state
   295     HandleDeviceStateChanged( EDeviceType );
   301     HandleDeviceStateChanged( EDeviceType );
       
   302     
       
   303     if ( disable )
       
   304         {
       
   305         TRAP_IGNORE(static_cast<CTsAppUi*>(iEikonEnv->AppUi())->DisablePopUpL());
       
   306         }
   296     }
   307     }
   297 
   308 
   298 
   309 
   299 // --------------------------------------------------------------------------
   310 // --------------------------------------------------------------------------
   300 // CTsFastSwapArea::GetFastSwapAreaRects
   311 // CTsFastSwapArea::GetFastSwapAreaRects
   305     TAknLayoutRect gridAppPane;
   316     TAknLayoutRect gridAppPane;
   306     TAknLayoutRect gridItem;
   317     TAknLayoutRect gridItem;
   307     TAknLayoutRect gridImage;
   318     TAknLayoutRect gridImage;
   308     TAknLayoutRect gridNextItem;
   319     TAknLayoutRect gridNextItem;
   309     
   320     
   310     TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
   321     TInt variety;
       
   322     TBool disable = GetVariety(variety);
       
   323     if ( disable )
       
   324         {
       
   325         TRAP_IGNORE(static_cast<CTsAppUi*>(iEikonEnv->AppUi())->RequestPopUpL());
       
   326         }
   311     
   327     
   312     gridAppPane.LayoutRect( Rect(), 
   328     gridAppPane.LayoutRect( Rect(), 
   313             AknLayoutScalable_Apps::tport_appsw_pane( variety ) );
   329             AknLayoutScalable_Apps::tport_appsw_pane( variety ) );
   314     aRects.Append(gridAppPane);
   330     aRects.Append(gridAppPane);
   315     
   331     
   321             AknLayoutScalable_Apps::cell_tport_appsw_pane_g1( variety ) ); 
   337             AknLayoutScalable_Apps::cell_tport_appsw_pane_g1( variety ) ); 
   322     aRects.Append(gridImage);
   338     aRects.Append(gridImage);
   323     gridNextItem.LayoutRect( gridAppPane.Rect(),
   339     gridNextItem.LayoutRect( gridAppPane.Rect(),
   324             AknLayoutScalable_Apps::cell_tport_appsw_pane_cp03( variety ) );
   340             AknLayoutScalable_Apps::cell_tport_appsw_pane_cp03( variety ) );
   325     aRects.Append(gridNextItem);
   341     aRects.Append(gridNextItem);
       
   342     
       
   343     if ( disable )
       
   344         {
       
   345         TRAP_IGNORE(static_cast<CTsAppUi*>(iEikonEnv->AppUi())->DisablePopUpL());
       
   346         }
   326     }
   347     }
   327 
   348 
   328 
   349 
   329 // --------------------------------------------------------------------------
   350 // --------------------------------------------------------------------------
   330 // CTsFastSwapArea::Setup
   351 // CTsFastSwapArea::Setup
   435             selIdx--;
   456             selIdx--;
   436             }
   457             }
   437         TInt wgId = iArray[aIndex]->WgId();
   458         TInt wgId = iArray[aIndex]->WgId();
   438         iFSClient->CloseApp( wgId );
   459         iFSClient->CloseApp( wgId );
   439         iIsClosing.Append(wgId);
   460         iIsClosing.Append(wgId);
       
   461         if ( iArray[aIndex]->Widget() )
       
   462             {
       
   463             iWidgetClosingCount++;
       
   464             }
   440         // The fsw content will change sooner or later
   465         // The fsw content will change sooner or later
   441         // but the updated content (without the closed app) will not
   466         // but the updated content (without the closed app) will not
   442         // come very fast. It looks better to the user if the item
   467         // come very fast. It looks better to the user if the item
   443         // in the grid is removed right here, right now.
   468         // in the grid is removed right here, right now.
   444         // If the app does not close for some reason then this is
   469         // If the app does not close for some reason then this is
   572         CTsFswEntry* e = iArray[i];
   597         CTsFswEntry* e = iArray[i];
   573         const TDesC& name( e->AppName() );
   598         const TDesC& name( e->AppName() );
   574         TSLOG4( TSLOG_INFO, "[%d]: %d %d %S", i, e->WgId(), e->AppUid(), &name );
   599         TSLOG4( TSLOG_INFO, "[%d]: %d %d %S", i, e->WgId(), e->AppUid(), &name );
   575         }
   600         }
   576 #endif
   601 #endif
       
   602     
       
   603     // Update closing widget count if necessary
       
   604     if ( iWidgetClosingCount )
       
   605         {
       
   606         TInt widgetCount(0);
       
   607         for ( TInt i = 0, ie = iArray.Count(); i != ie; ++i )
       
   608             {
       
   609             if ( iArray[i]->Widget() )
       
   610                 {
       
   611                 widgetCount++;
       
   612                 }
       
   613             }
       
   614         iWidgetClosingCount = widgetCount;
       
   615         }
   577 
   616 
   578     // draw
   617     // draw
   579     RenderContentL();
   618     RenderContentL();
   580 
   619 
   581     // notify observer, if present
   620     // notify observer, if present
   602     RArray<TInt> closeItemArray;
   641     RArray<TInt> closeItemArray;
   603     CleanupClosePushL(closeItemArray);
   642     CleanupClosePushL(closeItemArray);
   604     RArray<TInt> strokeItemArray;
   643     RArray<TInt> strokeItemArray;
   605     CleanupClosePushL(strokeItemArray);
   644     CleanupClosePushL(strokeItemArray);
   606     
   645     
   607     TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
       
   608     RArray<TAknLayoutRect> rects;
   646     RArray<TAknLayoutRect> rects;
   609     CleanupClosePushL(rects);
   647     CleanupClosePushL(rects);
   610     rects.ReserveL(KLayoutItemCount);
   648     rects.ReserveL(KLayoutItemCount);
   611     GetFastSwapAreaRects(rects);
   649     GetFastSwapAreaRects(rects);
   612     TAknLayoutRect gridItem = rects[1];
   650     TAknLayoutRect gridItem = rects[1];
   787     {
   825     {
   788     TSLOG_CONTEXT( CTsFastSwapArea::HandleSwitchToForegroundEvent, TSLOG_LOCAL );
   826     TSLOG_CONTEXT( CTsFastSwapArea::HandleSwitchToForegroundEvent, TSLOG_LOCAL );
   789     TSLOG_IN();
   827     TSLOG_IN();
   790     
   828     
   791     iIsClosing.Reset();
   829     iIsClosing.Reset();
       
   830     iWidgetClosingCount = 0;
   792     
   831     
   793     CTsGridItemDrawer* itemDrawer =
   832     CTsGridItemDrawer* itemDrawer =
   794         static_cast<CTsGridItemDrawer*>( iGrid->ItemDrawer() );
   833         static_cast<CTsGridItemDrawer*>( iGrid->ItemDrawer() );
   795     itemDrawer->SetRedrawBackground(ETrue);
   834     itemDrawer->SetRedrawBackground(ETrue);
   796     
   835     
  1710     return availableRect.iPixelSize.iWidth > availableRect.iPixelSize.iHeight;
  1749     return availableRect.iPixelSize.iWidth > availableRect.iPixelSize.iHeight;
  1711     }
  1750     }
  1712 
  1751 
  1713 
  1752 
  1714 // -----------------------------------------------------------------------------
  1753 // -----------------------------------------------------------------------------
       
  1754 // CTsFastSwapArea::GetVariety
       
  1755 // -----------------------------------------------------------------------------
       
  1756 //
       
  1757 TBool CTsFastSwapArea::GetVariety( TInt& aVariety )
       
  1758     {
       
  1759     aVariety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
       
  1760     TInt screenOrientation = GetCurrentScreenOrientation();
       
  1761     if ( aVariety != screenOrientation )
       
  1762         {
       
  1763         aVariety = screenOrientation;
       
  1764         return ETrue;
       
  1765         }
       
  1766     return EFalse;
       
  1767     }
       
  1768 
       
  1769 // -----------------------------------------------------------------------------
  1715 // CTsFastSwapArea::IsAppClosing
  1770 // CTsFastSwapArea::IsAppClosing
  1716 // -----------------------------------------------------------------------------
  1771 // -----------------------------------------------------------------------------
  1717 //
  1772 //
  1718 TBool CTsFastSwapArea::IsAppClosing( TInt aWgId )
  1773 TBool CTsFastSwapArea::IsAppClosing( TInt aWgId )
  1719     {
  1774     {
  1724         retVal = idx != KErrNotFound;
  1779         retVal = idx != KErrNotFound;
  1725         if ( retVal )
  1780         if ( retVal )
  1726             {
  1781             {
  1727             iIsClosing.Remove(idx);
  1782             iIsClosing.Remove(idx);
  1728             }
  1783             }
       
  1784         else if ( iWidgetClosingCount )
       
  1785             {
       
  1786             retVal = ETrue;
       
  1787             iWidgetClosingCount--;
       
  1788             }
       
  1789         }
       
  1790     else
       
  1791         {
       
  1792         // Check current item list
       
  1793         for ( TInt i = 0; i < iArray.Count(); i++ )
       
  1794             {
       
  1795             TInt wgId = iArray[i]->WgId();
       
  1796             if ( wgId == aWgId )
       
  1797                 {
       
  1798                 retVal = ETrue;
       
  1799                 }
       
  1800             }
  1729         }
  1801         }
  1730     return retVal;
  1802     return retVal;
  1731     }
  1803     }
  1732 
  1804 
  1733 // End of file
  1805 // End of file