camerauis/cameraapp/generic/src/camstartuplogo.cpp
branchRCL_3
changeset 24 bac7acad7cb3
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  CCoeControl to show a logo at camera application startup
       
    15 *
       
    16 */
       
    17 
       
    18 #include <fbs.h>
       
    19 #include <e32math.h>
       
    20 #include <e32debug.h>
       
    21 #include <AknIconUtils.h>
       
    22 #include <cameraapp.mbg>
       
    23 #include "camlogging.h"
       
    24 #include "camstartuplogo.h"
       
    25 
       
    26 _LIT(KCamBitmapFile, "z:\\resource\\apps\\cameraapp.mif");
       
    27 const TInt KStartupLogoOrdinalPriority( 2 );
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // Two-phased constructor
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CCamStartupLogo* CCamStartupLogo::NewL(CCamStartupLogoController& aController,
       
    34                                        const TRect& aRect)
       
    35     {
       
    36     PRINT(_L("Camera => CCamStartupLogo::NewL"))
       
    37     CCamStartupLogo* self = new (ELeave) CCamStartupLogo(aController, aRect);
       
    38     CleanupStack::PushL(self);
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop(self);
       
    41 
       
    42     PRINT(_L("Camera <= CCamStartupLogo::NewL"))
       
    43     return self;
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // C++ constructor
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CCamStartupLogo::CCamStartupLogo(CCamStartupLogoController& aController,
       
    51                                  const TRect& aRect)
       
    52     : iRect(aRect), iController(aController)
       
    53     {
       
    54     // No implementation needed
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // Destructor
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CCamStartupLogo::~CCamStartupLogo()
       
    62     {
       
    63     iController.RemoveObserver(this);
       
    64 
       
    65     delete iLogo;
       
    66     delete iLogoMask;
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // 2nd phase constructor
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 void CCamStartupLogo::ConstructL()
       
    74     {
       
    75     PRINT(_L("Camera => CCamStartupLogo::ConstructL"))
       
    76 
       
    77     iController.AddObserver(this);
       
    78 
       
    79     if (iController.State() == EStartupLogoVisible)
       
    80         {
       
    81         ShowL();
       
    82         }
       
    83 
       
    84     PRINT(_L("Camera <= CCamStartupLogo::ConstructL"))
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // CCamStartupLogo::StartupLogoControllerStateChanged
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 void CCamStartupLogo::StartupLogoControllerStateChanged(
       
    92     TStartupLogoState aNewState)
       
    93     {
       
    94     PRINT(_L("Camera => CCamStartupLogo::StartupLogoControllerStateChanged"))
       
    95 
       
    96     if (aNewState == EStartupLogoNotVisible)
       
    97         {
       
    98         Hide();
       
    99         }
       
   100     else if (aNewState == EStartupLogoVisible)
       
   101         {
       
   102         TRAP_IGNORE(ShowL()); 
       
   103         }
       
   104     else
       
   105         {
       
   106         PRINT(_L("Camera <> StartupLogoControllerStateChanged - unknown state"))
       
   107         }
       
   108 
       
   109     PRINT(_L("Camera <= CCamStartupLogo::StartupLogoControllerStateChanged"))
       
   110     }
       
   111 
       
   112 // ---------------------------------------------------------------------------
       
   113 // CCamStartupLogo::ShowL
       
   114 // ---------------------------------------------------------------------------
       
   115 //
       
   116 void CCamStartupLogo::ShowL()
       
   117     {
       
   118     PRINT(_L("Camera => CCamStartupLogo::ShowL"))
       
   119 
       
   120     if (!iLogo || !iLogoMask)
       
   121         {
       
   122         delete iLogo;
       
   123         iLogo = NULL;
       
   124         delete iLogoMask;
       
   125         iLogoMask = NULL;
       
   126 
       
   127         TTime t0;
       
   128         t0.UniversalTime();
       
   129 
       
   130         AknIconUtils::CreateIconL(iLogo,
       
   131                                   iLogoMask,
       
   132                                   KCamBitmapFile,
       
   133                                   EMbmCameraappQgn_menu_cams,
       
   134                                   EMbmCameraappQgn_menu_cams_mask);
       
   135         
       
   136         TSize logoSize(iRect.Size().iWidth/2, iRect.Size().iHeight/2);
       
   137         AknIconUtils::SetSize(iLogo, logoSize);
       
   138 
       
   139         TTime t1;
       
   140         t1.UniversalTime();
       
   141 
       
   142         PRINT1(_L("Camera <> Startup icon load took %d us"), I64LOW(t1.MicroSecondsFrom(t0).Int64()))
       
   143         }
       
   144 
       
   145     if (!iWindowCreated)
       
   146         {
       
   147         CreateWindowL();
       
   148         iWindowCreated = ETrue;
       
   149         }
       
   150 
       
   151     if (!IsActivated())
       
   152         {
       
   153         ActivateL();
       
   154         }
       
   155 
       
   156     SetExtentToWholeScreen();
       
   157 
       
   158     MakeVisible(ETrue);
       
   159     RDrawableWindow* window = DrawableWindow();
       
   160     if (window)
       
   161         {
       
   162         window->SetOrdinalPosition(0, KStartupLogoOrdinalPriority);
       
   163         }
       
   164 
       
   165     PRINT(_L("Camera <= CCamStartupLogo::ShowL"))
       
   166     }
       
   167 
       
   168 // ---------------------------------------------------------------------------
       
   169 // CCamStartupLogo::Hide
       
   170 // ---------------------------------------------------------------------------
       
   171 //
       
   172 void CCamStartupLogo::Hide()
       
   173     {
       
   174     PRINT(_L("Camera => CCamStartupLogo::Hide"))
       
   175 
       
   176     MakeVisible(EFalse);
       
   177 
       
   178     if (iWindowCreated)
       
   179         {
       
   180         CloseWindow();
       
   181         iWindowCreated = EFalse;
       
   182         }
       
   183 
       
   184     delete iLogo;
       
   185     iLogo = NULL;
       
   186     delete iLogoMask;
       
   187     iLogoMask = NULL;
       
   188 
       
   189     PRINT(_L("Camera <= CCamStartupLogo::Hide"))
       
   190     }
       
   191 
       
   192 // ---------------------------------------------------------------------------
       
   193 // CCamStartupLogo::Draw
       
   194 // ---------------------------------------------------------------------------
       
   195 //
       
   196 void CCamStartupLogo::Draw(const TRect& /*aRect*/) const
       
   197     {
       
   198     PRINT(_L("Camera <> CCamStartupLogo::Draw"))
       
   199 
       
   200     CWindowGc& gc = SystemGc();
       
   201 
       
   202     gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
       
   203     gc.SetBrushColor(TRgb::Color16MA(0xFF000000)); // opaque black
       
   204     gc.SetPenStyle(CGraphicsContext::ENullPen);
       
   205     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   206     gc.DrawRect(Rect());
       
   207 
       
   208     if (iLogo && iLogoMask)
       
   209         {
       
   210         TSize logoSize(iLogo->SizeInPixels());
       
   211         TPoint logoTl(iRect.Center().iX - logoSize.iWidth / 2,
       
   212                       iRect.Center().iY - logoSize.iHeight / 2);
       
   213         gc.BitBltMasked(logoTl, iLogo, TRect(logoSize), iLogoMask, EFalse);
       
   214         }
       
   215     }
       
   216