meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrvieweralarmdatefield.cpp
branchRCL_3
changeset 64 3533d4323edc
equal deleted inserted replaced
63:d189ee25cf9d 64: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 UI Container class
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cesmrvieweralarmdatefield.h"
       
    19 
       
    20 #include "cesmreditor.h"
       
    21 #include "mesmrlistobserver.h"
       
    22 #include "mesmrmeetingrequestentry.h"
       
    23 #include "mesmrcalentry.h"
       
    24 #include "esmrfieldbuilderdef.h"
       
    25 #include "cmrimage.h"
       
    26 #include "cmrlabel.h"
       
    27 #include "nmrlayoutmanager.h"
       
    28 #include "cesmrglobalnote.h"
       
    29 
       
    30 #include <caluser.h>
       
    31 #include <eikenv.h>
       
    32 #include <avkon.rsg>
       
    33 #include <calalarm.h>
       
    34 #include <calentry.h>
       
    35 
       
    36 #include "emailtrace.h"
       
    37 
       
    38 
       
    39 // ======== MEMBER FUNCTIONS ========
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // CESMRViewerAlarmDateField::CESMRViewerAlarmDateField()
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CESMRViewerAlarmDateField::CESMRViewerAlarmDateField()
       
    46     {
       
    47     FUNC_LOG;
       
    48     SetFieldId ( EESMRFieldAlarmDate );
       
    49     SetFocusType( EESMRHighlightFocus );
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // CESMRViewerAlarmDateField::~CESMRViewerAlarmDateField()
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CESMRViewerAlarmDateField::~CESMRViewerAlarmDateField()
       
    57     {
       
    58     FUNC_LOG;
       
    59     delete iIcon;
       
    60     delete iLockIcon;
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CESMRViewerAlarmDateField::NewL()
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CESMRViewerAlarmDateField* CESMRViewerAlarmDateField::NewL()
       
    68     {
       
    69     CESMRViewerAlarmDateField* self = new (ELeave) CESMRViewerAlarmDateField();
       
    70     CleanupStack::PushL( self );
       
    71     self->ConstructL();
       
    72     CleanupStack::Pop( self );
       
    73     return self;
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // CESMRViewerAlarmDateField::ConstructL()
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 void CESMRViewerAlarmDateField::ConstructL()
       
    81     {
       
    82     FUNC_LOG;
       
    83     iLabel = CMRLabel::NewL( this );
       
    84     CESMRField::ConstructL( iLabel ); // ownership transfered
       
    85 
       
    86     iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapDateStart, this );
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // CESMRViewerAlarmDateField::InternalizeL()
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 void CESMRViewerAlarmDateField::InternalizeL( MESMRCalEntry& aEntry )
       
    94     {
       
    95     MESMRCalEntry::TESMRAlarmType alarmType;
       
    96     aEntry.GetAlarmL( alarmType, iAlarmTime );
       
    97 
       
    98     if( alarmType == MESMRCalEntry::EESMRAlarmAbsolute )
       
    99         {
       
   100         FormatAlarmTimeL();
       
   101         }
       
   102     else // Remove the alarm fields
       
   103         {
       
   104         CCoeControl::MakeVisible(EFalse);
       
   105         iObserver->HideControl( EESMRFieldAlarmDate );
       
   106         }
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CESMRViewerAlarmDateField::SizeChanged()
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void CESMRViewerAlarmDateField::SizeChanged()
       
   114     {
       
   115     FUNC_LOG;
       
   116     TRect rect = Rect();
       
   117     TAknLayoutRect rowLayoutRect =
       
   118         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
       
   119     rect = rowLayoutRect.Rect();
       
   120 
       
   121     TAknWindowComponentLayout iconLayout =
       
   122         NMRLayoutManager::GetWindowComponentLayout(
       
   123                 NMRLayoutManager::EMRLayoutTextEditorIcon );
       
   124     AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
       
   125 
       
   126     // Layouting lock icon
       
   127     if( iLockIcon )
       
   128         {
       
   129         TAknWindowComponentLayout iconLayout(
       
   130                 NMRLayoutManager::GetWindowComponentLayout(
       
   131                     NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
       
   132         AknLayoutUtils::LayoutImage( iLockIcon, rect, iconLayout );
       
   133         }
       
   134 
       
   135     // Layouting label
       
   136     TAknTextComponentLayout viewerLayoutText;
       
   137 
       
   138     if( iLockIcon )
       
   139     	{
       
   140     	viewerLayoutText = NMRLayoutManager::GetTextComponentLayout(
       
   141     	        NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
       
   142     	}
       
   143     else
       
   144     	{
       
   145     	viewerLayoutText = NMRLayoutManager::GetTextComponentLayout(
       
   146     	        NMRLayoutManager::EMRTextLayoutTextEditor );
       
   147     	}
       
   148 
       
   149     AknLayoutUtils::LayoutLabel( iLabel, rect, viewerLayoutText );
       
   150     TRect viewerRect( iLabel->Rect() );
       
   151 
       
   152     // Move focus rect so that it's relative to field's position.
       
   153     viewerRect.Move( -Position() );
       
   154     SetFocusRect( viewerRect );
       
   155     }
       
   156 
       
   157 // ---------------------------------------------------------------------------
       
   158 // CESMRViewerAlarmDateField::CountComponentControls()
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 TInt CESMRViewerAlarmDateField::CountComponentControls() const
       
   162     {
       
   163     FUNC_LOG;
       
   164     TInt count( 0 );
       
   165     if ( iIcon )
       
   166         {
       
   167         ++count;
       
   168         }
       
   169 
       
   170     if ( iLabel )
       
   171         {
       
   172         ++count;
       
   173         }
       
   174 
       
   175     if ( iLockIcon )
       
   176     	{
       
   177     	++count;
       
   178     	}
       
   179 
       
   180     return count;
       
   181     }
       
   182 
       
   183 // ---------------------------------------------------------------------------
       
   184 // CESMRViewerAlarmDateField::ComponentControl()
       
   185 // ---------------------------------------------------------------------------
       
   186 //
       
   187 CCoeControl* CESMRViewerAlarmDateField::ComponentControl( TInt aIndex ) const
       
   188     {
       
   189     FUNC_LOG;
       
   190     switch ( aIndex )
       
   191         {
       
   192         case 0:
       
   193             return iIcon;
       
   194         case 1:
       
   195             return iLabel;
       
   196         case 2:
       
   197         	return iLockIcon;
       
   198         default:
       
   199             return NULL;
       
   200         }
       
   201     }
       
   202 
       
   203 // ---------------------------------------------------------------------------
       
   204 // CESMRViewerAlarmDateField::SetOutlineFocusL()
       
   205 // ---------------------------------------------------------------------------
       
   206 //
       
   207 void CESMRViewerAlarmDateField::SetOutlineFocusL( TBool aFocus )
       
   208     {
       
   209     FUNC_LOG;
       
   210     CESMRField::SetOutlineFocusL ( aFocus );
       
   211 
       
   212     iLabel->SetFocus( aFocus );
       
   213     }
       
   214 
       
   215 // ---------------------------------------------------------------------------
       
   216 // CESMRViewerAlarmDateField::ExecuteGenericCommandL()
       
   217 // ---------------------------------------------------------------------------
       
   218 //
       
   219 TBool CESMRViewerAlarmDateField::ExecuteGenericCommandL( TInt aCommand )
       
   220     {
       
   221     FUNC_LOG;
       
   222 
       
   223     TBool retValue( EFalse );
       
   224 
       
   225     if( (aCommand == EAknCmdOpen) && IsLocked()  )
       
   226     	{
       
   227 		HandleTactileFeedbackL();
       
   228 
       
   229     	CESMRGlobalNote::ExecuteL(
       
   230     	                    CESMRGlobalNote::EESMRUnableToEdit );
       
   231     	retValue = ETrue;
       
   232     	}
       
   233 
       
   234     if ( EMRCmdDoEnvironmentChange == aCommand )
       
   235         {
       
   236         FormatAlarmTimeL();
       
   237         retValue = ETrue;
       
   238         }
       
   239 
       
   240     return retValue;
       
   241     }
       
   242 
       
   243 // ---------------------------------------------------------------------------
       
   244 // CESMRViewerAlarmDateField::LockL()
       
   245 // ---------------------------------------------------------------------------
       
   246 //
       
   247 void CESMRViewerAlarmDateField::LockL()
       
   248 	{
       
   249 	FUNC_LOG;
       
   250 	if( IsLocked() )
       
   251 		{
       
   252 		return;
       
   253 		}
       
   254 
       
   255 	CESMRField::LockL();
       
   256 
       
   257 	delete iLockIcon;
       
   258 	iLockIcon = NULL;
       
   259 	iLockIcon = CMRImage::NewL(
       
   260 	        NMRBitmapManager::EMRBitmapLockField,
       
   261 	        this,
       
   262 	        ETrue );
       
   263 	}
       
   264 
       
   265 // ---------------------------------------------------------------------------
       
   266 // CESMRViewerAlarmDateField::FormatAlarmTimeL()
       
   267 // ---------------------------------------------------------------------------
       
   268 //
       
   269 void CESMRViewerAlarmDateField::FormatAlarmTimeL()
       
   270     {
       
   271     FUNC_LOG;
       
   272 
       
   273     // Read format string from AVKON resource
       
   274     HBufC* dateFormatString = iEikonEnv->AllocReadResourceLC(
       
   275             R_QTN_DATE_USUAL_WITH_ZERO );
       
   276     HBufC* buf = HBufC::NewLC( KBufferLength );
       
   277     TPtr ptr( buf->Des() );
       
   278 
       
   279     iAlarmTime.FormatL( ptr, *dateFormatString );
       
   280     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr );
       
   281     iLabel->SetTextL( *buf );
       
   282 
       
   283     CleanupStack::PopAndDestroy( 2, dateFormatString );
       
   284     }
       
   285 
       
   286 
       
   287 // EOF