uifw/AvKon/src/akncontext.cpp
branchRCL_3
changeset 38 c52421ed5f07
parent 0 2f259fa3e83a
child 55 aecbbf00d063
equal deleted inserted replaced
29:a8834a2e9a96 38:c52421ed5f07
     1 /*
     1 /*
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2002-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".
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description: Context pane control used to display the application icon
       
    15 *              in status pane.
    15 *
    16 *
    16 */
    17 */
    17 
    18 
    18 
    19 
    19 // INCLUDE FILES
    20 // INCLUDE FILES
    56 	CAknContextPaneExtension();
    57 	CAknContextPaneExtension();
    57 	~CAknContextPaneExtension();
    58 	~CAknContextPaneExtension();
    58 public:
    59 public:
    59     CEikImage*  iContextImage;
    60     CEikImage*  iContextImage;
    60     CEikImage*  iDefaultContextImage;
    61     CEikImage*  iDefaultContextImage;
    61     TInt        iCurrentColorScheme;
       
    62     };
    62     };
    63 
    63 
    64 CAknContextPaneExtension::CAknContextPaneExtension()
    64 CAknContextPaneExtension::CAknContextPaneExtension()
    65 	{
    65 	{
    66 	}
    66 	}
    89     }
    89     }
    90 
    90 
    91 EXPORT_C void CAknContextPane::ConstructL()
    91 EXPORT_C void CAknContextPane::ConstructL()
    92     {
    92     {
    93     CommonConstructL();
    93     CommonConstructL();
    94     TRAP_IGNORE(SetPictureToDefaultL()); // Trapped because of Java midlet issues
    94 
       
    95     // Perf optimization: We don't set the default picture if the context
       
    96     // pane is not in current status pane layout. The picture will be created
       
    97     // in SizeChanged() if a valid size is set for context pane, but at
       
    98     // the moment context pane isn't used in any of the supported Avkon
       
    99     // status pane layouts.
       
   100     CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
       
   101     if ( statusPane &&
       
   102          statusPane->PaneCapabilities(
       
   103              TUid::Uid( EEikStatusPaneUidContext ) ).IsInCurrentLayout() )
       
   104         {
       
   105         // Trapped because of Java midlet issues.
       
   106         TRAP_IGNORE( SetPictureToDefaultL() );
       
   107         }
    95     }
   108     }
    96 
   109 
    97 
   110 
    98 EXPORT_C void CAknContextPane::ConstructFromResourceL(TResourceReader& aReader)
   111 EXPORT_C void CAknContextPane::ConstructFromResourceL(TResourceReader& aReader)
    99     {
   112     {
   304     }
   317     }
   305 
   318 
   306 
   319 
   307 EXPORT_C void CAknContextPane::SizeChanged()
   320 EXPORT_C void CAknContextPane::SizeChanged()
   308     {
   321     {
   309     if (Rect() != TRect(0,0,0,0)) // Fix for Parent getting parent relative data. 
   322     if ( !Rect().IsEmpty() ) // Fix for Parent getting parent relative data. 
   310         {
   323         {
       
   324         if ( !iExtension->iContextImage )
       
   325             {
       
   326             // Create the default picture if it doesn't exist yet. 
       
   327             TRAP_IGNORE( SetPictureToDefaultL() );
       
   328             }
       
   329 
   311         if (iExtension->iContextImage && iExtension->iContextImage->Bitmap()) 
   330         if (iExtension->iContextImage && iExtension->iContextImage->Bitmap()) 
   312             {
   331             {
   313             TAknLayoutRect layoutRect;
   332             TAknLayoutRect layoutRect;
   314             layoutRect.LayoutRect(Rect(), AknLayout::Context_pane_elements_Line_1());
   333             layoutRect.LayoutRect(Rect(), AknLayout::Context_pane_elements_Line_1());
   315 
   334 
   360     }
   379     }
   361 
   380 
   362 
   381 
   363 EXPORT_C void CAknContextPane::HandleResourceChange( TInt aType ) 
   382 EXPORT_C void CAknContextPane::HandleResourceChange( TInt aType ) 
   364     {
   383     {
   365     if ( aType == KEikColorResourceChange || aType==KEikDynamicLayoutVariantSwitch )
   384     if ( aType==KEikDynamicLayoutVariantSwitch )
   366         {
   385         {
       
   386         SizeChanged();
   367         DrawDeferred();
   387         DrawDeferred();
   368         }
   388         }
   369     else if( aType == KAknsMessageSkinChange )
   389     else if( aType == KAknsMessageSkinChange )
   370         {
   390         {
   371         if( iExtension->iDefaultContextImage && iExtension->iContextImage )
   391         if( iExtension->iDefaultContextImage && iExtension->iContextImage )
   407 
   427 
   408 EXPORT_C void CAknContextPane::Draw(const TRect& /*aRect*/) const
   428 EXPORT_C void CAknContextPane::Draw(const TRect& /*aRect*/) const
   409     {
   429     {
   410     CWindowGc& gc=SystemGc();
   430     CWindowGc& gc=SystemGc();
   411 
   431 
   412     // screen
   432     TRect rect( Rect() );
   413     TRect screenRect = iAvkonAppUi->ApplicationRect();
       
   414     
       
   415     //TAknWindowLineLayout screenLayout = AknLayout::screen();
       
   416     //TRect screenRect = screenLayout.Rect();
       
   417 
       
   418 
       
   419     // app window
       
   420     TAknWindowLineLayout applicationWindowLayout =
       
   421         AknLayout::application_window(screenRect);
       
   422     
       
   423     TAknLayoutRect applicationWindowLayoutRect;
       
   424     applicationWindowLayoutRect.LayoutRect(screenRect, applicationWindowLayout);
       
   425     TRect applicationWindowRect = applicationWindowLayoutRect.Rect(); 
       
   426 
       
   427     // statuspane
       
   428     TAknWindowLineLayout statusPaneLayout = 
       
   429         AknLayout::status_pane(applicationWindowRect, 0);
       
   430 
       
   431     TAknLayoutRect statusPaneLayoutRect;
       
   432     statusPaneLayoutRect.LayoutRect(applicationWindowRect, statusPaneLayout);
       
   433     TRect statusPaneRect = statusPaneLayoutRect.Rect(); 
       
   434 
       
   435     // context pane
       
   436     TAknWindowLineLayout contextPaneLayout = 
       
   437         AknLayout::context_pane(statusPaneRect, 0);
       
   438     
       
   439     TAknLayoutRect contextPaneLayoutRect;
       
   440     contextPaneLayoutRect.LayoutRect(statusPaneRect, contextPaneLayout);
       
   441     TRect contextPaneRect = contextPaneLayoutRect.Rect(); 
       
   442 
       
   443     TAknWindowLineLayout naviPaneGraphicsLayout = 
       
   444         AknLayout::Status_pane_elements_Line_1();
       
   445 
       
   446     TAknWindowLineLayout naviWipeGraphicsLayout = 
       
   447         AknLayout::Status_pane_elements_Line_2();
       
   448 
       
   449     TAknLayoutRect naviPaneGraphicsLayoutRect;
       
   450     naviPaneGraphicsLayoutRect.LayoutRect(statusPaneRect, naviPaneGraphicsLayout);
       
   451     TRect naviPaneGraphicsRect = naviPaneGraphicsLayoutRect.Rect(); 
       
   452 
       
   453     TAknLayoutRect naviWipeGraphicsLayoutRect;
       
   454     naviWipeGraphicsLayoutRect.LayoutRect(statusPaneRect, naviWipeGraphicsLayout);
       
   455     TRect naviWipeGraphicsRect = naviWipeGraphicsLayoutRect.Rect(); 
       
   456 
       
   457     TRect rect(Rect());
       
   458 
       
   459     TRect barRect = contextPaneRect;
       
   460     if (barRect.Intersects(naviPaneGraphicsRect))
       
   461         {
       
   462         barRect.Intersection(naviPaneGraphicsRect);
       
   463         
       
   464         // calculate new origo, relative to context pane.
       
   465         barRect.iTl.iX -= contextPaneRect.iTl.iX;
       
   466         barRect.iTl.iY -= contextPaneRect.iTl.iY;
       
   467         barRect.iBr.iX -= contextPaneRect.iTl.iX;
       
   468         barRect.iBr.iY -= contextPaneRect.iTl.iY;
       
   469         }
       
   470     else
       
   471         {
       
   472         barRect = TRect(0,0,0,0);
       
   473         }
       
   474     
       
   475 
       
   476     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   433     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   477     MAknsControlContext* cc = AknsDrawUtils::ControlContext(this);
   434     MAknsControlContext* cc = AknsDrawUtils::ControlContext(this);
   478 
   435 
   479         // Solid or wipe comes from background
   436     // Solid or wipe comes from background
   480     if( !AknsDrawUtils::Background( skin, cc, this, gc, rect ) )
   437     if ( !AknsDrawUtils::Background( skin, cc, this, gc, rect ) )
   481         {
   438         {
       
   439         // screen
       
   440         TRect screenRect = iAvkonAppUi->ApplicationRect();
       
   441     
       
   442         // app window
       
   443         TAknWindowLineLayout applicationWindowLayout =
       
   444             AknLayout::application_window(screenRect);
       
   445         
       
   446         TAknLayoutRect applicationWindowLayoutRect;
       
   447         applicationWindowLayoutRect.LayoutRect(screenRect, applicationWindowLayout);
       
   448         TRect applicationWindowRect = applicationWindowLayoutRect.Rect(); 
       
   449     
       
   450         // statuspane
       
   451         TAknWindowLineLayout statusPaneLayout = 
       
   452             AknLayout::status_pane(applicationWindowRect, 0);
       
   453     
       
   454         TAknLayoutRect statusPaneLayoutRect;
       
   455         statusPaneLayoutRect.LayoutRect(applicationWindowRect, statusPaneLayout);
       
   456         TRect statusPaneRect = statusPaneLayoutRect.Rect(); 
       
   457     
       
   458         // context pane
       
   459         TAknWindowLineLayout contextPaneLayout = 
       
   460             AknLayout::context_pane(statusPaneRect, 0);
       
   461         
       
   462         TAknLayoutRect contextPaneLayoutRect;
       
   463         contextPaneLayoutRect.LayoutRect(statusPaneRect, contextPaneLayout);
       
   464         TRect contextPaneRect = contextPaneLayoutRect.Rect(); 
       
   465     
       
   466         TAknWindowLineLayout naviPaneGraphicsLayout = 
       
   467             AknLayout::Status_pane_elements_Line_1();
       
   468     
       
   469         TAknLayoutRect naviPaneGraphicsLayoutRect;
       
   470         naviPaneGraphicsLayoutRect.LayoutRect(statusPaneRect, naviPaneGraphicsLayout);
       
   471         TRect naviPaneGraphicsRect = naviPaneGraphicsLayoutRect.Rect();
       
   472 
       
   473         TRect barRect( contextPaneRect );
       
   474         if ( barRect.Intersects( naviPaneGraphicsRect ) )
       
   475             {
       
   476             barRect.Intersection( naviPaneGraphicsRect );
       
   477             
       
   478             // calculate new origo, relative to context pane.
       
   479             barRect.iTl.iX -= contextPaneRect.iTl.iX;
       
   480             barRect.iTl.iY -= contextPaneRect.iTl.iY;
       
   481             barRect.iBr.iX -= contextPaneRect.iTl.iX;
       
   482             barRect.iBr.iY -= contextPaneRect.iTl.iY;
       
   483             }
       
   484         else
       
   485             {
       
   486             barRect = TRect(0,0,0,0);
       
   487             }
       
   488 
   482         // Default drawing if skinning is not available
   489         // Default drawing if skinning is not available
   483         gc.Clear(rect); 
   490         gc.Clear(rect); 
   484         gc.SetPenStyle(CGraphicsContext::ENullPen);
   491         gc.SetPenStyle(CGraphicsContext::ENullPen);
   485         gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   492         gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   486         gc.SetBrushColor(AKN_LAF_COLOR(KStatusPaneBackgroundGraphicsColorUsual));
   493         gc.SetBrushColor(AKN_LAF_COLOR(KStatusPaneBackgroundGraphicsColorUsual));
   531             }
   538             }
   532         CleanupStack::PopAndDestroy();  // bitmapFile
   539         CleanupStack::PopAndDestroy();  // bitmapFile
   533         }
   540         }
   534     else
   541     else
   535         {
   542         {
   536         TRAP_IGNORE(SetPictureToDefaultL()); // Trapped because of Java midlet issues
   543         // Perf optimization: We don't set the default picture if the context
       
   544         // pane is not in current status pane layout. The picture will be
       
   545         // created in SizeChanged() if a valid size is set for context pane,
       
   546         // but at the moment context pane isn't used in any of the supported
       
   547         // Avkon status pane layouts.
       
   548         CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
       
   549         if ( statusPane &&
       
   550              statusPane->PaneCapabilities(
       
   551                  TUid::Uid( EEikStatusPaneUidContext ) ).IsInCurrentLayout() )
       
   552             {
       
   553             // Trapped because of Java midlet issues.
       
   554             TRAP_IGNORE( SetPictureToDefaultL() );
       
   555             }
   537         }
   556         }
   538     }
   557     }
   539 
   558 
   540 void CAknContextPane::LoadNaviWipeBitmapL()
   559 void CAknContextPane::LoadNaviWipeBitmapL()
   541     {    
   560     {