fep/aknfep/UiPlugins/AknFepUiInterface/AvkonImpl/src/AknFepUiAvkonImpl.cpp
changeset 0 eb1f2e154e89
child 3 f5a1e66df979
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2007 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:           
       
    15 *       Provides the FEP's Avkon UI access methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "AknFepUiAvkonImpl.h"
       
    31 #include "AknFepUiAvkonStylusPopUpMenu.h"
       
    32 #include <aknnotedialog.h>          //CAknNoteDialog
       
    33 #include <aknmessagequerydialog.h>  //CAknMessageQueryDialog
       
    34 #include <aknradiobuttonsettingpage.h>
       
    35 #include <aknsettingpage.h>
       
    36 #include <aknlistquerydialog.h>
       
    37 #include <aknedsts.h>               //CAknEdwinState
       
    38 #include <barsread.h>
       
    39 #include <AknFep.rsg>
       
    40 #include "AknFepGlobalEnums.h"
       
    41 #include <aknstyluspopupmenu.h>
       
    42 #include <aknSctDialog.h>           //CAknCharMapDialog
       
    43 #include <akntouchpane.h>
       
    44 #include "AknFepQuery.h"
       
    45 #include <aknedformaccessor.h>
       
    46 #include "AknFepIndicatorAvkon.h"
       
    47 #include <AknFepManagerInterface.h> // MAknFepManagerInterface
       
    48 #include <AknIndicatorContainer.h>  //CAknIndicatorContainer
       
    49 #include "AknFepUIAvkonCtrlContainerChinese.h"
       
    50 #include "AknFepUIAvkonCtrlContainerJapanese.h"
       
    51 #include <AknFepUiInterfacePanic.h>
       
    52 #include "AknFepUIAvkonCtrlJapaneseKutenQueryDialog.h"
       
    53 #include <featmgr.h>
       
    54 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
    55 // Predictive QWERTY (XT9) changes ---->
       
    56 #include <aknappui.h>
       
    57 #include <akntitle.h> //CAknTitlePane
       
    58 #include <StringLoader.h>
       
    59 #include "AknFepAvkonCandidatePopup.h"
       
    60 #include "AknFepUiAvkonCtrlExactWordPopupContent.h"
       
    61 #include "AknFepPredictiveSettingDialog.h"
       
    62 #include "AknFepUserDictionaryEditDialog.h"
       
    63 
       
    64 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
    65 #include "AknFepUIAvkonCtrlDualLanguageSettingDialog.h"
       
    66 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
    67 // Predictive QWERTY (XT9) changes <----
       
    68 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__    
       
    69 #include <AvkonInternalCRKeys.h> 
       
    70 #endif //__ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
    71 #endif //RD_INTELLIGENT_TEXT_INPUT
       
    72 
       
    73 GLDEF_C void AknFepUiInterfacePanic(TAknFepUiInterfacePanic aPanic)
       
    74     {
       
    75     User::Panic(_L("AKNFEPUI"),aPanic);
       
    76     }
       
    77 
       
    78 
       
    79 // This command is is used for setting empty CBA.
       
    80 const TInt ENullCommandId = 0;
       
    81 
       
    82 
       
    83 CAknFepUIAvkonImpl* CAknFepUIAvkonImpl::NewL()
       
    84 	{
       
    85 	CAknFepUIAvkonImpl* self = new(ELeave) CAknFepUIAvkonImpl();
       
    86     CleanupStack::PushL(self);
       
    87     self->ConstructL();
       
    88     CleanupStack::Pop(self);
       
    89     return self;	
       
    90 	}
       
    91 
       
    92 void CAknFepUIAvkonImpl::ConstructL()
       
    93     {
       
    94 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
    95 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__   
       
    96     //Attach the P&S property to the keyboardlayout and subscribe to the P&S framework
       
    97     // for any keyboard layout change.
       
    98     User::LeaveIfError(iKeyboardLayoutStatusProperty.Attach(KCRUidAvkon, KAknKeyBoardLayout));    
       
    99     iKeyboardLayoutStatusSubscriber = new (ELeave) CSubscriber(
       
   100                                          TCallBack(HandleKeyboardLayoutChangeNotification, this), 
       
   101                                          iKeyboardLayoutStatusProperty);    
       
   102     iKeyboardLayoutStatusSubscriber->SubscribeL();
       
   103 #endif
       
   104 #endif     
       
   105     }
       
   106 
       
   107 CAknFepUIAvkonImpl::CAknFepUIAvkonImpl()
       
   108 	{
       
   109     iDialog = NULL;
       
   110     iPredictiveSettingDialog = NULL;
       
   111     iListQueryDialog = NULL;
       
   112     iTextQueryDialog = NULL;
       
   113 	}
       
   114 CAknFepUIAvkonImpl::~CAknFepUIAvkonImpl()
       
   115 	{
       
   116     delete iCba;
       
   117     iCba = NULL;
       
   118     DeleteDialogs();
       
   119 
       
   120 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
   121 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__       
       
   122     if (iKeyboardLayoutStatusSubscriber)
       
   123         {
       
   124         iKeyboardLayoutStatusSubscriber->StopSubscribe();
       
   125         }
       
   126     iKeyboardLayoutStatusProperty.Close();
       
   127     delete iKeyboardLayoutStatusSubscriber;     
       
   128 #endif    
       
   129 #endif   
       
   130 	}
       
   131 
       
   132 void CAknFepUIAvkonImpl::DeleteDialogs()
       
   133     {
       
   134     if(iDialog)
       
   135         {
       
   136         delete iDialog;
       
   137         iDialog = NULL;
       
   138         }
       
   139     if(iCharMapDialog)
       
   140         {
       
   141         delete iCharMapDialog;
       
   142         iCharMapDialog = NULL;
       
   143         }
       
   144     if(iListQueryDialog)
       
   145         {
       
   146         delete iListQueryDialog;
       
   147         iListQueryDialog = NULL;
       
   148         }
       
   149     if(iTextQueryDialog)
       
   150         {
       
   151         delete iTextQueryDialog;
       
   152         iTextQueryDialog = NULL;
       
   153         }
       
   154     if(iPredictiveSettingDialog)
       
   155         {
       
   156         TRAP_IGNORE( iPredictiveSettingDialog->ProcessCommandL(EAknCmdExit));
       
   157         }
       
   158     }
       
   159 
       
   160 void CAknFepUIAvkonImpl::LaunchConfirmationNoteL(TInt aResourceId)
       
   161 	{
       
   162     CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog();
       
   163     dlg->SetTimeout(CAknNoteDialog::EShortTimeout);
       
   164     dlg->SetTone(CAknNoteDialog::ENoTone);
       
   165     dlg->ExecuteLD(aResourceId);
       
   166 	}
       
   167 
       
   168 void CAknFepUIAvkonImpl::LaunchHelpTextQueryL(TInt aResourceId)
       
   169 	{
       
   170     CAknMessageQueryDialog* dlg = new (ELeave) CAknMessageQueryDialog();
       
   171     iDialog = dlg;
       
   172     dlg->ExecuteLD(aResourceId);
       
   173     iDialog = NULL;
       
   174 	}
       
   175 
       
   176 TInt CAknFepUIAvkonImpl::LaunchCangJieOptionDlgL(TInt aResourceId, TInt& aLevel, MDesC16Array* aItems)
       
   177 	{
       
   178     CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage (
       
   179         aResourceId,
       
   180         aLevel,
       
   181         aItems
       
   182         );
       
   183     TBool ret = dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
       
   184 	return ret;
       
   185 	}
       
   186 
       
   187 /* TCleanupSlotBase can be placed on the cleanup stack to cleanup
       
   188  * a CBase derived object, but with the benefit that the CBase
       
   189  * object can be reassigned.
       
   190  * Essesntially it is a reusable cleanup stack slot.
       
   191  * This is useful for situations where you would like to be able
       
   192  * to remove or change an item on the cleanup stack, but do not
       
   193  * know enough about the contents of the cleanup stack above it
       
   194  * to unstack then restack the items that should remain.
       
   195  */
       
   196 class TCleanupSlotCBase
       
   197 	{
       
   198 public:
       
   199 	TCleanupSlotCBase() 
       
   200 		: iObj(NULL) 
       
   201 		{}
       
   202 	TCleanupSlotCBase(CBase* aObj) 
       
   203 		: iObj(aObj) 
       
   204 		{}
       
   205 	void PushL()
       
   206 		{ CleanupStack::PushL(TCleanupItem(Cleanup, this)); }
       
   207 	void Pop()
       
   208 		{ CleanupStack::Pop(); }
       
   209 	void PopAndDestroy()
       
   210 		{ CleanupStack::PopAndDestroy(); }
       
   211 	void SetObj(CBase* aObj)
       
   212 		{ iObj = aObj; }
       
   213 private:
       
   214 	static void Cleanup(TAny* aThis)
       
   215 		{ delete static_cast<CBase*>(static_cast<TCleanupSlotCBase*>(aThis)->iObj); }
       
   216 private:
       
   217 	CBase* iObj;
       
   218 	};
       
   219 	
       
   220 TInt CAknFepUIAvkonImpl::LaunchListPopupL(TInt aResourceId, TInt& aIndex, TInt aInitialIndex, MDesC16Array* aItems, CArrayPtr<CGulIcon>* aIcons)
       
   221 	{
       
   222 	TCleanupSlotCBase iconsCleanup(aIcons);
       
   223 	iconsCleanup.PushL();
       
   224 	
       
   225     iListQueryDialog = new (ELeave) CAknListQueryDialog(&aIndex);
       
   226     iListQueryDialog->PrepareLC( aResourceId );
       
   227     
       
   228     CAknListQueryControl* listQueryControl = 
       
   229         STATIC_CAST( CAknListQueryControl*, iListQueryDialog->Control(EListQueryControl));
       
   230     if (aIcons)
       
   231     	{
       
   232 	    listQueryControl->Listbox()->ItemDrawer()->FormattedCellData()
       
   233 	        ->SetIconArrayL( aIcons );
       
   234 	   	iconsCleanup.SetObj(NULL);	// ownership transferred to dialog
       
   235 	    listQueryControl->Listbox()->ItemDrawer()->FormattedCellData()
       
   236 	        ->SetNotAlwaysDrawnSubCellL( 0, ETrue );// Needed because not using icon in cell.
       
   237     	}
       
   238 
       
   239     // Activate selected language:
       
   240     CTextListBoxModel* model = listQueryControl->Listbox()->Model();
       
   241     model->SetItemTextArray( aItems );
       
   242     model->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   243     iListQueryDialog->ListBox()->SetCurrentItemIndex( aInitialIndex );
       
   244 
       
   245     // Fire up the dialog
       
   246     TInt ret = iListQueryDialog->RunLD();
       
   247     iconsCleanup.Pop();
       
   248     iListQueryDialog = NULL;
       
   249     return ret;
       
   250 	}
       
   251 
       
   252 void CAknFepUIAvkonImpl::UpdateSoftkeysL(TInt aResourceId, CAknEdwinState* aEditorState, MEikCommandObserver* aObserver, TInt aInputMode)
       
   253 	{
       
   254     CEikButtonGroupContainer* currentEditorCba=aEditorState->CbaState().iCurrentCba;
       
   255     if (currentEditorCba /*&& currentEditorCba->IsVisible()*/)
       
   256         {
       
   257 //        currentEditorCba->MakeVisible(ETrue);
       
   258         TBool cbaModified = EFalse;
       
   259 
       
   260         // remove the old command button(s)
       
   261         if (aEditorState->CbaState().iLeftSoftkeyCommandId)
       
   262             {
       
   263             currentEditorCba->RemoveCommandFromStack(ELeftSoftkeyIndex, currentEditorCba->ButtonGroup()->CommandId(ELeftSoftkeyIndex));
       
   264             currentEditorCba->RemoveCommandObserver(ELeftSoftkeyIndex);
       
   265             aEditorState->CbaState().iLeftSoftkeyCommandId=0;
       
   266             cbaModified = ETrue;
       
   267             }
       
   268         if (aEditorState->CbaState().iRightSoftkeyCommandId)
       
   269             {
       
   270             currentEditorCba->RemoveCommandFromStack(ERightSoftkeyIndex, currentEditorCba->ButtonGroup()->CommandId(ERightSoftkeyIndex));
       
   271             currentEditorCba->RemoveCommandObserver(ERightSoftkeyIndex);
       
   272             aEditorState->CbaState().iRightSoftkeyCommandId=0;
       
   273             cbaModified = ETrue;
       
   274             }
       
   275         if (aEditorState->MiddleSoftkeyCommandId())
       
   276             {
       
   277             currentEditorCba->RemoveCommandFromStack(EMiddleSoftkeyIndex, currentEditorCba->ButtonGroup()->CommandId(EMiddleSoftkeyIndex));
       
   278             currentEditorCba->RemoveCommandObserver(EMiddleSoftkeyIndex);
       
   279             aEditorState->SetMiddleSoftkeyCommandId(0);
       
   280             cbaModified = ETrue;
       
   281             }
       
   282 
       
   283         if( aResourceId  == R_AKNFEP_SOFTKEYS_FINGER ||
       
   284             aResourceId  == R_AKNFEP_SOFTKEYS_FINGER_OPTION_PREVIOUS  ||
       
   285             aResourceId  == R_AKNFEP_SOFTKEYS_FINGER_SPELL_PREVIOUS )
       
   286             {
       
   287             ShowOwnsSoftkeysL(aResourceId, aObserver);
       
   288             return;     // return this function
       
   289             }
       
   290         // for Japanese
       
   291         switch (aResourceId)
       
   292             {
       
   293             case R_AKNFEP_SOFTKEYS_PREDICT_OTHER_COMMIT:
       
   294             case R_AKNFEP_SOFTKEYS_EMPTY_EMPTY_COMMIT:
       
   295             case R_AKNFEP_SOFTKEYS_EMPTY_OTHER_COMMIT:
       
   296             case R_AKNFEP_SOFTKEYS_PHRASE_CREATION_SELECT_CANCEL_SELECT:
       
   297             case R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE:
       
   298                 ShowOwnsSoftkeysL(aResourceId, aObserver);
       
   299                 return;     // return this function
       
   300             case R_AKNFEP_SOFTKEYS_CONVERT_OTHER_SELECT:
       
   301             case R_AKNFEP_SOFTKEYS_EMPTY_CANCEL_SELECT:
       
   302             case R_AVKON_SOFTKEYS_EMPTY:
       
   303                 ShowEmptySoftkeysL(ETrue, aObserver, aInputMode);
       
   304                 return;     // return this function
       
   305             default:
       
   306                 // delete iCba object in this function
       
   307                 ShowEmptySoftkeysL(EFalse, aObserver, aInputMode);
       
   308                 break;
       
   309             }
       
   310 
       
   311         // add the new button/command ids
       
   312         if (aResourceId)
       
   313             {
       
   314             TResourceReader reader;
       
   315             CCoeEnv::Static()->CreateResourceReaderLC(reader, aResourceId);
       
   316             reader.ReadInt32();     // flags
       
   317             reader.ReadInt16();     // width
       
   318             reader.ReadInt32();     // related buttons
       
   319             reader.ReadInt16();     // size of buttons array
       
   320 
       
   321             TInt leftSoftkeyShortCommandId=(currentEditorCba->ButtonGroup()->CommandId(ELeftSoftkeyIndex)) & 0x0000ffff;
       
   322 
       
   323             for (TInt index=0; index < currentEditorCba->ButtonCount(); index++)
       
   324                 {
       
   325                 TInt cbaIndex = index;
       
   326                 if ( index >=1 )
       
   327                     {
       
   328                     cbaIndex++;    // skip the scrollbar
       
   329                     }
       
   330 
       
   331                 TUint8 version = (TUint8)reader.ReadUint8();
       
   332                 TInt commandId;
       
   333                 if (version == KAknCbaVersion)
       
   334                     {
       
   335                     TUint32 shortCommandId = reader.ReadUint16();
       
   336                     TUint32 longCommandId = reader.ReadUint16();
       
   337                     commandId = (longCommandId << 16) | shortCommandId;
       
   338                     }
       
   339                 else
       
   340                     {
       
   341                     commandId = TInt(TUint(reader.ReadUint16()));
       
   342                     }
       
   343                 TPtrC text=reader.ReadTPtrC();
       
   344                 reader.ReadTPtrC(); // bmp filename
       
   345                 reader.ReadInt16(); // bmp id
       
   346                 reader.ReadInt16(); // bmp mask id
       
   347 
       
   348                 // check we have a command and also check that if we're changing the
       
   349                 // left softkey that it is 'Options'
       
   350                 if ( commandId )
       
   351                     {
       
   352                     if(!currentEditorCba->UpdatedCommandObserverExists(CEikButtonGroupContainer::TCommandPosition(cbaIndex)))
       
   353                         {
       
   354                         currentEditorCba->UpdateCommandObserverL(cbaIndex, *aObserver);
       
   355                         currentEditorCba->AddCommandToStackL(cbaIndex, commandId, text);
       
   356                         
       
   357                     if (cbaIndex==ELeftSoftkeyIndex)
       
   358                         {
       
   359                         aEditorState->CbaState().iLeftSoftkeyCommandId=commandId;
       
   360                         }
       
   361                     else if (cbaIndex==ERightSoftkeyIndex)
       
   362                         {
       
   363                         aEditorState->CbaState().iRightSoftkeyCommandId=commandId;
       
   364                         }
       
   365                     else if (cbaIndex==EMiddleSoftkeyIndex)
       
   366                         {
       
   367                         aEditorState->SetMiddleSoftkeyCommandId(commandId);
       
   368                         }
       
   369                         }
       
   370 
       
   371                     cbaModified = ETrue;
       
   372                     }
       
   373                 }
       
   374             CleanupStack::PopAndDestroy(); // reader
       
   375             }
       
   376 
       
   377         if (cbaModified)
       
   378             {
       
   379             currentEditorCba->DrawNow(); // to update the cba
       
   380             }
       
   381         }
       
   382 	}
       
   383 
       
   384 /**
       
   385  *  Show cba of aResourceId using owns cba object(iCba)
       
   386  *
       
   387  *  @since 3.2
       
   388  *  @param aResourceId Cba resource id.
       
   389  *  @return None
       
   390  */
       
   391 void CAknFepUIAvkonImpl::ShowOwnsSoftkeysL(const TInt aResourceId, MEikCommandObserver* aObserver)
       
   392     {
       
   393     if (iCba)
       
   394         {
       
   395         delete iCba;
       
   396         iCba = NULL;
       
   397         }
       
   398     iCba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba,
       
   399                                           CEikButtonGroupContainer::EHorizontal,
       
   400                                           aObserver,
       
   401                                           aResourceId);
       
   402     iCba->SetBoundingRect(CEikonEnv::Static()->EikAppUi()->ApplicationRect());
       
   403     iCba->DrawNow();
       
   404     }
       
   405 
       
   406 /**
       
   407  * This method is that empty CBA is shown in case aShown is ETrue.
       
   408  * If aShown is EFalse, empty CBA is erased.
       
   409  */
       
   410 void CAknFepUIAvkonImpl::ShowEmptySoftkeysL(TBool aShown, MEikCommandObserver* aObserver, TInt aInputMode)
       
   411     {
       
   412     if (aShown)
       
   413         {
       
   414         if (!iCba)
       
   415             {
       
   416             iCba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, CEikButtonGroupContainer::EHorizontal, aObserver, R_AVKON_SOFTKEYS_EMPTY);
       
   417             iCba->SetBoundingRect(CEikonEnv::Static()->EikAppUi()->ApplicationRect());
       
   418             }
       
   419         // set each CBA
       
   420         TBool update = UpdateSoftkeyLabelL(ELeftSoftkeyIndex, ENullCommandId, R_TEXT_SOFTKEY_EMPTY);
       
   421         if (aInputMode == EPinyin || aInputMode == EZhuyin ||
       
   422             aInputMode == EStroke || aInputMode == ECangJie)
       
   423             {
       
   424             update |= UpdateSoftkeyLabelL(ERightSoftkeyIndex, EAknFepSoftkeyCloseWindow, R_AKNFEP_SOFTKEY_CCPU_CANCEL);
       
   425             update |= UpdateSoftkeyLabelL( EMiddleSoftkeyIndex, ENullCommandId, R_AVKON_SOFTKEY_SELECT_TEXT ); 
       
   426             }
       
   427         else
       
   428             {
       
   429             update |= UpdateSoftkeyLabelL(ERightSoftkeyIndex, ENullCommandId, R_TEXT_SOFTKEY_EMPTY);
       
   430             update |= UpdateSoftkeyLabelL(EMiddleSoftkeyIndex, ENullCommandId, R_TEXT_SOFTKEY_EMPTY);
       
   431             }
       
   432 
       
   433         if (update)
       
   434             {
       
   435             iCba->DrawNow();
       
   436             }
       
   437         }
       
   438     else
       
   439         {
       
   440         delete iCba;
       
   441         iCba = NULL;
       
   442         }
       
   443     }
       
   444 
       
   445 TBool CAknFepUIAvkonImpl::SoftkeysExist()
       
   446 	{
       
   447 	return iCba != NULL;
       
   448 	}
       
   449 
       
   450 TInt CAknFepUIAvkonImpl::SoftkeyCommandId(TInt aPosition)
       
   451 	{
       
   452 	return iCba->ButtonGroup()->CommandId(aPosition);
       
   453 	}
       
   454 
       
   455 void CAknFepUIAvkonImpl::DeleteSoftkeys()
       
   456 	{
       
   457 	delete iCba;
       
   458 	iCba = NULL;
       
   459 	}
       
   460 
       
   461 void CAknFepUIAvkonImpl::DrawSoftkeysNow()
       
   462 	{
       
   463 	iCba->DrawNow();
       
   464 	}
       
   465 
       
   466 void CAknFepUIAvkonImpl::CreateSoftkeys(TInt aResourceId, MEikCommandObserver* aObserver)
       
   467 	{
       
   468 	DeleteSoftkeys();
       
   469     TRAP_IGNORE(iCba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, CEikButtonGroupContainer::EHorizontal, aObserver, aResourceId));
       
   470     iCba->SetBoundingRect(CEikonEnv::Static()->EikAppUi()->ApplicationRect());
       
   471     iCba->MakeVisible(ETrue);
       
   472     iCba->ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront + 10);
       
   473 	}
       
   474 
       
   475 TBool CAknFepUIAvkonImpl::UpdateSoftkeyLabelL(TInt aPosition, TInt aCommandId, TInt aTextResId)
       
   476 	{
       
   477     if (iCba->ButtonGroup()->CommandId(aPosition) != aCommandId)
       
   478         {
       
   479         HBufC* buf = CEikonEnv::Static()->AllocReadResourceLC(aTextResId);
       
   480         if( buf->Des().Length() > 1 && EMiddleSoftkeyIndex != aPosition )
       
   481             {
       
   482             iCba->SetCommandL(aPosition, aCommandId, buf->Des().Mid(1));                    
       
   483             }
       
   484         else
       
   485             {           
       
   486             iCba->SetCommandL(aPosition, aCommandId, *buf);
       
   487             }
       
   488         CleanupStack::PopAndDestroy(buf);
       
   489         return ETrue;
       
   490         }
       
   491     return EFalse;
       
   492 	}
       
   493 
       
   494 void CAknFepUIAvkonImpl::SetFepMenuObserver(MAknFepUiInterfaceMenuObserver* aObserver)
       
   495 	{
       
   496 	iFepMenuObserver = aObserver;
       
   497 	if (aObserver)
       
   498 		{	
       
   499 		CAknEnv::Static()->SetFepMenuObserver(this);
       
   500 		}
       
   501 	else
       
   502 		{	
       
   503 		CAknEnv::Static()->SetFepMenuObserver(NULL);
       
   504 		}
       
   505 	}
       
   506 
       
   507 CAknFepUiInterfaceMenuBar* CAknFepUIAvkonImpl::EditorStateMenuBar(CAknEdwinState* aEditorState)
       
   508 	{
       
   509 	iEditorMenuBar.iMenuBar = aEditorState->MenuBar();
       
   510 	return &iEditorMenuBar;
       
   511 	}
       
   512 
       
   513 void CAknFepUIAvkonImpl::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
       
   514 	{
       
   515 	iTempMenuPane.iMenuPane = aMenuPane;
       
   516 	if (iFepMenuObserver)
       
   517 		iFepMenuObserver->DynInitMenuPaneL(aResourceId, &iTempMenuPane);
       
   518 	}
       
   519 
       
   520 void CAknFepUIAvkonImpl::DynInitMenuBarL(TInt aResourceId,CEikMenuBar* aMenuBar)
       
   521 	{
       
   522 	CAknFepUIAvkonMenuBarImpl* impl = &iTempMenuBar;
       
   523 	if (iEditorMenuBar.iMenuBar == aMenuBar)
       
   524 		impl = &iEditorMenuBar;
       
   525 	impl->iMenuBar = aMenuBar;
       
   526 	if (iFepMenuObserver)
       
   527 		iFepMenuObserver->DynInitMenuBarL(aResourceId, impl);
       
   528 	}
       
   529 
       
   530 void CAknFepUIAvkonImpl::SetEmphasis(CCoeControl* aMenuControl,TBool aEmphasis)
       
   531 	{
       
   532 	CBase* impl = NULL;
       
   533 	if (aMenuControl == iEditorMenuBar.iMenuBar)
       
   534 		impl = &iEditorMenuBar;
       
   535 	else if (aMenuControl == iTempMenuBar.iMenuBar)
       
   536 		impl = &iTempMenuBar;
       
   537 	else if (aMenuControl == iTempMenuPane.iMenuPane)
       
   538 		impl = &iTempMenuPane;
       
   539 	if (iFepMenuObserver)
       
   540 		iFepMenuObserver->SetEmphasis(impl, aEmphasis);
       
   541 	}
       
   542 
       
   543 void CAknFepUIAvkonImpl::ProcessCommandL(TInt aCommandId)
       
   544 	{
       
   545 	if (iFepMenuObserver)
       
   546 		iFepMenuObserver->ProcessCommandL(aCommandId);
       
   547 	}
       
   548 
       
   549 CAknFepUiInterfaceMenuBar* CAknFepUIAvkonImpl::NewMenuBarL(MAknFepUiInterfaceMenuObserver* aObserver, TInt aHotKeyResourceId, TInt aMenuTitleResourceId)
       
   550 	{
       
   551 	CAknFepUIAvkonMenuBarOwningImpl* menuBar = new(ELeave) CAknFepUIAvkonMenuBarOwningImpl;
       
   552 	CleanupStack::PushL(menuBar);
       
   553 	menuBar->ConstructL(aObserver, aHotKeyResourceId, aMenuTitleResourceId);
       
   554 	CleanupStack::Pop(menuBar);
       
   555 	return menuBar;
       
   556 	}
       
   557 
       
   558 CAknFepUiInterfaceStylusPopUpMenu* CAknFepUIAvkonImpl::NewStylusPopUpMenuL(MAknFepUiInterfaceMenuObserver* aObserver, const TPoint& aPoint)
       
   559 	{
       
   560 	CAknFepUIAvkonStylusPopUpMenu* popupMenu = new(ELeave) CAknFepUIAvkonStylusPopUpMenu;
       
   561 	CleanupStack::PushL(popupMenu);
       
   562 	popupMenu->ConstructL(aObserver, aPoint);
       
   563 	CleanupStack::Pop(popupMenu);
       
   564 	return popupMenu;
       
   565 	}
       
   566 
       
   567 TInt CAknFepUIAvkonImpl::CharMapDialogL(TInt aCharCase, TDes& aSpecialChars, TInt aCharSetResourceId, TBool aLockNumericKeys, TBool aShowPictographsFirst, TBool aShowNoPictographs, TBool aShowAnotherTable, TInt aAfterSctChars, TInt aResId, TBool aDisableRecentItemRow )
       
   568 	{
       
   569 	TInt result;
       
   570 	
       
   571 	iCharMapDialog = new(ELeave) CAknCharMapDialog(aCharCase, aSpecialChars, aCharSetResourceId);
       
   572 
       
   573     if (aLockNumericKeys)
       
   574         {
       
   575         iCharMapDialog->LockNumericKeys(ETrue);
       
   576         }
       
   577 
       
   578     if ( aShowPictographsFirst )
       
   579         {
       
   580         // It is supposed that the pictograph table launch is allowed in this case.
       
   581         iCharMapDialog->ShowPictographsFirst();
       
   582         }
       
   583     else if (aShowNoPictographs)
       
   584         {
       
   585         // Pictograph table is not shown.
       
   586         iCharMapDialog->ShowNoPictographs();
       
   587         }
       
   588 
       
   589     if (aShowAnotherTable)
       
   590         {
       
   591         iCharMapDialog->ShowAnotherTable(aAfterSctChars);
       
   592         }
       
   593     if(aDisableRecentItemRow)
       
   594         {
       
   595         iCharMapDialog->DisableRecentCharsRow();
       
   596         }
       
   597     
       
   598 
       
   599     result = iCharMapDialog->ExecuteLD(aResId);
       
   600     iCharMapDialog = NULL;
       
   601     return result;
       
   602 	}
       
   603 
       
   604 void CAknFepUIAvkonImpl::TouchPaneSetFepPenSupportInterface(MAknFepPenSupportInterface* aFepPenSupportInterface)
       
   605 	{
       
   606 	if(iAvkonAppUi->TouchPane())
       
   607 		iAvkonAppUi->TouchPane()->SetFepPenSupportInterface(aFepPenSupportInterface);
       
   608 	}
       
   609 
       
   610 void CAknFepUIAvkonImpl::TouchPaneAllowInputMethodActivation(TBool aValue)
       
   611 	{
       
   612 	if(iAvkonAppUi->TouchPane())
       
   613 		iAvkonAppUi->TouchPane()->AllowInputMethodActivation(aValue);
       
   614 	}
       
   615 
       
   616 void CAknFepUIAvkonImpl::TouchPaneRefreshL()
       
   617 	{
       
   618 	if(iAvkonAppUi->TouchPane())
       
   619 		iAvkonAppUi->TouchPane()->RefreshL();
       
   620 	}
       
   621 
       
   622 void CAknFepUIAvkonImpl::TouchPaneSetInputMethodIconActivated(TBool aActivated)
       
   623 	{
       
   624 	if(iAvkonAppUi->TouchPane())
       
   625 		iAvkonAppUi->TouchPane()->SetInputMethodIconActivated(aActivated);
       
   626 	}
       
   627 
       
   628 TInt CAknFepUIAvkonImpl::TextQueryDialogL(TDes& aDataText, CAknEdwinState& aEditorState, TInt aEditorFlag, TInt aResId)
       
   629 	{
       
   630 	TInt result;
       
   631     iTextQueryDialog = new (ELeave) CAknFepTextQueryDialog(aDataText, aEditorState, CAknFepTextQueryDialog::ENoTone, aEditorFlag);
       
   632     iTextQueryDialog->PrepareLC(aResId);
       
   633 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   634     //last char space has to be reserved for null terminator
       
   635     iTextQueryDialog->SetMaxLength( KMaxUDBLength - 1 );
       
   636 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   637     result = iTextQueryDialog->RunLD();
       
   638     iTextQueryDialog = NULL;
       
   639     return result;
       
   640 	}
       
   641 
       
   642 CPlainText* CAknFepUIAvkonImpl::PlainText(CAknEdwinState* aEditorState)
       
   643 	{
       
   644     CEikEdwin* editor = NULL;
       
   645     if (aEditorState)
       
   646         {
       
   647         CAknEdwinFormAccessor* formAccessor = aEditorState->FormAccessor();
       
   648         if (formAccessor)
       
   649             {
       
   650             editor = (CEikEdwin*)formAccessor->FormClientControl();
       
   651             if (editor)
       
   652                 {
       
   653                 return editor->Text();                
       
   654                 }
       
   655             }
       
   656         }
       
   657     return NULL;
       
   658 	}
       
   659 
       
   660 void CAknFepUIAvkonImpl::UpdateEditorContext(MAknEditingStateIndicator& aIndicator, MAknFepManagerInterface& aManager)
       
   661 	{
       
   662     CAknIndicatorContainer* indicatorContainer = aIndicator.IndicatorContainer();
       
   663 
       
   664     if(indicatorContainer)
       
   665         {
       
   666         TInt indicatorContext = indicatorContainer->IndicatorContext();
       
   667         aManager.SetEditorContext(indicatorContext);
       
   668         }
       
   669 	}
       
   670 
       
   671 CAknFepIndicator* CAknFepUIAvkonImpl::NewIndicatorL()
       
   672 	{
       
   673     return CAknFepIndicatorAvkon::NewL();
       
   674 	}
       
   675 
       
   676 TBool CAknFepUIAvkonImpl::IsDisplayDataQuery(TBool aIsFepAwareTextEditor)
       
   677 	{
       
   678     CEikAppUi* eikAppUi = (CEikAppUi *)CCoeEnv::Static()->AppUi();
       
   679     
       
   680     if( eikAppUi->IsDisplayingDialog() && eikAppUi->TopFocusedControl() )
       
   681         {
       
   682         CEikDialog* dlg = eikAppUi->TopFocusedControl()->MopGetObject( dlg );
       
   683         
       
   684         if ( dlg )
       
   685             {
       
   686             TInt flag = dlg->DialogFlags();
       
   687 
       
   688             if(!(flag & EEikDialogFlagFillScreen) &&
       
   689                !(flag & EEikDialogFlagFillAppClientRect) )
       
   690                 {
       
   691                 MObjectProvider* objectProvider = NULL;
       
   692 				MCoeFepAwareTextEditor* editor;
       
   693 			    MCoeFepAwareTextEditor_Extension1* ext1;
       
   694     			CAknEdwinState* state;
       
   695                 CCoeEnv* coeEnv = CCoeEnv::Static();
       
   696                 TCoeInputCapabilities inputCapabilities = 
       
   697                     static_cast<const CCoeAppUi*>(coeEnv->AppUi())->InputCapabilities();
       
   698 
       
   699     			if ( aIsFepAwareTextEditor &&
       
   700          			( editor = inputCapabilities.FepAwareTextEditor() ) != NULL &&       
       
   701          		    ( ext1 = editor->Extension1() ) != NULL &&
       
   702 				    ( state = (CAknEdwinState*)ext1->State( KNullUid ) ) != NULL )
       
   703         			{
       
   704         			objectProvider = state->ObjectProvider();
       
   705         			}
       
   706 
       
   707     			// If not found, try to get object provider from input capabilities.
       
   708     			// It is set there with CEikMfne-derived editors.
       
   709 
       
   710     			if ( !objectProvider )
       
   711         			{
       
   712         			objectProvider = inputCapabilities.ObjectProvider();
       
   713         			}
       
   714 
       
   715 			    if ( objectProvider )
       
   716         			{
       
   717         			CAknQueryControl* ctrl = objectProvider->MopGetObject( ctrl );
       
   718         		
       
   719         			if ( ctrl )
       
   720         				{
       
   721         				return ETrue;
       
   722         				}
       
   723         			}
       
   724         		}
       
   725             }
       
   726         }
       
   727          
       
   728     return EFalse;
       
   729 	}
       
   730 
       
   731 CAknFepUiInterfaceMenuBar* CAknFepUIAvkonImpl::ObjectProviderMenuBar(MObjectProvider* aObjectProvider)
       
   732 	{
       
   733 	if (!aObjectProvider)
       
   734 		return NULL;
       
   735 	CEikMenuBar* menu;
       
   736 	aObjectProvider->MopGetObject(menu);
       
   737 	if (menu)
       
   738 		{
       
   739 		iObjectProviderMenuBar.iMenuBar = menu;
       
   740 		return &iObjectProviderMenuBar;
       
   741 		}
       
   742 	else
       
   743 		return NULL;
       
   744 	}
       
   745 
       
   746 MAknFepUICtrlContainerChinese* CAknFepUIAvkonImpl::NewAknFepUICtrlContainerChineseL()
       
   747 	{
       
   748     if (FeatureManager::FeatureSupported(KFeatureIdChinese))
       
   749         {
       
   750         return CAknFepUICtrlContainerChinese::NewL();
       
   751         }
       
   752 
       
   753     User::Leave(KErrNotSupported);
       
   754 	return NULL;
       
   755 	}
       
   756 
       
   757 MAknFepUICtrlContainerJapanese* CAknFepUIAvkonImpl::NewAknFepUICtrlContainerJapaneseL(CAknFepUIManagerJapanese* aUiMng)
       
   758 	{
       
   759     if (FeatureManager::FeatureSupported(KFeatureIdJapanese))
       
   760         {
       
   761         return CAknFepUICtrlContainerJapanese::NewL(aUiMng);
       
   762         }
       
   763     return NULL;
       
   764 	}
       
   765 
       
   766 void CAknFepUIAvkonImpl::JapaneseKutenQueryDialogL(TInt aResId, TInt& aCharCode, TInt aTone)
       
   767 	{
       
   768     if (FeatureManager::FeatureSupported(KFeatureIdJapanese))
       
   769         {
       
   770         CAknFepUICtrlJapaneseKutenQueryDialog* query = CAknFepUICtrlJapaneseKutenQueryDialog::NewL(aCharCode, (CAknQueryDialog::TTone)aTone);
       
   771         iDialog = query;
       
   772         query->ExecuteLD(aResId);
       
   773         iDialog = NULL;
       
   774         }
       
   775 	}
       
   776 
       
   777 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   778 // Predictive QWERTY (XT9) changes ---->
       
   779 MAknFepCandidatePopup* CAknFepUIAvkonImpl::NewCandidatePopupL(MAknFepCandidatePopupCallback& aOwner)
       
   780 	{
       
   781 	MAknFepCandidatePopup* candidatePopup = CAknFepAvkonCandidatePopup::NewL(aOwner);
       
   782 	return candidatePopup;
       
   783 	}
       
   784 
       
   785 MAknFepUiWordPopupContent* CAknFepUIAvkonImpl::CreateWordPopupContentL()
       
   786 	{
       
   787 	return CAknFepExactWordPopupContent::NewL();	
       
   788 	}
       
   789 	
       
   790 void CAknFepUIAvkonImpl::LaunchPredictiveSettingDialogL(TInt aDialogResId, 
       
   791 														TInt aMenuResId, 
       
   792 														TInt aConfirmationQueryResId,
       
   793 														TInt aTitlePaneResId)
       
   794 	{
       
   795 	iPredictiveSettingDialog = CAknFepPredictiveSettingDialog::NewL(aMenuResId, aConfirmationQueryResId, aTitlePaneResId);
       
   796 	iPredictiveSettingDialog->ExecuteLD(aDialogResId);
       
   797 	iPredictiveSettingDialog = NULL;
       
   798 	}
       
   799 
       
   800 #ifdef __USER_DICTIONARY_EDITING__
       
   801 void CAknFepUIAvkonImpl::LaunchUserDictEditDialogL()
       
   802     {
       
   803     CAknFepUserDictionaryEditDialog::RunDlgLD();
       
   804     }
       
   805 #endif //__USER_DICTIONARY_EDITING__
       
   806 
       
   807 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
   808 void CAknFepUIAvkonImpl::LaunchWritingLanguageSettingDialogL(TInt aDialogResId, TInt aMenuResId, TInt aTitlePaneResId)
       
   809     {    
       
   810     CCoeEnv* coeEnv = CCoeEnv::Static();
       
   811 	CAknAppUi* appUi = static_cast<CAknAppUi*>(coeEnv->AppUi());
       
   812     CAknTitlePane* titlePane = static_cast<CAknTitlePane*>( appUi->StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   813     
       
   814     const TDesC* appTitle = titlePane->Text();
       
   815 	HBufC* oldTitle = appTitle->AllocL();
       
   816 	CleanupStack::PushL(oldTitle);
       
   817 	HBufC* title = StringLoader::LoadLC( aTitlePaneResId,coeEnv);
       
   818     titlePane->SetTextL( *title );
       
   819     CleanupStack::PopAndDestroy(title);
       
   820     
       
   821     CAknFepDualLanguageSettingDialog* dlg = CAknFepDualLanguageSettingDialog::NewL(aMenuResId);            
       
   822     iDialog = dlg;
       
   823     dlg->ExecuteLD(aDialogResId);
       
   824     iDialog = NULL;
       
   825     
       
   826     titlePane->SetTextL( *oldTitle );
       
   827     CleanupStack::PopAndDestroy(oldTitle);
       
   828     }
       
   829 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
   830 // Predictive QWERTY (XT9) changes <----	
       
   831 
       
   832 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
   833 TInt CAknFepUIAvkonImpl::HandleKeyboardLayoutChangeNotification(TAny* aObj)
       
   834     {
       
   835     if (aObj)
       
   836         {
       
   837         static_cast<CAknFepUIAvkonImpl*>(aObj)->HandleKeyboardLayoutChange();
       
   838         return KErrNone;
       
   839         }
       
   840     else
       
   841         {
       
   842         return KErrArgument;
       
   843         }
       
   844     }
       
   845 
       
   846 void CAknFepUIAvkonImpl::HandleKeyboardLayoutChange()
       
   847     {
       
   848     if(iPredictiveSettingDialog)
       
   849         {
       
   850         iPredictiveSettingDialog->HandleResourceChange(KEikDynamicLayoutVariantSwitch);
       
   851         }
       
   852     }
       
   853 
       
   854 CAknFepUIAvkonImpl::CSubscriber::CSubscriber(TCallBack aCallBack, RProperty& aProperty)
       
   855     :
       
   856     CActive(EPriorityNormal), iCallBack(aCallBack), iProperty(aProperty)
       
   857     {
       
   858     CActiveScheduler::Add(this);
       
   859     }
       
   860 
       
   861 CAknFepUIAvkonImpl::CSubscriber::~CSubscriber()
       
   862     {
       
   863     Cancel();
       
   864     }
       
   865 
       
   866 void CAknFepUIAvkonImpl::CSubscriber::SubscribeL()
       
   867     {
       
   868     if (!IsActive())
       
   869         {
       
   870         iProperty.Subscribe(iStatus);
       
   871         SetActive();
       
   872         }
       
   873     }
       
   874 
       
   875 void CAknFepUIAvkonImpl::CSubscriber::StopSubscribe()
       
   876     {
       
   877     Cancel();
       
   878     }
       
   879 
       
   880 void CAknFepUIAvkonImpl::CSubscriber::RunL()
       
   881     {
       
   882     if (iStatus.Int() == KErrNone)
       
   883         {
       
   884         iCallBack.CallBack();
       
   885         SubscribeL();
       
   886         }
       
   887     }
       
   888 
       
   889 void CAknFepUIAvkonImpl::CSubscriber::DoCancel()
       
   890     {
       
   891     iProperty.Cancel();
       
   892     }
       
   893     
       
   894 #endif //__ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
   895 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   896