meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrtimefield.cpp
branchRCL_3
changeset 25 3533d4323edc
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 2009 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:  ESMR time (start-end) field implementation
       
    15  *
       
    16 */
       
    17 
       
    18 #include "cesmrtimefield.h"
       
    19 #include "cmrtimecontainer.h"
       
    20 //<cmail>
       
    21 #include "esmrdef.h"
       
    22 //</cmail>
       
    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
       
    33 
       
    34 // ======== MEMBER FUNCTIONS ========
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // CESMRTimeField::CESMRTimeField
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 CESMRTimeField::CESMRTimeField( )
       
    41     {
       
    42     FUNC_LOG;
       
    43     SetFieldId ( EESMRFieldMeetingTime );
       
    44     SetFocusType( EESMRHighlightFocus );
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CESMRTimeField::~CESMRTimeField
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CESMRTimeField::~CESMRTimeField( )
       
    52     {
       
    53     FUNC_LOG;
       
    54     // iContainer is deleted by framework
       
    55     delete iFieldIcon;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CESMRTimeField::NewL
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CESMRTimeField* CESMRTimeField::NewL(
       
    63         MESMRFieldValidator* aValidator )
       
    64     {
       
    65     FUNC_LOG;
       
    66     CESMRTimeField* self = new (ELeave) CESMRTimeField;
       
    67     CleanupStack::PushL ( self );
       
    68     self->ConstructL ( aValidator );
       
    69     CleanupStack::Pop ( self );
       
    70     return self;
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CESMRTimeField::ConstructL
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 void CESMRTimeField::ConstructL(
       
    78         MESMRFieldValidator* aValidator )
       
    79     {
       
    80     FUNC_LOG;
       
    81     CCoeControl::SetComponentsToInheritVisibility( ETrue );
       
    82     iContainer =
       
    83             CMRTimeContainer::NewL(
       
    84                     aValidator,
       
    85                     this,
       
    86                     EESMRFieldMeetingTime );
       
    87     // This is taking ownership
       
    88     CESMRField::ConstructL( iContainer );
       
    89 
       
    90     iFieldIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapClock );
       
    91     iFieldIcon->SetParent( this );
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // CESMRTimeField::SetContainerWindowL
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CESMRTimeField::SetContainerWindowL(
       
    99         const CCoeControl& aControl )
       
   100     {
       
   101     FUNC_LOG;
       
   102     CCoeControl::SetContainerWindowL ( aControl );
       
   103     if ( iContainer )
       
   104         {
       
   105         iContainer->SetContainerWindowL ( aControl );
       
   106         iContainer->SetParent( this );
       
   107         }
       
   108     if ( iFieldIcon )
       
   109         {
       
   110         iFieldIcon->SetContainerWindowL( aControl );
       
   111         iFieldIcon->SetParent( this );
       
   112         }
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // CESMRTimeField::OfferKeyEventL
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 TKeyResponse CESMRTimeField::OfferKeyEventL(
       
   120         const TKeyEvent& aEvent,
       
   121         TEventCode aType )
       
   122     {
       
   123     FUNC_LOG;
       
   124     TKeyResponse response( EKeyWasNotConsumed);
       
   125     if ( iContainer )
       
   126         {
       
   127         response = iContainer->OfferKeyEventL ( aEvent, aType );
       
   128         }
       
   129     return response;
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // CESMRTimeField::OkToLoseFocusL
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 TBool CESMRTimeField::OkToLoseFocusL(
       
   137         TESMREntryFieldId aNext )
       
   138     {
       
   139     FUNC_LOG;
       
   140     if ( iContainer )
       
   141         {
       
   142         return iContainer->OkToLoseFocusL ( FieldId ( ), aNext );
       
   143         }
       
   144     return EFalse;
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // CESMRTimeField::SetOutlineFocusL
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 void CESMRTimeField::SetOutlineFocusL( TBool aFocus )
       
   152     {
       
   153     FUNC_LOG;
       
   154     CESMRField::SetOutlineFocusL ( aFocus );
       
   155     if ( aFocus )
       
   156         {
       
   157         ChangeMiddleSoftKeyL(EESMRCmdSaveMR,R_QTN_MSK_SAVE);
       
   158         }
       
   159     }
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // CESMRTimeField::SetValidatorL
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 void CESMRTimeField::SetValidatorL( MESMRFieldValidator* aValidator )
       
   166     {
       
   167     FUNC_LOG;
       
   168     
       
   169     // Update iValidator member
       
   170     CESMRField::SetValidatorL( aValidator );
       
   171     
       
   172     if ( iContainer )
       
   173         {
       
   174         iContainer->SetValidatorL( iValidator );
       
   175         }
       
   176     }
       
   177 
       
   178 // ---------------------------------------------------------------------------
       
   179 // CESMRTimeField::SizeChanged()
       
   180 // ---------------------------------------------------------------------------
       
   181 //
       
   182 TBool CESMRTimeField::ExecuteGenericCommandL( TInt aCommand )
       
   183     {
       
   184     FUNC_LOG;
       
   185     
       
   186     TBool retValue( EFalse );
       
   187     
       
   188     if ( iContainer && EMRCmdDoEnvironmentChange == aCommand )
       
   189         {
       
   190         iContainer->EnvironmentChangedL();
       
   191         SizeChanged();
       
   192         DrawDeferred();
       
   193     
       
   194         retValue = ETrue;
       
   195         }
       
   196     
       
   197     return retValue;
       
   198     }
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // CESMRTimeField::SizeChanged()
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 void CESMRTimeField::SizeChanged()
       
   205     {
       
   206     TRect rect( Rect() );
       
   207     TAknLayoutRect iconLayout = 
       
   208         NMRLayoutManager::GetLayoutRect( 
       
   209                 rect, NMRLayoutManager::EMRLayoutTimeEditorIcon );
       
   210     TRect iconRect( iconLayout.Rect() );
       
   211     iFieldIcon->SetRect( iconRect );
       
   212     
       
   213     TAknLayoutRect bgLayoutRect = 
       
   214         NMRLayoutManager::GetLayoutRect( 
       
   215                 rect, NMRLayoutManager::EMRLayoutTextEditorBg );
       
   216     TRect bgRect( bgLayoutRect.Rect() );
       
   217     // Move focus rect so that it's relative to field's position.
       
   218     bgRect.Move( -Position() );
       
   219     SetFocusRect( bgRect );
       
   220     
       
   221     iContainer->SetRect( rect );    
       
   222     iContainer->SetBgRect( bgRect );
       
   223     }
       
   224 
       
   225 // ---------------------------------------------------------------------------
       
   226 // CESMRTimeField::CountComponentControls()
       
   227 // ---------------------------------------------------------------------------
       
   228 //
       
   229 TInt CESMRTimeField::CountComponentControls() const
       
   230     {
       
   231     TInt count( KFieldComponentCount );
       
   232     return count;
       
   233     }
       
   234 
       
   235 // ---------------------------------------------------------------------------
       
   236 // CESMRTimeField::ComponentControl()
       
   237 // ---------------------------------------------------------------------------
       
   238 //
       
   239 CCoeControl* CESMRTimeField::ComponentControl( TInt aIndex ) const
       
   240     {
       
   241     switch ( aIndex )
       
   242         {
       
   243         case 0:
       
   244             return iFieldIcon;
       
   245         case 1:
       
   246             return iContainer;
       
   247         default:
       
   248             return NULL;
       
   249         }
       
   250     }
       
   251 
       
   252 // EOF
       
   253