browserui/browser/FavouritesSrc/BrowserAdaptiveListPopup.cpp
changeset 51 48e827313edd
parent 37 481242ead638
child 53 f427d27b98d8
equal deleted inserted replaced
37:481242ead638 51:48e827313edd
     1 /*
       
     2 * Copyright (c) 2002-2006 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 *       Implementation of CBrowserPopupList and CBrowserAdaptiveListPopup
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32std.h>
       
    22 #include <AknPopup.h>
       
    23 #include <AknListQueryDialog.h>
       
    24 #include <AknIconArray.h>
       
    25 #include <recenturlstore.h>
       
    26 #include <AknsUtils.h>
       
    27 #include <AknsListBoxBackgroundControlContext.h>
       
    28 #include <AppApacLayout.cdl.h>
       
    29 #include <AppLayout.cdl.h>
       
    30 #include <AknLayout.cdl.h>
       
    31 #include <SkinLayout.cdl.h>
       
    32 #include <AknLayout2ScalableDef.h>
       
    33 #include <AknLayoutScalable_Avkon.cdl.h>
       
    34 #include <AknLayoutScalable_Apps.cdl.h>
       
    35 #include <LayoutMetaData.cdl.h>
       
    36 #include <AknEnv.h>
       
    37 #include <aknsdrawutils.h>
       
    38 #include <browser.mbg>
       
    39 #include "BrowserContentView.h"
       
    40 #include "BrowserAdaptiveListPopup.h"
       
    41 #include "BrowserAppUi.h"
       
    42 #include "CommonConstants.h"
       
    43 #include "BrowserAppViewBase.h"
       
    44 #include <data_caging_path_literals.hrh>
       
    45 
       
    46 #include "eikon.hrh"
       
    47 
       
    48 // CONSTANTS
       
    49 const TInt KMaxIcons = 2;
       
    50 const TInt KListLengthToShow = 64;//the length of the string in the list
       
    51 _LIT( KItemTab, "1\t");//prefix for items
       
    52 _LIT( KDirTab, "0\t");//prefix for directories
       
    53 const TInt KArrayGranularity = 10;
       
    54 _LIT( KProtocolIdentifier,"://" );
       
    55 const TUint KSlash('/');
       
    56 const TUint KPeriod('.');
       
    57 
       
    58 static void TextPos(TPoint *aResultArray, const TAknTextLineLayout
       
    59 &aLayout, TSize aItemSize)
       
    60     {
       
    61     TRect itemRect(TPoint(0,0), aItemSize);
       
    62     TAknLayoutText textLayout;
       
    63     textLayout.LayoutText(itemRect, aLayout);
       
    64     aResultArray[0] = textLayout.TextRect().iTl;
       
    65     aResultArray[1] = textLayout.TextRect().iTl +
       
    66 textLayout.TextRect().Size();
       
    67     }
       
    68 
       
    69 static void GfxPos(TPoint *aResultArray, const TAknWindowLineLayout
       
    70 &aLayout, TSize aItemSize)
       
    71     {
       
    72     TRect itemRect(TPoint(0,0), aItemSize);
       
    73     TAknLayoutRect layout;
       
    74     layout.LayoutRect(itemRect, aLayout);
       
    75     aResultArray[0] = layout.Rect().iTl;
       
    76     aResultArray[1] = layout.Rect().iTl + layout.Rect().Size();
       
    77     }
       
    78 
       
    79 TSize ListBoxItemSize(CEikListBox &aListBox, CFormattedCellListBoxItemDrawer *aItemDrawer)
       
    80     {
       
    81     TSize size = TSize( aItemDrawer->LafItemSize().iWidth, aListBox.View()->ItemSize().iHeight );
       
    82     return size;
       
    83     }
       
    84 
       
    85 // ================= MEMBER FUNCTIONS =======================
       
    86 
       
    87 // ---------------------------------------------------------
       
    88 // CBrowserPopupList::CBrowserPopupList()
       
    89 //
       
    90 // ---------------------------------------------------------
       
    91 //
       
    92 CBrowserPopupList::CBrowserPopupList(TParentType aParentType):CAknSingleGraphicPopupMenuStyleListBox()
       
    93     {
       
    94     iParentType = aParentType;
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------
       
    98 // CBrowserPopupList::~CBrowserPopupList()
       
    99 //
       
   100 // ---------------------------------------------------------
       
   101 //
       
   102 CBrowserPopupList::~CBrowserPopupList()
       
   103     {
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------
       
   107 // CBrowserPopupList::ConstructL
       
   108 //
       
   109 // ---------------------------------------------------------
       
   110 //
       
   111 void CBrowserPopupList::ConstructL(const CCoeControl* aParent, TInt aFlags)
       
   112     {
       
   113     CAknSingleGraphicPopupMenuStyleListBox::ConstructL( aParent, aFlags);
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------
       
   117 // CBrowserPopupList::SetHighLight
       
   118 // Sets the highlight of the list
       
   119 // ---------------------------------------------------------
       
   120 //
       
   121 void CBrowserPopupList::SetHighLight(TBool aHighLight)
       
   122     {
       
   123 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF
       
   124     iItemDrawer->SetFlags( CListItemDrawer::ESingleClickEnabled );
       
   125 #endif    
       
   126     iListBoxFlags = ( aHighLight ?  iListBoxFlags &~ CEikListBox::EDisableHighlight : iListBoxFlags | CEikListBox::EDisableHighlight );
       
   127     if ( aHighLight )
       
   128         {
       
   129         iItemDrawer->ClearFlags( CListItemDrawer::EDisableHighlight );
       
   130         }
       
   131     else
       
   132         {
       
   133         iItemDrawer->SetFlags( CListItemDrawer::EDisableHighlight );
       
   134         }
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------
       
   138 // CBrowserPopupList::HighLightEnabled()
       
   139 // Enables the highlight in the list
       
   140 // ---------------------------------------------------------
       
   141 //
       
   142 TBool CBrowserPopupList::HighLightEnabled()
       
   143     {
       
   144     return !( iItemDrawer->Flags() & CListItemDrawer::EDisableHighlight );
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------
       
   148 // CBrowserPopupList::SizeChanged()
       
   149 // sets the inner layout
       
   150 // ---------------------------------------------------------
       
   151 //
       
   152 void CBrowserPopupList::SizeChanged()
       
   153     {
       
   154     CAknSingleGraphicPopupMenuStyleListBox::SizeChanged();
       
   155     TAknWindowLineLayout windowLineLayout;
       
   156     TAknWindowLineLayout windowLineLayoutTmp;
       
   157     TAknWindowLineLayout windowLineLayoutTmp2;
       
   158     TAknLayoutRect layoutRect;
       
   159     TPoint area[2] ;
       
   160     TRgb color;
       
   161     CEikFormattedCellListBox &aListBox = *this;
       
   162     CFormattedCellListBoxItemDrawer *itemDrawer = aListBox.ItemDrawer();
       
   163     AknListBoxLayouts::SetupStandardListBox(aListBox);
       
   164 
       
   165     AknListBoxLayouts::SetupListboxPos( aListBox, AppLayout::list_single_graphic_popup_wml_pane( 0 ));
       
   166 
       
   167     GfxPos(area,
       
   168     AknLayoutScalable_Apps::list_single_graphic_popup_wml_pane_g1(),
       
   169     ListBoxItemSize(*this, ItemDrawer()) );
       
   170 
       
   171     AknListBoxLayouts::SetupFormGfxCell(aListBox,
       
   172                                         itemDrawer,
       
   173                                         0,
       
   174                                         AknLayoutScalable_Apps::list_single_graphic_popup_wml_pane_g2(),
       
   175                                         area[0],
       
   176                                         area[1]);
       
   177 
       
   178     //sets the rectangle of the text
       
   179     TextPos(area,
       
   180     AknLayoutScalable_Apps::list_single_graphic_popup_wml_pane_t1( ),
       
   181     ListBoxItemSize(*this, ItemDrawer()) );
       
   182     AknListBoxLayouts::SetupFormAntiFlickerTextCell(aListBox,
       
   183                                                     itemDrawer,
       
   184                                                     1,
       
   185                                                     AknLayoutScalable_Apps::list_single_graphic_popup_wml_pane_t1( ),
       
   186                                                     area[0],
       
   187                                                     area[1]);
       
   188     }
       
   189 
       
   190 // ---------------------------------------------------------
       
   191 // CBrowserPopupList::Draw()
       
   192 // ---------------------------------------------------------
       
   193 //
       
   194 void CBrowserPopupList::Draw(const TRect& /*aRect*/) const
       
   195     {
       
   196     TRect windowRect = this->Rect();
       
   197     CEikFormattedCellListBox::Draw( windowRect );
       
   198     return;
       
   199     }
       
   200 
       
   201 
       
   202 // ================= CBrowserAdaptiveListPopup =======================
       
   203 
       
   204 
       
   205 // ---------------------------------------------------------
       
   206 // CBrowserAdaptiveListPopup::CBrowserAdaptiveListPopup()
       
   207 // ---------------------------------------------------------
       
   208 //
       
   209 CBrowserAdaptiveListPopup::CBrowserAdaptiveListPopup( CEikEdwin* aGotoPaneEdit, 
       
   210         CCoeControl* aParent, TParentType aParentType, TBool aSearchFeature): 
       
   211         iEditor( aGotoPaneEdit ), iParent( aParent ),
       
   212         iParentType( aParentType ), iSearchFeature( aSearchFeature )
       
   213     {
       
   214     iTouchSupported = AknLayoutUtils::PenEnabled();
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------
       
   218 // CBrowserAdaptiveListPopup::ConstructL(const TRect& aRect)
       
   219 // EPOC two-phased constructor
       
   220 // ---------------------------------------------------------
       
   221 void CBrowserAdaptiveListPopup::ConstructL( )
       
   222     {
       
   223     CreateWindowL();
       
   224 //-------- list ------
       
   225     iList = new(ELeave) CBrowserPopupList( iParentType );
       
   226 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF
       
   227     iList->ConstructL( this , CEikListBox::EDisableItemSpecificMenu );
       
   228 #else
       
   229     iList->ConstructL( this , CEikListBox::ELeftDownInViewRect );
       
   230 #endif
       
   231     iList->SetContainerWindowL( *this );
       
   232     if (iTouchSupported)
       
   233         {
       
   234         iList->SetListBoxObserver( this );
       
   235         }
       
   236     iList->CreateScrollBarFrameL( ETrue );
       
   237     iList->SetMopParent(iParent);
       
   238     iList->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   239                                 CEikScrollBarFrame::EOff,
       
   240                                 CEikScrollBarFrame::EAuto);
       
   241     iList->ScrollBarFrame()->SetTypeOfVScrollBar( CEikScrollBarFrame::EDoubleSpan );
       
   242     iList->UpdateScrollBarsL();
       
   243     iList->SetBorder(TGulBorder::ESingleBlack);
       
   244     iList->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue );
       
   245 //---------- items storing arrays ---------
       
   246     iItems = new(ELeave) CDesCArrayFlat(KArrayGranularity);
       
   247     iItemNames = new(ELeave) CDesCArrayFlat(KArrayGranularity);
       
   248     iItemNamesToShow = new(ELeave) CDesCArrayFlat(KArrayGranularity);
       
   249 //---------- model ----------
       
   250     CTextListBoxModel* model = iList->Model();
       
   251     model->SetItemTextArray( iItemNamesToShow );
       
   252     model->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   253 //---------- icons -----------
       
   254     SetIconsL();
       
   255 //--------- other --------
       
   256     iFirstGotoContent = KNullDesC().AllocL();
       
   257     iPrevGotoContent = KNullDesC().AllocL();
       
   258     iPoppedUp = EFalse;
       
   259     iDirectoryMode = ETrue;
       
   260     iOpenCBA=EFalse;
       
   261     iItemDrawer = iList->ItemDrawer();
       
   262     iPrevItem = -2;
       
   263     iUrlCompletionMode = EFalse;
       
   264     iRecentUrlStore = CBrowserAppUi::Static()->RecentUrlStore();
       
   265     if (!iRecentUrlStore)
       
   266         {
       
   267         User::Leave(KErrCouldNotConnect);
       
   268         }
       
   269 
       
   270     }
       
   271 
       
   272 // ---------------------------------------------------------
       
   273 // CBrowserAdaptiveListPopup::~CBrowserAdaptiveListPopup()
       
   274 // Destructor
       
   275 // ---------------------------------------------------------
       
   276 CBrowserAdaptiveListPopup::~CBrowserAdaptiveListPopup()
       
   277     {
       
   278     delete iList;
       
   279     delete iItems;
       
   280     delete iItemNames;
       
   281     delete iItemNamesToShow;
       
   282     delete iPrevGotoContent;
       
   283     delete iFirstGotoContent;
       
   284 }
       
   285 
       
   286 // ---------------------------------------------------------
       
   287 // CBrowserAdaptiveListPopup::SetOrdinalPosition
       
   288 // ---------------------------------------------------------
       
   289 //
       
   290 void CBrowserAdaptiveListPopup::SetOrdinalPosition( TInt aPos )
       
   291     {
       
   292     Window().SetOrdinalPosition( aPos );
       
   293     }
       
   294 
       
   295 void CBrowserAdaptiveListPopup::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   296     {
       
   297     if (iList && iTouchSupported)
       
   298         {
       
   299         //using ComponentControl(0) instead of iList because need access to a
       
   300         //protected function
       
   301         ComponentControl(0)->HandlePointerEventL( aPointerEvent );
       
   302         }
       
   303     }
       
   304 
       
   305 void CBrowserAdaptiveListPopup::HandleListBoxEventL(CEikListBox* aListBox,TListBoxEvent aEventType)
       
   306     {
       
   307     if (iList && aListBox == iList && iTouchSupported)
       
   308         {
       
   309         switch (aEventType)
       
   310             {
       
   311             case MEikListBoxObserver::EEventItemDoubleClicked:
       
   312                 {
       
   313                 TKeyEvent keyEvent;
       
   314                 keyEvent.iModifiers = 0;
       
   315                 keyEvent.iRepeats = 0;
       
   316                 keyEvent.iCode = EKeyDevice3;
       
   317                 keyEvent.iScanCode = EStdKeyDevice3;
       
   318                 if ( iParentType == EBookmarksGotoPane )
       
   319                     {
       
   320                     CCoeEnv::Static()->SimulateKeyEventL( keyEvent, EEventKeyDown );
       
   321                     }
       
   322                 CCoeEnv::Static()->SimulateKeyEventL( keyEvent, EEventKey );
       
   323                 if ( iParentType == EBookmarksGotoPane )
       
   324                     {
       
   325                     CCoeEnv::Static()->SimulateKeyEventL( keyEvent, EEventKeyUp );
       
   326                     }
       
   327                 }
       
   328                 break;
       
   329             case  MEikListBoxObserver::EEventItemClicked:
       
   330 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF                
       
   331             case  MEikListBoxObserver::EEventItemSingleClicked:      
       
   332 #endif                
       
   333                 HandleItemClickedL( aListBox );
       
   334                 break;
       
   335             default:
       
   336                 break;
       
   337             }
       
   338         }
       
   339     }
       
   340 
       
   341 void CBrowserAdaptiveListPopup::HandleItemClickedL( CEikListBox* aListBox )
       
   342     {
       
   343     //the first time
       
   344    if ( !iList->HighLightEnabled() )
       
   345        {
       
   346        iList->SetHighLight( ETrue );
       
   347 
       
   348        //save the original content
       
   349        if ( !iFirstGotoContent )
       
   350            {
       
   351            delete iFirstGotoContent;
       
   352            iFirstGotoContent = NULL;
       
   353            }
       
   354        iFirstGotoContent = iEditor->GetTextInHBufL();
       
   355        if ( !iFirstGotoContent )
       
   356            {
       
   357            iFirstGotoContent = KNullDesC().AllocL();
       
   358            }
       
   359        }
       
   360     TInt index = aListBox->CurrentItemIndex();
       
   361     index = iItems->Count() - index - 1;
       
   362     TPtrC16 item((*iItems)[ index ] );
       
   363     TPtrC rightSide;
       
   364 
       
   365     //cut the slash from the end if needed
       
   366     //permanent sollution until AHLE does not
       
   367     //solve this problem related to ID: TMCN-5TTRXV error
       
   368     if ( item[item.Length() - 1] != KSlash )
       
   369       {
       
   370       rightSide.Set( item.Left( item.Length() ) );
       
   371       }
       
   372     else
       
   373       {
       
   374       rightSide.Set( item.Left( item.Length() - 1 ) );
       
   375       }
       
   376     
       
   377     //if true then append the suffix(rightSide), to the
       
   378     //user-typed data
       
   379     //else just use the recent URLs text(rightSide) only
       
   380     if ( iUrlCompletionMode )
       
   381       {
       
   382       HBufC* currentCompletion = HBufC::NewLC(
       
   383           iFirstGotoContent->Des().Length() + rightSide.Length() + 1 );
       
   384       TPtr currentCompletionPtr = currentCompletion->Des();
       
   385     
       
   386       currentCompletionPtr.Copy( iFirstGotoContent->Des() );
       
   387       currentCompletionPtr.Append( rightSide );
       
   388       currentCompletionPtr.ZeroTerminate();
       
   389       iEditor->SetTextL( currentCompletion );
       
   390       iEditor->SetCursorPosL( currentCompletionPtr.Length(), EFalse );
       
   391       CleanupStack::PopAndDestroy( currentCompletion );
       
   392       }
       
   393     else
       
   394       {
       
   395       iEditor->SetTextL( &rightSide );
       
   396       iEditor->SetCursorPosL( rightSide.Length(), EFalse );
       
   397       }
       
   398     iEditor->HandleTextChangedL();
       
   399     
       
   400     delete iPrevGotoContent;
       
   401     iPrevGotoContent = NULL;
       
   402     iPrevGotoContent = item.AllocL();
       
   403     iEditor->DrawNow();
       
   404     //change the CBA depending on whether the highlight is
       
   405     //on url or domain
       
   406     CBrowserAppUi::Static()->UpdateCbaL();
       
   407     }
       
   408 
       
   409 
       
   410 //------------------------------------------------------------------
       
   411 // CBrowserAdaptiveListPopup::ShowSingleItemPopupListWithGraphicsL(TBool aShowTitle)
       
   412 // shows "List pane for single item with graphic"
       
   413 //------------------------------------------------------------------
       
   414 void CBrowserAdaptiveListPopup::ShowPopupListL(TBool aRelayout)
       
   415     {
       
   416     TAknWindowLineLayout windowLineLayout;
       
   417     TAknWindowLineLayout windowLineLayoutTmp;
       
   418     TAknWindowLineLayout windowLineLayoutMain;
       
   419     TAknWindowLineLayout windowLineLayoutMainTmp;
       
   420     TAknWindowLineLayout windowLineLayoutLW;
       
   421     TAknWindowLineLayout windowLineLayoutLWTmp;
       
   422     TAknWindowLineLayout windowLineLayoutSLW;
       
   423     TAknWindowLineLayout windowLineLayoutSLWTmp;
       
   424     TAknLayoutRect layoutRect;
       
   425     TAknLayoutRect layoutMainRect;
       
   426     TAknLayoutRect layoutLWRect;
       
   427     TAknLayoutRect layoutSLWRect;
       
   428 
       
   429     //turn of the highlight
       
   430     iList->SetHighLight( EFalse );
       
   431     //clear arrays
       
   432     iItems->Reset();
       
   433     iItemNames->Reset();
       
   434     iItemNamesToShow->Reset();
       
   435 
       
   436     TInt offset;
       
   437     HBufC* newText;
       
   438     //get create and get the string from the edit field
       
   439     if ( iEditor->TextLength() > 0 )
       
   440         {
       
   441         newText = iEditor->GetTextInHBufL();
       
   442         CleanupStack::PushL( newText );
       
   443         //cut the protokolidentifier from the string
       
   444         offset = newText->Find( KProtocolIdentifier );
       
   445         if ( offset == KErrNotFound )
       
   446             {
       
   447             offset = newText->Length();
       
   448             }
       
   449         else
       
   450             {
       
   451             offset = newText->Length() - offset - 3;
       
   452             }
       
   453         }
       
   454     else
       
   455         {
       
   456              offset = 0;
       
   457              newText = KNullDesC().AllocLC();
       
   458         }
       
   459     TPtrC trimmedContent( newText->Right( offset ) );
       
   460     TBuf<KListLengthToShow> buf;
       
   461 
       
   462     //find out if the user typed a ".", if so, bring up the url completion list
       
   463     TInt periodPos = trimmedContent.LocateReverse( TChar(KPeriod) );
       
   464     if ((periodPos != KErrNotFound) && ((periodPos + 1) == trimmedContent.Length()))
       
   465         {
       
   466         //add the url completion entries to the popup list
       
   467         iUrlCompletionMode = ETrue;
       
   468         CreateURLCompletionListL();
       
   469         }
       
   470     else
       
   471         {
       
   472         iUrlCompletionMode = EFalse;
       
   473         //only include recent URLs if not including the url completion items
       
   474         iRecentUrlStore->GetData( *iItems, *iItemNames, trimmedContent );
       
   475         }
       
   476     iDirectoryMode = EFalse;
       
   477     CleanupStack::PopAndDestroy();//newText
       
   478     TInt k;
       
   479     k = iItems->Count();
       
   480     iItemNo = k;
       
   481     TInt length = KListLengthToShow - 2;
       
   482     if ( k > 0 )
       
   483         {
       
   484         TInt j;
       
   485         TPtrC textToShow;
       
   486         TPtrC itemJ;
       
   487         //changeing the order
       
   488         for (j=k-1; j>-1; j--)
       
   489             {
       
   490             itemJ.Set( (*iItems)[j] );
       
   491             textToShow.Set( itemJ.Left( length ) );
       
   492             if ( iDirectoryMode )
       
   493                 {
       
   494             //directories and items
       
   495                 if ( itemJ[ itemJ.Length() - 1 ] == KSlash )
       
   496                     {
       
   497                 //item
       
   498                     buf.Format( _L( "%S%S" ), &KItemTab, &textToShow );
       
   499                     }
       
   500                 else
       
   501                     {
       
   502                     //directory
       
   503                     buf.Format( _L( "%S%S" ), &KDirTab, &textToShow );
       
   504                     }
       
   505                 }
       
   506             else
       
   507                 {
       
   508             //items only
       
   509                 buf.Format( _L( "%S%S" ), &KItemTab, &textToShow );
       
   510                 }
       
   511             iItemNamesToShow->AppendL( buf );
       
   512             }
       
   513         //set how many item will be shown
       
   514         TInt itemstoshow;
       
   515 
       
   516         if ( k >  iMaxRecentUrlsToShow)
       
   517             {
       
   518             itemstoshow = iMaxRecentUrlsToShow;
       
   519             }
       
   520         else
       
   521             {
       
   522             itemstoshow = k;
       
   523             }
       
   524 
       
   525         //set the main rect of the window
       
   526         // fixing bug RFON-7E2PPV, don't use ApplicationRect()
       
   527         TRect  rect;
       
   528         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
       
   529         windowLineLayoutMain = AknLayout::main_pane( rect, 0, 2, 1 );
       
   530         windowLineLayoutMainTmp = windowLineLayoutMain;
       
   531         layoutMainRect.LayoutRect( rect, windowLineLayoutMainTmp );
       
   532 
       
   533       
       
   534         windowLineLayoutLW = AppLayout::popup_wml_address_window( 1, itemstoshow );
       
   535       
       
   536         windowLineLayoutLWTmp = windowLineLayoutLW;
       
   537         layoutLWRect.LayoutRect( layoutMainRect.Rect(), windowLineLayoutLWTmp );
       
   538         windowLineLayoutSLW = AknLayoutScalable_Apps::listscroll_popup_wml_pane();
       
   539         windowLineLayoutSLWTmp = windowLineLayoutSLW;
       
   540         layoutSLWRect.LayoutRect( layoutLWRect.Rect(), windowLineLayoutSLWTmp );
       
   541         windowLineLayout = AppLayout::list_wml_pane( itemstoshow - 1 );
       
   542         windowLineLayoutTmp = windowLineLayout;
       
   543         layoutRect.LayoutRect( layoutLWRect.Rect(), windowLineLayoutTmp );
       
   544 
       
   545         TRect rectTemp(layoutSLWRect.Rect());
       
   546         // force listbox on top of goto pane
       
   547         rectTemp.iBr.iY = iParent->PositionRelativeToScreen().iY;
       
   548         rectTemp.iTl.iX = iParent->PositionRelativeToScreen().iX;
       
   549         // shrink list box to size of list
       
   550         rectTemp.iTl.iY =  rectTemp.iBr.iY - (AppLayout::list_single_graphic_popup_wml_pane( 0 ).iH * itemstoshow);
       
   551         // set bottom right x axis to full width
       
   552         rectTemp.iBr.iX = rect.iBr.iX;
       
   553         
       
   554         // we only want to call SetRect() when we have a relayout, otherwise just
       
   555         // scroll the list to the correct position. Doing this will reduce the amount
       
   556         // of flicker seen while typing into the gotopane
       
   557         if ((rectTemp.Size() != Rect().Size()) || aRelayout)
       
   558             {
       
   559             //set the window rect
       
   560             SetRect( rectTemp );
       
   561             }
       
   562         rectTemp = TRect( 0, 0, Rect().Width(), Rect().Height() );
       
   563         if ( rectTemp!=iList->Rect() )
       
   564             {
       
   565             //set the rect of the list
       
   566             iList->SetRect( rectTemp );
       
   567             }
       
   568         else
       
   569             {
       
   570             // this scrolls list to the correct position, probably still does too much work
       
   571             AknListBoxLayouts::SetupListboxPos( *iList, AppLayout::list_single_graphic_popup_wml_pane( 0 ));
       
   572             }
       
   573         //the last item is visible
       
   574         iList->ScrollToMakeItemVisible( iList->Model()->NumberOfItems()-1 );
       
   575         MakeVisible( ETrue );
       
   576         iPoppedUp = ETrue;
       
   577         DrawNow();
       
   578         iList->Draw(rectTemp);
       
   579         }
       
   580     else
       
   581         {
       
   582         MakeVisible( EFalse );
       
   583         iPoppedUp = EFalse;
       
   584         CBrowserAppUi::Static()->UpdateCbaL();
       
   585         }
       
   586     if (!IsActivated())
       
   587         {
       
   588         ActivateL();
       
   589         }
       
   590     iPrevItem = -2;
       
   591     }
       
   592 
       
   593 // ---------------------------------------------------------
       
   594 // CBrowserAdaptiveListPopup::CreateURLCompletionListL
       
   595 // ---------------------------------------------------------
       
   596 //
       
   597 void CBrowserAdaptiveListPopup::CreateURLCompletionListL()
       
   598     {
       
   599     _LIT(KSeparator, ",");
       
   600 
       
   601     if (iUrlSuffixBuf)
       
   602         {
       
   603         TPtrC urlSuffix(iUrlSuffixBuf->Des());
       
   604         TInt index(urlSuffix.FindF(KSeparator));
       
   605         TInt offset = 0;
       
   606 
       
   607         while (index != KErrNotFound)
       
   608             {
       
   609             // Omit empty string
       
   610             if (index > 0)
       
   611                 {
       
   612                 iItems->AppendL( urlSuffix.Mid(offset,index) );
       
   613                 }
       
   614 
       
   615             offset += (index + 1);
       
   616             TPtrC remainder(urlSuffix.Mid(offset));
       
   617             index = remainder.FindF(KSeparator);
       
   618             }
       
   619 
       
   620         // Cover the cases where we only have one suffix in the list and/or
       
   621         // the last suffix in the list does not have a comma
       
   622         if (offset < urlSuffix.Length())
       
   623             {
       
   624             TPtrC remainderB(urlSuffix.Mid(offset, urlSuffix.Length() - offset));
       
   625             iItems->AppendL( remainderB );
       
   626             }
       
   627         }
       
   628     }
       
   629 
       
   630 // ---------------------------------------------------------
       
   631 // CBrowserAdaptiveListPopup::HandleControlEventL
       
   632 // if the content of the edit box changes
       
   633 // ---------------------------------------------------------
       
   634 //
       
   635 void CBrowserAdaptiveListPopup::HandleControlEventL(CCoeControl* aControl,enum MCoeControlObserver::TCoeEvent aEventType)
       
   636     {
       
   637     CEikEdwin* edwin = ( CEikEdwin* )aControl;
       
   638     // the content of the edit box changes
       
   639     if ( MCoeControlObserver::EEventStateChanged == aEventType )
       
   640         {
       
   641         HBufC* newText = edwin->GetTextInHBufL();
       
   642         if (!newText)
       
   643             {
       
   644             newText = KNullDesC().AllocL();
       
   645             }
       
   646         CleanupStack::PushL( newText );
       
   647         //check whether the last content is different to the one in the editbox
       
   648         if ( !iPrevGotoContent || iPrevGotoContent->Compare( *newText ) )
       
   649             {
       
   650             ShowPopupListL();
       
   651             delete iPrevGotoContent;
       
   652             iPrevGotoContent = NULL;
       
   653             iPrevGotoContent = newText;
       
   654             CleanupStack::Pop( newText );//ownership is taken
       
   655             }
       
   656         else
       
   657             {
       
   658             if ( !iPrevGotoContent )
       
   659                 {
       
   660                 CleanupStack::PopAndDestroy( newText );
       
   661                 }
       
   662             else
       
   663                 {
       
   664                 ShowPopupListL();
       
   665                 delete iPrevGotoContent;
       
   666                 iPrevGotoContent = NULL;
       
   667                 iPrevGotoContent = newText;
       
   668                 CleanupStack::Pop( newText );//ownership is taken
       
   669                 }
       
   670             }
       
   671         //change the CBA
       
   672         if ( iOpenCBA )
       
   673             {
       
   674             iOpenCBA = EFalse;
       
   675             CBrowserAppUi::Static()->UpdateCbaL();
       
   676             }
       
   677         }
       
   678     }
       
   679 
       
   680 // ---------------------------------------------------------
       
   681 // CBrowserAdaptiveListPopup::CountComponentControls
       
   682 //
       
   683 // ---------------------------------------------------------
       
   684 //
       
   685 TInt CBrowserAdaptiveListPopup::CountComponentControls() const
       
   686     {
       
   687     if ( iList == NULL )
       
   688         {
       
   689         return 0;
       
   690         }
       
   691     return 1;
       
   692     }
       
   693 
       
   694 // ---------------------------------------------------------
       
   695 // CBrowserAdaptiveListPopup::ComponentControl
       
   696 //
       
   697 // ---------------------------------------------------------
       
   698 //
       
   699 CCoeControl* CBrowserAdaptiveListPopup::ComponentControl(TInt aIndex) const
       
   700     {
       
   701     if (aIndex==0)
       
   702         {
       
   703         return iList;
       
   704         }
       
   705     else
       
   706         {
       
   707         return NULL;
       
   708         }
       
   709     }
       
   710 
       
   711 // ---------------------------------------------------------
       
   712 // CBrowserAdaptiveListPopup::OfferKeyEventL
       
   713 // Handles key events
       
   714 // ---------------------------------------------------------
       
   715 //
       
   716 TKeyResponse CBrowserAdaptiveListPopup::OfferKeyEventL
       
   717 ( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   718     {
       
   719     TKeyResponse resp = EKeyWasNotConsumed;
       
   720     if (( iPoppedUp &&
       
   721     !CBrowserAppUi::Static()->ContentView()->MenuBar()->MenuPane()->IsVisible() &&
       
   722     (CBrowserAppUi::Static()->LastActiveViewId() == KUidBrowserContentViewId) ) || (( iPoppedUp ) &&
       
   723     (CBrowserAppUi::Static()->LastActiveViewId() != KUidBrowserContentViewId)))
       
   724         {
       
   725         TInt currIndex = iItems->Count() - iList->CurrentItemIndex() - 1;
       
   726 
       
   727         //the joystick is pressed
       
   728         if ( aKeyEvent.iCode == EKeyOK )
       
   729             {
       
   730             if ( ( iList->HighLightEnabled() )
       
   731               && ( iDirectoryMode )
       
   732               && ( (*iItems)[ currIndex ][(*iItems)[ currIndex ].Length() - 1] != KSlash ) )
       
   733                 {
       
   734                 SetDirectoryModeL( EFalse );
       
   735                 resp = EKeyWasConsumed;
       
   736                 }
       
   737             else
       
   738                 {
       
   739                 if (iEditor->TextLength()!=0)
       
   740                     {
       
   741                     HidePopupL();
       
   742                     }
       
   743                 }
       
   744             }
       
   745 
       
   746         //the joystick is pressed up
       
   747         else if (    aKeyEvent.iCode == EKeyLeftUpArrow      // Northwest
       
   748                   || aKeyEvent.iCode == EStdKeyDevice10      //   : Extra KeyEvent supports diagonal event simulator wedge
       
   749                   || aKeyEvent.iCode == EKeyUpArrow          // North
       
   750                   || aKeyEvent.iCode == EKeyRightUpArrow     // Northeast
       
   751                   || aKeyEvent.iCode == EStdKeyDevice11 )    //   : Extra KeyEvent supports diagonal event simulator wedge
       
   752             {
       
   753             resp = EKeyWasConsumed;
       
   754             //the first time
       
   755             if ( !iList->HighLightEnabled() )
       
   756                 {
       
   757                 iList->SetHighLight( ETrue );
       
   758                 currIndex = iList->Model()->NumberOfItems()-1;
       
   759                 iList->ScrollToMakeItemVisible( currIndex );
       
   760                 iList->SetCurrentItemIndex( currIndex );
       
   761                 DrawNow();
       
   762                 //save the original content
       
   763                 if ( iFirstGotoContent != NULL )
       
   764                     {
       
   765                     delete iFirstGotoContent;
       
   766                     iFirstGotoContent = NULL;
       
   767                     }
       
   768                 iFirstGotoContent = iEditor->GetTextInHBufL();
       
   769                 if (iFirstGotoContent == NULL)
       
   770                     {
       
   771                     iFirstGotoContent = KNullDesC().AllocL();
       
   772                     }
       
   773                 }
       
   774             else
       
   775                 {
       
   776                 if(  iSearchFeature )
       
   777                     {
       
   778                     if( iList->CurrentItemIndex() == 0 )
       
   779                         {
       
   780                         resp = EKeyWasConsumed;
       
   781                         return resp;
       
   782                         }
       
   783                     }
       
   784                 resp=iList->OfferKeyEventL( aKeyEvent, aType );
       
   785                 }
       
   786             if ( currIndex > -1 )
       
   787                 {
       
   788                 //copy the selected item to edit field
       
   789                 TPtrC16 item;
       
   790                 TPtrC rightSide;
       
   791                 TInt newIndex;
       
   792                 newIndex = iItems->Count() - iList->CurrentItemIndex() - 1;
       
   793                 item.Set( (*iItems)[ newIndex ] );
       
   794                 //cut the slash from the end if needed
       
   795                 //permanent sollution until AHLE does not
       
   796                 //solve this problem related to ID: TMCN-5TTRXV error
       
   797 
       
   798                 //if URL completion, then we want to append the item to the item in the edit field
       
   799                 if (iUrlCompletionMode)
       
   800                     {
       
   801                     TPtr16 ptr = iFirstGotoContent->Des();
       
   802 
       
   803                     HBufC* buf = HBufC::NewLC(ptr.Length() + item.Length() + 1);
       
   804 
       
   805                     buf->Des().Copy(ptr);
       
   806                     buf->Des().Append(item);
       
   807                     buf->Des().ZeroTerminate();
       
   808 
       
   809 
       
   810                     rightSide.Set(buf->Des());
       
   811 
       
   812                     iEditor->SetTextL( &rightSide );
       
   813                     iEditor->SetCursorPosL( rightSide.Length(), EFalse );
       
   814 
       
   815                     CleanupStack::PopAndDestroy(); //buf
       
   816                     }
       
   817                 else
       
   818                     {
       
   819                     if ( (*iItems)[ newIndex ][(*iItems)[ newIndex ].Length() - 1] != KSlash )
       
   820                         {
       
   821                         rightSide.Set( item.Left( item.Length() ) );
       
   822                         }
       
   823                     else
       
   824                         {
       
   825                         rightSide.Set( item.Left( item.Length() - 1 ) );
       
   826                         }
       
   827                     iEditor->SetTextL( &rightSide );
       
   828                     iEditor->SetCursorPosL( rightSide.Length(), EFalse );
       
   829                     }
       
   830                 delete iPrevGotoContent;
       
   831                 iPrevGotoContent = NULL;
       
   832                 iPrevGotoContent = item.AllocL();
       
   833                 iEditor->DrawNow();
       
   834                 //change the CBA depending on whether the highlight is
       
   835                 //on url or domain
       
   836                 if ( ( (*iItems)[ newIndex ][(*iItems)[ newIndex ].Length() - 1] != KSlash ) && iDirectoryMode )
       
   837                     {
       
   838                     iOpenCBA = ETrue;
       
   839                     }
       
   840                 else
       
   841                     {
       
   842                     iOpenCBA = EFalse;
       
   843                     }
       
   844                 CBrowserAppUi::Static()->UpdateCbaL();
       
   845                 }
       
   846             }
       
   847 
       
   848         //the joystisk is pressed down
       
   849         else if (    aKeyEvent.iCode == EKeyLeftDownArrow    // Southwest
       
   850                   || aKeyEvent.iCode == EStdKeyDevice13      //   : Extra KeyEvent supports diagonal event simulator wedge
       
   851                   || aKeyEvent.iCode == EKeyDownArrow        // South
       
   852                   || aKeyEvent.iCode == EKeyRightDownArrow   // Southeast
       
   853                   || aKeyEvent.iCode == EStdKeyDevice12 )    //   : Extra KeyEvent supports diagonal event simulator wedge
       
   854             {
       
   855             resp = EKeyWasConsumed;
       
   856             if(  iSearchFeature )
       
   857                 {
       
   858                 if ( iPrevItem <= 0 )
       
   859                     {
       
   860                     if(! iList->HighLightEnabled() )
       
   861                         {
       
   862                         resp = EKeyWasNotConsumed;
       
   863                         return resp;
       
   864                         }
       
   865                     }
       
   866                 }
       
   867             //it was the last item
       
   868             if ( iPrevItem == 0 )
       
   869                 {
       
   870                 //write back the original string
       
   871                 iList->SetHighLight( EFalse );
       
   872                 iEditor->SetTextL( iFirstGotoContent );
       
   873                 iEditor->HandleTextChangedL();
       
   874                 iEditor->SetCursorPosL( iFirstGotoContent->Length(), EFalse );
       
   875                 delete iPrevGotoContent;
       
   876                 iPrevGotoContent = NULL;
       
   877                 iPrevGotoContent = iFirstGotoContent->AllocL();
       
   878                 iEditor->DrawNow();
       
   879                 DrawNow();
       
   880                 //change the CBA
       
   881                 if ( iOpenCBA )
       
   882                     {
       
   883                     iOpenCBA = EFalse;
       
   884                     CBrowserAppUi::Static()->UpdateCbaL();
       
   885                     }
       
   886                 return resp;
       
   887                 }
       
   888             else if ( ( currIndex > -1 ) && iList->HighLightEnabled() )
       
   889                 {
       
   890                 //write the selected items string to the editor
       
   891                 TPtrC16 item;
       
   892                 TPtrC rightSide;
       
   893                 TInt newIndex;
       
   894                 resp = iList->OfferKeyEventL( aKeyEvent, aType );
       
   895                 newIndex = iItems->Count() - iList->CurrentItemIndex() - 1;
       
   896                 item.Set( (*iItems)[ newIndex ] );
       
   897                 //cut the slash from the end if needed
       
   898                 //permanent sollution until AHLE does not
       
   899                 //solve this problem related to ID: TMCN-5TTRXV error
       
   900                 if ( (*iItems)[ newIndex ][(*iItems)[ newIndex ].Length() - 1] != KSlash )
       
   901                     {
       
   902                     rightSide.Set( item.Left( item.Length() ) );
       
   903                     }
       
   904                 else
       
   905                     {
       
   906                     rightSide.Set( item.Left( item.Length() - 1 ) );
       
   907                     }
       
   908 
       
   909                 //if true then append the suffix (rightSide), to the
       
   910                 //user-typed data
       
   911                 //else just use the recent URLs text(rightSide) only
       
   912                 if ( iUrlCompletionMode )
       
   913                     {
       
   914                     HBufC* currentCompletion = HBufC::NewLC(
       
   915                         iFirstGotoContent->Des().Length() + rightSide.Length() + 1 );
       
   916                     TPtr currentCompletionPtr = currentCompletion->Des();
       
   917 
       
   918                     currentCompletionPtr.Copy( iFirstGotoContent->Des() );
       
   919                     currentCompletionPtr.Append( rightSide );
       
   920                     currentCompletionPtr.ZeroTerminate();
       
   921                     iEditor->SetTextL( currentCompletion );
       
   922                     iEditor->SetCursorPosL( currentCompletionPtr.Length(), EFalse );
       
   923                     CleanupStack::PopAndDestroy( currentCompletion );
       
   924                     }
       
   925                 else
       
   926                     {
       
   927                     iEditor->SetTextL( &rightSide );
       
   928                     iEditor->SetCursorPosL( rightSide.Length(), EFalse );
       
   929                     }
       
   930                 iEditor->HandleTextChangedL();
       
   931 
       
   932                 if ( iPrevGotoContent != NULL )
       
   933                     {
       
   934                     delete iPrevGotoContent;
       
   935                     iPrevGotoContent = NULL;
       
   936                     }
       
   937                 iPrevGotoContent = item.AllocL();
       
   938                 iEditor->DrawNow();
       
   939                 //change the CBA depending on whether the highlight is
       
   940                 //on url or domain
       
   941                 if ( ( (*iItems)[ newIndex ][(*iItems)[ newIndex ].Length() - 1] != KSlash ) && iDirectoryMode )
       
   942                     {
       
   943                     iOpenCBA = ETrue;
       
   944                     }
       
   945                 else
       
   946                     {
       
   947                     iOpenCBA = EFalse;
       
   948                     }
       
   949                 CBrowserAppUi::Static()->UpdateCbaL();
       
   950                 }
       
   951             }
       
   952 
       
   953         if ( iList->HighLightEnabled() )
       
   954             {
       
   955             iPrevItem = currIndex;
       
   956             }
       
   957         }
       
   958     return resp;
       
   959     }
       
   960 
       
   961 
       
   962 // ---------------------------------------------------------
       
   963 // CBrowserAdaptiveListPopup::HidePopupL
       
   964 // Hides the popup list
       
   965 // ---------------------------------------------------------
       
   966 //
       
   967 void CBrowserAdaptiveListPopup::HidePopupL()
       
   968     {
       
   969     //clear the lists
       
   970     if ( iPoppedUp )
       
   971         {
       
   972         HBufC* newText = HBufC::NewLC( iEditor->TextLength() );
       
   973         TPtr newTextDes = newText->Des();
       
   974         iEditor->GetText( newTextDes );
       
   975         iEditor->ClearSelectionL();
       
   976         iEditor->SetTextL( newText );
       
   977         iEditor->SetCursorPosL( iEditor->TextLength(), EFalse );
       
   978         CleanupStack::PopAndDestroy( newText );
       
   979         iItemNames->Reset();
       
   980         iList->Reset();
       
   981         if (!IsActivated())
       
   982             {
       
   983             ActivateL();
       
   984             }
       
   985         MakeVisible(EFalse);
       
   986         DrawNow();
       
   987         iPrevItem = -2;
       
   988         iPoppedUp = EFalse;
       
   989         // highlight a directory, cancel goto pane
       
   990         // activate goto pane again -> softkey problem
       
   991         iOpenCBA = EFalse;
       
   992         CBrowserAppUi::Static()->UpdateCbaL();
       
   993         }
       
   994     }
       
   995 
       
   996 // ---------------------------------------------------------
       
   997 // CBrowserAdaptiveListPopup::IsInDirectoryMode
       
   998 // gives back the directory mode
       
   999 // ---------------------------------------------------------
       
  1000 //
       
  1001 TBool CBrowserAdaptiveListPopup::IsInDirectoryMode()
       
  1002     {
       
  1003     return iDirectoryMode;
       
  1004     }
       
  1005 
       
  1006 // ---------------------------------------------------------
       
  1007 // CBrowserAdaptiveListPopup::SetDirectoryMode
       
  1008 // Sets the directory mode
       
  1009 // ---------------------------------------------------------
       
  1010 //
       
  1011 void CBrowserAdaptiveListPopup::SetDirectoryModeL(TBool aDirMode)
       
  1012     {
       
  1013     iDirectoryMode = aDirMode;
       
  1014     if ( aDirMode == EFalse )
       
  1015         {
       
  1016         //put the slash to the back of the editor fileds string
       
  1017         //it will show the directory mode
       
  1018         TInt length;
       
  1019         length = iEditor->TextLength() + 1;
       
  1020         HBufC* newText = HBufC::NewLC( length );
       
  1021         TPtr newTextDes = newText->Des();
       
  1022         iEditor->GetText( newTextDes );
       
  1023         newTextDes.Append( TChar(KSlash) );
       
  1024         iEditor->SetTextL( newText );
       
  1025         iEditor->SetCursorPosL( length, EFalse );
       
  1026         CleanupStack::PopAndDestroy( newText );
       
  1027         iEditor->DrawNow();
       
  1028         ShowPopupListL();
       
  1029         //change the CBA
       
  1030         if ( iOpenCBA )
       
  1031             {
       
  1032             iOpenCBA = EFalse;
       
  1033             CBrowserAppUi::Static()->UpdateCbaL();
       
  1034             }
       
  1035         }
       
  1036     return;
       
  1037     }
       
  1038 
       
  1039 // ---------------------------------------------------------
       
  1040 // CBrowserAdaptiveListPopup::IsOpenDirToShow
       
  1041 // Show which CBA is about to show
       
  1042 // ---------------------------------------------------------
       
  1043 //
       
  1044 TBool CBrowserAdaptiveListPopup::IsOpenDirToShow()
       
  1045 {
       
  1046     return iOpenCBA;
       
  1047 }
       
  1048 
       
  1049 // ---------------------------------------------------------
       
  1050 // CBrowserAdaptiveListPopup::IsPoppedUp
       
  1051 // Show whether the list is popped up or not
       
  1052 // ---------------------------------------------------------
       
  1053 //
       
  1054 TBool CBrowserAdaptiveListPopup::IsPoppedUp()
       
  1055 {
       
  1056     return iPoppedUp;
       
  1057 }
       
  1058 
       
  1059 
       
  1060 // ---------------------------------------------------------
       
  1061 // CBrowserAdaptiveListPopup::HandleResourceChange
       
  1062 // If new skin is set the icons will be reloaded
       
  1063 // ---------------------------------------------------------
       
  1064 //
       
  1065 void CBrowserAdaptiveListPopup::HandleResourceChange( TInt aType )
       
  1066     {
       
  1067     TRAP_IGNORE( HandleResourceChangeL( aType ) );
       
  1068     }
       
  1069 
       
  1070 // ---------------------------------------------------------
       
  1071 // CBrowserAdaptiveListPopup::HandleResourceChangeL
       
  1072 // If new skin is set the icons will be reloaded
       
  1073 // ---------------------------------------------------------
       
  1074 //
       
  1075 void CBrowserAdaptiveListPopup::HandleResourceChangeL( TInt aType )
       
  1076     {
       
  1077     if (( aType == KAknsMessageSkinChange )||
       
  1078        ( aType == KEikDynamicLayoutVariantSwitch ) )
       
  1079         {
       
  1080         CArrayPtr<CGulIcon>* array =
       
  1081                             iList->ItemDrawer()->ColumnData()->IconArray();
       
  1082 
       
  1083         array->ResetAndDestroy();
       
  1084         delete array;
       
  1085         SetIconsL();
       
  1086         }
       
  1087 
       
  1088     CCoeControl::HandleResourceChange(aType);
       
  1089     if (aType == KEikDynamicLayoutVariantSwitch)
       
  1090         {
       
  1091         TRect  rect;
       
  1092         if (AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect))
       
  1093             {
       
  1094             SetRect(rect);
       
  1095             }
       
  1096         }
       
  1097 
       
  1098     if ( ( aType == KEikDynamicLayoutVariantSwitch ) && ( iPoppedUp ) )
       
  1099         {
       
  1100 
       
  1101         if ( AknLayoutUtils::PenEnabled() )
       
  1102             {
       
  1103             SetOrdinalPosition( 0 );
       
  1104             }
       
  1105 
       
  1106         TInt selectionIndex = -1;
       
  1107         HBufC* originalText = NULL;
       
  1108         TInt popitem( 0 );
       
  1109         if ( iList->HighLightEnabled() )
       
  1110             {
       
  1111             selectionIndex = iList->CurrentItemIndex();
       
  1112             //save the editors content
       
  1113             originalText = iEditor->GetTextInHBufL();
       
  1114             if (originalText == NULL)
       
  1115                 {
       
  1116                 originalText = KNullDesC().AllocL();
       
  1117                 }
       
  1118             CleanupStack::PushL( originalText );
       
  1119             ++popitem;
       
  1120             //write back the first string
       
  1121             iEditor->SetTextL( iFirstGotoContent );
       
  1122             iEditor->HandleTextChangedL();
       
  1123             }
       
  1124         ShowPopupListL(ETrue);
       
  1125         if ( selectionIndex > -1)
       
  1126             {
       
  1127             iEditor->SetTextL( originalText );
       
  1128             iEditor->SetCursorPosL( originalText->Length(), EFalse );
       
  1129             iEditor->HandleTextChangedL();
       
  1130             iList->SetHighLight( ETrue );
       
  1131             iList->ScrollToMakeItemVisible( selectionIndex );
       
  1132             iList->SetCurrentItemIndex( selectionIndex );
       
  1133             DrawNow();
       
  1134             iEditor->DrawNow();
       
  1135             }
       
  1136         if ( popitem )
       
  1137             {
       
  1138             CleanupStack::PopAndDestroy( popitem );  // originalText
       
  1139             }
       
  1140         }
       
  1141     }
       
  1142 
       
  1143 // ---------------------------------------------------------
       
  1144 // CBrowserAdaptiveListPopup::SetIconsL()
       
  1145 // ---------------------------------------------------------
       
  1146 //
       
  1147 void CBrowserAdaptiveListPopup::SetIconsL()
       
  1148 {
       
  1149     CArrayPtr<CGulIcon>* icons =
       
  1150     new(ELeave) CAknIconArray( KMaxIcons );
       
  1151     CleanupStack::PushL(icons); // PUSH Icon
       
  1152     CGulIcon* newIcon;
       
  1153     CFbsBitmap *newIconBmp;
       
  1154     CFbsBitmap *newIconMaskBmp;
       
  1155 
       
  1156     TParse* fp = new(ELeave) TParse();
       
  1157     CleanupStack::PushL(fp);
       
  1158     TInt err = fp->Set(KBrowserDirAndFile, &KDC_APP_BITMAP_DIR, NULL);
       
  1159     if (err != KErrNone)
       
  1160         {
       
  1161         User::Leave(err);
       
  1162         }
       
  1163     TBuf<KMaxFileName> iconFile= fp->FullName();
       
  1164     CleanupStack::PopAndDestroy(fp);
       
  1165 
       
  1166     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
  1167     AknsUtils::CreateIconLC( skinInstance,
       
  1168                                            KAknsIIDQgnPropWmlFolderAdap,
       
  1169                                            newIconBmp,
       
  1170                                            newIconMaskBmp,
       
  1171                                            iconFile,
       
  1172                                            EMbmBrowserQgn_prop_wml_folder_adap,
       
  1173                                            EMbmBrowserQgn_prop_wml_folder_adap_mask);
       
  1174     newIcon = CGulIcon::NewL( newIconBmp, newIconMaskBmp);
       
  1175     CleanupStack::Pop(2);
       
  1176     CleanupStack::PushL(newIcon);
       
  1177     icons->AppendL( newIcon );
       
  1178     CleanupStack::Pop(newIcon);
       
  1179     AknsUtils::CreateIconLC( skinInstance,
       
  1180                                            KAknsIIDQgnPropWmlBmAdap,
       
  1181                                            newIconBmp,
       
  1182                                            newIconMaskBmp,
       
  1183                                            iconFile,
       
  1184                                            EMbmBrowserQgn_prop_wml_bm_adap,
       
  1185                                            EMbmBrowserQgn_prop_wml_bm_adap_mask);
       
  1186     newIcon = CGulIcon::NewL( newIconBmp, newIconMaskBmp);
       
  1187     CleanupStack::Pop(2);
       
  1188     CleanupStack::PushL(newIcon);
       
  1189     icons->AppendL( newIcon );
       
  1190     CleanupStack::Pop(newIcon);
       
  1191     iList->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
       
  1192     CleanupStack::Pop();    // POP Icon
       
  1193 }
       
  1194 
       
  1195 // ---------------------------------------------------------
       
  1196 // CBrowserAdaptiveListPopup::SetUrlSuffixList()
       
  1197 // ---------------------------------------------------------
       
  1198 //
       
  1199 void CBrowserAdaptiveListPopup::SetUrlSuffixList(HBufC* urlSuffixList)
       
  1200     {
       
  1201     iUrlSuffixBuf = urlSuffixList;
       
  1202     }
       
  1203 
       
  1204 // ---------------------------------------------------------
       
  1205 // CBrowserAdaptiveListPopup::SetMaxRecentUrls()
       
  1206 // ---------------------------------------------------------
       
  1207 //
       
  1208 void CBrowserAdaptiveListPopup::SetMaxRecentUrls (TInt maxRecentUrls)
       
  1209     {
       
  1210     iMaxRecentUrlsToShow = maxRecentUrls;
       
  1211     }
       
  1212 
       
  1213 
       
  1214 // End of File