coreapplicationuis/SysAp/Src/SysApShutdownImage.cpp
branchRCL_3
changeset 63 c2c61fdca848
parent 62 924385140d98
equal deleted inserted replaced
62:924385140d98 63:c2c61fdca848
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 //#include <aknappui.h>
    20 #include <aknappui.h>
    21 //#include <AknIconUtils.h>
    21 #include <AknIconUtils.h>
    22 //#include <AknUtils.h>
    22 #include <AknUtils.h>
    23 #include <eikenv.h>
       
    24 #include <coemain.h>
    23 #include <coemain.h>
    25 #include <barsread.h> //use of TResourceReader
    24 #include <barsread.h> //use of TResourceReader
    26 //#include <sysap.mbg>
    25 #include <sysap.mbg>
    27 #include "SysApShutdownImage.h"
    26 #include "SysApShutdownImage.h"
    28 #include "SysAp.hrh"
    27 #include "SysAp.hrh"
    29 #include <data_caging_path_literals.hrh>
    28 #include <data_caging_path_literals.hrh>
    30 #include <HbDeviceMessageBoxSymbian.h>
       
    31 #include <SVGEngineInterfaceImpl.h>
       
    32 
       
    33 //_LIT(KDC_APP_BITMAP_DIR,"\\resource\\apps\\"); 
       
    34 
    29 
    35 // ============================ MEMBER FUNCTIONS ==============================
    30 // ============================ MEMBER FUNCTIONS ==============================
    36 
    31 
    37 // ----------------------------------------------------------------------------
    32 // ----------------------------------------------------------------------------
    38 // CSysApShutdownImage::NewL()
    33 // CSysApShutdownImage::NewL()
    72 // ----------------------------------------------------------------------------
    67 // ----------------------------------------------------------------------------
    73 
    68 
    74 void CSysApShutdownImage::ShowShutdownImageL(TInt aBitmapId)
    69 void CSysApShutdownImage::ShowShutdownImageL(TInt aBitmapId)
    75     {
    70     {
    76     TRACES( RDebug::Print(_L("CSysApShutdownImage::ShowShutdownImageL:start" ) ) );
    71     TRACES( RDebug::Print(_L("CSysApShutdownImage::ShowShutdownImageL:start" ) ) );
    77     
       
    78     TInt err ( 0 );
    72     TInt err ( 0 );
    79     TRect rect(iCoeEnv->ScreenDevice()->SizeInPixels());
    73 
    80     SetRect(rect);
    74     SetRect(iAvkonAppUi->ApplicationRect());
    81     TRACES( RDebug::Print(_L("CSysApShutdownImage::After:SetRect --Minus one" ) ) );
       
    82     ActivateL();
    75     ActivateL();
    83 
       
    84     TRACES( RDebug::Print(_L("CSysApShutdownImage::After:ActivateL --Zero" ) ) );
       
    85 
    76 
    86     if ( aBitmapId )
    77     if ( aBitmapId )
    87         {
    78         {
    88         _LIT( KDirAndFile, "z:qgn_sysap_screen.svg" );
    79         _LIT( KDirAndFile, "z:sysap.mif" );
    89         TParse* fp = new (ELeave) TParse();
    80         TParse* fp = new (ELeave) TParse();
    90         CleanupStack::PushL(fp);
    81         CleanupStack::PushL(fp);
    91         fp->Set( KDirAndFile, &KDC_APP_BITMAP_DIR, NULL );
    82         fp->Set( KDirAndFile, &KDC_APP_BITMAP_DIR, NULL );
    92         TRACES( RDebug::Print(_L("CSysApShutdownImage::ShowShutdownImageL shutdown image: %S" ), &(fp->FullName())) );
    83         TRACES( RDebug::Print(_L("CSysApShutdownImage::ShowShutdownImageL shutdown image: %S" ), &(fp->FullName())) );
    93         RFs fs;
    84         RFs fs;
   106             else
    97             else
   107                 {
    98                 {
   108                 delete iBitmap;
    99                 delete iBitmap;
   109                 iBitmap = NULL;
   100                 iBitmap = NULL;
   110                 // Ownership of bitmap is transferred to CSysApShutdownImage in CreateIconL
   101                 // Ownership of bitmap is transferred to CSysApShutdownImage in CreateIconL
   111                 iBitmap = ReadSVGL(fp->FullName());
   102                 iBitmap = AknIconUtils::CreateIconL( fp->FullName(), aBitmapId );
   112                 TRACES( RDebug::Print(_L("CSysApShutdownImage::After:ReadSVGL --First" ) ) );
   103                 TAknLayoutRect bitmapRect;
       
   104                 bitmapRect.LayoutRect( Rect(), AKN_LAYOUT_WINDOW_screen );
       
   105                 AknIconUtils::SetSize( iBitmap, bitmapRect.Rect().Size(), EAspectRatioPreservedAndUnusedSpaceRemoved );
   113                 TInt xDelta=0; // for x coordinates
   106                 TInt xDelta=0; // for x coordinates
   114                 TInt yDelta=0; // for y coordinates
   107                 TInt yDelta=0; // for y coordinates
   115                 TSize bmpSizeInPixels = iBitmap->SizeInPixels();
   108                 TSize bmpSizeInPixels = iBitmap->SizeInPixels();
   116                 TRACES( RDebug::Print(_L("CSysApShutdownImage::After:SizeInPixels --Second" ) ) );
       
   117                 //center image to the center of the screen
   109                 //center image to the center of the screen
   118                 TRect rect = Rect();
   110                 TRect rect = Rect();
   119                 xDelta=( rect.Width() - bmpSizeInPixels.iWidth ) / 2;
   111                 xDelta=( rect.Width() - bmpSizeInPixels.iWidth ) / 2;
   120                 yDelta=( rect.Height() - bmpSizeInPixels.iHeight ) / 2;
   112                 yDelta=( rect.Height() - bmpSizeInPixels.iHeight ) / 2;
   121                 TPoint pos = TPoint( xDelta , yDelta ); // displacement vector
   113                 TPoint pos = TPoint( xDelta , yDelta ); // displacement vector
   122                 //pos += rect.iTl; // bitmap top left corner position
   114                 //pos += rect.iTl; // bitmap top left corner position
   123                 TRACES( RDebug::Print(_L("CSysApShutdownImage::After:TPoint --Three" ) ) );
       
   124                 CWindowGc& gc = SystemGc();
   115                 CWindowGc& gc = SystemGc();
   125                 TRACES( RDebug::Print(_L("CSysApShutdownImage::After:SystemGc --Four" ) ) );
       
   126                 ActivateGc();
   116                 ActivateGc();
   127                 TRACES( RDebug::Print(_L("CSysApShutdownImage::After:ActivateGc --Five" ) ) );
       
   128                 Window().Invalidate( rect );
   117                 Window().Invalidate( rect );
   129                 TRACES( RDebug::Print(_L("CSysApShutdownImage::After:Invalidate --Six" ) ) );
       
   130                 Window().BeginRedraw( rect );
   118                 Window().BeginRedraw( rect );
   131                 TRACES( RDebug::Print(_L("CSysApShutdownImage::After:BeginRedraw --Seven" ) ) );
       
   132                 gc.Clear();
   119                 gc.Clear();
   133                 TRACES( RDebug::Print(_L("CSysApShutdownImage::After:gc.Clear --Eight" ) ) );
       
   134                 gc.BitBlt( pos, iBitmap ); // CWindowGc member function
   120                 gc.BitBlt( pos, iBitmap ); // CWindowGc member function
   135                 TRACES( RDebug::Print(_L("CSysApShutdownImage::After:gc.BitBlt --Nine" ) ) );
       
   136                 Window().EndRedraw();
   121                 Window().EndRedraw();
   137                 TRACES( RDebug::Print(_L("CSysApShutdownImage::After:gc.EndRedraw --Ten" ) ) );
       
   138                 DeactivateGc();
   122                 DeactivateGc();
   139                 TRACES( RDebug::Print(_L("CSysApShutdownImage::After:gc.DeactivateGc --Eleven" ) ) );
       
   140                 ControlEnv()->WsSession().Flush(); // force draw of the context
   123                 ControlEnv()->WsSession().Flush(); // force draw of the context
   141                 TRACES( RDebug::Print(_L("CSysApShutdownImage::ShowShutdownImageL:end" ) ) );
   124                 TRACES( RDebug::Print(_L("CSysApShutdownImage::ShowShutdownImageL:end" ) ) );
   142                 }
   125                 }
   143             }
   126             }
   144 
   127 
   159         Window().EndRedraw();
   142         Window().EndRedraw();
   160         DeactivateGc();
   143         DeactivateGc();
   161         ControlEnv()->WsSession().Flush(); // force draw of the context
   144         ControlEnv()->WsSession().Flush(); // force draw of the context
   162 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
   145 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
   163         }
   146         }
   164     }
   147 
   165 
       
   166 // ----------------------------------------------------------------------------
       
   167 // CSysApShutdownImage::ShowShutdownImage()
       
   168 // ----------------------------------------------------------------------------
       
   169 CFbsBitmap* CSysApShutdownImage::ReadSVGL (TFileName aFileName)
       
   170     {
       
   171     TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL:start" ) ) );    
       
   172     TFontSpec fontspec;
       
   173     TDisplayMode mode = EColor16MA;
       
   174     TInt SIZE_X(360), SIZE_Y(360);
       
   175     TSize size(SIZE_X, SIZE_Y);
       
   176 
       
   177     //if ( mode >= (TDisplayMode)13 )  { mode = EColor16MA; }
       
   178 
       
   179     CFbsBitmap* frameBuffer = new ( ELeave ) CFbsBitmap;
       
   180     CleanupStack::PushL( frameBuffer );
       
   181     frameBuffer->Create( size, mode );
       
   182     
       
   183     CSvgEngineInterfaceImpl* svgEngine = NULL;
       
   184     svgEngine = CSvgEngineInterfaceImpl::NewL(frameBuffer, NULL, fontspec );    
       
   185     
       
   186     if (svgEngine == NULL)
       
   187         {
       
   188         TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL:SVG engine creation failed" ) ) );   
       
   189         }
       
   190     
       
   191     CleanupStack::PushL( svgEngine );
       
   192     TInt domHandle = 0;
       
   193     svgEngine->PrepareDom( aFileName, domHandle ) ;
       
   194     if (domHandle == 0)
       
   195         {
       
   196         TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL():DOM handle creation failed" ) ) );
       
   197         }
       
   198 
       
   199     CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;    
       
   200     CleanupStack::PushL( bitmap );
       
   201     User::LeaveIfError( bitmap->Create( size, EColor64K ) );
       
   202 
       
   203     svgEngine->UseDom( domHandle, bitmap, NULL ) ;
       
   204     
       
   205     MSvgError* err;
       
   206     svgEngine->Start( err );
       
   207     if (err->HasError())
       
   208         {
       
   209         TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL(): SVG Engine Start failed" ) ) );
       
   210         }
       
   211 
       
   212     svgEngine->DeleteDom( domHandle );
       
   213     CleanupStack::Pop( bitmap );
       
   214     CleanupStack::PopAndDestroy( svgEngine );
       
   215     CleanupStack::PopAndDestroy( frameBuffer );
       
   216     TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL:End" ) ) );   
       
   217     return bitmap;
       
   218     }
   148     }
   219 
   149 
   220 // ----------------------------------------------------------------------------
   150 // ----------------------------------------------------------------------------
   221 // CSysApShutdownImage::ShutdownCoeControlWindow()
   151 // CSysApShutdownImage::ShutdownCoeControlWindow()
   222 // ----------------------------------------------------------------------------
   152 // ----------------------------------------------------------------------------
   351 TKeyResponse CSysApShutdownImage::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/)
   281 TKeyResponse CSysApShutdownImage::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/)
   352     {
   282     {
   353     return EKeyWasNotConsumed;
   283     return EKeyWasNotConsumed;
   354     }
   284     }
   355 
   285 
   356 void CSysApShutdownImage::SetRectForAnimation()
       
   357     {
       
   358     TRect rect(iCoeEnv->ScreenDevice()->SizeInPixels());
       
   359     SetRect(rect);
       
   360     }
       
   361 
       
   362 // End of File
   286 // End of File