phoneapp/phoneuiview/src/cphonedialerview.cpp
changeset 0 5f000ab63145
child 9 8871b09be73b
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2008 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:  The dialer view of PhoneUI
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "phoneconstants.h"
       
    21 #include "cphonedialerview.h"
       
    22 
       
    23 #include <eikenv.h>
       
    24 #include <eikapp.h> 
       
    25 #include <eikappui.h>
       
    26 #include <eikcmobs.h>
       
    27 
       
    28 #include <w32std.h>          // iWindowSrvSession
       
    29 
       
    30 #include <eikimage.h>
       
    31 #include <coemain.h>
       
    32 #include <gulutil.h>         // DrawUtils, egul.lib 
       
    33 #include <aknappui.h>
       
    34 #include <AknsLayeredBackgroundControlContext.h>
       
    35 #include <AknsDrawUtils.h>
       
    36 #include <AknsUtils.h>
       
    37 
       
    38 #include "cphonestatuspane.h"
       
    39 #include "tphonecmdparambitmap.h"
       
    40 #include "phonelogger.h"
       
    41 
       
    42 #include <AknUtils.h> // needed for AKN_LAF_COLOR in 3.0 environment
       
    43 
       
    44 
       
    45 #include "phoneui.hrh"
       
    46 #include "phoneviewcommanddefinitions.h"
       
    47 // Scalable UI 
       
    48 #include <aknlayout.cdl.h>
       
    49 #include <layoutmetadata.cdl.h>
       
    50 #include <aknlayoutscalable_apps.cdl.h>
       
    51 #include <aknlayoutscalable_avkon.cdl.h>
       
    52 #include <AknStatuspaneUtils.h>
       
    53 
       
    54 enum TPhoneBgLayers
       
    55     {
       
    56     EPhoneBgFirstLayer          = 0,
       
    57     EPhoneBgLayersN             = 1
       
    58     };
       
    59 
       
    60 #define LSC_VARIETY   0
       
    61 #define PRT_VARIETY   6
       
    62 
       
    63 // ================= MEMBER FUNCTIONS =======================
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CPhoneDialerView::CPhoneDialerView
       
    67 // C++ default constructor can NOT contain any code, that
       
    68 // might leave.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 CPhoneDialerView::CPhoneDialerView() :
       
    72     iSecurityMode ( EFalse )
       
    73     {
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CPhoneDialerView::ConstructL
       
    78 // Symbian 2nd phase constructor can leave.
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 void CPhoneDialerView::ConstructL( TRect aRect )
       
    82     {
       
    83     // Create background control context for skins.
       
    84     iBgContext = CAknsLayeredBackgroundControlContext::NewL(
       
    85         KAknsIIDQsnBgScreen, aRect, ETrue /*Parent absolute*/,
       
    86         EPhoneBgLayersN );
       
    87 
       
    88     CreateWindowL();
       
    89     DrawableWindow()->SetPointerGrab( ETrue );
       
    90 
       
    91     SetRect( aRect );
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CPhoneDialerView::NewL
       
    96 // Two-phased constructor.
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 CPhoneDialerView* CPhoneDialerView::NewL( TRect aRect )
       
   100     {
       
   101     CPhoneDialerView* self = new ( ELeave ) CPhoneDialerView();
       
   102     
       
   103     CleanupStack::PushL( self );
       
   104     self->ConstructL( aRect );
       
   105     CleanupStack::Pop( self );
       
   106     return self;
       
   107     }
       
   108 
       
   109 // Destructor
       
   110 CPhoneDialerView::~CPhoneDialerView()
       
   111     {
       
   112      __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneDialerView::~CPhoneDialerView");
       
   113     delete iBgContext;
       
   114     iRegion.Close();
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CPhoneDialerView::ViewId
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 TVwsViewId CPhoneDialerView::ViewId() const
       
   122     {
       
   123     TVwsViewId id( 
       
   124         iEikonEnv->EikAppUi()->Application()->AppDllUid(), 
       
   125         KUidViewId );
       
   126     return id;
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CPhoneDialerView::ViewActivatedL
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 void CPhoneDialerView::ViewActivatedL( 
       
   134     const TVwsViewId& /*aPrevViewId*/, 
       
   135     TUid /*aCustomMessageId*/, 
       
   136     const TDesC8& /*aCustomMessage*/ )
       
   137     {
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CPhoneDialerView::ViewDeactivated
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 void CPhoneDialerView::ViewDeactivated()
       
   145     {
       
   146     }
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // CPhoneDialerView::SetControl
       
   150 // 
       
   151 // Change the control. 
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 void CPhoneDialerView::SetControl( CCoeControl* aControl )
       
   155     {
       
   156     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneDialerView::SetControl()");
       
   157     iControl = aControl;
       
   158     UpdateControlRect();
       
   159     iControl->MakeVisible( ETrue );
       
   160     }
       
   161 
       
   162     
       
   163 // -----------------------------------------------------------------------------
       
   164 // CPhoneDialerView::Control
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 CCoeControl* CPhoneDialerView::Control() const
       
   168     {
       
   169     return iControl;    
       
   170     }    
       
   171     
       
   172 // -----------------------------------------------------------------------------
       
   173 // CPhoneDialerView::ComponentControl
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 CCoeControl* CPhoneDialerView::ComponentControl( TInt /*aIndex*/ ) const
       
   177     {
       
   178     return iControl;        
       
   179     }
       
   180     
       
   181 // -----------------------------------------------------------------------------
       
   182 // CPhoneDialerView::CountComponentControls
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 TInt CPhoneDialerView::CountComponentControls() const
       
   186     {
       
   187     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneDialerView::CountComponentControls()");
       
   188     TInt count = 0;
       
   189 
       
   190     if ( iControl )
       
   191         {
       
   192         count = 1;
       
   193         }
       
   194 
       
   195     return count;
       
   196     }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CPhoneDialerView::MopSupplyObject
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 TTypeUid::Ptr CPhoneDialerView::MopSupplyObject( TTypeUid aId )
       
   203     {
       
   204     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneDialerView::MopSupplyObject()");
       
   205     // Required during rendering of the background skin in Draw()
       
   206     if (aId.iUid == MAknsControlContext::ETypeId)
       
   207         {
       
   208         return MAknsControlContext::SupplyMopObject( aId, iBgContext );
       
   209         }
       
   210     return CCoeControl::MopSupplyObject( aId );
       
   211     }
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 // CPhoneDialerView::SetRect
       
   215 // -----------------------------------------------------------------------------
       
   216 //    
       
   217 void CPhoneDialerView::SetRect( const TRect &aRect )
       
   218     {
       
   219     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneDialerView::SetRect()");
       
   220     if ( !AknLayoutUtils::PenEnabled() )
       
   221         {
       
   222         CCoeControl::SetRect( aRect );
       
   223         }
       
   224     else
       
   225         {
       
   226         if ( iSecurityMode )
       
   227             {
       
   228             // In security mode aRect is ok.
       
   229             CCoeControl::SetRect( aRect );    
       
   230             iControlRect = Rect();
       
   231             }
       
   232         else
       
   233             {
       
   234             TAknLayoutRect viewRect;
       
   235             
       
   236             TRect screenRect;
       
   237             AknLayoutUtils::LayoutMetricsRect( 
       
   238                 AknLayoutUtils::EScreen,
       
   239                 screenRect  );    
       
   240 
       
   241             // dialer view
       
   242             viewRect.LayoutRect( 
       
   243                 screenRect, 
       
   244                 TAknWindowComponentLayout::Compose(
       
   245                     AknLayoutScalable_Avkon::application_window( 0 ),
       
   246                     AknLayoutScalable_Avkon::main_pane( 7 ) ) );
       
   247 
       
   248             CCoeControl::SetRect( viewRect.Rect() );    
       
   249             
       
   250             TInt variety ( PRT_VARIETY ) ; // portrait
       
   251             if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
   252                 {
       
   253                 variety = LSC_VARIETY;
       
   254                 }
       
   255             
       
   256             // reduce toolbar
       
   257             TAknLayoutRect toolbarRect;
       
   258             toolbarRect.LayoutRect( 
       
   259                 screenRect, 
       
   260                 TAknWindowComponentLayout::Compose(
       
   261                 AknLayoutScalable_Avkon::application_window( 0 ),
       
   262                 AknLayoutScalable_Avkon::area_side_right_pane( variety ) ) );
       
   263             
       
   264             if ( toolbarRect.Rect().Intersects( viewRect.Rect() ) )
       
   265                 {
       
   266                 iControlRect = Rect();
       
   267                 if ( variety == PRT_VARIETY ) // portrait
       
   268                     {
       
   269                     iControlRect.iBr.iY -= toolbarRect.Rect().Height();
       
   270                     }
       
   271                 else
       
   272                     {
       
   273                     iControlRect.iBr.iX -= toolbarRect.Rect().Width();
       
   274                     }
       
   275                 }
       
   276             else
       
   277                 {
       
   278                 iControlRect = Rect();    
       
   279                 }                            
       
   280             }                
       
   281         }        
       
   282     }
       
   283 
       
   284 // -----------------------------------------------------------------------------
       
   285 // CPhoneDialerView::Draw
       
   286 // -----------------------------------------------------------------------------
       
   287 //
       
   288 void CPhoneDialerView::Draw(  const TRect& aRect ) const
       
   289     {
       
   290     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneDialerView::Draw()");
       
   291     TRect rect = Rect();
       
   292 
       
   293     if ( !rect.iTl.iY )
       
   294         {
       
   295         CWindowGc& gc = SystemGc();
       
   296         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   297         MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   298         
       
   299         if ( iSecurityMode || 
       
   300             !AknsDrawUtils::Background( skin, cc, this, gc, aRect ) )
       
   301             {
       
   302             gc.SetPenStyle(CGraphicsContext::ENullPen);
       
   303             gc.SetBrushColor( AKN_LAF_COLOR( 0 ) ); // 0 for white
       
   304             gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   305             gc.DrawRect( aRect ); 
       
   306             }
       
   307         }
       
   308     }
       
   309 
       
   310 // -----------------------------------------------------------------------------
       
   311 // CPhoneDialerView::HandlePointerEventL
       
   312 // -----------------------------------------------------------------------------
       
   313 //
       
   314 void CPhoneDialerView::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   315     {
       
   316     // Calling base class implementation
       
   317     CCoeControl::HandlePointerEventL( aPointerEvent );    
       
   318     }
       
   319 
       
   320 // -----------------------------------------------------------------------------
       
   321 // CPhoneDialerView::ActivateL
       
   322 // -----------------------------------------------------------------------------
       
   323 //
       
   324 void CPhoneDialerView::ActivateL()
       
   325     {
       
   326     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneDialerView::ActivateL()");
       
   327     CCoeControl::ActivateL();
       
   328     }
       
   329 
       
   330 // -----------------------------------------------------------------------------
       
   331 // CPhoneDialerView::SizeChanged()
       
   332 // 
       
   333 // Expects that the controls are initialised otherwise.
       
   334 // -----------------------------------------------------------------------------
       
   335 //
       
   336 void CPhoneDialerView::SizeChanged()
       
   337     {
       
   338     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneDialerView::SizeChanged()");
       
   339     AknsUtils::RegisterControlPosition( this );
       
   340 
       
   341     TRect screen;
       
   342     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen );    
       
   343     iBgContext->SetLayerImage( EPhoneBgFirstLayer, KAknsIIDQsnBgScreen );
       
   344     iBgContext->SetParentPos( screen.iTl );
       
   345     iBgContext->SetLayerRect( EPhoneBgFirstLayer, screen ) ;
       
   346 
       
   347     UpdateControlRect();
       
   348     }
       
   349 
       
   350 // -----------------------------------------------------------------------------
       
   351 // CPhoneDialerView::PositionChanged
       
   352 // -----------------------------------------------------------------------------
       
   353 //
       
   354 void CPhoneDialerView::PositionChanged()
       
   355     {
       
   356     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneDialerView::PositionChanged()");
       
   357     AknsUtils::RegisterControlPosition( this );
       
   358     }
       
   359     
       
   360 // -----------------------------------------------------------------------------
       
   361 // CPhoneDialerView::FocusChanged
       
   362 // -----------------------------------------------------------------------------
       
   363 //    
       
   364 void CPhoneDialerView::FocusChanged( TDrawNow /*aDrawNow*/ )
       
   365     {
       
   366     iControl->SetFocus( IsFocused () );
       
   367     }    
       
   368 
       
   369 // -----------------------------------------------------------------------------
       
   370 // CPhoneDialerView::UpdateControlRect
       
   371 // -----------------------------------------------------------------------------
       
   372 //
       
   373 void CPhoneDialerView::UpdateControlRect()
       
   374     {    
       
   375     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneDialerView::UpdateControlRect()");
       
   376     if ( iControl )
       
   377         {
       
   378         if ( !AknLayoutUtils::PenEnabled() )
       
   379             {
       
   380             if ( Rect() != iControl->Rect() )
       
   381                 {
       
   382                 iControl->SetRect( Rect() );
       
   383                 }    
       
   384             }
       
   385         else
       
   386             {
       
   387             if ( iControlRect != iControl->Rect() )
       
   388                 {
       
   389                 iControl->SetRect( iControlRect );
       
   390                 }    
       
   391             } 
       
   392         }
       
   393     }
       
   394 
       
   395 // -----------------------------------------------------------------------------
       
   396 // CPhoneDialerView::HandleResourceChangeL
       
   397 // -----------------------------------------------------------------------------
       
   398 //
       
   399 void CPhoneDialerView::HandleResourceChange( TInt aType )
       
   400     {
       
   401     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneDialerView::HandleResourceChange()");
       
   402 
       
   403     if ( aType == KAknsMessageSkinChange || 
       
   404          aType == KEikDynamicLayoutVariantSwitch )
       
   405         {
       
   406         DrawDeferred();
       
   407         }
       
   408     }
       
   409 
       
   410 // -----------------------------------------------------------------------------
       
   411 // CPhoneDialerView::SetSecurityMode
       
   412 // -----------------------------------------------------------------------------
       
   413 //
       
   414 void CPhoneDialerView::SetSecurityMode ( TBool aStatus )
       
   415     {
       
   416     if ( iSecurityMode != aStatus ) 
       
   417         {
       
   418         iSecurityMode = aStatus;
       
   419         SizeChanged();    
       
   420         }
       
   421     }
       
   422     
       
   423 // -----------------------------------------------------------------------------
       
   424 // CPhoneDialerView::IsSecurityMode
       
   425 // -----------------------------------------------------------------------------
       
   426 //
       
   427 TBool CPhoneDialerView::IsSecurityMode()    
       
   428     {
       
   429     return iSecurityMode;
       
   430     }
       
   431 
       
   432 // End of File