uifw/EikStd/coctlsrc/AknClearer.cpp
branchRCL_3
changeset 29 a8834a2e9a96
parent 25 941195f2d488
child 43 07b3ec0df257
child 55 aecbbf00d063
equal deleted inserted replaced
25:941195f2d488 29:a8834a2e9a96
    18 
    18 
    19 #include <eikappui.h>
    19 #include <eikappui.h>
    20 #include <eikspane.h>
    20 #include <eikspane.h>
    21 #include "aknclearer.h"
    21 #include "aknclearer.h"
    22 #include <aknconsts.h>
    22 #include <aknconsts.h>
    23 #include <aknnavi.h>
       
    24 #include <avkon.mbg>
    23 #include <avkon.mbg>
    25 #include <AknLayout.lag>
    24 #include <AknLayout.lag>
    26 #include <AknSgcc.h>
    25 #include <AknSgcc.h>
    27 #include <AknUtils.h>
    26 #include <AknUtils.h>
    28 #include <AknsUtils.h>
    27 #include <AknsUtils.h>
    49 #include <akntransitionutils.h>
    48 #include <akntransitionutils.h>
    50 #endif
    49 #endif
    51 
    50 
    52 enum TAknScreenClearerBaseFlags
    51 enum TAknScreenClearerBaseFlags
    53 	{
    52 	{
    54 	EAknScreenClearerDrawNavi,
    53 	EAknScreenClearerBlankAppStatusPane
    55 	EAknScreenClearerBlankAppStatusPane,
       
    56 	EAknScreenClearerDrawNaviSolid,
       
    57 	};
    54 	};
    58 
    55 
    59 enum 
    56 enum 
    60     {
    57     {
    61     ELayerCbaBackground=0,
    58     ELayerBackground = 0,
    62     ELayerBackground = 1,
    59     ELayerExtension = 1,
    63     ELayerExtension = 2,
    60     ELayerStripe = 2,
    64     ELayerStripe = 3,
    61     ELayerWallpaper = 3,
    65     ELayerWallpaper = 4,
    62     ELayerN = 4
    66     ELayerN = 5
       
    67     };
    63     };
    68 
       
    69     enum 
       
    70         {
       
    71         ELayerStaconCbaBackground=0,
       
    72         ELayerStaconTop = 1,
       
    73         ELayerStaconBottom = 2,
       
    74         ELayerStaconMain = 3,
       
    75         ELayerStaconWallpaper = 4,
       
    76         ELayerStaconN = 5
       
    77         };
       
    78 
    64 
    79 enum 
    65 enum 
    80     {
    66     {
    81     ELayerFlatCbaBackground=0,
    67     ELayerStaconTop = 0,
    82     ELayerFlatBackground = 1,
    68     ELayerStaconBottom = 1,
    83     ELayerFlatTl = 2,
    69     ELayerStaconMain = 2,
    84     ELayerFlatTr = 3,
    70     ELayerStaconWallpaper = 3,
    85     ELayerFlatBl = 4,
    71     ELayerStaconN = 4
    86     ELayerFlatBr = 5,
    72     };
    87     ELayerFlatT = 6,
    73 
    88     ELayerFlatB = 7,
    74 enum 
    89     ELayerFlatR = 8,
    75     {
    90     ELayerFlatL = 9,
    76     ELayerFlatBackground = 0,
    91     ELayerFlatCenter = 10,
    77     ELayerFlatTl = 1,
    92     ELayerFlatMain = 11,
    78     ELayerFlatTr = 2,
    93     ELayerFlatWallpaper = 12,
    79     ELayerFlatBl = 3,
    94     ELayerSCtrl1 = 13,
    80     ELayerFlatBr = 4,
    95     ELayerSCtrl2 = 14,
    81     ELayerFlatT = 5,
    96     ELayerSCtrl3 = 15,
    82     ELayerFlatB = 6,
    97     ELayerSCtrl4 = 16,
    83     ELayerFlatR = 7,
    98     ELayerSCtrl5 = 17,
    84     ELayerFlatL = 8,
    99     ELayerFlatN = 18
    85     ELayerFlatCenter = 9,
       
    86     ELayerFlatMain = 10,
       
    87     ELayerFlatWallpaper = 11,
       
    88     ELayerFlatN = 12
   100     };
    89     };
   101 
    90 
   102 
    91 
   103 class CAknScreenClearerBaseExtension : public CBase
    92 class CAknScreenClearerBaseExtension : public CBase
   104     {
    93     {
   105     public:
    94 public:
   106         ~CAknScreenClearerBaseExtension()
    95     ~CAknScreenClearerBaseExtension()
   107             {
    96         {
   108             delete iNaviWipe;
    97         delete iBgContext;
   109             delete iNaviMask;
    98         }
   110             delete iBgContext;
    99 public:
   111             }
   100     CAknsLayeredBackgroundControlContext* iBgContext;
   112     public:
   101     TInt iOrdinalPosition;
   113 	    CFbsBitmap* iNaviWipe;
   102 	TBool iTransparent;
   114         CFbsBitmap* iNaviMask;
       
   115         CAknsLayeredBackgroundControlContext* iBgContext;
       
   116         TInt iOrdinalPosition;
       
   117     };
   103     };
   118 
   104 
   119 /* THIS FUNCTION IS NOT USED
   105 
   120 
   106 EXPORT_C CAknScreenClearerBase::~CAknScreenClearerBase()
   121 static void LoadAndFlipBitmapL( 
   107 	{
   122     CFbsBitmap* aTrg, const TDesC& aFile, const TInt aIndex )
   108     delete iExtension;
       
   109 	}
       
   110 
       
   111 
       
   112 void CAknScreenClearerBase::CreateExtensionL()
       
   113 	{
       
   114 	if ( !iExtension )
       
   115 		{
       
   116 		iExtension = new (ELeave) CAknScreenClearerBaseExtension;
       
   117 		}
       
   118 	}
       
   119 
       
   120 
       
   121 void CAknScreenClearerBase::SetTransparent( TBool aTransparent )
   123     {
   122     {
   124     User::LeaveIfNull(aTrg);
   123     iExtension->iTransparent = aTransparent;
   125 
       
   126     CFbsBitmap* sourceBitmap = new (ELeave) CFbsBitmap();   
       
   127     CleanupStack::PushL(sourceBitmap);
       
   128     User::LeaveIfError(sourceBitmap->Load(aFile, aIndex, ETrue));    
       
   129     TSize sourceBitmapSize = sourceBitmap->SizeInPixels();
       
   130 
       
   131     User::LeaveIfError(aTrg->Create(sourceBitmapSize, sourceBitmap->DisplayMode()));
       
   132 
       
   133     CFbsBitmapDevice* destinationDevice = CFbsBitmapDevice::NewL( aTrg );
       
   134     CleanupStack::PushL(destinationDevice);
       
   135 
       
   136     CFbsBitGc* destinationGc;
       
   137     User::LeaveIfError( destinationDevice->CreateContext( destinationGc ) );
       
   138 
       
   139     TRect sourceBitmapBlittingRect( 0,0,1,sourceBitmapSize.iHeight );  
       
   140 
       
   141     for ( TInt xPos=sourceBitmapSize.iWidth-1; xPos >= 0; xPos-- )
       
   142         {
       
   143         destinationGc->BitBlt( TPoint(xPos,0), sourceBitmap, sourceBitmapBlittingRect );
       
   144         sourceBitmapBlittingRect.iTl.iX++;
       
   145         sourceBitmapBlittingRect.iBr.iX++;
       
   146         }
       
   147 
       
   148     delete destinationGc;  
       
   149     CleanupStack::PopAndDestroy(2); // sourceBitmap, destinationDevice
       
   150     }
   124     }
   151 */
   125 
   152 
       
   153 /* THIS FUNCTION IS NOT USED
       
   154 
       
   155 static CFbsBitmap* FlipBitmapL( CFbsBitmap* aBitmap )
       
   156     {
       
   157     User::LeaveIfNull(aBitmap);   
       
   158 
       
   159     TSize sourceBitmapSize = aBitmap->SizeInPixels();
       
   160 
       
   161     // get a copy of wanted rect of source bitmap to tmpBitmap
       
   162     CFbsBitmap* tmpBitmap = new (ELeave) CFbsBitmap();   
       
   163     CleanupStack::PushL( tmpBitmap );                      
       
   164 
       
   165     User::LeaveIfError( tmpBitmap->Create( sourceBitmapSize, aBitmap->DisplayMode() ) );
       
   166 
       
   167     CFbsBitmapDevice* destinationDevice = CFbsBitmapDevice::NewL( tmpBitmap );
       
   168     CleanupStack::PushL( destinationDevice );
       
   169     
       
   170     CFbsBitGc* destinationGc;
       
   171     User::LeaveIfError( destinationDevice->CreateContext( destinationGc ) );           
       
   172     
       
   173     TRect sourceBitmapBlittingRect( 0,0,1,sourceBitmapSize.iHeight );  
       
   174     
       
   175     for ( TInt xPos=sourceBitmapSize.iWidth-1; xPos >= 0; xPos-- )
       
   176         {
       
   177         destinationGc->BitBlt( TPoint(xPos,0), aBitmap, sourceBitmapBlittingRect );
       
   178         sourceBitmapBlittingRect.iTl.iX++;
       
   179         sourceBitmapBlittingRect.iBr.iX++;
       
   180         }
       
   181     
       
   182     delete destinationGc;  
       
   183     CleanupStack::PopAndDestroy(); // destinationDevice
       
   184     CleanupStack::Pop(); // tmpBitmap
       
   185   
       
   186     return tmpBitmap;
       
   187     }
       
   188 */
       
   189 
       
   190 EXPORT_C CAknScreenClearerBase::~CAknScreenClearerBase()
       
   191 	{
       
   192     delete iExtension;
       
   193 	}
       
   194 
   126 
   195 EXPORT_C void CAknScreenClearerBase::ConstructL(RWindowGroup& aParent, TInt aOrdinalPos, TBool aBlankAppStatusPane)
   127 EXPORT_C void CAknScreenClearerBase::ConstructL(RWindowGroup& aParent, TInt aOrdinalPos, TBool aBlankAppStatusPane)
   196 	{
   128 	{
   197     iExtension = new (ELeave) CAknScreenClearerBaseExtension();
   129 	CreateExtensionL();
   198 
   130 
   199 	CreateWindowL(&aParent);
   131 	CreateWindowL(&aParent);
       
   132 
       
   133 	if ( iExtension->iTransparent )
       
   134 		{
       
   135 		EnableWindowTransparency();
       
   136 		}
   200 
   137 
   201     CAlfEffectObserver* alfEffectObserver = CAlfEffectObserver::NewL(); 
   138     CAlfEffectObserver* alfEffectObserver = CAlfEffectObserver::NewL(); 
   202     alfEffectObserver->SetDistractionWindow(*DrawableWindow());
   139     alfEffectObserver->SetDistractionWindow(*DrawableWindow());
   203     delete alfEffectObserver;
   140     delete alfEffectObserver;
   204 
   141 
   229 
   166 
   230 EXPORT_C void CAknScreenClearerBase::Draw(const TRect& /*aRect*/) const
   167 EXPORT_C void CAknScreenClearerBase::Draw(const TRect& /*aRect*/) const
   231 	{
   168 	{
   232 	CWindowGc& gc = SystemGc();
   169 	CWindowGc& gc = SystemGc();
   233     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   170     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   234     AknsDrawUtils::Background( skin, iExtension->iBgContext, this, gc, Rect() );
   171 
       
   172     if ( !iExtension->iTransparent )
       
   173         {
       
   174         AknsDrawUtils::Background( skin, iExtension->iBgContext, this, gc, Rect() );
       
   175         }
       
   176     else
       
   177         {
       
   178         gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha );
       
   179         gc.Clear( Rect() );
       
   180         gc.Reset();
       
   181         }
   235 
   182 
   236     iEikonEnv->WsSession().Flush();
   183     iEikonEnv->WsSession().Flush();
   237     return;
   184     return;
   238 	}
   185 	}
   239 	
   186 	
   262     RRegion appStatuspaneShape;
   209     RRegion appStatuspaneShape;
   263 	CleanupClosePushL(appStatuspaneShape);
   210 	CleanupClosePushL(appStatuspaneShape);
   264 
   211 
   265 	CEikStatusPaneBase* sp = CEikStatusPaneBase::Current();
   212 	CEikStatusPaneBase* sp = CEikStatusPaneBase::Current();
   266     
   213     
   267     if (iFlags[EAknScreenClearerBlankAppStatusPane])
   214 	// Set the clearer window's size so that it covers the screen in both
   268         {
   215 	// portrait and landscape orientations simultaneously.
   269         shape.AddRect(KWholeScreen);
   216 	// This is done in order to prevent NGA from drawing control groups
       
   217 	// underneath the fullscreen foreground application in cases the clearer
       
   218 	// orientation can't be readily updated during the layout switch, due
       
   219 	// to e.g. application startup taking a long time.
       
   220 	// Note that only the clearer window's size is set to be larger, the
       
   221 	// skin background is still the screen size so that the skin background
       
   222 	// won't get stretched.
       
   223 	TRect screenRect( KWholeScreen );
       
   224 	TRect squareScreenRect( screenRect );
       
   225     if ( squareScreenRect.Width() > squareScreenRect.Height() )
       
   226         {
       
   227         squareScreenRect.SetHeight( squareScreenRect.Width() );
   270         }
   228         }
   271     else
   229     else
   272         {
   230         {
   273         shape.AddRect(KWholeScreen);
   231         squareScreenRect.SetWidth( squareScreenRect.Height() );
   274 		sp->GetShapeL(appStatuspaneShape, !iFlags[EAknScreenClearerBlankAppStatusPane], ETrue);
   232         }
   275         shape.SubRegion(appStatuspaneShape);
   233 	
   276         }
   234     if ( iFlags[EAknScreenClearerBlankAppStatusPane] )
   277 
   235         {
   278 	if (shape.CheckError())
   236         shape.AddRect( squareScreenRect );
   279 		User::Leave(KErrNoMemory);
   237         }
   280 
   238     else
   281 	SetRect(KWholeScreen);
   239         {
   282 	DrawableWindow()->SetShape(shape);
   240         // Square shape is used only if the clearer is used to clear the
   283 
   241         // whole screen.
   284 	CleanupStack::PopAndDestroy(2);		// close shapes	
   242         shape.AddRect( screenRect );
   285 
   243 		sp->GetShapeL( appStatuspaneShape,
   286 	TBool drawNavi =
   244 		               !iFlags[EAknScreenClearerBlankAppStatusPane],
   287 		iFlags[EAknScreenClearerBlankAppStatusPane] && 
   245 		               ETrue );
   288 		sp->IsVisible() && 
   246         shape.SubRegion( appStatuspaneShape );
   289 		sp->PaneCapabilities(TUid::Uid(EEikStatusPaneUidNavi)).IsInCurrentLayout();
   247         }
   290 
   248 
   291 	iFlags.Assign(EAknScreenClearerDrawNavi, drawNavi);
   249 	if ( shape.CheckError() )
       
   250 	    {
       
   251 		User::Leave( KErrNoMemory );
       
   252 	    }
       
   253 
       
   254 	SetRect( iFlags[EAknScreenClearerBlankAppStatusPane] ? squareScreenRect :
       
   255                                                            screenRect );
       
   256 	DrawableWindow()->SetShape( shape );
       
   257 
       
   258 	CleanupStack::PopAndDestroy( 2, &shape ); // close shapes
   292 	}
   259 	}
   293 
   260 
   294 
   261 
   295 
   262 
   296 void CAknScreenClearerBase::SetSkinShapeL()
   263 void CAknScreenClearerBase::SetSkinShapeL()
   506             iExtension->iBgContext->SetLayerImage( 4, KAknsIIDNone );
   473             iExtension->iBgContext->SetLayerImage( 4, KAknsIIDNone );
   507                         
   474                         
   508             iExtension->iBgContext->SetLayerRect( 0, main_pane.Rect() );
   475             iExtension->iBgContext->SetLayerRect( 0, main_pane.Rect() );
   509             iExtension->iBgContext->SetLayerRect( 1, staconTop );
   476             iExtension->iBgContext->SetLayerRect( 1, staconTop );
   510             iExtension->iBgContext->SetLayerRect( 2, staconBottom );
   477             iExtension->iBgContext->SetLayerRect( 2, staconBottom );
   511             }                        
   478             }
   512 
       
   513 	if (Layout_Meta_Data::IsPenEnabled())
       
   514 		{
       
   515 		TAknLayoutRect area_side_right_pane;
       
   516 		TInt variety = 0;
       
   517 		area_side_right_pane.LayoutRect(application_window, AknLayoutScalable_Avkon::area_side_right_pane(variety));
       
   518 
       
   519 		TAknLayoutRect sctrl_sk_top_pane;
       
   520 		sctrl_sk_top_pane.LayoutRect(area_side_right_pane.Rect(), AknLayoutScalable_Avkon::sctrl_sk_top_pane(0));
       
   521 	
       
   522 		TAknLayoutRect sctrl_sk_bottom_pane;
       
   523 		sctrl_sk_bottom_pane.LayoutRect(area_side_right_pane.Rect(), AknLayoutScalable_Avkon::sctrl_sk_bottom_pane(0));
       
   524 	
       
   525 		TAknLayoutRect grid_sctrl_middle_pane;
       
   526 		grid_sctrl_middle_pane.LayoutRect(area_side_right_pane.Rect(), AknLayoutScalable_Avkon::grid_sctrl_middle_pane(0));
       
   527 	
       
   528 		TAknLayoutRect cell_sctrl_middle_pane1;
       
   529 		cell_sctrl_middle_pane1.LayoutRect(grid_sctrl_middle_pane.Rect(), AknLayoutScalable_Avkon::cell_sctrl_middle_pane(0,0,0));
       
   530 		TAknLayoutRect cell_sctrl_middle_pane2;
       
   531 		cell_sctrl_middle_pane2.LayoutRect(grid_sctrl_middle_pane.Rect(), AknLayoutScalable_Avkon::cell_sctrl_middle_pane(0,0,1));
       
   532 		TAknLayoutRect cell_sctrl_middle_pane3;
       
   533 		cell_sctrl_middle_pane3.LayoutRect(grid_sctrl_middle_pane.Rect(), AknLayoutScalable_Avkon::cell_sctrl_middle_pane(0,0,2));
       
   534 	
       
   535 
       
   536 
       
   537 		iExtension->iBgContext->SetLayerImage( ELayerFlatCbaBackground, KAknsIIDQsnBgScreen );
       
   538 
       
   539 
       
   540 		iExtension->iBgContext->SetLayerRect( ELayerFlatCbaBackground, application_window );
       
   541 		}
       
   542 
       
   543 
       
   544 
       
   545 
       
   546         }
   479         }
   547     else
   480     else
   548         {
   481         {
   549         // Default is portrait 
   482         // Default is portrait 
   550         TInt spRes = CEikStatusPaneBase::Current()->CurrentLayoutResId();
   483         TInt spRes = CEikStatusPaneBase::Current()->CurrentLayoutResId();
   682 	CEikonEnv& eikEnv = *static_cast<CEikonEnv*>(self->ControlEnv());
   615 	CEikonEnv& eikEnv = *static_cast<CEikonEnv*>(self->ControlEnv());
   683 	self->ConstructL(eikEnv.RootWin(), 0, aBlankAppStatusPane);
   616 	self->ConstructL(eikEnv.RootWin(), 0, aBlankAppStatusPane);
   684 	return(self);
   617 	return(self);
   685 	}
   618 	}
   686 
   619 
       
   620 
       
   621 EXPORT_C CAknLocalScreenClearer* CAknLocalScreenClearer::NewLC(TBool aBlankAppStatusPane, TBool aTransparent)
       
   622 	{
       
   623 	CAknLocalScreenClearer* self=new(ELeave) CAknLocalScreenClearer;
       
   624 	CleanupStack::PushL(self);
       
   625 	self->CreateExtensionL();
       
   626 	self->SetTransparent(aTransparent);
       
   627 	CEikonEnv& eikEnv = *static_cast<CEikonEnv*>(self->ControlEnv());
       
   628 	self->ConstructL(eikEnv.RootWin(), 0, aBlankAppStatusPane);
       
   629 	return(self);
       
   630 	}
       
   631 
       
   632 
   687 EXPORT_C CAknLocalScreenClearer* CAknLocalScreenClearer::NewL(TBool aBlankAppStatusPane)
   633 EXPORT_C CAknLocalScreenClearer* CAknLocalScreenClearer::NewL(TBool aBlankAppStatusPane)
   688 	{
   634 	{
   689 	CAknLocalScreenClearer* self = CAknLocalScreenClearer::NewLC(aBlankAppStatusPane);
   635 	CAknLocalScreenClearer* self = CAknLocalScreenClearer::NewLC(aBlankAppStatusPane);
   690 	CleanupStack::Pop(self);
   636 	CleanupStack::Pop(self);
   691 	return(self);
   637 	return(self);
   692 	}
   638 	}
   693 	
   639 
       
   640 
       
   641 EXPORT_C CAknLocalScreenClearer* CAknLocalScreenClearer::NewL(TBool aBlankAppStatusPane, TBool aTransparent)
       
   642 	{
       
   643 	CAknLocalScreenClearer* self = CAknLocalScreenClearer::NewLC(aBlankAppStatusPane, aTransparent);
       
   644 	CleanupStack::Pop(self);
       
   645 	return(self);
       
   646 	}
       
   647 
       
   648 
   694 EXPORT_C void CAknLocalScreenClearer::HandleResourceChange(TInt aType)
   649 EXPORT_C void CAknLocalScreenClearer::HandleResourceChange(TInt aType)
   695 	{
   650 	{
   696 	if (aType == KEikDynamicLayoutVariantSwitch)
   651 	if (aType == KEikDynamicLayoutVariantSwitch)
   697 		{
   652 		{
   698         TRAP_IGNORE(
   653         TRAP_IGNORE(