emailuis/emailui/src/ncspopuplistbox.cpp
branchRCL_3
changeset 8 e1b6206813b4
parent 2 5253a20d2a1e
child 10 f5907b1a1053
equal deleted inserted replaced
4:e7aa27f58ae1 8:e1b6206813b4
   289 // -----------------------------------------------------------------------------
   289 // -----------------------------------------------------------------------------
   290 // CNcsPopupListBox::ReturnCurrentEmailAddressLC
   290 // CNcsPopupListBox::ReturnCurrentEmailAddressLC
   291 // -----------------------------------------------------------------------------
   291 // -----------------------------------------------------------------------------
   292 //
   292 //
   293 CNcsEmailAddressObject* CNcsPopupListBox::ReturnCurrentEmailAddressLC()
   293 CNcsEmailAddressObject* CNcsPopupListBox::ReturnCurrentEmailAddressLC()
   294 	{
   294     {
   295     FUNC_LOG;
   295     FUNC_LOG;
   296 	CNcsEmailAddressObject* addressObject = NULL;
   296     CNcsEmailAddressObject* addressObject = NULL;
   297 
   297 
   298     if ( iMatchingItems.Count() )
   298     if ( iMatchingItems.Count() )
   299 		{
   299         {
   300 		CFSEmailUiClsItem* clsItem = NULL;
   300         CFSEmailUiClsItem* clsItem = NULL;
   301 		if ( iRemoteLookupSupported )
   301         if ( iRemoteLookupSupported )
   302 			{
   302             {
   303 			clsItem = iMatchingItems[CurrentItemIndex()-1];  // -1 because of iRemoteLookupItemPos
   303             // calculate index of item
   304 			}
   304             TInt index = (CurrentItemIndex() > iRemoteLookupItemPos ? CurrentItemIndex() - 1 : CurrentItemIndex());
   305 		else
   305             clsItem = iMatchingItems[index];
   306 			{
   306             }
   307 			clsItem = iMatchingItems[CurrentItemIndex()]; // no iRemoteLookupItemPos			
   307         else
   308 			}
   308             {
   309 		addressObject= CNcsEmailAddressObject::NewL( clsItem->DisplayName(), clsItem->EmailAddress() );
   309             clsItem = iMatchingItems[CurrentItemIndex()]; // no iRemoteLookupItemPos
   310         CleanupStack::PushL( addressObject );			
   310             }
       
   311 
       
   312         addressObject= CNcsEmailAddressObject::NewL( clsItem->DisplayName(), clsItem->EmailAddress() );
       
   313         CleanupStack::PushL( addressObject );
   311         if ( clsItem->MultipleEmails() )
   314         if ( clsItem->MultipleEmails() )
   312         	{
   315             {
   313 
   316             addressObject->SetDisplayFull( ETrue );
   314         	addressObject->SetDisplayFull( ETrue );
   317             }
   315         	}
   318         }
   316       
   319 
   317         }
   320     return addressObject;
   318 	return addressObject;
   321     }
   319 	}
       
   320 
   322 
   321 // -----------------------------------------------------------------------------
   323 // -----------------------------------------------------------------------------
   322 // CNcsPopupListBox::SetPopupMaxRect
   324 // CNcsPopupListBox::SetPopupMaxRect
   323 // -----------------------------------------------------------------------------
   325 // -----------------------------------------------------------------------------
   324 void CNcsPopupListBox::SetPopupMaxRect( const TRect& aPopupMaxRect )
   326 void CNcsPopupListBox::SetPopupMaxRect( const TRect& aPopupMaxRect )
   501 			newRMLUItemIndex = iRemoteLookupItemPos + 1;
   503 			newRMLUItemIndex = iRemoteLookupItemPos + 1;
   502 			newCurrentItem = CurrentItemIndex() + 1;
   504 			newCurrentItem = CurrentItemIndex() + 1;
   503 			}
   505 			}
   504 
   506 
   505 
   507 
   506 		if( ItemExists ( newCurrentItem ) )
   508 		if( ItemExists ( newCurrentItem ) && newRMLUItemIndex != -1 )
   507 			{
   509 			{
   508 			iItemTextsArray->Delete( iRemoteLookupItemPos );
   510 			iItemTextsArray->Delete( iRemoteLookupItemPos );
   509 
   511 
   510 			HBufC* rmluText = StringLoader::LoadLC( R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, *iCurrentSearchText );
   512 			HBufC* rmluText = StringLoader::LoadLC( R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, *iCurrentSearchText );
   511 			
   513 			
   578 	iGc->SetPenColor(iBackColor);
   580 	iGc->SetPenColor(iBackColor);
   579 	iGc->SetPenStyle(CGraphicsContext::ESolidPen);
   581 	iGc->SetPenStyle(CGraphicsContext::ESolidPen);
   580 	iGc->SetBrushColor(iBackColor);
   582 	iGc->SetBrushColor(iBackColor);
   581 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   583 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   582 
   584 
       
   585     // draw the background
       
   586 	TRect backgroundRect( aActualItemRect );
       
   587 
       
   588     if ( !aItemIndex ) 
       
   589         {
       
   590         backgroundRect.iTl.iY = 0;
       
   591         }
       
   592     else if ( aItemIndex == iListBox.Model()->NumberOfItems() - 1 ) 
       
   593         {
       
   594         backgroundRect.iBr.iY = iListBox.Size().iHeight;
       
   595         }
       
   596     
       
   597     iGc->DrawRect( backgroundRect );
       
   598     
       
   599 
       
   600     TRect textRect( aActualItemRect );
       
   601     {
       
   602     // temporary const_cast to get scroll width
       
   603     CNcsPopupListBox& tmpListBox = const_cast<CNcsPopupListBox&>(iListBox);
       
   604     textRect.Resize( -tmpListBox.ScrollBarFrame()->ScrollBarBreadth(CEikScrollBar::EVertical), 0 );
       
   605     }
       
   606 
       
   607 
   583 	// Now draw the highlight
   608 	// Now draw the highlight
   584 	if( aItemIsCurrent ) 
   609 	if( aItemIsCurrent ) 
   585 		{
   610 		{
   586 		TRgb highlightColor = iListBox.LayoutHandler().PcsPopupHighlightColor();
   611 		TRgb highlightColor = iListBox.LayoutHandler().PcsPopupHighlightColor();
   587 		iGc->SetBrushColor(highlightColor);
   612 		iGc->SetBrushColor(highlightColor);
   588 //	    AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), *iGc,
   613 //	    AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), *iGc,
   589 //	    	aActualItemRect, aActualItemRect,
   614 //	    	aActualItemRect, aActualItemRect,
   590 //	    	KNcsIIDHighlightBackground, KNcsIIDHighlightBackground );
   615 //	    	KNcsIIDHighlightBackground, KNcsIIDHighlightBackground );
   591 		}
   616         iGc->DrawRect(textRect);
   592 	iGc->DrawRect(aActualItemRect);
   617 		}
   593 
       
   594 
   618 
   595 	iGc->SetPenColor(iTextColor);
   619 	iGc->SetPenColor(iTextColor);
   596 	iGc->SetPenStyle(CGraphicsContext::ESolidPen);
   620 	iGc->SetPenStyle(CGraphicsContext::ESolidPen);
   597 	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   621 	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   598 	TInt topToBaseline = ( aActualItemRect.Height() - font->HeightInPixels() ) / 2
   622 	TInt topToBaseline = ( textRect.Height() - font->HeightInPixels() ) / 2
   599 						+ font->AscentInPixels();
   623 						+ font->AscentInPixels();
   600 
   624 
   601 	TPtrC itemText = iListBox.Model()->ItemText( aItemIndex );
   625 	TPtrC itemText = iListBox.Model()->ItemText( aItemIndex );
   602 
   626 
   603 	// Construct bidirectional text object
   627 	// Construct bidirectional text object
   604 	// <cmail> Removed leave from non-leaving function.
   628 	// <cmail> Removed leave from non-leaving function.
   605 	TBidiText* bidiText = NULL;
   629 	TBidiText* bidiText = NULL;
   606 	TRAPD( err, bidiText = TBidiText::NewL( itemText, 1 ) );
   630 	TRAPD( err, bidiText = TBidiText::NewL( itemText, 1 ) );
   607 	if ( err == KErrNone )
   631 	if ( err == KErrNone )
   608 		{
   632 		{
   609 		bidiText->WrapText( aActualItemRect.Width(), *font, NULL );
   633 		bidiText->WrapText( textRect.Width(), *font, NULL );
   610 		}
   634 		}
   611 		
   635 		
   612 	TPoint leftBase = aActualItemRect.iTl + TPoint( 0, topToBaseline );
   636 	TPoint leftBase = textRect.iTl + TPoint( 0, topToBaseline );
   613 
   637 
   614     if ( err != KErrNone )
   638     if ( err != KErrNone )
   615         {
   639         {
   616         bidiText = NULL; // to be on the safe side
   640         bidiText = NULL; // to be on the safe side
   617         }
   641         }
   623 		bidiText->DrawText( *iGc, leftBase );
   647 		bidiText->DrawText( *iGc, leftBase );
   624 		}
   648 		}
   625 	else
   649 	else
   626 		{
   650 		{
   627 		// if list has rmlu item change item index right
   651 		// if list has rmlu item change item index right
   628 		if ( rmluPosition >= 0 )
   652 		if ( rmluPosition >= 0 && aItemIndex > rmluPosition )
   629 			{
   653 			{
   630 			aItemIndex--;
   654 			aItemIndex--;
   631 			}
   655 			}
   632 
   656 
   633 		// change color to gray if match doesn't have email address.
   657 		// change color to gray if match doesn't have email address.
   660 				{
   684 				{
   661 				if ( currentTextStart < underlines[i].index )
   685 				if ( currentTextStart < underlines[i].index )
   662 					{
   686 					{
   663 					// draw letters to the start of the underlined part
   687 					// draw letters to the start of the underlined part
   664 					currentTextLength = underlines[i].index - currentTextStart;
   688 					currentTextLength = underlines[i].index - currentTextStart;
   665 					DrawPartOfItem( aActualItemRect, *font, currentTextStart, currentTextLength, itemText,
   689 					DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText,
   666 									EFalse, topToBaseline );
   690 									EFalse, topToBaseline );
   667 					}
   691 					}
   668 				else if ( currentTextStart == underlines[i].index )
   692 				else if ( currentTextStart == underlines[i].index )
   669 					{
   693 					{
   670 					// draw underlined letters
   694 					// draw underlined letters
   671 					currentTextLength = underlines[i].length;
   695 					currentTextLength = underlines[i].length;
   672 					
   696 					
   673 					DrawPartOfItem( aActualItemRect, *font, currentTextStart, currentTextLength, itemText,
   697 					DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText,
   674 									ETrue, topToBaseline );
   698 									ETrue, topToBaseline );
   675 					i++;
   699 					i++;
   676 					}
   700 					}
   677 				else 
   701 				else 
   678 					{
   702 					{
   689 					partsLeft = EFalse;
   713 					partsLeft = EFalse;
   690 					// draw rest of the letters, if there are any after the last underlined part
   714 					// draw rest of the letters, if there are any after the last underlined part
   691 					if ( currentTextStart < itemText.Length() )
   715 					if ( currentTextStart < itemText.Length() )
   692 						{
   716 						{
   693 						currentTextLength = itemText.Length() - currentTextStart;
   717 						currentTextLength = itemText.Length() - currentTextStart;
   694 						DrawPartOfItem( aActualItemRect, *font, currentTextStart, currentTextLength, itemText,
   718 						DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText,
   695 										EFalse, topToBaseline );
   719 										EFalse, topToBaseline );
   696 						}
   720 						}
   697 					}
   721 					}
   698 				
   722 				
   699 				}
   723 				}
   744         iHeaderContainer.ClosePopupContactListL();
   768         iHeaderContainer.ClosePopupContactListL();
   745         }
   769         }
   746     else
   770     else
   747         {
   771         {
   748         MakeVisible( ETrue );
   772         MakeVisible( ETrue );
       
   773         UpdateScrollBarsL();
   749         iHeaderContainer.ShowPopupMenuBarL( ETrue );
   774         iHeaderContainer.ShowPopupMenuBarL( ETrue );
   750         }
   775         }
   751     }
   776     }
   752 
   777 
   753 // End of File
   778 // End of File