uifw/EikStd/coctlsrc/AknToolbar.cpp
branchRCL_3
changeset 19 aecbbf00d063
parent 17 a1caeb42b3a3
child 20 d48ab3b357f1
--- a/uifw/EikStd/coctlsrc/AknToolbar.cpp	Thu Aug 19 10:11:06 2010 +0300
+++ b/uifw/EikStd/coctlsrc/AknToolbar.cpp	Tue Aug 31 15:28:30 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -251,26 +251,31 @@
     aReader.ReadInt8();  //lines, not used currently
     iFlags = aReader.ReadInt32();
 
-    TBool enableTransparency = 
+    TBool enableTransparency = CAknEnv::Static()->TransparencyEnabled() && 
         ( ( !( iFlags & KAknToolbarFixed ) && 
                 !( iFlags & KAknToolbarFloatingUnTransparent ) ) || 
         ( iFlags & KAknToolbarTransparent && iFlags & KAknToolbarFixed ) ); 
 
-    if ( enableTransparency ) 
+
+    if( enableTransparency ) 
         {
         Window().SetRequiredDisplayMode( EColor16MA ); // Without this, ACT does not work in all cases in HW
-        EnableWindowTransparency();
+        TInt err = Window().SetTransparencyAlphaChannel();
+
+        if ( err == KErrNone ) // it should all ways be true in NGA
+            {
+            // Set the window initially completely transparent. This needs to be called only once.
+            Window().SetBackgroundColor(~0);
+            }
         }
 
-    TRect dummyRect( 0, 0, 0, 0 );
-    iFrameContext = CAknsFrameBackgroundControlContext::NewL(
-        KAknsIIDQsnFrPopupSub, 
-        dummyRect,
-        dummyRect,
-        ( iFlags & KAknToolbarFixed ) ? ETrue : EFalse );  
+
+
+    iFrameContext = CAknsFrameBackgroundControlContext::NewL( KAknsIIDQsnFrPopupSub, 
+            TRect(), TRect(), ( iFlags & KAknToolbarFixed )? ETrue : EFalse );  
 
     iBgContext = CAknsBasicBackgroundControlContext::NewL(
-        KAknsIIDQsnBgScreen, dummyRect, ETrue );
+        KAknsIIDQsnBgScreen, TRect(), ETrue );
 
     SetWithSliding( ETrue ); 
 
@@ -309,20 +314,15 @@
     // the rects correctly. 
     if ( iFlags & KAknToolbarFixed )
         {
-        SetFocusing( EFalse );
-        
-        // Don't set the size and position for default toolbar (never shown).
-        if ( !( iFlags & KAknToolbarDefault ) )
+        if ( iFlags & KAknToolbarDefault )
             {
-            SetRect( CalculateSizeAndPosition() );
+            SetDimmed( ETrue ); 
             }
+        SetFocusing( EFalse ); 
+        SetRect( CalculateSizeAndPosition() ); 
         }
 
-    // Unnecessary for default toolbar (never shown).
-    if ( !( iFlags & KAknToolbarDefault ) )
-        {
-        AdjustAllButtons();
-        }
+    AdjustAllButtons();
     }
 
 // -----------------------------------------------------------------------------
@@ -413,9 +413,8 @@
             iInternalFlags.Clear( EFixedShown );
             }
 
-        if ( visible &&
-             !Layout_Meta_Data::IsLandscapeOrientation() &&
-             iFlags & KAknToolbarDefault )
+        if ( visible && ( !AknLayoutUtils::PenEnabled() || 
+            ( !Layout_Meta_Data::IsLandscapeOrientation() && iFlags & KAknToolbarDefault ) ) )
             {
             return; 
             }
