meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrsubjectfield.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 0 8466d47a6819
child 16 b5fbb9b25d57
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    13 *
    13 *
    14 * Description:  ESMR subject field implementation
    14 * Description:  ESMR subject field implementation
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 #include "emailtrace.h"
       
    19 #include "cesmrsubjectfield.h"
    18 #include "cesmrsubjectfield.h"
    20 
    19 #include "cmrimage.h"
    21 #include <calentry.h>
    20 #include "nmrlayoutmanager.h"
    22 #include <StringLoader.h>
       
    23 #include <gulfont.h>
       
    24 #include <AknsConstants.h>
       
    25 #include <AknUtils.h>
       
    26 #include <AknsDrawUtils.h>
       
    27 #include <AknsFrameBackgroundControlContext.h>
       
    28 #include "esmrfieldbuilderdef.h"
       
    29 
       
    30 #include <esmrgui.rsg>
       
    31 
       
    32 #include "cesmreditor.h"
    21 #include "cesmreditor.h"
    33 #include "mesmrtitlepaneobserver.h"
    22 #include "mesmrtitlepaneobserver.h"
    34 #include "cesmrglobalnote.h"
    23 #include "cesmrglobalnote.h"
       
    24 #include "esmrfieldbuilderdef.h"
       
    25 #include "nmrcolormanager.h"
       
    26 #include "nmrbitmapmanager.h"
       
    27 #include "mesmrlistobserver.h"
       
    28 
       
    29 #include <calentry.h>
       
    30 #include <stringloader.h>
       
    31 #include <aknsconstants.h>
       
    32 #include <esmrgui.rsg>
       
    33 #include <aknsbasicbackgroundcontrolcontext.h>
       
    34 #include <eikmfne.h>
       
    35 
       
    36 #include "emailtrace.h"
    35 
    37 
    36 // ======== MEMBER FUNCTIONS ========
    38 // ======== MEMBER FUNCTIONS ========
    37 
    39 
    38 // ---------------------------------------------------------------------------
    40 // ---------------------------------------------------------------------------
    39 // CESMRSubjectField::CESMRSubjectField
    41 // CESMRSubjectField::CESMRSubjectField
    40 // ---------------------------------------------------------------------------
    42 // ---------------------------------------------------------------------------
    41 //
    43 //
    42 CESMRSubjectField::CESMRSubjectField( )
    44 CESMRSubjectField::CESMRSubjectField()
    43 :   CESMRIconField()
    45     {
    44     {
    46     FUNC_LOG;
    45     FUNC_LOG;
    47     SetFocusType( EESMRHighlightFocus );
    46     //do nothing
       
    47     }
    48     }
    48 
    49 
    49 // ---------------------------------------------------------------------------
    50 // ---------------------------------------------------------------------------
    50 // CESMRSubjectField::~CESMRSubjectField
    51 // CESMRSubjectField::~CESMRSubjectField
    51 // ---------------------------------------------------------------------------
    52 // ---------------------------------------------------------------------------
    52 //
    53 //
    53 CESMRSubjectField::~CESMRSubjectField( )
    54 CESMRSubjectField::~CESMRSubjectField( )
    54     {
    55     {
    55     FUNC_LOG;
    56     FUNC_LOG;
    56     delete iFrameBgContext;
    57     delete iFieldIcon;
       
    58     delete iBgControlContext;
       
    59     delete iPriorityIcon;
    57     }
    60     }
    58 
    61 
    59 // ---------------------------------------------------------------------------
    62 // ---------------------------------------------------------------------------
    60 // CESMRSubjectField::ConstructL
    63 // CESMRSubjectField::ConstructL
    61 // ---------------------------------------------------------------------------
    64 // ---------------------------------------------------------------------------
    62 //
    65 //
    63 void CESMRSubjectField::ConstructL( TESMREntryFieldId aId, TInt aTextId,
    66 void CESMRSubjectField::ConstructL( TESMREntryFieldId aId, TInt aTextId,
    64         TAknsItemID aIconID )
    67         NMRBitmapManager::TMRBitmapId aIconID )
    65     {
    68     {
    66     FUNC_LOG;
    69     FUNC_LOG;
    67     SetFieldId ( aId );
    70     SetFieldId( aId );
    68     SetExpandable ( );
    71 
    69 
    72     iFieldIcon = CMRImage::NewL( aIconID );
       
    73     iFieldIcon->SetParent( this );
       
    74     
    70     iSubject = CESMREditor::NewL ( this, 1, KMaxTextLength,
    75     iSubject = CESMREditor::NewL ( this, 1, KMaxTextLength,
    71             CEikEdwin::EResizable | CEikEdwin::EAvkonEditor | EAknEditorFlagNoLRNavigation);
    76             CEikEdwin::EResizable | CEikEdwin::EAvkonEditor | EAknEditorFlagNoLRNavigation);
    72     iSubject->SetEdwinSizeObserver ( this );
    77     iSubject->SetEdwinSizeObserver ( this );
    73     iSubject->SetEdwinObserver( this );
    78     iSubject->SetEdwinObserver( this );
       
    79     iSubject->SetParent( this );
       
    80 
       
    81     CESMRField::ConstructL( iSubject );  // iSubject ownership transfered
    74 
    82 
    75     HBufC* buf = StringLoader::LoadLC ( aTextId );
    83     HBufC* buf = StringLoader::LoadLC ( aTextId );
    76     iSubject->SetDefaultTextL( buf ); // ownership transferred
    84     iSubject->SetDefaultTextL( buf ); // ownership transferred
    77     CleanupStack::Pop( buf );
    85     CleanupStack::Pop( buf );
    78 
    86     
    79     iBackground = AknsDrawUtils::ControlContext( this );
    87     // Setting background instead of theme skin  
    80 
    88     NMRBitmapManager::TMRBitmapStruct bitmapStruct;
    81     CESMRIconField::ConstructL ( aIconID, iSubject );
    89     bitmapStruct = NMRBitmapManager::GetBitmapStruct( 
       
    90             NMRBitmapManager::EMRBitmapInputCenter );
       
    91 
       
    92     TRect initialisationRect( 0, 0, 0, 0 );
       
    93     iBgControlContext = 
       
    94                 CAknsBasicBackgroundControlContext::NewL( 
       
    95                         bitmapStruct.iItemId,
       
    96                         initialisationRect, 
       
    97                         EFalse );
       
    98                 
       
    99     iSubject->SetSkinBackgroundControlContextL( iBgControlContext );
       
   100     
       
   101     iCurrentPriority = EFSCalenMRPriorityNormal;
    82     }
   102     }
    83 
   103 
    84 // ---------------------------------------------------------------------------
   104 // ---------------------------------------------------------------------------
    85 // CESMRSubjectField::NewL
   105 // CESMRSubjectField::NewL
    86 // ---------------------------------------------------------------------------
   106 // ---------------------------------------------------------------------------
    87 //
   107 //
    88 CESMRSubjectField* CESMRSubjectField::NewL( TFieldType aType )
   108 CESMRSubjectField* CESMRSubjectField::NewL( TFieldType aType )
    89     {
   109     {
    90     FUNC_LOG;
   110     FUNC_LOG;
    91     CESMRSubjectField* self = new (ELeave) CESMRSubjectField;
   111     CESMRSubjectField* self = new( ELeave )CESMRSubjectField;
    92     CleanupStack::PushL ( self );
   112     CleanupStack::PushL ( self );
    93     if ( aType == ETypeSubject )
   113     if ( aType == ETypeSubject )
    94         {
   114         {
    95         self->ConstructL (EESMRFieldSubject,
   115         self->ConstructL( EESMRFieldSubject,
    96         R_QTN_MEET_REQ_SUBJECT_FIELD,
   116         R_QTN_MEET_REQ_SUBJECT_FIELD,
    97         KAknsIIDQgnFscalIndiSubject );
   117         NMRBitmapManager::EMRBitmapSubject );
    98         }
   118         }
    99     else
   119     else
   100         {
   120         {
   101         self->ConstructL (EESMRFieldOccasion,
   121         self->ConstructL( EESMRFieldOccasion,
   102         R_QTN_CALENDAR_ANNIVERSARY_TYPE_OCCASION,
   122         R_QTN_CALENDAR_ANNIVERSARY_TYPE_OCCASION,
   103         KAknsIIDQgnFscalIndiOccasion );
   123         NMRBitmapManager::EMRBitmapOccasion );
   104         }
   124         }
   105     CleanupStack::Pop ( self );
   125     CleanupStack::Pop( self );
   106     return self;
   126     return self;
   107     }
   127     }
   108 
   128 
   109 // ---------------------------------------------------------------------------
   129 // ---------------------------------------------------------------------------
       
   130 // CESMRSubjectField::MinimumSize
       
   131 // ---------------------------------------------------------------------------
       
   132 //
       
   133 TSize CESMRSubjectField::MinimumSize()
       
   134     {
       
   135     TRect parentRect( Parent()->Rect() );
       
   136     
       
   137     TRect fieldRect = 
       
   138        NMRLayoutManager::GetFieldLayoutRect( parentRect, 1 ).Rect();
       
   139 
       
   140     TRect editorRect( NMRLayoutManager::GetLayoutText( 
       
   141        fieldRect, 
       
   142        NMRLayoutManager::EMRTextLayoutTextEditor ).TextRect() );
       
   143     
       
   144     if( iPriorityIcon )
       
   145         {
       
   146 		editorRect = NMRLayoutManager::GetLayoutText( 
       
   147 			   fieldRect, 
       
   148 			   NMRLayoutManager::EMRTextLayoutSingleRowEditorText ).TextRect();
       
   149         }
       
   150  
       
   151     // Adjust field size so that there's room for expandable editor.
       
   152     fieldRect.Resize( 0, iSize.iHeight - editorRect.Height() );
       
   153     
       
   154     return fieldRect.Size();
       
   155     }
       
   156 
       
   157 // ---------------------------------------------------------------------------
   110 // CESMRSubjectField::InitializeL
   158 // CESMRSubjectField::InitializeL
   111 // ---------------------------------------------------------------------------
   159 // ---------------------------------------------------------------------------
   112 //
   160 //
   113 void CESMRSubjectField::InitializeL()
   161 void CESMRSubjectField::InitializeL()
   114     {
   162     {
   115     FUNC_LOG;
   163     FUNC_LOG;
   116     iSubject->SetFontL( iLayout->Font( iCoeEnv, iFieldId ), iLayout );
   164     // Do nothing
   117     }
   165     }
   118 
   166 
   119 // ---------------------------------------------------------------------------
   167 // ---------------------------------------------------------------------------
   120 // CESMRSubjectField::InternalizeL
   168 // CESMRSubjectField::InternalizeL
   121 // ---------------------------------------------------------------------------
   169 // ---------------------------------------------------------------------------
   134         if ( iTitlePaneObserver )
   182         if ( iTitlePaneObserver )
   135             {
   183             {
   136             iTitlePaneObserver->UpdateTitlePaneTextL( *subject );
   184             iTitlePaneObserver->UpdateTitlePaneTextL( *subject );
   137             }
   185             }
   138         }
   186         }
       
   187     
       
   188     if( entry.PriorityL() != EFSCalenMRPriorityNormal &&
       
   189             entry.EntryTypeL() == CCalEntry::EAppt )
       
   190         {
       
   191         SetPriorityIconL( entry.PriorityL() );
       
   192         }
   139 
   193 
   140     // this is needed to be re-called here, otherwise the CEikEdwin
   194     // this is needed to be re-called here, otherwise the CEikEdwin
   141     // does not get correctly instantiated with default text
   195     // does not get correctly instantiated with default text
   142     iSubject->FocusChanged(EDrawNow);
   196     iSubject->FocusChanged( EDrawNow );
   143 
   197 
   144     CleanupStack::PopAndDestroy ( subject );
   198     CleanupStack::PopAndDestroy ( subject );
   145     }
   199     }
   146 
   200 
   147 // ---------------------------------------------------------------------------
   201 // ---------------------------------------------------------------------------
   150 //
   204 //
   151 void CESMRSubjectField::ExternalizeL( MESMRCalEntry& aEntry )
   205 void CESMRSubjectField::ExternalizeL( MESMRCalEntry& aEntry )
   152     {
   206     {
   153     FUNC_LOG;
   207     FUNC_LOG;
   154     HBufC* subject = iSubject->GetTextInHBufL ( );
   208     HBufC* subject = iSubject->GetTextInHBufL ( );
   155 
   209     
       
   210     CCalEntry& entry = aEntry.Entry();
       
   211     
   156     if ( subject )
   212     if ( subject )
   157         {
   213         {
   158         CleanupStack::PushL ( subject );
   214         CleanupStack::PushL ( subject );
   159 
   215 
   160         // externalize the text only if it differs from the
   216         // externalize the text only if it differs from the
   161         // default text. In other words, default text is not
   217         // default text. In other words, default text is not
   162         // externalized.
   218         // externalized.
   163 
   219         if ( iSubject->DefaultText().Compare (*subject )!= 0 )
   164        if ( iSubject->DefaultText().Compare (*subject )!= 0 )
   220             {
   165             {
   221             entry.SetSummaryL( *subject );
   166             CCalEntry& entry = aEntry.Entry ( );
   222             }
   167             entry.SetSummaryL ( *subject );
   223 
   168             }
   224         CleanupStack::PopAndDestroy( subject );
   169 
       
   170        CleanupStack::PopAndDestroy ( subject );
       
   171         }
   225         }
   172     else
   226     else
   173         {
   227         {
   174         CCalEntry& entry = aEntry.Entry ( );
       
   175         entry.SetSummaryL( KNullDesC );
   228         entry.SetSummaryL( KNullDesC );
   176         }
   229         }
       
   230 
       
   231     entry.SetPriorityL( iCurrentPriority );
   177     }
   232     }
   178 
   233 
   179 // ---------------------------------------------------------------------------
   234 // ---------------------------------------------------------------------------
   180 // CESMRSubjectField::SetOutlineFocusL
   235 // CESMRSubjectField::SetOutlineFocusL
   181 // ---------------------------------------------------------------------------
   236 // ---------------------------------------------------------------------------
   183 void CESMRSubjectField::SetOutlineFocusL( TBool aFocus )
   238 void CESMRSubjectField::SetOutlineFocusL( TBool aFocus )
   184     {
   239     {
   185     FUNC_LOG;
   240     FUNC_LOG;
   186     CESMRField::SetOutlineFocusL ( aFocus );
   241     CESMRField::SetOutlineFocusL ( aFocus );
   187 
   242 
   188     if (aFocus) //Focus is gained on the field
   243     if ( aFocus ) //Focus is gained on the field
   189         {
   244         {
   190         ChangeMiddleSoftKeyL(EESMRCmdSaveMR,R_QTN_MSK_SAVE);
   245         ChangeMiddleSoftKeyL( EESMRCmdSaveMR,R_QTN_MSK_SAVE );
   191         }
       
   192     }
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // CESMRSubjectField::ExpandedHeight
       
   196 // ---------------------------------------------------------------------------
       
   197 //
       
   198 TInt CESMRSubjectField::ExpandedHeight( ) const
       
   199     {
       
   200     FUNC_LOG;
       
   201     TInt height = iLayout->FieldSize( FieldId() ).iHeight;
       
   202     if( iSize.iHeight < height )
       
   203         {
       
   204         return height - KEditorDifference;
       
   205         }
       
   206     else
       
   207         {
       
   208         return iSize.iHeight;
       
   209         }
   246         }
   210     }
   247     }
   211 
   248 
   212 // ---------------------------------------------------------------------------
   249 // ---------------------------------------------------------------------------
   213 // CESMRSubjectField::HandleEdwinSizeEventL
   250 // CESMRSubjectField::HandleEdwinSizeEventL
   214 // ---------------------------------------------------------------------------
   251 // ---------------------------------------------------------------------------
   215 //
   252 //
   216 TBool CESMRSubjectField::HandleEdwinSizeEventL(CEikEdwin* /*aEdwin*/,
   253 TBool CESMRSubjectField::HandleEdwinSizeEventL( CEikEdwin* aEdwin,
   217         TEdwinSizeEvent /*aType*/, TSize aSize )
   254         TEdwinSizeEvent /*aType*/, TSize aSize )
   218     {
   255     {
   219     FUNC_LOG;
   256     FUNC_LOG;
   220     iSize = aSize;
   257     TBool reDraw( EFalse );
   221     iSize.iHeight -= KEditorDifference;
   258     
   222 
   259     if( iSize != aSize )
   223     if (iLayout->CurrentFontZoom() == EAknUiZoomSmall ||
   260         {
   224         iLayout->CurrentFontZoom() == EAknUiZoomVerySmall)
   261         // Let's save the required size for the iSubject
   225         {
   262         iSize = aSize;
   226         iSize.iHeight -= KEditorDifference;
   263             
   227         }
   264         if ( iObserver && aEdwin == iSubject )
   228 
   265            {
   229     if ( iObserver )
   266            iObserver->ControlSizeChanged( this );
   230         {
   267            reDraw = ETrue;
   231         iObserver->ControlSizeChanged ( this );
   268            }
   232         }
   269         
   233 
   270         if( iSubject->LineCount() != iLineCount )
   234     if( iFrameBgContext )
   271             {
   235         {
   272             // Line count has changed, the whole component needs
   236         TRect visibleRect = CalculateVisibleRect( iSubject->Rect() );
   273             // to be redrawn
   237         iFrameBgContext->SetFrameRects( visibleRect, visibleRect );
   274             DrawDeferred();
   238         }
   275             iLineCount = iSubject->LineCount();
   239 
   276             }
   240     return ETrue;
   277         }
       
   278     return reDraw;
   241     }
   279     }
   242 
   280 
   243 // ---------------------------------------------------------------------------
   281 // ---------------------------------------------------------------------------
   244 // CESMRSubjectField::HandleEdwinEventL
   282 // CESMRSubjectField::HandleEdwinEventL
   245 // ---------------------------------------------------------------------------
   283 // ---------------------------------------------------------------------------
   258             
   296             
   259             iTitlePaneObserver->UpdateTitlePaneTextL( *text );
   297             iTitlePaneObserver->UpdateTitlePaneTextL( *text );
   260             
   298             
   261             TInt textLength( text->Length() );
   299             TInt textLength( text->Length() );
   262             if ( iSubject->GetLimitLength() <= textLength )
   300             if ( iSubject->GetLimitLength() <= textLength )
   263             	{
   301                 {
   264             	NotifyEventAsyncL( EESMRCmdSizeExceeded );
   302                 NotifyEventAsyncL( EESMRCmdSizeExceeded );
   265             	}  
   303                 }  
   266             
   304             
   267             CleanupStack::PopAndDestroy( text );
   305             CleanupStack::PopAndDestroy( text );
   268             }
   306             }
   269         else
   307         else
   270             {
   308             {
   282     FUNC_LOG;
   320     FUNC_LOG;
   283     iTitlePaneObserver = aObserver;
   321     iTitlePaneObserver = aObserver;
   284     }
   322     }
   285 
   323 
   286 // ---------------------------------------------------------------------------
   324 // ---------------------------------------------------------------------------
   287 // CESMRSubjectField::PositionChanged()
   325 // CESMRSubjectField::GetCursorLineVerticalPos
   288 // ---------------------------------------------------------------------------
   326 // ---------------------------------------------------------------------------
   289 //
   327 //
   290 void CESMRSubjectField::PositionChanged()
   328 void CESMRSubjectField::GetCursorLineVerticalPos(TInt& aUpper, TInt& aLower)
   291     {
   329     {
   292     FUNC_LOG;
       
   293     CCoeControl::PositionChanged();
       
   294     if( iFrameBgContext )
       
   295         {
       
   296         TRect visibleRect = CalculateVisibleRect( iSubject->Rect() );
       
   297         iFrameBgContext->SetFrameRects( visibleRect, visibleRect );
       
   298         }
       
   299     }
       
   300 
       
   301 // ---------------------------------------------------------------------------
       
   302 // CESMRSubjectField::GetVerticalFocusPosition
       
   303 // ---------------------------------------------------------------------------
       
   304 //
       
   305 void CESMRSubjectField::GetMinimumVisibleVerticalArea(TInt& aUpper, TInt& aLower)
       
   306     {
       
   307     FUNC_LOG;
       
   308     aLower = iSubject->CurrentLineNumber() * iSubject->RowHeight();
   330     aLower = iSubject->CurrentLineNumber() * iSubject->RowHeight();
   309     aUpper = aLower - iSubject->RowHeight();
   331     aUpper = aLower - iSubject->RowHeight();
   310     }
   332     }
   311 // ---------------------------------------------------------------------------
       
   312 // CESMRSubjectField::ActivateL
       
   313 // ---------------------------------------------------------------------------
       
   314 //
       
   315 void CESMRSubjectField::ActivateL()
       
   316     {
       
   317     FUNC_LOG;
       
   318     CCoeControl::ActivateL();
       
   319     TRect rect(TPoint(iSubject->Position()), iSubject->Size());
       
   320     TRect inner(rect);
       
   321     TRect outer(rect);
       
   322 
       
   323     iSubject->SetSize( TSize( iSubject->Size().iWidth, iLayout->FieldSize( FieldId() ).iHeight ));
       
   324 
       
   325     delete iFrameBgContext;
       
   326     iFrameBgContext = NULL;
       
   327     iFrameBgContext = CAknsFrameBackgroundControlContext::NewL( KAknsIIDQsnFrInput, outer, inner, EFalse ) ;
       
   328 
       
   329     iFrameBgContext->SetParentContext( iBackground );
       
   330     iSubject->SetSkinBackgroundControlContextL(iFrameBgContext);
       
   331 
       
   332     // update base class rects and redraw:
       
   333     SizeChanged();
       
   334     }
       
   335 
   333 
   336 // ---------------------------------------------------------------------------
   334 // ---------------------------------------------------------------------------
   337 // CESMRSubjectField::ListObserverSet
   335 // CESMRSubjectField::ListObserverSet
   338 // ---------------------------------------------------------------------------
   336 // ---------------------------------------------------------------------------
   339 //
   337 //
   345 
   343 
   346 // ---------------------------------------------------------------------------
   344 // ---------------------------------------------------------------------------
   347 // CESMRSubjectField::ExecuteGenericCommandL
   345 // CESMRSubjectField::ExecuteGenericCommandL
   348 // ---------------------------------------------------------------------------
   346 // ---------------------------------------------------------------------------
   349 //
   347 //
   350 void CESMRSubjectField::ExecuteGenericCommandL( 
   348 TBool CESMRSubjectField::ExecuteGenericCommandL(
   351 		TInt aCommand )
   349         TInt aCommand )
   352 	{
   350     {
   353     FUNC_LOG;
   351     FUNC_LOG;
   354 	if ( EESMRCmdSizeExceeded == aCommand )
   352     TBool isUsed( EFalse );
   355 		{
   353     switch ( aCommand )
   356 		CESMRGlobalNote::ExecuteL ( 
   354         {
   357 				CESMRGlobalNote::EESMRCannotDisplayMuchMore );
   355         case EESMRCmdPriorityHigh:
   358 
   356             {
   359 		HBufC* text = iSubject->GetTextInHBufL();
   357             SetPriorityIconL( EFSCalenMRPriorityHigh );
   360 		CleanupDeletePushL( text );
   358             isUsed = ETrue;
   361 		if ( text )
   359             break;
   362 			{    
   360             }
   363 	    	TInt curPos = iSubject->CursorPos();    	
   361         case EESMRCmdPriorityNormal:
   364 	    	if( curPos > iSubject->GetLimitLength() - 1 )
   362             {
   365 	    		curPos = iSubject->GetLimitLength() - 1;
   363             SetPriorityIconL( EFSCalenMRPriorityNormal );
   366 	    	HBufC* newText = 
   364             isUsed = ETrue;
   367 	    		text->Des().Mid( 0, iSubject->GetLimitLength() - 1 ).AllocLC();    	
   365             break;
   368 	    	
   366             }
   369 	    	iSubject->SetTextL ( newText );
   367         case EESMRCmdPriorityLow:
   370 	    	CleanupStack::PopAndDestroy( newText );
   368             {
   371 	    	newText = NULL;
   369             SetPriorityIconL( EFSCalenMRPriorityLow );
   372 	    	
   370             isUsed = ETrue;
   373 	    	iSubject->SetCursorPosL (curPos, EFalse );
   371             break;
   374 	    	iSubject->HandleTextChangedL();
   372             }
   375 	    	iSubject->UpdateScrollBarsL();
   373             
   376 	    	SetFocus(ETrue);
   374         case EESMRCmdSizeExceeded:
   377 			}
   375             {
   378 		CleanupStack::PopAndDestroy( text );	
   376             CESMRGlobalNote::ExecuteL ( 
   379 		}
   377                     CESMRGlobalNote::EESMRCannotDisplayMuchMore );
   380 	}
   378             
       
   379             HBufC* text = iSubject->GetTextInHBufL();
       
   380             CleanupDeletePushL( text );
       
   381             if ( text )
       
   382                 {    
       
   383                 TInt curPos = iSubject->CursorPos();        
       
   384                 if( curPos > iSubject->GetLimitLength() - 1 )
       
   385                     curPos = iSubject->GetLimitLength() - 1;
       
   386                 HBufC* newText = 
       
   387                     text->Des().Mid( 0, iSubject->GetLimitLength() - 1 ).AllocLC();     
       
   388                 
       
   389                 iSubject->SetTextL ( newText );
       
   390                 CleanupStack::PopAndDestroy( newText );
       
   391                 newText = NULL;
       
   392                 
       
   393                 iSubject->SetCursorPosL (curPos, EFalse );
       
   394                 iSubject->HandleTextChangedL();
       
   395                 iSubject->UpdateScrollBarsL();
       
   396                 SetFocus(ETrue);
       
   397                 }
       
   398             CleanupStack::PopAndDestroy( text );
       
   399             isUsed = ETrue;
       
   400             break;
       
   401             }
       
   402         default:
       
   403             {
       
   404             break;
       
   405             }
       
   406         }
       
   407     return isUsed;
       
   408     }
       
   409 
       
   410 // ---------------------------------------------------------------------------
       
   411 // CESMRSubjectField::CountComponentControls
       
   412 // ---------------------------------------------------------------------------
       
   413 //
       
   414 TInt CESMRSubjectField::CountComponentControls() const
       
   415     {
       
   416     TInt count( 0 );
       
   417     if ( iFieldIcon )
       
   418         {
       
   419         ++count;
       
   420         }
       
   421 
       
   422     if ( iSubject )
       
   423         {
       
   424         ++count;
       
   425         }
       
   426     
       
   427     if ( iPriorityIcon )
       
   428         {
       
   429         ++count;
       
   430         }
       
   431     return count;
       
   432     }
       
   433 
       
   434 // ---------------------------------------------------------------------------
       
   435 // CESMRSubjectField::ComponentControl
       
   436 // ---------------------------------------------------------------------------
       
   437 //
       
   438 CCoeControl* CESMRSubjectField::ComponentControl( 
       
   439         TInt aIndex ) const
       
   440     {
       
   441     switch ( aIndex )
       
   442         {
       
   443         case 0:
       
   444             return iFieldIcon;
       
   445         case 1:
       
   446             return iSubject;
       
   447         case 2:
       
   448             return iPriorityIcon;
       
   449         default:
       
   450             return NULL;
       
   451         }
       
   452     }
       
   453 
       
   454 // ---------------------------------------------------------------------------
       
   455 // CESMRSubjectField::SizeChanged
       
   456 // ---------------------------------------------------------------------------
       
   457 //
       
   458 void CESMRSubjectField::SizeChanged( )
       
   459     {
       
   460     TRect rect( Rect() );
       
   461 
       
   462     TAknLayoutRect rowLayoutRect( 
       
   463             NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ) );
       
   464     TRect rowRect( rowLayoutRect.Rect() );
       
   465     
       
   466     // Layouting field icon
       
   467     if( iFieldIcon )
       
   468         {
       
   469         TAknWindowComponentLayout iconLayout( 
       
   470             NMRLayoutManager::GetWindowComponentLayout( 
       
   471                     NMRLayoutManager::EMRLayoutSingleRowAColumnGraphic ) );
       
   472         AknLayoutUtils::LayoutControl( iFieldIcon, rowRect, iconLayout );
       
   473         }
       
   474     
       
   475     // Layouting priority icon
       
   476     if( iPriorityIcon )
       
   477         {
       
   478         TAknWindowComponentLayout iconLayout( 
       
   479                 NMRLayoutManager::GetWindowComponentLayout( 
       
   480                     NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
       
   481         AknLayoutUtils::LayoutImage( iPriorityIcon, rowRect, iconLayout );
       
   482         }
       
   483 
       
   484     TAknLayoutText editorLayoutText;
       
   485 
       
   486     if( iPriorityIcon )
       
   487         {
       
   488         editorLayoutText = NMRLayoutManager::GetLayoutText( rowRect, 
       
   489                     NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
       
   490         }
       
   491     else
       
   492         {
       
   493         editorLayoutText = NMRLayoutManager::GetLayoutText( rowRect, 
       
   494                     NMRLayoutManager::EMRTextLayoutTextEditor );
       
   495         }
       
   496     
       
   497     // Layouting editor field
       
   498     TRect editorRect( editorLayoutText.TextRect() );
       
   499 
       
   500     // Resize height according to actual height required by edwin.
       
   501     editorRect.Resize( 0, iSize.iHeight - editorRect.Height() );
       
   502     iSubject->SetRect( editorRect );  
       
   503     
       
   504     // Try setting font. Failures are ignored.
       
   505     TRAP_IGNORE( iSubject->SetFontL( editorLayoutText.Font() ) );
       
   506     
       
   507     // Layouting focus
       
   508     TRect bgRect( TPoint( editorRect.iTl.iX, editorRect.iTl.iY ), 
       
   509             editorRect.Size() );
       
   510     
       
   511     // Move focus rect so that it's relative to field's position.
       
   512     bgRect.Move( -Position() );
       
   513     SetFocusRect( bgRect );    
       
   514     }
       
   515 
       
   516 // ---------------------------------------------------------------------------
       
   517 // CESMRSubjectField::SetContainerWindowL
       
   518 // ---------------------------------------------------------------------------
       
   519 //
       
   520 void CESMRSubjectField::SetContainerWindowL( 
       
   521         const CCoeControl& aContainer )
       
   522     {
       
   523     CCoeControl::SetContainerWindowL( aContainer );
       
   524     iSubject->SetContainerWindowL( aContainer );
       
   525     
       
   526     iSubject->SetParent( this );
       
   527     }
       
   528 
       
   529 // ---------------------------------------------------------------------------
       
   530 // CESMRSubjectField::OfferKeyEventL()
       
   531 // ---------------------------------------------------------------------------
       
   532 //
       
   533 TKeyResponse CESMRSubjectField::OfferKeyEventL(
       
   534         const TKeyEvent& aEvent,
       
   535         TEventCode aType )
       
   536     {
       
   537     FUNC_LOG;
       
   538     TKeyResponse response( EKeyWasNotConsumed);
       
   539     response = iSubject->OfferKeyEventL ( aEvent, aType );
       
   540 
       
   541     if ( aType == EEventKey && 
       
   542     		( aEvent.iScanCode != EStdKeyUpArrow &&
       
   543 			  aEvent.iScanCode != EStdKeyDownArrow ))
       
   544     	{       
       
   545         iSubject->DrawDeferred();
       
   546     	}
       
   547     return response;
       
   548     }
       
   549 
       
   550 // ---------------------------------------------------------------------------
       
   551 // CESMRSubjectField::SetPriorityIconL
       
   552 // ---------------------------------------------------------------------------
       
   553 //
       
   554 void CESMRSubjectField::SetPriorityIconL( TUint aPriority )
       
   555     {
       
   556     switch ( aPriority )
       
   557         {
       
   558         case EFSCalenMRPriorityHigh:
       
   559             {
       
   560             delete iPriorityIcon;
       
   561             iPriorityIcon = NULL;
       
   562             
       
   563             iPriorityIcon = CMRImage::NewL( 
       
   564                   NMRBitmapManager::EMRBitmapPriorityHigh, ETrue );
       
   565             iPriorityIcon->SetParent( this );
       
   566             if( iCurrentPriority == EFSCalenMRPriorityNormal )
       
   567             	{
       
   568 				SizeChanged();
       
   569             	}
       
   570             iCurrentPriority = EFSCalenMRPriorityHigh;
       
   571             break;
       
   572             }
       
   573           
       
   574         case EFSCalenMRPriorityNormal:
       
   575             {
       
   576             delete iPriorityIcon;
       
   577             iPriorityIcon = NULL;
       
   578             if( iCurrentPriority != EFSCalenMRPriorityNormal )
       
   579 				{
       
   580 				SizeChanged();
       
   581 				}
       
   582             iCurrentPriority = EFSCalenMRPriorityNormal;
       
   583             break;
       
   584             }
       
   585           
       
   586         case EFSCalenMRPriorityLow:
       
   587             {
       
   588             delete iPriorityIcon;
       
   589             iPriorityIcon = NULL;
       
   590             
       
   591             iPriorityIcon = CMRImage::NewL( 
       
   592                   NMRBitmapManager::EMRBitmapPriorityLow );
       
   593             iPriorityIcon->SetParent( this );  
       
   594             if( iCurrentPriority == EFSCalenMRPriorityNormal )
       
   595 				{
       
   596 				SizeChanged();
       
   597 				}
       
   598             iCurrentPriority = EFSCalenMRPriorityLow;
       
   599             break;
       
   600             }
       
   601         default:
       
   602             {
       
   603             break;
       
   604             }
       
   605         }
       
   606     }
       
   607 
   381 // EOF
   608 // EOF