emailuis/emailui/src/ncsattachmentfield.cpp
changeset 0 8466d47a6819
child 2 5253a20d2a1e
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  message editor
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include <StringLoader.h>
       
    21 #include <AknUtils.h>
       
    22 #include <AknsUtils.h>
       
    23 #include <AknsSkinInstance.h>
       
    24 #include <FreestyleEmailUi.rsg>
       
    25 
       
    26 #include "FreestyleEmailUiLayoutData.h"
       
    27 #include "FreestyleEmailUiAppui.h"
       
    28 #include "FreestyleEmailUiTextureManager.h"
       
    29 #include "FreestyleEmailUiLayoutHandler.h"
       
    30 #include "ncsattachmentfield.h"
       
    31 #include "ncsutility.h"
       
    32 #include "ncsheadercontainer.h"
       
    33 
       
    34 
       
    35 CNcsAttachmentField* CNcsAttachmentField::NewL(
       
    36     TInt aLabelTextId,
       
    37     MNcsFieldSizeObserver* aSizeObserver,
       
    38     CNcsHeaderContainer* aParentControl )
       
    39     {
       
    40     FUNC_LOG;
       
    41     CNcsAttachmentField* self =
       
    42         new ( ELeave ) CNcsAttachmentField( aSizeObserver, aParentControl );
       
    43     CleanupStack::PushL( self );
       
    44     self->ConstructL( aLabelTextId );
       
    45     CleanupStack::Pop( self );
       
    46     return self;
       
    47     }
       
    48 
       
    49 CNcsAttachmentField::~CNcsAttachmentField()
       
    50     {
       
    51     FUNC_LOG;
       
    52     delete iAttachmentLabel;
       
    53 
       
    54     delete iAttachmentName;
       
    55     delete iAttachmentSizeDesc;
       
    56 
       
    57     delete iAttachmentBitmap;
       
    58     delete iAttachmentMask;
       
    59 
       
    60     delete iActionMenuBitmap;
       
    61     delete iActionMenuMask;
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CNcsAttachmentField::CNcsAttachmentField()
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 CNcsAttachmentField::CNcsAttachmentField( MNcsFieldSizeObserver* aSizeObserver,
       
    69         CNcsHeaderContainer* aParentControl ):
       
    70     MNcsControl( aSizeObserver ),
       
    71     iParentControl( aParentControl )
       
    72     {
       
    73     FUNC_LOG;
       
    74     }
       
    75 
       
    76 void CNcsAttachmentField::ConstructL( TInt aLabelTextId )
       
    77     {
       
    78     FUNC_LOG;
       
    79     // create title label
       
    80 	HBufC* textBuf = StringLoader::LoadLC( aLabelTextId );
       
    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();
       
    90 	// </cmail> Platform layout change
       
    91 	
       
    92 	UpdateFontSize();
       
    93     UpdateColors();
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CNcsAttachmentField::LineCount()
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 TInt CNcsAttachmentField::LineCount() const
       
   101     {
       
   102     FUNC_LOG;
       
   103     return 0;
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CNcsAttachmentField::ScrollableLines()
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 TInt CNcsAttachmentField::ScrollableLines() const
       
   111     {
       
   112     FUNC_LOG;
       
   113     return 0;
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CNcsAttachmentField::GetNumChars()
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 TInt CNcsAttachmentField::GetNumChars() const
       
   121     {
       
   122     FUNC_LOG;
       
   123     return 0;
       
   124     }
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CNcsAttachmentField::CursorLineNumber()
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 TInt CNcsAttachmentField::CursorLineNumber() const
       
   131     {
       
   132     FUNC_LOG;
       
   133     return 0;
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CNcsAttachmentField::CursorPosition()
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 TInt CNcsAttachmentField::CursorPosition() const
       
   141     {
       
   142     FUNC_LOG;
       
   143     return 0;
       
   144     }
       
   145 
       
   146 // <cmail> Platform layout change
       
   147 // -----------------------------------------------------------------------------
       
   148 // CNcsAttachmentField::Reposition()
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 void CNcsAttachmentField::Reposition(TPoint& aPt, TInt /*aWidth*/ )
       
   152     {
       
   153     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 );
       
   163     }
       
   164 // </cmail> Platform layout change
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CNcsAttachmentField::GetLabelText()
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 const TDesC& CNcsAttachmentField::GetLabelText() const
       
   171     {
       
   172     FUNC_LOG;
       
   173 	return KNullDesC;
       
   174     }
       
   175 
       
   176 // <cmail> Platform layout change
       
   177 // ---------------------------------------------------------------------------
       
   178 // CNcsAttachmentField::LayoutLineCount
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 TInt CNcsAttachmentField::LayoutLineCount() const
       
   182     {
       
   183     FUNC_LOG;
       
   184     return ( IsVisible() ? 1 : 0 );
       
   185     }
       
   186 // </cmail> Platform layout change
       
   187 
       
   188 // -----------------------------------------------------------------------------
       
   189 // CNcsAttachmentField::Draw()
       
   190 // -----------------------------------------------------------------------------
       
   191 //
       
   192 void CNcsAttachmentField::Draw( const TRect& /*aRect*/ ) const
       
   193     {
       
   194     FUNC_LOG;
       
   195     CWindowGc& gc = SystemGc();
       
   196 
       
   197     // Draw text box
       
   198     // <cmail> Drawing removed </cmail>
       
   199 
       
   200     if ( IsFocused() )
       
   201     	{
       
   202     	// highlight for label when focused
       
   203 	    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   204 	    TRgb imageColor;
       
   205 	    if( AknsUtils::GetCachedColor( skin, imageColor,
       
   206 	    		KAknsIIDFsHighlightColors, EAknsCIFsHighlightColorsCG4 ) != KErrNone )
       
   207 	        {
       
   208 		    if( AknsUtils::GetCachedColor( skin, imageColor,
       
   209 		    		KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG2 ) != KErrNone )
       
   210 		    	{
       
   211 		        imageColor = KRgbBlue;
       
   212 		    	}
       
   213 	        }
       
   214 	    
       
   215 	    gc.SetPenStyle( CGraphicsContext::ENullPen );
       
   216 	    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   217 	    gc.SetBrushColor( imageColor );
       
   218 	    
       
   219 	    TRect highlightRect( iAttachmentLabel->Rect() );
       
   220 
       
   221 	    TInt sizeTextInPixels = iAttachmentLabel->Font()->TextWidthInPixels( 
       
   222 									*iAttachmentLabel->Text() );
       
   223 	    
       
   224         highlightRect.SetWidth( sizeTextInPixels );
       
   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     	}
       
   236     
       
   237     // Draw icons
       
   238     gc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
   239     // <cmail> Platform layout change
       
   240 
       
   241     gc.BitBltMasked( iAttachmentIconPos, iAttachmentBitmap, 
       
   242     		iAttachmentBitmap->SizeInPixels(), iAttachmentMask, ETrue );
       
   243 
       
   244     if( IsFocused() )
       
   245     	{
       
   246         gc.BitBltMasked( iActionMenuIconPos, iActionMenuBitmap, 
       
   247         		iActionMenuBitmap->SizeInPixels(), iActionMenuMask, ETrue );
       
   248     	}
       
   249     }
       
   250 
       
   251 // -----------------------------------------------------------------------------
       
   252 // CNcsAttachmentField::SizeChanged()
       
   253 // -----------------------------------------------------------------------------
       
   254 //
       
   255 void CNcsAttachmentField::SizeChanged()
       
   256     {
       
   257     FUNC_LOG;
       
   258  
       
   259     LayoutControls();
       
   260     // </cmail> Platform laytout change
       
   261 	UpdateFontSize();
       
   262 	UpdateColors();
       
   263     // The attachment text needs to be updated when label size changes because it
       
   264 	// may now get truncated differently.
       
   265 	TRAP_IGNORE( UpdateAttachmentTextL() );
       
   266     }
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // CNcsAttachmentField::PositionChanged()
       
   270 // -----------------------------------------------------------------------------
       
   271 //
       
   272 void CNcsAttachmentField::PositionChanged()
       
   273     {
       
   274     FUNC_LOG;
       
   275     // <cmail> Platform layout change
       
   276     LayoutControls();
       
   277     UpdateColors();
       
   278    
       
   279     // </cmail> Platform layout change
       
   280     }
       
   281 
       
   282 // -----------------------------------------------------------------------------
       
   283 // CNcsAttachmentField::MinimumHeight()
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 TInt CNcsAttachmentField::MinimumHeight() const
       
   287     {
       
   288     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;
       
   296     }
       
   297 
       
   298 // -----------------------------------------------------------------------------
       
   299 // CNcsAttachmentField::SetMaxLabelLength()
       
   300 // -----------------------------------------------------------------------------
       
   301 //
       
   302 void CNcsAttachmentField::SetMaxLabelLength( TInt aMaxLength )
       
   303     {
       
   304     FUNC_LOG;
       
   305 	iMaximumLabelLength = aMaxLength;
       
   306     }
       
   307 
       
   308 // -----------------------------------------------------------------------------
       
   309 // CNcsAttachmentField::GetMinLabelLength()
       
   310 // -----------------------------------------------------------------------------
       
   311 //
       
   312 TInt CNcsAttachmentField::GetMinLabelLength() const
       
   313     {
       
   314     FUNC_LOG;
       
   315     return 0;
       
   316     }
       
   317 
       
   318 // -----------------------------------------------------------------------------
       
   319 // CNcsAttachmentField::SetContainerWindowL() const
       
   320 // -----------------------------------------------------------------------------
       
   321 //
       
   322 void CNcsAttachmentField::SetContainerWindowL( const CCoeControl& aContainer )
       
   323 	{
       
   324     FUNC_LOG;
       
   325 	CCoeControl::SetContainerWindowL( aContainer );
       
   326 
       
   327 	// Create the component array
       
   328     InitComponentArrayL();
       
   329 	CCoeControlArray& controls = Components();
       
   330 	controls.SetControlsOwnedExternally( ETrue );
       
   331 	controls.AppendLC( iAttachmentLabel );
       
   332     CleanupStack::Pop( iAttachmentLabel );
       
   333 
       
   334     // set label properties
       
   335 	UpdateFontSize();
       
   336 
       
   337     // Setup text alignment according the mirrored/normal layout.
       
   338     if ( AknLayoutUtils::LayoutMirrored() )
       
   339         {
       
   340         iAttachmentLabel->SetAlignment( EHRightVCenter );
       
   341         }
       
   342     else
       
   343         {
       
   344         iAttachmentLabel->SetAlignment( EHLeftVCenter );
       
   345         }
       
   346 	}
       
   347 
       
   348 // -----------------------------------------------------------------------------
       
   349 // CNcsAttachmentField::SetTextL()
       
   350 // -----------------------------------------------------------------------------
       
   351 //
       
   352 void CNcsAttachmentField::SetTextL( const TDesC& aText )
       
   353     {
       
   354     FUNC_LOG;
       
   355     delete iAttachmentName;
       
   356     iAttachmentName = NULL;
       
   357     delete iAttachmentSizeDesc;
       
   358     iAttachmentSizeDesc = NULL;
       
   359 
       
   360     iAttachmentLabel->SetTextL( aText );
       
   361     }
       
   362 
       
   363 // -----------------------------------------------------------------------------
       
   364 // CNcsAttachmentField::SetTextL()
       
   365 // -----------------------------------------------------------------------------
       
   366 //
       
   367 void CNcsAttachmentField::SetTextL( const TDesC& aAttachmentName, const TDesC& aAttachmentSizeDesc )
       
   368     {
       
   369     FUNC_LOG;
       
   370     delete iAttachmentName;
       
   371     iAttachmentName = NULL;
       
   372     delete iAttachmentSizeDesc;
       
   373     iAttachmentSizeDesc = NULL;
       
   374 
       
   375     iAttachmentName = aAttachmentName.AllocL();
       
   376     iAttachmentSizeDesc = aAttachmentSizeDesc.AllocL();
       
   377     UpdateAttachmentTextL();
       
   378     }
       
   379 
       
   380 // -----------------------------------------------------------------------------
       
   381 // CNcsAttachmentField::UpdateAttachmentTextL()
       
   382 // -----------------------------------------------------------------------------
       
   383 //
       
   384 void CNcsAttachmentField::UpdateAttachmentTextL()
       
   385     {
       
   386     FUNC_LOG;
       
   387     if ( iAttachmentName && iAttachmentSizeDesc )
       
   388         {
       
   389         // create decorated size text including the preceeding space character
       
   390         HBufC* decoratedSize = StringLoader::LoadLC( R_FSE_VIEWER_ATTACHMENTS_LIST_SIZE, 
       
   391                                                      *iAttachmentSizeDesc );
       
   392         HBufC* decoratedSizeWithSpace = HBufC::NewL( decoratedSize->Length() + 
       
   393                                                      KSpace().Length() +
       
   394                                                      KBidiRleStartChar().Length() +
       
   395                                                      KBidiPdfChar().Length() );
       
   396         decoratedSizeWithSpace->Des().Append( KSpace );
       
   397         if ( AknLayoutUtils::LayoutMirrored() )
       
   398             {
       
   399             // Put size part into embedded right-to-left block to ensure correct rendering
       
   400             // even when name part is written from left-to-right.
       
   401             decoratedSizeWithSpace->Des().Append( KBidiRleStartChar );
       
   402             decoratedSizeWithSpace->Des().Append( *decoratedSize );
       
   403             decoratedSizeWithSpace->Des().Append( KBidiPdfChar );
       
   404             }
       
   405         else
       
   406             {
       
   407             decoratedSizeWithSpace->Des().Append( *decoratedSize );
       
   408             }
       
   409         CleanupStack::PopAndDestroy( decoratedSize );
       
   410         CleanupStack::PushL( decoratedSizeWithSpace );
       
   411 
       
   412         // clip attachment name to fit the field so that size information has enough space too.
       
   413         const CFont& font = *iAttachmentLabel->Font();
       
   414 
       
   415         TInt labelWidth = iAttachmentLabel->Size().iWidth;
       
   416         TInt sizeTextInPixels = font.TextWidthInPixels( *decoratedSizeWithSpace );
       
   417         TInt pixelsLeftForAttachmentName = labelWidth - sizeTextInPixels;
       
   418 
       
   419         HBufC* attachmentText = NULL; // will contain the complete text
       
   420         // safe check if the size information is too wide for some reason.
       
   421         if ( pixelsLeftForAttachmentName < 0 )
       
   422             {
       
   423             attachmentText = HBufC::NewLC( iAttachmentName->Length() + decoratedSizeWithSpace->Length() );
       
   424             attachmentText->Des().Append( *iAttachmentName );
       
   425             attachmentText->Des().Append( *decoratedSizeWithSpace );
       
   426             TPtr attachmentTextBufferModDes = attachmentText->Des();
       
   427             AknTextUtils::ClipToFit( attachmentTextBufferModDes, font, labelWidth );
       
   428             }
       
   429         else
       
   430             { // normal case
       
   431             HBufC* attacmentNameBuffer = iAttachmentName->AllocLC();
       
   432             TPtr attachmentNameBufferModDes = attacmentNameBuffer->Des();
       
   433             AknTextUtils::ClipToFit( attachmentNameBufferModDes, font, pixelsLeftForAttachmentName );
       
   434 
       
   435             attachmentText = HBufC::NewL( attacmentNameBuffer->Length() + decoratedSizeWithSpace->Length() );
       
   436             attachmentText->Des().Append( *attacmentNameBuffer );
       
   437             attachmentText->Des().Append( *decoratedSizeWithSpace );
       
   438             CleanupStack::PopAndDestroy( attacmentNameBuffer );
       
   439             CleanupStack::PushL( attachmentText );
       
   440             }
       
   441 
       
   442         iAttachmentLabel->SetTextL( *attachmentText );
       
   443 
       
   444         CleanupStack::PopAndDestroy( attachmentText );
       
   445         CleanupStack::PopAndDestroy( decoratedSizeWithSpace );
       
   446         }
       
   447     }
       
   448 
       
   449 // <cmail> Platform layout change
       
   450 // -----------------------------------------------------------------------------
       
   451 // CNcsAttachmentField::ResizeIcons()
       
   452 // -----------------------------------------------------------------------------
       
   453 //
       
   454 void CNcsAttachmentField::ResizeIcons()
       
   455     {
       
   456     FUNC_LOG;
       
   457     const TSize frontIconSize( NcsUtility::HeaderDetailIconRect( Rect(), 1, NcsUtility::EIconFront ).Size() );
       
   458     if ( frontIconSize != iAttachmentBitmap->SizeInPixels() )
       
   459         {
       
   460         AknIconUtils::SetSize( iAttachmentBitmap, frontIconSize, EAspectRatioPreservedAndUnusedSpaceRemoved );
       
   461         AknIconUtils::SetSize( iAttachmentMask, frontIconSize, EAspectRatioPreservedAndUnusedSpaceRemoved );
       
   462         }
       
   463     const TSize backIconSize( NcsUtility::HeaderDetailIconRect( Rect(), 1, NcsUtility::EIconBack ).Size() );
       
   464     if ( backIconSize != iActionMenuBitmap->SizeInPixels() )
       
   465         {
       
   466         AknIconUtils::SetSize( iActionMenuBitmap, backIconSize, EAspectRatioNotPreserved  );
       
   467         AknIconUtils::SetSize( iActionMenuMask, backIconSize, EAspectRatioNotPreserved  );
       
   468         }
       
   469     }
       
   470 // </cmail> Platform layout change
       
   471 
       
   472 // -----------------------------------------------------------------------------
       
   473 // CNcsAttachmentField::FocusChanged()
       
   474 // -----------------------------------------------------------------------------
       
   475 //
       
   476 void CNcsAttachmentField::FocusChanged( TDrawNow aDrawNow )
       
   477 	{
       
   478     FUNC_LOG;
       
   479 	if ( IsFocused() )
       
   480 		{
       
   481 		iAttachmentLabel->SetFocus( ETrue );
       
   482 
       
   483         // make sure that control is visible on screen
       
   484 		if ( Rect().iTl.iY < 0 )
       
   485 			{
       
   486 			TPoint pt = TPoint( 0, 0 );
       
   487 			Reposition( pt,Rect().Width() );
       
   488             iSizeObserver->UpdateFieldPosition( this );
       
   489 			}
       
   490 		else
       
   491 		    {
       
   492 		    TPoint pos = PositionRelativeToScreen();
       
   493 		    pos.iY += Size().iHeight;
       
   494     	    CWsScreenDevice* screenDev = ControlEnv()->ScreenDevice();
       
   495     	    TPixelsAndRotation pix;
       
   496     		screenDev->GetDefaultScreenSizeAndRotation( pix );
       
   497     		const TInt h = pix.iPixelSize.iHeight;
       
   498     		if ( pos.iY >= h - h / 3 )
       
   499     		    {
       
   500     			TPoint pt = TPoint( 0, h / 3 );
       
   501     			Reposition( pt,Rect().Width() );
       
   502                 iSizeObserver->UpdateFieldPosition( this );
       
   503     		    }
       
   504 		    }
       
   505 
       
   506         if ( iParentControl )
       
   507             {
       
   508             TRAP_IGNORE( iParentControl->SetMskL() );
       
   509             }
       
   510 		}
       
   511 	else
       
   512 		{
       
   513 		iAttachmentLabel->SetFocus( EFalse );
       
   514 		}
       
   515 
       
   516     iAttachmentLabel->SetUnderlining( IsFocused() );
       
   517     UpdateColors();
       
   518     
       
   519 	if ( aDrawNow )
       
   520 		{
       
   521 		DrawNow();
       
   522 		}
       
   523 	else
       
   524 	    {
       
   525 	    DrawDeferred();
       
   526 	    }
       
   527 	}
       
   528 
       
   529 // -----------------------------------------------------------------------------
       
   530 // CNcsAttachmentField::UpdateColors()
       
   531 // -----------------------------------------------------------------------------
       
   532 //
       
   533 void CNcsAttachmentField::UpdateColors()
       
   534     {
       
   535     // <cmail> Platform layout change
       
   536     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   537     TRgb textColor = KRgbBlack;
       
   538 
       
   539     if( IsFocused() )
       
   540     	{
       
   541         AknsUtils::GetCachedColor(
       
   542             skin,
       
   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 =
       
   581         static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() );
       
   582     iBorderColor = appUi->LayoutHandler()->ComposerFieldBorderColor();
       
   583     iBgColor = appUi->LayoutHandler()->ComposerFieldBackgroundColor();
       
   584     }
       
   585 
       
   586 // <cmail> Platform layout change
       
   587 // -----------------------------------------------------------------------------
       
   588 // CNcsAttachmentField::UpdateFontSize()
       
   589 // -----------------------------------------------------------------------------
       
   590 //
       
   591 void CNcsAttachmentField::UpdateFontSize()
       
   592 	{
       
   593     FUNC_LOG;
       
   594     /*if ( iLabelFont )
       
   595         {
       
   596         ControlEnv()->ScreenDevice()->ReleaseFont( iLabelFont );
       
   597         iLabelFont = NULL;
       
   598         }
       
   599 
       
   600     if ( iEditorFont )
       
   601         {
       
   602         ControlEnv()->ScreenDevice()->ReleaseFont( iEditorFont );
       
   603         iEditorFont = NULL;
       
   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 	}
       
   626 
       
   627 // -----------------------------------------------------------------------------
       
   628 // CNcsAttachmentField::LayoutControls()
       
   629 // -----------------------------------------------------------------------------
       
   630 //
       
   631 void CNcsAttachmentField::LayoutControls()
       
   632     {
       
   633     FUNC_LOG;
       
   634     const TRect rect( Rect() );
       
   635     NcsUtility::LayoutDetailLabel( iAttachmentLabel, rect );
       
   636     UpdateIconPositions( rect );
       
   637     }
       
   638 
       
   639 // -----------------------------------------------------------------------------
       
   640 // CNcsAttachmentField::UpdateIconPositions()
       
   641 // -----------------------------------------------------------------------------
       
   642 //
       
   643 void CNcsAttachmentField::UpdateIconPositions( const TRect& aRect )
       
   644     {
       
   645     FUNC_LOG;
       
   646     iAttachmentIconPos = NcsUtility::HeaderDetailIconRect( aRect, 1, NcsUtility::EIconFront ).iTl;
       
   647     iActionMenuIconPos = NcsUtility::HeaderDetailIconRect( aRect, 1, NcsUtility::EIconBack ).iTl;
       
   648     }
       
   649 // </cmail> Platform layout change
       
   650 
       
   651 // -----------------------------------------------------------------------------
       
   652 // CNcsAttachmentField::HandleResourceChange()
       
   653 // -----------------------------------------------------------------------------
       
   654 //
       
   655 void CNcsAttachmentField::HandleResourceChange( TInt aType )
       
   656     {
       
   657     FUNC_LOG;
       
   658     CCoeControl::HandleResourceChange( aType );
       
   659     if ( aType == KAknsMessageSkinChange ||
       
   660          aType == KEikMessageColorSchemeChange )
       
   661         {
       
   662         UpdateFontSize();
       
   663         UpdateColors();
       
   664         // <cmail> Platform layout change
       
   665         CreateIcons();
       
   666         // </cmail> Platform layout change
       
   667         DrawDeferred();
       
   668         }
       
   669     }
       
   670 
       
   671 // <cmail> Platform layout change
       
   672 // -----------------------------------------------------------------------------
       
   673 // CNcsAttachmentField::CreateIcons()
       
   674 // -----------------------------------------------------------------------------
       
   675 //
       
   676 TInt CNcsAttachmentField::CreateIcons()
       
   677     {
       
   678     FUNC_LOG;
       
   679     TRAPD( error, CreateIconsL() );
       
   680     return error;
       
   681     }
       
   682 
       
   683 // -----------------------------------------------------------------------------
       
   684 // CNcsAttachmentField::CreateIconsL()
       
   685 // -----------------------------------------------------------------------------
       
   686 //
       
   687 void CNcsAttachmentField::CreateIconsL()
       
   688     {
       
   689     FUNC_LOG;
       
   690     CFreestyleEmailUiAppUi* fsAppUi = static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() );
       
   691     delete iAttachmentBitmap; 
       
   692     iAttachmentBitmap = NULL;
       
   693     delete iAttachmentMask; 
       
   694     iAttachmentMask = NULL;
       
   695     fsAppUi->FsTextureManager()->ProvideBitmapL( EAttachmentIcon, iAttachmentBitmap, iAttachmentMask );
       
   696     delete iActionMenuBitmap; 
       
   697     iActionMenuBitmap = NULL;
       
   698     delete iActionMenuMask; 
       
   699     iActionMenuMask = NULL;
       
   700     fsAppUi->FsTextureManager()->ProvideBitmapL( EListControlMenuIcon, iActionMenuBitmap, iActionMenuMask );
       
   701     ResizeIcons();
       
   702     }
       
   703 // </cmail> Platform layout change