uifw/AvKon/src/aknbattery.cpp
branchRCL_3
changeset 20 d48ab3b357f1
parent 19 aecbbf00d063
--- a/uifw/AvKon/src/aknbattery.cpp	Tue Aug 31 15:28:30 2010 +0300
+++ b/uifw/AvKon/src/aknbattery.cpp	Wed Sep 01 12:16:19 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 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"
@@ -25,6 +25,9 @@
 #include <aknlayoutscalable_avkon.cdl.h>
 #include <layoutmetadata.cdl.h>
 
+#include <AknSmallIndicator.h>
+#include <touchfeedback.h>
+
 #include <AknTasHook.h>
 #include "AknUtils.h"
 #include "aknconsts.h"
@@ -66,6 +69,7 @@
 EXPORT_C CAknBatteryPane::~CAknBatteryPane()
     {
     AKNTASHOOK_REMOVE();
+    
     AknsUtils::DeregisterControlPosition( this );
 
     delete iBatteryIconControl;
@@ -94,7 +98,7 @@
     iBatteryStrengthControl->SetContainerWindowL( *this );
     iPrivateFlags = 0; // reset flags
     iDataObserver = new (ELeave) CAknBatteryDataObserver( this );
-    iIsActiveIdle = AknStatuspaneUtils::IsActiveIdle();
+    iStatusPane = CEikStatusPaneBase::Current();
     }
 
 
@@ -326,6 +330,22 @@
         iBatteryStrengthControl, parent, batteryStrenghtLayout );
 
     AknsUtils::RegisterControlPosition( this );
+    
+    MTouchFeedback* feedback = MTouchFeedback::Instance();
+    if ( feedback )
+        {
+        if ( AknStatuspaneUtils::ExtendedFlatLayoutActive() )
+            {
+            // Disable tactile feedback in extended flat layout because
+            // the battery pane isn't adjacent to the universal indicator
+            // and small digital clock pane.
+            feedback->EnableFeedbackForControl( this, EFalse );
+            }
+        else
+            {
+            feedback->EnableFeedbackForControl( this, ETrue );
+            }
+        }
     }
 
 
@@ -345,24 +365,38 @@
 // Draws the battery pane.
 // ---------------------------------------------------------------------------
 //
-EXPORT_C void CAknBatteryPane::Draw( const TRect& /*aRect*/ ) const
+EXPORT_C void CAknBatteryPane::Draw( const TRect& aRect ) const
     {
-    if ( iIsActiveIdle )
+    if ( iStatusPane && 
+         iStatusPane->IsTransparent() )
         {
+        CWindowGc& gc = SystemGc();
+        TRgb rgb(TRgb::Color16MA(0));
+        gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
+        gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
+        gc.SetBrushColor(rgb);
+        gc.Clear(aRect);
         return;
         }
+        
 
-    if ( AknStatuspaneUtils::StaconPaneActive() )
+    // Don't allow normal background drawing if
+    // background is already drawn with a background drawer.
+    const MCoeControlBackground* backgroundDrawer = FindBackground();
+    if ( !backgroundDrawer )
         {
-        DrawInStaconPane( Rect() );
-        }
-    else if ( AknStatuspaneUtils::FlatLayoutActive() )
-        {
-        DrawInFlatStatusPane( Rect() );
-        }
-    else
-        {
-        DrawInNormalStatusPane( Rect() );
+        if ( AknStatuspaneUtils::StaconPaneActive() )
+            {
+            DrawInStaconPane( Rect() );
+            }
+        else if ( AknStatuspaneUtils::FlatLayoutActive() )
+            {
+            DrawInFlatStatusPane( Rect() );
+            }
+        else
+            {
+            DrawInNormalStatusPane( Rect() );
+            }
         }
     }
 
@@ -507,55 +541,135 @@
 
 // ---------------------------------------------------------------------------
 // CAknBatteryPane::HandlePointerEventL
