phoneuis/easydialing/src/easydialinglistboxdata.cpp
branchRCL_3
changeset 7 544e34b3255a
parent 6 38529f706030
child 14 b8d67d6176f5
equal deleted inserted replaced
6:38529f706030 7:544e34b3255a
   128 
   128 
   129 // LOCAL FUNCTION PROTOTYPES
   129 // LOCAL FUNCTION PROTOTYPES
   130 static TRect ContactNameBoundingBox(
   130 static TRect ContactNameBoundingBox(
   131         const TRect& aItemRect, 
   131         const TRect& aItemRect, 
   132         const CFont* aContactNameFont, 
   132         const CFont* aContactNameFont, 
   133         TBool aIsCurrentItem,
   133         TBool aArrowIconShown,
   134         TBool aIsFavourite, 
   134         TBool aIsFavourite, 
   135         TBool aThumbnailsShown );
   135         TBool aThumbnailsShown );
   136 static TRect CompanyNameBoundingBox(
   136 static TRect CompanyNameBoundingBox(
   137         const TRect& aItemRect, 
   137         const TRect& aItemRect, 
   138         const CFont* aCompanyNameFont, 
   138         const CFont* aCompanyNameFont, 
   179         TInt& aXOffset,
   179         TInt& aXOffset,
   180         const TDesC& aText,
   180         const TDesC& aText,
   181         TBool aMatch,
   181         TBool aMatch,
   182         const CFont* aFont );
   182         const CFont* aFont );
   183 
   183 
       
   184 static CGulIcon* CreateIconL(
       
   185         const TDesC& aFileName,
       
   186         TInt aBitmapId,
       
   187         TInt aMaskId );
   184 // FORWARD DECLARATIONS
   188 // FORWARD DECLARATIONS
   185 
   189 
   186 
   190 
   187 /*
   191 /*
   188  * ==============================================================================
   192  * ==============================================================================
   221 
   225 
   222 // -----------------------------------------------------------------------------
   226 // -----------------------------------------------------------------------------
   223 // CEasyDialingListBoxData
   227 // CEasyDialingListBoxData
   224 // 
   228 // 
   225 // -----------------------------------------------------------------------------
   229 // -----------------------------------------------------------------------------
   226 //       
   230 //
   227 CEasyDialingListBoxData::CEasyDialingListBoxData() :
   231 CEasyDialingListBoxData::CEasyDialingListBoxData() :
   228 CFormattedCellListBoxData()
   232 CFormattedCellListBoxData()
   229     {
   233     {
   230     }
   234     }
   231 
   235 
   232 // -----------------------------------------------------------------------------
   236 // -----------------------------------------------------------------------------
   233 // Destructor
   237 // Destructor
   234 // 
   238 // 
   235 // -----------------------------------------------------------------------------
   239 // -----------------------------------------------------------------------------
   236 //       
   240 //
   237 CEasyDialingListBoxData::~CEasyDialingListBoxData()
   241 CEasyDialingListBoxData::~CEasyDialingListBoxData()
   238     {
   242     {
   239     // Release fonts. ReleaseFont function can cope with null pointer
   243     // Release fonts. ReleaseFont function can cope with null pointer
   240     // so we don't need to null check them.
   244     // so we don't need to null check them.
   241     CWsScreenDevice& screenDev = *( CEikonEnv::Static()->ScreenDevice() );
   245     CWsScreenDevice& screenDev = *( CEikonEnv::Static()->ScreenDevice() );
   253 
   257 
   254 // -----------------------------------------------------------------------------
   258 // -----------------------------------------------------------------------------
   255 // NewL
   259 // NewL
   256 // 
   260 // 
   257 // -----------------------------------------------------------------------------
   261 // -----------------------------------------------------------------------------
   258 //       
   262 //
   259 CEasyDialingListBoxData* CEasyDialingListBoxData::NewL()
   263 CEasyDialingListBoxData* CEasyDialingListBoxData::NewL()
   260     {
   264     {
   261     CEasyDialingListBoxData* self = new (ELeave) CEasyDialingListBoxData();
   265     CEasyDialingListBoxData* self = new (ELeave) CEasyDialingListBoxData();
   262     
   266     
   263     CleanupStack::PushL( self );
   267     CleanupStack::PushL( self );
   270 
   274 
   271 // -----------------------------------------------------------------------------
   275 // -----------------------------------------------------------------------------
   272 // DrawData
   276 // DrawData
   273 // 
   277 // 
   274 // -----------------------------------------------------------------------------
   278 // -----------------------------------------------------------------------------
   275 //       
   279 //
   276 void CEasyDialingListBoxData::DrawData(
   280 void CEasyDialingListBoxData::DrawData(
   277     const TListItemProperties& aProperties, 
   281     const TListItemProperties& aProperties, 
   278     CWindowGc& aGc,
   282     CWindowGc& aGc,
   279     const TDesC* aText,
   283     const TDesC* aText,
   280     const TRect& aRect,
   284     const TRect& aRect,
   296 
   300 
   297 // -----------------------------------------------------------------------------
   301 // -----------------------------------------------------------------------------
   298 // ConstructLD
   302 // ConstructLD
   299 // 
   303 // 
   300 // -----------------------------------------------------------------------------
   304 // -----------------------------------------------------------------------------
   301 //       
   305 //
   302 void CEasyDialingListBoxData::ConstructLD()
   306 void CEasyDialingListBoxData::ConstructLD()
   303     {
   307     {
   304     CFormattedCellListBoxData::ConstructLD();
   308     CFormattedCellListBoxData::ConstructLD();
   305     
   309     
   306     // EasyDialing bitmap file is attempted to be read from the same directory where the
   310     // EasyDialing bitmap file is attempted to be read from the same directory where the
   309     Dll::FileName( dllFileName );
   313     Dll::FileName( dllFileName );
   310      
   314      
   311     TParse parse;
   315     TParse parse;
   312     User::LeaveIfError(parse.Set(KEasyDialingBitmapFile, &dllFileName, NULL));
   316     User::LeaveIfError(parse.Set(KEasyDialingBitmapFile, &dllFileName, NULL));
   313     TFileName bitmapFileName(parse.FullName());
   317     TFileName bitmapFileName(parse.FullName());
   314       
   318     
   315     CFbsBitmap* bm;
   319     // Icon displayed for the selected item in normal layout
   316     CFbsBitmap* mask;
   320     iArrowPointingRight = CreateIconL( bitmapFileName, EMbmEasydialingQgn_indi_org_arrow_right, 
   317     
   321             EMbmEasydialingQgn_indi_org_arrow_right_mask );
   318     // iArrowPointingLeft is the icon displayed for the selected item in EasyDialingListBox
   322 
   319     AknIconUtils::CreateIconL( bm, mask, bitmapFileName, EMbmEasydialingQgn_indi_org_arrow_left, 
   323     // Icon displayed for the selected item in mirrored layout
       
   324     iArrowPointingLeft = CreateIconL( bitmapFileName, EMbmEasydialingQgn_indi_org_arrow_left, 
   320             EMbmEasydialingQgn_indi_org_arrow_left_mask );
   325             EMbmEasydialingQgn_indi_org_arrow_left_mask );
   321 
   326 
   322     iArrowPointingLeft = CGulIcon::NewL( bm, mask );
   327     // Only mask for the arrow icons are used. iColorBitmap is used for making the icon 
   323 
       
   324     AknIconUtils::CreateIconL( bm, mask, bitmapFileName, EMbmEasydialingQgn_indi_org_arrow_right, 
       
   325             EMbmEasydialingQgn_indi_org_arrow_right_mask );
       
   326 
       
   327     iArrowPointingRight = CGulIcon::NewL( bm, mask );
       
   328 
       
   329     // Only mask for the icons are used. iColorBitmap is used for making the icon 
       
   330     // to follow text color changes according to skin.
   328     // to follow text color changes according to skin.
   331     iColorBitmap = new (ELeave) CFbsBitmap;
   329     iColorBitmap = new (ELeave) CFbsBitmap;
   332 
   330 
   333     // Contact default thumbnail is not available in themes. It is read from phonebook resource. 
   331     // Contact default thumbnail is not available in themes. It is read from phonebook resource.
   334     AknIconUtils::CreateIconL( bm, mask, KPhonebook2EceBitmapFile,
   332     iDummyThumbnail = CreateIconL( KPhonebook2EceBitmapFile,
   335             EMbmPhonebook2eceQgn_prop_pb_thumb_unknown, EMbmPhonebook2eceQgn_prop_pb_thumb_unknown_mask );
   333             EMbmPhonebook2eceQgn_prop_pb_thumb_unknown, EMbmPhonebook2eceQgn_prop_pb_thumb_unknown_mask );
   336     iDummyThumbnail = CGulIcon::NewL( bm, mask );
       
   337     
   334     
   338     // Create the favourite icon bitmap and mask
   335     // Create the favourite icon bitmap and mask
   339     AknIconUtils::CreateIconL( bm, mask, KFavouriteIconBitmapFile, 
   336     iFavouriteIcon = CreateIconL( KFavouriteIconBitmapFile, 
   340             EMbmPhonebook2Qgn_prop_pb_topc, EMbmPhonebook2Qgn_prop_pb_topc_mask );
   337             EMbmPhonebook2Qgn_prop_pb_topc, EMbmPhonebook2Qgn_prop_pb_topc_mask );
   341     
       
   342     iFavouriteIcon = CGulIcon::NewL( bm, mask );
       
   343     }
   338     }
   344 
   339 
   345 
   340 
   346 // -----------------------------------------------------------------------------
   341 // -----------------------------------------------------------------------------
   347 // DrawHighlight
   342 // DrawHighlight
   348 // 
   343 // 
   349 // -----------------------------------------------------------------------------
   344 // -----------------------------------------------------------------------------
   350 //       
   345 //
   351 void CEasyDialingListBoxData::DrawHighlight( CWindowGc &aGc, const TRect &aItemRect ) const
   346 void CEasyDialingListBoxData::DrawHighlight( CWindowGc &aGc, const TRect &aItemRect ) const
   352     {
   347     {
   353     MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( &aGc );
   348     MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( &aGc );
   354     if ( transApi )
   349     if ( transApi )
   355         {
   350         {
   415     TInt error = TextUtils::ColumnText( cellText , 0, aText );
   410     TInt error = TextUtils::ColumnText( cellText , 0, aText );
   416     __ASSERT_DEBUG( error == KErrNone, EasyDialingPanic( EEasyDialingPanicInvalidListBoxModelString ) );
   411     __ASSERT_DEBUG( error == KErrNone, EasyDialingPanic( EEasyDialingPanicInvalidListBoxModelString ) );
   417     __ASSERT_DEBUG( iContactNameFont, EasyDialingPanic( EEasyDialingNoFontFound ) );
   412     __ASSERT_DEBUG( iContactNameFont, EasyDialingPanic( EEasyDialingNoFontFound ) );
   418     __ASSERT_DEBUG( iCompanyNameFont, EasyDialingPanic( EEasyDialingNoFontFound ) );
   413     __ASSERT_DEBUG( iCompanyNameFont, EasyDialingPanic( EEasyDialingNoFontFound ) );
   419     
   414     
   420     MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( &aGc );
   415     MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( &aGc );
   421     if ( transApi )
   416     if ( transApi )
   422         {
   417         {
   423         transApi->StartDrawing( MAknListBoxTfxInternal::EListItem );
   418         transApi->StartDrawing( MAknListBoxTfxInternal::EListItem );
   424         if ( transApi->EffectsDisabled() )
   419         if ( transApi->EffectsDisabled() )
   425             {
   420             {
   431     if ( AknLayoutUtils::LayoutMirrored() )
   426     if ( AknLayoutUtils::LayoutMirrored() )
   432         {
   427         {
   433         boundingBox = MirrorLayoutBoundingBox( aItemRect, boundingBox );
   428         boundingBox = MirrorLayoutBoundingBox( aItemRect, boundingBox );
   434         }
   429         }
   435     
   430     
   436     //Draws the Contact Thumbnail Icon if exists else draws the dummy contact thumbnail
   431     // Arrow icon is drawn if the item is in focus and listbox has focus
   437     TBool fav = ContactThumbnailDrawing( aGc, boundingBox, cellText );   
   432     // (and not only the temporary visual focus caused by touching a list item).
       
   433     TBool showArrowIcon = aHighlight && iControl->IsFocused();
       
   434     if ( showArrowIcon )
       
   435         {
       
   436         TRect arrowRect = ArrowIconBoundingBox( aItemRect );
       
   437         if ( AknLayoutUtils::LayoutMirrored() )
       
   438             {
       
   439             arrowRect = MirrorLayoutBoundingBox( aItemRect, arrowRect );
       
   440             }
       
   441         DrawArrowIcon( aGc, arrowRect );
       
   442         }
       
   443 
       
   444     //Draws the Contact Thumbnail Icon if exists, else draws the dummy contact thumbnail
       
   445     TBool fav = DrawContactThumbnail( aGc, boundingBox, cellText );
   438 
   446 
   439     error = TextUtils::ColumnText( cellText , 1, aText );
   447     error = TextUtils::ColumnText( cellText , 1, aText );
   440     __ASSERT_DEBUG( error == KErrNone, EasyDialingPanic( EEasyDialingPanicInvalidListBoxModelString ) );
   448     __ASSERT_DEBUG( error == KErrNone, EasyDialingPanic( EEasyDialingPanicInvalidListBoxModelString ) );
   441 
   449 
   442     boundingBox = ContactNameBoundingBox( aItemRect,
   450     boundingBox = ContactNameBoundingBox( aItemRect,
   443                                           iContactNameFont,
   451                                           iContactNameFont,
   444                                           aHighlight,
   452                                           showArrowIcon,
   445                                           fav,
   453                                           fav,
   446                                           iContactDataManager->GetContactThumbnailSetting() );
   454                                           iContactDataManager->GetContactThumbnailSetting() );
   447     TRect nameRectUnMirrored = boundingBox; // used for favourite star drawing
   455     TRect nameRectUnMirrored = boundingBox; // used for favourite star drawing
   448 
   456 
   449     if ( AknLayoutUtils::LayoutMirrored() )
   457     if ( AknLayoutUtils::LayoutMirrored() )
   452         }
   460         }
   453 
   461 
   454     // favourite icon size is set the same as contact name bounding box height.
   462     // favourite icon size is set the same as contact name bounding box height.
   455     TInt favouriteIconSize = boundingBox.Height();
   463     TInt favouriteIconSize = boundingBox.Height();
   456     
   464     
   457     TRect arrowRect = ArrowIconBoundingBox( aItemRect );
       
   458     if ( AknLayoutUtils::LayoutMirrored() )
       
   459         {
       
   460         arrowRect = MirrorLayoutBoundingBox( aItemRect, arrowRect );
       
   461         }
       
   462     
       
   463     // Draw arrow icon if the item is in focus.
       
   464     if ( aHighlight )
       
   465         {
       
   466         DrawArrowIcon( aGc, arrowRect );
       
   467         }
       
   468 
       
   469     TInt err( KErrNone );
   465     TInt err( KErrNone );
   470     TRAP( err, DrawTextWithMatchHighlightL(
   466     TRAP( err, DrawTextWithMatchHighlightL(
   471             boundingBox, aGc, cellText, iContactNameFont, aColors, aHighlight ) );
   467             boundingBox, aGc, cellText, iContactNameFont, aColors, aHighlight ) );
   472 
   468 
   473     if ( !err && TextUtils::ColumnText( cellText , 2, aText ) == KErrNone ) 
   469     if ( !err && TextUtils::ColumnText( cellText , 2, aText ) == KErrNone ) 
   494         transApi->StopDrawing();
   490         transApi->StopDrawing();
   495         }
   491         }
   496     }
   492     }
   497 
   493 
   498 // -----------------------------------------------------------------------------
   494 // -----------------------------------------------------------------------------
   499 // ContactThumbnailDrawing
   495 // DrawContactThumbnail
   500 // 
   496 // 
   501 // Draws the Contact Thumbnail Icon if any else draws the dummy contact thumbnail
   497 // Draws the Contact Thumbnail Icon if any, else draws the dummy contact thumbnail
   502 // -----------------------------------------------------------------------------
   498 // Also check if this is a favorite contact and return true if this is.
   503 
   499 // -----------------------------------------------------------------------------
   504 TBool CEasyDialingListBoxData::ContactThumbnailDrawing(CWindowGc& aGc, TRect aBoundingBox, TPtrC aCellText) const
   500 //
       
   501 TBool CEasyDialingListBoxData::DrawContactThumbnail(CWindowGc& aGc, TRect aBoundingBox, TPtrC aCellText) const
   505     {
   502     {
   506     TBool fav(EFalse);
   503     TBool fav(EFalse);
   507     CFbsBitmap* thumbnail(NULL);
   504     CFbsBitmap* thumbnail(NULL);
   508     TBool isLoaded = iContactDataManager->GetThumbnailAndFav(aCellText, thumbnail, fav);
   505     TBool isLoaded = iContactDataManager->GetThumbnailAndFav(aCellText, thumbnail, fav);
   509     if ( isLoaded && thumbnail )
   506     if ( isLoaded && thumbnail )
   532 
   529 
   533 // -----------------------------------------------------------------------------
   530 // -----------------------------------------------------------------------------
   534 // DrawArrowIcon
   531 // DrawArrowIcon
   535 //  Draws the Action Menu 
   532 //  Draws the Action Menu 
   536 // -----------------------------------------------------------------------------
   533 // -----------------------------------------------------------------------------
       
   534 //
   537 void CEasyDialingListBoxData::DrawArrowIcon( 
   535 void CEasyDialingListBoxData::DrawArrowIcon( 
   538         CWindowGc& aGc, TRect aArrowRect) const
   536         CWindowGc& aGc, TRect aArrowRect) const
   539     {
   537     {
   540     // Action Menu Arrow for opening the Action Menu
   538     // Action Menu Arrow for opening the Action Menu
   541     if ( AknLayoutUtils::LayoutMirrored() )
   539     if ( AknLayoutUtils::LayoutMirrored() )
   559 // -----------------------------------------------------------------------------
   557 // -----------------------------------------------------------------------------
   560 // DrawFavouriteIcon
   558 // DrawFavouriteIcon
   561 // 
   559 // 
   562 // Draws the Favourite Icon
   560 // Draws the Favourite Icon
   563 // -----------------------------------------------------------------------------
   561 // -----------------------------------------------------------------------------
       
   562 //
   564 void CEasyDialingListBoxData::DrawFavouriteIcon(
   563 void CEasyDialingListBoxData::DrawFavouriteIcon(
   565         CWindowGc& aGc, 
   564         CWindowGc& aGc, 
   566          TRect aNameRectUnMirrored,
   565          TRect aNameRectUnMirrored,
   567          TRect aEffectiveRect) const
   566          TRect aEffectiveRect) const
   568     {
   567     {
   594     }
   593     }
   595 // -----------------------------------------------------------------------------
   594 // -----------------------------------------------------------------------------
   596 // SetContactDataManager
   595 // SetContactDataManager
   597 // 
   596 // 
   598 // -----------------------------------------------------------------------------
   597 // -----------------------------------------------------------------------------
   599 // 
   598 //
   600 void CEasyDialingListBoxData::SetContactDataManager(CEasyDialingContactDataManager* aContactDataManager)
   599 void CEasyDialingListBoxData::SetContactDataManager(CEasyDialingContactDataManager* aContactDataManager)
   601     {
   600     {
   602     iContactDataManager = aContactDataManager;
   601     iContactDataManager = aContactDataManager;
   603     }
   602     }
   604 
   603 
   621 
   620 
   622 // -----------------------------------------------------------------------------
   621 // -----------------------------------------------------------------------------
   623 // ObtainFonts
   622 // ObtainFonts
   624 // 
   623 // 
   625 // -----------------------------------------------------------------------------
   624 // -----------------------------------------------------------------------------
   626 //       
   625 //
   627 void CEasyDialingListBoxData::ObtainFonts( TInt aItemHeight )
   626 void CEasyDialingListBoxData::ObtainFonts( TInt aItemHeight )
   628     {
   627     {
   629     CWsScreenDevice& screenDev = *( CEikonEnv::Static()->ScreenDevice() );
   628     CWsScreenDevice& screenDev = *( CEikonEnv::Static()->ScreenDevice() );
   630     
   629     
   631     // Release previous fonts. ReleaseFont function can cope with null pointers
   630     // Release previous fonts. ReleaseFont function can cope with null pointers
   666 
   665 
   667 // -----------------------------------------------------------------------------
   666 // -----------------------------------------------------------------------------
   668 // UpdateColorBitmapL
   667 // UpdateColorBitmapL
   669 // ColorBitmap is redrawn when UI layout or text color (Theme) changes
   668 // ColorBitmap is redrawn when UI layout or text color (Theme) changes
   670 // -----------------------------------------------------------------------------
   669 // -----------------------------------------------------------------------------
   671 //       
   670 //
   672 void CEasyDialingListBoxData::UpdateColorBitmapL( const TSize& aSize )
   671 void CEasyDialingListBoxData::UpdateColorBitmapL( const TSize& aSize )
   673     {
   672     {
   674     TRgb color;
   673     TRgb color;
   675     // Get the HighLighted text color in ListBox from the Theme
   674     // Get the HighLighted text color in ListBox from the Theme
   676     AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), color, 
   675     AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), color, 
   705 
   704 
   706 // -----------------------------------------------------------------------------
   705 // -----------------------------------------------------------------------------
   707 // SetEDLBXControl
   706 // SetEDLBXControl
   708 // 
   707 // 
   709 // -----------------------------------------------------------------------------
   708 // -----------------------------------------------------------------------------
   710 //       
   709 //
   711 void CEasyDialingListBoxData::SetEDLBXControl(CEasyDialingListBox* aControl)
   710 void CEasyDialingListBoxData::SetEDLBXControl(CEasyDialingListBox* aControl)
   712     {
   711     {
   713     iControl = aControl;
   712     iControl = aControl;
   714     }
   713     }
   715 
   714 
   726 // -----------------------------------------------------------------------------
   725 // -----------------------------------------------------------------------------
   727 // ContactImageBoundingBox
   726 // ContactImageBoundingBox
   728 // Calculates the area where contact thumbnail is confined
   727 // Calculates the area where contact thumbnail is confined
   729 // -----------------------------------------------------------------------------
   728 // -----------------------------------------------------------------------------
   730 //
   729 //
   731 TRect ContactImageBoundingBox(const TRect& aItemRect)
   730 TRect ContactImageBoundingBox( const TRect& aItemRect )
   732     {
   731     {
   733     TInt leftMargin = aItemRect.Width() * KMarginXPercent / KCent;
   732     TInt leftMargin = aItemRect.Width() * KMarginXPercent / KCent;
   734     TInt topMargin = KMarginYPercent * aItemRect.Height() / KCent;
   733     TInt topMargin = KMarginYPercent * aItemRect.Height() / KCent;
   735     TInt bottomMargin = topMargin;
   734     TInt bottomMargin = topMargin;
   736     TInt width = ((aItemRect.Height() - topMargin - bottomMargin) * KThumbnailAspectRatio) / KCent;
   735     TInt width = ((aItemRect.Height() - topMargin - bottomMargin) * KThumbnailAspectRatio) / KCent;
   744 
   743 
   745 // -----------------------------------------------------------------------------
   744 // -----------------------------------------------------------------------------
   746 // ContactNameBoundingBox
   745 // ContactNameBoundingBox
   747 // Calculates the area to which the contact name and possible match highlights
   746 // Calculates the area to which the contact name and possible match highlights
   748 // are confined.
   747 // are confined.
   749 //      
       
   750 // -----------------------------------------------------------------------------
   748 // -----------------------------------------------------------------------------
   751 //
   749 //
   752 static TRect ContactNameBoundingBox(
   750 static TRect ContactNameBoundingBox(
   753         const TRect& aItemRect,
   751         const TRect& aItemRect,
   754         const CFont* aContactNameFont,
   752         const CFont* aContactNameFont,
   755         TBool aIsCurrentItem,
   753         TBool aArrowIconShown,
   756         TBool aIsFavourite,
   754         TBool aIsFavourite,
   757         TBool aThumbnailsShown )
   755         TBool aThumbnailsShown )
   758     {
   756     {
   759     // Position X will contain the starting position of text from left side of item rect.
   757     // Position X will contain the starting position of text from left side of item rect.
   760     TInt positionX = aItemRect.Width() * KMarginXPercent / KCent;
   758     TInt positionX = aItemRect.Width() * KMarginXPercent / KCent;
   769     
   767     
   770     TInt topMargin = KContactNameYOffsetPercent * aItemRect.Height() / KCent;
   768     TInt topMargin = KContactNameYOffsetPercent * aItemRect.Height() / KCent;
   771     TInt height = KTextBoundingBoxHeightPercent * aContactNameFont->FontMaxHeight() / KCent;
   769     TInt height = KTextBoundingBoxHeightPercent * aContactNameFont->FontMaxHeight() / KCent;
   772     TInt rightMargin = KMarginXPercent * aItemRect.Width() / KCent;
   770     TInt rightMargin = KMarginXPercent * aItemRect.Width() / KCent;
   773     
   771     
   774     // Reserve space for communication launcher icon.
   772     // Reserve space for communication launcher icon if it's shown on this item
   775     // Communication launcher icon is shown only id item is highlighted.
   773     if ( aArrowIconShown )
   776     if ( aIsCurrentItem )
       
   777         {
   774         {
   778         rightMargin += KArrowIconSizePercent * aItemRect.Height() / KCent;
   775         rightMargin += KArrowIconSizePercent * aItemRect.Height() / KCent;
   779         }
   776         }
   780     
   777     
   781     // If item is favourite, reserve space for favourite icon. Icon dimensions are the same as bounding box height.
   778     // If item is favourite, reserve space for favourite icon. Icon dimensions are the same as bounding box height.
   837 // -----------------------------------------------------------------------------
   834 // -----------------------------------------------------------------------------
   838 // ArrowIconBoundingBox
   835 // ArrowIconBoundingBox
   839 // Calculates the area to which the action menu icon is drawn.
   836 // Calculates the area to which the action menu icon is drawn.
   840 // -----------------------------------------------------------------------------
   837 // -----------------------------------------------------------------------------
   841 //
   838 //
   842 TRect ArrowIconBoundingBox(const TRect& aItemRect)
   839 TRect ArrowIconBoundingBox( const TRect& aItemRect )
   843     {
   840     {
   844     TInt iconSize = KArrowIconSizePercent * aItemRect.Height() / KCent;
   841     TInt iconSize = KArrowIconSizePercent * aItemRect.Height() / KCent;
   845     TInt rightMargin = KMarginXPercent * aItemRect.Width() / KCent;
   842     TInt rightMargin = KMarginXPercent * aItemRect.Width() / KCent;
   846     TInt positionX = aItemRect.iBr.iX - rightMargin - iconSize;
   843     TInt positionX = aItemRect.iBr.iX - rightMargin - iconSize;
   847     TInt topMargin = ( aItemRect.Height() - iconSize ) / 2; // Icon is vertically centered.
   844     TInt topMargin = ( aItemRect.Height() - iconSize ) / 2; // Icon is vertically centered.
   892 // -----------------------------------------------------------------------------
   889 // -----------------------------------------------------------------------------
   893 // MirrorLayoutBoundingBox
   890 // MirrorLayoutBoundingBox
   894 //
   891 //
   895 // -----------------------------------------------------------------------------
   892 // -----------------------------------------------------------------------------
   896 //
   893 //
   897 static TRect MirrorLayoutBoundingBox(const TRect& aSourceRect, TRect& aBoundingBoxRect)
   894 static TRect MirrorLayoutBoundingBox( const TRect& aSourceRect, TRect& aBoundingBoxRect )
   898     {
   895     {
   899     return TRect(
   896     return TRect(
   900             aSourceRect.iTl.iX + aSourceRect.iBr.iX - aBoundingBoxRect.iBr.iX,
   897             aSourceRect.iTl.iX + aSourceRect.iBr.iX - aBoundingBoxRect.iBr.iX,
   901             aBoundingBoxRect.iTl.iY,
   898             aBoundingBoxRect.iTl.iY,
   902             aSourceRect.iTl.iX + aSourceRect.iBr.iX - aBoundingBoxRect.iTl.iX,
   899             aSourceRect.iTl.iX + aSourceRect.iBr.iX - aBoundingBoxRect.iTl.iX,
   912 // width for matching highlight.
   909 // width for matching highlight.
   913 // NOTE 2: This function cannot handle right-to-left or bidirectional text currently.
   910 // NOTE 2: This function cannot handle right-to-left or bidirectional text currently.
   914 // These cases must be handled elsewhere.
   911 // These cases must be handled elsewhere.
   915 // -----------------------------------------------------------------------------
   912 // -----------------------------------------------------------------------------
   916 //
   913 //
   917 
       
   918 _LIT( KThreeDots, "..." );
       
   919 
       
   920 static void ClipTextToWidth(
   914 static void ClipTextToWidth(
   921         TDes& aText,
   915         TDes& aText,
   922         const CFont& aFont,
   916         const CFont& aFont,
   923         TInt aMaxWidthInPixels,
   917         TInt aMaxWidthInPixels,
   924         TBool& aMatch)
   918         TBool& aMatch)
   925     {
   919     {
       
   920     _LIT( KThreeDots, "..." );
   926     TInt minimumWidth = aFont.TextWidthInPixels( KThreeDots );
   921     TInt minimumWidth = aFont.TextWidthInPixels( KThreeDots );
   927     
   922     
   928     // If this is a matching piece of text, also match text marginals need to be counted.
   923     // If this is a matching piece of text, also match text marginals need to be counted.
   929     if ( aMatch )
   924     if ( aMatch )
   930         {
   925         {
   945         aMaxWidthInPixels -= 2 * KMatchingTextMarginInPixels;
   940         aMaxWidthInPixels -= 2 * KMatchingTextMarginInPixels;
   946         }
   941         }
   947     
   942     
   948     AknTextUtils::ClipToFit( aText, aFont, aMaxWidthInPixels );    
   943     AknTextUtils::ClipToFit( aText, aFont, aMaxWidthInPixels );    
   949     }
   944     }
   950 
       
   951 
   945 
   952 // -----------------------------------------------------------------------------
   946 // -----------------------------------------------------------------------------
   953 // DrawPieceOfText
   947 // DrawPieceOfText
   954 // Draws a piece of text of contact, either matching or not matching.
   948 // Draws a piece of text of contact, either matching or not matching.
   955 // Updates aXOffset argument by adding drawn text width.
   949 // Updates aXOffset argument by adding drawn text width.
  1048     delete newText;
  1042     delete newText;
  1049     aXOffset += wholeWidth;
  1043     aXOffset += wholeWidth;
  1050     return ETrue;
  1044     return ETrue;
  1051     }
  1045     }
  1052 
  1046 
  1053 
       
  1054 // -----------------------------------------------------------------------------
  1047 // -----------------------------------------------------------------------------
  1055 // DrawTextWithMatchHighlight
  1048 // DrawTextWithMatchHighlight
  1056 // Draws a string with match highlight. Highlighted and non-highlighted
  1049 // Draws a string with match highlight. Highlighted and non-highlighted
  1057 // parts are separated with KHighlightSeparatorChar.
  1050 // parts are separated with KHighlightSeparatorChar.
  1058 // The first text part is not highlighted and from that on highlight
  1051 // The first text part is not highlighted and from that on highlight
  1064         const TRect& aBoundingBox,
  1057         const TRect& aBoundingBox,
  1065         CWindowGc &aGc, 
  1058         CWindowGc &aGc, 
  1066         const TDesC& aText,
  1059         const TDesC& aText,
  1067         const CFont* aFont,
  1060         const CFont* aFont,
  1068         const CEasyDialingListBoxData::TExtendedColors& aColors,
  1061         const CEasyDialingListBoxData::TExtendedColors& aColors,
  1069         TBool aHighLight)
  1062         TBool aHighLight )
  1070     {
  1063     {
  1071     TInt xOffset = 0;
  1064     TInt xOffset = 0;
  1072     
  1065     
  1073     HBufC* visualBuf = ConvertToVisualAndClipLC( aText, *aFont, aBoundingBox );
  1066     HBufC* visualBuf = ConvertToVisualAndClipLC( aText, *aFont, aBoundingBox );
  1074     
  1067     
  1109 // -----------------------------------------------------------------------------
  1102 // -----------------------------------------------------------------------------
  1110 // CalculateTextWidth
  1103 // CalculateTextWidth
  1111 // Calculates the width of the text and returns it 
  1104 // Calculates the width of the text and returns it 
  1112 // -----------------------------------------------------------------------------
  1105 // -----------------------------------------------------------------------------
  1113 //
  1106 //
  1114 static TInt CalculateTextWidth(const TRect& aBoundingBox, const TDesC& aText, const CFont* aFont )
  1107 static TInt CalculateTextWidth( const TRect& aBoundingBox, 
  1115     {
  1108                                 const TDesC& aText, 
  1116     
  1109                                 const CFont* aFont )
       
  1110     {
  1117     TInt xOffset = 0;
  1111     TInt xOffset = 0;
  1118     TPtrC textPiece;
  1112     TPtrC textPiece;
  1119     TInt textPieceIndex = 0;
  1113     TInt textPieceIndex = 0;
  1120     TBool match = EFalse;
  1114     TBool match = EFalse;
  1121 
  1115 
  1252 // NOTE2: It's assumed that there can be highlights only in pure LTR and RTL
  1246 // NOTE2: It's assumed that there can be highlights only in pure LTR and RTL
  1253 // texts. Highlights for mixed LTR-RTL text cannot be handled properly.
  1247 // texts. Highlights for mixed LTR-RTL text cannot be handled properly.
  1254 // -----------------------------------------------------------------------------
  1248 // -----------------------------------------------------------------------------
  1255 //
  1249 //
  1256 static HBufC* ConvertToVisualAndClipLC( const TDesC& aText, 
  1250 static HBufC* ConvertToVisualAndClipLC( const TDesC& aText, 
  1257                                        const CFont& aFont, 
  1251                                         const CFont& aFont, 
  1258                                        const TRect& aBoundingBox )
  1252                                         const TRect& aBoundingBox )
  1259     {
  1253     {
  1260     HBufC* buf = HBufC::NewLC( aText.Length() + KAknBidiExtraSpacePerLine );
  1254     HBufC* buf = HBufC::NewLC( aText.Length() + KAknBidiExtraSpacePerLine );
  1261     TPtr ptr = buf->Des();
  1255     TPtr ptr = buf->Des();
  1262     ptr.Copy( aText );
  1256     ptr.Copy( aText );
  1263     
  1257     
  1318         }
  1312         }
  1319     
  1313     
  1320     return sepCount;
  1314     return sepCount;
  1321     }
  1315     }
  1322 
  1316 
       
  1317 // -----------------------------------------------------------------------------
       
  1318 // CreateIconL
       
  1319 // 
       
  1320 // Create and return a new icon object from given file and with given ID
       
  1321 // -----------------------------------------------------------------------------
       
  1322 //
       
  1323 static CGulIcon* CreateIconL(
       
  1324         const TDesC& aFileName,
       
  1325         TInt aBitmapId,
       
  1326         TInt aMaskId )
       
  1327     {
       
  1328     CGulIcon* icon = CGulIcon::NewLC();
       
  1329 
       
  1330     CFbsBitmap* bm;
       
  1331     CFbsBitmap* mask;
       
  1332     AknIconUtils::CreateIconL( bm, mask, aFileName, aBitmapId, aMaskId );
       
  1333     
       
  1334     icon->SetBitmap( bm );
       
  1335     icon->SetMask( mask );
       
  1336     
       
  1337     CleanupStack::Pop( icon );
       
  1338     return icon;
       
  1339     }
       
  1340 
  1323 //  End of File.
  1341 //  End of File.
  1324 
  1342