meetingrequest/mrgui/mrfieldbuilderpluginextension/src/cesmrncspopuplistbox.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 0 8466d47a6819
child 16 b5fbb9b25d57
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    13 *
    13 *
    14 * Description:  Definition of the class CESMRNcsPopupListBox
    14 * Description:  Definition of the class CESMRNcsPopupListBox
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "emailtrace.h"
       
    19 #include "cesmrncspopuplistbox.h"
    18 #include "cesmrncspopuplistbox.h"
       
    19 #include "cesmrncsemailaddressobject.h"
       
    20 #include "cesmrcontacthandler.h"
       
    21 #include "nmrbitmapmanager.h"
       
    22 #include "nmrcolormanager.h"
    20 
    23 
    21 #include <eikclbd.h>
    24 #include <eikclbd.h>
    22 #include <AknsLayeredBackgroundControlContext.h>
    25 #include <aknslayeredbackgroundcontrolcontext.h>
    23 #include <StringLoader.h>                       // StringLoader
    26 #include <stringloader.h>                       // StringLoader
    24 #include <ct/rcpointerarray.h>
    27 #include <ct/rcpointerarray.h>
    25 
       
    26 //text truncation
    28 //text truncation
    27 #include <AknBidiTextUtils.h>//line wrapping and mirroring
    29 #include <aknbiditextutils.h>//line wrapping and mirroring
    28 #include <aknlayoutscalable_apps.cdl.h> //xml layout data for applications
    30 #include <aknlayoutscalable_apps.cdl.h> //xml layout data for applications
    29 #include <aknlayoutscalable_avkon.cdl.h> //xml layout data of avkon components
    31 #include <aknlayoutscalable_avkon.cdl.h> //xml layout data of avkon components
    30 
       
    31 #include <esmrgui.rsg>
    32 #include <esmrgui.rsg>
    32 
    33 #include <eikscrlb.h>
    33 #include "cesmrncsemailaddressobject.h"
    34 // DEBUG
    34 #include "cesmrcontacthandler.h"
    35 #include "emailtrace.h"
    35 #include "cesmrlayoutmgr.h"
       
    36 
    36 
    37 namespace { // codescanner::namespace
    37 namespace { // codescanner::namespace
    38 const TInt KItemExtraHeight = 8;
    38 const TInt KItemExtraHeight = 8;
    39 const TInt KEdge (8);
    39 const TInt KEdge (8);
    40 const TInt KScrollbarWidth (6);
       
    41 const TInt KListBoxDrawMargin (4);
    40 const TInt KListBoxDrawMargin (4);
    42 //drop down list colors since we have no official LAF
    41 //drop down list colors since we have no official LAF
    43 #define KWhite TRgb( 255,255,255 )
    42 #define KWhite TRgb( 255,255,255 )
    44 #define KGraySelectable TRgb( 30,30,30 )
    43 #define KGraySelectable TRgb( 30,30,30 )
    45 #define KGrayNoEmail TRgb( 215,215,215 )
    44 #define KGrayNoEmail TRgb( 215,215,215 )
   108     {
   107     {
   109     FUNC_LOG;
   108     FUNC_LOG;
   110     RCPointerArray<CESMRClsItem> matchingArray; // Empty array
   109     RCPointerArray<CESMRClsItem> matchingArray; // Empty array
   111     CleanupClosePushL( matchingArray );
   110     CleanupClosePushL( matchingArray );
   112     SetSearchTextL( aText );
   111     SetSearchTextL( aText );
   113     OperationCompleteL( ESearchContacts, &matchingArray );
       
   114     CleanupStack::PopAndDestroy( &matchingArray );
   112     CleanupStack::PopAndDestroy( &matchingArray );
   115     }
   113     }
   116 
   114 
   117 // ---------------------------------------------------------------------------
   115 // ---------------------------------------------------------------------------
   118 // CESMRNcsPopupListBox::~CESMRNcsPopupListBox
   116 // CESMRNcsPopupListBox::~CESMRNcsPopupListBox
   172     {
   170     {
   173     FUNC_LOG;
   171     FUNC_LOG;
   174     TKeyResponse ret( EKeyWasNotConsumed );
   172     TKeyResponse ret( EKeyWasNotConsumed );
   175     if( aKeyEvent.iCode == EKeyDownArrow )
   173     if( aKeyEvent.iCode == EKeyDownArrow )
   176         {
   174         {
   177         MoveRemoteLookupItemL( ERemoteLookupItemDown );
       
   178         iView->MoveCursorL( CListBoxView::ECursorNextItem, CListBoxView::ENoSelection );
   175         iView->MoveCursorL( CListBoxView::ECursorNextItem, CListBoxView::ENoSelection );
   179         ret = EKeyWasConsumed;
   176         ret = EKeyWasConsumed;
   180         }
   177         }
   181     else if( aKeyEvent.iCode == EKeyUpArrow )
   178     else if( aKeyEvent.iCode == EKeyUpArrow )
   182         {
   179         {
   183         TBool stay = EFalse;
   180         TBool stay = EFalse;
   184         // Move cursor separator line over
   181         // Move cursor separator line over
   185         if( CurrentItemIndex() - 1 > 0 && CurrentItemIndex() - 1 == iRMLUItemPosition )
   182         if( CurrentItemIndex() - 1 > 0 && CurrentItemIndex() - 1 == iRMLUItemPosition )
   186             {
   183             {
   187             MoveRemoteLookupItemL( ERemoteLookupItemUp );
       
   188             iView->MoveCursorL( CListBoxView::ECursorPreviousItem, CListBoxView::ENoSelection );
   184             iView->MoveCursorL( CListBoxView::ECursorPreviousItem, CListBoxView::ENoSelection );
   189             stay = ETrue;
   185             stay = ETrue;
   190             }
   186             }
   191 
   187 
   192         MoveRemoteLookupItemL( ERemoteLookupItemUp );
       
   193         iView->MoveCursorL( CListBoxView::ECursorPreviousItem, CListBoxView::ENoSelection );
   188         iView->MoveCursorL( CListBoxView::ECursorPreviousItem, CListBoxView::ENoSelection );
   194         if( stay )
   189         if( stay )
   195             {
   190             {
   196             MoveRemoteLookupItemL( ERemoteLookupItemDown );
       
   197 
       
   198             iView->MoveCursorL( CListBoxView::ECursorNextItem, CListBoxView::ENoSelection );
   191             iView->MoveCursorL( CListBoxView::ECursorNextItem, CListBoxView::ENoSelection );
   199             }
   192             }
   200 
   193 
   201 
   194 
   202         ret = EKeyWasConsumed;
   195         ret = EKeyWasConsumed;
   279     CESMRNcsEmailAddressObject* addressObject = NULL;
   272     CESMRNcsEmailAddressObject* addressObject = NULL;
   280 
   273 
   281     if( iMatchingArray.Count() > 0 )
   274     if( iMatchingArray.Count() > 0 )
   282         {
   275         {
   283         CESMRClsItem* clsItem = NULL;
   276         CESMRClsItem* clsItem = NULL;
   284         if( iRemoteLookupSupported )
   277         clsItem =iMatchingArray[CurrentItemIndex()];
   285             {
       
   286             clsItem =iMatchingArray[CurrentItemIndex()-1];  // -1 because of iRMLUItemPosition
       
   287             }
       
   288         else
       
   289             {
       
   290             clsItem =iMatchingArray[CurrentItemIndex()]; // no iRMLUItemPosition
       
   291             }
       
   292         addressObject= CESMRNcsEmailAddressObject::NewL( clsItem->DisplayName(), clsItem->EmailAddress() );
   278         addressObject= CESMRNcsEmailAddressObject::NewL( clsItem->DisplayName(), clsItem->EmailAddress() );
   293         CleanupStack::PushL( addressObject );
   279         CleanupStack::PushL( addressObject );
   294         if ( clsItem->MultipleEmails() )
   280         if ( clsItem->MultipleEmails() )
   295             {
   281             {
   296             addressObject->SetDisplayFull( ETrue );
   282             addressObject->SetDisplayFull( ETrue );
   376         {
   362         {
   377         iItemTextsArray->AppendL( iMatchingArray[i]->FullTextL() );
   363         iItemTextsArray->AppendL( iMatchingArray[i]->FullTextL() );
   378         }
   364         }
   379 
   365 
   380     // Update rmlu item
   366     // Update rmlu item
   381     SetRemoteLookupItemFirstToTheListL();
   367     SetRemoteLookupItemLastToTheListL();
   382 
   368 
   383     HandleItemAdditionL();
   369     HandleItemAdditionL();
   384 
   370 
   385     if( iItemTextsArray && iItemTextsArray->Count() > 0 )
   371     if( iItemTextsArray && iItemTextsArray->Count() > 0 )
   386         {
   372         {
   431     UpdateScrollBarsL();
   417     UpdateScrollBarsL();
   432     SetRect( rect );
   418     SetRect( rect );
   433     }
   419     }
   434 
   420 
   435 // -----------------------------------------------------------------------------
   421 // -----------------------------------------------------------------------------
   436 // CESMRNcsPopupListBox::SetRemoteLookupItemFirstToTheListL
   422 // CESMRNcsPopupListBox::SetRemoteLookupItemLastToTheListL
   437 // -----------------------------------------------------------------------------
   423 // -----------------------------------------------------------------------------
   438 //
   424 //
   439 void CESMRNcsPopupListBox::SetRemoteLookupItemFirstToTheListL()
   425 void CESMRNcsPopupListBox::SetRemoteLookupItemLastToTheListL()
   440     {
   426     {
   441     FUNC_LOG;
   427     FUNC_LOG;
       
   428     
   442     if( iRemoteLookupSupported )
   429     if( iRemoteLookupSupported )
   443         {
   430         {
   444         HBufC* rmluText = StringLoader::LoadLC( R_MEET_REQ_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, *iCurrentSearchText );
   431         HBufC* rmluText = StringLoader::LoadLC( 
   445 
   432                 R_MEET_REQ_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, 
   446         iItemTextsArray->InsertL( 0, *rmluText );
   433                 *iCurrentSearchText );
       
   434 
       
   435         iItemTextsArray->AppendL( *rmluText );
   447         CleanupStack::PopAndDestroy( rmluText );
   436         CleanupStack::PopAndDestroy( rmluText );
   448         iRMLUItemPosition = 0;
   437         iRMLUItemPosition = iItemTextsArray->Count() - 1;
   449         }
   438         }
   450     else
   439     else
   451         {
   440         {
   452         iRMLUItemPosition = -1;
   441         iRMLUItemPosition = KErrNotFound;
   453         }
       
   454     }
       
   455 
       
   456 // -----------------------------------------------------------------------------
       
   457 // CESMRNcsPopupListBox::MoveRemoteLookupItemL
       
   458 // -----------------------------------------------------------------------------
       
   459 //
       
   460 void CESMRNcsPopupListBox::MoveRemoteLookupItemL( TRemoteLookupItemMoveDirection aDirection )
       
   461     {
       
   462     FUNC_LOG;
       
   463     if( iRemoteLookupSupported )
       
   464         {
       
   465         TInt newRMLUItemIndex = -1;
       
   466         TInt newCurrentItem = -1;
       
   467         if( aDirection == ERemoteLookupItemUp &&
       
   468              iView->CurrentItemIndex() == iView->TopItemIndex() )
       
   469             {
       
   470             newRMLUItemIndex = iRMLUItemPosition - 1;
       
   471             newCurrentItem = CurrentItemIndex() - 1;
       
   472             }
       
   473         else if( aDirection == ERemoteLookupItemDown &&
       
   474                  iView->CurrentItemIndex() == iView->BottomItemIndex() )
       
   475             {
       
   476             newRMLUItemIndex = iRMLUItemPosition + 1;
       
   477             newCurrentItem = CurrentItemIndex() + 1;
       
   478             }
       
   479 
       
   480 
       
   481         if( ItemExists ( newCurrentItem ) )
       
   482             {
       
   483             iItemTextsArray->Delete( iRMLUItemPosition );
       
   484 
       
   485             HBufC* rmluText = StringLoader::LoadLC( R_MEET_REQ_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, *iCurrentSearchText );
       
   486 
       
   487             iItemTextsArray->InsertL( newRMLUItemIndex, *rmluText );
       
   488             CleanupStack::PopAndDestroy( rmluText );
       
   489             iRMLUItemPosition = newRMLUItemIndex;
       
   490             }
       
   491         }
   442         }
   492     }
   443     }
   493 
   444 
   494 // -----------------------------------------------------------------------------
   445 // -----------------------------------------------------------------------------
   495 // CESMRNcsPopupListBox::CreateTextArrayAndSetToTheListboxL
   446 // CESMRNcsPopupListBox::CreateTextArrayAndSetToTheListboxL
   511         iItemTextsArray = new ( ELeave ) CDesCArraySeg( KItemTextArrayLen );
   462         iItemTextsArray = new ( ELeave ) CDesCArraySeg( KItemTextArrayLen );
   512         // Set the popup list data
   463         // Set the popup list data
   513         Model()->SetItemTextArray( iItemTextsArray );
   464         Model()->SetItemTextArray( iItemTextsArray );
   514         Model()->SetOwnershipType( ELbmDoesNotOwnItemArray  );
   465         Model()->SetOwnershipType( ELbmDoesNotOwnItemArray  );
   515         }
   466         }
   516     }
       
   517 
       
   518 // -----------------------------------------------------------------------------
       
   519 // CESMRNcsPopupListBox::InitialiseL
       
   520 // -----------------------------------------------------------------------------
       
   521 //
       
   522 void CESMRNcsPopupListBox::Initialise(CESMRLayoutManager* aLayout)
       
   523     {
       
   524     FUNC_LOG;
       
   525     static_cast<CESMRNcsListItemDrawer*>( iItemDrawer )->SetLayoutManager(aLayout);
       
   526     }
   467     }
   527 
   468 
   528 // -----------------------------------------------------------------------------
   469 // -----------------------------------------------------------------------------
   529 // CESMRNcsListItemDrawer::CESMRNcsListItemDrawer
   470 // CESMRNcsListItemDrawer::CESMRNcsListItemDrawer
   530 // -----------------------------------------------------------------------------
   471 // -----------------------------------------------------------------------------
   556                                     aViewIsDimmed,
   497                                     aViewIsDimmed,
   557                                     aItemIsSelected ) )
   498                                     aItemIsSelected ) )
   558     }
   499     }
   559 
   500 
   560 // -----------------------------------------------------------------------------
   501 // -----------------------------------------------------------------------------
   561 // CESMRNcsListItemDrawer::SetLayoutManager
       
   562 // -----------------------------------------------------------------------------
       
   563 //
       
   564 void CESMRNcsListItemDrawer::SetLayoutManager(CESMRLayoutManager* aLayout)
       
   565     {
       
   566     FUNC_LOG;
       
   567     iLayout = aLayout;
       
   568     }
       
   569 
       
   570 // -----------------------------------------------------------------------------
       
   571 // CESMRNcsListItemDrawer::DoDrawActualItemL
   502 // CESMRNcsListItemDrawer::DoDrawActualItemL
   572 // -----------------------------------------------------------------------------
   503 // -----------------------------------------------------------------------------
   573 //
   504 //
   574 void CESMRNcsListItemDrawer::DoDrawActualItemL( TInt aItemIndex,
   505 void CESMRNcsListItemDrawer::DoDrawActualItemL( TInt aItemIndex,
   575 	const TRect& aActualItemRect, TBool aItemIsCurrent,
   506     const TRect& aActualItemRect, TBool aItemIsCurrent,
   576 	TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/,
   507     TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/,
   577 	TBool /*aItemIsSelected*/ ) const
   508     TBool /*aItemIsSelected*/ ) const
   578 	{
   509     {
   579     FUNC_LOG;
   510     FUNC_LOG;
   580 	// Get reference to curren popup cls item list.
   511     DrawPopUpBackGroundL( aActualItemRect );
   581 	const RPointerArray<CESMRClsItem>& clsItemArray = 	iListBox.CurrentPopupClsItemsArray();
   512     
   582 	TInt rmluPosition = iListBox.RMLUItemPosition();
   513     // Draw the selector if current item is the focused one
   583 
   514     if( aItemIsCurrent )
   584 	// Sets all the attributes, like font, text color and background color.
   515         {
   585 	const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont );
   516         DrawPopUpSelectorL( aActualItemRect );
   586 	iGc->UseFont(font);
   517         }
   587 
   518 
   588 	// We have to draw the item in layered fashion in order to do the skin
   519     DrawPopUpTextL( aItemIndex, aActualItemRect );
   589 	// First clear the backround by drawing a solid rect.	
   520     }
       
   521 
       
   522 // -----------------------------------------------------------------------------
       
   523 // CESMRNcsListItemDrawer::DrawPopUpBackGroundL
       
   524 // -----------------------------------------------------------------------------
       
   525 //
       
   526 void CESMRNcsListItemDrawer::DrawPopUpBackGroundL(
       
   527         const TRect& aActualItemRect ) const
       
   528     {
   590     iGc->SetPenColor( KGrayBackground );
   529     iGc->SetPenColor( KGrayBackground );
   591     iGc->SetBrushColor( KGrayBackground );
   530     iGc->SetBrushColor( KGrayBackground );
   592 	iGc->SetPenStyle(CGraphicsContext::ESolidPen);
   531 
   593 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   532     iGc->SetPenStyle( CGraphicsContext::ESolidPen );
   594 
   533     iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
   595 	// Now draw the highlight
   534 
   596 	if( aItemIsCurrent ) 
   535     iGc->DrawRect( aActualItemRect );
   597 		{
   536     }
   598 		if (iLayout)
   537     
   599 		    {
   538 // -----------------------------------------------------------------------------
   600             CFbsBitmap* selector = NULL;
   539 // CESMRNcsListItemDrawer::DrawPopUpSelectorL
   601             CFbsBitmap* selectorMask = NULL;
   540 // -----------------------------------------------------------------------------
   602 
   541 //
   603             // highlight bitmap target rect:
   542 void CESMRNcsListItemDrawer::DrawPopUpSelectorL( 
   604             TRect rect( aActualItemRect );
   543         const TRect& aActualItemRect ) const
   605 
   544     {
   606             TSize corner(KEdge, KEdge);
   545     CFbsBitmap* selector = NULL;
   607             iLayout->GetSkinBasedBitmap( 
   546     CFbsBitmap* selectorMask = NULL;
   608                     KAknsIIDQgnFsListCornerTl, selector, selectorMask, corner );
   547 
   609             
   548     // Highlight bitmap target rect:
   610             //adjust selector size for if scrollbar is on screen
   549     TRect rect( aActualItemRect );
   611             if (iListBox.ScrollBarFrame()->ScrollBarVisibility(CEikScrollBar::EVertical) ==
   550 
   612                 CEikScrollBarFrame::EOn)
   551     TSize corner( KEdge, KEdge );
   613                 {
   552     NMRBitmapManager::GetSkinBasedBitmap( 
   614                 rect.SetWidth( (rect.Width() - KScrollbarWidth) );
   553             NMRBitmapManager::EMRBitmapListTopLeft, 
   615                 }
   554             selector, selectorMask, corner );            
   616                        
   555     
   617             if( selector && selectorMask)
   556     // Adjust selector size if scrollbar is present
   618                 {
   557     if ( iListBox.ScrollBarFrame()->
   619                 //corner TL
   558             ScrollBarVisibility( CEikScrollBar::EVertical ) == 
   620                 iGc->BitBltMasked( 
   559                 CEikScrollBarFrame::EOn )
   621                         rect.iTl, selector, corner, selectorMask, EFalse );
   560         {
   622 
   561         TInt scrollBarWidth = 
   623                 //side L
   562                 iListBox.ScrollBarFrame()->VerticalScrollBar()->Rect().Width();
   624                 TSize side(KEdge, (rect.Height() - 2 * KEdge) );
   563         rect.SetWidth( ( rect.Width() - scrollBarWidth ) );
   625                 iLayout->GetSkinBasedBitmap( 
   564         }
   626                         KAknsIIDQgnFsListSideL, selector, selectorMask, side );
   565                
   627                 iGc->BitBltMasked( TPoint(rect.iTl.iX, rect.iTl.iY + KEdge),
   566     if( selector && selectorMask )
   628                                   selector, side, selectorMask, EFalse );
   567         {
   629 
   568         //corner TL
   630                 //corner BL
   569         iGc->BitBltMasked( 
   631                 iLayout->GetSkinBasedBitmap( 
   570                 rect.iTl, selector, corner, selectorMask, EFalse );
   632                     KAknsIIDQgnFsListCornerBl, selector, selectorMask, corner );
   571 
   633                 iGc->BitBltMasked( 
   572         //side L
   634                         TPoint(rect.iTl.iX, rect.iTl.iY + KEdge + side.iHeight),
   573         TSize side( KEdge, ( rect.Height() - 2 * KEdge ) );
   635                         selector, corner, selectorMask, EFalse );
   574         NMRBitmapManager::GetSkinBasedBitmap( 
   636 
   575                 NMRBitmapManager::EMRBitmapListLeft, 
   637                 //top
   576                 selector, selectorMask, side );
   638                 TSize top( (rect.Width() - 2 * KEdge) , KEdge);
   577         iGc->BitBltMasked( TPoint(rect.iTl.iX, rect.iTl.iY + KEdge ),
   639                 iLayout->GetSkinBasedBitmap( 
   578                           selector, side, selectorMask, EFalse );
   640                         KAknsIIDQgnFsListSideT, selector, selectorMask, top );
   579 
   641                 iGc->BitBltMasked( TPoint(rect.iTl.iX + KEdge, rect.iTl.iY),
   580         //corner BL
   642                                   selector, top, selectorMask, EFalse );
   581         NMRBitmapManager::GetSkinBasedBitmap( 
   643 
   582                 NMRBitmapManager::EMRBitmapListBottomLeft, 
   644                 //center
   583                 selector, selectorMask, corner );
   645                 TSize center( top.iWidth, side.iHeight);
   584         iGc->BitBltMasked( 
   646                 iLayout->GetSkinBasedBitmap( 
   585                 TPoint(rect.iTl.iX, rect.iTl.iY + KEdge + side.iHeight ),
   647                     KAknsIIDQgnFsListCenter, selector, selectorMask, center );
   586                 selector, corner, selectorMask, EFalse );
   648                 iGc->BitBltMasked( 
   587 
   649                         TPoint(rect.iTl.iX + KEdge, rect.iTl.iY + KEdge),
   588         //top
   650                         selector, center, selectorMask, EFalse );
   589         TSize top( ( rect.Width() - 2 * KEdge ) , KEdge );
   651 
   590         NMRBitmapManager::GetSkinBasedBitmap( 
   652                 //bottom
   591                 NMRBitmapManager::EMRBitmapListTop, 
   653                 iLayout->GetSkinBasedBitmap( 
   592                 selector, selectorMask, top );
   654                         KAknsIIDQgnFsListSideB, selector, selectorMask, top );
   593         iGc->BitBltMasked( TPoint( rect.iTl.iX + KEdge, rect.iTl.iY ),
   655                 iGc->BitBltMasked( 
   594                           selector, top, selectorMask, EFalse );
   656                 TPoint(rect.iTl.iX + KEdge, rect.iTl.iY + side.iHeight + KEdge),
   595 
   657                 selector, top, selectorMask, EFalse );
   596         //center
   658 
   597         TSize center( top.iWidth, side.iHeight );
   659                 //corner TR
   598         NMRBitmapManager::GetSkinBasedBitmap( 
   660                 iLayout->GetSkinBasedBitmap( 
   599                 NMRBitmapManager::EMRBitmapListCenter, 
   661                     KAknsIIDQgnFsListCornerTr, selector, selectorMask, corner );
   600                 selector, selectorMask, center );
   662                 iGc->BitBltMasked( 
   601         iGc->BitBltMasked( 
   663                         TPoint(rect.iTl.iX + KEdge + top.iWidth, rect.iTl.iY),
   602                 TPoint( rect.iTl.iX + KEdge, rect.iTl.iY + KEdge ),
   664                         selector, corner, selectorMask, EFalse );
   603                 selector, center, selectorMask, EFalse );
   665 
   604 
   666                 //side R
   605         //bottom
   667                 iLayout->GetSkinBasedBitmap( 
   606         NMRBitmapManager::GetSkinBasedBitmap( 
   668                         KAknsIIDQgnFsListSideR, selector, selectorMask, side );
   607                 NMRBitmapManager::EMRBitmapListBottom, 
   669                 iGc->BitBltMasked( 
   608                 selector, selectorMask, top );
   670                  TPoint(rect.iTl.iX + KEdge + top.iWidth, rect.iTl.iY + KEdge),
   609         iGc->BitBltMasked( 
   671                  selector, side, selectorMask, EFalse );
   610         TPoint( rect.iTl.iX + KEdge, rect.iTl.iY + side.iHeight + KEdge ),
   672 
   611         selector, top, selectorMask, EFalse );
   673                 //corner Br
   612 
   674                 iLayout->GetSkinBasedBitmap( 
   613         //corner TR
   675                     KAknsIIDQgnFsListCornerBr, selector, selectorMask, corner );
   614         NMRBitmapManager::GetSkinBasedBitmap( 
   676                 iGc->BitBltMasked( 
   615                 NMRBitmapManager::EMRBitmapListTopRight, 
   677                         TPoint(rect.iTl.iX + KEdge + top.iWidth, 
   616                 selector, selectorMask, corner );
   678                                rect.iTl.iY + KEdge + side.iHeight),
   617         iGc->BitBltMasked( 
   679                         selector, corner, selectorMask, EFalse );
   618                 TPoint( rect.iTl.iX + KEdge + top.iWidth, rect.iTl.iY ),
   680                 }
   619                 selector, corner, selectorMask, EFalse );
   681             else
   620 
   682                 {
   621         //side R
       
   622         NMRBitmapManager::GetSkinBasedBitmap( 
       
   623                 NMRBitmapManager::EMRBitmapListRight, 
       
   624                 selector, selectorMask, side );
       
   625 
       
   626         iGc->BitBltMasked( 
       
   627          TPoint( rect.iTl.iX + KEdge + top.iWidth, rect.iTl.iY + KEdge ),
       
   628          selector, side, selectorMask, EFalse );
       
   629 
       
   630         //corner Br
       
   631         NMRBitmapManager::GetSkinBasedBitmap( 
       
   632                 NMRBitmapManager::EMRBitmapListBottomRight, 
       
   633                 selector, selectorMask, corner );
       
   634         iGc->BitBltMasked( 
       
   635                 TPoint( rect.iTl.iX + KEdge + top.iWidth, 
       
   636                        rect.iTl.iY + KEdge + side.iHeight ),
       
   637                 selector, corner, selectorMask, EFalse );
       
   638         }
       
   639     else
       
   640         {
   683                 iGc->SetBrushColor( KSelectorFallbackColor );
   641                 iGc->SetBrushColor( KSelectorFallbackColor );
   684                 }
   642         }            
   685             
   643     delete selector;
   686             delete selector;
   644     delete selectorMask;
   687             delete selectorMask;
   645     }
   688             }
   646 
   689 	    else
   647 // -----------------------------------------------------------------------------
   690 	        {
   648 // CESMRNcsListItemDrawer::DrawPopUpTextL
   691 	        iGc->SetBrushColor( KSelectorFallbackColor );
   649 // -----------------------------------------------------------------------------
   692 	        }
   650 //
   693 		}
   651 void CESMRNcsListItemDrawer::DrawPopUpTextL( 
   694 	else
   652         TInt aItemIndex, 
   695 	    {
   653         const TRect& aActualItemRect ) const
   696 	    iGc->DrawRect(aActualItemRect);
   654     {
   697 	    }
   655     // Get reference to curren popup cls item list.
   698 	
   656     const RPointerArray<CESMRClsItem>& clsItemArray = 
   699     if(aItemIsCurrent)
   657         iListBox.CurrentPopupClsItemsArray();
   700         {
   658     TInt rmluPosition = iListBox.RMLUItemPosition();
   701         iGc->SetPenColor( KWhite );
   659 
       
   660     iGc->SetPenColor( NMRColorManager::Color( 
       
   661                 NMRColorManager::EMRMainAreaTextColor ) );
       
   662     
       
   663     // Sets all the attributes, like font, text color and background color.
       
   664     const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont );
       
   665     iGc->UseFont( font );
       
   666     
       
   667     iGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
   668     iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   669     TInt topToBaseline = ( aActualItemRect.Height() - font->HeightInPixels() ) / 2
       
   670                         + font->AscentInPixels();
       
   671 
       
   672     TPtrC itemText( iListBox.Model()->ItemText( aItemIndex ) );
       
   673 
       
   674     // Construct bidirectional text object
       
   675     TBidiText* bidiText = TBidiText::NewL( itemText, 1 );
       
   676     CleanupStack::PushL( bidiText );
       
   677         bidiText->WrapText( aActualItemRect.Width(), *font, NULL );
       
   678     TPoint leftBase = aActualItemRect.iTl + TPoint( 0, topToBaseline );
       
   679     leftBase.iX += KListBoxDrawMargin;
       
   680 
       
   681     // check if we are drawing remote lookup item or contact match
       
   682     if ( rmluPosition == aItemIndex )
       
   683         {
       
   684         iGc->SetUnderlineStyle( EUnderlineOff );
       
   685         bidiText->DrawText( *iGc, leftBase );
   702         }
   686         }
   703     else
   687     else
   704         {
   688         {
   705         iGc->SetPenColor( KGraySelectable );
   689         // if list has rmlu item change item index right
   706         }
   690 //        if ( rmluPosition >= 0 )
   707 
   691 //            {
   708 	iGc->SetPenStyle(CGraphicsContext::ESolidPen);
   692 //            --aItemIndex;
   709 	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
   693 //            aItemIndex = Max( 0, aItemIndex );
   710 	TInt topToBaseline = ( aActualItemRect.Height() - font->HeightInPixels() ) / 2
   694 //            }
   711 						+ font->AscentInPixels();
   695 
   712 
   696         TPtrC email = clsItemArray[aItemIndex]->EmailAddress().Ptr();
   713 	TPtrC itemText = iListBox.Model()->ItemText( aItemIndex );
   697         // change color to gray if match doesn't have email address.
   714 
   698         if ( clsItemArray[aItemIndex]->EmailAddress().Compare( KNullDesC ) == 0 )
   715 	// Construct bidirectional text object
   699             {
   716 	TBidiText* bidiText = TBidiText::NewL( itemText, 1 );
       
   717 	CleanupStack::PushL( bidiText );
       
   718 	bidiText->WrapText( aActualItemRect.Width(), *font, NULL );
       
   719 	TPoint leftBase = aActualItemRect.iTl + TPoint( 0, topToBaseline );
       
   720 	leftBase.iX += KListBoxDrawMargin;
       
   721 	
       
   722 	// check if we are drawing remote lookup item or contact match
       
   723 	if ( rmluPosition == aItemIndex )
       
   724 		{
       
   725 		iGc->SetUnderlineStyle( EUnderlineOff );
       
   726 		bidiText->DrawText( *iGc, leftBase );
       
   727 		}
       
   728 	else
       
   729 		{
       
   730 		// if list has rmlu item change item index right
       
   731 		if ( rmluPosition >= 0 )
       
   732 			{
       
   733 			--aItemIndex; 
       
   734 			aItemIndex = Max( 0, aItemIndex );
       
   735 			}
       
   736 
       
   737 		// change color to gray if match doesn't have email address.
       
   738 		if ( clsItemArray[aItemIndex]->EmailAddress().Compare( KNullDesC ) == 0 )
       
   739 			{
       
   740             iGc->SetPenColor( KGrayNoEmail );
   700             iGc->SetPenColor( KGrayNoEmail );
   741             iGc->SetBrushColor( KGrayNoEmail );
   701             iGc->SetBrushColor( KGrayNoEmail );
   742 			}
   702             }
   743 		
   703 
   744 		// We know the text contains RTL script if the display string is not just
   704         // TO-DO: For now, we support underlining the matching part only if the
   745 		// truncated version of the original string.
   705         // text is written completely with left-to-right script
   746 		TPtrC dispText = bidiText->DisplayText();
   706         
   747 		TInt compLength = dispText.Length() - 1; // -1 to omit the truncation character
   707         // We know the text contains RTL script if the display string is not just
   748 		TBool textContainsRtl = 
   708         // truncated version of the original string.
       
   709         TPtrC dispText = bidiText->DisplayText();
       
   710         TInt compLength = dispText.Length() - 1; // -1 to omit the truncation character
       
   711         TBool textContainsRtl = 
   749             ( itemText.Left(compLength) != dispText.Left(compLength) );
   712             ( itemText.Left(compLength) != dispText.Left(compLength) );
   750 		
   713         
   751         const RArray<TPsMatchLocation>& underlines = clsItemArray[aItemIndex]->Highlights();
   714         const RArray<TPsMatchLocation>& underlines = clsItemArray[aItemIndex]->Highlights();
   752         
   715         
   753 		if ( underlines.Count() > 0 && !textContainsRtl )
   716         if ( underlines.Count() > 0 && !textContainsRtl )
   754 			{
   717             {
   755 	        TInt i = 0;
   718             TInt i = 0;
   756 	        TBool partsLeft = ETrue;
   719             TBool partsLeft = ETrue;
   757 	        TInt currentTextStart = 0;
   720             TInt currentTextStart = 0;
   758 	        TInt currentTextLength = 0;
   721             TInt currentTextLength = 0;
   759 
   722 
   760 			while ( partsLeft )
   723             while ( partsLeft )
   761 				{
   724                 {
   762 				if ( currentTextStart < underlines[i].index )
   725                 if ( currentTextStart < underlines[i].index )
   763 					{
   726                     {
   764 					// draw letters to the start of the underlined part
   727                     // draw letters to the start of the underlined part
   765 					currentTextLength = underlines[i].index - currentTextStart;
   728                     currentTextLength = underlines[i].index - currentTextStart;
   766 					DrawPartOfItem( aActualItemRect, *font, currentTextStart, currentTextLength, itemText,
   729                     DrawPartOfItem( aActualItemRect, *font, currentTextStart, currentTextLength, itemText,
   767 									EFalse, topToBaseline );
   730                                     EFalse, topToBaseline );
   768 					}
   731                     }
   769 				else if ( currentTextStart == underlines[i].index )
   732                 else if ( currentTextStart == underlines[i].index )
   770 					{
   733                     {
   771 					// draw underlined letters
   734                     // draw underlined letters
   772 					currentTextLength = underlines[i].length;
   735                     currentTextLength = underlines[i].length;
   773 					
   736                     
   774 					DrawPartOfItem( aActualItemRect, *font, currentTextStart, currentTextLength, itemText,
   737                     DrawPartOfItem( aActualItemRect, *font, currentTextStart, currentTextLength, itemText,
   775 									ETrue, topToBaseline );
   738                                     ETrue, topToBaseline );
   776 					i++;
   739                     i++;
   777 					}
   740                     }
   778 				else 
   741                 else 
   779 					{
   742                     {
   780 					// This is here, because PCS Engine might give you duplicate match entries,
   743                     // This is here, because PCS Engine might give you duplicate match entries,
   781 					// in this case we're not advancing text but we'll skip that match
   744                     // in this case we're not advancing text but we'll skip that match
   782 					currentTextLength = 0;
   745                     currentTextLength = 0;
   783 					i++;
   746                     i++;
   784 					}
   747                     }
   785 					// update text start point
   748                     // update text start point
   786 					currentTextStart += currentTextLength;
   749                     currentTextStart += currentTextLength;
   787 				
   750                 
   788 				if ( i >= underlines.Count() )
   751                 if ( i >= underlines.Count() )
   789 					{
   752                     {
   790 					partsLeft = EFalse;
   753                     partsLeft = EFalse;
   791 					// draw rest of the letters, if there are any after the last underlined part
   754                     // draw rest of the letters, if there are any after the last underlined part
   792 					if ( currentTextStart < itemText.Length() )
   755                     if ( currentTextStart < itemText.Length() )
   793 						{
   756                         {
   794 						currentTextLength = itemText.Length() - currentTextStart;
   757                         currentTextLength = itemText.Length() - currentTextStart;
   795 						DrawPartOfItem( aActualItemRect, *font, currentTextStart, currentTextLength, itemText,
   758                         DrawPartOfItem( aActualItemRect, *font, currentTextStart, currentTextLength, itemText,
   796 										EFalse, topToBaseline );
   759                                         EFalse, topToBaseline );
   797 						}
   760                         }
   798 					}				
   761                     }
   799 				}
   762                 }
   800 			}
   763             }
   801 		else
   764         else
   802 			{
   765             {
   803 			iGc->SetUnderlineStyle( EUnderlineOff );
   766             iGc->SetUnderlineStyle( EUnderlineOff );
   804 			bidiText->DrawText( *iGc, leftBase );
   767             bidiText->DrawText( *iGc, leftBase );
   805 			}		
   768             }       
   806 		}
   769         }
   807 	CleanupStack::PopAndDestroy( bidiText );
   770     CleanupStack::PopAndDestroy( bidiText );
   808 	}
   771 	}
   809 
   772 
   810 // -----------------------------------------------------------------------------
   773 // -----------------------------------------------------------------------------
   811 // CESMRNcsListItemDrawer::DrawPartOfItem
   774 // CESMRNcsListItemDrawer::DrawPartOfItem
   812 // -----------------------------------------------------------------------------
   775 // -----------------------------------------------------------------------------
   813 void CESMRNcsListItemDrawer::DrawPartOfItem( const TRect& aItemRect, const CFont& aFont,
   776 void CESMRNcsListItemDrawer::DrawPartOfItem( const TRect& aItemRect, const CFont& aFont,
   814 						 TInt aStartPos, TInt aLength, const TDesC& aDes,
   777                          TInt aStartPos, TInt aLength, const TDesC& aDes,
   815 						 TBool aUnderlined, TInt aBaselineOffsetFromTop  ) const
   778                          TBool aUnderlined, TInt aBaselineOffsetFromTop  ) const
   816 	{
   779     {
   817     FUNC_LOG;
   780     FUNC_LOG;
   818 	if( aUnderlined )
   781     if( aUnderlined )
   819 		{
   782         {
   820 		iGc->SetUnderlineStyle( EUnderlineOn );
   783         iGc->SetUnderlineStyle( EUnderlineOn );
   821 		}
       
   822 	else
       
   823 		{
       
   824 		iGc->SetUnderlineStyle( EUnderlineOff );
       
   825 		}
       
   826 	TRect currentTextRect( aItemRect );
       
   827 	TInt pixels = aFont.TextWidthInPixels( aDes.Left( aStartPos ) );
       
   828 	currentTextRect.iTl.iX = currentTextRect.iTl.iX + pixels + KListBoxDrawMargin;
       
   829 	
       
   830     //adjust selector size for if scrollbar is on screen
       
   831     if (iListBox.ScrollBarFrame()->ScrollBarVisibility(CEikScrollBar::EVertical) ==
       
   832         CEikScrollBarFrame::EOn)
       
   833         {
       
   834         currentTextRect.iBr.iX = currentTextRect.iBr.iX - KListBoxDrawMargin - KScrollbarWidth;
       
   835         }
   784         }
   836     else
   785     else
   837         {
   786         {
       
   787         iGc->SetUnderlineStyle( EUnderlineOff );
       
   788         }
       
   789     TRect currentTextRect( aItemRect );
       
   790     TInt pixels = aFont.TextWidthInPixels( aDes.Left( aStartPos ) );
       
   791     currentTextRect.iTl.iX = currentTextRect.iTl.iX + pixels + KListBoxDrawMargin;
       
   792     
       
   793     // adjust selector size for if scrollbar is on screen
       
   794     if ( iListBox.ScrollBarFrame()->
       
   795             ScrollBarVisibility( CEikScrollBar::EVertical ) ==
       
   796                 CEikScrollBarFrame::EOn )
       
   797         {
       
   798         TInt scrollBarWidth = 
       
   799                 iListBox.ScrollBarFrame()->VerticalScrollBar()->Rect().Width();
       
   800         currentTextRect.iBr.iX = 
       
   801             currentTextRect.iBr.iX - KListBoxDrawMargin - scrollBarWidth;
       
   802         }
       
   803     else
       
   804         {
   838         currentTextRect.iBr.iX = currentTextRect.iBr.iX - KListBoxDrawMargin;
   805         currentTextRect.iBr.iX = currentTextRect.iBr.iX - KListBoxDrawMargin;
   839         }
   806         }
   840     
   807     
   841 	iGc->DrawText( aDes.Mid( aStartPos, aLength ), currentTextRect, aBaselineOffsetFromTop );
   808     iGc->DrawText( aDes.Mid( aStartPos, aLength ), currentTextRect, aBaselineOffsetFromTop );
   842 	
   809     
   843 	}
   810     }
   844 
       
   845 
       
   846 
   811 
   847 // End of File
   812 // End of File
   848