idlehomescreen/xmluirendering/uiengine/src/xnbackgroundmanager.cpp
branchRCL_3
changeset 9 f966699dea19
parent 5 c743ef5928ba
child 15 ff572dfe6d86
equal deleted inserted replaced
5:c743ef5928ba 9:f966699dea19
    24 #include "xnplugindefs.h"
    24 #include "xnplugindefs.h"
    25 #include "hspssapi.h"
    25 #include "hspssapi.h"
    26 #include "xnappuiadapter.h"
    26 #include "xnappuiadapter.h"
    27 #include "xnwallpaperview.h"
    27 #include "xnwallpaperview.h"
    28 #include "xnrootdata.h"
    28 #include "xnrootdata.h"
       
    29 #include "xnuiengine.h"
    29 
    30 
    30 // SYSTEM INCLUDE FILES
    31 // SYSTEM INCLUDE FILES
    31 #include <aknlistquerydialog.h> 
    32 #include <aknlistquerydialog.h> 
    32 #include <xnuiengine.rsg>
    33 #include <xnuiengine.rsg>
    33 #include <aknskinsinternalcrkeys.h>
    34 #include <AknSkinsInternalCRKeys.h>
    34 #include <activeidle2domaincrkeys.h>
    35 #include <activeidle2domaincrkeys.h>
    35 #include <aknswallpaperutils.h>
    36 #include <AknsWallpaperUtils.h>
    36 #include <imageconversion.h>
    37 #include <imageconversion.h>
    37 #include <bitmaptransforms.h>
    38 #include <bitmaptransforms.h>
    38 
    39 
    39 #include <aknsutils.h>
    40 #include <AknsUtils.h>
    40 #include <aknsdrawutils.h>
    41 #include <AknsDrawUtils.h>
    41 #include <aknscontrolcontext.h>
    42 #include <AknsControlContext.h>
    42 #include <aknslayeredbackgroundcontrolcontext.h>
    43 #include <AknsLayeredBackgroundControlContext.h>
    43 #include <driveinfo.h>
    44 #include <driveinfo.h>
    44 
    45 
    45 using namespace hspswrapper;
    46 using namespace hspswrapper;
    46 
    47 
    47 _LIT8( KSingle, "single" );
    48 _LIT8( KSingle, "single" );
    48 const TUid KDummyUid = { 0x0000000 };
    49 const TUid KDummyUid = { 0x0000000 };
       
    50 const TInt KSkinGfxInnerRectShrink = 5;
    49 
    51 
    50 // ============================ MEMBER FUNCTIONS ===============================
    52 // ============================ MEMBER FUNCTIONS ===============================
    51 
    53 
    52 // -----------------------------------------------------------------------------
    54 // -----------------------------------------------------------------------------
    53 // C++ default constructor.
    55 // C++ default constructor.
    65 //
    67 //
    66 void CXnBackgroundManager::ConstructL()
    68 void CXnBackgroundManager::ConstructL()
    67     {    
    69     {    
    68     CreateWindowL();
    70     CreateWindowL();
    69 
    71 
       
    72     iRect = TRect();
    70     iBgContext = CAknsLayeredBackgroundControlContext::NewL(
    73     iBgContext = CAknsLayeredBackgroundControlContext::NewL(
    71             KAknsIIDQsnBgScreenIdle, TRect(), ETrue, 1 );
    74             KAknsIIDQsnBgScreenIdle, iRect, ETrue, 1 );
    72 
    75 
    73     TRect bgRect;
    76     TRect bgRect;
    74     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, bgRect );
    77     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, bgRect );
    75     SetRect( bgRect );
    78     SetRect( bgRect );
    76 
    79 
   132     if( iFeatureSuppoted )
   135     if( iFeatureSuppoted )
   133         {
   136         {
   134         CXnViewData& viewData( iViewManager.ActiveViewData() );
   137         CXnViewData& viewData( iViewManager.ActiveViewData() );
   135         CFbsBitmap* wallpaper = viewData.WallpaperImage();
   138         CFbsBitmap* wallpaper = viewData.WallpaperImage();
   136         if( wallpaper )
   139         if( wallpaper )
   137             {
   140             {   
   138             SystemGc().BitBlt( TPoint(0, 0), wallpaper ); 
   141             TSize bitmapSize = wallpaper->SizeInPixels();
       
   142             
       
   143             if( iRect.Height() > bitmapSize.iHeight && iRect.Width() > bitmapSize.iWidth )
       
   144                 {
       
   145                 TInt width = bitmapSize.iWidth / 2;
       
   146                 TInt height = bitmapSize.iHeight / 2;
       
   147             
       
   148                 TPoint point = iRect.Center();
       
   149                 point.SetXY( point.iX - width, point.iY - height );
       
   150                 
       
   151                 SystemGc().SetBrushColor( KRgbBlack );
       
   152                 SystemGc().Clear( aRect );
       
   153                 SystemGc().BitBlt( point, wallpaper ); 
       
   154                 }
       
   155             else
       
   156                 {
       
   157                 SystemGc().BitBlt( TPoint( 0, 0 ), wallpaper );
       
   158                 }
       
   159 
       
   160             if( iViewManager.UiEngine().IsEditMode() )
       
   161                 {
       
   162                 DrawEditModeBackgroundSkin();
       
   163                 }
   139             return;
   164             return;
   140             }
   165             }
   141         }
   166         }
   142     else if( iBgImage )
   167     else if( iBgImage )
   143         {
   168         {
   144         SystemGc().BitBlt( TPoint(0, 0), iBgImage ); 
   169         TSize bitmapSize = iBgImage->SizeInPixels();
       
   170         
       
   171         if( iRect.Height() > bitmapSize.iHeight && iRect.Width() > bitmapSize.iWidth )
       
   172             {
       
   173             TInt width = bitmapSize.iWidth / 2;
       
   174             TInt height = bitmapSize.iHeight / 2;
       
   175         
       
   176             TPoint point = iRect.Center();
       
   177             point.SetXY( point.iX - width, point.iY - height );
       
   178             
       
   179             SystemGc().SetBrushColor( KRgbBlack );
       
   180             SystemGc().Clear( aRect );
       
   181             SystemGc().BitBlt( point, iBgImage ); 
       
   182             }
       
   183         else
       
   184             {
       
   185             SystemGc().BitBlt( TPoint( 0, 0 ), iBgImage );
       
   186             }
       
   187         if( iViewManager.UiEngine().IsEditMode() )
       
   188             {
       
   189             DrawEditModeBackgroundSkin();
       
   190             }
   145         return;
   191         return;
   146         }    
   192         }    
   147     MAknsSkinInstance* skin( AknsUtils::SkinInstance() );     
   193     MAknsSkinInstance* skin( AknsUtils::SkinInstance() );     
   148     AknsDrawUtils::Background( skin, iBgContext, this, SystemGc(), aRect );
   194     AknsDrawUtils::Background( skin, iBgContext, this, SystemGc(), aRect );
       
   195     
       
   196     if( iViewManager.UiEngine().IsEditMode() )
       
   197         {
       
   198         DrawEditModeBackgroundSkin();
       
   199         }   
   149     }
   200     }
   150 
   201 
   151 // -----------------------------------------------------------------------------
   202 // -----------------------------------------------------------------------------
   152 // CXnBackgroundManager::SizeChanged
   203 // CXnBackgroundManager::SizeChanged
   153 // -----------------------------------------------------------------------------
   204 // -----------------------------------------------------------------------------
   685             }
   736             }
   686         // WallpaperImage changed back to default. Update view data.
   737         // WallpaperImage changed back to default. Update view data.
   687         else
   738         else
   688             {
   739             {
   689             viewData.SetWallpaperImagePathL( KNullDesC );
   740             viewData.SetWallpaperImagePathL( KNullDesC );
   690             viewData.SetWallpaperImage( NULL );            
   741             viewData.SetWallpaperImage( NULL ); 
       
   742             SaveWallpaperL(); // to HSPS
   691             }
   743             }
   692 
   744 
   693         // Update screen
   745         // Update screen
   694         UpdateScreen();
   746         UpdateScreen();
   695         
   747         
   834         {
   886         {
   835         DrawNow();  
   887         DrawNow();  
   836         }
   888         }
   837     }
   889     }
   838 
   890 
       
   891 // -----------------------------------------------------------------------------
       
   892 // CXnBackgroundManager::DrawEditModeBackgroundSkin
       
   893 // -----------------------------------------------------------------------------
       
   894 //
       
   895 void CXnBackgroundManager::DrawEditModeBackgroundSkin() const
       
   896     { 
       
   897     TRect shrunkRect = iRect;
       
   898 
       
   899     shrunkRect.Shrink(
       
   900         KSkinGfxInnerRectShrink,
       
   901         KSkinGfxInnerRectShrink );
       
   902     
       
   903     AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), SystemGc(), 
       
   904             iRect, shrunkRect, KAknsIIDQgnHomeEditBg, KAknsIIDDefault );
       
   905     }
       
   906 
   839 //  End of File
   907 //  End of File