uifw/AvKon/src/akncontext.cpp
branchRCL_3
changeset 38 c52421ed5f07
parent 0 2f259fa3e83a
child 55 aecbbf00d063
--- a/uifw/AvKon/src/akncontext.cpp	Wed Jun 09 09:58:37 2010 +0300
+++ b/uifw/AvKon/src/akncontext.cpp	Mon Jun 21 15:57:43 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002 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"
@@ -11,7 +11,8 @@
 *
 * Contributors:
 *
-* Description:
+* Description: Context pane control used to display the application icon
+*              in status pane.
 *
 */
 
@@ -58,7 +59,6 @@
 public:
     CEikImage*  iContextImage;
     CEikImage*  iDefaultContextImage;
-    TInt        iCurrentColorScheme;
     };
 
 CAknContextPaneExtension::CAknContextPaneExtension()
@@ -91,7 +91,20 @@
 EXPORT_C void CAknContextPane::ConstructL()
     {
     CommonConstructL();
-    TRAP_IGNORE(SetPictureToDefaultL()); // Trapped because of Java midlet issues
+
+    // Perf optimization: We don't set the default picture if the context
+    // pane is not in current status pane layout. The picture will be created
+    // in SizeChanged() if a valid size is set for context pane, but at
+    // the moment context pane isn't used in any of the supported Avkon
+    // status pane layouts.
+    CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
+    if ( statusPane &&
+         statusPane->PaneCapabilities(
+             TUid::Uid( EEikStatusPaneUidContext ) ).IsInCurrentLayout() )
+        {
+        // Trapped because of Java midlet issues.
+        TRAP_IGNORE( SetPictureToDefaultL() );
+        }
     }
 
 
