meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrvieweralldayeventfield.cpp
branchRCL_3
changeset 33 da5135c61bad
parent 0 8466d47a6819
child 19 b13141f05c3d
equal deleted inserted replaced
32:a3a1ae9acec6 33:da5135c61bad
     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".
    20 #include "cesmreditor.h"
    20 #include "cesmreditor.h"
    21 #include "mesmrlistobserver.h"
    21 #include "mesmrlistobserver.h"
    22 #include "nmrlayoutmanager.h"
    22 #include "nmrlayoutmanager.h"
    23 #include "cmrlabel.h"
    23 #include "cmrlabel.h"
    24 #include "cmrimage.h"
    24 #include "cmrimage.h"
       
    25 #include "cesmrglobalnote.h"
    25 
    26 
    26 #include <caluser.h>
    27 #include <caluser.h>
    27 #include <calalarm.h>
    28 #include <calalarm.h>
    28 #include <calentry.h>
    29 #include <calentry.h>
    29 #include <StringLoader.h>
    30 #include <stringloader.h>
    30 #include <AknLayout2ScalableDef.h>
    31 #include <aknlayout2scalabledef.h>
    31 #include <esmrgui.rsg>
    32 #include <esmrgui.rsg>
    32 
    33 
    33 #include "emailtrace.h"
    34 #include "emailtrace.h"
    34 
    35 
    35 
    36 
    55 //
    56 //
    56 CESMRViewerAllDayEventField::~CESMRViewerAllDayEventField()
    57 CESMRViewerAllDayEventField::~CESMRViewerAllDayEventField()
    57     {
    58     {
    58     FUNC_LOG;
    59     FUNC_LOG;
    59     delete iIcon;
    60     delete iIcon;
    60     delete iLabel;
    61     delete iLockIcon;
    61     }
    62     }
    62 
    63 
    63 // ---------------------------------------------------------------------------
    64 // ---------------------------------------------------------------------------
    64 // CESMRViewerAllDayEventField::CESMRViewerAllDayEventField()
    65 // CESMRViewerAllDayEventField::CESMRViewerAllDayEventField()
    65 // ---------------------------------------------------------------------------
    66 // ---------------------------------------------------------------------------
    66 //
    67 //
    67 CESMRViewerAllDayEventField::CESMRViewerAllDayEventField()
    68 CESMRViewerAllDayEventField::CESMRViewerAllDayEventField()
    68     {
    69     {
    69     FUNC_LOG;
    70     FUNC_LOG;
    70     SetFieldId( EESMRFieldAllDayEvent );
    71     SetFieldId( EESMRFieldAllDayEvent );
       
    72     SetFocusType( EESMRHighlightFocus );
    71     }
    73     }
    72 
    74 
    73 // ---------------------------------------------------------------------------
    75 // ---------------------------------------------------------------------------
    74 // CESMRViewerAllDayEventField::ConstructL()
    76 // CESMRViewerAllDayEventField::ConstructL()
    75 // ---------------------------------------------------------------------------
    77 // ---------------------------------------------------------------------------
    77 void CESMRViewerAllDayEventField::ConstructL()
    79 void CESMRViewerAllDayEventField::ConstructL()
    78     {
    80     {
    79     FUNC_LOG;
    81     FUNC_LOG;
    80     iLabel = CMRLabel::NewL();
    82     iLabel = CMRLabel::NewL();
    81     iLabel->SetParent( this );
    83     iLabel->SetParent( this );
    82     iIcon = CMRImage::NewL( KAknsIIDQgnMeetReqIndiCheckboxMark );
    84     CESMRField::ConstructL( iLabel ); // ownership transfered
       
    85 
       
    86     iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapCheckBoxOn );
    83     iIcon->SetParent( this );
    87     iIcon->SetParent( this );
    84     
       
    85     SetFocusType( EESMRHighlightFocus );
       
    86     }
    88     }
    87 
    89 
    88 // ---------------------------------------------------------------------------
    90 // ---------------------------------------------------------------------------
    89 // CESMRViewerAllDayEventField::InternalizeL()
    91 // CESMRViewerAllDayEventField::InternalizeL()
    90 // ---------------------------------------------------------------------------
    92 // ---------------------------------------------------------------------------
   110 // CESMRViewerAllDayEventField::InitializeL()
   112 // CESMRViewerAllDayEventField::InitializeL()
   111 // ---------------------------------------------------------------------------
   113 // ---------------------------------------------------------------------------
   112 //
   114 //
   113 void CESMRViewerAllDayEventField::InitializeL()
   115 void CESMRViewerAllDayEventField::InitializeL()
   114     {
   116     {
   115     TAknLayoutText text = NMRLayoutManager::GetLayoutText( 
   117     // No implementation yet
   116             Rect(), 
       
   117             NMRLayoutManager::EMRTextLayoutTextEditor );
       
   118     
       
   119     iLabel->SetFont( text.Font() );
       
   120     // This is called so that theme changes will apply when changing theme "on the fly"
       
   121     if ( IsFocused() )
       
   122         {
       
   123         iLabel->FocusChanged( EDrawNow );
       
   124         }
       
   125 
       
   126     AknLayoutUtils::OverrideControlColorL ( *iLabel, EColorLabelText,
       
   127                                              KRgbBlack );
       
   128     }
   118     }
   129 
   119 
   130 // ---------------------------------------------------------------------------
   120 // ---------------------------------------------------------------------------
   131 // CESMRViewerAllDayEventField::SizeChanged()
   121 // CESMRViewerAllDayEventField::SizeChanged()
   132 // ---------------------------------------------------------------------------
   122 // ---------------------------------------------------------------------------
   135     {
   125     {
   136     TRect rect = Rect();
   126     TRect rect = Rect();
   137     TAknLayoutRect rowLayoutRect =
   127     TAknLayoutRect rowLayoutRect =
   138         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
   128         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
   139     rect = rowLayoutRect.Rect();
   129     rect = rowLayoutRect.Rect();
   140     
   130 
   141     TAknWindowComponentLayout iconLayout =
   131     TAknWindowComponentLayout iconLayout =
   142         NMRLayoutManager::GetWindowComponentLayout( NMRLayoutManager::EMRLayoutTextEditorIcon );
   132         NMRLayoutManager::GetWindowComponentLayout( NMRLayoutManager::EMRLayoutTextEditorIcon );
   143     AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
   133     AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
   144     
   134 
   145     TAknLayoutRect bgLayoutRect =
   135     // Layouting lock icon
   146         NMRLayoutManager::GetLayoutRect( rect, NMRLayoutManager::EMRLayoutTextEditorBg );
   136     if( iLockIcon )
   147     TRect bgRect( bgLayoutRect.Rect() );
   137     	{
       
   138     	TAknWindowComponentLayout iconLayout( 
       
   139     			NMRLayoutManager::GetWindowComponentLayout( 
       
   140     					NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
       
   141     	AknLayoutUtils::LayoutImage( iLockIcon, rect, iconLayout );
       
   142     	}
       
   143 
       
   144     // Layouting label
       
   145     TAknLayoutText viewerLayoutText;
       
   146     if( iLockIcon )
       
   147     	{
       
   148     	viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, 
       
   149     			NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
       
   150     	}
       
   151     else
       
   152     	{
       
   153     	viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, 
       
   154     			NMRLayoutManager::EMRTextLayoutTextEditor );
       
   155     	}
       
   156 
       
   157     TRect viewerRect( viewerLayoutText.TextRect() );    
       
   158     iLabel->SetRect( viewerRect );
       
   159 
   148     // Move focus rect so that it's relative to field's position.
   160     // Move focus rect so that it's relative to field's position.
   149     bgRect.Move( -Position() );
   161     viewerRect.Move( -Position() );
   150     SetFocusRect( bgRect );
   162     SetFocusRect( viewerRect );
   151  
       
   152     TAknLayoutText labelLayout = 
       
   153         NMRLayoutManager::GetLayoutText( 
       
   154                 rect, NMRLayoutManager::EMRTextLayoutTextEditor );
       
   155     iLabel->SetRect( labelLayout.TextRect() );
       
   156     }
   163     }
   157 
   164 
   158 // ---------------------------------------------------------------------------
   165 // ---------------------------------------------------------------------------
   159 // CESMRViewerAllDayEventField::CountComponentControls()
   166 // CESMRViewerAllDayEventField::CountComponentControls()
   160 // ---------------------------------------------------------------------------
   167 // ---------------------------------------------------------------------------
   169 
   176 
   170     if ( iLabel )
   177     if ( iLabel )
   171         {
   178         {
   172         ++count;
   179         ++count;
   173         }
   180         }
       
   181     if ( iLockIcon )
       
   182     	{
       
   183     	++count;
       
   184     	}
   174     return count;
   185     return count;
   175     }
   186     }
   176 
   187 
   177 // ---------------------------------------------------------------------------
   188 // ---------------------------------------------------------------------------
   178 // CESMRViewerAllDayEventField::ComponentControl()
   189 // CESMRViewerAllDayEventField::ComponentControl()
   184         {
   195         {
   185         case 0:
   196         case 0:
   186             return iIcon;
   197             return iIcon;
   187         case 1:
   198         case 1:
   188             return iLabel;
   199             return iLabel;
       
   200         case 2:
       
   201         	return iLockIcon;
   189         default:
   202         default:
   190             return NULL;
   203             return NULL;
   191         }
   204         }
   192     }
   205     }
   193 
   206 
   196 // ---------------------------------------------------------------------------
   209 // ---------------------------------------------------------------------------
   197 //
   210 //
   198 void CESMRViewerAllDayEventField::SetOutlineFocusL( TBool aFocus )
   211 void CESMRViewerAllDayEventField::SetOutlineFocusL( TBool aFocus )
   199     {
   212     {
   200     CESMRField::SetOutlineFocusL ( aFocus );
   213     CESMRField::SetOutlineFocusL ( aFocus );
       
   214 
       
   215     iLabel->SetFocus( aFocus );
       
   216     }
       
   217 
       
   218 // ---------------------------------------------------------------------------
       
   219 // CESMRViewerStartDateField::LockL()
       
   220 // ---------------------------------------------------------------------------
       
   221 //
       
   222 void CESMRViewerAllDayEventField::LockL()
       
   223 	{
       
   224 	FUNC_LOG;
       
   225 	if( IsLocked() )
       
   226 		{
       
   227 		return;
       
   228 		}
       
   229 	
       
   230 	CESMRField::LockL();
       
   231 	
       
   232 	delete iLockIcon;
       
   233 	iLockIcon = NULL;
       
   234 	iLockIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapLockField, ETrue );
       
   235 	iLockIcon->SetParent( this );
       
   236 	}
       
   237 
       
   238 // ---------------------------------------------------------------------------
       
   239 // CESMRViewerStartDateField::ExecuteGenericCommandL()
       
   240 // ---------------------------------------------------------------------------
       
   241 //
       
   242 TBool CESMRViewerAllDayEventField::ExecuteGenericCommandL( TInt aCommand )
       
   243 	{
       
   244     FUNC_LOG;
   201     
   245     
   202     iLabel->SetFocus( aFocus );    
   246     TBool retValue( EFalse );
   203 
   247     
   204     if ( !aFocus )
   248     if( (aCommand == EAknCmdOpen) && IsLocked()  )
   205         {
   249     	{
   206         AknLayoutUtils::OverrideControlColorL ( *iLabel, EColorLabelText,
   250 		HandleTactileFeedbackL();
   207                                                  KRgbBlack );
   251 		
   208         }
   252     	CESMRGlobalNote::ExecuteL(
   209     }
   253     	                    CESMRGlobalNote::EESMRUnableToEdit );
       
   254     	retValue = ETrue;
       
   255     	}
       
   256     
       
   257     return retValue;
       
   258 	}
   210 
   259 
   211 // EOF
   260 // EOF