uifw/EikStd/coctlsrc/AknToolbar.cpp
branchRCL_3
changeset 15 c52421ed5f07
parent 8 71dd06cfe933
child 17 a1caeb42b3a3
equal deleted inserted replaced
13:a8834a2e9a96 15:c52421ed5f07
     1 /*
     1 /*
     2 * Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2005-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".
   249     {
   249     {
   250     aReader.ReadInt8(); //version, not used currently
   250     aReader.ReadInt8(); //version, not used currently
   251     aReader.ReadInt8();  //lines, not used currently
   251     aReader.ReadInt8();  //lines, not used currently
   252     iFlags = aReader.ReadInt32();
   252     iFlags = aReader.ReadInt32();
   253 
   253 
   254     TBool enableTransparency = CAknEnv::Static()->TransparencyEnabled() && 
   254     TBool enableTransparency = 
   255         ( ( !( iFlags & KAknToolbarFixed ) && 
   255         ( ( !( iFlags & KAknToolbarFixed ) && 
   256                 !( iFlags & KAknToolbarFloatingUnTransparent ) ) || 
   256                 !( iFlags & KAknToolbarFloatingUnTransparent ) ) || 
   257         ( iFlags & KAknToolbarTransparent && iFlags & KAknToolbarFixed ) ); 
   257         ( iFlags & KAknToolbarTransparent && iFlags & KAknToolbarFixed ) ); 
   258 
   258 
   259 
   259     if ( enableTransparency ) 
   260     if( enableTransparency ) 
       
   261         {
   260         {
   262         Window().SetRequiredDisplayMode( EColor16MA ); // Without this, ACT does not work in all cases in HW
   261         Window().SetRequiredDisplayMode( EColor16MA ); // Without this, ACT does not work in all cases in HW
   263         TInt err = Window().SetTransparencyAlphaChannel();
   262         EnableWindowTransparency();
   264 
   263         }
   265         if ( err == KErrNone ) // it should all ways be true in NGA
   264 
   266             {
   265     TRect dummyRect( 0, 0, 0, 0 );
   267             // Set the window initially completely transparent. This needs to be called only once.
   266     iFrameContext = CAknsFrameBackgroundControlContext::NewL(
   268             Window().SetBackgroundColor(~0);
   267         KAknsIIDQsnFrPopupSub, 
   269             }
   268         dummyRect,
   270         }
   269         dummyRect,
   271 
   270         ( iFlags & KAknToolbarFixed ) ? ETrue : EFalse );  
   272 
       
   273 
       
   274     iFrameContext = CAknsFrameBackgroundControlContext::NewL( KAknsIIDQsnFrPopupSub, 
       
   275             TRect(), TRect(), ( iFlags & KAknToolbarFixed )? ETrue : EFalse );  
       
   276 
   271 
   277     iBgContext = CAknsBasicBackgroundControlContext::NewL(
   272     iBgContext = CAknsBasicBackgroundControlContext::NewL(
   278         KAknsIIDQsnBgScreen, TRect(), ETrue );
   273         KAknsIIDQsnBgScreen, dummyRect, ETrue );
   279 
   274 
   280     SetWithSliding( ETrue ); 
   275     SetWithSliding( ETrue ); 
   281 
   276 
   282     TInt softkeyResource = aReader.ReadUint32(); //softkeys
   277     TInt softkeyResource = aReader.ReadUint32(); //softkeys
   283 
   278 
   312     
   307     
   313     // If toolbar is fixed need to set size for toolbar so that it can reduce 
   308     // If toolbar is fixed need to set size for toolbar so that it can reduce 
   314     // the rects correctly. 
   309     // the rects correctly. 
   315     if ( iFlags & KAknToolbarFixed )
   310     if ( iFlags & KAknToolbarFixed )
   316         {
   311         {
   317         if ( iFlags & KAknToolbarDefault )
   312         SetFocusing( EFalse );
   318             {
   313         
   319             SetDimmed( ETrue ); 
   314         // Don't set the size and position for default toolbar (never shown).
   320             }
   315         if ( !( iFlags & KAknToolbarDefault ) )
   321         SetFocusing( EFalse ); 
   316             {
   322         SetRect( CalculateSizeAndPosition() ); 
   317             SetRect( CalculateSizeAndPosition() );
   323         }
   318             }
   324 
   319         }
   325     AdjustAllButtons();
   320 
       
   321     // Unnecessary for default toolbar (never shown).
       
   322     if ( !( iFlags & KAknToolbarDefault ) )
       
   323         {
       
   324         AdjustAllButtons();
       
   325         }
   326     }
   326     }
   327 
   327 
   328 // -----------------------------------------------------------------------------
   328 // -----------------------------------------------------------------------------
   329 // CAknToolbar::ConstructFromResourceL
   329 // CAknToolbar::ConstructFromResourceL
   330 // Constructs controls from a resource file.
   330 // Constructs controls from a resource file.
   411         else
   411         else
   412             {
   412             {
   413             iInternalFlags.Clear( EFixedShown );
   413             iInternalFlags.Clear( EFixedShown );
   414             }
   414             }
   415 
   415 
   416         if ( visible && ( !AknLayoutUtils::PenEnabled() || 
   416         if ( visible &&
   417             ( !Layout_Meta_Data::IsLandscapeOrientation() && iFlags & KAknToolbarDefault ) ) )
   417              !Layout_Meta_Data::IsLandscapeOrientation() &&
       
   418              iFlags & KAknToolbarDefault )
   418             {
   419             {
   419             return; 
   420             return; 
   420             }
   421             }
   421 
   422 
   422         }
   423         }
   545 // The position of the top left corner should be set in advance.
   546 // The position of the top left corner should be set in advance.
   546 // -----------------------------------------------------------------------------
   547 // -----------------------------------------------------------------------------
   547 //
   548 //
   548 void CAknToolbar::ShowToolbarL()
   549 void CAknToolbar::ShowToolbarL()
   549     {
   550     {
   550     if ( iFlags & KAknToolbarFixed &&
   551     if ( iFlags & KAknToolbarFixed && iFlags & KAknToolbarDefault )
   551          ( !AknLayoutUtils::PenEnabled() ||
       
   552            iFlags & KAknToolbarDefault ) )
       
   553         {
   552         {
   554         if ( IsVisible() )
   553         if ( IsVisible() )
   555             {
   554             {
   556             MakeVisible( EFalse );
   555             MakeVisible( EFalse );
   557             }
   556             }
   590             startPos.iX = -rect.Size().iWidth;
   589             startPos.iX = -rect.Size().iWidth;
   591             }
   590             }
   592         SetExtent( startPos, rect.Size() );
   591         SetExtent( startPos, rect.Size() );
   593         UpdateControlPositions(); 
   592         UpdateControlPositions(); 
   594 
   593 
   595         TBool redrawStoreEnabled(EFalse);
       
   596         if( !CAknEnv::Static()->TransparencyEnabled() )
       
   597             {
       
   598             redrawStoreEnabled = Window().IsRedrawStoreEnabled();
       
   599             }
       
   600 
       
   601         CTouchToolbarData* data = CheckRegistration( this );      
   594         CTouchToolbarData* data = CheckRegistration( this );      
   602         if ( data && !(iFlags & KAknToolbarFixed) && iAvkonAppUi->IsForeground() )
   595         if ( data && !(iFlags & KAknToolbarFixed) && iAvkonAppUi->IsForeground() )
   603             {
   596             {
   604             data->SetBetweenRegisterAndBegin( EFalse );
   597             data->SetBetweenRegisterAndBegin( EFalse );
   605             
   598             
   633             else
   626             else
   634                 {
   627                 {
   635                 CAknTransitionUtils::RemoveData( reinterpret_cast<TInt>( this ) );
   628                 CAknTransitionUtils::RemoveData( reinterpret_cast<TInt>( this ) );
   636                 delete data;
   629                 delete data;
   637                 GfxTransEffect::Deregister( this );
   630                 GfxTransEffect::Deregister( this );
   638                 }
       
   639 
       
   640             if ( !CAknEnv::Static()->TransparencyEnabled() && redrawStoreEnabled )
       
   641                 {
       
   642                 Window().EnableRedrawStore( ETrue );
       
   643                 }
   631                 }
   644             }
   632             }
   645 
   633 
   646         // notify observer, for example touch pane, that toolbar was shown
   634         // notify observer, for example touch pane, that toolbar was shown
   647         if ( Observer() )
   635         if ( Observer() )
   743 //
   731 //
   744 void CAknToolbar::HideToolbarL()
   732 void CAknToolbar::HideToolbarL()
   745     {
   733     {
   746     if ( !iInternalFlags.IsSet( EShown ) ) // nothing to hide
   734     if ( !iInternalFlags.IsSet( EShown ) ) // nothing to hide
   747         {
   735         {
   748         if ( iFlags & KAknToolbarDefault && !AknLayoutUtils::PenEnabled()
       
   749               && IsVisible() )
       
   750             {
       
   751             MakeVisible( EFalse );
       
   752             }
       
   753         return;
   736         return;
   754         }
   737         }
   755 
   738 
   756    if ( iIdle && iIdle->IsActive() ) 
   739    if ( iIdle && iIdle->IsActive() ) 
   757         {
   740         {
  1198                 iInternalFlags.Clear( EFixedShown );
  1181                 iInternalFlags.Clear( EFixedShown );
  1199                 }
  1182                 }
  1200             return;
  1183             return;
  1201             }
  1184             }
  1202         }
  1185         }
  1203         
  1186 
  1204     if ( aType == KAknToolbarSetVisible && iFlags & KAknToolbarDefault 
  1187     if ( aType == KAknToolbarSetVisible && !IsShown() )
  1205             && !AknLayoutUtils::PenEnabled() )
       
  1206         {
       
  1207         return; 
       
  1208         }
       
  1209     else if ( aType == KAknToolbarSetVisible && !IsShown() )
       
  1210         {
  1188         {
  1211         iInternalFlags.Set( ECalledFromFW );
  1189         iInternalFlags.Set( ECalledFromFW );
  1212         iInternalFlags.Clear( EDrawBackground ); 
  1190         iInternalFlags.Clear( EDrawBackground ); 
  1213         SetToolbarVisibility(ETrue, EFalse);
  1191         SetToolbarVisibility(ETrue, EFalse);
  1214         iInternalFlags.Clear( ECalledFromFW );
  1192         iInternalFlags.Clear( ECalledFromFW );
  1233             {
  1211             {
  1234             CAknToolbarItem* item = iVisibleItems[ i ];
  1212             CAknToolbarItem* item = iVisibleItems[ i ];
  1235             CAknButton* button = static_cast<CAknButton*>( item->Control() ); 
  1213             CAknButton* button = static_cast<CAknButton*>( item->Control() ); 
  1236             button->ResetState();
  1214             button->ResetState();
  1237             }
  1215             }
  1238         if ( iFlags & KAknToolbarDefault && !AknLayoutUtils::PenEnabled() && IsVisible() )
  1216 
  1239             {
  1217         if ( iFlags & KAknToolbarFixed )
  1240             TRAP_IGNORE( HideToolbarL() ); 
  1218             {
  1241             return; 
  1219             if ( Layout_Meta_Data::IsLandscapeOrientation() )
  1242             }
       
  1243         else if ( iFlags & KAknToolbarFixed )
       
  1244             {
       
  1245             if ( Layout_Meta_Data::IsLandscapeOrientation() && AknLayoutUtils::PenEnabled() )
       
  1246                 {
  1220                 {
  1247                 iOrientation = EAknOrientationVertical; 
  1221                 iOrientation = EAknOrientationVertical; 
  1248                 if ( ( iInternalFlags.IsSet( EFixedShown ) 
  1222                 if ( ( iInternalFlags.IsSet( EFixedShown ) 
  1249                     || ( iInternalFlags.IsSet( EItemsHidden )
  1223                     || ( iInternalFlags.IsSet( EItemsHidden )
  1250                     && iInternalFlags.IsSet( EAppOverrideVisibility ) ) )
  1224                     && iInternalFlags.IsSet( EAppOverrideVisibility ) ) )
  1260                         {
  1234                         {
  1261                         ShowViaIdle();                          
  1235                         ShowViaIdle();                          
  1262                         }
  1236                         }
  1263                     }
  1237                     }
  1264                 }
  1238                 }
  1265             else if ( !( iFlags & KAknToolbarDefault ) && AknLayoutUtils::PenEnabled() )
  1239             else if ( !( iFlags & KAknToolbarDefault ) )
  1266                 {
  1240                 {
  1267                 iOrientation = EAknOrientationHorizontal; 
  1241                 iOrientation = EAknOrientationHorizontal; 
  1268                 if ( iInternalFlags.IsSet( EFixedShown ) && !iInternalFlags.IsSet( EShown ) )
  1242                 if ( iInternalFlags.IsSet( EFixedShown ) && !iInternalFlags.IsSet( EShown ) )
  1269                     {
  1243                     {
  1270                     // If showing toolbar because HideItemsAndDrawOnlyBackground( EFalse )
  1244                     // If showing toolbar because HideItemsAndDrawOnlyBackground( EFalse )
  1278                         {
  1252                         {
  1279                         ShowViaIdle();
  1253                         ShowViaIdle();
  1280                         }
  1254                         }
  1281                     }
  1255                     }
  1282                 }
  1256                 }
  1283             else if ( ( !AknLayoutUtils::PenEnabled() || iFlags & KAknToolbarDefault ) && iInternalFlags.IsSet( EShown ) )
  1257             else if ( iFlags & KAknToolbarDefault && iInternalFlags.IsSet( EShown ) )
  1284                 {
  1258                 {
  1285                 TRAP_IGNORE( HideToolbarL() ); 
  1259                 TRAP_IGNORE( HideToolbarL() ); 
  1286                 return; 
  1260                 return; 
  1287                 }
  1261                 }
  1288             else
  1262             else
  2381             {
  2355             {
  2382             iFrameContext->SetCenter( KAknsIIDQgnGrafPopupTransCenter ); 
  2356             iFrameContext->SetCenter( KAknsIIDQgnGrafPopupTransCenter ); 
  2383             }
  2357             }
  2384         } 
  2358         } 
  2385 
  2359 
  2386     TRect rect = CalculateSizeAndPosition();
  2360     // Don't set the size and position for default toolbar (never shown).
  2387     // Set focused item again to avoid panic in a case when toolbar has more 
  2361     if ( !( iFlags & KAknToolbarDefault ) )
  2388     // items in previous orientation and some of the items that do not 
  2362         {
  2389     // fit to toolbar in this orientation was focused. 
  2363         TRect rect = CalculateSizeAndPosition();
  2390     if ( IsFocused() )
  2364         // Set focused item again to avoid panic in a case when toolbar has
  2391         {
  2365         // more items in previous orientation and some of the items that do
  2392         TRAP_IGNORE( MoveHighlightL( iFocusedItem, EFalse ) ); 
  2366         // not  fit to toolbar in this orientation was focused. 
  2393         }
  2367         if ( IsFocused() )
  2394 
  2368             {
  2395     if ( iInternalFlags.IsSet( EShown ) )
  2369             TRAP_IGNORE( MoveHighlightL( iFocusedItem, EFalse ) ); 
  2396         {
  2370             }
  2397         if ( !( iFlags & KAknToolbarFlexiblePosition ) )
  2371     
  2398             {
  2372         if ( iInternalFlags.IsSet( EShown ) )
  2399             SetPosition( rect.iTl );
  2373             {
  2400             }
  2374             if ( !( iFlags & KAknToolbarFlexiblePosition ) )
  2401         else 
  2375                 {
  2402             {
  2376                 SetPosition( rect.iTl );
  2403             UpdateControlPositions(); 
  2377                 }
  2404             }
  2378             else 
  2405         SetSize( rect.Size() );
  2379                 {
  2406         DrawDeferred();
  2380                 UpdateControlPositions(); 
       
  2381                 }
       
  2382             SetSize( rect.Size() );
       
  2383             DrawDeferred();
       
  2384             }
  2407         }
  2385         }
  2408     }
  2386     }
  2409 
  2387 
  2410 // -----------------------------------------------------------------------------
  2388 // -----------------------------------------------------------------------------
  2411 // CAknToolbar::NotifyBackgroundChange
  2389 // CAknToolbar::NotifyBackgroundChange
  2637 //    
  2615 //    
  2638 void CAknToolbar::ReduceRect( TRect& aBoundingRect ) const
  2616 void CAknToolbar::ReduceRect( TRect& aBoundingRect ) const
  2639     {
  2617     {
  2640     TBool toolbarNotVisible( !IsShown() && !( iFlags & KAknToolbarDefault ) );
  2618     TBool toolbarNotVisible( !IsShown() && !( iFlags & KAknToolbarDefault ) );
  2641     TBool fixedToolbar( iFlags & KAknToolbarFixed );
  2619     TBool fixedToolbar( iFlags & KAknToolbarFixed );
  2642     TBool landscapeOrientation( Layout_Meta_Data::IsLandscapeOrientation() );
       
  2643     TBool touchEnabled( AknLayoutUtils::PenEnabled() );
       
  2644     TBool defaultContent( iFlags & KAknToolbarDefault );
  2620     TBool defaultContent( iFlags & KAknToolbarDefault );
  2645 
  2621 
  2646     if ( toolbarNotVisible || 
  2622     if ( toolbarNotVisible || 
  2647          !fixedToolbar ||
  2623          !fixedToolbar ||
  2648          ( defaultContent && !landscapeOrientation ) ||
       
  2649          !touchEnabled ||
       
  2650          ( fixedToolbar && defaultContent ) )
  2624          ( fixedToolbar && defaultContent ) )
  2651         {
  2625         {
  2652         return;
  2626         return;
  2653         }
  2627         }
  2654     TRect appRect, toolbarRect; 
  2628     TRect appRect, toolbarRect;