phoneapp/phoneuiview/src/cphonedialerview.cpp
branchCompilerCompatibility
changeset 13 2411cd0e2ad6
parent 9 8871b09be73b
child 14 24062c24fe38
equal deleted inserted replaced
11:abbe9afab2af 13:2411cd0e2ad6
     1 /*
     1 /*
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2008 - 2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    55     {
    55     {
    56     EPhoneBgFirstLayer          = 0,
    56     EPhoneBgFirstLayer          = 0,
    57     EPhoneBgLayersN             = 1
    57     EPhoneBgLayersN             = 1
    58     };
    58     };
    59 
    59 
    60 #define LSC_VARIETY   0
       
    61 #define PRT_VARIETY   6
       
    62 
       
    63 // ================= MEMBER FUNCTIONS =======================
    60 // ================= MEMBER FUNCTIONS =======================
    64 
    61 
    65 // -----------------------------------------------------------------------------
    62 // -----------------------------------------------------------------------------
    66 // CPhoneDialerView::CPhoneDialerView
    63 // CPhoneDialerView::CPhoneDialerView
    67 // C++ default constructor can NOT contain any code, that
    64 // C++ default constructor can NOT contain any code, that
    86         EPhoneBgLayersN );
    83         EPhoneBgLayersN );
    87 
    84 
    88     CreateWindowL();
    85     CreateWindowL();
    89     DrawableWindow()->SetPointerGrab( ETrue );
    86     DrawableWindow()->SetPointerGrab( ETrue );
    90 
    87 
    91     SetRect( aRect );
    88     SetComponentsToInheritVisibility( ETrue );
    92     }
    89     }
    93 
    90 
    94 // -----------------------------------------------------------------------------
    91 // -----------------------------------------------------------------------------
    95 // CPhoneDialerView::NewL
    92 // CPhoneDialerView::NewL
    96 // Two-phased constructor.
    93 // Two-phased constructor.
   212 
   209 
   213 // -----------------------------------------------------------------------------
   210 // -----------------------------------------------------------------------------
   214 // CPhoneDialerView::SetRect
   211 // CPhoneDialerView::SetRect
   215 // -----------------------------------------------------------------------------
   212 // -----------------------------------------------------------------------------
   216 //    
   213 //    
   217 void CPhoneDialerView::SetRect( const TRect &aRect )
   214 void CPhoneDialerView::SetRect( const TRect& aRect )
   218     {
   215     {
   219     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneDialerView::SetRect()");
   216     CCoeControl::SetRect( aRect );
   220     if ( !AknLayoutUtils::PenEnabled() )
   217     iControlRect = Rect();
   221         {
   218     // Forward size change to the control only if we are visible. Otherwise the
   222         CCoeControl::SetRect( aRect );
   219     // control rect is just srored and relayed to control when we do become
   223         }
   220     // visible. This way we can avoid unnecessary relayout work for example when
   224     else
   221     // status bar size changes or screen is rotated while in-call ui is active.
   225         {
   222     if ( IsVisible() )
   226         if ( iSecurityMode )
   223         {
   227             {
   224         UpdateControlRect();
   228             // In security mode aRect is ok.
   225         }
   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     }
   226     }
   283 
   227 
   284 // -----------------------------------------------------------------------------
   228 // -----------------------------------------------------------------------------
   285 // CPhoneDialerView::Draw
   229 // CPhoneDialerView::Draw
   286 // -----------------------------------------------------------------------------
   230 // -----------------------------------------------------------------------------
   287 //
   231 //
   288 void CPhoneDialerView::Draw(  const TRect& aRect ) const
   232 void CPhoneDialerView::Draw( const TRect& aRect ) const
   289     {
   233     {
   290     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneDialerView::Draw()");
   234     __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneDialerView::Draw()");
   291     TRect rect = Rect();
   235     TRect rect = Rect();
   292 
   236 
   293     if ( !rect.iTl.iY )
   237     if ( !rect.iTl.iY )
   341     TRect screen;
   285     TRect screen;
   342     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen );    
   286     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen );    
   343     iBgContext->SetLayerImage( EPhoneBgFirstLayer, KAknsIIDQsnBgScreen );
   287     iBgContext->SetLayerImage( EPhoneBgFirstLayer, KAknsIIDQsnBgScreen );
   344     iBgContext->SetParentPos( screen.iTl );
   288     iBgContext->SetParentPos( screen.iTl );
   345     iBgContext->SetLayerRect( EPhoneBgFirstLayer, screen ) ;
   289     iBgContext->SetLayerRect( EPhoneBgFirstLayer, screen ) ;
   346 
       
   347     UpdateControlRect();
       
   348     }
   290     }
   349 
   291 
   350 // -----------------------------------------------------------------------------
   292 // -----------------------------------------------------------------------------
   351 // CPhoneDialerView::PositionChanged
   293 // CPhoneDialerView::PositionChanged
   352 // -----------------------------------------------------------------------------
   294 // -----------------------------------------------------------------------------
   385         else
   327         else
   386             {
   328             {
   387             if ( iControlRect != iControl->Rect() )
   329             if ( iControlRect != iControl->Rect() )
   388                 {
   330                 {
   389                 iControl->SetRect( iControlRect );
   331                 iControl->SetRect( iControlRect );
   390                 }    
   332                 }
   391             } 
   333             } 
   392         }
   334         }
   393     }
   335     }
   394 
   336 
   395 // -----------------------------------------------------------------------------
   337 // -----------------------------------------------------------------------------
   406         DrawDeferred();
   348         DrawDeferred();
   407         }
   349         }
   408     }
   350     }
   409 
   351 
   410 // -----------------------------------------------------------------------------
   352 // -----------------------------------------------------------------------------
       
   353 // CPhoneDialerView::MakeVisible
       
   354 // -----------------------------------------------------------------------------
       
   355 //
       
   356 void CPhoneDialerView::MakeVisible( TBool aVisible )
       
   357     {
       
   358     if ( aVisible )
       
   359         {
       
   360         // Deferred control rect size update before view becomes visible.
       
   361         // We don't relay size changes to our control while view is invisible
       
   362         // to avoid unnecessary layout recalculations.
       
   363         UpdateControlRect();
       
   364         }
       
   365     CCoeControl::MakeVisible( aVisible );
       
   366     }
       
   367 
       
   368 // -----------------------------------------------------------------------------
   411 // CPhoneDialerView::SetSecurityMode
   369 // CPhoneDialerView::SetSecurityMode
   412 // -----------------------------------------------------------------------------
   370 // -----------------------------------------------------------------------------
   413 //
   371 //
   414 void CPhoneDialerView::SetSecurityMode ( TBool aStatus )
   372 void CPhoneDialerView::SetSecurityMode ( TBool aStatus )
   415     {
   373     {