textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutvkbkeyctrl.cpp
branchRCL_3
changeset 20 ebd48d2de13c
parent 19 ac7e4d1d9209
child 21 ecbabf52600f
equal deleted inserted replaced
19:ac7e4d1d9209 20:ebd48d2de13c
    20 #include <w32std.h>
    20 #include <w32std.h>
    21 #include <AknsDrawUtils.h>
    21 #include <AknsDrawUtils.h>
    22 #include <eikenv.h>
    22 #include <eikenv.h>
    23 #include <AknsConstants.h>
    23 #include <AknsConstants.h>
    24 #include <AknUtils.h>
    24 #include <AknUtils.h>
    25 #include <featmgr.h>
       
    26 
    25 
    27 #include "peninputlayoutvirtualkeyctrl.h"
    26 #include "peninputlayoutvirtualkeyctrl.h"
    28 #include "peninputlayoutvkb.h"
    27 #include "peninputlayoutvkb.h"
    29 #include "peninputlayout.h"
    28 #include "peninputlayout.h"
    30 #include "peninputpluginutils.h"
    29 #include "peninputpluginutils.h"
    31 #include "peninputcmd.h"
       
    32 
    30 
    33 _LIT( KKeyShiftCharacter, "\x2191");
    31 _LIT( KKeyShiftCharacter, "\x2191");
    34 _LIT( KKeyStarCharacter, "\x002a");
       
    35 
    32 
    36 const TInt KDefaultKeyMargin = 10;
    33 const TInt KDefaultKeyMargin = 10;
    37 
    34 
    38 // ---------------------------------------------------------------------------
    35 // ---------------------------------------------------------------------------
    39 // CVirtualKeyCtrl::NewL
    36 // CVirtualKeyCtrl::NewL
   102 // ---------------------------------------------------------------------------
    99 // ---------------------------------------------------------------------------
   103 //        
   100 //        
   104 void CVirtualKeyCtrl::ConstructL()
   101 void CVirtualKeyCtrl::ConstructL()
   105     {
   102     {
   106     BaseConstructL();
   103     BaseConstructL();
   107     
       
   108     //tap accuracy enhancement
       
   109     if( FeatureManager::FeatureSupported( KFeatureIdFfCapacitiveDisplay ))
       
   110         {
       
   111         EnableExtResponseArea( ETrue, TRect(TPoint(10,10),TSize(10,10)) );
       
   112         }
       
   113     }
   104     }
   114 
   105 
   115 // ---------------------------------------------------------------------------
   106 // ---------------------------------------------------------------------------
   116 // CVirtualKeyCtrl::DrawKeyText
   107 // CVirtualKeyCtrl::DrawKeyText
   117 // Draw key text
   108 // Draw key text
   118 // (other items were commented in a header).
   109 // (other items were commented in a header).
   119 // ---------------------------------------------------------------------------
   110 // ---------------------------------------------------------------------------
   120 //        
   111 //        
   121 void CVirtualKeyCtrl::DrawKeyText(CFbsBitGc* aGc)  
   112 void CVirtualKeyCtrl::DrawKeyText()    
   122     {
   113     {
   123     TBool textlineset = EFalse;
   114     TBool textlineset = EFalse;
   124 
   115 
   125     // if text line set
   116     // if text line set
   126     for (TInt i = 0; i <= EPosLast; i++)
   117     for (TInt i = 0; i <= EPosLast; i++)
   130             textlineset = ETrue;
   121             textlineset = ETrue;
   131 
   122 
   132             if (iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) != KNullDesC)
   123             if (iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) != KNullDesC)
   133                 {
   124                 {
   134                 TAknLayoutText textLayout;
   125                 TAknLayoutText textLayout;
   135                 textLayout.LayoutText(GetRect(), 
   126                 textLayout.LayoutText(Rect(), 
   136                                       iKeyboard->TextLineLayout(TVirtualKeyTextPos(i)));
   127                                       iKeyboard->TextLineLayout(TVirtualKeyTextPos(i)));
   137 				TRgb color( KRgbBlack );  // sane default for nonskinned case			    
   128 				TRgb color( KRgbBlack );  // sane default for nonskinned case			    
   138 			    if ( AknsUtils::AvkonSkinEnabled() )
   129 			    if ( AknsUtils::AvkonSkinEnabled() )
   139 			        {
   130 			        {
   140 			        AknsUtils::GetCachedColor( UiLayout()->SkinInstance(),
   131 			        AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
   141 				                               color, 
   132 				                               color, 
   142 				                               KAknsIIDQsnTextColors, 
   133 				                               KAknsIIDQsnTextColors, 
   143 				                               iKeyboard->KeyTextColorGroup() );
   134 				                               iKeyboard->KeyTextColorGroup() );
   144 			        }
   135 			        }
   145 			    
   136 			    
   146 			    // replace the shift text to shift icon			        
   137 			    // replace the shift text to shift icon			        
   147 				if( iKeyboard->ShiftIcon() &&
   138 				if( iKeyboard->ShiftIcon() &&
   148 					iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) == KKeyShiftCharacter )
   139 					iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) == KKeyShiftCharacter )
   149 					{
   140 					{
   150 					//CFbsBitGc* gc = GetGc();//static_cast<CFbsBitGc*>(BitGc());
   141 					CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
   151 					AknPenInputDrawUtils::DrawColorIcon( iKeyboard->ShiftIcon(),
   142 					AknPenInputDrawUtils::DrawColorIcon( iKeyboard->ShiftIcon(),
   152 														 *aGc,
   143 														 *gc,
   153 														 textLayout.TextRect() );	
   144 														 textLayout.TextRect() );	
   154 					}
       
   155 				else if(iKeyboard->StarIcon() &&
       
   156 						iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) == KKeyStarCharacter )
       
   157 					{
       
   158 					//CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
       
   159 					AknPenInputDrawUtils::DrawColorIcon( iKeyboard->StarIcon(),
       
   160 														 *aGc,
       
   161 														 textLayout.TextRect() );		
       
   162 					}
   145 					}
   163 				else				    
   146 				else				    
   164 				    {
   147 				    {
   165 				    textLayout.DrawText(*aGc, iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)), 
   148 				    textLayout.DrawText(*BitGc(), iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)), 
   166                                     EFalse, color);
   149                                     EFalse, color);
   167 				    }
   150 				    }
   168                 }
   151                 }
   169             }
   152             }
   170         }
   153         }
   171 
   154 
   172     if (!textlineset)
   155     if (!textlineset)
   173         {
   156         {
   174 		TAknLayoutText textLayout;
   157 		TAknLayoutText textLayout;
   175 		textLayout.LayoutText(GetRect(), iKeyboard->iVKBTextLineLayout);
   158 		textLayout.LayoutText(Rect(), iKeyboard->iVKBTextLineLayout);
   176 	    
   159 	    
   177 	    //CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());    
   160 	    CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());    
   178 	    
   161 	    
   179 	    //charRect.Move(keyboardRect.iTl);
   162 	    //charRect.Move(keyboardRect.iTl);
   180 	    //if(iKeyInfo->Dimmed())
   163 	    //if(iKeyInfo->Dimmed())
   181 	    //    {        
   164 	    //    {        
   182 	    //    gc->SetFadingParameters(iKeyboard->iFadingParamBlack, iKeyboard->iFadingParamWhite);
   165 	    //    gc->SetFadingParameters(iKeyboard->iFadingParamBlack, iKeyboard->iFadingParamWhite);
   184 	    //    }
   167 	    //    }
   185 		TRgb color( KRgbBlack );  // sane default for nonskinned case			    
   168 		TRgb color( KRgbBlack );  // sane default for nonskinned case			    
   186 	    if ( AknsUtils::AvkonSkinEnabled() || 
   169 	    if ( AknsUtils::AvkonSkinEnabled() || 
   187 	    	 iKeyboard->KeyTextColorGroup() != INVALID_COLOR_GROUP )
   170 	    	 iKeyboard->KeyTextColorGroup() != INVALID_COLOR_GROUP )
   188 	        {
   171 	        {
   189 	        AknsUtils::GetCachedColor( UiLayout()->SkinInstance(),
   172 	        AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
   190 		                               color, 
   173 		                               color, 
   191 		                               KAknsIIDQsnTextColors, 
   174 		                               KAknsIIDQsnTextColors, 
   192 		                               iKeyboard->KeyTextColorGroup() );
   175 		                               iKeyboard->KeyTextColorGroup() );
   193 	        }
   176 	        }
   194 	    else
   177 	    else
   200 			{			
   183 			{			
   201 			color = KRgbGray;	
   184 			color = KRgbGray;	
   202 			}	
   185 			}	
   203     	if( iKeyInfo->DisplayUnicode() && iKeyInfo->DisplayUnicode()->Length() != 0)
   186     	if( iKeyInfo->DisplayUnicode() && iKeyInfo->DisplayUnicode()->Length() != 0)
   204     		{
   187     		{
   205     		textLayout.DrawText(*aGc, *iKeyInfo->DisplayUnicode(), EFalse, color);		
   188     		textLayout.DrawText(*BitGc(), *iKeyInfo->DisplayUnicode(), EFalse, color);		
   206     		}
   189     		}
   207     	else
   190     	else
   208     		{
   191     		{
   209     		textLayout.DrawText(*aGc, iKeyInfo->KeyUnicodes(), EFalse, color);		
   192     		textLayout.DrawText(*BitGc(), iKeyInfo->KeyUnicodes(), EFalse, color);		
   210     		}		
   193     		}		
   211     		
   194     		
   212 	    //if(iKeyInfo->Dimmed())
   195 	    //if(iKeyInfo->Dimmed())
   213 	    //    gc->SetFaded(EFalse);            
   196 	    //    gc->SetFaded(EFalse);            
   214 	    
   197 	    
   234        iVirtualKeyDrawInfo.iVKDimRightImgID.iMajor)
   217        iVirtualKeyDrawInfo.iVKDimRightImgID.iMajor)
   235         {
   218         {
   236         TRect innerRect = Rect();
   219         TRect innerRect = Rect();
   237 		innerRect.Shrink( 4, 0 );
   220 		innerRect.Shrink( 4, 0 );
   238 		    
   221 		    
   239 		AknPenInputDrawUtils::Draw3PiecesFrame(UiLayout()->SkinInstance(),
   222 		AknPenInputDrawUtils::Draw3PiecesFrame(AknsUtils::SkinInstance(),
   240 								   *gc,
   223 								   *gc,
   241 								   Rect(),
   224 								   Rect(),
   242 								   innerRect,
   225 								   innerRect,
   243 								   iVirtualKeyDrawInfo.iVKDimLeftImgID,
   226 								   iVirtualKeyDrawInfo.iVKDimLeftImgID,
   244 								   iVirtualKeyDrawInfo.iVKDimMiddleImgID,
   227 								   iVirtualKeyDrawInfo.iVKDimMiddleImgID,
   251     else if (iKeyboard->KeySkinId(EKeyBmpDim) != KAknsIIDNone)
   234     else if (iKeyboard->KeySkinId(EKeyBmpDim) != KAknsIIDNone)
   252         {
   235         {
   253         TRect innerrect = rect;
   236         TRect innerrect = rect;
   254         innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin );
   237         innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin );
   255         
   238         
   256         AknsDrawUtils::DrawFrame(UiLayout()->SkinInstance(),
   239         AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(),
   257                                  *gc,
   240                                  *gc,
   258                                  rect,
   241                                  rect,
   259                                  innerrect,
   242                                  innerrect,
   260                                  iKeyboard->KeySkinId(EKeyBmpDim),
   243                                  iKeyboard->KeySkinId(EKeyBmpDim),
   261                                  KAknsIIDDefault);
   244                                  KAknsIIDDefault);
   298         }
   281         }
   299         
   282         
   300     gc->SetPenColor(KRgbBlack);
   283     gc->SetPenColor(KRgbBlack);
   301     gc->SetBrushStyle( CGraphicsContext::ENullBrush );    
   284     gc->SetBrushStyle( CGraphicsContext::ENullBrush );    
   302     //Draw text again.
   285     //Draw text again.
   303     DrawKeyText(gc); 
   286     DrawKeyText(); 
   304     }
   287     }
   305 
   288 
   306 // ---------------------------------------------------------------------------
   289 // ---------------------------------------------------------------------------
   307 // CVirtualKeyCtrl::DrawBmp
   290 // CVirtualKeyCtrl::DrawBmp
   308 // Draw bitmap
   291 // Draw bitmap
   312 void CVirtualKeyCtrl::DrawBmp(const TRect& aDestRect,const TRect& aSourceRect,
   295 void CVirtualKeyCtrl::DrawBmp(const TRect& aDestRect,const TRect& aSourceRect,
   313                                   const CFbsBitmap* aBmp,CFbsBitmap* aMask,
   296                                   const CFbsBitmap* aBmp,CFbsBitmap* aMask,
   314                                   TBool aInvertFlag)
   297                                   TBool aInvertFlag)
   315     {
   298     {
   316     CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
   299     CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
   317     DrawBmp(gc,aDestRect,aSourceRect,aBmp,aMask,aInvertFlag);					     
       
   318     }
       
   319 
       
   320 // ---------------------------------------------------------------------------
       
   321 // CVirtualKeyCtrl::DrawBmp
       
   322 // Draw bitmap
       
   323 // (other items were commented in a header).
       
   324 // ---------------------------------------------------------------------------
       
   325 //        
       
   326 void CVirtualKeyCtrl::DrawBmp(CFbsBitGc* aGc, const TRect& aDestRect,const TRect& aSourceRect,
       
   327                                   const CFbsBitmap* aBmp,CFbsBitmap* aMask,
       
   328                                   TBool aInvertFlag)
       
   329     {
       
   330     if(aMask)
   300     if(aMask)
   331         {
   301         {
   332         //TRect bmpRect(TPoint(0,0),aMask->SizeInPixels());
   302         //TRect bmpRect(TPoint(0,0),aMask->SizeInPixels());
   333         aGc->DrawBitmapMasked(aDestRect,aBmp,aSourceRect,aMask,aInvertFlag);        
   303         gc->DrawBitmapMasked(aDestRect,aBmp,aSourceRect,aMask,aInvertFlag);        
   334         }
   304         }
   335     else
   305     else
   336         {
   306         {
   337         aGc->DrawBitmap(aDestRect,aBmp,aSourceRect);
   307         gc->DrawBitmap(aDestRect,aBmp,aSourceRect);
   338         }                            
   308         }						     
   339     }
   309     }
   340     
   310     
   341 // ---------------------------------------------------------------------------
   311 // ---------------------------------------------------------------------------
   342 // CVirtualKeyCtrl::DrawNormalStateKey
   312 // CVirtualKeyCtrl::DrawNormalStateKey
   343 // Draw key in normal state
   313 // Draw key in normal state
   356        iVirtualKeyDrawInfo.iVKRightImgID.iMajor)
   326        iVirtualKeyDrawInfo.iVKRightImgID.iMajor)
   357         {
   327         {
   358         TRect innerRect = Rect();
   328         TRect innerRect = Rect();
   359 		innerRect.Shrink( 4, 0 );
   329 		innerRect.Shrink( 4, 0 );
   360 		    
   330 		    
   361 		AknPenInputDrawUtils::Draw3PiecesFrame(UiLayout()->SkinInstance(),
   331 		AknPenInputDrawUtils::Draw3PiecesFrame(AknsUtils::SkinInstance(),
   362 								   *gc,
   332 								   *gc,
   363 								   Rect(),
   333 								   Rect(),
   364 								   innerRect,
   334 								   innerRect,
   365 								   iVirtualKeyDrawInfo.iVKLeftImgID,
   335 								   iVirtualKeyDrawInfo.iVKLeftImgID,
   366 								   iVirtualKeyDrawInfo.iVKMiddleImgID,
   336 								   iVirtualKeyDrawInfo.iVKMiddleImgID,
   372         }
   342         }
   373     else if (iKeyboard->KeySkinId(EKeyBmpNormal) != KAknsIIDNone)
   343     else if (iKeyboard->KeySkinId(EKeyBmpNormal) != KAknsIIDNone)
   374         {
   344         {
   375         TRect innerrect = rect;
   345         TRect innerrect = rect;
   376         innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin );
   346         innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin );
   377         TBool bHasDrawn = EFalse;
   347 
   378         if(UiLayout()->NotDrawToLayoutDevice())
   348         AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(), 
   379             {
   349                                  *gc, 
   380             /*TBool ret = iKeyboard->PrepareKeyBmp(iKeyboard->NormalKeyBmp(),
   350                                  rect, 
   381                                     iKeyboard->NormalKeyDev(),
   351                                  innerrect,
   382                                     rect,innerrect,
   352                                  iKeyboard->KeySkinId(EKeyBmpNormal), 
   383                                     iKeyboard->KeySkinId(EKeyBmpNormal), 
   353                                  KAknsIIDDefault); 
   384                                     KAknsIIDDefault,Rect());*/
       
   385             TBool ret = iKeyboard->PrepareNormalKeyBmp(rect,innerrect,Rect());                                    
       
   386             if(ret)
       
   387                 {
       
   388                 gc->BitBlt(rect.iTl,iKeyboard->NormalKeyBmp());
       
   389                 bHasDrawn = ETrue;
       
   390                 }
       
   391             }
       
   392         
       
   393         if(!bHasDrawn)
       
   394             {
       
   395 	        AknsDrawUtils::DrawFrame(UiLayout()->SkinInstance(), 
       
   396 	                                 *gc, 
       
   397 	                                 rect, 
       
   398 	                                 innerrect,
       
   399 	                                 iKeyboard->KeySkinId(EKeyBmpNormal), 
       
   400 	                                 KAknsIIDDefault); 
       
   401             }
       
   402         }
   354         }
   403     else if( iKeyboard->NonIrregularKeyBitmap( EKeyBmpNormal ) )
   355     else if( iKeyboard->NonIrregularKeyBitmap( EKeyBmpNormal ) )
   404     	{
   356     	{
   405         TRect srcRect(TPoint(0,0), 
   357         TRect srcRect(TPoint(0,0), 
   406                       iKeyboard->NonIrregularKeyBitmap( EKeyBmpNormal )->SizeInPixels());
   358                       iKeyboard->NonIrregularKeyBitmap( EKeyBmpNormal )->SizeInPixels());
   433         }        
   385         }        
   434         
   386         
   435     gc->SetPenColor( KRgbBlack );
   387     gc->SetPenColor( KRgbBlack );
   436     gc->SetBrushStyle( CGraphicsContext::ENullBrush );    
   388     gc->SetBrushStyle( CGraphicsContext::ENullBrush );    
   437     gc->SetFaded(EFalse);            
   389     gc->SetFaded(EFalse);            
   438     DrawKeyText(gc);        
   390     DrawKeyText();        
   439     }
   391     }
   440 
   392     
   441 CFbsBitGc* CVirtualKeyCtrl::GetGc()
       
   442     {
       
   443     if(UiLayout()->NotDrawToLayoutDevice())
       
   444         {
       
   445         //draw to highligh bitmap
       
   446         if(Keyboard()->Bitmap()->SizeInPixels() != Rect().Size())
       
   447             {
       
   448             Keyboard()->Bitmap()->Resize(Rect().Size());
       
   449             Keyboard()->HighlightDev()->Resize( Rect().Size());
       
   450                 //gc must be adjusted
       
   451             Keyboard()->HighlightGc()->Activate(Keyboard()->HighlightDev());
       
   452             Keyboard()->HighlightGc()->Resized();
       
   453             }
       
   454         return Keyboard()->HighlightGc();
       
   455         }
       
   456     else
       
   457         return static_cast<CFbsBitGc*>(BitGc());
       
   458     }
       
   459 
       
   460 // ---------------------------------------------------------------------------
   393 // ---------------------------------------------------------------------------
   461 // CVirtualKeyCtrl::DrawHighlightKey
   394 // CVirtualKeyCtrl::DrawHighlightKey
   462 // Draw key in highlight state
   395 // Draw key in highlight state
   463 // (other items were commented in a header).
   396 // (other items were commented in a header).
   464 // ---------------------------------------------------------------------------
   397 // ---------------------------------------------------------------------------
   465 //                
   398 //                
   466 void CVirtualKeyCtrl::DrawHighlightKey()
   399 void CVirtualKeyCtrl::DrawHighlightKey()
   467     {    
   400     {    
   468     CFbsBitGc* gc = GetGc();
   401     CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
   469     if(UiLayout()->NotDrawToLayoutDevice())
   402     TRect rect = Rect();
   470         gc->Activate( Keyboard()->HighlightDev() );
       
   471     TRect rect = GetRect();
       
   472 
       
   473     TPoint bmpPos = rect.iTl;
   403     TPoint bmpPos = rect.iTl;
   474     TRect bmpRect(TPoint(0,0),rect.Size());
   404     TRect bmpRect(TPoint(0,0),rect.Size());
   475    
   405    
   476     if(iVirtualKeyDrawInfo.iVKPressedLeftImgID.iMajor && 
   406     if(iVirtualKeyDrawInfo.iVKPressedLeftImgID.iMajor && 
   477        iVirtualKeyDrawInfo.iVKPressedMiddleImgID.iMajor &&
   407        iVirtualKeyDrawInfo.iVKPressedMiddleImgID.iMajor &&
   478        iVirtualKeyDrawInfo.iVKPressedRightImgID.iMajor)
   408        iVirtualKeyDrawInfo.iVKPressedRightImgID.iMajor)
   479         {
   409         {
   480         TRect innerRect = GetRect();
   410         TRect innerRect = Rect();
   481 		innerRect.Shrink( 4, 0 );
   411 		innerRect.Shrink( 4, 0 );
   482 		    
   412 		    
   483 		AknPenInputDrawUtils::Draw3PiecesFrame(UiLayout()->SkinInstance(),
   413 		AknPenInputDrawUtils::Draw3PiecesFrame(AknsUtils::SkinInstance(),
   484 								   *gc,
   414 								   *gc,
   485 								   GetRect(),
   415 								   Rect(),
   486 								   innerRect,
   416 								   innerRect,
   487 								   iVirtualKeyDrawInfo.iVKPressedLeftImgID,
   417 								   iVirtualKeyDrawInfo.iVKPressedLeftImgID,
   488 								   iVirtualKeyDrawInfo.iVKPressedMiddleImgID,
   418 								   iVirtualKeyDrawInfo.iVKPressedMiddleImgID,
   489 								   iVirtualKeyDrawInfo.iVKPressedRightImgID);
   419 								   iVirtualKeyDrawInfo.iVKPressedRightImgID);
   490 
   420 
   496 
   426 
   497     //do we have highlight background bmp for this key?
   427     //do we have highlight background bmp for this key?
   498     else if (iKeyboard->KeySkinId(EKeyBmpHighlight) != KAknsIIDNone)
   428     else if (iKeyboard->KeySkinId(EKeyBmpHighlight) != KAknsIIDNone)
   499         {
   429         {
   500         TRect innerrect = rect;
   430         TRect innerrect = rect;
   501 
       
   502         innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin );
   431         innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin );
   503         TBool bHasDrawn = EFalse;
   432 
   504         if(UiLayout()->NotDrawToLayoutDevice())
   433         AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(), 
   505             {
   434                                  *gc, 
   506             /*TBool ret = iKeyboard->PrepareKeyBmp(iKeyboard->HighightKeyBmp(),
   435                                  rect, 
   507                                     iKeyboard->HighlightKeyDev(),
   436                                  innerrect,
   508                                     rect,innerrect,
   437                                  iKeyboard->KeySkinId(EKeyBmpHighlight), 
   509                                     iKeyboard->KeySkinId(EKeyBmpHighlight), 
   438                                  KAknsIIDDefault); 
   510                                     KAknsIIDDefault,Rect());*/
       
   511             TBool ret = iKeyboard->PrepareHighlightKeyBmp(rect,innerrect,Rect());                                    
       
   512             if(ret)
       
   513                 {
       
   514                 gc->BitBlt(rect.iTl,iKeyboard->HighightKeyBmp());
       
   515                 bHasDrawn = ETrue;
       
   516                 }
       
   517             }
       
   518         
       
   519         if(!bHasDrawn)
       
   520             {        
       
   521 	        AknsDrawUtils::DrawFrame(UiLayout()->SkinInstance(), 
       
   522 	                                 *gc, 
       
   523 	                                 rect, 
       
   524 	                                 innerrect,
       
   525 	                                 iKeyboard->KeySkinId(EKeyBmpHighlight), 
       
   526 	                                 KAknsIIDDefault); 
       
   527             }
       
   528         }
   439         }
   529     else if( iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight ) )
   440     else if( iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight ) )
   530     	{
   441     	{
   531         TRect srcRect(TPoint(0,0), 
   442         TRect srcRect(TPoint(0,0), 
   532                       iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight )->SizeInPixels());
   443                       iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight )->SizeInPixels());
   533         DrawBmp(gc, rect,
   444         DrawBmp(rect,
   534                 srcRect,
   445                 srcRect,
   535                 iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight ),
   446                 iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight ),
   536                 iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlightMask ),
   447                 iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlightMask ),
   537                 ETrue); 
   448                 ETrue); 
   538     	}
   449     	}
   561  
   472  
   562     gc->SetPenColor( KRgbBlack );
   473     gc->SetPenColor( KRgbBlack );
   563 
   474 
   564     gc->SetBrushStyle( CGraphicsContext::ENullBrush );    
   475     gc->SetBrushStyle( CGraphicsContext::ENullBrush );    
   565     gc->SetFaded(EFalse);       
   476     gc->SetFaded(EFalse);       
   566     if(UiLayout()->NotDrawToLayoutDevice())
   477     DrawKeyText();    
   567         {
       
   568 		DrawKeyText(Keyboard()->HighlightGc());
       
   569         UpdateChangedArea(ETrue);
       
   570 		}
       
   571     else
       
   572         {
       
   573 		DrawKeyText(gc);
       
   574 		}   
       
   575 
   478 
   576     }
   479     }
   577     
   480     
   578 // ---------------------------------------------------------------------------
   481 // ---------------------------------------------------------------------------
   579 // CVirtualKeyCtrl::Draw
   482 // CVirtualKeyCtrl::Draw
   633     
   536     
   634     CFepUiBaseCtrl::HandlePointerDownEventL(aPoint);
   537     CFepUiBaseCtrl::HandlePointerDownEventL(aPoint);
   635     
   538     
   636     //draw key new state
   539     //draw key new state
   637     iKeyboard->DrawBubble(iKeyInfo);
   540     iKeyboard->DrawBubble(iKeyInfo);
   638     if(UiLayout()->NotDrawToLayoutDevice())
   541     ReDraw();            	
   639         {
       
   640         if( !(iKeyInfo->Dimmed()) && (iKeyInfo->Latched() || (PointerDown()&&!iKeyInfo->IsLatchKey())) )
       
   641             {        
       
   642             DrawHighlightKey();
       
   643             }
       
   644 		else
       
   645 		    {
       
   646 			ReDraw();
       
   647 			}	
       
   648         }
       
   649     else
       
   650         {
       
   651         ReDraw();
       
   652         UpdateArea( Rect() );
       
   653         }         	
       
   654     UpdateArea( Rect() );
   542     UpdateArea( Rect() );
   655 
   543 
   656     if(iKeyInfo->IsLatchKey())
   544     if(iKeyInfo->IsLatchKey())
   657         {
   545         {
   658         // Only set latch status, not generate event for latch key
   546         // Only set latch status, not generate event for latch key
   687         {
   575         {
   688         // When key up, latch key will generate event. 
   576         // When key up, latch key will generate event. 
   689         // When key down, latch key won't generate event.
   577         // When key down, latch key won't generate event.
   690         eventType = iKeyInfo->Latched() ? EEventVirtualKeyLatched : EEventVirtualKeyUnLatched;
   578         eventType = iKeyInfo->Latched() ? EEventVirtualKeyLatched : EEventVirtualKeyUnLatched;
   691         }     
   579         }     
   692     if(UiLayout()->NotDrawToLayoutDevice())
   580     ReDraw();            
   693         {
   581     UpdateAreaImmed( Rect() );
   694         //no need to draw again, just remove the highlight bitmap
       
   695         UpdateChangedArea(EFalse);
       
   696 		Draw();
       
   697         }
       
   698     else
       
   699         {
       
   700         ReDraw();
       
   701         UpdateAreaImmed( Rect() );
       
   702         }
       
   703     ReportKeyEvent(eventType); 
   582     ReportKeyEvent(eventType); 
   704     
   583     
   705     
   584     
   706     //Advanced tactile feedback REQ 417-47932
   585     //Advanced tactile feedback REQ 417-47932
   707 	#ifdef RD_TACTILE_FEEDBACK
   586 	#ifdef RD_TACTILE_FEEDBACK
   708     if (UiLayout()->SupportTactileFeedback())
   587     if (UiLayout()->SupportTactileFeedback())
   709     	{
   588     	{
   710    		UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveInput, ETrue, EFalse);
   589    		UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveKeypad, ETrue, EFalse);
   711         }
   590         }
   712 	#endif // RD_TACTILE_FEEDBACK 
   591 	#endif // RD_TACTILE_FEEDBACK 
   713     return this;
   592     return this;
   714     }
   593     }
   715 	
   594 	
   731         iKeyInfo->SetLatched(!iKeyInfo->Latched());       
   610         iKeyInfo->SetLatched(!iKeyInfo->Latched());       
   732         }
   611         }
   733         
   612         
   734     iKeyboard->DrawBubble(iKeyInfo);    
   613     iKeyboard->DrawBubble(iKeyInfo);    
   735     ReDraw();
   614     ReDraw();
   736     if(UiLayout()->NotDrawToLayoutDevice())
   615     UpdateArea( Rect() );
   737         {
       
   738         UpdateChangedArea(ETrue);
       
   739         }
       
   740     else
       
   741         UpdateArea( Rect() );
       
   742       
   616       
   743     }
   617     }
   744 
   618 
   745 // ---------------------------------------------------------------------------
   619 // ---------------------------------------------------------------------------
   746 // CVirtualKeyCtrl::HandlePointerLeave
   620 // CVirtualKeyCtrl::HandlePointerLeave
   759         {
   633         {
   760         iKeyInfo->SetLatched(!iKeyInfo->Latched());       
   634         iKeyInfo->SetLatched(!iKeyInfo->Latched());       
   761         }
   635         }
   762         
   636         
   763     iKeyboard->ClearBubble(ETrue);
   637     iKeyboard->ClearBubble(ETrue);
   764     if(UiLayout()->NotDrawToLayoutDevice())
   638 	ReDraw();
   765         {
   639     UpdateArea( Rect() );
   766         UpdateChangedArea(EFalse);
       
   767         }
       
   768     else
       
   769         {
       
   770         ReDraw();
       
   771         UpdateArea( Rect() );
       
   772         }
       
   773 	
   640 	
   774 #ifdef RD_TACTILE_FEEDBACK
   641 #ifdef RD_TACTILE_FEEDBACK
   775     if ( iKeyboard->GowithPointerDown() )
   642     if ( iKeyboard->GowithPointerDown() )
   776 		{
   643 		{
   777 	    
   644 	    
   778 		if (UiLayout()->SupportTactileFeedback())
   645 		if (UiLayout()->SupportTactileFeedback())
   779 			{
   646 			{
   780 			if (!Hiden())
   647 			if (!Hiden())
   781 				{				
   648 				{				
   782 				UiLayout()->DoTactileFeedback(ETouchFeedbackCharacterInputButton, ETrue, EFalse);				
   649 				UiLayout()->DoTactileFeedback(ETouchFeedbackBasicKeypad, ETrue, EFalse);				
   783 				}
   650 				}
   784 			}
   651 			}
   785 		}
   652 		}
   786 #endif //RD_TACTILE_FEEDBACK
   653 #endif //RD_TACTILE_FEEDBACK
   787     }
   654     }
   788 
   655 
   789 void CVirtualKeyCtrl::CancelPointerDownL()
   656 void CVirtualKeyCtrl::CancelPointerDownL()
   790 	{
   657 	{
   791 	CFepUiBaseCtrl::CancelPointerDownL();
   658 	CFepUiBaseCtrl::CancelPointerDownL();
   792 	iKeyboard->ClearBubble(ETrue);
   659 	iKeyboard->ClearBubble(ETrue);
   793     if(UiLayout()->NotDrawToLayoutDevice())
   660 	ReDraw();
   794         {
   661     UpdateArea( Rect() );
   795         UpdateChangedArea(EFalse);
       
   796         }
       
   797     else
       
   798         {	
       
   799         ReDraw();
       
   800         UpdateArea( Rect() );
       
   801         }
       
   802 	}
   662 	}
   803 // ---------------------------------------------------------------------------
   663 // ---------------------------------------------------------------------------
   804 // CVirtualKeyCtrl::ReDraw
   664 // CVirtualKeyCtrl::ReDraw
   805 // Redraw and updates the key
   665 // Redraw and updates the key
   806 // (other items were commented in a header).
   666 // (other items were commented in a header).
   807 // ---------------------------------------------------------------------------
   667 // ---------------------------------------------------------------------------
   808 //    
   668 //    
   809 void CVirtualKeyCtrl::ReDraw()
   669 void CVirtualKeyCtrl::ReDraw()
   810     {
   670     {
   811     if(UiLayout()->NotDrawToLayoutDevice())
   671     Draw();    
   812         {
   672     UpdateArea(Rect(), EFalse);            
   813         if(iKeyInfo->Latched()||(PointerDown()&&!iKeyInfo->IsLatchKey()))
       
   814             {        
       
   815             DrawHighlightKey();
       
   816             UpdateChangedArea(ETrue);
       
   817             }
       
   818 		else
       
   819             {
       
   820 			Draw();
       
   821 			UpdateArea(Rect(), EFalse);
       
   822 			}		
       
   823         }
       
   824     else
       
   825         {
       
   826         Draw();        
       
   827         UpdateArea(Rect(), EFalse);
       
   828         }    
       
   829     }
   673     }
   830     
   674     
   831 // ---------------------------------------------------------------------------
   675 // ---------------------------------------------------------------------------
   832 // CVirtualKeyCtrl::ReportKeyEvent
   676 // CVirtualKeyCtrl::ReportKeyEvent
   833 // Report current key event
   677 // Report current key event
  1041 // (other items were commented in a header).
   885 // (other items were commented in a header).
  1042 // ---------------------------------------------------------------------------
   886 // ---------------------------------------------------------------------------
  1043 //
   887 //
  1044 void CVirtualRawKeyCtrl::HandlePointerLeave(const TPoint& aPoint)
   888 void CVirtualRawKeyCtrl::HandlePointerLeave(const TPoint& aPoint)
  1045     {    
   889     {    
  1046     if(UiLayout()->NotDrawToLayoutDevice())
       
  1047         {
       
  1048         UpdateChangedArea(EFalse);
       
  1049         }
       
  1050     TRawEvent event;
   890     TRawEvent event;
  1051     event.Set(TRawEvent::EButton1Up,aPoint.iX,aPoint.iY);
   891     event.Set(TRawEvent::EButton1Up,aPoint.iX,aPoint.iY);
  1052     
   892     
  1053     SimulateRawEvent(event);
   893     SimulateRawEvent(event);
  1054     
   894     
  1056 #ifdef RD_TACTILE_FEEDBACK
   896 #ifdef RD_TACTILE_FEEDBACK
  1057 	if (UiLayout()->SupportTactileFeedback())
   897 	if (UiLayout()->SupportTactileFeedback())
  1058 		{		
   898 		{		
  1059 		if (!VirtualKey()->Dimmed() && !Hiden())
   899 		if (!VirtualKey()->Dimmed() && !Hiden())
  1060 			{
   900 			{
  1061 			UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveInput, ETrue, EFalse);
   901 			UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveKeypad, ETrue, EFalse);
  1062 			}
   902 			}
  1063         }
   903         }
  1064 #endif //RD_TACTILE_FEEDBACK     
   904 #endif //RD_TACTILE_FEEDBACK     
  1065 	}
   905 	}
  1066 
       
  1067 TRect CVirtualKeyCtrl::GetRect()
       
  1068     {
       
  1069     TRect r(Rect());
       
  1070     if(UiLayout()->NotDrawToLayoutDevice())
       
  1071         {
       
  1072 		if(iKeyInfo->Latched()||(PointerDown()&&!iKeyInfo->IsLatchKey()))
       
  1073 		    {
       
  1074 			r.Move(-r.iTl.iX, -r.iTl.iY);
       
  1075 			}
       
  1076         }
       
  1077     return r;
       
  1078     }
       
  1079 	
       
  1080 void CVirtualKeyCtrl::UpdateChangedArea(TBool aFlag)
       
  1081     {
       
  1082     struct SData
       
  1083         {
       
  1084     	TUint32 ctrl;
       
  1085         TBool flag;
       
  1086         CFbsBitmap* bmp;
       
  1087         TRect pos;
       
  1088         } data;
       
  1089         
       
  1090     data.ctrl = (TUint32)this;
       
  1091     data.flag = aFlag;
       
  1092     data.bmp = Keyboard()->Bitmap();//aFlag ? Keyboard()->iBitmap : 0;
       
  1093     data.pos = Rect();
       
  1094     TPtrC ptr;
       
  1095     ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16));
       
  1096     
       
  1097     UiLayout()->SignalOwner(ESignalUpdateChangedArea,ptr);
       
  1098     }
       
  1099 //end of file
   906 //end of file