meetingrequest/mrgui/src/cesmrview.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".
    24 #include "esmrinternaluid.h"
    24 #include "esmrinternaluid.h"
    25 #include "cesmrtitlepane.h"
    25 #include "cesmrtitlepane.h"
    26 #include "cesmrfield.h"
    26 #include "cesmrfield.h"
    27 #include "mesmrcalentry.h"
    27 #include "mesmrcalentry.h"
    28 #include "nmrlayoutmanager.h"
    28 #include "nmrlayoutmanager.h"
       
    29 #include "mesmrfieldstorage.h"
    29 #include "FreestyleEmailUiConstants.h"
    30 #include "FreestyleEmailUiConstants.h"
       
    31 #include "cesmrcaldbmgr.h"
       
    32 #include "mmrfocusstrategy.h"
       
    33 #include "cmrnaviarrow.h"
       
    34 #include "mesmrlistobserver.h"
       
    35 #include "cmrtoolbar.h"
       
    36 #include "cmrattachmentindicator.h"
       
    37 #include "esmrdef.h"
       
    38 #include "mesmrfieldevent.h"
       
    39 #include "cesmrgenericfieldevent.h"
    30 
    40 
    31 #include <eiklabel.h>
    41 #include <eiklabel.h>
    32 #include <avkon.hrh>
    42 #include <avkon.hrh>
    33 #include <MAgnEntryUi.h>
    43 #include <magnentryui.h>
    34 #include <StringLoader.h>
    44 #include <stringloader.h>
    35 #include <gulcolor.h>
    45 #include <gulcolor.h>
    36 #include <eikimage.h>
    46 #include <eikimage.h>
    37 #include <esmrgui.rsg>
    47 #include <esmrgui.rsg>
    38 #include <AknIconUtils.h>
    48 #include <akniconutils.h>
    39 #include <eikenv.h>
    49 #include <eikenv.h>
    40 #include <AknsConstants.h>
    50 #include <aknsconstants.h>
    41 #include <AknUtils.h>
    51 #include <aknutils.h>
    42 #include <AknsDrawUtils.h>
    52 #include <aknsdrawutils.h>
    43 #include <AknsBasicBackgroundControlContext.h>
    53 #include <aknsbasicbackgroundcontrolcontext.h>
    44 #include <hlplch.h>
    54 #include <hlplch.h>
    45 #include <csxhelp/cmail.hlp.hrh>
    55 #include <csxhelp/cmail.hlp.hrh>
    46 
    56 #include <touchfeedback.h>
    47 #include <featmgr.h>
    57 #include <akntoolbar.h>
    48 //</cmail>
    58 #include <eikcolib.h>
       
    59 #include <featdiscovery.h>
       
    60 #include <bldvariant.hrh>
       
    61 #include <layoutmetadata.cdl.h>
    49 
    62 
    50 #include "emailtrace.h"
    63 #include "emailtrace.h"
    51 
    64 
    52 
    65 
    53 // <cmail> Removed profiling. </cmail>
    66 // <cmail> Removed profiling. </cmail>
    57 
    70 
    58 // ---------------------------------------------------------------------------
    71 // ---------------------------------------------------------------------------
    59 // CESMRView::CESMRView()
    72 // CESMRView::CESMRView()
    60 // ---------------------------------------------------------------------------
    73 // ---------------------------------------------------------------------------
    61 //
    74 //
    62 CESMRView::CESMRView( MESMRFieldStorage* aStorage, MESMRCalEntry& aEntry ) :
    75 CESMRView::CESMRView( MESMRFieldStorage* aStorage,
    63 	iStorage(aStorage),
    76         MESMRCalEntry& aEntry,
    64 	iEntry(aEntry)
    77         MMRFocusStrategy& aFocusStrategy,
       
    78         MESMRNaviArrowEventObserver* aObserver, 
       
    79         CMRToolbar& aToolbar )
       
    80     : iStorage( aStorage ),
       
    81       iEntry( &aEntry ),
       
    82 	  iFocusStrategy( aFocusStrategy ),
       
    83 	  iObserver( aObserver ),
       
    84 	  iToolbar( aToolbar )
    65     {
    85     {
    66     FUNC_LOG;
    86     FUNC_LOG;
    67     // Do nothing
    87     // Do nothing
    68     }
    88     }
    69 
    89 
    72 // ---------------------------------------------------------------------------
    92 // ---------------------------------------------------------------------------
    73 //
    93 //
    74 CESMRView* CESMRView::NewL(
    94 CESMRView* CESMRView::NewL(
    75         MESMRFieldStorage* aStorage,
    95         MESMRFieldStorage* aStorage,
    76         MESMRCalEntry& aEntry,
    96         MESMRCalEntry& aEntry,
    77         const TRect& aRect )
    97         const TRect& aRect,
    78     {
    98         MMRFocusStrategy& aFocusStrategy,
    79     FUNC_LOG;
    99         CMRToolbar& aToolbar,
    80     CESMRView* self = new (ELeave) CESMRView( aStorage, aEntry );
   100         MESMRNaviArrowEventObserver* aObserver )
       
   101     {
       
   102     FUNC_LOG;
       
   103     CESMRView* self = new (ELeave) CESMRView( 
       
   104             aStorage, aEntry, aFocusStrategy, aObserver, aToolbar );
    81     CleanupStack::PushL( self );
   105     CleanupStack::PushL( self );
    82     self->ConstructL( aRect );
   106     self->ConstructL( aRect );
    83     CleanupStack::Pop( self );
   107     CleanupStack::Pop( self );
    84     return self;
   108     return self;
    85     }
   109     }
    89 // ---------------------------------------------------------------------------
   113 // ---------------------------------------------------------------------------
    90 //
   114 //
    91 void CESMRView::ConstructL( const TRect& aRect )
   115 void CESMRView::ConstructL( const TRect& aRect )
    92     {
   116     {
    93     FUNC_LOG;
   117     FUNC_LOG;
    94     iBgContext = CAknsBasicBackgroundControlContext::NewL( 
   118     CreateWindowL();
    95             KAknsIIDQsnBgAreaMain, aRect, ETrue);
       
    96 
       
    97     iLayout = CESMRLayoutManager::NewL();
       
    98     iLayout->SetObserver( NULL );
       
    99     iTitle = CESMRTitlePane::NewL();
       
   100     // Default title text is set here.
       
   101 
       
   102     HBufC* title ;
       
   103     switch (iEntry.Type())
       
   104         {
       
   105         case MESMRCalEntry::EESMRCalEntryTodo:
       
   106         	{
       
   107             title = StringLoader::LoadLC ( R_QTN_CALENDAR_TITLE_NEW_TODO );
       
   108             break;
       
   109         	}
       
   110         case MESMRCalEntry::EESMRCalEntryMemo:
       
   111         	{
       
   112             title = StringLoader::LoadLC ( R_QTN_CALENDAR_TITLE_NEW_MEMO );
       
   113             break;
       
   114         	}
       
   115         case MESMRCalEntry::EESMRCalEntryAnniversary:
       
   116         	{
       
   117             title = StringLoader::LoadLC(R_QTN_CALENDAR_TITLE_NEW_ANNIVERSARY);
       
   118             break;
       
   119         	}
       
   120         case MESMRCalEntry::EESMRCalEntryMeetingRequest: // Fall through
       
   121         case MESMRCalEntry::EESMRCalEntryMeeting: // Fall through
       
   122         case MESMRCalEntry::EESMRCalEntryReminder: // Fall through
       
   123         default:
       
   124         	{
       
   125             title = StringLoader::LoadLC( R_QTN_MEET_REQ_TITLE );
       
   126             break;
       
   127         	}
       
   128         }
       
   129 
       
   130     iTitle->SetTextL( *title );
       
   131     CleanupStack::PopAndDestroy( title );
       
   132 
       
   133     SetRect( aRect );
   119     SetRect( aRect );
   134     }
   120     }
   135 
   121 
   136 // ---------------------------------------------------------------------------
   122 // ---------------------------------------------------------------------------
   137 // CESMRView::~CESMRView()
   123 // CESMRView::~CESMRView()
   138 // ---------------------------------------------------------------------------
   124 // ---------------------------------------------------------------------------
   139 //
   125 //
   140 CESMRView::~CESMRView()
   126 CESMRView::~CESMRView()
   141     {
   127     {
   142     FUNC_LOG;
   128     FUNC_LOG;
   143     delete iTitle;
   129     delete iListPane;
   144     delete iList;
       
   145     delete iLayout;
       
   146     delete iBgContext;
   130     delete iBgContext;
       
   131     delete iNaviArrowLeft;
       
   132     delete iNaviArrowRight;
       
   133     delete iScrollBar;
       
   134     delete iStorage;
   147     }
   135     }
   148 
   136 
   149 // ---------------------------------------------------------------------------
   137 // ---------------------------------------------------------------------------
   150 // CESMRView::ExternalizeL()
   138 // CESMRView::ExternalizeL()
   151 // ---------------------------------------------------------------------------
   139 // ---------------------------------------------------------------------------
   152 //
   140 //
   153 void CESMRView::ExternalizeL( TBool aForceValidation )
   141 void CESMRView::ExternalizeL( TBool aForceValidation )
   154     {
   142     {
   155     FUNC_LOG;
   143     FUNC_LOG;
   156     // externalize all fields:
   144     // externalize all fields:
   157     iList->ExternalizeL( iEntry, aForceValidation );
   145     iListPane->ExternalizeL( *iEntry, aForceValidation );
   158     // externalize title pane for priority value
       
   159     iTitle->ExternalizeL( iEntry );
       
   160     }
   146     }
   161 
   147 
   162 // ---------------------------------------------------------------------------
   148 // ---------------------------------------------------------------------------
   163 // CESMRView::InternalizeL()
   149 // CESMRView::InternalizeL()
   164 // ---------------------------------------------------------------------------
   150 // ---------------------------------------------------------------------------
   165 //
   151 //
   166 void CESMRView::InternalizeL()
   152 void CESMRView::InternalizeL()
   167     {
   153     {
   168     FUNC_LOG;
   154     FUNC_LOG;
   169     // internalize title pane ( for priority )
   155     iListPane->DisableSizeChange( ETrue );
   170     iTitle->InternalizeL( iEntry );
       
   171     iList->DisableSizeChange( ETrue );
       
   172     // internalize all fields:
   156     // internalize all fields:
   173     iList->InternalizeL( iEntry );
   157     iListPane->InternalizeL( *iEntry );
   174     iList->DisableSizeChange( EFalse );
   158     iListPane->DisableSizeChange( EFalse );
   175     iList->SizeChanged();
   159     iListPane->SizeChanged();
   176     }
   160     }
   177 
   161 
   178 // ---------------------------------------------------------------------------
   162 // ---------------------------------------------------------------------------
   179 // CESMRView::IsComponentVisible()
   163 // CESMRView::IsControlVisible()
   180 // ---------------------------------------------------------------------------
   164 // ---------------------------------------------------------------------------
   181 //
   165 //
   182 TBool CESMRView::IsComponentVisible( TESMREntryFieldId aField ) const
   166 TBool CESMRView::IsControlVisible( TESMREntryFieldId aFieldId ) const
   183     {
   167     {
   184     FUNC_LOG;
   168     FUNC_LOG;
   185     return iList->ListObserver().IsControlVisible( aField );
   169     return iListPane->IsControlVisible( aFieldId );
   186     }
   170     }
   187 
   171 
   188 
       
   189 // ---------------------------------------------------------------------------
       
   190 // CESMRView::CanProcessEditorCommandL
       
   191 // ---------------------------------------------------------------------------
       
   192 //
       
   193 TBool CESMRView::CanProcessEditorCommandL( TInt aCommand )
       
   194     {
       
   195     FUNC_LOG;
       
   196     CESMRField*  field = iList->FocusedItem();
       
   197     TBool result(ETrue);
       
   198     switch ( aCommand )
       
   199         {
       
   200         case EESMRCmdClipboardCopy:
       
   201         switch (field->FieldId())
       
   202             {
       
   203             // quite few fields allow copiing
       
   204             case EESMRFieldOrganizer:       // fall through 
       
   205             case EESMRFieldAttendee:        // fall through 
       
   206             case EESMRFieldDetailedSubject: // fall through 
       
   207             case EESMRFieldDescription:     // fall through
       
   208                 result = ETrue;
       
   209                 break;
       
   210             }
       
   211         break;
       
   212         default:
       
   213             result = EFalse;
       
   214             break;
       
   215         }
       
   216     return result;    
       
   217     }
       
   218     
       
   219 // ---------------------------------------------------------------------------
   172 // ---------------------------------------------------------------------------
   220 // CESMRView::ProcessCommandL
   173 // CESMRView::ProcessCommandL
   221 // ---------------------------------------------------------------------------
   174 // ---------------------------------------------------------------------------
   222 //
   175 //
   223 void CESMRView::ProcessEditorCommandL( TInt aCommand )
   176 void CESMRView::ProcessEditorCommandL( TInt aCommand )
   225     FUNC_LOG;
   178     FUNC_LOG;
   226     switch ( aCommand )
   179     switch ( aCommand )
   227         {
   180         {
   228         case EESMRCmdPriorityHigh: // Fall through
   181         case EESMRCmdPriorityHigh: // Fall through
   229         case EESMRCmdPriorityNormal: // Fall through
   182         case EESMRCmdPriorityNormal: // Fall through
   230         case EESMRCmdPriorityLow: 
   183         case EESMRCmdPriorityLow:
   231         	{
   184            {
   232             iTitle->HandleSetPriorityCmdL( aCommand );
   185            CESMRField* field = iStorage->FieldById( EESMRFieldSubject );
   233             break;
   186            if ( field )
   234         	}
   187                {
       
   188                field->ExecuteGenericCommandL(
       
   189                        aCommand );
       
   190                iListPane->SizeChanged();
       
   191                }
       
   192            break;
       
   193            }
   235         case EESMRCmdAddOptAttendee:
   194         case EESMRCmdAddOptAttendee:
   236         	{
   195         	{
   237             iList->ListObserver().InsertControl( EESMRFieldOptAttendee );
   196             iListPane->ShowControl( EESMRFieldOptAttendee );
   238             SetControlFocusedL(EESMRFieldOptAttendee);
   197             SetControlFocusedL( EESMRFieldOptAttendee );
   239             break;
   198             break;
   240         	}
   199         	}
   241         case EAknCmdHelp:
   200         case EAknCmdHelp:
   242         	{
   201         	{
   243         	break;
   202         	break;
   244         	}
   203         	}
   245         case EESMRCmdEdit:
   204         case EMRCmdHideAttachmentIndicator:
   246             {
   205             {
   247             iList->ListObserver().InsertControl( EESMRFieldResponseArea );
   206             if ( iAttachmentIndicator )
   248             iList->ListObserver().RemoveControl( EESMRFieldResponseReadyArea );
   207                 {
   249             iList->ListObserver().SetControlFocusedL( EESMRFieldResponseArea );
   208                 TInt pos = iControls.Find( iAttachmentIndicator );
   250             break;
   209                 if (KErrNotFound != pos )
   251             }
   210                     {
       
   211                     iControls.Remove( pos );
       
   212                     }
       
   213                     
       
   214                 delete iAttachmentIndicator;
       
   215                 iAttachmentIndicator = NULL;
       
   216                 
       
   217                 ReLayout();
       
   218                 }            
       
   219             }
       
   220             break;
   252         default://forward to fields
   221         default://forward to fields
   253         	{
   222         	{
   254             iList->FocusedItem()->ExecuteGenericCommandL(aCommand);
   223             iListPane->FocusedField()->ExecuteGenericCommandL( aCommand );
   255             break;
   224             break;
   256         	}
   225         	}
   257         }
   226         }
   258     }
   227     }
   259 
   228 
   260 // ---------------------------------------------------------------------------
   229 // ---------------------------------------------------------------------------
   261 // CIpsSetUiDialogCtrl::DynInitMenuPaneL()
       
   262 // ---------------------------------------------------------------------------
       
   263 //
       
   264 void CESMRView::DynInitMenuPaneL(
       
   265         /*TInt aResourceId,*/
       
   266         CEikMenuPane* aMenuPane )
       
   267     {
       
   268     FUNC_LOG;
       
   269 	if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
       
   270 		{
       
   271 		// remove help support in pf5250
       
   272 		aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue);      
       
   273 		}
       
   274     }
       
   275 
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 // CESMRView::LaunchEditorHelpL
   230 // CESMRView::LaunchEditorHelpL
   279 // ---------------------------------------------------------------------------
   231 // ---------------------------------------------------------------------------
   280 //
   232 //
   281 void CESMRView::LaunchEditorHelpL()
   233 void CESMRView::LaunchEditorHelpL()
   282     {
   234     {
   283     FUNC_LOG;
   235     FUNC_LOG;
   284     LaunchHelpL( KFSE_HLP_LAUNCHER_GRID );
   236 
       
   237     switch ( iEntry->Type() )
       
   238         {
       
   239         case MESMRCalEntry::EESMRCalEntryTodo:
       
   240             {
       
   241             LaunchHelpL( KFSCA_HLP_TODO_EDITOR );
       
   242         	break;
       
   243             }
       
   244         case MESMRCalEntry::EESMRCalEntryMemo:
       
   245             {
       
   246             LaunchHelpL( KFSCA_HLP_MEMO_EDITOR );
       
   247             break;
       
   248             }
       
   249         case MESMRCalEntry::EESMRCalEntryAnniversary:
       
   250             {
       
   251             LaunchHelpL( KFSCA_HLP_ANNIVERSARY_EDITOR );
       
   252             break;
       
   253             }
       
   254         case MESMRCalEntry::EESMRCalEntryMeeting:
       
   255             {
       
   256             LaunchHelpL( KFSCA_HLP_CALE_MEETING_EDITOR );
       
   257             break;
       
   258             }
       
   259         case MESMRCalEntry::EESMRCalEntryMeetingRequest:
       
   260             {
       
   261             LaunchHelpL( KMEET_REQ_HLP_EDITOR );
       
   262             break;
       
   263             }
       
   264         case MESMRCalEntry::EESMRCalEntryReminder: // Fall through
       
   265         default:
       
   266             {
       
   267             break;
       
   268             }
       
   269         }
       
   270 
   285     }
   271     }
   286 
   272 
   287 // ---------------------------------------------------------------------------
   273 // ---------------------------------------------------------------------------
   288 // CESMRView::LaunchViewerHelpL
   274 // CESMRView::LaunchViewerHelpL
   289 // ---------------------------------------------------------------------------
   275 // ---------------------------------------------------------------------------
   290 //
   276 //
   291 void CESMRView::LaunchViewerHelpL()
   277 void CESMRView::LaunchViewerHelpL()
   292     {
   278     {
   293     FUNC_LOG;
   279     FUNC_LOG;
   294     LaunchHelpL( KFSE_HLP_LAUNCHER_GRID );
   280 
       
   281 
       
   282     switch ( iEntry->Type() )
       
   283         {
       
   284     	case MESMRCalEntry::EESMRCalEntryTodo:
       
   285     	    {
       
   286             LaunchHelpL( KFSCA_HLP_TODO_VIEWER );
       
   287             break;
       
   288     	    }
       
   289         case MESMRCalEntry::EESMRCalEntryMemo:
       
   290             {
       
   291             LaunchHelpL( KFSCA_HLP_MEMO_VIEWER );
       
   292             break;
       
   293             }
       
   294         case MESMRCalEntry::EESMRCalEntryAnniversary:
       
   295             {
       
   296             LaunchHelpL( KFSCA_HLP_ANNI_VIEWER );
       
   297             break;
       
   298             }
       
   299         case MESMRCalEntry::EESMRCalEntryMeeting:
       
   300             {
       
   301             LaunchHelpL( KFSCA_HLP_CALE_MEETING_VIEWER );
       
   302             break;
       
   303             }
       
   304         case MESMRCalEntry::EESMRCalEntryMeetingRequest:
       
   305             {
       
   306             MESMRMeetingRequestEntry* mrEntry =
       
   307                static_cast<MESMRMeetingRequestEntry*>( iEntry );
       
   308             
       
   309             if ( mrEntry->IsOpenedFromMail() )
       
   310                 {
       
   311                 if ( CFeatureDiscovery::IsFeatureSupportedL(
       
   312                         TUid::Uid( KFeatureIdFfCalMeetingRequestUi ) ) )
       
   313                     {
       
   314                     // Full functionality
       
   315                     LaunchHelpL( KFS_VIEWER_HLP_MEETING_REQ_VIEW );
       
   316                     }
       
   317                 else
       
   318                     {
       
   319                     // Only viewer from Mail supported
       
   320                     // TODO: Change to KFS_VIEWER_HLP_MR_RECEIVED
       
   321                     // when help id is released on wk9 platform
       
   322                     LaunchHelpL( KFS_VIEWER_HLP_MEETING_REQ_VIEW );
       
   323                     }
       
   324                 }
       
   325             else if ( mrEntry->RoleL() == EESMRRoleOrganizer )
       
   326                 {
       
   327                 LaunchHelpL( KFSCA_HLP_VIEWER_ORGANIZER );
       
   328                 }
       
   329             else 
       
   330                 {
       
   331                 LaunchHelpL( KFSCA_HLP_VIEWER );
       
   332                 }
       
   333             break;
       
   334             }
       
   335         case MESMRCalEntry::EESMRCalEntryReminder: // Fall through
       
   336         default:
       
   337             {
       
   338             break;
       
   339             }
       
   340         }
       
   341 
   295     }
   342     }
   296 
   343 
   297 // ---------------------------------------------------------------------------
   344 // ---------------------------------------------------------------------------
   298 // CESMRView::IsComponentfocused
   345 // CESMRView::IsComponentfocused
   299 // ---------------------------------------------------------------------------
   346 // ---------------------------------------------------------------------------
   303     FUNC_LOG;
   350     FUNC_LOG;
   304 	return 	FocusedField() == aField;
   351 	return 	FocusedField() == aField;
   305 	}
   352 	}
   306 
   353 
   307 // ---------------------------------------------------------------------------
   354 // ---------------------------------------------------------------------------
   308 // CESMRView::IsComponentfocused
   355 // CESMRView::FocusedField
   309 // ---------------------------------------------------------------------------
   356 // ---------------------------------------------------------------------------
   310 //
   357 //
   311 TESMREntryFieldId CESMRView::FocusedField() const
   358 TESMREntryFieldId CESMRView::FocusedField() const
   312     {
   359     {
   313     FUNC_LOG;
   360     FUNC_LOG;
   314     TESMREntryFieldId fieldId( ( TESMREntryFieldId ) 0 );
   361     TESMREntryFieldId fieldId( ( TESMREntryFieldId ) 0 );
   315     
   362 
   316 	CESMRField* field = iList->FocusedItem();
   363 	CESMRField* field = iListPane->FocusedField();
   317     
   364 
   318     if ( field )
   365     if ( field )
   319         {
   366         {
   320         fieldId = field->FieldId();
   367         fieldId = field->FieldId();
   321         }
   368         }
   322     
   369 
   323     return fieldId;
   370     return fieldId;
   324 	}
   371 	}
   325 
   372 
   326 // ---------------------------------------------------------------------------
   373 // ---------------------------------------------------------------------------
       
   374 // CESMRView::ClickedOrFocusedField
       
   375 // ---------------------------------------------------------------------------
       
   376 //
       
   377 TESMREntryFieldId CESMRView::ClickedOrFocusedField() const
       
   378     {
       
   379     FUNC_LOG;
       
   380     TESMREntryFieldId fieldId( ( TESMREntryFieldId ) 0 );
       
   381 
       
   382     // Get clicked item if exists
       
   383     CESMRField* field = iListPane->ClickedField();
       
   384 
       
   385     if ( field )
       
   386         {
       
   387         fieldId = field->FieldId();
       
   388         }
       
   389     // If doesn't, try getting focused item
       
   390     else
       
   391         {
       
   392         field = iListPane->FocusedField();
       
   393         if( field )
       
   394             {
       
   395             fieldId = FocusedField();
       
   396             }
       
   397         }
       
   398 
       
   399     return fieldId;
       
   400     }
       
   401 
       
   402 // ---------------------------------------------------------------------------
       
   403 // CESMRView::AdjustViewL
       
   404 // ---------------------------------------------------------------------------
       
   405 //
       
   406 void CESMRView::AdjustViewL(
       
   407             MESMRCalEntry* aNewEntry,
       
   408             const CESMRPolicy& aNewPolicy )
       
   409     {
       
   410     iStorage->ChangePolicyL( aNewPolicy,*aNewEntry );
       
   411     iEntry = aNewEntry;
       
   412     iListPane->InitializeL();
       
   413     iListPane->ReActivateL();
       
   414     InternalizeL();
       
   415     SetControlFocusedL( EESMRFieldUnifiedEditor );
       
   416     SetTitlePaneObserver();
       
   417     DrawDeferred();
       
   418     }
       
   419 
       
   420 // ---------------------------------------------------------------------------
   327 // CESMRView::LaunchHelpL
   421 // CESMRView::LaunchHelpL
   328 // ---------------------------------------------------------------------------
   422 // ---------------------------------------------------------------------------
   329 //
   423 //
   330 void CESMRView::LaunchHelpL( const TDesC& aContext )
   424 void CESMRView::LaunchHelpL( const TDesC& aContext )
   331     {
   425     {
   332     FUNC_LOG;
   426     FUNC_LOG;
   333     
   427 
   334     CArrayFix<TCoeHelpContext>* cntx = 
   428     CArrayFix<TCoeHelpContext>* cntx =
   335 		new (ELeave) CArrayFixFlat<TCoeHelpContext>(1);
   429 		new (ELeave) CArrayFixFlat<TCoeHelpContext>(1);
   336     CleanupStack::PushL(cntx);
   430     CleanupStack::PushL(cntx);
   337     cntx->AppendL( TCoeHelpContext( KFSEmailUiUid, aContext ) );
   431     cntx->AppendL( TCoeHelpContext( KFSEmailUiUid, aContext ) );
   338     CleanupStack::Pop(cntx);
   432     CleanupStack::Pop(cntx);
   339     HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), cntx );
   433     HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), cntx );
   340     }
   434     }
   341 
   435 
       
   436 
       
   437 // ---------------------------------------------------------------------------
       
   438 // CESMRView::SetTitlePaneObserver
       
   439 // ---------------------------------------------------------------------------
       
   440 //
       
   441 void CESMRView::SetTitlePaneObserver()
       
   442     {
       
   443     CESMRField* field = NULL;
       
   444     TInt fieldCount( iStorage->Count() );
       
   445     for ( TInt i(0); i < fieldCount; ++i )
       
   446         {
       
   447         field = iStorage->Field( i );
       
   448         TESMREntryFieldId fieldId( field->FieldId() );
       
   449 
       
   450         switch( fieldId )
       
   451             {
       
   452             case EESMRFieldSubject: //Fall through
       
   453             case EESMRFieldOccasion://Fall through
       
   454             case EESMRFieldPriority://Fall through
       
   455             case EESMRFieldDetailedSubject:
       
   456                 {
       
   457                 field->SetTitlePaneObserver( this );
       
   458                 break;
       
   459                 }
       
   460             default:
       
   461                 break;
       
   462             }
       
   463         }
       
   464     }
       
   465 
   342 // ---------------------------------------------------------------------------
   466 // ---------------------------------------------------------------------------
   343 // CESMRView::UpdateTitlePaneTextL
   467 // CESMRView::UpdateTitlePaneTextL
   344 // ---------------------------------------------------------------------------
   468 // ---------------------------------------------------------------------------
   345 //
   469 //
   346 void CESMRView::UpdateTitlePaneTextL( const TDesC& aText )
   470 void CESMRView::UpdateTitlePaneTextL( const TDesC& aText )
   348     FUNC_LOG;
   472     FUNC_LOG;
   349     SetTitleL( aText );
   473     SetTitleL( aText );
   350     }
   474     }
   351 
   475 
   352 // ---------------------------------------------------------------------------
   476 // ---------------------------------------------------------------------------
   353 // CESMRView::UpdateTitlePanePriorityIconL()
   477 // CESMRView::HandleScrollEventL
   354 // ---------------------------------------------------------------------------
   478 // ---------------------------------------------------------------------------
   355 //
   479 //
   356 void CESMRView::UpdateTitlePanePriorityIconL( TUint aPriority )
   480 void CESMRView::HandleScrollEventL(
   357     {
   481     CEikScrollBar* aScrollBar,
   358     FUNC_LOG;
   482     TEikScrollEvent aEventType )
   359     iTitle->SetPriorityL( aPriority );
   483     {
       
   484     FUNC_LOG;
       
   485 
       
   486     if ( !aScrollBar )
       
   487        {
       
   488        return;
       
   489        }
       
   490 
       
   491     TInt newPosition = aScrollBar->ThumbPosition();
       
   492 
       
   493     switch( aEventType )
       
   494        {
       
   495        case EEikScrollThumbDragVert: // Drag started
       
   496        case EEikScrollThumbReleaseVert: // Drag released
       
   497            {
       
   498            if( newPosition < iScrollBarThumbPosition )
       
   499                {
       
   500                iListPane->ScrollFieldsDown(
       
   501                        iScrollBarThumbPosition - newPosition );
       
   502 
       
   503                iScrollBarThumbPosition = newPosition;
       
   504                }
       
   505 
       
   506            else if( newPosition > iScrollBarThumbPosition )
       
   507                {
       
   508                iListPane->ScrollFieldsUp(
       
   509                        newPosition - iScrollBarThumbPosition );
       
   510 
       
   511                iScrollBarThumbPosition = newPosition;
       
   512                }
       
   513            break;
       
   514            }
       
   515        case EEikScrollPageUp:
       
   516            {
       
   517            if( newPosition < iScrollBarThumbPosition )
       
   518                {
       
   519                iListPane->ScrollFieldsDown(
       
   520                        iScrollBarThumbPosition - newPosition );
       
   521 
       
   522                iScrollBarThumbPosition = newPosition;
       
   523                }
       
   524            break;
       
   525            }
       
   526        case EEikScrollPageDown:
       
   527            {
       
   528            if( newPosition > iScrollBarThumbPosition )
       
   529                {
       
   530                iListPane->ScrollFieldsUp(
       
   531                        newPosition - iScrollBarThumbPosition );
       
   532 
       
   533                iScrollBarThumbPosition = newPosition;
       
   534                }
       
   535            break;
       
   536            }
       
   537        default:
       
   538            {
       
   539            break;
       
   540            }
       
   541        }
       
   542 
       
   543     DrawNow();
       
   544     }
       
   545 
       
   546 // ---------------------------------------------------------------------------
       
   547 // CESMRView::ScrollBarPositionChanged()
       
   548 // ---------------------------------------------------------------------------
       
   549 //
       
   550 void CESMRView::ScrollBarPositionChanged( TInt aThumbPosition )
       
   551     {
       
   552     FUNC_LOG;
       
   553     iScrollBarThumbPosition = aThumbPosition;
   360     }
   554     }
   361 
   555 
   362 // ---------------------------------------------------------------------------
   556 // ---------------------------------------------------------------------------
   363 // CESMRView::SetContainerWindowL
   557 // CESMRView::SetContainerWindowL
   364 // ---------------------------------------------------------------------------
   558 // ---------------------------------------------------------------------------
   365 //
   559 //
   366 void CESMRView::SetContainerWindowL(const CCoeControl& aContainer)
   560 void CESMRView::SetContainerWindowL( const CCoeControl& aContainer )
   367     {
   561     {
   368     FUNC_LOG;
   562     FUNC_LOG;
   369     CCoeControl::SetContainerWindowL( aContainer );
   563     CCoeControl::SetContainerWindowL( aContainer );
   370     iTitle->SetContainerWindowL( *this );
   564 
   371     /**
   565     /**
   372      * Somehow if list is constructed before this SetContainerWindowL is called,
   566      * Somehow if list is constructed before this SetContainerWindowL is called,
   373      * all redraws throws KERN-EXEC 3 (the CCoeControl's iWin variable is NULL)
   567      * all redraws throws KERN-EXEC 3 (the CCoeControl's iWin variable is NULL)
   374      */
   568      */
   375     
   569 
   376     iList = CESMRListComponent::NewL( this, iStorage, iLayout );
   570     iScrollBar = new (ELeave) CAknDoubleSpanScrollBar( this );
   377     iList->SetBackground( this );
   571     iScrollBar->ConstructL( EFalse, this, this, CEikScrollBar::EVertical, 0 );
   378     // Font size setting Observer can now be set
   572     iScrollBar->SetModel( &iScrollBarModel );
   379     iLayout->SetObserver( this );
   573     iScrollBar->MakeVisible( ETrue );
       
   574 
       
   575     iControls.AppendL( iScrollBar );
       
   576     
       
   577     iListPane = CMRListPane::NewL(
       
   578             *this,
       
   579             *iStorage,
       
   580             iScrollBarModel,
       
   581             *iScrollBar,
       
   582             *this );
       
   583 
       
   584     iControls.AppendL( iListPane );
       
   585     
       
   586     iListPane->SetBackground( this );
       
   587 
       
   588     iBgContext = CAknsBasicBackgroundControlContext::NewL(
       
   589             KAknsIIDQsnBgAreaMain, Rect(), ETrue );
       
   590 
       
   591     if( iEntry )
       
   592         {
       
   593         MESMRCalDbMgr& dbMgr = iEntry->GetDBMgr();
       
   594         dbMgr.SetCurCalendarByEntryL( *iEntry );
       
   595         }
       
   596 
       
   597     // Physics: enable needed pointer events
       
   598     EnableDragEvents();
       
   599     ClaimPointerGrab();
       
   600 
       
   601     // Initialize the focus
       
   602     iFocusStrategy.InitializeFocus();
       
   603 
       
   604     if( iEntry->Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
       
   605         {
       
   606         // Static cast is safe here. We know for sure that entry is MR
       
   607         MESMRMeetingRequestEntry* mrEntry =
       
   608                 static_cast<MESMRMeetingRequestEntry*>( iEntry );
       
   609         if ( mrEntry->IsOpenedFromMail() )
       
   610             {
       
   611             TAknLayoutRect naviArrowRightLayoutRect =
       
   612                         NMRLayoutManager::GetLayoutRect( Rect(),
       
   613                                 NMRLayoutManager::EMRLayoutMRNaviArrowRight );
       
   614             TRect naviArrowRect( naviArrowRightLayoutRect.Rect() );
       
   615             
       
   616             iNaviArrowLeft = CMRNaviArrow::NewL(
       
   617                     this, 
       
   618                     CMRNaviArrow::EMRArrowLeft, 
       
   619             		iObserver, 
       
   620             		naviArrowRect.Size()  );
       
   621             
       
   622             iNaviArrowRight = CMRNaviArrow::NewL( 
       
   623                     this, 
       
   624                     CMRNaviArrow::EMRArrowRight, 
       
   625             		iObserver, 
       
   626             		naviArrowRect.Size() );
       
   627             
       
   628             iControls.AppendL( iNaviArrowLeft );
       
   629             iControls.AppendL( iNaviArrowRight );
       
   630             }
       
   631         }
   380     }
   632     }
   381 
   633 
   382 // ---------------------------------------------------------------------------
   634 // ---------------------------------------------------------------------------
   383 // CESMRView::CountComponentControls
   635 // CESMRView::CountComponentControls
   384 // ---------------------------------------------------------------------------
   636 // ---------------------------------------------------------------------------
   385 //
   637 //
   386 TInt CESMRView::CountComponentControls() const
   638 TInt CESMRView::CountComponentControls() const
   387     {
   639     {
   388     FUNC_LOG;
   640     FUNC_LOG;
   389     TInt count( 0 );
   641     return iControls.Count();
   390 
       
   391     if ( iTitle )
       
   392         ++count;
       
   393 
       
   394     if ( iList )
       
   395         ++count;
       
   396 
       
   397     return count;
       
   398     }
   642     }
   399 
   643 
   400 // ---------------------------------------------------------------------------
   644 // ---------------------------------------------------------------------------
   401 // CESMRView::ComponentControl()
   645 // CESMRView::ComponentControl()
   402 // ---------------------------------------------------------------------------
   646 // ---------------------------------------------------------------------------
   403 //
   647 //
   404 CCoeControl* CESMRView::ComponentControl( TInt aInd ) const
   648 CCoeControl* CESMRView::ComponentControl( TInt aInd ) const
   405     {
   649     {
   406     FUNC_LOG;
   650     FUNC_LOG;
   407     switch ( aInd )
   651     return iControls[aInd];
   408         {
       
   409         case 0:
       
   410         	{
       
   411             return iTitle;
       
   412         	}
       
   413         case 1:
       
   414         	{
       
   415             return iList;
       
   416         	}
       
   417         default:
       
   418         	{
       
   419             return NULL;
       
   420         	}
       
   421         }
       
   422     }
   652     }
   423 
   653 
   424 // ---------------------------------------------------------------------------
   654 // ---------------------------------------------------------------------------
   425 // CESMRView::SizeChanged()
   655 // CESMRView::SizeChanged()
   426 // ---------------------------------------------------------------------------
   656 // ---------------------------------------------------------------------------
   427 //
   657 //
   428 void CESMRView::SizeChanged()
   658 void CESMRView::SizeChanged()
   429     {
   659     {
   430     FUNC_LOG;
   660     FUNC_LOG;
   431     
   661     
   432     TRect rect( Rect() );
   662     // If list pane is not yet constructed, no point in layouting anything
   433     if ( iTitle )
   663     if( !iListPane )
   434         {
   664         {
   435         TAknWindowComponentLayout titleLayout =
   665         return;
   436             NMRLayoutManager::GetWindowComponentLayout( NMRLayoutManager::EMRLayoutCtrlBar );
   666         }
   437         AknLayoutUtils::LayoutControl( iTitle, rect, titleLayout );
   667             
   438         }
   668     TRect containerRect( Rect() );
   439     if ( iList )
   669     
   440         {
   670     // Get the rect of stripe.
   441         TAknWindowComponentLayout listLayout =
   671     TAknLayoutRect stripeLayoutRect =
   442             NMRLayoutManager::GetWindowComponentLayout( NMRLayoutManager::EMRLayoutContentArea );
   672         NMRLayoutManager::GetLayoutRect( containerRect,
   443         AknLayoutUtils::LayoutControl( iList, rect, listLayout );
   673                 NMRLayoutManager::EMRLayoutStripe );
   444         }
   674     iStripeRect = stripeLayoutRect.Rect();
       
   675     
       
   676     // Layouting listpane, scroll bar and navi arrows in landscape mode
       
   677     if( Layout_Meta_Data::IsLandscapeOrientation() )
       
   678         {
       
   679         TAknLayoutRect listareaLayoutRect =
       
   680                 NMRLayoutManager::GetLayoutRect( containerRect,
       
   681                         NMRLayoutManager::EMRLayoutListArea );
       
   682         TRect listareaRect( listareaLayoutRect.Rect() );
       
   683 
       
   684         // List panes default rect needs to be modified due to
       
   685         // possible toolbar, scrollbar and calendar indication stripe
       
   686         
       
   687         // Remove stripe width from list pane width
       
   688         listareaRect.iTl.iX += iStripeRect.Width();
       
   689         
       
   690         // Remove toolbar width from list pane width
       
   691         listareaRect.iBr.iX -= iToolbar.Rect().Width();
       
   692         
       
   693         if( iScrollBar )
       
   694            {
       
   695            TAknLayoutRect scrollareaLayoutRect =
       
   696                NMRLayoutManager::GetLayoutRect( containerRect,
       
   697                        NMRLayoutManager::EMRLayoutScrollBar );
       
   698            TRect scrollareaRect( scrollareaLayoutRect.Rect() );
       
   699            // Scroll bar's height is always the same as listpane's height
       
   700            scrollareaRect.SetHeight( listareaRect.Height() );
       
   701            
       
   702            // Scrollbar needs to be moved to the left side of possible
       
   703            // toolbar
       
   704            scrollareaRect.Move( -iToolbar.Rect().Width(), 0 );
       
   705            iScrollBar->SetRect( scrollareaRect );
       
   706            
       
   707            // Remove scroll bar width from list area's width
       
   708            listareaRect.iBr.iX -= iScrollBar->Rect().Width();
       
   709            }
       
   710 
       
   711         iListPane->SetRect( listareaRect );
       
   712         
       
   713         // Make sure, that stripe height is the list pane height
       
   714         iStripeRect.SetHeight( iListPane->Rect().Height() );
       
   715 
       
   716         if(iViewMode == EESMRViewMR)
       
   717             {
       
   718             if( iNaviArrowLeft )
       
   719                 {
       
   720                 TAknLayoutRect naviArrowLeftLayoutRect =
       
   721                     NMRLayoutManager::GetLayoutRect( containerRect,
       
   722                             NMRLayoutManager::EMRLayoutMRNaviArrowLeft );
       
   723                 TRect naviArrowLeftRect( naviArrowLeftLayoutRect.Rect() );
       
   724     
       
   725                 // Left arrow needs to be moved right the amount of
       
   726                 // stripe width in landscape
       
   727                 naviArrowLeftRect.Move( iStripeRect.Width(), 0 );
       
   728                 
       
   729                 iNaviArrowLeft->SetRect( naviArrowLeftRect );
       
   730                 }
       
   731     
       
   732             if( iNaviArrowRight )
       
   733                 {
       
   734                 TAknLayoutRect naviArrowRightLayoutRect =
       
   735                         NMRLayoutManager::GetLayoutRect( containerRect,
       
   736                                 NMRLayoutManager::EMRLayoutMRNaviArrowRight );
       
   737                 TRect naviArrowRightRect( naviArrowRightLayoutRect.Rect() );
       
   738     
       
   739                 // Right arrow needs to be moved left the amount of
       
   740                 // possible toolbar width in landscape
       
   741                 TInt scrollWidth( 0 );
       
   742                 if( iScrollBar )
       
   743                     {
       
   744                     scrollWidth = iScrollBar->Rect().Width();
       
   745                     }
       
   746                 
       
   747                 naviArrowRightRect.Move( 
       
   748                         -( iToolbar.Rect().Width() + scrollWidth ), 0 );
       
   749     
       
   750                 iNaviArrowRight->SetRect( naviArrowRightRect );
       
   751                 }
       
   752             }
       
   753         else
       
   754             {
       
   755             SetNaviArrowStatus( EFalse, EFalse );
       
   756             }
       
   757         }
       
   758 
       
   759     // Layouting listpane, scroll bar and navi arrows in portrait mode
       
   760     else
       
   761         {
       
   762         TAknLayoutRect listareaLayoutRect =
       
   763                NMRLayoutManager::GetLayoutRect( containerRect,
       
   764                        NMRLayoutManager::EMRLayoutListArea );
       
   765         TRect listareaRect( listareaLayoutRect.Rect() );
       
   766         
       
   767         // The listPane's area should be:
       
   768         // X: Should subtract the width of stripe
       
   769         // Y: Should subtract the height of MRToolbar
       
   770         listareaRect.iTl.iX += iStripeRect.Width();
       
   771         listareaRect.iBr.iY -= iToolbar.Rect().Height();
       
   772                 
       
   773         iListPane->SetRect( listareaRect );
       
   774         
       
   775         if( iScrollBar )
       
   776            {
       
   777            TAknLayoutRect scrollareaLayoutRect =
       
   778                NMRLayoutManager::GetLayoutRect( containerRect,
       
   779                        NMRLayoutManager::EMRLayoutScrollBar );
       
   780            TRect scrollareaRect( scrollareaLayoutRect.Rect() );
       
   781            // Scroll bar's height is always the same as listpane's height
       
   782            scrollareaRect.SetHeight( iListPane->Rect().Height() );
       
   783            iScrollBar->SetRect( scrollareaRect );
       
   784            }
       
   785         
       
   786         // Make sure, that stripe height is the list pane height
       
   787         iStripeRect.SetHeight( iListPane->Rect().Height() );
       
   788 
       
   789         if(iViewMode == EESMRViewMR)
       
   790             {
       
   791             if( iNaviArrowLeft )
       
   792                 {
       
   793                 TAknLayoutRect naviArrowLeftLayoutRect =
       
   794                     NMRLayoutManager::GetLayoutRect( containerRect,
       
   795                             NMRLayoutManager::EMRLayoutMRNaviArrowLeft );
       
   796                 TRect naviArrowLeftRect( naviArrowLeftLayoutRect.Rect() );
       
   797             
       
   798                 // Left arrow needs to be moved right the amount of
       
   799                 // stripe width in portrait
       
   800                 naviArrowLeftRect.Move( iStripeRect.Width(), 0 );
       
   801                 
       
   802                 // Left arrow needs to be moved up the amount of
       
   803                 // possible toolbar height in portrait
       
   804                 naviArrowLeftRect.Move( 0, -iToolbar.Rect().Height() );
       
   805                 
       
   806                 iNaviArrowLeft->SetRect( naviArrowLeftRect );
       
   807                 }
       
   808             
       
   809             if( iNaviArrowRight )
       
   810                 {
       
   811                 TAknLayoutRect naviArrowRightLayoutRect =
       
   812                         NMRLayoutManager::GetLayoutRect( containerRect,
       
   813                                 NMRLayoutManager::EMRLayoutMRNaviArrowRight );
       
   814                 TRect naviArrowRightRect( naviArrowRightLayoutRect.Rect() );
       
   815             
       
   816                 // Right arrow needs to be moved right the amount of
       
   817                 // stripe width in portrait
       
   818                 naviArrowRightRect.Move( iStripeRect.Width(), 0 );
       
   819                 
       
   820                 // Right arrow needs to be moved up the amount of
       
   821                 // possible toolbar height in portrait
       
   822                 naviArrowRightRect.Move( 0, -iToolbar.Rect().Height() );
       
   823                 
       
   824                 
       
   825                 iNaviArrowRight->SetRect( naviArrowRightRect );
       
   826                 }
       
   827             }
       
   828         else
       
   829             {
       
   830             SetNaviArrowStatus( EFalse, EFalse );
       
   831             }
       
   832         }
       
   833     
       
   834     if ( iAttachmentIndicator )
       
   835         {
       
   836         iAttachmentIndicator->SetRect( 
       
   837                 CalculateAttachmentIndicatorLayout() );
       
   838         }
       
   839     
   445     if( iBgContext )
   840     if( iBgContext )
   446         {
   841         {
   447         iBgContext->SetRect( rect );
   842         iBgContext->SetRect( containerRect );
   448         if ( &Window() )
   843         if ( &Window() )
   449             {
   844             {
   450             iBgContext->SetParentPos( PositionRelativeToScreen() );
   845             iBgContext->SetParentPos( PositionRelativeToScreen() );
   451             }
   846             }
   452         }
   847         }
   468 // ---------------------------------------------------------------------------
   863 // ---------------------------------------------------------------------------
   469 // CESMRView::OfferKeyEventL
   864 // CESMRView::OfferKeyEventL
   470 // ---------------------------------------------------------------------------
   865 // ---------------------------------------------------------------------------
   471 //
   866 //
   472 TKeyResponse CESMRView::OfferKeyEventL(
   867 TKeyResponse CESMRView::OfferKeyEventL(
   473 		const TKeyEvent &aKeyEvent, 
   868 		const TKeyEvent &aKeyEvent,
   474 		TEventCode aType)
   869 		TEventCode aType)
   475     {
   870     {
   476     FUNC_LOG;
   871     FUNC_LOG;
   477     TKeyResponse response( EKeyWasNotConsumed );
   872     TKeyResponse response( EKeyWasNotConsumed );
   478     if ( iList )
   873     if ( iListPane )
   479         {
   874         {
   480         response = iList->OfferKeyEventL( aKeyEvent, aType );
   875         // Use focus strategy
       
   876         iFocusStrategy.EventOccured( MMRFocusStrategy::EFocusKeyEvent );
       
   877 
       
   878         TBool forwardEvent( ETrue );
       
   879         // Remove Delete hw key command if the focus is not visible
       
   880         if ( !iFocusStrategy.IsFocusVisible() )
       
   881             {
       
   882             if ( aType == EEventKey && aKeyEvent.iCode == EKeyBackspace )
       
   883                 {
       
   884                 forwardEvent = EFalse;
       
   885                 }
       
   886             }
       
   887 
       
   888         if ( forwardEvent )
       
   889             {
       
   890             response = iListPane->OfferKeyEventL( aKeyEvent, aType );
       
   891             iListPane->DrawDeferred();
       
   892             }
   481         }
   893         }
   482     return response;
   894     return response;
   483     }
   895     }
       
   896 
   484 
   897 
   485 // ---------------------------------------------------------------------------
   898 // ---------------------------------------------------------------------------
   486 // CESMRView::Draw
   899 // CESMRView::Draw
   487 // This Draw is called when background for title pane (iTitle) is drawn
   900 // This Draw is called when background for title pane (iTitle) is drawn
   488 // ---------------------------------------------------------------------------
   901 // ---------------------------------------------------------------------------
   489 //
   902 //
   490 void CESMRView::Draw( const TRect& aRect ) const
   903 void CESMRView::Draw( const TRect& aRect ) const
   491     {
   904     {
   492     FUNC_LOG;
   905     FUNC_LOG;
   493     CWindowGc& gc = SystemGc();
   906     CWindowGc& gc = SystemGc();
   494       
   907 
   495     // Draw the background for iTitle using the current skin
   908     // Draw the background for iTitle using the current skin
   496     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   909     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   497     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
   910     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
   498     AknsDrawUtils::Background( skin, cc, this, gc, aRect );
   911     AknsDrawUtils::Background( skin, cc, this, gc, aRect );
       
   912 
       
   913     // Draw color stripe
       
   914     MESMRCalDbMgr& DbMgr = iEntry->GetDBMgr();
       
   915 
       
   916     TRgb stripeColor = DbMgr.GetCurCalendarColor();
       
   917     gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   918     gc.SetBrushColor( stripeColor );
       
   919     gc.DrawRect( iStripeRect );
       
   920 
       
   921     gc.Reset();
   499     }
   922     }
   500 
   923 
   501 // ---------------------------------------------------------------------------
   924 // ---------------------------------------------------------------------------
   502 // CESMRView::Draw
   925 // CESMRView::Draw
   503 // This draw method draws the dialog area
   926 // This draw method draws the dialog area
   504 // ---------------------------------------------------------------------------
   927 // ---------------------------------------------------------------------------
   505 //
   928 //
   506 void CESMRView::Draw(
   929 void CESMRView::Draw(
   507 		CWindowGc&  aGc , 
   930 		CWindowGc& /* aGc */,
   508 		const CCoeControl& /* aControl */, 
   931 		const CCoeControl& aControl,
   509 		const TRect& /*aRect*/) const
   932 		const TRect& /*aRect*/) const
   510     {
   933     {
   511     FUNC_LOG;
   934     FUNC_LOG;
   512     aGc.Clear();
   935     CWindowGc& gc = SystemGc();
       
   936 
       
   937     // Draw the background for aControl using the current skin
       
   938     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   939     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   940     AknsDrawUtils::Background( skin, cc, &aControl, gc, aControl.Rect() );
   513     }
   941     }
   514 
   942 
   515 // ---------------------------------------------------------------------------
   943 // ---------------------------------------------------------------------------
   516 // CESMRView::GetTextDrawer
   944 // CESMRView::GetTextDrawer
   517 // ---------------------------------------------------------------------------
   945 // ---------------------------------------------------------------------------
   518 //
   946 //
   519 void CESMRView::GetTextDrawer(
   947 void CESMRView::GetTextDrawer(
   520 		CCoeTextDrawerBase*& /*aText*/, 
   948 		CCoeTextDrawerBase*& /*aText*/,
   521 		const CCoeControl* /*aControl*/) const
   949 		const CCoeControl* /*aControl*/) const
   522     {
   950     {
   523     // Do nothing
   951     // Do nothing
   524     }
   952     }
   525 
   953 
   526 // ---------------------------------------------------------------------------
   954 // ---------------------------------------------------------------------------
   527 // CESMRView::SetTitleL()
   955 // CESMRView::SetTitleL()
   528 // ---------------------------------------------------------------------------
   956 // ---------------------------------------------------------------------------
   529 //
   957 //
   530 void CESMRView::SetTitleL( const TDesC& aTitle, TBool aDefault)
   958 void CESMRView::SetTitleL( const TDesC& /*aTitle*/, TBool /*aDefault*/)
   531     {
   959     {
   532     FUNC_LOG;
   960     FUNC_LOG;
   533     iTitle->SetTextL( aTitle );
       
   534     iTitle->SetDefaultIcon(aDefault);
       
   535     }
   961     }
   536 
   962 
   537 // ---------------------------------------------------------------------------
   963 // ---------------------------------------------------------------------------
   538 // CESMRView::SetControlFocusedL()
   964 // CESMRView::SetControlFocusedL()
   539 // ---------------------------------------------------------------------------
   965 // ---------------------------------------------------------------------------
   540 //
   966 //
   541 void CESMRView::SetControlFocusedL( TESMREntryFieldId aField )
   967 void CESMRView::SetControlFocusedL( TESMREntryFieldId aField )
   542     {
   968     {
   543     FUNC_LOG;
   969     FUNC_LOG;
   544     iList->ListObserver().SetControlFocusedL( aField );
   970     iListPane->SetControlFocusedL( aField );
   545     }
       
   546 
       
   547 // ---------------------------------------------------------------------------
       
   548 // CESMRView::FontSizeSettingsChanged()
       
   549 // ---------------------------------------------------------------------------
       
   550 //
       
   551 void CESMRView::FontSizeSettingsChanged()
       
   552     {
       
   553     FUNC_LOG;
       
   554     iList->HandleFontChange();
       
   555     SizeChanged();
       
   556     }
   971     }
   557 
   972 
   558 // ---------------------------------------------------------------------------
   973 // ---------------------------------------------------------------------------
   559 // CESMRView::HandleResourceChange()
   974 // CESMRView::HandleResourceChange()
   560 // ---------------------------------------------------------------------------
   975 // ---------------------------------------------------------------------------
   562 void CESMRView::HandleResourceChange( TInt aType )
   977 void CESMRView::HandleResourceChange( TInt aType )
   563     {
   978     {
   564     FUNC_LOG;
   979     FUNC_LOG;
   565     CCoeControl::HandleResourceChange( aType );
   980     CCoeControl::HandleResourceChange( aType );
   566     TInt error = KErrNone;
   981     TInt error = KErrNone;
   567     
   982 
   568     switch ( aType )
   983     switch ( aType )
   569         {
   984         {
   570         case  KAknsMessageSkinChange:
   985         case  KAknsMessageSkinChange:
   571             {
   986             {
   572             TRAP( error, iList->InitializeL() );
   987             TRAP( error, iListPane->InitializeL() );
   573             SizeChanged();
       
   574             break;
   988             break;
   575             }
   989             }
   576         case KEikMessageColorSchemeChange:
   990         case KEikMessageColorSchemeChange:
   577             {
   991             {
   578             TRAP( error, iList->InitializeL() );
   992             TRAP( error, iListPane->InitializeL() );
   579             SizeChanged();
       
   580             break;
   993             break;
   581             }
   994             }
   582         case KEikDynamicLayoutVariantSwitch:
   995         case KEikDynamicLayoutVariantSwitch:
   583         case KAknLocalZoomLayoutSwitch:
   996         case KAknLocalZoomLayoutSwitch:
   584             {
   997             {
   585             SizeChanged();
   998             SizeChanged();
       
   999             DrawNow();
   586             break;
  1000             break;
   587             }
  1001             }
   588         default:
  1002         default:
   589             {
  1003             {
   590             break;
  1004             break;
   601 // CESMRView::MopSupplyObject()
  1015 // CESMRView::MopSupplyObject()
   602 // ---------------------------------------------------------------------------
  1016 // ---------------------------------------------------------------------------
   603 //
  1017 //
   604 TTypeUid::Ptr CESMRView::MopSupplyObject( TTypeUid aId )
  1018 TTypeUid::Ptr CESMRView::MopSupplyObject( TTypeUid aId )
   605     {
  1019     {
       
  1020     FUNC_LOG;
   606     if ( iBgContext )
  1021     if ( iBgContext )
   607         {
  1022         {
   608         return MAknsControlContext::SupplyMopObject( aId, iBgContext );
  1023         return MAknsControlContext::SupplyMopObject( aId, iBgContext );
   609         }
  1024         }
   610     return CCoeControl::MopSupplyObject( aId );
  1025     return CCoeControl::MopSupplyObject( aId );
   611     }
  1026     }
   612     
  1027 
   613 // <cmail>
  1028 // -----------------------------------------------------------------------------
   614 // ---------------------------------------------------------------------------
  1029  // CESMRView::HandlePointerEventL()
   615 // CESMRView::FocusChanged
  1030  // -----------------------------------------------------------------------------
   616 // ---------------------------------------------------------------------------
  1031  //
   617 //
  1032  void CESMRView::HandlePointerEventL(
   618 void CESMRView::FocusChanged(TDrawNow aDrawNow)
  1033      const TPointerEvent &aPointerEvent )
   619     {
  1034      {
   620     CCoeControl::FocusChanged(aDrawNow);
  1035      FUNC_LOG;
   621     
  1036      // Call focus strategy
   622     // if attachments are focused, update the field to make sure
  1037      iFocusStrategy.EventOccured( MMRFocusStrategy::EFocusPointerEvent );
   623     // attachment status is shown correctly
  1038 
   624     if( IsComponentFocused( EESMRFieldAttachments ) )
  1039      CCoeControl::HandlePointerEventL( aPointerEvent );
   625         {
  1040      }
   626         TRAP_IGNORE( iList->FocusedItem()->SetOutlineFocusL(ETrue) );
  1041 
   627         }
  1042 // ---------------------------------------------------------------------------
   628     }
  1043 // CESMRView::InitialScroll()
   629 // </cmail>
  1044 // ---------------------------------------------------------------------------
       
  1045 //
       
  1046 void CESMRView::InitialScrollL()
       
  1047     {
       
  1048     FUNC_LOG;
       
  1049     iListPane->InitialScrollL();
       
  1050     }
       
  1051 
       
  1052 // ---------------------------------------------------------------------------
       
  1053 // CESMRView::DynInitMenuPaneL
       
  1054 // ---------------------------------------------------------------------------
       
  1055 //
       
  1056 void CESMRView::DynInitMenuPaneL(
       
  1057         TMRMenuStyle aMenuStyle,
       
  1058         TInt aResourceId,
       
  1059         CEikMenuPane* aMenuPane )
       
  1060     {
       
  1061     FUNC_LOG;
       
  1062     // Initialize field specific options in context menu and options menu.
       
  1063     // Options menu has field specific options only when focus is visible.
       
  1064     if ( aMenuStyle != EMROptionsMenu
       
  1065          || ( aMenuStyle == EMROptionsMenu
       
  1066               && iFocusStrategy.IsFocusVisible() ) )
       
  1067         {
       
  1068         CESMRField* field = iStorage->FieldById( ClickedOrFocusedField() );
       
  1069         field->DynInitMenuPaneL( aResourceId, aMenuPane );
       
  1070         }
       
  1071     }
       
  1072 
       
  1073 // ---------------------------------------------------------------------------
       
  1074 // CESMRView::SetNaviArrowStatus
       
  1075 // ---------------------------------------------------------------------------
       
  1076 //
       
  1077 void CESMRView::SetNaviArrowStatus( 
       
  1078         TBool aLeftArrowVisible, 
       
  1079         TBool aRightArrowVisible )
       
  1080     {
       
  1081     FUNC_LOG;
       
  1082     if ( iNaviArrowLeft )
       
  1083         {
       
  1084         iNaviArrowLeft->SetNaviArrowStatus( aLeftArrowVisible );
       
  1085         }
       
  1086     if ( iNaviArrowRight )
       
  1087         {
       
  1088         iNaviArrowRight->SetNaviArrowStatus( aRightArrowVisible );
       
  1089         }
       
  1090     }
       
  1091 // ---------------------------------------------------------------------------
       
  1092 // CESMRView::SetViewMode
       
  1093 // ---------------------------------------------------------------------------
       
  1094 //
       
  1095 void CESMRView::SetViewMode(TESMRViewMode aMode)
       
  1096 	{
       
  1097     FUNC_LOG;
       
  1098 	iViewMode = aMode;
       
  1099 	}
       
  1100 // ---------------------------------------------------------------------------
       
  1101 // CESMRView::GetViewMode
       
  1102 // ---------------------------------------------------------------------------
       
  1103 //
       
  1104 TESMRViewMode CESMRView::GetViewMode()
       
  1105 	{
       
  1106     FUNC_LOG;
       
  1107 	return iViewMode;
       
  1108 	}
       
  1109 
       
  1110 // ---------------------------------------------------------------------------
       
  1111 // CESMRView::ReLayout
       
  1112 // ---------------------------------------------------------------------------
       
  1113 //
       
  1114 void CESMRView::ReLayout()
       
  1115     {
       
  1116     FUNC_LOG;
       
  1117     SizeChanged();
       
  1118     }
       
  1119 
       
  1120 // ---------------------------------------------------------------------------
       
  1121 // CESMRView::ProcessEventL
       
  1122 // ---------------------------------------------------------------------------
       
  1123 //
       
  1124 void CESMRView::ProcessEventL( const MESMRFieldEvent& aEvent )
       
  1125     {
       
  1126     FUNC_LOG;
       
  1127 
       
  1128     if ( MESMRFieldEvent::EESMRFieldChangeEvent ==  aEvent.Type() )
       
  1129         {
       
  1130         TInt* fieldId = static_cast< TInt* >( aEvent.Param( 0 ) );
       
  1131         
       
  1132         if ( EESMRFieldViewerAttachments == *fieldId )
       
  1133             {
       
  1134             if ( !iAttachmentIndicator )
       
  1135                 {
       
  1136                 TRect attachmentDownloadIndicatorRect( 
       
  1137                         CalculateAttachmentIndicatorLayout() );
       
  1138                 
       
  1139                 iAttachmentIndicator = CMRAttachmentIndicator::NewL( 
       
  1140                         attachmentDownloadIndicatorRect, 
       
  1141                         this );
       
  1142     
       
  1143                 CFbsBitmap* bitMap( NULL );
       
  1144                 CFbsBitmap* bitMapMask( NULL );
       
  1145                 TSize size( 0,0 );
       
  1146                 NMRBitmapManager::GetSkinBasedBitmapLC(
       
  1147                                 NMRBitmapManager::EMRBitmapDownloadAttachment,
       
  1148                                 bitMap, bitMapMask, size );
       
  1149                 
       
  1150                 CleanupStack::Pop( 2 ); // bitMap, bitMapMask
       
  1151                 
       
  1152                 
       
  1153                 
       
  1154                 iAttachmentIndicator->SetImage( bitMap, bitMapMask );
       
  1155                 iControls.AppendL( iAttachmentIndicator );
       
  1156                 }
       
  1157             
       
  1158             MESMRFieldEventValue* value =
       
  1159                     static_cast< MESMRFieldEventValue* >( aEvent.Param( 1 ) );
       
  1160             
       
  1161             iAttachmentIndicator->SetTextL( value->StringValue() );            
       
  1162             iAttachmentIndicator->MakeVisible( ETrue );
       
  1163             
       
  1164             ReLayout();        
       
  1165             }
       
  1166         }
       
  1167     }
       
  1168 
       
  1169 // ---------------------------------------------------------------------------
       
  1170 // CESMRView::CalculateAttachmentIndicatorLayout
       
  1171 // ---------------------------------------------------------------------------
       
  1172 //
       
  1173 TRect CESMRView::CalculateAttachmentIndicatorLayout()
       
  1174     {
       
  1175     TRect containerRect( Rect() );
       
  1176     
       
  1177     TAknLayoutRect naviArrowLeftLayoutRect =
       
  1178             NMRLayoutManager::GetLayoutRect( containerRect,
       
  1179                     NMRLayoutManager::EMRLayoutMRNaviArrowLeft );    
       
  1180     TRect naviArrowLeftRect = naviArrowLeftLayoutRect.Rect();
       
  1181     
       
  1182     TAknLayoutRect naviArrowRightLayoutRect =
       
  1183             NMRLayoutManager::GetLayoutRect( containerRect,
       
  1184                     NMRLayoutManager::EMRLayoutMRNaviArrowRight );
       
  1185     TRect naviArrowRightRect = naviArrowRightLayoutRect.Rect();
       
  1186     
       
  1187     if( Layout_Meta_Data::IsLandscapeOrientation() )
       
  1188         {                
       
  1189         naviArrowLeftRect.Move( iStripeRect.Width(), 0 );
       
  1190 
       
  1191         TInt scrollWidth( 0 );
       
  1192         if( iScrollBar )
       
  1193             {
       
  1194             scrollWidth = iScrollBar->Rect().Width();
       
  1195             }
       
  1196         
       
  1197         naviArrowRightRect.Move( 
       
  1198                 -( iToolbar.Rect().Width() + scrollWidth ), 0 );    
       
  1199         }
       
  1200     else
       
  1201         {
       
  1202         // Left arrow needs to be moved right the amount of
       
  1203         // stripe width in portrait
       
  1204         naviArrowLeftRect.Move( iStripeRect.Width(), 0 );
       
  1205         naviArrowLeftRect.Move( 0, -iToolbar.Rect().Height() );
       
  1206 
       
  1207         TRect naviArrowRightRect = naviArrowRightLayoutRect.Rect();
       
  1208         
       
  1209         naviArrowRightRect.Move( iStripeRect.Width(), 0 );
       
  1210         naviArrowRightRect.Move( 0, -iToolbar.Rect().Height() );        
       
  1211         }   
       
  1212 
       
  1213     // Get height for one row 
       
  1214     TAknLayoutRect rowLayout = 
       
  1215         NMRLayoutManager::GetLayoutRect( 
       
  1216                 containerRect, NMRLayoutManager::EMRLayoutTextEditorIcon );
       
  1217     TRect rowRect( rowLayout.Rect() );
       
  1218     
       
  1219     TRect attachmentIndicatorRect;
       
  1220     /*attachmentIndicatorRect.iTl = 
       
  1221             TPoint( naviArrowLeftRect.iBr.iX, 
       
  1222                     naviArrowLeftRect.iBr.iY - rowRect.Height() ); */
       
  1223     
       
  1224     attachmentIndicatorRect.iTl = 
       
  1225                 TPoint( naviArrowLeftRect.iBr.iX, 
       
  1226                         naviArrowLeftRect.iBr.iY - naviArrowLeftRect.Height() );    
       
  1227     
       
  1228     attachmentIndicatorRect.iBr = 
       
  1229             TPoint(  naviArrowRightRect.iTl.iX, 
       
  1230                     naviArrowLeftRect.iBr.iY );
       
  1231     
       
  1232     return attachmentIndicatorRect;
       
  1233     }
   630 
  1234 
   631 // EOF
  1235 // EOF
   632