textinput/peninputcommonctrls/src/peninputbuttons/peninputbutton.cpp
branchRCL_3
changeset 44 ecbabf52600f
child 50 5a1685599b76
equal deleted inserted replaced
43:ebd48d2de13c 44:ecbabf52600f
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  Implementation of button
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // system includes
       
    20 #include <barsread.h>
       
    21 #include <peninputlayout.h>
       
    22 #include <AknIconUtils.h>
       
    23 #include <coemain.h>
       
    24 #include <AknsUtils.h>
       
    25 #include <AknUtils.h>
       
    26 #include <AknsDrawUtils.h> 
       
    27 // user includes
       
    28 #include <peninputbutton.h>
       
    29 #include <peninputdragbutton.h>
       
    30 #include <peninputeventbutton.h>
       
    31 #include <peninputmultimodebutton.h>
       
    32 #include <peninputrepeatbutton.h>
       
    33 #include <peninputrawkeybutton.h>
       
    34 #include <peninputcommonbutton.h>
       
    35 #include <peninputmultiimagebutton.h>
       
    36 #include <peninputcommonctrls.hrh>
       
    37 #include <peninputcommonlayoutglobalenum.h>
       
    38 #include <peninputlongpressbutton.h>
       
    39 
       
    40 const TInt KInvalidBmp = -1 ;
       
    41 
       
    42 //default value for long press timer
       
    43 const TInt KLongPressInterval = 600000;
       
    44 
       
    45 //default value for repeat timer
       
    46 const TInt KRepeatInterval = 100000;
       
    47 
       
    48 //default text color and shadow text color
       
    49 const TUint32 KDefaultTextColor = 0x000000;
       
    50 const TUint32 KDefaultShadowTextColor = 0xffffff;
       
    51 const TInt32 KInvalidResId = -1;
       
    52 const TInt KInvalidEventId = 0xffff;
       
    53 //const TInt KFadingParamBlack = 255;
       
    54 //const TInt KFadingParamWhite = 0;
       
    55 
       
    56 const TInt KTransparency[256] =
       
    57     { 
       
    58     0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7,
       
    59     8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 13, 13, 13,
       
    60     14, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 19,
       
    61     19, 19, 20, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 23, 24, 24,
       
    62     24, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29,
       
    63     30, 30, 30, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35,
       
    64     35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 38, 38, 39, 39, 39, 40, 40, 40,
       
    65     41, 41, 41, 41, 42, 42, 42, 43, 43, 43, 44, 44, 44, 44, 45, 45, 45, 46,
       
    66     46, 46, 47, 47, 47, 47, 48, 48, 48, 49, 49, 49, 50, 50, 50, 50, 51, 51,
       
    67     51, 52, 52, 52, 53, 53, 53, 53, 54, 54, 54, 55, 55, 55, 56, 56, 56, 56,
       
    68     57, 57, 57, 58, 58, 58, 59, 59, 59, 59, 60, 60, 60, 61, 61, 61, 62, 62,
       
    69     62, 62, 63, 63, 63, 64, 64, 64, 65, 65, 65, 65, 66, 66, 66, 67, 67, 67,
       
    70     68, 68, 68, 68, 69, 69, 69, 70, 70, 70, 71, 71, 71, 71, 72, 72, 72, 73,
       
    71     73, 73, 74, 74, 74, 74, 75, 75, 75, 76, 76, 76, 77, 77 
       
    72     };
       
    73 // Invalid function icon color group
       
    74 const TInt KInvalidColorGroup = -1;
       
    75 
       
    76 // ======== MEMBER FUNCTIONS ========
       
    77    
       
    78 // ---------------------------------------------------------------------------
       
    79 // CAknFepCtrlButton::CAknFepCtrlButton
       
    80 // C++ default constructor can NOT contain any code, that
       
    81 // might leave.
       
    82 // (other items were commented in a header).
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 EXPORT_C CAknFepCtrlButton::CAknFepCtrlButton(CFepUiLayout* aUiLayout, TInt aControlId)
       
    86 : CButtonBase(TRect(), aUiLayout, aControlId), iFirstTimeConstruct(ETrue), iHighlight(EFalse) 
       
    87     {
       
    88     }
       
    89     
       
    90 // ---------------------------------------------------------------------------
       
    91 // CAknFepCtrlButton::NewL
       
    92 // Two-phased constructor.
       
    93 // (other items were commented in a header).
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 EXPORT_C CAknFepCtrlButton* CAknFepCtrlButton::NewL(CFepUiLayout* aUiLayout, TInt aControlId)
       
    97     {
       
    98     CAknFepCtrlButton* self = NewLC(aUiLayout, aControlId);
       
    99     CleanupStack::Pop(self);
       
   100     
       
   101     return self;
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // CAknFepCtrlButton::NewLC
       
   106 // Two-phased constructor.
       
   107 // (other items were commented in a header).
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 EXPORT_C CAknFepCtrlButton* CAknFepCtrlButton::NewLC(CFepUiLayout* aUiLayout, TInt aControlId)
       
   111     {
       
   112     CAknFepCtrlButton* self = new (ELeave) CAknFepCtrlButton(aUiLayout, aControlId);
       
   113     CleanupStack::PushL(self);
       
   114     self->BaseConstructL();
       
   115 
       
   116     return self;
       
   117     }    
       
   118     
       
   119 // -----------------------------------------------------------------------------
       
   120 // Destructor.
       
   121 // (other items were commented in a header).
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 EXPORT_C CAknFepCtrlButton::~CAknFepCtrlButton()
       
   125     {
       
   126     iBmpList.Close();
       
   127     iMaskBmpList.Close();
       
   128     }
       
   129 // ---------------------------------------------------------------------------
       
   130 // CAknFepCtrlButton::ConstructFromResourceL
       
   131 // The order of the image ids in the CButtonBase class must not be changed
       
   132 // (other items were commented in a header).
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 EXPORT_C void CAknFepCtrlButton::ConstructFromResourceL(TResourceReader& aReader)
       
   136     {
       
   137 	if (!iFirstTimeConstruct)
       
   138 		{
       
   139         iBmpList.Close();
       
   140         iMaskBmpList.Close();
       
   141         ResetBmpPool();
       
   142 		}
       
   143     
       
   144     TPtrC bmpFileName = aReader.ReadTPtrC();    // Read the file name of the bmps
       
   145     TInt32 imgMajorSkinId = aReader.ReadInt32();
       
   146    	TInt colorgroup = aReader.ReadInt16();
       
   147     TAknsItemID id;
       
   148 
       
   149     for (TInt ii = 0; ii < EBtnBmpLastType + 1; ++ii)
       
   150         {
       
   151         // Get the image ids and mask ids from resource
       
   152         TInt bmpId = aReader.ReadInt16(); 
       
   153         TInt bmpMskId = aReader.ReadInt16();
       
   154         
       
   155         // read skin item id
       
   156         const TInt skinitemid = aReader.ReadInt16();
       
   157         id.Set(TInt(imgMajorSkinId), skinitemid);
       
   158         
       
   159         if (bmpId != KInvalidBmp)
       
   160             {
       
   161         	CFbsBitmap* bmp = NULL;
       
   162         	CFbsBitmap* maskbmp = NULL;
       
   163 
       
   164         	if (bmpMskId != KInvalidBmp)
       
   165         		{
       
   166         		AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
   167         		                       id,
       
   168         		                       bmp,
       
   169         		                       maskbmp,
       
   170         		                       bmpFileName,
       
   171         		                       bmpId,
       
   172         		                       bmpMskId);
       
   173         		
       
   174        		    // set maskbmp and size
       
   175                 SetMaskBitmapL(maskbmp, TButtonBmpType(EBtnBmpNonActive + ii));
       
   176                 iMaskBmpList.Append(maskbmp);
       
   177                 }
       
   178             else
       
   179                 {
       
   180         	    AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
   181         	                           id,
       
   182         	                           bmp,
       
   183         	                           bmpFileName,
       
   184         	                           bmpId);
       
   185                 }
       
   186 
       
   187             // set bmp and size
       
   188             SetBitmapL(bmp, TButtonBmpType(EBtnBmpNonActive + ii));
       
   189             iBmpList.Append(bmp);
       
   190             }
       
   191         }
       
   192 
       
   193     if (!iFirstTimeConstruct)
       
   194     	{
       
   195         ResizeBitmaps(Rect().Size());
       
   196     	Draw();
       
   197     	}
       
   198     
       
   199     iFirstTimeConstruct = EFalse;    
       
   200     }
       
   201     
       
   202 // ---------------------------------------------------------------------------
       
   203 // CAknFepCtrlButton::ConstructFromResourceL
       
   204 // (other items were commented in a header).
       
   205 // ---------------------------------------------------------------------------
       
   206 //
       
   207 EXPORT_C void CAknFepCtrlButton::ConstructFromResourceL()
       
   208 	{
       
   209 	if (iResourceId == KInvalidResId)
       
   210 		{
       
   211         User::Leave(KErrArgument);
       
   212 		}
       
   213 	
       
   214 	if (!iFirstTimeConstruct)
       
   215 		{
       
   216 		// need to remove original bmp and maskbmp
       
   217         iBmpList.Close();
       
   218         iMaskBmpList.Close();
       
   219         ResetBmpPool();
       
   220 		}
       
   221 
       
   222     TResourceReader reader;
       
   223     CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId);
       
   224 
       
   225     TPtrC bmpFileName = reader.ReadTPtrC();    // Read the file name of the bmps
       
   226     TInt32 imgMajorSkinId = reader.ReadInt32();
       
   227     TInt colorgroup = reader.ReadInt16();
       
   228     TAknsItemID id;
       
   229 
       
   230     for (TInt ii = 0; ii < EBtnBmpLastType + 1; ++ii)
       
   231         {
       
   232         // Get the image ids and mask ids from resource
       
   233         TInt bmpId = reader.ReadInt16(); 
       
   234         TInt bmpMskId = reader.ReadInt16();
       
   235         
       
   236         // read skin item id
       
   237         const TInt skinitemid = reader.ReadInt16();
       
   238         id.Set(TInt(imgMajorSkinId), skinitemid);
       
   239         
       
   240         if (bmpId != KInvalidBmp)
       
   241             {
       
   242         	CFbsBitmap* bmp = NULL;
       
   243         	CFbsBitmap* maskbmp = NULL;
       
   244 
       
   245         	if (bmpMskId != KInvalidBmp)
       
   246         		{
       
   247         		AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
   248         		                       id,
       
   249         		                       bmp,
       
   250         		                       maskbmp,
       
   251         		                       bmpFileName,
       
   252         		                       bmpId,
       
   253         		                       bmpMskId);
       
   254         		
       
   255        		    // set maskbmp and size
       
   256                 SetMaskBitmapL(maskbmp, TButtonBmpType(EBtnBmpNonActive + ii));
       
   257                 iMaskBmpList.Append(maskbmp);
       
   258                 }
       
   259             else
       
   260                 {
       
   261         	    AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
   262         	                           id,
       
   263         	                           bmp,
       
   264         	                           bmpFileName,
       
   265         	                           bmpId);
       
   266                 }
       
   267 
       
   268             // set bmp and size
       
   269             SetBitmapL(bmp, TButtonBmpType(EBtnBmpNonActive + ii));
       
   270             iBmpList.Append(bmp);
       
   271             }
       
   272         }
       
   273         
       
   274     CleanupStack::PopAndDestroy(); // reader
       
   275     
       
   276     if (!iFirstTimeConstruct)
       
   277     	{
       
   278         ResizeBitmaps(Rect().Size());
       
   279     	Draw();
       
   280     	}
       
   281 
       
   282     iFirstTimeConstruct = EFalse;    	
       
   283 	}
       
   284 
       
   285 // ---------------------------------------------------------------------------
       
   286 // CAknFepCtrlButton::Draw
       
   287 // Draws UI
       
   288 // (other items were commented in a header).
       
   289 // ---------------------------------------------------------------------------
       
   290 //
       
   291 EXPORT_C void CAknFepCtrlButton::Draw()
       
   292     {
       
   293 	if(!AbleToDraw())
       
   294         return;
       
   295     
       
   296     if ( !BackgroundBmp() )
       
   297         {
       
   298         CButtonBase::Draw();
       
   299         }
       
   300 
       
   301     CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());        
       
   302     
       
   303     //mask bitmaps
       
   304     gc->Activate( MaskBitmapDevice() );
       
   305    
       
   306     gc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   307     gc->SetBrushColor( TRgb(KOpaqueColor));//Non transparent at all
       
   308     gc->SetPenStyle(CGraphicsContext::ESolidPen );
       
   309     gc->SetPenSize( PenSize());
       
   310     gc->SetPenColor( TRgb(KOpaqueColor) );
       
   311     gc->DrawRect(Rect());   
       
   312 
       
   313     // ----- draw bitmaps -----
       
   314     gc->Activate( BitmapDevice() );   
       
   315     if ( BackgroundBmp() )
       
   316         {
       
   317         TSize size=BackgroundBmp()->SizeInPixels();
       
   318     
       
   319         gc->DrawBitmap(Rect(), BackgroundBmp(),size);
       
   320         }
       
   321     }
       
   322     
       
   323 // ---------------------------------------------------------------------------
       
   324 // CAknFepCtrlButton::SetActive
       
   325 // Set active for the button
       
   326 // (other items were commented in a header).
       
   327 // ---------------------------------------------------------------------------
       
   328 //
       
   329 EXPORT_C void CAknFepCtrlButton::SetActive(TBool aActiveFlag)
       
   330     {
       
   331     if( IsDimmed() )
       
   332         {
       
   333         return;
       
   334         }
       
   335         
       
   336     if(IsActive() != aActiveFlag)
       
   337         {
       
   338         CFepUiBaseCtrl::SetActive(aActiveFlag);
       
   339         if(aActiveFlag || iHighlight)
       
   340             {               
       
   341             SetBackgroundBmp(Bitmap(EBtnBmpActive,EFalse));
       
   342             SetBackgroundMaskBmp(Bitmap(EBtnBmpActive,ETrue));
       
   343             //Hide(EFalse);   //active button won't be Hiden ???
       
   344             }
       
   345         else
       
   346             {
       
   347             SetBackgroundBmp(Bitmap(EBtnBmpNonActive,EFalse));
       
   348             SetBackgroundMaskBmp(Bitmap(EBtnBmpNonActive,ETrue));
       
   349             }
       
   350         if(BitGc())
       
   351             {       
       
   352             Draw();
       
   353             UpdateArea(Rect(),EFalse);
       
   354             }
       
   355         }
       
   356     }
       
   357 
       
   358 // ---------------------------------------------------------------------------
       
   359 // CAknFepCtrlButton::SetHighlight
       
   360 // Set highlight for the button
       
   361 // (other items were commented in a header).
       
   362 // ---------------------------------------------------------------------------
       
   363 //    
       
   364 EXPORT_C void CAknFepCtrlButton::SetHighlight(TBool aIsHighlight)
       
   365     {
       
   366     iHighlight = aIsHighlight;
       
   367 
       
   368     if ( iHighlight )
       
   369         {
       
   370         SetBackgroundBmp(Bitmap(EBtnBmpActive,EFalse));
       
   371         SetBackgroundMaskBmp(Bitmap(EBtnBmpActive,ETrue));            
       
   372         }
       
   373     else
       
   374         {
       
   375         SetBackgroundBmp(Bitmap(EBtnBmpNonActive,EFalse));
       
   376         SetBackgroundMaskBmp(Bitmap(EBtnBmpNonActive,ETrue));
       
   377         }
       
   378     Draw();
       
   379     UpdateArea(Rect(), EFalse);         
       
   380     }
       
   381     
       
   382 // ---------------------------------------------------------------------------
       
   383 // CAknFepCtrlButton::ResizeBitmaps
       
   384 // This methods shall be called by the container's SizeChanged handler
       
   385 // (other items were commented in a header).
       
   386 // ---------------------------------------------------------------------------
       
   387 //
       
   388 void CAknFepCtrlButton::ResizeBitmaps(TSize aSize)
       
   389     {
       
   390     if (iMaskBmpList.Count() >= 1 && 
       
   391         iMaskBmpList[0]->SizeInPixels() != aSize)
       
   392         {
       
   393         for( int ii = 0; ii < iMaskBmpList.Count(); ++ii )
       
   394             {
       
   395           	AknIconUtils::SetSize(iMaskBmpList[ii], aSize, EAspectRatioNotPreserved);
       
   396             }
       
   397         }
       
   398 
       
   399     if (iBmpList.Count() >= 1 &&
       
   400         iBmpList[0]->SizeInPixels() != aSize)
       
   401         {
       
   402         for( int ii = 0; ii < iBmpList.Count(); ++ii )
       
   403             {
       
   404        	    AknIconUtils::SetSize(iBmpList[ii], aSize, EAspectRatioNotPreserved);
       
   405             }
       
   406         }
       
   407     }
       
   408     
       
   409 // ---------------------------------------------------------------------------
       
   410 // CAknFepCtrlButton::SizeChanged
       
   411 // This methods shall be called by the container's SizeChanged handler
       
   412 // (other items were commented in a header).
       
   413 // ---------------------------------------------------------------------------
       
   414 //
       
   415 EXPORT_C void CAknFepCtrlButton::SizeChanged(TRect aNewRect, TBool aIsReloadImages)
       
   416     {
       
   417     if ((aNewRect.Size().iWidth == 0 || aNewRect.Size().iHeight == 0) &&
       
   418         (ControlId() != EPeninupWindowCtrlIdArrowLeftBtn && 
       
   419          ControlId() != EPeninupWindowCtrlIdArrowRightBtn))
       
   420         {
       
   421    	    return;
       
   422         }
       
   423     
       
   424     SetRect(aNewRect);
       
   425 
       
   426     //if (aIsReloadImages)
       
   427         {
       
   428         ResizeBitmaps(aNewRect.Size());	
       
   429         }
       
   430 
       
   431     Draw();
       
   432     UpdateArea(Rect(), EFalse);
       
   433     }
       
   434 
       
   435 // ---------------------------------------------------------------------------
       
   436 // CAknFepCtrlButton::HandlePointerLeave
       
   437 // Handle pointer leave event
       
   438 // ---------------------------------------------------------------------------
       
   439 //           
       
   440 void CAknFepCtrlButton::HandlePointerLeave(const TPoint& aPt)
       
   441     {
       
   442     if( IsDimmed() )
       
   443         return;
       
   444     if( iHighlight )
       
   445         {
       
   446         SetBackgroundBmp(iActiveBmp);
       
   447         SetBackgroundMaskBmp(iActiveMaskBmp);
       
   448         }
       
   449         
       
   450     else
       
   451         {
       
   452         SetBackgroundBmp(iNonActiveBkBmp);
       
   453         SetBackgroundMaskBmp(iNonActiveBkMaskBmp);
       
   454         }
       
   455     Draw();
       
   456     UpdateArea(Rect(), EFalse);   
       
   457     CFepUiBaseCtrl::HandlePointerLeave(aPt);
       
   458     return ;
       
   459     }
       
   460     
       
   461 // -----------------------------------------------------------------------------
       
   462 // CAknFepCtrlDragButton::CAknFepCtrlDragButton
       
   463 // C++ default constructor can NOT contain any code, that
       
   464 // might leave.
       
   465 // -----------------------------------------------------------------------------
       
   466 //
       
   467 EXPORT_C CAknFepCtrlDragButton::CAknFepCtrlDragButton(CFepUiLayout* aUiLayout, TInt aControlId)
       
   468 : CDragBar(TRect(), aUiLayout, aControlId), iFirstTimeConstruct(ETrue)
       
   469     {
       
   470     }
       
   471     
       
   472 // -----------------------------------------------------------------------------
       
   473 // Destructor.
       
   474 // (other items were commented in a header).
       
   475 // -----------------------------------------------------------------------------
       
   476 //
       
   477 EXPORT_C CAknFepCtrlDragButton::~CAknFepCtrlDragButton()
       
   478     {
       
   479     iBmpList.Close();
       
   480     iMaskBmpList.Close();
       
   481     
       
   482 	DeleteForgroundRes();
       
   483     delete iText;    
       
   484     }
       
   485 
       
   486     
       
   487 // -----------------------------------------------------------------------------
       
   488 // CAknFepCtrlDragButton::NewL
       
   489 // Two-phased constructor.
       
   490 // -----------------------------------------------------------------------------
       
   491 //
       
   492 EXPORT_C CAknFepCtrlDragButton* CAknFepCtrlDragButton::NewL(CFepUiLayout* aUiLayout, 
       
   493                                                             TInt aControlId)
       
   494     {
       
   495     CAknFepCtrlDragButton* self = NewLC(aUiLayout, aControlId);
       
   496     CleanupStack::Pop(self);
       
   497 
       
   498     return self;
       
   499     }
       
   500 
       
   501 // -----------------------------------------------------------------------------
       
   502 // CAknFepCtrlDragButton::NewLC
       
   503 // Two-phased constructor.
       
   504 // -----------------------------------------------------------------------------
       
   505 //
       
   506 EXPORT_C CAknFepCtrlDragButton* CAknFepCtrlDragButton::NewLC(CFepUiLayout* aUiLayout, 
       
   507                                                              TInt aControlId)
       
   508     {
       
   509     CAknFepCtrlDragButton* self = new (ELeave) CAknFepCtrlDragButton(aUiLayout, aControlId);
       
   510     CleanupStack::PushL(self);
       
   511     self->ConstructL();
       
   512 
       
   513     return self;
       
   514     }    
       
   515     
       
   516 // -----------------------------------------------------------------------------
       
   517 // CAknFepCtrlDragButton::ConstructFromResourceL
       
   518 // The order of the image ids in the CButtonBase class must not be changed
       
   519 // (other items were commented in a header).
       
   520 // -----------------------------------------------------------------------------
       
   521 //
       
   522 EXPORT_C void CAknFepCtrlDragButton::ConstructFromResourceL(TResourceReader& aReader)
       
   523     {
       
   524     /*
       
   525 	if (!iFirstTimeConstruct)
       
   526 		{
       
   527         iBmpList.Close();
       
   528         iMaskBmpList.Close();
       
   529         ResetBmpPool();
       
   530 		}
       
   531     
       
   532     TPtrC bmpFileName = aReader.ReadTPtrC();
       
   533     TInt32 imgMajorSkinId = aReader.ReadInt32();
       
   534     TAknsItemID id;
       
   535 
       
   536     for (TInt ii = 0; ii < EBtnBmpLastType + 1; ++ii)
       
   537         {
       
   538         const TInt16 bmpId = aReader.ReadInt16();
       
   539         const TInt16 bmpMskId = aReader.ReadInt16();
       
   540         
       
   541         // read skin item id
       
   542         const TInt skinitemid = aReader.ReadInt16();
       
   543         id.Set(TInt(imgMajorSkinId), skinitemid);
       
   544         
       
   545         if (bmpId != KInvalidBmp)
       
   546             {
       
   547         	CFbsBitmap* bmp = NULL;
       
   548         	CFbsBitmap* maskbmp = NULL;
       
   549 
       
   550         	if (bmpMskId != KInvalidBmp)
       
   551         		{
       
   552         		AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
   553         		                       id,
       
   554         		                       bmp,
       
   555         		                       maskbmp,
       
   556         		                       bmpFileName,
       
   557         		                       bmpId,
       
   558         		                       bmpMskId);
       
   559         		
       
   560                 SetMaskBitmapL(maskbmp, TButtonBmpType(EBtnBmpNonActive + ii));
       
   561                 iMaskBmpList.Append(maskbmp);
       
   562                 }
       
   563             else
       
   564                 {
       
   565         	    AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
   566         	                           id,
       
   567         	                           bmp,
       
   568         	                           bmpFileName,
       
   569         	                           bmpId);
       
   570                 }
       
   571 
       
   572             SetBitmapL(bmp, TButtonBmpType(EBtnBmpNonActive + ii));
       
   573             iBmpList.Append(bmp);
       
   574             }
       
   575         }
       
   576     
       
   577     if (!iFirstTimeConstruct)
       
   578     	{
       
   579         ResizeBitmaps(Rect().Size());
       
   580     	Draw();
       
   581     	}
       
   582     
       
   583     iFirstTimeConstruct = EFalse;*/
       
   584 	if (!iFirstTimeConstruct)
       
   585 		{
       
   586         DeleteForgroundRes();
       
   587 		}
       
   588     
       
   589     TPtrC bmpFileName = aReader.ReadTPtrC();    // Read the file name of the bmps
       
   590     TInt32 imgMajorSkinId = aReader.ReadInt32();
       
   591     TInt colorGroup = aReader.ReadInt16();
       
   592     TAknsItemID id;
       
   593 	
       
   594     // Get the image ids and mask ids from resource
       
   595     TInt bmpId = aReader.ReadInt16(); 
       
   596     TInt bmpMskId = aReader.ReadInt16();
       
   597     
       
   598     // read skin item id
       
   599     const TInt skinitemid = aReader.ReadInt16();
       
   600     id.Set(TInt(imgMajorSkinId), skinitemid);
       
   601     
       
   602     if (bmpId != KInvalidBmp)
       
   603         {
       
   604     	if (bmpMskId != KInvalidBmp)
       
   605     		{
       
   606     		if( colorGroup == KInvalidColorGroup )
       
   607     			{
       
   608 	    		AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
   609                        id,
       
   610                        iForgroundBmp,
       
   611                        iForgroundBmpMask,
       
   612                        bmpFileName,
       
   613                        bmpId,
       
   614                        bmpMskId);	
       
   615     			}
       
   616 			else
       
   617 				{
       
   618 			    AknsUtils::CreateColorIconL( UiLayout()->SkinInstance(),
       
   619                              id,
       
   620                              KAknsIIDQsnIconColors,
       
   621                              colorGroup,
       
   622                              iForgroundBmp,
       
   623                              iForgroundBmpMask,
       
   624                              bmpFileName,
       
   625                              bmpId,
       
   626                              bmpMskId,
       
   627                              AKN_LAF_COLOR( 0 ) );   	
       
   628 				}
       
   629 
       
   630         AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved);
       
   631         AknIconUtils::SetSize(iForgroundBmpMask, iForgroundBmpRect.Size(), 
       
   632                               EAspectRatioNotPreserved);
       
   633     		                       
       
   634     		/*CreateDimmedMaskL( iForgroundDimBmpMask, 
       
   635     						   iForgroundBmpMask );
       
   636    			AknIconUtils::SetSize(iForgroundDimBmpMask, iForgroundBmpRect.Size(), 
       
   637                               EAspectRatioNotPreserved);*/
       
   638     		}
       
   639     		else
       
   640 	        {
       
   641 		    AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
   642 		                           id,
       
   643 		                           iForgroundBmp,
       
   644 		                           bmpFileName,
       
   645 		                           bmpId);
       
   646 		    AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved);
       
   647 	        }
       
   648         }
       
   649 	
       
   650     if (!iFirstTimeConstruct)
       
   651     	{
       
   652         //ResizeBitmaps(iForgroundBmpRect.Size());
       
   653     	Draw();
       
   654     	}
       
   655     
       
   656     iFirstTimeConstruct = EFalse;    
       
   657     
       
   658     }
       
   659     
       
   660 // -----------------------------------------------------------------------------
       
   661 // CAknFepCtrlDragButton::ConstructFromResourceL
       
   662 // (other items were commented in a header).
       
   663 // -----------------------------------------------------------------------------
       
   664 //
       
   665 EXPORT_C void CAknFepCtrlDragButton::ConstructFromResourceL()
       
   666 	{
       
   667 	/*
       
   668 	if (iResourceId == KInvalidResId)
       
   669 		{
       
   670 		User::Leave(KErrArgument);
       
   671 		}
       
   672 	
       
   673 	if (!iFirstTimeConstruct)
       
   674 		{
       
   675         iBmpList.Close();
       
   676         iMaskBmpList.Close();
       
   677         ResetBmpPool();
       
   678 		}
       
   679 
       
   680     TResourceReader reader;
       
   681     CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId);
       
   682 
       
   683     TPtrC bmpFileName = reader.ReadTPtrC();
       
   684     TInt32 imgMajorSkinId = reader.ReadInt32();
       
   685     TAknsItemID id;
       
   686 
       
   687     for (TInt ii = 0; ii < EBtnBmpLastType + 1; ++ii)
       
   688         {
       
   689         const TInt16 bmpId = reader.ReadInt16();
       
   690         const TInt16 bmpMskId = reader.ReadInt16();
       
   691         
       
   692         // read skin item id
       
   693         const TInt skinitemid = reader.ReadInt16();
       
   694         id.Set(TInt(imgMajorSkinId), skinitemid);
       
   695         
       
   696         if (bmpId != KInvalidBmp)
       
   697             {
       
   698         	CFbsBitmap* bmp = NULL;
       
   699         	CFbsBitmap* maskbmp = NULL;
       
   700 
       
   701         	if (bmpMskId != KInvalidBmp)
       
   702         		{
       
   703         		AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
   704         		                       id,
       
   705         		                       bmp,
       
   706         		                       maskbmp,
       
   707         		                       bmpFileName,
       
   708         		                       bmpId,
       
   709         		                       bmpMskId);
       
   710         		
       
   711                 SetMaskBitmapL(maskbmp, TButtonBmpType(EBtnBmpNonActive + ii));
       
   712                 iMaskBmpList.Append(maskbmp);
       
   713                 }
       
   714             else
       
   715                 {
       
   716         	    AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
   717         	                           id,
       
   718         	                           bmp,
       
   719         	                           bmpFileName,
       
   720         	                           bmpId);
       
   721                 }
       
   722 
       
   723             SetBitmapL(bmp, TButtonBmpType(EBtnBmpNonActive + ii));
       
   724             iBmpList.Append(bmp);
       
   725             }
       
   726         }
       
   727         
       
   728     CleanupStack::PopAndDestroy(); // reader
       
   729     
       
   730     if (!iFirstTimeConstruct)
       
   731     	{
       
   732         ResizeBitmaps(Rect().Size());
       
   733         Draw();
       
   734     	}
       
   735     	
       
   736     iFirstTimeConstruct = EFalse;*/
       
   737 	if (iResourceId == KInvalidResId)
       
   738 		{
       
   739         return;
       
   740 		}
       
   741 	
       
   742 	if (!iFirstTimeConstruct)
       
   743 		{
       
   744 		// need to remove original bmp and maskbmp
       
   745         DeleteForgroundRes();
       
   746 		}
       
   747 
       
   748     TResourceReader reader;
       
   749     CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId);
       
   750 
       
   751     TPtrC bmpFileName = reader.ReadTPtrC();    // Read the file name of the bmps
       
   752     TInt32 imgMajorSkinId = reader.ReadInt32();
       
   753     TInt colorGroup = reader.ReadInt16();
       
   754     TAknsItemID id;
       
   755 	
       
   756 	// Get the image ids and mask ids from resource
       
   757     TInt bmpId = reader.ReadInt16(); 
       
   758     TInt bmpMskId = reader.ReadInt16();
       
   759     
       
   760     // Read skin item id
       
   761     const TInt skinitemid = reader.ReadInt16();
       
   762     id.Set(TInt(imgMajorSkinId), skinitemid);
       
   763 
       
   764     if (bmpId != KInvalidBmp)
       
   765         {
       
   766     	if (bmpMskId != KInvalidBmp)
       
   767     		{
       
   768     		if( colorGroup == KInvalidColorGroup )
       
   769     			{
       
   770 	    		AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
   771                        id,
       
   772                        iForgroundBmp,
       
   773                        iForgroundBmpMask,
       
   774                        bmpFileName,
       
   775                        bmpId,
       
   776                        bmpMskId);	
       
   777     			}
       
   778 			else
       
   779 				{
       
   780 			    AknsUtils::CreateColorIconL( UiLayout()->SkinInstance(),
       
   781                              id,
       
   782                              KAknsIIDQsnIconColors,
       
   783                              colorGroup,
       
   784                              iForgroundBmp,
       
   785                              iForgroundBmpMask,
       
   786                              bmpFileName,
       
   787                              bmpId,
       
   788                              bmpMskId,
       
   789                              AKN_LAF_COLOR( 0 ) );   	
       
   790 				}
       
   791 
       
   792     		AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved);
       
   793     		AknIconUtils::SetSize(iForgroundBmpMask, iForgroundBmpRect.Size(), 
       
   794     		                      EAspectRatioNotPreserved);
       
   795     		                       
       
   796     		/*CreateDimmedMaskL( iForgroundDimBmpMask, iForgroundBmpMask );
       
   797    			AknIconUtils::SetSize(iForgroundDimBmpMask, iForgroundBmpRect.Size(), 
       
   798    			                      EAspectRatioNotPreserved);*/
       
   799     		}
       
   800     		else
       
   801 	        {
       
   802 		    AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
   803 		                           id,
       
   804 		                           iForgroundBmp,
       
   805 		                           bmpFileName,
       
   806 		                           bmpId);
       
   807 		    AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved);
       
   808 	        }
       
   809         }
       
   810 
       
   811     CleanupStack::PopAndDestroy(); // reader
       
   812     
       
   813     if (!iFirstTimeConstruct)
       
   814     	{
       
   815         //ResizeBitmaps(iForgroundBmpRect.Size());
       
   816     	Draw();
       
   817     	}
       
   818 
       
   819     iFirstTimeConstruct = EFalse;    	
       
   820     
       
   821 	}
       
   822     
       
   823     
       
   824 // ---------------------------------------------------------------------------
       
   825 // CAknFepCtrlDragButton::DeleteForgroundRes
       
   826 // This methods shall be called by the container's SizeChanged handler
       
   827 // (other items were commented in a header).
       
   828 // ---------------------------------------------------------------------------
       
   829 //
       
   830 void CAknFepCtrlDragButton::DeleteForgroundRes()
       
   831 	{
       
   832     if( iForgroundBmp )
       
   833 		{
       
   834 		delete iForgroundBmp;
       
   835 		iForgroundBmp = NULL;
       
   836 		}
       
   837 	if( iForgroundBmpMask )
       
   838 		{
       
   839 		delete iForgroundBmpMask;
       
   840 		iForgroundBmpMask = NULL;
       
   841 		}
       
   842 	if( iForgroundDimBmpMask )
       
   843 		{
       
   844 		delete iForgroundDimBmpMask;
       
   845 		iForgroundDimBmpMask = NULL;
       
   846 		}
       
   847 	}    
       
   848     
       
   849 // ---------------------------------------------------------------------------
       
   850 // CAknFepCtrlDragButton::CreateDimmedMaskL
       
   851 // This methods shall be called by the container's SizeChanged handler
       
   852 // (other items were commented in a header).
       
   853 // ---------------------------------------------------------------------------
       
   854 //	
       
   855 void CAknFepCtrlDragButton::CreateDimmedMaskL( CFbsBitmap*& aDimmedMask,
       
   856                                         		 const CFbsBitmap* aMask
       
   857                                         		 /*TScaleMode aScaleMode*/ )
       
   858 	{
       
   859 	    if (aMask && aMask->DisplayMode() == EGray256)
       
   860 	        {
       
   861 	        delete aDimmedMask;
       
   862 	        aDimmedMask = NULL;
       
   863 
       
   864 	        aDimmedMask = new (ELeave) CFbsBitmap;
       
   865 
       
   866 	        User::LeaveIfError(aDimmedMask->Create(aMask->SizeInPixels(), EGray256)); 
       
   867 	        CleanupStack::PushL(aDimmedMask);
       
   868 
       
   869 	        CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(aDimmedMask);
       
   870 	        CleanupStack::PushL(bitmapDevice);
       
   871 
       
   872 	        CFbsBitGc* bitGc(NULL);
       
   873 	        User::LeaveIfError(bitmapDevice->CreateContext(bitGc));
       
   874 	        CleanupStack::PushL(bitGc);
       
   875 
       
   876 	        bitGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
   877 	        bitGc->BitBlt(TPoint(0, 0), aMask);
       
   878 
       
   879 	        aDimmedMask->LockHeap();
       
   880 	        TInt w = aMask->SizeInPixels().iWidth; 
       
   881 	        TInt h = aMask->SizeInPixels().iHeight;
       
   882 	        TInt dataStride = aMask->DataStride() - w; 
       
   883 	        unsigned char* address = (unsigned char *)aDimmedMask->DataAddress();  
       
   884 
       
   885 	        for ( TInt i = 0; i < h; ++i )
       
   886 	            {
       
   887 	            for ( TInt j = 0; j < w; ++j )
       
   888 	                {
       
   889 	                *address = KTransparency[*address];
       
   890 	                ++address;
       
   891 	                }
       
   892 	            address += dataStride;         
       
   893 	            }
       
   894 
       
   895 	        aDimmedMask->UnlockHeap();
       
   896 
       
   897 	        //AknIconUtils::SetSize(aDimmedMask, aMask->SizeInPixels(), aScaleMode);
       
   898 
       
   899 	        CleanupStack::PopAndDestroy(2); // bitmapDevice, bitGc
       
   900 	        CleanupStack::Pop(1); // aDimmedMask
       
   901 	        }
       
   902 
       
   903 	}
       
   904     
       
   905     
       
   906 // ---------------------------------------------------------------------------
       
   907 // CAknFepCtrlDragButton::SetForgroundBmpRect
       
   908 // This methods shall be called by the container's SizeChanged handler
       
   909 // (other items were commented in a header).
       
   910 // ---------------------------------------------------------------------------
       
   911 //
       
   912 EXPORT_C void CAknFepCtrlDragButton::SetForgroundBmpRect(const TRect& aRect)
       
   913 	{
       
   914 	iForgroundBmpRect = aRect;	
       
   915 	}    
       
   916     
       
   917 // ---------------------------------------------------------------------------
       
   918 // CAknFepCtrlDragButton::SetForegroundBmpL
       
   919 // (other items were commented in a header).
       
   920 // ---------------------------------------------------------------------------
       
   921 //        
       
   922 EXPORT_C void CAknFepCtrlDragButton::SetForegroundBmpL(CFbsBitmap* aBmp,
       
   923                                                          CFbsBitmap* aMaskBmp)
       
   924     {
       
   925     DeleteForgroundRes();
       
   926 
       
   927     iForgroundBmp = aBmp;
       
   928     iForgroundBmpMask = aMaskBmp;
       
   929 
       
   930     ResizeBitmaps(iForgroundBmpRect.Size());
       
   931     }
       
   932 
       
   933 EXPORT_C void CAknFepCtrlDragButton::Move(const TPoint& aOffset)
       
   934     {
       
   935     CButtonBase::Move(aOffset);
       
   936     iForgroundBmpRect.Move( aOffset );
       
   937     }    
       
   938     
       
   939 // ---------------------------------------------------------------------------
       
   940 // CAknFepCtrlDragButton::HandlePointerDownEventL
       
   941 // Handle button down event
       
   942 // (other items were commented in a header).
       
   943 // ---------------------------------------------------------------------------
       
   944 //   
       
   945 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlDragButton::HandlePointerDownEventL(const TPoint& aPt)
       
   946 	{
       
   947     if( IsDimmed() )
       
   948     	return NULL;
       
   949     
       
   950     CDragBar::HandlePointerDownEventL(aPt);
       
   951 		
       
   952 	SetReady(ETrue);
       
   953     Draw();
       
   954     UpdateArea(Rect(),EFalse);
       
   955     ReportEvent(EEventButtonDown);
       
   956     return this;
       
   957 	}    
       
   958     
       
   959 // ---------------------------------------------------------------------------
       
   960 // CAknFepCtrlDragButton::Draw
       
   961 // Draws UI
       
   962 // (other items were commented in a header).
       
   963 // ---------------------------------------------------------------------------
       
   964 //
       
   965 EXPORT_C void CAknFepCtrlDragButton::Draw()
       
   966     {
       
   967 	if(!AbleToDraw())
       
   968         return;
       
   969     
       
   970     CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
       
   971     
       
   972     //mask bitmaps
       
   973   	DrawOpaqueMaskBackground();  
       
   974     TRect rect = Rect();        
       
   975     TRect innerRect = rect;
       
   976     innerRect.Shrink( 10, 10 );
       
   977     
       
   978     // ----- draw bitmaps -----
       
   979     gc->Activate( BitmapDevice() );                
       
   980     //gc->Clear(rect);
       
   981     	
       
   982 	CFbsBitmap* bmpMask = NULL;
       
   983 	
       
   984 	// Draw background    
       
   985  	if( IsDimmed() ) // Dimmed state
       
   986     	{
       
   987 		AknsDrawUtils::DrawFrame( UiLayout()->SkinInstance(), 
       
   988 		                         *gc, 
       
   989 		                         rect, 
       
   990 		                         innerRect,
       
   991 		                         iInactiveImgID,
       
   992 		                         KAknsIIDDefault );
       
   993     	if( iForgroundDimBmpMask )
       
   994     		{
       
   995     		delete iForgroundDimBmpMask;
       
   996     		iForgroundDimBmpMask = NULL;
       
   997     		}		                         
       
   998     	TRAP_IGNORE(CreateDimmedMaskL( iForgroundDimBmpMask, 
       
   999     					   iForgroundBmpMask ));
       
  1000 		AknIconUtils::SetSize(iForgroundDimBmpMask, iForgroundBmpRect.Size(), 
       
  1001                               EAspectRatioNotPreserved);		                         
       
  1002 		bmpMask = iForgroundDimBmpMask;    
       
  1003     	}
       
  1004     else
       
  1005     	{
       
  1006 		// Normal state or pressed state
       
  1007 		TAknsItemID ImgID = (IsDragging() | PointerDown()) ? iPressedImgID : iNormalImgID;
       
  1008 		AknsDrawUtils::DrawFrame( UiLayout()->SkinInstance(), 
       
  1009 	                     *gc, 
       
  1010 	                     rect, 
       
  1011 	                     innerRect,
       
  1012 	                     ImgID,
       
  1013 	                     KAknsIIDDefault ); 
       
  1014 	    bmpMask = iForgroundBmpMask;            	    		
       
  1015     	}
       
  1016     
       
  1017     // Draw forground
       
  1018 	if( iForgroundBmp )
       
  1019 		{
       
  1020 		TRect srcRect( TPoint( 0, 0 ), iForgroundBmp->SizeInPixels() );
       
  1021 		if( bmpMask )
       
  1022 			{
       
  1023 			gc->BitBltMasked( iForgroundBmpRect.iTl, 
       
  1024 							  iForgroundBmp, 
       
  1025 							  srcRect,
       
  1026 							  bmpMask,
       
  1027 							  EFalse);
       
  1028 			}
       
  1029 		else
       
  1030 			{
       
  1031 			gc->BitBlt( iForgroundBmpRect.iTl,
       
  1032 						iForgroundBmp,
       
  1033 						srcRect );	
       
  1034 			}
       
  1035 		}
       
  1036 
       
  1037     if (iText)
       
  1038         {
       
  1039         TAknLayoutText textLayout;
       
  1040         textLayout.LayoutText(Rect(), iTextFormat);
       
  1041         textLayout.DrawText(*gc, *iText);
       
  1042         }
       
  1043     }
       
  1044     
       
  1045     
       
  1046 // -----------------------------------------------------------------------------
       
  1047 // CAknFepCtrlDragButton::ResizeBitmaps
       
  1048 // This methods shall be called by the container's SizeChanged handler
       
  1049 // (other items were commented in a header).
       
  1050 // -----------------------------------------------------------------------------
       
  1051 //
       
  1052 void CAknFepCtrlDragButton::ResizeBitmaps(TSize aInnerSize)
       
  1053     {
       
  1054     /*
       
  1055     if (iMaskBmpList.Count() >= 1 &&
       
  1056         iMaskBmpList[0]->SizeInPixels() != aSize)
       
  1057         {
       
  1058         for( TInt ii = 0; ii < iMaskBmpList.Count(); ++ii )
       
  1059             {
       
  1060        	    AknIconUtils::SetSize(iMaskBmpList[ii], aSize, EAspectRatioNotPreserved);
       
  1061             }
       
  1062         }
       
  1063         
       
  1064     if (iBmpList.Count() >= 1 &&
       
  1065         iBmpList[0]->SizeInPixels() != aSize)
       
  1066         {
       
  1067         for( TInt ii = 0; ii < iBmpList.Count(); ++ii )
       
  1068             {
       
  1069             AknIconUtils::SetSize(iBmpList[ii], aSize, EAspectRatioNotPreserved);
       
  1070             }
       
  1071         }*/
       
  1072     if( iForgroundBmp && ( iForgroundBmp->SizeInPixels() != aInnerSize ) )
       
  1073     	{
       
  1074     	AknIconUtils::SetSize( iForgroundBmp, aInnerSize, EAspectRatioNotPreserved );
       
  1075     	}
       
  1076     if( iForgroundBmpMask && ( iForgroundBmpMask->SizeInPixels() != aInnerSize ) )
       
  1077     	{
       
  1078     	AknIconUtils::SetSize( iForgroundBmpMask, aInnerSize, EAspectRatioNotPreserved );
       
  1079     	}    
       
  1080     	
       
  1081     /*TRAP_IGNORE(CreateDimmedMaskL(iForgroundDimBmpMask, 
       
  1082                                   iForgroundBmpMask));   */     
       
  1083     }
       
  1084 
       
  1085 // -----------------------------------------------------------------------------
       
  1086 // CAknFepCtrlDragButton::SizeChanged
       
  1087 // This methods shall be called by the container's SizeChanged handler
       
  1088 // (other items were commented in a header).
       
  1089 // -----------------------------------------------------------------------------
       
  1090 //
       
  1091 EXPORT_C void CAknFepCtrlDragButton::SizeChanged(TRect aNewRect, 
       
  1092 												 TRect aInnerRect, 
       
  1093 												 TBool aIsReloadImages)
       
  1094     {
       
  1095     // Reset the position and the extent of the button aera
       
  1096     /*if (aNewRect.Size().iWidth == 0 || aNewRect.Size().iHeight == 0)
       
  1097         {
       
  1098    	    return;
       
  1099         }
       
  1100         
       
  1101     SetRect(aNewRect);
       
  1102 
       
  1103     if (aIsReloadImages)
       
  1104         {
       
  1105         ResizeBitmaps(aNewRect.Size());
       
  1106         }
       
  1107 
       
  1108     Draw();
       
  1109     UpdateArea(Rect(), ETrue);*/
       
  1110     
       
  1111     if (aNewRect.Size().iWidth == 0 || aNewRect.Size().iHeight == 0)
       
  1112         {
       
  1113    	    return;
       
  1114         }
       
  1115     
       
  1116     TRect oriRect = Rect();
       
  1117     SetRect(aNewRect);
       
  1118 	iForgroundBmpRect = aInnerRect;
       
  1119 	
       
  1120     if (aIsReloadImages)
       
  1121         {
       
  1122         ResizeBitmaps(aInnerRect.Size() );	
       
  1123         }
       
  1124 	RootControl()->ReDrawRect( oriRect );
       
  1125     UpdateArea(oriRect, EFalse);
       
  1126     Draw();
       
  1127     UpdateArea(Rect(), EFalse);    
       
  1128     }
       
  1129 
       
  1130 // -----------------------------------------------------------------------------
       
  1131 // CAknFepCtrlMultiModeButton::CAknFepCtrlMultiModeButton
       
  1132 // C++ default constructor can NOT contain any code, that
       
  1133 // might leave.
       
  1134 // (other items were commented in a header).
       
  1135 // -----------------------------------------------------------------------------
       
  1136 //
       
  1137 EXPORT_C CAknFepCtrlMultiModeButton::CAknFepCtrlMultiModeButton(CFepUiLayout* aUiLayout, 
       
  1138                                      TInt aControlId,TAknsItemID aNormalID,
       
  1139                                      TAknsItemID aPressedID,TAknsItemID aInactiveID)
       
  1140          : CAknFepCtrlCommonButton(aUiLayout, aControlId, aNormalID, aPressedID, aInactiveID)
       
  1141     {
       
  1142     }
       
  1143     
       
  1144 // -----------------------------------------------------------------------------
       
  1145 // CAknFepCtrlMultiModeButton::NewL
       
  1146 // Two-phased constructor.
       
  1147 // (other items were commented in a header).
       
  1148 // -----------------------------------------------------------------------------
       
  1149 //
       
  1150 EXPORT_C CAknFepCtrlMultiModeButton* CAknFepCtrlMultiModeButton::NewL(CFepUiLayout* aUiLayout, 
       
  1151                                                     TInt aControlId,TAknsItemID aNormalID,
       
  1152                                                     TAknsItemID aPressedID,TAknsItemID aInactiveID)
       
  1153     {
       
  1154     CAknFepCtrlMultiModeButton* self = NewLC(aUiLayout, aControlId, 
       
  1155                                              aNormalID, aPressedID, aInactiveID);
       
  1156     CleanupStack::Pop(self);
       
  1157     
       
  1158     return self;
       
  1159     }
       
  1160 
       
  1161 // -----------------------------------------------------------------------------
       
  1162 // CAknFepCtrlMultiModeButton::NewLC
       
  1163 // Two-phased constructor.
       
  1164 // (other items were commented in a header).
       
  1165 // -----------------------------------------------------------------------------
       
  1166 //
       
  1167 EXPORT_C CAknFepCtrlMultiModeButton* CAknFepCtrlMultiModeButton::NewLC(CFepUiLayout* aUiLayout, 
       
  1168                                                     TInt aControlId,TAknsItemID aNormalID,
       
  1169                                                     TAknsItemID aPressedID,TAknsItemID aInactiveID)
       
  1170     {
       
  1171     CAknFepCtrlMultiModeButton* self = new (ELeave) CAknFepCtrlMultiModeButton(aUiLayout, 
       
  1172                                                                                aControlId, 
       
  1173                                                                                aNormalID, 
       
  1174                                                                                aPressedID,
       
  1175                                                                                aInactiveID);
       
  1176     CleanupStack::PushL(self);
       
  1177     self->BaseConstructL();
       
  1178     
       
  1179     return self;
       
  1180     }
       
  1181 
       
  1182 // -----------------------------------------------------------------------------
       
  1183 // Destructor.
       
  1184 // (other items were commented in a header).
       
  1185 // -----------------------------------------------------------------------------
       
  1186 //
       
  1187 EXPORT_C CAknFepCtrlMultiModeButton::~CAknFepCtrlMultiModeButton()
       
  1188     {
       
  1189     iImageResIdList.Close();
       
  1190     iForegroundBmpList.ResetAndDestroy();
       
  1191     iForegroundBmpList.Close();
       
  1192     iForegroundMaskBmpList.ResetAndDestroy();
       
  1193     iForegroundMaskBmpList.Close();
       
  1194         
       
  1195     iModeTextList.ResetAndDestroy();
       
  1196     iModeTextList.Close();  
       
  1197     
       
  1198     iModesList.ResetAndDestroy();
       
  1199     iModesList.Close();
       
  1200     }
       
  1201     
       
  1202 // -----------------------------------------------------------------------------
       
  1203 // CAknFepCtrlMultiModeButton::ConstructFromResourceL
       
  1204 // The order of the image ids in the CButtonBase class must not be changed
       
  1205 // (other items were commented in a header).
       
  1206 // -----------------------------------------------------------------------------
       
  1207 //
       
  1208 
       
  1209 EXPORT_C void CAknFepCtrlMultiModeButton::ConstructFromResourceL(TResourceReader& aReader)
       
  1210     {
       
  1211     if (!iFirstTimeConstruct)
       
  1212     	{
       
  1213         iImageResIdList.Close();
       
  1214         iForegroundBmpList.ResetAndDestroy();
       
  1215         iForegroundBmpList.Close();
       
  1216         iForegroundMaskBmpList.ResetAndDestroy();
       
  1217         iForegroundMaskBmpList.Close();
       
  1218              
       
  1219         iModeTextList.ResetAndDestroy();
       
  1220         iModeTextList.Close();  
       
  1221 
       
  1222 
       
  1223         iModesList.ResetAndDestroy();
       
  1224         iModesList.Close();
       
  1225     	
       
  1226         ResetBmpPool();
       
  1227     	}
       
  1228     
       
  1229     // read text color and shadow text color	
       
  1230     TInt32 colorMajorSkinId = aReader.ReadInt32();
       
  1231     const TInt skinitemid = aReader.ReadInt16();
       
  1232     TInt textcoloridx = aReader.ReadInt16();
       
  1233     TInt shadowtextcoloridx = aReader.ReadInt16();
       
  1234     
       
  1235     TAknsItemID id;
       
  1236     
       
  1237     id.Set(TInt(colorMajorSkinId), skinitemid);
       
  1238     TInt error = AknsUtils::GetCachedColor(UiLayout()->SkinInstance(),
       
  1239                                            iFontColor,
       
  1240                                            id,
       
  1241                                            textcoloridx);
       
  1242 
       
  1243     if (error != KErrNone)
       
  1244         {
       
  1245     	iFontColor = TRgb(KDefaultTextColor);
       
  1246         }
       
  1247     
       
  1248     SetFontColor(iFontColor);    
       
  1249     
       
  1250     error = AknsUtils::GetCachedColor(UiLayout()->SkinInstance(),
       
  1251                                       iShadowFontColor,
       
  1252                                       id,
       
  1253                                       shadowtextcoloridx);
       
  1254                                       
       
  1255     if (error != KErrNone)
       
  1256         {
       
  1257     	iShadowFontColor = TRgb(KDefaultShadowTextColor);
       
  1258         }
       
  1259     
       
  1260     SetShadowFontColor(iShadowFontColor);    
       
  1261     
       
  1262     const TInt16 countModes = aReader.ReadInt16();      // Read the count of different cases
       
  1263     
       
  1264     if (countModes <= 0)
       
  1265         {
       
  1266         User::Leave(KErrArgument);
       
  1267         }
       
  1268 
       
  1269     iNumberOfModes = 0;
       
  1270 
       
  1271     for (TInt ii = 0; ii < countModes; ii++)
       
  1272         {
       
  1273         AddModeL(aReader);
       
  1274         iNumberOfModes++;
       
  1275         }
       
  1276         
       
  1277     if (iFirstTimeConstruct)
       
  1278     	{
       
  1279         if (iImageResIdList.Count() == 1)
       
  1280             {
       
  1281             // set background bimap for button    
       
  1282             SetButtonBmpL(EBtnBmpNonActive, 0);
       
  1283             iCurrentBmpType = EBtnBmpNonActive;
       
  1284             }
       
  1285 
       
  1286         const TInt16 defaultModeIndex = aReader.ReadInt16();
       
  1287         SetCurrentModeL(EBtnBmpNonActive, defaultModeIndex);
       
  1288     	}
       
  1289     else
       
  1290     	{
       
  1291         SetButtonBmpL(iCurrentBmpType, iCurrentMode);
       
  1292         Draw();
       
  1293     	}
       
  1294 
       
  1295     iFirstTimeConstruct = EFalse;
       
  1296     }
       
  1297 
       
  1298 // -----------------------------------------------------------------------------
       
  1299 // CAknFepCtrlMultiModeButton::ConstructFromResourceL
       
  1300 // (other items were commented in a header).
       
  1301 // -----------------------------------------------------------------------------
       
  1302 //
       
  1303 
       
  1304 EXPORT_C void CAknFepCtrlMultiModeButton::ConstructFromResourceL()
       
  1305 	{
       
  1306     if (iResourceId == KInvalidResId)
       
  1307     	{
       
  1308     	return;
       
  1309     	}
       
  1310  
       
  1311     if (!iFirstTimeConstruct)
       
  1312     	{
       
  1313         iImageResIdList.Close();
       
  1314         iForegroundBmpList.ResetAndDestroy();
       
  1315         iForegroundBmpList.Close();
       
  1316         iForegroundMaskBmpList.ResetAndDestroy();
       
  1317         iForegroundMaskBmpList.Close();
       
  1318         
       
  1319         iModeTextList.ResetAndDestroy();
       
  1320         iModeTextList.Close();  
       
  1321 
       
  1322 
       
  1323         iModesList.ResetAndDestroy();
       
  1324         iModesList.Close();
       
  1325     	
       
  1326         ResetBmpPool();
       
  1327     	}
       
  1328     	
       
  1329     TResourceReader reader;
       
  1330     CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId);
       
  1331 	
       
  1332     // read text color and shadow text color	
       
  1333     TInt32 colorMajorSkinId = reader.ReadInt32();
       
  1334     const TInt skinitemid = reader.ReadInt16();
       
  1335     TInt textcoloridx = reader.ReadInt16();
       
  1336     TInt shadowtextcoloridx = reader.ReadInt16();
       
  1337     
       
  1338     TAknsItemID id;
       
  1339     
       
  1340     id.Set(TInt(colorMajorSkinId), skinitemid);
       
  1341     TInt error = AknsUtils::GetCachedColor(UiLayout()->SkinInstance(),
       
  1342                                            iFontColor,
       
  1343                                            id,
       
  1344                                            textcoloridx);
       
  1345 
       
  1346     if (error != KErrNone)
       
  1347         {
       
  1348     	iFontColor = TRgb(KDefaultTextColor);
       
  1349         }
       
  1350     
       
  1351     SetFontColor(iFontColor);    
       
  1352     
       
  1353     error = AknsUtils::GetCachedColor(UiLayout()->SkinInstance(),
       
  1354                                       iShadowFontColor,
       
  1355                                       id,
       
  1356                                       shadowtextcoloridx);
       
  1357                                       
       
  1358     if (error != KErrNone)
       
  1359         {
       
  1360     	iShadowFontColor = TRgb(KDefaultShadowTextColor);
       
  1361         }
       
  1362     
       
  1363     SetShadowFontColor(iShadowFontColor);    
       
  1364 
       
  1365     const TInt16 countModes = reader.ReadInt16();
       
  1366     
       
  1367     if (countModes <= 0)
       
  1368         {
       
  1369         User::Leave(KErrArgument);
       
  1370         }
       
  1371 
       
  1372    	iNumberOfModes = 0;
       
  1373     
       
  1374     for (TInt ii = 0; ii < countModes; ii++)
       
  1375         {
       
  1376         AddModeL(reader);
       
  1377        	iNumberOfModes++;
       
  1378         }
       
  1379 
       
  1380 	
       
  1381     if (iFirstTimeConstruct)
       
  1382     	{
       
  1383         if (iImageResIdList.Count() == 1)
       
  1384             {
       
  1385             // set background bimap for button    
       
  1386             SetButtonBmpL(EBtnBmpNonActive, 0);
       
  1387             iCurrentBmpType = EBtnBmpNonActive;
       
  1388             }
       
  1389 
       
  1390         const TInt16 defaultModeIndex = reader.ReadInt16();
       
  1391         SetCurrentModeL(EBtnBmpNonActive, defaultModeIndex);
       
  1392     	}
       
  1393     else
       
  1394     	{
       
  1395     	ResizeBitmaps(iForgroundBmpRect.Size());
       
  1396         SetButtonBmpL(iCurrentBmpType, iCurrentMode);
       
  1397         Draw();
       
  1398     	}	
       
  1399     	
       
  1400     CleanupStack::PopAndDestroy(); // reader
       
  1401     
       
  1402     iFirstTimeConstruct = EFalse;
       
  1403 
       
  1404 	}
       
  1405 
       
  1406 // -----------------------------------------------------------------------------
       
  1407 // CAknFepCtrlMultiModeButton::AddModeL
       
  1408 // Add new display mode from resource reader
       
  1409 // (other items were commented in a header).
       
  1410 // -----------------------------------------------------------------------------
       
  1411 //
       
  1412 EXPORT_C void CAknFepCtrlMultiModeButton::AddModeL(TResourceReader& aReader)
       
  1413     {
       
  1414     const TInt32 imageResId = aReader.ReadInt32();
       
  1415     iModeTextList.Append(aReader.ReadHBufCL());
       
  1416     const TInt rangeId = aReader.ReadInt16();
       
  1417     const TInt modeId = aReader.ReadInt16();
       
  1418 
       
  1419     TAknFepModeIndicator* modeIndicator = new (ELeave) TAknFepModeIndicator;
       
  1420     CleanupStack::PushL(modeIndicator);
       
  1421 
       
  1422     modeIndicator->iRangeId = rangeId;
       
  1423     modeIndicator->iModeId = modeId;
       
  1424     modeIndicator->iPermitted = ETrue;
       
  1425 
       
  1426     iModesList.AppendL(modeIndicator);
       
  1427     CleanupStack::Pop(modeIndicator); // indicator        
       
  1428 
       
  1429     if ( imageResId != KInvalidBmp )
       
  1430         {
       
  1431         // switch mode means change image    
       
  1432         TResourceReader reader;
       
  1433         CCoeEnv::Static()->CreateResourceReaderLC(reader, imageResId);
       
  1434         
       
  1435         TPtrC bmpFileName = reader.ReadTPtrC();
       
  1436         TInt32 imgMajorSkinId = reader.ReadInt32();
       
  1437         TInt colorGroup = reader.ReadInt16();
       
  1438         TAknsItemID id;
       
  1439 
       
  1440         for (TInt jj = 0; jj < /*EBtnBmpLastType +*/ 1; jj++)
       
  1441             {
       
  1442             const TInt16 bmpId = reader.ReadInt16();
       
  1443             const TInt16 bmpMskId = reader.ReadInt16();
       
  1444             const TInt16 skinitemid = reader.ReadInt16();
       
  1445             id.Set(TInt(imgMajorSkinId), skinitemid);
       
  1446 
       
  1447             if (bmpId != KInvalidBmp)
       
  1448             	{
       
  1449             	CFbsBitmap* bmp = NULL;
       
  1450             	CFbsBitmap* maskbmp = NULL;
       
  1451             	
       
  1452         	    if (bmpMskId != KInvalidBmp)
       
  1453         	        {
       
  1454         	        if( colorGroup == KInvalidColorGroup )
       
  1455 	        	    	{
       
  1456 	        		    AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
  1457 	        		                           id,
       
  1458 	        		                           bmp,
       
  1459 	        		                           maskbmp,
       
  1460 	        		                           bmpFileName,
       
  1461 	        		                           bmpId,
       
  1462 	        		                           bmpMskId);
       
  1463 	        	    	}
       
  1464         	    	else
       
  1465 	        	    	{
       
  1466 	        	    	AknsUtils::CreateColorIconL( UiLayout()->SkinInstance(),
       
  1467 				                             id,
       
  1468 				                             KAknsIIDQsnIconColors,
       
  1469 				                             colorGroup,
       
  1470 				                             bmp,
       
  1471 				                             maskbmp,
       
  1472 				                             bmpFileName,
       
  1473 				                             bmpId,
       
  1474 				                             bmpMskId,
       
  1475 				                             AKN_LAF_COLOR( 0 ) );   	
       
  1476 	
       
  1477 	        	    	}
       
  1478                     CleanupStack::PushL(maskbmp);
       
  1479                     AknIconUtils::SetSize(maskbmp, iForgroundBmpRect.Size(),
       
  1480                                           EAspectRatioNotPreserved);                    
       
  1481                     iForegroundMaskBmpList.AppendL(maskbmp);            
       
  1482                     CleanupStack::Pop(maskbmp);    
       
  1483                     
       
  1484         	        }
       
  1485         	    else
       
  1486         	        {
       
  1487         	        AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
  1488         	                               id,
       
  1489         	                               bmp,
       
  1490         	                               bmpFileName,
       
  1491         	                               bmpId);
       
  1492 
       
  1493         	        }
       
  1494         	    
       
  1495         	    CleanupStack::PushL(bmp);
       
  1496         	    AknIconUtils::SetSize(bmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved);
       
  1497         	    iForegroundBmpList.AppendL(bmp);        	    
       
  1498         	    CleanupStack::Pop(bmp);    
       
  1499                 
       
  1500             	}
       
  1501             }
       
  1502         
       
  1503         CleanupStack::PopAndDestroy(); //reader
       
  1504         
       
  1505         iImageResIdList.Append(imageResId);
       
  1506         }
       
  1507     }
       
  1508     
       
  1509 // -----------------------------------------------------------------------------
       
  1510 // CAknFepCtrlMultiModeButton::SetButtonBmp
       
  1511 // (other items were commented in a header).
       
  1512 // -----------------------------------------------------------------------------
       
  1513 //
       
  1514 EXPORT_C void CAknFepCtrlMultiModeButton::SetButtonBmpL(const TButtonBmpType aType , 
       
  1515                                                         const TInt aMode)
       
  1516     {
       
  1517     if ( !ForgroundBmp() || 
       
  1518          ForgroundBmp()->Handle() != iForegroundBmpList[aMode]->Handle() ||
       
  1519          !ForgroundBmpMask() || 
       
  1520          ForgroundBmpMask()->Handle() != iForegroundMaskBmpList[aMode]->Handle() )
       
  1521         {
       
  1522         CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
       
  1523         if(iForegroundMaskBmpList.Count() > 0 && iForegroundBmpList[aMode])
       
  1524             {
       
  1525             CleanupStack::PushL( bmp );
       
  1526             
       
  1527             User::LeaveIfError(bmp->Duplicate(iForegroundBmpList[aMode]->Handle()));
       
  1528             
       
  1529             CleanupStack::Pop( bmp );            
       
  1530             }
       
  1531         else
       
  1532             {
       
  1533             delete bmp;
       
  1534             bmp = NULL;
       
  1535             }
       
  1536         CFbsBitmap* maskbmp = new (ELeave) CFbsBitmap;
       
  1537         
       
  1538         if(iForegroundMaskBmpList.Count() > 0 && iForegroundMaskBmpList[aMode])
       
  1539             {    
       
  1540             CleanupStack::PushL( maskbmp );
       
  1541             User::LeaveIfError(maskbmp->Duplicate(iForegroundMaskBmpList[aMode]->Handle()));    
       
  1542             CleanupStack::Pop( maskbmp );     
       
  1543             }
       
  1544         else
       
  1545             {
       
  1546             delete maskbmp;
       
  1547             maskbmp = NULL;
       
  1548             }
       
  1549         SetForegroundBmpL(bmp,maskbmp);
       
  1550         }
       
  1551     else if ( ForgroundBmp()->SizeInPixels() != iForegroundBmpList[aMode]->SizeInPixels() ||
       
  1552               ForgroundBmpMask()->SizeInPixels() != iForegroundMaskBmpList[aMode]->SizeInPixels())
       
  1553         {
       
  1554         ResizeBitmaps(iForegroundBmpList[aMode]->SizeInPixels());
       
  1555         }
       
  1556         
       
  1557     if(aType == EBtnBmpActivePressed
       
  1558       || aType == EBtnBmpNonActivePressed)
       
  1559         {
       
  1560         SetHighlight(ETrue);
       
  1561         }
       
  1562     }
       
  1563 
       
  1564 // -----------------------------------------------------------------------------
       
  1565 // CAknFepCtrlMultiModeButton::SetCurrentModeL
       
  1566 // (other items were commented in a header).
       
  1567 // -----------------------------------------------------------------------------
       
  1568 //
       
  1569 EXPORT_C void CAknFepCtrlMultiModeButton::SetCurrentModeL(const TButtonBmpType aType, 
       
  1570                                                           const TInt aModeIndex)
       
  1571     {
       
  1572     if ((aModeIndex >= 0) && 
       
  1573         (aModeIndex <= NumberOfModes()-1) && 
       
  1574         (iModesList[aModeIndex]->iPermitted))
       
  1575         {
       
  1576         iCurrentMode = aModeIndex;
       
  1577 
       
  1578         if (iImageResIdList.Count() > 1)
       
  1579             {
       
  1580             // change mode means change image
       
  1581             SetButtonBmpL(aType, iCurrentMode);
       
  1582             iCurrentBmpType = aType;
       
  1583             }
       
  1584 
       
  1585         Draw();
       
  1586         UpdateArea(Rect());
       
  1587         }
       
  1588     }
       
  1589 
       
  1590 // -----------------------------------------------------------------------------
       
  1591 // CAknFepCtrlMultiModeButton::NextMode
       
  1592 // (other items were commented in a header).
       
  1593 // -----------------------------------------------------------------------------
       
  1594 //
       
  1595 EXPORT_C TInt CAknFepCtrlMultiModeButton::NextMode() const
       
  1596     {
       
  1597     TInt startIndex = 0;
       
  1598 
       
  1599     if (iCurrentMode < (NumberOfModes() -1))
       
  1600         {
       
  1601         startIndex = iCurrentMode + 1;
       
  1602         }
       
  1603 
       
  1604     TBool find = EFalse;
       
  1605     
       
  1606     while (!find && (startIndex != iCurrentMode))
       
  1607         {
       
  1608         if (iModesList[startIndex]->iPermitted)
       
  1609             {
       
  1610             find = ETrue;
       
  1611             }
       
  1612         else
       
  1613             {
       
  1614             startIndex++;
       
  1615             
       
  1616             if (startIndex > (NumberOfModes()-1))
       
  1617                 {
       
  1618                 startIndex = 0;
       
  1619                 }
       
  1620             }
       
  1621         }        
       
  1622 
       
  1623     if (find)
       
  1624         {
       
  1625         return startIndex;
       
  1626         }
       
  1627     else
       
  1628         {
       
  1629         return iCurrentMode;
       
  1630         }    
       
  1631     }
       
  1632     
       
  1633 // -----------------------------------------------------------------------------
       
  1634 // CAknFepCtrlMultiModeButton::ImageAlreadyExist
       
  1635 // (other items were commented in a header).
       
  1636 // -----------------------------------------------------------------------------
       
  1637 //
       
  1638 EXPORT_C TBool CAknFepCtrlMultiModeButton::ImageAlreadyExist(const TInt32 aResId)
       
  1639     {
       
  1640     TBool findResId = EFalse;
       
  1641 
       
  1642     for (TInt i=0; i<iImageResIdList.Count(); i++)
       
  1643         {
       
  1644         if (aResId == iImageResIdList[i])
       
  1645             {
       
  1646             findResId = ETrue;
       
  1647 
       
  1648             break;
       
  1649             }
       
  1650         }
       
  1651 
       
  1652     return findResId;
       
  1653     }
       
  1654 
       
  1655 // -----------------------------------------------------------------------------
       
  1656 // CAknFepCtrlMultiModeButton::DisplayText
       
  1657 // (other items were commented in a header).
       
  1658 // -----------------------------------------------------------------------------
       
  1659 //
       
  1660 EXPORT_C void CAknFepCtrlMultiModeButton::DisplayText()
       
  1661     {
       
  1662     if ((iFont) && (iShadowFont))
       
  1663         {
       
  1664         // draw shadow text
       
  1665         BitGc()->UseFont(iShadowFont);
       
  1666 
       
  1667         BitGc()->SetBrushStyle( CGraphicsContext::ENullBrush );
       
  1668         BitGc()->SetBrushColor( KRgbBlack);//Non transparent at all
       
  1669         BitGc()->SetPenColor(iShadowFontColor);
       
  1670         BitGc()->SetPenStyle(CGraphicsContext::ESolidPen);
       
  1671         BitGc()->SetPenSize( PenSize());
       
  1672 
       
  1673         TPoint pointText;
       
  1674         TPoint pointShadowText;
       
  1675 
       
  1676         TInt leftMarginOfText = 
       
  1677                      (Rect().Width() - iFont->TextWidthInPixels(*(iModeTextList[iCurrentMode])))/2;
       
  1678 
       
  1679         pointText.iX = Rect().iTl.iX + leftMarginOfText;
       
  1680         pointText.iY = Rect().iTl.iY + Rect().Height()*3/4;
       
  1681 
       
  1682         pointShadowText.iX = pointText.iX + 1;
       
  1683         pointShadowText.iY = pointText.iY + 1;
       
  1684 
       
  1685         //BitGc()->DrawText(*(iModeTextList[iCurrentMode]), Rect(), Rect().Height()*3/4, CGraphicsContext::ECenter, Rect().Width()/2 - iFont->TextWidthInPixels(*(iModeTextList[iCurrentMode]))/2);
       
  1686         BitGc()->DrawText(*(iModeTextList[iCurrentMode]), pointShadowText);
       
  1687 
       
  1688         BitGc()->DiscardFont();
       
  1689 
       
  1690         // draw text
       
  1691         BitGc()->UseFont(iFont);
       
  1692 
       
  1693         BitGc()->SetBrushStyle( CGraphicsContext::ENullBrush );
       
  1694         BitGc()->SetBrushColor( KRgbBlack);//Non transparent at all
       
  1695         BitGc()->SetPenColor(iFontColor);
       
  1696         BitGc()->SetPenStyle(CGraphicsContext::ESolidPen);
       
  1697         BitGc()->SetPenSize( PenSize());
       
  1698 
       
  1699         //BitGc()->DrawText(*(iModeTextList[iCurrentMode]), Rect(), Rect().Height()*3/4+1, CGraphicsContext::ECenter, Rect().Width()/2 - iFont->TextWidthInPixels(*(iModeTextList[iCurrentMode]))/2-1);
       
  1700         BitGc()->DrawText(*(iModeTextList[iCurrentMode]), pointText);
       
  1701 
       
  1702         BitGc()->DiscardFont();
       
  1703 
       
  1704         //BitGc()->SetPenStyle(CGraphicsContext::ENullPen);        
       
  1705         }
       
  1706     }
       
  1707 
       
  1708 // -----------------------------------------------------------------------------
       
  1709 // CAknFepCtrlMultiModeButton::Draw
       
  1710 // (other items were commented in a header).
       
  1711 // -----------------------------------------------------------------------------
       
  1712 //
       
  1713 EXPORT_C void CAknFepCtrlMultiModeButton::Draw()
       
  1714     {
       
  1715 	if(!AbleToDraw())
       
  1716         return;
       
  1717     
       
  1718     CAknFepCtrlCommonButton::Draw();
       
  1719     //CButtonBase::Draw();  
       
  1720     if ( iModeTextList.Count() )
       
  1721         {
       
  1722         if ((iModeTextList[iCurrentMode]) && (iModeTextList[iCurrentMode]->Length() > 0)) 
       
  1723             {
       
  1724             DisplayText();
       
  1725             }        
       
  1726         }
       
  1727     }
       
  1728 
       
  1729 // -----------------------------------------------------------------------------
       
  1730 // CAknFepCtrlMultiModeButton::SetFontColor
       
  1731 // (other items were commented in a header).
       
  1732 // -----------------------------------------------------------------------------
       
  1733 //
       
  1734 EXPORT_C void CAknFepCtrlMultiModeButton::SetFontColor(const TRgb aFontColor)
       
  1735     {
       
  1736     iFontColor = aFontColor;
       
  1737     }
       
  1738 
       
  1739 // -----------------------------------------------------------------------------
       
  1740 // CAknFepCtrlMultiModeButton::SetShadowFontColor
       
  1741 // (other items were commented in a header).
       
  1742 // -----------------------------------------------------------------------------
       
  1743 //
       
  1744 EXPORT_C void CAknFepCtrlMultiModeButton::SetShadowFontColor(const TRgb aShadowFontColor)
       
  1745     {
       
  1746     iShadowFontColor = aShadowFontColor;
       
  1747     }
       
  1748 
       
  1749 // -----------------------------------------------------------------------------
       
  1750 // CAknFepCtrlMultiModeButton::SetPermittedModes
       
  1751 // (other items were commented in a header).
       
  1752 // -----------------------------------------------------------------------------
       
  1753 //
       
  1754 EXPORT_C TInt CAknFepCtrlMultiModeButton::SetPermittedModes(const TInt aRangeId,
       
  1755                                                             const TInt aRealCaseId,
       
  1756                                                             TBool aPermit)
       
  1757     {
       
  1758     for (TInt i = 0; i < iModesList.Count(); i++)
       
  1759         {
       
  1760     	if ((iModesList[i]->iRangeId == aRangeId) && (iModesList[i]->iModeId == aRealCaseId))
       
  1761     	    {
       
  1762           	iModesList[i]->iPermitted = aPermit;
       
  1763             
       
  1764             return KErrNone;    
       
  1765     	    }
       
  1766         }
       
  1767     
       
  1768     return KErrNotSupported;    
       
  1769     }
       
  1770     
       
  1771 // -----------------------------------------------------------------------------
       
  1772 // CAknFepCtrlMultiModeButton::SetPermittedRange
       
  1773 // (other items were commented in a header).
       
  1774 // -----------------------------------------------------------------------------
       
  1775 //
       
  1776 EXPORT_C TInt CAknFepCtrlMultiModeButton::SetPermittedRange(const TInt aRangeId, TBool aPermit)
       
  1777     {
       
  1778     TBool findRangeId = EFalse;
       
  1779     
       
  1780     for (TInt i = 0; i < iModesList.Count(); i++)
       
  1781         {
       
  1782         if ((iModesList[i]->iRangeId == aRangeId) && (iModesList[i]->iPermitted != aPermit))
       
  1783             {
       
  1784             iModesList[i]->iPermitted = aPermit;
       
  1785             findRangeId = ETrue;
       
  1786             }
       
  1787         }
       
  1788     
       
  1789     if (!findRangeId)
       
  1790         {
       
  1791         return KErrNotSupported;
       
  1792         }
       
  1793     else
       
  1794         {
       
  1795         return KErrNone;
       
  1796         }    
       
  1797     }
       
  1798 
       
  1799 // -----------------------------------------------------------------------------
       
  1800 // CAknFepCtrlMultiModeButton::EnableAllModes
       
  1801 // (other items were commented in a header).
       
  1802 // -----------------------------------------------------------------------------
       
  1803 //
       
  1804 EXPORT_C void CAknFepCtrlMultiModeButton::EnableAllModes()
       
  1805     {
       
  1806     for (TInt i = 0; i < iModesList.Count(); i++)
       
  1807         {
       
  1808         iModesList[i]->iPermitted = ETrue;
       
  1809         }
       
  1810     }
       
  1811     
       
  1812 // -----------------------------------------------------------------------------
       
  1813 // CAknFepCtrlMultiModeButton::DisableAllModes
       
  1814 // (other items were commented in a header).
       
  1815 // -----------------------------------------------------------------------------
       
  1816 //
       
  1817 EXPORT_C void CAknFepCtrlMultiModeButton::DisableAllModes()
       
  1818     {
       
  1819     for (TInt i = 0; i < iModesList.Count(); i++)
       
  1820         {
       
  1821         iModesList[i]->iPermitted = EFalse;
       
  1822         }
       
  1823     }
       
  1824 
       
  1825 // -----------------------------------------------------------------------------
       
  1826 // CAknFepCtrlMultiModeButton::DisableAllModes
       
  1827 // (other items were commented in a header).
       
  1828 // -----------------------------------------------------------------------------
       
  1829 //
       
  1830 EXPORT_C void CAknFepCtrlMultiModeButton::DisableOneModes(const TInt aRangeId)
       
  1831     {
       
  1832     for (TInt i = 0; i < iModesList.Count(); i++)
       
  1833         {
       
  1834         if(iModesList[i]->iRangeId == aRangeId)
       
  1835             {
       
  1836             iModesList[i]->iPermitted = EFalse;
       
  1837             TRAP_IGNORE(SetCurrentModeL(EBtnBmpNonActive, NextMode()));
       
  1838             }
       
  1839         }
       
  1840     }
       
  1841 
       
  1842 // -----------------------------------------------------------------------------
       
  1843 // CAknFepCtrlMultiModeButton::IsGivenRangeSupported
       
  1844 // (other items were commented in a header).
       
  1845 // -----------------------------------------------------------------------------
       
  1846 //
       
  1847 EXPORT_C TBool CAknFepCtrlMultiModeButton::IsGivenRangeSupported(const TInt aRange)
       
  1848     {
       
  1849     for (TInt i = 0; i < iModesList.Count(); i++)
       
  1850         {
       
  1851         // judge if aRange is supported by at least 1 mode
       
  1852         if ((iModesList[i]->iRangeId == aRange) && (iModesList[i]->iPermitted))
       
  1853             {
       
  1854             return ETrue;
       
  1855             }
       
  1856         }
       
  1857     
       
  1858     return EFalse;
       
  1859     }
       
  1860 
       
  1861 // -----------------------------------------------------------------------------
       
  1862 // CAknFepCtrlMultiModeButton::SetRange
       
  1863 // (other items were commented in a header).
       
  1864 // -----------------------------------------------------------------------------
       
  1865 //
       
  1866 EXPORT_C TInt CAknFepCtrlMultiModeButton::SetRange(const TInt aRange)
       
  1867     {
       
  1868     if (CurrentRange() != aRange)
       
  1869         {
       
  1870         for (TInt i = 0; i < iModesList.Count(); i++)
       
  1871             {
       
  1872     	    if ((iModesList[i]->iRangeId == aRange) && 
       
  1873     	        (iModesList[i]->iPermitted))
       
  1874     	        {
       
  1875                 TRAP_IGNORE(SetCurrentModeL(EBtnBmpActive, i));
       
  1876                 return KErrNone;
       
  1877     	        }
       
  1878             }
       
  1879         }
       
  1880     
       
  1881     return KErrNotSupported;    
       
  1882     }
       
  1883 
       
  1884 // -----------------------------------------------------------------------------
       
  1885 // CAknFepCtrlMultiModeButton::CurrentRange
       
  1886 // (other items were commented in a header).
       
  1887 // -----------------------------------------------------------------------------
       
  1888 //
       
  1889 EXPORT_C TInt CAknFepCtrlMultiModeButton::CurrentRange() const
       
  1890     {
       
  1891     if ((iCurrentMode >= 0) && (iCurrentMode <= (NumberOfModes()-1)))
       
  1892         {
       
  1893         return iModesList[iCurrentMode]->iRangeId;
       
  1894         }
       
  1895     else
       
  1896         {
       
  1897         return KErrNotFound;
       
  1898         }    
       
  1899     }
       
  1900 
       
  1901 // -----------------------------------------------------------------------------
       
  1902 // CAknFepCtrlMultiModeButton::RangeOfGivenMode()
       
  1903 // (other items were commented in a header).
       
  1904 // -----------------------------------------------------------------------------
       
  1905 //
       
  1906 EXPORT_C TInt CAknFepCtrlMultiModeButton::RangeOfGivenMode(TInt aModeIndex) const
       
  1907     {
       
  1908     if ((aModeIndex >= 0) && (aModeIndex <= NumberOfModes()-1))
       
  1909         {
       
  1910         return iModesList[aModeIndex]->iRangeId; 
       
  1911         }
       
  1912     
       
  1913     return KErrNotSupported;    
       
  1914     }
       
  1915 
       
  1916 // -----------------------------------------------------------------------------
       
  1917 // CAknFepCtrlMultiModeButton::GetRealCaseByMode()
       
  1918 // (other items were commented in a header).
       
  1919 // -----------------------------------------------------------------------------
       
  1920 //
       
  1921 EXPORT_C TInt CAknFepCtrlMultiModeButton::GetRealCaseByMode(TInt aModeIndex) const
       
  1922     {
       
  1923     if ((aModeIndex >= 0) && (aModeIndex <= NumberOfModes() -1))	
       
  1924         {
       
  1925         return iModesList[aModeIndex]->iModeId;
       
  1926         }
       
  1927     
       
  1928     return KErrNotFound;    
       
  1929     }
       
  1930 
       
  1931 // -----------------------------------------------------------------------------
       
  1932 // CAknFepCtrlMultiModeButton::GetRangeListL()
       
  1933 // (other items were commented in a header).
       
  1934 // -----------------------------------------------------------------------------
       
  1935 //
       
  1936 void CAknFepCtrlMultiModeButton::GetRangeListL(RArray<TInt>& aList)
       
  1937     {
       
  1938 	CleanupClosePushL( aList );
       
  1939     for (TInt i = 0; i < NumberOfModes(); i++)
       
  1940         {
       
  1941         if (aList.Find(iModesList[i]->iRangeId) == KErrNotFound)
       
  1942             {
       
  1943             aList.AppendL(iModesList[i]->iRangeId);
       
  1944             }
       
  1945         }
       
  1946     CleanupStack::Pop();
       
  1947     }
       
  1948 
       
  1949 // -----------------------------------------------------------------------------
       
  1950 // CAknFepCtrlMultiModeButton::DuplicateBitmapL
       
  1951 // (other items were commented in a header).
       
  1952 // -----------------------------------------------------------------------------
       
  1953 //
       
  1954 CFbsBitmap* CAknFepCtrlMultiModeButton::DuplicateBitmapL(CFbsBitmap* aSourceBmp)
       
  1955     {
       
  1956     CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
       
  1957     CleanupStack::PushL( bmp );
       
  1958     
       
  1959     User::LeaveIfError(bmp->Duplicate(aSourceBmp->Handle()));
       
  1960     
       
  1961     CleanupStack::Pop( bmp );
       
  1962     //iOwnedBitmaps.InsertInAddressOrder(bmp);
       
  1963     return bmp;
       
  1964     }
       
  1965 
       
  1966 // -----------------------------------------------------------------------------
       
  1967 // CAknFepCtrlMultiModeButton::ResizeBitmaps
       
  1968 // (other items were commented in a header).
       
  1969 // -----------------------------------------------------------------------------
       
  1970 //
       
  1971 void CAknFepCtrlMultiModeButton::ResizeBitmaps(TSize aSize)
       
  1972     {
       
  1973     if(iForegroundBmpList.Count() >= 1 && iForegroundBmpList[0]->SizeInPixels() != aSize
       
  1974     || iForegroundMaskBmpList.Count() >= 1 && iForegroundMaskBmpList[0]->SizeInPixels() != aSize)
       
  1975         {
       
  1976         for (TInt i=0; i<iForegroundBmpList.Count(); i++)
       
  1977             {
       
  1978           	AknIconUtils::SetSize(iForegroundBmpList[i], aSize, EAspectRatioNotPreserved);
       
  1979             }        
       
  1980         for (TInt i=0; i<iForegroundMaskBmpList.Count(); i++)
       
  1981             {
       
  1982           	AknIconUtils::SetSize(iForegroundMaskBmpList[i], aSize, EAspectRatioNotPreserved);
       
  1983             }
       
  1984         }
       
  1985     }
       
  1986 
       
  1987 // -----------------------------------------------------------------------------
       
  1988 // CAknFepCtrlMultiModeButton::SizeChanged
       
  1989 // (other items were commented in a header).
       
  1990 // -----------------------------------------------------------------------------
       
  1991 //
       
  1992 EXPORT_C void CAknFepCtrlMultiModeButton::SizeChanged(TRect aRect, TRect aInnerRect,
       
  1993                                                       TBool aIsReloadImages)
       
  1994     {
       
  1995     if (aRect.Size().iWidth == 0 || aRect.Size().iHeight == 0)
       
  1996         {
       
  1997     	  return;
       
  1998         }
       
  1999     SetRect(aRect);
       
  2000     
       
  2001     iForgroundBmpRect = aInnerRect;
       
  2002     
       
  2003     if (aIsReloadImages)
       
  2004         {
       
  2005         ResizeBitmaps(aInnerRect.Size());
       
  2006         }
       
  2007 
       
  2008     TRAP_IGNORE(SetButtonBmpL(iCurrentBmpType, iCurrentMode));
       
  2009 
       
  2010     CAknFepCtrlCommonButton::SizeChanged(aRect,aInnerRect,aIsReloadImages);
       
  2011 /*    
       
  2012     Draw();
       
  2013     UpdateArea(Rect(), ETrue);
       
  2014 */    
       
  2015     }
       
  2016 
       
  2017 // -----------------------------------------------------------------------------
       
  2018 // CAknFepCtrlMultiModeButton::TransferOwnership
       
  2019 // (other items were commented in a header).
       
  2020 // -----------------------------------------------------------------------------
       
  2021 //    
       
  2022 void CAknFepCtrlMultiModeButton::TransferOwnership(CFbsBitmap* aRemoved)
       
  2023     {
       
  2024 /*    
       
  2025     TInt index = iOwnedBitmaps.FindInAddressOrder(aRemoved);
       
  2026     if( index != KErrNotFound )
       
  2027         {
       
  2028         iOwnedBitmaps.Remove(index);
       
  2029         }
       
  2030 */        
       
  2031     }
       
  2032     
       
  2033 // -----------------------------------------------------------------------------
       
  2034 // CAknFepCtrlEventButton::NewL
       
  2035 // (other items were commented in a header).
       
  2036 // -----------------------------------------------------------------------------
       
  2037 //
       
  2038 EXPORT_C CAknFepCtrlEventButton* CAknFepCtrlEventButton::NewL(CFepUiLayout* aUiLayout, 
       
  2039                                                               TInt aControlId, 
       
  2040                                                               TInt aEvent,
       
  2041                                                               TInt aUnicode,
       
  2042                                                               TAknsItemID aNormalID,
       
  2043                                                               TAknsItemID aPressedID,
       
  2044                                                               TAknsItemID aInactiveID)
       
  2045     { 
       
  2046     CAknFepCtrlEventButton* self = NewLC(aUiLayout, aControlId, aEvent, aUnicode, 
       
  2047     									 aNormalID, aPressedID, aInactiveID);
       
  2048     CleanupStack::Pop(self);
       
  2049     
       
  2050     return self;                        
       
  2051     }
       
  2052     
       
  2053 // -----------------------------------------------------------------------------
       
  2054 // CAknFepCtrlEventButton::NewLC
       
  2055 // (other items were commented in a header).
       
  2056 // -----------------------------------------------------------------------------
       
  2057 //
       
  2058 EXPORT_C CAknFepCtrlEventButton* CAknFepCtrlEventButton::NewLC(CFepUiLayout* aUiLayout, 
       
  2059                                                                TInt aControlId, 
       
  2060                                                                TInt aEvent,
       
  2061                                                                TInt aUnicode,
       
  2062                                                                TAknsItemID aNormalID,
       
  2063                                                                TAknsItemID aPressedID,
       
  2064                                                                TAknsItemID aInactiveID)
       
  2065     { 
       
  2066     CAknFepCtrlEventButton* self = new (ELeave) CAknFepCtrlEventButton(aUiLayout, 
       
  2067                                                                        aControlId,
       
  2068                                                                        aEvent,
       
  2069                                                                        aUnicode,
       
  2070                                                                        aNormalID,
       
  2071                                                                        aPressedID,
       
  2072                                                                        aInactiveID);
       
  2073     CleanupStack::PushL(self);
       
  2074     self->BaseConstructL();
       
  2075 
       
  2076     return self;                      
       
  2077     }
       
  2078 
       
  2079 // -----------------------------------------------------------------------------
       
  2080 // CAknFepCtrlEventButton::CAknFepCtrlEventButton
       
  2081 // (other items were commented in a header).
       
  2082 // -----------------------------------------------------------------------------
       
  2083 //
       
  2084 EXPORT_C CAknFepCtrlEventButton::CAknFepCtrlEventButton(CFepUiLayout* aUiLayout, 
       
  2085                                                         TInt aControlId, 
       
  2086                                                         TInt aEvent,
       
  2087                                                         TInt aUnicode,
       
  2088                                                         TAknsItemID aNormalID,
       
  2089                                                         TAknsItemID aPressedID,
       
  2090                                                         TAknsItemID aInactiveID)
       
  2091     : CAknFepCtrlCommonButton(aUiLayout, aControlId, aNormalID, aPressedID, aInactiveID),
       
  2092 	  iEvent(aEvent),iUnicode(aUnicode),iText(NULL) 
       
  2093     {        
       
  2094     }
       
  2095 
       
  2096 // -----------------------------------------------------------------------------
       
  2097 // CAknFepCtrlEventButton::~CAknFepCtrlEventButton
       
  2098 // (other items were commented in a header).
       
  2099 // -----------------------------------------------------------------------------
       
  2100 //                                    
       
  2101 EXPORT_C CAknFepCtrlEventButton::~CAknFepCtrlEventButton()
       
  2102     {
       
  2103     delete iText;
       
  2104     }
       
  2105 
       
  2106 // -----------------------------------------------------------------------------
       
  2107 // CAknFepCtrlEventButton::HandlePointerUpEventL
       
  2108 // (other items were commented in a header).
       
  2109 // -----------------------------------------------------------------------------
       
  2110 //
       
  2111 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlEventButton::HandlePointerUpEventL(const TPoint& aPoint)
       
  2112     {
       
  2113     if (iEvent == 0xFFFF)
       
  2114         {
       
  2115         return CAknFepCtrlCommonButton::HandlePointerUpEventL(aPoint);
       
  2116         }
       
  2117     else
       
  2118         {
       
  2119         CAknFepCtrlCommonButton::HandlePointerUpEventL(aPoint);
       
  2120         if(IsDimmed())
       
  2121             {
       
  2122             return NULL;
       
  2123             }
       
  2124         
       
  2125         if(IsActive())
       
  2126             {
       
  2127             SetBackgroundBmp(Bitmap(EBtnBmpActive,EFalse));
       
  2128             SetBackgroundMaskBmp(Bitmap(EBtnBmpActive,ETrue));
       
  2129             }
       
  2130         else
       
  2131             {
       
  2132             SetBackgroundBmp(Bitmap(EBtnBmpNonActive,EFalse));
       
  2133             SetBackgroundMaskBmp(Bitmap(EBtnBmpNonActive,ETrue));
       
  2134             }
       
  2135             
       
  2136         SetActive(ETrue);
       
  2137         Draw();
       
  2138         UpdateArea(Rect(),EFalse);         
       
  2139         
       
  2140         TPtrC ptr = (TUint16*)(&iUnicode);
       
  2141         ReportEvent(iEvent,ptr);     
       
  2142         
       
  2143         return this;                                      
       
  2144         }    
       
  2145     }
       
  2146 
       
  2147 // -----------------------------------------------------------------------------
       
  2148 // CAknFepCtrlEventButton::DisplayText
       
  2149 // (other items were commented in a header).
       
  2150 // -----------------------------------------------------------------------------
       
  2151 //
       
  2152 EXPORT_C void CAknFepCtrlEventButton::DisplayText()
       
  2153     {
       
  2154     if ((iFont) && (iShadowFont))
       
  2155         {
       
  2156         CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
       
  2157 
       
  2158         gc->Activate(BitmapDevice());
       
  2159 
       
  2160         // draw shadow text
       
  2161         gc->UseFont(iShadowFont);
       
  2162 
       
  2163         gc->SetBrushStyle( CGraphicsContext::ENullBrush );
       
  2164         gc->SetBrushColor( KRgbBlack);//Non transparent at all
       
  2165         gc->SetPenColor(iShadowFontColor);
       
  2166         gc->SetPenStyle(CGraphicsContext::ESolidPen);
       
  2167         gc->SetPenSize( PenSize());
       
  2168 
       
  2169         TPoint pointText;
       
  2170         TPoint pointShadowText;
       
  2171 
       
  2172         TInt leftMarginOfText = (Rect().Width() - iFont->TextWidthInPixels(*iText))/2;
       
  2173 
       
  2174         pointText.iX = Rect().iTl.iX + leftMarginOfText;
       
  2175         pointText.iY = Rect().iTl.iY + Rect().Height()*3/4;
       
  2176 
       
  2177         pointShadowText.iX = pointText.iX + 1;
       
  2178         pointShadowText.iY = pointText.iY + 1;
       
  2179 
       
  2180         gc->DrawText(*iText, pointShadowText);
       
  2181 
       
  2182         gc->DiscardFont();
       
  2183 
       
  2184         // draw text
       
  2185         gc->UseFont(iFont);
       
  2186 
       
  2187         gc->SetBrushStyle( CGraphicsContext::ENullBrush );
       
  2188         gc->SetBrushColor( KRgbBlack);//Non transparent at all
       
  2189         gc->SetPenColor(iFontColor);
       
  2190         gc->SetPenStyle(CGraphicsContext::ESolidPen);
       
  2191         gc->SetPenSize( PenSize());
       
  2192 
       
  2193         gc->DrawText(*iText, pointText);
       
  2194 
       
  2195         gc->DiscardFont();
       
  2196         }
       
  2197     }
       
  2198 
       
  2199 // -----------------------------------------------------------------------------
       
  2200 // CAknFepCtrlEventButton::SetFontColor
       
  2201 // (other items were commented in a header).
       
  2202 // -----------------------------------------------------------------------------
       
  2203 //
       
  2204 EXPORT_C void CAknFepCtrlEventButton::SetFontColor(const TRgb aColor)
       
  2205     {
       
  2206     iFontColor = aColor;
       
  2207     }
       
  2208 
       
  2209 // -----------------------------------------------------------------------------
       
  2210 // CAknFepCtrlEventButton::SetShadowFontColor
       
  2211 // (other items were commented in a header).
       
  2212 // -----------------------------------------------------------------------------
       
  2213 //
       
  2214 EXPORT_C void CAknFepCtrlEventButton::SetShadowFontColor(const TRgb aColor)
       
  2215     {
       
  2216     iShadowFontColor = aColor;
       
  2217     }
       
  2218 
       
  2219 
       
  2220 // -----------------------------------------------------------------------------
       
  2221 // CAknFepCtrlEventButton::Draw
       
  2222 // (other items were commented in a header).
       
  2223 // -----------------------------------------------------------------------------
       
  2224 //
       
  2225 EXPORT_C void CAknFepCtrlEventButton::Draw()
       
  2226     {
       
  2227 	if(!AbleToDraw())
       
  2228         return;
       
  2229     
       
  2230     CAknFepCtrlCommonButton::Draw();
       
  2231 
       
  2232     if ( iText && (iText->Length() > 0 ) ) 
       
  2233         {
       
  2234         DisplayText();
       
  2235         }
       
  2236     }
       
  2237 
       
  2238 // -----------------------------------------------------------------------------
       
  2239 // CAknFepCtrlEventButton::SetText
       
  2240 // (other items were commented in a header).
       
  2241 // -----------------------------------------------------------------------------
       
  2242 //
       
  2243 EXPORT_C void CAknFepCtrlEventButton::SetText(const TDesC& aText)
       
  2244     {
       
  2245     if ( iText )
       
  2246         {
       
  2247         delete iText;
       
  2248         iText = NULL;
       
  2249         }
       
  2250     TRAPD(err, iText = aText.AllocL());
       
  2251     if (err != KErrNone)
       
  2252         {
       
  2253         iText = NULL;
       
  2254         }
       
  2255     Draw();
       
  2256     }
       
  2257 
       
  2258 // -----------------------------------------------------------------------------
       
  2259 // CAknFepCtrlEventButton::SetFont
       
  2260 // (other items were commented in a header).
       
  2261 // -----------------------------------------------------------------------------
       
  2262 //
       
  2263 EXPORT_C void CAknFepCtrlEventButton::SetFont(const CFont* aFont)
       
  2264     {
       
  2265     iFont = aFont;
       
  2266     }
       
  2267 
       
  2268 // -----------------------------------------------------------------------------
       
  2269 // CAknFepCtrlEventButton::SetShadowFont
       
  2270 // (other items were commented in a header).
       
  2271 // -----------------------------------------------------------------------------
       
  2272 //
       
  2273 EXPORT_C void CAknFepCtrlEventButton::SetShadowFont(const CFont* aFont)
       
  2274     {
       
  2275     iShadowFont = aFont;
       
  2276     }
       
  2277         
       
  2278 // -----------------------------------------------------------------------------
       
  2279 // CAknFepCtrlEventButton::Event
       
  2280 // (other items were commented in a header).
       
  2281 // -----------------------------------------------------------------------------
       
  2282 //
       
  2283 EXPORT_C TInt CAknFepCtrlEventButton::Event() const
       
  2284     {                           
       
  2285     return iEvent;                       
       
  2286     }
       
  2287 
       
  2288 // -----------------------------------------------------------------------------
       
  2289 // CAknFepCtrlEventButton::Unicode
       
  2290 // (other items were commented in a header).
       
  2291 // -----------------------------------------------------------------------------
       
  2292 //    
       
  2293 EXPORT_C TInt CAknFepCtrlEventButton::Unicode() const
       
  2294     {             
       
  2295     return iUnicode;                                     
       
  2296     }
       
  2297 
       
  2298 // -----------------------------------------------------------------------------
       
  2299 // CAknFepCtrlEventButton::SetEvent
       
  2300 // (other items were commented in a header).
       
  2301 // -----------------------------------------------------------------------------
       
  2302 //    
       
  2303 EXPORT_C void CAknFepCtrlEventButton::SetEvent(TInt aEvent)
       
  2304     {               
       
  2305     iEvent = aEvent;                                   
       
  2306     }
       
  2307 
       
  2308 // -----------------------------------------------------------------------------
       
  2309 // CAknFepCtrlEventButton::SetUnicode
       
  2310 // (other items were commented in a header).
       
  2311 // -----------------------------------------------------------------------------
       
  2312 //    
       
  2313 EXPORT_C void CAknFepCtrlEventButton::SetUnicode(TInt aUnicode)
       
  2314     {                                                
       
  2315     iUnicode = aUnicode;  
       
  2316     }
       
  2317 
       
  2318 // ---------------------------------------------------------
       
  2319 // Constructor
       
  2320 // ---------------------------------------------------------
       
  2321 //
       
  2322 EXPORT_C CAknFepCtrlRepeatButton* CAknFepCtrlRepeatButton::NewLC(CFepUiLayout* aUiLayout, 
       
  2323                                                                  TInt aCtrlId,
       
  2324                                                                  TInt aEvent,
       
  2325                                                                  TInt aUnicode,
       
  2326                                                                  TAknsItemID aNormalID,
       
  2327                                                                  TAknsItemID aPressedID,
       
  2328                                                                  TAknsItemID aInactiveID)
       
  2329     {
       
  2330     //PRINTF((_L("CAknFepCtrlRepeatButton::NewLC(), aCtrlId = %d\n"), aCtrlId));
       
  2331     CAknFepCtrlRepeatButton *self = new(ELeave) CAknFepCtrlRepeatButton(aUiLayout, 
       
  2332                                                                         aCtrlId, 
       
  2333                                                                         aEvent, 
       
  2334                                                                         aUnicode,
       
  2335                                                                         aNormalID,
       
  2336                                                                         aPressedID,
       
  2337                                                                         aInactiveID);
       
  2338 
       
  2339     CleanupStack::PushL(self);
       
  2340     self->ConstructL();
       
  2341     
       
  2342     return self;
       
  2343     }
       
  2344 
       
  2345 // ---------------------------------------------------------
       
  2346 // Constructor
       
  2347 // ---------------------------------------------------------
       
  2348 //
       
  2349 EXPORT_C CAknFepCtrlRepeatButton* CAknFepCtrlRepeatButton::NewL(CFepUiLayout* aUiLayout, 
       
  2350                                                                 TInt aCtrlId,
       
  2351                                                                 TInt aEvent,
       
  2352                                                                 TInt aUnicode,
       
  2353                                                                 TAknsItemID aNormalID,
       
  2354                                                                 TAknsItemID aPressedID,
       
  2355                                                                 TAknsItemID aInactiveID)
       
  2356     {
       
  2357     //PRINTF((_L("CAknFepCtrlRepeatButton::NewL(), aCtrlId = %d\n"), aCtrlId));
       
  2358     CAknFepCtrlRepeatButton *self = NewLC(aUiLayout, aCtrlId, aEvent, aUnicode,
       
  2359                                           aNormalID, aPressedID, aInactiveID);
       
  2360     CleanupStack::Pop(self);
       
  2361     
       
  2362     return self;
       
  2363     }
       
  2364         
       
  2365 // ---------------------------------------------------------
       
  2366 // Destructor
       
  2367 // ---------------------------------------------------------
       
  2368 //
       
  2369 EXPORT_C CAknFepCtrlRepeatButton::~CAknFepCtrlRepeatButton()
       
  2370     {
       
  2371     //PRINTF((_L("CAknFepCtrlRepeatButton::~CAknFepCtrlRepeatButton()\n")));
       
  2372     CancelRepeat();
       
  2373 
       
  2374     delete iLongPressTimer;
       
  2375     delete iRepeatTimer;
       
  2376     }
       
  2377     
       
  2378 // ---------------------------------------------------------
       
  2379 // Constructor
       
  2380 // ---------------------------------------------------------
       
  2381 //
       
  2382 EXPORT_C CAknFepCtrlRepeatButton::CAknFepCtrlRepeatButton(CFepUiLayout* aUiLayout, 
       
  2383                                                           TInt aCtrlId,
       
  2384                                                           TInt aEvent,
       
  2385                                                           TInt aUnicode,
       
  2386                                                           TAknsItemID aNormalID,
       
  2387                                                           TAknsItemID aPressedID,
       
  2388                                                           TAknsItemID aInactiveID)
       
  2389     :CAknFepCtrlEventButton(aUiLayout, aCtrlId, aEvent, aUnicode,
       
  2390 														aNormalID,
       
  2391 														aPressedID,
       
  2392 														aInactiveID)
       
  2393     {
       
  2394     iLongPressInterval = KLongPressInterval;
       
  2395     iRepeatInterval = KRepeatInterval;
       
  2396     }
       
  2397 
       
  2398 // ---------------------------------------------------------
       
  2399 // Constructor
       
  2400 // ---------------------------------------------------------
       
  2401 //
       
  2402 EXPORT_C void CAknFepCtrlRepeatButton::ConstructL()
       
  2403     {
       
  2404     //PRINTF((_L("CAknFepCtrlRepeatButton::ConstructL()\n")));
       
  2405     BaseConstructL();
       
  2406     
       
  2407     iLongPressTimer = CAknFepTimer::NewL(this);
       
  2408     iRepeatTimer = CAknFepTimer::NewL(this);
       
  2409     }
       
  2410     
       
  2411 // ---------------------------------------------------------
       
  2412 // Time out event handler of both long press timer & repeat timer
       
  2413 // ---------------------------------------------------------
       
  2414 //
       
  2415 EXPORT_C void CAknFepCtrlRepeatButton::HandleTimerOut(const CAknFepTimer* aTimer)
       
  2416     {
       
  2417     //PRINTF((_L("CAknFepCtrlRepeatButton::HandleTimerOut()--")));
       
  2418     if (aTimer == iLongPressTimer)
       
  2419         {
       
  2420         //PRINTF((_L("long press timer timeout\n")));
       
  2421         iRepeatTimer->SetTimer(iRepeatInterval);
       
  2422         }
       
  2423     else
       
  2424         {
       
  2425         if (aTimer == iRepeatTimer)
       
  2426             {
       
  2427             //PRINTF((_L("repeat timer timeout: EEventButtonUp reported\n")));
       
  2428             if ( Unicode() )
       
  2429                 {
       
  2430                 TInt unicode = Unicode();
       
  2431                 TPtrC ptr = (TUint16*)(&unicode ) ;
       
  2432                 ReportEvent(Event(),ptr);   
       
  2433 #ifdef RD_TACTILE_FEEDBACK
       
  2434 			    if (UiLayout()->SupportTactileFeedback())
       
  2435 			        {
       
  2436 			        UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveInput);
       
  2437 			        }
       
  2438 #endif //RD_TACTILE_FEEDBACK                
       
  2439                 }
       
  2440             else
       
  2441                 {
       
  2442                 ReportEvent(EEventButtonUp);
       
  2443                 }
       
  2444             iRepeatTimer->SetTimer(iRepeatInterval);
       
  2445             }
       
  2446         }
       
  2447     }
       
  2448 
       
  2449 // ---------------------------------------------------------
       
  2450 // Handle button down start long press timer 
       
  2451 // ---------------------------------------------------------
       
  2452 //
       
  2453 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlRepeatButton::HandlePointerDownEventL(const TPoint& aPt)
       
  2454     {
       
  2455     //PRINTF((_L("CAknFepCtrlRepeatButton::HandleButtonDown()\n")));
       
  2456     
       
  2457     //PRINTF((_L("Set long press Timer\n")));
       
  2458     if( IsDimmed() )
       
  2459     	{
       
  2460     	return NULL;
       
  2461     	}
       
  2462     iLongPressTimer->SetTimer(iLongPressInterval);
       
  2463     TInt unicode = Unicode();
       
  2464     TPtrC ptr = (TUint16*)(&unicode);
       
  2465     ReportEvent(Event(), ptr);  
       
  2466     return CAknFepCtrlCommonButton::HandlePointerDownEventL(aPt);
       
  2467     }
       
  2468                                                           
       
  2469 // ---------------------------------------------------------
       
  2470 // Handle button up cancel timers 
       
  2471 // ---------------------------------------------------------
       
  2472 //
       
  2473 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlRepeatButton::HandlePointerUpEventL(const TPoint& aPt)
       
  2474     {
       
  2475     //PRINTF((_L("CAknFepCtrlRepeatButton::HandleButtonUp()\n")));
       
  2476     
       
  2477     CancelRepeat();
       
  2478     
       
  2479     return CAknFepCtrlCommonButton::HandlePointerUpEventL(aPt);
       
  2480     }
       
  2481 
       
  2482 // ---------------------------------------------------------
       
  2483 // Handle pointer levae event cancel timers 
       
  2484 // ---------------------------------------------------------
       
  2485 //
       
  2486 EXPORT_C void CAknFepCtrlRepeatButton::HandlePointerLeave(const TPoint& aPoint)
       
  2487     {
       
  2488     CAknFepCtrlCommonButton::HandlePointerLeave(aPoint);
       
  2489 
       
  2490     CancelRepeat();
       
  2491     }
       
  2492 
       
  2493 // ---------------------------------------------------------------------------
       
  2494 // CAknFepCtrlRepeatButton::CancelPointerDownL
       
  2495 // Cancel pointer down event
       
  2496 // (other items were commented in a header).
       
  2497 // ---------------------------------------------------------------------------
       
  2498 //    
       
  2499 EXPORT_C void CAknFepCtrlRepeatButton::CancelPointerDownL()
       
  2500     {
       
  2501     CAknFepCtrlCommonButton::CancelPointerDownL();     
       
  2502     
       
  2503     CancelRepeat();
       
  2504     }
       
  2505 
       
  2506 // ---------------------------------------------------------
       
  2507 // Set the repeat interval of repeat timer
       
  2508 // ---------------------------------------------------------
       
  2509 //
       
  2510 EXPORT_C void CAknFepCtrlRepeatButton::SetRepeatInterval(const TTimeIntervalMicroSeconds32& aTime)
       
  2511     {
       
  2512     iRepeatInterval = aTime;
       
  2513     }
       
  2514 
       
  2515 // ---------------------------------------------------------
       
  2516 // Cancel timers 
       
  2517 // ---------------------------------------------------------
       
  2518 //
       
  2519 EXPORT_C void CAknFepCtrlRepeatButton::CancelRepeat()
       
  2520     {
       
  2521     //PRINTF((_L("CAknFepCtrlRepeatButton::CancelRepeat()\n")));
       
  2522     iLongPressTimer->Cancel();
       
  2523     iRepeatTimer->Cancel();
       
  2524     }
       
  2525     
       
  2526 EXPORT_C CAknFepCtrlRawKeyButton* CAknFepCtrlRawKeyButton::NewL(CFepUiLayout* aUiLayout, 
       
  2527                                                                 TInt aControlId,
       
  2528                                                                 TAknsItemID aNormalID,
       
  2529                                                                 TAknsItemID aPressedID,
       
  2530                                                                 TAknsItemID aInactiveID, 
       
  2531                                                                 TInt aDownEvent,
       
  2532                                                                 TInt aUpEvent,
       
  2533                                                                 TInt aScanCode)
       
  2534     { 
       
  2535     CAknFepCtrlRawKeyButton* self = NewLC(aUiLayout, 
       
  2536                                           aControlId,
       
  2537                                           aNormalID,
       
  2538                                           aPressedID,
       
  2539                                           aInactiveID, 
       
  2540                                           aDownEvent, 
       
  2541                                           aUpEvent,
       
  2542                                           aScanCode);
       
  2543     CleanupStack::Pop(self);
       
  2544     
       
  2545     return self;                        
       
  2546     }
       
  2547     
       
  2548 EXPORT_C CAknFepCtrlRawKeyButton* CAknFepCtrlRawKeyButton::NewLC(CFepUiLayout* aUiLayout, 
       
  2549                                                                  TInt aControlId, 
       
  2550                                                                  TAknsItemID aNormalID,
       
  2551                                                                  TAknsItemID aPressedID,
       
  2552                                                                  TAknsItemID aInactiveID,
       
  2553                                                                  TInt aDownEvent,
       
  2554                                                                  TInt aUpEvent,
       
  2555                                                                  TInt aScanCode)
       
  2556     { 
       
  2557     CAknFepCtrlRawKeyButton* self = new (ELeave) CAknFepCtrlRawKeyButton(aUiLayout, 
       
  2558                                                                          aControlId,
       
  2559                                                                          aNormalID,
       
  2560                                                                          aPressedID,
       
  2561                                                                          aInactiveID,
       
  2562                                                                          aDownEvent,
       
  2563                                                                          aUpEvent,
       
  2564                                                                          aScanCode);
       
  2565     CleanupStack::PushL(self);
       
  2566     self->BaseConstructL();
       
  2567     return self;                      
       
  2568     }
       
  2569 
       
  2570 EXPORT_C CAknFepCtrlRawKeyButton::CAknFepCtrlRawKeyButton(CFepUiLayout* aUiLayout, 
       
  2571                                                           TInt aControlId,
       
  2572                                                           TAknsItemID aNormalID,
       
  2573                                                           TAknsItemID aPressedID,
       
  2574                                                           TAknsItemID aInactiveID, 
       
  2575                                                           TInt aDownEvent,
       
  2576                                                           TInt aUpEvent,
       
  2577                                                           TInt aScanCode)
       
  2578     : CAknFepCtrlCommonButton(aUiLayout, aControlId, aNormalID, aPressedID, aInactiveID),
       
  2579       iDownEvent(aDownEvent),
       
  2580       iUpEvent(aUpEvent),
       
  2581       iScanCode(aScanCode),
       
  2582       iLastPntDownEvent(EFalse)
       
  2583     {        
       
  2584     }
       
  2585 
       
  2586 EXPORT_C CAknFepCtrlRawKeyButton::~CAknFepCtrlRawKeyButton()
       
  2587     {
       
  2588     }
       
  2589 
       
  2590 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlRawKeyButton::HandlePointerDownEventL(const TPoint& aPoint)
       
  2591     {
       
  2592 /*    if (iDownEvent == KInvalidEventId)
       
  2593         {
       
  2594         return CButtonBase::HandlePointerDownEventL(aPoint);
       
  2595         }
       
  2596     
       
  2597     if(IsDimmed())
       
  2598         {
       
  2599         return NULL;
       
  2600         }
       
  2601     
       
  2602     CAknFepCtrlButton::HandlePointerDownEventL(aPoint);
       
  2603     if(IsActive())
       
  2604         {
       
  2605         SetBackgroundBmp(iActiveBmpPressed);
       
  2606         SetBackgroundMaskBmp(iActiveMaskBmpPressed);
       
  2607         }        
       
  2608     else
       
  2609         {
       
  2610         SetBackgroundBmp(iNonActiveBkBmpPressed);
       
  2611         SetBackgroundMaskBmp(iNonActiveBkMaskBmpPressed);
       
  2612         }        
       
  2613 
       
  2614     Draw();
       
  2615     UpdateArea(Rect(),ETrue);
       
  2616 */
       
  2617     if(IsDimmed())
       
  2618         {
       
  2619         return NULL;
       
  2620         }
       
  2621 
       
  2622     CAknFepCtrlCommonButton::HandlePointerDownEventL(aPoint);
       
  2623     TKeyEvent event= {0,0,0,0};
       
  2624     TPtrC eventDataPtr;
       
  2625     event.iScanCode = iScanCode;
       
  2626     eventDataPtr.Set(reinterpret_cast<TUint16*>(&event),sizeof(event));
       
  2627         
       
  2628     ReportEvent(iDownEvent,eventDataPtr);
       
  2629     
       
  2630     iLastPntDownEvent = ETrue;
       
  2631 
       
  2632     return this;
       
  2633     }
       
  2634 
       
  2635 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlRawKeyButton::HandlePointerUpEventL(const TPoint& aPoint)
       
  2636     {
       
  2637     if (iUpEvent == KInvalidEventId)
       
  2638         {
       
  2639         return CButtonBase::HandlePointerUpEventL(aPoint);
       
  2640         }
       
  2641     
       
  2642 /*    if(IsDimmed())
       
  2643         {
       
  2644         return NULL;
       
  2645         }
       
  2646         
       
  2647     if(IsActive())
       
  2648         {
       
  2649         SetBackgroundBmp(Bitmap(EBtnBmpActive,EFalse));
       
  2650         SetBackgroundMaskBmp(Bitmap(EBtnBmpActive,ETrue));
       
  2651         }
       
  2652     else
       
  2653         {
       
  2654         SetBackgroundBmp(Bitmap(EBtnBmpNonActive,EFalse));
       
  2655         SetBackgroundMaskBmp(Bitmap(EBtnBmpNonActive,ETrue));
       
  2656         }
       
  2657 
       
  2658     SetActive(ETrue);
       
  2659     Draw();
       
  2660     UpdateArea(Rect(),ETrue);    
       
  2661 */
       
  2662     if(IsDimmed())
       
  2663         {
       
  2664         return NULL;
       
  2665         }
       
  2666         
       
  2667     CAknFepCtrlCommonButton::HandlePointerUpEventL(aPoint);
       
  2668     if (iLastPntDownEvent)
       
  2669         {
       
  2670         // only when last event is pointer down event, there is need to simulate
       
  2671         // pointer up event
       
  2672     	TKeyEvent event= {0,0,0,0};
       
  2673         TPtrC eventDataPtr;
       
  2674         event.iScanCode = iScanCode;
       
  2675         eventDataPtr.Set(reinterpret_cast<TUint16*>(&event),sizeof(event));
       
  2676 
       
  2677         ReportEvent(iUpEvent,eventDataPtr);
       
  2678 
       
  2679         iLastPntDownEvent = EFalse;
       
  2680         }
       
  2681 
       
  2682     return this;
       
  2683     }
       
  2684 
       
  2685 EXPORT_C void CAknFepCtrlRawKeyButton::ConstructFromResourceL(TResourceReader& aReader)
       
  2686     {
       
  2687     TInt scancode = aReader.ReadInt16();
       
  2688     SetScanCode(scancode);
       
  2689     
       
  2690     TInt32 btnimgResId = aReader.ReadInt32();
       
  2691     TResourceReader imgreader;
       
  2692     CCoeEnv::Static()->CreateResourceReaderLC(imgreader, btnimgResId);
       
  2693     CAknFepCtrlCommonButton::ConstructFromResourceL(imgreader);
       
  2694     CleanupStack::PopAndDestroy(); // imgreader
       
  2695     
       
  2696     //ResizeBitmaps(Rect().Size());
       
  2697     iFirstTimeConstruct = EFalse;
       
  2698     }
       
  2699 
       
  2700 EXPORT_C void CAknFepCtrlRawKeyButton::ConstructFromResourceL()
       
  2701     {
       
  2702 	if (iResourceId == KInvalidResId)
       
  2703 	    {
       
  2704 	    return;
       
  2705 	    }
       
  2706 	
       
  2707     TResourceReader reader;
       
  2708     CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId);
       
  2709     
       
  2710     TInt scancode = reader.ReadInt16();
       
  2711     SetScanCode(scancode);
       
  2712     
       
  2713     TInt32 btnimgResId = reader.ReadInt32();
       
  2714     TResourceReader imgreader;
       
  2715     CCoeEnv::Static()->CreateResourceReaderLC(imgreader, btnimgResId);
       
  2716     CAknFepCtrlCommonButton::ConstructFromResourceL(imgreader);
       
  2717     CleanupStack::PopAndDestroy(2); // reader, imgreader
       
  2718     
       
  2719     //ResizeBitmaps(Rect().Size());
       
  2720     iFirstTimeConstruct = EFalse;
       
  2721     }
       
  2722 
       
  2723 EXPORT_C void CAknFepCtrlRawKeyButton::HandlePointerLeave(const TPoint& aPoint)
       
  2724     {
       
  2725     if (!Rect().Contains(aPoint))
       
  2726         {
       
  2727         TRAP_IGNORE(HandlePointerUpEventL(Rect().Center()));
       
  2728         }
       
  2729     }
       
  2730     
       
  2731 EXPORT_C void CAknFepCtrlRawKeyButton::OnDeActivate()
       
  2732     {
       
  2733     CButtonBase::OnDeActivate();
       
  2734     
       
  2735     if (iLastPntDownEvent)
       
  2736         {
       
  2737         TRAP_IGNORE(HandlePointerUpEventL(Rect().Center()));
       
  2738         }
       
  2739     }
       
  2740 
       
  2741 // ---------------------------------------------------------------------------
       
  2742 // CAknFepCtrlCommonButton::CAknFepCtrlCommonButton
       
  2743 // C++ default constructor can NOT contain any code, that
       
  2744 // might leave.
       
  2745 // (other items were commented in a header).
       
  2746 // ---------------------------------------------------------------------------
       
  2747 //
       
  2748 EXPORT_C CAknFepCtrlCommonButton::CAknFepCtrlCommonButton(CFepUiLayout* aUiLayout, 
       
  2749                                                           TInt aControlId,
       
  2750                                                           TAknsItemID aNormalID,
       
  2751                                                           TAknsItemID aPressedID,
       
  2752                                                           TAknsItemID aInactiveID)
       
  2753 : CButtonBase(TRect(), aUiLayout, aControlId),
       
  2754   iFirstTimeConstruct(ETrue),
       
  2755   iHighlight(EFalse),
       
  2756   iPressed(EFalse),
       
  2757   iTextColorIndex( KInvalidColorGroup )
       
  2758     {
       
  2759     iNormalImgID 	= aNormalID;
       
  2760     iPressedImgID	= aPressedID;
       
  2761     iInactiveImgID	= aInactiveID;
       
  2762     CFepUiBaseCtrl::SetActive( ETrue );
       
  2763     }
       
  2764     
       
  2765 // ---------------------------------------------------------------------------
       
  2766 // CAknFepCtrlCommonButton::NewL
       
  2767 // Two-phased constructor.
       
  2768 // (other items were commented in a header).
       
  2769 // ---------------------------------------------------------------------------
       
  2770 //
       
  2771 EXPORT_C CAknFepCtrlCommonButton* CAknFepCtrlCommonButton::NewL(CFepUiLayout* aUiLayout, 
       
  2772                                                                 TInt aControlId,
       
  2773                                                                 TAknsItemID aNormalID,
       
  2774                                                                 TAknsItemID aPressedID,
       
  2775                                                                 TAknsItemID aInactiveID)
       
  2776     {
       
  2777     CAknFepCtrlCommonButton* self = NewLC(aUiLayout, 
       
  2778     									  aControlId,
       
  2779     									  aNormalID,
       
  2780     									  aPressedID,
       
  2781     									  aInactiveID);
       
  2782     CleanupStack::Pop(self);
       
  2783     
       
  2784     return self;
       
  2785     }
       
  2786 // ---------------------------------------------------------------------------
       
  2787 // CAknFepCtrlCommonButton::NewLC
       
  2788 // Two-phased constructor.
       
  2789 // (other items were commented in a header).
       
  2790 // ---------------------------------------------------------------------------
       
  2791 //
       
  2792 EXPORT_C CAknFepCtrlCommonButton* CAknFepCtrlCommonButton::NewLC(CFepUiLayout* aUiLayout,
       
  2793                                                                  TInt aControlId,
       
  2794                                                                  TAknsItemID aNormalID,
       
  2795                                                                  TAknsItemID aPressedID,
       
  2796                                                                  TAknsItemID aInactiveID)
       
  2797     {
       
  2798     CAknFepCtrlCommonButton* self = new (ELeave) CAknFepCtrlCommonButton(aUiLayout, 
       
  2799     									aControlId,
       
  2800     									aNormalID,
       
  2801     									aPressedID,
       
  2802     									aInactiveID);
       
  2803     CleanupStack::PushL(self);
       
  2804     self->BaseConstructL();
       
  2805 
       
  2806     return self;
       
  2807     }    
       
  2808     
       
  2809 // -----------------------------------------------------------------------------
       
  2810 // Destructor.
       
  2811 // (other items were commented in a header).
       
  2812 // -----------------------------------------------------------------------------
       
  2813 //
       
  2814 EXPORT_C CAknFepCtrlCommonButton::~CAknFepCtrlCommonButton()
       
  2815     {
       
  2816     DeleteForgroundRes();
       
  2817     delete iColorIcons;
       
  2818     delete iText;
       
  2819     }
       
  2820 // ---------------------------------------------------------------------------
       
  2821 // CAknFepCtrlCommonButton::ConstructFromResourceL
       
  2822 // The order of the image ids in the CButtonBase class must not be changed
       
  2823 // (other items were commented in a header).
       
  2824 // ---------------------------------------------------------------------------
       
  2825 //
       
  2826 EXPORT_C void CAknFepCtrlCommonButton::ConstructFromResourceL(TResourceReader& aReader)
       
  2827     {
       
  2828     if (!iFirstTimeConstruct)
       
  2829 		{
       
  2830         DeleteForgroundRes();
       
  2831         if( iColorIcons )
       
  2832         	iColorIcons->ReConstructL();
       
  2833 		}
       
  2834     
       
  2835     TPtrC bmpFileName = aReader.ReadTPtrC();    // Read the file name of the bmps
       
  2836     TInt32 imgMajorSkinId = aReader.ReadInt32();
       
  2837     TInt colorGroup = aReader.ReadInt16();    
       
  2838     TAknsItemID id;
       
  2839 	
       
  2840     // Get the image ids and mask ids from resource
       
  2841     TInt bmpId = aReader.ReadInt16(); 
       
  2842     TInt bmpMskId = aReader.ReadInt16();
       
  2843     
       
  2844     // read skin item id
       
  2845     const TInt skinitemid = aReader.ReadInt16();
       
  2846     id.Set(TInt(imgMajorSkinId), skinitemid);
       
  2847     
       
  2848     if (bmpId != KInvalidBmp)
       
  2849         {
       
  2850     	if (bmpMskId != KInvalidBmp)
       
  2851     		{
       
  2852     		if( colorGroup == KInvalidColorGroup )
       
  2853     			{
       
  2854 	    		AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
  2855                        id,
       
  2856                        iForgroundBmp,
       
  2857                        iForgroundBmpMask,
       
  2858                        bmpFileName,
       
  2859                        bmpId,
       
  2860                        bmpMskId);	
       
  2861     			}
       
  2862 			else
       
  2863 				{
       
  2864 			    AknsUtils::CreateColorIconL( UiLayout()->SkinInstance(),
       
  2865                              id,
       
  2866                              KAknsIIDQsnIconColors,
       
  2867                              colorGroup,
       
  2868                              iForgroundBmp,
       
  2869                              iForgroundBmpMask,
       
  2870                              bmpFileName,
       
  2871                              bmpId,
       
  2872                              bmpMskId,
       
  2873                              AKN_LAF_COLOR( 0 ) );   	
       
  2874 				}
       
  2875 
       
  2876     		AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved);
       
  2877     		AknIconUtils::SetSize(iForgroundBmpMask, iForgroundBmpRect.Size(), 
       
  2878     		                      EAspectRatioNotPreserved);
       
  2879     		                       
       
  2880     		/*CreateDimmedMaskL( iForgroundDimBmpMask, iForgroundBmpMask );
       
  2881     		AknIconUtils::SetSize(iForgroundDimBmpMask, iForgroundBmpRect.Size(), 
       
  2882     		                      EAspectRatioNotPreserved);*/
       
  2883     		}
       
  2884     	else
       
  2885 	        {
       
  2886 		    AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
  2887 		                           id,
       
  2888 		                           iForgroundBmp,
       
  2889 		                           bmpFileName,
       
  2890 		                           bmpId);
       
  2891 		    AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved);
       
  2892 	        }
       
  2893         }
       
  2894 	
       
  2895     if (!iFirstTimeConstruct)
       
  2896     	{
       
  2897         //ResizeBitmaps(iForgroundBmpRect.Size());
       
  2898     	Draw();
       
  2899     	}
       
  2900     
       
  2901     iFirstTimeConstruct = EFalse;    
       
  2902     }
       
  2903     
       
  2904 // ---------------------------------------------------------------------------
       
  2905 // CAknFepCtrlCommonButton::ConstructFromResourceL
       
  2906 // (other items were commented in a header).
       
  2907 // ---------------------------------------------------------------------------
       
  2908 //
       
  2909 EXPORT_C void CAknFepCtrlCommonButton::ConstructFromResourceL()
       
  2910 	{
       
  2911 	if (iResourceId == KInvalidResId)
       
  2912 		{
       
  2913         return;
       
  2914 		}
       
  2915 	
       
  2916 	if (!iFirstTimeConstruct)
       
  2917 		{
       
  2918 		// need to remove original bmp and maskbmp
       
  2919         DeleteForgroundRes();
       
  2920         if( iColorIcons )
       
  2921         	iColorIcons->ReConstructL();
       
  2922 		}
       
  2923 
       
  2924     TResourceReader reader;
       
  2925     CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId);
       
  2926 
       
  2927     TPtrC bmpFileName = reader.ReadTPtrC();    // Read the file name of the bmps
       
  2928     TInt32 imgMajorSkinId = reader.ReadInt32();
       
  2929     TInt colorGroup = reader.ReadInt16();
       
  2930     TAknsItemID id;
       
  2931 	
       
  2932 	// Get the image ids and mask ids from resource
       
  2933     TInt bmpId = reader.ReadInt16(); 
       
  2934     TInt bmpMskId = reader.ReadInt16();
       
  2935     
       
  2936     // Read skin item id
       
  2937     const TInt skinitemid = reader.ReadInt16();
       
  2938     id.Set(TInt(imgMajorSkinId), skinitemid);
       
  2939 
       
  2940     if (bmpId != KInvalidBmp)
       
  2941     {
       
  2942 	if (bmpMskId != KInvalidBmp)
       
  2943 		{
       
  2944 		if( colorGroup == KInvalidColorGroup )
       
  2945 			{
       
  2946     		AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
  2947                    id,
       
  2948                    iForgroundBmp,
       
  2949                    iForgroundBmpMask,
       
  2950                    bmpFileName,
       
  2951                    bmpId,
       
  2952                    bmpMskId);	
       
  2953 			}
       
  2954 		else
       
  2955 			{
       
  2956 		    AknsUtils::CreateColorIconL( UiLayout()->SkinInstance(),
       
  2957                          id,
       
  2958                          KAknsIIDQsnIconColors,
       
  2959                          colorGroup,
       
  2960                          iForgroundBmp,
       
  2961                          iForgroundBmpMask,
       
  2962                          bmpFileName,
       
  2963                          bmpId,
       
  2964                          bmpMskId,
       
  2965                          AKN_LAF_COLOR( 0 ) );   	
       
  2966 			}
       
  2967 
       
  2968         AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved);
       
  2969         AknIconUtils::SetSize(iForgroundBmpMask, iForgroundBmpRect.Size(), 
       
  2970                               EAspectRatioNotPreserved);
       
  2971 
       
  2972 		/*CreateDimmedMaskL( iForgroundDimBmpMask, 
       
  2973     					   iForgroundBmpMask );   
       
  2974  		AknIconUtils::SetSize(iForgroundDimBmpMask, iForgroundBmpRect.Size(), EAspectRatioNotPreserved);*/
       
  2975 		}
       
  2976     else
       
  2977         {
       
  2978 	    AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
  2979 	                           id,
       
  2980 	                           iForgroundBmp,
       
  2981 	                           bmpFileName,
       
  2982 	                           bmpId);
       
  2983 	    AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved);
       
  2984         }
       
  2985     }
       
  2986 
       
  2987     CleanupStack::PopAndDestroy(); // reader
       
  2988     
       
  2989     if (!iFirstTimeConstruct)
       
  2990     	{
       
  2991         //ResizeBitmaps(iForgroundBmpRect.Size());
       
  2992     	Draw();
       
  2993     	}
       
  2994 
       
  2995     iFirstTimeConstruct = EFalse;    	
       
  2996 	}
       
  2997 
       
  2998 // ---------------------------------------------------------------------------
       
  2999 // CAknFepCtrlCommonButton::Draw
       
  3000 // Draws UI
       
  3001 // (other items were commented in a header).
       
  3002 // ---------------------------------------------------------------------------
       
  3003 //
       
  3004 EXPORT_C void CAknFepCtrlCommonButton::Draw()
       
  3005     {
       
  3006     if(!AbleToDraw())
       
  3007         return;
       
  3008     
       
  3009     CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
       
  3010     
       
  3011     //mask bitmaps
       
  3012   	DrawOpaqueMaskBackground();  
       
  3013     TRect rect = Rect();        
       
  3014     TRect innerRect = rect;
       
  3015     innerRect.Shrink( 10, 10 );
       
  3016     
       
  3017     // ----- draw bitmaps -----
       
  3018     gc->Activate( BitmapDevice() );     
       
  3019    // gc->SetClippingRegion( &ValidClipRegion() );           
       
  3020     //gc->Clear(rect);
       
  3021     	
       
  3022     CFbsBitmap* bmpMask = NULL;
       
  3023 	
       
  3024     // Draw background    
       
  3025     if( IsDimmed() ) // Dimmed state
       
  3026     	{
       
  3027 		AknsDrawUtils::DrawFrame( UiLayout()->SkinInstance(), 
       
  3028 		                         *gc, 
       
  3029 		                         rect, 
       
  3030 		                         innerRect,
       
  3031 		                         iInactiveImgID,
       
  3032 		                         KAknsIIDDefault );
       
  3033     	if( iForgroundDimBmpMask )
       
  3034     		{
       
  3035     		delete iForgroundDimBmpMask;
       
  3036     		iForgroundDimBmpMask = NULL;
       
  3037     		}		                         
       
  3038     	TRAP_IGNORE(CreateDimmedMaskL( iForgroundDimBmpMask, 
       
  3039     					   iForgroundBmpMask ));
       
  3040 		AknIconUtils::SetSize(iForgroundDimBmpMask, iForgroundBmpRect.Size(), 
       
  3041                               EAspectRatioNotPreserved);
       
  3042                               		                         
       
  3043 		bmpMask = iForgroundDimBmpMask;    
       
  3044     	}
       
  3045     else
       
  3046     	{
       
  3047 		// Normal state or pressed state
       
  3048 		TAknsItemID ImgID;
       
  3049 		if (iHighlight)
       
  3050 			{
       
  3051 			ImgID = iPressedImgID;
       
  3052 			}
       
  3053 		else 
       
  3054 			{
       
  3055 			ImgID = /*iPressed*/PointerDown()? iPressedImgID : iNormalImgID;
       
  3056 			}
       
  3057 		
       
  3058 		AknsDrawUtils::DrawFrame( UiLayout()->SkinInstance(), 
       
  3059 	                     *gc, 
       
  3060 	                     rect, 
       
  3061 	                     innerRect,
       
  3062 	                     ImgID,
       
  3063 	                     KAknsIIDDefault ); 
       
  3064 	    bmpMask = iForgroundBmpMask;            	    		
       
  3065     	}
       
  3066     
       
  3067     // Draw forground
       
  3068     if ( iColorIcons ) // 3-pieces color icon
       
  3069     	{
       
  3070     	AknPenInputDrawUtils::Draw3PiecesColorIcon( iColorIcons, 
       
  3071     												*gc, 
       
  3072     												iForgroundBmpRect, 
       
  3073     												iDraw3PiecesInfo.iInnerRect );
       
  3074     	}
       
  3075 	else if( iForgroundBmp )
       
  3076 		{
       
  3077 		TRect srcRect( TPoint( 0, 0 ), iForgroundBmp->SizeInPixels() );
       
  3078 		if( bmpMask )
       
  3079 			{
       
  3080 			gc->BitBltMasked( iForgroundBmpRect.iTl, 
       
  3081 							  iForgroundBmp, 
       
  3082 							  srcRect,
       
  3083 							  bmpMask,
       
  3084 							  EFalse);
       
  3085 			}
       
  3086 		else
       
  3087 			{
       
  3088 			gc->BitBlt( iForgroundBmpRect.iTl,
       
  3089 						iForgroundBmp,
       
  3090 						srcRect );	
       
  3091 			}
       
  3092 		}
       
  3093 	
       
  3094     if (iText)
       
  3095         {
       
  3096 		//if( IsDimmed() )
       
  3097 		//	{
       
  3098 		//	gc->SetFadingParameters( KFadingParamBlack, KFadingParamWhite );
       
  3099         //	gc->SetFaded( ETrue );		
       
  3100 		//	}
       
  3101         
       
  3102         TAknLayoutText textLayout;
       
  3103         textLayout.LayoutText(Rect(), iTextFormat);
       
  3104         if( iTextColorIndex == KInvalidColorGroup )
       
  3105         	textLayout.DrawText(*gc, *iText);
       
  3106         else
       
  3107         	{
       
  3108 			TRgb color( KRgbBlack );  // sane default for nonskinned case
       
  3109 			if ( AknsUtils::AvkonSkinEnabled() )
       
  3110 				{
       
  3111 				AknsUtils::GetCachedColor( UiLayout()->SkinInstance(),
       
  3112 				               color, KAknsIIDQsnTextColors, iTextColorIndex );
       
  3113 				}	
       
  3114 			if( IsDimmed() )
       
  3115 				{			
       
  3116 				color = KRgbGray;	
       
  3117 				}	
       
  3118 			textLayout.DrawText(*gc, *iText, ETrue, color);	
       
  3119         	}
       
  3120         //if( IsDimmed() )
       
  3121         //	gc->SetFaded( EFalse );
       
  3122         }
       
  3123     }
       
  3124     
       
  3125 // ---------------------------------------------------------------------------
       
  3126 // CAknFepCtrlCommonButton::SetActive
       
  3127 // Set active for the button
       
  3128 // (other items were commented in a header).
       
  3129 // ---------------------------------------------------------------------------
       
  3130 //
       
  3131 EXPORT_C void CAknFepCtrlCommonButton::SetActive(TBool aActiveFlag)
       
  3132     {
       
  3133     if( IsDimmed() )
       
  3134         {
       
  3135         return;
       
  3136         }
       
  3137         
       
  3138     if(IsActive() != aActiveFlag)
       
  3139         {
       
  3140         CFepUiBaseCtrl::SetActive(aActiveFlag);
       
  3141 /*       if(BitGc())
       
  3142             {       
       
  3143             Draw();
       
  3144             UpdateArea(Rect(),EFalse);
       
  3145             }*/
       
  3146         }
       
  3147     }
       
  3148 
       
  3149 // ---------------------------------------------------------------------------
       
  3150 // CAknFepCtrlCommonButton::SetHighlight
       
  3151 // Set highlight for the button
       
  3152 // (other items were commented in a header).
       
  3153 // ---------------------------------------------------------------------------
       
  3154 //    
       
  3155 EXPORT_C void CAknFepCtrlCommonButton::SetHighlight(TBool aIsHighlight)
       
  3156     {
       
  3157     iHighlight = aIsHighlight;
       
  3158 
       
  3159     Draw();
       
  3160     UpdateArea(Rect(),EFalse);         
       
  3161     }
       
  3162     
       
  3163 // ---------------------------------------------------------------------------
       
  3164 // CAknFepCtrlCommonButton::ResizeBitmaps
       
  3165 // This methods shall be called by the container's SizeChanged handler
       
  3166 // (other items were commented in a header).
       
  3167 // ---------------------------------------------------------------------------
       
  3168 //
       
  3169 void CAknFepCtrlCommonButton::ResizeBitmaps(TSize aInnerSize)
       
  3170     {
       
  3171     if( iForgroundBmp && ( iForgroundBmp->SizeInPixels() != aInnerSize ) )
       
  3172         {
       
  3173         AknIconUtils::SetSize( iForgroundBmp, aInnerSize, EAspectRatioNotPreserved );
       
  3174         }
       
  3175     if( iForgroundBmpMask && ( iForgroundBmpMask->SizeInPixels() != aInnerSize ) )
       
  3176         {
       
  3177         AknIconUtils::SetSize( iForgroundBmpMask, aInnerSize, EAspectRatioNotPreserved );
       
  3178         }
       
  3179     
       
  3180         /*TRAP_IGNORE(CreateDimmedMaskL(iForgroundDimBmpMask, 
       
  3181                                       iForgroundBmpMask));*/
       
  3182     }
       
  3183     
       
  3184 // ---------------------------------------------------------------------------
       
  3185 // CAknFepCtrlCommonButton::SizeChanged
       
  3186 // This methods shall be called by the container's SizeChanged handler
       
  3187 // (other items were commented in a header).
       
  3188 // ---------------------------------------------------------------------------
       
  3189 //
       
  3190 EXPORT_C void CAknFepCtrlCommonButton::SizeChanged(TRect aNewRect, 
       
  3191 												   TRect aInnerRect, 
       
  3192 												   TBool aIsReloadImages)
       
  3193     {
       
  3194     if (aNewRect.Size().iWidth == 0 || aNewRect.Size().iHeight == 0)
       
  3195         {
       
  3196    	    return;
       
  3197         }
       
  3198     
       
  3199     TRect oriRect = Rect();
       
  3200     
       
  3201     if( oriRect == aNewRect && iForgroundBmpRect == aInnerRect )
       
  3202         {
       
  3203         return;
       
  3204         }
       
  3205     
       
  3206     SetRect(aNewRect);
       
  3207 
       
  3208     if (aIsReloadImages)
       
  3209         {
       
  3210         iForgroundBmpRect = aInnerRect;
       
  3211         ResizeBitmaps(aInnerRect.Size() );	
       
  3212         }
       
  3213     RootControl()->ReDrawRect( Rect() );
       
  3214     UpdateArea(Rect(), EFalse);
       
  3215     Draw();
       
  3216     UpdateArea(Rect(), EFalse);
       
  3217     }
       
  3218     
       
  3219 // ---------------------------------------------------------------------------
       
  3220 // CAknFepCtrlCommonButton::SetForgroundBmpRect
       
  3221 // This methods shall be called by the container's SizeChanged handler
       
  3222 // (other items were commented in a header).
       
  3223 // ---------------------------------------------------------------------------
       
  3224 //
       
  3225 EXPORT_C void CAknFepCtrlCommonButton::SetForgroundBmpRect(const TRect& aRect)
       
  3226 	{
       
  3227 	iForgroundBmpRect = aRect;	
       
  3228 	}
       
  3229 
       
  3230 EXPORT_C void CAknFepCtrlCommonButton::SetDraw3PieceFrameInfo(TDraw3PiecesFrame a3PiecesFrameInfo)
       
  3231 	{
       
  3232 	iDraw3PiecesInfo = a3PiecesFrameInfo;
       
  3233 	}
       
  3234 
       
  3235 // ---------------------------------------------------------------------------
       
  3236 // CAknFepCtrlCommonButton::DeleteForgroundRes
       
  3237 // This methods shall be called by the container's SizeChanged handler
       
  3238 // (other items were commented in a header).
       
  3239 // ---------------------------------------------------------------------------
       
  3240 //
       
  3241 void CAknFepCtrlCommonButton::DeleteForgroundRes()
       
  3242 	{
       
  3243     if( iForgroundBmp )
       
  3244 		{
       
  3245 		delete iForgroundBmp;
       
  3246 		iForgroundBmp = NULL;
       
  3247 		}
       
  3248 	if( iForgroundBmpMask )
       
  3249 		{
       
  3250 		delete iForgroundBmpMask;
       
  3251 		iForgroundBmpMask = NULL;
       
  3252 		}
       
  3253 	if( iForgroundDimBmpMask )
       
  3254 		{
       
  3255 		delete iForgroundDimBmpMask;
       
  3256 		iForgroundDimBmpMask = NULL;
       
  3257 		}
       
  3258 	}
       
  3259 	
       
  3260 // ---------------------------------------------------------------------------
       
  3261 // CAknFepCtrlCommonButton::CreateDimmedMaskL
       
  3262 // This methods shall be called by the container's SizeChanged handler
       
  3263 // (other items were commented in a header).
       
  3264 // ---------------------------------------------------------------------------
       
  3265 //	
       
  3266 void CAknFepCtrlCommonButton::CreateDimmedMaskL( CFbsBitmap*& aDimmedMask,
       
  3267                                                  const CFbsBitmap* aMask
       
  3268                                         		 /*TScaleMode aScaleMode*/ )
       
  3269 	{
       
  3270 	    if (aMask && aMask->DisplayMode() == EGray256)
       
  3271 	        {
       
  3272 	        delete aDimmedMask;
       
  3273 	        aDimmedMask = NULL;
       
  3274 
       
  3275 	        aDimmedMask = new (ELeave) CFbsBitmap;
       
  3276 
       
  3277 	        User::LeaveIfError(aDimmedMask->Create(aMask->SizeInPixels(), EGray256)); 
       
  3278 	        CleanupStack::PushL(aDimmedMask);
       
  3279 
       
  3280 	        CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(aDimmedMask);
       
  3281 	        CleanupStack::PushL(bitmapDevice);
       
  3282 
       
  3283 	        CFbsBitGc* bitGc(NULL);
       
  3284 	        User::LeaveIfError(bitmapDevice->CreateContext(bitGc));
       
  3285 	        CleanupStack::PushL(bitGc);
       
  3286 
       
  3287 	        bitGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
  3288 	        bitGc->BitBlt(TPoint(0, 0), aMask);
       
  3289 
       
  3290 	        aDimmedMask->LockHeap();
       
  3291 	        TInt w = aMask->SizeInPixels().iWidth; 
       
  3292 	        TInt h = aMask->SizeInPixels().iHeight;
       
  3293 	        TInt dataStride = aMask->DataStride() - w; 
       
  3294 	        unsigned char* address = (unsigned char *)aDimmedMask->DataAddress();  
       
  3295 
       
  3296 	        for ( TInt i = 0; i < h; ++i )
       
  3297 	            {
       
  3298 	            for ( TInt j = 0; j < w; ++j )
       
  3299 	                {
       
  3300 	                *address = KTransparency[*address];
       
  3301 	                ++address;
       
  3302 	                }
       
  3303 	            address += dataStride;         
       
  3304 	            }
       
  3305 
       
  3306 	        aDimmedMask->UnlockHeap();
       
  3307 
       
  3308 	        //AknIconUtils::SetSize(aDimmedMask, aMask->SizeInPixels(), aScaleMode);
       
  3309 
       
  3310 	        CleanupStack::PopAndDestroy(2); // bitmapDevice, bitGc
       
  3311 	        CleanupStack::Pop(1); // aDimmedMask
       
  3312 	        }
       
  3313 
       
  3314 	}
       
  3315 
       
  3316 // ---------------------------------------------------------------------------
       
  3317 // CAknFepCtrlCommonButton::HandlePointerDownEventL
       
  3318 // Handle button down event
       
  3319 // (other items were commented in a header).
       
  3320 // ---------------------------------------------------------------------------
       
  3321 //   
       
  3322 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlCommonButton::HandlePointerDownEventL(const TPoint& aPt)
       
  3323 	{
       
  3324     if( IsDimmed() )
       
  3325     	return NULL;
       
  3326     
       
  3327     CFepUiBaseCtrl::HandlePointerDownEventL(aPt);
       
  3328     iPressed =  ETrue;
       
  3329 	
       
  3330     Draw();
       
  3331     UpdateArea(Rect(),EFalse);
       
  3332     ReportEvent(EEventButtonDown);
       
  3333     return this;
       
  3334 	}
       
  3335 	
       
  3336 // ---------------------------------------------------------------------------
       
  3337 // CAknFepCtrlCommonButton::HandlePointerLeave
       
  3338 // Handle pointer leave event
       
  3339 // ---------------------------------------------------------------------------
       
  3340 //           
       
  3341 EXPORT_C void CAknFepCtrlCommonButton::HandlePointerLeave(const TPoint& aPt)
       
  3342     {
       
  3343     if( IsDimmed() )
       
  3344         return;
       
  3345     
       
  3346     CFepUiBaseCtrl::HandlePointerLeave(aPt);    
       
  3347     iPressed = EFalse; 
       
  3348 	
       
  3349     RootControl()->ReDrawRect( Rect() );
       
  3350     UpdateArea(Rect(),EFalse);   
       
  3351 
       
  3352     return ;
       
  3353     }
       
  3354 	
       
  3355 // ---------------------------------------------------------------------------
       
  3356 // CAknFepCtrlCommonButton::HandleButtonUpEventL
       
  3357 // Handle button up event
       
  3358 // (other items were commented in a header).
       
  3359 // ---------------------------------------------------------------------------
       
  3360 //        
       
  3361 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlCommonButton::HandlePointerUpEventL(const TPoint& aPt)        
       
  3362     {
       
  3363     CFepUiBaseCtrl::HandlePointerUpEventL(aPt);    
       
  3364     if( IsDimmed() )
       
  3365         return NULL;
       
  3366 	
       
  3367     iPressed = EFalse;
       
  3368     SetActive(ETrue);
       
  3369    	RootControl()->ReDrawRect( Rect() );
       
  3370     //Draw();
       
  3371     UpdateArea(Rect(),EFalse);    
       
  3372     
       
  3373     ReportEvent(EEventButtonUp);
       
  3374     
       
  3375 #ifdef RD_TACTILE_FEEDBACK   
       
  3376     {
       
  3377     UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveInput, ETrue, EFalse);
       
  3378     }
       
  3379 #endif // RD_TACTILE_FEEDBACK    
       
  3380     
       
  3381     return this;
       
  3382     }
       
  3383 
       
  3384 EXPORT_C void CAknFepCtrlCommonButton::HandlePointerEnter(const TPoint& aPt)
       
  3385     {
       
  3386     if( IsDimmed() )
       
  3387         return;
       
  3388     
       
  3389     CFepUiBaseCtrl::HandlePointerEnter(aPt);    
       
  3390     iPressed = ETrue; 
       
  3391     Draw();
       
  3392     UpdateArea(Rect(),EFalse);   
       
  3393 
       
  3394     return ;
       
  3395     }
       
  3396 
       
  3397 // ---------------------------------------------------------------------------
       
  3398 // CAknFepCtrlCommonButton::CancelPointerDownL
       
  3399 // (other items were commented in a header).
       
  3400 // ---------------------------------------------------------------------------
       
  3401 //        
       
  3402 EXPORT_C void CAknFepCtrlCommonButton::CancelPointerDownL()
       
  3403     {
       
  3404     CFepUiBaseCtrl::CancelPointerDownL();
       
  3405     }
       
  3406 
       
  3407 // ---------------------------------------------------------------------------
       
  3408 // CAknFepCtrlCommonButton::SetForegroundBmpL
       
  3409 // (other items were commented in a header).
       
  3410 // ---------------------------------------------------------------------------
       
  3411 //        
       
  3412 EXPORT_C void CAknFepCtrlCommonButton::SetForegroundBmpL(CFbsBitmap* aBmp,
       
  3413                                                          CFbsBitmap* aMaskBmp)
       
  3414     {
       
  3415     DeleteForgroundRes();
       
  3416     
       
  3417     iForgroundBmp = aBmp;
       
  3418     iForgroundBmpMask = aMaskBmp;
       
  3419 
       
  3420     ResizeBitmaps(iForgroundBmpRect.Size());
       
  3421     }
       
  3422 
       
  3423 EXPORT_C void CAknFepCtrlCommonButton::Move(const TPoint& aOffset)
       
  3424     {
       
  3425     CButtonBase::Move(aOffset);
       
  3426     iForgroundBmpRect.Move( aOffset );
       
  3427     
       
  3428     if ( iColorIcons ) 
       
  3429         {
       
  3430         iDraw3PiecesInfo.iInnerRect.Move( aOffset );
       
  3431         }
       
  3432     }
       
  3433 
       
  3434 
       
  3435 
       
  3436 // ---------------------------------------------------------------------------
       
  3437 // CAknFepCtrlMultiImageButton::CAknFepCtrlMultiImageButton
       
  3438 // C++ default constructor can NOT contain any code, that
       
  3439 // might leave.
       
  3440 // (other items were commented in a header).
       
  3441 // ---------------------------------------------------------------------------
       
  3442 //
       
  3443 EXPORT_C CAknFepCtrlMultiImageButton::CAknFepCtrlMultiImageButton(CFepUiLayout* aUiLayout, 
       
  3444                                                                   TInt aControlId,
       
  3445                                                                   TAknsItemID aNormalID,
       
  3446                                                                   TAknsItemID aPressedID,
       
  3447                                                                   TAknsItemID aInactiveID)
       
  3448 	: CAknFepCtrlCommonButton(aUiLayout, aControlId, aNormalID, aPressedID, aInactiveID)    								
       
  3449     {
       
  3450     iNormalImgID = aNormalID;
       
  3451     iPressedImgID = aPressedID;
       
  3452     iInactiveImgID = aInactiveID;       
       
  3453     }
       
  3454     
       
  3455 // ---------------------------------------------------------------------------
       
  3456 // CAknFepCtrlMultiImageButton::NewL
       
  3457 // Two-phased constructor.
       
  3458 // (other items were commented in a header).
       
  3459 // ---------------------------------------------------------------------------
       
  3460 //
       
  3461 EXPORT_C CAknFepCtrlMultiImageButton* CAknFepCtrlMultiImageButton::NewL(CFepUiLayout* aUiLayout, 
       
  3462                                                                         TInt aControlId,
       
  3463                                                                         TAknsItemID aNormalID,
       
  3464                                                                         TAknsItemID aPressedID,
       
  3465                                                                         TAknsItemID aInactiveID)
       
  3466     {
       
  3467     CAknFepCtrlMultiImageButton* self = NewLC(aUiLayout, 
       
  3468     									  aControlId,
       
  3469     									  aNormalID,
       
  3470     									  aPressedID,
       
  3471     									  aInactiveID);
       
  3472     CleanupStack::Pop(self);
       
  3473     
       
  3474     return self;
       
  3475     }
       
  3476 // ---------------------------------------------------------------------------
       
  3477 // CAknFepCtrlMultiImageButton::NewLC
       
  3478 // Two-phased constructor.
       
  3479 // (other items were commented in a header).
       
  3480 // ---------------------------------------------------------------------------
       
  3481 //
       
  3482 EXPORT_C CAknFepCtrlMultiImageButton* CAknFepCtrlMultiImageButton::NewLC(CFepUiLayout* aUiLayout,
       
  3483                                                                          TInt aControlId,
       
  3484                                                                          TAknsItemID aNormalID,
       
  3485                                                                          TAknsItemID aPressedID,
       
  3486                                                                          TAknsItemID aInactiveID)
       
  3487     {
       
  3488     CAknFepCtrlMultiImageButton* self = new (ELeave) CAknFepCtrlMultiImageButton(aUiLayout, 
       
  3489     									aControlId,
       
  3490     									aNormalID,
       
  3491     									aPressedID,
       
  3492     									aInactiveID);
       
  3493     CleanupStack::PushL(self);
       
  3494     self->BaseConstructL();
       
  3495 
       
  3496     return self;
       
  3497     }    
       
  3498     
       
  3499 // -----------------------------------------------------------------------------
       
  3500 // Destructor.
       
  3501 // (other items were commented in a header).
       
  3502 // -----------------------------------------------------------------------------
       
  3503 //
       
  3504 EXPORT_C CAknFepCtrlMultiImageButton::~CAknFepCtrlMultiImageButton()
       
  3505     {
       
  3506     DeleteForgroundRes();
       
  3507     delete iText;
       
  3508     }
       
  3509 // ---------------------------------------------------------------------------
       
  3510 // CAknFepCtrlMultiImageButton::ConstructFromResourceL
       
  3511 // The order of the image ids in the CButtonBase class must not be changed
       
  3512 // (other items were commented in a header).
       
  3513 // ---------------------------------------------------------------------------
       
  3514 //
       
  3515 EXPORT_C void CAknFepCtrlMultiImageButton::ConstructFromResourceL(TResourceReader& aReader)
       
  3516     {
       
  3517 		if (!iFirstTimeConstruct)
       
  3518 		{
       
  3519         DeleteForgroundRes();
       
  3520 		}
       
  3521     
       
  3522     TPtrC bmpFileName = aReader.ReadTPtrC();    // Read the file name of the bmps
       
  3523     TInt32 imgMajorSkinId = aReader.ReadInt32();
       
  3524     TInt colorGroup = aReader.ReadInt16();    
       
  3525     TAknsItemID id;
       
  3526 	
       
  3527     // Get the image ids and mask ids from resource
       
  3528     TInt bmpId = aReader.ReadInt16(); 
       
  3529     TInt bmpMskId = aReader.ReadInt16();
       
  3530     
       
  3531     // read skin item id
       
  3532     const TInt skinitemid = aReader.ReadInt16();
       
  3533     id.Set(TInt(imgMajorSkinId), skinitemid);
       
  3534     
       
  3535     if (bmpId != KInvalidBmp)
       
  3536         {
       
  3537     	if (bmpMskId != KInvalidBmp)
       
  3538     		{
       
  3539     		if( colorGroup == KInvalidColorGroup )
       
  3540     			{
       
  3541 	    		AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
  3542                        id,
       
  3543                        iForground1Bmp,
       
  3544                        iForground1BmpMask,
       
  3545                        bmpFileName,
       
  3546                        bmpId,
       
  3547                        bmpMskId);	
       
  3548     			}
       
  3549 			else
       
  3550 				{
       
  3551 			    AknsUtils::CreateColorIconL( UiLayout()->SkinInstance(),
       
  3552                              id,
       
  3553                              KAknsIIDQsnIconColors,
       
  3554                              colorGroup,
       
  3555                              iForground1Bmp,
       
  3556                              iForground1BmpMask,
       
  3557                              bmpFileName,
       
  3558                              bmpId,
       
  3559                              bmpMskId,
       
  3560                              AKN_LAF_COLOR( 0 ) );   	
       
  3561 				}
       
  3562 
       
  3563     		AknIconUtils::SetSize(iForground1Bmp, iForground1BmpRect.Size(), EAspectRatioNotPreserved);
       
  3564     		AknIconUtils::SetSize(iForground1BmpMask, iForground1BmpRect.Size(), 
       
  3565     		                      EAspectRatioNotPreserved);
       
  3566     		                       
       
  3567     		/*CreateDimmedMaskL( iForground1DimBmpMask, iForground1BmpMask );
       
  3568     		AknIconUtils::SetSize(iForground1DimBmpMask, iForground1BmpRect.Size(), 
       
  3569     		                      EAspectRatioNotPreserved);*/
       
  3570     		}
       
  3571     	else
       
  3572 	        {
       
  3573 		    AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
  3574 		                           id,
       
  3575 		                           iForground1Bmp,
       
  3576 		                           bmpFileName,
       
  3577 		                           bmpId);
       
  3578 		    AknIconUtils::SetSize(iForground1Bmp, iForground1BmpRect.Size(), EAspectRatioNotPreserved);
       
  3579 	        }
       
  3580         }
       
  3581 	
       
  3582 	
       
  3583 	
       
  3584     TAknsItemID id2;
       
  3585 	
       
  3586     // Get the image ids and mask ids from resource
       
  3587     TInt bmp2Id = aReader.ReadInt16(); 
       
  3588     TInt bmp2MskId = aReader.ReadInt16();
       
  3589     
       
  3590     // read skin item id
       
  3591     const TInt skinitem2id = aReader.ReadInt16();
       
  3592     id2.Set(TInt(imgMajorSkinId), skinitem2id);
       
  3593     
       
  3594     if (bmp2Id != KInvalidBmp)
       
  3595         {
       
  3596     	if (bmp2MskId != KInvalidBmp)
       
  3597     		{
       
  3598     		if( colorGroup == KInvalidColorGroup )
       
  3599     			{
       
  3600 	    		AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
  3601                        id2,
       
  3602                        iForground2Bmp,
       
  3603                        iForground2BmpMask,
       
  3604                        bmpFileName,
       
  3605                        bmp2Id,
       
  3606                        bmp2MskId);	
       
  3607     			}
       
  3608 			else
       
  3609 				{
       
  3610 			    AknsUtils::CreateColorIconL( UiLayout()->SkinInstance(),
       
  3611                              id2,
       
  3612                              KAknsIIDQsnIconColors,
       
  3613                              colorGroup,
       
  3614                              iForground2Bmp,
       
  3615                              iForground2BmpMask,
       
  3616                              bmpFileName,
       
  3617                              bmp2Id,
       
  3618                              bmp2MskId,
       
  3619                              AKN_LAF_COLOR( 0 ) );   	
       
  3620 				}
       
  3621 
       
  3622     		AknIconUtils::SetSize(iForground2Bmp, iForground2BmpRect.Size(), EAspectRatioNotPreserved);
       
  3623     		AknIconUtils::SetSize(iForground2BmpMask, iForground2BmpRect.Size(), 
       
  3624                               EAspectRatioNotPreserved);
       
  3625     		                       
       
  3626     		/*CreateDimmedMaskL( iForground2DimBmpMask, iForground2BmpMask );
       
  3627     		AknIconUtils::SetSize(iForground2DimBmpMask, iForground2BmpRect.Size(), 
       
  3628                               EAspectRatioNotPreserved);*/
       
  3629     		}
       
  3630     	else
       
  3631 	        {
       
  3632 		    AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
  3633 		                           id2,
       
  3634 		                           iForground2Bmp,
       
  3635 		                           bmpFileName,
       
  3636 		                           bmp2Id);
       
  3637 		    AknIconUtils::SetSize(iForground2Bmp, iForground2BmpRect.Size(), EAspectRatioNotPreserved);
       
  3638 	        }
       
  3639         }	
       
  3640 	
       
  3641     if (!iFirstTimeConstruct)
       
  3642     	{
       
  3643     	Draw();
       
  3644     	}
       
  3645     
       
  3646     iFirstTimeConstruct = EFalse;    
       
  3647     }
       
  3648     
       
  3649 // ---------------------------------------------------------------------------
       
  3650 // CAknFepCtrlMultiImageButton::ConstructFromResourceL
       
  3651 // (other items were commented in a header).
       
  3652 // ---------------------------------------------------------------------------
       
  3653 //
       
  3654 EXPORT_C void CAknFepCtrlMultiImageButton::ConstructFromResourceL()
       
  3655 	{
       
  3656 	if (iResourceId == KInvalidResId)
       
  3657 		{
       
  3658         User::Leave(KErrArgument);
       
  3659 		}
       
  3660 	
       
  3661 	if (!iFirstTimeConstruct)
       
  3662 		{
       
  3663 		// need to remove original bmp and maskbmp
       
  3664         DeleteForgroundRes();
       
  3665 		}
       
  3666 
       
  3667     TResourceReader reader;
       
  3668     CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId);
       
  3669 
       
  3670     TPtrC bmpFileName = reader.ReadTPtrC();    // Read the file name of the bmps
       
  3671     TInt32 imgMajorSkinId = reader.ReadInt32();
       
  3672     TInt colorGroup = reader.ReadInt16();
       
  3673     TAknsItemID id;
       
  3674 	
       
  3675 	// Get the image ids and mask ids from resource
       
  3676     TInt bmpId = reader.ReadInt16(); 
       
  3677     TInt bmpMskId = reader.ReadInt16();
       
  3678     
       
  3679     // Read skin item id
       
  3680     const TInt skinitemid = reader.ReadInt16();
       
  3681     id.Set(TInt(imgMajorSkinId), skinitemid);
       
  3682 
       
  3683     if (bmpId != KInvalidBmp)
       
  3684     {
       
  3685 	if (bmpMskId != KInvalidBmp)
       
  3686 		{
       
  3687 		if( colorGroup == KInvalidColorGroup )
       
  3688 			{
       
  3689     		AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
  3690                    id,
       
  3691                    iForground1Bmp,
       
  3692                    iForground1BmpMask,
       
  3693                    bmpFileName,
       
  3694                    bmpId,
       
  3695                    bmpMskId);	
       
  3696 			}
       
  3697 		else
       
  3698 			{
       
  3699 		    AknsUtils::CreateColorIconL( UiLayout()->SkinInstance(),
       
  3700                          id,
       
  3701                          KAknsIIDQsnIconColors,
       
  3702                          colorGroup,
       
  3703                          iForground1Bmp,
       
  3704                          iForground1BmpMask,
       
  3705                          bmpFileName,
       
  3706                          bmpId,
       
  3707                          bmpMskId,
       
  3708                          AKN_LAF_COLOR( 0 ) );   	
       
  3709 			}
       
  3710 
       
  3711     AknIconUtils::SetSize(iForground1Bmp, iForground1BmpRect.Size(), EAspectRatioNotPreserved);
       
  3712     AknIconUtils::SetSize(iForground1BmpMask, iForground1BmpRect.Size(), EAspectRatioNotPreserved);
       
  3713 
       
  3714 		/*CreateDimmedMaskL( iForground1DimBmpMask, 
       
  3715     					   iForground1BmpMask );   
       
  3716  		AknIconUtils::SetSize(iForground1DimBmpMask, iForground1BmpRect.Size(), EAspectRatioNotPreserved);*/
       
  3717 		}
       
  3718     else
       
  3719         {
       
  3720 	    AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
  3721 	                           id,
       
  3722 	                           iForground1Bmp,
       
  3723 	                           bmpFileName,
       
  3724 	                           bmpId);
       
  3725 	    AknIconUtils::SetSize(iForground1Bmp, iForground1BmpRect.Size(), EAspectRatioNotPreserved);
       
  3726         }
       
  3727     }
       
  3728 
       
  3729 
       
  3730 
       
  3731 
       
  3732 
       
  3733 
       
  3734 
       
  3735 
       
  3736 
       
  3737 
       
  3738 
       
  3739 
       
  3740     TAknsItemID id2;
       
  3741 	
       
  3742 	// Get the image ids and mask ids from resource
       
  3743     TInt bmp2Id = reader.ReadInt16(); 
       
  3744     TInt bmp2MskId = reader.ReadInt16();
       
  3745     
       
  3746     // Read skin item id
       
  3747     const TInt skinitem2id = reader.ReadInt16();
       
  3748     id2.Set(TInt(imgMajorSkinId), skinitem2id);
       
  3749 
       
  3750     if (bmp2Id != KInvalidBmp)
       
  3751     {
       
  3752 	if (bmp2MskId != KInvalidBmp)
       
  3753 		{
       
  3754 		if( colorGroup == KInvalidColorGroup )
       
  3755 			{
       
  3756     		AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
  3757                    id2,
       
  3758                    iForground2Bmp,
       
  3759                    iForground2BmpMask,
       
  3760                    bmpFileName,
       
  3761                    bmp2Id,
       
  3762                    bmp2MskId);	
       
  3763 			}
       
  3764 		else
       
  3765 			{
       
  3766 		    AknsUtils::CreateColorIconL( UiLayout()->SkinInstance(),
       
  3767                          id,
       
  3768                          KAknsIIDQsnIconColors,
       
  3769                          colorGroup,
       
  3770                          iForground2Bmp,
       
  3771                          iForground2BmpMask,
       
  3772                          bmpFileName,
       
  3773                          bmp2Id,
       
  3774                          bmp2MskId,
       
  3775                          AKN_LAF_COLOR( 0 ) );   	
       
  3776 			}
       
  3777 
       
  3778 		AknIconUtils::SetSize(iForground2Bmp, iForground2BmpRect.Size(), EAspectRatioPreserved);
       
  3779 		AknIconUtils::SetSize(iForground2BmpMask, iForground2BmpRect.Size(), EAspectRatioPreserved);
       
  3780 
       
  3781 		/*CreateDimmedMaskL( iForground2DimBmpMask, iForground2BmpMask );   
       
  3782  		AknIconUtils::SetSize(iForground2DimBmpMask, iForground2BmpRect.Size(), 
       
  3783                           EAspectRatioNotPreserved);*/
       
  3784 		}
       
  3785     else
       
  3786         {
       
  3787 	    AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
       
  3788 	                           id,
       
  3789 	                           iForground2Bmp,
       
  3790 	                           bmpFileName,
       
  3791 	                           bmp2Id);
       
  3792 	    AknIconUtils::SetSize(iForground2Bmp, iForground2BmpRect.Size(), EAspectRatioPreserved);
       
  3793         }
       
  3794     }
       
  3795 
       
  3796 
       
  3797 
       
  3798 
       
  3799 
       
  3800 
       
  3801     CleanupStack::PopAndDestroy(); // reader
       
  3802     
       
  3803     if (!iFirstTimeConstruct)
       
  3804     	{
       
  3805         //ResizeBitmaps(iForgroundBmpRect.Size());
       
  3806     	Draw();
       
  3807     	}
       
  3808 
       
  3809     iFirstTimeConstruct = EFalse;    	
       
  3810 	}
       
  3811 
       
  3812 // ---------------------------------------------------------------------------
       
  3813 // CAknFepCtrlMultiImageButton::Draw
       
  3814 // Draws UI
       
  3815 // (other items were commented in a header).
       
  3816 // ---------------------------------------------------------------------------
       
  3817 //
       
  3818 EXPORT_C void CAknFepCtrlMultiImageButton::Draw()
       
  3819     {
       
  3820 	if(!AbleToDraw())
       
  3821         return;
       
  3822     
       
  3823     CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
       
  3824     
       
  3825     //mask bitmaps
       
  3826   	DrawOpaqueMaskBackground();  
       
  3827     TRect rect = Rect();        
       
  3828     TRect innerRect = rect;
       
  3829     innerRect.Shrink( 10, 10 );
       
  3830     
       
  3831     // ----- draw bitmaps -----
       
  3832     gc->Activate( BitmapDevice() );     
       
  3833    // gc->SetClippingRegion( &ValidClipRegion() );           
       
  3834     //gc->Clear(rect);
       
  3835     	
       
  3836 		CFbsBitmap* bmpMask1 = NULL;
       
  3837 		CFbsBitmap* bmpMask2 = NULL;
       
  3838 	
       
  3839 		// Draw background    
       
  3840 		if( IsDimmed() ) // Dimmed state
       
  3841     	{
       
  3842 		AknsDrawUtils::DrawFrame( UiLayout()->SkinInstance(), 
       
  3843 		                         *gc, 
       
  3844 		                         rect, 
       
  3845 		                         innerRect,
       
  3846 		                         iInactiveImgID,
       
  3847 		                         KAknsIIDDefault );
       
  3848         if( iForground1DimBmpMask )
       
  3849     		{
       
  3850     		delete iForground1DimBmpMask;
       
  3851     		iForground1DimBmpMask = NULL;
       
  3852     		}		                         
       
  3853         TRAP_IGNORE(CreateDimmedMaskL( iForground1DimBmpMask, 
       
  3854     					   iForground1BmpMask ));
       
  3855 		AknIconUtils::SetSize(iForground1DimBmpMask, iForground1BmpRect.Size(), 
       
  3856                               EAspectRatioNotPreserved);		                         
       
  3857 		bmpMask1 = iForground1DimBmpMask;
       
  3858 		
       
  3859 		if( iForground2DimBmpMask )
       
  3860     		{
       
  3861     		delete iForground2DimBmpMask;
       
  3862     		iForground2DimBmpMask = NULL;
       
  3863     		}		                         
       
  3864 		TRAP_IGNORE(CreateDimmedMaskL( iForground2DimBmpMask, 
       
  3865     					   iForground2BmpMask ));
       
  3866 		AknIconUtils::SetSize(iForground2DimBmpMask, iForground2BmpRect.Size(), 
       
  3867                               EAspectRatioNotPreserved);
       
  3868 		bmpMask2 = iForground2DimBmpMask;  
       
  3869     	}
       
  3870     else
       
  3871     	{
       
  3872 		// Normal state or pressed state
       
  3873 		TAknsItemID ImgID;
       
  3874 		if (iHighlight)
       
  3875 			{
       
  3876 			ImgID = iPressedImgID;
       
  3877 			}
       
  3878 		else 
       
  3879 			{
       
  3880 			ImgID = /*iPressed*/PointerDown()? iPressedImgID : iNormalImgID;
       
  3881 			}
       
  3882 		
       
  3883 		AknsDrawUtils::DrawFrame( UiLayout()->SkinInstance(), 
       
  3884 	                     *gc, 
       
  3885 	                     rect, 
       
  3886 	                     innerRect,
       
  3887 	                     ImgID,
       
  3888 	                     KAknsIIDDefault ); 
       
  3889 	    bmpMask1 = iForground1BmpMask;
       
  3890 	    bmpMask2 = iForground2BmpMask;
       
  3891     	}
       
  3892     
       
  3893     // Draw forground
       
  3894 		if( iForground1Bmp && iForground2Bmp)
       
  3895 		{
       
  3896 		TRect srcRect( TPoint( 0, 0 ), iForground1Bmp->SizeInPixels() );
       
  3897 		if( bmpMask1 )
       
  3898 			{
       
  3899 			gc->BitBltMasked( iForground1BmpRect.iTl, 
       
  3900 							  iForground1Bmp, 
       
  3901 							  srcRect,
       
  3902 							  bmpMask1,
       
  3903 							  EFalse);
       
  3904 			}
       
  3905 		else
       
  3906 			{
       
  3907 			gc->BitBlt( iForground1BmpRect.iTl,
       
  3908 						iForground1Bmp,
       
  3909 						srcRect );	
       
  3910 			}
       
  3911 			
       
  3912 		TRect src2Rect( TPoint( 0, 0 ), iForground2Bmp->SizeInPixels() );	
       
  3913 		if( bmpMask2 )
       
  3914 			{
       
  3915 			gc->BitBltMasked( rect.iTl, // layout of 2nd foreground is determined by image itself, but not hard code.   
       
  3916 							  iForground2Bmp, 
       
  3917 							  src2Rect,
       
  3918 							  bmpMask2,
       
  3919 							  EFalse);
       
  3920 			}
       
  3921 		else
       
  3922 			{
       
  3923 			gc->BitBlt( rect.iTl, 
       
  3924 						iForground2Bmp,
       
  3925 						src2Rect );	
       
  3926 			}		
       
  3927 		}
       
  3928 	
       
  3929     if (iText)
       
  3930         {
       
  3931         TAknLayoutText textLayout;
       
  3932         textLayout.LayoutText(Rect(), iTextFormat);
       
  3933         textLayout.DrawText(*gc, *iText);
       
  3934         }
       
  3935     }
       
  3936 
       
  3937 // ---------------------------------------------------------------------------
       
  3938 // CAknFepCtrlMultiImageButton::ResizeBitmaps
       
  3939 // This methods shall be called by the container's SizeChanged handler
       
  3940 // (other items were commented in a header).
       
  3941 // ---------------------------------------------------------------------------
       
  3942 //
       
  3943 void CAknFepCtrlMultiImageButton::ResizeBitmaps(TSize aInnerSize)
       
  3944     {
       
  3945     if( iForground1Bmp && ( iForground1Bmp->SizeInPixels() != aInnerSize ) )
       
  3946     	{
       
  3947     	AknIconUtils::SetSize( iForground1Bmp, aInnerSize, EAspectRatioNotPreserved );
       
  3948     	}
       
  3949     if( iForground1BmpMask && ( iForground1BmpMask->SizeInPixels() != aInnerSize ) )
       
  3950     	{
       
  3951     	AknIconUtils::SetSize( iForground1BmpMask, aInnerSize, EAspectRatioNotPreserved );
       
  3952     	}    
       
  3953     	
       
  3954     //TRAP_IGNORE(CreateDimmedMaskL(iForground1DimBmpMask, iForground1BmpMask));
       
  3955     				  
       
  3956     				  
       
  3957     				  
       
  3958     				  
       
  3959     if( iForground2Bmp && ( iForground2Bmp->SizeInPixels() != Rect().Size() ) )
       
  3960     	{
       
  3961     	AknIconUtils::SetSize( iForground2Bmp, Rect().Size(), EAspectRatioNotPreserved );
       
  3962     	}
       
  3963     if( iForground2BmpMask && ( iForground2BmpMask->SizeInPixels() != Rect().Size() ) )
       
  3964     	{
       
  3965     	AknIconUtils::SetSize( iForground2BmpMask, Rect().Size(), EAspectRatioNotPreserved );
       
  3966     	}    
       
  3967     	
       
  3968     //TRAP_IGNORE(CreateDimmedMaskL(iForground2DimBmpMask, iForground2BmpMask));    				  
       
  3969     }
       
  3970     
       
  3971 // ---------------------------------------------------------------------------
       
  3972 // CAknFepCtrlMultiImageButton::SizeChanged
       
  3973 // This methods shall be called by the container's SizeChanged handler
       
  3974 // (other items were commented in a header).
       
  3975 // ---------------------------------------------------------------------------
       
  3976 //
       
  3977 EXPORT_C void CAknFepCtrlMultiImageButton::SizeChanged(TRect aNewRect, 
       
  3978 												   TRect aInnerRect, 
       
  3979 												   TBool aIsReloadImages)
       
  3980     {
       
  3981     if (aNewRect.Size().iWidth == 0 || aNewRect.Size().iHeight == 0)
       
  3982         {
       
  3983    	    return;
       
  3984         }
       
  3985     
       
  3986     TRect oriRect = Rect();
       
  3987     SetRect(aNewRect);
       
  3988     iForground1BmpRect = aInnerRect;
       
  3989     iForground2BmpRect = aInnerRect;
       
  3990 	
       
  3991     if (aIsReloadImages)
       
  3992         {
       
  3993         ResizeBitmaps(aInnerRect.Size() );	
       
  3994         }
       
  3995     RootControl()->ReDrawRect( oriRect );
       
  3996     UpdateArea(oriRect, EFalse);
       
  3997     Draw();
       
  3998     UpdateArea(Rect(), EFalse);
       
  3999     }
       
  4000     
       
  4001 // ---------------------------------------------------------------------------
       
  4002 // CAknFepCtrlMultiImageButton::DeleteForgroundRes
       
  4003 // This methods shall be called by the container's SizeChanged handler
       
  4004 // (other items were commented in a header).
       
  4005 // ---------------------------------------------------------------------------
       
  4006 //
       
  4007 void CAknFepCtrlMultiImageButton::DeleteForgroundRes()
       
  4008 	{
       
  4009     if( iForground1Bmp )
       
  4010 		{
       
  4011 		delete iForground1Bmp;
       
  4012 		iForground1Bmp = NULL;
       
  4013 		}
       
  4014 	if( iForground1BmpMask )
       
  4015 		{
       
  4016 		delete iForground1BmpMask;
       
  4017 		iForground1BmpMask = NULL;
       
  4018 		}
       
  4019 	if( iForground1DimBmpMask )
       
  4020 		{
       
  4021 		delete iForground1DimBmpMask;
       
  4022 		iForground1DimBmpMask = NULL;
       
  4023 		}
       
  4024 	
       
  4025 	
       
  4026     if( iForground2Bmp )
       
  4027 		{
       
  4028 		delete iForground2Bmp;
       
  4029 		iForground2Bmp = NULL;
       
  4030 		}
       
  4031 	if( iForground2BmpMask )
       
  4032 		{
       
  4033 		delete iForground2BmpMask;
       
  4034 		iForground2BmpMask = NULL;
       
  4035 		}
       
  4036 	if( iForground2DimBmpMask )
       
  4037 		{
       
  4038 		delete iForground2DimBmpMask;
       
  4039 		iForground2DimBmpMask = NULL;
       
  4040 		}	
       
  4041 
       
  4042 	}
       
  4043 	
       
  4044 // ---------------------------------------------------------------------------
       
  4045 // CAknFepCtrlMultiImageButton::CreateDimmedMaskL
       
  4046 // This methods shall be called by the container's SizeChanged handler
       
  4047 // (other items were commented in a header).
       
  4048 // ---------------------------------------------------------------------------
       
  4049 //	
       
  4050 void CAknFepCtrlMultiImageButton::CreateDimmedMaskL( CFbsBitmap*& aDimmedMask,
       
  4051                                         		 const CFbsBitmap* aMask
       
  4052                                         		 /*TScaleMode aScaleMode*/ )
       
  4053 	{
       
  4054 	    if (aMask && aMask->DisplayMode() == EGray256)
       
  4055 	        {
       
  4056 	        delete aDimmedMask;
       
  4057 	        aDimmedMask = NULL;
       
  4058 
       
  4059 	        aDimmedMask = new (ELeave) CFbsBitmap;
       
  4060 
       
  4061 	        User::LeaveIfError(aDimmedMask->Create(aMask->SizeInPixels(), EGray256)); 
       
  4062 	        CleanupStack::PushL(aDimmedMask);
       
  4063 
       
  4064 	        CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(aDimmedMask);
       
  4065 	        CleanupStack::PushL(bitmapDevice);
       
  4066 
       
  4067 	        CFbsBitGc* bitGc(NULL);
       
  4068 	        User::LeaveIfError(bitmapDevice->CreateContext(bitGc));
       
  4069 	        CleanupStack::PushL(bitGc);
       
  4070 
       
  4071 	        bitGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
  4072 	        bitGc->BitBlt(TPoint(0, 0), aMask);
       
  4073 
       
  4074 	        aDimmedMask->LockHeap();
       
  4075 	        TInt w = aMask->SizeInPixels().iWidth; 
       
  4076 	        TInt h = aMask->SizeInPixels().iHeight;
       
  4077 	        TInt dataStride = aMask->DataStride() - w; 
       
  4078 	        unsigned char* address = (unsigned char *)aDimmedMask->DataAddress();  
       
  4079 
       
  4080 	        for ( TInt i = 0; i < h; ++i )
       
  4081 	            {
       
  4082 	            for ( TInt j = 0; j < w; ++j )
       
  4083 	                {
       
  4084 	                *address = KTransparency[*address];
       
  4085 	                ++address;
       
  4086 	                }
       
  4087 	            address += dataStride;         
       
  4088 	            }
       
  4089 
       
  4090 	        aDimmedMask->UnlockHeap();
       
  4091 
       
  4092 	        //AknIconUtils::SetSize(aDimmedMask, aMask->SizeInPixels(), aScaleMode);
       
  4093 
       
  4094 	        CleanupStack::PopAndDestroy(2); // bitmapDevice, bitGc
       
  4095 	        CleanupStack::Pop(1); // aDimmedMask
       
  4096 	        }
       
  4097 
       
  4098 	}
       
  4099 
       
  4100 EXPORT_C void CAknFepCtrlMultiImageButton::Move(const TPoint& aOffset)
       
  4101     {
       
  4102     CButtonBase::Move(aOffset);
       
  4103     iForground1BmpRect.Move( aOffset );
       
  4104     iForground2BmpRect.Move( aOffset );
       
  4105     }
       
  4106 
       
  4107 // ---------------------------------------------------------
       
  4108 // Constructor
       
  4109 // ---------------------------------------------------------
       
  4110 //
       
  4111 EXPORT_C CAknFepCtrlLongPressButton* CAknFepCtrlLongPressButton::NewLC(CFepUiLayout* aUiLayout, 
       
  4112                                                                  TInt aCtrlId,
       
  4113                                                                  TInt aEvent,
       
  4114                                                                  TInt aUnicode,
       
  4115                                                                  TAknsItemID aNormalID,
       
  4116                                                                  TAknsItemID aPressedID,
       
  4117                                                                  TAknsItemID aInactiveID)
       
  4118     {
       
  4119     //PRINTF((_L("CAknFepCtrlLongPressButton::NewLC(), aCtrlId = %d\n"), aCtrlId));
       
  4120     CAknFepCtrlLongPressButton *self = new(ELeave) CAknFepCtrlLongPressButton(aUiLayout, 
       
  4121                                                                         aCtrlId, 
       
  4122                                                                         aEvent, 
       
  4123                                                                         aUnicode,
       
  4124                                                                         aNormalID,
       
  4125                                                                         aPressedID,
       
  4126                                                                         aInactiveID);
       
  4127 
       
  4128     CleanupStack::PushL(self);
       
  4129     self->ConstructL();
       
  4130     
       
  4131     return self;
       
  4132     }
       
  4133 
       
  4134 // ---------------------------------------------------------
       
  4135 // Constructor
       
  4136 // ---------------------------------------------------------
       
  4137 //
       
  4138 EXPORT_C CAknFepCtrlLongPressButton* CAknFepCtrlLongPressButton::NewL(CFepUiLayout* aUiLayout, 
       
  4139                                                                 TInt aCtrlId,
       
  4140                                                                 TInt aEvent,
       
  4141                                                                 TInt aUnicode,
       
  4142                                                                 TAknsItemID aNormalID,
       
  4143                                                                 TAknsItemID aPressedID,
       
  4144                                                                 TAknsItemID aInactiveID)
       
  4145     {
       
  4146     //PRINTF((_L("CAknFepCtrlLongPressButton::NewL(), aCtrlId = %d\n"), aCtrlId));
       
  4147     CAknFepCtrlLongPressButton *self = NewLC(aUiLayout, aCtrlId, aEvent, aUnicode,
       
  4148                                           aNormalID, aPressedID, aInactiveID);
       
  4149     CleanupStack::Pop(self);
       
  4150     
       
  4151     return self;
       
  4152     }
       
  4153         
       
  4154 // ---------------------------------------------------------
       
  4155 // Destructor
       
  4156 // ---------------------------------------------------------
       
  4157 //
       
  4158 EXPORT_C CAknFepCtrlLongPressButton::~CAknFepCtrlLongPressButton()
       
  4159     {
       
  4160     //PRINTF((_L("CAknFepCtrlLongPressButton::~CAknFepCtrlLongPressButton()\n")));
       
  4161     CancelTimer();
       
  4162 
       
  4163     delete iLongPressTimer;
       
  4164     }
       
  4165     
       
  4166 // ---------------------------------------------------------
       
  4167 // Constructor
       
  4168 // ---------------------------------------------------------
       
  4169 //
       
  4170 EXPORT_C CAknFepCtrlLongPressButton::CAknFepCtrlLongPressButton(CFepUiLayout* aUiLayout, 
       
  4171                                                           TInt aCtrlId,
       
  4172                                                           TInt aEvent,
       
  4173                                                           TInt aUnicode,
       
  4174                                                           TAknsItemID aNormalID,
       
  4175                                                           TAknsItemID aPressedID,
       
  4176                                                           TAknsItemID aInactiveID)
       
  4177     :CAknFepCtrlEventButton(aUiLayout, aCtrlId, aEvent, aUnicode,
       
  4178                                                         aNormalID,
       
  4179                                                         aPressedID,
       
  4180                                                         aInactiveID)
       
  4181     {
       
  4182     iLongPressInterval = KLongPressInterval;
       
  4183     }
       
  4184 
       
  4185 // ---------------------------------------------------------
       
  4186 // Constructor
       
  4187 // ---------------------------------------------------------
       
  4188 //
       
  4189 EXPORT_C void CAknFepCtrlLongPressButton::ConstructL()
       
  4190     {
       
  4191     //PRINTF((_L("CAknFepCtrlLongPressButton::ConstructL()\n")));
       
  4192     BaseConstructL();
       
  4193     iIsLongPress = EFalse;
       
  4194     iLongPressTimer = CAknFepTimer::NewL(this);
       
  4195     }
       
  4196     
       
  4197 // ---------------------------------------------------------
       
  4198 // Time out event handler of long press timer
       
  4199 // ---------------------------------------------------------
       
  4200 //
       
  4201 EXPORT_C void CAknFepCtrlLongPressButton::HandleTimerOut(const CAknFepTimer* aTimer)
       
  4202     {
       
  4203     //PRINTF((_L("CAknFepCtrlLongPressButton::HandleTimerOut()--")));
       
  4204     if (aTimer == iLongPressTimer)
       
  4205         {
       
  4206         iIsLongPress = ETrue;
       
  4207         CancelTimer();
       
  4208         TInt unicode = Unicode();
       
  4209         TPtrC ptr = (TUint16*)(&unicode);
       
  4210         ReportEvent(EPeninputLayoutEventMultiRangeLongPress, ptr);
       
  4211         }
       
  4212     }
       
  4213 
       
  4214 // ---------------------------------------------------------
       
  4215 // Handle button down start long press timer 
       
  4216 // ---------------------------------------------------------
       
  4217 //
       
  4218 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlLongPressButton::HandlePointerDownEventL(const TPoint& aPt)
       
  4219     {
       
  4220     //PRINTF((_L("CAknFepCtrlLongPressButton::HandleButtonDown()\n")));
       
  4221     //PRINTF((_L("Set long press Timer\n")));
       
  4222     if ( IsDimmed() )
       
  4223         {
       
  4224         return NULL;
       
  4225         }
       
  4226     
       
  4227     iLongPressTimer->SetTimer(iLongPressInterval);
       
  4228     iIsLongPress = EFalse;
       
  4229 
       
  4230     return CAknFepCtrlCommonButton::HandlePointerDownEventL(aPt);
       
  4231     }
       
  4232                                                           
       
  4233 // ---------------------------------------------------------
       
  4234 // Handle button up cancel timer
       
  4235 // ---------------------------------------------------------
       
  4236 //
       
  4237 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlLongPressButton::HandlePointerUpEventL(const TPoint& aPt)
       
  4238     {
       
  4239     //PRINTF((_L("CAknFepCtrlLongPressButton::HandleButtonUp()\n")));
       
  4240 
       
  4241     if ( IsDimmed() )
       
  4242         {
       
  4243         return NULL;
       
  4244         }
       
  4245 
       
  4246     CancelTimer();
       
  4247     
       
  4248     if (!iIsLongPress)
       
  4249         {
       
  4250         TInt unicode = Unicode();
       
  4251         TPtrC ptr = (TUint16*)(&unicode);
       
  4252         ReportEvent(EPeninputLayoutEventMultiRange, ptr);   
       
  4253         }
       
  4254 
       
  4255     iIsLongPress = EFalse;
       
  4256     
       
  4257     
       
  4258     return CAknFepCtrlCommonButton::HandlePointerUpEventL(aPt);
       
  4259     }
       
  4260 
       
  4261 // ---------------------------------------------------------
       
  4262 // Handle pointer leave event cancel timer 
       
  4263 // ---------------------------------------------------------
       
  4264 //
       
  4265 EXPORT_C void CAknFepCtrlLongPressButton::HandlePointerLeave(const TPoint& aPoint)
       
  4266     {
       
  4267     CAknFepCtrlCommonButton::HandlePointerLeave(aPoint);
       
  4268 
       
  4269     CancelTimer();
       
  4270     }
       
  4271 
       
  4272 // ---------------------------------------------------------------------------
       
  4273 // CAknFepCtrlLongPressButton::CancelPointerDownL
       
  4274 // Cancel pointer down event
       
  4275 // (other items were commented in a header).
       
  4276 // ---------------------------------------------------------------------------
       
  4277 //    
       
  4278 EXPORT_C void CAknFepCtrlLongPressButton::CancelPointerDownL()
       
  4279     {
       
  4280     // No implementation needed
       
  4281 	CAknFepCtrlCommonButton::CancelPointerDownL();
       
  4282     }
       
  4283 
       
  4284 // ---------------------------------------------------------
       
  4285 // Cancel timer
       
  4286 // ---------------------------------------------------------
       
  4287 //
       
  4288 EXPORT_C void CAknFepCtrlLongPressButton::CancelTimer()
       
  4289     {
       
  4290     //PRINTF((_L("CAknFepCtrlLongPressButton::CancelTimer()\n")));
       
  4291     iLongPressTimer->Cancel();
       
  4292     }
       
  4293 //  End Of File