@@ -548,7 +547,9 @@
 //
 void CAknToolbar::ShowToolbarL()
     {
-    if ( iFlags & KAknToolbarFixed && iFlags & KAknToolbarDefault )
+    if ( iFlags & KAknToolbarFixed &&
+         ( !AknLayoutUtils::PenEnabled() ||
+           iFlags & KAknToolbarDefault ) )
         {
         if ( IsVisible() )
             {
@@ -591,6 +592,12 @@
         SetExtent( startPos, rect.Size() );
         UpdateControlPositions(); 
 
+        TBool redrawStoreEnabled(EFalse);
+        if( !CAknEnv::Static()->TransparencyEnabled() )
+            {
+            redrawStoreEnabled = Window().IsRedrawStoreEnabled();
+            }
+
         CTouchToolbarData* data = CheckRegistration( this );      
         if ( data && !(iFlags & KAknToolbarFixed) && iAvkonAppUi->IsForeground() )
             {
@@ -629,6 +636,11 @@
                 delete data;
                 GfxTransEffect::Deregister( this );
                 }
+
+            if ( !CAknEnv::Static()->TransparencyEnabled() && redrawStoreEnabled )
+                {
+                Window().EnableRedrawStore( ETrue );
+                }
             }
 
         // notify observer, for example touch pane, that toolbar was shown
@@ -733,6 +745,11 @@
     {
     if ( !iInternalFlags.IsSet( EShown ) ) // nothing to hide
         {
+        if ( iFlags & KAknToolbarDefault && !AknLayoutUtils::PenEnabled()
+              && IsVisible() )
+            {
+            MakeVisible( EFalse );
+            }
         return;
         }
 
@@ -889,8 +906,6 @@
                                           const TBool aDimmed, 
                                           const TBool aDrawNow ) 
     {
-    if( IsDimmed() )
-    	return;
     CAknToolbarItem* item = ToolbarItemById( aCommandId );
     if ( item && item->Control() ) 
         {
@@ -1119,10 +1134,7 @@
                             MTouchFeedback* feedback = MTouchFeedback::Instance();
                             if ( feedback )
                                 {
-                                feedback->InstantFeedback( button,
-                                                           ETouchFeedbackBasicButton,
-                                                           ETouchFeedbackVibra,
-                                                           aPointerEvent );
+                                feedback->InstantFeedback( ETouchFeedbackBasicButton );
                                 }
                             }
                 
@@ -1183,8 +1195,13 @@
             return;
             }
         }
-
-    if ( aType == KAknToolbarSetVisible && !IsShown() )
+        
+    if ( aType == KAknToolbarSetVisible && iFlags & KAknToolbarDefault 
+            && !AknLayoutUtils::PenEnabled() )
+        {
+        return; 
+        }
+    else if ( aType == KAknToolbarSetVisible && !IsShown() )
         {
         iInternalFlags.Set( ECalledFromFW );
         iInternalFlags.Clear( EDrawBackground ); 
@@ -1210,17 +1227,17 @@
         for(TInt i = 0; i < iVisibleItems.Count(); i++)
             {
             CAknToolbarItem* item = iVisibleItems[ i ];
-            if( item->ControlType() == EAknCtButton 
-                || item->ControlType() == EAknCtToolbarExtension )
-                {
-                CAknButton* button = static_cast<CAknButton*>( item->Control() ); 
-                button->ResetState();
-                }
+            CAknButton* button = static_cast<CAknButton*>( item->Control() ); 
+            button->ResetState();
             }
-
-        if ( iFlags & KAknToolbarFixed )
+        if ( iFlags & KAknToolbarDefault && !AknLayoutUtils::PenEnabled() && IsVisible() )
             {
-            if ( Layout_Meta_Data::IsLandscapeOrientation() )
+            TRAP_IGNORE( HideToolbarL() ); 
+            return; 
+            }
+        else if ( iFlags & KAknToolbarFixed )
+            {
+            if ( Layout_Meta_Data::IsLandscapeOrientation() && AknLayoutUtils::PenEnabled() )
                 {
                 iOrientation = EAknOrientationVertical; 
                 if ( ( iInternalFlags.IsSet( EFixedShown ) 
@@ -1240,7 +1257,7 @@
                         }
                     }
                 }
-            else if ( !( iFlags & KAknToolbarDefault ) )
+            else if ( !( iFlags & KAknToolbarDefault ) && AknLayoutUtils::PenEnabled() )
                 {
                 iOrientation = EAknOrientationHorizontal; 
                 if ( iInternalFlags.IsSet( EFixedShown ) && !iInternalFlags.IsSet( EShown ) )
@@ -1258,7 +1275,7 @@
                         }
                     }
                 }
-            else if ( iFlags & KAknToolbarDefault && iInternalFlags.IsSet( EShown ) )
+            else if ( ( !AknLayoutUtils::PenEnabled() || iFlags & KAknToolbarDefault ) && iInternalFlags.IsSet( EShown ) )
                 {
                 TRAP_IGNORE( HideToolbarL() ); 
                 return; 
@@ -2025,11 +2042,8 @@
 
     CWindowGc& gc = SystemGc();
     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
-    
-    //
-    // Draw background
-    //
-    if ( iFlags & KAknToolbarFixed && !( iFlags & KAknToolbarNoBackground ) &&
+    // Draw background         
+    if ( iFlags & KAknToolbarFixed && 
          iBgRect.Height() > 0 &&
          iBgRect.Width() > 0 )
         {
@@ -2361,31 +2375,27 @@
             }
         } 
 
-    // Don't set the size and position for default toolbar (never shown).
-    if ( !( iFlags & KAknToolbarDefault ) )
+    TRect rect = CalculateSizeAndPosition();
+    // Set focused item again to avoid panic in a case when toolbar has more 
+    // items in previous orientation and some of the items that do not 
+    // fit to toolbar in this orientation was focused. 
+    if ( IsFocused() )
         {
-        TRect rect = CalculateSizeAndPosition();
-        // Set focused item again to avoid panic in a case when toolbar has
-        // more items in previous orientation and some of the items that do
-        // not  fit to toolbar in this orientation was focused. 
-        if ( IsFocused() )
+        TRAP_IGNORE( MoveHighlightL( iFocusedItem, EFalse ) ); 
+        }
+
+    if ( iInternalFlags.IsSet( EShown ) )
+        {
+        if ( !( iFlags & KAknToolbarFlexiblePosition ) )
             {
-            TRAP_IGNORE( MoveHighlightL( iFocusedItem, EFalse ) ); 
+            SetPosition( rect.iTl );
             }
-    
-        if ( iInternalFlags.IsSet( EShown ) )
+        else 
             {
-            if ( !( iFlags & KAknToolbarFlexiblePosition ) )
-                {
-                SetPosition( rect.iTl );
-                }
-            else 
-                {
-                UpdateControlPositions(); 
-                }
-            SetSize( rect.Size() );
-            DrawDeferred();
+            UpdateControlPositions(); 
             }
+        SetSize( rect.Size() );
+        DrawDeferred();
         }
     }
 
@@ -2621,10 +2631,14 @@
     {
     TBool toolbarNotVisible( !IsShown() && !( iFlags & KAknToolbarDefault ) );
     TBool fixedToolbar( iFlags & KAknToolbarFixed );
+    TBool landscapeOrientation( Layout_Meta_Data::IsLandscapeOrientation() );
+    TBool touchEnabled( AknLayoutUtils::PenEnabled() );
     TBool defaultContent( iFlags & KAknToolbarDefault );
 
     if ( toolbarNotVisible || 
          !fixedToolbar ||
+         ( defaultContent && !landscapeOrientation ) ||
+         !touchEnabled ||
          ( fixedToolbar && defaultContent ) )
         {
         return;
@@ -3100,11 +3114,11 @@
                 AknLayoutScalable_Avkon::cell_sctrl_middle_pane( 0, 0, 0 ) );
             }
         }
-    else
+    else    
         {
         if ( iOrientation == EAknOrientationHorizontal )
-            {
-            variety = 4;
+            {        
+            variety = 4;    
             aToolbarRect = RectFromLayout( aMainPaneRect,
                 AknLayoutScalable_Avkon::popup_toolbar_window( variety ) );