emailuis/emailui/src/ncssubjectfield.cpp
changeset 0 8466d47a6819
child 1 12c456ceeff2
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:  compose view container
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "emailtrace.h"
       
    21 #include <AknIconUtils.h>
       
    22 #include <avkon.hrh>
       
    23 #include <eiklabel.h>
       
    24 #include <eikimage.h>
       
    25 #include <eikenv.h>
       
    26 #include <AknsDrawUtils.h>
       
    27 #include <AknUtils.h>
       
    28 #include <StringLoader.h>
       
    29 #include <s32mem.h>
       
    30 #include <txtrich.h>
       
    31 #include <FreestyleEmailUi.rsg>
       
    32 #include <freestyleemailui.mbg>
       
    33 #include "FreestyleEmailUiLayoutData.h"
       
    34 #include "FreestyleEmailUiLayoutHandler.h"
       
    35 #include "FreestyleEmailUiAppui.h"
       
    36 #include "FreestyleEmailUiTextureManager.h"
       
    37 #include "ncssubjectfield.h"
       
    38 #include "ncsconstants.h"
       
    39 #include "ncsfieldsizeobserver.h"
       
    40 #include "ncsutility.h"
       
    41 #include "ncsheadercontainer.h"
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // CNcsSubjectField::CNcsSubjectField()
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CNcsSubjectField::CNcsSubjectField( MNcsFieldSizeObserver* aSizeObserver,
       
    48         CNcsHeaderContainer* aParentControl ):
       
    49 	MNcsControl( aSizeObserver ),
       
    50 	iParentControl( aParentControl )
       
    51     {
       
    52     FUNC_LOG;
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CNcsSubjectField::NewL()
       
    57 // Two-phased constructor.
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CNcsSubjectField* CNcsSubjectField::NewL( TInt aLabelTextId,
       
    61 	MNcsFieldSizeObserver* aSizeObserver, CNcsHeaderContainer* aParentControl )
       
    62     {
       
    63     FUNC_LOG;
       
    64     CNcsSubjectField* self =
       
    65         new ( ELeave ) CNcsSubjectField( aSizeObserver, aParentControl );
       
    66     CleanupStack::PushL( self );
       
    67     self->ConstructL( aLabelTextId );
       
    68     CleanupStack::Pop( self );
       
    69     return self;
       
    70     }
       
    71 
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CNcsSubjectField::ConstructL()
       
    75 // Symbian 2nd phase constructor can leave.
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void CNcsSubjectField::ConstructL( TInt aLabelTextId )
       
    79     {
       
    80     FUNC_LOG;
       
    81     // Create label
       
    82 	HBufC* aTextBuf = StringLoader::LoadLC( aLabelTextId );
       
    83     iLabel = new ( ELeave ) CNcsLabel( *this, NULL );
       
    84     iLabel->SetTextL( aTextBuf->Des() );
       
    85 	CleanupStack::PopAndDestroy( aTextBuf );
       
    86 	// S60 Skin support
       
    87 	iLabel->SetBrushStyle(CWindowGc::ENullBrush);
       
    88 
       
    89     iTextEditor = new ( ELeave ) CNcsEditor( iSizeObserver, ETrue, ENcsEditorSubject );
       
    90     // iTextEditor is not completely constructed until in SetContainerWindowL()
       
    91     iFocusChangeHandler = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // Destructor
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 CNcsSubjectField::~CNcsSubjectField()
       
    99     {
       
   100     FUNC_LOG;
       
   101     delete iTextEditor;
       
   102     delete iLabel;
       
   103     // Platform layout change
       
   104     /*if ( iFont )
       
   105         {
       
   106         ControlEnv()->ScreenDevice()->ReleaseFont( iFont );
       
   107         iFont = NULL;
       
   108         }*/
       
   109 
       
   110     delete iFocusChangeHandler;
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CNcsSubjectField::SetContainerWindowL() const
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 void CNcsSubjectField::SetContainerWindowL(const CCoeControl& aContainer)
       
   118 	{
       
   119     FUNC_LOG;
       
   120 	CCoeControl::SetContainerWindowL(aContainer);
       
   121 
       
   122 	// Create the component array
       
   123     InitComponentArrayL();
       
   124 	CCoeControlArray& controls = Components();
       
   125 	controls.SetControlsOwnedExternally(ETrue);
       
   126 	controls.AppendLC(iLabel);
       
   127 	CleanupStack::Pop(iLabel);
       
   128 	controls.AppendLC(iTextEditor);
       
   129     CleanupStack::Pop(iTextEditor);
       
   130 
       
   131     // Setup text editor
       
   132     iTextEditor->ConstructL( &aContainer, KMaxAddressFieldLines, 0 );
       
   133 	iTextEditor->SetBorder( TGulBorder::ENone );
       
   134     iTextEditor->SetAknEditorInputMode( EAknEditorTextInputMode );
       
   135 	iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
       
   136     iTextEditor->SetEdwinSizeObserver( this );
       
   137     iTextEditor->SetupEditorL();
       
   138     // Setup label
       
   139     UpdateFontSize();
       
   140     UpdateColors();
       
   141 	}
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CNcsSubjectField::Draw() const
       
   145 // Draws the display
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 void CNcsSubjectField::Draw( const TRect& /*aRect*/ ) const
       
   149     {
       
   150     FUNC_LOG;
       
   151     CWindowGc& gc = SystemGc();
       
   152     gc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
   153     }
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // CNcsSubjectField::GetMinLabelLength()
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 TInt CNcsSubjectField::GetMinLabelLength() const
       
   160 	{
       
   161     FUNC_LOG;
       
   162     return iLabel->Font()->TextWidthInPixels( *iLabel->Text() );
       
   163 	}
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // CNcsSubjectField::SizeChanged()
       
   167 // set size
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 void CNcsSubjectField::SizeChanged()
       
   171     {
       
   172     FUNC_LOG;
       
   173 	
       
   174     const TRect rect( Rect() );
       
   175     NcsUtility::LayoutCaptionLabel( iLabel, rect );
       
   176     NcsUtility::LayoutDetailEdwinTouch( iTextEditor, rect, iEditorLineCount, EFalse );  
       
   177     
       
   178     if (iTextEditor->ScrollBarFrame())
       
   179         {
       
   180         TRect rc = iTextEditor->Rect();
       
   181         if (AknLayoutUtils::LayoutMirrored())
       
   182             {
       
   183             rc.iTl.iX += iTextEditor->ScrollBarFrame()->ScrollBarBreadth(CEikScrollBar::EVertical);
       
   184             }
       
   185         else
       
   186             {
       
   187             rc.iBr.iX -= iTextEditor->ScrollBarFrame()->ScrollBarBreadth(CEikScrollBar::EVertical);
       
   188             }
       
   189         iTextEditor->SetRect(rc);
       
   190         }
       
   191 
       
   192     // Setup text alignment according the mirrored/normal layout.
       
   193     if ( AknLayoutUtils::LayoutMirrored() )
       
   194         {
       
   195         iLabel->SetAlignment( EHLeftVCenter );
       
   196         iLabel->SetLabelAlignment( ELayoutAlignLeft );
       
   197         iTextEditor->SetAlignment( EAknEditorAlignRight );
       
   198         }
       
   199     else
       
   200         {
       
   201         iLabel->SetAlignment( EHRightVCenter );
       
   202         iLabel->SetLabelAlignment( ELayoutAlignRight );
       
   203         iTextEditor->SetAlignment( EAknEditorAlignLeft );
       
   204         }
       
   205     
       
   206 	UpdateFontSize();
       
   207 
       
   208 	iTextEditor->UpdateCustomDrawer();
       
   209     }
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CNcsSubjectField::PositionChanged()
       
   213 // set size
       
   214 // -----------------------------------------------------------------------------
       
   215 //
       
   216 void CNcsSubjectField::PositionChanged()
       
   217     {
       
   218     FUNC_LOG;
       
   219     //SizeChanged();
       
   220     }
       
   221 
       
   222 // -----------------------------------------------------------------------------
       
   223 // CNcsSubjectField::OfferKeyEventL()
       
   224 // Handles key events
       
   225 // -----------------------------------------------------------------------------
       
   226 //
       
   227 TKeyResponse CNcsSubjectField::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   228     {
       
   229     FUNC_LOG;
       
   230 	TKeyResponse ret( EKeyWasNotConsumed );
       
   231 
       
   232 	ret = iTextEditor->OfferKeyEventL( aKeyEvent, aType );
       
   233     return ret;
       
   234     }
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CNcsAddressInputField::HandlePointerEventL()
       
   238 // Handles pointer events
       
   239 // -----------------------------------------------------------------------------
       
   240 //
       
   241 void CNcsSubjectField::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   242     {
       
   243 	FUNC_LOG;
       
   244     iTextEditor->HandlePointerEventL( aPointerEvent );
       
   245     }
       
   246 
       
   247 // -----------------------------------------------------------------------------
       
   248 // CNcsSubjectField::FocusChanged()
       
   249 // -----------------------------------------------------------------------------
       
   250 //
       
   251 void CNcsSubjectField::FocusChanged( TDrawNow aDrawNow )
       
   252 	{
       
   253     FUNC_LOG;
       
   254 	// The focus change gaining handling needs to be deferred until AknFep is fully
       
   255 	// initialised. Otherwise there will be problems when moving focus from
       
   256 	// body to subject. Focus losing can be handled immediately
       
   257 	iDrawAfterFocusChange = aDrawNow;
       
   258 	if ( IsFocused() )
       
   259 	    {
       
   260 	TCallBack callback( DoHandleFocusChanged, this );
       
   261 	iFocusChangeHandler->Cancel();
       
   262 	iFocusChangeHandler->Set( callback );
       
   263 	iFocusChangeHandler->CallBack();
       
   264 	}
       
   265 	else
       
   266 	    {
       
   267 	    DoHandleFocusChanged( this );
       
   268 	    }
       
   269 	}
       
   270 
       
   271 // -----------------------------------------------------------------------------
       
   272 // CNcsSubjectField::HandleFocusChangedL()
       
   273 // -----------------------------------------------------------------------------
       
   274 //
       
   275 void CNcsSubjectField::HandleFocusChangedL()
       
   276     {
       
   277     FUNC_LOG;
       
   278     if ( IsFocused() )
       
   279         {
       
   280         iTextEditor->SetFocus( ETrue );
       
   281         iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse );
       
   282 
       
   283         // make sure that control is visible on screen
       
   284         if ( Rect().iTl.iY < 0 )
       
   285             {
       
   286             TPoint pt = TPoint( 0, 0 );
       
   287             Reposition( pt, Rect().Width() );
       
   288             iSizeObserver->UpdateFieldPosition( this );
       
   289             }
       
   290         else
       
   291             {
       
   292             TPoint pos = PositionRelativeToScreen();
       
   293             pos.iY += Size().iHeight;
       
   294             CWsScreenDevice* screenDev = ControlEnv()->ScreenDevice();
       
   295             TPixelsAndRotation pix;
       
   296             screenDev->GetDefaultScreenSizeAndRotation( pix );
       
   297             const TInt h = pix.iPixelSize.iHeight;
       
   298             if ( pos.iY >= h - h / 3 )
       
   299                 {
       
   300                 TPoint pt = TPoint( 0, h / 3 );
       
   301                 Reposition( pt, Rect().Width() );
       
   302                 iSizeObserver->UpdateFieldPosition( this );
       
   303                 }
       
   304             }
       
   305 
       
   306         if ( iParentControl )
       
   307             {
       
   308             iParentControl->SetMskL();
       
   309             }
       
   310         }
       
   311     else
       
   312         {
       
   313         iTextEditor->HandleTextChangedL();
       
   314         iTextEditor->SetFocus( EFalse );
       
   315         }
       
   316 
       
   317     if ( iDrawAfterFocusChange )
       
   318         {
       
   319         DrawNow();
       
   320         }
       
   321     }
       
   322 
       
   323 // -----------------------------------------------------------------------------
       
   324 // CNcsSubjectField::DoHandleFocusChanged()
       
   325 // -----------------------------------------------------------------------------
       
   326 //
       
   327 TInt CNcsSubjectField::DoHandleFocusChanged( TAny* aSelfPtr )
       
   328     {
       
   329     FUNC_LOG;
       
   330     CNcsSubjectField* self = static_cast<CNcsSubjectField*>( aSelfPtr );
       
   331     TRAPD( err, self->HandleFocusChangedL() );
       
   332     return err;
       
   333     }
       
   334 
       
   335 // -----------------------------------------------------------------------------
       
   336 // CNcsSubjectField::MinimumHeight()
       
   337 // return height of subject control
       
   338 // -----------------------------------------------------------------------------
       
   339 //
       
   340 TInt CNcsSubjectField::MinimumHeight()
       
   341     {
       
   342     FUNC_LOG;
       
   343     // Platform layout changes
       
   344     /*
       
   345     TNcsMeasures m = NcsUtility::Measures();
       
   346 	TInt height = m.iAifHeight - m.iAifEditorHeight + iEditorMinimumHeight + m.iSubjectExtraHeightBottom;
       
   347 	TInt height2 = m.iAifHeight + m.iSubjectExtraHeightBottom;
       
   348 	// if followup icon and priority icon are both visible increase the subject field height
       
   349 	if ( iFollowUp && iPriority != EMsgPriorityNormal )
       
   350 	    {
       
   351 	    height2 += KIconHeightFollowUp;
       
   352 	    }
       
   353     return Max( height, height2 );
       
   354     */
       
   355     //return NcsUtility::MinimumHeaderSize( Rect(), iEditorLineCount ).iHeight;
       
   356     // Platform layout changes
       
   357     return 0;
       
   358     }
       
   359 
       
   360 // -----------------------------------------------------------------------------
       
   361 // CNcsSubjectField::SetSubjectL()
       
   362 // -----------------------------------------------------------------------------
       
   363 //
       
   364 void CNcsSubjectField::SetSubjectL( const TDesC& aSubject )
       
   365     {
       
   366     FUNC_LOG;
       
   367     if ( &aSubject && aSubject.Length() > 0 )
       
   368     	{
       
   369 	    RMemReadStream inputStream( aSubject.Ptr(), aSubject.Size() );
       
   370 	    CleanupClosePushL( inputStream );
       
   371 
       
   372 	  	iTextEditor->RichText()->ImportTextL( 0, inputStream, CPlainText::EOrganiseByParagraph );
       
   373 
       
   374 		// Activating the field will set the control to the end of the text
       
   375 	    iTextEditor->ActivateL();
       
   376 	    iTextEditor->SetCursorPosL(0,EFalse);
       
   377 
       
   378 	    CleanupStack::PopAndDestroy( &inputStream );
       
   379     	}
       
   380     }
       
   381 
       
   382 // -----------------------------------------------------------------------------
       
   383 // CNcsSubjectField::HandleEdwinSizeEventL()
       
   384 // -----------------------------------------------------------------------------
       
   385 //
       
   386 TBool CNcsSubjectField::HandleEdwinSizeEventL( CEikEdwin* /*aEdwin*/,
       
   387 	TEdwinSizeEvent /*aEventType*/, TSize aDesirableEdwinSize )
       
   388     {
       
   389     FUNC_LOG;
       
   390     //  Platform layout chage
       
   391     /*
       
   392     TInt ret( EFalse );
       
   393     TInt htLine = iTextEditor->GetLineHeightL();
       
   394     TInt numLinesDesired = aDesirableEdwinSize.iHeight / htLine;
       
   395 
       
   396     if ( numLinesDesired < KMaxAddressFieldLines &&
       
   397          iEditorMinimumHeight != aDesirableEdwinSize.iHeight )
       
   398         {
       
   399         iEditorMinimumHeight = aDesirableEdwinSize.iHeight;
       
   400         iTextEditor->CreateScrollBarFrameL()->SetScjrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
       
   401         if ( iSizeObserver )
       
   402             {
       
   403             ret = iSizeObserver->UpdateFieldSizeL();
       
   404             }
       
   405         }
       
   406     else if ( iEditorMinimumHeight != htLine * KMaxAddressFieldLines )
       
   407         {
       
   408         //We may still need to resize the controll.
       
   409         iEditorMinimumHeight = htLine * KMaxAddressFieldLines;
       
   410         iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn );
       
   411         if ( iSizeObserver )
       
   412             {
       
   413             ret = iSizeObserver->UpdateFieldSizeL();
       
   414             }
       
   415         }
       
   416     */
       
   417 
       
   418     TInt ret( EFalse );
       
   419     TInt htLine = iTextEditor->GetLineHeightL();
       
   420     TInt numLinesDesired = aDesirableEdwinSize.iHeight / htLine;
       
   421     CEikScrollBarFrame& scrollBarFrame( *iTextEditor->CreateScrollBarFrameL() );
       
   422     iEditorLineCount = numLinesDesired;
       
   423     scrollBarFrame.SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
       
   424     if ( iSizeObserver )
       
   425         {
       
   426         ret = iSizeObserver->UpdateFieldSizeL();
       
   427         }
       
   428     return ret;
       
   429     }
       
   430 
       
   431 // -----------------------------------------------------------------------------
       
   432 // CNcsSubjectField::SelectAllTextL()
       
   433 // -----------------------------------------------------------------------------
       
   434 //
       
   435 void CNcsSubjectField::SelectAllTextL()
       
   436 	{
       
   437     FUNC_LOG;
       
   438 	iTextEditor->SelectAllL();
       
   439 	}
       
   440 
       
   441 // -----------------------------------------------------------------------------
       
   442 // CNcsSubjectField::Editor
       
   443 // -----------------------------------------------------------------------------
       
   444 CNcsEditor* CNcsSubjectField::Editor() const
       
   445 	{
       
   446     FUNC_LOG;
       
   447 	return iTextEditor;
       
   448 	}
       
   449 
       
   450 // -----------------------------------------------------------------------------
       
   451 // CNcsSubjectField::LineCount
       
   452 // -----------------------------------------------------------------------------
       
   453 TInt CNcsSubjectField::LineCount() const
       
   454 	{
       
   455     FUNC_LOG;
       
   456 	return iTextEditor->LineCount();
       
   457 	}
       
   458 
       
   459 // -----------------------------------------------------------------------------
       
   460 // CNcsSubjectField::CursorLineNumber
       
   461 // -----------------------------------------------------------------------------
       
   462 TInt CNcsSubjectField::CursorLineNumber() const
       
   463 	{
       
   464     FUNC_LOG;
       
   465 	return iTextEditor->CursorLineNumber();
       
   466 	}
       
   467 
       
   468 // -----------------------------------------------------------------------------
       
   469 // CNcsSubjectField::CursorPosition
       
   470 // -----------------------------------------------------------------------------
       
   471 TInt CNcsSubjectField::CursorPosition() const
       
   472 	{
       
   473     FUNC_LOG;
       
   474 	TInt pos = iTextEditor->CursorPosition();
       
   475 	//Add the delta between the top of the edit control
       
   476 	//and the top of the parent control
       
   477 	pos += iTextEditor->Rect().iTl.iY - Rect().iTl.iY;
       
   478 	return pos;
       
   479 	}
       
   480 
       
   481 // -----------------------------------------------------------------------------
       
   482 // CNcsSubjectField::ScrollableLines
       
   483 // -----------------------------------------------------------------------------
       
   484 TInt CNcsSubjectField::ScrollableLines() const
       
   485 	{
       
   486     FUNC_LOG;
       
   487 	return iTextEditor->ScrollableLines();
       
   488 	}
       
   489 
       
   490 // -----------------------------------------------------------------------------
       
   491 // CNcsSubjectField::GetNumChars
       
   492 // -----------------------------------------------------------------------------
       
   493 TInt CNcsSubjectField::GetNumChars() const
       
   494 	{
       
   495     FUNC_LOG;
       
   496 	return iTextEditor->GetNumChars();
       
   497 	}
       
   498 
       
   499 // -----------------------------------------------------------------------------
       
   500 // CNcsSubjectField::GetLabelText
       
   501 // -----------------------------------------------------------------------------
       
   502 const TDesC& CNcsSubjectField::GetLabelText() const
       
   503 	{
       
   504     FUNC_LOG;
       
   505 	return KNullDesC;
       
   506 	}
       
   507 
       
   508 // Platform layout change
       
   509 // ---------------------------------------------------------------------------
       
   510 // CNcsSubjectField::LayoutLineCount
       
   511 // ---------------------------------------------------------------------------
       
   512 //
       
   513 TInt CNcsSubjectField::LayoutLineCount() const
       
   514     {
       
   515     FUNC_LOG;
       
   516     return ( IsVisible() ? Max( 1, iEditorLineCount ) : 0 );
       
   517     }
       
   518 
       
   519 // -----------------------------------------------------------------------------
       
   520 // CNcsSubjectField::Reposition
       
   521 // -----------------------------------------------------------------------------
       
   522 void CNcsSubjectField::Reposition(TPoint& aPt, TInt /*aWidth*/)
       
   523 	{
       
   524     FUNC_LOG;
       
   525     /*
       
   526 	const TSize size( aWidth, MinimumHeight() );
       
   527     SetExtent( aPt, size );
       
   528     aPt.iY += size.iHeight;
       
   529     */
       
   530     SetPosition( aPt );
       
   531     // Platform layout changes
       
   532 	}
       
   533 
       
   534 // -----------------------------------------------------------------------------
       
   535 // CNcsSubjectField::GetLineRectL
       
   536 // -----------------------------------------------------------------------------
       
   537 void CNcsSubjectField::GetLineRectL( TRect& aLineRect ) const
       
   538 	{
       
   539     FUNC_LOG;
       
   540     return iTextEditor->GetLineRectL( aLineRect );
       
   541 	}
       
   542 
       
   543 // -----------------------------------------------------------------------------
       
   544 // CNcsSubjectField::SetMaxLabelLength
       
   545 // -----------------------------------------------------------------------------
       
   546 void CNcsSubjectField::SetMaxLabelLength( TInt aMaxLength )
       
   547 	{
       
   548     FUNC_LOG;
       
   549 	iMaximumLabelLength = aMaxLength;
       
   550 	}
       
   551 
       
   552 // -----------------------------------------------------------------------------
       
   553 // CNcsSubjectField::SetTextColorL
       
   554 // -----------------------------------------------------------------------------
       
   555 void CNcsSubjectField::SetTextColorL( TLogicalRgb aColor )
       
   556 	{
       
   557     FUNC_LOG;
       
   558 	iTextEditor->SetTextColorL( aColor );
       
   559 	}
       
   560 
       
   561 // ---------------------------------------------------------------------------
       
   562 // CNcsSubjectField::UpdateColors()
       
   563 // ---------------------------------------------------------------------------
       
   564 //
       
   565 void CNcsSubjectField::UpdateColors()
       
   566     {
       
   567 	FUNC_LOG;
       
   568     // Platform layout change
       
   569     TRgb textColor = KRgbBlack;
       
   570     if ( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor,
       
   571         KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ) != KErrNone )
       
   572         {
       
   573         textColor = KRgbBlack;
       
   574         }
       
   575     TRAP_IGNORE( iLabel->OverrideColorL( EColorLabelText, textColor ) );
       
   576     // Platform layout change
       
   577 
       
   578     CFreestyleEmailUiAppUi* appUi =
       
   579         static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() );
       
   580     iBorderColor = appUi->LayoutHandler()->ComposerFieldBorderColor();
       
   581     iBgColor = appUi->LayoutHandler()->ComposerFieldBackgroundColor();
       
   582     }
       
   583 
       
   584 // Platform layout changes
       
   585 // ---------------------------------------------------------------------------
       
   586 // CNcsSubjectField::UpdateFontSize()
       
   587 // ---------------------------------------------------------------------------
       
   588 //
       
   589 void CNcsSubjectField::UpdateFontSize()
       
   590 	{
       
   591     FUNC_LOG;
       
   592     /*if ( iFont )
       
   593         {
       
   594         ControlEnv()->ScreenDevice()->ReleaseFont( iFont );
       
   595         iFont = NULL;
       
   596         }
       
   597 
       
   598 	TNcsMeasures m = NcsUtility::Measures();
       
   599 	if ( !iFont )
       
   600 	    {
       
   601 	    TRAP_IGNORE( iFont = NcsUtility::GetNearestFontL(EAknLogicalFontPrimarySmallFont,
       
   602 	    m.iLabelFontHeightPx) );
       
   603 	    }*/
       
   604 	iFont = NcsUtility::GetLayoutFont( iLabel->Rect(), NcsUtility::ENcsHeaderCaptionFont );
       
   605 	iLabel->SetFont( iFont );
       
   606 	iTextEditor->UpdateFontSize();
       
   607 	UpdateColors();
       
   608 	}
       
   609 
       
   610 // ---------------------------------------------------------------------------
       
   611 // CNcsSubjectField::HandleResourceChange()
       
   612 // ---------------------------------------------------------------------------
       
   613 //
       
   614 void CNcsSubjectField::HandleResourceChange( TInt aType )
       
   615     {
       
   616     FUNC_LOG;
       
   617     CCoeControl::HandleResourceChange( aType );
       
   618     if ( aType == KAknsMessageSkinChange ||
       
   619          aType == KEikMessageColorSchemeChange )
       
   620         {
       
   621         UpdateFontSize();
       
   622         UpdateColors();
       
   623         // Platform layout changes
       
   624         iTextEditor->HandleResourceChange( aType ) ;//CreateScrollBarFrameL()->DrawScrollBarsNow();
       
   625         // Platform layout changes
       
   626         }
       
   627     }
       
   628