textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutvkb.cpp
branchRCL_3
changeset 5 a47de9135b21
parent 0 eb1f2e154e89
child 8 4eb1ae11334f
equal deleted inserted replaced
3:f5a1e66df979 5:a47de9135b21
    25 #include "peninputlayoutbubblectrl.h"
    25 #include "peninputlayoutbubblectrl.h"
    26 #include "peninputlayoutvirtualkeyctrl.h"
    26 #include "peninputlayoutvirtualkeyctrl.h"
    27 #include "peninputlayoutvkb.h"
    27 #include "peninputlayoutvkb.h"
    28 #include "peninputpluginutils.h"
    28 #include "peninputpluginutils.h"
    29 
    29 
       
    30 #include "peninputvkbpreviewbubblerenderer.h"
    30 const TInt KFadingParamBlack = 128;
    31 const TInt KFadingParamBlack = 128;
    31 const TInt KFadingParamWhite = 192;
    32 const TInt KFadingParamWhite = 192;
    32 const TInt KDefaultBubbleSize = 50;
    33 const TInt KDefaultBubbleSize = 50;
    33 
    34 
    34 // ======== MEMBER FUNCTIONS ========
    35 // ======== MEMBER FUNCTIONS ========
   100                                 iBubbleVerticalMargin(0),                                
   101                                 iBubbleVerticalMargin(0),                                
   101                                 iKeyTextColorGroup(INVALID_COLOR_GROUP)
   102                                 iKeyTextColorGroup(INVALID_COLOR_GROUP)
   102     {
   103     {
   103     iFontSpec = aFontSpec;   
   104     iFontSpec = aFontSpec;   
   104     SetControlType(ECtrlVirtualKeyboard);
   105     SetControlType(ECtrlVirtualKeyboard);
       
   106     iBubbleSize = TSize( KDefaultBubbleSize, KDefaultBubbleSize );
   105     }
   107     }
   106     
   108     
   107 // ---------------------------------------------------------------------------
   109 // ---------------------------------------------------------------------------
   108 // CVirtualKeyboard::~CVirtualKeyboard
   110 // CVirtualKeyboard::~CVirtualKeyboard
   109 // Destructor
   111 // Destructor
   111 //
   113 //
   112 EXPORT_C CVirtualKeyboard::~CVirtualKeyboard()
   114 EXPORT_C CVirtualKeyboard::~CVirtualKeyboard()
   113     {
   115     {
   114     if ( iBubbleCtrl )
   116     if ( iBubbleCtrl )
   115         delete iBubbleCtrl;
   117         delete iBubbleCtrl;
       
   118     if ( iPreviewBubbleRenderer )
       
   119         {
       
   120         iPreviewBubbleRenderer->Detach();
       
   121         iPreviewBubbleRenderer = NULL;
       
   122         }
   116     
   123     
   117     //free keys
   124     //free keys
   118     iKeyArray.ResetAndDestroy();
   125     iKeyArray.ResetAndDestroy();
   119     iKeyArray.Close();
   126     iKeyArray.Close();
   120     
   127     
   439     {
   446     {
   440     if ( iBubbleCtrl )
   447     if ( iBubbleCtrl )
   441         {
   448         {
   442         iBubbleCtrl->Close();
   449         iBubbleCtrl->Close();
   443         }
   450         }
       
   451     if( iPreviewBubbleRenderer )
       
   452         {
       
   453         iPreviewBubbleRenderer->ClearBubble();
       
   454         }
   444     }
   455     }
   445 
   456 
   446 void CVirtualKeyboard::DrawBubble(CVirtualKey* aKey)
   457 void CVirtualKeyboard::DrawBubble(CVirtualKey* aKey)
   447     {
   458     {
       
   459     if( iPreviewBubbleRenderer )
       
   460         {
       
   461         if ( iIsShowBubble )
       
   462             {
       
   463             TPoint org = UiLayout()->Position();
       
   464             TPoint vkbpos = Rect().iTl;
       
   465             iPreviewBubbleRenderer->DrawBubble( aKey, vkbpos, org, iBubbleSize );
       
   466             }
       
   467         return;
       
   468         }
   448     
   469     
   449     if ( aKey && !aKey->Dimmed() && iBubbleCtrl && iIsShowBubble)
   470     if ( aKey && !aKey->Dimmed() && iBubbleCtrl && iIsShowBubble)
   450         {
   471         {
   451         TRect rect = iBubbleCtrl->Rect();
   472         TRect rect = iBubbleCtrl->Rect();
   452         TRect parentWndRect = Rect();       
   473         TRect parentWndRect = Rect();       
   464             }
   485             }
   465         else
   486         else
   466             {
   487             {
   467             rect.iTl.iX = x1;     
   488             rect.iTl.iX = x1;     
   468             rect.iBr.iX = x2;                 
   489             rect.iBr.iX = x2;                 
       
   490             
       
   491             TPoint vkbpos = Rect().iTl;
       
   492             rect.Move( vkbpos.iX, 0 );
   469             }
   493             }
   470         
   494         
   471         rect.iTl.iY = iBubbleVerticalMargin + aKey->Rect().iTl.iY - 
   495         rect.iTl.iY = iBubbleVerticalMargin + aKey->Rect().iTl.iY - 
   472                       iBubbleSize.iHeight + Rect().iTl.iY;
   496                       iBubbleSize.iHeight + Rect().iTl.iY;
   473         rect.iBr.iY = iBubbleVerticalMargin + aKey->Rect().iTl.iY + Rect().iTl.iY;
   497         rect.iBr.iY = iBubbleVerticalMargin + aKey->Rect().iTl.iY + Rect().iTl.iY;
   474 		
   498         
       
   499         TPoint org = UiLayout()->Position();
       
   500         rect.Move( org.iX, org.iY ); //now is in screen coord-sys
       
   501         
   475 		if( aKey->DisplayUnicode() && aKey->DisplayUnicode()->Length() != 0 )
   502 		if( aKey->DisplayUnicode() && aKey->DisplayUnicode()->Length() != 0 )
   476 			{
   503 			{
   477 			TRAP_IGNORE(iBubbleCtrl->SetTextL(*aKey->DisplayUnicode()));		
   504 			TRAP_IGNORE(iBubbleCtrl->SetTextL(*aKey->DisplayUnicode()));		
   478 			}
   505 			}
   479         else
   506         else
   483         iBubbleCtrl->Popup(rect);
   510         iBubbleCtrl->Popup(rect);
   484         }
   511         }
   485     }
   512     }
   486 
   513 
   487 EXPORT_C void CVirtualKeyboard::ShowBubble(TBool aFlag)
   514 EXPORT_C void CVirtualKeyboard::ShowBubble(TBool aFlag)
   488     {  
   515     {
       
   516     iIsShowBubble = aFlag;
       
   517 
       
   518     if( iPreviewBubbleRenderer )
       
   519         {
       
   520         iPreviewBubbleRenderer->ShowBubble( aFlag );
       
   521         return;
       
   522         }
   489     TBool flag = iBubbleCtrl ? ETrue : EFalse;
   523     TBool flag = iBubbleCtrl ? ETrue : EFalse;
   490     iIsShowBubble = aFlag;
       
   491     if ( flag != aFlag )
   524     if ( flag != aFlag )
   492         {
   525         {
   493         if(!flag)
   526         if(!flag)
   494             {
   527             {
   495             TRAP_IGNORE(iBubbleCtrl = CBubbleCtrl::NewL(TRect(0,0,0,0),UiLayout(),-0xFFFF));
   528             TRAP_IGNORE(iBubbleCtrl = CBubbleCtrl::NewL(TRect(0,0,0,0),UiLayout(),-0xFFFF));
   514     {
   547     {
   515     if ( iBubbleCtrl )
   548     if ( iBubbleCtrl )
   516         {
   549         {
   517         iBubbleCtrl->SetBitmapParam(aBmpId,aMaskBmpId,aBgSkinId);
   550         iBubbleCtrl->SetBitmapParam(aBmpId,aMaskBmpId,aBgSkinId);
   518         }
   551         }
       
   552     if( iPreviewBubbleRenderer )
       
   553         {
       
   554         iPreviewBubbleRenderer->SetBubbleBitmapParam( aBmpId,aMaskBmpId,aBgSkinId );
       
   555         }
   519     }
   556     }
   520         
   557         
   521 EXPORT_C void CVirtualKeyboard::SetBubbleSize(const TSize& aSize)
   558 EXPORT_C void CVirtualKeyboard::SetBubbleSize(const TSize& aSize)
   522     {
   559     {
   523     iBubbleSize = aSize;
   560     iBubbleSize = aSize;
   532     {
   569     {
   533     if ( iBubbleCtrl )
   570     if ( iBubbleCtrl )
   534         {
   571         {
   535         iBubbleCtrl->SetTextFormat(aTextFormat);    
   572         iBubbleCtrl->SetTextFormat(aTextFormat);    
   536         }
   573         }
       
   574     if( iPreviewBubbleRenderer )
       
   575         {
       
   576         iPreviewBubbleRenderer->SetTextFormat( aTextFormat );
       
   577         }
   537     }
   578     }
   538 
   579 
   539 EXPORT_C void CVirtualKeyboard::SetFrameDiff(TInt aLeftDiff, TInt aTopDiff,
   580 EXPORT_C void CVirtualKeyboard::SetFrameDiff(TInt aLeftDiff, TInt aTopDiff,
   540                                              TInt aRightDiff,TInt aBottomDiff)
   581                                              TInt aRightDiff,TInt aBottomDiff)
   541     {
   582     {
   542     if ( iBubbleCtrl )
   583     if ( iBubbleCtrl )
   543         {
   584         {
   544         iBubbleCtrl->SetFrameDiff(aLeftDiff,aTopDiff,aRightDiff,aBottomDiff);    
   585         iBubbleCtrl->SetFrameDiff(aLeftDiff,aTopDiff,aRightDiff,aBottomDiff);    
   545         }        
   586         }
       
   587     if ( iPreviewBubbleRenderer )
       
   588         {
       
   589         iPreviewBubbleRenderer->SetFrameDiff( aLeftDiff, aTopDiff, aRightDiff, aBottomDiff );
       
   590         }
   546     }
   591     }
   547        
   592        
   548 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerMoveEventL(const TPoint& aPt)
   593 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerMoveEventL(const TPoint& aPt)
   549     {
   594     {
   550     if(iWndControl)
   595     if(iWndControl)
  1103 
  1148 
  1104 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerMoveEventL(const TPoint& aPoint)
  1149 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerMoveEventL(const TPoint& aPoint)
  1105     {
  1150     {
  1106     return CControlGroup::HandlePointerMoveEventL(aPoint);
  1151     return CControlGroup::HandlePointerMoveEventL(aPoint);
  1107     }
  1152     }
  1108     */				 
  1153     */
       
  1154 EXPORT_C void CVirtualKeyboard::SetPreviewBubbleRenderer( MPeninputVkbPreviewBubbleRenderer* aRenderer )
       
  1155     {
       
  1156     if ( ( NULL != aRenderer ) && ( aRenderer == iPreviewBubbleRenderer ) )
       
  1157         {
       
  1158         return;
       
  1159         }
       
  1160     
       
  1161     if( iPreviewBubbleRenderer )
       
  1162         {
       
  1163         iPreviewBubbleRenderer->Detach();
       
  1164         }
       
  1165     
       
  1166     iPreviewBubbleRenderer = aRenderer;
       
  1167     if ( aRenderer )
       
  1168         {
       
  1169         aRenderer->Attach();
       
  1170         }
       
  1171     }
  1109 //end of implementation of class CVirtualKeyboard
  1172 //end of implementation of class CVirtualKeyboard
  1110     
  1173     
  1111 // Implementation of Class CVirtualKey
  1174 // Implementation of Class CVirtualKey
  1112 
  1175 
  1113 // ---------------------------------------------------------------------------
  1176 // ---------------------------------------------------------------------------