browserui/browser/BrowserAppSrc/BrowserContentViewContainer.cpp
changeset 51 48e827313edd
parent 37 481242ead638
child 53 f427d27b98d8
equal deleted inserted replaced
37:481242ead638 51:48e827313edd
     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 #include "BrowserContentViewContainer.h"
       
    20 #include "BrowserAppUi.h"
       
    21 #include "BrowserAppViewBase.h"
       
    22 #include "BrowserGotoPane.h"
       
    23 #include "CommonConstants.h"
       
    24 #include "BrowserContentView.h"
       
    25 #include "Display.h"
       
    26 #include "Preferences.h"
       
    27 #include "BrowserUtil.h"
       
    28 
       
    29 #include "BrowserPreferences.h"
       
    30 #include "BrowserWindow.h"
       
    31 #include "BrowserWindowManager.h"
       
    32 #include <FeatMgr.h>
       
    33 
       
    34 #include <eikrted.h>
       
    35 #include <eikbctrl.h>
       
    36 #include <Eikmenub.h>
       
    37 
       
    38 #include <aknutils.h>
       
    39 
       
    40 #include "BrowserUIVariant.hrh"
       
    41 
       
    42 #ifdef __SERIES60_HELP
       
    43 // Context-Sensitve Help File
       
    44 #include "BrowserApplication.h"
       
    45 #include <csxhelp/ope.hlp.hrh>
       
    46 #include <csxhelp/browser.hlp.hrh>
       
    47 #endif // __SERIES60_HELP
       
    48 
       
    49 #include "eikon.hrh"
       
    50 
       
    51 
       
    52 //Constant
       
    53 // The interval zoom tooltip is visible, it will disappear after KZoomLevelShowTime seconds
       
    54 const TInt KZoomLevelShowTime( 2 * 1000 ); // 2 seconds
       
    55 
       
    56 //---------------------------------------------------------------------------
       
    57 // CBrowserContentViewContainer::NewL()
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 CBrowserContentViewContainer*
       
    61 CBrowserContentViewContainer::NewL(CBrowserContentView* aView,
       
    62                                    MApiProvider& aApiProvider )
       
    63     {
       
    64     CBrowserContentViewContainer* container =
       
    65         new (ELeave) CBrowserContentViewContainer( aView, aApiProvider );
       
    66     CleanupStack::PushL( container );
       
    67     container->ConstructL();
       
    68     CleanupStack::Pop(); // container
       
    69 
       
    70     return container;
       
    71     }
       
    72 
       
    73 //---------------------------------------------------------------------------
       
    74 // CBrowserContentViewContainer::CBrowserContentViewContainer()
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 CBrowserContentViewContainer::
       
    78 CBrowserContentViewContainer(CBrowserContentView* aView,
       
    79                              MApiProvider& aApiProvider ) :
       
    80     iView( aView ),
       
    81     iApiProvider( aApiProvider )
       
    82     {
       
    83     }
       
    84 
       
    85 //---------------------------------------------------------------------------
       
    86 // CBrowserContentViewContainer::~CBrowserContentViewContainer()
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 CBrowserContentViewContainer::~CBrowserContentViewContainer()
       
    90     {
       
    91     delete iGotoPane;
       
    92     delete iFindKeywordPane;
       
    93     iView = NULL; // Not owned
       
    94 
       
    95     iShortCutFuncMap.Close();
       
    96     }
       
    97 
       
    98 //---------------------------------------------------------------------------
       
    99 // CBrowserContentViewContainer::ConstructL()
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void CBrowserContentViewContainer::ConstructL()
       
   103     {
       
   104     CreateWindowL();
       
   105     SetAllowStrayPointers();
       
   106     SetMopParent( iView );
       
   107 
       
   108     iGotoPane = CBrowserGotoPane::NewL( this,
       
   109                                         EMbmAvkonQgn_indi_find_goto,
       
   110                                         EMbmAvkonQgn_indi_find_goto_mask,
       
   111                                         GOTOPANE_POPUPLIST_ENABLE,
       
   112                                         iView );
       
   113 
       
   114     // Create the find pane with magnifier glass icon, and
       
   115     // without adaptive popup list...
       
   116     iFindKeywordPane = CBrowserGotoPane::NewL( this,
       
   117                                                EMbmAvkonQgn_indi_find_glass,
       
   118                                                EMbmAvkonQgn_indi_find_glass_mask,
       
   119                                                GOTOPANE_POPUPLIST_DISABLE,
       
   120                                                iView,
       
   121                                                ETrue );
       
   122     }
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CBrowserContentViewContainer::HandlePointerEventL
       
   126 // Handles pointer events
       
   127 // -----------------------------------------------------------------------------
       
   128 void CBrowserContentViewContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   129     {
       
   130      switch ( aPointerEvent.iType )
       
   131         {
       
   132         case TPointerEvent::EButton1Down:
       
   133             {
       
   134             // Do nothing
       
   135             break;
       
   136             }
       
   137         case TPointerEvent::EDrag:
       
   138             {
       
   139             // Do nothing
       
   140             break;
       
   141             }
       
   142         case TPointerEvent::EButton1Up:
       
   143             {
       
   144             // Close the zoom silder when the user selects anywhere in the
       
   145             // BrowserContainerView
       
   146             if ( iView->ZoomSliderVisible() )
       
   147                 {
       
   148                 iView->MakeZoomSliderVisibleL( EFalse );
       
   149                 }
       
   150             break;
       
   151             }
       
   152         default:
       
   153             {
       
   154             break;
       
   155             }
       
   156         }   // end of switch
       
   157 
       
   158     // Must pass the pointer event to the CoeControl
       
   159     CCoeControl::HandlePointerEventL( aPointerEvent );
       
   160     }
       
   161 
       
   162 //---------------------------------------------------------------------------
       
   163 // CBrowserContentViewContainer::OfferKeyEventL()
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 TKeyResponse CBrowserContentViewContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
   167     {
       
   168     CBrowserAppUi* ui = CBrowserAppUi::Static();
       
   169     TKeyResponse result( EKeyWasNotConsumed );
       
   170 
       
   171     if (ui->OfferApplicationSpecificKeyEventL(aKeyEvent, aType) == EKeyWasConsumed)
       
   172         {
       
   173         return EKeyWasConsumed;
       
   174         }
       
   175 
       
   176     // For Short Cut
       
   177     if (!iShortCutFuncsReady)
       
   178     {
       
   179         CreateShortCutFuncsHashTable();
       
   180         iShortCutFuncsReady = ETrue;
       
   181     }
       
   182 
       
   183     // Turn off some controls, if we receive events
       
   184     if ( aType == EEventKey )
       
   185         {
       
   186         // Turn off the keymap if on
       
   187         if ( iView->KeymapIsUp() )
       
   188             {
       
   189             iView->HandleCommandL( EWmlCmdHideShortcutKeymap );
       
   190             }
       
   191 
       
   192         // Turn off the zoom slider if on
       
   193         if ( iView->ZoomSliderVisible() )
       
   194             {
       
   195             iView->MakeZoomSliderVisibleL( EFalse );
       
   196             }
       
   197         }
       
   198 
       
   199     // If goto pane is visible, offer key events to it
       
   200     if ( iGotoPane->IsVisible() )
       
   201         {
       
   202         return iGotoPane->OfferKeyEventL( aKeyEvent, aType );
       
   203         }
       
   204 
       
   205     TKeyEvent keyEvent( aKeyEvent );
       
   206     TBrCtlDefs::TBrCtlElementType elementtype =
       
   207         iApiProvider.BrCtlInterface().FocusedElementType();
       
   208 
       
   209     // Don't allow virtual keyboard backspace key event to close the window
       
   210     // And don't close window if editing in an input box or textarea input 
       
   211     if ( !AknLayoutUtils::PenEnabled() && aType == EEventKey
       
   212         && keyEvent.iCode == EKeyBackspace
       
   213         && elementtype != TBrCtlDefs::EElementActivatedInputBox 
       
   214         && elementtype != TBrCtlDefs::EElementTextAreaBox )
       
   215         {
       
   216         if ( iApiProvider.Preferences().UiLocalFeatureSupported(
       
   217                                                     KBrowserMultipleWindows ) )
       
   218             {
       
   219             TInt winCount = iApiProvider.WindowMgr().WindowCount();
       
   220             if ( ( winCount > 1 ) && ( !iView->IsMiniatureViewUp() ) )
       
   221                 {
       
   222                 ui->CloseWindowL();
       
   223                 result = EKeyWasConsumed;
       
   224                 }
       
   225             }
       
   226         }
       
   227 
       
   228     // Handle zooming events
       
   229     // 1. RemConInterface will translate dedicated HW key press to OfferKeyEventL().
       
   230     // See eikon.hrh for mapping.
       
   231     // 2. When the browser is in Zoom Mode (slider or tooltip displayed), the
       
   232     // navi-keys will zoom.
       
   233     if ( aType == EEventKey )
       
   234         {
       
   235         // Handle dedicated HW key zoom-in: if not in zoom mode, HW zoom key takes
       
   236         // zooming immediately without going to zoom mode
       
   237         // if it's already in zoom mode, then HW zoom key acts the same as up
       
   238         // and down navigation key mode
       
   239         // Zoom mode can display tooltip (current) or slider (future)
       
   240         if ( iView->isZoomMode() )
       
   241             {
       
   242             }
       
   243         else if (!iView->IsHistoryViewUp() && !iView->IsMiniatureViewUp())
       
   244             {
       
   245             // Not in zoom mode, or history view, or page overview, and HW zoom key
       
   246             // pressed -  zoom immediately without entering zoom mode.
       
   247             if ( keyEvent.iCode == EKeyZoomIn )
       
   248                 {
       
   249                 iApiProvider.BrCtlInterface().HandleCommandL(
       
   250                         (TInt)TBrCtlDefs::ECommandZoomIn +
       
   251                         (TInt)TBrCtlDefs::ECommandIdBase );
       
   252                 iView->ZoomImagesInL(KZoomLevelShowTime);
       
   253                 result = EKeyWasConsumed;
       
   254                 }
       
   255             // Handle dedicated HW key zoom-out
       
   256             else if ( keyEvent.iCode == EKeyZoomOut )
       
   257                 {
       
   258                 iApiProvider.BrCtlInterface().HandleCommandL(
       
   259                         (TInt)TBrCtlDefs::ECommandZoomOut +
       
   260                         (TInt)TBrCtlDefs::ECommandIdBase );
       
   261                 iView->ZoomImagesOutL(KZoomLevelShowTime);
       
   262                 result = EKeyWasConsumed;
       
   263                 }
       
   264             }
       
   265 
       
   266         }   // End of handling key events for zooming
       
   267 
       
   268     
       
   269     // Web Engine opens the highlighted link into a new window. (long press)
       
   270     // Currently the option is disabled and the link is opened in the same window
       
   271     // The commented part below enables the "Open link in new window" option on long press.
       
   272     // UI change request AHUN-6U3NT4, S60 bug AHUN-6UYT6N
       
   273 
       
   274     TBool aEnterKeyForLinksActivation = (keyEvent.iCode == EKeyEnter) && 
       
   275         (iApiProvider.Preferences().EnterKeyMode() == TBrCtlDefs::EEnterKeyCanActivateLink);
       
   276     if ( aType == EEventKey && 
       
   277          (keyEvent.iCode == EKeyOK || aEnterKeyForLinksActivation) )
       
   278         {
       
   279         if ( keyEvent.iRepeats && iSelectionKeyPressed )
       
   280             {
       
   281 
       
   282             TInt command( KErrNotFound );
       
   283             switch( elementtype )
       
   284                 {
       
   285                 case TBrCtlDefs::EElementAnchor:
       
   286                     {
       
   287     //                command = TBrCtlDefs::ECommandOpenNewWindow;
       
   288                       command = TBrCtlDefs::ECommandOpen;
       
   289                     break;
       
   290                     }
       
   291                 default: break;
       
   292                 }
       
   293     //        if ( command == TBrCtlDefs::ECommandOpenNewWindow &&
       
   294     //          iApiProvider.Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) &&
       
   295     //          !iApiProvider.Preferences().UiLocalFeatureSupported( KBrowserMinimalMultipleWindows ))
       
   296               if ( command == TBrCtlDefs::ECommandOpen)
       
   297                 {
       
   298                 iSelectionKeyPressed = EFalse;
       
   299                 keyEvent.iCode = EKeyNull;
       
   300                 result = EKeyWasConsumed;
       
   301                 iApiProvider.BrCtlInterface().HandleCommandL(
       
   302                     command + TBrCtlDefs::ECommandIdBase );
       
   303                 }
       
   304             }
       
   305         }
       
   306 
       
   307     // stop the event handling when find item was actived
       
   308     if ( (keyEvent.iScanCode == EStdKeyDevice3 || 
       
   309           keyEvent.iScanCode == EStdKeyXXX ||
       
   310           aEnterKeyForLinksActivation)
       
   311         && aType == EEventKeyDown && !iView->FindItemIsInProgress() )
       
   312         {
       
   313         iSelectionKeyPressed = ETrue;
       
   314         keyEvent.iCode = EKeyNull;
       
   315         }
       
   316 
       
   317     // Ignore key event in zoom mode
       
   318     if ( result == EKeyWasNotConsumed && !iView->isZoomMode())
       
   319         {
       
   320         TRAP_IGNORE(result = iApiProvider.BrCtlInterface().OfferKeyEventL(keyEvent, aType));
       
   321         }
       
   322 
       
   323     /**
       
   324     * When checking long or short key presses, iScanCode must be used, because
       
   325     * when EEventKeyUp/EEventKeyUp are handled, the iCode is not available.
       
   326     * iIsKeyLongPressed must be checked in short key presses because, when the
       
   327     * button is released short key code will be called again. And that time it
       
   328     * must be ignored.
       
   329     */
       
   330 
       
   331     /**
       
   332     // This key is inactive, only for testing short / long key presses.
       
   333     if ( keyEvent.iScanCode == 48 && keyEvent.iRepeats && !iIsKeyLongPressed)
       
   334         {
       
   335         iEikonEnv->InfoMsg(_L("0 Long"));
       
   336         iIsKeyLongPressed = ETrue;
       
   337         keyEvent.iCode = EKeyNull;
       
   338         result = EKeyWasConsumed;
       
   339         }
       
   340     if ( aType == EEventKeyUp && keyEvent.iScanCode == 48 && !keyEvent.iRepeats)
       
   341         {
       
   342         if ( !iIsKeyLongPressed )
       
   343             {
       
   344             iEikonEnv->InfoMsg(_L("0 Short"));
       
   345             keyEvent.iCode = EKeyNull;
       
   346             result = EKeyWasConsumed;
       
   347             }
       
   348         iIsKeyLongPressed = EFalse;
       
   349         }
       
   350     **/
       
   351 
       
   352     /*
       
   353     * Not processing short keys, if the History view, or the
       
   354     * Miniature View ( old name: Thumbnail View ) is up,
       
   355     * except short key: '8'.
       
   356     */
       
   357     if (!iApiProvider.Preferences().AccessKeys())
       
   358     {
       
   359         // Key short press, activate function based on keyEvent.iCode
       
   360         if ( aType == EEventKey && result == EKeyWasNotConsumed )
       
   361             {
       
   362             if (!AknLayoutUtils::PenEnabled())
       
   363                 {
       
   364                 if (iView->isZoomMode())
       
   365                     {
       
   366                     result = EKeyWasConsumed;
       
   367                     }
       
   368                 else
       
   369                     {
       
   370                     if (iApiProvider.Preferences().ShortcutKeysForQwerty())
       
   371                         {
       
   372                         result = InvokeFunction ( keyEvent.iCode );
       
   373                         }
       
   374                     else
       
   375                         {
       
   376                         if ( !iView->IsMiniatureViewUp() && !iView->IsHistoryViewUp() )
       
   377                             {
       
   378                             TInt function = -1;
       
   379                             switch(keyEvent.iCode)
       
   380                                 {
       
   381                                 case '0':
       
   382                                     {
       
   383                                     function = ShortcutsCommandDecodeMatrix[iApiProvider.Preferences().ShortcutKey0Cmd()][KShortcutsCommandDecodeMatrixCmdVal];
       
   384                                     break;
       
   385                                     }
       
   386                                 case '1':
       
   387                                     {
       
   388                                     function = ShortcutsCommandDecodeMatrix[iApiProvider.Preferences().ShortcutKey1Cmd()][KShortcutsCommandDecodeMatrixCmdVal];
       
   389                                     break;
       
   390                                     }
       
   391                                 case '2':
       
   392                                     {
       
   393                                     function = ShortcutsCommandDecodeMatrix[iApiProvider.Preferences().ShortcutKey2Cmd()][KShortcutsCommandDecodeMatrixCmdVal];
       
   394                                     break;
       
   395                                     }
       
   396                                 case '3':
       
   397                                     {
       
   398                                     function = ShortcutsCommandDecodeMatrix[iApiProvider.Preferences().ShortcutKey3Cmd()][KShortcutsCommandDecodeMatrixCmdVal];
       
   399                                     break;
       
   400                                     }
       
   401                                 case '4':
       
   402                                     {
       
   403                                     function = ShortcutsCommandDecodeMatrix[iApiProvider.Preferences().ShortcutKey4Cmd()][KShortcutsCommandDecodeMatrixCmdVal];
       
   404                                     break;
       
   405                                     }
       
   406                                 case '5':
       
   407                                     {
       
   408                                     function = ShortcutsCommandDecodeMatrix[iApiProvider.Preferences().ShortcutKey5Cmd()][KShortcutsCommandDecodeMatrixCmdVal];
       
   409                                     break;
       
   410                                     }
       
   411                                 case '6':
       
   412                                     {
       
   413                                     function = ShortcutsCommandDecodeMatrix[iApiProvider.Preferences().ShortcutKey6Cmd()][KShortcutsCommandDecodeMatrixCmdVal];
       
   414                                     break;
       
   415                                     }
       
   416                                 case '7':
       
   417                                     {
       
   418                                     function = ShortcutsCommandDecodeMatrix[iApiProvider.Preferences().ShortcutKey7Cmd()][KShortcutsCommandDecodeMatrixCmdVal];
       
   419                                     break;
       
   420                                     }
       
   421                                 case '8':
       
   422                                     {
       
   423                                     function = ShortcutsCommandDecodeMatrix[iApiProvider.Preferences().ShortcutKey8Cmd()][KShortcutsCommandDecodeMatrixCmdVal];
       
   424                                     break;
       
   425                                     }
       
   426                                 case '9':
       
   427                                     {
       
   428                                     function = ShortcutsCommandDecodeMatrix[iApiProvider.Preferences().ShortcutKey9Cmd()][KShortcutsCommandDecodeMatrixCmdVal];
       
   429                                     break;
       
   430                                     }
       
   431                                 case '*':
       
   432                                     {
       
   433                                     function = ShortcutsCommandDecodeMatrix[iApiProvider.Preferences().ShortcutKeyStarCmd()][KShortcutsCommandDecodeMatrixCmdVal];
       
   434                                     break;
       
   435                                     }
       
   436                                 case '#':
       
   437                                     {
       
   438                                     function = ShortcutsCommandDecodeMatrix[iApiProvider.Preferences().ShortcutKeyHashCmd()][KShortcutsCommandDecodeMatrixCmdVal];
       
   439                                     break;
       
   440                                     }
       
   441                                 default:
       
   442                                     {
       
   443                                     break;
       
   444                                     }
       
   445                                 }
       
   446 
       
   447                             if (function != -1)
       
   448                                 {
       
   449                                 iView->HandleCommandL(function);
       
   450                                 result = EKeyWasConsumed;
       
   451                                 }
       
   452                             }
       
   453                         } //endof handle shortcut keys
       
   454 
       
   455                     if (result == EKeyWasConsumed)
       
   456                         {
       
   457                             keyEvent.iCode = EKeyNull;
       
   458                         }
       
   459                     }
       
   460                 }
       
   461             }
       
   462 
       
   463             if ( iView->IsHistoryViewUp() && result == EKeyWasConsumed )
       
   464                 {
       
   465                 if (    ( aType == EEventKey || aType == EEventKeyUp )
       
   466                      && (    keyEvent.iCode == EKeyLeftUpArrow       // Northwest
       
   467                           || keyEvent.iCode == EStdKeyDevice10       //   : Extra KeyEvent supports diagonal event simulator wedge
       
   468                           || keyEvent.iCode == EKeyLeftArrow         // West
       
   469                           || keyEvent.iCode == EKeyLeftDownArrow     // Southwest
       
   470                           || keyEvent.iCode == EStdKeyDevice13       //   : Extra KeyEvent supports diagonal event simulator wedge
       
   471 
       
   472                           || keyEvent.iCode == EKeyRightUpArrow      // Northeast
       
   473                           || keyEvent.iCode == EStdKeyDevice11       //   : Extra KeyEvent supports diagonal event simulator wedge
       
   474                           || keyEvent.iCode == EKeyRightArrow        // East
       
   475                           || keyEvent.iCode == EKeyRightDownArrow    // Southeast
       
   476                           || keyEvent.iCode == EStdKeyDevice12 ) )   //   : Extra KeyEvent supports diagonal event simulator wedge
       
   477                     {
       
   478                     iView->UpdateTitleL( iApiProvider );
       
   479                     }
       
   480                 }
       
   481 
       
   482             // If in zoom mode, then show the zoom tooltip
       
   483             if (iView->isZoomMode() && result == EKeyWasConsumed )
       
   484                 {
       
   485                 iView->SetZoomLevelTitleTextL(R_BROWSER_ZOOM_LEVEL);
       
   486                 }
       
   487 
       
   488         }   // if (!iApiProvider.Preferences().AccessKeys())
       
   489 
       
   490     if ( result == EKeyWasNotConsumed &&
       
   491          (keyEvent.iScanCode == EStdKeyDevice3 || keyEvent.iScanCode == EStdKeyXXX) &&
       
   492          aType == EEventKeyUp  &&
       
   493          iSelectionKeyPressed )
       
   494         {
       
   495         // Selection key was released and it is not a long press!
       
   496         iSelectionKeyPressed = EFalse;
       
   497         aType = EEventKey;
       
   498         keyEvent.iCode = EKeyOK;
       
   499 
       
   500         // first offer event to browser control, e.g. link activation
       
   501         // result = iApiProvider.BrCtlInterface().OfferKeyEventL(keyEvent, aType);
       
   502 
       
   503         iView->ResetPreviousViewFlag();
       
   504         }
       
   505     return result;
       
   506     }
       
   507 
       
   508 //---------------------------------------------------------------------------
       
   509 // CBrowserContentViewContainer::FocusChanged()
       
   510 // ---------------------------------------------------------------------------
       
   511 //
       
   512 void CBrowserContentViewContainer::FocusChanged(TDrawNow aDrawNow)
       
   513     {
       
   514     // do not proceed further if a browser app exit is in progress
       
   515     if ( iApiProvider.ExitInProgress() )
       
   516         {
       
   517         return;
       
   518         }
       
   519 
       
   520     if ( iApiProvider.StartedUp() )
       
   521         iApiProvider.BrCtlInterface().SetFocus(IsFocused());
       
   522     if ( iGotoPane->IsVisible() )
       
   523         {
       
   524         TRAP_IGNORE(iGotoPane->EnableKeyEventHandlerL( IsFocused() ));
       
   525         }
       
   526 
       
   527     CCoeControl::FocusChanged( aDrawNow );
       
   528     }
       
   529 
       
   530 //---------------------------------------------------------------------------
       
   531 // CBrowserContentViewContainer::SizeChanged()
       
   532 // ---------------------------------------------------------------------------
       
   533 //
       
   534 void CBrowserContentViewContainer::SizeChanged()
       
   535     {
       
   536     // BrCtl could be uninitialized
       
   537     if ( iApiProvider.StartedUp() )
       
   538         {
       
   539         if(iApiProvider.LastActiveViewId() != KUidBrowserFeedsFeedViewId)
       
   540             {
       
   541             const TRect& oldRect = iApiProvider.BrCtlInterface().Rect();
       
   542             iApiProvider.BrCtlInterface().SetRect( TRect( oldRect.iTl, Size() ) );
       
   543             }
       
   544         }
       
   545 
       
   546     if ( iFindKeywordPane->IsFocused() )
       
   547         {
       
   548         iFindKeywordPane->HandleFindSizeChanged();
       
   549         }
       
   550     else
       
   551         {
       
   552         iGotoPane->HandleFindSizeChanged();
       
   553         }
       
   554 
       
   555     }
       
   556 
       
   557 //---------------------------------------------------------------------------
       
   558 // CBrowserContentViewContainer::CountComponentControls()
       
   559 // ---------------------------------------------------------------------------
       
   560 //
       
   561 TInt CBrowserContentViewContainer::CountComponentControls() const
       
   562     {
       
   563     TInt ctrls = 0;
       
   564     ctrls++;        // iGotoPane
       
   565     if ( iApiProvider.StartedUp() )
       
   566         {
       
   567         ctrls++;
       
   568         }
       
   569     ctrls++;        // iFindKeywordPane
       
   570     return ctrls;
       
   571     }
       
   572 
       
   573 //---------------------------------------------------------------------------
       
   574 // CBrowserContentViewContainer::ComponentControl()
       
   575 // ---------------------------------------------------------------------------
       
   576 //
       
   577 CCoeControl* CBrowserContentViewContainer::ComponentControl( TInt aIndex ) const
       
   578     {
       
   579     CCoeControl *ctrl = NULL;
       
   580     switch( aIndex )
       
   581         {
       
   582         case 0:
       
   583             {
       
   584             ctrl = iGotoPane;
       
   585             break;
       
   586             }
       
   587         case 1:
       
   588             {
       
   589             if ( iApiProvider.StartedUp() )
       
   590                 ctrl = &(iApiProvider.BrCtlInterface());
       
   591             break;
       
   592             }
       
   593         case 2:
       
   594             {
       
   595             ctrl = iFindKeywordPane;
       
   596             break;
       
   597             }
       
   598 
       
   599         default:
       
   600             break;
       
   601         }
       
   602     return ctrl;
       
   603     }
       
   604 
       
   605 //---------------------------------------------------------------------------
       
   606 // CBrowserContentViewContainer::ShutDownGotoURLEditorL()
       
   607 // ---------------------------------------------------------------------------
       
   608 //
       
   609 void CBrowserContentViewContainer::ShutDownGotoURLEditorL()
       
   610     {
       
   611     iGotoPane->MakeVisible( EFalse );
       
   612     iGotoPane->SetFocus( EFalse );
       
   613     SetFocus( ETrue );
       
   614     }
       
   615 
       
   616 
       
   617 //---------------------------------------------------------------------------
       
   618 // CBrowserContentViewContainer::ShutDownFindKeywordEditorL()
       
   619 // ---------------------------------------------------------------------------
       
   620 //
       
   621 void CBrowserContentViewContainer::ShutDownFindKeywordEditorL()
       
   622     {
       
   623     iFindKeywordPane->MakeVisible( EFalse );
       
   624     iFindKeywordPane->SetFocus( EFalse );
       
   625     SetFocus( ETrue );
       
   626     }
       
   627 
       
   628 
       
   629 //---------------------------------------------------------------------------
       
   630 // CBrowserContentViewContainer::HandleResourceChange()
       
   631 // ---------------------------------------------------------------------------
       
   632 //
       
   633 void CBrowserContentViewContainer::HandleResourceChange(TInt aType)
       
   634     {
       
   635     CCoeControl::HandleResourceChange( aType );
       
   636     if ( aType == KEikDynamicLayoutVariantSwitch)
       
   637         {
       
   638         if (!iView->FindItemIsInProgress())
       
   639             {
       
   640             iView->UpdateFullScreenL();
       
   641             iApiProvider.Display().RestoreTitleL();
       
   642             }
       
   643 
       
   644         SetRect(iView->ClientRect());
       
   645         
       
   646         if( iApiProvider.Preferences().SearchFeature() )
       
   647           {
       
   648           iGotoPane->SetTextModeItalicL();
       
   649           // To Avoid Flickring, only when layout changed. 
       
   650           iGotoPane->DrawNow();
       
   651           }
       
   652         
       
   653         DrawDeferred();
       
   654 
       
   655         // For Touch only-If find pane open, force toolbar to show since avkon disables
       
   656         // touch toolbar whenever a dialog is open and a rotate event is handled.
       
   657         // ** This workaround was provided by Avkon toolbar group
       
   658         if ( AknLayoutUtils::PenEnabled() &&
       
   659              iFindKeywordPane->IsVisible() &&
       
   660              iView->Toolbar() )
       
   661             {
       
   662             iView->Toolbar()->DrawableWindow()->SetOrdinalPosition( 0 );
       
   663             }
       
   664         }
       
   665     }
       
   666 
       
   667 
       
   668 //---------------------------------------------------------------------------
       
   669 // CBrowserContentViewContainer::CreateShortCutFuncsHashTable()
       
   670 // ---------------------------------------------------------------------------
       
   671 //
       
   672 void CBrowserContentViewContainer::CreateShortCutFuncsHashTable()
       
   673     {
       
   674     InsertFuncToHashTable(iApiProvider.Preferences().ShortCutFuncHomePg(), EWmlSettingsShortCutsActivateHomepage);
       
   675     InsertFuncToHashTable(iApiProvider.Preferences().ShortCutFuncBkMark(), EWmlSettingsShortCutsActivateBkmkview);
       
   676     InsertFuncToHashTable(iApiProvider.Preferences().ShortCutFuncFindKeyWord(), EWmlSettingsShortCutsShowFindKeyword);
       
   677     InsertFuncToHashTable(iApiProvider.Preferences().ShortCutFuncPrePage(), EWmlSettingsShortCutsGotoPreviousPage);
       
   678     InsertFuncToHashTable(iApiProvider.Preferences().ShortCutFuncSwitchWin(), EWmlSettingsShortCutsShowSwitchWindowList);
       
   679     InsertFuncToHashTable(iApiProvider.Preferences().ShortCutFuncMiniImage(), EWmlSettingsShortCutsShowMiniature);
       
   680     InsertFuncToHashTable(iApiProvider.Preferences().ShortCutFuncFullScreen(), EWmlSettingsShortCutsShowFullScreen);
       
   681     InsertFuncToHashTable(iApiProvider.Preferences().ShortCutFuncGoAddr(), EWmlSettingsShortCutsGotoPane);
       
   682     InsertFuncToHashTable(iApiProvider.Preferences().ShortCutFuncZoomIn(), EWmlSettingsShortCutsZoomIn);
       
   683     InsertFuncToHashTable(iApiProvider.Preferences().ShortCutFuncZoomOut(), EWmlSettingsShortCutsZoomOut);
       
   684     // InsertFuncToHashTable(iApiProvider.Preferences().ShortCutFuncZoomMode(), EWmlSettingsShortCutsZoomMode);
       
   685     }
       
   686 
       
   687 //---------------------------------------------------------------------------
       
   688 // CBrowserContentViewContainer::InsertFuncToHashTable()
       
   689 // ---------------------------------------------------------------------------
       
   690 //
       
   691 void CBrowserContentViewContainer::InsertFuncToHashTable(HBufC* aKeyStr, TInt aFunc)
       
   692     {
       
   693 
       
   694     __ASSERT_DEBUG( (aKeyStr != NULL), Util::Panic( Util::EUninitializedData ));
       
   695 
       
   696         if (aKeyStr->Length() == 0)
       
   697         {
       
   698             return;
       
   699         }
       
   700 
       
   701         TBuf<4> key1Str; //  Ex.: 0075
       
   702         TBuf<4> key2Str; //  Ex.: 0032
       
   703 
       
   704         // Get the position of the separator ',' character from '0075, 0032'.
       
   705         TInt pos = aKeyStr->LocateF( ',' );
       
   706         if ( ( pos != KErrNotFound ) )
       
   707         {    //we have two string
       
   708             // Extract the first unicode string
       
   709             key1Str.Copy( aKeyStr->Des().Left( pos ) );
       
   710             TUint key1 = MyAtoi(key1Str);
       
   711 
       
   712             // Extract the second unicode string; second "-1" below is for remove space
       
   713             key2Str.Copy( aKeyStr->Des().Right( aKeyStr->Des().Length() - pos - 1 -1) );
       
   714             TUint key2 = MyAtoi(key2Str);
       
   715 
       
   716             // insert key and function
       
   717             iShortCutFuncMap.Insert(key1, aFunc);
       
   718             iShortCutFuncMap.Insert(key2, aFunc);
       
   719         }
       
   720         else
       
   721         {    //we only have one string
       
   722             // Extract the first unicode string
       
   723             key1Str.Copy( aKeyStr->Des() );
       
   724             TUint key1 = MyAtoi(key1Str);
       
   725             // insert key and function
       
   726             iShortCutFuncMap.Insert(key1, aFunc);
       
   727         }
       
   728     }
       
   729 
       
   730 //---------------------------------------------------------------------------
       
   731 // CBrowserContentViewContainer::MyAtoi()
       
   732 // ---------------------------------------------------------------------------
       
   733 //
       
   734 TUint CBrowserContentViewContainer::MyAtoi(TPtrC aData)
       
   735     {
       
   736         TLex lex(aData);
       
   737         TUint dataValue = 0;
       
   738         lex.Val(dataValue, EHex);
       
   739         return dataValue;
       
   740     }
       
   741 
       
   742 //---------------------------------------------------------------------------
       
   743 // CBrowserContentViewContainer::InvokeFunction()
       
   744 // ---------------------------------------------------------------------------
       
   745 //
       
   746 TKeyResponse CBrowserContentViewContainer::InvokeFunction(TUint aCode)
       
   747     {
       
   748     TInt function = -1;
       
   749     // if error, no function defined for this shortcut key
       
   750     TRAPD( err, function = iShortCutFuncMap.FindL(aCode) );
       
   751     if ( err != KErrNone )
       
   752         {
       
   753             return EKeyWasNotConsumed;
       
   754         }
       
   755 
       
   756     TBool embedded = iApiProvider.IsEmbeddedModeOn();
       
   757 
       
   758     if ( !iView->IsMiniatureViewUp() && !iView->IsHistoryViewUp() )
       
   759     {
       
   760         CBrowserAppUi* ui = CBrowserAppUi::Static();
       
   761 
       
   762         switch(function)
       
   763             {
       
   764             case EWmlSettingsShortCutsActivateHomepage:
       
   765                 {
       
   766                 TBool homepage = iApiProvider.Preferences().UiLocalFeatureSupported( KBrowserUiHomePageSetting );
       
   767                 // home page
       
   768                 if ( homepage )
       
   769                     {
       
   770                     //
       
   771                     TWmlSettingsHomePage pgtype = iApiProvider.Preferences().HomePageType();
       
   772 
       
   773                     if ( !(embedded || pgtype == EWmlSettingsHomePageBookmarks) )
       
   774                         {
       
   775                         ui->LaunchHomePageL();
       
   776                         }
       
   777                     else
       
   778                         {
       
   779                         if ( pgtype == EWmlSettingsHomePageBookmarks )
       
   780                             {
       
   781                             iApiProvider.SetViewToBeActivatedIfNeededL( KUidBrowserBookmarksViewId );
       
   782                             }
       
   783                         }
       
   784                     }
       
   785                 return EKeyWasConsumed;
       
   786                 }
       
   787             case EWmlSettingsShortCutsActivateBkmkview:
       
   788                 {
       
   789                 if ( !embedded )
       
   790                 {
       
   791                     iApiProvider.SetViewToBeActivatedIfNeededL( KUidBrowserBookmarksViewId );
       
   792                 }
       
   793                 return EKeyWasConsumed;
       
   794                 }
       
   795             case EWmlSettingsShortCutsGotoPane:
       
   796                 {
       
   797                 iView->LaunchGotoAddressEditorL();
       
   798                 iView->MenuBar()->MenuPane()->MakeVisible(EFalse);
       
   799                 return EKeyWasConsumed;
       
   800                 }
       
   801             case EWmlSettingsShortCutsShowFindKeyword:
       
   802                 {
       
   803                 if (!iView->ApiProvider().WindowMgr().CurrentWindow()->HasWMLContent(ETrue /* is current page wml?*/))
       
   804                     {
       
   805                     iView->LaunchFindKeywordEditorL();
       
   806                     iView->MenuBar()->MenuPane()->MakeVisible(EFalse);
       
   807                     }
       
   808                 return EKeyWasConsumed;
       
   809                 }
       
   810             case EWmlSettingsShortCutsShowSwitchWindowList:
       
   811                 {
       
   812                 if (!iView->ApiProvider().WindowMgr().CurrentWindow()->HasWMLContent(EFalse /*is any page wml?*/))
       
   813                     {
       
   814                     if (iApiProvider.Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) &&
       
   815                         !iApiProvider.Preferences().UiLocalFeatureSupported( KBrowserMinimalMultipleWindows ) &&
       
   816                         iApiProvider.WindowMgr().WindowCount() > 1)
       
   817                         {
       
   818                         iApiProvider.SetViewToBeActivatedIfNeededL( KUidBrowserWindowSelectionViewId );
       
   819                         }
       
   820                     else
       
   821                         {
       
   822                         if (iApiProvider.WindowMgr().WindowCount() > 1)
       
   823                             {
       
   824                             ui->SwitchWindowL();
       
   825                             }
       
   826                         }
       
   827                     }
       
   828                 return EKeyWasConsumed;
       
   829                 }
       
   830 
       
   831             case EWmlSettingsShortCutsZoomOut:
       
   832                 {
       
   833                 iView->ZoomImagesOutL();
       
   834                 return EKeyWasConsumed;
       
   835                 }
       
   836 
       
   837             case EWmlSettingsShortCutsZoomIn:
       
   838                 {
       
   839                 iView->ZoomImagesInL();
       
   840                 return EKeyWasConsumed;
       
   841                 }
       
   842 
       
   843             case EWmlSettingsShortCutsGotoPreviousPage:
       
   844                 {
       
   845                 if ( iApiProvider.BrCtlInterface().NavigationAvailable( TBrCtlDefs::ENavigationBack ) )
       
   846                     {
       
   847                         iApiProvider.LoadObserver().DoStartLoad( CBrowserLoadObserver::ELoadUrlTypeOther );
       
   848                         iApiProvider.BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandOneStepBack +
       
   849                                                             (TInt)TBrCtlDefs::ECommandIdBase );
       
   850                     }
       
   851                 return EKeyWasConsumed;
       
   852                 }
       
   853 
       
   854             case EWmlSettingsShortCutsShowFullScreen:
       
   855                 {
       
   856                 iView->HandleCommandL(EWmlCmdEnterFullScreenBrowsing);
       
   857                 return EKeyWasConsumed;
       
   858                 }
       
   859           }
       
   860     } // END if ( !iView->IsMiniatureViewUp() && !iView->IsHistoryViewUp() && !iView->isZoomMode())
       
   861 
       
   862 
       
   863     if ( function == EWmlSettingsShortCutsShowMiniature && !iView->IsHistoryViewUp() )
       
   864         {   // Process short key '8' only if History view is not shown.
       
   865             if (!iView->ApiProvider().WindowMgr().CurrentWindow()->HasWMLContent(ETrue /* is current page wml?*/))
       
   866                 {
       
   867                 iApiProvider.BrCtlInterface().HandleCommandL(
       
   868                         (TInt)TBrCtlDefs::ECommandShowThumbnailView + (TInt)TBrCtlDefs::ECommandIdBase );
       
   869                 }
       
   870             return EKeyWasConsumed;
       
   871         }
       
   872 
       
   873     return EKeyWasNotConsumed;
       
   874    }
       
   875 
       
   876 
       
   877 
       
   878 #ifdef __SERIES60_HELP
       
   879 // ---------------------------------------------------------
       
   880 // CBrowserContentViewContainer::GetHelpContext()
       
   881 // ---------------------------------------------------------
       
   882 //
       
   883 void CBrowserContentViewContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   884     {
       
   885     const TUid KUidOperatorMenuApp = { 0x10008D5E };
       
   886     aContext.iMajor = KUidBrowserApplication;
       
   887     if ( iApiProvider.IsEmbeddedModeOn() )
       
   888         {
       
   889         if ( CBrowserAppUi::Static()->IsEmbeddedInOperatorMenu() )
       
   890             {
       
   891             aContext.iMajor = KUidOperatorMenuApp;
       
   892             aContext.iContext = KOPERATOR_HLP_OPTIONS_LIST;
       
   893             }
       
   894         else
       
   895             {
       
   896             aContext.iContext = KOSS_HLP_PAGEVIEW_EMBED;
       
   897             }
       
   898 
       
   899         }
       
   900     else
       
   901         {
       
   902         aContext.iContext = KOSS_HLP_PAGEVIEW;
       
   903         }
       
   904     }
       
   905 
       
   906 #endif // __SERIES60_HELP
       
   907 
       
   908 // End of File