@@ -306,8 +319,14 @@
 
 EXPORT_C void CAknContextPane::SizeChanged()
     {
-    if (Rect() != TRect(0,0,0,0)) // Fix for Parent getting parent relative data. 
+    if ( !Rect().IsEmpty() ) // Fix for Parent getting parent relative data. 
         {
+        if ( !iExtension->iContextImage )
+            {
+            // Create the default picture if it doesn't exist yet. 
+            TRAP_IGNORE( SetPictureToDefaultL() );
+            }
+
         if (iExtension->iContextImage && iExtension->iContextImage->Bitmap()) 
             {
             TAknLayoutRect layoutRect;
@@ -362,8 +381,9 @@
 
 EXPORT_C void CAknContextPane::HandleResourceChange( TInt aType ) 
     {
-    if ( aType == KEikColorResourceChange || aType==KEikDynamicLayoutVariantSwitch )
+    if ( aType==KEikDynamicLayoutVariantSwitch )
         {
+        SizeChanged();
         DrawDeferred();
         }
     else if( aType == KAknsMessageSkinChange )
@@ -409,76 +429,63 @@
     {
     CWindowGc& gc=SystemGc();
 
-    // screen
-    TRect screenRect = iAvkonAppUi->ApplicationRect();
-    
-    //TAknWindowLineLayout screenLayout = AknLayout::screen();
-    //TRect screenRect = screenLayout.Rect();
-
-
-    // app window
-    TAknWindowLineLayout applicationWindowLayout =
-        AknLayout::application_window(screenRect);
-    
-    TAknLayoutRect applicationWindowLayoutRect;
-    applicationWindowLayoutRect.LayoutRect(screenRect, applicationWindowLayout);
-    TRect applicationWindowRect = applicationWindowLayoutRect.Rect(); 
-
-    // statuspane
-    TAknWindowLineLayout statusPaneLayout = 
-        AknLayout::status_pane(applicationWindowRect, 0);
-
-    TAknLayoutRect statusPaneLayoutRect;
-    statusPaneLayoutRect.LayoutRect(applicationWindowRect, statusPaneLayout);
-    TRect statusPaneRect = statusPaneLayoutRect.Rect(); 
-
-    // context pane
-    TAknWindowLineLayout contextPaneLayout = 
-        AknLayout::context_pane(statusPaneRect, 0);
-    
-    TAknLayoutRect contextPaneLayoutRect;
-    contextPaneLayoutRect.LayoutRect(statusPaneRect, contextPaneLayout);
-    TRect contextPaneRect = contextPaneLayoutRect.Rect(); 
-
-    TAknWindowLineLayout naviPaneGraphicsLayout = 
-        AknLayout::Status_pane_elements_Line_1();
-
-    TAknWindowLineLayout naviWipeGraphicsLayout = 
-        AknLayout::Status_pane_elements_Line_2();
-
-    TAknLayoutRect naviPaneGraphicsLayoutRect;
-    naviPaneGraphicsLayoutRect.LayoutRect(statusPaneRect, naviPaneGraphicsLayout);
-    TRect naviPaneGraphicsRect = naviPaneGraphicsLayoutRect.Rect(); 
-
-    TAknLayoutRect naviWipeGraphicsLayoutRect;
-    naviWipeGraphicsLayoutRect.LayoutRect(statusPaneRect, naviWipeGraphicsLayout);
-    TRect naviWipeGraphicsRect = naviWipeGraphicsLayoutRect.Rect(); 
-
-    TRect rect(Rect());
-
-    TRect barRect = contextPaneRect;
-    if (barRect.Intersects(naviPaneGraphicsRect))
-        {
-        barRect.Intersection(naviPaneGraphicsRect);
-        
-        // calculate new origo, relative to context pane.
-        barRect.iTl.iX -= contextPaneRect.iTl.iX;
-        barRect.iTl.iY -= contextPaneRect.iTl.iY;
-        barRect.iBr.iX -= contextPaneRect.iTl.iX;
-        barRect.iBr.iY -= contextPaneRect.iTl.iY;
-        }
-    else
-        {
-        barRect = TRect(0,0,0,0);
-        }
-    
-
+    TRect rect( Rect() );
     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
     MAknsControlContext* cc = AknsDrawUtils::ControlContext(this);
 
-        // Solid or wipe comes from background
-    if( !AknsDrawUtils::Background( skin, cc, this, gc, rect ) )
+    // Solid or wipe comes from background
+    if ( !AknsDrawUtils::Background( skin, cc, this, gc, rect ) )
         {
+        // screen
+        TRect screenRect = iAvkonAppUi->ApplicationRect();
+    
+        // app window
+        TAknWindowLineLayout applicationWindowLayout =
+            AknLayout::application_window(screenRect);
+        
+        TAknLayoutRect applicationWindowLayoutRect;
+        applicationWindowLayoutRect.LayoutRect(screenRect, applicationWindowLayout);
+        TRect applicationWindowRect = applicationWindowLayoutRect.Rect(); 
+    
+        // statuspane
+        TAknWindowLineLayout statusPaneLayout = 
+            AknLayout::status_pane(applicationWindowRect, 0);
+    
+        TAknLayoutRect statusPaneLayoutRect;
+        statusPaneLayoutRect.LayoutRect(applicationWindowRect, statusPaneLayout);
+        TRect statusPaneRect = statusPaneLayoutRect.Rect(); 
+    
+        // context pane
+        TAknWindowLineLayout contextPaneLayout = 
+            AknLayout::context_pane(statusPaneRect, 0);
+        
+        TAknLayoutRect contextPaneLayoutRect;
+        contextPaneLayoutRect.LayoutRect(statusPaneRect, contextPaneLayout);
+        TRect contextPaneRect = contextPaneLayoutRect.Rect(); 
+    
+        TAknWindowLineLayout naviPaneGraphicsLayout = 
+            AknLayout::Status_pane_elements_Line_1();
+    
+        TAknLayoutRect naviPaneGraphicsLayoutRect;
+        naviPaneGraphicsLayoutRect.LayoutRect(statusPaneRect, naviPaneGraphicsLayout);
+        TRect naviPaneGraphicsRect = naviPaneGraphicsLayoutRect.Rect();
+
+        TRect barRect( contextPaneRect );
+        if ( barRect.Intersects( naviPaneGraphicsRect ) )
+            {
+            barRect.Intersection( naviPaneGraphicsRect );
+            
+            // calculate new origo, relative to context pane.
+            barRect.iTl.iX -= contextPaneRect.iTl.iX;
+            barRect.iTl.iY -= contextPaneRect.iTl.iY;
+            barRect.iBr.iX -= contextPaneRect.iTl.iX;
+            barRect.iBr.iY -= contextPaneRect.iTl.iY;
+            }
+        else
+            {
+            barRect = TRect(0,0,0,0);
+            }
+
         // Default drawing if skinning is not available
         gc.Clear(rect); 
         gc.SetPenStyle(CGraphicsContext::ENullPen);
@@ -533,7 +540,19 @@
         }
     else
         {
-        TRAP_IGNORE(SetPictureToDefaultL()); // Trapped because of Java midlet issues
+        // Perf optimization: We don't set the default picture if the context
+        // pane is not in current status pane layout. The picture will be
+        // created in SizeChanged() if a valid size is set for context pane,
+        // but at the moment context pane isn't used in any of the supported
+        // Avkon status pane layouts.
+        CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
+        if ( statusPane &&
+             statusPane->PaneCapabilities(
+                 TUid::Uid( EEikStatusPaneUidContext ) ).IsInCurrentLayout() )
+            {
+            // Trapped because of Java midlet issues.
+            TRAP_IGNORE( SetPictureToDefaultL() );
+            }
         }
     }