meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrviewerrecurrencefield.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 "cesmrviewerrecurrencefield.h"
    18 #include "cesmrviewerrecurrencefield.h"
    19 #include "nmrlayoutmanager.h"
    19 #include "nmrlayoutmanager.h"
    20 #include "cmrlabel.h"
    20 #include "cmrlabel.h"
    21 #include "cmrimage.h"
    21 #include "cmrimage.h"
    22 #include "mesmrlistobserver.h"
    22 #include "mesmrlistobserver.h"
       
    23 #include "nmrbitmapmanager.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 <avkon.rsg>
    28 #include <avkon.rsg>
    27 #include <calentry.h>
    29 #include <calentry.h>
    28 #include <eikenv.h>
    30 #include <eikenv.h>
    29 #include <eikedwin.h>
    31 #include <eikedwin.h>
    30 #include <StringLoader.h>
    32 #include <stringloader.h>
    31 #include <AknsConstants.h>
    33 #include <aknsconstants.h>
    32 #include <esmrgui.rsg>
    34 #include <esmrgui.rsg>
    33 
    35 
    34 // DEBUG
    36 // DEBUG
    35 #include "emailtrace.h"
    37 #include "emailtrace.h"
    36 
    38 
    62 //
    64 //
    63 CESMRViewerRecurrenceField::~CESMRViewerRecurrenceField()
    65 CESMRViewerRecurrenceField::~CESMRViewerRecurrenceField()
    64     {
    66     {
    65     FUNC_LOG;
    67     FUNC_LOG;
    66     delete iIcon;
    68     delete iIcon;
    67     delete iLabel;
    69     delete iLockIcon;
    68     }
    70     }
    69 
    71 
    70 // -----------------------------------------------------------------------------
    72 // -----------------------------------------------------------------------------
    71 // CESMRViewerRecurrenceField::CESMRViewerRecurrenceField()
    73 // CESMRViewerRecurrenceField::CESMRViewerRecurrenceField()
    72 // -----------------------------------------------------------------------------
    74 // -----------------------------------------------------------------------------
    73 //
    75 //
    74 CESMRViewerRecurrenceField::CESMRViewerRecurrenceField()
    76 CESMRViewerRecurrenceField::CESMRViewerRecurrenceField()
    75     {
    77     {
    76     FUNC_LOG;
    78     FUNC_LOG;
    77     SetFieldId( EESMRFieldRecurrence );
    79     SetFieldId( EESMRFieldRecurrence );
       
    80     SetFocusType( EESMRHighlightFocus );
    78     }
    81     }
    79 
    82 
    80 // -----------------------------------------------------------------------------
    83 // -----------------------------------------------------------------------------
    81 // CESMRViewerRecurrenceField::ConstructL()
    84 // CESMRViewerRecurrenceField::ConstructL()
    82 // -----------------------------------------------------------------------------
    85 // -----------------------------------------------------------------------------
    84 void CESMRViewerRecurrenceField::ConstructL()
    87 void CESMRViewerRecurrenceField::ConstructL()
    85     {
    88     {
    86     FUNC_LOG;
    89     FUNC_LOG;
    87     iLabel = CMRLabel::NewL();
    90     iLabel = CMRLabel::NewL();
    88     iLabel->SetParent( this );
    91     iLabel->SetParent( this );
    89     iIcon = CMRImage::NewL( KAknsIIDQgnFscalIndiRecurrence );
    92     CESMRField::ConstructL( iLabel ); // ownership transfered
       
    93 
       
    94     iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapRecurrence );
    90     iIcon->SetParent( this );
    95     iIcon->SetParent( this );
    91     
       
    92     SetFocusType( EESMRHighlightFocus );    
       
    93     }
    96     }
    94 
    97 
    95 // -----------------------------------------------------------------------------
    98 // -----------------------------------------------------------------------------
    96 // CESMRViewerRecurrenceField::InitializeL()
    99 // CESMRViewerRecurrenceField::InitializeL()
    97 // -----------------------------------------------------------------------------
   100 // -----------------------------------------------------------------------------
    98 //
   101 //
    99 void CESMRViewerRecurrenceField::InitializeL()
   102 void CESMRViewerRecurrenceField::InitializeL()
   100     {
   103     {
   101     FUNC_LOG;
   104     FUNC_LOG;
   102     // Setting Font for the rich text viewer
   105     // Setting Font for the rich text viewer
   103     TAknLayoutText text = NMRLayoutManager::GetLayoutText( 
   106     TAknLayoutText text = NMRLayoutManager::GetLayoutText(
   104             Rect(), 
   107             Rect(),
   105             NMRLayoutManager::EMRTextLayoutTextEditor );
   108             NMRLayoutManager::EMRTextLayoutTextEditor );
   106     
   109 
   107     iLabel->SetFont( text.Font() );
   110     iLabel->SetFont( text.Font() );
   108         
   111 
   109     // This is called so theme changes will apply when changing theme "on the fly"
   112     // This is called so theme changes will apply when changing theme "on the fly"
   110     if ( IsFocused() )
   113     if ( IsFocused() )
   111         {
   114         {
   112         iLabel->FocusChanged( EDrawNow );
   115         iLabel->FocusChanged( EDrawNow );
   113         }
   116         }
   114 
       
   115     AknLayoutUtils::OverrideControlColorL ( *iLabel, EColorLabelText,
       
   116                                              KRgbBlack );
       
   117     }
   117     }
   118 
   118 
   119 // -----------------------------------------------------------------------------
   119 // -----------------------------------------------------------------------------
   120 // CESMRViewerRecurrenceField::InternalizeL()
   120 // CESMRViewerRecurrenceField::InternalizeL()
   121 // -----------------------------------------------------------------------------
   121 // -----------------------------------------------------------------------------
   170             }
   170             }
   171         case ERecurrenceNot:
   171         case ERecurrenceNot:
   172         default:
   172         default:
   173             {
   173             {
   174             // Hide the field if there is no recurrence
   174             // Hide the field if there is no recurrence
   175             iObserver->RemoveControl( iFieldId );
   175             iObserver->HideControl( iFieldId );
   176             break;
   176             break;
   177             }
   177             }
   178         }
   178         }
   179     if ( recHolder )
   179     if ( recHolder )
   180         {
   180         {
   191     {
   191     {
   192     TRect rect = Rect();
   192     TRect rect = Rect();
   193     TAknLayoutRect rowLayoutRect =
   193     TAknLayoutRect rowLayoutRect =
   194         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
   194         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
   195     rect = rowLayoutRect.Rect();
   195     rect = rowLayoutRect.Rect();
   196     
   196 
   197     TAknWindowComponentLayout iconLayout =
   197     TAknWindowComponentLayout iconLayout =
   198         NMRLayoutManager::GetWindowComponentLayout( 
   198         NMRLayoutManager::GetWindowComponentLayout(
   199                 NMRLayoutManager::EMRLayoutTextEditorIcon );
   199                 NMRLayoutManager::EMRLayoutTextEditorIcon );
   200     AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
   200     AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
       
   201 
       
   202     // Layouting lock icon
       
   203     if( iLockIcon )
       
   204     	{
       
   205     	TAknWindowComponentLayout iconLayout( 
       
   206     			NMRLayoutManager::GetWindowComponentLayout( 
       
   207     					NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
       
   208     	AknLayoutUtils::LayoutImage( iLockIcon, rect, iconLayout );
       
   209     	}
       
   210         
       
   211     // Layouting label
       
   212     TAknLayoutText viewerLayoutText;
       
   213     if( iLockIcon )
       
   214     	{
       
   215     	viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, 
       
   216     			NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
       
   217     	}
       
   218     else
       
   219     	{
       
   220     	viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, 
       
   221     			NMRLayoutManager::EMRTextLayoutTextEditor );
       
   222     	}
       
   223 
       
   224     TRect viewerRect( viewerLayoutText.TextRect() );    
       
   225     iLabel->SetRect( viewerRect );
       
   226 
       
   227     // Move focus rect so that it's relative to field's position.
       
   228     viewerRect.Move( -Position() );
       
   229     SetFocusRect( viewerRect );
       
   230 
       
   231     // Setting font also for the label
       
   232     iLabel->SetFont( viewerLayoutText.Font() );
       
   233     }
       
   234 
       
   235 // -----------------------------------------------------------------------------
       
   236 // CESMRViewerRecurrenceField::CountComponentControls()
       
   237 // -----------------------------------------------------------------------------
       
   238 //
       
   239 TInt CESMRViewerRecurrenceField::CountComponentControls() const
       
   240     {
       
   241     TInt count( KComponentCount );
       
   242     if( iLockIcon )
       
   243     	{
       
   244     	++count;
       
   245     	}
   201     
   246     
   202     TAknLayoutRect bgLayoutRect =
   247     return count;
   203         NMRLayoutManager::GetLayoutRect( 
       
   204                 rect, NMRLayoutManager::EMRLayoutTextEditorBg );
       
   205     TRect bgRect( bgLayoutRect.Rect() );
       
   206     // Move focus rect so that it's relative to field's position.
       
   207     bgRect.Move( -Position() );
       
   208     SetFocusRect( bgRect );
       
   209     
       
   210     TAknLayoutText labelLayout = 
       
   211         NMRLayoutManager::GetLayoutText( 
       
   212                 rect, NMRLayoutManager::EMRTextLayoutTextEditor );
       
   213     iLabel->SetRect( labelLayout.TextRect() );  
       
   214     }
       
   215 
       
   216 // -----------------------------------------------------------------------------
       
   217 // CESMRViewerRecurrenceField::CountComponentControls()
       
   218 // -----------------------------------------------------------------------------
       
   219 //
       
   220 TInt CESMRViewerRecurrenceField::CountComponentControls() const
       
   221     {
       
   222     return KComponentCount;
       
   223     }
   248     }
   224 
   249 
   225 // -----------------------------------------------------------------------------
   250 // -----------------------------------------------------------------------------
   226 // CESMRViewerRecurrenceField::ComponentControl()
   251 // CESMRViewerRecurrenceField::ComponentControl()
   227 // -----------------------------------------------------------------------------
   252 // -----------------------------------------------------------------------------
   232         {
   257         {
   233         case 0:
   258         case 0:
   234             return iIcon;
   259             return iIcon;
   235         case 1:
   260         case 1:
   236             return iLabel;
   261             return iLabel;
       
   262         case 2:
       
   263         	return iLockIcon;
   237         default:
   264         default:
   238             return NULL;
   265             return NULL;
   239         }
   266         }
   240     }
   267     }
   241 
   268 
   245 //
   272 //
   246 void CESMRViewerRecurrenceField::SetOutlineFocusL( TBool aFocus )
   273 void CESMRViewerRecurrenceField::SetOutlineFocusL( TBool aFocus )
   247     {
   274     {
   248     FUNC_LOG;
   275     FUNC_LOG;
   249     CESMRField::SetOutlineFocusL ( aFocus );
   276     CESMRField::SetOutlineFocusL ( aFocus );
   250     
   277 
   251     iLabel->SetFocus( aFocus );    
   278     iLabel->SetFocus( aFocus );
   252 
   279     }
   253     if ( !aFocus )
   280 
   254         {
   281 // ---------------------------------------------------------------------------
   255         AknLayoutUtils::OverrideControlColorL ( *iLabel, EColorLabelText,
   282 // CESMRViewerRecurrenceField::LockL()
   256                                                  KRgbBlack );
   283 // ---------------------------------------------------------------------------
   257         }
   284 //
   258     }
   285 void CESMRViewerRecurrenceField::LockL()
       
   286 	{
       
   287 	FUNC_LOG;
       
   288 	if( IsLocked() )
       
   289 		{
       
   290 		return;
       
   291 		}
       
   292 	
       
   293 	CESMRField::LockL();
       
   294 	
       
   295 	delete iLockIcon;
       
   296 	iLockIcon = NULL;
       
   297 	iLockIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapLockField, ETrue );
       
   298 	iLockIcon->SetParent( this );
       
   299 	}
       
   300 
       
   301 // ---------------------------------------------------------------------------
       
   302 // CESMRViewerRecurrenceField::ExecuteGenericCommandL()
       
   303 // ---------------------------------------------------------------------------
       
   304 //
       
   305 TBool CESMRViewerRecurrenceField::ExecuteGenericCommandL( TInt aCommand )
       
   306 	{
       
   307 	FUNC_LOG;
       
   308 
       
   309 	TBool retValue( EFalse );
       
   310 
       
   311 	if( (aCommand == EAknCmdOpen) && IsLocked()  )
       
   312 		{
       
   313 		HandleTactileFeedbackL();
       
   314 		
       
   315 		CESMRGlobalNote::ExecuteL(
       
   316 				CESMRGlobalNote::EESMRUnableToEdit );
       
   317 		retValue = ETrue;
       
   318 		}
       
   319 
       
   320 	return retValue;
       
   321 	}
   259 // EOF
   322 // EOF
   260 
   323