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