textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutvkbkeyctrl.cpp
branchRCL_3
changeset 50 5a1685599b76
parent 46 bd83ceabce89
child 56 8152b1f1763a
equal deleted inserted replaced
46:bd83ceabce89 50:5a1685599b76
   120 // CVirtualKeyCtrl::DrawKeyText
   120 // CVirtualKeyCtrl::DrawKeyText
   121 // Draw key text
   121 // Draw key text
   122 // (other items were commented in a header).
   122 // (other items were commented in a header).
   123 // ---------------------------------------------------------------------------
   123 // ---------------------------------------------------------------------------
   124 //        
   124 //        
   125 void CVirtualKeyCtrl::DrawKeyText(CFbsBitGc* aGc)  
   125 void CVirtualKeyCtrl::DrawKeyText(CFbsBitGc* aGc, const TRect& aRect)  
   126     {
   126     {
   127     TBool textlineset = EFalse;
   127     TBool textlineset = EFalse;
   128 
   128 
   129     // if text line set
   129     // if text line set
   130     for (TInt i = 0; i <= EPosLast; i++)
   130     for (TInt i = 0; i <= EPosLast; i++)
   134             textlineset = ETrue;
   134             textlineset = ETrue;
   135 
   135 
   136             if (iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) != KNullDesC)
   136             if (iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) != KNullDesC)
   137                 {
   137                 {
   138                 TAknLayoutText textLayout;
   138                 TAknLayoutText textLayout;
   139                 textLayout.LayoutText(GetRect(), 
   139                 textLayout.LayoutText(aRect, 
   140                                       iKeyboard->TextLineLayout(TVirtualKeyTextPos(i)));
   140                                       iKeyboard->TextLineLayout(TVirtualKeyTextPos(i)));
   141 				TRgb color( KRgbBlack );  // sane default for nonskinned case			    
   141 				TRgb color( KRgbBlack );  // sane default for nonskinned case			    
   142 			    if ( AknsUtils::AvkonSkinEnabled() )
   142 			    if ( AknsUtils::AvkonSkinEnabled() )
   143 			        {
   143 			        {
   144 			        AknsUtils::GetCachedColor( UiLayout()->SkinInstance(),
   144 			        AknsUtils::GetCachedColor( UiLayout()->SkinInstance(),
   149 			    
   149 			    
   150 			    // replace the shift text to shift icon			        
   150 			    // replace the shift text to shift icon			        
   151 				if( iKeyboard->ShiftIcon() &&
   151 				if( iKeyboard->ShiftIcon() &&
   152 					iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) == KKeyShiftCharacter )
   152 					iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) == KKeyShiftCharacter )
   153 					{
   153 					{
   154 					//CFbsBitGc* gc = GetGc();//static_cast<CFbsBitGc*>(BitGc());
   154 				    // Get the rect of the shift icon
       
   155 					TRect shiftIconDrawRect = iKeyboard->ShiftIconRect();
       
   156 					shiftIconDrawRect.Move( iKeyboard->Rect().iTl );
   155 					AknPenInputDrawUtils::DrawColorIcon( iKeyboard->ShiftIcon(),
   157 					AknPenInputDrawUtils::DrawColorIcon( iKeyboard->ShiftIcon(),
   156 														 *aGc,
   158 														 *aGc,
   157 														 textLayout.TextRect() );	
   159 														 shiftIconDrawRect );	
   158 					}
   160 					}
   159 				else if(iKeyboard->StarIcon() &&
   161 				else if(iKeyboard->StarIcon() &&
   160 						iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) == KKeyStarCharacter )
   162 						iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) == KKeyStarCharacter )
   161 					{
   163 					{
   162 					// Get the size of the icon
   164 					// Get the size of the icon
   163 					TSize starIconSize = iKeyboard->StarIcon()->Bitmap()->SizeInPixels();
   165 					TSize starIconSize = iKeyboard->StarIcon()->Bitmap()->SizeInPixels();
   164 					// Get the rect of draw icon area
   166 					// Get the rect of draw icon area
   165 					TRect drawIconRect = textLayout.TextRect();
   167 					TRect drawIconRect = iKeyboard->StarIconRect();
       
   168 					drawIconRect.Move( iKeyboard->Rect().iTl );
       
   169 					
   166 					// When the size of icon is different with the size of draw icon area,
   170 					// When the size of icon is different with the size of draw icon area,
   167 					// because the icon is drew from the left top coordinate of the draw
   171 					// because the icon is drew from the left top coordinate of the draw
   168 					// icon area, so the icon will not be drew in the center. In this case,
   172 					// icon area, so the icon will not be drew in the center. In this case,
   169 					// we need to adjust the top left coordinate of draw icon rect to 
   173 					// we need to adjust the top left coordinate of draw icon rect to 
   170 					// make sure that the icon will be drew in the center of the key
   174 					// make sure that the icon will be drew in the center of the key
   193         }
   197         }
   194 
   198 
   195     if (!textlineset)
   199     if (!textlineset)
   196         {
   200         {
   197 		TAknLayoutText textLayout;
   201 		TAknLayoutText textLayout;
   198 		textLayout.LayoutText(GetRect(), iKeyboard->iVKBTextLineLayout);
   202 		textLayout.LayoutText(aRect, iKeyboard->iVKBTextLineLayout);
   199 	    
   203 	    
   200 	    //CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());    
   204 	    //CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());    
   201 	    
   205 	    
   202 	    //charRect.Move(keyboardRect.iTl);
   206 	    //charRect.Move(keyboardRect.iTl);
   203 	    //if(iKeyInfo->Dimmed())
   207 	    //if(iKeyInfo->Dimmed())
   321         }
   325         }
   322         
   326         
   323     gc->SetPenColor(KRgbBlack);
   327     gc->SetPenColor(KRgbBlack);
   324     gc->SetBrushStyle( CGraphicsContext::ENullBrush );    
   328     gc->SetBrushStyle( CGraphicsContext::ENullBrush );    
   325     //Draw text again.
   329     //Draw text again.
   326     DrawKeyText(gc); 
   330     
       
   331     DrawKeyText(gc,GetRect()); 
   327     }
   332     }
   328 
   333 
   329 // ---------------------------------------------------------------------------
   334 // ---------------------------------------------------------------------------
   330 // CVirtualKeyCtrl::DrawBmp
   335 // CVirtualKeyCtrl::DrawBmp
   331 // Draw bitmap
   336 // Draw bitmap
   456         }        
   461         }        
   457         
   462         
   458     gc->SetPenColor( KRgbBlack );
   463     gc->SetPenColor( KRgbBlack );
   459     gc->SetBrushStyle( CGraphicsContext::ENullBrush );    
   464     gc->SetBrushStyle( CGraphicsContext::ENullBrush );    
   460     gc->SetFaded(EFalse);            
   465     gc->SetFaded(EFalse);            
   461     DrawKeyText(gc);        
   466     DrawKeyText(gc,Rect());        
   462     }
   467     }
   463 
   468 
   464 CFbsBitGc* CVirtualKeyCtrl::GetGc()
   469 CFbsBitGc* CVirtualKeyCtrl::GetGc()
   465     {
   470     {
   466     if(UiLayout()->NotDrawToLayoutDevice())
   471     if(UiLayout()->NotDrawToLayoutDevice())
   524 
   529 
   525         innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin );
   530         innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin );
   526         TBool bHasDrawn = EFalse;
   531         TBool bHasDrawn = EFalse;
   527         if(UiLayout()->NotDrawToLayoutDevice())
   532         if(UiLayout()->NotDrawToLayoutDevice())
   528             {
   533             {
   529             /*TBool ret = iKeyboard->PrepareKeyBmp(iKeyboard->HighightKeyBmp(),
       
   530                                     iKeyboard->HighlightKeyDev(),
       
   531                                     rect,innerrect,
       
   532                                     iKeyboard->KeySkinId(EKeyBmpHighlight), 
       
   533                                     KAknsIIDDefault,Rect());*/
       
   534             TBool ret = iKeyboard->PrepareHighlightKeyBmp(rect,innerrect,Rect());                                    
   534             TBool ret = iKeyboard->PrepareHighlightKeyBmp(rect,innerrect,Rect());                                    
   535             if(ret)
   535             if(ret)
   536                 {
   536                 {
   537                 gc->BitBlt(rect.iTl,iKeyboard->HighightKeyBmp());
   537                 gc->BitBlt(rect.iTl,iKeyboard->HighightKeyBmp());
   538                 bHasDrawn = ETrue;
   538                 bHasDrawn = ETrue;
   586 
   586 
   587     gc->SetBrushStyle( CGraphicsContext::ENullBrush );    
   587     gc->SetBrushStyle( CGraphicsContext::ENullBrush );    
   588     gc->SetFaded(EFalse);       
   588     gc->SetFaded(EFalse);       
   589     if(UiLayout()->NotDrawToLayoutDevice())
   589     if(UiLayout()->NotDrawToLayoutDevice())
   590         {
   590         {
   591 		DrawKeyText(Keyboard()->HighlightGc());
   591         DrawKeyText(Keyboard()->HighlightGc(), GetRect());
   592         UpdateChangedArea(ETrue);
   592         UpdateChangedArea(ETrue);
   593 		}
   593 		}
   594     else
   594     else
   595         {
   595         {
   596 		DrawKeyText(gc);
   596         DrawKeyText(gc, Rect());
   597 		}   
   597 		}   
   598 
   598 
   599     }
   599     }
   600     
   600     
   601 // ---------------------------------------------------------------------------
   601 // ---------------------------------------------------------------------------
   627         DrawDimKey();
   627         DrawDimKey();
   628         return;
   628         return;
   629         }
   629         }
   630     
   630     
   631     if(iKeyInfo->Latched()||(PointerDown()&&!iKeyInfo->IsLatchKey()))
   631     if(iKeyInfo->Latched()||(PointerDown()&&!iKeyInfo->IsLatchKey()))
   632         {        
   632         { 
       
   633         // If some layout initializes a RootCtrl redraw operation when the key was in a highlighted state, the normal key would not be seen
       
   634         // after key was returned to the normal state, that's because the layout device has been cleaned and redrawn again so when it comes to draw
       
   635         // this highlighted virtual key, it just draws the bitmap on its own device, so the area the highlighted key occupied on the layout device
       
   636         // is totally undrawn with the normal state key bitmap.
       
   637         // So we have to redraw the normal state key first to make sure the normal key was drawn on the layout bitmap.
       
   638         // [use case: Open the chinse VITUT, input some pinyin letter to bring the candidate list to the forground by clicking the virtual key ctrl
       
   639         //  ==> select some chinese words in the candidate list ==> then click and release the virtual key agian]
       
   640         if(UiLayout()->NotDrawToLayoutDevice())
       
   641             {
       
   642             DrawNormalStateKey();
       
   643             }
       
   644         
   633         DrawHighlightKey();
   645         DrawHighlightKey();
   634         
   646         
   635 // remove DrawBubble() into HandlePointerDownEventL()
   647 // remove DrawBubble() into HandlePointerDownEventL()
   636 // to avoid showing more than one bubble at the same time.        
   648 // to avoid showing more than one bubble at the same time.        
   637 //        iKeyboard->DrawBubble(iKeyInfo);
   649 //        iKeyboard->DrawBubble(iKeyInfo);
   712         // When key down, latch key won't generate event.
   724         // When key down, latch key won't generate event.
   713         eventType = iKeyInfo->Latched() ? EEventVirtualKeyLatched : EEventVirtualKeyUnLatched;
   725         eventType = iKeyInfo->Latched() ? EEventVirtualKeyLatched : EEventVirtualKeyUnLatched;
   714         }     
   726         }     
   715     if(UiLayout()->NotDrawToLayoutDevice())
   727     if(UiLayout()->NotDrawToLayoutDevice())
   716         {
   728         {
   717         //no need to draw again, just remove the highlight bitmap
   729         if(!iKeyInfo->Latched())
   718         UpdateChangedArea(EFalse);
   730         	{
   719 		Draw();
   731         	//no need to draw again, just remove the highlight bitmap
       
   732             UpdateChangedArea(EFalse);
       
   733         	}
       
   734         
       
   735         // no need to draw the normal key to layout bitmap since the highlighted key bitmap is drawn in a seperate device instead of layout device
       
   736         // so just notify the PEN UI to simply remove the highlighted key bitmap. It will somehow improve the performance and decrease the CPU usage
       
   737 		//Draw();
   720         }
   738         }
   721     else
   739     else
   722         {
   740         {
   723         ReDraw();
   741         ReDraw();
   724         UpdateAreaImmed( Rect() );
   742         UpdateAreaImmed( Rect() );