textinput/peninputarc/gsplugin/gspeninputplugin/src/gspeninputcontainer.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:  Container for GSPenInputPlugin.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <gscommon.hrh>
       
    20 #include <gspeninputpluginrsc.rsg>
       
    21 #include <aknlists.h>
       
    22 #include <gslistbox.h>     
       
    23 #include <featmgr.h>
       
    24 #include <aknradiobuttonsettingpage.h> 
       
    25 #include <AknColourSelectionGrid.h> 
       
    26 #include <aknlayoutscalable_avkon.cdl.h>
       
    27 #include <avkon.mbg>
       
    28 #include <AknsDrawUtils.h>
       
    29 #include <AknsFrameBackgroundControlContext.h>
       
    30 #include <skinlayout.cdl.h>
       
    31 #include <aknconsts.h>
       
    32 #include <aknslider.h>
       
    33 #include <settingsinternalcrkeys.h>
       
    34 #include <AknFepInternalCRKeys.h>
       
    35 #include <AvkonInternalCRKeys.h>
       
    36 //#include <csxhelp\cp.hlp.hrh> //Temp fix for helps integration build break;
       
    37 #include <AknNullService.h>
       
    38 
       
    39 using namespace SkinLayout;
       
    40 
       
    41 #include "gspeninputcontainer.h"
       
    42 #include "gspeninputplugin.h"
       
    43 #include "gspeninputplugin.hrh"
       
    44 #include "gspeninputmodel.h"
       
    45 #include "peninputpluginutils.h"
       
    46 // ======== MEMBER FUNCTIONS ========
       
    47 
       
    48 // ---------------------------------------------------------
       
    49 // Constructor
       
    50 // ---------------------------------------------------------
       
    51 //
       
    52 CGSPenInputContainer::CGSPenInputContainer()
       
    53     {
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------
       
    57 // Constructor
       
    58 // ---------------------------------------------------------
       
    59 //
       
    60 void CGSPenInputContainer::ConstructL(const TRect& aRect)
       
    61     {
       
    62     iModel = CGSPenInputModel::NewL(this);
       
    63     iListBox = new (ELeave) CAknSettingStyleListBox;
       
    64     
       
    65     iModel->InputLanguage();
       
    66     iModel->InputMode();
       
    67     iModel->TrailColour();
       
    68     iModel->TrailWidth();
       
    69     iModel->GuideLine();
       
    70     iModel->InputMethodForFind();
       
    71     iModel->ChineseFindMethod();
       
    72     iModel->RecognitionWithDictionary();
       
    73 
       
    74     BaseConstructL(aRect, R_CP_INPUTPEN_PLUGIN_TITLE, R_INPUTPEN_LBX);
       
    75     iChinese = iModel->ChineseLanguage();
       
    76 
       
    77     iJapanese = iModel->JapaneseLanguage();
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------
       
    81 // This callback method is used to notify the client about
       
    82 // key changing
       
    83 // ---------------------------------------------------------
       
    84 //
       
    85 void CGSPenInputContainer::HandleNotifyInt(TUint32 aId, TInt /*aNewValue*/)
       
    86     {
       
    87     switch (aId)
       
    88         {
       
    89         case KAknFepInputTxtLang:
       
    90             {
       
    91             TRAP_IGNORE(UpdateListBoxL(EGSInputpenIdInputLanguage));
       
    92             }
       
    93             break;
       
    94         case KSettingsWritingSpeed:
       
    95             {
       
    96             TRAP_IGNORE(UpdateListBoxL(EGSInputpenIdWritingSpeed));
       
    97             }
       
    98             break;
       
    99         case KSettingsPenInputGuideLine:
       
   100             {
       
   101             TRAP_IGNORE(UpdateListBoxL(EGSInputpenIdGuidLine));
       
   102             }
       
   103             break;
       
   104         case KSettingRecognitionwithdictionary:
       
   105             {
       
   106             TRAP_IGNORE(UpdateListBoxL(EGSInputpenIdRecognitionWithDictionary));
       
   107             }
       
   108             break;            
       
   109         case KSettingsPenWidth:
       
   110             {
       
   111             TRAP_IGNORE(UpdateListBoxL(EGSInputpenIdPenTrailWidth));
       
   112             }
       
   113             break;
       
   114         case KSettingsPenColor:
       
   115             {
       
   116             TRAP_IGNORE(UpdateListBoxL(EGSInputpenIdPenTrailColour));
       
   117             }
       
   118             break;
       
   119         case KSettingsDefaultVkbPrc:
       
   120         case KSettingsDefaultVkbTw:
       
   121         case KSettingsDefaultVkbHk:
       
   122             {
       
   123             TRAP_IGNORE(UpdateListBoxL(EGSDefaultChineseOnscreenKeyboard));
       
   124             }
       
   125             break;
       
   126         default:
       
   127             break;
       
   128         }
       
   129     }
       
   130 // ---------------------------------------------------------
       
   131 // This callback method is used to notify the client about 
       
   132 // key changing
       
   133 // ---------------------------------------------------------
       
   134 //
       
   135 void CGSPenInputContainer::HandleNotifyInt( TUid aRepositoryUid, TUint32 aId, TInt aNewValue )
       
   136     {
       
   137     TRAP_IGNORE
       
   138         (
       
   139         if ( aRepositoryUid == KCRUidPersonalizationSettings )
       
   140             {
       
   141             HandleNotifyIntFromPersonalizationL( aId, aNewValue );
       
   142             }
       
   143         else if ( aRepositoryUid == KCRUidAknFep )
       
   144             {
       
   145             HandleNotifyIntFromAknFepL( aId, aNewValue );
       
   146             }
       
   147         else if ( aRepositoryUid == KCRUidAvkon )
       
   148             {
       
   149             HandleNotifyIntFromAvkonL( aId, aNewValue );
       
   150             }
       
   151         )
       
   152     }
       
   153 // ---------------------------------------------------------
       
   154 // Handle notifier from KCRUidPersonalizationSettings 
       
   155 // in CRepository
       
   156 // ---------------------------------------------------------
       
   157 //
       
   158 void CGSPenInputContainer::HandleNotifyIntFromPersonalizationL
       
   159                          ( TUint32 aId, TInt /*aNewValue*/ )
       
   160     {
       
   161     switch ( aId )
       
   162         {
       
   163         case KSettingsWritingSpeed:
       
   164             {
       
   165             UpdateListBoxL(EGSInputpenIdWritingSpeed);
       
   166             break;
       
   167             }
       
   168         case KSettingsPenInputGuideLine:
       
   169             {
       
   170             UpdateListBoxL(EGSInputpenIdGuidLine);
       
   171             break;
       
   172             }
       
   173         case KSettingsPenWidth:
       
   174             {
       
   175             UpdateListBoxL(EGSInputpenIdPenTrailWidth);
       
   176             break;
       
   177             }
       
   178         case KSettingsPenColor:
       
   179             {
       
   180             UpdateListBoxL(EGSInputpenIdPenTrailColour);
       
   181             break;
       
   182             }
       
   183         case KSettingsDefaultVkbPrc:
       
   184         case KSettingsDefaultVkbHk:
       
   185         case KSettingsDefaultVkbTw:
       
   186             {
       
   187             UpdateListBoxL(EGSDefaultChineseOnscreenKeyboard);
       
   188             break;
       
   189             }
       
   190         case KSettingRecognitionwithdictionary:
       
   191             {
       
   192             UpdateListBoxL(EGSInputpenIdRecognitionWithDictionary);
       
   193             break;
       
   194             }
       
   195         default:
       
   196             break;
       
   197         }                            
       
   198     }
       
   199     
       
   200 // ---------------------------------------------------------
       
   201 // Handle notifier from KCRUidAknFep in CRepository
       
   202 // ---------------------------------------------------------
       
   203 //
       
   204 void CGSPenInputContainer::HandleNotifyIntFromAknFepL
       
   205                          ( TUint32 aId, TInt /*aNewValue*/ )
       
   206     {
       
   207     switch ( aId )
       
   208         {
       
   209         case KAknFepInputTxtLang:
       
   210             {
       
   211             UpdateListBoxL(EGSInputpenIdInputLanguage);
       
   212             break;
       
   213             }
       
   214         default:
       
   215             break;
       
   216         }        
       
   217     }
       
   218 
       
   219 // ---------------------------------------------------------
       
   220 // Handle notifier from KCRUidAvkon in CRepository
       
   221 // ---------------------------------------------------------
       
   222 //
       
   223 void CGSPenInputContainer::HandleNotifyIntFromAvkonL
       
   224                          ( TUint32 aId, TInt /*aNewValue*/ )
       
   225     {
       
   226     switch ( aId )
       
   227         {
       
   228         case KAknAvkonAdaptiveSearchEnabled:
       
   229             {
       
   230             UpdateListBoxL(EGSInputpenIdInputMethodForFind);
       
   231             break;
       
   232             }
       
   233         case KAknAdaptiveSearchChinesePRC:
       
   234         case KAknAdaptiveSearchChineseTW:
       
   235         case KAknAdaptiveSearchChineseHongkong:
       
   236             {
       
   237             UpdateListBoxL(EGSInputpenIdChineseFindMethod);
       
   238             break;            
       
   239             }
       
   240         default:
       
   241             break;
       
   242         }            
       
   243     }
       
   244             
       
   245 // ---------------------------------------------------------
       
   246 // Constructs listbox 
       
   247 // ---------------------------------------------------------
       
   248 //
       
   249 void CGSPenInputContainer::ConstructListBoxL(TInt aResLbxId)
       
   250     {
       
   251     iListBox->ConstructL(this, EAknListBoxSelectionList);
       
   252     
       
   253     iListboxItemArray = CGSListBoxItemTextArray::NewL(aResLbxId,
       
   254                                                       *iListBox,
       
   255                                                       *iCoeEnv);
       
   256     
       
   257     iListBox->Model()->SetItemTextArray(iListboxItemArray);
       
   258     iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);
       
   259 
       
   260     delete iWritingSpeedItems;
       
   261     iWritingSpeedItems = NULL;
       
   262     
       
   263     iWritingSpeedItems = iCoeEnv->ReadDesC16ArrayResourceL(
       
   264                                   R_GS_WRITINGSPEED_SETTING_PAGE_LBX);
       
   265 
       
   266     delete iPenTrailWidthItems;
       
   267     iPenTrailWidthItems = NULL;
       
   268     
       
   269     iPenTrailWidthItems = iCoeEnv->ReadDesC16ArrayResourceL(
       
   270                                    R_GS_PENTRAIL_SETTING_PAGE_LBX);
       
   271                                    
       
   272     delete iGuideLineItems;
       
   273     iGuideLineItems = NULL;
       
   274     
       
   275     iGuideLineItems = iCoeEnv->ReadDesC16ArrayResourceL(
       
   276                                    R_GS_GUIDLINE_SETTING_PAGE_LBX);
       
   277     
       
   278     delete iRecognitionWithDictionaryItems;
       
   279     iRecognitionWithDictionaryItems = NULL;
       
   280     
       
   281     iRecognitionWithDictionaryItems = iCoeEnv->ReadDesC16ArrayResourceL(
       
   282             R_GS_RECOGNIZEWITHDICTIONARY_SETTING_PAGE_LBX);    
       
   283 
       
   284     delete iInputMethodForFindItems;
       
   285     iInputMethodForFindItems = NULL;
       
   286 
       
   287     iInputMethodForFindItems = iCoeEnv->ReadDesC16ArrayResourceL(
       
   288                                    R_GS_INPUTMETHODFORFIND_SETTING_PAGE_LBX);
       
   289 
       
   290     delete iChineseFindMethodItems;
       
   291     iChineseFindMethodItems = NULL;
       
   292 
       
   293     iChineseFindMethodResourceID = iModel->ChineseFindMethodResourceID();
       
   294     if (iChineseFindMethodResourceID != -1)
       
   295         {
       
   296         iChineseFindMethodItems = iCoeEnv->ReadDesC16ArrayResourceL(
       
   297                                    iChineseFindMethodResourceID);
       
   298         }
       
   299 
       
   300     delete iInputModeItems;
       
   301     iInputModeItems = NULL;
       
   302     
       
   303     if (iModel->InputModeResourceID() != -1)
       
   304         {
       
   305         iInputModeItems = iCoeEnv->ReadDesC16ArrayResourceL(
       
   306                                    iModel->InputModeResourceID());
       
   307         iModel->ResetInputModeArray(iInputModeItems);	
       
   308         }
       
   309         
       
   310     CArrayPtr<CGulIcon>* icons = new (ELeave) CArrayPtrFlat<CGulIcon>(2);
       
   311     CleanupStack::PushL(icons);
       
   312     CGulIcon* icon = CGulIcon::NewL();
       
   313     CleanupStack::PushL(icon);
       
   314     
       
   315     icons->AppendL(icon);
       
   316 
       
   317     CEikFormattedCellListBox* listbox = static_cast<CEikFormattedCellListBox*>(iListBox);
       
   318     
       
   319     listbox->ItemDrawer()->FormattedCellData()->SetIconArray(icons);// icons owned by List box
       
   320     
       
   321     CleanupStack::Pop(icon);
       
   322     CleanupStack::Pop(icons);
       
   323     
       
   324     iIconArray = listbox->ItemDrawer()->FormattedCellData()->IconArray();
       
   325      
       
   326     CreateListBoxItemsL();
       
   327     }
       
   328 
       
   329 // ---------------------------------------------------------
       
   330 // Constructs listbox items
       
   331 // ---------------------------------------------------------
       
   332 //
       
   333 void CGSPenInputContainer::CreateListBoxItemsL()
       
   334     {
       
   335     MakeHwrTruiItemL();
       
   336     MakeInputLanguageL();
       
   337     MakeInputModeL();
       
   338     MakeSpeedItemL();
       
   339     MakeGuideItemL();
       
   340     MakeTrailWidthItemL();
       
   341     MakeRecognitionWithDictionaryL();
       
   342     MakeTrailColourItemL();
       
   343     MakeTouchScrCalibItemL();
       
   344     MakeInputMethodForFindItemL();
       
   345     MakeChineseFindMethodItemL();
       
   346     }
       
   347 
       
   348 // ---------------------------------------------------------
       
   349 // Destructor
       
   350 // ---------------------------------------------------------
       
   351 //
       
   352 CGSPenInputContainer::~CGSPenInputContainer()
       
   353     {
       
   354     delete iModel;
       
   355     delete iWritingSpeedItems;
       
   356     delete iGuideLineItems;
       
   357     delete iRecognitionWithDictionaryItems;
       
   358     delete iPenTrailWidthItems;
       
   359     delete iInputMethodForFindItems;
       
   360     delete iChineseFindMethodItems;
       
   361     delete iInputModeItems;
       
   362     delete iListboxItemArray;        
       
   363     delete iNullService;
       
   364     }
       
   365 
       
   366 // ---------------------------------------------------------
       
   367 // Updates listbox item's value
       
   368 // ---------------------------------------------------------
       
   369 //
       
   370 void CGSPenInputContainer::UpdateListBoxL(TInt aFeatureId)
       
   371     {
       
   372     switch (aFeatureId)
       
   373         {
       
   374         case EGSInputpenIdInputLanguage:
       
   375             {
       
   376             MakeInputLanguageL();
       
   377             }
       
   378             break;
       
   379         case EGSDefaultChineseOnscreenKeyboard:
       
   380             {
       
   381             MakeInputModeL();
       
   382             }
       
   383             break;
       
   384         case EGSInputpenIdWritingSpeed:
       
   385             {
       
   386             MakeSpeedItemL();
       
   387             }
       
   388             break;
       
   389         case EGSInputpenIdGuidLine:
       
   390             {
       
   391             MakeGuideItemL();
       
   392             }
       
   393             break; 
       
   394         case EGSInputpenIdRecognitionWithDictionary:
       
   395             {
       
   396             MakeRecognitionWithDictionaryL();
       
   397             }
       
   398             break;            
       
   399         case EGSInputpenIdPenTrailWidth:
       
   400             {
       
   401             MakeTrailWidthItemL();
       
   402             }
       
   403             break;
       
   404         case EGSInputpenIdPenTrailColour:
       
   405             {
       
   406             MakeTrailColourItemL();
       
   407             }
       
   408             break;
       
   409         case EGSInputpenIdInputMethodForFind:
       
   410             {
       
   411             MakeInputMethodForFindItemL();
       
   412             }
       
   413         case EGSInputpenIdChineseFindMethod:
       
   414             {
       
   415             MakeChineseFindMethodItemL();
       
   416             }
       
   417             break;            
       
   418         default:
       
   419             break;  
       
   420         }
       
   421     // Update the listbox
       
   422     iListBox->HandleItemAdditionL();    
       
   423     }
       
   424 
       
   425 // ---------------------------------------------------------
       
   426 // Retrieves the currently selected listbox id
       
   427 // ---------------------------------------------------------
       
   428 //
       
   429 TInt CGSPenInputContainer::CurrentSelectedId() const
       
   430     {
       
   431     return iListboxItemArray->CurrentFeature();
       
   432     }
       
   433 
       
   434 // ---------------------------------------------------------
       
   435 // Create listbox input language item 
       
   436 // ---------------------------------------------------------
       
   437 //
       
   438 void CGSPenInputContainer::MakeInputLanguageL()
       
   439     {
       
   440     HBufC* dynamicText = HBufC::NewLC(KGSBufSize);
       
   441     TPtr ptrBuffer(dynamicText->Des());
       
   442     
       
   443     iModel->InputLanguage(ptrBuffer); 
       
   444 
       
   445     // Finally, set the dynamic text
       
   446     iListboxItemArray->SetDynamicTextL(EGSInputpenIdInputLanguage, ptrBuffer);
       
   447     
       
   448     CleanupStack::PopAndDestroy(dynamicText);
       
   449 
       
   450     // And add to listbox
       
   451     iListboxItemArray->SetItemVisibilityL(EGSInputpenIdInputLanguage,
       
   452                                           CGSListBoxItemTextArray::EVisible);
       
   453                                           
       
   454     // Decide handwritting training visible
       
   455     MakeHwrTruiItemL();
       
   456     // Decide if show Default chinese on-screen keyboard
       
   457     MakeInputModeL();
       
   458     // Decide which chinese find method should be shown
       
   459     MakeChineseFindMethodItemL();
       
   460     // Decide which guideline should be shown
       
   461     MakeGuideItemL();
       
   462     
       
   463     MakeTrailColourItemL();
       
   464     
       
   465     MakeTrailWidthItemL();
       
   466     
       
   467     MakeSpeedItemL();
       
   468     
       
   469     MakeRecognitionWithDictionaryL();
       
   470     }
       
   471 
       
   472 // ---------------------------------------------------------
       
   473 // Create  input mode item 
       
   474 // ---------------------------------------------------------
       
   475 //
       
   476 void CGSPenInputContainer::MakeInputModeL()
       
   477     {
       
   478     TBool bVisible = iModel->IsSettingItemAvailable(EGSDefaultChineseOnscreenKeyboard);       
       
   479 
       
   480     delete iInputModeItems;
       
   481     iInputModeItems = NULL;
       
   482     // if current input language is not Chinese, 
       
   483     // Hide default chinese on-screen keyboard
       
   484     if ( iListboxItemArray && !iModel->ChineseLanguage() )
       
   485         {        
       
   486         iListboxItemArray->SetItemVisibilityL(
       
   487                 EGSDefaultChineseOnscreenKeyboard, 
       
   488                 CGSItemTextArray::EInvisible);
       
   489         } 
       
   490 
       
   491     if (iModel->InputModeResourceID() != -1)
       
   492         {
       
   493         iInputModeItems = iCoeEnv->ReadDesC16ArrayResourceL(
       
   494                                    iModel->InputModeResourceID());
       
   495         iModel->ResetInputModeArray(iInputModeItems);	
       
   496         }
       
   497     else
       
   498         {
       
   499         return;
       
   500         }
       
   501         
       
   502     HBufC* dynamicText = HBufC::NewLC(KGSBufSize);
       
   503     TPtr ptrBuffer(dynamicText->Des());
       
   504     iModel->InputMode();
       
   505     const TInt index = iModel->InputModeInSettingPage();
       
   506     
       
   507     if ( iInputModeItems && index < iInputModeItems->Count() )
       
   508         {
       
   509         ptrBuffer = (*iInputModeItems)[index];
       
   510         }    
       
   511 
       
   512     // Finally, set the dynamic text
       
   513     iListboxItemArray->SetDynamicTextL(EGSDefaultChineseOnscreenKeyboard, ptrBuffer);
       
   514     CleanupStack::PopAndDestroy(dynamicText);
       
   515 
       
   516     // And add to listbox
       
   517     iListboxItemArray->SetItemVisibilityL(
       
   518             EGSDefaultChineseOnscreenKeyboard, 
       
   519             bVisible ? CGSItemTextArray::EVisible : CGSItemTextArray::EInvisible);
       
   520     }
       
   521 
       
   522 // ---------------------------------------------------------
       
   523 // Create listbox writing speed item 
       
   524 // ---------------------------------------------------------
       
   525 //
       
   526 void CGSPenInputContainer::MakeGuideItemL()
       
   527     {
       
   528 
       
   529     TBool bVisible = iModel->IsSettingItemAvailable(EGSInputpenIdGuidLine);       
       
   530 
       
   531     
       
   532     HBufC* dynamicText = HBufC::NewLC(KGSBufSize);
       
   533     TPtr ptrBuffer(dynamicText->Des());
       
   534     const TInt guideLine = iModel->GuideLine();
       
   535 
       
   536     ptrBuffer = (*iGuideLineItems)[guideLine == 0 ? 1:0];
       
   537 
       
   538 
       
   539     if (!ptrBuffer.Length() && iGuideLineItems->Count() > 0)
       
   540         {
       
   541         ptrBuffer = (*iGuideLineItems)[0];
       
   542         }
       
   543 
       
   544     // Finally, set the dynamic text
       
   545     iListboxItemArray->SetDynamicTextL(EGSInputpenIdGuidLine, ptrBuffer);
       
   546     CleanupStack::PopAndDestroy(dynamicText);
       
   547 
       
   548     // And add to listbox
       
   549     iListboxItemArray->SetItemVisibilityL(
       
   550             EGSInputpenIdGuidLine, 
       
   551             bVisible ? CGSItemTextArray::EVisible : CGSItemTextArray::EInvisible);
       
   552     }
       
   553 // ---------------------------------------------------------
       
   554 // Create listbox for the item of recognition with dictionary 
       
   555 // ---------------------------------------------------------
       
   556 //
       
   557 void CGSPenInputContainer::MakeRecognitionWithDictionaryL()
       
   558     {
       
   559 
       
   560     TBool bVisible = iModel->IsSettingItemAvailable(EGSInputpenIdRecognitionWithDictionary);       
       
   561 
       
   562     
       
   563     HBufC* dynamicText = HBufC::NewLC(KGSBufSize);
       
   564     TPtr ptrBuffer(dynamicText->Des());
       
   565     const TInt guideLine = iModel->RecognitionWithDictionary();
       
   566 
       
   567     ptrBuffer = (*iRecognitionWithDictionaryItems)[guideLine == 0 ? 1:0];
       
   568 
       
   569 
       
   570     if (!ptrBuffer.Length() && iRecognitionWithDictionaryItems->Count() > 0)
       
   571         {
       
   572         ptrBuffer = (*iRecognitionWithDictionaryItems)[0];
       
   573         }
       
   574 
       
   575     // Finally, set the dynamic text
       
   576     iListboxItemArray->SetDynamicTextL(EGSInputpenIdRecognitionWithDictionary, ptrBuffer);
       
   577     CleanupStack::PopAndDestroy(dynamicText);
       
   578 
       
   579     // And add to listbox
       
   580     iListboxItemArray->SetItemVisibilityL(
       
   581             EGSInputpenIdRecognitionWithDictionary, 
       
   582             bVisible ? CGSItemTextArray::EVisible : CGSItemTextArray::EInvisible);
       
   583     }
       
   584 
       
   585 // ---------------------------------------------------------
       
   586 // Create listbox writing speed item 
       
   587 // ---------------------------------------------------------
       
   588 //
       
   589 void CGSPenInputContainer::MakeSpeedItemL()
       
   590     {
       
   591     TBool bVisible = iModel->IsSettingItemAvailable(EGSInputpenIdWritingSpeed);
       
   592     
       
   593     if(bVisible)
       
   594         {
       
   595         HBufC* dynamicText = HBufC::NewLC(KGSBufSize);
       
   596         TPtr ptrBuffer(dynamicText->Des());
       
   597         const TInt writingSpeed = iModel->WritingSpeed();
       
   598         const TInt count = iWritingSpeedItems->Count();
       
   599 
       
   600         for (TInt index = 0; index < count; ++index)
       
   601             {
       
   602             if (index == writingSpeed)
       
   603                 {
       
   604                 ptrBuffer = (*iWritingSpeedItems)[index];
       
   605                 break;
       
   606                 }
       
   607             }
       
   608 
       
   609         if (!ptrBuffer.Length() && iWritingSpeedItems->Count() > 0)
       
   610             {
       
   611             ptrBuffer = (*iWritingSpeedItems)[0];
       
   612             }
       
   613 
       
   614         // Finally, set the dynamic text
       
   615         iListboxItemArray->SetDynamicTextL(EGSInputpenIdWritingSpeed, ptrBuffer);
       
   616         CleanupStack::PopAndDestroy(dynamicText);
       
   617         }
       
   618 
       
   619     // Enable or disable to listbox
       
   620     iListboxItemArray->SetItemVisibilityL(EGSInputpenIdWritingSpeed,
       
   621         bVisible ? CGSListBoxItemTextArray::EVisible : CGSListBoxItemTextArray::EInvisible);    
       
   622     }
       
   623     
       
   624 // ---------------------------------------------------------
       
   625 // Create listbox pen trail width item
       
   626 // ---------------------------------------------------------
       
   627 //
       
   628 void CGSPenInputContainer::MakeTrailWidthItemL()
       
   629     {
       
   630     TBool bVisible = EFalse;
       
   631     if( !(FeatureManager::FeatureSupported( KFeatureIdFfCapacitiveDisplay )) )
       
   632         {
       
   633         bVisible = iModel->IsSettingItemAvailable(EGSInputpenIdPenTrailWidth);
       
   634         }
       
   635     
       
   636     if(bVisible)
       
   637         {
       
   638         HBufC* dynamicText = HBufC::NewLC(KGSBufSize);
       
   639         TPtr ptrBuffer(dynamicText->Des());
       
   640         const TInt trailwidth = iModel->TrailWidth();
       
   641         const TInt count = iPenTrailWidthItems->Count();
       
   642 
       
   643         for (TInt index = 0; index < count; ++index)
       
   644             {
       
   645             if (index == trailwidth)
       
   646                 {
       
   647                 ptrBuffer = (*iPenTrailWidthItems)[index];
       
   648                 break;
       
   649                 }
       
   650             }
       
   651 
       
   652         if (!ptrBuffer.Length() && iPenTrailWidthItems->Count() > 0)
       
   653             {
       
   654             ptrBuffer = (*iPenTrailWidthItems)[0];
       
   655             }
       
   656 
       
   657         // Finally, set the dynamic text
       
   658         iListboxItemArray->SetDynamicTextL(EGSInputpenIdPenTrailWidth, ptrBuffer);
       
   659         CleanupStack::PopAndDestroy(dynamicText);
       
   660         }
       
   661 
       
   662     // enable or disable to listbox
       
   663     iListboxItemArray->SetItemVisibilityL(EGSInputpenIdPenTrailWidth,
       
   664         bVisible ? CGSListBoxItemTextArray::EVisible : CGSListBoxItemTextArray::EInvisible);       
       
   665     }
       
   666     
       
   667 // ---------------------------------------------------------
       
   668 // Create listbox pen trail colour item
       
   669 // ---------------------------------------------------------
       
   670 //
       
   671 void CGSPenInputContainer::MakeTrailColourItemL()
       
   672     {
       
   673     TBool bVisible = iModel->IsSettingItemAvailable(EGSInputpenIdPenTrailColour);
       
   674     if(bVisible)
       
   675         {
       
   676         CreateIconL();
       
   677         }
       
   678     
       
   679     iListboxItemArray->SetItemVisibilityL(EGSInputpenIdPenTrailColour, 
       
   680             bVisible ? CGSListBoxItemTextArray::EVisible : CGSListBoxItemTextArray::EInvisible);
       
   681     }
       
   682     
       
   683 // ---------------------------------------------------------
       
   684 // Create listbox touch screen calibration item
       
   685 // ---------------------------------------------------------
       
   686 //
       
   687 void CGSPenInputContainer::MakeTouchScrCalibItemL()
       
   688     {
       
   689     if( FeatureManager::FeatureSupported( KFeatureIdPenSupportCalibration ) )
       
   690         {
       
   691         // And add to listbox
       
   692         iListboxItemArray->SetItemVisibilityL(EGSInputpenIdTouchScrCalib, 
       
   693                                               CGSListBoxItemTextArray::EVisible);
       
   694         }
       
   695     else
       
   696         {
       
   697         iListboxItemArray->SetItemVisibilityL(EGSInputpenIdTouchScrCalib, 
       
   698                                               CGSListBoxItemTextArray::EInvisible);
       
   699         }
       
   700     }
       
   701 
       
   702 // ---------------------------------------------------------
       
   703 // Create listbox input method for find item 
       
   704 // ---------------------------------------------------------
       
   705 //
       
   706 void CGSPenInputContainer::MakeInputMethodForFindItemL()
       
   707     {
       
   708     HBufC* dynamicText = HBufC::NewLC(KGSBufSize);
       
   709     TPtr ptrBuffer(dynamicText->Des());
       
   710     const TInt inputMethodForFind = iModel->InputMethodForFind();
       
   711 
       
   712     ptrBuffer = (*iInputMethodForFindItems)[inputMethodForFind];
       
   713 
       
   714 
       
   715     if (!ptrBuffer.Length() && iInputMethodForFindItems->Count() > 0)
       
   716         {
       
   717         ptrBuffer = (*iInputMethodForFindItems)[0];
       
   718         }
       
   719 
       
   720     // Finally, set the dynamic text
       
   721     iListboxItemArray->SetDynamicTextL(EGSInputpenIdInputMethodForFind, ptrBuffer);
       
   722     CleanupStack::PopAndDestroy(dynamicText);
       
   723 
       
   724     // And add to listbox
       
   725     iListboxItemArray->SetItemVisibilityL(EGSInputpenIdInputMethodForFind,
       
   726                                           CGSListBoxItemTextArray::EVisible);
       
   727     }
       
   728 
       
   729 // ---------------------------------------------------------
       
   730 // Create listbox chinese find method item 
       
   731 // ---------------------------------------------------------
       
   732 //
       
   733 void CGSPenInputContainer::MakeChineseFindMethodItemL()
       
   734     {
       
   735     if(iChineseFindMethodResourceID != iModel->ChineseFindMethodResourceID())
       
   736         {
       
   737         iChineseFindMethodResourceID = iModel->ChineseFindMethodResourceID();
       
   738         delete iChineseFindMethodItems;
       
   739         iChineseFindMethodItems = NULL;
       
   740 
       
   741         if (iChineseFindMethodResourceID != -1)
       
   742             {
       
   743             iChineseFindMethodItems = iCoeEnv->ReadDesC16ArrayResourceL(
       
   744                                        iChineseFindMethodResourceID);
       
   745             }
       
   746         }
       
   747 
       
   748     if (iModel->IsSettingItemAvailable(EGSInputpenIdChineseFindMethod))
       
   749         {
       
   750         HBufC* dynamicText = HBufC::NewLC(KGSBufSize);
       
   751         TPtr ptrBuffer(dynamicText->Des());
       
   752         const TInt chineseFindMethod = iModel->ChineseFindMethod();
       
   753 
       
   754         ptrBuffer = (*iChineseFindMethodItems)[chineseFindMethod];
       
   755 
       
   756         if (!ptrBuffer.Length() && iChineseFindMethodItems->Count() > 0)
       
   757             {
       
   758             ptrBuffer = (*iChineseFindMethodItems)[0];
       
   759             }
       
   760 
       
   761         // Finally, set the dynamic text
       
   762         iListboxItemArray->SetDynamicTextL(EGSInputpenIdChineseFindMethod, ptrBuffer);
       
   763         CleanupStack::PopAndDestroy(dynamicText);
       
   764 
       
   765         // Show listbox item
       
   766         iListboxItemArray->SetItemVisibilityL(EGSInputpenIdChineseFindMethod,
       
   767                 CGSItemTextArray::EVisible);
       
   768         }
       
   769     else
       
   770         {
       
   771         // Hide listbox item
       
   772         iListboxItemArray->SetItemVisibilityL(EGSInputpenIdChineseFindMethod,
       
   773                 CGSItemTextArray::EInvisible);
       
   774         }
       
   775     }
       
   776     
       
   777 // ---------------------------------------------------------
       
   778 // Create listbox hwr trui item
       
   779 // ---------------------------------------------------------
       
   780 //
       
   781 void CGSPenInputContainer::MakeHwrTruiItemL()
       
   782     {
       
   783     // And add to listbox
       
   784     TBool bVisible = iModel->IsSettingItemAvailable(EGSInputpenIdHwrTraining);       
       
   785     iListboxItemArray->SetItemVisibilityL(
       
   786             EGSInputpenIdHwrTraining, 
       
   787             bVisible ? CGSItemTextArray::EVisible : CGSItemTextArray::EInvisible);
       
   788     }    
       
   789 
       
   790 // ---------------------------------------------------------
       
   791 // Get model instance
       
   792 // ---------------------------------------------------------
       
   793 //
       
   794 CGSPenInputModel* CGSPenInputContainer::Model()
       
   795     {
       
   796     return iModel;     
       
   797     }
       
   798     
       
   799 // ---------------------------------------------------------
       
   800 // Create a icon for pen trail colour item
       
   801 // ---------------------------------------------------------
       
   802 //
       
   803 void CGSPenInputContainer::CreateIconL()
       
   804     {
       
   805     CGulIcon* icon = CreateNewIconL();
       
   806     
       
   807     delete iIconArray->At(0);
       
   808     iIconArray->At(0) = icon;
       
   809     }
       
   810  
       
   811 // ---------------------------------------------------------
       
   812 // Create a new icon
       
   813 // ---------------------------------------------------------
       
   814 //
       
   815 CGulIcon* CGSPenInputContainer::CreateNewIconL()
       
   816     {
       
   817     CGulIcon* icon = CGulIcon::NewLC();
       
   818     
       
   819     TRect origin;
       
   820     
       
   821     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, origin);
       
   822     
       
   823     TAknLayoutRect layoutRect;
       
   824     
       
   825     layoutRect.LayoutRect(origin, 
       
   826                           AknLayoutScalable_Avkon::listscroll_gen_pane(0));
       
   827     layoutRect.LayoutRect(layoutRect.Rect(), 
       
   828                           AknLayoutScalable_Avkon::list_gen_pane(0));
       
   829     layoutRect.LayoutRect(layoutRect.Rect(), 
       
   830                            AknLayoutScalable_Avkon::list_setting_number_pane(0));
       
   831                            
       
   832     TRect listSettingPaneRect(layoutRect.Rect());
       
   833     
       
   834     layoutRect.LayoutRect(layoutRect.Rect(), 
       
   835                           AknLayoutScalable_Avkon::set_value_pane(0));
       
   836                           
       
   837     TRect setValuePaneRect(layoutRect.Rect());
       
   838     TRect rect(setValuePaneRect);
       
   839 
       
   840     // Move to 0,0
       
   841     rect.Move(-rect.iTl.iX, -rect.iTl.iY);
       
   842     
       
   843     DrawIconL(rect, icon);
       
   844     
       
   845     CleanupStack::Pop(icon); // icon - not owned anymore, do not destroy
       
   846     
       
   847     return icon; // icon owned by listbox
       
   848     }
       
   849 
       
   850 // ---------------------------------------------------------
       
   851 // Draw icon bitmap 
       
   852 // ---------------------------------------------------------
       
   853 //
       
   854 void CGSPenInputContainer::DrawIconL(const TRect& aRect, CGulIcon* aIcon)
       
   855     {
       
   856     CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
       
   857     CleanupStack::PushL(bitmap);
       
   858     
       
   859     bitmap->Create(aRect.Size(), CCoeEnv::Static()->ScreenDevice()->DisplayMode());
       
   860     
       
   861     CFbsBitGc* fbsBitGc = CFbsBitGc::NewL();
       
   862     CleanupStack::PushL(fbsBitGc);
       
   863     
       
   864     CFbsBitmapDevice* bmpDevice = CFbsBitmapDevice::NewL(bitmap);
       
   865     CleanupStack::PushL(bmpDevice);
       
   866     
       
   867     fbsBitGc->Activate(bmpDevice);
       
   868     
       
   869     TRect outerRect;
       
   870     TRect innerRect;
       
   871     TRect origin;
       
   872     
       
   873     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, origin);
       
   874     
       
   875     TAknLayoutRect layoutRect;
       
   876     
       
   877     layoutRect.LayoutRect(origin, 
       
   878                           AknLayoutScalable_Avkon::listscroll_gen_pane(0));
       
   879     layoutRect.LayoutRect(layoutRect.Rect(), 
       
   880                           AknLayoutScalable_Avkon::list_gen_pane(0));
       
   881     layoutRect.LayoutRect(layoutRect.Rect(), 
       
   882                           AknLayoutScalable_Avkon::list_setting_number_pane(0));
       
   883     TRect listSettingPaneRect(layoutRect.Rect());
       
   884 
       
   885     // Background skinning
       
   886     TAknLayoutRect topLeft;
       
   887     TAknLayoutRect bottomRight;
       
   888 
       
   889     topLeft.LayoutRect(listSettingPaneRect, 
       
   890                        Setting_list_item_skin_elements__value_background__Line_2());
       
   891     bottomRight.LayoutRect(listSettingPaneRect, 
       
   892                            Setting_list_item_skin_elements__value_background__Line_5());
       
   893 
       
   894     // Move to 0,0
       
   895     TRect topLeftRect = topLeft.Rect();
       
   896     TRect bottomRightRect = bottomRight.Rect();
       
   897 
       
   898     TPoint skinOffset(-topLeftRect.iTl.iX, -topLeftRect.iTl.iY);
       
   899     bottomRightRect.Move(skinOffset);
       
   900     topLeftRect.Move(skinOffset);
       
   901 
       
   902     outerRect = TRect(topLeftRect.iTl, bottomRightRect.iBr);
       
   903     innerRect = TRect(topLeftRect.iBr, bottomRightRect.iTl);
       
   904 
       
   905     // Frame IID for qsn_fr_set_opt_foc_xxxxx
       
   906     const TAknsItemID *frameId = &KAknsIIDQsnFrSetOptFoc;
       
   907 
       
   908     // Make a control context:
       
   909     CAknsFrameBackgroundControlContext* cc = CAknsFrameBackgroundControlContext::NewL(
       
   910         *frameId, outerRect, innerRect, EFalse);
       
   911     CleanupStack::PushL(cc);
       
   912 
       
   913     TPoint dstPos(0,0);
       
   914 
       
   915     AknsDrawUtils::DrawBackground(AknsUtils::SkinInstance(), cc, NULL, *fbsBitGc,
       
   916                                   dstPos, outerRect, KAknsDrawParamDefault);
       
   917 
       
   918     fbsBitGc->SetPenColor(TRgb(iModel->TrailColour()));
       
   919     fbsBitGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
   920     fbsBitGc->SetBrushColor(iModel->TrailColour());
       
   921     fbsBitGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   922    
       
   923 
       
   924     TInt clolorWidth = outerRect.Width() / 3;
       
   925     TInt clolorHight = (outerRect.Height() * 2) / 3;
       
   926     
       
   927     dstPos.iX = (outerRect.Width() / 2) - (clolorWidth / 2);
       
   928     dstPos.iY = (outerRect.Height() / 2) - (clolorHight / 2);
       
   929     
       
   930     fbsBitGc->DrawRect(TRect(dstPos.iX,
       
   931                              dstPos.iY,
       
   932                              dstPos.iX + clolorWidth, 
       
   933                              dstPos.iY + clolorHight));
       
   934  
       
   935     CleanupStack::PopAndDestroy(cc);
       
   936     CleanupStack::PopAndDestroy(bmpDevice); 
       
   937     CleanupStack::PopAndDestroy(fbsBitGc); 
       
   938     
       
   939     aIcon->SetBitmap(bitmap); // Transfers ownership, so all we need to do is to..
       
   940     CleanupStack::Pop(bitmap);  
       
   941     
       
   942     // For mask    
       
   943     CFbsBitmap* mask = new (ELeave) CFbsBitmap;
       
   944     CleanupStack::PushL( mask );
       
   945     
       
   946     mask->Create(aRect.Size(), EGray256);
       
   947     fbsBitGc = CFbsBitGc::NewL();
       
   948     CleanupStack::PushL(fbsBitGc);
       
   949     bmpDevice = CFbsBitmapDevice::NewL(mask);
       
   950     CleanupStack::PushL(bmpDevice);
       
   951     fbsBitGc->Activate(bmpDevice);
       
   952     fbsBitGc->SetPenStyle(CGraphicsContext::ENullPen);
       
   953     fbsBitGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   954     fbsBitGc->SetBrushColor(KRgbWhite);
       
   955     fbsBitGc->DrawRect(TRect(aRect.Size()));
       
   956     
       
   957     AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(), *fbsBitGc, outerRect,
       
   958                              innerRect, KAknsIIDQsnFrSetOptFoc, 
       
   959                              KAknsIIDQsnFrSetOptFocCenter, KAknsSDMAlphaOnly);
       
   960     
       
   961     CleanupStack::PopAndDestroy(bmpDevice); 
       
   962     CleanupStack::PopAndDestroy(fbsBitGc); 
       
   963     aIcon->SetMask(mask); // mask owned by listbox
       
   964     CleanupStack::Pop(mask);   
       
   965     }
       
   966     
       
   967 // ---------------------------------------------------------
       
   968 // Display input language setting page
       
   969 // ---------------------------------------------------------
       
   970 //
       
   971 void CGSPenInputContainer::ShowInputLanguagePageL()
       
   972     {
       
   973     CDesCArrayFlat* languageItems = new(ELeave)CDesCArrayFlat(10);
       
   974     CleanupStack::PushL(languageItems);
       
   975     
       
   976     iModel->GetLanguagesFromPtiL(EFalse, languageItems);
       
   977 
       
   978     TInt currentItem = iModel->InputLanguageIndex();
       
   979 
       
   980     CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage(
       
   981                                       R_GS_INPUTLANGUAGE_TEXT_SETTING_PAGE, 
       
   982                                       currentItem,
       
   983                                       languageItems);
       
   984 
       
   985     CleanupStack::PushL(dlg);
       
   986     
       
   987     if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged))
       
   988         {
       
   989         if (currentItem != iModel->InputLanguageIndex())
       
   990             {
       
   991             iModel->SetInputLanguageIndex(currentItem);
       
   992             iModel->SetInputLanguageL();
       
   993             UpdateListBoxL(EGSInputpenIdInputLanguage);
       
   994             if (iModel->ChineseLanguage() && iChinese)
       
   995                 {
       
   996                 iModel->ResetFepDefaultInputMode();
       
   997                 UpdateListBoxL(EGSDefaultChineseOnscreenKeyboard);
       
   998                 UpdateListBoxL(EGSInputpenIdChineseFindMethod);
       
   999                 }
       
  1000             }
       
  1001 
       
  1002         if ((iChinese != iModel->ChineseLanguage()) ||
       
  1003             (iJapanese !=  iModel->JapaneseLanguage()))
       
  1004             {
       
  1005             ReConstructListBoxL();    
       
  1006             }
       
  1007         }
       
  1008 
       
  1009     CleanupStack::Pop(dlg);
       
  1010     CleanupStack::PopAndDestroy(languageItems);   
       
  1011     }
       
  1012 
       
  1013 // ---------------------------------------------------------
       
  1014 // Display input mode setting page
       
  1015 // ---------------------------------------------------------
       
  1016 //
       
  1017 void CGSPenInputContainer::ShowInputModePageL()
       
  1018     {
       
  1019     delete iInputModeItems;
       
  1020     iInputModeItems = NULL;
       
  1021     
       
  1022     if (iModel->InputModeResourceID() != -1)
       
  1023         {
       
  1024         iInputModeItems = iCoeEnv->ReadDesC16ArrayResourceL(
       
  1025                                    iModel->InputModeResourceID());
       
  1026         iModel->ResetInputModeArray(iInputModeItems);	
       
  1027         }
       
  1028     else
       
  1029         {
       
  1030         return;
       
  1031         }    
       
  1032     
       
  1033     TInt currentItem = iModel->InputModeInSettingPage();
       
  1034 
       
  1035     if ( currentItem < iInputModeItems->Count() )
       
  1036         {
       
  1037         CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage(
       
  1038                                           R_GS_VKB_DEFAULTCHINESE_OSK_TEXT_SETTING_PAGE, 
       
  1039                                           currentItem, 
       
  1040                                           iInputModeItems);
       
  1041 
       
  1042         CleanupStack::PushL(dlg);
       
  1043         
       
  1044         if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged))
       
  1045             {
       
  1046             if(currentItem != iModel->InputModeInSettingPage())
       
  1047                 {
       
  1048                 iModel->SetInputModeBySettingPage(currentItem);
       
  1049                 UpdateListBoxL(EGSDefaultChineseOnscreenKeyboard);
       
  1050                 }        
       
  1051             }
       
  1052         CleanupStack::Pop(dlg);        
       
  1053         }        
       
  1054     }
       
  1055     
       
  1056 // ---------------------------------------------------------
       
  1057 // Display writing speed setting page
       
  1058 // ---------------------------------------------------------
       
  1059 //
       
  1060 void CGSPenInputContainer::ShowWritingSpeedPageL()
       
  1061     {
       
  1062     TInt currentItem = iModel->WritingSpeed();
       
  1063 
       
  1064     CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage(
       
  1065                                       R_GS_WRITINGSPEED_TEXT_SETTING_PAGE, 
       
  1066                                       currentItem, 
       
  1067                                       iWritingSpeedItems);
       
  1068 
       
  1069     CleanupStack::PushL(dlg);
       
  1070     
       
  1071     if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged))
       
  1072         {
       
  1073         if(currentItem != iModel->WritingSpeed())
       
  1074             {
       
  1075             iModel->SetWritingSpeed(currentItem);
       
  1076             UpdateListBoxL(EGSInputpenIdWritingSpeed);
       
  1077             }
       
  1078         } 
       
  1079         
       
  1080     CleanupStack::Pop(dlg);        
       
  1081     }
       
  1082 
       
  1083 // ---------------------------------------------------------
       
  1084 // Display pen trail width setting page
       
  1085 // ---------------------------------------------------------
       
  1086 //
       
  1087 void CGSPenInputContainer::ShowTrailWidthPageL()
       
  1088     {
       
  1089     TInt currentItem = iModel->TrailWidth();
       
  1090 
       
  1091     CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage(
       
  1092                                       R_GS_TRAILWIDTH_TEXT_SETTING_PAGE, 
       
  1093                                       currentItem, 
       
  1094                                       iPenTrailWidthItems);
       
  1095 
       
  1096     CleanupStack::PushL(dlg);
       
  1097     
       
  1098     if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged))
       
  1099         {
       
  1100         if(currentItem != iModel->TrailWidth())
       
  1101             {
       
  1102             iModel->SetTrailWidth(currentItem);
       
  1103             UpdateListBoxL(EGSInputpenIdPenTrailWidth);
       
  1104             }     
       
  1105         }
       
  1106     
       
  1107     CleanupStack::Pop(dlg);          
       
  1108     }
       
  1109 
       
  1110 // ---------------------------------------------------------
       
  1111 // Display guide line setting page
       
  1112 // ---------------------------------------------------------
       
  1113 //
       
  1114 void CGSPenInputContainer::ShowGuideLinePageL()
       
  1115     {
       
  1116     TInt currentItem = iModel->GuideLine();
       
  1117     
       
  1118     if (currentItem == 1)
       
  1119         {
       
  1120         currentItem = 0;
       
  1121         }
       
  1122     else
       
  1123         {
       
  1124         currentItem = 1;
       
  1125         }
       
  1126 
       
  1127     CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage(
       
  1128                                       R_GS_GUIDLINE_TEXT_SETTING_PAGE, 
       
  1129                                       currentItem, 
       
  1130                                       iGuideLineItems);
       
  1131 
       
  1132     CleanupStack::PushL(dlg);
       
  1133     
       
  1134     if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged))
       
  1135         {
       
  1136         if(currentItem == iModel->GuideLine())
       
  1137             {
       
  1138             iModel->SetGuideLine(currentItem == 0? 1:0);
       
  1139             UpdateListBoxL(EGSInputpenIdGuidLine);
       
  1140             }
       
  1141         }
       
  1142  
       
  1143     CleanupStack::Pop(dlg);  
       
  1144     }
       
  1145 
       
  1146 // ---------------------------------------------------------
       
  1147 // Display recognition with dictionary setting page
       
  1148 // ---------------------------------------------------------
       
  1149 //
       
  1150 void CGSPenInputContainer::ShowRecognitionWithDictionaryL()
       
  1151     {
       
  1152     TInt currentItem = iModel->RecognitionWithDictionary();
       
  1153     
       
  1154     if (currentItem == 1)
       
  1155         {
       
  1156         currentItem = 0;
       
  1157         }
       
  1158     else
       
  1159         {
       
  1160         currentItem = 1;
       
  1161         }
       
  1162 
       
  1163     CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage(
       
  1164             R_GS_RECOGNITIONWITHDICTIONARY_TEXT_SETTING_PAGE,  
       
  1165                                       currentItem, 
       
  1166                                       iRecognitionWithDictionaryItems);
       
  1167 
       
  1168     CleanupStack::PushL(dlg);
       
  1169     
       
  1170     if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged))
       
  1171         {
       
  1172         if(currentItem == iModel->RecognitionWithDictionary())
       
  1173             {
       
  1174             iModel->SetRecognitionWithDictionary(currentItem == 0? 1:0);
       
  1175             UpdateListBoxL(EGSInputpenIdRecognitionWithDictionary);
       
  1176             }
       
  1177         }
       
  1178  
       
  1179     CleanupStack::Pop(dlg);  
       
  1180     }
       
  1181 
       
  1182 // ---------------------------------------------------------
       
  1183 // Display input method for find setting page
       
  1184 // ---------------------------------------------------------
       
  1185 //
       
  1186 void CGSPenInputContainer::ShowInputMethodForFindPageL()
       
  1187     {
       
  1188     TInt currentItem = iModel->InputMethodForFind();
       
  1189 
       
  1190     CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage(
       
  1191                                       R_GS_INPUTMETHODFORFIND_TEXT_SETTING_PAGE, 
       
  1192                                       currentItem, 
       
  1193                                       iInputMethodForFindItems);
       
  1194 
       
  1195     CleanupStack::PushL(dlg);
       
  1196     
       
  1197     if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged))
       
  1198         {
       
  1199         if(currentItem != iModel->InputMethodForFind())
       
  1200             {
       
  1201             iModel->SetInputMethodForFind(currentItem);
       
  1202             UpdateListBoxL(EGSInputpenIdInputMethodForFind);
       
  1203             }
       
  1204         }
       
  1205  
       
  1206     CleanupStack::Pop(dlg);
       
  1207     }
       
  1208 
       
  1209 // ---------------------------------------------------------
       
  1210 // Display chinese find method setting page
       
  1211 // ---------------------------------------------------------
       
  1212 //
       
  1213 void CGSPenInputContainer::ShowChineseFindMethodPageL()
       
  1214     {
       
  1215     TInt currentItem = iModel->ChineseFindMethod();
       
  1216 
       
  1217     CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage(
       
  1218                                       R_GS_CHINESEFINDMETHOD_TEXT_SETTING_PAGE,
       
  1219                                       currentItem,
       
  1220                                       iChineseFindMethodItems);
       
  1221 
       
  1222     CleanupStack::PushL(dlg);
       
  1223 
       
  1224     if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged))
       
  1225         {
       
  1226         if(currentItem != iModel->ChineseFindMethod())
       
  1227             {
       
  1228             iModel->SetChineseFindMethod(currentItem);
       
  1229             UpdateListBoxL(EGSInputpenIdChineseFindMethod);
       
  1230             }
       
  1231         }
       
  1232 
       
  1233     CleanupStack::Pop(dlg);
       
  1234     }
       
  1235 
       
  1236 // ---------------------------------------------------------
       
  1237 // Display pen trail colour setting page
       
  1238 // ---------------------------------------------------------
       
  1239 //
       
  1240 void CGSPenInputContainer::ShowTrailColourPageL()
       
  1241     {
       
  1242     CArrayFixFlat<TRgb>* colours = new (ELeave) CArrayFixFlat<TRgb>(8);
       
  1243     CleanupStack::PushL(colours);
       
  1244 
       
  1245     for(TInt i = 0; i < AknPenInputTrailColorUtils::ColorCount(); i++)
       
  1246         {
       
  1247         colours->AppendL(AknPenInputTrailColorUtils::ColorAt(i));
       
  1248         }
       
  1249 //    colours->AppendL(KRgbBlack);
       
  1250 //    colours->AppendL(KRgbDarkGray);
       
  1251 //    colours->AppendL(KRgbDarkRed);
       
  1252 //    colours->AppendL(KRgbDarkGreen);
       
  1253 //    colours->AppendL(KRgbDarkYellow);
       
  1254 //    colours->AppendL(KRgbDarkBlue);
       
  1255 //    colours->AppendL(KRgbDarkMagenta);
       
  1256 //    colours->AppendL(KRgbDarkCyan);
       
  1257 //    colours->AppendL(KRgbRed);
       
  1258 //    colours->AppendL(KRgbGreen);
       
  1259 //    colours->AppendL(KRgbYellow);
       
  1260 //    colours->AppendL(KRgbBlue);
       
  1261 //    colours->AppendL(KRgbMagenta);
       
  1262 //    colours->AppendL(KRgbCyan);
       
  1263 //    colours->AppendL(KRgbGray);
       
  1264 //    colours->AppendL(KRgbWhite);
       
  1265 
       
  1266     TBool noneChosen = EFalse; 
       
  1267     TRgb colourChosen = TRgb(iModel->TrailColour());
       
  1268                             
       
  1269     CAknColourSelectionGrid* dlg = CAknColourSelectionGrid::NewL(colours, 
       
  1270                                                                  EFalse, 
       
  1271                                                                  noneChosen, 
       
  1272                                                                  colourChosen);
       
  1273     
       
  1274     CleanupStack::PushL(dlg);
       
  1275     
       
  1276     if (dlg->ExecuteLD())
       
  1277         {
       
  1278         iModel->SetTrailColour(colourChosen.Value());
       
  1279         UpdateListBoxL(EGSInputpenIdPenTrailColour);
       
  1280         }
       
  1281     
       
  1282     CleanupStack::Pop(dlg);         
       
  1283     CleanupStack::PopAndDestroy(colours);
       
  1284     }
       
  1285 
       
  1286 // ---------------------------------------------------------
       
  1287 // Display touch screen calibration setting page
       
  1288 // ---------------------------------------------------------
       
  1289 //
       
  1290 void CGSPenInputContainer::StartTouchScreenCalibL()
       
  1291     {
       
  1292     _LIT( KTouchScreenCalibFileName, "z:TouchScreenCalib.exe" );
       
  1293     TInt err = KErrNone;
       
  1294  
       
  1295     TParse parse;
       
  1296     parse.Set( KTouchScreenCalibFileName, 
       
  1297                    &KDC_PROGRAMS_DIR, NULL );
       
  1298     TFileName fileName( parse.FullName() );
       
  1299  
       
  1300     RProcess process;
       
  1301     err = process.Create( fileName, KNullDesC );
       
  1302     User::LeaveIfError(err);
       
  1303  
       
  1304     CApaCommandLine* commandLine = CApaCommandLine::NewLC();
       
  1305     commandLine->SetDocumentNameL( KNullDesC );
       
  1306     commandLine->SetExecutableNameL( fileName );
       
  1307     commandLine->SetProcessEnvironmentL( process );
       
  1308     CleanupStack::PopAndDestroy( commandLine );
       
  1309  
       
  1310     process.Resume();
       
  1311     process.Close();
       
  1312     }
       
  1313     
       
  1314 // ---------------------------------------------------------
       
  1315 // Re-Construct List box
       
  1316 // ---------------------------------------------------------
       
  1317 //
       
  1318 void CGSPenInputContainer::ReConstructListBoxL() 
       
  1319     {
       
  1320     iChinese = iModel->ChineseLanguage();
       
  1321     iJapanese = iModel->JapaneseLanguage();        
       
  1322 
       
  1323     delete iListboxItemArray;
       
  1324     iListboxItemArray = NULL;
       
  1325     
       
  1326     iListboxItemArray = CGSListBoxItemTextArray::NewL(R_INPUTPEN_LBX,
       
  1327                                                       *iListBox,
       
  1328                                                       *iCoeEnv);
       
  1329     iListBox->Model()->SetItemTextArray(iListboxItemArray);
       
  1330     iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);
       
  1331     
       
  1332     if (!iIconArray)
       
  1333         {
       
  1334         CArrayPtr<CGulIcon>* icons = new (ELeave) CArrayPtrFlat<CGulIcon>(2);
       
  1335         CleanupStack::PushL(icons);
       
  1336         CGulIcon* icon = CGulIcon::NewL();
       
  1337         CleanupStack::PushL(icon);
       
  1338     
       
  1339         icons->AppendL(icon);
       
  1340 
       
  1341         CEikFormattedCellListBox* listbox = static_cast<CEikFormattedCellListBox*>(iListBox);
       
  1342     
       
  1343         listbox->ItemDrawer()->FormattedCellData()->SetIconArray(icons);// icons owned by List box
       
  1344     
       
  1345         iIconArray = listbox->ItemDrawer()->FormattedCellData()->IconArray();
       
  1346     
       
  1347         CleanupStack::Pop(icon);
       
  1348         CleanupStack::Pop(icons);
       
  1349     }
       
  1350 
       
  1351     CreateListBoxItemsL();
       
  1352     iListBox->HandleItemAdditionL();
       
  1353     }
       
  1354     
       
  1355 
       
  1356 // ---------------------------------------------------------
       
  1357 //  Launch other application;
       
  1358 // ---------------------------------------------------------
       
  1359 //
       
  1360 void CGSPenInputContainer::LaunchAppL( TUid aAppUid )
       
  1361     {
       
  1362     // Find the task with uid
       
  1363     TApaTaskList taskList( iEikonEnv->WsSession() );    
       
  1364     TApaTask task = taskList.FindApp( aAppUid );
       
  1365 
       
  1366     if ( task.Exists() )
       
  1367         {
       
  1368         task.BringToForeground();
       
  1369         }
       
  1370     else
       
  1371         {
       
  1372         // Launch peninputsetting application as embedded.
       
  1373         if ( iNullService )
       
  1374             {
       
  1375             delete iNullService;
       
  1376             iNullService = NULL;
       
  1377             }
       
  1378         iNullService = CAknNullService::NewL( aAppUid, NULL );
       
  1379         }    
       
  1380     }
       
  1381 
       
  1382 // ---------------------------------------------------------
       
  1383 //  Identify the help context so that the framework can look up
       
  1384 //  the corresponding help topic
       
  1385 // ---------------------------------------------------------
       
  1386 //
       
  1387 void CGSPenInputContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
  1388     {
       
  1389     aContext.iMajor = KUidGS;
       
  1390     aContext.iContext = HLP_GS_PEN_INPUT; // temp fix for helps integration build break;
       
  1391     }
       
  1392 
       
  1393 // End Of File