emailuis/emailui/src/ncsattachmentfield.cpp
changeset 2 5253a20d2a1e
parent 0 8466d47a6819
child 14 b13141f05c3d
equal deleted inserted replaced
1:12c456ceeff2 2:5253a20d2a1e
    20 #include <StringLoader.h>
    20 #include <StringLoader.h>
    21 #include <AknUtils.h>
    21 #include <AknUtils.h>
    22 #include <AknsUtils.h>
    22 #include <AknsUtils.h>
    23 #include <AknsSkinInstance.h>
    23 #include <AknsSkinInstance.h>
    24 #include <FreestyleEmailUi.rsg>
    24 #include <FreestyleEmailUi.rsg>
       
    25 #include <touchfeedback.h>
    25 
    26 
    26 #include "FreestyleEmailUiLayoutData.h"
    27 #include "FreestyleEmailUiLayoutData.h"
    27 #include "FreestyleEmailUiAppui.h"
    28 #include "FreestyleEmailUiAppui.h"
    28 #include "FreestyleEmailUiTextureManager.h"
    29 #include "FreestyleEmailUiTextureManager.h"
    29 #include "FreestyleEmailUiLayoutHandler.h"
    30 #include "FreestyleEmailUiLayoutHandler.h"
    30 #include "ncsattachmentfield.h"
    31 #include "ncsattachmentfield.h"
    31 #include "ncsutility.h"
    32 #include "ncsutility.h"
    32 #include "ncsheadercontainer.h"
    33 #include "ncsheadercontainer.h"
       
    34 #include "FSEmail.pan"
    33 
    35 
    34 
    36 
    35 CNcsAttachmentField* CNcsAttachmentField::NewL(
    37 CNcsAttachmentField* CNcsAttachmentField::NewL(
    36     TInt aLabelTextId,
    38     TInt aLabelTextId,
    37     MNcsFieldSizeObserver* aSizeObserver,
    39     MNcsFieldSizeObserver* aSizeObserver,
    38     CNcsHeaderContainer* aParentControl )
    40     CNcsHeaderContainer* aParentControl )
    39     {
    41     {
    40     FUNC_LOG;
    42     FUNC_LOG;
    41     CNcsAttachmentField* self =
    43     CNcsAttachmentField* self =
    42         new ( ELeave ) CNcsAttachmentField( aSizeObserver, aParentControl );
    44         new ( ELeave ) CNcsAttachmentField( aLabelTextId, aSizeObserver, aParentControl );
    43     CleanupStack::PushL( self );
    45     CleanupStack::PushL( self );
    44     self->ConstructL( aLabelTextId );
    46     self->ConstructL();
    45     CleanupStack::Pop( self );
    47     CleanupStack::Pop( self );
    46     return self;
    48     return self;
    47     }
    49     }
    48 
    50 
    49 CNcsAttachmentField::~CNcsAttachmentField()
    51 CNcsAttachmentField::~CNcsAttachmentField()
    50     {
    52     {
    51     FUNC_LOG;
    53     FUNC_LOG;
    52     delete iAttachmentLabel;
    54     iAttachmentLabels.ResetAndDestroy();
    53 
    55 
    54     delete iAttachmentName;
    56     delete iAttachmentNames;
    55     delete iAttachmentSizeDesc;
    57     delete iAttachmentSizes;
    56 
    58 
    57     delete iAttachmentBitmap;
    59     delete iAttachmentBitmap;
    58     delete iAttachmentMask;
    60     delete iAttachmentMask;
    59 
       
    60     delete iActionMenuBitmap;
       
    61     delete iActionMenuMask;
       
    62     }
    61     }
    63 
    62 
    64 // -----------------------------------------------------------------------------
    63 // -----------------------------------------------------------------------------
    65 // CNcsAttachmentField::CNcsAttachmentField()
    64 // CNcsAttachmentField::CNcsAttachmentField()
    66 // -----------------------------------------------------------------------------
    65 // -----------------------------------------------------------------------------
    67 //
    66 //
    68 CNcsAttachmentField::CNcsAttachmentField( MNcsFieldSizeObserver* aSizeObserver,
    67 CNcsAttachmentField::CNcsAttachmentField( TInt aLabelTextId, 
       
    68         MNcsFieldSizeObserver* aSizeObserver,
    69         CNcsHeaderContainer* aParentControl ):
    69         CNcsHeaderContainer* aParentControl ):
    70     MNcsControl( aSizeObserver ),
    70     MNcsControl( aSizeObserver ),
    71     iParentControl( aParentControl )
    71     iParentControl( aParentControl ),
    72     {
    72     iLabelTextId ( aLabelTextId ),
    73     FUNC_LOG;
    73     iFocusedLabelIndex( KNoAttachmentLabelFocused )
    74     }
    74     {
    75 
    75     FUNC_LOG;
    76 void CNcsAttachmentField::ConstructL( TInt aLabelTextId )
    76     }
    77     {
    77 
    78     FUNC_LOG;
    78 void CNcsAttachmentField::ConstructL()
    79     // create title label
    79     {
    80 	HBufC* textBuf = StringLoader::LoadLC( aLabelTextId );
    80     FUNC_LOG;	
    81 
       
    82 	// create attachment label
       
    83     iAttachmentLabel = new ( ELeave ) CNcsLabel( *this, NULL );
       
    84     iAttachmentLabel->SetTextL( textBuf->Des() );
       
    85 
       
    86 	CleanupStack::PopAndDestroy( textBuf );
       
    87 
       
    88     // <cmail> Platform layout change
       
    89 	CreateIconsL();
    81 	CreateIconsL();
    90 	// </cmail> Platform layout change
       
    91 	
       
    92 	UpdateFontSize();
       
    93     UpdateColors();
       
    94     }
    82     }
    95 
    83 
    96 // -----------------------------------------------------------------------------
    84 // -----------------------------------------------------------------------------
    97 // CNcsAttachmentField::LineCount()
    85 // CNcsAttachmentField::LineCount()
    98 // -----------------------------------------------------------------------------
    86 // -----------------------------------------------------------------------------
   141     {
   129     {
   142     FUNC_LOG;
   130     FUNC_LOG;
   143     return 0;
   131     return 0;
   144     }
   132     }
   145 
   133 
   146 // <cmail> Platform layout change
       
   147 // -----------------------------------------------------------------------------
   134 // -----------------------------------------------------------------------------
   148 // CNcsAttachmentField::Reposition()
   135 // CNcsAttachmentField::Reposition()
   149 // -----------------------------------------------------------------------------
   136 // -----------------------------------------------------------------------------
   150 //
   137 //
   151 void CNcsAttachmentField::Reposition(TPoint& aPt, TInt /*aWidth*/ )
   138 void CNcsAttachmentField::Reposition(TPoint& aPt, TInt /*aWidth*/ )
   152     {
   139     {
   153     FUNC_LOG;
   140     FUNC_LOG;
   154     /*
       
   155 	TSize sz( aWidth, MinimumHeight() );
       
   156 	if ( Rect() != TRect( aPt, sz ) )
       
   157 	    {
       
   158 		SetExtent( aPt, sz );
       
   159 	    }
       
   160     aPt.iY += Size().iHeight;
       
   161     */
       
   162     SetPosition( aPt );
   141     SetPosition( aPt );
   163     }
   142     }
   164 // </cmail> Platform layout change
       
   165 
   143 
   166 // -----------------------------------------------------------------------------
   144 // -----------------------------------------------------------------------------
   167 // CNcsAttachmentField::GetLabelText()
   145 // CNcsAttachmentField::GetLabelText()
   168 // -----------------------------------------------------------------------------
   146 // -----------------------------------------------------------------------------
   169 //
   147 //
   171     {
   149     {
   172     FUNC_LOG;
   150     FUNC_LOG;
   173 	return KNullDesC;
   151 	return KNullDesC;
   174     }
   152     }
   175 
   153 
   176 // <cmail> Platform layout change
       
   177 // ---------------------------------------------------------------------------
   154 // ---------------------------------------------------------------------------
   178 // CNcsAttachmentField::LayoutLineCount
   155 // CNcsAttachmentField::LayoutLineCount
   179 // ---------------------------------------------------------------------------
   156 // ---------------------------------------------------------------------------
   180 //
   157 //
   181 TInt CNcsAttachmentField::LayoutLineCount() const
   158 TInt CNcsAttachmentField::LayoutLineCount() const
   182     {
   159     {
   183     FUNC_LOG;
   160     FUNC_LOG;
   184     return ( IsVisible() ? 1 : 0 );
   161     return ( IsVisible() ? iAttachmentLabelCount : 0 );
   185     }
   162     }
   186 // </cmail> Platform layout change
       
   187 
   163 
   188 // -----------------------------------------------------------------------------
   164 // -----------------------------------------------------------------------------
   189 // CNcsAttachmentField::Draw()
   165 // CNcsAttachmentField::Draw()
   190 // -----------------------------------------------------------------------------
   166 // -----------------------------------------------------------------------------
   191 //
   167 //
   193     {
   169     {
   194     FUNC_LOG;
   170     FUNC_LOG;
   195     CWindowGc& gc = SystemGc();
   171     CWindowGc& gc = SystemGc();
   196 
   172 
   197     // Draw text box
   173     // Draw text box
   198     // <cmail> Drawing removed </cmail>
       
   199 
       
   200     if ( IsFocused() )
   174     if ( IsFocused() )
   201     	{
   175     	{
   202     	// highlight for label when focused
   176     	TBool highlighedFound( EFalse );
   203 	    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   177     	for ( TInt i( 0 ); !highlighedFound && i<iAttachmentLabelCount; ++i )
   204 	    TRgb imageColor;
   178     	    {
   205 	    if( AknsUtils::GetCachedColor( skin, imageColor,
   179     	    if ( iAttachmentLabels[i]->IsFocused() )
   206 	    		KAknsIIDFsHighlightColors, EAknsCIFsHighlightColorsCG4 ) != KErrNone )
   180     	        {
   207 	        {
   181     	        highlighedFound = ETrue;
   208 		    if( AknsUtils::GetCachedColor( skin, imageColor,
   182     	        // highlight for label when focused
   209 		    		KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG2 ) != KErrNone )
   183     	        MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   210 		    	{
   184     	        TRgb imageColor;
   211 		        imageColor = KRgbBlue;
   185     	        if( KErrNone != AknsUtils::GetCachedColor( 
   212 		    	}
   186                         skin, imageColor,
   213 	        }
   187                         KAknsIIDFsHighlightColors, 
       
   188                         EAknsCIFsHighlightColorsCG4 ) &&
       
   189                     KErrNone != AknsUtils::GetCachedColor(
       
   190                         skin, imageColor,
       
   191                         KAknsIIDQsnHighlightColors,
       
   192                         EAknsCIQsnHighlightColorsCG2 ) )
       
   193     	            {
       
   194     	            imageColor = KRgbBlue;
       
   195     	            }
   214 	    
   196 	    
   215 	    gc.SetPenStyle( CGraphicsContext::ENullPen );
   197     	        gc.SetPenStyle( CGraphicsContext::ENullPen );
   216 	    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
   198     	        gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
   217 	    gc.SetBrushColor( imageColor );
   199     	        gc.SetBrushColor( imageColor );
   218 	    
   200 
   219 	    TRect highlightRect( iAttachmentLabel->Rect() );
   201     	        TRect highlightRect( 
   220 
   202     	                iAttachmentLabels[i]->TextHitAreaRect() );
   221 	    TInt sizeTextInPixels = iAttachmentLabel->Font()->TextWidthInPixels( 
   203     	        highlightRect.Grow( 0, 1 );
   222 									*iAttachmentLabel->Text() );
   204     	        gc.DrawRect( highlightRect );
   223 	    
   205     	        }
   224         highlightRect.SetWidth( sizeTextInPixels );
   206     	    }
   225         highlightRect.Grow( 0, 1 );
       
   226 	    
       
   227 	    if( AknLayoutUtils::LayoutMirrored() )
       
   228 	    	{
       
   229 	    	highlightRect.Move( Rect().Size().iWidth - 
       
   230 								highlightRect.Size().iWidth - 
       
   231 								highlightRect.iTl.iX - 2, 0 );
       
   232 	    	}
       
   233 	    
       
   234 	    gc.DrawRect( highlightRect );
       
   235     	}
   207     	}
   236     
   208     
   237     // Draw icons
   209     // Draw icons
   238     gc.SetBrushStyle( CGraphicsContext::ENullBrush );
   210     gc.SetBrushStyle( CGraphicsContext::ENullBrush );
   239     // <cmail> Platform layout change
       
   240 
       
   241     gc.BitBltMasked( iAttachmentIconPos, iAttachmentBitmap, 
   211     gc.BitBltMasked( iAttachmentIconPos, iAttachmentBitmap, 
   242     		iAttachmentBitmap->SizeInPixels(), iAttachmentMask, ETrue );
   212     		         iAttachmentBitmap->SizeInPixels(), 
   243 
   213     		         iAttachmentMask, ETrue );
   244     if( IsFocused() )
       
   245     	{
       
   246         gc.BitBltMasked( iActionMenuIconPos, iActionMenuBitmap, 
       
   247         		iActionMenuBitmap->SizeInPixels(), iActionMenuMask, ETrue );
       
   248     	}
       
   249     }
   214     }
   250 
   215 
   251 // -----------------------------------------------------------------------------
   216 // -----------------------------------------------------------------------------
   252 // CNcsAttachmentField::SizeChanged()
   217 // CNcsAttachmentField::SizeChanged()
   253 // -----------------------------------------------------------------------------
   218 // -----------------------------------------------------------------------------
   254 //
   219 //
   255 void CNcsAttachmentField::SizeChanged()
   220 void CNcsAttachmentField::SizeChanged()
   256     {
   221     {
   257     FUNC_LOG;
   222     FUNC_LOG;
   258  
       
   259     LayoutControls();
   223     LayoutControls();
   260     // </cmail> Platform laytout change
       
   261 	UpdateFontSize();
   224 	UpdateFontSize();
   262 	UpdateColors();
   225 	UpdateColors();
   263     // The attachment text needs to be updated when label size changes because it
   226     // The attachment texts needs to be updated when label size changes because it
   264 	// may now get truncated differently.
   227 	// may now get truncated differently.
   265 	TRAP_IGNORE( UpdateAttachmentTextL() );
   228 	TRAP_IGNORE( UpdateAttachmentTextsL() );
   266     }
   229     }
   267 
   230 
   268 // -----------------------------------------------------------------------------
   231 // -----------------------------------------------------------------------------
   269 // CNcsAttachmentField::PositionChanged()
   232 // CNcsAttachmentField::PositionChanged()
   270 // -----------------------------------------------------------------------------
   233 // -----------------------------------------------------------------------------
   271 //
   234 //
   272 void CNcsAttachmentField::PositionChanged()
   235 void CNcsAttachmentField::PositionChanged()
   273     {
   236     {
   274     FUNC_LOG;
   237     FUNC_LOG;
   275     // <cmail> Platform layout change
       
   276     LayoutControls();
   238     LayoutControls();
   277     UpdateColors();
   239     UpdateColors();
   278    
       
   279     // </cmail> Platform layout change
       
   280     }
   240     }
   281 
   241 
   282 // -----------------------------------------------------------------------------
   242 // -----------------------------------------------------------------------------
   283 // CNcsAttachmentField::MinimumHeight()
   243 // CNcsAttachmentField::MinimumHeight()
   284 // -----------------------------------------------------------------------------
   244 // -----------------------------------------------------------------------------
   285 //
   245 //
   286 TInt CNcsAttachmentField::MinimumHeight() const
   246 TInt CNcsAttachmentField::MinimumHeight() const
   287     {
   247     {
   288     FUNC_LOG;
   248     FUNC_LOG;
   289     // <cmail> Platform laytout change
       
   290     /*
       
   291     TNcsMeasures m = NcsUtility::Measures();
       
   292     return m.iAifHeight + m.iAttachmentExtraHeightBottom;*/
       
   293     //return NcsUtility::MinimumHeaderSize( Rect(), 1 ).iHeight;
       
   294     // </cmail> Platform laytout change
       
   295     return 0;
   249     return 0;
   296     }
   250     }
   297 
   251 
   298 // -----------------------------------------------------------------------------
   252 // -----------------------------------------------------------------------------
   299 // CNcsAttachmentField::SetMaxLabelLength()
   253 // CNcsAttachmentField::SetMaxLabelLength()
   314     FUNC_LOG;
   268     FUNC_LOG;
   315     return 0;
   269     return 0;
   316     }
   270     }
   317 
   271 
   318 // -----------------------------------------------------------------------------
   272 // -----------------------------------------------------------------------------
   319 // CNcsAttachmentField::SetContainerWindowL() const
   273 // CNcsAttachmentField::SetContainerWindowL()
   320 // -----------------------------------------------------------------------------
   274 // -----------------------------------------------------------------------------
   321 //
   275 //
   322 void CNcsAttachmentField::SetContainerWindowL( const CCoeControl& aContainer )
   276 void CNcsAttachmentField::SetContainerWindowL( const CCoeControl& aContainer )
   323 	{
   277 	{
   324     FUNC_LOG;
   278     FUNC_LOG;
   325 	CCoeControl::SetContainerWindowL( aContainer );
   279 	CCoeControl::SetContainerWindowL( aContainer );
   326 
   280 
   327 	// Create the component array
   281 	UpdateComponentArrayL();
       
   282 	}
       
   283 
       
   284 // -----------------------------------------------------------------------------
       
   285 // CNcsAttachmentField::UpdateComponentArrayL()
       
   286 // -----------------------------------------------------------------------------
       
   287 //
       
   288 void CNcsAttachmentField::UpdateComponentArrayL()
       
   289     {
       
   290     FUNC_LOG;
   328     InitComponentArrayL();
   291     InitComponentArrayL();
   329 	CCoeControlArray& controls = Components();
   292     CCoeControlArray& controls = Components();
   330 	controls.SetControlsOwnedExternally( ETrue );
   293     TInt controlsCount( controls.Count() );
   331 	controls.AppendLC( iAttachmentLabel );
   294     controls.SetControlsOwnedExternally( ETrue );
   332     CleanupStack::Pop( iAttachmentLabel );
   295     
   333 
   296     // Create the new component array items if needed
   334     // set label properties
   297     if ( iAttachmentLabelCount > controlsCount )
   335 	UpdateFontSize();
   298         {
   336 
   299         // append controls for new attachment labels after the existing ones
   337     // Setup text alignment according the mirrored/normal layout.
   300         for ( TInt i( controlsCount ); i<iAttachmentLabelCount; ++i )
   338     if ( AknLayoutUtils::LayoutMirrored() )
   301             {
   339         {
   302             controls.AppendLC( iAttachmentLabels[i] );
   340         iAttachmentLabel->SetAlignment( EHRightVCenter );
   303             CleanupStack::Pop( iAttachmentLabels[i] );
   341         }
   304         
   342     else
   305             UpdateFontSize( iAttachmentLabels[i] );
   343         {
   306         
   344         iAttachmentLabel->SetAlignment( EHLeftVCenter );
   307             // Align according to mirrored layout variation
   345         }
   308             iAttachmentLabels[i]->SetAlignment( AknLayoutUtils::LayoutMirrored() ?
   346 	}
   309                     EHRightVCenter : EHLeftVCenter );
   347 
   310             }
   348 // -----------------------------------------------------------------------------
   311         }
   349 // CNcsAttachmentField::SetTextL()
   312     // Remove unnecessary component array items from the end
   350 // -----------------------------------------------------------------------------
   313     else if ( iAttachmentLabelCount < controlsCount )
   351 //
   314         {
   352 void CNcsAttachmentField::SetTextL( const TDesC& aText )
   315         for ( TInt i( controlsCount-1 ); i>=iAttachmentLabelCount ; --i )
   353     {
   316             {
   354     FUNC_LOG;
   317             controls.Remove( iAttachmentLabels[i] );
   355     delete iAttachmentName;
   318             }
   356     iAttachmentName = NULL;
   319         }
   357     delete iAttachmentSizeDesc;
   320     }
   358     iAttachmentSizeDesc = NULL;
   321 
   359 
   322 // -----------------------------------------------------------------------------
   360     iAttachmentLabel->SetTextL( aText );
   323 // CNcsAttachmentField::SetTextsLD()
   361     }
   324 // -----------------------------------------------------------------------------
   362 
   325 //
   363 // -----------------------------------------------------------------------------
   326 void CNcsAttachmentField::SetTextsLD( 
   364 // CNcsAttachmentField::SetTextL()
   327     CDesCArray* aAttachmentNames, CDesCArray* aAttachmentSizes )
   365 // -----------------------------------------------------------------------------
   328     {
   366 //
   329     FUNC_LOG;
   367 void CNcsAttachmentField::SetTextL( const TDesC& aAttachmentName, const TDesC& aAttachmentSizeDesc )
   330     delete iAttachmentNames; 
   368     {
   331     iAttachmentNames = NULL;
   369     FUNC_LOG;
   332     iAttachmentNames = aAttachmentNames;
   370     delete iAttachmentName;
   333     delete iAttachmentSizes;
   371     iAttachmentName = NULL;
   334     iAttachmentSizes = NULL;
   372     delete iAttachmentSizeDesc;
   335     iAttachmentSizes = aAttachmentSizes;
   373     iAttachmentSizeDesc = NULL;
   336 
   374 
   337     if ( iAttachmentNames )
   375     iAttachmentName = aAttachmentName.AllocL();
   338         {
   376     iAttachmentSizeDesc = aAttachmentSizeDesc.AllocL();
   339         __ASSERT_DEBUG( iAttachmentNames && 
   377     UpdateAttachmentTextL();
   340                         iAttachmentSizes && 
   378     }
   341                         iAttachmentNames->Count() == iAttachmentSizes->Count(), 
   379 
   342                         Panic( ENcsBasicUi ) );
   380 // -----------------------------------------------------------------------------
   343  
   381 // CNcsAttachmentField::UpdateAttachmentTextL()
   344         TInt attachmentLabelCountBeforeUpdate( iAttachmentLabelCount );
   382 // -----------------------------------------------------------------------------
   345     
   383 //
   346         UpdateAttachmentTextsL();
   384 void CNcsAttachmentField::UpdateAttachmentTextL()
   347     
   385     {
   348         // set the focused attachment label
   386     FUNC_LOG;
   349         if ( iAttachmentLabelCount == 0 )
   387     if ( iAttachmentName && iAttachmentSizeDesc )
   350             {
   388         {
   351             // No attachments
   389         // create decorated size text including the preceeding space character
   352             iFocusedLabelIndex = KNoAttachmentLabelFocused;
   390         HBufC* decoratedSize = StringLoader::LoadLC( R_FSE_VIEWER_ATTACHMENTS_LIST_SIZE, 
   353             }
   391                                                      *iAttachmentSizeDesc );
   354         else if ( iFocusedLabelIndex >= iAttachmentLabelCount ||
   392         HBufC* decoratedSizeWithSpace = HBufC::NewL( decoratedSize->Length() + 
   355                   attachmentLabelCountBeforeUpdate < iAttachmentLabelCount )
   393                                                      KSpace().Length() +
   356             {
   394                                                      KBidiRleStartChar().Length() +
   357             // Set the focused index to last, we get here either if the last
   395                                                      KBidiPdfChar().Length() );
   358             // attachment label in list was removed or a new one was added.
   396         decoratedSizeWithSpace->Des().Append( KSpace );
   359             // In either case focused should be the new last attachment label.
   397         if ( AknLayoutUtils::LayoutMirrored() )
   360             iFocusedLabelIndex = iAttachmentLabelCount-1;
   398             {
   361             }
   399             // Put size part into embedded right-to-left block to ensure correct rendering
   362         // In any other case, don't re-set the focused label index
   400             // even when name part is written from left-to-right.
   363         }
   401             decoratedSizeWithSpace->Des().Append( KBidiRleStartChar );
   364     else // no attachments 
   402             decoratedSizeWithSpace->Des().Append( *decoratedSize );
   365         {
   403             decoratedSizeWithSpace->Des().Append( KBidiPdfChar );
   366         iAttachmentLabelCount = 0;
   404             }
   367         iFocusedLabelIndex = KNoAttachmentLabelFocused;
   405         else
   368         }
   406             {
   369     
   407             decoratedSizeWithSpace->Des().Append( *decoratedSize );
   370     UpdateComponentArrayL();
   408             }
   371     LayoutControls();
   409         CleanupStack::PopAndDestroy( decoratedSize );
   372     iSizeObserver->UpdateFieldSizeL();
   410         CleanupStack::PushL( decoratedSizeWithSpace );
   373     }
   411 
   374 
   412         // clip attachment name to fit the field so that size information has enough space too.
   375 // -----------------------------------------------------------------------------
   413         const CFont& font = *iAttachmentLabel->Font();
   376 // CNcsAttachmentField::FocusedAttachmentLabelIndex()
   414 
   377 // -----------------------------------------------------------------------------
   415         TInt labelWidth = iAttachmentLabel->Size().iWidth;
   378 //
   416         TInt sizeTextInPixels = font.TextWidthInPixels( *decoratedSizeWithSpace );
   379 TInt CNcsAttachmentField::FocusedAttachmentLabelIndex()
   417         TInt pixelsLeftForAttachmentName = labelWidth - sizeTextInPixels;
   380     {
   418 
   381     FUNC_LOG;
   419         HBufC* attachmentText = NULL; // will contain the complete text
   382     return iFocusedLabelIndex;
   420         // safe check if the size information is too wide for some reason.
   383     }
   421         if ( pixelsLeftForAttachmentName < 0 )
   384 
   422             {
   385 // -----------------------------------------------------------------------------
   423             attachmentText = HBufC::NewLC( iAttachmentName->Length() + decoratedSizeWithSpace->Length() );
   386 // CNcsAttachmentField::UpdateAttachmentTextsL()
   424             attachmentText->Des().Append( *iAttachmentName );
   387 // -----------------------------------------------------------------------------
   425             attachmentText->Des().Append( *decoratedSizeWithSpace );
   388 //
   426             TPtr attachmentTextBufferModDes = attachmentText->Des();
   389 void CNcsAttachmentField::UpdateAttachmentTextsL()
   427             AknTextUtils::ClipToFit( attachmentTextBufferModDes, font, labelWidth );
   390     {
   428             }
   391     FUNC_LOG;
   429         else
   392     // create new array of labels. 
   430             { // normal case
   393     iAttachmentLabelCount = 0;
   431             HBufC* attacmentNameBuffer = iAttachmentName->AllocLC();
   394     TInt count = iAttachmentNames->MdcaCount();
   432             TPtr attachmentNameBufferModDes = attacmentNameBuffer->Des();
   395     TInt existingLabelCount = iAttachmentLabels.Count();
   433             AknTextUtils::ClipToFit( attachmentNameBufferModDes, font, pixelsLeftForAttachmentName );
   396     TInt i( 0 );    
   434 
   397     
   435             attachmentText = HBufC::NewL( attacmentNameBuffer->Length() + decoratedSizeWithSpace->Length() );
   398     // First, set the new texts using existing attachment labels objects
   436             attachmentText->Des().Append( *attacmentNameBuffer );
   399     for ( ; i<count; ++i )
   437             attachmentText->Des().Append( *decoratedSizeWithSpace );
   400         {
   438             CleanupStack::PopAndDestroy( attacmentNameBuffer );
   401         if ( i==existingLabelCount )
   439             CleanupStack::PushL( attachmentText );
   402             {
   440             }
   403             // no more re-usable label objects in their array.. break this 
   441 
   404             // loop and continue with the next one (that creates new labels)
   442         iAttachmentLabel->SetTextL( *attachmentText );
   405             break;
   443 
   406             }
   444         CleanupStack::PopAndDestroy( attachmentText );
   407         UpdateSingleAttachmentLabelTextL( iAttachmentLabels[i], i );
   445         CleanupStack::PopAndDestroy( decoratedSizeWithSpace );
   408         ++iAttachmentLabelCount;
   446         }
   409         }
   447     }
   410     
   448 
   411     // Create new attachment labels if needed
   449 // <cmail> Platform layout change
   412     if ( i<count )
       
   413         {
       
   414         // stringloader used to get the initial (dummy) attachment text..
       
   415         HBufC* textBuf = StringLoader::LoadLC( iLabelTextId );
       
   416         
       
   417         for ( ; i<count; ++i )
       
   418             {
       
   419             // create and initialize (fonts & colors) new label
       
   420             CNcsLabel* label = new ( ELeave ) CNcsLabel( *this, NULL );
       
   421             CleanupStack::PushL( label );
       
   422             label->SetTextL( *textBuf );
       
   423             UpdateFontSize( label );
       
   424             UpdateColors( label );
       
   425             UpdateSingleAttachmentLabelTextL( label, i );
       
   426      
       
   427             // append then new label to attachment label array
       
   428             iAttachmentLabels.AppendL( label );
       
   429             CleanupStack::Pop( label );
       
   430             ++iAttachmentLabelCount;
       
   431             }
       
   432         CleanupStack::PopAndDestroy( textBuf );
       
   433         }
       
   434     }
       
   435 
       
   436 
   450 // -----------------------------------------------------------------------------
   437 // -----------------------------------------------------------------------------
   451 // CNcsAttachmentField::ResizeIcons()
   438 // CNcsAttachmentField::ResizeIcons()
   452 // -----------------------------------------------------------------------------
   439 // -----------------------------------------------------------------------------
   453 //
   440 //
   454 void CNcsAttachmentField::ResizeIcons()
   441 void CNcsAttachmentField::ResizeIcons()
   455     {
   442     {
   456     FUNC_LOG;
   443     FUNC_LOG;
   457     const TSize frontIconSize( NcsUtility::HeaderDetailIconRect( Rect(), 1, NcsUtility::EIconFront ).Size() );
   444     const TSize frontIconSize( NcsUtility::HeaderDetailIconRect( 
       
   445             Rect(), 1, NcsUtility::EIconFront ).Size() );
   458     if ( frontIconSize != iAttachmentBitmap->SizeInPixels() )
   446     if ( frontIconSize != iAttachmentBitmap->SizeInPixels() )
   459         {
   447         {
   460         AknIconUtils::SetSize( iAttachmentBitmap, frontIconSize, EAspectRatioPreservedAndUnusedSpaceRemoved );
   448         AknIconUtils::SetSize( iAttachmentBitmap, frontIconSize, 
   461         AknIconUtils::SetSize( iAttachmentMask, frontIconSize, EAspectRatioPreservedAndUnusedSpaceRemoved );
   449                                EAspectRatioPreservedAndUnusedSpaceRemoved );
   462         }
   450         AknIconUtils::SetSize( iAttachmentMask, frontIconSize, 
   463     const TSize backIconSize( NcsUtility::HeaderDetailIconRect( Rect(), 1, NcsUtility::EIconBack ).Size() );
   451                                EAspectRatioPreservedAndUnusedSpaceRemoved );
   464     if ( backIconSize != iActionMenuBitmap->SizeInPixels() )
   452         }
   465         {
   453     }
   466         AknIconUtils::SetSize( iActionMenuBitmap, backIconSize, EAspectRatioNotPreserved  );
       
   467         AknIconUtils::SetSize( iActionMenuMask, backIconSize, EAspectRatioNotPreserved  );
       
   468         }
       
   469     }
       
   470 // </cmail> Platform layout change
       
   471 
   454 
   472 // -----------------------------------------------------------------------------
   455 // -----------------------------------------------------------------------------
   473 // CNcsAttachmentField::FocusChanged()
   456 // CNcsAttachmentField::FocusChanged()
   474 // -----------------------------------------------------------------------------
   457 // -----------------------------------------------------------------------------
   475 //
   458 //
   476 void CNcsAttachmentField::FocusChanged( TDrawNow aDrawNow )
   459 void CNcsAttachmentField::FocusChanged( TDrawNow aDrawNow )
   477 	{
   460 	{
   478     FUNC_LOG;
   461     FUNC_LOG;
   479 	if ( IsFocused() )
   462 	if ( IsFocused() )
   480 		{
   463 	    {
   481 		iAttachmentLabel->SetFocus( ETrue );
   464 	    for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i )
   482 
   465 	        {
       
   466 	        iAttachmentLabels[i]->SetFocus( i==iFocusedLabelIndex );
       
   467 	        }
   483         // make sure that control is visible on screen
   468         // make sure that control is visible on screen
   484 		if ( Rect().iTl.iY < 0 )
   469 		if ( Rect().iTl.iY < 0 )
   485 			{
   470 			{
   486 			TPoint pt = TPoint( 0, 0 );
   471 			TPoint pt = TPoint( 0, 0 );
   487 			Reposition( pt,Rect().Width() );
   472 			Reposition( pt,Rect().Width() );
   508             TRAP_IGNORE( iParentControl->SetMskL() );
   493             TRAP_IGNORE( iParentControl->SetMskL() );
   509             }
   494             }
   510 		}
   495 		}
   511 	else
   496 	else
   512 		{
   497 		{
   513 		iAttachmentLabel->SetFocus( EFalse );
   498 		for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i )
       
   499 		    {
       
   500 		    iAttachmentLabels[i]->SetFocus( EFalse );
       
   501 		    }
   514 		}
   502 		}
   515 
   503 	
   516     iAttachmentLabel->SetUnderlining( IsFocused() );
       
   517     UpdateColors();
   504     UpdateColors();
   518     
   505     
   519 	if ( aDrawNow )
   506 	if ( aDrawNow )
   520 		{
   507 		{
   521 		DrawNow();
   508 		DrawNow();
   530 // CNcsAttachmentField::UpdateColors()
   517 // CNcsAttachmentField::UpdateColors()
   531 // -----------------------------------------------------------------------------
   518 // -----------------------------------------------------------------------------
   532 //
   519 //
   533 void CNcsAttachmentField::UpdateColors()
   520 void CNcsAttachmentField::UpdateColors()
   534     {
   521     {
   535     // <cmail> Platform layout change
   522     FUNC_LOG;
   536     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   523     for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i )
   537     TRgb textColor = KRgbBlack;
   524         {
   538 
   525         UpdateColors( iAttachmentLabels[i] );
   539     if( IsFocused() )
   526         // currently all attachments are underlined
   540     	{
   527         iAttachmentLabels[i]->SetUnderlining( ETrue );
   541         AknsUtils::GetCachedColor(
   528         }
   542             skin,
   529     
   543             textColor,
       
   544             KAknsIIDQsnTextColors,
       
   545             EAknsCIQsnTextColorsCG24 );
       
   546     	}
       
   547     else
       
   548     	{
       
   549 		AknsUtils::GetCachedColor(
       
   550 			skin,
       
   551 			textColor,
       
   552 			KAknsIIDQsnTextColors,
       
   553 			EAknsCIQsnTextColorsCG6 );
       
   554     	}
       
   555     TRAP_IGNORE( iAttachmentLabel->OverrideColorL( 
       
   556             EColorLabelText, textColor ) );
       
   557 
       
   558     textColor = KRgbBlack;
       
   559 
       
   560     TInt err = AknsUtils::GetCachedColor(
       
   561         skin,
       
   562         textColor,
       
   563         KAknsIIDQsnHighlightColors,
       
   564         EAknsCIQsnHighlightColorsCG3 );
       
   565 
       
   566     TRAP_IGNORE( iAttachmentLabel->OverrideColorL(
       
   567         EColorLabelTextEmphasis, textColor ) );
       
   568 
       
   569     textColor = KRgbBlack;
       
   570 
       
   571     err = AknsUtils::GetCachedColor(
       
   572         skin,
       
   573         textColor,
       
   574         KAknsIIDQsnHighlightColors,
       
   575         EAknsCIQsnHighlightColorsCG2 );
       
   576 
       
   577     TRAP_IGNORE( iAttachmentLabel->OverrideColorL(
       
   578         EColorLabelHighlightFullEmphasis, textColor ) );
       
   579     // </cmail> Platform layout change
       
   580     CFreestyleEmailUiAppUi* appUi =
   530     CFreestyleEmailUiAppUi* appUi =
   581         static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() );
   531         static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() );
   582     iBorderColor = appUi->LayoutHandler()->ComposerFieldBorderColor();
   532     iBorderColor = appUi->LayoutHandler()->ComposerFieldBorderColor();
   583     iBgColor = appUi->LayoutHandler()->ComposerFieldBackgroundColor();
   533     iBgColor = appUi->LayoutHandler()->ComposerFieldBackgroundColor();
   584     }
   534     }
   585 
   535 
   586 // <cmail> Platform layout change
   536 // -----------------------------------------------------------------------------
       
   537 // CNcsAttachmentField::UpdateColors()
       
   538 // -----------------------------------------------------------------------------
       
   539 //
       
   540 void CNcsAttachmentField::UpdateColors( CNcsLabel* aLabel )
       
   541     {
       
   542     FUNC_LOG;    
       
   543     if ( aLabel )
       
   544         {
       
   545         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   546         TRgb labelTextColor = KRgbBlack;
       
   547         TRgb labelEmphasisColor = KRgbBlack;
       
   548         TRgb labelHighlightFullEmphasisColor = KRgbBlack;
       
   549     
       
   550         AknsUtils::GetCachedColor(
       
   551             skin,
       
   552             labelTextColor,
       
   553             KAknsIIDQsnTextColors,
       
   554             aLabel->IsFocused() ? 
       
   555                 EAknsCIQsnTextColorsCG24 : EAknsCIQsnTextColorsCG6 );
       
   556         AknsUtils::GetCachedColor(
       
   557             skin,
       
   558             labelEmphasisColor,
       
   559             KAknsIIDQsnHighlightColors,
       
   560             EAknsCIQsnHighlightColorsCG3 );
       
   561         AknsUtils::GetCachedColor(
       
   562             skin,
       
   563             labelHighlightFullEmphasisColor,
       
   564             KAknsIIDQsnHighlightColors,
       
   565             EAknsCIQsnHighlightColorsCG2 );
       
   566         
       
   567         TRAP_IGNORE( aLabel->OverrideColorL( 
       
   568             EColorLabelText, labelTextColor ) );
       
   569         TRAP_IGNORE( aLabel->OverrideColorL(
       
   570             EColorLabelTextEmphasis, labelEmphasisColor ) );
       
   571         TRAP_IGNORE( aLabel->OverrideColorL(
       
   572             EColorLabelHighlightFullEmphasis, 
       
   573             labelHighlightFullEmphasisColor ) );
       
   574         }
       
   575     }
       
   576 
   587 // -----------------------------------------------------------------------------
   577 // -----------------------------------------------------------------------------
   588 // CNcsAttachmentField::UpdateFontSize()
   578 // CNcsAttachmentField::UpdateFontSize()
   589 // -----------------------------------------------------------------------------
   579 // -----------------------------------------------------------------------------
   590 //
   580 //
   591 void CNcsAttachmentField::UpdateFontSize()
   581 void CNcsAttachmentField::UpdateFontSize()
   592 	{
   582 	{
   593     FUNC_LOG;
   583     FUNC_LOG;
   594     /*if ( iLabelFont )
   584     if ( iAttachmentLabelCount )
   595         {
   585         {
   596         ControlEnv()->ScreenDevice()->ReleaseFont( iLabelFont );
   586         // same font used for all labels, so just get the first one's
   597         iLabelFont = NULL;
   587         iEditorFont = NcsUtility::GetLayoutFont( 
   598         }
   588             iAttachmentLabels[0]->Rect(), NcsUtility::ENcsHeaderDetailFont );            
   599 
   589         }
   600     if ( iEditorFont )
   590     for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i )
   601         {
   591         {
   602         ControlEnv()->ScreenDevice()->ReleaseFont( iEditorFont );
   592         iAttachmentLabels[i]->SetFont( iEditorFont );
   603         iEditorFont = NULL;
   593         }
   604         }
       
   605 
       
   606     // set label properties
       
   607 	TNcsMeasures m = NcsUtility::Measures();
       
   608 	if ( !iLabelFont )
       
   609 	    {
       
   610 	    TRAP_IGNORE( iLabelFont = NcsUtility::GetNearestFontL(EAknLogicalFontPrimarySmallFont,
       
   611 	    	m.iLabelFontHeightPx) );
       
   612 	    }
       
   613 
       
   614 	iTitleLabel->SetFont( iLabelFont );
       
   615 
       
   616 	if ( !iEditorFont )
       
   617 		{
       
   618 		TRAP_IGNORE( iEditorFont = NcsUtility::GetNearestFontL(EAknLogicalFontPrimarySmallFont,
       
   619 			m.iEditorFontHeightPx) );
       
   620 		}
       
   621 
       
   622 	iAttachmentLabel->SetFont( iEditorFont );*/
       
   623     iEditorFont = NcsUtility::GetLayoutFont( iAttachmentLabel->Rect(), NcsUtility::ENcsHeaderDetailFont );
       
   624 	iAttachmentLabel->SetFont( iEditorFont );
       
   625 	}
   594 	}
   626 
   595 
   627 // -----------------------------------------------------------------------------
   596 // -----------------------------------------------------------------------------
       
   597 // CNcsAttachmentField::UpdateFontSize()
       
   598 // -----------------------------------------------------------------------------
       
   599 //
       
   600 void CNcsAttachmentField::UpdateFontSize( CNcsLabel* aLabel )
       
   601     {
       
   602     FUNC_LOG;
       
   603     iEditorFont = NcsUtility::GetLayoutFont( 
       
   604             aLabel->Rect(), NcsUtility::ENcsHeaderDetailFont );
       
   605     aLabel->SetFont( iEditorFont );
       
   606     }
       
   607 
       
   608 // -----------------------------------------------------------------------------
   628 // CNcsAttachmentField::LayoutControls()
   609 // CNcsAttachmentField::LayoutControls()
   629 // -----------------------------------------------------------------------------
   610 // -----------------------------------------------------------------------------
   630 //
   611 //
   631 void CNcsAttachmentField::LayoutControls()
   612 void CNcsAttachmentField::LayoutControls()
   632     {
   613     {
   633     FUNC_LOG;
   614     FUNC_LOG;
   634     const TRect rect( Rect() );
   615     const TRect rect( Rect() );
   635     NcsUtility::LayoutDetailLabel( iAttachmentLabel, rect );
   616     for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i )
   636     UpdateIconPositions( rect );
   617         {
       
   618         NcsUtility::LayoutDetailLabel( iAttachmentLabels[i], rect, i );
       
   619         if ( i == 0 )
       
   620             {
       
   621             // icons need to be updated for first round only
       
   622             UpdateIconPositions( rect );
       
   623             }
       
   624         }
   637     }
   625     }
   638 
   626 
   639 // -----------------------------------------------------------------------------
   627 // -----------------------------------------------------------------------------
   640 // CNcsAttachmentField::UpdateIconPositions()
   628 // CNcsAttachmentField::UpdateIconPositions()
   641 // -----------------------------------------------------------------------------
   629 // -----------------------------------------------------------------------------
   642 //
   630 //
   643 void CNcsAttachmentField::UpdateIconPositions( const TRect& aRect )
   631 void CNcsAttachmentField::UpdateIconPositions( const TRect& aRect )
   644     {
   632     {
   645     FUNC_LOG;
   633     FUNC_LOG;
   646     iAttachmentIconPos = NcsUtility::HeaderDetailIconRect( aRect, 1, NcsUtility::EIconFront ).iTl;
   634     iAttachmentIconPos = NcsUtility::HeaderDetailIconRect( 
   647     iActionMenuIconPos = NcsUtility::HeaderDetailIconRect( aRect, 1, NcsUtility::EIconBack ).iTl;
   635             aRect, 1, NcsUtility::EIconFront ).iTl;
   648     }
   636     }
   649 // </cmail> Platform layout change
       
   650 
   637 
   651 // -----------------------------------------------------------------------------
   638 // -----------------------------------------------------------------------------
   652 // CNcsAttachmentField::HandleResourceChange()
   639 // CNcsAttachmentField::HandleResourceChange()
   653 // -----------------------------------------------------------------------------
   640 // -----------------------------------------------------------------------------
   654 //
   641 //
   659     if ( aType == KAknsMessageSkinChange ||
   646     if ( aType == KAknsMessageSkinChange ||
   660          aType == KEikMessageColorSchemeChange )
   647          aType == KEikMessageColorSchemeChange )
   661         {
   648         {
   662         UpdateFontSize();
   649         UpdateFontSize();
   663         UpdateColors();
   650         UpdateColors();
   664         // <cmail> Platform layout change
       
   665         CreateIcons();
   651         CreateIcons();
   666         // </cmail> Platform layout change
       
   667         DrawDeferred();
   652         DrawDeferred();
   668         }
   653         }
   669     }
   654     }
   670 
   655 
   671 // <cmail> Platform layout change
   656 // -----------------------------------------------------------------------------
       
   657 // CNcsAttachmentField::HandlePointerEventL()
       
   658 // -----------------------------------------------------------------------------
       
   659 //
       
   660 void CNcsAttachmentField::HandlePointerEventL( 
       
   661         const TPointerEvent& aPointerEvent )
       
   662     {
       
   663     FUNC_LOG;
       
   664     CCoeControl::HandlePointerEventL( aPointerEvent );
       
   665     
       
   666     if ( Rect().Contains( aPointerEvent.iPosition ) &&
       
   667          aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   668         {
       
   669         TBool focusedAttachmentLabelIndexChanged( EFalse );
       
   670         TInt i( 0 );
       
   671         for ( ; i<iAttachmentLabelCount; ++i )
       
   672             {
       
   673             if ( iAttachmentLabels[i]->TextHitAreaRect().Contains( 
       
   674                     aPointerEvent.iPosition ) )
       
   675                 {
       
   676                 // tactile feedback
       
   677                 MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   678                 if ( feedback )
       
   679                     {
       
   680                     feedback->InstantFeedback( this, ETouchFeedbackBasic );
       
   681                     }
       
   682                 
       
   683                 if ( iFocusedLabelIndex != i )
       
   684                     {
       
   685                     focusedAttachmentLabelIndexChanged = ETrue;
       
   686                     iFocusedLabelIndex =  i;
       
   687                     }
       
   688                 break;
       
   689                 }
       
   690             }
       
   691 
       
   692         if ( i == iAttachmentLabelCount )
       
   693             {
       
   694             // Pointer event happened outside any of the labels. 
       
   695             // Invalidate focused label index.. this will cause the next
       
   696             // for loop to set all label focuses to EFalse.
       
   697             iFocusedLabelIndex = KNoAttachmentLabelFocused;
       
   698             focusedAttachmentLabelIndexChanged = ETrue;
       
   699             }
       
   700 
       
   701         if ( focusedAttachmentLabelIndexChanged )
       
   702             {
       
   703             // only redraw if focused attachment label changed
       
   704             for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i )
       
   705                 {
       
   706                 iAttachmentLabels[i]->SetFocus( i==iFocusedLabelIndex );
       
   707                 }
       
   708             UpdateColors();
       
   709             DrawNow();
       
   710             }
       
   711         }
       
   712     }
       
   713 
   672 // -----------------------------------------------------------------------------
   714 // -----------------------------------------------------------------------------
   673 // CNcsAttachmentField::CreateIcons()
   715 // CNcsAttachmentField::CreateIcons()
   674 // -----------------------------------------------------------------------------
   716 // -----------------------------------------------------------------------------
   675 //
   717 //
   676 TInt CNcsAttachmentField::CreateIcons()
   718 TInt CNcsAttachmentField::CreateIcons()
   685 // -----------------------------------------------------------------------------
   727 // -----------------------------------------------------------------------------
   686 //
   728 //
   687 void CNcsAttachmentField::CreateIconsL()
   729 void CNcsAttachmentField::CreateIconsL()
   688     {
   730     {
   689     FUNC_LOG;
   731     FUNC_LOG;
   690     CFreestyleEmailUiAppUi* fsAppUi = static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() );
   732     CFreestyleEmailUiAppUi* fsAppUi = 
       
   733         static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() );
   691     delete iAttachmentBitmap; 
   734     delete iAttachmentBitmap; 
   692     iAttachmentBitmap = NULL;
   735     iAttachmentBitmap = NULL;
   693     delete iAttachmentMask; 
   736     delete iAttachmentMask; 
   694     iAttachmentMask = NULL;
   737     iAttachmentMask = NULL;
   695     fsAppUi->FsTextureManager()->ProvideBitmapL( EAttachmentIcon, iAttachmentBitmap, iAttachmentMask );
   738     fsAppUi->FsTextureManager()->ProvideBitmapL( 
   696     delete iActionMenuBitmap; 
   739             EAttachmentIcon, iAttachmentBitmap, iAttachmentMask );
   697     iActionMenuBitmap = NULL;
       
   698     delete iActionMenuMask; 
       
   699     iActionMenuMask = NULL;
       
   700     fsAppUi->FsTextureManager()->ProvideBitmapL( EListControlMenuIcon, iActionMenuBitmap, iActionMenuMask );
       
   701     ResizeIcons();
   740     ResizeIcons();
   702     }
   741     }
   703 // </cmail> Platform layout change
   742 
       
   743 // -----------------------------------------------------------------------------
       
   744 // CNcsAttachmentField::UpdateSingleAttachmentLabelTextL()
       
   745 // -----------------------------------------------------------------------------
       
   746 //
       
   747 void CNcsAttachmentField::UpdateSingleAttachmentLabelTextL( 
       
   748         CNcsLabel* aLabel, TInt aIndex )
       
   749     {
       
   750     FUNC_LOG;  
       
   751     // create decorated size text including the preceeding space character
       
   752     HBufC* decoratedSize = StringLoader::LoadLC( 
       
   753         R_FSE_VIEWER_ATTACHMENTS_LIST_SIZE, 
       
   754         iAttachmentSizes->MdcaPoint( aIndex ) );
       
   755     HBufC* decoratedSizeWithSpace = HBufC::NewL( 
       
   756         decoratedSize->Length() + 
       
   757         KSpace().Length() +
       
   758         KBidiRleStartChar().Length() +
       
   759         KBidiPdfChar().Length() );
       
   760     decoratedSizeWithSpace->Des().Append( KSpace );
       
   761     if ( AknLayoutUtils::LayoutMirrored() )
       
   762         {
       
   763         // Put size part into embedded right-to-left block to ensure 
       
   764         // correct rendering even when name part is written from 
       
   765         // left-to-right.
       
   766         decoratedSizeWithSpace->Des().Append( KBidiRleStartChar );
       
   767         decoratedSizeWithSpace->Des().Append( *decoratedSize );
       
   768         decoratedSizeWithSpace->Des().Append( KBidiPdfChar );
       
   769         }
       
   770     else
       
   771         {
       
   772         decoratedSizeWithSpace->Des().Append( *decoratedSize );
       
   773         }
       
   774     CleanupStack::PopAndDestroy( decoratedSize );
       
   775     CleanupStack::PushL( decoratedSizeWithSpace );
       
   776     
       
   777     // clip attachment name to fit the field so that size information has
       
   778     // enough space too.
       
   779     const CFont& font = *aLabel->Font();
       
   780 
       
   781     TInt labelWidth = aLabel->Size().iWidth;
       
   782     TInt sizeTextInPixels = 
       
   783         font.TextWidthInPixels( *decoratedSizeWithSpace );
       
   784     TInt pixelsLeftForAttachmentName = labelWidth - sizeTextInPixels;
       
   785 
       
   786     HBufC* attachmentText = NULL; // will contain the complete text
       
   787     // safe check if the size information is too wide for some reason.
       
   788     if ( pixelsLeftForAttachmentName < 0 )
       
   789         {
       
   790         attachmentText = HBufC::NewLC( 
       
   791                 iAttachmentNames->MdcaPoint( aIndex ).Length() 
       
   792                 + decoratedSizeWithSpace->Length() );
       
   793         attachmentText->Des().Append( iAttachmentNames->MdcaPoint( aIndex ) );
       
   794         attachmentText->Des().Append( *decoratedSizeWithSpace );
       
   795         TPtr attachmentTextBufferModDes = attachmentText->Des();
       
   796         AknTextUtils::ClipToFit( attachmentTextBufferModDes, 
       
   797                                  font, labelWidth );
       
   798         }
       
   799     else
       
   800         { // normal case
       
   801         HBufC* attacmentNameBuffer = 
       
   802             iAttachmentNames->MdcaPoint( aIndex ).AllocLC();
       
   803         TPtr attachmentNameBufferModDes = attacmentNameBuffer->Des();
       
   804         AknTextUtils::ClipToFit( attachmentNameBufferModDes, 
       
   805                                  font, pixelsLeftForAttachmentName );
       
   806 
       
   807         attachmentText = HBufC::NewL( 
       
   808                 attacmentNameBuffer->Length() 
       
   809                 + decoratedSizeWithSpace->Length() );
       
   810         attachmentText->Des().Append( *attacmentNameBuffer );
       
   811         attachmentText->Des().Append( *decoratedSizeWithSpace );
       
   812         CleanupStack::PopAndDestroy( attacmentNameBuffer );
       
   813         CleanupStack::PushL( attachmentText );
       
   814         }
       
   815     aLabel->SetTextL( *attachmentText );
       
   816     CleanupStack::PopAndDestroy( attachmentText );
       
   817     CleanupStack::PopAndDestroy( decoratedSizeWithSpace );
       
   818     }
       
   819