meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrvieweralarmfield.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".
    18 #include "cesmrvieweralarmfield.h"
    18 #include "cesmrvieweralarmfield.h"
    19 #include "cesmreditor.h"
    19 #include "cesmreditor.h"
    20 #include "cmrlabel.h"
    20 #include "cmrlabel.h"
    21 #include "cmrimage.h"
    21 #include "cmrimage.h"
    22 #include "nmrlayoutmanager.h"
    22 #include "nmrlayoutmanager.h"
       
    23 #include "mesmrlistobserver.h"
       
    24 #include "cesmrglobalnote.h"
    23 
    25 
    24 #include <caluser.h>
    26 #include <caluser.h>
    25 #include <calalarm.h>
    27 #include <calalarm.h>
    26 #include <calentry.h>
    28 #include <calentry.h>
    27 #include <StringLoader.h>
    29 #include <stringloader.h>
    28 #include <AknLayout2ScalableDef.h>
    30 #include <aknlayout2scalabledef.h>
    29 #include <esmrgui.rsg>
    31 #include <esmrgui.rsg>
    30 
    32 
    31 // DEBUG
    33 // DEBUG
    32 #include "emailtrace.h"
    34 #include "emailtrace.h"
    33 
    35 
    61 //
    63 //
    62 CESMRViewerAlarmField::~CESMRViewerAlarmField()
    64 CESMRViewerAlarmField::~CESMRViewerAlarmField()
    63     {
    65     {
    64     FUNC_LOG;
    66     FUNC_LOG;
    65     delete iIcon;
    67     delete iIcon;
    66     delete iLabel;
    68     delete iLockIcon;
    67     }
    69     }
    68 
    70 
    69 // ---------------------------------------------------------------------------
    71 // ---------------------------------------------------------------------------
    70 // CESMRViewerAlarmField::CESMRViewerAlarmField()
    72 // CESMRViewerAlarmField::CESMRViewerAlarmField()
    71 // ---------------------------------------------------------------------------
    73 // ---------------------------------------------------------------------------
    72 //
    74 //
    73 CESMRViewerAlarmField::CESMRViewerAlarmField()
    75 CESMRViewerAlarmField::CESMRViewerAlarmField()
    74     {
    76     {
    75     FUNC_LOG;
    77     FUNC_LOG;
    76     SetFieldId ( EESMRFieldAlarm );
    78     SetFieldId ( EESMRFieldAlarm );
       
    79     SetFocusType( EESMRHighlightFocus );
    77     }
    80     }
    78 
    81 
    79 // ---------------------------------------------------------------------------
    82 // ---------------------------------------------------------------------------
    80 // CESMRViewerAlarmField::ConstructL()
    83 // CESMRViewerAlarmField::ConstructL()
    81 // ---------------------------------------------------------------------------
    84 // ---------------------------------------------------------------------------
    83 void CESMRViewerAlarmField::ConstructL()
    86 void CESMRViewerAlarmField::ConstructL()
    84     {
    87     {
    85     FUNC_LOG;
    88     FUNC_LOG;
    86     iLabel = CMRLabel::NewL();
    89     iLabel = CMRLabel::NewL();
    87     iLabel->SetParent( this );
    90     iLabel->SetParent( this );
    88     iIcon = CMRImage::NewL( KAknsIIDQgnMeetReqIndiAlarm );
    91     CESMRField::ConstructL( iLabel ); // ownership transfered
       
    92 
       
    93     iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapAlarm );
    89     iIcon->SetParent( this );
    94     iIcon->SetParent( this );
    90     
       
    91     SetFocusType( EESMRHighlightFocus );
       
    92     }
    95     }
    93 
    96 
    94 // ---------------------------------------------------------------------------
    97 // ---------------------------------------------------------------------------
    95 // CESMRViewerAlarmField::InternalizeL()
    98 // CESMRViewerAlarmField::InternalizeL()
    96 // ---------------------------------------------------------------------------
    99 // ---------------------------------------------------------------------------
    98 void CESMRViewerAlarmField::InternalizeL( MESMRCalEntry& aEntry )
   101 void CESMRViewerAlarmField::InternalizeL( MESMRCalEntry& aEntry )
    99     {
   102     {
   100     FUNC_LOG;
   103     FUNC_LOG;
   101     if ( aEntry.IsAllDayEventL() )
   104     if ( aEntry.IsAllDayEventL() )
   102         {
   105         {
   103         iObserver->RemoveControl( FieldId() );
   106         iObserver->HideControl( FieldId() );
   104         }
   107         }
   105     else
   108     else
   106         {
   109         {
   107         CCalAlarm* alarm = aEntry.Entry().AlarmL();
   110         CCalAlarm* alarm = aEntry.Entry().AlarmL();
   108         TInt minutes(0);
   111         TInt minutes(0);
   113             delete alarm;
   116             delete alarm;
   114             alarm = NULL;
   117             alarm = NULL;
   115             }
   118             }
   116         else
   119         else
   117             {
   120             {
   118             stringholder = StringLoader::LoadLC( 
   121             stringholder = StringLoader::LoadLC(
   119                     R_QTN_MEET_REQ_ALARM_OFF , iEikonEnv );
   122                     R_QTN_MEET_REQ_ALARM_OFF , iEikonEnv );
   120             iLabel->SetTextL( *stringholder );
   123             iLabel->SetTextL( *stringholder );
   121             CleanupStack::PopAndDestroy( stringholder );
   124             CleanupStack::PopAndDestroy( stringholder );
   122             return;
   125             return;
   123             }
   126             }
   127 
   130 
   128         // Alarm is one hour before
   131         // Alarm is one hour before
   129         if( minutes == KHourInMinutes )
   132         if( minutes == KHourInMinutes )
   130             {
   133             {
   131             timeUnits = minutes / KHourInMinutes;
   134             timeUnits = minutes / KHourInMinutes;
   132             stringholder = StringLoader::LoadLC( 
   135             stringholder = StringLoader::LoadLC(
   133                     R_QTN_MEET_REQ_ALARM_HOUR , timeUnits, iEikonEnv );
   136                     R_QTN_MEET_REQ_ALARM_HOUR , timeUnits, iEikonEnv );
   134             }
   137             }
   135         // Alarm time is more than one hour and less than one day before
   138         // Alarm time is more than one hour and less than one day before
   136         else if( minutes > KHourInMinutes && minutes < KDayInMinutes )
   139         else if( minutes > KHourInMinutes && minutes < KDayInMinutes )
   137             {
   140             {
   138             timeUnits = minutes / KHourInMinutes;
   141             timeUnits = minutes / KHourInMinutes;
   139             stringholder = StringLoader::LoadLC( 
   142             stringholder = StringLoader::LoadLC(
   140                     R_QTN_MEET_REQ_ALARM_HOURS , timeUnits, iEikonEnv );
   143                     R_QTN_MEET_REQ_ALARM_HOURS , timeUnits, iEikonEnv );
   141             }
   144             }
   142         // Alarm is several days before // 
   145         // Alarm is several days before //
   143         else if( minutes >= KDayInMinutes )
   146         else if( minutes >= KDayInMinutes )
   144             {
   147             {
   145             timeUnits = minutes / KDayInMinutes;
   148             timeUnits = minutes / KDayInMinutes;
   146             stringholder = StringLoader::LoadLC( 
   149             stringholder = StringLoader::LoadLC(
   147                     R_QTN_MEET_REQ_ALARM_DAYS , timeUnits, iEikonEnv );
   150                     R_QTN_MEET_REQ_ALARM_DAYS , timeUnits, iEikonEnv );
   148             }
   151             }
   149         // Alarm is minutes before // 
   152         // Alarm is minutes before //
   150         else
   153         else
   151             {
   154             {
   152             stringholder = StringLoader::LoadLC( 
   155             stringholder = StringLoader::LoadLC(
   153                     R_QTN_MEET_REQ_ALARM_MINUTES , minutes, iEikonEnv );
   156                     R_QTN_MEET_REQ_ALARM_MINUTES , minutes, iEikonEnv );
   154             }
   157             }
   155 
   158 
   156         iLabel->SetTextL( *stringholder );
   159         iLabel->SetTextL( *stringholder );
   157         CleanupStack::PopAndDestroy( stringholder );
   160         CleanupStack::PopAndDestroy( stringholder );
   163 // ---------------------------------------------------------------------------
   166 // ---------------------------------------------------------------------------
   164 //
   167 //
   165 void CESMRViewerAlarmField::InitializeL()
   168 void CESMRViewerAlarmField::InitializeL()
   166     {
   169     {
   167     FUNC_LOG;
   170     FUNC_LOG;
   168     TAknLayoutText text = NMRLayoutManager::GetLayoutText( 
   171     TAknLayoutText text = NMRLayoutManager::GetLayoutText(
   169             Rect(), 
   172             Rect(),
   170             NMRLayoutManager::EMRTextLayoutTextEditor );
   173             NMRLayoutManager::EMRTextLayoutTextEditor );
   171     
   174 
   172     iLabel->SetFont( text.Font() );
   175     iLabel->SetFont( text.Font() );
   173     // This is called so that theme changes will apply when changing theme "on the fly"
   176     // This is called so that theme changes will apply when changing theme "on the fly"
   174     if ( IsFocused() )
   177     if ( IsFocused() )
   175         {
   178         {
   176         iLabel->FocusChanged( EDrawNow );
   179         iLabel->FocusChanged( EDrawNow );
   177         }
   180         }
   178 
   181     // No implementation yet
   179     AknLayoutUtils::OverrideControlColorL ( *iLabel, EColorLabelText,
       
   180                                              KRgbBlack );
       
   181     }
   182     }
   182 
   183 
   183 // ---------------------------------------------------------------------------
   184 // ---------------------------------------------------------------------------
   184 // CESMRViewerAlarmField::SizeChanged()
   185 // CESMRViewerAlarmField::SizeChanged()
   185 // ---------------------------------------------------------------------------
   186 // ---------------------------------------------------------------------------
   189     FUNC_LOG;
   190     FUNC_LOG;
   190     TRect rect = Rect();
   191     TRect rect = Rect();
   191     TAknLayoutRect rowLayoutRect =
   192     TAknLayoutRect rowLayoutRect =
   192         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
   193         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
   193     rect = rowLayoutRect.Rect();
   194     rect = rowLayoutRect.Rect();
   194     
   195 
   195     TAknWindowComponentLayout iconLayout =
   196     TAknWindowComponentLayout iconLayout =
   196         NMRLayoutManager::GetWindowComponentLayout( 
   197         NMRLayoutManager::GetWindowComponentLayout(
   197                 NMRLayoutManager::EMRLayoutTextEditorIcon );
   198                 NMRLayoutManager::EMRLayoutTextEditorIcon );
   198     AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
   199     AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
   199     
   200   
   200     TAknLayoutRect bgLayoutRect =
   201     // Layouting lock icon
   201         NMRLayoutManager::GetLayoutRect( 
   202     if( iLockIcon )
   202                 rect, NMRLayoutManager::EMRLayoutTextEditorBg );
   203     	{
   203     TRect bgRect( bgLayoutRect.Rect() );
   204     	TAknWindowComponentLayout iconLayout( 
       
   205     			NMRLayoutManager::GetWindowComponentLayout( 
       
   206     					NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
       
   207     	AknLayoutUtils::LayoutImage( iLockIcon, rect, iconLayout );
       
   208     	}
       
   209 
       
   210     // Layouting label
       
   211     TAknLayoutText viewerLayoutText;
       
   212     if( iLockIcon )
       
   213     	{
       
   214     	viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, 
       
   215     			NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
       
   216     	}
       
   217     else
       
   218     	{
       
   219     	viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, 
       
   220     			NMRLayoutManager::EMRTextLayoutTextEditor );
       
   221     	}
       
   222 
       
   223     TRect viewerRect( viewerLayoutText.TextRect() );    
       
   224     iLabel->SetRect( viewerRect );
       
   225 
   204     // Move focus rect so that it's relative to field's position.
   226     // Move focus rect so that it's relative to field's position.
   205     bgRect.Move( -Position() );
   227     viewerRect.Move( -Position() );
   206     SetFocusRect( bgRect );
   228     SetFocusRect( viewerRect );
   207     
   229 
   208     TAknLayoutText labelLayout = 
   230     // Setting font also for the label
   209         NMRLayoutManager::GetLayoutText( 
   231     iLabel->SetFont( viewerLayoutText.Font() );
   210                 rect, NMRLayoutManager::EMRTextLayoutTextEditor );
       
   211     iLabel->SetRect( labelLayout.TextRect() );
       
   212     }
   232     }
   213 
   233 
   214 // ---------------------------------------------------------------------------
   234 // ---------------------------------------------------------------------------
   215 // CESMRViewerAlarmField::CountComponentControls()
   235 // CESMRViewerAlarmField::CountComponentControls()
   216 // ---------------------------------------------------------------------------
   236 // ---------------------------------------------------------------------------
   226 
   246 
   227     if ( iLabel )
   247     if ( iLabel )
   228         {
   248         {
   229         ++count;
   249         ++count;
   230         }
   250         }
       
   251     
       
   252     if ( iLockIcon )
       
   253     	{
       
   254     	++count;
       
   255     	}
   231     return count;
   256     return count;
   232     }
   257     }
   233 
   258 
   234 // ---------------------------------------------------------------------------
   259 // ---------------------------------------------------------------------------
   235 // CESMRViewerAlarmField::ComponentControl()
   260 // CESMRViewerAlarmField::ComponentControl()
   242         {
   267         {
   243         case 0:
   268         case 0:
   244             return iIcon;
   269             return iIcon;
   245         case 1:
   270         case 1:
   246             return iLabel;
   271             return iLabel;
       
   272         case 2:
       
   273         	return iLockIcon;
   247         default:
   274         default:
   248             return NULL;
   275             return NULL;
   249         }
   276         }
   250     }
   277     }
   251 
   278 
   255 //
   282 //
   256 void CESMRViewerAlarmField::SetOutlineFocusL( TBool aFocus )
   283 void CESMRViewerAlarmField::SetOutlineFocusL( TBool aFocus )
   257     {
   284     {
   258     FUNC_LOG;
   285     FUNC_LOG;
   259     CESMRField::SetOutlineFocusL ( aFocus );
   286     CESMRField::SetOutlineFocusL ( aFocus );
       
   287 
       
   288     iLabel->SetFocus( aFocus );
       
   289     }
       
   290 
       
   291 // ---------------------------------------------------------------------------
       
   292 // CESMRViewerAlarmField::LockL()
       
   293 // ---------------------------------------------------------------------------
       
   294 //
       
   295 void CESMRViewerAlarmField::LockL()
       
   296 	{
       
   297 	FUNC_LOG;
       
   298 	if( IsLocked() )
       
   299 		{
       
   300 		return;
       
   301 		}
       
   302 	
       
   303 	CESMRField::LockL();
       
   304 	
       
   305 	delete iLockIcon;
       
   306 	iLockIcon = NULL;
       
   307 	iLockIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapLockField, ETrue );
       
   308 	iLockIcon->SetParent( this );
       
   309 	}
       
   310 
       
   311 // ---------------------------------------------------------------------------
       
   312 // CESMRViewerAlarmField::ExecuteGenericCommandL()
       
   313 // ---------------------------------------------------------------------------
       
   314 //
       
   315 TBool CESMRViewerAlarmField::ExecuteGenericCommandL( TInt aCommand )
       
   316 	{
       
   317     FUNC_LOG;
   260     
   318     
   261     iLabel->SetFocus( aFocus );    
   319     TBool retValue( EFalse );
   262 
   320     
   263     if ( !aFocus )
   321     if( (aCommand == EAknCmdOpen) && IsLocked()  )
   264         {
   322     	{
   265         AknLayoutUtils::OverrideControlColorL ( *iLabel, EColorLabelText,
   323 		HandleTactileFeedbackL();
   266                                                  KRgbBlack );
   324 		
   267         }
   325     	CESMRGlobalNote::ExecuteL(
   268     }
   326     			CESMRGlobalNote::EESMRUnableToEdit );
       
   327     	retValue = ETrue;
       
   328     	}
       
   329     
       
   330     return retValue;
       
   331 	}
   269 
   332 
   270 // EOF
   333 // EOF