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