meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrtimefield.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 0 8466d47a6819
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 time (start-end) field implementation
    14 * Description:  ESMR time (start-end) field implementation
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 #include "emailtrace.h"
       
    19 #include "cesmrtimefield.h"
    18 #include "cesmrtimefield.h"
    20 
    19 #include "cmrtimecontainer.h"
    21 #include <eikmfne.h>
       
    22 #include <avkon.hrh>
       
    23 #include <eiklabel.h>
       
    24 #include <AknUtils.h>
       
    25 #include <AknsFrameBackgroundControlContext.h>
       
    26 #include <AknsDrawUtils.h>
       
    27 
       
    28 #include "mesmrfieldvalidator.h"
       
    29 #include "cesmrglobalnote.h"
       
    30 //<cmail>
    20 //<cmail>
    31 #include "esmrdef.h"
    21 #include "esmrdef.h"
    32 //</cmail>
    22 //</cmail>
    33 #include "esmrfieldbuilderdef.h"
    23 #include "cmrimage.h"
       
    24 #include "nmrlayoutmanager.h"
       
    25 
       
    26 // DEBUG
       
    27 #include "emailtrace.h"
       
    28 
       
    29 namespace // codescanner::namespace
       
    30     {
       
    31     const TInt KFieldComponentCount( 2 );
       
    32     } // unnamed namespace
    34 
    33 
    35 // ======== MEMBER FUNCTIONS ========
    34 // ======== MEMBER FUNCTIONS ========
    36 
    35 
    37 // ---------------------------------------------------------------------------
    36 // ---------------------------------------------------------------------------
    38 // CESMRTimeField::CESMRTimeField
    37 // CESMRTimeField::CESMRTimeField
    39 // ---------------------------------------------------------------------------
    38 // ---------------------------------------------------------------------------
    40 //
    39 //
    41 CESMRTimeField::CESMRTimeField( )
    40 CESMRTimeField::CESMRTimeField( )
    42     {
    41     {
    43     FUNC_LOG;
    42     FUNC_LOG;
    44     // do nothing
    43     SetFieldId ( EESMRFieldMeetingTime );
       
    44     SetFocusType( EESMRHighlightFocus );
    45     }
    45     }
    46 
    46 
    47 // ---------------------------------------------------------------------------
    47 // ---------------------------------------------------------------------------
    48 // CESMRTimeField::~CESMRTimeField
    48 // CESMRTimeField::~CESMRTimeField
    49 // ---------------------------------------------------------------------------
    49 // ---------------------------------------------------------------------------
    50 //
    50 //
    51 CESMRTimeField::~CESMRTimeField( )
    51 CESMRTimeField::~CESMRTimeField( )
    52     {
    52     {
    53     FUNC_LOG;
    53     FUNC_LOG;
    54     // iContainer is deleted by framework
    54     // iContainer is deleted by framework
    55     // do nothing
    55     delete iFieldIcon;
    56     }
    56     }
    57 
    57 
    58 // ---------------------------------------------------------------------------
    58 // ---------------------------------------------------------------------------
    59 // CESMRTimeField::NewL
    59 // CESMRTimeField::NewL
    60 // ---------------------------------------------------------------------------
    60 // ---------------------------------------------------------------------------
    76 //
    76 //
    77 void CESMRTimeField::ConstructL(
    77 void CESMRTimeField::ConstructL(
    78         MESMRFieldValidator* aValidator )
    78         MESMRFieldValidator* aValidator )
    79     {
    79     {
    80     FUNC_LOG;
    80     FUNC_LOG;
    81     SetFieldId ( EESMRFieldMeetingTime );
    81     CCoeControl::SetComponentsToInheritVisibility( ETrue );
    82     iContainer =
    82     iContainer =
    83             CTimeContainer::NewL(
    83             CMRTimeContainer::NewL(
    84                     aValidator,
    84                     aValidator,
    85                     this,
    85                     this,
    86                     EESMRFieldMeetingTime );
    86                     EESMRFieldMeetingTime );
    87 
    87     // This is taking ownership
    88     CESMRIconField::ConstructL(
    88     CESMRField::ConstructL( iContainer );
    89             KAknsIIDQgnMeetReqIndiClock,
    89 
    90             iContainer );
    90     iFieldIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapClock );
       
    91     iFieldIcon->SetParent( this );
    91     }
    92     }
    92 
    93 
    93 // ---------------------------------------------------------------------------
    94 // ---------------------------------------------------------------------------
    94 // CESMRTimeField::SetContainerWindowL
    95 // CESMRTimeField::SetContainerWindowL
    95 // ---------------------------------------------------------------------------
    96 // ---------------------------------------------------------------------------
   100     FUNC_LOG;
   101     FUNC_LOG;
   101     CCoeControl::SetContainerWindowL ( aControl );
   102     CCoeControl::SetContainerWindowL ( aControl );
   102     if ( iContainer )
   103     if ( iContainer )
   103         {
   104         {
   104         iContainer->SetContainerWindowL ( aControl );
   105         iContainer->SetContainerWindowL ( aControl );
       
   106         iContainer->SetParent( this );
       
   107         }
       
   108     if ( iFieldIcon )
       
   109         {
       
   110         iFieldIcon->SetContainerWindowL( aControl );
       
   111         iFieldIcon->SetParent( this );
   105         }
   112         }
   106     }
   113     }
   107 
   114 
   108 // ---------------------------------------------------------------------------
   115 // ---------------------------------------------------------------------------
   109 // CESMRTimeField::OfferKeyEventL
   116 // CESMRTimeField::OfferKeyEventL
   121         }
   128         }
   122     return response;
   129     return response;
   123     }
   130     }
   124 
   131 
   125 // ---------------------------------------------------------------------------
   132 // ---------------------------------------------------------------------------
   126 // CESMRTimeField::InitializeL
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 void CESMRTimeField::InitializeL()
       
   130     {
       
   131     FUNC_LOG;
       
   132     if ( iContainer )
       
   133         {
       
   134         iContainer->SetFontL( iLayout->Font ( iCoeEnv, iFieldId ), iLayout );
       
   135         }
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // CESMRTimeField::OkToLoseFocusL
   133 // CESMRTimeField::OkToLoseFocusL
   140 // ---------------------------------------------------------------------------
   134 // ---------------------------------------------------------------------------
   141 //
   135 //
   142 TBool CESMRTimeField::OkToLoseFocusL(
   136 TBool CESMRTimeField::OkToLoseFocusL(
   143         TESMREntryFieldId aNext )
   137         TESMREntryFieldId aNext )
   163         ChangeMiddleSoftKeyL(EESMRCmdSaveMR,R_QTN_MSK_SAVE);
   157         ChangeMiddleSoftKeyL(EESMRCmdSaveMR,R_QTN_MSK_SAVE);
   164         }
   158         }
   165     }
   159     }
   166 
   160 
   167 // ---------------------------------------------------------------------------
   161 // ---------------------------------------------------------------------------
   168 // CTimeContainer::CTimeContainer
   162 // CESMRTimeField::SetValidatorL
   169 // ---------------------------------------------------------------------------
   163 // ---------------------------------------------------------------------------
   170 //
   164 //
   171 CTimeContainer::CTimeContainer(
   165 void CESMRTimeField::SetValidatorL( MESMRFieldValidator* aValidator )
   172         MESMRFieldValidator* aValidator,
   166     {
   173         TESMREntryFieldId aFieldId  ) :
   167     FUNC_LOG;
   174     iValidator(aValidator),
   168     
   175     iFieldId( aFieldId )
   169     // Update iValidator member
   176     {
   170     CESMRField::SetValidatorL( aValidator );
   177     FUNC_LOG;
   171     
   178     // do nothing
   172     if ( iContainer )
   179     }
   173         {
   180 
   174         iContainer->SetValidatorL( iValidator );
   181 // ---------------------------------------------------------------------------
   175         }
   182 // CTimeContainer::~CTimeContainer
   176     }
   183 // ---------------------------------------------------------------------------
   177 
   184 //
   178 // ---------------------------------------------------------------------------
   185 CTimeContainer::~CTimeContainer( )
   179 // CESMRTimeField::SizeChanged()
   186     {
   180 // ---------------------------------------------------------------------------
   187     FUNC_LOG;
   181 //
   188     delete iStartTime;
   182 TBool CESMRTimeField::ExecuteGenericCommandL( TInt aCommand )
   189     delete iEndTime;
   183     {
   190     delete iSeparator;
   184     FUNC_LOG;
   191     delete iStartTimeBgContext;
   185     
   192     delete iEndTimeBgContext;
   186     TBool retValue( EFalse );
   193     }
   187     
   194 
   188     if ( iContainer && EMRCmdDoEnvironmentChange == aCommand )
   195 // ---------------------------------------------------------------------------
   189         {
   196 // CTimeContainer::NewL
   190         iContainer->EnvironmentChangedL();
   197 // ---------------------------------------------------------------------------
   191         SizeChanged();
   198 //
   192         DrawDeferred();
   199 CTimeContainer* CTimeContainer::NewL(
   193     
   200         MESMRFieldValidator* aValidator,
   194         retValue = ETrue;
   201         CCoeControl* aParent,
   195         }
   202         TESMREntryFieldId aFieldId )
   196     
   203     {
   197     return retValue;
   204     FUNC_LOG;
   198     }
   205     CTimeContainer* self =
   199 
   206             new (ELeave) CTimeContainer( aValidator, aFieldId );
   200 // ---------------------------------------------------------------------------
   207     CleanupStack::PushL ( self );
   201 // CESMRTimeField::SizeChanged()
   208     self->ConstructL ( aParent );
   202 // ---------------------------------------------------------------------------
   209     CleanupStack::Pop ( self );
   203 //
   210     return self;
   204 void CESMRTimeField::SizeChanged()
   211     }
   205     {
   212 
   206     TRect rect( Rect() );
   213 // ---------------------------------------------------------------------------
   207     TAknLayoutRect iconLayout = 
   214 // CTimeContainer::ConstructL
   208         NMRLayoutManager::GetLayoutRect( 
   215 // ---------------------------------------------------------------------------
   209                 rect, NMRLayoutManager::EMRLayoutTimeEditorIcon );
   216 //
   210     TRect iconRect( iconLayout.Rect() );
   217 void CTimeContainer::ConstructL(
   211     iFieldIcon->SetRect( iconRect );
   218         CCoeControl* /*aParent*/)
   212     
   219     {
   213     TAknLayoutRect bgLayoutRect = 
   220     FUNC_LOG;
   214         NMRLayoutManager::GetLayoutRect( 
   221     TTime startTime;
   215                 rect, NMRLayoutManager::EMRLayoutTextEditorBg );
   222     startTime.UniversalTime ( );
   216     TRect bgRect( bgLayoutRect.Rect() );
   223 
   217     // Move focus rect so that it's relative to field's position.
   224     iStartTime = new (ELeave) CEikTimeEditor;
   218     bgRect.Move( -Position() );
   225     iEndTime = new (ELeave) CEikTimeEditor;
   219     SetFocusRect( bgRect );
   226     iSeparator = new (ELeave) CEikLabel;
   220     
   227 
   221     iContainer->SetRect( rect );    
   228     iStartTime->ConstructL ( TTIME_TIMEFIELDMINIMUMDATE, 
   222     iContainer->SetBgRect( bgRect );
   229                              TTIME_TIMEFIELDMAXIMUMDATE,
   223     }
   230                              startTime, 
   224 
   231                              EEikTimeWithoutSecondsField );
   225 // ---------------------------------------------------------------------------
   232     
   226 // CESMRTimeField::CountComponentControls()
   233     iEndTime->ConstructL ( TTIME_TIMEFIELDMINIMUMDATE, 
   227 // ---------------------------------------------------------------------------
   234                            TTIME_TIMEFIELDMAXIMUMDATE,
   228 //
   235                            startTime, 
   229 TInt CESMRTimeField::CountComponentControls() const
   236                            EEikTimeWithoutSecondsField );
   230     {
   237 
   231     TInt count( KFieldComponentCount );
   238     iBackground = AknsDrawUtils::ControlContext( this );
       
   239 
       
   240     TInt align = CESMRLayoutManager::IsMirrored ( ) ? EAknEditorAlignRight
       
   241             : EAknEditorAlignLeft;
       
   242     iStartTime->SetMfneAlignment ( align );
       
   243     iEndTime->SetMfneAlignment ( align );
       
   244 
       
   245     iSeparator->SetTextL ( KTimeFieldSeparator );
       
   246 
       
   247     if ( iValidator )
       
   248         {
       
   249         iValidator->SetStartTimeFieldL( *iStartTime );
       
   250         iValidator->SetEndTimeFieldL( *iEndTime );
       
   251         }
       
   252     }
       
   253 
       
   254 // ---------------------------------------------------------------------------
       
   255 // CTimeContainer::SetContainerWindowL
       
   256 // ---------------------------------------------------------------------------
       
   257 //
       
   258 void CTimeContainer::SetContainerWindowL(
       
   259         const CCoeControl& aControl )
       
   260     {
       
   261     FUNC_LOG;
       
   262     CCoeControl::SetContainerWindowL ( aControl );
       
   263     iStartTime->SetContainerWindowL ( aControl );
       
   264     iEndTime->SetContainerWindowL ( aControl );
       
   265     }
       
   266 
       
   267 // ---------------------------------------------------------------------------
       
   268 // CTimeContainer::CountComponentControls
       
   269 // ---------------------------------------------------------------------------
       
   270 //
       
   271 TInt CTimeContainer::CountComponentControls() const
       
   272     {
       
   273     FUNC_LOG;
       
   274     TInt count( 0);
       
   275 
       
   276     if ( iStartTime )
       
   277         {
       
   278         ++count;
       
   279         }
       
   280 
       
   281     if ( iSeparator )
       
   282         {
       
   283         ++count;
       
   284         }
       
   285 
       
   286     if ( iEndTime )
       
   287         {
       
   288         ++count;
       
   289         }
       
   290 
       
   291     return count;
   232     return count;
   292     }
   233     }
   293 
   234 
   294 // ---------------------------------------------------------------------------
   235 // ---------------------------------------------------------------------------
   295 // CTimeContainer::ComponentControl
   236 // CESMRTimeField::ComponentControl()
   296 // ---------------------------------------------------------------------------
   237 // ---------------------------------------------------------------------------
   297 //
   238 //
   298 CCoeControl* CTimeContainer::ComponentControl(
   239 CCoeControl* CESMRTimeField::ComponentControl( TInt aIndex ) const
   299         TInt aInd ) const
   240     {
   300     {
   241     switch ( aIndex )
   301     FUNC_LOG;
       
   302     switch ( aInd )
       
   303         {
   242         {
   304         case 0:
   243         case 0:
   305             return iStartTime;
   244             return iFieldIcon;
   306         case 1:
   245         case 1:
   307             return iSeparator;
   246             return iContainer;
   308         case 2:
       
   309             return iEndTime;
       
   310         default:
   247         default:
   311             return NULL;
   248             return NULL;
   312         }
   249         }
   313     }
   250     }
   314 
   251 
   315 
       
   316 // ---------------------------------------------------------------------------
       
   317 // CTimeContainer::PositionChanged()
       
   318 // ---------------------------------------------------------------------------
       
   319 //
       
   320 void CTimeContainer::PositionChanged()
       
   321     {
       
   322     FUNC_LOG;
       
   323     CCoeControl::PositionChanged();
       
   324     if( iStartTimeBgContext )
       
   325         {
       
   326         iStartTimeBgContext->SetFrameRects(
       
   327                 iStartTime->Rect(),
       
   328                 iStartTime->Rect() );
       
   329         }
       
   330 
       
   331     if( iEndTimeBgContext )
       
   332         {
       
   333         iEndTimeBgContext->SetFrameRects(
       
   334                 iEndTime->Rect(),
       
   335                 iEndTime->Rect() );
       
   336         }
       
   337     }
       
   338 
       
   339 // ---------------------------------------------------------------------------
       
   340 // CTimeContainer::SizeChanged
       
   341 // ---------------------------------------------------------------------------
       
   342 //
       
   343 void CTimeContainer::SizeChanged()
       
   344     {
       
   345     FUNC_LOG;
       
   346     TInt x = CESMRLayoutManager::IsMirrored ( ) ? Rect().iBr.iX : Rect().iTl.iX;
       
   347     TPoint p( x, Rect().iTl.iY);
       
   348 
       
   349     TSize editorSize;
       
   350     TSize separatorSize;
       
   351 
       
   352     editorSize = iStartTime->MinimumSize();
       
   353     editorSize.iHeight = Rect().Height();
       
   354 
       
   355     separatorSize = iSeparator->MinimumSize();
       
   356     separatorSize.iHeight = Rect().Height();
       
   357 
       
   358     iStartTime->SetBorder( TGulBorder::ENone );
       
   359     iEndTime->SetBorder( TGulBorder::ENone );
       
   360 
       
   361     if ( CESMRLayoutManager::IsMirrored ( ) )
       
   362         {
       
   363         p.iX -= editorSize.iWidth;
       
   364         iStartTime->SetExtent ( p, editorSize );
       
   365 
       
   366         p.iX -= separatorSize.iWidth;
       
   367         iSeparator->SetExtent ( p, separatorSize );
       
   368 
       
   369         p.iX -= editorSize.iWidth;
       
   370         iEndTime->SetExtent ( p, editorSize );
       
   371         }
       
   372     else
       
   373         {
       
   374         iStartTime->SetExtent ( p, editorSize );
       
   375         p.iX += editorSize.iWidth;
       
   376 
       
   377         iSeparator->SetExtent ( p, separatorSize );
       
   378         p.iX += separatorSize.iWidth;
       
   379 
       
   380         iEndTime->SetExtent ( p, editorSize );
       
   381         }
       
   382     }
       
   383 
       
   384 // ---------------------------------------------------------------------------
       
   385 // CTimeContainer::OfferKeyEventL
       
   386 // ---------------------------------------------------------------------------
       
   387 //
       
   388 TKeyResponse CTimeContainer::OfferKeyEventL(
       
   389         const TKeyEvent& aEvent,
       
   390         TEventCode aType )
       
   391     {
       
   392     FUNC_LOG;
       
   393     TBool startFocusedBefore( iStartTime->IsFocused() );
       
   394     TInt startIndex( iStartTime->CurrentField() );
       
   395 
       
   396     TBool endFocusedBefore( iEndTime->IsFocused() );
       
   397     TInt endIndex( iEndTime->CurrentField() );
       
   398 
       
   399     TKeyResponse response = EKeyWasNotConsumed;
       
   400     if ( aType == EEventKey )
       
   401         {
       
   402         switch ( aEvent.iScanCode )
       
   403             {
       
   404             case EStdKeyLeftArrow:
       
   405                 response = ChangeFocusLeftL( aEvent, aType );
       
   406                 break;
       
   407 
       
   408             case EStdKeyRightArrow:
       
   409                 response = ChangeFocusRightL( aEvent, aType );
       
   410                 break;
       
   411 
       
   412             default: // other events than left/right arrows
       
   413                 {
       
   414                 response = FocusedEditor()->OfferKeyEventL( aEvent, aType );
       
   415                 }
       
   416                 break;
       
   417             }
       
   418         }
       
   419 
       
   420     if ( EKeyWasConsumed == response )
       
   421         {
       
   422         CheckIfValidatingNeededL(
       
   423                 startFocusedBefore,
       
   424                 startIndex,
       
   425                 endFocusedBefore,
       
   426                 endIndex );
       
   427         }
       
   428 
       
   429     return response;
       
   430     }
       
   431 
       
   432 // ---------------------------------------------------------------------------
       
   433 // CTimeContainer::FocusChanged
       
   434 // ---------------------------------------------------------------------------
       
   435 //
       
   436 void CTimeContainer::FocusChanged(
       
   437         TDrawNow /*aDrawNow*/)
       
   438     {
       
   439     FUNC_LOG;
       
   440     if ( IsFocused ( ) ) // if focus is gained
       
   441         {
       
   442         iStartTime->SetFocus ( ETrue );
       
   443         }
       
   444     else
       
   445         {
       
   446         if ( iStartTime->IsFocused() )
       
   447             {
       
   448             iStartTime->SetFocus( EFalse, EDrawNow );
       
   449             }
       
   450 
       
   451         if ( iEndTime->IsFocused() )
       
   452             {
       
   453             iEndTime->SetFocus( EFalse, EDrawNow );
       
   454             }
       
   455         }
       
   456     }
       
   457 
       
   458 // ---------------------------------------------------------------------------
       
   459 // CTimeContainer::SetFont
       
   460 // ---------------------------------------------------------------------------
       
   461 //
       
   462 void CTimeContainer::SetFontL(
       
   463         const CFont* aFont,
       
   464         CESMRLayoutManager* aLayout )
       
   465     {
       
   466     FUNC_LOG;
       
   467     iLayout = aLayout;
       
   468 
       
   469     iStartTime->SetFont ( aFont );
       
   470     iSeparator->SetFont ( aFont );
       
   471     iEndTime->SetFont ( aFont );
       
   472 
       
   473     iStartTime->SetSkinTextColorL( aLayout->NormalTextColorID() );
       
   474     iEndTime->SetSkinTextColorL( aLayout->NormalTextColorID() );
       
   475 
       
   476     AknLayoutUtils::OverrideControlColorL ( *iSeparator, EColorLabelText,
       
   477                                              aLayout->NormalTextColor() );
       
   478     }
       
   479 
       
   480 // ---------------------------------------------------------------------------
       
   481 // CTimeContainer::FocusedEditor
       
   482 // ---------------------------------------------------------------------------
       
   483 //
       
   484 CEikTimeEditor* CTimeContainer::FocusedEditor( )
       
   485     {
       
   486     FUNC_LOG;
       
   487     return iStartTime->IsFocused ( ) ? iStartTime : iEndTime;
       
   488     }
       
   489 
       
   490 // ---------------------------------------------------------------------------
       
   491 // CTimeContainer::OkToLoseFocusL
       
   492 // ---------------------------------------------------------------------------
       
   493 //
       
   494 TBool CTimeContainer::OkToLoseFocusL(
       
   495         TESMREntryFieldId /*aFrom*/,
       
   496         TESMREntryFieldId /*aTo*/ )
       
   497     {
       
   498     FUNC_LOG;
       
   499     // validate the current time
       
   500     FocusedEditor()->PrepareForFocusLossL();
       
   501 
       
   502     if ( iStartTime->IsFocused() )
       
   503         {
       
   504         TriggerStartTimeChangedL();
       
   505         }
       
   506     else
       
   507         {
       
   508         TriggerEndTimeChangedL();
       
   509         }
       
   510 
       
   511     return ETrue;
       
   512     }
       
   513 
       
   514 // ---------------------------------------------------------------------------
       
   515 // CTimeContainer::ActivateL
       
   516 // ---------------------------------------------------------------------------
       
   517 //
       
   518 void CTimeContainer::ActivateL()
       
   519     {
       
   520     FUNC_LOG;
       
   521     CCoeControl::ActivateL();
       
   522     TRect rect(TPoint(iStartTime->Position()), iStartTime->Size());
       
   523     TRect inner(rect);
       
   524     TRect outer(rect);
       
   525 
       
   526     delete iStartTimeBgContext;
       
   527     delete iEndTimeBgContext;
       
   528     iStartTimeBgContext = NULL;
       
   529     iEndTimeBgContext = NULL;
       
   530 
       
   531     iStartTimeBgContext =
       
   532             CAknsFrameBackgroundControlContext::NewL(
       
   533                     KAknsIIDQsnFrInput,
       
   534                     outer,
       
   535                     inner,
       
   536                     EFalse ) ;
       
   537 
       
   538     rect.SetRect( iEndTime->Position(), iEndTime->Size());
       
   539     inner = rect;
       
   540     iEndTimeBgContext =
       
   541             CAknsFrameBackgroundControlContext::NewL(
       
   542                     KAknsIIDQsnFrInput,
       
   543                     outer,
       
   544                     inner,
       
   545                     EFalse ) ;
       
   546 
       
   547     iStartTimeBgContext->SetParentContext( iBackground );
       
   548     iEndTimeBgContext->SetParentContext( iBackground );
       
   549     iStartTime->SetSkinBackgroundControlContextL(iStartTimeBgContext);
       
   550     iEndTime->SetSkinBackgroundControlContextL(iEndTimeBgContext);
       
   551     }
       
   552 
       
   553 // ---------------------------------------------------------------------------
       
   554 // CTimeContainer::ChangeFocusRightL
       
   555 // ---------------------------------------------------------------------------
       
   556 //
       
   557 TKeyResponse CTimeContainer::ChangeFocusRightL(const TKeyEvent& aEvent,
       
   558         TEventCode aType )
       
   559     {
       
   560     FUNC_LOG;
       
   561     TKeyResponse response = EKeyWasNotConsumed;
       
   562 
       
   563     if ( iStartTime->IsFocused ( ) )
       
   564         {
       
   565         // if the focus is in the last field of start time, move focus
       
   566         // to end times first field.
       
   567         TInt current = iStartTime->CurrentField();
       
   568         TInt count = iStartTime->NumFields();
       
   569         if ( current == (count - 1) )
       
   570             {
       
   571             iStartTime->SetFocus( EFalse, EDrawNow );
       
   572             iEndTime->SetFocus( ETrue, EDrawNow );
       
   573             response = EKeyWasConsumed;
       
   574             }
       
   575         else
       
   576             {
       
   577             response = iStartTime->OfferKeyEventL ( aEvent, aType );
       
   578             }
       
   579         TriggerStartTimeChangedL();
       
   580         }
       
   581 
       
   582     else if ( iEndTime->IsFocused ( ) )
       
   583         {
       
   584         if ( iEndTime->CurrentField() == (iEndTime->NumFields() - 1) )
       
   585             {
       
   586             iEndTime->SetFocus ( EFalse, EDrawNow );
       
   587             iStartTime->SetFocus ( ETrue, EDrawNow );
       
   588             response = EKeyWasConsumed;
       
   589             }
       
   590         else
       
   591             {
       
   592             response = iEndTime->OfferKeyEventL ( aEvent, aType );
       
   593             }
       
   594         TriggerEndTimeChangedL();
       
   595         }
       
   596     return response;
       
   597     }
       
   598 
       
   599 // ---------------------------------------------------------------------------
       
   600 // CTimeContainer::ChangeFocusLeftL
       
   601 // ---------------------------------------------------------------------------
       
   602 //
       
   603 TKeyResponse CTimeContainer::ChangeFocusLeftL(
       
   604         const TKeyEvent& aEvent,
       
   605         TEventCode aType )
       
   606     {
       
   607     FUNC_LOG;
       
   608     TKeyResponse response = EKeyWasNotConsumed;
       
   609     if ( iStartTime->IsFocused ( ) )
       
   610         {
       
   611         // if the focus is in the first field of start time, move focus
       
   612         // to end times last field.
       
   613         if ( iStartTime->CurrentField ( )== 0 )
       
   614             {
       
   615             iStartTime->SetFocus ( EFalse, EDrawNow );
       
   616             iEndTime->SetFocus ( ETrue, EDrawNow );
       
   617             // last item should highlighted, API does not export the highlight
       
   618             // function, so emulate key presses
       
   619             response = iEndTime->OfferKeyEventL ( aEvent, aType );
       
   620             }
       
   621         else
       
   622             {
       
   623             response = iStartTime->OfferKeyEventL ( aEvent, aType );
       
   624             }
       
   625         TriggerStartTimeChangedL();
       
   626         }
       
   627 
       
   628     else if ( iEndTime->IsFocused ( ) )
       
   629         {
       
   630         if ( iEndTime->CurrentField ( )== 0 )
       
   631             {
       
   632             iEndTime->SetFocus ( EFalse, EDrawNow );
       
   633             iStartTime->SetFocus ( ETrue, EDrawNow );
       
   634             // last item should highlighted, API does not export the highlight
       
   635             // function, so emulate key presses
       
   636             response = iStartTime->OfferKeyEventL ( aEvent, aType );
       
   637             }
       
   638         else
       
   639             {
       
   640             response = iEndTime->OfferKeyEventL ( aEvent, aType );
       
   641             }
       
   642 
       
   643         TriggerEndTimeChangedL();
       
   644         }
       
   645     return response;
       
   646     }
       
   647 
       
   648 // ---------------------------------------------------------------------------
       
   649 // CTimeContainer::CheckIfValidatingNeededL
       
   650 // ---------------------------------------------------------------------------
       
   651 //
       
   652 void CTimeContainer::CheckIfValidatingNeededL(
       
   653         TBool aStartFocusedBefore,
       
   654         TInt aStartFieldIndex,
       
   655         TBool aEndFocusedBefore,
       
   656         TInt aEndFieldIndex )
       
   657     {
       
   658     FUNC_LOG;
       
   659     TBool startFocusedAfter( iStartTime->IsFocused() );
       
   660     TBool endFocusedAfter( iEndTime->IsFocused() );
       
   661 
       
   662     if ( aStartFocusedBefore != startFocusedAfter )
       
   663         {
       
   664         if ( startFocusedAfter )
       
   665             {
       
   666             TriggerEndTimeChangedL();
       
   667             }
       
   668         else
       
   669             {
       
   670             TriggerStartTimeChangedL();
       
   671             }
       
   672         }
       
   673 
       
   674     else if ( startFocusedAfter &&
       
   675               aStartFocusedBefore == startFocusedAfter )
       
   676         {
       
   677         TInt fieldIndex( iStartTime->CurrentField() );
       
   678         if ( fieldIndex != aStartFieldIndex )
       
   679             {
       
   680             TriggerStartTimeChangedL();
       
   681             }
       
   682         }
       
   683 
       
   684     else if ( endFocusedAfter &&
       
   685               aEndFocusedBefore == endFocusedAfter )
       
   686         {
       
   687         TInt fieldIndex( iEndTime->CurrentField() );
       
   688         if ( fieldIndex != aEndFieldIndex )
       
   689             {
       
   690             TriggerEndTimeChangedL();
       
   691             }
       
   692         }
       
   693     }
       
   694 
       
   695 // ---------------------------------------------------------------------------
       
   696 // CTimeContainer::TriggerStartTimeChangedL
       
   697 // ---------------------------------------------------------------------------
       
   698 //
       
   699 void CTimeContainer::TriggerStartTimeChangedL()
       
   700     {
       
   701     FUNC_LOG;
       
   702     if ( iValidator )
       
   703         {
       
   704         TRAPD( err, iValidator->StartTimeChangedL() );
       
   705         if ( err != KErrNone )
       
   706             {
       
   707             switch ( err )
       
   708                 {
       
   709                 case KErrOverflow:
       
   710                     CESMRGlobalNote::ExecuteL(
       
   711                             CESMRGlobalNote::EESMRRepeatReSchedule );                    
       
   712                     break;
       
   713                 }
       
   714             }
       
   715         }
       
   716     }
       
   717 
       
   718 // ---------------------------------------------------------------------------
       
   719 // CTimeContainer::TriggerEndTimeChangedL
       
   720 // ---------------------------------------------------------------------------
       
   721 //
       
   722 void CTimeContainer::TriggerEndTimeChangedL()
       
   723     {
       
   724     FUNC_LOG;
       
   725     if ( iValidator )
       
   726         {
       
   727         TRAPD( err, iValidator->EndTimeChangedL() );
       
   728         if ( err != KErrNone )
       
   729             {
       
   730             switch ( err )
       
   731                 {
       
   732                 case KErrArgument:
       
   733                     // Assuming that end date is different
       
   734                     // and this is repeating entry
       
   735                     CESMRGlobalNote::ExecuteL(
       
   736                             CESMRGlobalNote::EESMRRepeatDifferentStartAndEndDate );
       
   737                     break;
       
   738                 case KErrOverflow:
       
   739                     CESMRGlobalNote::ExecuteL(
       
   740                             CESMRGlobalNote::EESMRRepeatReSchedule );                    
       
   741                     break;
       
   742                 }
       
   743             }
       
   744         }
       
   745     }
       
   746 
       
   747 // EOF
   252 // EOF
   748 
   253