textinput/peninputgenericvkb/src/peninputgenericvkbwindow.cpp
changeset 0 eb1f2e154e89
child 3 f5a1e66df979
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     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 vkb window class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // System includes
       
    20 
       
    21 
       
    22 #include <peninputvkbwindow.rsg>
       
    23 #include <peninputvkbwindowconfiginfo_01.rsg>
       
    24 #include <aknfeppeninputenums.h>
       
    25 #include <peninputinputcontextfield.h>
       
    26 #include <peninputpluginutils.h>
       
    27 #include <peninputcommonlayoutext.h>
       
    28 #include <peninputvkbctrllayout.h>
       
    29 #include <peninputvkbctrlext.h>
       
    30 #include <peninputeventbutton.h>
       
    31 #include <peninputdragbutton.h>
       
    32 #include <peninputrepeatbutton.h>
       
    33 #include <peninputmultimodebutton.h>
       
    34 #include <peninputrangebar.h>
       
    35 #include <peninputdataconverter.h>
       
    36 #include <peninputdataprovider.h>
       
    37 #include <peninputclientlayoutinfo.h>
       
    38 #include <peninputlayoutchoicelist.h>
       
    39 
       
    40 #include <aknlayoutscalable_apps.cdl.h>
       
    41 #include <peninputlayoutbubblectrl.h>
       
    42 #include <peninputscrollablelist.h>
       
    43 
       
    44 #include <e32keys.h>
       
    45 #include <AknIconUtils.h>
       
    46 #include <AknLayoutDef.h>
       
    47 #include <AknUtils.h>
       
    48 #include <aknlayoutscalable_avkon.cdl.h>
       
    49 #include <AknsUtils.h>
       
    50 #include <AknFepGlobalEnums.h>
       
    51 #include <peninputlayoutinputmodechoice.h>
       
    52 #include <peninputlayoutmultilineicf.h>
       
    53 #include <s32mem.h>
       
    54 // User includes
       
    55 #include "peninputgenericvkb.hrh"
       
    56 #include "peninputgenericvkbwindow.h"
       
    57 #include "peninputgenericvkbenum.h"
       
    58 #include "peninputrangebarinfo.h"
       
    59 #include "peninputgenericvkblafdatamgr.h"
       
    60 #include "peninputgenericvkblangmeritpair.h"
       
    61 #include "peninputgenericvkblayout.h"
       
    62 
       
    63 // Constants
       
    64 const TInt KPeninputVkbWndInvalidIndex = -1;
       
    65 const TInt KInvalidImg = -1 ;
       
    66 const TInt KKeyCodeSize = 1;
       
    67 
       
    68 _LIT( KVkbWindowResourceFile, 
       
    69       "z:\\resource\\plugins\\peninputvkbwindow.RSC" );
       
    70 _LIT( KConfigurationResourceFile, 
       
    71       "z:\\resource\\plugins\\peninputvkbwindowconfiginfo_" );
       
    72 _LIT( KResourceFileExtName, ".RSC" );
       
    73 
       
    74 // ======== MEMBER FUNCTIONS ========
       
    75 
       
    76 // --------------------------------------------------------------------------
       
    77 // CPeninputGenericVkbWindow::CPeninputGenericVkbWindow
       
    78 // (other items were commented in a header)
       
    79 // --------------------------------------------------------------------------
       
    80 //
       
    81 CPeninputGenericVkbWindow::CPeninputGenericVkbWindow( 
       
    82     CFepUiLayout* aUiLayout, MPeninputLayoutContext* aLayoutContext, 
       
    83     MPeninputUiStateMgr* aUiStateMgr )
       
    84     : CPeninputLayoutWindowExt( aUiLayout, aLayoutContext ),
       
    85       iUiStateMgr(aUiStateMgr),
       
    86       iPopupInited(EFalse),
       
    87       iPopupSet(EFalse),
       
    88       iLafMgr(NULL),
       
    89       iFirstConstruct(ETrue)
       
    90     {
       
    91     }
       
    92 
       
    93 // --------------------------------------------------------------------------
       
    94 // CPeninputGenericVkbWindow::NewL
       
    95 // (other items were commented in a header)
       
    96 // --------------------------------------------------------------------------
       
    97 // 
       
    98 CPeninputGenericVkbWindow* CPeninputGenericVkbWindow::NewL( 
       
    99     CFepUiLayout* aUiLayout, MPeninputLayoutContext* aLayoutContext, 
       
   100     MPeninputUiStateMgr* aUiStateMgr )
       
   101     {
       
   102     CPeninputGenericVkbWindow* self = 
       
   103         new ( ELeave ) CPeninputGenericVkbWindow( aUiLayout, aLayoutContext, aUiStateMgr );
       
   104     CleanupStack::PushL( self );
       
   105     self->ConstructL();
       
   106     CleanupStack::Pop( self );
       
   107 
       
   108     return self;
       
   109     }
       
   110 
       
   111 // --------------------------------------------------------------------------
       
   112 // CPeninputGenericVkbWindow::~CPeninputGenericVkbWindow
       
   113 // (other items were commented in a header)
       
   114 // --------------------------------------------------------------------------
       
   115 //
       
   116 CPeninputGenericVkbWindow::~CPeninputGenericVkbWindow()
       
   117     {
       
   118     delete iIdle;
       
   119     iUnits.Close();
       
   120     
       
   121     delete iLafMgr;
       
   122     iLafMgr = NULL;
       
   123     delete iBmpRotator;
       
   124     }
       
   125 void CPeninputGenericVkbWindow::ConstructL()
       
   126     {
       
   127     iBmpRotator = CPeninputSyncBitmapRotator::NewL();
       
   128     iLafMgr = CPeninputGenericVkbLafMgr::NewL();
       
   129     iLafMgr->SetInputModeL(TPluginInputMode (iLayoutContext->LayoutType()));
       
   130     CPeninputLayoutWindowExt::ConstructL();
       
   131 
       
   132     // For addition of ITI features, add a candidate list in vkb window   
       
   133     CreateCandidateListL();    
       
   134     }
       
   135 
       
   136 // --------------------------------------------------------------------------
       
   137 // CPeninputGenericVkbWindow::HandleControlEvent
       
   138 // (other items were commented in a header)
       
   139 // --------------------------------------------------------------------------
       
   140 //
       
   141 void CPeninputGenericVkbWindow::HandleControlEvent( TInt aEventType,
       
   142                                                     CFepUiBaseCtrl* aCtrl, 
       
   143                                                     const TDesC& aEventData )
       
   144     {
       
   145     // Call this function in base class
       
   146     CPeninputLayoutWindowExt::HandleControlEvent( aEventType, aCtrl, 
       
   147                                                   aEventData );
       
   148     
       
   149     TInt* data = ( TInt* ) aEventData.Ptr(); 
       
   150     
       
   151     switch ( aEventType )
       
   152         {
       
   153         case EPeninputLayoutVkbEventResetShift: 
       
   154             {
       
   155             HandleShiftAndCapslockBtnClicked();
       
   156             }
       
   157             break;  
       
   158         case EPenInputLayoutEventClosePopup:
       
   159         	{
       
   160             if ( iPopupWnd && !iPopupWnd->Hiden() )
       
   161                 {
       
   162                 iPopupWnd->CloseWindow();
       
   163                 ResetAccentButton();
       
   164                 iUiStateMgr->SetCurrentUiState( EPeninputVkbUiStateStandby );
       
   165                 }
       
   166         	}
       
   167             break;
       
   168         case EEventChoiceSelected:
       
   169             {
       
   170             CFepLayoutChoiceList::SEvent* event = 
       
   171                 ( CFepLayoutChoiceList::SEvent* ) aEventData.Ptr();
       
   172 
       
   173             if ( event->iIndex != KPeninputVkbWndInvalidIndex )
       
   174                 {
       
   175                 if (aCtrl->ControlId() == EPeninutWindowCtrlIdAccentPopupWindow)
       
   176                     {
       
   177                     TInt currentRange = CPeninputDataConverter::AnyToInt(
       
   178                                       iLayoutContext->RequestData(EPeninputDataTypeCurrentRange));
       
   179                     TInt currentAccent = CPeninputDataConverter::AnyToInt(
       
   180                                       iLayoutContext->RequestData(EPeninputDataTypeCurrentAccent));
       
   181                 
       
   182                     if ((currentRange == ERangeAccent) && (currentAccent == event->iIndex))
       
   183                         {
       
   184 						iUiStateMgr->SetCurrentUiState( EPeninputVkbUiStateStandby );
       
   185                         return;
       
   186                         }
       
   187 
       
   188                     iLayoutContext->SetData( EPeninputDataTypeCurrentAccent, &(event->iIndex));
       
   189                                          
       
   190                     // Active range, update rangebar and vkb layout
       
   191                     //ChangeRange( ERangeAccent, EPeninputVkbLayoutAccented1 + 2 * event->iIndex);
       
   192                     (currentRange == ERangeAccent) ? ChangeRange(ERangeAccent, 
       
   193                                        EPeninputVkbLayoutAccented1 + 2 * event->iIndex, EFalse) :
       
   194                                                      ChangeRange(ERangeAccent, 
       
   195                                        EPeninputVkbLayoutAccented1 + 2 * event->iIndex, ETrue);
       
   196                     }
       
   197                 else if (aCtrl->ControlId() == EPeninutWindowCtrlIdSwitcherPopupWindow)
       
   198                     {
       
   199                     if (iLayoutContext->LayoutType() != event->iCommand)
       
   200                         {
       
   201                         TBool switchByMode = ETrue;
       
   202                         TInt  mode = event->iCommand;
       
   203 
       
   204                         TBuf<8> buf;
       
   205                         buf.Append(reinterpret_cast<TText*>(&switchByMode), 
       
   206                                                             sizeof(TBool)/sizeof(TText));
       
   207                         buf.Append(reinterpret_cast<TText*>(&mode), sizeof(TInt)/sizeof(TText));
       
   208                         UiLayout()->SignalOwner(ESignalLayoutUIChanged,buf);
       
   209                         }
       
   210                     }
       
   211                 else if ( aCtrl->ControlId() == EPentinputHwrCandidateList )
       
   212                     {
       
   213                     TRAP_IGNORE( HandleCandidateListSelectedL( aCtrl, aEventData ) );
       
   214                     }
       
   215                 }
       
   216             else
       
   217                 {
       
   218                 ResetAccentButton();   
       
   219                 }
       
   220             iUiStateMgr->SetCurrentUiState( EPeninputVkbUiStateStandby );
       
   221             }
       
   222             break;
       
   223         case EPeninputLayoutEventToHwr:
       
   224             {
       
   225             TRAP_IGNORE( UpdateICFTextL() );
       
   226             TRAP_IGNORE(PopupSwitchWindowL());
       
   227             }
       
   228             break; 
       
   229         case EEventVirtualKeyLatched:
       
   230             {
       
   231             HandleVirtualKeyLatchedEvent(aEventType, aCtrl, aEventData);
       
   232             }
       
   233             break;
       
   234         case EEventVirtualKeyUnLatched:
       
   235             {
       
   236             UiLayout()->SignalOwner(ESignalKeyEvent, iNewDeadKeyBuf);
       
   237             TBool deadKeyChange = EFalse;
       
   238             iLayoutContext->SetData(EAkninputDataTypeLatchedSet, &deadKeyChange);
       
   239             iNewDeadKeyBuf = KNullDesC;
       
   240             }
       
   241             break;
       
   242         case EPeninputLayoutEventBack:
       
   243             {
       
   244             TInt latchedFlag = CPeninputDataConverter::AnyToInt
       
   245                                (iLayoutContext->RequestData(EAkninputDataTypeLatchedSet));
       
   246             // If one DeadKey is latched, only unlatch the DeadKey and reset the iNewDeadKeyBuf
       
   247             // Don't delete the visible charater in ICF
       
   248             if(latchedFlag)
       
   249                 {
       
   250                 UnLatchDeadKey(iNewDeadKeyBuf);
       
   251 
       
   252                 TBool deadKeyChange = EFalse;
       
   253                 iLayoutContext->SetData(EAkninputDataTypeLatchedSet, &deadKeyChange);
       
   254                 iNewDeadKeyBuf = KNullDesC;
       
   255                 }
       
   256             }
       
   257             break;
       
   258         case EPeninputLayoutEventEnter:
       
   259         case EPeninputLayoutEventSpace:
       
   260             {
       
   261             TInt latchedFlag = CPeninputDataConverter::AnyToInt
       
   262                                (iLayoutContext->RequestData(EAkninputDataTypeLatchedSet));
       
   263             if(latchedFlag)
       
   264                 {
       
   265                 HBufC* newCharBuf = HBufC::New( aEventData.Length() + iNewDeadKeyBuf.Length() );
       
   266                 if( newCharBuf )
       
   267                     {
       
   268                     newCharBuf->Des().Append( iNewDeadKeyBuf );
       
   269                     newCharBuf->Des().Append( aEventData );
       
   270                     }                
       
   271                 
       
   272                 UnLatchDeadKey(iNewDeadKeyBuf);
       
   273 
       
   274                 TBool deadKeyChange = EFalse;
       
   275                 iLayoutContext->SetData(EAkninputDataTypeLatchedSet, &deadKeyChange);
       
   276                 
       
   277                 // Submit DeadKey + Space or Enter at the same time
       
   278                 UiLayout()->SignalOwner(ESignalKeyEvent,*newCharBuf);
       
   279                 iNewDeadKeyBuf = KNullDesC;
       
   280                 delete newCharBuf;
       
   281                 }
       
   282             }
       
   283             break;
       
   284             
       
   285 /*        case EPeninputLayoutEventLeftArrow:
       
   286             SimulateRawEvent(EStdKeyLeftArrow,TRawEvent::EKeyDown);
       
   287             SimulateRawEvent(EStdKeyLeftArrow,TRawEvent::EKeyUp);
       
   288             break;
       
   289 
       
   290         case EPeninputLayoutEventRightArrow:
       
   291             SimulateRawEvent(EStdKeyRightArrow,TRawEvent::EKeyDown);
       
   292             SimulateRawEvent(EStdKeyRightArrow,TRawEvent::EKeyUp);
       
   293             break;*/
       
   294             
       
   295         default:
       
   296             break;
       
   297         }
       
   298     }
       
   299     
       
   300 // --------------------------------------------------------------------------
       
   301 // CPeninputGenericVkbWindow::SimulateRawEvent
       
   302 // (other items were commented in a header)
       
   303 // --------------------------------------------------------------------------
       
   304 //
       
   305 void CPeninputGenericVkbWindow::SimulateRawEvent(TInt aScanCode, TRawEvent::TType aType)
       
   306     {
       
   307     TRawEvent event; 
       
   308     event.Set(aType,aScanCode);
       
   309     
       
   310     TPtrC eventPtr(reinterpret_cast<const TUint16*>(&event),sizeof(event)/sizeof(TUint16));
       
   311 
       
   312     UiLayout()->SignalOwner(ESignalSimulateEvent,eventPtr);
       
   313     }
       
   314 
       
   315 // --------------------------------------------------------------------------
       
   316 // CPeninputGenericVkbWindow::GetWindowConfigResId
       
   317 // (other items were commented in a header)
       
   318 // --------------------------------------------------------------------------
       
   319 //
       
   320 TInt CPeninputGenericVkbWindow::GetWindowConfigResId()
       
   321     {
       
   322     return R_PENINPUT_LAYOUT_CONFIG_INFO;
       
   323     }
       
   324 
       
   325 // --------------------------------------------------------------------------
       
   326 // CPeninputGenericVkbWindow::GetWindowResId
       
   327 // (other items were commented in a header)
       
   328 // --------------------------------------------------------------------------
       
   329 //
       
   330 TInt CPeninputGenericVkbWindow::GetWindowResId()
       
   331     {
       
   332     if ( iLayoutContext->LayoutType() == EPluginInputModeFSQ )
       
   333         {
       
   334         return R_PENINPUT_LAYOUT_FSQ_WINDOW_INFO;
       
   335         }
       
   336     return R_PENINPUT_LAYOUT_VKB_WINDOW_INFO;        
       
   337     }
       
   338 
       
   339 // --------------------------------------------------------------------------
       
   340 // CPeninputGenericVkbWindow::GetNumKeymappingResId
       
   341 // (other items were commented in a header)
       
   342 // --------------------------------------------------------------------------
       
   343 //
       
   344 TInt CPeninputGenericVkbWindow::GetNumKeymappingResId()
       
   345     {
       
   346     return R_PENINPUT_LAYOUT_KEY_MAPPING_STRING_LIST;
       
   347     }
       
   348 
       
   349 // --------------------------------------------------------------------------
       
   350 // CPeninputGenericVkbWindow::GetWindowConfigResFileName
       
   351 // (other items were commented in a header)
       
   352 // --------------------------------------------------------------------------
       
   353 //
       
   354 const TDesC& CPeninputGenericVkbWindow::GetWindowConfigResFileName( 
       
   355     TInt aLangID )
       
   356     {
       
   357     if ( aLangID <= 0 ) 
       
   358         {
       
   359         return KNullDesC;
       
   360         }
       
   361         
       
   362      if ( aLangID == ELangFrench )
       
   363         {
       
   364 
       
   365         TBuf<KMaxFileLength>  canadianfrenchresfilename; 
       
   366         canadianfrenchresfilename= KConfigurationResourceFile();
       
   367         canadianfrenchresfilename.AppendNum( ELangCanadianFrench );
       
   368         canadianfrenchresfilename.Append( KResourceFileExtName );
       
   369 
       
   370         RFile file;
       
   371         TInt rs = file.Open( CCoeEnv::Static()->FsSession(),canadianfrenchresfilename, EFileRead );
       
   372         if ( rs == KErrNone )
       
   373             {
       
   374             file.Close();
       
   375             aLangID = ELangCanadianFrench;   
       
   376             }
       
   377 
       
   378         }
       
   379     iResourceFilename.Zero();
       
   380     // Generate resource file name according to language id
       
   381     iResourceFilename = KConfigurationResourceFile();
       
   382     
       
   383     if ( aLangID < 10 )
       
   384         {
       
   385         iResourceFilename.AppendNum( 0 );
       
   386         iResourceFilename.AppendNum( aLangID );
       
   387         }
       
   388     else
       
   389         {
       
   390         iResourceFilename.AppendNum( aLangID );
       
   391         }
       
   392     iResourceFilename.Append( KResourceFileExtName );
       
   393     
       
   394     return iResourceFilename;
       
   395     }
       
   396 
       
   397 // --------------------------------------------------------------------------
       
   398 // CPeninputGenericVkbWindow::GetWindowResFileName
       
   399 // (other items were commented in a header)
       
   400 // --------------------------------------------------------------------------
       
   401 //
       
   402 const TDesC& CPeninputGenericVkbWindow::GetWindowResFileName()
       
   403     {
       
   404     return KVkbWindowResourceFile();
       
   405     }
       
   406 
       
   407 // --------------------------------------------------------------------------
       
   408 // CPeninputGenericVkbWindow::CreateAllControls
       
   409 // (other items were commented in a header)
       
   410 // --------------------------------------------------------------------------
       
   411 //
       
   412 void CPeninputGenericVkbWindow::CreateAllControlsL()
       
   413     {
       
   414     CFepLayoutMultiLineIcf* icf = static_cast<CFepLayoutMultiLineIcf*>
       
   415                                                    (Control(EPeninputWindowCtrlIdMultiLineICF));
       
   416     iBubbleSize = AknLayoutScalable_Apps::popup_char_count_window().LayoutLine();
       
   417     iBubbleTextLayout = AknLayoutScalable_Apps::popup_char_count_window_t1(0).LayoutLine();
       
   418     
       
   419     icf->MsgBubbleCtrl()->SetTextFormat(iBubbleTextLayout);
       
   420     icf->MsgBubbleCtrl()->SetTextColorIndex( EAknsCIQsnTextColorsCG67 );
       
   421     //Change the ID when ID into release
       
   422     icf->MsgBubbleCtrl()->SetBitmapParam(NULL,
       
   423     									  NULL,
       
   424     									  KAknsIIDQsnFrInputPreviewSideL,
       
   425     									  KAknsIIDQsnFrInputPreviewMiddle,
       
   426     									  KAknsIIDQsnFrInputPreviewSideR);  
       
   427     icf->InfoBubbleCtrl()->SetTextFormat(iBubbleTextLayout);
       
   428     icf->InfoBubbleCtrl()->SetTextColorIndex( EAknsCIQsnTextColorsCG67 );
       
   429     icf->InfoBubbleCtrl()->SetBitmapParam(NULL,
       
   430     									  NULL,
       
   431     									  KAknsIIDQsnFrInputPreviewSideL,
       
   432     									  KAknsIIDQsnFrInputPreviewMiddle,
       
   433     									  KAknsIIDQsnFrInputPreviewSideR);
       
   434     if (iLayoutContext->LayoutType() == EPluginInputModeFSQ)
       
   435         {
       
   436         icf->SetMsgBubbleCtrlSize(TSize(iBubbleSize.iW,iBubbleSize.iH));
       
   437         icf->SetInfoBubbleCtrlSize(TSize(iBubbleSize.iW,iBubbleSize.iH));
       
   438         }
       
   439         
       
   440     // Range bar
       
   441     AddRangeBarL();
       
   442 
       
   443     // Vkb control
       
   444     iVkbCtrl = CPeninputVkbCtrlExt::NewL( TRect(), UiLayout(), 
       
   445         EPeninutWindowCtrlIdVkbCtrl, NULL  );
       
   446     iVkbCtrl->SetResourceId( R_PENINPUT_LAYOUT_VKB_KEYBOARD );
       
   447     iVkbCtrl->ConstructFromResourceL();
       
   448     iVkbCtrl->SetKeyTextColorGroup( EAknsCIQsnTextColorsCG68 );
       
   449     iVkbLayout->SetVkbKeyboard( iVkbCtrl );
       
   450     if (iLayoutContext->LayoutType() != EPluginInputModeFSQ)
       
   451         {
       
   452         iVkbCtrl->SetIrregularKeyBoard(ETrue);
       
   453         iVkbLayout->SetIrregularResourceId(R_AKN_FEP_VKB_IRREGULAR_BITMAP);
       
   454         iVkbLayout->ConstructFromIrregularResourceL();
       
   455         }
       
   456     else
       
   457         {
       
   458         iVkbCtrl->SetIrregularKeyBoard(EFalse);
       
   459         iVkbLayout->SetNonIrregularResourceId(R_AKN_FEP_VKB_NONIRREGULAR_BITMAP);
       
   460         iVkbLayout->ConstructFromNonIrregularResourceL();        
       
   461         }
       
   462 
       
   463     // Add bubble support
       
   464     iVkbCtrl->ShowBubble(ETrue);    
       
   465     iVkbCtrl->SetGowithPointerDown(ETrue);
       
   466     iVkbCtrl->SetBubbleBitmapParam(NULL,NULL,KAknsIIDQsnFrInputCharPreview);  //Change the ID when ID into release
       
   467     
       
   468     //set key to be 9 piece graphics
       
   469     if ( iLayoutContext->LayoutType() == EPluginInputModeFSQ )
       
   470         {
       
   471         iVkbCtrl->SetKeySkinId( EKeyBmpNormal, KAknsIIDQsnFrKeypadButtonFrNormal );
       
   472         iVkbCtrl->SetKeySkinId( EKeyBmpHighlight, KAknsIIDQsnFrKeypadButtonFrPressed );
       
   473         iVkbCtrl->SetKeySkinId( EKeyBmpDim, KAknsIIDQsnFrKeypadButtonFrInactive );
       
   474         }
       
   475     
       
   476     AddControlL( iVkbCtrl );
       
   477     iVkbCtrl->AddEventObserver( UiLayout() );
       
   478     
       
   479     AddButtonL( EPeninutWindowCtrlIdEnterBtn, 
       
   480                 EPeninputLayoutEventEnter, 
       
   481                 R_PENINPUT_LAYOUT_VKB_ENTER, 
       
   482                 EKeyEnter );
       
   483        
       
   484     // Shift and capslock merged button
       
   485 
       
   486   	CAknFepCtrlMultiModeButton* button = 
       
   487   		CAknFepCtrlMultiModeButton::NewLC( UiLayout(), 
       
   488   										   EPeninutWindowCtrlIdShiftBtn );
       
   489     if ( button )
       
   490 	    {
       
   491 	    // Read resource
       
   492 	    TResourceReader reader;
       
   493 	    
       
   494 	    CCoeEnv::Static()->CreateResourceReaderLC( reader,
       
   495 	    	 			   R_PENINPUT_LAYOUT_VKB_SHIFT_CAPSLOCK );  
       
   496 	    button->SetResourceId( R_PENINPUT_LAYOUT_VKB_SHIFT_CAPSLOCK );      
       
   497 	    button->ConstructFromResourceL();  
       
   498 	    // Pop and destroy reader
       
   499 	    CleanupStack::PopAndDestroy( 1 );
       
   500 	    
       
   501 	    // Add into the control pool                                                   
       
   502 	    AddControlL( button );
       
   503 	    
       
   504 	    button->AddEventObserver( UiLayout() );
       
   505 	    }
       
   506     CleanupStack::Pop( button );  
       
   507     // Space button          
       
   508     CAknFepCtrlEventButton* spaceButton = static_cast<CAknFepCtrlEventButton*>
       
   509                                                    (Control(EPeninutWindowCtrlIdSpaceBtn));
       
   510     // Create 3-pieces color icon for space button
       
   511 	CPenInput3PiecesColorIcons* colorIcons = 
       
   512 				CPenInput3PiecesColorIcons::NewL( R_AKN_FEP_VKB_SPACE_ICON1,
       
   513 												  R_AKN_FEP_VKB_SPACE_ICON2,
       
   514 												  R_AKN_FEP_VKB_SPACE_ICON3 );
       
   515 	spaceButton->Set3PiecesColorIcons( colorIcons );
       
   516 
       
   517 	//set background of space button to be 9 piece graphics
       
   518 	if ( iLayoutContext->LayoutType() == EPluginInputModeFSQ )
       
   519 	    {
       
   520 	    spaceButton->SetImageFrameId( KAknsIIDQsnFrKeypadButtonFrNormal, 
       
   521 	                                  KAknsIIDQsnFrKeypadButtonFrPressed,
       
   522 	                                  KAknsIIDQsnFrKeypadButtonFrInactive );
       
   523 	    }
       
   524 	
       
   525     // Switch to hwr button  
       
   526     AddButtonL( EPeninutWindowCtrlIdSwitchToHwrBtn, 
       
   527                 EPeninputLayoutEventToHwr, 
       
   528                 R_PENINPUT_LAYOUT_VKB_HWR );
       
   529                   
       
   530     // Add popup window
       
   531     AddPopupWindowL();
       
   532   
       
   533     }
       
   534     
       
   535 // --------------------------------------------------------------------------
       
   536 // CPeninputGenericVkbWindow::ChangeUnitSize
       
   537 // (other items were commented in a header)
       
   538 // --------------------------------------------------------------------------
       
   539 //
       
   540 const TRect CPeninputGenericVkbWindow::ChangeUnitSize()
       
   541     {
       
   542     return TRect();
       
   543     }
       
   544 
       
   545 // --------------------------------------------------------------------------
       
   546 // CPeninputGenericVkbWindow::ChangeClientSize
       
   547 // (other items were commented in a header)
       
   548 // --------------------------------------------------------------------------
       
   549 //
       
   550 void CPeninputGenericVkbWindow::ChangeClientSize()
       
   551     {
       
   552     if ( !iPopupWnd->Hiden() )
       
   553         {
       
   554         iPopupWnd->CloseWindow();
       
   555         ResetAccentButton();
       
   556         iUiStateMgr->SetCurrentUiState( EPeninputVkbUiStateStandby );
       
   557         }
       
   558         
       
   559     PopupWindowSizeChange();
       
   560             
       
   561     TInt clientLayoutId = CPeninputDataConverter::AnyToInt
       
   562         ( iLayoutContext->RequestData( EPeninputDataTypeClientLayout ) );
       
   563     CPeninputClientLayoutInfo* clientLayout = 
       
   564         ConfigInfo()->FindClientLayoutInfo( clientLayoutId );
       
   565         
       
   566     if ( clientLayout )
       
   567         {
       
   568         ReorganizeControls( clientLayout->LayoutID(), EFalse );
       
   569         } 
       
   570 
       
   571     UpdateArea( iVkbCtrl->Rect(), EFalse );
       
   572     }
       
   573 void CPeninputGenericVkbWindow::SetVkbLayoutSize()
       
   574     {
       
   575     TRect outrect,innerrect;   
       
   576     iLafMgr->GetPreviewWndRect(outrect,innerrect);
       
   577     iVkbCtrl->SetTextFormat(iLafMgr->PreviewWndText());  //Read laf 
       
   578     iVkbCtrl->SetBubbleSize(TSize(outrect.Width(),outrect.Height()));  // Read laf
       
   579     iVkbCtrl->SetFrameDiff(innerrect.iTl.iX - outrect.iTl.iX,
       
   580                            innerrect.iTl.iY - outrect.iTl.iY,
       
   581                            outrect.iBr.iX - innerrect.iBr.iX,
       
   582                            outrect.iBr.iY - innerrect.iBr.iY);
       
   583     
       
   584     TInt vkbLayoutid = CPeninputDataConverter::AnyToInt
       
   585         ( iLayoutContext->RequestData( EPeninputDataTypeVkbLayout ) );
       
   586     CPeninputVkbLayoutInfo* vkbLayout = 
       
   587         ConfigInfo()->FindVkbLayoutInfo( vkbLayoutid );
       
   588 
       
   589     // Calculate current vkblayout according current layout
       
   590     if ( vkbLayout )
       
   591         {
       
   592         const TInt columns = vkbLayout->Columns();
       
   593         const TInt rows = vkbLayout->Rows();
       
   594         TRect keyRect;
       
   595         TRect charRect;
       
   596         
       
   597         //iLafMgr->SetLayoutType(iLafMgr->LayoutTypeFromRowsColumns(rows,columns));
       
   598         
       
   599  
       
   600         for (TInt exter = 0; exter < rows; exter ++)
       
   601             {
       
   602             for (TInt inter = 0; inter < columns; inter ++ )
       
   603                 {
       
   604                 iLafMgr->GetKeyRect(inter,exter, keyRect, charRect);
       
   605                 vkbLayout->SetKeyInfo(exter,inter,keyRect,charRect,iLafMgr->KeyTextFont());
       
   606                 }
       
   607             }
       
   608      
       
   609         if ( iVkbCtrl->IsIrregularKeyBoard() )
       
   610             {
       
   611             TSize curSize = vkbLayout->KeyInfoList()[0]->Key()->Rect().Size();
       
   612             TSize size = iVkbCtrl->IrregularKeyBitmap(EKeyLeftDown,
       
   613                                                       EKeyStateNormal)->SizeInPixels();
       
   614             if ( curSize != size )
       
   615                 {
       
   616                 for ( TInt i = 0; i <= EKeyRightUp; i++ )
       
   617                     {
       
   618                     for ( TInt j = 0; j <= EKeyStateDimmedMask; j++ )
       
   619                         {
       
   620                         AknIconUtils::SetSize( iVkbCtrl->IrregularKeyBitmap(
       
   621                             (TVirtualKeyIrregularKeyType)i,(TVirtualKeyIrregularKeyState)j), 
       
   622                              curSize, EAspectRatioNotPreserved ); 
       
   623                             
       
   624                         AknIconUtils::SetSize( iVkbCtrl->IrregularKeyBitmap(
       
   625                             (TVirtualKeyIrregularKeyType)i,(TVirtualKeyIrregularKeyState)j), 
       
   626                              curSize, EAspectRatioNotPreserved );
       
   627                         }
       
   628                     }
       
   629                 }
       
   630             }
       
   631         else
       
   632         	{
       
   633         	TSize curSize = vkbLayout->KeyInfoList()[0]->Key()->Rect().Size();
       
   634         	TSize size = iVkbCtrl->NonIrregularKeyBitmap(EKeyBmpNormal)->SizeInPixels();
       
   635         	if( curSize != size )	
       
   636         		{
       
   637                 for ( TInt i = 0; i <= EKeyBmpLastType; i++ )
       
   638                     {
       
   639                     if( iVkbCtrl->NonIrregularKeyBitmap((TVirtualKeyBmpType)i) )
       
   640                     	{
       
   641                         AknIconUtils::SetSize( 
       
   642                                            iVkbCtrl->NonIrregularKeyBitmap((TVirtualKeyBmpType)i), 
       
   643                                            curSize, EAspectRatioNotPreserved );
       
   644                     	}
       
   645                     }
       
   646         		}
       
   647         	}
       
   648         }
       
   649     }
       
   650 
       
   651 // --------------------------------------------------------------------------
       
   652 // CPeninputGenericVkbWindow::ReorganizeControls
       
   653 // (other items were commented in a header)
       
   654 // --------------------------------------------------------------------------
       
   655 //
       
   656 void CPeninputGenericVkbWindow::ReorganizeControls( TInt aClientLayoutId,
       
   657                                                     TBool aNeedReset )
       
   658     {
       
   659     CPeninputClientLayoutInfo* clientLayout = 
       
   660         ConfigInfo()->FindClientLayoutInfo( aClientLayoutId ); 
       
   661     RPointerArray<CPeninputControlInfo>& controlList = 
       
   662         clientLayout->ControlInfoList();
       
   663   
       
   664     const TInt keyColumns = clientLayout->Columns();
       
   665     const TInt keyRows = clientLayout->Rows();
       
   666     
       
   667     if( iLastUsedTotalColumns == keyColumns &&
       
   668     	iLastUsedTotalRows == keyRows )
       
   669 		{
       
   670 		return;
       
   671 		}    
       
   672 
       
   673     iLafMgr->SetLayoutType(iLafMgr->LayoutTypeFromRowsColumns(keyRows,keyColumns));
       
   674     
       
   675     iLastUsedTotalColumns = keyColumns;
       
   676     iLastUsedTotalRows = keyRows;
       
   677     
       
   678     TRect winRect( Rect().iTl, iLafMgr->EntirePaneRect().Size());
       
   679         
       
   680     SetWindowRect(winRect);  
       
   681     ReorgnizeTitleBar();
       
   682     
       
   683     const TInt count = controlList.Count();
       
   684     TInt controlID = 0;
       
   685     CFepUiBaseCtrl* ctrl = NULL;
       
   686     TRect rect;
       
   687     TRect inRect;
       
   688     TRect exRect;
       
   689 
       
   690     TPoint winPoint = Rect().iTl;
       
   691     TPoint LafPoint = iLafMgr->EntirePaneRect().iTl;
       
   692     
       
   693     TInt x = winPoint.iX - LafPoint.iX;
       
   694     TInt y = winPoint.iY - LafPoint.iY;
       
   695 
       
   696     if ( iLayoutContext->LayoutType() == EPluginInputModeFSQ )
       
   697         {
       
   698         x = 0;
       
   699         y = 0;
       
   700         }
       
   701     for ( TInt i = 0; i < count; i++ )
       
   702         {
       
   703         controlID = controlList[i]->ControlID();
       
   704         ctrl = Control( controlID );
       
   705 
       
   706         if ( ctrl )
       
   707             { 
       
   708             AddNotOwnedControl( ctrl );
       
   709             if ( ( ctrl->ControlType() | ECtrlButton ) == ECtrlButton )
       
   710                 {
       
   711                 
       
   712                 iLafMgr->GetButtonRect(TPeninputCommonCtrlID(ctrl->ControlId()),exRect ,inRect);
       
   713                 
       
   714                 exRect.Move(x, y);
       
   715                 inRect.Move(x, y);
       
   716                 if( controlID ==  EPeninutWindowCtrlIdShiftBtn)
       
   717 	                {
       
   718 					( static_cast<CAknFepCtrlMultiModeButton*> (ctrl) )->
       
   719 						SizeChanged( exRect, inRect, ETrue );		            	                	
       
   720 	                }
       
   721 	            else
       
   722 		            {
       
   723 		            if (TPeninputCommonCtrlID(ctrl->ControlId()) == EPeninutWindowCtrlIdSpaceBtn)
       
   724 		            	{
       
   725 		            	// config 3 pieces icon info       
       
   726 		            	TRect iconsFrameRect, middleIconRect;
       
   727 		            	iLafMgr->GetSpaceButtonExLayoutInfo( iconsFrameRect, middleIconRect );
       
   728 		            	iconsFrameRect.Move( x, y );
       
   729 		               	middleIconRect.Move( x, y );
       
   730 			            inRect = iconsFrameRect;
       
   731 			            
       
   732 						( static_cast<CAknFepCtrlCommonButton*> (ctrl) )->SetDraw3PieceFrameInfo(
       
   733 														  TDraw3PiecesFrame(KAknsIIDQgnIndiInputSpaceL,
       
   734     													  KAknsIIDQgnIndiInputSpaceMiddle,
       
   735     													  KAknsIIDQgnIndiInputSpaceR,
       
   736     													  middleIconRect));			            
       
   737 		            	}
       
   738 	                ( static_cast<CAknFepCtrlCommonButton*> (ctrl) )->SizeChanged( exRect, 
       
   739                                                                                  inRect, 
       
   740                                                                                  ETrue );
       
   741 		            }
       
   742                 }
       
   743             else if ( ctrl->ControlId() == EPeninutWindowCtrlIdVkbCtrl )
       
   744                 {
       
   745 				iVkbCtrl->SetFont( iLafMgr->KeyTextFont() );
       
   746 				iVkbCtrl->SetTextLineLayout( iLafMgr->KeyTextLayout() );
       
   747 			    iVkbCtrl->SetTextFormat( iLafMgr->PreviewWndText() );  //Read laf 
       
   748 				if (aNeedReset)
       
   749 			        {
       
   750 			        iVkbCtrl->Reset();
       
   751 			        }
       
   752     
       
   753                 rect = iLafMgr->KeypadRect();
       
   754                 
       
   755                 rect.Move(x, y);
       
   756 
       
   757                 ( static_cast<CPeninputVkbCtrlExt*> (ctrl) )->SizeChanged(rect);
       
   758                 }
       
   759                 
       
   760             else if ( ctrl->ControlId() == EPeninutWindowCtrlIdRangeBar )
       
   761                 {
       
   762                 TRAP_IGNORE(SetRangeBarSizeL(x, y));
       
   763                 }
       
   764             }
       
   765         }
       
   766 
       
   767     // Addition for ITI features, read LAF data for candidate list
       
   768     const TPeninputCandidateListLayoutData& candidateListLAF =    
       
   769                                         iLafMgr->CandidateListLayoutData();
       
   770     iCandidateList->SizeChanged( candidateListLAF.iSelectionItemSize, 
       
   771                                  candidateListLAF.iSelectionHorMargin,
       
   772                                  candidateListLAF.iSelectionVerMargin,
       
   773                                  candidateListLAF.iSelectionNaviSize,
       
   774                                  candidateListLAF.iSelectionNaviInnerSize );    
       
   775     iCandidateList->SetPageInfoTextLineLayout
       
   776                                 ( candidateListLAF.iSelectionPageTextLine );
       
   777     
       
   778     
       
   779     const CFont* itemFont = candidateListLAF.iFont;    
       
   780     TRgb textColor = CandidateListTextColor();
       
   781     if ( itemFont )
       
   782         {
       
   783         // Set font defined in LAF
       
   784         iCandidateList->SetTextProperty( itemFont, textColor );
       
   785         }
       
   786     else
       
   787         {
       
   788         // If font in LAF is NULL, set ICF text font to candidate list
       
   789         iCandidateList->SetTextProperty( iLafMgr->ICFTextFont(), textColor );
       
   790         }
       
   791     
       
   792     CFepLayoutMultiLineIcf* icf = static_cast<CFepLayoutMultiLineIcf*>
       
   793                                    (Control(EPeninputWindowCtrlIdMultiLineICF));
       
   794     if ( icf )
       
   795         {
       
   796         // read LAF data for tooltip box
       
   797         const TPeninputTooltipBoxLayoutData& tooltipBoxLAF 
       
   798                                           = iLafMgr->TooltipBoxLayoutData();
       
   799         icf->TooltipBubbleCtrl()->SetRect( tooltipBoxLAF.iRect );
       
   800         icf->TooltipBubbleCtrl()->SetTextFormat( tooltipBoxLAF.iTooltipTextLayout );
       
   801         icf->TooltipBubbleCtrl()->SetTextColorIndex( EAknsCIQsnTextColorsCG55 );
       
   802         icf->TooltipBubbleCtrl()->SetBitmapParam(NULL,
       
   803 									  NULL,
       
   804 									  KAknsIIDQsnFrInputPreviewSideL,
       
   805 									  KAknsIIDQsnFrInputPreviewMiddle,
       
   806 									  KAknsIIDQsnFrInputPreviewSideR);
       
   807         
       
   808         // read color from skin for autocompletion part
       
   809         icf->SetAutoCompleteTextColor( AutoCompletionPartColor() );        
       
   810         }       
       
   811     }
       
   812 
       
   813 void CPeninputGenericVkbWindow::SetRangeBarSizeL(TInt x, TInt y)
       
   814 	{
       
   815 	TRect exRect; 
       
   816     exRect = iLafMgr->RangbarRect();
       
   817     exRect.Move(x, y);
       
   818     // Get range bar display cell rects
       
   819 	TRect rect, innerRect;
       
   820 	RArray<TRect> displayCellRects, dispalyCellInnerRects;
       
   821 	CleanupClosePushL( displayCellRects );
       
   822 	CleanupClosePushL( dispalyCellInnerRects );
       
   823     for( TInt i = 0; i < iLafMgr->RangbarCellCount(); i++ )
       
   824     	{
       
   825     	iLafMgr->RangbarCellAt( i, rect, innerRect );
       
   826 		rect.Move(x, y);
       
   827 		displayCellRects.AppendL( rect );
       
   828 		innerRect.Move(x, y);
       
   829 		dispalyCellInnerRects.AppendL( innerRect );               	
       
   830     	}
       
   831 	iRangeBar->SetDispalyCellRectsL( displayCellRects, dispalyCellInnerRects );
       
   832 	CleanupStack::PopAndDestroy(2);
       
   833     iRangeBar->SizeChanged( exRect );
       
   834 	}
       
   835 
       
   836 // --------------------------------------------------------------------------
       
   837 // CPeninputGenericVkbWindow::SetControlsFont
       
   838 // (other items were commented in a header)
       
   839 // --------------------------------------------------------------------------
       
   840 //
       
   841 void CPeninputGenericVkbWindow::SetControlsFont()
       
   842     {
       
   843 /*    
       
   844     CFepLayoutMultiLineIcf* icf = static_cast<CFepLayoutMultiLineIcf*>(Control(EPeninputWindowCtrlIdMultiLineICF));
       
   845     
       
   846     const CFont* icfFont = iLafMgr->ICFTextFont();
       
   847     
       
   848     // set icf margin
       
   849     TPeninputICFConfig icfConfig;
       
   850     iLafMgr->GetICFConfig( icfConfig );
       
   851     icf->SetTextMargin( icfConfig.iLeftMargin,
       
   852     					icfConfig.iRightMargin,
       
   853     					icfConfig.iTopMargin,
       
   854     					0 );    			
       
   855     
       
   856     TRAP_IGNORE(icf->SizeChangedL( 
       
   857           		icf->Rect(), 
       
   858 				icfConfig.iTextLineHeight,
       
   859 				icfFont->FontMaxHeight(),
       
   860 				icfFont));
       
   861 */    
       
   862     }
       
   863 
       
   864 // --------------------------------------------------------------------------
       
   865 // CPeninputGenericVkbWindow::AddPopupWindowL
       
   866 // (other items were commented in a header)
       
   867 // --------------------------------------------------------------------------
       
   868 //
       
   869 void CPeninputGenericVkbWindow::AddPopupWindowL()
       
   870     {
       
   871     iPopupWnd = CPeninputCommonChoiceList::NewL( UiLayout(), 
       
   872         			EPeninutWindowCtrlIdAccentPopupWindow,
       
   873         			KAknsIIDQsnFrList,
       
   874         			KAknsIIDQsnFrPopupSub );
       
   875     
       
   876         
       
   877    
       
   878     iPopupWnd->AddEventObserver( UiLayout() );
       
   879     
       
   880     AddControlL( iPopupWnd );
       
   881     iIdle = CIdle::NewL(CActive::EPriorityIdle );
       
   882     iIdle ->Start(TCallBack(BackgroundTaskL,this));
       
   883     }
       
   884 
       
   885 // --------------------------------------------------------------------------
       
   886 // CPeninputGenericVkbWindow::PopupChoiceList
       
   887 // (other items were commented in a header)
       
   888 // --------------------------------------------------------------------------
       
   889 //
       
   890 void CPeninputGenericVkbWindow::PopupChoiceList()
       
   891     {
       
   892     CFepUiBaseCtrl* accentBtn = Control( EPeninutWindowCtrlIdAccentedBtn );
       
   893     
       
   894     if ( accentBtn )
       
   895         {
       
   896         if(!iPopupInited)
       
   897             TRAP_IGNORE(DoIdleConstructL());
       
   898         iPopupWnd->Display( accentBtn->Rect() );
       
   899         iUiStateMgr->SetCurrentUiState( EPeninputVkbUiStatePopup );
       
   900         }
       
   901     }
       
   902 
       
   903 // --------------------------------------------------------------------------
       
   904 // CPeninputGenericVkbWindow::ResetAccentButton
       
   905 // (other items were commented in a header)
       
   906 // --------------------------------------------------------------------------
       
   907 //
       
   908 void CPeninputGenericVkbWindow::ResetAccentButton()
       
   909     {
       
   910     TInt curRange = CPeninputDataConverter::AnyToInt
       
   911         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   912         
       
   913     if ( iRangeBar )
       
   914         {
       
   915         iRangeBar->ActiveRange( curRange );
       
   916         }        
       
   917     }
       
   918 
       
   919 // --------------------------------------------------------------------------
       
   920 // CPeninputGenericVkbWindow::PopupWindowSizeChange
       
   921 // (other items were commented in a header)
       
   922 // --------------------------------------------------------------------------
       
   923 //
       
   924 void CPeninputGenericVkbWindow::PopupWindowSizeChange()
       
   925     {
       
   926     if (CPeninputDataConverter::AnyToInt(
       
   927         iLayoutContext->RequestData(EAkninputDataTypeSizeChanging)) || (!iPopupSet))
       
   928     	{
       
   929     	// if size changing, or popup window's property has not been set yet
       
   930         TAknWindowLineLayout appWnd = AknLayoutScalable_Avkon::application_window(0).LayoutLine();
       
   931         iAppWndRect = appWnd.Rect();
       
   932     	
       
   933         TAknWindowLineLayout mainPane = AknLayoutScalable_Avkon::main_pane(4).LayoutLine();
       
   934         TAknLayoutRect mainPaneRect;
       
   935         mainPaneRect.LayoutRect(iAppWndRect, mainPane);
       
   936         
       
   937         TAknWindowLineLayout choiceWnd = 
       
   938                          AknLayoutScalable_Avkon::popup_choice_list_window(1).LayoutLine();
       
   939         TAknLayoutRect choiceRect;
       
   940         choiceRect.LayoutRect(mainPaneRect.Rect(), choiceWnd);
       
   941         
       
   942         iPopupItemRect = TRect(0, 0, choiceRect.Rect().Width(), 
       
   943                          AknLayoutScalable_Avkon::list_single_choice_list_pane(0).LayoutLine().iH);
       
   944         
       
   945         iChoiceTextLayout = 
       
   946                          AknLayoutScalable_Avkon::list_single_choice_list_pane_t1(1).LayoutLine();
       
   947     	}
       
   948     	
       
   949     const CFont* font = AknLayoutUtils::FontFromId(iChoiceTextLayout.iFont, NULL);
       
   950     iPopupWnd->SetFont(font);
       
   951     iPopupWnd->SetItemRect(iPopupItemRect, iPopupItemRect);
       
   952 
       
   953     TInt leftMargin = iChoiceTextLayout.il;
       
   954     
       
   955     iPopupWnd->SetMarginAndBaseline(leftMargin, font->HeightInPixels());
       
   956     
       
   957     iPopupWnd->SetFontColor(AKN_LAF_COLOR_STATIC(iChoiceTextLayout.iC));
       
   958 
       
   959     AknIconUtils::SetSize(iPopupWndBgImg, TSize(iPopupItemRect.Width(), 
       
   960                           iPopupItemRect.Height()*3), EAspectRatioNotPreserved);
       
   961     AknIconUtils::SetSize(iPopupWndFocusImg, TSize(iPopupItemRect.Width(), 
       
   962                           iPopupItemRect.Height()* 3), EAspectRatioNotPreserved);
       
   963     
       
   964     iPopupSet = ETrue;
       
   965     }
       
   966 
       
   967 
       
   968 // --------------------------------------------------------------------------
       
   969 // CPeninputGenericVkbWindow::GetPopupWndInfoFromRes
       
   970 // (other items were commented in a header)
       
   971 // --------------------------------------------------------------------------
       
   972 //
       
   973 void CPeninputGenericVkbWindow::GetPopupWndInfoFromResL( TResourceReader aRes,
       
   974                                                         const TRect& aRect )
       
   975     {
       
   976     TPtrC bmpFileName = aRes.ReadTPtrC();        
       
   977     TInt32 imgMajorSkinId = aRes.ReadInt32();
       
   978 
       
   979     TAknsItemID id;
       
   980     
       
   981     MAknsSkinInstance* skininstance = AknsUtils::SkinInstance();
       
   982 
       
   983     TInt popWinBmpId = aRes.ReadInt16();
       
   984     TInt popWinBmpMaskId = aRes.ReadInt16();
       
   985     TInt popWinBmpSkinId = aRes.ReadInt16();
       
   986     
       
   987     id.Set( TInt( imgMajorSkinId ), popWinBmpSkinId );
       
   988     
       
   989     if ( popWinBmpId != KInvalidImg )
       
   990     	{
       
   991         AknsUtils::CreateIconL( skininstance,
       
   992                                 id,
       
   993                                 iPopupWndBgImg,
       
   994                                 bmpFileName,
       
   995                                 popWinBmpId );
       
   996             
       
   997     	AknIconUtils::SetSize( iPopupWndBgImg, TSize( aRect.Width(), 
       
   998             aRect.Height() * 3 ), EAspectRatioNotPreserved );
       
   999         iPopupWnd->SetBackgroundBitmapL( iPopupWndBgImg );
       
  1000     	}
       
  1001     	
       
  1002     TInt focusBmpId = aRes.ReadInt16();
       
  1003     TInt focusBmpMaskId = aRes.ReadInt16();
       
  1004     TInt focusBmpSkinId = aRes.ReadInt16();
       
  1005 
       
  1006     id.Set( TInt( imgMajorSkinId ), focusBmpSkinId );
       
  1007     
       
  1008     if ( focusBmpId != KInvalidImg )
       
  1009     	{
       
  1010         AknsUtils::CreateIconL( skininstance,
       
  1011                                 id,
       
  1012                                 iPopupWndFocusImg,
       
  1013                                 bmpFileName,
       
  1014                                 focusBmpId );
       
  1015 
       
  1016     	AknIconUtils::SetSize( iPopupWndFocusImg, TSize( aRect.Width(), 
       
  1017             aRect.Height() * 3 ), EAspectRatioNotPreserved );
       
  1018         iPopupWnd->SetFocusBmp( iPopupWndFocusImg );
       
  1019     	}
       
  1020     }
       
  1021       
       
  1022 // --------------------------------------------------------------------------
       
  1023 // CAknFepVkbClientArea::AddRangeBarL
       
  1024 // (other items were commented in a header)
       
  1025 // --------------------------------------------------------------------------
       
  1026 //
       
  1027 void CPeninputGenericVkbWindow::AddRangeBarL()
       
  1028     {
       
  1029     // Range bar
       
  1030     iRangeBar = CAknFepCtrlRangeBar::NewL( UiLayout(),
       
  1031         EPeninutWindowCtrlIdRangeBar, 
       
  1032         CAknFepCtrlRangeBar::EBtnGroupHorizontal );
       
  1033 
       
  1034     // Set event id    
       
  1035     iRangeBar->SetEventIdForRange( EPeninputLayoutEventRange );
       
  1036     iRangeBar->SetEventIdForCase( EPeninputLayoutEventRangeLoop );
       
  1037 
       
  1038     AddControlL( iRangeBar );
       
  1039     iRangeBar->AddEventObserver(UiLayout());    
       
  1040     }
       
  1041     
       
  1042 // --------------------------------------------------------------------------
       
  1043 // CPeninputGenericVkbWindow::AddButtonL
       
  1044 // (other items were commented in a header)
       
  1045 // --------------------------------------------------------------------------
       
  1046 //
       
  1047 CAknFepCtrlEventButton* CPeninputGenericVkbWindow::AddButtonL( 
       
  1048     const TInt aControlId, const TInt aEventId, const TInt aResId, 
       
  1049     const TInt aUnicode, const TBool aIsRepeat )
       
  1050     {
       
  1051     CAknFepCtrlEventButton* button = NULL;
       
  1052     
       
  1053     if ( aIsRepeat )
       
  1054         {
       
  1055         button = CAknFepCtrlRepeatButton::NewL( UiLayout(), aControlId, 
       
  1056             aEventId, aUnicode );
       
  1057         }
       
  1058     else
       
  1059         {
       
  1060         button = CAknFepCtrlEventButton::NewL( UiLayout(), aControlId, 
       
  1061             aEventId, aUnicode,
       
  1062 			  KAknsIIDQsnFrFunctionButtonNormal,
       
  1063 			  KAknsIIDQsnFrFunctionButtonPressed,
       
  1064 			  KAknsIIDQsnFrFunctionButtonInactive );
       
  1065         }
       
  1066         
       
  1067     CleanupStack::PushL( button );  
       
  1068     if ( button )
       
  1069         {
       
  1070         // Read resource
       
  1071         TResourceReader reader;
       
  1072         
       
  1073         CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId );  
       
  1074         button->SetResourceId( aResId );      
       
  1075         button->ConstructFromResourceL();  
       
  1076         // Pop and destroy reader
       
  1077         CleanupStack::PopAndDestroy( 1 );
       
  1078         
       
  1079         // Add into the control pool                                                   
       
  1080         AddControlL( button );
       
  1081         button->AddEventObserver(UiLayout());
       
  1082         
       
  1083         }
       
  1084     CleanupStack::Pop( button );  
       
  1085     	  
       
  1086     return button;
       
  1087     }
       
  1088 
       
  1089 // --------------------------------------------------------------------------
       
  1090 // CPeninputGenericVkbWindow::DoCaseChange
       
  1091 // (other items were commented in a header)
       
  1092 // --------------------------------------------------------------------------
       
  1093 //
       
  1094 void CPeninputGenericVkbWindow::DoCaseChange( TInt aNewCase )
       
  1095     {
       
  1096     TInt curCase = CPeninputDataConverter::AnyToInt
       
  1097         ( iLayoutContext->RequestData( EPeninputDataTypeCase ) );            
       
  1098     
       
  1099     if ( aNewCase == curCase )
       
  1100         {
       
  1101         return;
       
  1102         }
       
  1103         
       
  1104     TInt curRange = CPeninputDataConverter::AnyToInt
       
  1105         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) ); 
       
  1106                                
       
  1107     if ((( curRange == ERangeAccent ) || ( ( curRange == ERangeEnglish ) 
       
  1108             || ( ( curRange == ERangeNative ) && ( ConfigInfo()->CaseSensitive()) ) ) ) )
       
  1109         {
       
  1110         // Set shift and caplock button
       
  1111         TInt shfit;  
       
  1112         TInt capslock;  
       
  1113         
       
  1114         CPeninputDataConverter::ShiftCapslockByCase( aNewCase, 
       
  1115             shfit, capslock );
       
  1116 
       
  1117         iLayoutContext->SetData( EPeninputDataTypeShiftDown, &shfit );
       
  1118         //ChangeButtonStatus( shfit, EPeninutWindowCtrlIdShiftBtn );          
       
  1119         iLayoutContext->SetData( EPeninputDataTypeCapslockDown, &capslock );        
       
  1120         //ChangeButtonStatus( capslock, EPeninutWindowCtrlIdCapslockBtn );
       
  1121         iLayoutContext->SetData( EPeninputDataTypeCase, &aNewCase ); 
       
  1122         ChangeMergedButtonStatus( shfit, capslock );
       
  1123         
       
  1124         TInt vkblayout = ConfigInfo()->ShiftCapsSingleVkbLayoutByCase
       
  1125             ( curRange, aNewCase );
       
  1126 
       
  1127         if ( curRange == ERangeAccent ) 
       
  1128            {
       
  1129            TInt curAccentIndex = CPeninputDataConverter::AnyToInt
       
  1130                ( iLayoutContext->RequestData( EPeninputDataTypeCurrentAccent ) );
       
  1131                  vkblayout = vkblayout + curAccentIndex * 2;
       
  1132            }
       
  1133         
       
  1134         ChangeVkbLayout( vkblayout );
       
  1135         }
       
  1136     }
       
  1137 
       
  1138 // ---------------------------------------------------------------------------
       
  1139 // CPeninputGenericVkbWindow::BackgroundConstructL
       
  1140 // Do background construct.
       
  1141 // ---------------------------------------------------------------------------
       
  1142 //
       
  1143 TInt CPeninputGenericVkbWindow::BackgroundTaskL(TAny* aPtr)
       
  1144     {
       
  1145     CPeninputGenericVkbWindow* self = static_cast<CPeninputGenericVkbWindow*>(aPtr);
       
  1146     self->DoIdleConstructL();
       
  1147     return EFalse; // only run once
       
  1148     }
       
  1149 
       
  1150 
       
  1151 void CPeninputGenericVkbWindow::DoIdleConstructL()
       
  1152     {   
       
  1153     if(iPopupInited)
       
  1154         return;
       
  1155     
       
  1156 
       
  1157     // Read resource
       
  1158     TResourceReader reader;
       
  1159     
       
  1160     CCoeEnv::Static()->CreateResourceReaderLC( reader, 
       
  1161         R_PENINPUT_LAYOUT_VKB_POPUP_WINDOW ); 
       
  1162         
       
  1163     GetPopupWndInfoFromResL(reader, iPopupItemRect);    
       
  1164        
       
  1165     // Pop and destroy reader
       
  1166     CleanupStack::PopAndDestroy( 1 );
       
  1167 
       
  1168     }
       
  1169     
       
  1170 // -----------------------------------------------------------------------------
       
  1171 // CPeninputGenericVkbWindow::ConstructFromResourceL
       
  1172 // (other items were commented in a header).
       
  1173 // -----------------------------------------------------------------------------
       
  1174 //
       
  1175 void CPeninputGenericVkbWindow::ConstructFromResourceL()
       
  1176     {     	        
       
  1177     CPeninputLayoutWindowExt::ConstructFromResourceL();
       
  1178     if( iVkbLayout && !iFirstConstruct )
       
  1179     	{
       
  1180     	if( iVkbCtrl->IsIrregularKeyBoard() )    	
       
  1181     		iVkbLayout->ConstructFromIrregularResourceL();
       
  1182     	else
       
  1183     		iVkbLayout->ConstructFromNonIrregularResourceL();
       
  1184     	SetVkbLayoutSize();
       
  1185     	
       
  1186     	if( IsRtoLLanguage( iLanguage ) )
       
  1187     		{
       
  1188 			//Mirror backspace graphic
       
  1189 			HandleButtonResOnLangDirChange( EPeninutWindowCtrlIdBackspaceBtn );    			
       
  1190     		}
       
  1191     	}
       
  1192     	
       
  1193     iFirstConstruct = EFalse;
       
  1194     }
       
  1195     
       
  1196 // -----------------------------------------------------------------------------
       
  1197 // CPeninputGenericVkbWindow::SetSwitchlistLanguage
       
  1198 // (other items were commented in a header).
       
  1199 // -----------------------------------------------------------------------------
       
  1200 //
       
  1201 void  CPeninputGenericVkbWindow::SetSwitchlistLanguage(TInt aLang)
       
  1202     {
       
  1203     ASSERT( IsValidLanguage( aLang ) );
       
  1204     //Check language input direction change
       
  1205     TBool isLangDirectionChange = EFalse;
       
  1206     if( IsValidLanguage( iLanguage ) )
       
  1207     	isLangDirectionChange =  IsRtoLLanguage( aLang ) ^ IsRtoLLanguage( iLanguage );    
       
  1208     else
       
  1209     	isLangDirectionChange = IsRtoLLanguage( aLang );
       
  1210     
       
  1211     if( aLang ==ELangHebrew || 
       
  1212 	    aLang == ELangGreek ||
       
  1213 		aLang == ELangHindi ||
       
  1214 		aLang == ELangMarathi ) 
       
  1215 		{
       
  1216 		iLafMgr->SetLafOption( (TPeninputVkbLafOption)
       
  1217 							   ( iLafMgr->OptionType() &(~EOption3CellRange) ) );	
       
  1218 		}
       
  1219 	else
       
  1220 		{
       
  1221 		iLafMgr->SetLafOption( (TPeninputVkbLafOption)
       
  1222 				   ( iLafMgr->OptionType() | EOption3CellRange) );	
       
  1223 		}
       
  1224 			
       
  1225 	if( isLangDirectionChange )
       
  1226 		{
       
  1227 		//Mirror backspace graphic
       
  1228 		HandleButtonResOnLangDirChange( EPeninutWindowCtrlIdBackspaceBtn );
       
  1229 		}
       
  1230 			
       
  1231 	iLanguage = aLang;	
       
  1232     }
       
  1233 
       
  1234 // -----------------------------------------------------------------------------
       
  1235 // CPeninputGenericVkbWindow::SetSwitchlistSecretFlag
       
  1236 // (other items were commented in a header).
       
  1237 // -----------------------------------------------------------------------------
       
  1238 //    
       
  1239 void  CPeninputGenericVkbWindow::SetSwitchlistSecretFlag(TBool aSecret)
       
  1240     {
       
  1241 	static_cast<CPeninputLayoutInputmodelChoice*>
       
  1242 	    	(Control(EPeninutWindowCtrlIdSwitcherPopupWindow))->SetSecretEditor(aSecret);    
       
  1243 	//disable or enable arrow keys of FSQ in secret editor.    	
       
  1244     }
       
  1245     
       
  1246 // ---------------------------------------------------------------------------
       
  1247 // CPeninputGenericVkbWindow::DimArrowKeys
       
  1248 // (other items were commented in a header).
       
  1249 // ---------------------------------------------------------------------------
       
  1250 //
       
  1251 void CPeninputGenericVkbWindow::DimArrowKeys( TBool aDimArrow )
       
  1252     {
       
  1253     if(iLayoutContext->LayoutType() == EPluginInputModeFSQ 
       
  1254        && iArrowLeftButton && iArrowRightButton)
       
  1255         {
       
  1256         iArrowLeftButton->SetDimmed( aDimArrow );
       
  1257         iArrowRightButton->SetDimmed( aDimArrow );
       
  1258         }	    	
       
  1259     }
       
  1260 
       
  1261 // ---------------------------------------------------------------------------
       
  1262 // CAknFepVkbWindow::PopupAccentWindow
       
  1263 // (other items were commented in a header).
       
  1264 // ---------------------------------------------------------------------------
       
  1265 //
       
  1266 void CPeninputGenericVkbWindow::PopupSwitchWindowL()
       
  1267     {
       
  1268     CFepUiBaseCtrl* accentBtn = Control(EPeninutWindowCtrlIdSwitchToHwrBtn);
       
  1269 
       
  1270     if ( accentBtn )
       
  1271         {
       
  1272         if (!iPopupInited)
       
  1273             {
       
  1274         	  DoIdleConstructL();
       
  1275             }
       
  1276         TRect rect = accentBtn->Rect();   
       
  1277 		static_cast<CPeninputLayoutInputmodelChoice*>
       
  1278 		    	(Control(EPeninutWindowCtrlIdSwitcherPopupWindow))->PopUpSwitchListL( accentBtn->Rect() );
       
  1279         }         
       
  1280     }
       
  1281 
       
  1282 // ---------------------------------------------------------------------------
       
  1283 // CPeninputGenericVkbWindow::SetDeadKey
       
  1284 // (Set DeadKey)
       
  1285 // ---------------------------------------------------------------------------
       
  1286 //     
       
  1287 void CPeninputGenericVkbWindow::SetDeadKey()
       
  1288     {
       
  1289     // Get VKB list
       
  1290     RPointerArray<CPeninputVkbLayoutInfo> vkbListInfo;
       
  1291     vkbListInfo = iVkbLayout->VkbLayoutInfoList();
       
  1292     TInt vkbListNum = vkbListInfo.Count();
       
  1293     
       
  1294     CPeninputVkbKeyInfo* pVKBKeyInfo;
       
  1295     CVirtualKey* pKey;
       
  1296     TInt count = sizeof(KSupportLanguages)/sizeof(TLangMeritPair);
       
  1297     for(TInt i = 0; i < vkbListNum; i++)
       
  1298         {
       
  1299         for(TInt j = 0; j < count; j++)
       
  1300             {
       
  1301             if(vkbListInfo[i]->LayoutID() == EPeninputVkbLayoutNativeChar ||
       
  1302                vkbListInfo[i]->LayoutID() == EPeninputVkbLayoutNativeCharShift)
       
  1303                 {
       
  1304                 pVKBKeyInfo = vkbListInfo[i]->FindKey( KSupportLanguages[j].iDeadKey );
       
  1305                 if(pVKBKeyInfo)
       
  1306                     {
       
  1307                     // Set the DeadKey as a latch button
       
  1308                     pKey = pVKBKeyInfo->Key();
       
  1309                     pKey->SetLatchKey(ETrue);
       
  1310                     }
       
  1311                 }
       
  1312             }
       
  1313         }
       
  1314     }
       
  1315     
       
  1316     
       
  1317 // ---------------------------------------------------------------------------
       
  1318 // CPeninputGenericVkbWindow::UnLatchDeadKey
       
  1319 // (Unlatch the DeadKey)
       
  1320 // ---------------------------------------------------------------------------
       
  1321 //     
       
  1322 void CPeninputGenericVkbWindow::UnLatchDeadKey( const TDesC& abuf )
       
  1323     {
       
  1324     RPointerArray<CPeninputVkbLayoutInfo> vkbListInfo;
       
  1325     vkbListInfo = iVkbLayout->VkbLayoutInfoList();
       
  1326     TInt vkbListNum = vkbListInfo.Count();
       
  1327     
       
  1328     CPeninputVkbKeyInfo* pVKBKeyInfo;
       
  1329     CVirtualKey* pKey;
       
  1330     TInt count = sizeof(KSupportLanguages)/sizeof(TLangMeritPair);
       
  1331     for(TInt i = 0; i < vkbListNum; i++)
       
  1332         {
       
  1333         for(TInt j = 0; j < count; j++)
       
  1334             {
       
  1335             // Only NativeChar and NativeCharShift layout contain DeadKey
       
  1336             if(vkbListInfo[i]->LayoutID() == EPeninputVkbLayoutNativeChar ||
       
  1337                vkbListInfo[i]->LayoutID() == EPeninputVkbLayoutNativeCharShift)
       
  1338                 {
       
  1339                 // Find the DeadKey in NativeChar or NativeCharShift layout
       
  1340                 pVKBKeyInfo = vkbListInfo[i]->FindKey( KSupportLanguages[j].iDeadKey );
       
  1341                 if(pVKBKeyInfo)
       
  1342                     {
       
  1343                     pKey = pVKBKeyInfo->Key();
       
  1344                     if(pKey->Latched())
       
  1345                         {
       
  1346                         if(abuf == KNullDesC)
       
  1347                             {
       
  1348                             // When focus change, the latched key will be released
       
  1349                             TBool deadKeyChange = EFalse;
       
  1350                             iLayoutContext->SetData(EAkninputDataTypeLatchedSet, &deadKeyChange);
       
  1351                             pKey->SetLatched(EFalse);
       
  1352                             TRect rect = pKey->Rect();
       
  1353                             rect.Move( iVkbCtrl->Rect().iTl );
       
  1354                             UpdateArea( rect, EFalse ); 
       
  1355                             return;
       
  1356                             }
       
  1357                         if(abuf[0] == KSupportLanguages[j].iDeadKey)
       
  1358                             {
       
  1359                             // When another DeadKey is clicked, the old one will be released
       
  1360                             pKey->SetLatched(EFalse);
       
  1361                             TRect rect = pKey->Rect();
       
  1362                             rect.Move( iVkbCtrl->Rect().iTl );
       
  1363                             UpdateArea( rect, EFalse ); 
       
  1364                             return;
       
  1365                             }
       
  1366                         }
       
  1367                     }
       
  1368                 }
       
  1369             }
       
  1370         }
       
  1371     }
       
  1372 
       
  1373 // ---------------------------------------------------------------------------
       
  1374 // CPeninputGenericVkbWindow::HandleAccentCharEvent
       
  1375 // (Unlatch the DeadKey)
       
  1376 // ---------------------------------------------------------------------------
       
  1377 //     
       
  1378 TBool CPeninputGenericVkbWindow::HandleAccentCharEvent( TInt /*aEventType*/, 
       
  1379                                                     const TDesC& aEventData, 
       
  1380                                                     const TDesC& aDeadKey, 
       
  1381                                                     HBufC* anewCharBuf )
       
  1382     {
       
  1383     // Get the unicode of virtual key char
       
  1384     TBuf<16> buf;
       
  1385     TKeyEvent* event = (TKeyEvent*) aEventData.Ptr();
       
  1386     buf.Append(event->iCode);
       
  1387     TBool rs = EFalse;
       
  1388     
       
  1389     // Caculate the accent char number
       
  1390     TInt count = sizeof(KSupportLanguages)/sizeof(TLangMeritPair);
       
  1391     TInt i = 0; 
       
  1392     if(aDeadKey.Compare( KNullDesC ) != 0) // One DeadKey is latched
       
  1393         {
       
  1394         for(i = 0; i < count; i++)
       
  1395             {
       
  1396             if((aDeadKey[0] == KSupportLanguages[i].iDeadKey) && 
       
  1397                (buf[0] == KSupportLanguages[i].iChar))
       
  1398                 {
       
  1399                 if(anewCharBuf)
       
  1400                     {                    
       
  1401                     anewCharBuf->Des().Append(KSupportLanguages[i].iAccentedChar);
       
  1402                     rs = ETrue;
       
  1403                     }
       
  1404                 break;
       
  1405                 }
       
  1406             }
       
  1407         }
       
  1408     return rs;
       
  1409     }
       
  1410     
       
  1411  
       
  1412 // ---------------------------------------------------------------------------
       
  1413 // CPeninputGenericVkbWindow::HandleVirtualKeyLatchedEvent
       
  1414 // (Handle virtual key latched event).
       
  1415 // ---------------------------------------------------------------------------
       
  1416 //
       
  1417 void CPeninputGenericVkbWindow::HandleVirtualKeyLatchedEvent(TInt /*aEventType*/, 
       
  1418                                                          CFepUiBaseCtrl* /*aCtrl*/, 
       
  1419                                                          const TDesC& aEventData )
       
  1420     {
       
  1421     TBuf<16> deadKey(KNullDesC);
       
  1422     TKeyEvent* event = (TKeyEvent*) aEventData.Ptr();
       
  1423     deadKey.Append(event->iCode);
       
  1424 
       
  1425     CPeninputGenericVkbLayout* layout 
       
  1426                                   = static_cast<CPeninputGenericVkbLayout*>( UiLayout() );                                  
       
  1427     TInt latchedFlag = CPeninputDataConverter::AnyToInt(
       
  1428                        iLayoutContext->RequestData(EAkninputDataTypeLatchedSet));
       
  1429     if(latchedFlag)
       
  1430         {
       
  1431         // Update the new and old DeadKey buffer
       
  1432         iOldDeadKeyBuf = iNewDeadKeyBuf;
       
  1433         iNewDeadKeyBuf = deadKey;
       
  1434 
       
  1435         // When type another DeadKey, submit the previous one.
       
  1436      	if ( layout->IsEnableITIOnFSQ() )
       
  1437      		{
       
  1438      		UiLayout()->SignalOwner( ESignalKeyEvent, iNewDeadKeyBuf );
       
  1439      		}
       
  1440      	else
       
  1441      		{
       
  1442      		UiLayout()->SignalOwner( ESignalKeyEvent, iOldDeadKeyBuf );
       
  1443      		}        
       
  1444         // Unlatch the previous DeadKey
       
  1445         UnLatchDeadKey(iOldDeadKeyBuf);
       
  1446         
       
  1447 
       
  1448         }
       
  1449     else
       
  1450         {
       
  1451         iNewDeadKeyBuf = deadKey;
       
  1452         
       
  1453         // Set DeadKey state to latched
       
  1454         TBool deadKeyChange = ETrue;
       
  1455         iLayoutContext->SetData(EAkninputDataTypeLatchedSet, &deadKeyChange);
       
  1456         
       
  1457      	if ( layout->IsEnableITIOnFSQ() )
       
  1458      		{
       
  1459      		UiLayout()->SignalOwner( ESignalKeyEvent, iNewDeadKeyBuf );
       
  1460      		}
       
  1461         }
       
  1462    
       
  1463     // Send the char to FEP
       
  1464     // Not submit the DeadKey when latch it.
       
  1465 //    UiLayout()->SignalOwner( ESignalKeyEvent, iNewDeadKeyBuf );
       
  1466     }
       
  1467 
       
  1468 // ---------------------------------------------------------------------------
       
  1469 // CPeninputCommonLayout::HandleVirtualKeyUpEvent
       
  1470 // (Handle virtual key up event).
       
  1471 // ---------------------------------------------------------------------------
       
  1472 //
       
  1473 TBool CPeninputGenericVkbWindow::HandleVirtualKeyUpEvent(TInt aEventType, 
       
  1474                                                     CFepUiBaseCtrl* /*aCtrl*/, 
       
  1475                                                     const TDesC& aEventData )
       
  1476     {
       
  1477     // Get DeadKey state
       
  1478     TInt latchedFlag = CPeninputDataConverter::AnyToInt(
       
  1479                        iLayoutContext->RequestData(EAkninputDataTypeLatchedSet));
       
  1480     if(latchedFlag)
       
  1481         {
       
  1482         TBool ret = EFalse;
       
  1483         
       
  1484         TRAP_IGNORE(ret = HandleDeadKeyL(aEventType,aEventData))
       
  1485         
       
  1486         if(ret)
       
  1487         	{
       
  1488         	return ETrue;	
       
  1489         	}
       
  1490         else
       
  1491             {
       
  1492             // When the DeadKey can not combine with current character,
       
  1493             // Sumit current DeadKey
       
  1494             UiLayout()->SignalOwner( ESignalKeyEvent, iNewDeadKeyBuf );
       
  1495             }
       
  1496         }
       
  1497         
       
  1498     iNewDeadKeyBuf = KNullDesC;
       
  1499     return EFalse;
       
  1500     } 
       
  1501  
       
  1502  TBool CPeninputGenericVkbWindow::HandleDeadKeyL(TInt aEventType, 
       
  1503                                                  const TDesC& aEventData )
       
  1504  	{
       
  1505     // Set DeadKey to unlatched state
       
  1506     TBool deadKeyChange = EFalse;
       
  1507     iLayoutContext->SetData(EAkninputDataTypeLatchedSet, &deadKeyChange);
       
  1508     UnLatchDeadKey(iNewDeadKeyBuf);
       
  1509 
       
  1510     CPeninputGenericVkbLayout* layout 
       
  1511                       = static_cast<CPeninputGenericVkbLayout*>( UiLayout() );
       
  1512  	if ( layout->IsEnableITIOnFSQ() )
       
  1513  		{
       
  1514  	    TBuf<KKeyCodeSize> buf;
       
  1515  	    TKeyEvent* event = (TKeyEvent*) aEventData.Ptr();
       
  1516  	    buf.Append(event->iCode); 	    
       
  1517  		UiLayout()->SignalOwner( ESignalKeyEvent, buf );
       
  1518  		return ETrue;
       
  1519  		}
       
  1520  	
       
  1521     // Get the accent char
       
  1522     HBufC* newCharBuf = HBufC::NewL(1);
       
  1523     if(HandleAccentCharEvent(aEventType, 
       
  1524                              aEventData, 
       
  1525                              iNewDeadKeyBuf, 
       
  1526                              newCharBuf))
       
  1527         {
       
  1528         // Send ths accent key to FEP
       
  1529         UiLayout()->SignalOwner( ESignalKeyEvent, *newCharBuf);
       
  1530         iNewDeadKeyBuf = KNullDesC;
       
  1531         delete newCharBuf;
       
  1532         return ETrue;
       
  1533         }
       
  1534     delete newCharBuf;
       
  1535     
       
  1536     return EFalse; 		
       
  1537  	}
       
  1538  
       
  1539 void CPeninputGenericVkbWindow::SetLafLayOut(TInt aRows, TInt aColumns)
       
  1540     {
       
  1541     iLafMgr->SetLayoutType(iLafMgr->LayoutTypeFromRowsColumns(aRows,aColumns));
       
  1542     }
       
  1543 
       
  1544     
       
  1545 void CPeninputGenericVkbWindow::AddCustomControlGroupL(CFepUiBaseCtrl* aCtrl)
       
  1546 	{
       
  1547 	AddControlL(aCtrl);
       
  1548 	}    
       
  1549 
       
  1550 TBool CPeninputGenericVkbWindow::CreateCustomControlL( TInt16 aControlId, TInt32 aImageId )
       
  1551 	{
       
  1552 	TBool create = ETrue;
       
  1553     switch ( aControlId )
       
  1554         {
       
  1555         case EPeninutWindowCtrlIdMoveBtn:
       
  1556             {
       
  1557             if ( !iMoveButton )
       
  1558                 {
       
  1559                 iMoveButton = CAknFepCtrlDragButton::NewL(UiLayout(), EPeninutWindowCtrlIdMoveBtn);
       
  1560                 AddControlL(iMoveButton);
       
  1561                 iMoveButton->AddPositionObserver(this);
       
  1562                 iMoveButton->AddEventObserver( UiLayout() );
       
  1563                 iMoveButton->SetResourceId( aImageId );
       
  1564                 iMoveButton->SetImageFrameId(KAknsIIDQsnFrFunctionButtonNormal,
       
  1565         									  KAknsIIDQsnFrFunctionButtonPressed,
       
  1566         									  KAknsIIDQsnFrFunctionButtonInactive);
       
  1567                 UiLayout()->EnableLayoutMoving( static_cast<CDragBar*>( iMoveButton ) );
       
  1568                 }
       
  1569             iMoveButton->ConstructFromResourceL();
       
  1570             }
       
  1571             break;
       
  1572         case EPeninupWindowCtrlIdArrowLeftBtn:
       
  1573             {
       
  1574             if ( iLayoutContext->LayoutType() != EPluginInputModeFSQ )
       
  1575                 {
       
  1576                 break;
       
  1577                 }
       
  1578 
       
  1579             if (!iArrowLeftButton)
       
  1580                 {
       
  1581                 
       
  1582 	            iArrowLeftButton = CAknFepCtrlRepeatButton::NewL( 
       
  1583 	                UiLayout(), aControlId, EPeninputLayoutEventLeftArrow, EKeyLeftArrow, 
       
  1584 	            								  KAknsIIDQsnFrFunctionButtonNormal,
       
  1585 	        									  KAknsIIDQsnFrFunctionButtonPressed,
       
  1586 	        									  KAknsIIDQsnFrFunctionButtonInactive );
       
  1587 
       
  1588                 AddControlL(iArrowLeftButton);
       
  1589                 iArrowLeftButton->AddEventObserver(UiLayout());
       
  1590                 iArrowLeftButton->SetResourceId( aImageId );
       
  1591                 }
       
  1592 
       
  1593             iArrowLeftButton->ConstructFromResourceL();
       
  1594             }
       
  1595             break;
       
  1596         case EPeninupWindowCtrlIdArrowRightBtn:
       
  1597             {
       
  1598             if ( iLayoutContext->LayoutType() != EPluginInputModeFSQ )
       
  1599                 {
       
  1600                 break;
       
  1601                 }
       
  1602 
       
  1603             if (!iArrowRightButton)
       
  1604                 {
       
  1605 	            iArrowRightButton = CAknFepCtrlRepeatButton::NewL( 
       
  1606 	                UiLayout(), aControlId, EPeninputLayoutEventRightArrow, EKeyRightArrow, 
       
  1607 	            								  KAknsIIDQsnFrFunctionButtonNormal,
       
  1608 	        									  KAknsIIDQsnFrFunctionButtonPressed,
       
  1609 	        									  KAknsIIDQsnFrFunctionButtonInactive );
       
  1610 
       
  1611                 AddControlL(iArrowRightButton);
       
  1612                 iArrowRightButton->AddEventObserver(UiLayout());
       
  1613                 iArrowRightButton->SetResourceId( aImageId );
       
  1614 
       
  1615                 }
       
  1616             iArrowRightButton->ConstructFromResourceL();
       
  1617             }
       
  1618             break;
       
  1619         default:
       
  1620             {
       
  1621             create = EFalse;
       
  1622             }
       
  1623         }
       
  1624         return create;
       
  1625     }
       
  1626     
       
  1627 void CPeninputGenericVkbWindow::SetPromptTextL(TUint8* aData)
       
  1628     {
       
  1629     RDesReadStream readStream;
       
  1630 
       
  1631     TPtr8 countPtr(aData, 2*sizeof(TInt), 2*sizeof(TInt));
       
  1632 	  readStream.Open(countPtr);
       
  1633 	  CleanupClosePushL(readStream);
       
  1634     const TInt dataCount = readStream.ReadInt32L();
       
  1635 	  const TInt textCount = readStream.ReadInt32L();
       
  1636     CleanupStack::PopAndDestroy(&readStream);
       
  1637     
       
  1638     TPtr8 ptr( aData+2*sizeof(TInt), dataCount+textCount, dataCount+textCount );            
       
  1639 	  readStream.Open(ptr);
       
  1640 	  CleanupClosePushL(readStream);
       
  1641 	
       
  1642 	  HBufC8* dataBuf = HBufC8::NewLC(dataCount);
       
  1643 	  TPtr8 dataBufPtr = dataBuf->Des();
       
  1644 	  readStream.ReadL(dataBufPtr, dataCount);
       
  1645 
       
  1646     TFepPromptText* pIcfData = 
       
  1647         reinterpret_cast<TFepPromptText*>(const_cast<TUint8*>(dataBufPtr.Ptr()));
       
  1648 
       
  1649     HBufC* textBuf;
       
  1650     if (textCount > 0)
       
  1651         {
       
  1652         textBuf = HBufC::NewLC(textCount/2);
       
  1653     	  TPtr textBufPtr = textBuf->Des();
       
  1654     	  readStream.ReadL(textBufPtr, textCount/2);
       
  1655         static_cast<CFepLayoutMultiLineIcf*>
       
  1656             (Control(EPeninputWindowCtrlIdMultiLineICF))->SetPromptTextL
       
  1657                 (textBuf->Des(), pIcfData->iCleanContent);
       
  1658         CleanupStack::PopAndDestroy(textBuf);
       
  1659         }
       
  1660     else
       
  1661         {
       
  1662         static_cast<CFepLayoutMultiLineIcf*>
       
  1663             (Control(EPeninputWindowCtrlIdMultiLineICF))->SetPromptTextL(KNullDesC, pIcfData->iCleanContent);
       
  1664         }
       
  1665 
       
  1666     CleanupStack::PopAndDestroy(dataBuf);
       
  1667 	CleanupStack::PopAndDestroy(&readStream);
       
  1668     }    
       
  1669 
       
  1670 void CPeninputGenericVkbWindow::UpdateLafData()
       
  1671     {
       
  1672     TRAP_IGNORE( iLafMgr->UpdateLafDataL() );
       
  1673     }
       
  1674 
       
  1675 void CPeninputGenericVkbWindow::ReorgnizeTitleBar()
       
  1676 	{
       
  1677     TRect rect;
       
  1678     
       
  1679     TPoint winPoint = Rect().iTl;
       
  1680     TPoint LafPoint = iLafMgr->EntirePaneRect().iTl;
       
  1681     
       
  1682     TInt x = winPoint.iX - LafPoint.iX;
       
  1683     TInt y = winPoint.iY - LafPoint.iY;    
       
  1684     if ( iLayoutContext->LayoutType() == EPluginInputModeFSQ )
       
  1685         {
       
  1686         x = 0;
       
  1687         y = 0;
       
  1688         }
       
  1689         
       
  1690     TRect inRect;
       
  1691     TRect exRect;
       
  1692     
       
  1693    
       
  1694     rect = iLafMgr->ICFRect();
       
  1695     rect.Move(x, y);
       
  1696     
       
  1697     CFepLayoutMultiLineIcf* icf = static_cast<CFepLayoutMultiLineIcf*>
       
  1698                                   (Control(EPeninputWindowCtrlIdMultiLineICF));
       
  1699 
       
  1700     const CFont* icfFont = iLafMgr->ICFTextFont();
       
  1701     
       
  1702     // set icf margin
       
  1703     TPeninputICFConfig icfConfig;
       
  1704     iLafMgr->GetICFConfig( icfConfig );
       
  1705     icf->SetTextMargin( icfConfig.iLeftMargin,
       
  1706     					icfConfig.iRightMargin,
       
  1707     					icfConfig.iTopMargin,
       
  1708     					0 );    			
       
  1709     icf->SetLineSpace( icfConfig.iLineSpaceMargin );
       
  1710     TRAP_IGNORE(icf->SizeChangedL( 
       
  1711           		rect, 
       
  1712 				icfConfig.iTextLineHeight,
       
  1713 				icfFont->FontMaxHeight(),
       
  1714 				icfFont));
       
  1715 
       
  1716     
       
  1717     iLafMgr->GetButtonRect(EPeninutWindowCtrlIdOptionBtn,exRect ,inRect);
       
  1718     exRect.Move(x, y); 
       
  1719     inRect.Move(x, y);
       
  1720     static_cast<CAknFepCtrlEventButton*>
       
  1721         ( Control( EPeninutWindowCtrlIdOptionBtn ) )->SizeChanged( exRect, inRect, ETrue );
       
  1722 
       
  1723     iLafMgr->GetButtonRect(EPeninutWindowCtrlIdCloseBtn,exRect ,inRect);
       
  1724     exRect.Move(x, y); 
       
  1725     inRect.Move(x, y);
       
  1726     static_cast<CAknFepCtrlCommonButton*>
       
  1727         ( Control( EPeninutWindowCtrlIdCloseBtn ) )->SizeChanged( exRect, inRect, ETrue );
       
  1728 
       
  1729     iLafMgr->GetButtonRect(EPeninutWindowCtrlIdBackspaceBtn,exRect ,inRect);
       
  1730     exRect.Move(x, y); 
       
  1731     inRect.Move(x, y);
       
  1732     
       
  1733     // Check size change of bk button, need for mirroring when arabic
       
  1734     CAknFepCtrlCommonButton* bkBtn = static_cast<CAknFepCtrlCommonButton*>
       
  1735         ( Control( EPeninutWindowCtrlIdBackspaceBtn ) );
       
  1736     TBool bBKSizeChanged = EFalse;
       
  1737 	if( exRect.Size() != bkBtn->Rect().Size() &&
       
  1738 		inRect.Size() != bkBtn->ForgroundBmpRect().Size() )
       
  1739 		{
       
  1740 		bBKSizeChanged = ETrue;
       
  1741 		}    
       
  1742     bkBtn->SizeChanged( exRect, inRect, ETrue );
       
  1743 
       
  1744 
       
  1745     iLafMgr->GetButtonRect(EPeninutWindowCtrlIdSpaceBtn,exRect ,inRect);
       
  1746     inRect = exRect;
       
  1747     inRect.Shrink(10, 0);
       
  1748     
       
  1749     exRect.Move(x, y); 
       
  1750     inRect.Move(x, y);
       
  1751     static_cast<CAknFepCtrlCommonButton*>
       
  1752         ( Control( EPeninutWindowCtrlIdSpaceBtn ) )->SizeChanged( exRect, inRect, ETrue );
       
  1753         
       
  1754     TRect spaceIconRect = inRect;
       
  1755     spaceIconRect.Shrink(10, 0);
       
  1756 	static_cast<CAknFepCtrlCommonButton*>
       
  1757         ( Control( EPeninutWindowCtrlIdSpaceBtn ) )->SetDraw3PieceFrameInfo(
       
  1758                       TDraw3PiecesFrame(KAknsIIDQgnIndiInputSpaceL,
       
  1759             													  KAknsIIDQgnIndiInputSpaceMiddle,
       
  1760             													  KAknsIIDQgnIndiInputSpaceR,
       
  1761             													  spaceIconRect));
       
  1762 
       
  1763     if ( iLayoutContext->LayoutType() == EPluginInputModeFSQ )
       
  1764         {
       
  1765         iLafMgr->GetButtonRect(EPeninupWindowCtrlIdArrowLeftBtn,exRect ,inRect);
       
  1766         exRect.Move(x, y); 
       
  1767         inRect.Move(x, y);
       
  1768         iArrowLeftButton->SizeChanged( exRect, inRect, ETrue );
       
  1769         
       
  1770         iLafMgr->GetButtonRect(EPeninupWindowCtrlIdArrowRightBtn,exRect ,inRect);
       
  1771         exRect.Move(x, y);
       
  1772         inRect.Move(x, y); 
       
  1773         iArrowRightButton->SizeChanged( exRect, inRect, ETrue );
       
  1774         }
       
  1775 	else
       
  1776 		{
       
  1777 	    iLafMgr->GetButtonRect(EPeninutWindowCtrlIdMoveBtn,exRect ,inRect);
       
  1778 	    exRect.Move(x, y); 
       
  1779 	    inRect.Move(x, y);
       
  1780 	    static_cast<CAknFepCtrlDragButton*>
       
  1781 	        ( Control( EPeninutWindowCtrlIdMoveBtn ) )->SizeChanged( exRect, inRect, ETrue );
       
  1782 		}    
       
  1783 
       
  1784     //If backspace size changed when language is RtoL mirror should be used    
       
  1785     if( bBKSizeChanged && IsRtoLLanguage( iLanguage ) )
       
  1786     	{
       
  1787 		//Mirror backspace graphic
       
  1788 		HandleButtonResOnLangDirChange( EPeninutWindowCtrlIdBackspaceBtn );
       
  1789     	}		
       
  1790 		    
       
  1791 	}
       
  1792 void CPeninputGenericVkbWindow::ShowBubble(TInt aShow)
       
  1793     {
       
  1794     if (aShow > 0)
       
  1795         {
       
  1796         iVkbCtrl->ShowBubble(ETrue);    
       
  1797         }
       
  1798     else
       
  1799         {
       
  1800         iVkbCtrl->ShowBubble(EFalse);     
       
  1801         }
       
  1802     }
       
  1803 	
       
  1804 void CPeninputGenericVkbWindow::ConstructAccentListL(TInt aLang)
       
  1805 	{
       
  1806 	iPopupWnd->ClearItemsL();
       
  1807 	
       
  1808 	if (aLang == ELangVietnamese)
       
  1809 		{
       
  1810 		_LIT( KVietAccentList1, "\x00E0 - \x013A" );
       
  1811 		_LIT( KVietAccentList2, "\x013C - \x017E" );
       
  1812 		
       
  1813 	    CFepLayoutChoiceList::SItem item;
       
  1814 
       
  1815 	    item.iCommand = EPeninputVkbLayoutAccented1;
       
  1816 	    item.iText.Copy( KVietAccentList1 );
       
  1817 	    iPopupWnd->AddItemL( item );
       
  1818 	    
       
  1819 	    item.iCommand = EPeninputVkbLayoutAccented2;
       
  1820 	    item.iText.Copy( KVietAccentList2 );
       
  1821 	    iPopupWnd->AddItemL( item );
       
  1822 		}
       
  1823 	// 10X3
       
  1824 	else if (aLang == ELangEnglish
       
  1825 	        || aLang == ELangAmerican
       
  1826 	        || aLang == ELangDutch
       
  1827 	        || aLang == ELangTagalog
       
  1828 	        || aLang == ELangIndonesian
       
  1829 	        || aLang == ELangMalay)
       
  1830 		    {
       
  1831 	        _LIT( KVietAccentList1, "\x00E0 - \x0121" );
       
  1832 	        _LIT( KVietAccentList2, "\x0123 - \x014F" );
       
  1833 	        _LIT( KVietAccentList3, "\x0151 - \x017E" );
       
  1834 	        
       
  1835 	        CFepLayoutChoiceList::SItem item;
       
  1836 
       
  1837 	        item.iCommand = EPeninputVkbLayoutAccented1;
       
  1838 	        item.iText.Copy( KVietAccentList1 );
       
  1839 	        iPopupWnd->AddItemL( item );
       
  1840 	        
       
  1841 	        item.iCommand = EPeninputVkbLayoutAccented2;
       
  1842 	        item.iText.Copy( KVietAccentList2 );
       
  1843 	        iPopupWnd->AddItemL( item );
       
  1844 	        
       
  1845             item.iCommand = EPeninputVkbLayoutAccented3;
       
  1846             item.iText.Copy( KVietAccentList3 );
       
  1847             iPopupWnd->AddItemL( item );
       
  1848 		    }
       
  1849 	//10X4
       
  1850 	else
       
  1851 		{
       
  1852 	    // Add item
       
  1853 	    TResourceReader reader;
       
  1854 	    CFepLayoutChoiceList::SItem item;
       
  1855 
       
  1856 	    item.iCommand = EPeninputVkbLayoutAccented1;
       
  1857 	    CCoeEnv::Static()->CreateResourceReaderLC( reader, R_PENINPUT_VKB_ACCENT1 );
       
  1858 	    TPtrC p1 = reader.ReadTPtrC();
       
  1859 	    item.iText.Copy( p1 );
       
  1860 	    iPopupWnd->AddItemL( item );
       
  1861 	    CleanupStack::PopAndDestroy( 1 );
       
  1862 	    item.iCommand = EPeninputVkbLayoutAccented2;
       
  1863 	    CCoeEnv::Static()->CreateResourceReaderLC( reader, R_PENINPUT_VKB_ACCENT2 );
       
  1864 	    TPtrC p2 = reader.ReadTPtrC();
       
  1865 	    item.iText.Copy( p2 );
       
  1866 	    iPopupWnd->AddItemL( item );
       
  1867 	    CleanupStack::PopAndDestroy( 1 );
       
  1868 	    
       
  1869 		item.iCommand = EPeninputVkbLayoutAccented3;
       
  1870 		CCoeEnv::Static()->CreateResourceReaderLC( reader, R_PENINPUT_VKB_ACCENT3 );
       
  1871 		TPtrC p3 = reader.ReadTPtrC();
       
  1872 		item.iText.Copy( p3 );
       
  1873 		iPopupWnd->AddItemL( item );
       
  1874 		CleanupStack::PopAndDestroy( 1 );      	
       
  1875 		}
       
  1876 	iPopupWnd->SetListColumnNumWithLafL( iPopupWnd->ItemsCount() );
       
  1877     iPopupInited = ETrue;
       
  1878     iPopupSet = ETrue;
       
  1879 	}
       
  1880 void CPeninputGenericVkbWindow::UpdateICFTextL()
       
  1881     {
       
  1882     CFepLayoutMultiLineIcf* icf = 
       
  1883         static_cast<CFepLayoutMultiLineIcf*>(Control(EPeninputWindowCtrlIdMultiLineICF));
       
  1884     if( icf )
       
  1885         {
       
  1886         icf->UpdateSecretTextL();    
       
  1887         }
       
  1888     }
       
  1889     
       
  1890 void CPeninputGenericVkbWindow::HandleButtonResOnLangDirChange( TInt aControlId )
       
  1891 	{
       
  1892     TRAP_IGNORE(HandleButtonResOnLangDirChangeL(aControlId));
       
  1893     }
       
  1894 void CPeninputGenericVkbWindow::HandleButtonResOnLangDirChangeL( TInt aControlId )
       
  1895 	{
       
  1896 	CAknFepCtrlCommonButton* ctrl = static_cast<CAknFepCtrlCommonButton*>(
       
  1897 										Control(aControlId) );
       
  1898 	if( ctrl && iBmpRotator)
       
  1899 		{
       
  1900 		TSyncRotationAngle rotChoice = CBitmapRotator::EMirrorVerticalAxis; 
       
  1901 		User::LeaveIfError( iBmpRotator->Rotate( *ctrl->ForgroundBmp() ,
       
  1902 								  				 rotChoice ) );
       
  1903 		User::LeaveIfError( iBmpRotator->Rotate( *ctrl->ForgroundBmpMask() ,
       
  1904 								  				 rotChoice ) );   								  
       
  1905 		}		
       
  1906 	}    
       
  1907 		
       
  1908 // --------------------------------------------------------------------------
       
  1909 // Show tooltip of ICF
       
  1910 // --------------------------------------------------------------------------
       
  1911 //
       
  1912 void CPeninputGenericVkbWindow::ShowTooltipL( const TDesC& aText )
       
  1913     {
       
  1914     CFepLayoutMultiLineIcf* icf = static_cast<CFepLayoutMultiLineIcf*>
       
  1915                                 (Control(EPeninputWindowCtrlIdMultiLineICF));    
       
  1916     CPeninputGenericVkbLayout* layout 
       
  1917                       = static_cast<CPeninputGenericVkbLayout*>( UiLayout() );    
       
  1918     if ( !icf || !( layout->IsEnableITIOnFSQ() ) )
       
  1919         {
       
  1920         return;
       
  1921         }    
       
  1922     icf->ShowTooltipL( aText );
       
  1923     }
       
  1924 	
       
  1925 // --------------------------------------------------------------------------
       
  1926 // Hide tooltip of ICF
       
  1927 // --------------------------------------------------------------------------
       
  1928 //
       
  1929 void CPeninputGenericVkbWindow::HideTooltip()
       
  1930     {
       
  1931     CFepLayoutMultiLineIcf* icf = static_cast<CFepLayoutMultiLineIcf*>
       
  1932                                 (Control(EPeninputWindowCtrlIdMultiLineICF));
       
  1933     if ( !icf  )
       
  1934         {
       
  1935         return;
       
  1936         }
       
  1937     icf->HideTooltip();
       
  1938     }
       
  1939 
       
  1940 // --------------------------------------------------------------------------
       
  1941 // Hide candidate list
       
  1942 // --------------------------------------------------------------------------
       
  1943 //
       
  1944 void CPeninputGenericVkbWindow::HideCandidateList()
       
  1945     {
       
  1946     if ( !iCandidateList )
       
  1947         {
       
  1948         return;
       
  1949         }
       
  1950     iCandidateList->Hide( ETrue );
       
  1951     }
       
  1952 	
       
  1953 // --------------------------------------------------------------------------
       
  1954 // Show candidate list
       
  1955 // --------------------------------------------------------------------------
       
  1956 //
       
  1957 void CPeninputGenericVkbWindow::ShowCandidateListL( const CDesCArray* aItemArray,
       
  1958                                                    TInt aActiveIndex )
       
  1959     {
       
  1960     if ( !iCandidateList )
       
  1961         {
       
  1962         return;
       
  1963         }                
       
  1964     iCandidateList->ClearItemsL();
       
  1965     if ( aItemArray )
       
  1966         {        
       
  1967         for ( TInt i = 0; i < aItemArray->Count(); i++ )
       
  1968             {
       
  1969             CFepLayoutChoiceList::SItem item;
       
  1970             item.iCommand = 0;
       
  1971             if ( (*aItemArray)[i].Length() <= item.iText.MaxLength() )
       
  1972                 {
       
  1973                 item.iText.Copy( (*aItemArray)[i] );
       
  1974                 }
       
  1975             else
       
  1976                 {
       
  1977                 // Given longer than maxlength, display the part of less than max
       
  1978                 item.iText.Copy( (*aItemArray)[i].Left( item.iText.MaxLength() ) );
       
  1979                 }
       
  1980             iCandidateList->AddItemL( item );
       
  1981             }
       
  1982         }
       
  1983     iCandidateList->SetCurrentFocusedIndex( aActiveIndex );
       
  1984     
       
  1985     CFepLayoutMultiLineIcf* icf = static_cast<CFepLayoutMultiLineIcf*>
       
  1986          (Control(EPeninputWindowCtrlIdMultiLineICF)); 
       
  1987 
       
  1988     TPoint posBelow( 0, 0 );
       
  1989     TPoint posRight( 0, 0 );
       
  1990     posBelow = posRight = icf->Rect().iTl;
       
  1991     icf->InlineTextPos( posBelow, posRight );
       
  1992     TPoint tlPos = posRight;
       
  1993     iCandidateList->Display( TRect( tlPos, tlPos ), 
       
  1994                              CFepLayoutPopupWnd::EDispBottomRight );
       
  1995     }
       
  1996 
       
  1997 // --------------------------------------------------------------------------
       
  1998 // Handle candidate list selected events.
       
  1999 // --------------------------------------------------------------------------
       
  2000 //
       
  2001 void CPeninputGenericVkbWindow::HandleCandidateListSelectedL
       
  2002                          ( CFepUiBaseCtrl* aCtrl, const TDesC& aEventData )
       
  2003     {
       
  2004     if ( aCtrl != iCandidateList )
       
  2005         {
       
  2006         return;
       
  2007         }
       
  2008 
       
  2009     CFepLayoutChoiceList::SEvent* event = 
       
  2010             (CFepLayoutChoiceList::SEvent*)aEventData.Ptr();
       
  2011     if ( event->iIndex != KErrNotFound )
       
  2012         {
       
  2013         TPtrC ptr;
       
  2014         ptr.Set( reinterpret_cast<TUint16*>(&( event->iIndex ) ), 
       
  2015                  sizeof( TInt ) );            
       
  2016         UiLayout()->SignalOwner( ESignalSelectCandidate, ptr );
       
  2017         }
       
  2018     }
       
  2019 
       
  2020 // --------------------------------------------------------------------------
       
  2021 // Create a candidate list control.
       
  2022 // --------------------------------------------------------------------------
       
  2023 //    
       
  2024 void CPeninputGenericVkbWindow::CreateCandidateListL()
       
  2025     {
       
  2026     iCandidateList = CFepLayoutScrollableList::NewL( 
       
  2027                             UiLayout(), 
       
  2028                             EPentinputHwrCandidateList,
       
  2029                             TSize( 0, 0 ),
       
  2030                             0,
       
  2031                             0,
       
  2032                             TSize( 0, 0 ),
       
  2033                             TSize( 0, 0 ) );
       
  2034          
       
  2035     iCandidateList->SetImgFrId(KAknsIIDQsnFrPopupSub, 
       
  2036                                 KAknsIIDQsnFrFunctionButtonNormal,
       
  2037 								KAknsIIDQsnFrFunctionButtonPressed,
       
  2038 								KAknsIIDQsnFrFunctionButtonInactive,
       
  2039                                 KAknsIIDQsnFrList,
       
  2040                                 KAknsIIDQsnFrPopupSub);
       
  2041                                 
       
  2042     iCandidateList->SetResourceId(R_PENINPUT_FSQ_CANDIDATE_LIST);
       
  2043     iCandidateList->ConstructFromResourceL();
       
  2044     iCandidateList->SetPageInfoResID( R_PENINPUT_FSQ_CANDIDATE_LIST_PAGE_NUM );
       
  2045     iCandidateList->AddEventObserver( UiLayout() );
       
  2046     AddControlL(iCandidateList);    
       
  2047     }
       
  2048 
       
  2049 // --------------------------------------------------------------------------
       
  2050 // Retrieve text color from skin for candidiate list.
       
  2051 // --------------------------------------------------------------------------
       
  2052 //
       
  2053 TRgb CPeninputGenericVkbWindow::CandidateListTextColor()
       
  2054     {
       
  2055     MAknsSkinInstance* skininstance = AknsUtils::SkinInstance();
       
  2056     TRgb matchlistcolor = KRgbBlack;
       
  2057     AknsUtils::GetCachedColor( skininstance, 
       
  2058                                 matchlistcolor, 
       
  2059                                 KAknsIIDQsnTextColors,
       
  2060                                 EAknsCIQsnTextColorsCG43 );
       
  2061     return matchlistcolor;
       
  2062     }
       
  2063 
       
  2064 // --------------------------------------------------------------------------
       
  2065 // Retrieve text color from skin for autocompletion part.
       
  2066 // --------------------------------------------------------------------------
       
  2067 //
       
  2068 TRgb CPeninputGenericVkbWindow::AutoCompletionPartColor()
       
  2069     {
       
  2070     MAknsSkinInstance* skininstance = AknsUtils::SkinInstance();
       
  2071     TRgb matchlistcolor = KRgbBlack;
       
  2072     AknsUtils::GetCachedColor( skininstance, 
       
  2073                                 matchlistcolor, 
       
  2074                                 KAknsIIDQsnTextColors,
       
  2075                                 EAknsCIQsnTextColorsCG64 );
       
  2076     return matchlistcolor;
       
  2077     }
       
  2078 
       
  2079 // End Of File