meetingrequest/mrgui/mrfieldbuildercommon/src/cesmrviewerlabelfield.cpp
branchRCL_3
changeset 16 4ce476e64c59
parent 13 0396474f30f5
child 17 8592a65ad3fb
equal deleted inserted replaced
13:0396474f30f5 16:4ce476e64c59
     1 /*
       
     2 * Copyright (c) 2007-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:  Base class for most of the fields in viewer
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include <eiklabel.h>
       
    21 #include <caluser.h>
       
    22 #include <calalarm.h>
       
    23 #include <avkon.rsg>
       
    24 #include <calentry.h>
       
    25 #include <eikenv.h>
       
    26 #include <eikedwin.h>
       
    27 #include <StringLoader.h>
       
    28 #include <avkon.hrh>
       
    29 #include <AknUtils.h>
       
    30 
       
    31 #include <esmrgui.rsg>
       
    32 //<cmail>
       
    33 #include "esmrdef.h"
       
    34 //</cmail>
       
    35 #include "cesmrviewerlabelfield.h"
       
    36 #include "cesmreditor.h"
       
    37 #include "mesmrlistobserver.h"
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // CESMRViewerLabelField::NewL
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 EXPORT_C CESMRViewerLabelField* CESMRViewerLabelField::NewL()
       
    44     {
       
    45     FUNC_LOG;
       
    46     CESMRViewerLabelField* self = new (ELeave) CESMRViewerLabelField();
       
    47     CleanupStack::PushL( self );
       
    48     CleanupStack::Pop( self );
       
    49     return self;
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // CESMRViewerLabelField::~CESMRViewerLabelField
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 EXPORT_C CESMRViewerLabelField::~CESMRViewerLabelField()
       
    57     {
       
    58     FUNC_LOG;
       
    59     // Do nothing
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CESMRViewerLabelField::CESMRViewerLabelField
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 EXPORT_C CESMRViewerLabelField::CESMRViewerLabelField()
       
    67     {
       
    68     FUNC_LOG;
       
    69     // Do nothing
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CESMRViewerLabelField::InitializeL
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 EXPORT_C void CESMRViewerLabelField::InitializeL()
       
    77     {
       
    78     FUNC_LOG;
       
    79     iLabel->SetFont( iLayout->Font( iCoeEnv, iFieldId ));
       
    80 
       
    81     if( CESMRLayoutManager::IsMirrored() )
       
    82         {
       
    83         iLabel->iMargin.iRight = iLayout->TextSideMargin();
       
    84         }
       
    85     else
       
    86         {
       
    87         iLabel->iMargin.iLeft = iLayout->TextSideMargin();
       
    88         }
       
    89 
       
    90     // Set the text color.
       
    91     if ( IsFocused() )
       
    92         {
       
    93         AknLayoutUtils::OverrideControlColorL( *iLabel, EColorLabelText,
       
    94                                                 iLayout->ViewerListAreaHighlightedTextColor() );
       
    95         }
       
    96     else
       
    97         {
       
    98         AknLayoutUtils::OverrideControlColorL( *iLabel, EColorLabelText,
       
    99                                                 iLayout->ViewerListAreaTextColor() );
       
   100         }
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CESMRViewerLabelField::ConstructL
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 EXPORT_C void CESMRViewerLabelField::ConstructL( TAknsItemID aIconID )
       
   108     {
       
   109     FUNC_LOG;
       
   110     // If field id is not specified, make this field a "basic" field:
       
   111     // Basic field can't be hidden from the list.
       
   112     if( iFieldId == 0 )
       
   113         {
       
   114         SetFieldId( EESMRFieldViewerBasic );
       
   115         }
       
   116 
       
   117     iLabel = new (ELeave) CEikLabel();
       
   118     iLabel->SetLabelAlignment(CESMRLayoutManager::IsMirrored() ?
       
   119         ELayoutAlignRight :
       
   120         ELayoutAlignLeft );
       
   121 
       
   122     _LIT( KEmptyText, "" );
       
   123     iLabel->SetTextL( KEmptyText );
       
   124     CESMRIconField::ConstructL( aIconID, iLabel, EESMRHighlightFocus );
       
   125     }
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // CESMRViewerLabelField::FocusChanged
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 EXPORT_C void CESMRViewerLabelField::FocusChanged( TDrawNow /*aDrawNow*/ )
       
   132     {
       
   133     FUNC_LOG;
       
   134     // Focus received
       
   135     if ( IsFocused() )
       
   136         {
       
   137         // If function leaves we continue w/o changing the color
       
   138         TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( 
       
   139         		*iLabel, EColorLabelText,
       
   140                  iLayout->ViewerListAreaHighlightedTextColor() ) );
       
   141         DrawDeferred();
       
   142         }
       
   143     else
       
   144         {
       
   145         // If function leaves we continue w/o changing the color
       
   146         TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( 
       
   147         		*iLabel, EColorLabelText,
       
   148                      iLayout->ViewerListAreaTextColor() ) );
       
   149         DrawDeferred();
       
   150         }
       
   151     }
       
   152 
       
   153 // EOF
       
   154