textinput/peninputgenerichwr/src/peninputhwrarabicwindow.cpp
changeset 0 eb1f2e154e89
child 10 6defe5d1bd39
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 hwr window class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // System includes
       
    20 #include <peninputhwrwindow.rsg>
       
    21 #include <peninputhwrwindowconfiginfo_01.rsg>
       
    22 #include <aknfeppeninputenums.h>
       
    23 #include <peninputinputcontextfield.h>
       
    24 #include <peninputpluginutils.h>
       
    25 #include <peninputcommonlayout.h>
       
    26 #include <peninputeventbutton.h>
       
    27 #include <peninputrepeatbutton.h>
       
    28 #include <peninputlayouthwrwnd.h>
       
    29 #include <peninputrangebar.h>
       
    30 #include <peninputdataconverter.h>
       
    31 #include <peninputdataprovider.h>
       
    32 #include <peninputclientlayoutinfo.h>
       
    33 #include <peninputdropdownlist.h>
       
    34 #include <AknIconUtils.h>
       
    35 #include <AknLayoutDef.h>
       
    36 #include <AknUtils.h>
       
    37 #include <aknlayoutscalable_avkon.cdl.h>
       
    38 #include <AknsUtils.h>
       
    39 #include <peninputlayoutchoicelist.h>
       
    40 #include <AknFepGlobalEnums.h>
       
    41 #include <peninputlayoutinputmodechoice.h>
       
    42 #include <peninputlayoutmultilineicf.h>
       
    43 #include <coemain.h>
       
    44 #include <peninputdragbutton.h>
       
    45 #include <peninputrepeatbutton.h>
       
    46 #include <peninputdataconverter.h>
       
    47 #include <peninputpluginutils.h>
       
    48 
       
    49 // User includes
       
    50 #include "peninputlayoutchoicelist.h"
       
    51 #include "peninputhwrarabicwindow.h"
       
    52 #include "peninputhwrarabicdatamgr.h"
       
    53 #include "peninputhwrarabic.hrh"
       
    54 #include "peninputhwrarabicengine.h"
       
    55 //#include "peninputhwrevent.h"
       
    56 #include "peninputhwrarabiclayout.h"
       
    57 // Constants
       
    58 _LIT( KHwrWindowResourceFile, 
       
    59       "z:\\resource\\plugins\\peninputhwrwindow.RSC" );
       
    60 _LIT( KConfigurationResourceFile, 
       
    61       "z:\\resource\\plugins\\peninputhwrwindowconfiginfo_" );
       
    62 _LIT( KResourceFileExtName, ".RSC" );
       
    63 
       
    64 _LIT(KStandardPuncExclamatoryPoint, "\x0021");
       
    65 _LIT(KStandardPuncDotPoint, "\x002E");
       
    66 _LIT(KArabicPuncComma, "\x060C");
       
    67 _LIT(KArabicPuncSemicolon, "\x061B");
       
    68 _LIT(KArabicPuncQuestion, "\x061F");
       
    69 _LIT(KArabicPuncWaw, "\x0648");
       
    70 
       
    71 const TInt KWrittingFactor = 0;
       
    72 const TInt KNormalFactor = 26;
       
    73 
       
    74 const TInt KWriteBoxFrameBackColorMajor = EAknsMajorSkin;
       
    75 const TInt KWriteBoxFrameBackColorGrp = EAknsMinorQsnOtherColors;
       
    76 const TInt KWriteBoxFrameBackColorIdx = EAknsCIQsnOtherColorsCG9; 
       
    77 const TUint32 KDefaultWriteBoxFrameColor = 0x000000;
       
    78 const TUint32 KDefaultWriteBoxBackColor = 0xffffff;
       
    79 
       
    80 const TInt KPeninputHwrWndInvalidIndex = -1;
       
    81 // ======== MEMBER FUNCTIONS ========
       
    82 
       
    83 // --------------------------------------------------------------------------
       
    84 // CPeninputHwrBxAbWnd::CPeninputHwrBxAbWnd
       
    85 // (other items were commented in a header)
       
    86 // --------------------------------------------------------------------------
       
    87 //
       
    88 CPeninputHwrBxAbWnd::CPeninputHwrBxAbWnd( 
       
    89     CFepUiLayout* aUiLayout, MPeninputLayoutContext* aLayoutContext )
       
    90     : CPeninputLayoutWindow( aUiLayout, aLayoutContext ),
       
    91       iNormalTransFactor(KNormalFactor),
       
    92       iWriteTransFactor(KWrittingFactor),
       
    93       iGuideLineSet(EFalse),
       
    94       iBackspaceMirrored(EFalse)
       
    95     {
       
    96     }
       
    97 
       
    98 // --------------------------------------------------------------------------
       
    99 // CPeninputHwrBxAbWnd::NewL
       
   100 // (other items were commented in a header)
       
   101 // --------------------------------------------------------------------------
       
   102 //
       
   103 CPeninputHwrBxAbWnd* CPeninputHwrBxAbWnd::NewL( 
       
   104     CFepUiLayout* aUiLayout, MPeninputLayoutContext* aLayoutContext )
       
   105     {
       
   106     CPeninputHwrBxAbWnd* self = 
       
   107         new ( ELeave ) CPeninputHwrBxAbWnd( aUiLayout, aLayoutContext );
       
   108     CleanupStack::PushL( self );
       
   109     self->ConstructL();
       
   110     CleanupStack::Pop( self );
       
   111 
       
   112     return self;
       
   113     }
       
   114 
       
   115 // --------------------------------------------------------------------------
       
   116 // CPeninputHwrBxAbWnd::~CPeninputHwrBxAbWnd
       
   117 // (other items were commented in a header)
       
   118 // --------------------------------------------------------------------------
       
   119 //
       
   120 CPeninputHwrBxAbWnd::~CPeninputHwrBxAbWnd()
       
   121     {
       
   122     for ( TInt i = 0; i < iRecogResult.Count(); i++ )
       
   123         {
       
   124         delete iRecogResult[i];
       
   125         }
       
   126     iRecogResult.Close();
       
   127     iStrokeArray.Close();
       
   128     delete iLastResult;
       
   129     delete iBmpRotator;
       
   130     }
       
   131 
       
   132 // --------------------------------------------------------------------------
       
   133 // CPeninputHwrBxAbWnd::ConstructL
       
   134 // (other items were commented in a header)
       
   135 // --------------------------------------------------------------------------
       
   136 //
       
   137 void CPeninputHwrBxAbWnd::ConstructL()
       
   138     {
       
   139     iBmpRotator = CPeninputSyncBitmapRotator::NewL();    
       
   140     CPeninputLayoutWindow::ConstructL();   
       
   141     CPeninputHwrBxAbDataMgr::THandWritingPenData* penData = 
       
   142         ( CPeninputHwrBxAbDataMgr::THandWritingPenData* ) 
       
   143         iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
       
   144 
       
   145     if ( ( penData ) && ( iHwBox ) )
       
   146         {
       
   147         iHwBox->SetCharacterDelay( penData->iWritingSpeed );
       
   148         iHwBox->SetFadingSpeed(penData->iFadingSpeed);
       
   149 #ifdef _NOT_USING_DECUMA_MCR_
       
   150         // similar as S90     
       
   151 
       
   152         iHwBox->SetStrokeDelay( 90000 );
       
   153         
       
   154 #endif
       
   155         
       
   156         iHwBox->SetPenSize( penData->iPenSize );
       
   157         iHwBox->SetPenColor( penData->iPenColor );
       
   158         iHwBox->SetWndTransparencyFactor(iNormalTransFactor);
       
   159         }
       
   160     }
       
   161 
       
   162 // --------------------------------------------------------------------------
       
   163 // CPeninputHwrBxAbWnd::HandleControlEvent
       
   164 // (other items were commented in a header)
       
   165 // --------------------------------------------------------------------------
       
   166 //
       
   167 void CPeninputHwrBxAbWnd::HandleControlEvent( TInt aEventType,
       
   168                                                     CFepUiBaseCtrl* aCtrl, 
       
   169                                                     const TDesC& aEventData )
       
   170     {
       
   171     // Call this function in base class
       
   172     CPeninputLayoutWindow::HandleControlEvent( aEventType, 
       
   173                                                aCtrl, 
       
   174                                                aEventData );
       
   175 
       
   176     TInt* data = ( TInt* ) aEventData.Ptr(); 
       
   177     
       
   178     switch ( aEventType )
       
   179         {
       
   180         case EPeninputLayoutHwrEventPenColorChange:
       
   181         case EPeninputLayoutHwrEventPenSizeChange:
       
   182         case EPeninputLayoutHwrEventWritingSpeedChange:
       
   183             {
       
   184             CPeninputHwrBxAbDataMgr::THandWritingPenData* penData = 
       
   185                 ( CPeninputHwrBxAbDataMgr::THandWritingPenData* ) 
       
   186                 iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
       
   187 
       
   188             iHwBox->SetCharacterDelay( penData->iWritingSpeed );
       
   189             iHwBox->SetFadingSpeed(penData->iFadingSpeed);
       
   190             
       
   191 #ifdef _NOT_USING_DECUMA_MCR_
       
   192         
       
   193             // similar as S90                 
       
   194             iHwBox->SetStrokeDelay( 90000 );
       
   195             
       
   196 #endif
       
   197 
       
   198             iHwBox->SetPenSize( penData->iPenSize );
       
   199             iHwBox->SetPenColor( penData->iPenColor );
       
   200             }
       
   201             break;
       
   202         case EPeninputLayoutHwrEventGuideLineChanged:
       
   203             {
       
   204             CPeninputHwrBxAbDataMgr::THandWritingPenData* penData = 
       
   205                 ( CPeninputHwrBxAbDataMgr::THandWritingPenData* ) 
       
   206                 iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
       
   207 
       
   208             iHwBox->HideGuideLine( penData->iGuideLineOn == 0 ? EFalse : ETrue );
       
   209             iHwBox->RefreshUI();
       
   210             }
       
   211             break;
       
   212         case EEventHwrStrokeCanceled:
       
   213             {
       
   214             OnStrokeCanceled();
       
   215             }
       
   216             break;  
       
   217         case EPeninputLayoutEventCloseWindow:
       
   218             {
       
   219             iStrokeArray.Reset();
       
   220             iHwBox->CapturePointer(EFalse);
       
   221             iHwBox->CancelCharWriting();
       
   222             }
       
   223             break;        
       
   224         case EEventChoiceSelected:
       
   225             {            
       
   226             CFepLayoutChoiceList::SEvent* event = 
       
   227                 ( CFepLayoutChoiceList::SEvent* ) aEventData.Ptr();
       
   228             
       
   229             if ( event->iIndex != KPeninputHwrWndInvalidIndex )
       
   230                 {
       
   231                 if (aCtrl->ControlId() == EPeninutWindowCtrlIdSwitcherPopupWindow)
       
   232                     {
       
   233                     if (EPluginInputModeHwr != event->iCommand)
       
   234                         {
       
   235                         TBool switchByMode = ETrue;
       
   236                         TInt  mode = event->iCommand;
       
   237 
       
   238                         TBuf<8> buf;
       
   239                         buf.Append(reinterpret_cast<TText*>(&switchByMode), 
       
   240                                    sizeof(TBool)/sizeof(TText));
       
   241                         buf.Append(reinterpret_cast<TText*>(&mode), sizeof(TInt)/sizeof(TText));
       
   242                         UiLayout()->SignalOwner(ESignalLayoutUIChanged,buf);
       
   243                         }
       
   244                     }
       
   245                 }
       
   246             else
       
   247                 {// handle dropdownlist when user tapped switch inputmethods popup window without selecting other inputmethods.
       
   248                 TInt dataType = CPeninputDataConverter::AnyToInt(iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ));
       
   249                 if (dataType == ERangeNative)
       
   250                     {
       
   251                     ResetAndShowDropdownList();
       
   252                     }
       
   253                 else
       
   254                     {
       
   255                     ClearAndCloseDropdownList();
       
   256                     }
       
   257                 }
       
   258             }
       
   259             break;
       
   260         case EPeninputLayoutEventToVkb:
       
   261             {
       
   262             iHwBox->CancelCharWriting();
       
   263             TInt curRange = CPeninputDataConverter::AnyToInt(iLayoutContext->RequestData(EPeninputDataTypeCurrentRange) );
       
   264             if (curRange == ERangeNative)
       
   265                 {
       
   266                 iDropdownList->ResetAndClear(CFepCtrlDropdownList::EListExpandableMultiRowWithoutIcon );
       
   267                 }
       
   268             PopupSwitchWindow();
       
   269             }
       
   270             break; 
       
   271         case EPeninputLayoutEventRange:
       
   272             {
       
   273             iHwBox->CancelCharWriting();
       
   274             ClearAndCloseDropdownList();
       
   275             SizeChanged(ETrue);
       
   276             }
       
   277             break;
       
   278         case EPeninputLayoutEventBack:
       
   279             {
       
   280             HandleBackspaceKeyEvent();
       
   281             }
       
   282             break;
       
   283             
       
   284         default:
       
   285             break;
       
   286         }
       
   287     }
       
   288 
       
   289 // --------------------------------------------------------------------------
       
   290 // CPeninputHwrBxAbWnd::GetWindowConfigResId
       
   291 // (other items were commented in a header)
       
   292 // --------------------------------------------------------------------------
       
   293 //
       
   294 TInt CPeninputHwrBxAbWnd::GetWindowConfigResId()
       
   295     {
       
   296     return R_PENINPUT_LAYOUT_CONFIG_INFO;
       
   297     }
       
   298 
       
   299 // --------------------------------------------------------------------------
       
   300 // CPeninputHwrBxAbWnd::GetWindowResId
       
   301 // (other items were commented in a header)
       
   302 // --------------------------------------------------------------------------
       
   303 //
       
   304 TInt CPeninputHwrBxAbWnd::GetWindowResId()
       
   305     {
       
   306     return R_PENINPUT_LAYOUT_HWR_WINDOW;        
       
   307     }
       
   308 
       
   309 // --------------------------------------------------------------------------
       
   310 // CPeninputHwrBxAbWnd::GetWindowConfigResFileName
       
   311 // (other items were commented in a header)
       
   312 // --------------------------------------------------------------------------
       
   313 //
       
   314 const TDesC& CPeninputHwrBxAbWnd::GetWindowConfigResFileName( 
       
   315     TInt aLangID )
       
   316     {
       
   317     if ( aLangID <= 0 ) 
       
   318         {
       
   319         return KNullDesC;
       
   320         }
       
   321 
       
   322     iResourceFilename.Zero();
       
   323     iResourceFilename = KConfigurationResourceFile();
       
   324     
       
   325     if ( aLangID < 10 )
       
   326         {
       
   327          iResourceFilename.AppendNum( 0 );
       
   328          iResourceFilename.AppendNum( aLangID );
       
   329         }
       
   330     else
       
   331         {
       
   332          iResourceFilename.AppendNum( aLangID );
       
   333         }
       
   334     iResourceFilename.Append( KResourceFileExtName );
       
   335     
       
   336     return iResourceFilename;
       
   337     }
       
   338 
       
   339 // --------------------------------------------------------------------------
       
   340 // CPeninputHwrBxAbWnd::GetWindowResFileName
       
   341 // (other items were commented in a header)
       
   342 // --------------------------------------------------------------------------
       
   343 //
       
   344 const TDesC& CPeninputHwrBxAbWnd::GetWindowResFileName()
       
   345     {
       
   346     return KHwrWindowResourceFile();
       
   347     }
       
   348 
       
   349 // --------------------------------------------------------------------------
       
   350 // CPeninputHwrBxAbWnd::CreateAllControlsL
       
   351 // (other items were commented in a header)
       
   352 // --------------------------------------------------------------------------
       
   353 //
       
   354 void CPeninputHwrBxAbWnd::CreateAllControlsL()
       
   355     {
       
   356     // Hwr box    
       
   357     AddHwBoxL();
       
   358     
       
   359     // Range bar
       
   360     AddRangeBarL();
       
   361                
       
   362     // Language switch button
       
   363     iLangSwitchBtn = AddButtonL( EPeninutWindowCtrlIdInputLangSwitcherBtn, 
       
   364                                  EPeninputLayoutEventSwitchLanguage, 
       
   365                                  R_PENINPUT_LAYOUT_HWR_SWITCH ); 
       
   366     SetSwitchBtnFont(*iLangSwitchBtn);
       
   367     SetSwitchBtnTextColor(*iLangSwitchBtn);
       
   368                
       
   369     // Switch to vkb button
       
   370     AddButtonL( EPeninutWindowCtrlIdSwitchToVkbBtn, 
       
   371                 EPeninputLayoutEventToVkb, 
       
   372                 R_PENINPUT_LAYOUT_HWR_VKB );
       
   373     
       
   374     iModeSwitchChoice = CPeninputLayoutInputmodelChoice::NewL( UiLayout(),
       
   375             EPeninutWindowCtrlIdSwitcherPopupWindow, EPluginInputModeHwr);
       
   376     iModeSwitchChoice->SetListSkinID( KAknsIIDQsnFrList, KAknsIIDQsnFrPopupSub );
       
   377     AddControlL( iModeSwitchChoice );    
       
   378     iModeSwitchChoice->AddEventObserver( UiLayout() );             
       
   379 
       
   380 
       
   381     //add dropdown list to client pane.
       
   382     TPixelsTwipsAndRotation ptSize;     
       
   383     CCoeEnv* coeEnv = CCoeEnv::Static();    
       
   384     coeEnv->ScreenDevice()->GetDefaultScreenSizeAndRotation(ptSize);
       
   385 
       
   386     TBool boxWndLandscape;
       
   387     
       
   388     //set proper screen style for box window
       
   389     if (ptSize.iPixelSize.iWidth < ptSize.iPixelSize.iHeight)
       
   390         {
       
   391         // protrait screen
       
   392         boxWndLandscape = EFalse;
       
   393         }
       
   394     else
       
   395         {
       
   396         // landscape screen
       
   397         boxWndLandscape = ETrue;
       
   398         }
       
   399     AddDropdownListL(boxWndLandscape);
       
   400 //    TRect rect = iHwBox->Rect();
       
   401 //    rect.iTl.iY = rect.iTl.iY + 2*iUnitHeight;
       
   402 //    
       
   403 //    iHwBox->SetRect(rect);
       
   404     for ( TInt i = 0; i < iCtrlPool->ControlCount(); i++ )
       
   405         {
       
   406         if ( iCtrlPool && iCtrlPool->ControlByIndex( i ))
       
   407             {
       
   408             iCtrlPool->ControlByIndex( i )->AddEventObserver( UiLayout() );
       
   409             }
       
   410         }
       
   411     }
       
   412         
       
   413 // --------------------------------------------------------------------------
       
   414 // CPeninputHwrBxAbWnd::ChangeUnitSize
       
   415 // (other items were commented in a header)
       
   416 // --------------------------------------------------------------------------
       
   417 //
       
   418 const TRect CPeninputHwrBxAbWnd::ChangeUnitSize()
       
   419     {
       
   420     if (CPeninputDataConverter::AnyToInt(
       
   421                                    iLayoutContext->RequestData(EAkninputDataTypeSizeChanging)) ||
       
   422         !(CPeninputDataConverter::AnyToInt(
       
   423                                    iLayoutContext->RequestData(EAkninputDataTypeUnitSizeSet))))
       
   424         {
       
   425         // if size changing, or unitwidth, unitheight has not been set yet
       
   426         TAknWindowLineLayout appWnd;
       
   427         TAknWindowLineLayout mainPane;
       
   428         TAknWindowLineLayout wndLayout;
       
   429         TAknWindowLineLayout unitLayout;
       
   430         TAknLayoutRect mainPaneRect;
       
   431         TAknLayoutRect wndRect;
       
   432         TAknLayoutRect unitRect;
       
   433 
       
   434         // Get hwr window layout
       
   435         appWnd = AknLayoutScalable_Avkon::application_window( 0 ).LayoutLine();
       
   436 
       
   437         if (appWnd.iW > appWnd.iH)
       
   438             {
       
   439               // landscape
       
   440               mainPane = AknLayoutScalable_Avkon::main_pane(4).LayoutLine();
       
   441             wndLayout = AknLayoutScalable_Avkon::popup_fep_hwr_window(2).LayoutLine();
       
   442             }
       
   443         else
       
   444             {
       
   445             // portrait 
       
   446             mainPane = AknLayoutScalable_Avkon::main_pane(1).LayoutLine();
       
   447             wndLayout = AknLayoutScalable_Avkon::popup_fep_hwr_window(0).LayoutLine();
       
   448             }
       
   449 
       
   450         mainPaneRect.LayoutRect(appWnd.Rect(), mainPane);
       
   451         wndRect.LayoutRect(mainPaneRect.Rect(), wndLayout);
       
   452 
       
   453         unitLayout = AknLayoutScalable_Avkon::fep_hwr_aid_pane(1).LayoutLine();
       
   454         unitRect.LayoutRect(wndRect.Rect(), unitLayout);
       
   455 
       
   456         iHwrWndRect = TRect(0,
       
   457                             0,
       
   458                             wndRect.Rect().Width(),
       
   459                             wndRect.Rect().Height());
       
   460                              
       
   461         TInt unitWidth = unitRect.Rect().Width();
       
   462         TInt unitHeight = unitRect.Rect().Height();
       
   463 
       
   464         iLayoutContext->SetData(EPeninputDataTypeUnitWidth, &unitWidth);
       
   465         iLayoutContext->SetData(EPeninputDataTypeUnitHeight, &unitHeight);
       
   466         }
       
   467     
       
   468     return iHwrWndRect;
       
   469     }
       
   470 
       
   471 // --------------------------------------------------------------------------
       
   472 // CPeninputHwrBxAbWnd::ChangeClientSize
       
   473 // (other items were commented in a header)
       
   474 // --------------------------------------------------------------------------
       
   475 //
       
   476 void CPeninputHwrBxAbWnd::ChangeClientSize()
       
   477     {
       
   478     TInt unitWidth = CPeninputDataConverter::AnyToInt
       
   479         ( iLayoutContext->RequestData( EPeninputDataTypeUnitWidth ) );
       
   480     TInt unitHeight = CPeninputDataConverter::AnyToInt
       
   481         ( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) );   
       
   482         
       
   483     // Modify language switch button font
       
   484     SetSwitchBtnFont(*iLangSwitchBtn);
       
   485 
       
   486     TInt clientLayoutId = CPeninputDataConverter::AnyToInt
       
   487         ( iLayoutContext->RequestData( EPeninputDataTypeClientLayout ) );
       
   488     CPeninputClientLayoutInfo* clientLayout = 
       
   489         ConfigInfo()->FindClientLayoutInfo( clientLayoutId );
       
   490     
       
   491     if ( clientLayout )
       
   492         {
       
   493         // Change self rect
       
   494         /*TInt width = clientLayout->Columns() * unitWidth;
       
   495         TInt height = clientLayout->Rows() * unitHeight;
       
   496         TRect rect = TRect( ClientPane()->Rect().iTl, 
       
   497                             TSize( width, height ) );
       
   498 
       
   499         ClientPane()->SetRect( rect );*/
       
   500         // Change the postion and size of controls in current layout
       
   501         ReorganizeControls( clientLayout->LayoutID() );
       
   502         }
       
   503     //mirror backspace arrow
       
   504     TRAP_IGNORE(MirrorBackspaceButtonResL());    
       
   505     }
       
   506 
       
   507 // --------------------------------------------------------------------------
       
   508 // CPeninputHwrBxAbWnd::ReorganizeControls
       
   509 // (other items were commented in a header)
       
   510 // --------------------------------------------------------------------------
       
   511 //
       
   512 void CPeninputHwrBxAbWnd::ReorganizeControls( TInt aClientLayoutId, TBool /*aNeedReset*/ )
       
   513     {
       
   514     TInt unitWidth = CPeninputDataConverter::AnyToInt
       
   515         ( iLayoutContext->RequestData( EPeninputDataTypeUnitWidth ) );
       
   516     TInt unitHeight = CPeninputDataConverter::AnyToInt
       
   517         ( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) );
       
   518  
       
   519     CPeninputClientLayoutInfo* clientLayout = 
       
   520                 ConfigInfo()->FindClientLayoutInfo( aClientLayoutId );
       
   521 
       
   522     // First remove all controls in the client pane, but don't delete them
       
   523     ( const_cast<RPointerArray<CFepUiBaseCtrl>&>
       
   524         ( ClientPane()->ControlList() ) ).Reset();
       
   525 
       
   526     // Set case sensitive for the engine
       
   527     CPeninputHwrBxAbDataMgr::THandWritingPenData* penData = 
       
   528         ( CPeninputHwrBxAbDataMgr::THandWritingPenData* ) 
       
   529         iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
       
   530     
       
   531     penData->iRecognizer->SetCaseSensitive( ConfigInfo()->CaseSensitive() );
       
   532 
       
   533     
       
   534     //reset window rect, titlebar rect, client rect
       
   535     TSize szClient( clientLayout->Columns() * unitWidth, 
       
   536                     clientLayout->Rows() * unitHeight );
       
   537 
       
   538     TSize szWnd( clientLayout->Columns() * unitWidth, 
       
   539                  clientLayout->Rows() * unitHeight + unitHeight );                       
       
   540                  
       
   541     TSize szTitle ( clientLayout->Columns() * unitWidth, unitHeight );
       
   542     
       
   543     SetWindowRect( TRect(Rect().iTl, szWnd) ); 
       
   544     
       
   545     //setwindowrect may change automactially for shadow or other things
       
   546     TPoint ptTopLeft = Rect().iTl;
       
   547     
       
   548     TitleBar()->SetRect( TRect(ptTopLeft, szTitle ) );
       
   549     ClientPane()->SetRect( TRect(ptTopLeft + TPoint(0, unitHeight),
       
   550                                szClient) );
       
   551                                
       
   552     // Get control list from client layout
       
   553     RPointerArray<CPeninputControlInfo>& controlList = 
       
   554         clientLayout->ControlInfoList();
       
   555     const TInt count = controlList.Count();
       
   556     TInt controlID = 0;
       
   557     TInt cols = 0;
       
   558     TInt rows = 0;
       
   559     CFepUiBaseCtrl* ctrl = NULL;
       
   560     
       
   561     //controls are based on client pane
       
   562     TPoint point = ptTopLeft + TPoint(0, unitHeight);
       
   563     
       
   564     for ( TInt i = 0; i < count; i++ )
       
   565         {
       
   566         controlID = controlList[i]->ControlID();
       
   567         ctrl = iCtrlPool->Control( controlID );
       
   568 
       
   569         if ( ctrl )
       
   570             {
       
   571             TRect rect;
       
   572             rect.iTl = point 
       
   573                 + TPoint( controlList[i]->BeginColumn() * unitWidth, 
       
   574                           controlList[i]->BeginRow() * unitHeight );
       
   575             cols = controlList[i]->EndColumn() 
       
   576                 - controlList[i]->BeginColumn();
       
   577             rows = controlList[i]->EndRow() 
       
   578                 - controlList[i]->BeginRow();
       
   579             rect.SetSize( TSize( cols * unitWidth, rows * unitHeight ) ); 
       
   580             AddNotOwnedControl( ctrl );
       
   581             
       
   582             if ( ( ctrl->ControlType() | ECtrlButton ) == ECtrlButton )
       
   583                 {
       
   584                 TRect innerRect;
       
   585                 AknPenImageUtils::CalculateGraphicRect( rect, innerRect );                    
       
   586                 ( static_cast<CAknFepCtrlCommonButton*> ( ctrl ) )->SizeChanged
       
   587                     ( rect, innerRect, ETrue );
       
   588                 }
       
   589             else if ( ctrl->ControlId() == EPeninutWindowCtrlIdRangeBar )
       
   590                 {
       
   591                 rect = TRect( rect.iTl, TSize( unitWidth, unitHeight ) );
       
   592                 ( static_cast<CAknFepCtrlRangeBar*> ( ctrl ) )->SizeChanged( rect );
       
   593                 }   
       
   594             else if ( ctrl->ControlId() == EPeninutWindowCtrlIdHwrBox )
       
   595                 {
       
   596                 TInt language = penData->iRecognizer->GetLanguage();
       
   597                 TInt curRange = CPeninputDataConverter::AnyToInt( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   598                 if (language == ELangArabic && curRange
       
   599                                 > ERangeInvalid)
       
   600                             {
       
   601                             if (language == ELangArabic && curRange
       
   602                                     == ERangeNative)
       
   603                                 {
       
   604                                 iHwBox->SetRect(rect);
       
   605                                 DrawGuideLine();
       
   606                                 }
       
   607                             else
       
   608                                 {
       
   609                                 //recalculate rect size to include dropdown list area.
       
   610                                 rect.iTl = point + TPoint(
       
   611                                         controlList[i]->BeginColumn()
       
   612                                                 * unitWidth,
       
   613                                         (controlList[i]->BeginRow() - 2)
       
   614                                                 * unitHeight);
       
   615                                 cols = controlList[i]->EndColumn()
       
   616                                         - controlList[i]->BeginColumn();
       
   617                                 rows = controlList[i]->EndRow()
       
   618                                         - controlList[i]->BeginRow() + 2;
       
   619                                 rect.SetSize(TSize(cols * unitWidth, rows
       
   620                                         * unitHeight) );
       
   621                                 iHwBox->SetRect(rect);
       
   622                                 DrawGuideLine();
       
   623                                 }
       
   624                             }
       
   625                         else
       
   626                             {
       
   627                             iHwBox->SetRect(rect);
       
   628                             DrawGuideLine();
       
   629                             }
       
   630                 }
       
   631             else if(ctrl->ControlId() == EPentinputHwrCandidateList)
       
   632                 {
       
   633                 TInt language = penData->iRecognizer->GetLanguage();
       
   634                 TInt curRange = CPeninputDataConverter::AnyToInt( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   635                 if(language == ELangArabic && curRange > ERangeInvalid)
       
   636                     {
       
   637                 if(language == ELangArabic && curRange == ERangeNative)
       
   638                     {
       
   639                     iDropdownList->SetRect(rect);
       
   640                     iDropdownList->Hide(EFalse);
       
   641                     }
       
   642                 else
       
   643                     {
       
   644                     iDropdownList->SetRect(TRect(0,0,0,0));
       
   645                     }
       
   646                     }
       
   647                 else
       
   648                     {
       
   649                     iDropdownList->SetRect(rect);
       
   650                     iDropdownList->Hide(EFalse);                    
       
   651                     }
       
   652                 }
       
   653             }
       
   654         }   
       
   655     }
       
   656 
       
   657 // --------------------------------------------------------------------------
       
   658 // CPeninputHwrBxAbWnd::CalculateGuideLinePos
       
   659 // (other items were commented in a header)
       
   660 // --------------------------------------------------------------------------
       
   661 //
       
   662 void CPeninputHwrBxAbWnd::CalculateGuideLinePos()
       
   663       {
       
   664       TRect rect = iHwBox->Rect();
       
   665     TInt leftrightmargin = rect.Size().iWidth / 10;
       
   666     
       
   667     TSize size;
       
   668     size.iHeight = rect.iBr.iY - rect.iTl.iY;
       
   669     size.iWidth = rect.iBr.iX - rect.iTl.iX;
       
   670     iLayoutContext->SetData( EAkninputDataTypeInputArea, &size );
       
   671     
       
   672     TInt bottommargin = *(TInt*)iLayoutContext->RequestData( EAkninputDataTypeGuideLineBottom );
       
   673     TInt topmargin = *(TInt*)iLayoutContext->RequestData( EAkninputDataTypeGuideLineTop );
       
   674         
       
   675     //TAknWindowLineLayout guideLineTop = AknLayoutScalable_Avkon::fep_hwr_write_pane_g5(0).LayoutLine();
       
   676     //TAknWindowLineLayout guideLineBottom = AknLayoutScalable_Avkon::fep_hwr_write_pane_g6(0).LayoutLine();
       
   677     
       
   678     iGuideLineTopTl.iX = rect.iTl.iX + leftrightmargin;
       
   679     iGuideLineTopTl.iY = rect.iTl.iY + topmargin;
       
   680     
       
   681     iGuideLineTopBr.iX = rect.iBr.iX - leftrightmargin;
       
   682     iGuideLineTopBr.iY = rect.iTl.iY + topmargin;
       
   683     
       
   684     iGuideLineBottomTl.iX = rect.iTl.iX + leftrightmargin;
       
   685     iGuideLineBottomTl.iY = rect.iTl.iY + bottommargin;
       
   686     
       
   687     iGuideLineBottomBr.iX = rect.iBr.iX - leftrightmargin;
       
   688     iGuideLineBottomBr.iY = rect.iTl.iY + bottommargin;
       
   689     
       
   690     iGuideLineSet = ETrue;
       
   691       }
       
   692 
       
   693 // --------------------------------------------------------------------------
       
   694 // CPeninputHwrBxAbWnd::DrawGuideLine
       
   695 // (other items were commented in a header)
       
   696 // --------------------------------------------------------------------------
       
   697 //
       
   698 void CPeninputHwrBxAbWnd::DrawGuideLine()
       
   699     {
       
   700     // Set guide line
       
   701     if ( ConfigInfo() )
       
   702         {
       
   703         TInt style = ConfigInfo()->GuideLine();
       
   704         
       
   705         CPeninputHwrBxAbDataMgr::THandWritingPenData* penData = 
       
   706     ( CPeninputHwrBxAbDataMgr::THandWritingPenData* ) 
       
   707     iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
       
   708     
       
   709         TInt language = penData->iRecognizer->GetLanguage();
       
   710         
       
   711             TInt curRange = CPeninputDataConverter::AnyToInt
       
   712         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );   
       
   713         
       
   714         if(language == ELangHindi && curRange == ERangeNative)
       
   715             style = EPeninputGuideLineTop;
       
   716         
       
   717         iHwBox->SetGuideLineStyle( style );
       
   718 
       
   719         // if size changing, or guide line pos has not been set
       
   720         CalculateGuideLinePos();
       
   721         
       
   722         if ( style == EPeninputGuideLineTop)
       
   723             {
       
   724             iHwBox->SetTopGuideLinePosition(iGuideLineTopTl, iGuideLineTopBr);
       
   725             }
       
   726         else if ( style == EPeninputGuideLineBottom)
       
   727             {
       
   728             iHwBox->SetBottomGuideLinePosition(iGuideLineBottomTl, iGuideLineBottomBr);
       
   729             }
       
   730         else if ( style == EPeninputGuideLineBoth)
       
   731             {
       
   732             iHwBox->SetTopGuideLinePosition(iGuideLineTopTl, iGuideLineTopBr);
       
   733             iHwBox->SetBottomGuideLinePosition(iGuideLineBottomTl, iGuideLineBottomBr);
       
   734             }
       
   735             
       
   736         iHwBox->RefreshUI();            
       
   737         }        
       
   738     }
       
   739 // --------------------------------------------------------------------------
       
   740 // CPeninputHwrBxAbWnd::SetControlsFont
       
   741 // (other items were commented in a header)
       
   742 // --------------------------------------------------------------------------
       
   743 //
       
   744 void CPeninputHwrBxAbWnd::SetControlsFont()
       
   745     {
       
   746     TAknTextLineLayout textPaneTextLayout;
       
   747     TAknLayoutText txt;
       
   748     textPaneTextLayout = 
       
   749         AknLayoutScalable_Avkon::fep_hwr_top_text_pane_t1().LayoutLine();
       
   750   
       
   751     TInt leftMargin, rightMargin, topMargin, txtHeight;
       
   752     
       
   753     CFepLayoutMultiLineIcf* icf = static_cast<CFepLayoutMultiLineIcf*>
       
   754                                     (Control(EPeninputWindowCtrlIdMultiLineICF));
       
   755     TRect rect = icf->Rect();
       
   756     txt.LayoutText( rect, textPaneTextLayout );
       
   757     TRect txtRect = txt.TextRect();
       
   758     leftMargin = txtRect.iTl.iX - rect.iTl.iX;
       
   759     rightMargin = rect.iBr.iX - txtRect.iBr.iX;
       
   760     topMargin = txtRect.iTl.iY - rect.iTl.iY;
       
   761     txtHeight = txtRect.Height();
       
   762             
       
   763     icf->SetTextMargin( leftMargin, rightMargin, topMargin, 0);
       
   764     icf->SetLineSpace( 1 );
       
   765     const CFont* icfFont = AknLayoutUtils::FontFromId( textPaneTextLayout.iFont, NULL );
       
   766         
       
   767     TRAP_IGNORE(icf->SizeChangedL( 
       
   768           static_cast<CFepLayoutMultiLineIcf*>(
       
   769                                   Control(EPeninputWindowCtrlIdMultiLineICF))->Rect(), 
       
   770                                   txtHeight,
       
   771                                   icfFont->FontMaxHeight(),
       
   772                                   icfFont));    
       
   773     }
       
   774 
       
   775 // --------------------------------------------------------------------------
       
   776 // CPeninputHwrBxAbWnd::AddRangeBarL
       
   777 // (other items were commented in a header)
       
   778 // --------------------------------------------------------------------------
       
   779 //
       
   780 void CPeninputHwrBxAbWnd::AddRangeBarL()
       
   781     {
       
   782     // Range bar
       
   783     iRangeBar = CAknFepCtrlRangeBar::NewL( UiLayout(), 
       
   784         EPeninutWindowCtrlIdRangeBar, 
       
   785         CAknFepCtrlRangeBar::EBtnGroupVertical );
       
   786           
       
   787     // Set event id
       
   788     iRangeBar->SetEventIdForRange( EPeninputLayoutEventRange );
       
   789     iRangeBar->SetEventIdForCase( EPeninputLayoutEventRangeLoop );
       
   790 //    ClientPane()->AddControlL(iRangeBar);
       
   791 //    iRangeBar->AddEventObserver(UiLayout());      
       
   792     if (iCtrlPool)
       
   793         {
       
   794         iCtrlPool->AddControl(iRangeBar);
       
   795         }
       
   796     }
       
   797         
       
   798 // --------------------------------------------------------------------------
       
   799 // CPeninputHwrBxAbWnd::AddButtonL
       
   800 // (other items were commented in a header)
       
   801 // --------------------------------------------------------------------------
       
   802 //
       
   803 CAknFepCtrlEventButton* CPeninputHwrBxAbWnd::AddButtonL( 
       
   804     const TInt aControlId, const TInt aEventId, const TInt aResId,
       
   805     const TInt aUnicode, const TBool aIsRepeat )
       
   806     {
       
   807     CAknFepCtrlEventButton* button = NULL;
       
   808     
       
   809     if ( aIsRepeat )
       
   810         {
       
   811         button = CAknFepCtrlRepeatButton::NewL( UiLayout(), aControlId, 
       
   812                                                 aEventId, aUnicode );
       
   813         }
       
   814     else
       
   815         {
       
   816         button = CAknFepCtrlEventButton::NewL( UiLayout(), aControlId, 
       
   817                                                aEventId, aUnicode,
       
   818                                               KAknsIIDQsnFrFunctionButtonNormal,
       
   819                                               KAknsIIDQsnFrFunctionButtonPressed,
       
   820                                               KAknsIIDQsnFrFunctionButtonInactive );
       
   821         }
       
   822         
       
   823     CleanupStack::PushL( button );
       
   824     if ( button )
       
   825         {
       
   826         // Read resource
       
   827         TResourceReader reader;
       
   828         
       
   829         CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId );
       
   830         button->SetResourceId( aResId );
       
   831         button->ConstructFromResourceL();
       
   832         // Pop and destroy reader
       
   833         CleanupStack::PopAndDestroy( 1 );
       
   834         
       
   835         // Add into the control pool                                                   
       
   836         if ( iCtrlPool )
       
   837             {
       
   838             iCtrlPool->AddControl( button );
       
   839             }
       
   840         }
       
   841     CleanupStack::Pop( button );
       
   842              
       
   843     return button;
       
   844     }
       
   845 void CPeninputHwrBxAbWnd::AddBackspaceButtonL()
       
   846     {
       
   847     iBackspaceButton = CAknFepCtrlRepeatButton::NewL( 
       
   848                                       UiLayout(), EPeninutWindowCtrlIdBackspaceBtn,
       
   849                                       EPeninputLayoutEventBack, EKeyBackspace, 
       
   850                                       KAknsIIDQsnFrFunctionButtonNormal,
       
   851                                       KAknsIIDQsnFrFunctionButtonPressed,
       
   852                                       KAknsIIDQsnFrFunctionButtonInactive );
       
   853 //    iBackspaceButton->AddEventObserver( UiLayout() );
       
   854     // Read resource
       
   855     TResourceReader reader;
       
   856     
       
   857     CCoeEnv::Static()->CreateResourceReaderLC( reader, R_PENINPUT_LAYOUT_HWR_BACKSPACE );
       
   858     iBackspaceButton->SetResourceId( R_PENINPUT_LAYOUT_HWR_BACKSPACE );
       
   859     iBackspaceButton->ConstructFromResourceL();
       
   860     // Pop and destroy reader
       
   861     CleanupStack::PopAndDestroy( 1 );    
       
   862     }
       
   863 // --------------------------------------------------------------------------
       
   864 // CPeninputHwrBxAbWnd::AddHwBoxL
       
   865 // (other items were commented in a header)
       
   866 // --------------------------------------------------------------------------
       
   867 //
       
   868 void CPeninputHwrBxAbWnd::AddHwBoxL()
       
   869     {
       
   870     CPeninputHwrBxAbDataMgr::THandWritingPenData* penData = 
       
   871         ( CPeninputHwrBxAbDataMgr::THandWritingPenData* ) 
       
   872         iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
       
   873     
       
   874     iHwBox = CTransparentHwrWndExt::NewL( Rect(), UiLayout(), 
       
   875                                           EPeninutWindowCtrlIdHwrBox, 
       
   876                                           EFalse, penData->iGuideLineOn ); 
       
   877     iHwBox->SetEnableFade( ETrue );                                           
       
   878     iHwBox->EnableTraceOutsideWindow( EFalse );
       
   879     iHwBox->SetWndTransparencyFactor(iNormalTransFactor);
       
   880     
       
   881     if ( iCtrlPool )
       
   882         {
       
   883         iCtrlPool->AddControl( iHwBox );       
       
   884         }
       
   885     
       
   886     SetHwBoxFrameBackColor();
       
   887     }
       
   888 // ---------------------------------------------------------
       
   889 // Add dropdown list to window
       
   890 // ---------------------------------------------------------
       
   891 //
       
   892 void CPeninputHwrBxAbWnd::AddDropdownListL(TBool aLandscapeStyle)
       
   893     {   
       
   894     TResourceReader reader;
       
   895     CCoeEnv::Static()->CreateResourceReaderLC(reader,R_PENINPUT_LAYOUT_DROP_DOWN_LIST);
       
   896     
       
   897 //    iSecondRangeColor = TRgb(0xFF0000);
       
   898 
       
   899     ReadLafInfo(aLandscapeStyle);
       
   900     TAknTextLineLayout candTextLayout = 
       
   901                       AknLayoutScalable_Avkon::cell_hwr_candidate_pane_t1(0).LayoutLine();
       
   902 
       
   903     TInt textMargin = (iUnitHeight - 
       
   904                       AknLayoutUtils::FontFromId(candTextLayout.iFont, NULL)->HeightInPixels())/2;
       
   905 
       
   906     TDropdownListDrawInfo candiDrawInfo(KAknsIIDQsnFrFunctionButtonInactive, 
       
   907                                         KAknsIIDQsnFrFunctionButtonNormal,
       
   908                                         KAknsIIDQsnFrFunctionButtonPressed,
       
   909                                         KAknsIIDQsnFrItutButtonCandiSideL,
       
   910                                         KAknsIIDQsnFrItutButtonCandiMiddle,
       
   911                                         KAknsIIDQsnFrItutButtonCandiSideR,
       
   912                                         KAknsIIDQsnFrItutButtonCandiPressedSideL,
       
   913                                         KAknsIIDQsnFrItutButtonCandiPressedMiddle,
       
   914                                         KAknsIIDQsnFrItutButtonCandiPressedSideR,
       
   915                                         TRgb(194, 221, 242),
       
   916                                         ETrue);
       
   917     CFont* listfont = (CFont *)AknLayoutUtils::FontFromId(candTextLayout.iFont, NULL);
       
   918     
       
   919     iDropdownList = CFepCtrlDropdownList::NewL(UiLayout(),
       
   920                                                EPentinputHwrCandidateList,
       
   921                                                R_PENINPUT_LAYOUT_DROP_DOWN_LIST,                                            
       
   922                                                TPoint(Rect().iTl.iX + 3, Rect().iTl.iY + 3 + iUnitHeight),                                               
       
   923                                                listfont ,
       
   924                                                TSize(iUnitWidth,iUnitHeight),
       
   925                                                iUnitWidth,
       
   926                                                6,2,
       
   927                                                iUnitHeight,
       
   928                                                0,
       
   929                                                0,
       
   930                                                CFepCtrlDropdownList::ECandFromRToL,
       
   931                                                EFalse);
       
   932     if ( iCtrlPool )
       
   933         {
       
   934         iCtrlPool->AddControl( iDropdownList );       
       
   935         }
       
   936     iDropdownList->SetFont(listfont);    
       
   937     iDropdownList->SetEventIdForCandidateSelected(EPeninputLayoutHwrEventCandidateSelected);
       
   938     //iDropdownList->SetEventIdForNextPageCandidate(EPeninputLayoutHwrEventGetNextCandidatePage);
       
   939     //iDropdownList->SetEventIdForPreviousPageCandidate(EPeninputLayoutHwrEventGetPreviousCandidatePage);
       
   940     iDropdownList->SetEventIdForCandidateExisted(EPeninputLayoutHwrEventCandidateExisted);
       
   941     iDropdownList->SetCandTruncateType(CFepCtrlDropdownList::ECandTruncateFromBeginning);    
       
   942     iDropdownList->SetDropdownListImgID(candiDrawInfo);
       
   943     
       
   944     CleanupStack::PopAndDestroy(); // reader  
       
   945     }       
       
   946     // ---------------------------------------------------------
       
   947 // CAknFepHwrBxWnd::ReadUnitSize
       
   948 // ---------------------------------------------------------
       
   949 //
       
   950 void CPeninputHwrBxAbWnd::ReadLafInfo(TBool aLandscapeStyle)
       
   951 	{
       
   952 	//if (iDataMgr->SizeChanging())// || (!iUnitShadowSizeSet))
       
   953 		{
       
   954         // if size is changing, or unit size, shadow size have not been set yet
       
   955         TAknWindowLineLayout appWnd;
       
   956         TAknWindowLineLayout mainPane;
       
   957         TAknWindowLineLayout wndLayout;
       
   958         TAknWindowLineLayout unitLayout;
       
   959         TAknWindowLineLayout shadowPane;
       
   960         TAknWindowLineLayout shadowTl;
       
   961         TAknWindowLineLayout shadowBr;
       
   962         TAknLayoutRect mainPaneRect;
       
   963         TAknLayoutRect wndRect;
       
   964         TAknLayoutRect unitRect;
       
   965         TAknLayoutRect shadowRect;
       
   966         TAknLayoutRect shadowTlRect;
       
   967         TAknLayoutRect shadowBrRect;
       
   968 
       
   969         // Get hwr window layout
       
   970         appWnd = AknLayoutScalable_Avkon::application_window(0).LayoutLine();
       
   971         
       
   972         if (aLandscapeStyle)
       
   973         	{
       
   974     	    // landscape
       
   975     	    mainPane = AknLayoutScalable_Avkon::main_pane(4).LayoutLine();
       
   976             wndLayout = AknLayoutScalable_Avkon::popup_fep_hwr_window(2).LayoutLine();
       
   977         	}
       
   978         else
       
   979         	{
       
   980             // portrait	
       
   981             mainPane = AknLayoutScalable_Avkon::main_pane(1).LayoutLine();
       
   982             wndLayout = AknLayoutScalable_Avkon::popup_fep_hwr_window(0).LayoutLine();
       
   983         	}	
       
   984 
       
   985         mainPaneRect.LayoutRect(appWnd.Rect(), mainPane);
       
   986         wndRect.LayoutRect(mainPaneRect.Rect(), wndLayout);
       
   987     
       
   988         unitLayout = AknLayoutScalable_Avkon::fep_hwr_aid_pane(1).LayoutLine();
       
   989         unitRect.LayoutRect(wndRect.Rect(), unitLayout);
       
   990     
       
   991         TRect hwrWndRect = TRect(0, 
       
   992                                  0,
       
   993                                  wndRect.Rect().Width(),
       
   994                                  wndRect.Rect().Height());
       
   995                              
       
   996         iUnitWidth = unitRect.Rect().Width();
       
   997         iUnitHeight = unitRect.Rect().Height();
       
   998 
       
   999         shadowPane = AknLayoutScalable_Avkon::bg_popup_fep_shadow_pane(2).LayoutLine();
       
  1000         shadowRect.LayoutRect(hwrWndRect, shadowPane);
       
  1001     
       
  1002         shadowTl = AknLayoutScalable_Avkon::bg_popup_fep_shadow_pane_g1().LayoutLine();
       
  1003         shadowTlRect.LayoutRect(shadowRect.Rect(), shadowTl);
       
  1004     
       
  1005         shadowBr = AknLayoutScalable_Avkon::bg_popup_fep_shadow_pane_g8().LayoutLine();
       
  1006         shadowBrRect.LayoutRect(shadowRect.Rect(), shadowBr);
       
  1007     
       
  1008         iShadowTl = shadowTlRect.Rect().Size();
       
  1009         iShadowBr = shadowBrRect.Rect().Size();
       
  1010         
       
  1011         //iUnitShadowSizeSet = ETrue;
       
  1012 		}
       
  1013  	}
       
  1014  
       
  1015 // --------------------------------------------------------------------------
       
  1016 // CPeninputHwrBxAbWnd::SetHwBoxFrameBackColor
       
  1017 // (other items were commented in a header)
       
  1018 // --------------------------------------------------------------------------
       
  1019 //
       
  1020 void CPeninputHwrBxAbWnd::SetHwBoxFrameBackColor()
       
  1021     {
       
  1022     TRgb frameColor;
       
  1023     TRgb backColor;
       
  1024     TAknsItemID id;
       
  1025     
       
  1026     id.Set(KWriteBoxFrameBackColorMajor, KWriteBoxFrameBackColorGrp);
       
  1027 
       
  1028     TInt error = AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
       
  1029                                            frameColor,
       
  1030                                            id,
       
  1031                                            KWriteBoxFrameBackColorIdx);
       
  1032 
       
  1033     if (error != KErrNone)
       
  1034         {
       
  1035         frameColor = TRgb(KDefaultWriteBoxFrameColor);
       
  1036         backColor = TRgb(KDefaultWriteBoxBackColor);
       
  1037         }
       
  1038     else
       
  1039         {
       
  1040         backColor = frameColor; 
       
  1041         }
       
  1042     
       
  1043     if (iHwBox)
       
  1044         {
       
  1045         iHwBox->SetFrameCol(frameColor);
       
  1046         iHwBox->SetBkColor(backColor);
       
  1047         }
       
  1048     }
       
  1049 
       
  1050 // --------------------------------------------------------------------------
       
  1051 // CPeninputHwrBxAbWnd::PopupChoiceList
       
  1052 // (other items were commented in a header)
       
  1053 // --------------------------------------------------------------------------
       
  1054 //
       
  1055 void CPeninputHwrBxAbWnd::PopupChoiceList()
       
  1056     {
       
  1057     }
       
  1058 
       
  1059 // --------------------------------------------------------------------------
       
  1060 // CPeninputHwrBxAbWnd::DoCaseChange
       
  1061 // (other items were commented in a header)
       
  1062 // --------------------------------------------------------------------------
       
  1063 //
       
  1064 void CPeninputHwrBxAbWnd::DoCaseChange( TInt aNewCase )
       
  1065     {
       
  1066     if( iDisableCaseChange )
       
  1067         {
       
  1068         iCachedCase = aNewCase;
       
  1069         return;
       
  1070         }
       
  1071         
       
  1072     TInt curRange = CPeninputDataConverter::AnyToInt
       
  1073         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
  1074     TInt index = 0;
       
  1075     
       
  1076     if ( ( curRange == ERangeEnglish ) 
       
  1077          || ( ( curRange == ERangeNative ) && ( ConfigInfo()->CaseSensitive() ) ) )
       
  1078         {
       
  1079         switch ( aNewCase )
       
  1080             {
       
  1081             case ECaseUpper:
       
  1082                 {
       
  1083                 index = 2;
       
  1084                 }
       
  1085                 break;
       
  1086             case ECaseLower:
       
  1087                 {
       
  1088                 index = 1;
       
  1089                 }
       
  1090                 break;
       
  1091             case ECaseText:
       
  1092                 {
       
  1093                 index = 0;
       
  1094                 }
       
  1095                 break;
       
  1096             default:
       
  1097                 break;
       
  1098             }
       
  1099             
       
  1100         TRAP_IGNORE( iRangeBar->SetCaseL( curRange, index ) );    
       
  1101         iLayoutContext->SetData( EPeninputDataTypeCase, &aNewCase );
       
  1102         }
       
  1103         //to modify guideline pos.
       
  1104         iHwBox->RefreshUI();
       
  1105         DrawGuideLine();
       
  1106     }
       
  1107 
       
  1108 // --------------------------------------------------------------------------
       
  1109 // CPeninputHwrBxAbWnd::OnStrokeStarted
       
  1110 // (other items were commented in a header)
       
  1111 // --------------------------------------------------------------------------
       
  1112 //
       
  1113 void CPeninputHwrBxAbWnd::OnStrokeStarted()
       
  1114     {
       
  1115     iDisableCaseChange = ETrue;
       
  1116     iHwBox->SetWndTransparencyFactor(iWriteTransFactor);
       
  1117     if( !iCharacterStart )
       
  1118         {
       
  1119         iCharacterStart = ETrue;
       
  1120     
       
  1121         TBuf<4> buf;
       
  1122         buf.Append(reinterpret_cast<TText*>(&iCharacterStart), sizeof(TBool)/sizeof(TText));
       
  1123         iLayoutContext->Sendkey( ESignalCharacterStart, buf );
       
  1124         
       
  1125         }    
       
  1126     }
       
  1127 
       
  1128 // --------------------------------------------------------------------------
       
  1129 // CPeninputHwrBxAbWnd::OnStrokeFinished
       
  1130 // (other items were commented in a header)
       
  1131 // --------------------------------------------------------------------------
       
  1132 //
       
  1133 void CPeninputHwrBxAbWnd::OnStrokeFinished()
       
  1134     {    
       
  1135     // No trace
       
  1136     if ( !iHwBox->HasNewTrace() )
       
  1137         {
       
  1138         return;
       
  1139         }
       
  1140     
       
  1141     RArray<TPoint> strokes = iHwBox->StrokeList();
       
  1142     
       
  1143     iStrokeArray.Reset();
       
  1144     
       
  1145     const TInt count = strokes.Count();
       
  1146     
       
  1147 #ifdef _NOT_USING_DECUMA_MCR_
       
  1148     // similar as S90         
       
  1149     
       
  1150     for ( TInt i = 0; i < count; i++ )
       
  1151         {
       
  1152         iStrokeArray.Append( strokes[i] );
       
  1153         } 
       
  1154     
       
  1155     CPeninputHwrBxAbDataMgr::THandWritingPenData* penData = 
       
  1156         ( CPeninputHwrBxAbDataMgr::THandWritingPenData* ) 
       
  1157         iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
       
  1158     
       
  1159     TInt err = penData->iRecognizer->Recognize( iStrokeArray, iRecogResult );
       
  1160     
       
  1161     if ( err == KErrNone && iRecogResult.Count() > 0 )
       
  1162         {
       
  1163         TInt dataType = CPeninputDataConverter::AnyToInt(iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ));
       
  1164         if (dataType == ERangeNative)
       
  1165             {
       
  1166             if( iRecogResult[0]->Locate( EKeyBackspace ) == KErrNotFound 
       
  1167               && iRecogResult[0]->Locate( EKeyFormFeed ) == KErrNotFound
       
  1168               && iRecogResult[0]->Locate( EKeySpace ) == KErrNotFound 
       
  1169               && iRecogResult[0]->Locate( EKeyEnter ) == KErrNotFound
       
  1170               && iRecogResult[0]->Locate(EKeyDelete) == KErrNotFound)
       
  1171                 {
       
  1172                 for (TInt i = 1; i < iRecogResult.Count(); i++)
       
  1173                     {
       
  1174                     if((iRecogResult[i]->Locate( EKeyBackspace ) != KErrNotFound)
       
  1175                             ||(iRecogResult[i]->Locate( EKeySpace ) != KErrNotFound)
       
  1176                             ||(iRecogResult[i]->Locate( EKeyLineFeed ) != KErrNotFound)
       
  1177                             ||(iRecogResult[i]->Locate( EKeyEnter ) != KErrNotFound))
       
  1178                         {
       
  1179                         delete iRecogResult[i];
       
  1180                         iRecogResult.Remove(i);
       
  1181                         }
       
  1182                     }
       
  1183                 iDropdownList->Hide(EFalse);
       
  1184                 TRAP_IGNORE(iDropdownList->SetCandidatesL(iRecogResult,
       
  1185                         CFepCtrlDropdownList::EListExpandableMultiRowWithoutIcon ));
       
  1186                 iDropdownList->SetHighlightCell(0);
       
  1187                 }
       
  1188             else
       
  1189                 {
       
  1190                 ResetAndShowDropdownList();                
       
  1191                 }
       
  1192             }
       
  1193         else
       
  1194             {
       
  1195             ClearAndCloseDropdownList();
       
  1196             }
       
  1197                 
       
  1198         SubmitRecognitionResult( iRecogResult[0] );
       
  1199 
       
  1200         
       
  1201         }
       
  1202 #else          
       
  1203 
       
  1204     for ( TInt i = 0; i < count; i++ )
       
  1205         {
       
  1206         iStrokeArray.Append( strokes[i] );
       
  1207         } 
       
  1208         
       
  1209 #endif
       
  1210     }
       
  1211 
       
  1212 // --------------------------------------------------------------------------
       
  1213 // CPeninputHwrBxAbWnd::OnStrokeCharacterTimerOut
       
  1214 // (other items were commented in a header)
       
  1215 // --------------------------------------------------------------------------
       
  1216 //
       
  1217 void CPeninputHwrBxAbWnd::OnStrokeCharacterTimerOut()
       
  1218     {
       
  1219     iDisableCaseChange = EFalse;
       
  1220     DoCaseChange(iCachedCase);
       
  1221     iHwBox->SetWndTransparencyFactor(iNormalTransFactor);
       
  1222 #ifdef _NOT_USING_DECUMA_MCR_    
       
  1223     // similar as S90     
       
  1224     CPeninputHwrBxAbDataMgr::THandWritingPenData* penData = 
       
  1225     ( CPeninputHwrBxAbDataMgr::THandWritingPenData* ) 
       
  1226     iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
       
  1227     
       
  1228     TInt language = penData->iRecognizer->GetLanguage();
       
  1229     if( language == ELangThai || language == ELangHindi || language == ELangVietnamese )
       
  1230         {
       
  1231         // This is a workarround to clear the recognizer.
       
  1232         RArray<TPoint> stroke_array;
       
  1233         stroke_array.Reset(); 
       
  1234         // Call recognize with a empty array of stroke is the condition
       
  1235         // to clear the context>
       
  1236         TInt err = penData->iRecognizer->Recognize( stroke_array, iRecogResult );
       
  1237         if( err == KErrNone && iRecogResult.Count() > 0 )
       
  1238             {
       
  1239             TInt dataType = CPeninputDataConverter::AnyToInt(iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ));
       
  1240             if (dataType == ERangeNative)
       
  1241                 {
       
  1242                 iDropdownList->Hide(EFalse);
       
  1243                 TRAP_IGNORE(iDropdownList->SetCandidatesL(iRecogResult, CFepCtrlDropdownList::EListExpandableMultiRowWithoutIcon ));
       
  1244                 }
       
  1245             else
       
  1246                 {
       
  1247                 ClearAndCloseDropdownList();
       
  1248                 }
       
  1249             SubmitRecognitionResult( iRecogResult[0] );
       
  1250             }
       
  1251         }
       
  1252 
       
  1253     delete iLastResult;
       
  1254     iLastResult = NULL;     
       
  1255         
       
  1256 #else
       
  1257 
       
  1258     CPeninputHwrBxAbDataMgr::THandWritingPenData* penData = 
       
  1259         ( CPeninputHwrBxAbDataMgr::THandWritingPenData* ) 
       
  1260         iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
       
  1261     
       
  1262     TInt err = penData->iRecognizer->Recognize( iStrokeArray, iRecogResult );
       
  1263     if ( err == KErrNone && iRecogResult.Count() > 0 )
       
  1264         {        
       
  1265         const HBufC* res = iRecogResult[0];
       
  1266         iLayoutContext->Sendkey( ESignalKeyEvent, *res );
       
  1267         } 
       
  1268     iStrokeArray.Reset();    
       
  1269      
       
  1270 #endif
       
  1271     iCharacterStart = EFalse;
       
  1272     }
       
  1273 
       
  1274 // --------------------------------------------------------------------------
       
  1275 // CPeninputHwrBxAbWnd::OnStrokeCanceled
       
  1276 // (other items were commented in a header)
       
  1277 // --------------------------------------------------------------------------
       
  1278 //
       
  1279 void CPeninputHwrBxAbWnd::OnStrokeCanceled()
       
  1280     {
       
  1281     iDisableCaseChange = EFalse;
       
  1282     iHwBox->SetWndTransparencyFactor(iNormalTransFactor);
       
  1283 #ifdef _NOT_USING_DECUMA_MCR_    
       
  1284     // similar as S90     
       
  1285     CPeninputHwrBxAbDataMgr::THandWritingPenData* penData = 
       
  1286     ( CPeninputHwrBxAbDataMgr::THandWritingPenData* ) 
       
  1287     iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
       
  1288     
       
  1289     TInt language = penData->iRecognizer->GetLanguage();
       
  1290     if( language == ELangThai || language == ELangHindi || language == ELangVietnamese )
       
  1291         {
       
  1292         // This is a workarround to clear the recognizer.
       
  1293         RArray<TPoint> stroke_array;
       
  1294         stroke_array.Reset(); 
       
  1295         // Call recognize with a empty array of stroke is the condition
       
  1296         // to clear the context>
       
  1297         TInt err = penData->iRecognizer->Recognize( stroke_array, iRecogResult );       
       
  1298 //        if( err == KErrNone && iRecogResult.Count() > 0 )
       
  1299 //            {
       
  1300 //            SubmitRecognitionResult( iRecogResult[0] );
       
  1301 //            }
       
  1302         }
       
  1303 
       
  1304     delete iLastResult;
       
  1305     iLastResult = NULL;     
       
  1306         
       
  1307      
       
  1308 #endif
       
  1309     iCharacterStart = EFalse;
       
  1310     } 
       
  1311 
       
  1312 // -----------------------------------------------------------------------------
       
  1313 // CPeninputHwrBxAbWnd::ConstructFromResourceL
       
  1314 // (other items were commented in a header).
       
  1315 // -----------------------------------------------------------------------------
       
  1316 //
       
  1317 void CPeninputHwrBxAbWnd::ConstructFromResourceL()
       
  1318     {               
       
  1319     CPeninputLayoutWindow::ConstructFromResourceL();
       
  1320     
       
  1321     if (iLangSwitchBtn)
       
  1322         {
       
  1323         SetSwitchBtnTextColor(*iLangSwitchBtn);
       
  1324         } 
       
  1325     iBackspaceMirrored = EFalse;
       
  1326     if(!iBackspaceButton)
       
  1327         {
       
  1328         AddBackspaceButtonL();
       
  1329         // Add into the group   
       
  1330         CControlGroup* headerPane = HeaderPane();            
       
  1331         headerPane->AddControlL(iBackspaceButton);
       
  1332         iBackspaceButton->AddEventObserver(UiLayout());            
       
  1333         }        
       
  1334     SetHwBoxFrameBackColor();    
       
  1335     
       
  1336     TRgb* penColor =
       
  1337                     ( TRgb* ) iLayoutContext->RequestData(EPeninputDataTypePenTailColor);
       
  1338     if (iHwBox)
       
  1339         {
       
  1340         iHwBox->SetPenColor( *penColor);
       
  1341         }  
       
  1342     }
       
  1343 
       
  1344 // ---------------------------------------------------------------------------
       
  1345 // CPeninputHwrBxAbWnd::PopupSwitchWindow
       
  1346 // (other items were commented in a header).
       
  1347 // ---------------------------------------------------------------------------
       
  1348 //
       
  1349 void CPeninputHwrBxAbWnd::PopupSwitchWindow()
       
  1350     {
       
  1351     CFepUiBaseCtrl* modeSwitchBtn = Control(EPeninutWindowCtrlIdSwitchToVkbBtn);
       
  1352 
       
  1353     if ( modeSwitchBtn )
       
  1354         {
       
  1355         TRect rect = modeSwitchBtn->Rect();   
       
  1356         TRAP_IGNORE(iModeSwitchChoice->PopUpSwitchListL(rect));
       
  1357         }      
       
  1358     }
       
  1359 // ---------------------------------------------------------------------------
       
  1360 // CPeninputHwrBxAbWnd::OnDeActivate
       
  1361 // (other items were commented in a header).
       
  1362 // ---------------------------------------------------------------------------
       
  1363 //
       
  1364 void CPeninputHwrBxAbWnd::OnDeActivate()
       
  1365     {
       
  1366     //reset range
       
  1367     TInt range = -1;
       
  1368     iLayoutContext->SetData( EPeninputDataTypeCurrentRange, &range );
       
  1369     CPeninputLayoutWindow::OnDeActivate();
       
  1370     iDropdownList->ResetAndClear(CFepCtrlDropdownList::EListExpandableMultiRowWithoutIcon );
       
  1371     iDropdownList->Hide(ETrue);
       
  1372     }
       
  1373 
       
  1374 
       
  1375 TBool CPeninputHwrBxAbWnd::IsMultiLineIcf()
       
  1376     {
       
  1377     return ETrue;   
       
  1378     }
       
  1379     
       
  1380 TBool CPeninputHwrBxAbWnd::IsCanChangeRange(TInt aRange)
       
  1381     {
       
  1382     if (aRange == ERangeSymbol)
       
  1383         {
       
  1384         UiLayout()->SignalOwner(ESignalLaunchSCT);
       
  1385         
       
  1386         return EFalse;  
       
  1387         }
       
  1388         
       
  1389     return ETrue;
       
  1390     }  
       
  1391      
       
  1392 void CPeninputHwrBxAbWnd::ChangeToPreviousRange(TInt aRange)
       
  1393     {
       
  1394     if(iRangeBar)
       
  1395         {
       
  1396         iRangeBar->ActiveRange(aRange); 
       
  1397         }
       
  1398     }
       
  1399                                                                                                               
       
  1400 inline TBool IsLanguageBidi( TInt aLanguage )
       
  1401     {
       
  1402     return aLanguage == ELangArabic || aLanguage == ELangFarsi ||
       
  1403            aLanguage == ELangHebrew ;    
       
  1404     }
       
  1405 void CPeninputHwrBxAbWnd::OnLanguageChange()
       
  1406     {
       
  1407     TBool bidi = IsLanguageBidi( ConfigInfo()->Language() );
       
  1408     iHwBox->SetEnableFade( !bidi );                                           
       
  1409     }
       
  1410 
       
  1411 TBool CPeninputHwrBxAbWnd::IsAddingSpace(HBufC* aRes)
       
  1412     {
       
  1413     TInt curRange = CPeninputDataConverter::AnyToInt(iLayoutContext->RequestData(EPeninputDataTypeCurrentRange) );
       
  1414     if (curRange != ERangeNative)
       
  1415         {
       
  1416         return EFalse;
       
  1417         }
       
  1418     if (aRes->Des().Length() == 1)
       
  1419         {
       
  1420         if ( ( *aRes ).Compare(KStandardPuncDotPoint) == 0 || 
       
  1421              ( *aRes ).Compare(KStandardPuncExclamatoryPoint) == 0 || 
       
  1422              ( *aRes ).Compare(KArabicPuncComma) == 0 || 
       
  1423              ( *aRes ).Compare(KArabicPuncSemicolon) == 0 || 
       
  1424              ( *aRes ).Compare(KArabicPuncQuestion) == 0 ||
       
  1425              ( *aRes ).Compare(KArabicPuncWaw) == 0)
       
  1426             {
       
  1427             return ETrue;
       
  1428             }
       
  1429         }
       
  1430     else if (aRes->Des().Length() > 1)
       
  1431         {
       
  1432         if ( ( *aRes ).Locate(EKeyBackspace) == KErrNotFound &&
       
  1433              ( *aRes ).Locate(EKeyFormFeed) == KErrNotFound &&
       
  1434              ( *aRes ).Locate(EKeySpace) == KErrNotFound &&
       
  1435              ( *aRes ).Locate(EKeyEnter) == KErrNotFound &&
       
  1436              ( *aRes ).Locate(EKeyDelete) == KErrNotFound )
       
  1437             {
       
  1438             return ETrue;
       
  1439             }
       
  1440         }
       
  1441     return EFalse;
       
  1442     }
       
  1443 
       
  1444 void CPeninputHwrBxAbWnd::SubmitRecognitionResult(HBufC* aRes )
       
  1445     {
       
  1446     _LIT(KSpaceChar, " ");
       
  1447     TBuf<1> buf;
       
  1448     buf.Zero();
       
  1449     buf.Append(KSpaceChar); 
       
  1450     
       
  1451     if( !iLastResult )
       
  1452         {
       
  1453         if (!IsAddingSpace(aRes))
       
  1454             {
       
  1455             iLayoutContext->Sendkey(ESignalKeyEvent, *aRes);
       
  1456             }
       
  1457         else
       
  1458             {
       
  1459             HBufC* p = HBufC::New(aRes->Length() + buf.Length());
       
  1460             p->Des().Copy(*aRes);
       
  1461             p->Des().Append(buf);
       
  1462             iLayoutContext->Sendkey(ESignalKeyEvent, *p);
       
  1463             delete p;
       
  1464             }
       
  1465         }
       
  1466     else
       
  1467         {
       
  1468         if( iLastResult->Compare( *aRes ) != 0 )
       
  1469             {
       
  1470             //replace
       
  1471             if ( ( *aRes ).Locate( EKeyBackspace ) != KErrNotFound )
       
  1472                 {
       
  1473                 TBuf<1> buf;
       
  1474                 buf.Append( EKeyBackspace );
       
  1475                 iLayoutContext->Sendkey( ESignalKeyEvent, buf );
       
  1476                 }
       
  1477             else
       
  1478                 {                 
       
  1479                 HBufC* p = NULL;
       
  1480                 if (IsAddingSpace(aRes))
       
  1481                     {
       
  1482                     p = HBufC::New(aRes->Length() + 2 + buf.Length());
       
  1483                     }
       
  1484                 else
       
  1485                     {
       
  1486                     p = HBufC::New(aRes->Length() + 2);
       
  1487                     }
       
  1488                 if( p )
       
  1489                     {
       
  1490                     TInt len = iLastResult->Length();
       
  1491                     if (IsAddingSpace(aRes))
       
  1492                         {
       
  1493                         len += buf.Length();
       
  1494                         }
       
  1495                     p->Des().Append((TUint16*)&len, 2);
       
  1496                     p->Des().Append(*aRes);
       
  1497                     if (IsAddingSpace(aRes))
       
  1498                         {
       
  1499                         p->Des().Append(buf);
       
  1500                         }                        
       
  1501                     iLayoutContext->Sendkey( ESignalReplaceText, *p );
       
  1502                     delete p;
       
  1503                     }
       
  1504                 }
       
  1505             }
       
  1506         }
       
  1507         
       
  1508     delete iLastResult;
       
  1509     iLastResult = NULL;
       
  1510     
       
  1511     if ( (*aRes).Locate( EKeyBackspace ) != KErrNotFound  ||
       
  1512          aRes->Length() >= 50 )
       
  1513         {
       
  1514         iHwBox->CancelCharWriting();
       
  1515         }
       
  1516     else
       
  1517         {
       
  1518         iLastResult = aRes->Alloc();
       
  1519         }
       
  1520     }
       
  1521 void CPeninputHwrBxAbWnd::Move(const TPoint& aOffset)
       
  1522     {
       
  1523     CPeninputLayoutWindow::Move(aOffset);
       
  1524     DrawGuideLine();
       
  1525     }
       
  1526 
       
  1527 // ---------------------------------------------------------
       
  1528 // Get the candidate
       
  1529 // ---------------------------------------------------------
       
  1530 //
       
  1531 void CPeninputHwrBxAbWnd::GetCandidate(TInt aIndex, TDes& aCharCode) const
       
  1532     {
       
  1533     aCharCode.Zero();
       
  1534     if (aIndex >=0 && aIndex < iRecogResult.Count())
       
  1535         {
       
  1536         aCharCode = *iRecogResult[aIndex];
       
  1537         }
       
  1538     }
       
  1539 
       
  1540 // ---------------------------------------------------------
       
  1541 // Cancel writing
       
  1542 // ---------------------------------------------------------
       
  1543 //
       
  1544 void CPeninputHwrBxAbWnd::CancelWriting()
       
  1545     {
       
  1546     if( !iHwBox )
       
  1547         {
       
  1548         //there is nothing to cancel
       
  1549         return;
       
  1550         }
       
  1551     //iHwBox->SetWndTransparencyFactor(iInactiveTrans);
       
  1552     iHwBox->CancelCharWriting();
       
  1553     iDropdownList->ResetAndClear(CFepCtrlDropdownList::EListExpandableMultiRowWithoutIcon );
       
  1554     iDropdownList->Hide(ETrue);
       
  1555     }
       
  1556 
       
  1557 void CPeninputHwrBxAbWnd::ClearAndCloseDropdownList()
       
  1558     {
       
  1559     iDropdownList->ResetAndClear(CFepCtrlDropdownList::EListExpandableMultiRowWithoutIcon );
       
  1560     iDropdownList->Hide(ETrue);
       
  1561     }
       
  1562 void CPeninputHwrBxAbWnd::ResetAndShowDropdownList()
       
  1563     {
       
  1564     iDropdownList->ResetAndClear(CFepCtrlDropdownList::EListExpandableMultiRowWithoutIcon );
       
  1565     iDropdownList->Hide(EFalse);
       
  1566     }
       
  1567 void CPeninputHwrBxAbWnd::MirrorBackspaceButtonResL()
       
  1568     {
       
  1569     if(iBackspaceMirrored)
       
  1570         return;
       
  1571     CAknFepCtrlCommonButton* ctrl = static_cast<CAknFepCtrlCommonButton*>(iBackspaceButton);
       
  1572     if( ctrl && iBmpRotator)
       
  1573         {
       
  1574         TSyncRotationAngle rotChoice = CBitmapRotator::EMirrorVerticalAxis; 
       
  1575         User::LeaveIfError( iBmpRotator->Rotate( *ctrl->ForgroundBmp() ,
       
  1576                                                  rotChoice ) );
       
  1577         User::LeaveIfError( iBmpRotator->Rotate( *ctrl->ForgroundBmpMask() ,
       
  1578                                                  rotChoice ) );
       
  1579         iBackspaceMirrored = ETrue;
       
  1580         }       
       
  1581     }
       
  1582 void CPeninputHwrBxAbWnd::HandleBackspaceKeyEvent()
       
  1583     {
       
  1584     TBuf<1> buf;
       
  1585     buf.Append( EKeyBackspace );
       
  1586     iLayoutContext->Sendkey( ESignalKeyEvent, buf );      
       
  1587     }