--- a/phoneuis/easydialing/src/easydialinglistboxdata.cpp Wed Mar 31 21:30:06 2010 +0300
+++ b/phoneuis/easydialing/src/easydialinglistboxdata.cpp Wed Apr 14 15:56:42 2010 +0300
@@ -130,7 +130,7 @@
static TRect ContactNameBoundingBox(
const TRect& aItemRect,
const CFont* aContactNameFont,
- TBool aIsCurrentItem,
+ TBool aArrowIconShown,
TBool aIsFavourite,
TBool aThumbnailsShown );
static TRect CompanyNameBoundingBox(
@@ -181,6 +181,10 @@
TBool aMatch,
const CFont* aFont );
+static CGulIcon* CreateIconL(
+ const TDesC& aFileName,
+ TInt aBitmapId,
+ TInt aMaskId );
// FORWARD DECLARATIONS
@@ -223,7 +227,7 @@
// CEasyDialingListBoxData
//
// -----------------------------------------------------------------------------
-//
+//
CEasyDialingListBoxData::CEasyDialingListBoxData() :
CFormattedCellListBoxData()
{
@@ -233,7 +237,7 @@
// Destructor
//
// -----------------------------------------------------------------------------
-//
+//
CEasyDialingListBoxData::~CEasyDialingListBoxData()
{
// Release fonts. ReleaseFont function can cope with null pointer
@@ -255,7 +259,7 @@
// NewL
//
// -----------------------------------------------------------------------------
-//
+//
CEasyDialingListBoxData* CEasyDialingListBoxData::NewL()
{
CEasyDialingListBoxData* self = new (ELeave) CEasyDialingListBoxData();
@@ -272,7 +276,7 @@
// DrawData
//
// -----------------------------------------------------------------------------
-//
+//
void CEasyDialingListBoxData::DrawData(
const TListItemProperties& aProperties,
CWindowGc& aGc,
@@ -298,7 +302,7 @@
// ConstructLD
//
// -----------------------------------------------------------------------------
-//
+//
void CEasyDialingListBoxData::ConstructLD()
{
CFormattedCellListBoxData::ConstructLD();
@@ -311,35 +315,26 @@
TParse parse;
User::LeaveIfError(parse.Set(KEasyDialingBitmapFile, &dllFileName, NULL));
TFileName bitmapFileName(parse.FullName());
-
- CFbsBitmap* bm;
- CFbsBitmap* mask;
- // iArrowPointingLeft is the icon displayed for the selected item in EasyDialingListBox
- AknIconUtils::CreateIconL( bm, mask, bitmapFileName, EMbmEasydialingQgn_indi_org_arrow_left,
+ // Icon displayed for the selected item in normal layout
+ iArrowPointingRight = CreateIconL( bitmapFileName, EMbmEasydialingQgn_indi_org_arrow_right,
+ EMbmEasydialingQgn_indi_org_arrow_right_mask );
+
+ // Icon displayed for the selected item in mirrored layout
+ iArrowPointingLeft = CreateIconL( bitmapFileName, EMbmEasydialingQgn_indi_org_arrow_left,
EMbmEasydialingQgn_indi_org_arrow_left_mask );
- iArrowPointingLeft = CGulIcon::NewL( bm, mask );
-
- AknIconUtils::CreateIconL( bm, mask, bitmapFileName, EMbmEasydialingQgn_indi_org_arrow_right,
- EMbmEasydialingQgn_indi_org_arrow_right_mask );
-
- iArrowPointingRight = CGulIcon::NewL( bm, mask );
-
- // Only mask for the icons are used. iColorBitmap is used for making the icon
+ // Only mask for the arrow icons are used. iColorBitmap is used for making the icon
// to follow text color changes according to skin.
iColorBitmap = new (ELeave) CFbsBitmap;
- // Contact default thumbnail is not available in themes. It is read from phonebook resource.
- AknIconUtils::CreateIconL( bm, mask, KPhonebook2EceBitmapFile,
+ // Contact default thumbnail is not available in themes. It is read from phonebook resource.
+ iDummyThumbnail = CreateIconL( KPhonebook2EceBitmapFile,
EMbmPhonebook2eceQgn_prop_pb_thumb_unknown, EMbmPhonebook2eceQgn_prop_pb_thumb_unknown_mask );
- iDummyThumbnail = CGulIcon::NewL( bm, mask );
// Create the favourite icon bitmap and mask
- AknIconUtils::CreateIconL( bm, mask, KFavouriteIconBitmapFile,
+ iFavouriteIcon = CreateIconL( KFavouriteIconBitmapFile,
EMbmPhonebook2Qgn_prop_pb_topc, EMbmPhonebook2Qgn_prop_pb_topc_mask );
-
- iFavouriteIcon = CGulIcon::NewL( bm, mask );
}
@@ -347,7 +342,7 @@
// DrawHighlight
//
// -----------------------------------------------------------------------------
-//
+//
void CEasyDialingListBoxData::DrawHighlight( CWindowGc &aGc, const TRect &aItemRect ) const
{
MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( &aGc );
@@ -417,7 +412,7 @@
__ASSERT_DEBUG( iContactNameFont, EasyDialingPanic( EEasyDialingNoFontFound ) );
__ASSERT_DEBUG( iCompanyNameFont, EasyDialingPanic( EEasyDialingNoFontFound ) );
- MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( &aGc );
+ MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( &aGc );
if ( transApi )
{
transApi->StartDrawing( MAknListBoxTfxInternal::EListItem );
@@ -433,15 +428,28 @@
boundingBox = MirrorLayoutBoundingBox( aItemRect, boundingBox );
}
- //Draws the Contact Thumbnail Icon if exists else draws the dummy contact thumbnail
- TBool fav = ContactThumbnailDrawing( aGc, boundingBox, cellText );
+ // Arrow icon is drawn if the item is in focus and listbox has focus
+ // (and not only the temporary visual focus caused by touching a list item).
+ TBool showArrowIcon = aHighlight && iControl->IsFocused();
+ if ( showArrowIcon )
+ {
+ TRect arrowRect = ArrowIconBoundingBox( aItemRect );
+ if ( AknLayoutUtils::LayoutMirrored() )
+ {
+ arrowRect = MirrorLayoutBoundingBox( aItemRect, arrowRect );
+ }
+ DrawArrowIcon( aGc, arrowRect );
+ }
+
+ //Draws the Contact Thumbnail Icon if exists, else draws the dummy contact thumbnail
+ TBool fav = DrawContactThumbnail( aGc, boundingBox, cellText );
error = TextUtils::ColumnText( cellText , 1, aText );
__ASSERT_DEBUG( error == KErrNone, EasyDialingPanic( EEasyDialingPanicInvalidListBoxModelString ) );
boundingBox = ContactNameBoundingBox( aItemRect,
iContactNameFont,
- aHighlight,
+ showArrowIcon,
fav,
iContactDataManager->GetContactThumbnailSetting() );
TRect nameRectUnMirrored = boundingBox; // used for favourite star drawing
@@ -454,18 +462,6 @@
// favourite icon size is set the same as contact name bounding box height.
TInt favouriteIconSize = boundingBox.Height();
- TRect arrowRect = ArrowIconBoundingBox( aItemRect );
- if ( AknLayoutUtils::LayoutMirrored() )
- {
- arrowRect = MirrorLayoutBoundingBox( aItemRect, arrowRect );
- }
-
- // Draw arrow icon if the item is in focus.
- if ( aHighlight )
- {
- DrawArrowIcon( aGc, arrowRect );
- }
-
TInt err( KErrNone );
TRAP( err, DrawTextWithMatchHighlightL(
boundingBox, aGc, cellText, iContactNameFont, aColors, aHighlight ) );
@@ -496,12 +492,13 @@
}
// -----------------------------------------------------------------------------
-// ContactThumbnailDrawing
+// DrawContactThumbnail
//
-// Draws the Contact Thumbnail Icon if any else draws the dummy contact thumbnail
+// Draws the Contact Thumbnail Icon if any, else draws the dummy contact thumbnail
+// Also check if this is a favorite contact and return true if this is.
// -----------------------------------------------------------------------------
-
-TBool CEasyDialingListBoxData::ContactThumbnailDrawing(CWindowGc& aGc, TRect aBoundingBox, TPtrC aCellText) const
+//
+TBool CEasyDialingListBoxData::DrawContactThumbnail(CWindowGc& aGc, TRect aBoundingBox, TPtrC aCellText) const
{
TBool fav(EFalse);
CFbsBitmap* thumbnail(NULL);
@@ -534,6 +531,7 @@
// DrawArrowIcon
// Draws the Action Menu
// -----------------------------------------------------------------------------
+//
void CEasyDialingListBoxData::DrawArrowIcon(
CWindowGc& aGc, TRect aArrowRect) const
{
@@ -561,6 +559,7 @@
//
// Draws the Favourite Icon
// -----------------------------------------------------------------------------
+//
void CEasyDialingListBoxData::DrawFavouriteIcon(
CWindowGc& aGc,
TRect aNameRectUnMirrored,
@@ -596,7 +595,7 @@
// SetContactDataManager
//
// -----------------------------------------------------------------------------
-//
+//
void CEasyDialingListBoxData::SetContactDataManager(CEasyDialingContactDataManager* aContactDataManager)
{
iContactDataManager = aContactDataManager;
@@ -623,7 +622,7 @@
// ObtainFonts
//
// -----------------------------------------------------------------------------
-//
+//
void CEasyDialingListBoxData::ObtainFonts( TInt aItemHeight )
{
CWsScreenDevice& screenDev = *( CEikonEnv::Static()->ScreenDevice() );
@@ -668,7 +667,7 @@
// UpdateColorBitmapL
// ColorBitmap is redrawn when UI layout or text color (Theme) changes
// -----------------------------------------------------------------------------
-//
+//
void CEasyDialingListBoxData::UpdateColorBitmapL( const TSize& aSize )
{
TRgb color;
@@ -707,7 +706,7 @@
// SetEDLBXControl
//
// -----------------------------------------------------------------------------
-//
+//
void CEasyDialingListBoxData::SetEDLBXControl(CEasyDialingListBox* aControl)
{
iControl = aControl;
@@ -728,7 +727,7 @@
// Calculates the area where contact thumbnail is confined
// -----------------------------------------------------------------------------
//
-TRect ContactImageBoundingBox(const TRect& aItemRect)
+TRect ContactImageBoundingBox( const TRect& aItemRect )
{
TInt leftMargin = aItemRect.Width() * KMarginXPercent / KCent;
TInt topMargin = KMarginYPercent * aItemRect.Height() / KCent;
@@ -746,13 +745,12 @@
// ContactNameBoundingBox
// Calculates the area to which the contact name and possible match highlights
// are confined.
-//
// -----------------------------------------------------------------------------
//
static TRect ContactNameBoundingBox(
const TRect& aItemRect,
const CFont* aContactNameFont,
- TBool aIsCurrentItem,
+ TBool aArrowIconShown,
TBool aIsFavourite,
TBool aThumbnailsShown )
{
@@ -771,9 +769,8 @@
TInt height = KTextBoundingBoxHeightPercent * aContactNameFont->FontMaxHeight() / KCent;
TInt rightMargin = KMarginXPercent * aItemRect.Width() / KCent;
- // Reserve space for communication launcher icon.
- // Communication launcher icon is shown only id item is highlighted.
- if ( aIsCurrentItem )
+ // Reserve space for communication launcher icon if it's shown on this item
+ if ( aArrowIconShown )
{
rightMargin += KArrowIconSizePercent * aItemRect.Height() / KCent;
}
@@ -839,7 +836,7 @@
// Calculates the area to which the action menu icon is drawn.
// -----------------------------------------------------------------------------
//
-TRect ArrowIconBoundingBox(const TRect& aItemRect)
+TRect ArrowIconBoundingBox( const TRect& aItemRect )
{
TInt iconSize = KArrowIconSizePercent * aItemRect.Height() / KCent;
TInt rightMargin = KMarginXPercent * aItemRect.Width() / KCent;
@@ -894,7 +891,7 @@
//
// -----------------------------------------------------------------------------
//
-static TRect MirrorLayoutBoundingBox(const TRect& aSourceRect, TRect& aBoundingBoxRect)
+static TRect MirrorLayoutBoundingBox( const TRect& aSourceRect, TRect& aBoundingBoxRect )
{
return TRect(
aSourceRect.iTl.iX + aSourceRect.iBr.iX - aBoundingBoxRect.iBr.iX,
@@ -914,15 +911,13 @@
// These cases must be handled elsewhere.
// -----------------------------------------------------------------------------
//
-
-_LIT( KThreeDots, "..." );
-
static void ClipTextToWidth(
TDes& aText,
const CFont& aFont,
TInt aMaxWidthInPixels,
TBool& aMatch)
{
+ _LIT( KThreeDots, "..." );
TInt minimumWidth = aFont.TextWidthInPixels( KThreeDots );
// If this is a matching piece of text, also match text marginals need to be counted.
@@ -948,7 +943,6 @@
AknTextUtils::ClipToFit( aText, aFont, aMaxWidthInPixels );
}
-
// -----------------------------------------------------------------------------
// DrawPieceOfText
// Draws a piece of text of contact, either matching or not matching.
@@ -1050,7 +1044,6 @@
return ETrue;
}
-
// -----------------------------------------------------------------------------
// DrawTextWithMatchHighlight
// Draws a string with match highlight. Highlighted and non-highlighted
@@ -1066,7 +1059,7 @@
const TDesC& aText,
const CFont* aFont,
const CEasyDialingListBoxData::TExtendedColors& aColors,
- TBool aHighLight)
+ TBool aHighLight )
{
TInt xOffset = 0;
@@ -1111,9 +1104,10 @@
// Calculates the width of the text and returns it
// -----------------------------------------------------------------------------
//
-static TInt CalculateTextWidth(const TRect& aBoundingBox, const TDesC& aText, const CFont* aFont )
+static TInt CalculateTextWidth( const TRect& aBoundingBox,
+ const TDesC& aText,
+ const CFont* aFont )
{
-
TInt xOffset = 0;
TPtrC textPiece;
TInt textPieceIndex = 0;
@@ -1254,8 +1248,8 @@
// -----------------------------------------------------------------------------
//
static HBufC* ConvertToVisualAndClipLC( const TDesC& aText,
- const CFont& aFont,
- const TRect& aBoundingBox )
+ const CFont& aFont,
+ const TRect& aBoundingBox )
{
HBufC* buf = HBufC::NewLC( aText.Length() + KAknBidiExtraSpacePerLine );
TPtr ptr = buf->Des();
@@ -1320,5 +1314,29 @@
return sepCount;
}
+// -----------------------------------------------------------------------------
+// CreateIconL
+//
+// Create and return a new icon object from given file and with given ID
+// -----------------------------------------------------------------------------
+//
+static CGulIcon* CreateIconL(
+ const TDesC& aFileName,
+ TInt aBitmapId,
+ TInt aMaskId )
+ {
+ CGulIcon* icon = CGulIcon::NewLC();
+
+ CFbsBitmap* bm;
+ CFbsBitmap* mask;
+ AknIconUtils::CreateIconL( bm, mask, aFileName, aBitmapId, aMaskId );
+
+ icon->SetBitmap( bm );
+ icon->SetMask( mask );
+
+ CleanupStack::Pop( icon );
+ return icon;
+ }
+
// End of File.