browserui/browser/BrowserAppSrc/BrowserGotoPane.cpp
changeset 0 84ad3b177aa3
child 1 57d5b8e231c4
equal deleted inserted replaced
-1:000000000000 0:84ad3b177aa3
       
     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 the License "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 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <eikmenub.h>
       
    23 #include <eikdef.h>
       
    24 #include <akninfrm.h>
       
    25 #include <eikon.rsg>
       
    26 #include <eikenv.h>
       
    27 #include <txtglobl.h>
       
    28 #include <gulfont.h>
       
    29 #include <txtfrmat.h>
       
    30 #include <eikgted.h>
       
    31 #include <aknconsts.h>
       
    32 #include <akneditstateindicator.h>
       
    33 #include <AknsListBoxBackgroundControlContext.h>
       
    34 #include <BrowserNG.rsg>
       
    35 #include <Featmgr.h>
       
    36 #include <fepbase.h>
       
    37 #include <aknutils.h>
       
    38 
       
    39 #include <centralrepository.h> 
       
    40 #include <AknFepInternalCRKeys.h>
       
    41 #include <PtiDefs.h>
       
    42 
       
    43 #include "CommonConstants.h"
       
    44 #include "BrowserGotoPane.h"
       
    45 #include "BrowserAppUi.h"
       
    46 #include "BrowserUtil.h"
       
    47 #include "browser.hrh"
       
    48 #include "FavouritesLimits.h"
       
    49 #include "BrowserAdaptiveListPopup.h"
       
    50 #include "BrowserContentView.h"
       
    51 
       
    52 #include "eikon.hrh"
       
    53 
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CBrowserGotoPane::NewL
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CBrowserGotoPane* CBrowserGotoPane::NewL(
       
    60         const CCoeControl* aParent, TInt aIconBitmapId, TInt aIconMaskId,
       
    61         TBool aPopupListStatus, CBrowserContentView* aContentView,
       
    62         TBool aFindKeywordMode )
       
    63     {
       
    64     CBrowserGotoPane* gotoPane = new(ELeave)
       
    65         CBrowserGotoPane( aContentView, aFindKeywordMode );
       
    66 
       
    67     CleanupStack::PushL( gotoPane );
       
    68     gotoPane->ConstructL( aParent, aIconBitmapId, aIconMaskId, aPopupListStatus );
       
    69     gotoPane->MakeVisibleL( EFalse );
       
    70     gotoPane->SetFocus( EFalse );
       
    71     CleanupStack::Pop();    // gotoPane
       
    72 
       
    73     return gotoPane;
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // CBrowserGotoPane::MakeVisibleL
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 void CBrowserGotoPane::MakeVisibleL( TBool aVisible )
       
    81     {
       
    82     if ( aVisible )
       
    83     {
       
    84         HandleFindSizeChanged();
       
    85         if ( AUTOCOMP ) //ask the feature manager
       
    86         {
       
    87         //2.1 does not put http:// there
       
    88             SetTextL( KNullDesC );
       
    89         }
       
    90         else
       
    91         {
       
    92         //2.0 does put the http:// there
       
    93             SetTextL( KHttpString );
       
    94         }
       
    95     }
       
    96     if (AknLayoutUtils::PenEnabled())
       
    97         {
       
    98         SetPointerCapture(aVisible);
       
    99         if (aVisible)
       
   100             {
       
   101             ActivateVKB();
       
   102             }
       
   103         }
       
   104 
       
   105     CCoeControl::MakeVisible( aVisible );
       
   106 
       
   107     iGotoKeyHandled->Reset();
       
   108     iGotoKeyHandled->EnableL( aVisible );
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // CBrowserGotoPane::MakeVisible
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 void CBrowserGotoPane::MakeVisible( TBool aVisible )
       
   116     {
       
   117     TRAP_IGNORE( MakeVisibleL( aVisible ) );
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // CBrowserGotoPane::~CBrowserGotoPane
       
   122 // ---------------------------------------------------------------------------
       
   123 //
       
   124 CBrowserGotoPane::~CBrowserGotoPane()
       
   125     {
       
   126     if (iAvkonAppUi!=NULL)
       
   127         {
       
   128         iAvkonAppUi->RemoveFromStack( iGotoKeyHandled );
       
   129         }
       
   130     delete iGotoKeyHandled;
       
   131     delete iEditor;
       
   132     delete iInputFrame;
       
   133     delete iPrevKeyword;
       
   134     delete iBAdaptiveListPopup;
       
   135     iContentView = NULL;
       
   136     CCoeEnv::Static()->RemoveFepObserver(static_cast<MCoeFepObserver &>(*this));
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // CBrowserGotoPane::CBrowserGotoPane
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 CBrowserGotoPane::CBrowserGotoPane( CBrowserContentView* aContentView, TBool aFindKeywordMode )
       
   144 :   iContentView( aContentView),
       
   145     iFindKeywordMode( aFindKeywordMode ),
       
   146     iHandleFEPFind( ETrue )
       
   147     ,iBAdaptiveListPopup( NULL )
       
   148     {
       
   149     }
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // CBrowserGotoPane::ConstructL
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 void CBrowserGotoPane::ConstructL ( const CCoeControl* aParent, TInt aIconBitmapId, TInt aIconMaskId,
       
   156             TBool
       
   157             aPopupListStatus
       
   158             )
       
   159     {
       
   160     CreateWindowL();
       
   161 
       
   162     // remove 'const' modifier and set parent control
       
   163     SetMopParent( CONST_CAST( CCoeControl*, aParent ) );
       
   164 
       
   165     iEditor = new (ELeave) CEikGlobalTextEditor;
       
   166 
       
   167     iInputFrame = CAknInputFrame::NewL(
       
   168         iEditor,
       
   169         EFalse,
       
   170         KAvkonBitmapFile,
       
   171         aIconBitmapId,
       
   172         aIconMaskId,
       
   173         CAknInputFrame::EPopupLayout );
       
   174 
       
   175     iInputFrame->SetContainerWindowL( *this );
       
   176 
       
   177     AknEditUtils::ConstructEditingL (   iEditor,
       
   178                                         KFavouritesMaxUrlGotoPaneDefine,
       
   179                                         1,
       
   180                                         EAknEditorCharactersLowerCase,
       
   181                                         EAknEditorAlignRight,
       
   182                                         EFalse,
       
   183                                         ETrue,
       
   184                                         EFalse );
       
   185 
       
   186     iEditor->SetContainerWindowL( *this );
       
   187     iEditor->SetObserver( this );
       
   188     iEditor->SetBorder( TGulBorder::ENone );
       
   189     iEditor->SetAknEditorCase( EAknEditorLowerCase );
       
   190     iEditor->SetAknEditorInputMode( EAknEditorTextInputMode );
       
   191 
       
   192     if (AVKONAPAC)
       
   193         {
       
   194         // Disallow chinese input.
       
   195         iEditor->SetAknEditorAllowedInputModes( EAknEditorTextInputMode |
       
   196                                             EAknEditorNumericInputMode );
       
   197         }
       
   198     TInt editorFlags =  ((iFindKeywordMode) ? EAknEditorFlagDefault : EAknEditorFlagLatinInputModesOnly) |EAknEditorFlagUseSCTNumericCharmap;
       
   199 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   200     TInt physicalKeyboards = 0; 
       
   201     CRepository* aknFepRepository = CRepository::NewL( KCRUidAknFep );
       
   202 	User::LeaveIfNull( aknFepRepository );
       
   203 
       
   204     aknFepRepository->Get( KAknFepPhysicalKeyboards,  physicalKeyboards );
       
   205     delete aknFepRepository; 
       
   206         
       
   207 	if ( physicalKeyboards &&   EPtiKeyboardQwerty3x11 ) {
       
   208         editorFlags = (editorFlags | EAknEditorFlagNoT9);
       
   209 	}
       
   210 #endif 
       
   211     iEditor->SetAknEditorFlags( editorFlags ); 
       
   212 
       
   213     iEditor->SetAknEditorPermittedCaseModes (   EAknEditorUpperCase |
       
   214                                                 EAknEditorLowerCase );
       
   215 
       
   216     iGotoKeyHandled = new (ELeave) CBrowserKeyEventHandled( *this );
       
   217     iAvkonAppUi->AddToStackL( iGotoKeyHandled,
       
   218                                 ECoeStackPriorityFep + 1,
       
   219                                 ECoeStackFlagRefusesFocus );
       
   220     iEditor->SetEdwinObserver( iGotoKeyHandled );
       
   221     iEditor->SetSkinBackgroundControlContextL(NULL);
       
   222 
       
   223     //adaptive popuplist
       
   224     if ( aPopupListStatus && AUTOCOMP )
       
   225         {
       
   226         iBAdaptiveListPopup =
       
   227             new (ELeave) CBrowserAdaptiveListPopup( iEditor, this, EGotoPane );
       
   228         iBAdaptiveListPopup->ConstructL();
       
   229         iEditor->SetObserver( iBAdaptiveListPopup );
       
   230         if (iContentView)
       
   231             {
       
   232             iBAdaptiveListPopup->SetUrlSuffixList(iContentView->ApiProvider().Preferences().URLSuffixList());
       
   233             iBAdaptiveListPopup->SetMaxRecentUrls(iContentView->ApiProvider().Preferences().MaxRecentUrls());
       
   234             }
       
   235         }
       
   236 
       
   237     CCoeEnv::Static()->AddFepObserverL(static_cast<MCoeFepObserver &>(*this));
       
   238     iPrevKeyword = KNullDesC().AllocL();
       
   239     }
       
   240 
       
   241 // ---------------------------------------------------------------------------
       
   242 // CBrowserGotoPane::SetOrdinalPosition
       
   243 // ---------------------------------------------------------------------------
       
   244 //
       
   245 void CBrowserGotoPane::SetOrdinalPosition( TInt aPos )
       
   246     {
       
   247     Window().SetOrdinalPosition( aPos );
       
   248     if ( iBAdaptiveListPopup )
       
   249         {
       
   250         iBAdaptiveListPopup->SetOrdinalPosition( aPos );
       
   251         }
       
   252     }
       
   253 
       
   254 // ---------------------------------------------------------------------------
       
   255 // CBrowserGotoPane::HandleFindSizeChanged
       
   256 // ---------------------------------------------------------------------------
       
   257 //
       
   258 void CBrowserGotoPane::HandleFindSizeChanged()
       
   259     {
       
   260 
       
   261     if ( !AknLayoutUtils::PenEnabled() )
       
   262         {
       
   263         TRect parentrect = iAvkonAppUi->ApplicationRect();
       
   264 
       
   265         TAknLayoutRect lrect;
       
   266         lrect.LayoutRect( parentrect,
       
   267                         AknLayout::main_pane( CBrowserAppUi::Static()->ApplicationRect(), 0, 1, 1 )
       
   268                         );
       
   269         AknLayoutUtils::LayoutControl ( this,
       
   270                                         lrect.Rect(),
       
   271                                         AknLayout::popup_find_window() );
       
   272         }
       
   273     else
       
   274         {
       
   275         // The ClientRect() will be the application rectangle minus any
       
   276         // toolbars/menu bars etc.
       
   277         AknLayoutUtils::LayoutControl ( this,
       
   278                                         CBrowserAppUi::Static()->ClientRect(),
       
   279                                         AknLayout::popup_find_window() );
       
   280         }
       
   281 
       
   282     }
       
   283 
       
   284 // ---------------------------------------------------------------------------
       
   285 // CBrowserGotoPane::EnableKeyEventHandler
       
   286 // ---------------------------------------------------------------------------
       
   287 //
       
   288 void CBrowserGotoPane::EnableKeyEventHandlerL( TBool aEnable )
       
   289     {
       
   290     iGotoKeyHandled->EnableL( aEnable );
       
   291     }
       
   292 
       
   293 // ---------------------------------------------------------------------------
       
   294 // CBrowserGotoPane::HandleControlEventL
       
   295 // ---------------------------------------------------------------------------
       
   296 //
       
   297 void CBrowserGotoPane::HandleControlEventL ( CCoeControl* /*aControl*/,
       
   298                                                         TCoeEvent aEventType )
       
   299     {
       
   300     if ( iFindKeywordMode )
       
   301         {
       
   302         if ( iEditor->AknEditorCurrentInputMode() == EAknEditorCalculatorNumberModeKeymap
       
   303             // When the user copies and paste's content to the find dialog, the editor
       
   304             // is in Text Input mode, The engine should still get the find keyword request
       
   305             || iEditor->AknEditorCurrentInputMode() == EAknEditorTextInputMode
       
   306             )
       
   307             {
       
   308             if ( aEventType == MCoeControlObserver::EEventStateChanged )
       
   309                 {
       
   310                 HBufC* newText = GetTextL();
       
   311                 if (!newText)
       
   312                     {
       
   313                     newText = KNullDesC().AllocL();
       
   314                     }
       
   315 
       
   316                 if ( iPrevKeyword->Compare( *newText ) )
       
   317                     {
       
   318                     delete iPrevKeyword;
       
   319                     iPrevKeyword = NULL;
       
   320                     iPrevKeyword = newText;
       
   321                     // Find the typed keyword.
       
   322                     iContentView->FindKeywordL( GetTextL() );
       
   323                     iHandleFEPFind = EFalse;
       
   324                     }
       
   325                 else
       
   326                     {
       
   327                     delete newText;
       
   328                     }
       
   329                 }
       
   330             }
       
   331         }
       
   332 
       
   333     switch (aEventType)
       
   334         {
       
   335         case EEventRequestFocus:
       
   336             {
       
   337             FocusChanged( EDrawNow );
       
   338             break;
       
   339             }
       
   340 
       
   341         default:
       
   342             break;
       
   343         }
       
   344     }
       
   345 
       
   346 // ----------------------------------------------------------------------------
       
   347 // CBrowserGotoPane::OfferKeyEventL
       
   348 // ----------------------------------------------------------------------------
       
   349 //
       
   350 TKeyResponse CBrowserGotoPane::OfferKeyEventL
       
   351 ( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   352     {
       
   353     TKeyResponse resp;
       
   354 
       
   355     if ( AknLayoutUtils::PenEnabled() &&
       
   356          PopupList() &&
       
   357          PopupList()->DrawableWindow()->OrdinalPosition() > 0)
       
   358         {
       
   359         PopupList()->SetOrdinalPosition(0);
       
   360         }
       
   361 
       
   362     // Escape key event handling
       
   363     if ( aType == EEventKey && aKeyEvent.iCode == EKeyEscape )
       
   364         {
       
   365         CCoeEnv::Static()->AppUi()->RemoveFromStack( this );
       
   366         if ( PopupList() )
       
   367             {
       
   368             PopupList()->SetDirectoryModeL( ETrue );
       
   369             PopupList()->HidePopupL();
       
   370             }
       
   371 
       
   372         // Hide Goto pane
       
   373         MakeVisible( EFalse );
       
   374         SetFocus( EFalse );
       
   375         // should set the focus of container to ETrue...how?
       
   376         resp = EKeyWasConsumed;
       
   377         }
       
   378 
       
   379     if ( iFindKeywordMode )
       
   380         {
       
   381         if ( iContentView->MenuBar()->MenuPane()->IsVisible() )
       
   382             {
       
   383             return iContentView->MenuBar()->MenuPane()->OfferKeyEventL(  aKeyEvent, aType );
       
   384             }
       
   385         else
       
   386             {
       
   387             // Handle up and down arow keys to search for
       
   388             // next and previous keywords.
       
   389             if ( aType == EEventKey )
       
   390                 {
       
   391                 if (    aKeyEvent.iCode == EKeyLeftUpArrow      // Northwest
       
   392                      || aKeyEvent.iCode == EStdKeyDevice10      //   : Extra KeyEvent supports diagonal event simulator wedge
       
   393                      || aKeyEvent.iCode == EKeyUpArrow          // North
       
   394                      || aKeyEvent.iCode == EKeyRightUpArrow     // Northeast
       
   395                      || aKeyEvent.iCode == EStdKeyDevice11 )    //   : Extra KeyEvent supports diagonal event simulator wedge
       
   396                     {
       
   397                     // Find previous keyword
       
   398                     iContentView->FindKeywordL( NULL, EFalse );
       
   399                     iHandleFEPFind = EFalse;
       
   400                     return EKeyWasConsumed;
       
   401                     }
       
   402                 if (    aKeyEvent.iCode == EKeyLeftDownArrow    // Southwest
       
   403                      || aKeyEvent.iCode == EStdKeyDevice13      //   : Extra KeyEvent supports diagonal event simulator wedge
       
   404                      || aKeyEvent.iCode == EKeyDownArrow        // South
       
   405                      || aKeyEvent.iCode == EKeyRightDownArrow   // Southeast
       
   406                      || aKeyEvent.iCode == EStdKeyDevice12 )    //   : Extra KeyEvent supports diagonal event simulator wedge
       
   407                     {
       
   408                     // Find next keyword
       
   409                     iContentView->FindKeywordL( NULL, ETrue );
       
   410                     iHandleFEPFind = EFalse;
       
   411                     return EKeyWasConsumed;
       
   412                     }
       
   413                 if ( aKeyEvent.iCode == EKeyDevice3 )
       
   414                     {
       
   415                     // ignore select key
       
   416                     return EKeyWasConsumed;
       
   417                     }
       
   418                 }
       
   419             return iEditor->OfferKeyEventL( aKeyEvent, aType );
       
   420             }
       
   421         }
       
   422     else
       
   423         {
       
   424         if ( (aKeyEvent.iCode == EKeyOK ) && iGPObserver && IsFocused() )
       
   425             {
       
   426             if ( CBrowserAppUi::Static()->ContentView()->MenuBar()->MenuPane()->IsVisible() )
       
   427                 {
       
   428                 return CBrowserAppUi::Static()->ContentView()->MenuBar()->MenuPane()->OfferKeyEventL( aKeyEvent, aType );
       
   429                 }
       
   430             else
       
   431                 {
       
   432                 // If there is an observer and we have the focus, enter key is
       
   433                 // consumed and observer is notified.
       
   434                 iGPObserver->HandleGotoPaneEventL
       
   435                                 ( this, MGotoPaneObserver::EEventEnterKeyPressed );
       
   436                 return EKeyWasConsumed;
       
   437                 }
       
   438             }
       
   439         // For touch UI, handle enter key from VKB as a "GOTO"
       
   440         else if (AknLayoutUtils::PenEnabled() && aKeyEvent.iCode == EKeyEnter)
       
   441             {
       
   442             CBrowserAppUi::Static()->ActiveView()->HandleCommandL(EWmlCmdGotoPaneGoTo);
       
   443             return EKeyWasConsumed;
       
   444             }
       
   445 
       
   446         resp = iEditor->OfferKeyEventL( aKeyEvent, aType );
       
   447 
       
   448         if ((iBAdaptiveListPopup ) && (resp != EKeyWasConsumed))
       
   449             {
       
   450             resp = iBAdaptiveListPopup->OfferKeyEventL( aKeyEvent, aType );
       
   451             }
       
   452         return resp;
       
   453         }
       
   454     }
       
   455 
       
   456 // ----------------------------------------------------------------------------
       
   457 // CBrowserGotoPane::HandlePointerEventL
       
   458 // ----------------------------------------------------------------------------
       
   459 //
       
   460 void CBrowserGotoPane::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   461     {
       
   462     if ( !AknLayoutUtils::PenEnabled() )
       
   463         {
       
   464         return;
       
   465         }
       
   466 
       
   467     // ponter is in goto pane
       
   468     if (Rect().Contains(aPointerEvent.iPosition))
       
   469         {
       
   470         iGotoKeyHandled->EnableL(ETrue);
       
   471         iEditor->HandlePointerEventL(aPointerEvent);
       
   472         iGotoKeyHandled->SetFirstKeyEvent(EFalse);
       
   473         }
       
   474     else
       
   475         {
       
   476         // pointer outside of control
       
   477         CBrowserAppUi::Static()->ActiveView()->HandleCommandL(EWmlCmdGotoPaneCancel);
       
   478         }
       
   479     }
       
   480 
       
   481 // ----------------------------------------------------------------------------
       
   482 // CBrowserGotoPane::CountComponentControls
       
   483 // ----------------------------------------------------------------------------
       
   484 //
       
   485 TInt CBrowserGotoPane::CountComponentControls() const
       
   486     {
       
   487     return 2;   // iEditor and input frame
       
   488     }
       
   489 
       
   490 // ----------------------------------------------------------------------------
       
   491 // CBrowserGotoPane::ComponentControl
       
   492 // ----------------------------------------------------------------------------
       
   493 //
       
   494 CCoeControl* CBrowserGotoPane::ComponentControl ( TInt aIndex ) const
       
   495     {
       
   496     switch(aIndex)
       
   497         {
       
   498         case 0:
       
   499             {
       
   500             return iInputFrame;
       
   501             }
       
   502         case 1:
       
   503             {
       
   504             return iEditor;
       
   505             }
       
   506         default:
       
   507             return NULL;
       
   508         }
       
   509     }
       
   510 
       
   511 // ----------------------------------------------------------------------------
       
   512 // CBrowserGotoPane::SizeChanged
       
   513 // ----------------------------------------------------------------------------
       
   514 //
       
   515 void CBrowserGotoPane::SizeChanged()
       
   516     {
       
   517     iInputFrame->SetRect( Rect() );
       
   518     }
       
   519 
       
   520 // ----------------------------------------------------------------------------
       
   521 // CBrowserGotoPane::FocusChanged
       
   522 // ----------------------------------------------------------------------------
       
   523 //
       
   524 void CBrowserGotoPane::FocusChanged( TDrawNow aDrawNow )
       
   525     {
       
   526     // this is a workaround
       
   527     TRAP_IGNORE( iGotoKeyHandled->EnableL( IsFocused() ) );
       
   528     CCoeControl::FocusChanged( aDrawNow );
       
   529     iEditor->SetFocus( IsFocused() );
       
   530     }
       
   531 
       
   532 // ----------------------------------------------------------------------------
       
   533 // CBrowserGotoPane::TextLength
       
   534 // ----------------------------------------------------------------------------
       
   535 //
       
   536 TInt CBrowserGotoPane::TextLength() const
       
   537     {
       
   538     return iEditor->TextLength();
       
   539     }
       
   540 
       
   541 // ----------------------------------------------------------------------------
       
   542 // CBrowserGotoPane::GetText
       
   543 // ----------------------------------------------------------------------------
       
   544 //
       
   545 HBufC* CBrowserGotoPane::GetTextL() const
       
   546     {
       
   547     HBufC *retVal = NULL;
       
   548 
       
   549     if ( TextLength() || iFindKeywordMode)
       
   550         {
       
   551         retVal = HBufC::NewL( TextLength() + 1 );
       
   552         TPtr ptr = retVal->Des();
       
   553         iEditor->GetText( ptr );
       
   554         ptr.ZeroTerminate();
       
   555         if (!iFindKeywordMode)
       
   556            Util::EncodeSpaces(retVal);
       
   557 
       
   558         }
       
   559 
       
   560     return retVal;
       
   561     }
       
   562 
       
   563 // ----------------------------------------------------------------------------
       
   564 // CBrowserGotoPane::SetTextL
       
   565 // ----------------------------------------------------------------------------
       
   566 //
       
   567 void CBrowserGotoPane::SetTextL( const TDesC& aTxt )
       
   568     {
       
   569     iEditor->SetTextL( &aTxt );
       
   570     TInt curPos = TextLength();
       
   571     // Cursor to end, no selection.
       
   572     iEditor->SetSelectionL( curPos, curPos );
       
   573     iEditor->DrawNow();
       
   574     }
       
   575 
       
   576 // ----------------------------------------------------------------------------
       
   577 // CBrowserGotoPane::SelectAllL
       
   578 // ----------------------------------------------------------------------------
       
   579 //
       
   580 void CBrowserGotoPane::SelectAllL()
       
   581     {
       
   582     iEditor->SelectAllL();
       
   583     }
       
   584 
       
   585 // ----------------------------------------------------------------------------
       
   586 // CBrowserGotoPane::SetInfoTextL
       
   587 // ----------------------------------------------------------------------------
       
   588 //
       
   589 void CBrowserGotoPane::SetInfoTextL( const TDesC& aText )
       
   590     {
       
   591     iInputFrame->SetInfoTextL( aText );
       
   592     }
       
   593 
       
   594 // ----------------------------------------------------------------------------
       
   595 // CBrowserGotoPane::ClipboardL
       
   596 // ----------------------------------------------------------------------------
       
   597 //
       
   598 void CBrowserGotoPane::ClipboardL( CEikEdwin::TClipboardFunc aClipboardFunc )
       
   599     {
       
   600     iEditor->ClipboardL( aClipboardFunc );
       
   601     }
       
   602 
       
   603 // ----------------------------------------------------------------------------
       
   604 // CBrowserGotoPane::Editor
       
   605 // ----------------------------------------------------------------------------
       
   606 CEikEdwin* CBrowserGotoPane::Editor() const
       
   607     {
       
   608     return iEditor;
       
   609     }
       
   610 
       
   611 // ----------------------------------------------------------------------------
       
   612 // CBrowserGotoPane::SetGPObserver
       
   613 // ----------------------------------------------------------------------------
       
   614 //
       
   615 void CBrowserGotoPane::SetGPObserver( MGotoPaneObserver* aObserver )
       
   616     {
       
   617     __ASSERT_DEBUG( !iGPObserver, \
       
   618         Util::Panic( Util::EGotoPaneObserverAlreadySet ) );
       
   619     iGPObserver = aObserver;
       
   620     }
       
   621 
       
   622 // ----------------------------------------------------------------------------
       
   623 // CBrowserKeyEventHandled::CBrowserKeyEventHandled
       
   624 // ----------------------------------------------------------------------------
       
   625 //
       
   626 CBrowserKeyEventHandled::CBrowserKeyEventHandled(
       
   627                                     CBrowserGotoPane& aGotoPane ) :
       
   628     iEnabled( EFalse )
       
   629     ,iFirstKeyEvent( ETrue )
       
   630     ,iLeftRightEvent ( EFalse )
       
   631     ,iGotoPane( aGotoPane )
       
   632     {
       
   633     }
       
   634 
       
   635 
       
   636 // ----------------------------------------------------------------------------
       
   637 // CBrowserKeyEventHandled::OfferKeyEventL
       
   638 // ----------------------------------------------------------------------------
       
   639 //
       
   640 TKeyResponse
       
   641     CBrowserKeyEventHandled::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   642                                                 TEventCode aType)
       
   643     {
       
   644     TKeyResponse response( EKeyWasNotConsumed );
       
   645     iLeftRightEvent = EFalse;
       
   646 
       
   647     if ( iEnabled && aType == EEventKey )
       
   648         {
       
   649         switch( aKeyEvent.iCode )
       
   650             {
       
   651             case    EKeyUpArrow:
       
   652             case    EKeyDownArrow:
       
   653                 {
       
   654                 iFirstKeyEvent = EFalse;
       
   655                 break;
       
   656                 }
       
   657 
       
   658             case    EKeyLeftArrow:
       
   659             case    EKeyRightArrow:
       
   660                 {
       
   661                 iFirstKeyEvent = EFalse;
       
   662                 iLeftRightEvent = ETrue;
       
   663 
       
   664                 // Below added to compensate for a weird key event situation:
       
   665                 //   For some reason the CBrowserGotoPane::OfferKeyEventL function
       
   666                 //   is not being called for an EEventKey when you press the left/right
       
   667                 //   arrows in the menupane produced to paste previously used special
       
   668                 //   chars (this is brought up by pressing the pen button on the phone).
       
   669                 //   This only happens when the cursor is in the first or last position in
       
   670                 //   the goto pane with text in it.
       
   671                 //   Therefore, in this particular scenario, we need to process the EEventKey
       
   672                 //   here since we will not be able to in CBrowserGotoPane::OfferKeyEventL
       
   673                 if (CBrowserAppUi::Static()->ContentView()->MenuBar()->MenuPane()->IsFocused())
       
   674                     {
       
   675                     response = CBrowserAppUi::Static()->ContentView()->MenuBar()->MenuPane()->OfferKeyEventL( aKeyEvent, aType );
       
   676                     }
       
   677                 break;
       
   678                 }
       
   679 
       
   680             case    EKeyBackspace:
       
   681             case    EKeyDelete:
       
   682                 {
       
   683                 if ( iFirstKeyEvent )
       
   684                     {
       
   685                     iFirstKeyEvent = EFalse;
       
   686                     iCoeEnv->SimulateKeyEventL( aKeyEvent, aType );
       
   687                     response = EKeyWasConsumed;
       
   688                     }
       
   689                 break;
       
   690                 }
       
   691 
       
   692             default:
       
   693                 {
       
   694                 if ( iFirstKeyEvent )
       
   695                     {
       
   696                     if ( TChar( aKeyEvent.iCode ).IsPrint() )
       
   697                         {
       
   698                         iFirstKeyEvent = EFalse;
       
   699                         response = EKeyWasConsumed;
       
   700                         iCoeEnv->SimulateKeyEventL( aKeyEvent, aType );
       
   701                         }
       
   702                     }
       
   703                 break;
       
   704                 }
       
   705             }
       
   706 //        CBrowserAppUi::Static()->UpdateCbaL();
       
   707         }
       
   708     return response;
       
   709     }
       
   710 
       
   711 // ----------------------------------------------------------------------------
       
   712 // CBrowserKeyEventHandled::HandleEdwinEventL
       
   713 // ----------------------------------------------------------------------------
       
   714 //
       
   715 void CBrowserKeyEventHandled::HandleEdwinEventL( CEikEdwin* /*aEdwin*/,
       
   716                                                     TEdwinEvent aEventType )
       
   717     {
       
   718     // if text changed in the editor we don't have to handle clear key anymore
       
   719     if ( aEventType == EEventTextUpdate )
       
   720         {
       
   721         iFirstKeyEvent = EFalse;
       
   722         }
       
   723     }
       
   724 
       
   725 // ----------------------------------------------------------------------------
       
   726 // CBrowserKeyEventHandled::EnableL
       
   727 // ----------------------------------------------------------------------------
       
   728 //
       
   729 void CBrowserKeyEventHandled::EnableL( TBool aEnable )
       
   730     {
       
   731     iEnabled = aEnable;
       
   732     }
       
   733 
       
   734 // ----------------------------------------------------------------------------
       
   735 // CBrowserKeyEventHandled::Reset
       
   736 // ----------------------------------------------------------------------------
       
   737 //
       
   738 void CBrowserKeyEventHandled::Reset()
       
   739     {
       
   740     iFirstKeyEvent = ETrue;
       
   741     }
       
   742 
       
   743 // ---------------------------------------------------------------------------
       
   744 // CBrowserGotoPane::PopupList
       
   745 // ---------------------------------------------------------------------------
       
   746 //
       
   747 CBrowserAdaptiveListPopup* CBrowserGotoPane::PopupList()
       
   748     {
       
   749     return iBAdaptiveListPopup;
       
   750     }
       
   751 // ---------------------------------------------------------------------------
       
   752 // CBrowserGotoPane::HandleResourceChange
       
   753 // ---------------------------------------------------------------------------
       
   754 //
       
   755 void CBrowserGotoPane::HandleResourceChange(
       
   756                 TInt
       
   757                 aType
       
   758                 )
       
   759     {
       
   760     CCoeControl::HandleResourceChange( aType );
       
   761 
       
   762     if ( iBAdaptiveListPopup )
       
   763         {
       
   764         iBAdaptiveListPopup->HandleResourceChange( aType );
       
   765         }
       
   766     }
       
   767 
       
   768 // ---------------------------------------------------------------------------
       
   769 // CBrowserGotoPane::HandleStartOfTransactionL()
       
   770 // ---------------------------------------------------------------------------
       
   771 //
       
   772 void CBrowserGotoPane::HandleStartOfTransactionL()
       
   773     {
       
   774     }
       
   775 
       
   776 // ---------------------------------------------------------------------------
       
   777 // CBrowserGotoPane::HandleCompletionOfTransactionL()
       
   778 // ---------------------------------------------------------------------------
       
   779 //
       
   780 void CBrowserGotoPane::HandleCompletionOfTransactionL()
       
   781     {
       
   782     if ( iContentView && iFindKeywordMode && this->IsVisible() &&
       
   783         !iContentView->MenuBar()->MenuPane()->IsVisible() )
       
   784         {
       
   785         if ( GetTextL() )
       
   786             {
       
   787             // Find the typed keyword.
       
   788             if ( iHandleFEPFind && iPrevKeyword->Compare(GetTextL()->Des()) )
       
   789                 {
       
   790                 iContentView->FindKeywordL( GetTextL() );
       
   791                 }
       
   792             }
       
   793         }
       
   794     iHandleFEPFind = ETrue;
       
   795     }
       
   796 
       
   797 // ----------------------------------------------------------------------------
       
   798 // CBrowserGotoPane::ActivateVKB
       
   799 // ----------------------------------------------------------------------------
       
   800 void CBrowserGotoPane::ActivateVKB()
       
   801     {
       
   802     if (iEditor && iEditor->TextView())
       
   803         {
       
   804         // make sure observer is set
       
   805         iCoeEnv->SyncNotifyFocusObserversOfChangeInFocus();
       
   806 
       
   807         // simulate pointer event to force VKB
       
   808 
       
   809         // first get point at cursor location
       
   810         TInt pos = iEditor->CursorPos();
       
   811         CTextView* textView = iEditor->TextView();
       
   812         TPoint curPos;
       
   813         textView->DocPosToXyPosL(pos, curPos);
       
   814 
       
   815         TPointerEvent pe;
       
   816         pe.iPosition = curPos;
       
   817 
       
   818         pe.iType = TPointerEvent::EButton1Down;
       
   819         TInt err(KErrNone);
       
   820         TRAP(err, iEditor->HandlePointerEventL(pe));
       
   821         if (err != KErrNone)
       
   822             {
       
   823             return;
       
   824             }
       
   825 
       
   826         // VKB will only activate is nothing selected
       
   827         iEditor->SetSelectionL(pos,pos);
       
   828 
       
   829         pe.iType = TPointerEvent::EButton1Up;
       
   830         if (KErrNone == err)
       
   831            {
       
   832            TRAP_IGNORE(iEditor->HandlePointerEventL(pe));
       
   833            }
       
   834         }
       
   835     }
       
   836 
       
   837 //  END OF FILE