uifw/AvKon/src/aknsfld.cpp
changeset 0 2f259fa3e83a
child 14 3320e4e6e8bb
child 23 3d340a0166ff
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002 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 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <aknenv.h>
       
    20 #include <eikdef.h>
       
    21 #include <aknsfld.h>
       
    22 #include <akninfrm.h>   
       
    23 #include <avkon.mbg>
       
    24 
       
    25 #include <aknappui.h>
       
    26 #include <eikon.rsg>        
       
    27 #include <eikenv.h>
       
    28 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    29 #include <uikon/eikenvinterface.h>
       
    30 #endif
       
    31 #include <txtglobl.h>
       
    32 #include <gulfont.h>
       
    33 #include <txtfrmat.h>
       
    34 #include <eikedwin.h>
       
    35 #include <uikon.hrh>
       
    36 #include <aknconsts.h>
       
    37 #include <aknEditStateIndicator.h>
       
    38 #include <featmgr.h>                
       
    39 
       
    40 #include <AknsListBoxBackgroundControlContext.h>
       
    41 #include <AknsFrameBackgroundControlContext.h>
       
    42 #include <AknsUtils.h>
       
    43 #include "AknAdaptiveSearch.h"
       
    44 #include <StringLoader.h>
       
    45 
       
    46 #include <centralrepository.h>      // CenRep for AS
       
    47 #include <AvkonInternalCRKeys.h>    // CenRep for AS
       
    48 
       
    49 #include <AknTasHook.h>
       
    50 #include <touchfeedback.h>
       
    51 
       
    52 #include "aknSfldIndicatorFactory.h"
       
    53 #include "aknsfldIndicator.h"
       
    54 
       
    55 #include <eikbtgpc.h>
       
    56 #include <eiklbx.h>
       
    57 #include <skinlayout.cdl.h>
       
    58 
       
    59 #include "akntrace.h"  // trace
       
    60 
       
    61 using namespace SkinLayout;
       
    62 
       
    63 // CONSTANTS
       
    64 const TInt EUseSkinContext = 0x01;
       
    65 const TInt EParentAbsolute = 0x02;
       
    66 const TInt ETileIIDNone    = 0x04;
       
    67 NONSHARABLE_CLASS(CHwKbSubscriber) : public CActive
       
    68     {
       
    69 public:
       
    70     CHwKbSubscriber( TAny* aPtr, RProperty& aProperty );
       
    71     ~CHwKbSubscriber();
       
    72     
       
    73 public: // New functions
       
    74     void SubscribeL();
       
    75     void StopSubscribe();
       
    76     static TInt HandlePropertyChaned( TAny* aPtr );
       
    77 private: // from CActive
       
    78     void RunL();
       
    79     void DoCancel();
       
    80     
       
    81 private:
       
    82     TCallBack  iCallBack;
       
    83     RProperty&  iProperty;
       
    84     };
       
    85 
       
    86 CHwKbSubscriber::CHwKbSubscriber( TAny* aPtr, RProperty& aProperty )
       
    87     :CActive(EPriorityNormal), iCallBack( TCallBack( HandlePropertyChaned, aPtr)), 
       
    88      iProperty(aProperty)
       
    89     {
       
    90     CActiveScheduler::Add(this);
       
    91     }
       
    92 
       
    93 CHwKbSubscriber::~CHwKbSubscriber()
       
    94     {
       
    95     Cancel();
       
    96     }
       
    97 
       
    98 void CHwKbSubscriber::SubscribeL()
       
    99     {
       
   100     if (!IsActive())
       
   101         {
       
   102         iProperty.Subscribe(iStatus);
       
   103         SetActive();
       
   104         }
       
   105     }
       
   106 
       
   107 void CHwKbSubscriber::StopSubscribe()
       
   108     {
       
   109     Cancel();
       
   110     }
       
   111 
       
   112 TInt CHwKbSubscriber::HandlePropertyChaned( TAny* aPtr )
       
   113     {
       
   114     if ( aPtr )
       
   115         {
       
   116         TRAPD(err, 
       
   117               static_cast<CAknSearchField*>(aPtr)->HandleHWKeyboardModeChangeL());
       
   118         return err;
       
   119         }
       
   120     else
       
   121         {
       
   122         return KErrArgument;
       
   123         }
       
   124     }
       
   125 
       
   126 void CHwKbSubscriber::RunL()
       
   127     {
       
   128     if (iStatus.Int() == KErrNone)
       
   129         {
       
   130         iCallBack.CallBack();
       
   131         SubscribeL();
       
   132         }
       
   133     }
       
   134 
       
   135 void CHwKbSubscriber::DoCancel()
       
   136     {
       
   137     iProperty.Cancel();
       
   138     }
       
   139 
       
   140 
       
   141 // ============================ MEMBER FUNCTIONS ===============================
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CAknSearchField::CAknSearchField
       
   145 // C++ default constructor.
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 CAknSearchField::CAknSearchField()
       
   149     {
       
   150     }
       
   151     
       
   152 // -----------------------------------------------------------------------------
       
   153 // CAknSearchField::~CAknSearchField
       
   154 // Destructor.
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 EXPORT_C CAknSearchField::~CAknSearchField()
       
   158     {
       
   159     AKNTASHOOK_REMOVE();
       
   160     if ( iCBAObserverUpdated && iCba )
       
   161         {
       
   162         iCba->RemoveCommandObserver( 2 );
       
   163         if ( iBackedAppUi && !iBackedAppUi->IsAppClosing() )
       
   164             {
       
   165             iCba->RemoveCommandFromStack( 2, EAknSoftkeyCancel );
       
   166             }
       
   167         }
       
   168     delete iEditor;
       
   169     delete iAdaptiveSearch;    
       
   170     delete iInputFrame;    
       
   171     delete iSkinContext;
       
   172     delete iInputContext; 
       
   173     delete iIndicator;
       
   174     delete iHwKbSub;
       
   175     iHwKeyboardPro.Close();
       
   176     }  
       
   177     
       
   178 // -----------------------------------------------------------------------------
       
   179 // CAknSearchField::NewL
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 EXPORT_C CAknSearchField* CAknSearchField::NewL( const CCoeControl& aParent, 
       
   183                                                  TSearchFieldStyle aFieldStyle, 
       
   184                                                  CGulIcon* aIcon, 
       
   185                                                  TInt aTextLimit )
       
   186     { 
       
   187     _AKNTRACE_FUNC_ENTER;
       
   188     CAknSearchField* self=new(ELeave) CAknSearchField();
       
   189     CleanupStack::PushL( self );
       
   190     _AKNTRACE( "[%s][%s] aSearchFieldStyle: %d", 
       
   191                             "CAknSearchField", __FUNCTION__, aFieldStyle );
       
   192     self->ConstructL( aParent, aFieldStyle, aIcon, aTextLimit );
       
   193     CleanupStack::Pop(); 
       
   194     AKNTASHOOK_ADDL( self, "CAknSearchField" );
       
   195     _AKNTRACE_FUNC_EXIT;
       
   196     return self;
       
   197     }   
       
   198         
       
   199 NONSHARABLE_CLASS( CSearchFieldEditor ) : public CEikEdwin
       
   200     {
       
   201 public:
       
   202     IMPORT_C TCoeInputCapabilities InputCapabilities() const;
       
   203     };
       
   204 EXPORT_C TCoeInputCapabilities CSearchFieldEditor::InputCapabilities() const
       
   205     {
       
   206     TCoeInputCapabilities c( TCoeInputCapabilities::EAllText 
       
   207                 | TCoeInputCapabilities::EWesternAlphabetic );
       
   208     c.MergeWith( CEikEdwin::InputCapabilities() );    
       
   209     return c;
       
   210     }
       
   211     
       
   212 // -----------------------------------------------------------------------------
       
   213 // CAknSearchField::ConstructL
       
   214 // -----------------------------------------------------------------------------
       
   215 //
       
   216 void CAknSearchField::ConstructL( const CCoeControl& aParent,
       
   217                                   TSearchFieldStyle aFieldStyle,
       
   218                                   CGulIcon* aIcon, TInt aTextLimit )
       
   219     {
       
   220     SetMopParent( const_cast<CCoeControl*>(&aParent) );    
       
   221     iBackedAppUi = iAvkonAppUi;
       
   222     TFileName path(KAvkonBitmapFile);
       
   223     TInt bitmapId;
       
   224     TInt bitmapMaskId;    
       
   225     iIsPopup = EFalse; 
       
   226     TUint32 flags = NULL;
       
   227 
       
   228     iEditor = new ( ELeave ) CSearchFieldEditor;
       
   229     TBool isShowIndicator = EFalse;
       
   230     TBool ASEnabled = EFalse;
       
   231     if( AknLayoutUtils::PenEnabled())
       
   232         {
       
   233         ASEnabled = GetASStatusAndSubKbLayoutL( isShowIndicator );
       
   234         }
       
   235     else
       
   236         {
       
   237         isShowIndicator = ETrue;
       
   238         }         
       
   239 
       
   240     // Adaptive search is not allowed in popups anymore
       
   241     if ( aFieldStyle == EPopupAdaptiveSearch )
       
   242         {
       
   243         aFieldStyle = EPopup;
       
   244         }
       
   245     else if ( aFieldStyle == EPopupAdaptiveSearchWindow )
       
   246         {
       
   247         aFieldStyle = EPopupWindow;
       
   248         }
       
   249 
       
   250     switch ( aFieldStyle )
       
   251         {
       
   252         case EFixed:
       
   253             bitmapId = EMbmAvkonQgn_indi_find_glass;
       
   254             bitmapMaskId = EMbmAvkonQgn_indi_find_glass_mask;
       
   255             CreateWindowL( &aParent ); // This is now non-window owning control
       
   256             break;
       
   257         case ESearchWithoutLine:
       
   258             flags |= CAknInputFrame::EFixedFindWithoutLine;
       
   259         // FALL THROUGH/ no break here.
       
   260         case ESearch:
       
   261             bitmapId = EMbmAvkonQgn_indi_find_glass;
       
   262             bitmapMaskId = EMbmAvkonQgn_indi_find_glass_mask;
       
   263             SetContainerWindowL( aParent ); // This is now non-window owning control
       
   264             break;
       
   265         case EPopup:
       
   266             bitmapId = EMbmAvkonQgn_indi_find_glass;
       
   267             bitmapMaskId = EMbmAvkonQgn_indi_find_glass_mask;
       
   268             flags |= CAknInputFrame::EPopupLayout;
       
   269             CreateWindowL(); 
       
   270             iIsPopup = ETrue;
       
   271             if ( CAknEnv::Static()->TransparencyEnabled() )
       
   272                 {
       
   273                 Window().SetRequiredDisplayMode( EColor16MA );
       
   274                 TInt err = Window().SetTransparencyAlphaChannel();
       
   275                 if ( err == KErrNone )                    
       
   276                     Window().SetBackgroundColor(~0);                    
       
   277                 }            
       
   278             break;
       
   279         case EPinb:
       
   280             bitmapId = EMbmAvkonQgn_indi_find_glass_pinb;
       
   281             bitmapMaskId = EMbmAvkonQgn_indi_find_glass_pinb_mask;
       
   282             flags |= CAknInputFrame::EPinbLayout;
       
   283             SetContainerWindowL( aParent ); // This is now non-window owning control
       
   284             break;
       
   285         case EClockApp:
       
   286             bitmapId = EMbmAvkonQgn_indi_find_glass;
       
   287             bitmapMaskId = EMbmAvkonQgn_indi_find_glass_mask;
       
   288             flags |= CAknInputFrame::EClockAppLayout;
       
   289             SetContainerWindowL( aParent ); // This is now non-window owning control
       
   290             break;
       
   291         case EPopupWindow:
       
   292             bitmapId = EMbmAvkonQgn_indi_find_glass;
       
   293             bitmapMaskId = EMbmAvkonQgn_indi_find_glass_mask;
       
   294 
       
   295             if ( AknLayoutUtils::PenEnabled() )
       
   296                 {
       
   297                 flags |= CAknInputFrame::EPopupWindowEmbeddedSoftkeys;
       
   298                 }
       
   299 
       
   300             flags |= CAknInputFrame::EPopupWindowLayout;
       
   301             flags |= CAknInputFrame::EFixedFindWithoutLine;
       
   302             SetContainerWindowL( aParent ); // This is now non-window owning control
       
   303             break;
       
   304         case EAdaptiveSearch:
       
   305             bitmapId = EMbmAvkonQgn_indi_find_glass;
       
   306             bitmapMaskId = EMbmAvkonQgn_indi_find_glass_mask;
       
   307             SetContainerWindowL( aParent );  
       
   308             iColumnFlag = 0xFFFFFFFF;     
       
   309             if( AknLayoutUtils::PenEnabled() )
       
   310                 {
       
   311                 iAdaptiveSearch = CAknAdaptiveSearch::NewL( aTextLimit, aFieldStyle );       
       
   312                 iAdaptiveSearch->SetSearchField( this );         
       
   313                 if ( ASEnabled )
       
   314                     {
       
   315                     iEditor->AddFlagToUserFlags( CEikEdwin::EAvkonDisableVKB );
       
   316                     }
       
   317                 TInt edwinFlag( iEditor->AknEdwinFlags() );
       
   318                 iEditor->SetAknEditorFlags( edwinFlag | 
       
   319                         EAknEditorFlagAdaptiveSearch );
       
   320                 }                    
       
   321             break; 
       
   322         case EAdaptive:
       
   323             bitmapId = EMbmAvkonQgn_indi_find_glass;
       
   324             bitmapMaskId = EMbmAvkonQgn_indi_find_glass_mask;
       
   325             CreateWindowL( &aParent ); 
       
   326             iColumnFlag = 0xFFFFFFFF; 
       
   327             if( AknLayoutUtils::PenEnabled() )
       
   328                 {
       
   329                 iAdaptiveSearch = CAknAdaptiveSearch::NewL( aTextLimit, aFieldStyle );       
       
   330                 iAdaptiveSearch->SetSearchField( this ); 
       
   331                 if ( ASEnabled )
       
   332                     {
       
   333                     iEditor->AddFlagToUserFlags( CEikEdwin::EAvkonDisableVKB );
       
   334                     }
       
   335                 TInt edwinFlag( iEditor->AknEdwinFlags() );
       
   336                 iEditor->SetAknEditorFlags( edwinFlag | 
       
   337                         EAknEditorFlagAdaptiveSearch );
       
   338                 }                      
       
   339             break;
       
   340         case EPopupAdaptiveSearch:
       
   341             bitmapId = EMbmAvkonQgn_indi_find_glass;
       
   342             bitmapMaskId = EMbmAvkonQgn_indi_find_glass_mask;
       
   343             flags |= CAknInputFrame::EPopupLayout;
       
   344             CreateWindowL(); 
       
   345             iColumnFlag = 0xFFFFFFFF; 
       
   346             iIsPopup = ETrue;
       
   347             if( AknLayoutUtils::PenEnabled() )
       
   348                 {
       
   349                 iAdaptiveSearch = CAknAdaptiveSearch::NewL( aTextLimit, aFieldStyle );       
       
   350                 iAdaptiveSearch->SetSearchField( this );  
       
   351                 if ( ASEnabled )
       
   352                     {
       
   353                     iEditor->AddFlagToUserFlags( CEikEdwin::EAvkonDisableVKB );
       
   354                     }
       
   355                 TInt edwinFlag( iEditor->AknEdwinFlags() );
       
   356                 iEditor->SetAknEditorFlags( edwinFlag | 
       
   357                         EAknEditorFlagAdaptiveSearch );
       
   358                 }          
       
   359             if ( CAknEnv::Static()->TransparencyEnabled() )
       
   360                 {
       
   361                 Window().SetRequiredDisplayMode( EColor16MA );
       
   362                 TInt err = Window().SetTransparencyAlphaChannel();
       
   363                 if ( err == KErrNone )                    
       
   364                     Window().SetBackgroundColor(~0);                    
       
   365                 }                    
       
   366             break;
       
   367         case EPopupAdaptiveSearchWindow:
       
   368             bitmapId = EMbmAvkonQgn_indi_find_glass;
       
   369             bitmapMaskId = EMbmAvkonQgn_indi_find_glass_mask;
       
   370 
       
   371             if ( AknLayoutUtils::PenEnabled() )
       
   372                 {
       
   373                 flags |= CAknInputFrame::EPopupWindowEmbeddedSoftkeys;
       
   374                 }
       
   375 
       
   376             flags |= CAknInputFrame::EPopupWindowLayout;
       
   377             flags |= CAknInputFrame::EFixedFindWithoutLine;
       
   378             SetContainerWindowL( aParent ); 
       
   379             iColumnFlag = 0xFFFFFFFF;   
       
   380             if( AknLayoutUtils::PenEnabled() )
       
   381                 {
       
   382                 iAdaptiveSearch = CAknAdaptiveSearch::NewL( aTextLimit, aFieldStyle );       
       
   383                 iAdaptiveSearch->SetSearchField( this );  
       
   384                 if ( ASEnabled )
       
   385                     {
       
   386                     iEditor->AddFlagToUserFlags( CEikEdwin::EAvkonDisableVKB );
       
   387                     }
       
   388                 TInt edwinFlag( iEditor->AknEdwinFlags() );
       
   389                 iEditor->SetAknEditorFlags( edwinFlag | 
       
   390                         EAknEditorFlagAdaptiveSearch );
       
   391                 }             
       
   392             break;
       
   393 /*     case EInput:
       
   394             bitmapId = EMbmAvkonInput;
       
   395             bitmapMaskId = EMbmAvkonInputm;
       
   396             SetFocus( ETrue );
       
   397             break;
       
   398         case EUrl:
       
   399             bitmapId = EMbmAvkonUrlm;
       
   400             bitmapMaskId = EMbmAvkonUrl;
       
   401             break;
       
   402 */
       
   403         default:
       
   404             bitmapId = 0;
       
   405             bitmapMaskId = 0;
       
   406             path = KNullDesC;
       
   407             SetContainerWindowL( aParent ); 
       
   408             break;
       
   409         }
       
   410     if ( !aIcon )
       
   411         {
       
   412         iInputFrame = CAknInputFrame::NewL( iEditor, EFalse, path, bitmapId, bitmapMaskId, 
       
   413                                             isShowIndicator ? 
       
   414                                             flags | CAknInputFrame::EShowIndicators :
       
   415                                             flags );
       
   416         }
       
   417     else
       
   418         {
       
   419         iInputFrame = CAknInputFrame::NewL( iEditor, EFalse, NULL, 
       
   420                                             flags | CAknInputFrame::EShowIndicators);
       
   421         }
       
   422     TAknLayoutId layout;
       
   423     iAvkonEnv->GetCurrentLayoutId( layout );
       
   424     if (layout == EAknLayoutIdAPAC && !AknLayoutUtils::PenEnabled()
       
   425         || FeatureManager::FeatureSupported( KFeatureIdChinese ) )
       
   426         {
       
   427         if ( aFieldStyle != EClockApp )
       
   428             {
       
   429             iIndicator = AknSearchFieldIndicatorFactory::CreateIndicatorL();
       
   430             if ( iIndicator ) // iIndicator is NULL if KFeatureIdAvkonApac is not supported.
       
   431                 {
       
   432                 iIndicator->SetContainerWindowL( *this );
       
   433                 iIndicator->SetSearchFieldStyle( aFieldStyle );                
       
   434                 if ( !isShowIndicator )
       
   435                     {
       
   436                     iIndicator->MakeVisible( EFalse );
       
   437                     }
       
   438                 }
       
   439             }
       
   440         }
       
   441     iInputFrame->SetContainerWindowL( *this );
       
   442     iEditor->SetContainerWindowL( *this );
       
   443     AknEditUtils::ConstructEditingL( iEditor,
       
   444                                      aTextLimit,
       
   445                                      1,
       
   446                                      EAknEditorCharactersLowerCase,
       
   447                                      EAknEditorAlignLeft,
       
   448                                      EFalse,
       
   449                                      ETrue,
       
   450                                      EFalse );
       
   451     iEditor->SetObserver( this );
       
   452     iEditor->SetBorder( TGulBorder::ENone );
       
   453     iEditor->SetAknEditorInputMode( EAknEditorTextInputMode );
       
   454     iEditor->SetAknEditorAllowedInputModes( EAknEditorTextInputMode |
       
   455                                             EAknEditorNumericInputMode ); 
       
   456 
       
   457     if ( FeatureManager::FeatureSupported(KFeatureIdJapanese) )
       
   458         {
       
   459         iEditor->SetAknEditorPermittedCaseModes(EAknEditorCharactersLowerCase);
       
   460         }
       
   461 
       
   462     TInt editorFlags = iEditor->AknEdwinFlags() |
       
   463                        EAknEditorFlagNoT9 | 
       
   464                        EAknEditorFlagNoLRNavigation |
       
   465                        EAknEditorFlagForceTransparentFepModes |
       
   466                        EAknEditorFlagNoEditIndicators |
       
   467                        EAknEditorFlagFindPane;
       
   468     iEditor->SetAknEditorFlags( editorFlags );
       
   469     iEditor->CreateTextViewL();      
       
   470     if ( aFieldStyle == EPopup || 
       
   471          aFieldStyle == EFixed ||
       
   472          aFieldStyle == EPopupAdaptiveSearch || 
       
   473          aFieldStyle == EAdaptive )
       
   474         {
       
   475         iFlags |= EParentAbsolute;
       
   476         }
       
   477 
       
   478     if( aFieldStyle == ESearchWithoutLine )        
       
   479         iFlags |= ETileIIDNone;          
       
   480         
       
   481     SetupSkinContextL();    
       
   482     if ( aIcon )        
       
   483         iInputFrame->SetIcon( aIcon ); // May not leave after this    
       
   484     if ( aFieldStyle == EPopup || aFieldStyle == EPopupAdaptiveSearch )
       
   485         {
       
   486         iEditor->SetFocus( EFalse );
       
   487         }
       
   488     else 
       
   489         {      
       
   490         iEditor->SetFocus( ETrue );
       
   491         }  
       
   492     if ( AknsUtils::AvkonSkinEnabled() )        
       
   493         iFlags |= EUseSkinContext;    
       
   494     iStyle = aFieldStyle;      
       
   495     ActivateL();
       
   496     }
       
   497     
       
   498 // -----------------------------------------------------------------------------
       
   499 // CAknSearchField::SetLinePos
       
   500 // -----------------------------------------------------------------------------
       
   501 //
       
   502 EXPORT_C void CAknSearchField::SetLinePos( TInt aLinePos )
       
   503     {
       
   504     iLinePos = aLinePos;
       
   505     TAknsItemID tileIID = KAknsIIDQsnBgColumnA;
       
   506     if ( iLinePos == 1 || iLinePos == 0 )
       
   507         {
       
   508         tileIID = KAknsIIDNone;
       
   509         }
       
   510     if ( iLinePos == 3 )
       
   511         {
       
   512         tileIID = KAknsIIDQsnBgColumnAB;
       
   513         }
       
   514     iSkinContext->SetTiledBitmap( tileIID );
       
   515     TAknWindowLineLayout tile = Column_background_and_list_slice_skin_placing_Line_2();
       
   516     if ( iLinePos == 1 )
       
   517         {
       
   518         tile = Column_background_and_list_slice_skin_placing_Line_1();
       
   519         }    
       
   520     if ( iLinePos == 3 )
       
   521         {
       
   522         tile = Column_background_and_list_slice_skin_placing_Line_3();
       
   523         }
       
   524     TRect main_pane;
       
   525     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, main_pane );     
       
   526     TRect clientRect( TRect(TPoint(0,0), main_pane.Size() ) );
       
   527     TAknLayoutRect tileRect;
       
   528     tileRect.LayoutRect( clientRect, tile );  
       
   529     iSkinContext->SetTiledRect( tileRect.Rect() );
       
   530     }
       
   531     
       
   532 // -----------------------------------------------------------------------------
       
   533 // CAknSearchField::OfferKeyEventL
       
   534 // -----------------------------------------------------------------------------
       
   535 //
       
   536 EXPORT_C TKeyResponse CAknSearchField::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   537                                              TEventCode aType )
       
   538     {
       
   539     if ( aKeyEvent.iCode == EKeyRightArrow )
       
   540         {
       
   541         if ( iEditor->CursorPos() == iEditor->TextLength() )
       
   542             return EKeyWasNotConsumed;
       
   543         }
       
   544     if ( aKeyEvent.iCode == EKeyLeftArrow )
       
   545         {
       
   546         if ( iEditor->CursorPos() == 0 )
       
   547             return EKeyWasNotConsumed;
       
   548         }
       
   549     if ( aKeyEvent.iCode == EKeyUpArrow )
       
   550         {
       
   551         // this is because searchfield should not eat up/down arrows.
       
   552         // otherwise this breaks markable lists in phonebook.
       
   553         // (obviously edwins have been changed so they eat the key.)
       
   554         return EKeyWasNotConsumed;
       
   555         }
       
   556     if ( aKeyEvent.iCode == EKeyDownArrow )
       
   557         {
       
   558         return EKeyWasNotConsumed;
       
   559         }
       
   560     // listbox needs the enter key - it is not acceptable for 
       
   561     // searchfield to eat it.
       
   562     if ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iCode == EKeyOK )
       
   563         {
       
   564         return EKeyWasNotConsumed;
       
   565         }   
       
   566      if( aKeyEvent.iCode == EKeyNo ) 
       
   567         {        
       
   568         if ( iAdaptiveSearch )
       
   569             {
       
   570             iAdaptiveSearch->HideAdaptiveSearchGridL();              
       
   571             }
       
   572         if ( iIsPopup ) 
       
   573             {
       
   574             ResetL();       
       
   575             TBool needRefresh;
       
   576             AknFind::HandleFindPaneVisibility( this, ETrue, EFalse, needRefresh );
       
   577             if ( needRefresh && iListBox && iParent )
       
   578                 {
       
   579                 AknFind::HandlePopupFindSizeChanged( iParent, iListBox, this );
       
   580                 CAknFilteredTextListBoxModel* model = static_cast<CAknFilteredTextListBoxModel*> ( iListBox->Model() );                
       
   581                 if ( model->Filter() )
       
   582                     {
       
   583                     model->Filter()->ResetFilteringL();
       
   584                     }             
       
   585                 iListBox->DrawNow();
       
   586                 }    
       
   587             }        
       
   588         }                   
       
   589     TKeyResponse response = iEditor->OfferKeyEventL( aKeyEvent, aType );
       
   590     return response;
       
   591     }    
       
   592 
       
   593 // -----------------------------------------------------------------------------
       
   594 // CAknSearchField::HandlePointerEventL
       
   595 // -----------------------------------------------------------------------------
       
   596 //
       
   597 void CAknSearchField::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   598     {
       
   599     if(  AknLayoutUtils::PenEnabled() )
       
   600         {  
       
   601         if ( iAdaptiveSearch && aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   602             {
       
   603             if( AdaptiveSearchEnabled() )
       
   604                 {
       
   605                 iEditor->AddFlagToUserFlags( CEikEdwin::EAvkonDisableVKB ); 
       
   606                 MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   607                 if ( feedback )
       
   608                     {
       
   609                     feedback->InstantFeedback( ETouchFeedbackBasic );
       
   610                     }
       
   611                 TBool selectall = FeatureManager::FeatureSupported( KFeatureIdChinese )
       
   612                     && iEditor->SelectionLength() == iEditor->TextLength();
       
   613                 iAdaptiveSearch->InvertAdaptiveSearchGridVisibilityL( selectall );          
       
   614                 }
       
   615             else
       
   616                 {                   
       
   617                 iEditor->RemoveFlagFromUserFlags( CEikEdwin::EAvkonDisableVKB );
       
   618                 CAknControl::HandlePointerEventL( aPointerEvent );
       
   619                 }
       
   620             }
       
   621         else            
       
   622             {
       
   623             iEditor->RemoveFlagFromUserFlags( CEikEdwin::EAvkonDisableVKB );           
       
   624             CAknControl::HandlePointerEventL( aPointerEvent );
       
   625             }
       
   626         }
       
   627     }
       
   628 
       
   629 // -----------------------------------------------------------------------------
       
   630 // CAknSearchField::ShowAdaptiveSearchGrid
       
   631 // Show adaptive search grid. For the application's menu
       
   632 // -----------------------------------------------------------------------------
       
   633 //
       
   634 EXPORT_C void CAknSearchField::ShowAdaptiveSearchGrid() const   
       
   635     {    
       
   636     _AKNTRACE_FUNC_ENTER;
       
   637     CAknSearchField* searchField = const_cast<CAknSearchField*>( this );
       
   638     if( iAdaptiveSearch && searchField->AdaptiveSearchEnabled() )
       
   639         {
       
   640         TRAP_IGNORE( iAdaptiveSearch->ShowAdaptiveSearchGridL() );              
       
   641         }                                   
       
   642     _AKNTRACE_FUNC_EXIT;
       
   643     }
       
   644     
       
   645 // -----------------------------------------------------------------------------
       
   646 // CAknSearchField::TextLength
       
   647 // Returns the length of search text.
       
   648 // -----------------------------------------------------------------------------
       
   649 //
       
   650 EXPORT_C TInt CAknSearchField::TextLength() const   
       
   651     {
       
   652     return iEditor->TextLength();
       
   653     }
       
   654 
       
   655 // -----------------------------------------------------------------------------
       
   656 // CAknSearchField::GetSearchText
       
   657 // Returns the text of search field by writing it into the buffer aSearchText.
       
   658 // -----------------------------------------------------------------------------
       
   659 //
       
   660 EXPORT_C void CAknSearchField::GetSearchText( TDes& aSearchTxt ) const
       
   661     {
       
   662     _AKNTRACE_FUNC_ENTER;
       
   663     // caller's responsibility to provide long enough buffer
       
   664     iEditor->GetText( aSearchTxt ); 
       
   665     
       
   666     _AKNDEBUG(
       
   667     _LIT( KClassName, "CAknSearchField" );
       
   668     _LIT( KFunctionName, "GetSearchText" );
       
   669     _LIT( KFormat, "[%S][%S] aSearchTxt: %S" );
       
   670     _AKNTRACE( KFormat, &KClassName, &KFunctionName, &aSearchTxt );
       
   671     );
       
   672 
       
   673     _AKNTRACE_FUNC_EXIT;
       
   674     }
       
   675 
       
   676 // -----------------------------------------------------------------------------
       
   677 // CAknSearchField::SetSearchTextL 
       
   678 // Sets text into search field.
       
   679 // -----------------------------------------------------------------------------
       
   680 //
       
   681 EXPORT_C void CAknSearchField::SetSearchTextL( const TDesC& aSearchTxt )
       
   682     {
       
   683     iEditor->SetTextL( &aSearchTxt );
       
   684     TInt curPos = iEditor->TextLength(); 
       
   685     iEditor->SetSelectionL( curPos, curPos );  //This set selection all off
       
   686     }
       
   687 
       
   688 // -----------------------------------------------------------------------------
       
   689 // CAknSearchField::SelectSearchTextL
       
   690 // Selects the whole search text.                          
       
   691 // -----------------------------------------------------------------------------
       
   692 //
       
   693 EXPORT_C void CAknSearchField::SelectSearchTextL()
       
   694     {
       
   695     iEditor->SelectAllL();
       
   696     }
       
   697 
       
   698 // -----------------------------------------------------------------------------
       
   699 // CAknSearchField::ResetL
       
   700 //  Clears text in the search field.                          
       
   701 // -----------------------------------------------------------------------------
       
   702 //
       
   703 EXPORT_C void CAknSearchField::ResetL()
       
   704     {
       
   705     TBuf<2> str;
       
   706     str.Zero();
       
   707     iEditor->SetTextL( &str );
       
   708     }
       
   709 
       
   710 // -----------------------------------------------------------------------------
       
   711 // CAknSearchField::SetInfoTextL
       
   712 // Sets additional info text to the search field.                         
       
   713 // -----------------------------------------------------------------------------
       
   714 //
       
   715 EXPORT_C void CAknSearchField::SetInfoTextL( const TDesC& aText )
       
   716     {
       
   717     iInputFrame->SetInfoTextL( aText );
       
   718     }
       
   719 
       
   720 // -----------------------------------------------------------------------------
       
   721 // CAknSearchField::ClipboardL
       
   722 // Calls editor's ClipboardL function.                         
       
   723 // -----------------------------------------------------------------------------
       
   724 //
       
   725 EXPORT_C void CAknSearchField::ClipboardL( CEikEdwin::TClipboardFunc aClipboardFunc )
       
   726     {
       
   727     iEditor->ClipboardL( aClipboardFunc );
       
   728     }
       
   729 
       
   730 EXPORT_C void CAknSearchField::SetSkinEnabledL( const TBool aEnabled )
       
   731     {
       
   732     if ( aEnabled )
       
   733         {
       
   734         iFlags |= EUseSkinContext;
       
   735         }
       
   736     else
       
   737         {
       
   738         iFlags &= ( ~EUseSkinContext );
       
   739         }
       
   740     }
       
   741 
       
   742 // -----------------------------------------------------------------------------
       
   743 // CAknSearchField::HandleControlEventL                         
       
   744 // -----------------------------------------------------------------------------
       
   745 //
       
   746 void CAknSearchField::HandleControlEventL( CCoeControl* /*aControl*/, TCoeEvent aEventType )
       
   747     {
       
   748     switch ( aEventType )
       
   749         {
       
   750         case EEventRequestFocus:
       
   751             FocusChanged( EDrawNow );
       
   752             break;
       
   753         case EEventStateChanged:
       
   754             if (Observer())
       
   755                 {
       
   756                 Observer()->HandleControlEventL(this, EEventStateChanged);
       
   757                 }
       
   758             break;
       
   759         default:
       
   760             break;
       
   761         }
       
   762     }
       
   763 
       
   764 // -----------------------------------------------------------------------------
       
   765 // CAknSearchField::ProcessCommandL
       
   766 // Processes popup find right softkey (Cancel). This closes popup find
       
   767 // and returns softkey processing to underlying control.
       
   768 // -----------------------------------------------------------------------------
       
   769 //
       
   770 EXPORT_C void CAknSearchField::ProcessCommandL( TInt aCommandId )
       
   771     {
       
   772     if ( aCommandId == EAknSoftkeyCancel )
       
   773         {
       
   774         ResetL();
       
   775         // To provent last text filckering when next time it pop out.
       
   776         DrawNow();
       
   777         TBool needRefresh;
       
   778         AknFind::HandleFindPaneVisibility( this, ETrue, EFalse, needRefresh );
       
   779         if ( needRefresh && iListBox && iParent )
       
   780             {
       
   781             AknFind::HandlePopupFindSizeChanged( iParent, iListBox, this );
       
   782 
       
   783             CAknFilteredTextListBoxModel* model = static_cast<CAknFilteredTextListBoxModel*> ( iListBox->Model() );
       
   784             
       
   785             if ( model->Filter() )
       
   786                 {
       
   787                 model->Filter()->ResetFilteringL();
       
   788                 }
       
   789 
       
   790             if ( iOldItemIndex >= 0 &&
       
   791                  iOldItemIndex < model->NumberOfItems())
       
   792                 {
       
   793                 iListBox->SetCurrentItemIndex( iOldItemIndex );
       
   794                 }
       
   795                 
       
   796             if( iAdaptiveSearch )
       
   797                 {
       
   798                 iAdaptiveSearch->HideAdaptiveSearchGridL();              
       
   799                 }                  
       
   800             iListBox->DrawNow();
       
   801             }
       
   802         }
       
   803     }
       
   804 
       
   805 TInt CAknSearchField::CountComponentControls() const
       
   806     {  
       
   807     if ( iIndicator )
       
   808         {
       
   809         return 3;
       
   810         }
       
   811     else
       
   812        {
       
   813        return 2;             
       
   814        }    
       
   815     }
       
   816 
       
   817 CCoeControl* CAknSearchField::ComponentControl( TInt aIndex ) const
       
   818     {
       
   819     CCoeControl* control = NULL;
       
   820 
       
   821     if ( aIndex == 0 )
       
   822         {
       
   823         control = iInputFrame;
       
   824         }
       
   825     else if ( aIndex == 1 && iIndicator)
       
   826         {
       
   827         control =  iIndicator;
       
   828         }
       
   829     else
       
   830         {
       
   831         control = iEditor;
       
   832         }      
       
   833     return control;
       
   834     }
       
   835 
       
   836 void CAknSearchField::SizeChanged()
       
   837     {
       
   838     iInputFrame->SetRect( Rect() );
       
   839 
       
   840     if ( iIndicator )
       
   841         {
       
   842         iIndicator->SetRect( Rect() );
       
   843         }   
       
   844     
       
   845     if ( iAdaptiveSearch )
       
   846         {
       
   847         iAdaptiveSearch->SaveFindPaneRect( Rect() );
       
   848         }
       
   849     
       
   850     TRAP_IGNORE( SetupSkinContextL() );
       
   851     }
       
   852 
       
   853 void CAknSearchField::FocusChanged( TDrawNow /*aDrawNow*/ )
       
   854     {
       
   855     if ( iEditor && IsVisible() )
       
   856         {
       
   857         iEditor->SetFocus( IsFocused() );
       
   858         }       
       
   859 
       
   860     if ( iIsPopup && IsFocused() && !iCBAObserverUpdated )
       
   861         {
       
   862         // non-leaving function, TRAP possible CBA update leaves.
       
   863         // if CBA updating leaves, do nothing
       
   864         TRAP_IGNORE( UpdatePopupCBAL() );
       
   865         }
       
   866 
       
   867     if ( iIsPopup && !IsFocused() && iCBAObserverUpdated )
       
   868         {
       
   869         RestorePopupCBA();
       
   870         }
       
   871     }
       
   872 
       
   873 EXPORT_C TSize CAknSearchField::MinimumSize()
       
   874     {
       
   875     // Returns minimum size. Minimum size depends on zoom factor.
       
   876     return TSize( 0, 0 );
       
   877     }
       
   878 
       
   879 EXPORT_C void CAknSearchField::MakeVisible( TBool aVisible )
       
   880     {
       
   881     _AKNTRACE_FUNC_ENTER;
       
   882     
       
   883     CCoeControl::MakeVisible( aVisible );
       
   884     
       
   885     _AKNTRACE( "[%s][%s] aVisible: %d", 
       
   886     		"CAknSearchField", __FUNCTION__, aVisible );
       
   887         
       
   888     if ( iEditor )
       
   889         {
       
   890         // IsFocused() can not return standand boolean value to compare
       
   891         TBool focused = iEditor->IsFocused() ? ETrue : EFalse;
       
   892         _AKNTRACE( "[%s][%s] Is Editor Foucused: %d", 
       
   893             	"CAknSearchField", __FUNCTION__, focused );
       
   894         // "EHMS-7KVGXV"
       
   895         if ( focused != aVisible )
       
   896             {
       
   897             iEditor->SetFocus( aVisible );
       
   898             }
       
   899         }        
       
   900     _AKNTRACE_FUNC_EXIT;
       
   901     }
       
   902 
       
   903 void CAknSearchField::HandleResourceChange( TInt aType )
       
   904 	{
       
   905 	if( aType == KAknsMessageSkinChange )
       
   906 		{
       
   907 		CAknSearchField* searchField = const_cast<CAknSearchField*>( this );
       
   908 		if( iAdaptiveSearch && searchField->AdaptiveSearchEnabled() )
       
   909 			{
       
   910 			TRAP_IGNORE( iAdaptiveSearch->UpdateGridSkinL() );
       
   911 			}
       
   912 		}
       
   913 	CAknControl::HandleResourceChange( aType );
       
   914 	}
       
   915 
       
   916 TTypeUid::Ptr CAknSearchField::MopSupplyObject( TTypeUid aId )
       
   917     {
       
   918     if( aId.iUid == MAknsControlContext::ETypeId && iFlags & EUseSkinContext )
       
   919         {
       
   920         return MAknsControlContext::SupplyMopObject( aId, iSkinContext );
       
   921         }
       
   922     return SupplyMopObject( aId, (MAknEditingStateIndicator*)iIndicator );
       
   923     }
       
   924 
       
   925 
       
   926 void CAknSearchField::UpdatePopupCBAL()
       
   927     {
       
   928     // Change right CBA for popup find
       
   929     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
       
   930     if ( cba == NULL ) return; //no CBAs - do nothing
       
   931 
       
   932     HBufC* label = StringLoader::LoadL( R_AVKON_SOFTKEY_CANCEL, iCoeEnv );
       
   933     CleanupStack::PushL( label );
       
   934     cba->AddCommandToStackL( 2, EAknSoftkeyCancel, label->Des() );
       
   935     CleanupStack::PopAndDestroy(); // label
       
   936     cba->DrawNow();      
       
   937     
       
   938     if( !cba->UpdatedCommandObserverExists(CEikButtonGroupContainer::ERightSoftkeyPosition) )
       
   939         {
       
   940         TRAPD( error, cba->UpdateCommandObserverL(2, *this) );
       
   941         
       
   942          if ( error == KErrNone )
       
   943             {
       
   944             iCBAObserverUpdated = ETrue;
       
   945             }   
       
   946         }           
       
   947     iCba = cba;
       
   948     }
       
   949 
       
   950 void CAknSearchField::RestorePopupCBA()
       
   951     {
       
   952     // Restore right CBA to what it was
       
   953     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
       
   954     
       
   955     // if view switch happened, Current() might return different cba;
       
   956     // no use for modifying it.
       
   957     if ( iCba != cba ) return;
       
   958     
       
   959     if ( cba )
       
   960         {
       
   961         cba->RemoveCommandObserver( 2 );
       
   962         cba->RemoveCommandFromStack( 2, EAknSoftkeyCancel );
       
   963         cba->DrawNow();
       
   964         }
       
   965     iCBAObserverUpdated = EFalse;
       
   966     iCba = NULL;
       
   967     }
       
   968 
       
   969 void CAknSearchField::SetListbox( CEikListBox *aListBox )
       
   970     {
       
   971     if( iListBox != aListBox )
       
   972         {
       
   973         iListBox = aListBox;
       
   974         if( iParent )
       
   975             {
       
   976             if ( iIsPopup )
       
   977                 {
       
   978                 AknFind::HandlePopupFindSizeChanged( iParent, iListBox, this );
       
   979                 }
       
   980             else
       
   981                 {
       
   982                 AknFind::HandleFixedFindSizeChanged( iParent, (CAknColumnListBox*)iListBox, this );
       
   983                 }
       
   984             }
       
   985         }         
       
   986     }
       
   987 
       
   988 void CAknSearchField::SetParentCtrl( CCoeControl *aParent )
       
   989     {
       
   990     iParent = aParent;
       
   991     }
       
   992 
       
   993 TBool CAknSearchField::IsPopup()
       
   994     {
       
   995     return iIsPopup;
       
   996     }
       
   997 
       
   998 // -----------------------------------------------------------------------------
       
   999 // CAknSearchField::Editor
       
  1000 // Access to the edwin owned by the search field.
       
  1001 // -----------------------------------------------------------------------------
       
  1002 //
       
  1003 EXPORT_C CEikEdwin& CAknSearchField::Editor() const
       
  1004     {
       
  1005     return *iEditor;
       
  1006     }
       
  1007 
       
  1008 // -----------------------------------------------------------------------------
       
  1009 // CAknSearchField::SetupSkinContextL
       
  1010 // -----------------------------------------------------------------------------
       
  1011 //
       
  1012 void CAknSearchField::SetupSkinContextL()
       
  1013     {
       
  1014     TAknsItemID tileIID = KAknsIIDQsnBgColumnA;
       
  1015     if (iLinePos == 1 || iLinePos == 0)
       
  1016         {
       
  1017         tileIID = KAknsIIDNone;
       
  1018         }
       
  1019     if (iLinePos == 3)
       
  1020         {
       
  1021         tileIID = KAknsIIDQsnBgColumnAB;
       
  1022         }    
       
  1023     if( iFlags & ETileIIDNone )
       
  1024         {
       
  1025         tileIID = KAknsIIDNone;
       
  1026         }    
       
  1027     TAknWindowLineLayout tile =
       
  1028         Column_background_and_list_slice_skin_placing_Line_2();    
       
  1029     if (iLinePos==1)
       
  1030         {
       
  1031         tile = Column_background_and_list_slice_skin_placing_Line_1();
       
  1032         }    
       
  1033     if (iLinePos==3)
       
  1034         {
       
  1035         tile = Column_background_and_list_slice_skin_placing_Line_3();
       
  1036         }    
       
  1037     TRect screen;  // was mainpane
       
  1038     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen );    
       
  1039     TAknLayoutRect tileRect;
       
  1040     tileRect.LayoutRect(screen, tile);  
       
  1041     TBool parentAbsolute = iFlags & EParentAbsolute;
       
  1042     if ( !iSkinContext )
       
  1043         {
       
  1044         iSkinContext = CAknsListBoxBackgroundControlContext::NewL(
       
  1045             KAknsIIDQsnBgAreaMainListGene, 
       
  1046             screen,
       
  1047             parentAbsolute,
       
  1048             tileIID,
       
  1049             tileRect.Rect() );
       
  1050         }
       
  1051     else
       
  1052         {
       
  1053         iSkinContext->SetRect( screen );
       
  1054         }
       
  1055     if ( !iInputContext )
       
  1056         {
       
  1057         iInputContext = CAknsFrameBackgroundControlContext::NewL(
       
  1058             KAknsIIDQsnFrInput, TRect(0,0,0,0), TRect(0,0,0,0), EFalse );
       
  1059         }
       
  1060     iInputFrame->SetInputContext( iInputContext );
       
  1061     iEditor->SetSkinBackgroundControlContextL( iInputContext );
       
  1062     if ( parentAbsolute )
       
  1063         {
       
  1064         iSkinContext->SetParentPos( iAvkonAppUi->ClientRect().iTl );
       
  1065         }
       
  1066     }
       
  1067 
       
  1068 void CAknSearchField::HandleHWKeyboardModeChangeL()
       
  1069     {
       
  1070     _AKNTRACE_FUNC_ENTER;
       
  1071     TInt isHwKbOpen = 0;
       
  1072     iHwKeyboardPro.Get( isHwKbOpen );    
       
  1073     if ( isHwKbOpen != 0 ) // QWERTY open
       
  1074         {
       
  1075         if ( iIndicator )
       
  1076             {
       
  1077             iIndicator->SetRect( Rect() );
       
  1078             iIndicator->MakeVisible( ETrue );
       
  1079             }
       
  1080         iInputFrame->SetFlags( iInputFrame->Flags() 
       
  1081                                | CAknInputFrame::EShowIndicators );
       
  1082         iInputFrame->SetRect( Rect() );
       
  1083         
       
  1084         if ( iAdaptiveSearch )
       
  1085             {
       
  1086             iAdaptiveSearch->HideAdaptiveSearchGridL();
       
  1087             }
       
  1088         else
       
  1089             {
       
  1090             // Enforce focus to edwin to get cursor and indicator,
       
  1091             // Hidden find pane should ignore this.
       
  1092             if ( !IsFocused() && IsVisible() )
       
  1093 				{
       
  1094 				SetFocus( ETrue );
       
  1095 				}
       
  1096             }
       
  1097         
       
  1098         }
       
  1099     else
       
  1100         {
       
  1101         iIndicator->MakeVisible(EFalse);
       
  1102         iInputFrame->SetFlags( iInputFrame->Flags() 
       
  1103                                & ~CAknInputFrame::EShowIndicators );
       
  1104         iInputFrame->SetRect( Rect() );
       
  1105         }
       
  1106     // we need CAknInputFrame::SizeChanged to redo layout
       
  1107     iInputFrame->SetRect( Rect() );
       
  1108 
       
  1109     iEditor->SelectAllL();
       
  1110     DrawNow();
       
  1111     _AKNTRACE_FUNC_EXIT;
       
  1112     }
       
  1113 
       
  1114 TBool CAknSearchField::GetASStatusAndSubKbLayoutL( TBool& aShowIndicator )
       
  1115     {
       
  1116     _AKNTRACE_FUNC_ENTER;
       
  1117     CRepository* cenrep = NULL;
       
  1118     TRAPD( ret, cenrep = CRepository::NewL( KCRUidAvkon ) );
       
  1119     CleanupStack::PushL( cenrep );
       
  1120     TBool isAsEnable = EFalse;
       
  1121     if ( ret == KErrNone )
       
  1122         {        
       
  1123         ret = cenrep->Get( KAknAvkonAdaptiveSearchEnabled, isAsEnable );
       
  1124         if ( FeatureManager::FeatureSupported( KFeatureIdChinese ))
       
  1125             {
       
  1126             ret = iHwKeyboardPro.Attach( KCRUidAvkon, 
       
  1127                     KAknKeyBoardLayout );
       
  1128             if ( ret == KErrNone )
       
  1129                 {
       
  1130                 iHwKbSub = new(ELeave) CHwKbSubscriber( this, iHwKeyboardPro);
       
  1131                 TInt kb = 0;
       
  1132                 if ( iHwKeyboardPro.Get(kb) == KErrNone )
       
  1133                     {
       
  1134                     _AKNTRACE( "[%s][%s] Keyboard Layout: %d", 
       
  1135                             "CAknSearchField", __FUNCTION__, kb );
       
  1136                     // show indicator when handware is open
       
  1137                     aShowIndicator = kb != 0;
       
  1138                     _AKNTRACE( "[%s][%s] Show Indicator: %d", 
       
  1139                                 "CAknSearchField", __FUNCTION__, aShowIndicator );
       
  1140                     }
       
  1141                 iHwKbSub->SubscribeL();
       
  1142                 }
       
  1143             }
       
  1144         }                
       
  1145     CleanupStack::PopAndDestroy( cenrep );    
       
  1146     _AKNTRACE_FUNC_EXIT;
       
  1147     return isAsEnable;
       
  1148     }
       
  1149 
       
  1150 void CAknSearchField::SetOldItemIndex( TInt aOldItemIndex )
       
  1151     {
       
  1152     iOldItemIndex = aOldItemIndex;
       
  1153     }
       
  1154 
       
  1155 TInt CAknSearchField::OldItemIndex()
       
  1156     {
       
  1157     return iOldItemIndex;
       
  1158     }
       
  1159  
       
  1160 // -----------------------------------------------------------------------------
       
  1161 // CAknSearchField::SetAdaptiveGridChars
       
  1162 // Set adaptive search grid characters.
       
  1163 // -----------------------------------------------------------------------------
       
  1164 //
       
  1165 EXPORT_C void CAknSearchField::SetAdaptiveGridChars( const TDesC& aGridChars ) const
       
  1166     {
       
  1167     _AKNTRACE_FUNC_ENTER;
       
  1168     if( iAdaptiveSearch )
       
  1169         {
       
  1170         _AKNDEBUG(
       
  1171         _LIT( KClassName, "CAknSearchField" );
       
  1172         _LIT( KFunctionName, "SetAdaptiveGridChars" );
       
  1173         _LIT( KFormat, "[%S][%S] aGridChars: %S" );
       
  1174         _AKNTRACE( KFormat, &KClassName, &KFunctionName, &aGridChars );
       
  1175         );
       
  1176         TRAP_IGNORE( iAdaptiveSearch->SetButtonCharsL( aGridChars ) );
       
  1177         }
       
  1178     _AKNTRACE_FUNC_EXIT;
       
  1179     }   
       
  1180 
       
  1181 // -----------------------------------------------------------------------------
       
  1182 // CAknSearchField::SetListColumnFilterFlags
       
  1183 // Set flag of columns for adaptive search grid.
       
  1184 // -----------------------------------------------------------------------------
       
  1185 //
       
  1186 EXPORT_C void CAknSearchField::SetListColumnFilterFlags( const TBitFlags32 aFlag )
       
  1187     {
       
  1188     iColumnFlag = aFlag;
       
  1189     }
       
  1190 
       
  1191 EXPORT_C TBitFlags32 CAknSearchField::ListColumnFilterFlags() const 
       
  1192     {
       
  1193     return iColumnFlag;
       
  1194     }
       
  1195     
       
  1196 EXPORT_C CAknSearchField::TSearchFieldStyle CAknSearchField::SearchFieldStyle() const
       
  1197     {
       
  1198     return iStyle;
       
  1199     }
       
  1200     
       
  1201 // -----------------------------------------------------------------------------
       
  1202 // CAknSearchField::AddAdaptiveSearchTextObserverL
       
  1203 // Adds an adaptive search text observer. Duplicates are not checked 
       
  1204 // -----------------------------------------------------------------------------
       
  1205 //
       
  1206 EXPORT_C void CAknSearchField::AddAdaptiveSearchTextObserverL( 
       
  1207                                         MAdaptiveSearchTextObserver* aObserver )
       
  1208     {
       
  1209     if( iAdaptiveSearch )
       
  1210         {
       
  1211         iAdaptiveSearch->AddAdaptiveSearchTextObserverL( aObserver );
       
  1212         }
       
  1213     }
       
  1214 
       
  1215 // ----------------------------------------------------------------------------- 
       
  1216 // CAknSearchField::RemoveAdaptiveSearchTextObserver
       
  1217 // Removes an adaptive search text observer. 
       
  1218 // -----------------------------------------------------------------------------
       
  1219 //
       
  1220 EXPORT_C TBool CAknSearchField::RemoveAdaptiveSearchTextObserver( 
       
  1221                                         MAdaptiveSearchTextObserver* aObserver )
       
  1222     {
       
  1223     if( iAdaptiveSearch )
       
  1224         {
       
  1225         return iAdaptiveSearch->RemoveAdaptiveSearchTextObserver( aObserver );
       
  1226         }
       
  1227     return EFalse;
       
  1228     }
       
  1229     
       
  1230 // -----------------------------------------------------------------------------
       
  1231 // CAknSearchField::AdaptiveSearchEnabled
       
  1232 // Check adaptive search availability from cenrep
       
  1233 // -----------------------------------------------------------------------------
       
  1234 //
       
  1235 EXPORT_C TBool CAknSearchField::AdaptiveSearchEnabled()
       
  1236     {
       
  1237     if ( !iAdaptiveSearch )
       
  1238         {
       
  1239         return EFalse;
       
  1240         }       
       
  1241     CRepository* repository = NULL;
       
  1242     TBool ASEnabled;
       
  1243     TRAPD( ret, repository = CRepository::NewL( KCRUidAvkon ) );
       
  1244     if ( ret == KErrNone )
       
  1245         {
       
  1246         ret = repository->Get( KAknAvkonAdaptiveSearchEnabled, ASEnabled );
       
  1247         }
       
  1248     delete repository;    
       
  1249     TInt isHwKbOpen = 0;
       
  1250     if ( iHwKbSub )
       
  1251         {
       
  1252         iHwKeyboardPro.Get( isHwKbOpen );
       
  1253         }
       
  1254     return ASEnabled && isHwKbOpen == 0;
       
  1255     }   
       
  1256 // -----------------------------------------------------------------------------
       
  1257 // CAknSearchField::SetLanguageChangedFlag
       
  1258 // Set language changed flag for AS 
       
  1259 // -----------------------------------------------------------------------------
       
  1260 //
       
  1261 void CAknSearchField::SetLanguageChangedFlag( TBool aLanguageChanged )
       
  1262     {   
       
  1263     iLanguageChanged = aLanguageChanged;
       
  1264     }
       
  1265     
       
  1266 // -----------------------------------------------------------------------------
       
  1267 // CAknSearchField::LanguageChanged
       
  1268 // Notify client that input language was changed in settings for AS 
       
  1269 // -----------------------------------------------------------------------------
       
  1270 //
       
  1271 EXPORT_C TBool CAknSearchField::LanguageChanged() const
       
  1272     {   
       
  1273     return iLanguageChanged;
       
  1274     }
       
  1275     
       
  1276 // End of File