-// Processes battery pane's pointer events. Actually this does nothing yet.
+// Processes battery pane's pointer events.
 // ---------------------------------------------------------------------------
 //
 void CAknBatteryPane::HandlePointerEventL( const TPointerEvent& aPointerEvent )
     {
-    if ( AknLayoutUtils::PenEnabled() )
+    if ( IsDimmed() )
         {
-        if ( IsDimmed() )
+        iPrivateFlags &= (~EAknBatteryPaneButton1DownInBatteryRect);
+        return;
+        }
+
+    CEikStatusPaneBase* sp = CEikStatusPaneBase::Current();
+	if ( sp )
+	    {
+        TInt statusPaneCurrentLayoutResourceId = sp->CurrentLayoutResId();
+        if ( statusPaneCurrentLayoutResourceId ==
+                 R_AVKON_STATUS_PANE_LAYOUT_POWER_OFF_RECHARGE ||
+             statusPaneCurrentLayoutResourceId ==
+                 R_AVKON_STATUS_PANE_LAYOUT_POWER_OFF_RECHARGE_MIRRORED )
             {
-            iPrivateFlags &= (~EAknBatteryPaneButton1DownInBatteryRect);
+            AknsUtils::DeregisterControlPosition( this );
             return;
             }
+        }
+    // Get the rect of battery pane.
+    TRect rect( Rect() );
 
-        // Get the rect of battery pane.
-        TRect rect( Rect() );
-
-        // Switch by type
-        switch ( aPointerEvent.iType )
+    // Switch by type
+    switch ( aPointerEvent.iType )
+        {
+        case TPointerEvent::EButton1Down:
             {
-            case TPointerEvent::EButton1Down:
+            // if battery pane's rect contains pointer down position
+            if ( rect.Contains( aPointerEvent.iPosition ) )
                 {
-                // if battery pane's rect contains pointer down position
-                if ( rect.Contains( aPointerEvent.iPosition ) )
+                // set flag that pointerdown was inside battery pane
+                iPrivateFlags |= EAknBatteryPaneButton1DownInBatteryRect;
+                if ( !AknStatuspaneUtils::ExtendedFlatLayoutActive() )
                     {
-                    // set flag that pointerdown was inside battery pane
-                    iPrivateFlags |= EAknBatteryPaneButton1DownInBatteryRect;
+                    MTouchFeedback* feedback = MTouchFeedback::Instance();
+                    if ( feedback )
+                        {
+                        feedback->InstantFeedback( ETouchFeedbackSensitiveButton );
+                        }
                     }
                 }
-                break;
+            }
+            break;
 
-            case TPointerEvent::EButton1Up:
+        case TPointerEvent::EButton1Up:
+            {
+            if ( !AknStatuspaneUtils::ExtendedFlatLayoutActive() )
                 {
-                // if battery pane's rect contains pointer down position and
-                // Button1Down was clicked inside battery rect
-                if ( iPrivateFlags&EAknBatteryPaneButton1DownInBatteryRect &&
-                    rect.Contains( aPointerEvent.iPosition ) )
+                // Currently the small digital clock pane, universal
+                // indicator pane and battery pane (in status pane layouts
+                // where it's adjacent to universal indicator or digital
+                // clock pane) are regarded as one touch responsive
+                // area from which the universal indicator popup should
+                // open on tap, so upon pointer up event it must be checked
+                // here if the down event happened inside this control,
+                // but the up event inside digital clock or indicator
+                // pane area.
+                
+                TBool pointerUpInIndicatorArea( EFalse );
+                TBool pointerUpInClockArea( EFalse );
+                    
+                if ( sp )
                     {
-                    // Up happened inside battery pane's rect
-                    // activate something
+                    CCoeControl* clockPane = sp->ContainerControlL(
+                        TUid::Uid( EEikStatusPaneUidDigitalClock ) );
+                    if ( clockPane )
+                        {
+                        TRect clockRect(
+                            clockPane->PositionRelativeToScreen(),
+                            clockPane->Size() );
+                        pointerUpInClockArea =
+                            clockRect.Contains( aPointerEvent.iParentPosition );
+                        }
+                        
+                    CCoeControl* indicatorPane = sp->ContainerControlL(
+                        TUid::Uid( EEikStatusPaneUidIndic ) );
+                    if ( indicatorPane )
+                        {
+                        TRect indicatorRect(
+                            indicatorPane->PositionRelativeToScreen(),
+                            indicatorPane->Size() );
+                        pointerUpInIndicatorArea =
+                            indicatorRect.Contains( aPointerEvent.iParentPosition );
+                        }
                     }
+    
+                if ( ( iPrivateFlags & EAknBatteryPaneButton1DownInBatteryRect &&
+                       rect.Contains( aPointerEvent.iPosition ) ) ||
+                     pointerUpInClockArea ||
+                     pointerUpInIndicatorArea )
+                    {
+                    MTouchFeedback* feedback = MTouchFeedback::Instance();
+                    if ( feedback )
+                        {
+                        feedback->InstantFeedback(
+                            this,
+                            ETouchFeedbackSensitiveButton,
+                            ETouchFeedbackVibra,
+                            aPointerEvent );
+                        }
 
-                // Up happened, reset button down flag
-                iPrivateFlags &= (~EAknBatteryPaneButton1DownInBatteryRect);
+                    CAknSmallIndicator* indicatorNotifier =
+                        CAknSmallIndicator::NewLC( TUid::Uid( 0 ) );
+                    indicatorNotifier->HandleIndicatorTapL();
+                    //for indicator popup event
+                    if ( feedback )
+                        {
+                        feedback->InstantFeedback(
+                                           this,
+                                           ETouchFeedbackPopUp,
+                                           ETouchFeedbackVibra,
+                                           aPointerEvent );
+                        }
+                    CleanupStack::PopAndDestroy( indicatorNotifier );
+                    }
                 }
-                break;
 
-            default:
-                break;
+            // Up happened, reset button down flag
+            iPrivateFlags &= (~EAknBatteryPaneButton1DownInBatteryRect);
             }
+            break;
+
+        default:
+            break;
         }
     }