uifw/AvKon/src/akncontext.cpp
changeset 0 2f259fa3e83a
child 38 c52421ed5f07
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <eikfutil.h>
       
    21 #include <eikappui.h>
       
    22 #include <eikapp.h>
       
    23 
       
    24 #include <apgcli.h>
       
    25 #include <apgicnfl.h>
       
    26 #include <apgwgnam.h> 
       
    27 
       
    28 #include <gulicon.h>
       
    29 #include <gulutil.h>
       
    30 #include <eikimage.h>
       
    31 
       
    32 #include <AknIconUtils.h>
       
    33 
       
    34 #include <AknsUtils.h>
       
    35 #include <AknsDrawUtils.h>
       
    36 
       
    37 #include <AknTasHook.h>
       
    38 #include "AknPanic.h"
       
    39 #include "AknUtils.h"
       
    40 #include "aknconsts.h"
       
    41 #include "akncontext.h"
       
    42 
       
    43 #include <avkon.mbg>
       
    44 #include <eikspane.h>
       
    45 
       
    46 #include "aknnavi.h"
       
    47 #include "AknBitmapMirrorUtils.h"
       
    48 #include "AknNaviConstants.h"
       
    49 #include "aknappui.h"
       
    50 #include <AknDef.h>
       
    51 
       
    52 
       
    53 NONSHARABLE_CLASS(CAknContextPaneExtension): public CBase
       
    54 	{
       
    55 public:
       
    56 	CAknContextPaneExtension();
       
    57 	~CAknContextPaneExtension();
       
    58 public:
       
    59     CEikImage*  iContextImage;
       
    60     CEikImage*  iDefaultContextImage;
       
    61     TInt        iCurrentColorScheme;
       
    62     };
       
    63 
       
    64 CAknContextPaneExtension::CAknContextPaneExtension()
       
    65 	{
       
    66 	}
       
    67 
       
    68 CAknContextPaneExtension::~CAknContextPaneExtension()
       
    69 	{
       
    70 	}
       
    71 
       
    72 EXPORT_C CAknContextPane::CAknContextPane()
       
    73     {
       
    74     AKNTASHOOK_ADD( this, "CAknContextPane" );
       
    75     }
       
    76 
       
    77 EXPORT_C CAknContextPane::~CAknContextPane()
       
    78     {
       
    79     AKNTASHOOK_REMOVE();
       
    80     AknsUtils::DeregisterControlPosition( this );
       
    81 	if (iExtension)
       
    82 		{
       
    83 		AknsUtils::DeregisterControlPosition( iExtension->iContextImage );
       
    84 		AknsUtils::DeregisterControlPosition( iExtension->iDefaultContextImage );
       
    85 		delete iExtension->iContextImage;
       
    86 		delete iExtension->iDefaultContextImage;
       
    87 		delete iExtension;
       
    88 		}
       
    89     }
       
    90 
       
    91 EXPORT_C void CAknContextPane::ConstructL()
       
    92     {
       
    93     CommonConstructL();
       
    94     TRAP_IGNORE(SetPictureToDefaultL()); // Trapped because of Java midlet issues
       
    95     }
       
    96 
       
    97 
       
    98 EXPORT_C void CAknContextPane::ConstructFromResourceL(TResourceReader& aReader)
       
    99     {
       
   100     CommonConstructL();
       
   101     ReadFromResourceFileL(aReader);
       
   102     }
       
   103 
       
   104 EXPORT_C void CAknContextPane::SetPicture(const CFbsBitmap* aBitmap, const CFbsBitmap* aMaskBitmap)
       
   105     {
       
   106     TBool bitmapChanged = EFalse;
       
   107     if (iExtension->iContextImage)
       
   108         {
       
   109         bitmapChanged = ETrue;
       
   110         iExtension->iContextImage->SetPictureOwnedExternally(EFalse);
       
   111         iExtension->iContextImage->SetPicture(aBitmap, aMaskBitmap);
       
   112         }
       
   113     else
       
   114         {
       
   115         // Try to create new iContextImage object.
       
   116         TRAPD( error, InitL() );
       
   117         if ( !error )
       
   118             {
       
   119             bitmapChanged = ETrue;
       
   120             iExtension->iContextImage->SetPictureOwnedExternally(EFalse);
       
   121             iExtension->iContextImage->SetPicture(aBitmap, aMaskBitmap);
       
   122             }
       
   123         else
       
   124             {
       
   125             // Ownership taken - delete if there is not memory to create new iContextImage.
       
   126             delete aBitmap;
       
   127             delete aMaskBitmap;
       
   128             }
       
   129         }
       
   130 
       
   131     if ( bitmapChanged )
       
   132         {
       
   133         SizeChanged();	
       
   134         DrawNow();
       
   135         }
       
   136     }
       
   137 
       
   138 EXPORT_C void CAknContextPane::SetPicture(CEikImage* aImage)
       
   139     {
       
   140     __ASSERT_ALWAYS(aImage && aImage->Bitmap(), Panic(EAknPanicNullPointer));
       
   141 
       
   142     delete iExtension->iContextImage;   
       
   143     iExtension->iContextImage = aImage;
       
   144 	if (!iExtension->iContextImage->DrawableWindow())
       
   145 		{
       
   146 		TRAP_IGNORE(iExtension->iContextImage->SetContainerWindowL(*this));
       
   147 		}
       
   148 	__ASSERT_DEBUG(iExtension->iContextImage->DrawableWindow(), Panic(EAknPanicNullPointer));
       
   149 
       
   150     iExtension->iContextImage->SetPictureOwnedExternally(EFalse);
       
   151 
       
   152     SizeChanged();
       
   153     DrawNow();
       
   154     }
       
   155 
       
   156 EXPORT_C void CAknContextPane::SetPictureFromFileL(const TDesC& aFileName, TInt aMainId, TInt aMaskId)
       
   157     {
       
   158     delete iExtension->iContextImage;
       
   159     iExtension->iContextImage = NULL;
       
   160     
       
   161     InitL();
       
   162     iExtension->iContextImage->CreatePictureFromFileL(aFileName, aMainId, aMaskId);
       
   163     
       
   164     SizeChanged();
       
   165     DrawNow();
       
   166     }
       
   167 
       
   168 
       
   169 EXPORT_C void CAknContextPane::SetFromResourceL(TResourceReader& aReader)
       
   170     {
       
   171     ReadFromResourceFileL(aReader);
       
   172     }
       
   173 
       
   174 
       
   175 void FindRootApplication(TInt aCount, TInt& aWgId, RArray<RWsSession::TWindowGroupChainInfo>* aWgIds )
       
   176     {
       
   177     // Go through all window group IDs looking for the current one
       
   178     for (TInt i=0;i<aCount;i++)
       
   179         {
       
   180         RWsSession::TWindowGroupChainInfo wgId=(*aWgIds)[i];
       
   181         
       
   182         if ( wgId.iId == aWgId ) // found my wg
       
   183         	{
       
   184             if (wgId.iParentId <= 0) // I'm standalone application
       
   185                 break;
       
   186             else
       
   187                 {
       
   188                 aWgId = wgId.iParentId;
       
   189                 FindRootApplication(aCount, aWgId, aWgIds);
       
   190                 }
       
   191         	}
       
   192         }
       
   193  
       
   194     }
       
   195 
       
   196 
       
   197 EXPORT_C void CAknContextPane::SetPictureToDefaultL()
       
   198     {
       
   199     if (iExtension->iDefaultContextImage)
       
   200         {
       
   201         CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
       
   202         CleanupStack::PushL(bitmap);                
       
   203         CFbsBitmap* mask = new (ELeave) CFbsBitmap();                
       
   204         
       
   205         if ( iExtension->iDefaultContextImage->Bitmap() )
       
   206             {
       
   207             bitmap->Duplicate(iExtension->iDefaultContextImage->Bitmap()->Handle());
       
   208             }
       
   209         if ( iExtension->iDefaultContextImage->Mask() )
       
   210             {
       
   211             mask->Duplicate(iExtension->iDefaultContextImage->Mask()->Handle());
       
   212             }
       
   213         SetPicture(bitmap, mask); 
       
   214         CleanupStack::Pop(); // bitmap
       
   215         return;
       
   216         }
       
   217 
       
   218     CFbsBitmap* bitmap = NULL;
       
   219     CFbsBitmap* mask = NULL;
       
   220 
       
   221     // statuspane
       
   222     TAknLayoutRect statuspane;
       
   223     statuspane.LayoutRect(iAvkonAppUi->ApplicationRect(), AknLayout::status_pane(iAvkonAppUi->ApplicationRect(),0));
       
   224        
       
   225     // context pane
       
   226     TAknWindowLineLayout contextPaneLayout = AknLayout::context_pane(statuspane.Rect(), 0);    
       
   227     TAknLayoutRect contextPaneLayoutRect;
       
   228     contextPaneLayoutRect.LayoutRect(statuspane.Rect(), contextPaneLayout);
       
   229     TRect contextPaneRect = contextPaneLayoutRect.Rect(); 
       
   230 
       
   231     // context pane elements    
       
   232     TAknWindowLineLayout contextPaneElements = 
       
   233         AknLayout::Context_pane_elements_Line_1();    
       
   234     TAknLayoutRect rect;
       
   235     rect.LayoutRect(contextPaneRect, contextPaneElements);
       
   236 
       
   237     // -- Wg chaining support ---
       
   238     RWsSession& ws = iEikonEnv->WsSession();    
       
   239 
       
   240     TInt wgCount=ws.NumWindowGroups();
       
   241 	TInt wgId = iEikonEnv->RootWin().Identifier();
       
   242     
       
   243     RArray<RWsSession::TWindowGroupChainInfo>* wgIds=new(ELeave) RArray<RWsSession::TWindowGroupChainInfo>(wgCount);
       
   244     CleanupStack::PushL(wgIds);
       
   245     CleanupClosePushL(*wgIds);
       
   246 
       
   247     User::LeaveIfError(ws.WindowGroupList(wgIds));
       
   248     
       
   249     FindRootApplication(wgCount, wgId, wgIds );
       
   250     
       
   251 	CleanupStack::PopAndDestroy(2);  // wgids
       
   252 	
       
   253     CApaWindowGroupName* windowName = CApaWindowGroupName::NewLC(ws, wgId);
       
   254     TUid appUid  = windowName->AppUid();
       
   255 	CleanupStack::PopAndDestroy();  //windowName
       
   256 
       
   257     // ------
       
   258 
       
   259     AknsUtils::CreateAppIconLC( AknsUtils::SkinInstance(), 
       
   260         appUid, EAknsAppIconTypeContext,
       
   261         bitmap, mask );
       
   262     
       
   263     SetPictureSize( bitmap, 
       
   264         rect.Rect().Size() ) ;
       
   265 
       
   266     iExtension->iDefaultContextImage = new (ELeave) CEikImage;
       
   267     CFbsBitmap* defaultBitmap = new (ELeave) CFbsBitmap();
       
   268     CleanupStack::PushL(defaultBitmap);                
       
   269     CFbsBitmap* defaultMask = new (ELeave) CFbsBitmap();                
       
   270     defaultBitmap->Duplicate(bitmap->Handle());
       
   271     defaultMask->Duplicate(mask->Handle());
       
   272     iExtension->iDefaultContextImage->SetPicture(defaultBitmap, defaultMask);
       
   273     iExtension->iDefaultContextImage->SetPictureOwnedExternally(EFalse);
       
   274 
       
   275     // ownership of the defaultBitmap moved to iDefaultContextImage.
       
   276     CleanupStack::Pop( 3 ); // defaultBitmap,  mask, bitmap
       
   277     SetPicture( bitmap, mask );    
       
   278     }
       
   279 
       
   280 EXPORT_C const CEikImage& CAknContextPane::Picture() const
       
   281     {
       
   282     return *(iExtension->iContextImage);
       
   283     }
       
   284 
       
   285 EXPORT_C CEikImage* CAknContextPane::SwapPicture(CEikImage* aNewImage)
       
   286     {
       
   287     CEikImage* previousImage = iExtension->iContextImage;
       
   288     iExtension->iContextImage = aNewImage;
       
   289     if (iExtension->iContextImage)
       
   290         {
       
   291         if (!iExtension->iContextImage->DrawableWindow())
       
   292             {
       
   293             TRAP_IGNORE( iExtension->iContextImage->SetContainerWindowL(*this) );
       
   294             }
       
   295 
       
   296         __ASSERT_DEBUG(iExtension->iContextImage->DrawableWindow(), Panic(EAknPanicNullPointer));
       
   297 
       
   298         iExtension->iContextImage->SetPictureOwnedExternally(EFalse);
       
   299         }
       
   300     SizeChanged();
       
   301     DrawNow();
       
   302     
       
   303     return previousImage;
       
   304     }
       
   305 
       
   306 
       
   307 EXPORT_C void CAknContextPane::SizeChanged()
       
   308     {
       
   309     if (Rect() != TRect(0,0,0,0)) // Fix for Parent getting parent relative data. 
       
   310         {
       
   311         if (iExtension->iContextImage && iExtension->iContextImage->Bitmap()) 
       
   312             {
       
   313             TAknLayoutRect layoutRect;
       
   314             layoutRect.LayoutRect(Rect(), AknLayout::Context_pane_elements_Line_1());
       
   315 
       
   316             TBool sameIcons = EFalse;
       
   317 
       
   318             if ( iExtension->iDefaultContextImage &&
       
   319                  iExtension->iDefaultContextImage->Bitmap() &&
       
   320                  iExtension->iDefaultContextImage->Bitmap()->Handle() ==
       
   321                  iExtension->iContextImage->Bitmap()->Handle() )
       
   322                 {
       
   323                 sameIcons = ETrue;
       
   324                 }
       
   325         
       
   326             // This potentially changes bitmap handles.
       
   327             SetPictureSize( const_cast<CFbsBitmap*>( iExtension->iContextImage->Bitmap() ),
       
   328                 layoutRect.Rect().Size());
       
   329 
       
   330             if ( sameIcons )
       
   331                 {
       
   332                 // Must duplicate again after SetSize.
       
   333                 CFbsBitmap* bitmap = const_cast<CFbsBitmap*>(
       
   334                     iExtension->iDefaultContextImage->Bitmap() );
       
   335                 CFbsBitmap* mask = const_cast<CFbsBitmap*>(
       
   336                     iExtension->iDefaultContextImage->Mask() );
       
   337 
       
   338                 if ( bitmap )
       
   339                     {
       
   340                     // ignore error
       
   341                     bitmap->Duplicate( iExtension->iContextImage->Bitmap()->Handle() );
       
   342                     }
       
   343 
       
   344                 if ( mask )
       
   345                     {
       
   346                     // ignore error
       
   347                     mask->Duplicate( iExtension->iContextImage->Mask()->Handle() );
       
   348                     }
       
   349                 }
       
   350 
       
   351             TSize bmpSize=iExtension->iContextImage->Bitmap()->SizeInPixels();
       
   352             TGulAlignment iAlignment;
       
   353             iAlignment.SetHAlignment(EHCenter);
       
   354             iAlignment.SetVAlignment(EVCenter);
       
   355             iExtension->iContextImage->SetRect(iAlignment.InnerRect(Rect(),bmpSize));
       
   356             AknsUtils::RegisterControlPosition( iExtension->iContextImage );
       
   357             }
       
   358         AknsUtils::RegisterControlPosition( this );
       
   359         }
       
   360     }
       
   361 
       
   362 
       
   363 EXPORT_C void CAknContextPane::HandleResourceChange( TInt aType ) 
       
   364     {
       
   365     if ( aType == KEikColorResourceChange || aType==KEikDynamicLayoutVariantSwitch )
       
   366         {
       
   367         DrawDeferred();
       
   368         }
       
   369     else if( aType == KAknsMessageSkinChange )
       
   370         {
       
   371         if( iExtension->iDefaultContextImage && iExtension->iContextImage )
       
   372             {
       
   373             const CFbsBitmap* defBmp = iExtension->iDefaultContextImage->Bitmap();
       
   374             const CFbsBitmap* bmp = iExtension->iContextImage->Bitmap();
       
   375             if( defBmp && bmp )
       
   376                 {
       
   377                 // Update icon only if the default context image is used.
       
   378                 // Otherwise, the application is responsible of updating the
       
   379                 // image upon skin change (since it has set a non-default image).
       
   380                 if( defBmp->Handle() == bmp->Handle() )
       
   381                     {
       
   382                     delete iExtension->iDefaultContextImage;
       
   383                     iExtension->iDefaultContextImage = NULL;
       
   384                     TRAP_IGNORE(SetPictureToDefaultL()); // Ignore error
       
   385                     }
       
   386                 }
       
   387             }
       
   388         }
       
   389     }
       
   390 
       
   391 
       
   392 EXPORT_C TInt CAknContextPane::CountComponentControls() const
       
   393     {
       
   394     if (iExtension->iContextImage)
       
   395         {
       
   396         return 1;
       
   397         }
       
   398     return 0;
       
   399     }
       
   400 
       
   401 
       
   402 EXPORT_C CCoeControl* CAknContextPane::ComponentControl(TInt /*aIndex*/) const
       
   403     {
       
   404     return (iExtension->iContextImage);
       
   405     }
       
   406 
       
   407 
       
   408 EXPORT_C void CAknContextPane::Draw(const TRect& /*aRect*/) const
       
   409     {
       
   410     CWindowGc& gc=SystemGc();
       
   411 
       
   412     // screen
       
   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();
       
   477     MAknsControlContext* cc = AknsDrawUtils::ControlContext(this);
       
   478 
       
   479         // Solid or wipe comes from background
       
   480     if( !AknsDrawUtils::Background( skin, cc, this, gc, rect ) )
       
   481         {
       
   482         // Default drawing if skinning is not available
       
   483         gc.Clear(rect); 
       
   484         gc.SetPenStyle(CGraphicsContext::ENullPen);
       
   485         gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   486         gc.SetBrushColor(AKN_LAF_COLOR(KStatusPaneBackgroundGraphicsColorUsual));
       
   487         gc.DrawRect(barRect);
       
   488         }
       
   489     }
       
   490 
       
   491 
       
   492 void CAknContextPane::CommonConstructL()
       
   493     {
       
   494     InitL();
       
   495     // Wipe is never used initally anymore 
       
   496     SetNaviPaneBackgroundType( EAknNaviPaneBackgroundTypeSolid );
       
   497     }
       
   498 
       
   499 
       
   500 TUid CAknContextPane::AppUid()
       
   501     {
       
   502     // Returns application's Uid. 
       
   503     // In embedded applications, root application's Uid is returned.
       
   504     CEikAppUi* root = iEikonEnv->EikAppUi();
       
   505     while (root->ContainerAppUi())
       
   506         {
       
   507         root = root->ContainerAppUi();
       
   508         }
       
   509     
       
   510     CEikApplication* app = root->Application();
       
   511     if (app)
       
   512         {
       
   513         return app->AppDllUid();
       
   514         }
       
   515     return KNullUid;
       
   516     }
       
   517 
       
   518 
       
   519 void CAknContextPane::ReadFromResourceFileL(TResourceReader& aReader)
       
   520     {
       
   521     HBufC* bitmapFile = aReader.ReadHBufCL();	// bmp filename
       
   522     TInt bitmapId = aReader.ReadInt16();	// bmp id
       
   523     TInt maskId = aReader.ReadInt16();	// bmp mask id
       
   524     
       
   525     if ( bitmapFile ) 
       
   526         {
       
   527         CleanupStack::PushL(bitmapFile);
       
   528         if (bitmapId != -1)
       
   529             {
       
   530             SetPictureFromFileL(*bitmapFile, bitmapId, maskId);
       
   531             }
       
   532         CleanupStack::PopAndDestroy();  // bitmapFile
       
   533         }
       
   534     else
       
   535         {
       
   536         TRAP_IGNORE(SetPictureToDefaultL()); // Trapped because of Java midlet issues
       
   537         }
       
   538     }
       
   539 
       
   540 void CAknContextPane::LoadNaviWipeBitmapL()
       
   541     {    
       
   542     // Naviwipe is no more used (since 3.0)
       
   543     }
       
   544 
       
   545 void CAknContextPane::SetNaviPaneBackgroundType( TInt /*aType*/ ) 
       
   546     {
       
   547     // Naviwipe is no more used (since 3.0)
       
   548     }
       
   549 
       
   550 EXPORT_C void CAknContextPane::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
       
   551     { 
       
   552     CAknControl::HandlePointerEventL(aPointerEvent); 
       
   553     }
       
   554 
       
   555 EXPORT_C void* CAknContextPane::ExtensionInterface( TUid /*aInterface*/ ) 
       
   556     { 
       
   557     return NULL;
       
   558     }
       
   559 
       
   560 TTypeUid::Ptr CAknContextPane::MopSupplyObject(TTypeUid aId)
       
   561     {
       
   562     if(aId.iUid == CAknContextPane::ETypeId)
       
   563         {
       
   564         // Return self, this code makes it possible to workaround the fact
       
   565         // that statuspane controls cannot be safely casted after
       
   566         // retrieving them using CEikStatusPaneBase::ControlL().
       
   567         // 
       
   568         // So now the caller could do something like this rather safely:
       
   569         //
       
   570         // CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
       
   571         // CAknContextPane* contextPane = NULL;
       
   572         //
       
   573         //if (statusPane && 
       
   574         //    statusPane->PaneCapabilities(TUid::Uid(EEikStatusPaneUidContext)).IsInCurrentLayout())
       
   575         //    {
       
   576         //    CCoeControl* control = statusPane->ControlL(TUid::Uid( EEikStatusPaneUidContext ));
       
   577         //    control->MopGetObject(contextPane);
       
   578         //    }
       
   579         //
       
   580         //if (contextPane)
       
   581         //  {
       
   582         //  // The retrieved control was type of CAknContextPane
       
   583         //  }
       
   584         //else
       
   585         //  {
       
   586         //  // The retrieved control was NOT type of CAknContextPane. 
       
   587         //  // Someone has perhaps swap the control in the statuspane.
       
   588         //  }
       
   589         return aId.MakePtr(this);
       
   590         }
       
   591 
       
   592     return CCoeControl::MopSupplyObject(aId);
       
   593     }
       
   594 
       
   595 void CAknContextPane::InitL()
       
   596     {
       
   597     if (!iExtension)
       
   598         {
       
   599         iExtension = new (ELeave) CAknContextPaneExtension(); 
       
   600         }
       
   601     iExtension->iContextImage = new (ELeave) CEikImage;
       
   602     iExtension->iContextImage->SetContainerWindowL(*this);
       
   603 	__ASSERT_DEBUG(iExtension->iContextImage->DrawableWindow(), Panic(EAknPanicNullPointer));
       
   604     iExtension->iContextImage->SetNonFocusing();
       
   605     iExtension->iContextImage->SetAlignment(EHCenterVCenter);
       
   606     }
       
   607 
       
   608 void CAknContextPane::SetPictureSize(CFbsBitmap* aPicture, TSize aSize)
       
   609     {
       
   610     const TSize KLegacyScreenSize = TSize(176,208);
       
   611     const TSize KLegacyPictureMaxSize = TSize(44,44);
       
   612     
       
   613     if (!aPicture)
       
   614         return;
       
   615 
       
   616     TRect screenRect = iAvkonAppUi->ApplicationRect();
       
   617     TSize originalSize = aPicture->SizeInPixels();
       
   618     
       
   619     TBool isLegacyScreenSize = 
       
   620         (screenRect.Height() == KLegacyScreenSize.iHeight && 
       
   621          screenRect.Width() == KLegacyScreenSize.iWidth);
       
   622 
       
   623     TBool isBitmap = !AknIconUtils::IsMifIcon(aPicture);        
       
   624 
       
   625     TBool isBitmapValidLegacySize = 
       
   626         (originalSize.iHeight <= KLegacyPictureMaxSize.iHeight &&
       
   627          originalSize.iWidth <= KLegacyPictureMaxSize.iWidth);
       
   628 
       
   629     // If we are in legacy screen size and the given bitmap is bitmap (not SVG originated)
       
   630     // and its size is ok we don't set the size. This is done because
       
   631     // some legacy app have contextpane icons sizes other than
       
   632     // 44x44 and those look better if left not scaled.
       
   633     if (isLegacyScreenSize && 
       
   634         isBitmap &&
       
   635         isBitmapValidLegacySize)        
       
   636         {
       
   637         return;
       
   638         }
       
   639 
       
   640     // Perf optimization: We dont set the size if context pane is not in current status pane layout. When
       
   641     // status pane layout changes, this method will be called again and size is set then.
       
   642     CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
       
   643    	if (statusPane && statusPane->PaneCapabilities(TUid::Uid(EEikStatusPaneUidContext)).IsInCurrentLayout())
       
   644    		{
       
   645 		AknIconUtils::SetSize( aPicture, aSize);
       
   646    		}
       
   647     }
       
   648 
       
   649 
       
   650 //  End of File  
       
   651 
       
   652