emailuis/emailui/src/ncspopuplistbox.cpp
branchRCL_3
changeset 80 726fba06891a
parent 73 c8382f7b54ef
equal deleted inserted replaced
73:c8382f7b54ef 80:726fba06891a
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include "emailtrace.h"
    20 #include "emailtrace.h"
    21 #include <eikclbd.h>
    21 #include <eikclbd.h>
    22 #include <AknsFrameBackgroundControlContext.h>
    22 #include <AknsFrameBackgroundControlContext.h>
    23 #include <FreestyleEmailUi.rsg>
    23 #include <FreestyleEmailUi.rsg>						// R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH
    24 #include <StringLoader.h>
    24 #include <StringLoader.h>						// StringLoader
    25 #include <CPbkContactEngine.h>
    25 #include <CPbkContactEngine.h>
    26 #include <AknsDrawUtils.h>
    26 #include <AknsDrawUtils.h>
    27 #include <AknsUtils.h>
    27 #include <AknsUtils.h>
    28 #include <aknlayoutscalable_apps.cdl.h>
    28 #include <aknlayoutscalable_apps.cdl.h>
    29 #include <aknlayoutscalable_avkon.cdl.h>
    29 #include <aknlayoutscalable_avkon.cdl.h>
    30 
    30 
    31 #include "ncspopuplistbox.h"
    31 #include "ncspopuplistbox.h"
    32 #include "ncsemailaddressobject.h"
    32 #include "ncsemailaddressobject.h"					// CNcsEmailAddressObject
    33 #include "ncsconstants.h"
    33 #include "ncsconstants.h"
    34 #include "ncsheadercontainer.h"
    34 #include "ncsheadercontainer.h"						// CNcsHeaderContainer
    35 #include "FreestyleEmailUiContactHandler.h"
    35 #include "FreestyleEmailUiContactHandler.h"		// CFSEmailUiClsListsHandler
    36 #include "ncsutility.h"
    36 #include "ncsutility.h"
    37 #include "FreestyleEmailUiUtilities.h"
    37 #include "FreestyleEmailUiUtilities.h"
    38 #include "FreestyleEmailUiAppui.h"
    38 #include "FreestyleEmailUiAppui.h"
    39 #include "FreestyleEmailUiLayoutHandler.h"
    39 #include "FreestyleEmailUiLayoutHandler.h"
    40 #include "FSDelayedLoader.h"
    40 #include "FSDelayedLoader.h"
    47 // -----------------------------------------------------------------------------
    47 // -----------------------------------------------------------------------------
    48 // CNcsPopupListBox::NewL
    48 // CNcsPopupListBox::NewL
    49 // -----------------------------------------------------------------------------
    49 // -----------------------------------------------------------------------------
    50 CNcsPopupListBox* CNcsPopupListBox::NewL( const CCoeControl* aParent, 
    50 CNcsPopupListBox* CNcsPopupListBox::NewL( const CCoeControl* aParent, 
    51                                           CFSMailBox& aMailBox, 
    51                                           CFSMailBox& aMailBox, 
    52                                           MNcsPopupListBoxObserver& aObserver,
    52                                           CNcsHeaderContainer& aHeaderContainer, 
    53                                           TBool aRemoteLookupSupported  )
    53                                           TBool aRemoteLookupSupported  )
    54     {
    54     {
    55     FUNC_LOG;
    55     FUNC_LOG;
    56     CNcsPopupListBox* self =  new (ELeave) CNcsPopupListBox( aMailBox,
    56     CNcsPopupListBox* self =  new (ELeave) CNcsPopupListBox( aHeaderContainer,
    57         aObserver, aRemoteLookupSupported );
    57         aRemoteLookupSupported, aMailBox );
    58     CleanupStack::PushL( self );
    58     CleanupStack::PushL( self );
    59     self->ConstructL( aParent );
    59     self->ConstructL( aParent );
    60     CleanupStack::Pop( self );
    60     CleanupStack::Pop( self );
    61     return self;
    61     return self;
    62     }
    62     }
    63 
    63 
    64 // -----------------------------------------------------------------------------
    64 // -----------------------------------------------------------------------------
    65 // CNcsPopupListBox::CNcsPopupListBox
    65 // CNcsPopupListBox::CNcsPopupListBox
    66 // -----------------------------------------------------------------------------
    66 // -----------------------------------------------------------------------------
    67 CNcsPopupListBox::CNcsPopupListBox( CFSMailBox& aMailBox,
    67 CNcsPopupListBox::CNcsPopupListBox( CNcsHeaderContainer& aHeaderContainer, 
    68     MNcsPopupListBoxObserver& aObserver, TBool aRemoteLookupSupported )
    68                                     TBool aRemoteLookupSupported, 
    69     : iMailBox( aMailBox ),
    69                                     CFSMailBox& aMailBox)
    70       iObserver( aObserver ),
    70     : iHeaderContainer( aHeaderContainer ),
       
    71       iMailBox( aMailBox ),
    71       iRemoteLookupSupported( aRemoteLookupSupported ),
    72       iRemoteLookupSupported( aRemoteLookupSupported ),
    72       iCachingInProgress( EFalse ),
    73       iCachingInProgress( EFalse ),
    73       iAppUi( static_cast<CFreestyleEmailUiAppUi*>( iEikonEnv->AppUi() ) )
    74       iAppUi( static_cast<CFreestyleEmailUiAppUi*>( iEikonEnv->AppUi() ) )
    74     {
    75     {
    75     FUNC_LOG;
    76     FUNC_LOG;
    84     FUNC_LOG;
    85     FUNC_LOG;
    85     CEikTextListBox::ConstructL( NULL, CEikListBox::EPopout );
    86     CEikTextListBox::ConstructL( NULL, CEikListBox::EPopout );
    86     SetMopParent( const_cast<CCoeControl*>( aParent ) );
    87     SetMopParent( const_cast<CCoeControl*>( aParent ) );
    87     User::LeaveIfError( SetParent( const_cast<CCoeControl*>( aParent ) ) );
    88     User::LeaveIfError( SetParent( const_cast<CCoeControl*>( aParent ) ) );
    88 
    89 
    89     CreateScrollBarFrameL( EFalse, EFalse, ETrue );
    90     CEikScrollBarFrame* frame = CreateScrollBarFrameL( EFalse, EFalse, ETrue );
    90 
    91 
    91     CEikTextListBox::SetBorder( TGulBorder::ENone );
    92     CEikTextListBox::SetBorder( TGulBorder::ENone );
    92 
    93 
    93     const CFont* font = 
    94     const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont );
    94             AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont );
       
    95     CEikTextListBox::SetItemHeightL( font->FontMaxHeight() + 12 );
    95     CEikTextListBox::SetItemHeightL( font->FontMaxHeight() + 12 );
    96 
    96 
    97     iBackgroundContext = CAknsFrameBackgroundControlContext::NewL(
    97     iBackgroundContext = CAknsFrameBackgroundControlContext::NewL(
    98         KAknsIIDQsnFrPopupSub, Rect(), Rect(), EFalse );
    98         KAknsIIDQsnFrPopupSub, Rect(), Rect(), EFalse );
    99     UpdateTextColors();
    99     UpdateTextColors();
   103         {
   103         {
   104         iContactHandler = NULL;
   104         iContactHandler = NULL;
   105         }
   105         }
   106 
   106 
   107     SetListBoxObserver( this );
   107     SetListBoxObserver( this );
   108     MakeVisible( EFalse );
       
   109     }
   108     }
   110 
   109 
   111 // -----------------------------------------------------------------------------
   110 // -----------------------------------------------------------------------------
   112 // CNcsPopupListBox::InitAndSearchL
   111 // CNcsPopupListBox::InitAndSearchL
   113 // -----------------------------------------------------------------------------
   112 // -----------------------------------------------------------------------------
   120     OperationCompleteL( ESearchContacts, emptyArray );
   119     OperationCompleteL( ESearchContacts, emptyArray );
   121     CleanupStack::PopAndDestroy( &emptyArray );
   120     CleanupStack::PopAndDestroy( &emptyArray );
   122     }
   121     }
   123 
   122 
   124 // ---------------------------------------------------------------------------
   123 // ---------------------------------------------------------------------------
   125 // Hides the popup window.
       
   126 // ---------------------------------------------------------------------------
       
   127 void CNcsPopupListBox::ClosePopupL()
       
   128     {
       
   129     UpdateVisibilityL( EFalse );
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // CNcsPopupListBox::~CNcsPopupListBox
   124 // CNcsPopupListBox::~CNcsPopupListBox
   134 // ---------------------------------------------------------------------------
   125 // ---------------------------------------------------------------------------
   135 CNcsPopupListBox::~CNcsPopupListBox()
   126 CNcsPopupListBox::~CNcsPopupListBox()
   136     {
   127     {
   137     FUNC_LOG;
   128     FUNC_LOG;
   151     }
   142     }
   152 
   143 
   153 // -----------------------------------------------------------------------------
   144 // -----------------------------------------------------------------------------
   154 // CNcsPopupListBox::MopSupplyObject
   145 // CNcsPopupListBox::MopSupplyObject
   155 // -----------------------------------------------------------------------------
   146 // -----------------------------------------------------------------------------
   156 TTypeUid::Ptr CNcsPopupListBox::MopSupplyObject( TTypeUid aId )
   147 TTypeUid::Ptr CNcsPopupListBox::MopSupplyObject(TTypeUid aId)
   157     {
   148     {
   158     FUNC_LOG;
   149     FUNC_LOG;
   159     if ( aId.iUid == MAknsControlContext::ETypeId )
   150     if ( aId.iUid == MAknsControlContext::ETypeId )
   160         {
   151         {
   161         return MAknsControlContext::SupplyMopObject( aId, iBackgroundContext );
   152         return MAknsControlContext::SupplyMopObject( aId, iBackgroundContext );
   180 
   171 
   181     SetViewRectFromClientRect( innerRect );
   172     SetViewRectFromClientRect( innerRect );
   182     TRAP_IGNORE( HandleViewRectSizeChangeL() );
   173     TRAP_IGNORE( HandleViewRectSizeChangeL() );
   183     }
   174     }
   184 
   175 
   185 // -----------------------------------------------------------------------------
       
   186 // CNcsPopupListBox::HandleResourceChange
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 void CNcsPopupListBox::HandleResourceChange( TInt aType )
   176 void CNcsPopupListBox::HandleResourceChange( TInt aType )
   190     {
   177     {
   191     FUNC_LOG;
   178     FUNC_LOG;
   192     CEikTextListBox::HandleResourceChange( aType );
       
   193     if ( aType == KAknsMessageSkinChange )
   179     if ( aType == KAknsMessageSkinChange )
   194         {
   180         {
   195         UpdateTextColors();
   181         UpdateTextColors();
   196         }
   182         }
   197     }
   183     }
   198 
   184 
   199 // -----------------------------------------------------------------------------
       
   200 // CNcsPopupListBox::HandlePointerEventL
       
   201 // -----------------------------------------------------------------------------
       
   202 //
       
   203 void CNcsPopupListBox::HandlePointerEventL( const TPointerEvent& aPointerEvent )
   185 void CNcsPopupListBox::HandlePointerEventL( const TPointerEvent& aPointerEvent )
   204     {
   186     {
   205     CEikTextListBox::HandlePointerEventL( aPointerEvent );
   187     CEikTextListBox::HandlePointerEventL( aPointerEvent );
   206     }
   188     }
   207 
   189 
   208 // -----------------------------------------------------------------------------
   190 // -----------------------------------------------------------------------------
   209 // CNcsPopupListBox::OfferKeyEventL
   191 // CNcsPopupListBox::OfferKeyEventL
   210 // -----------------------------------------------------------------------------
   192 // -----------------------------------------------------------------------------
   211 //
   193 //    
   212 TKeyResponse CNcsPopupListBox::OfferKeyEventL( const TKeyEvent& aKeyEvent,
   194 TKeyResponse CNcsPopupListBox::OfferKeyEventL( const TKeyEvent& aKeyEvent,
   213     TEventCode aType )
   195     TEventCode aType )
   214     {
   196     {
   215     FUNC_LOG;
   197     FUNC_LOG;
   216     TKeyResponse ret( EKeyWasNotConsumed );
   198     TKeyResponse ret( EKeyWasNotConsumed );
   217     if( aKeyEvent.iCode == EKeyDownArrow )
   199     if( aKeyEvent.iCode == EKeyDownArrow )
   218         {
   200         {
   219         MoveRemoteLookupItemL( ERemoteLookupItemDown );
   201         MoveRemoteLookupItemL( ERemoteLookupItemDown );
   220         iView->MoveCursorL( 
   202         iView->MoveCursorL( CListBoxView::ECursorNextItem, CListBoxView::ENoSelection );
   221                 CListBoxView::ECursorNextItem, CListBoxView::ENoSelection );
       
   222 		ret = EKeyWasConsumed;
   203 		ret = EKeyWasConsumed;
   223         } 
   204         } 
   224     else if( aKeyEvent.iCode == EKeyUpArrow )
   205     else if( aKeyEvent.iCode == EKeyUpArrow )
   225         {
   206         {
   226 		TBool stay = EFalse;
   207 		TBool stay = EFalse;
   227         // Move cursor separator line over
   208         // Move cursor separator line over
   228 		if ( CurrentItemIndex() - 1 > 0 && 
   209 		if ( CurrentItemIndex() - 1 > 0 && CurrentItemIndex() - 1 == iRemoteLookupItemPos )
   229 		     CurrentItemIndex() - 1 == iRemoteLookupItemPos )
       
   230 			{
   210 			{
   231 	        MoveRemoteLookupItemL( ERemoteLookupItemUp );
   211 	        MoveRemoteLookupItemL( ERemoteLookupItemUp );
   232 	        iView->MoveCursorL( CListBoxView::ECursorPreviousItem, 
   212 	        iView->MoveCursorL( CListBoxView::ECursorPreviousItem, CListBoxView::ENoSelection );
   233 	                            CListBoxView::ENoSelection );
       
   234 			stay = ETrue;
   213 			stay = ETrue;
   235 			}
   214 			}
   236 
   215 
   237         MoveRemoteLookupItemL( ERemoteLookupItemUp );
   216         MoveRemoteLookupItemL( ERemoteLookupItemUp );
   238         iView->MoveCursorL( CListBoxView::ECursorPreviousItem, 
   217         iView->MoveCursorL( CListBoxView::ECursorPreviousItem, CListBoxView::ENoSelection );
   239                             CListBoxView::ENoSelection );
       
   240 	    if( stay )
   218 	    if( stay )
   241 			{
   219 			{
   242 	        MoveRemoteLookupItemL( ERemoteLookupItemDown );
   220 	        MoveRemoteLookupItemL( ERemoteLookupItemDown );
   243 
   221 
   244 			iView->MoveCursorL( CListBoxView::ECursorNextItem, 
   222 			iView->MoveCursorL( CListBoxView::ECursorNextItem, CListBoxView::ENoSelection );
   245 			                    CListBoxView::ENoSelection );
       
   246 			}
   223 			}
   247 
   224 
   248 
   225 
   249     	ret = EKeyWasConsumed;
   226     	ret = EKeyWasConsumed;
   250         }
   227         }
   251        
   228        
   252     if( ret == EKeyWasNotConsumed )
   229     if( ret == EKeyWasNotConsumed )
   253         {
   230         {
   254         ret = CEikListBox::OfferKeyEventL( aKeyEvent, aType );
   231         ret = CEikListBox::OfferKeyEventL( aKeyEvent, aType );
   255         }
   232         }
   256 	// call HandleItemAdditionL just in case. There might be changes on remote
   233 	// call HandleItemAdditionL just in case. There might be changes on remote lookup item place.
   257     // lookup item place.
   234 	// The call is here, because we don't want to have extra redraw events when the popuplist
   258 	// The call is here, because we don't want to have extra redraw events when
   235 	// is not fully updated.
   259     // the popuplist is not fully updated.
       
   260 	HandleItemAdditionL(); 
   236 	HandleItemAdditionL(); 
   261     return ret;
   237     return ret;
   262     }
   238     }
   263 
   239 
   264 // ---------------------------------------------------------------------------
   240 // ---------------------------------------------------------------------------
   269     TListBoxEvent aEventType )
   245     TListBoxEvent aEventType )
   270     {
   246     {
   271     if ( aEventType == EEventItemClicked || 
   247     if ( aEventType == EEventItemClicked || 
   272          aEventType == EEventItemSingleClicked )
   248          aEventType == EEventItemSingleClicked )
   273         {
   249         {
   274         iObserver.PopupItemSelectedL();
   250         iHeaderContainer.DoPopupSelectL();
   275         }
   251         }
   276     }
   252     }
   277 
   253 
   278 // -----------------------------------------------------------------------------
   254 // -----------------------------------------------------------------------------
   279 // CNcsPopupListBox::OperationComplete
   255 // CNcsPopupListBox::OperationComplete
   303 	{
   279 	{
   304     FUNC_LOG;
   280     FUNC_LOG;
   305 	
   281 	
   306 	if ( aCmd == ESearchContacts )
   282 	if ( aCmd == ESearchContacts )
   307 		{
   283 		{
   308 		// KerrNotReady --> caching in progress,
   284 		// KerrNotReady --> caching in progress, KErrNotFound --> caching not started yet
   309 	    // KErrNotFound --> caching not started yet
   285 		if ( (aError == KErrNotReady) || (aError == KErrNotFound) )
   310 		if ( ( aError == KErrNotReady ) || ( aError == KErrNotFound ) )
       
   311 			{
   286 			{
   312 			if( !iAppUi->AppUiExitOngoing() )
   287 			if(!iAppUi->AppUiExitOngoing()) //<cmail>
   313 			    {
   288 			    TFsEmailUiUtility::ShowInfoNoteL( R_FSE_EDITOR_INFO_BUILDING_CACHE );
   314 			    TFsEmailUiUtility::ShowInfoNoteL( 
       
   315 			            R_FSE_EDITOR_INFO_BUILDING_CACHE );
       
   316 			    }
       
   317 			iCachingInProgress = ETrue;
   289 			iCachingInProgress = ETrue;
   318 			}
   290 			}
   319 		if ( aError == KErrNone && iCachingInProgress )
   291 		if ( aError == KErrNone && iCachingInProgress )
   320 			{
   292 			{
   321 			if ( !iAppUi->AppUiExitOngoing() )
   293 			if(!iAppUi->AppUiExitOngoing()) //<cmail>
   322 			    {
   294 			    TFsEmailUiUtility::ShowInfoNoteL( R_FSE_EDITOR_INFO_CACHING_COMPLETED );
   323 			    TFsEmailUiUtility::ShowInfoNoteL( 
       
   324 			            R_FSE_EDITOR_INFO_CACHING_COMPLETED );
       
   325 			    }
       
   326 			iCachingInProgress = EFalse;
   295 			iCachingInProgress = EFalse;
   327 			}
   296 			}
   328 		}
   297 		}
   329 	}
   298 	}
   330 
   299 
   336     {
   305     {
   337     FUNC_LOG;
   306     FUNC_LOG;
   338     delete iCurrentSearchText;
   307     delete iCurrentSearchText;
   339     iCurrentSearchText = NULL;
   308     iCurrentSearchText = NULL;
   340     iCurrentSearchText = aText.AllocL();
   309     iCurrentSearchText = aText.AllocL();
   341     if ( !iCachingInProgress )
   310     if ( !iCachingInProgress  )
   342         {
   311         {
   343         if ( iContactHandler )
   312         if ( iContactHandler  )
   344             {
   313             {
   345             iContactHandler->SearchMatchesL( aText, this, &iMailBox, aMode );
   314             iContactHandler->SearchMatchesL( aText, this, &iMailBox, aMode );
   346             }
       
   347         else
       
   348             {
       
   349             // update list for languages which don't support PCS
       
   350             UpdateListL();
       
   351             }
   315             }
   352         }
   316         }
   353     }
   317     }
   354 
   318 
   355 // -----------------------------------------------------------------------------
   319 // -----------------------------------------------------------------------------
   365         {
   329         {
   366         CFSEmailUiClsItem* clsItem = NULL;
   330         CFSEmailUiClsItem* clsItem = NULL;
   367         if ( iRemoteLookupSupported )
   331         if ( iRemoteLookupSupported )
   368             {
   332             {
   369             // calculate index of item
   333             // calculate index of item
   370             TInt index = ( CurrentItemIndex() > iRemoteLookupItemPos ? 
   334             TInt index = (CurrentItemIndex() > iRemoteLookupItemPos ? CurrentItemIndex() - 1 : CurrentItemIndex());
   371                 CurrentItemIndex() - 1 : CurrentItemIndex() );
       
   372             clsItem = iMatchingItems[index];
   335             clsItem = iMatchingItems[index];
   373             }
   336             }
   374         else
   337         else
   375             {
   338             {
   376             clsItem = iMatchingItems[CurrentItemIndex()];
   339             clsItem = iMatchingItems[CurrentItemIndex()]; // no iRemoteLookupItemPos
   377             }
   340             }
   378 
   341 
   379         addressObject= CNcsEmailAddressObject::NewL( 
   342         addressObject= CNcsEmailAddressObject::NewL( clsItem->DisplayName(), clsItem->EmailAddress() );
   380                 clsItem->DisplayName(), clsItem->EmailAddress() );
       
   381         CleanupStack::PushL( addressObject );
   343         CleanupStack::PushL( addressObject );
   382         if ( clsItem->MultipleEmails() )
   344         if ( clsItem->MultipleEmails() )
   383             {
   345             {
   384             addressObject->SetDisplayFull( ETrue );
   346             addressObject->SetDisplayFull( ETrue );
   385             }
   347             }
   426     }
   388     }
   427 
   389 
   428 // -----------------------------------------------------------------------------
   390 // -----------------------------------------------------------------------------
   429 // CNcsPopupListBox::CurrentPopupClsItemsArray
   391 // CNcsPopupListBox::CurrentPopupClsItemsArray
   430 // -----------------------------------------------------------------------------
   392 // -----------------------------------------------------------------------------
   431 const RPointerArray<CFSEmailUiClsItem>& 
   393 const RPointerArray<CFSEmailUiClsItem>& CNcsPopupListBox::CurrentPopupClsItemsArray() const
   432 CNcsPopupListBox::CurrentPopupClsItemsArray() const
       
   433     {
   394     {
   434     return iMatchingItems;
   395     return iMatchingItems;
   435     }
   396     }
   436 
   397 
   437 // -----------------------------------------------------------------------------
   398 // -----------------------------------------------------------------------------
   456 // CNcsPopupListBox::SetListItemsFromArrayL
   417 // CNcsPopupListBox::SetListItemsFromArrayL
   457 // -----------------------------------------------------------------------------
   418 // -----------------------------------------------------------------------------
   458 void CNcsPopupListBox::SetListItemsFromArrayL()
   419 void CNcsPopupListBox::SetListItemsFromArrayL()
   459 	{
   420 	{
   460     FUNC_LOG;
   421     FUNC_LOG;
   461 
   422 	// reset the cursor to point to the first item
       
   423     //iView->MoveCursorL( CListBoxView::ECursorFirstItem, CListBoxView::ENoSelection);
   462 	Reset();
   424 	Reset();
   463 	
   425 	
   464 	// Create totally new text array
   426 	// Create totally new text array
   465 	CreateTextArrayAndSetToTheListboxL( ETrue );
   427 	CreateTextArrayAndSetToTheListboxL( ETrue );
   466 
   428 
   467 	TInt matchCount = iMatchingItems.Count();
       
   468 	// Remote lookup item's index is set as last item by default
       
   469 	// (in case of empty matching items list it is the only item)
       
   470 	TInt rmluIndex = matchCount;
       
   471 
       
   472 	// append texts to text array
   429 	// append texts to text array
   473     for( TInt i=0; i < matchCount; i++ )
   430 	for( TInt i=0; i < iMatchingItems.Count(); i++ )
   474         {
   431 		{
   475         iItemTextsArray->AppendL( iMatchingItems[i]->FullTextL() );
   432 		iItemTextsArray->AppendL( iMatchingItems[i]->FullTextL() );
   476         if ( iRemoteLookupSupported && 
   433 		}
   477              rmluIndex == matchCount &&
       
   478              iMatchingItems[i]->EmailAddress().Compare( KNullDesC ) == 0 )
       
   479             {
       
   480             rmluIndex = i;
       
   481             }
       
   482         }
       
   483 
   434 
   484 	// Update rmlu item
   435 	// Update rmlu item
   485 	SetRemoteLookupItemToTheListL( rmluIndex );
   436 	SetRemoteLookupItemFirstToTheListL();
   486 
   437 	
   487 	SetPopupRect();
   438 	SetPopupRect();
   488 	SetScrollBarVisibilityL();
   439 	SetScrollBarVisibilityL();
   489 	HandleItemAdditionL();
   440 	HandleItemAdditionL();
   490 
   441 
   491     if ( iItemTextsArray && iItemTextsArray->Count() > 0 )
   442     if ( iItemTextsArray && iItemTextsArray->Count() > 0 )
   500     }
   451     }
   501 
   452 
   502 // -----------------------------------------------------------------------------
   453 // -----------------------------------------------------------------------------
   503 // CNcsPopupListBox::RoundToItemHeight
   454 // CNcsPopupListBox::RoundToItemHeight
   504 // -----------------------------------------------------------------------------
   455 // -----------------------------------------------------------------------------
   505 TInt CNcsPopupListBox::RoundToItemHeight( const TInt aPopupHeight ) const
   456 TInt CNcsPopupListBox::RoundToItemHeight(const TInt aPopupHeight) const
   506     {
   457     {
   507     TReal fullItems; // number of full visible items in window
   458     TReal fullItems; // number of full visible items in window
   508     TInt err = Math::Round( fullItems, ( aPopupHeight / ItemHeight() ), 0 );
   459     TInt err = Math::Round(fullItems, (aPopupHeight / ItemHeight()), 0);
   509     if ( err == KErrNone )
   460     if (err == KErrNone)
   510         {
   461         {
   511         return (TInt)( fullItems * ItemHeight() ); 
   462         return (TInt)(fullItems * ItemHeight()); 
   512         }
   463         }
   513     return aPopupHeight; // in case of error
   464     return aPopupHeight; // in case of error
   514     }
   465     }
   515 
   466 
   516 // -----------------------------------------------------------------------------
   467 // -----------------------------------------------------------------------------
   517 // CNcsPopupListBox::SetPopupRect
   468 // CNcsPopupListBox::SetPopupRect
   518 // -----------------------------------------------------------------------------
   469 // -----------------------------------------------------------------------------
   519 void CNcsPopupListBox::SetPopupRect()
   470 void CNcsPopupListBox::SetPopupRect()
   520     {
   471     {
   521     FUNC_LOG;
   472     FUNC_LOG;
   522 
   473     // The popup width and horizontal position is adjusted so that it
   523     // The popup height and vertical position is adjusted based on the
   474     // will be within the area specified in both layout data and the set
       
   475     // maximum rect.
       
   476     TAknLayoutRect editorPane;
       
   477     editorPane.LayoutRect( iAppUi->ClientRect(),
       
   478         TAknWindowComponentLayout::Compose(
       
   479             TAknWindowComponentLayout::Compose(
       
   480                 AknLayoutScalable_Apps::list_cmail_pane(),
       
   481                 AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0 ) ),
       
   482             AknLayoutScalable_Apps::list_single_cmail_header_editor_pane_bg( 4 ) ) );
       
   483     TRect editorPaneRect = editorPane.Rect();
       
   484 
       
   485     TRect newRect = iPopupMaxRect;
       
   486     newRect.iTl.iX = Max( iPopupMaxRect.iTl.iX, editorPaneRect.iTl.iX );
       
   487     newRect.iBr.iX = Min( iPopupMaxRect.iBr.iX, editorPaneRect.iBr.iX );
       
   488 
       
   489     // Thhe popup height and vertical position is adjusted based on the
   524     // available space below and above the cursor and the number of items
   490     // available space below and above the cursor and the number of items
   525     // in the list.
   491     // in the list.
   526     TRect newRect = iPopupMaxRect;
   492     const TRect rect = iPopupMaxRect;
   527     TAknLayoutRect subpane;
   493     TAknLayoutRect subpane;
   528     subpane.LayoutRect( newRect, 
   494     subpane.LayoutRect( rect, AknLayoutScalable_Avkon::bg_popup_sub_pane_g1() );
   529             AknLayoutScalable_Avkon::bg_popup_sub_pane_g1() );
   495     const TRect subpaneRect = subpane.Rect();
   530     const TInt frameHeights = 
   496 
   531             iPopupMaxRect.Height() - subpane.Rect().Height();
   497     const TInt frameHeights = iPopupMaxRect.Height() - subpaneRect.Height();
   532 
   498 
   533     // This is the total height in pixels needed to show all items
   499     // This is the total height in pixels needed to show all items
   534     const TInt minimumHeight = frameHeights + 
   500     TInt minimumHeight = frameHeights + 
   535         CalcHeightBasedOnNumOfItems( Model()->NumberOfItems() );
   501         CalcHeightBasedOnNumOfItems( Model()->NumberOfItems() );
   536 
   502 
       
   503     CCoeControl* container = Parent()->Parent();
       
   504     TInt containerTop = container->PositionRelativeToScreen().iY;
       
   505     TInt containerHeight = container->Rect().Height();
       
   506     TInt containerCenter = containerTop + containerHeight / 2;
       
   507 
   537     // Get height of one line in Address field
   508     // Get height of one line in Address field
   538     TInt toLineHeight =
   509     CNcsHeaderContainer* headerObj = static_cast<CNcsHeaderContainer* >(Parent());
   539             static_cast<CNcsHeaderContainer*>( Parent() )->GetToLineHeight();
   510     TInt toLineHeight = headerObj->GetToLineHeight(); // height of one line height
   540     if ( toLineHeight == 0 )
   511     if ( toLineHeight == 0 )
   541         {
   512         {
   542         toLineHeight = ItemHeight();
   513         toLineHeight = ItemHeight();
   543         }
   514         }
   544 
   515 
   545     TInt newHeight = minimumHeight; // default window height
   516     TInt newHeight = minimumHeight; // default window height
   546     CCoeControl* container = Parent()->Parent();
   517 
   547     const TInt maxHeight = 
   518     // latch listbox on the bottom of the editor field
   548             container->Rect().Height() - 
   519     if ( newRect.iTl.iY <= containerCenter ) 
   549             ( newRect.iTl.iY - container->PositionRelativeToScreen().iY );
   520         {
   550     newHeight = 
   521         TInt maxHeight = containerHeight - ( newRect.iTl.iY - containerTop ); 
   551             RoundToItemHeight( maxHeight - frameHeights ) + frameHeights;
   522         newHeight = RoundToItemHeight( maxHeight - frameHeights ) + frameHeights;
   552     if ( newHeight > minimumHeight )
   523         if ( newHeight > minimumHeight )
   553         {
   524             {
   554         newHeight = minimumHeight; // shrink window (if needed)
   525             newHeight = minimumHeight; // shrink window (if needed)
   555         }
   526             }
   556 
   527         }
   557     newRect.SetHeight( newHeight );
   528     // latch listbox on the top of the editor field
       
   529     else
       
   530         {
       
   531         TInt yOffset = -minimumHeight - toLineHeight; // how much up
       
   532         TInt newTlY = newRect.iTl.iY + yOffset;       // new Top Left Y coordinate
       
   533         if ( newTlY >= containerTop )
       
   534             {
       
   535             newRect.Move( 0, yOffset );
       
   536             }
       
   537         else
       
   538             {
       
   539             // shrink height to visible area and move
       
   540             TInt maxHeight = newRect.iTl.iY - toLineHeight - containerTop;
       
   541             newHeight = RoundToItemHeight( maxHeight - frameHeights ) + frameHeights;
       
   542             newRect.Move( 0, -newHeight - toLineHeight );
       
   543             }
       
   544         }
       
   545     newRect.SetHeight( newHeight ); // set new height
   558     SetRect( newRect );
   546     SetRect( newRect );
   559     }
   547     }
   560 
   548 
   561 // -----------------------------------------------------------------------------
   549 // -----------------------------------------------------------------------------
   562 // CNcsPopupListBox::SetScrollBarVisibilityL
   550 // CNcsPopupListBox::SetScrollBarVisibilityL
   563 // -----------------------------------------------------------------------------
   551 // -----------------------------------------------------------------------------
   564 void CNcsPopupListBox::SetScrollBarVisibilityL()
   552 void CNcsPopupListBox::SetScrollBarVisibilityL()
   565 	{
   553 	{
   566     FUNC_LOG;
   554     FUNC_LOG;
   567 	// This is the total height in pixels needed to show all items
   555 	// This is the total height in pixels needed to show all items
   568 	TInt minimumHeight =
   556 	TInt minimumHeight = CalcHeightBasedOnNumOfItems( Model()->NumberOfItems() );
   569 	        CalcHeightBasedOnNumOfItems( Model()->NumberOfItems() );
       
   570 
   557 
   571 	// Show scroll bar if there is more items we can show at once.
   558 	// Show scroll bar if there is more items we can show at once.
   572 	if( iPopupMaxRect.Height() > minimumHeight )
   559 	if( iPopupMaxRect.Height() > minimumHeight ) 
   573 		{
   560 		{
   574 		ScrollBarFrame()->SetScrollBarVisibilityL(
   561 		ScrollBarFrame()->SetScrollBarVisibilityL(
   575 			CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); 
   562 			CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); 
   576 		}
   563 		}
   577 	else 
   564 	else 
   581 		}
   568 		}
   582 	}
   569 	}
   583 
   570 
   584 
   571 
   585 // -----------------------------------------------------------------------------
   572 // -----------------------------------------------------------------------------
   586 // CNcsPopupListBox::SetRemoteLookupItemToTheListL
   573 // CNcsPopupListBox::SetRemoteLookupItemFirstToTheListL
   587 // -----------------------------------------------------------------------------
   574 // -----------------------------------------------------------------------------
   588 void CNcsPopupListBox::SetRemoteLookupItemToTheListL( TInt aIndex )
   575 void CNcsPopupListBox::SetRemoteLookupItemFirstToTheListL()
   589 	{
   576 	{
   590     FUNC_LOG;
   577     FUNC_LOG;
   591 	if( iRemoteLookupSupported )
   578 	if( iRemoteLookupSupported )
   592 		{
   579 		{
   593 		HBufC* rmluText = StringLoader::LoadLC( 
   580 		HBufC* rmluText = StringLoader::LoadLC( 
   594 		    R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, 
   581 		    R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, *iCurrentSearchText );
   595 		    *iCurrentSearchText );
       
   596 		
   582 		
   597 		iItemTextsArray->InsertL( aIndex, *rmluText );
   583 		iItemTextsArray->InsertL( 0, *rmluText );
   598 		CleanupStack::PopAndDestroy( rmluText );
   584 		CleanupStack::PopAndDestroy( rmluText );
   599 		iRemoteLookupItemPos = aIndex;
   585 		iRemoteLookupItemPos = 0;
   600 		}
   586 		}
   601 	else
   587 	else
   602 		{
   588 		{
   603 		iRemoteLookupItemPos = -1;
   589 		iRemoteLookupItemPos = -1;
   604 		}
   590 		}
   605 	}
   591 	}
   606 
   592 
   607 // -----------------------------------------------------------------------------
   593 // -----------------------------------------------------------------------------
   608 // CNcsPopupListBox::MoveRemoteLookupItemL
   594 // CNcsPopupListBox::MoveRemoteLookupItemL
   609 // -----------------------------------------------------------------------------
   595 // -----------------------------------------------------------------------------
   610 void CNcsPopupListBox::MoveRemoteLookupItemL( 
   596 void CNcsPopupListBox::MoveRemoteLookupItemL( TRemoteLookupItemMoveDirection aDirection )
   611         TRemoteLookupItemMoveDirection aDirection )
       
   612 	{
   597 	{
   613     FUNC_LOG;
   598     FUNC_LOG;
   614 	if( iRemoteLookupSupported )
   599 	if( iRemoteLookupSupported )
   615 		{
   600 		{
   616 		TInt newRMLUItemIndex = -1;
   601 		TInt newRMLUItemIndex = -1;
   631 
   616 
   632 		if( ItemExists ( newCurrentItem ) && newRMLUItemIndex != -1 )
   617 		if( ItemExists ( newCurrentItem ) && newRMLUItemIndex != -1 )
   633 			{
   618 			{
   634 			iItemTextsArray->Delete( iRemoteLookupItemPos );
   619 			iItemTextsArray->Delete( iRemoteLookupItemPos );
   635 
   620 
   636 			HBufC* rmluText = StringLoader::LoadLC(
   621 			HBufC* rmluText = StringLoader::LoadLC( R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, *iCurrentSearchText );
   637 			        R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH,
       
   638 			        *iCurrentSearchText );
       
   639 			
   622 			
   640 			iItemTextsArray->InsertL( newRMLUItemIndex, *rmluText );
   623 			iItemTextsArray->InsertL( newRMLUItemIndex, *rmluText );
   641 			CleanupStack::PopAndDestroy( rmluText );
   624 			CleanupStack::PopAndDestroy( rmluText );
   642 			iRemoteLookupItemPos = newRMLUItemIndex;
   625 			iRemoteLookupItemPos = newRMLUItemIndex;
   643 			}
   626 			}
   646 
   629 
   647 
   630 
   648 // -----------------------------------------------------------------------------
   631 // -----------------------------------------------------------------------------
   649 // CNcsPopupListBox::CreateTextArrayAndSetToTheListboxL
   632 // CNcsPopupListBox::CreateTextArrayAndSetToTheListboxL
   650 // -----------------------------------------------------------------------------
   633 // -----------------------------------------------------------------------------
   651 void CNcsPopupListBox::CreateTextArrayAndSetToTheListboxL(
   634 void CNcsPopupListBox::CreateTextArrayAndSetToTheListboxL( const TBool& aResetIfExists )
   652         const TBool& aResetIfExists )
       
   653 	{
   635 	{
   654     FUNC_LOG;
   636     FUNC_LOG;
   655 	if( !iItemTextsArray )
   637 	if( !iItemTextsArray )
   656 		{
   638 		{
   657 		iItemTextsArray = new ( ELeave ) CDesCArraySeg( 8 );
   639 		iItemTextsArray = new ( ELeave ) CDesCArraySeg( 8 );
   676 :CListItemDrawer(), iListBox( aListBox )
   658 :CListItemDrawer(), iListBox( aListBox )
   677     {
   659     {
   678     FUNC_LOG;
   660     FUNC_LOG;
   679     // Store a GC for later use
   661     // Store a GC for later use
   680     iGc = &CCoeEnv::Static()->SystemGc();
   662     iGc = &CCoeEnv::Static()->SystemGc();
   681     SetGc( iGc );
   663     SetGc(iGc);
   682     }
   664     }
   683 
   665 
   684 // -----------------------------------------------------------------------------
   666 // -----------------------------------------------------------------------------
   685 // CNcsListItemDrawer::DrawActualItem
   667 // CNcsListItemDrawer::DrawActualItem
   686 // -----------------------------------------------------------------------------
   668 // -----------------------------------------------------------------------------
   687 void CNcsListItemDrawer::DrawActualItem( TInt aItemIndex,
   669 void CNcsListItemDrawer::DrawActualItem(TInt aItemIndex,
   688     const TRect& aActualItemRect, TBool aItemIsCurrent,
   670     const TRect& aActualItemRect, TBool aItemIsCurrent,
   689     TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/,
   671     TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/,
   690     TBool /*aItemIsSelected*/ ) const
   672     TBool /*aItemIsSelected*/) const
   691     {
   673     {
   692     FUNC_LOG;
   674     FUNC_LOG;
   693     iGc->DiscardFont();
   675     iGc->DiscardFont();
   694 
   676 
   695     // Get reference to curren popup cls item list.
   677     // Get reference to curren popup cls item list.
   696     const RPointerArray<CFSEmailUiClsItem>& clsItemArray =
   678     const RPointerArray<CFSEmailUiClsItem>& clsItemArray =
   697         iListBox.CurrentPopupClsItemsArray();
   679         iListBox.CurrentPopupClsItemsArray();
   698     TInt rmluPosition = iListBox.RemoteLookupItemPos();
   680     TInt rmluPosition = iListBox.RemoteLookupItemPos();
   699 
   681 
   700     // Sets all the attributes, like font, text color and background color.
   682     // Sets all the attributes, like font, text color and background color.
   701     const CFont* font = AknLayoutUtils::FontFromId(
   683     const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont );
   702             EAknLogicalFontPrimarySmallFont );
       
   703     iGc->UseFont( font );
   684     iGc->UseFont( font );
   704     iGc->SetPenStyle( CGraphicsContext::ESolidPen );
   685     iGc->SetPenStyle( CGraphicsContext::ESolidPen );
   705     iGc->SetBrushStyle( CGraphicsContext::ENullBrush );
   686     iGc->SetBrushStyle( CGraphicsContext::ENullBrush );
   706 
   687 
   707     TRect itemRect = aActualItemRect;
   688     TRect itemRect = aActualItemRect;
   800         }
   781         }
   801 
   782 
   802 		// For now, we support underlining the matching part only if the
   783 		// For now, we support underlining the matching part only if the
   803 		//       text is written completely with left-to-right script
   784 		//       text is written completely with left-to-right script
   804 		
   785 		
   805 		// We know the text contains RTL script if the display string is not
   786 		// We know the text contains RTL script if the display string is not just
   806 		// just truncated version of the original string.
   787 		// truncated version of the original string.
   807 		TPtrC dispText = bidiText->DisplayText();
   788 		TPtrC dispText = bidiText->DisplayText();
   808 		// -1 to omit the truncation character
   789 		TInt compLength = dispText.Length() - 1; // -1 to omit the truncation character
   809 		TInt compLength = dispText.Length() - 1;
       
   810 		TBool textContainsRtl = 
   790 		TBool textContainsRtl = 
   811             ( itemText.Left( compLength ) != dispText.Left( compLength ) );
   791             ( itemText.Left(compLength) != dispText.Left(compLength) );
   812 		
   792 		
   813         const RArray<TPsMatchLocation>& underlines = 
   793         const RArray<TPsMatchLocation>& underlines = clsItemArray[aItemIndex]->Highlights();
   814                 clsItemArray[aItemIndex]->Highlights();
       
   815         
   794         
   816 		if ( underlines.Count() > 0 && !textContainsRtl )
   795 		if ( underlines.Count() > 0 && !textContainsRtl )
   817 			{
   796 			{
   818 			TInt i = 0;
   797 			TInt i = 0;
   819 			TBool partsLeft = ETrue;
   798 			TBool partsLeft = ETrue;
   824 				{
   803 				{
   825 				if ( currentTextStart < underlines[i].index )
   804 				if ( currentTextStart < underlines[i].index )
   826 					{
   805 					{
   827 					// draw letters to the start of the underlined part
   806 					// draw letters to the start of the underlined part
   828 					currentTextLength = underlines[i].index - currentTextStart;
   807 					currentTextLength = underlines[i].index - currentTextStart;
   829 					DrawPartOfItem( textRect, *font, currentTextStart,
   808 					DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText,
   830                                     currentTextLength, itemText,
       
   831 									EFalse, topToBaseline );
   809 									EFalse, topToBaseline );
   832 					}
   810 					}
   833 				else if ( currentTextStart == underlines[i].index )
   811 				else if ( currentTextStart == underlines[i].index )
   834 					{
   812 					{
   835 					// draw underlined letters
   813 					// draw underlined letters
   836 					currentTextLength = underlines[i].length;
   814 					currentTextLength = underlines[i].length;
   837 					
   815 					
   838 					DrawPartOfItem( textRect, *font, currentTextStart,
   816 					DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText,
   839                                     currentTextLength, itemText,
       
   840 									ETrue, topToBaseline );
   817 									ETrue, topToBaseline );
   841 					i++;
   818 					i++;
   842 					}
   819 					}
   843 				else 
   820 				else 
   844 					{
   821 					{
   845 					// This is here, because PCS Engine might give you 
   822 					// This is here, because PCS Engine might give you duplicate match entries,
   846 				    // duplicate match entries, in this case we're not 
   823 					// in this case we're not advancing text but we'll skip that match
   847                     // advancing text but we'll skip that match
       
   848 					currentTextLength = 0;
   824 					currentTextLength = 0;
   849 					i++;
   825 					i++;
   850 					}
   826 					}
   851 					// update text start point
   827 					// update text start point
   852 					currentTextStart += currentTextLength;
   828 					currentTextStart += currentTextLength;
   853 				
   829 				
   854 				if ( i >= underlines.Count() )
   830 				if ( i >= underlines.Count() )
   855 					{
   831 					{
   856 					partsLeft = EFalse;
   832 					partsLeft = EFalse;
   857 					// draw rest of the letters, if there are any after the
   833 					// draw rest of the letters, if there are any after the last underlined part
   858 					// last underlined part
       
   859 					if ( currentTextStart < itemText.Length() )
   834 					if ( currentTextStart < itemText.Length() )
   860 						{
   835 						{
   861 						currentTextLength = 
   836 						currentTextLength = itemText.Length() - currentTextStart;
   862 						        itemText.Length() - currentTextStart;
   837 						DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText,
   863 						DrawPartOfItem( textRect, *font, currentTextStart,
       
   864                                         currentTextLength, itemText,
       
   865 										EFalse, topToBaseline );
   838 										EFalse, topToBaseline );
   866 						}
   839 						}
   867 					}
   840 					}
   868 				
   841 				
   869 				}
   842 				}
   880 	}
   853 	}
   881 
   854 
   882 // -----------------------------------------------------------------------------
   855 // -----------------------------------------------------------------------------
   883 // CNcsListItemDrawer::DrawPartOfItem
   856 // CNcsListItemDrawer::DrawPartOfItem
   884 // -----------------------------------------------------------------------------
   857 // -----------------------------------------------------------------------------
   885 void CNcsListItemDrawer::DrawPartOfItem(
   858 void CNcsListItemDrawer::DrawPartOfItem( const TRect& aItemRect, const CFont& aFont,
   886         const TRect& aItemRect, const CFont& aFont,
   859 						 TInt aStartPos, TInt aLength, const TDesC& aDes,
   887         TInt aStartPos, TInt aLength, const TDesC& aDes,
   860 						 TBool aUnderlined, TInt aBaselineOffsetFromTop  ) const
   888         TBool aUnderlined, TInt aBaselineOffsetFromTop ) const
       
   889 	{
   861 	{
   890     FUNC_LOG;
   862     FUNC_LOG;
   891 	if( aUnderlined )
   863 	if( aUnderlined )
   892 		{
   864 		{
   893 		iGc->SetUnderlineStyle( EUnderlineOn );
   865 		iGc->SetUnderlineStyle( EUnderlineOn );
   902 	iGc->DrawText( aDes.Mid( aStartPos, aLength ), 
   874 	iGc->DrawText( aDes.Mid( aStartPos, aLength ), 
   903 	        currentTextRect, aBaselineOffsetFromTop );
   875 	        currentTextRect, aBaselineOffsetFromTop );
   904 	}
   876 	}
   905 
   877 
   906 
   878 
   907 // ---------------------------------------------------------------------------
       
   908 // Updates popup list content.
       
   909 // ---------------------------------------------------------------------------
       
   910 //
       
   911 void CNcsPopupListBox::UpdateListL()
   879 void CNcsPopupListBox::UpdateListL()
   912     {
   880     {
   913     FUNC_LOG;
   881     FUNC_LOG;
   914     SetListItemsFromArrayL();
   882     SetListItemsFromArrayL();
   915 
   883 
   916     // Close the popup if it's empty and make sure it's visible if it's not empty.
   884     // Close the popup if it's empty and make sure it's visible if it's not empty.
   917     UpdateVisibilityL( !IsPopupEmpty() );
   885     if ( IsPopupEmpty() )
   918     }
   886         {
   919 
   887         iHeaderContainer.ClosePopupContactListL();
   920 // ---------------------------------------------------------------------------
   888         }
   921 // Shows or hides popup if necessary.
   889     else
   922 // ---------------------------------------------------------------------------
   890         {
   923 //
   891         MakeVisible( ETrue );
   924 void CNcsPopupListBox::UpdateVisibilityL( TBool aVisible )
       
   925     {
       
   926     if ( IsVisible() != aVisible )
       
   927         {
       
   928         if ( iObserver.PopupVisibilityChangingL( aVisible ) )
       
   929             {
       
   930             MakeVisible( aVisible );
       
   931             if ( aVisible )
       
   932                 {
       
   933                 UpdateScrollBarsL();
       
   934                 SetScrollBarVisibilityL();
       
   935                 // Popup is always on top (also on top of e.g. toolbar buttons)
       
   936                 DrawableWindow()->SetOrdinalPosition( 0 );
       
   937                 }
       
   938             }
       
   939         }
       
   940     else if ( IsVisible() )
       
   941         {
       
   942         UpdateScrollBarsL();
   892         UpdateScrollBarsL();
   943         SetScrollBarVisibilityL();
   893         iHeaderContainer.ShowPopupMenuBarL( ETrue );
   944         }
   894         }
   945     }
   895     }
   946 
   896 
   947 // ---------------------------------------------------------------------------
       
   948 // Updates popup text colors.
       
   949 // ---------------------------------------------------------------------------
       
   950 //
       
   951 void CNcsPopupListBox::UpdateTextColors()
   897 void CNcsPopupListBox::UpdateTextColors()
   952     {
   898     {
   953     if ( iItemDrawer )
   899     if ( iItemDrawer )
   954         {
   900         {
   955         // Get skin instance.
   901         // Get skin instance.