calendarui/views/src/calendaycontainer.cpp
changeset 0 f979ecb2b13e
child 10 38571fd2a704
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  For Day view container of calendar application.
       
    15  *                The class derived from CCalenContainer
       
    16  *
       
    17 */
       
    18 
       
    19 
       
    20 //debug
       
    21 #include "calendarui_debug.h"
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include "calendaycontainer.h"
       
    25 #include "calencontainerlayoutmanager.h"
       
    26 #include "calencontroller.h"
       
    27 
       
    28 #include <calenconstants.h>
       
    29 #include <calendateutils.h>
       
    30 #include "calendaylistboxmodel.h"
       
    31 #include "calendaylistboxview.h"
       
    32 #include "calendaylistbox.h"
       
    33 #include "calendayview.h"
       
    34 #include "CalenUid.h"
       
    35 #include <calenagendautils.h>
       
    36 #include <calenservices.h>
       
    37 #include "calenlocationutil.h"
       
    38 
       
    39 #include "calendar.hrh"
       
    40 #include <Calendar.rsg>
       
    41 #include <csxhelp/cale.hlp.hrh>
       
    42 
       
    43 #include <AknsDrawUtils.h>
       
    44 #include <AknsFrameBackgroundControlContext.h>
       
    45 #include <AknUtils.h>
       
    46 #include <AknIconArray.h>
       
    47 #include <eikfrlbd.h>
       
    48 #include <eiklabel.h>
       
    49 #include <eikmenub.h>
       
    50 #include <StringLoader.h>
       
    51 #include <calenviewutils.h>
       
    52 #include <aknlayoutscalable_apps.cdl.h>
       
    53 
       
    54 #include <calinstance.h>
       
    55 #include <calentry.h>
       
    56 #include <calinstanceview.h>
       
    57 #include <caltime.h>
       
    58 
       
    59 #include <AknDef.h>
       
    60 #include <calencontext.h>
       
    61 #include <akntoolbar.h>
       
    62 #include <aknstyluspopupmenu.h>
       
    63 #include <barsread.h>
       
    64 
       
    65 //  LOCAL CONSTANTS AND MACROS
       
    66 const TInt KLayoutTableGranularity(10);
       
    67 const TInt KNullMinutes = -1;
       
    68 
       
    69 // ================= MEMBER FUNCTIONS =======================
       
    70 
       
    71 // ----------------------------------------------------------------------------
       
    72 // CCalenDayContainer::CCalenDayContainer
       
    73 // C++ constructor
       
    74 // (other items were commented in a header).
       
    75 // ----------------------------------------------------------------------------
       
    76 //
       
    77 CCalenDayContainer::CCalenDayContainer( CCalenNativeView* aView,
       
    78                                         TTime& aDate,
       
    79                                         TInt& aHighlightedRowNumber,
       
    80                                         TInt& aFirstEntryOnScreenIndex,
       
    81                                         MCalenServices& aServices )
       
    82     : CCalenContainer( aView, aServices ),
       
    83       iDeletedIndex( KIndexError ),
       
    84       iDate( aDate ),
       
    85       iHighlightedRowNumber( aHighlightedRowNumber ),
       
    86       iFirstEntryOnScreenIndex( aFirstEntryOnScreenIndex )
       
    87     {
       
    88     TRACE_ENTRY_POINT;
       
    89     TRACE_EXIT_POINT;
       
    90     }
       
    91 
       
    92 // ----------------------------------------------------------------------------
       
    93 // CCalenDayContainer::~CCalenDayContainer
       
    94 // Destructor
       
    95 // (other items were commented in a header).
       
    96 // ----------------------------------------------------------------------------
       
    97 //
       
    98 CCalenDayContainer::~CCalenDayContainer()
       
    99     {
       
   100     TRACE_ENTRY_POINT;
       
   101 
       
   102     delete iListBoxModel;
       
   103     delete iListBox;
       
   104     iInstanceList.ResetAndDestroy();
       
   105     delete iLayoutTable;
       
   106     // Skin contexts
       
   107     delete iBackgroundSkinContext;
       
   108 
       
   109     TRACE_EXIT_POINT;
       
   110     }
       
   111 	
       
   112 // ---------------------------------------------------------
       
   113 // CCalenDayOnlyEventContainer::HandleListBoxEventL
       
   114 // Handle events incoming from list instance. 
       
   115 // ---------------------------------------------------------
       
   116 //
       
   117 void CCalenDayContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, 
       
   118                                                       TListBoxEvent aEventType)
       
   119     {
       
   120     TRACE_ENTRY_POINT;
       
   121     switch( aEventType )
       
   122         {
       
   123         // Single click integration
       
   124         case EEventItemSingleClicked:
       
   125             {
       
   126             //Handle listbox item selection event
       
   127             //iListBox->HandlePointerEventL(aPointerEvent);
       
   128             if(iView->MenuBar()->IsDisplayed() == EFalse)
       
   129                 {
       
   130                 iView->HandleCommandL( ECalenViewCurrentEntry );
       
   131                 }
       
   132             break;
       
   133             }
       
   134 			
       
   135         // Single click integration
       
   136         case EEventEnterKeyPressed:
       
   137             {
       
   138             iView->HandleCommandL( ECalenViewCurrentEntry );
       
   139             break;
       
   140             }
       
   141         default:
       
   142             break;
       
   143         };
       
   144     TRACE_EXIT_POINT;
       
   145     }
       
   146 	
       
   147 
       
   148 // ----------------------------------------------------------------------------
       
   149 // CCalenDayContainer::UpdateContainerL
       
   150 // Refresh Day view data and draws.
       
   151 // Data is based on active context.
       
   152 // (other items were commented in a header).
       
   153 // ----------------------------------------------------------------------------
       
   154 //
       
   155 void CCalenDayContainer::UpdateContainerL()
       
   156     {
       
   157     TRACE_ENTRY_POINT;
       
   158 
       
   159     UpdateStatusPaneAndExtensionsL();
       
   160 
       
   161     iView->BeginRepopulationL();
       
   162     iListBox->View()->SetDisableRedraw(ETrue);   
       
   163 
       
   164     TRACE_EXIT_POINT;
       
   165     }
       
   166 
       
   167 // ----------------------------------------------------------------------------
       
   168 // CCalenDayContainer::UpdateTimeFormat
       
   169 // ?implementation_description
       
   170 // (other items were commented in a header).
       
   171 // ----------------------------------------------------------------------------
       
   172 //
       
   173 void CCalenDayContainer::UpdateTimeFormat()
       
   174     {
       
   175     TRACE_ENTRY_POINT;
       
   176 
       
   177     SizeChanged();
       
   178 
       
   179     TRACE_EXIT_POINT;
       
   180     }
       
   181 
       
   182 // ----------------------------------------------------------------------------
       
   183 // CCalenDayContainer::DestroyInstanceListL
       
   184 // ?implementation_description
       
   185 // (other items were commented in a header).
       
   186 // ----------------------------------------------------------------------------
       
   187 //
       
   188 void CCalenDayContainer::DestroyInstanceListL()
       
   189     {
       
   190     TRACE_ENTRY_POINT;
       
   191 
       
   192     // NULL temporary instance references in layout table
       
   193     for ( TInt i=0; i < iLayoutTable->Count(); ++i )
       
   194         {
       
   195         iLayoutTable->At(i).iTmpInstance = NULL;
       
   196         }
       
   197 
       
   198     // Destroy instances.
       
   199     iInstanceList.ResetAndDestroy();
       
   200 
       
   201     TRACE_EXIT_POINT;
       
   202     }
       
   203 
       
   204 // ----------------------------------------------------------------------------
       
   205 // CCalenDayContainer::CreateListBoxDataL
       
   206 // Set Listbox data to ListBox
       
   207 // Step 4 of construction of ListBox data
       
   208 // (other items were commented in a header).
       
   209 // ----------------------------------------------------------------------------
       
   210 //
       
   211 void CCalenDayContainer::CreateListBoxDataL()
       
   212     {
       
   213     TRACE_ENTRY_POINT;
       
   214 
       
   215     MCalenContext& context = iServices.Context();
       
   216 	TInt aIndex = FindItemIndex( context.InstanceId() );
       
   217 	
       
   218     // ---------------------
       
   219     // Listbox model and view setup
       
   220     iListBox->View()->SetDisableRedraw(ETrue);
       
   221 
       
   222     CArrayFixFlat<TInt>* cellArray = new(ELeave)CArrayFixFlat<TInt>(5);
       
   223     CleanupStack::PushL(cellArray);
       
   224 
       
   225     iListBoxModel->CreateListBoxDataL( *iLayoutTable,
       
   226                                        *cellArray,
       
   227                                        iServices,
       
   228                                        iDate );
       
   229 
       
   230     CleanupStack::Pop( cellArray );
       
   231     View()->SetCellArray( cellArray );
       
   232     
       
   233     UpdateHighlightedRowIfDeletedL();
       
   234     if(iHighlightedRowNumber!=KErrNotFound)
       
   235         {
       
   236         // Cycled to from another view when no one changed the context,
       
   237         // or refreshing current view. No need to set context.
       
   238       	if (aIndex!=KErrNotFound ) 
       
   239        		{
       
   240        		SItemInfo& itemInfo = (*iLayoutTable)[aIndex];
       
   241         	iHighlightedRowNumber = itemInfo.iTopLine;  
       
   242        		}
       
   243       	else if(iDeletedIndex!=KErrNotFound)
       
   244       	    {
       
   245       	    iDeletedIndex = KErrNotFound;
       
   246       	    }
       
   247       	else 
       
   248        	    {
       
   249        	    iHighlightedRowNumber = KErrNotFound;
       
   250        	    iFirstEntryOnScreenIndex = KErrNotFound;
       
   251        	    }
       
   252         }
       
   253 
       
   254     if(iDateWasNull) // iDate was null when population was started.
       
   255         {
       
   256         // Cycled to from another view after someone else changed the context.
       
   257         // Set the new highlight based on the context.
       
   258         SetHighlightFromContextL();
       
   259         }
       
   260     SetContextFromHighlightL();
       
   261 
       
   262     DestroyInstanceListL();
       
   263 
       
   264     iListBox->HandleItemAdditionL(); // Is this causing unnecessary draw?
       
   265 
       
   266     iListBox->View()->SetDisableRedraw(EFalse);
       
   267     iListBox->SetFocus(ETrue);
       
   268     iListBox->DrawNow();
       
   269     DayView().UpdateCbaL();
       
   270 
       
   271     TRACE_EXIT_POINT;
       
   272     }
       
   273 
       
   274 // ----------------------------------------------------------------------------
       
   275 // CCalenDayContainer::IsEmptyView
       
   276 // ?implementation_description
       
   277 // (other items were commented in a header).
       
   278 // ----------------------------------------------------------------------------
       
   279 //
       
   280 TBool CCalenDayContainer::IsEmptyView() const
       
   281     {
       
   282     TRACE_ENTRY_POINT;
       
   283 
       
   284     TRACE_EXIT_POINT;
       
   285     return (iListBox->Model()->NumberOfItems() <= 0);
       
   286     }
       
   287 
       
   288 // ----------------------------------------------------------------------------
       
   289 // CCalenDayContainer::FindItem
       
   290 // ?implementation_description
       
   291 // (other items were commented in a header).
       
   292 // ----------------------------------------------------------------------------
       
   293 //
       
   294 CCalenDayContainer::SItemInfo& CCalenDayContainer::FindItem( TInt aLineIndex ) const
       
   295     {
       
   296     TRACE_ENTRY_POINT;
       
   297 
       
   298     ASSERT( aLineIndex >= 0 );
       
   299 
       
   300     TInt itemIx = FindItemIndexForRow( aLineIndex );
       
   301     __ASSERT_DEBUG(itemIx >= 0, User::Invariant());
       
   302 
       
   303     SItemInfo& result = (*iLayoutTable)[itemIx];
       
   304 
       
   305     TRACE_EXIT_POINT;
       
   306     return result;
       
   307     }
       
   308 
       
   309 // ----------------------------------------------------------------------------
       
   310 // ?classname::?member_function
       
   311 // ?implementation_description
       
   312 // (other items were commented in a header).
       
   313 // ----------------------------------------------------------------------------
       
   314 //
       
   315 MCalenServices& CCalenDayContainer::Services()
       
   316     {
       
   317     TRACE_ENTRY_POINT
       
   318     TRACE_EXIT_POINT
       
   319     return iServices;
       
   320     }
       
   321 
       
   322 // ----------------------------------------------------------------------------
       
   323 // ?classname::?member_function
       
   324 // ?implementation_description
       
   325 // (other items were commented in a header).
       
   326 // ----------------------------------------------------------------------------
       
   327 //
       
   328 TInt CCalenDayContainer::FindItemIndexForRow( TInt aListIndex ) const
       
   329     {
       
   330     TRACE_ENTRY_POINT;
       
   331 
       
   332     for ( TInt i(0); i < iLayoutTable->Count(); ++i )
       
   333         {
       
   334         SItemInfo& item = (*iLayoutTable)[i];
       
   335         if ( item.iTopLine == aListIndex )
       
   336             {
       
   337             TRACE_EXIT_POINT;
       
   338             return i;
       
   339             }
       
   340         }
       
   341         
       
   342     TRACE_EXIT_POINT;
       
   343     return KIndexError;
       
   344     }
       
   345 
       
   346 // ----------------------------------------------------------------------------
       
   347 // CCalenDayContainer::UpdateHighlightedRowIfDeletedL
       
   348 // Updates the highlighted index based on whether an entry has just been
       
   349 // deleted.
       
   350 // (other items were commented in a header).
       
   351 // ----------------------------------------------------------------------------
       
   352 //
       
   353 void CCalenDayContainer::UpdateHighlightedRowIfDeletedL()
       
   354     {
       
   355     TRACE_ENTRY_POINT;
       
   356 
       
   357     CCalenDayListBoxView* view =  View();
       
   358     if ( iDeletedIndex != KErrNotFound )
       
   359         // If just deleted an entry
       
   360         {
       
   361         if ( iLayoutTable->Count() > 0 )
       
   362             {
       
   363             // Precondition: iDeletedIndex can contain only index to first line
       
   364             // of deleted item.
       
   365             // Fixed to work as specifed in Selection Service
       
   366             // 2.1.1 Focus while adding or deleting items.
       
   367             //TInt previousLine = iDeletedIndex;
       
   368             //highlightLine = previousLine;
       
   369 
       
   370             iHighlightedRowNumber = iDeletedIndex-1;
       
   371             }
       
   372         else
       
   373             {
       
   374             iHighlightedRowNumber = KErrNotFound;
       
   375             }
       
   376        // iDeletedIndex = KErrNotFound;
       
   377         }
       
   378 
       
   379     TRACE_EXIT_POINT;
       
   380     }
       
   381 
       
   382 // ----------------------------------------------------------------------------
       
   383 // CCalenDayContainer::SetHighlightFromContextL
       
   384 // Sets the highlighted row based on the context.
       
   385 // (other items were commented in a header).
       
   386 // ----------------------------------------------------------------------------
       
   387 //
       
   388 void CCalenDayContainer::SetHighlightFromContextL()
       
   389     {
       
   390     TRACE_ENTRY_POINT;
       
   391 
       
   392     MCalenContext& context = iServices.Context();
       
   393     TCalenInstanceId instId = context.InstanceId();
       
   394 
       
   395     if ( instId == TCalenInstanceId::NullInstanceId() )
       
   396         {
       
   397         iHighlightedRowNumber = 0;
       
   398 
       
   399         // Context points at a day/time, not an entry.
       
   400         // If we have an entry for this day set it to be the context,
       
   401         // as long as we weren't cycled to.
       
   402         if ( iLayoutTable->Count() )
       
   403             {
       
   404             if ( context.FocusTime().Int() == -1 )
       
   405                 {
       
   406                 // Context has a date but no time and no instance.
       
   407                 // We're not being cycled to, so set the context.
       
   408                 SetContextFromHighlightL();
       
   409                 }
       
   410             // else context has a date and time but no instance. This happens
       
   411             // for example when the week view highlights a cell with no instance,
       
   412             // then cycles to us - don't reset the context.
       
   413             }
       
   414 //      else Nothing on this day. Don't set context, as it's already set to this day.
       
   415         }
       
   416     else
       
   417         {
       
   418         TInt index = FindItemIndex( context.InstanceId() );
       
   419         if(index != KErrNotFound)
       
   420             {
       
   421             SItemInfo& itemInfo = (*iLayoutTable)[index];
       
   422             iHighlightedRowNumber = itemInfo.iTopLine;
       
   423             iFirstEntryOnScreenIndex = iListBox->TopItemIndex();
       
   424             SetHighlightAndVisibleItem( iHighlightedRowNumber, iFirstEntryOnScreenIndex );
       
   425             }
       
   426         }
       
   427 
       
   428     TRACE_EXIT_POINT;
       
   429     }
       
   430 
       
   431 // ----------------------------------------------------------------------------
       
   432 // CCalenDayContainer::SetContextFromHighlightL
       
   433 // Sets the context based on what's highlighted.
       
   434 // (other items were commented in a header).
       
   435 // ----------------------------------------------------------------------------
       
   436 //
       
   437 void CCalenDayContainer::SetContextFromHighlightL()
       
   438     {
       
   439     TRACE_ENTRY_POINT;
       
   440 
       
   441     MCalenContext& context = iServices.Context();
       
   442 	
       
   443     if ( iLayoutTable->Count() <= 0 )
       
   444         {
       
   445         // Nothing in the day view. Set context to this day.
       
   446         TCalTime dayCalTime;
       
   447         dayCalTime.SetTimeLocalL( iDate );
       
   448         context.SetFocusDateL( dayCalTime,
       
   449                                TVwsViewId( KUidCalendar, KUidCalenDayView ) );
       
   450         iHighlightedRowNumber = KErrNotFound;
       
   451         }
       
   452     else
       
   453         {
       
   454         // Stuff is present for this day.
       
   455      	
       
   456      	SetHighlightAndVisibleItem( iHighlightedRowNumber, iFirstEntryOnScreenIndex );
       
   457 		
       
   458 		TInt lineIx = iListBox->View()->CurrentItemIndex();
       
   459 	
       
   460     	// If list is empty, index is -1
       
   461     	if (lineIx >= 0)
       
   462         	{ 
       
   463         	TInt itemIx = FindItemIndexForRow(lineIx);
       
   464         	if( itemIx != KIndexError)
       
   465             	{
       
   466           		SItemInfo& item = (*iLayoutTable)[itemIx];
       
   467           		iHighlightedRowNumber = item.iTopLine;
       
   468           
       
   469           		if ( item.iTimedNote )
       
   470             		{
       
   471             		// Timed entry.
       
   472             		TCalTime dayCalTime;
       
   473             		dayCalTime.SetTimeLocalL( CalenDateUtils::BeginningOfDay( iDate ) + item.iStartTime );
       
   474             		context.SetFocusDateAndTimeAndInstanceL( dayCalTime,
       
   475                     		                                 item.iId,
       
   476                             		                         TVwsViewId( KUidCalendar, KUidCalenDayView ) );
       
   477             		}
       
   478         		else
       
   479             		{
       
   480             		// Untimed entry.
       
   481             		if ( item.iId.iType == CCalEntry::ETodo &&
       
   482                  		item.iId.iInstanceTime < CalenDateUtils::Today() )
       
   483                 		{
       
   484                 		TCalTime dayCalTime;
       
   485                 		dayCalTime.SetTimeLocalL( CalenDateUtils::Today() );
       
   486                 		// For todos in the past, set focus on the todo but view it today.
       
   487                 		context.SetFocusDateAndTimeAndInstanceL(
       
   488                         		                            dayCalTime,
       
   489                                 		                    item.iId,
       
   490                                         		            TVwsViewId( KUidCalendar, KUidCalenDayView ) );
       
   491                 		}
       
   492             		else
       
   493                 		{
       
   494                 		if ( CalenDateUtils::OnSameDay( item.iId.iInstanceTime, iDate ) )
       
   495                     		{
       
   496                     		context.SetInstanceIdL( item.iId,
       
   497                             		                TVwsViewId( KUidCalendar, KUidCalenDayView ) );
       
   498                     		}
       
   499                 		else
       
   500                     		{
       
   501                     		// Multi-day untimed note (either multi-day day note or weird todo).
       
   502                     		// Focus on the instance and set the focus time to the highlighted day.
       
   503                     		TCalTime dayCalTime;
       
   504                     		dayCalTime.SetTimeLocalL( iDate );
       
   505                     		context.SetFocusDateAndTimeAndInstanceL( dayCalTime,
       
   506                             		                                 item.iId,
       
   507                                                              TVwsViewId( KUidCalendar, KUidCalenDayView ) );
       
   508  		                   }
       
   509         		        }
       
   510             		}
       
   511             
       
   512             
       
   513             
       
   514              	}
       
   515         	else 
       
   516             	{
       
   517             	// FIXME: If item is not found, should we do something? 
       
   518             	__ASSERT_DEBUG(EFalse, User::Invariant());
       
   519             	}
       
   520         	}
       
   521     	else
       
   522         	{ // Empty list
       
   523         	// do nothing
       
   524         	}
       
   525         }
       
   526 
       
   527     TRACE_EXIT_POINT;
       
   528     }
       
   529 
       
   530 // ----------------------------------------------------------------------------
       
   531 // CCalenDayContainer::FindItemIndex
       
   532 // Returns the index into iLayoutTable of the given instance id (for highlighting).
       
   533 // (other items were commented in a header).
       
   534 // ----------------------------------------------------------------------------
       
   535 //
       
   536 TInt CCalenDayContainer::FindItemIndex( const TCalenInstanceId& aId ) const
       
   537     {
       
   538     TRACE_ENTRY_POINT;
       
   539 
       
   540     // For instances finishing the next day (now possible with unified DateTime editor),
       
   541     // we have to do our best to match the instance time exactly - otherwise we could
       
   542     // match the LocalUid to the incorrect instance in a series.
       
   543     for(TInt index(0); index < iLayoutTable->Count(); ++index)
       
   544         {
       
   545         SItemInfo& itemInfo = (*iLayoutTable)[index];
       
   546 
       
   547         if( itemInfo.iId.iEntryLocalUid == aId.iEntryLocalUid )
       
   548             {
       
   549             // Check the instance time matches.
       
   550             if( itemInfo.iId.iInstanceTime == aId.iInstanceTime )
       
   551                 {
       
   552                 return index;
       
   553                 }
       
   554             }
       
   555         }
       
   556 
       
   557     // Couldn't match the instance time exactly - just use the instance
       
   558     // with the same LocalUid as the one we're looking for.
       
   559     // In theory this shouldn't happen but it's good to have a failsafe.
       
   560     for(TInt index(0); index < iLayoutTable->Count(); ++index)
       
   561         {
       
   562         SItemInfo& itemInfo = (*iLayoutTable)[index];
       
   563 
       
   564         if( itemInfo.iId.iEntryLocalUid == aId.iEntryLocalUid )
       
   565             {
       
   566             return index;
       
   567             }
       
   568         }
       
   569 
       
   570     TRACE_EXIT_POINT;
       
   571     return KErrNotFound;
       
   572     }
       
   573 
       
   574 // ----------------------------------------------------------------------------
       
   575 // CCalenDayContainer::SetHighlightAndVisibleItem
       
   576 // Sets highlight item in ListBox
       
   577 // (other items were commented in a header).
       
   578 // ----------------------------------------------------------------------------
       
   579 //
       
   580 void CCalenDayContainer::SetHighlightAndVisibleItem( TInt aIndex,
       
   581                                                      TInt aTopItem )
       
   582     {
       
   583     TRACE_ENTRY_POINT;
       
   584 
       
   585     TInt count(iListBox->Model()->NumberOfItems());
       
   586     if ( count <= 0 )
       
   587         {
       
   588         return;
       
   589         }
       
   590 
       
   591     // aIndex and aTopItem can be indexes to any
       
   592     // line, not just first lines of items.
       
   593     // But we want to make sure that current item and top item indexes points
       
   594     // always only to the first line of item.
       
   595 
       
   596     // Limit range
       
   597     aIndex = Min(count - 1, aIndex);
       
   598     aIndex = Max(0, aIndex);
       
   599 
       
   600     // FIXME: can be done with layout table, no need for view-> calls  !
       
   601     TInt firstLine = View()->FirstLineOfCell(aIndex);
       
   602     iListBox->SetCurrentItemIndex(firstLine);
       
   603 
       
   604     SetVisibleLines(firstLine, aTopItem);
       
   605 
       
   606     TRACE_EXIT_POINT;
       
   607     }
       
   608 
       
   609 // ----------------------------------------------------------------------------
       
   610 // ?classname::?member_function
       
   611 // ?implementation_description
       
   612 // (other items were commented in a header).
       
   613 // ----------------------------------------------------------------------------
       
   614 //
       
   615 void CCalenDayContainer::SetVisibleLines( TInt aHighlightFirstLine,
       
   616                                           TInt aPreferredTopLine )
       
   617     {
       
   618     TRACE_ENTRY_POINT;
       
   619 
       
   620     CCalenDayListBoxView* view =  View();
       
   621 
       
   622     TInt highLightLastLine = view->LastLineOfCell( aHighlightFirstLine );
       
   623 
       
   624     TInt maxVisibleLines = view->NumberOfItemsThatFitInRect( view->ViewRect() );
       
   625     TInt totalListLines = iListBox->Model()->NumberOfItems();
       
   626 
       
   627     // Initial top line
       
   628     TInt topLine = aPreferredTopLine == KIndexError ? aHighlightFirstLine : aPreferredTopLine;
       
   629     topLine = Min(totalListLines - 1, topLine);
       
   630     topLine = Max(0, topLine);
       
   631 
       
   632     if ( aHighlightFirstLine < topLine )
       
   633         {
       
   634         topLine = aHighlightFirstLine;
       
   635         }
       
   636 
       
   637     // Adjust bottom line
       
   638     TInt bottomLine = topLine + maxVisibleLines - 1;
       
   639     TInt lastListLine = totalListLines - 1;
       
   640     bottomLine = bottomLine > lastListLine ? lastListLine : bottomLine;
       
   641     if ( highLightLastLine > bottomLine )
       
   642         {
       
   643         bottomLine = highLightLastLine;
       
   644         }
       
   645 
       
   646     TInt currentlyVisibleLines = bottomLine - topLine + 1;
       
   647     if ( currentlyVisibleLines > maxVisibleLines )
       
   648         {
       
   649         topLine = bottomLine - maxVisibleLines + 1;
       
   650         }
       
   651     // Now we have ensured that highlight is between [topLine, bottomLine]
       
   652     // If there are room for more lines in display, and still more lines
       
   653     // in list, we can scroll view up
       
   654 
       
   655     currentlyVisibleLines = bottomLine - topLine + 1;
       
   656     if ( (currentlyVisibleLines < maxVisibleLines - 1)
       
   657          && (totalListLines >= currentlyVisibleLines))
       
   658         {
       
   659         topLine = bottomLine - maxVisibleLines + 1;
       
   660         topLine = topLine < 0 ? 0 : topLine;
       
   661         }
       
   662 
       
   663     iListBox->SetTopItemIndex( topLine );
       
   664 
       
   665     TRACE_EXIT_POINT;
       
   666     }
       
   667 
       
   668 // ---------------------------------------------------------
       
   669 // CCalenDayContainer::SearchNearestItem
       
   670 // Searches list item that is nearest to aTime
       
   671 // (other items were commented in a header).
       
   672 // ---------------------------------------------------------
       
   673 //
       
   674 TInt CCalenDayContainer::SearchNearestItem( TTimeIntervalMinutes aTime ) const
       
   675     {
       
   676     TRACE_ENTRY_POINT;
       
   677 
       
   678     TInt foundIndex( KIndexError );
       
   679     const TInt count( iLayoutTable->Count() );
       
   680 
       
   681     for( TInt index(0); index < count; ++index )
       
   682         {
       
   683         SItemInfo& itemInfo = (*iLayoutTable)[index];
       
   684 
       
   685         // times match
       
   686         if( itemInfo.iStartTime == aTime )
       
   687             {
       
   688             foundIndex = index;
       
   689             break;
       
   690             }
       
   691         // times fall into same hour
       
   692         else if( (itemInfo.iStartTime.Int()/KCalenMinutesInHour) == (aTime.Int() / KCalenMinutesInHour)
       
   693                  && foundIndex == KIndexError )
       
   694             {
       
   695                 // Same starting hour
       
   696                 foundIndex = index;
       
   697             }
       
   698         }
       
   699 
       
   700     TRACE_EXIT_POINT;
       
   701     return foundIndex;
       
   702     }
       
   703 
       
   704 // ----------------------------------------------------------------------------
       
   705 // CCalenDayContainer::SizeChanged
       
   706 // Resizes child controls
       
   707 // (other items were commented in a header).
       
   708 // ----------------------------------------------------------------------------
       
   709 //
       
   710 void CCalenDayContainer::SizeChanged()
       
   711     {
       
   712     TRACE_ENTRY_POINT;
       
   713 
       
   714     CCalenContainer::SizeChanged( Rect() );
       
   715     
       
   716     TRAPD(error,iLayoutManager->GetLayoutAndExtensionL());
       
   717     if(error!=KErrNone)
       
   718     	{
       
   719     	// do avoid warning
       
   720     	}
       
   721               
       
   722     // Find the layout variant based upon a preview pane building present or not.
       
   723     TInt layoutVariant = LayoutVariantIndex( EListScrollCaleDayPane );
       
   724        
       
   725     TAknLayoutRect main_cale_day_pane;
       
   726     main_cale_day_pane.LayoutRect( Rect(), 
       
   727                     AknLayoutScalable_Apps::main_cale_day_pane(0).LayoutLine() );
       
   728         
       
   729     TAknLayoutRect listscroll_cale_day_pane;
       
   730     listscroll_cale_day_pane.LayoutRect( main_cale_day_pane.Rect(), 
       
   731             AknLayoutScalable_Apps::listscroll_cale_day_pane( layoutVariant ).LayoutLine() );
       
   732     
       
   733 
       
   734 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION
       
   735     PIM_TRAPD_HANDLE(GetMidnightVisualizationL()) // sets iMidnight
       
   736 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION
       
   737 
       
   738 
       
   739     iListBoxModel->UpdateLayoutValues( layoutVariant
       
   740 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION
       
   741         , iMidnight
       
   742 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION
       
   743         );
       
   744 
       
   745     // Now get the correct version for if we have a info bar or not
       
   746     listscroll_cale_day_pane.LayoutRect( main_cale_day_pane.Rect(), AknLayoutScalable_Apps::listscroll_cale_day_pane(layoutVariant).LayoutLine() );
       
   747 
       
   748 
       
   749     layoutVariant = LayoutVariantIndex( EBgCalePane );
       
   750 
       
   751     TAknLayoutRect bg_cale_pane;
       
   752     bg_cale_pane.LayoutRect( listscroll_cale_day_pane.Rect(), AknLayoutScalable_Apps::bg_cale_pane( layoutVariant ).LayoutLine() );
       
   753 
       
   754     TAknLayoutRect cale_bg_pane_center;
       
   755     cale_bg_pane_center.LayoutRect( bg_cale_pane.Rect(), AknLayoutScalable_Apps::cale_bg_pane_g1().LayoutLine() );
       
   756 
       
   757     iBackgroundSkinContext->SetFrameRects( bg_cale_pane.Rect(), cale_bg_pane_center.Rect() );
       
   758     iBackgroundSkinContext->SetParentContext( iBgContext );
       
   759 
       
   760     // Listbox layout
       
   761     TAknLayoutRect list_cale_pane;
       
   762     list_cale_pane.LayoutRect( main_cale_day_pane.Rect(), AknLayoutScalable_Apps::list_cale_pane( layoutVariant ).LayoutLine() );
       
   763 
       
   764     iListBox->SetRect( list_cale_pane.Rect() );
       
   765 
       
   766     // Inside of listbox.
       
   767     iListBox->ItemDrawer()->FormattedCellData()->SetBackgroundSkinStyle( &KAknsIIDQsnFrCaleCenter, cale_bg_pane_center.Rect() );
       
   768     layoutVariant = LayoutVariantIndex( EScrollPaneCp09 );
       
   769     // Scrollbar layout
       
   770     AknLayoutUtils::LayoutVerticalScrollBar( iListBox->ScrollBarFrame(),
       
   771                                              listscroll_cale_day_pane.Rect(),
       
   772                                              AknLayoutScalable_Apps::scroll_pane_cp09( layoutVariant ).LayoutLine() );
       
   773     
       
   774    
       
   775        
       
   776     PIM_TRAPD_HANDLE( UpdateStatusPaneAndExtensionsL() )
       
   777     
       
   778     CCoeControl* infoControl = iLayoutManager->ControlOrNull();
       
   779     if(infoControl)
       
   780     	{
       
   781     	TRAP_IGNORE(infoControl->ActivateL());
       
   782     	}
       
   783         
       
   784     
       
   785     DrawNow();
       
   786     TRACE_EXIT_POINT;
       
   787     }
       
   788 
       
   789 // ----------------------------------------------------------------------------
       
   790 // CCalenDayContainer::FocusChanged
       
   791 // ?implementation_description
       
   792 // (other items were commented in a header).
       
   793 // ----------------------------------------------------------------------------
       
   794 //
       
   795 void CCalenDayContainer::FocusChanged( TDrawNow aDrawNow )
       
   796     {
       
   797     TRACE_ENTRY_POINT;
       
   798 
       
   799     CCalenContainer::FocusChanged( aDrawNow );
       
   800 
       
   801     if( iListBox )
       
   802         {
       
   803         iListBox->SetFocus( IsFocused() );
       
   804         }
       
   805 
       
   806     TRACE_EXIT_POINT;
       
   807     }
       
   808 
       
   809 // ----------------------------------------------------------------------------
       
   810 // CCalenDayContainer::UpdateIconsL
       
   811 // update icons
       
   812 // (other items were commented in a header).
       
   813 // ----------------------------------------------------------------------------
       
   814 //
       
   815 void CCalenDayContainer::UpdateIconsL()
       
   816     {
       
   817     TRACE_ENTRY_POINT;
       
   818     
       
   819     CAknIconArray* iconList = CreateIconsL( iIconIndices );
       
   820     if(iListBox)
       
   821     {
       
   822     CArrayPtr<CGulIcon>* iconArray =iListBox->ItemDrawer()->FormattedCellData()->IconArray();
       
   823     delete iconArray;
       
   824     iconArray = NULL;
       
   825     iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconList );
       
   826     }
       
   827     
       
   828     TRACE_EXIT_POINT;
       
   829     }
       
   830     
       
   831 // ----------------------------------------------------------------------------
       
   832 // CCalenDayContainer::HandleResourceChange
       
   833 // Called when layout or skin changes
       
   834 // (other items were commented in a header).
       
   835 // ----------------------------------------------------------------------------
       
   836 //
       
   837 void CCalenDayContainer::HandleResourceChange( TInt aType )
       
   838     {
       
   839     TRACE_ENTRY_POINT;
       
   840 
       
   841     CCalenContainer::HandleResourceChange( aType );
       
   842 
       
   843     if ( aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch )
       
   844         {
       
   845         TRAPD(error,UpdateIconsL());
       
   846 	    if(error!=KErrNone)
       
   847 	       	{
       
   848 	       	// do avoid warning
       
   849 	       	}     
       
   850         // refresh
       
   851         TRAPD(err,iView->BeginRepopulationL());
       
   852 	    if(err!=KErrNone)
       
   853 	       	{
       
   854 	       	// do avoid warning
       
   855 	       	}
       
   856 	    SizeChanged();
       
   857 
       
   858 	            // Update date formats to status pane
       
   859 	    TRAP_IGNORE(UpdateStatusPaneAndExtensionsL());
       
   860 
       
   861         }
       
   862 
       
   863     CCoeControl::HandleResourceChange( aType );
       
   864 
       
   865     TRACE_EXIT_POINT;
       
   866     }
       
   867 
       
   868 // ----------------------------------------------------------------------------
       
   869 // CCalenDayContainer::CountComponentControls
       
   870 // Gets child control count
       
   871 // (other items were commented in a header).
       
   872 // ----------------------------------------------------------------------------
       
   873 TInt CCalenDayContainer::CountComponentControls() const
       
   874     {
       
   875     TRACE_ENTRY_POINT;
       
   876     
       
   877     TInt controlCount;
       
   878 
       
   879     if ( iLayoutManager->ControlOrNull() )
       
   880         {
       
   881         controlCount = 2;
       
   882         }
       
   883     else
       
   884         {
       
   885         controlCount = 1;
       
   886         }
       
   887 
       
   888     TRACE_EXIT_POINT;
       
   889     return controlCount;
       
   890     }
       
   891 
       
   892 // ----------------------------------------------------------------------------
       
   893 // CCalenDayContainer::ComponentControl
       
   894 // Gets child control pointer
       
   895 // (other items were commented in a header).
       
   896 // ----------------------------------------------------------------------------
       
   897 CCoeControl* CCalenDayContainer::ComponentControl(TInt aIndex) const
       
   898     {
       
   899     TRACE_ENTRY_POINT;
       
   900 
       
   901     CCoeControl* control( NULL );
       
   902 
       
   903     switch (aIndex)
       
   904         {
       
   905         case 0:
       
   906             control = iListBox;
       
   907             break;
       
   908         
       
   909         case 1:
       
   910             control = iLayoutManager->ControlOrNull();
       
   911             break;
       
   912         
       
   913         default:
       
   914             __ASSERT_DEBUG( 0, User::Invariant() );
       
   915             break;
       
   916         }
       
   917 
       
   918     TRACE_EXIT_POINT;
       
   919     return control;
       
   920     }
       
   921 
       
   922 // ----------------------------------------------------------------------------
       
   923 // CCalenDayContainer::OfferKeyEventL
       
   924 // Process key event
       
   925 // (other items were commented in a header).
       
   926 // ----------------------------------------------------------------------------
       
   927 //
       
   928 TKeyResponse CCalenDayContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   929                                                           TEventCode aType )
       
   930     {
       
   931     TRACE_ENTRY_POINT;
       
   932 
       
   933     // common view key handling
       
   934     if (CCalenContainer::OfferKeyEventL(aKeyEvent, aType) == EKeyWasConsumed)
       
   935         {
       
   936         return EKeyWasConsumed;
       
   937         }
       
   938 
       
   939     // day view specific key handling
       
   940     TKeyResponse exitCode(EKeyWasNotConsumed);
       
   941 
       
   942     if (aType == EEventKey)
       
   943         {
       
   944         TBool mirrored(AknLayoutUtils::LayoutMirrored());
       
   945         switch (aKeyEvent.iCode)
       
   946             {
       
   947             case EKeyLeftArrow:
       
   948                 {
       
   949                 HandleHorizontalScrollL(TTimeIntervalDays(mirrored ? 1 : -1));
       
   950                 exitCode = EKeyWasConsumed;
       
   951                 break;
       
   952                 }
       
   953             case EKeyRightArrow:
       
   954                 {
       
   955                 HandleHorizontalScrollL(TTimeIntervalDays(mirrored ? -1 : 1));
       
   956                 exitCode = EKeyWasConsumed;
       
   957                 break;
       
   958                 }
       
   959             case EKeyBackspace:
       
   960                 {
       
   961                  // Single click integration
       
   962                 if( iView->MenuBar()->ItemSpecificCommandsEnabled()
       
   963                         && !IsEmptyView() )
       
   964 	                {
       
   965 	                iView->HandleCommandL( ECalenDeleteCurrentEntry );
       
   966 	                exitCode = EKeyWasConsumed;
       
   967 	                }
       
   968                 break;
       
   969                 }
       
   970             case EKeyOK:
       
   971                 {
       
   972                 if(iListBox->Model()->NumberOfItems() > 0)
       
   973                     {
       
   974                      // Single click integration
       
   975                     iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   976                     }
       
   977                 else
       
   978                     {
       
   979                     CEikMenuBar* menuBar = iView->MenuBar();
       
   980                     menuBar->SetContextMenuTitleResourceId( R_CALENDAR_DAY_CASE_MENUBAR );
       
   981                     menuBar->TryDisplayContextMenuBarL();
       
   982                     }
       
   983                 exitCode = EKeyWasConsumed;
       
   984                 break;
       
   985                 }
       
   986             case EKeyEnter:    
       
   987         		{
       
   988         		if(IsEmptyView())
       
   989                    	{ 
       
   990                    	iView->HandleCommandL(ECalenCmdOpenMskDialog);                    
       
   991                     }
       
   992                 else
       
   993 	                {
       
   994                      // Single click integration
       
   995                     iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   996 	            	}
       
   997          		exitCode = EKeyWasConsumed;	
       
   998                 break;
       
   999         		}
       
  1000             default:
       
  1001                 break;
       
  1002             }
       
  1003         }
       
  1004 
       
  1005 	// For handling geokeys on corolla hardware
       
  1006 	// For Add location hard key
       
  1007 	if( aKeyEvent.iScanCode == EStdKeyApplication1C && aType == EEventKeyUp )
       
  1008 		{
       
  1009          // Single click integration
       
  1010         if( iView->MenuBar()->ItemSpecificCommandsEnabled()
       
  1011                 && CCalenLocationUtil::IsMapProviderAvailableL() )
       
  1012 			{
       
  1013 			MCalenContext& context = iServices.Context();
       
  1014 			TCalLocalUid instanceId = context.InstanceId().iEntryLocalUid;
       
  1015 			CCalEntry* entry = iServices.EntryViewL(context.InstanceId().iColId)->FetchL(instanceId);
       
  1016 			CleanupStack::PushL( entry );
       
  1017 			if(entry)
       
  1018 				{
       
  1019 				CCalEntry::TType entryType = entry->EntryTypeL();
       
  1020 				if(entryType == CCalEntry::EAppt)
       
  1021 					{
       
  1022 					iServices.IssueCommandL(ECalenGetLocationAndSave);
       
  1023 					}
       
  1024 				}
       
  1025 			CleanupStack::PopAndDestroy( entry );
       
  1026 			}
       
  1027 		exitCode = EKeyWasConsumed;
       
  1028 		}
       
  1029 	// For Show location hard key
       
  1030     // Single click integration 
       
  1031     else if( aKeyEvent.iScanCode == EStdKeyApplication1B && aType == EEventKeyUp
       
  1032             && iView->MenuBar()->ItemSpecificCommandsEnabled() )
       
  1033 		{
       
  1034 		MCalenContext& context = iServices.Context();
       
  1035 		TCalLocalUid instanceId = context.InstanceId().iEntryLocalUid;
       
  1036 		
       
  1037 		CCalEntry* entry = iServices.EntryViewL(context.InstanceId().iColId)->FetchL(instanceId);
       
  1038 		CleanupStack::PushL( entry );
       
  1039 		if(entry)
       
  1040 			{
       
  1041 			CCalEntry::TType entryType = entry->EntryTypeL();
       
  1042 			if(entryType == CCalEntry::EAppt)
       
  1043 				{
       
  1044 				TPtrC location = entry->LocationL();
       
  1045 				if( entry->GeoValueL())
       
  1046 					{ 
       
  1047 					iServices.IssueCommandL(ECalenShowLocation);
       
  1048 					}
       
  1049 				else if(location.Length())
       
  1050 					{
       
  1051 					iServices.IssueCommandL(ECalenGetLocationAndReplace);
       
  1052 					}
       
  1053 				else
       
  1054 					{
       
  1055 					iServices.IssueCommandL(ECalenShowLocationQuery);
       
  1056 					}
       
  1057 				}
       
  1058 			}
       
  1059 		CleanupStack::PopAndDestroy( entry );
       
  1060 		}
       
  1061 		
       
  1062     // listbox key handling
       
  1063     if (exitCode == EKeyWasConsumed || !iListBox)
       
  1064         {        // if DoDeactivate() is done, iListBox will be NULL.
       
  1065         // do nothing
       
  1066         }
       
  1067     else
       
  1068         {
       
  1069         TInt oldCursor = iListBox->View()->CurrentItemIndex();
       
  1070         exitCode = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
  1071         TInt newCursor = iListBox->View()->CurrentItemIndex();
       
  1072         if (oldCursor != newCursor)
       
  1073             {
       
  1074             HandleVerticalScrollL( newCursor );
       
  1075             }
       
  1076         }
       
  1077 
       
  1078     TRACE_EXIT_POINT;
       
  1079     return exitCode;
       
  1080     }
       
  1081 
       
  1082 // ----------------------------------------------------------------------------
       
  1083 // CCalenDayContainer::HandleHorizontalScrollL
       
  1084 // Handles moving left or right to a new day.
       
  1085 // (other items were commented in a header).
       
  1086 // ----------------------------------------------------------------------------
       
  1087 //
       
  1088 void CCalenDayContainer::HandleHorizontalScrollL( TTimeIntervalDays aDirection )
       
  1089     {
       
  1090     TRACE_ENTRY_POINT;
       
  1091 
       
  1092     TTime time = CalenDateUtils::BeginningOfDay( iDate + aDirection );
       
  1093     time += iServices.Context().DefaultTimeForViews();
       
  1094 
       
  1095     if ( CalenDateUtils::IsValidDay( time ) )
       
  1096         {
       
  1097         iDate = time;
       
  1098         iHighlightedRowNumber = KErrNotFound;
       
  1099         iFirstEntryOnScreenIndex = KErrNotFound;
       
  1100 
       
  1101         // set the idate in to context
       
  1102         TCalTime time;
       
  1103         time.SetTimeLocalL( iDate );
       
  1104         iServices.Context().SetFocusDateL( time,
       
  1105                          TVwsViewId( KUidCalendar, KUidCalenDayView ) );
       
  1106 
       
  1107         UpdateContainerL(); // Repopulate.
       
  1108         }
       
  1109     else
       
  1110         {
       
  1111         CalenViewUtils::ShowDateOutOfRangeErrorNoteL();
       
  1112         }
       
  1113 
       
  1114     TRACE_EXIT_POINT;
       
  1115     }
       
  1116 
       
  1117 // ----------------------------------------------------------------------------
       
  1118 // CCalenDayContainer::HandleVerticalScrollL
       
  1119 // Handles moving up or down in the same day.
       
  1120 // (other items were commented in a header).
       
  1121 // ----------------------------------------------------------------------------
       
  1122 //
       
  1123 void CCalenDayContainer::HandleVerticalScrollL( TInt aNewCursor )
       
  1124     {
       
  1125     TRACE_ENTRY_POINT;
       
  1126 
       
  1127     iHighlightedRowNumber = aNewCursor;
       
  1128     ASSERT( iHighlightedRowNumber >= 0 );
       
  1129     iFirstEntryOnScreenIndex = iListBox->TopItemIndex();
       
  1130     SetContextFromHighlightL();
       
  1131 
       
  1132     TRACE_EXIT_POINT;
       
  1133     }
       
  1134 
       
  1135 // ----------------------------------------------------------------------------
       
  1136 // CCalenDayContainer::Draw
       
  1137 // Drawing day name
       
  1138 // (other items were commented in a header).
       
  1139 // ----------------------------------------------------------------------------
       
  1140 //
       
  1141 void CCalenDayContainer::Draw(const TRect& /*aRect*/) const  // Clipping rectangle
       
  1142     {
       
  1143     TRACE_ENTRY_POINT;
       
  1144 
       
  1145     CWindowGc& gc = SystemGc();
       
  1146 
       
  1147     MAknsControlContext* cc =AknsDrawUtils::ControlContext( this );
       
  1148 
       
  1149     if( cc )
       
  1150         {
       
  1151         TRect main_pane( Rect() );
       
  1152 
       
  1153         // To prevent "tearing" (tearing resembles flickering), we don't want to clear
       
  1154         // area under bottom-most skin image (KAknsDrawParamNoClearUnderImage).
       
  1155         // But if bottom-most skin is semitransparent, we need to draw it without alpha channel,
       
  1156         // so that something else doesn't show through it (KAknsDrawParamBottomLevelRGBOnly).
       
  1157         const TInt drawParams = KAknsDrawParamNoClearUnderImage | KAknsDrawParamBottomLevelRGBOnly;
       
  1158         AknsDrawUtils::Background( AknsUtils::SkinInstance(),
       
  1159                                    cc,
       
  1160                                    NULL,
       
  1161                                    gc,
       
  1162                                    main_pane,
       
  1163                                    drawParams);
       
  1164         }
       
  1165 
       
  1166     TRACE_EXIT_POINT;
       
  1167     }
       
  1168 
       
  1169 // ----------------------------------------------------------------------------
       
  1170 // CCalenDayContainer::GetHelpContext
       
  1171 // Gets help context
       
  1172 // (other items were commented in a header).
       
  1173 // ----------------------------------------------------------------------------
       
  1174 //
       
  1175 void CCalenDayContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
  1176     {
       
  1177     TRACE_ENTRY_POINT;
       
  1178 
       
  1179     aContext.iMajor = KUidCalendar;
       
  1180     // This is specified in HRH file.
       
  1181     aContext.iContext = KCALE_HLP_DAY_VIEW;
       
  1182 
       
  1183     TRACE_EXIT_POINT;
       
  1184     }
       
  1185 
       
  1186 // ----------------------------------------------------------------------------
       
  1187 // CCalenDayContainer::UpdateSize
       
  1188 // Do layout changes after calendar settings are
       
  1189 // changed.  No necessary actions for this view.
       
  1190 // ----------------------------------------------------------------------------
       
  1191 //
       
  1192 void CCalenDayContainer::UpdateSize()
       
  1193     {
       
  1194     TRACE_ENTRY_POINT;
       
  1195 
       
  1196     SizeChanged();
       
  1197 
       
  1198     TRACE_EXIT_POINT;
       
  1199     }
       
  1200 
       
  1201 // ----------------------------------------------------------------------------
       
  1202 // CCalenDayContainer::ConstructImplL
       
  1203 // Third phase constructor.
       
  1204 // This function was called CCalenNativeView::ConstructL().
       
  1205 // (other items were commented in a header).
       
  1206 // ----------------------------------------------------------------------------
       
  1207 //
       
  1208 void CCalenDayContainer::ConstructImplL()
       
  1209     {
       
  1210     TRACE_ENTRY_POINT;
       
  1211 
       
  1212     // 1) Extension plugins
       
  1213   //  InitializeUiExtensionL();
       
  1214 
       
  1215     // 2) Background Skins
       
  1216     iBackgroundSkinContext = CAknsFrameBackgroundControlContext::NewL(
       
  1217         KAknsIIDQsnFrCale, TRect(0,0,0,0), TRect(0,0,0,0), EFalse );
       
  1218 
       
  1219     // 3) Listbox initialization
       
  1220     iListBox = CCalenDayListBox::NewL(this, iServices);
       
  1221     iListBox->SetListBoxObserver( this );
       
  1222 
       
  1223     iListBoxModel = CCalenDayListBoxModel::NewL( this );
       
  1224     CTextListBoxModel* model = iListBox->Model();
       
  1225     model->SetItemTextArray(iListBoxModel->ItemTextArray());
       
  1226     model->SetOwnershipType(ELbmDoesNotOwnItemArray);
       
  1227     
       
  1228     CAknIconArray* iconList = CreateIconsL( iIconIndices );
       
  1229     iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconList );
       
  1230     
       
  1231     TRACE_EXIT_POINT;
       
  1232     }
       
  1233 
       
  1234 // ----------------------------------------------------------------------------
       
  1235 // CCalenDayContainer::NotifyDeleteItemL
       
  1236 // Delete note command notification handler
       
  1237 // (other items were commented in a header).
       
  1238 // ----------------------------------------------------------------------------
       
  1239 //
       
  1240 void CCalenDayContainer::NotifyDeleteItemL()
       
  1241     {
       
  1242     TRACE_ENTRY_POINT;
       
  1243 
       
  1244     iDeletedIndex = iListBox->View()->CurrentItemIndex();
       
  1245 //    CCalenContainer::NotifyDeleteItemL();
       
  1246 
       
  1247     TRACE_EXIT_POINT;
       
  1248     }
       
  1249 
       
  1250 // ----------------------------------------------------------------------------
       
  1251 // CCalenDayContainer::NotifyChangeDateL
       
  1252 // Date cahnge operation notification handler.
       
  1253 // (other items were commented in a header).
       
  1254 // ----------------------------------------------------------------------------
       
  1255 //
       
  1256 void CCalenDayContainer::NotifyChangeDateL()
       
  1257     {
       
  1258     TRACE_ENTRY_POINT;
       
  1259 
       
  1260     TTime newDay = iServices.Context().FocusDateAndTimeL().TimeLocalL();
       
  1261 
       
  1262     if ( ! CalenDateUtils::OnSameDay( iDate, newDay ) )
       
  1263         {
       
  1264         iDate = newDay;
       
  1265         UpdateContainerL();
       
  1266         }
       
  1267     else
       
  1268         {
       
  1269         iListBox->View()->SetDisableRedraw( ETrue );
       
  1270         SetContextFromHighlightL();
       
  1271         iListBox->View()->SetDisableRedraw( EFalse );
       
  1272         iListBox->DrawNow();
       
  1273         }
       
  1274 
       
  1275     TRACE_EXIT_POINT;
       
  1276     }
       
  1277 
       
  1278 // ----------------------------------------------------------------------------
       
  1279 // CCalenDayContainer::MopSupplyObject
       
  1280 // Pass skin information if needed.
       
  1281 // ----------------------------------------------------------------------------
       
  1282 //
       
  1283 TTypeUid::Ptr CCalenDayContainer::MopSupplyObject(TTypeUid aId)
       
  1284     {
       
  1285     TRACE_ENTRY_POINT;
       
  1286 
       
  1287     if(aId.iUid == MAknsControlContext::ETypeId )
       
  1288         {
       
  1289         MAknsControlContext* cc = iBackgroundSkinContext;
       
  1290         if ( !cc ) cc = iBgContext;
       
  1291 
       
  1292         if ( cc )
       
  1293             {
       
  1294             TRACE_EXIT_POINT;
       
  1295             return MAknsControlContext::SupplyMopObject( aId, cc );
       
  1296             }
       
  1297         }
       
  1298 
       
  1299     TRACE_EXIT_POINT;
       
  1300     return CCoeControl::MopSupplyObject( aId );
       
  1301     }
       
  1302 
       
  1303 // ----------------------------------------------------------------------------
       
  1304 // CCalenDayContainer::View
       
  1305 // ?implementation_description
       
  1306 // (other items were commented in a header).
       
  1307 // ----------------------------------------------------------------------------
       
  1308 //
       
  1309 CCalenDayListBoxView* CCalenDayContainer::View()
       
  1310     {
       
  1311     TRACE_ENTRY_POINT;
       
  1312 
       
  1313     TRACE_EXIT_POINT;
       
  1314     return static_cast<CCalenDayListBoxView*>(iListBox->View());
       
  1315     }
       
  1316 
       
  1317 // ----------------------------------------------------------------------------
       
  1318 // CCalenDayContainer::DayView
       
  1319 // ?implementation_description
       
  1320 // (other items were commented in a header).
       
  1321 // ----------------------------------------------------------------------------
       
  1322 //
       
  1323 CCalenDayView& CCalenDayContainer::DayView() const
       
  1324     {
       
  1325     TRACE_ENTRY_POINT;
       
  1326 
       
  1327     TRACE_EXIT_POINT;
       
  1328     return *(static_cast<CCalenDayView*>(iView));
       
  1329     }
       
  1330 
       
  1331 // ----------------------------------------------------------------------------
       
  1332 // CCalenDayContainer::LayoutVariantIndex
       
  1333 // ----------------------------------------------------------------------------
       
  1334 //
       
  1335 TInt CCalenDayContainer::LayoutVariantIndex( TDayLayoutVariant aLayout ) const
       
  1336     {
       
  1337     TRACE_ENTRY_POINT;
       
  1338     
       
  1339     TBitFlags layoutFlags = iLayoutManager->LayoutFlags();
       
  1340 
       
  1341     TInt layoutVariant(ENoLayoutVariantSet);
       
  1342     switch (aLayout)
       
  1343         {
       
  1344         case EListScrollCaleDayPane:
       
  1345             {
       
  1346             if( layoutFlags.IsSet( 
       
  1347                     CCalenContainerLayoutManager::ECalenContainerToolbar ) )
       
  1348                 layoutVariant = 1;
       
  1349             else
       
  1350                 layoutVariant = 0;
       
  1351             break;
       
  1352             }
       
  1353         case EPopupToolbarWindowCp02:
       
  1354             {
       
  1355             if( layoutFlags.IsSet( 
       
  1356                     CCalenContainerLayoutManager::ECalenContainerToolbar ) )
       
  1357                 layoutVariant = 0;
       
  1358             else
       
  1359                 __ASSERT_DEBUG(0, User::Invariant());
       
  1360             break;
       
  1361             }
       
  1362         case EBgCalePane:
       
  1363         case EListCalePane:
       
  1364         case EScrollPaneCp09:
       
  1365             {
       
  1366             if( layoutFlags.IsSet( 
       
  1367                     CCalenContainerLayoutManager::ECalenContainerToolbar ) && 
       
  1368                 layoutFlags.IsSet( 
       
  1369                     CCalenContainerLayoutManager::ECalenContainerInfobar ) )
       
  1370                 layoutVariant = 3;
       
  1371                 
       
  1372             else if( layoutFlags.IsSet( 
       
  1373                     CCalenContainerLayoutManager::ECalenContainerToolbar ) )
       
  1374                 layoutVariant = 2;
       
  1375                 
       
  1376             else if( layoutFlags.IsSet( 
       
  1377                     CCalenContainerLayoutManager::ECalenContainerInfobar ) )
       
  1378                 layoutVariant = 3;
       
  1379             else
       
  1380                 layoutVariant = 0;
       
  1381             break;
       
  1382             }
       
  1383         case EListScrollCaleDayPaneT1:
       
  1384             {
       
  1385             if( layoutFlags.IsSet(
       
  1386                     CCalenContainerLayoutManager::ECalenContainerToolbar ) && 
       
  1387                 layoutFlags.IsSet( 
       
  1388                     CCalenContainerLayoutManager::ECalenContainerInfobar ) )
       
  1389                 layoutVariant = 1;
       
  1390                 
       
  1391             else if( layoutFlags.IsSet( 
       
  1392                     CCalenContainerLayoutManager::ECalenContainerInfobar ) )
       
  1393                 layoutVariant = 0;
       
  1394             else
       
  1395                 __ASSERT_DEBUG(0, User::Invariant());
       
  1396             break;
       
  1397             }
       
  1398          case ENoLayoutVariantSet:
       
  1399             {
       
  1400             ASSERT(EFalse);
       
  1401             break;
       
  1402             }
       
  1403         }
       
  1404 
       
  1405     TRACE_EXIT_POINT;
       
  1406     return layoutVariant;
       
  1407     }
       
  1408 
       
  1409 
       
  1410 // ----------------------------------------------------------------------------
       
  1411 // CCalenDayContainer::HandleLongTapEventL
       
  1412 // processing of a long tap event
       
  1413 // (other items were commented in a header).
       
  1414 // ----------------------------------------------------------------------------
       
  1415 //
       
  1416 void CCalenDayContainer::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/,
       
  1417                                               const TPoint& /*aPenEventScreenLocation*/ )
       
  1418     {
       
  1419     TRACE_ENTRY_POINT;
       
  1420 
       
  1421 
       
  1422     TRACE_EXIT_POINT;
       
  1423     }
       
  1424 
       
  1425 // ----------------------------------------------------------------------------
       
  1426 // CCalenDayContainer::HandlePointerEventL
       
  1427 // ?implementation_description
       
  1428 // (other items were commented in a header).
       
  1429 // ----------------------------------------------------------------------------
       
  1430 //
       
  1431 void CCalenDayContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
  1432     {
       
  1433     TRACE_ENTRY_POINT;
       
  1434     CCoeControl* control( NULL );
       
  1435 
       
  1436     if(! AknLayoutUtils::PenEnabled() )
       
  1437         {
       
  1438         return;
       
  1439         }
       
  1440         
       
  1441     if(aPointerEvent.iType == TPointerEvent::EButton1Up)
       
  1442         {
       
  1443         control = iLayoutManager->ControlOrNull();
       
  1444         if(control)
       
  1445             {
       
  1446             if(control->Rect().Contains(aPointerEvent.iPosition))
       
  1447                 {
       
  1448                 control->HandlePointerEventL(aPointerEvent);		        		
       
  1449                 }
       
  1450             }
       
  1451         }
       
  1452 	        	
       
  1453     TInt pointerIndex(-1);
       
  1454     if(iListBox->Model()->NumberOfItems() <= 0)
       
  1455         {   
       
  1456         iView->HandleCommandL(ECalenCmdOpenMskDialog);
       
  1457         return;
       
  1458         }
       
  1459      // Single click integration
       
  1460     if ( aPointerEvent.iType == TPointerEvent::EButton1Down
       
  1461             && iListBox->View()->XYPosToItemIndex(
       
  1462                     aPointerEvent.iPosition, pointerIndex ) )
       
  1463         {
       
  1464         CCalenDayListBoxView* view =
       
  1465             static_cast<CCalenDayListBoxView*>( iListBox->View() );
       
  1466         TInt pointerItemIndex( view->FirstLineOfCell( pointerIndex ) );
       
  1467         if ( iListBox->CurrentItemIndex() != pointerItemIndex )
       
  1468             {
       
  1469             HandleVerticalScrollL( pointerItemIndex );
       
  1470             }
       
  1471         }
       
  1472     if ( aPointerEvent.iType != TPointerEvent::EButtonRepeat )
       
  1473         {
       
  1474         iListBox->HandlePointerEventL( aPointerEvent );
       
  1475         }
       
  1476 
       
  1477     TRACE_EXIT_POINT;
       
  1478     }
       
  1479 
       
  1480 // ----------------------------------------------------------------------------
       
  1481 // CCalenDayContainer::HandleNaviDecoratorEventL
       
  1482 // ?implementation_description
       
  1483 // (other items were commented in a header).
       
  1484 // ----------------------------------------------------------------------------
       
  1485 //
       
  1486 void CCalenDayContainer::HandleNaviDecoratorEventL( TInt aEventID )
       
  1487     {
       
  1488     TRACE_ENTRY_POINT;
       
  1489 
       
  1490     if(AknLayoutUtils::PenEnabled())
       
  1491         {
       
  1492         TInt direction(0);
       
  1493         if(aEventID == EAknNaviDecoratorEventLeftTabArrow)
       
  1494                     {
       
  1495                     if(AknLayoutUtils::LayoutMirrored())
       
  1496                         direction = 1;
       
  1497                     else
       
  1498                         direction = -1;
       
  1499                     }
       
  1500                     
       
  1501                 else if(aEventID == EAknNaviDecoratorEventRightTabArrow)
       
  1502                     { 
       
  1503                     if(AknLayoutUtils::LayoutMirrored())
       
  1504                          direction = -1;
       
  1505                     else
       
  1506                          direction = 1;
       
  1507                     }
       
  1508         else
       
  1509             return;
       
  1510 
       
  1511         HandleHorizontalScrollL(TTimeIntervalDays(direction));
       
  1512         }
       
  1513 
       
  1514     TRACE_EXIT_POINT;
       
  1515     }
       
  1516 
       
  1517 
       
  1518 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION
       
  1519 void CCalenDayContainer::GetMidnightVisualizationL()
       
  1520     {
       
  1521     TRACE_ENTRY_POINT;
       
  1522 
       
  1523     iMidnight = EFalse;
       
  1524     TTime focusedDayBeginning = CalenDateUtils::BeginningOfDay(iDate);
       
  1525     TTime focusedDayEnd = focusedDayBeginning + TTimeIntervalDays(1);
       
  1526 
       
  1527     TInt count = iInstanceList.Count();
       
  1528     for(TInt i = 0; i < count; ++i )
       
  1529         {
       
  1530         CCalInstance* instance = iInstanceList[i];
       
  1531         if((instance->StartTimeL().TimeLocalL() < focusedDayBeginning)
       
  1532         || (instance->EndTimeL().TimeLocalL() > focusedDayEnd))
       
  1533             {
       
  1534             iMidnight = ETrue;
       
  1535             break;
       
  1536             }
       
  1537         }
       
  1538 
       
  1539     TRACE_EXIT_POINT;
       
  1540     }
       
  1541 
       
  1542 TBool CCalenDayContainer::IsMidnightVisualization() const
       
  1543     {
       
  1544     TRACE_ENTRY_POINT;
       
  1545 
       
  1546     TRACE_EXIT_POINT;
       
  1547     return iMidnight;
       
  1548     }
       
  1549 
       
  1550 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION
       
  1551 
       
  1552 // ----------------------------------------------------------------------------
       
  1553 // CCalenDayContainer::GetInstanceListL
       
  1554 // Get instances for day. List of instances is processed during construction
       
  1555 // of list box data and destroyed once it's done.
       
  1556 // Step 1 of construction of listbox data.
       
  1557 // ----------------------------------------------------------------------------
       
  1558 //
       
  1559 void CCalenDayContainer::GetInstanceListL()
       
  1560     {
       
  1561     TRACE_ENTRY_POINT;
       
  1562 
       
  1563     iInstanceList.ResetAndDestroy();
       
  1564 
       
  1565     iDateWasNull = iDate == Time::NullTTime();
       
  1566     iDate = CCalenContainer::DateFromContextL( iServices.Context() );
       
  1567     iDateWasNull = EFalse;
       
  1568     
       
  1569     RArray<TInt> colIdArray;
       
  1570     CCalenNativeView::GetActiveCollectionidsL( iServices, colIdArray );
       
  1571     
       
  1572     if(colIdArray.Count() > 0)
       
  1573           {
       
  1574           CalenAgendaUtils::CreateEntryIdListForDayL( iInstanceList,
       
  1575                                                 iServices.InstanceViewL(colIdArray),
       
  1576                                                 iDate );          
       
  1577           }
       
  1578     else
       
  1579         {
       
  1580         CalenAgendaUtils::CreateEntryIdListForDayL( iInstanceList,
       
  1581                                                       iServices.InstanceViewL(),
       
  1582                                                       iDate );
       
  1583         }
       
  1584     colIdArray.Reset();
       
  1585     TRACE_EXIT_POINT;
       
  1586     }
       
  1587 
       
  1588 // ----------------------------------------------------------------------------
       
  1589 // CCalenDayContainer::CreateSlotTableL
       
  1590 // Setup layout table. Step 2 of construction of listbox data
       
  1591 // (other items were commented in a header).
       
  1592 // ----------------------------------------------------------------------------
       
  1593 //
       
  1594 void CCalenDayContainer::CreateSlotTableL()
       
  1595     {
       
  1596     TRACE_ENTRY_POINT;
       
  1597 
       
  1598     // Init layoyt table
       
  1599     delete iLayoutTable;
       
  1600     iLayoutTable = NULL;
       
  1601     iLayoutTable = new( ELeave )CArrayFixFlat<SItemInfo>( KLayoutTableGranularity );
       
  1602     
       
  1603         // Process non-timed entries second
       
  1604     for ( TInt instanceIndex = 0; instanceIndex < iInstanceList.Count(); ++instanceIndex )
       
  1605         {
       
  1606         CCalInstance* instance = iInstanceList[ instanceIndex ];
       
  1607         if ( ! CalenAgendaUtils::IsTimedEntryL( instance->Entry().EntryTypeL()) 
       
  1608             && (!CalenViewUtils::IsAlldayEventL( *instance))  )
       
  1609             {
       
  1610             SItemInfo itemInfo;
       
  1611             itemInfo.iId = TCalenInstanceId::CreateL( *instance );
       
  1612             itemInfo.iStartTime = TTimeIntervalMinutes( KNullMinutes );
       
  1613             itemInfo.iTimedNote = EFalse;
       
  1614             itemInfo.iTopLine = KErrNotFound;
       
  1615 
       
  1616             itemInfo.iTmpInstance = instance;
       
  1617 
       
  1618             iLayoutTable->AppendL( itemInfo );
       
  1619             }
       
  1620         }
       
  1621     
       
  1622     // Process Alldayevent timed entries first
       
  1623     for ( TInt instanceIndex = 0; instanceIndex < iInstanceList.Count(); ++instanceIndex )
       
  1624         {
       
  1625         CCalInstance* instance = iInstanceList[ instanceIndex ];
       
  1626         if( (instance->Entry().EntryTypeL() == CCalEntry::EAppt
       
  1627              || instance->Entry().EntryTypeL() == CCalEntry::EEvent) 
       
  1628              && (CalenViewUtils::IsAlldayEventL( *instance)) )
       
  1629             {
       
  1630             TTime start = instance->Time().TimeLocalL();
       
  1631             SItemInfo itemInfo;
       
  1632             itemInfo.iId = TCalenInstanceId::CreateL( *instance );
       
  1633             itemInfo.iStartTime = CalenDateUtils::TimeOfDay( start );
       
  1634             itemInfo.iTimedNote = EFalse;
       
  1635             itemInfo.iTopLine = KErrNotFound;
       
  1636             itemInfo.iTmpInstance = instance;
       
  1637 
       
  1638             iLayoutTable->AppendL( itemInfo );
       
  1639             }
       
  1640         }
       
  1641 
       
  1642 
       
  1643     // Process timed entries second
       
  1644     for ( TInt instanceIndex = 0; instanceIndex < iInstanceList.Count(); ++instanceIndex )
       
  1645         {
       
  1646         CCalInstance* instance = iInstanceList[ instanceIndex ];
       
  1647         if ( ( CalenAgendaUtils::IsTimedEntryL( instance->Entry().EntryTypeL() ) )
       
  1648              && ( !CalenViewUtils::IsAlldayEventL( *instance ) ) ) 
       
  1649             {
       
  1650             TTime start = instance->Time().TimeLocalL();
       
  1651 
       
  1652             SItemInfo itemInfo;
       
  1653             itemInfo.iId = TCalenInstanceId::CreateL( *instance );
       
  1654             itemInfo.iStartTime = CalenDateUtils::TimeOfDay( start );
       
  1655             itemInfo.iTimedNote = ETrue;
       
  1656             itemInfo.iTopLine = KErrNotFound;
       
  1657 
       
  1658             itemInfo.iTmpInstance = instance;
       
  1659 
       
  1660             iLayoutTable->AppendL( itemInfo );
       
  1661             }
       
  1662         }
       
  1663 
       
  1664     TRACE_EXIT_POINT;
       
  1665     }
       
  1666 
       
  1667 // ----------------------------------------------------------------------------
       
  1668 // CCalenDayContainer::CompletePopulationL
       
  1669 // Completes population. Third and last stage stage of population.
       
  1670 // (other items were commented in a header).
       
  1671 // ----------------------------------------------------------------------------
       
  1672 //
       
  1673 void CCalenDayContainer::CompletePopulationL()
       
  1674     {
       
  1675     TRACE_ENTRY_POINT;
       
  1676 
       
  1677     CreateListBoxDataL();
       
  1678     AddToStackAndMakeVisibleL();
       
  1679     UpdateStatusPaneAndExtensionsL();
       
  1680 	// Hide/unhide "today" toolbar item based on the focused day
       
  1681     UpdateTodayToolbarItemL();
       
  1682     DrawNow();
       
  1683     TRACE_EXIT_POINT;
       
  1684     }
       
  1685     
       
  1686 // ----------------------------------------------------------------------------
       
  1687 // CCalenDayContainer::CreateIconIndicesL
       
  1688 // Create icon index for day view
       
  1689 // ----------------------------------------------------------------------------
       
  1690 //
       
  1691 void CCalenDayContainer::CreateIconIndicesL( RArray<MCalenServices::TCalenIcons>& aIndexArray )
       
  1692     {
       
  1693     TRACE_ENTRY_POINT;
       
  1694     // Icons needed for the day view
       
  1695     aIndexArray.Reset();
       
  1696     aIndexArray.AppendL( MCalenServices::ECalenBirthdayIcon );
       
  1697     aIndexArray.AppendL( MCalenServices::ECalenMeetingIcon );
       
  1698     aIndexArray.AppendL( MCalenServices::ECalenDaynoteIcon );
       
  1699     aIndexArray.AppendL( MCalenServices::ECalenToDoIcon );
       
  1700     aIndexArray.AppendL( MCalenServices::ECalenAlarmIcon );
       
  1701     aIndexArray.AppendL( MCalenServices::ECalenRepeatIcon );
       
  1702     aIndexArray.AppendL( MCalenServices::ECalenRepeatExceptionIcon );
       
  1703     aIndexArray.AppendL( MCalenServices::ECalenNotePriorityLow );
       
  1704     aIndexArray.AppendL( MCalenServices::ECalenNotePriorityHigh );
       
  1705     aIndexArray.AppendL( MCalenServices::ECalenMapIcon );
       
  1706 
       
  1707     TRACE_EXIT_POINT;
       
  1708     }
       
  1709 
       
  1710 // ----------------------------------------------------------------------------
       
  1711 // CCalenDayContainer::InfoBarRectL
       
  1712 // Returns the available info bar rect for this container
       
  1713 // ----------------------------------------------------------------------------
       
  1714 TRect CCalenDayContainer::InfoBarRectL( TBool aToolbarAvailable )
       
  1715     {
       
  1716     TRACE_ENTRY_POINT;
       
  1717    
       
  1718     // Get the main pane
       
  1719     TAknLayoutRect main_cale_day_pane;
       
  1720     main_cale_day_pane.LayoutRect( Rect(), 
       
  1721                     AknLayoutScalable_Apps::main_cale_day_pane().LayoutLine() );
       
  1722         
       
  1723     TAknLayoutRect listscroll_cale_day_pane;
       
  1724     listscroll_cale_day_pane.LayoutRect( main_cale_day_pane.Rect(), 
       
  1725             AknLayoutScalable_Apps::listscroll_cale_day_pane(1).LayoutLine() );
       
  1726 
       
  1727     // Create a dummy label to find the layout rect
       
  1728     CEikLabel* dummyLabel = new( ELeave ) CEikLabel;
       
  1729     CleanupStack::PushL( dummyLabel );
       
  1730 
       
  1731     // Get the layout variant for the month view infobar.
       
  1732     // We assume that we have one for this check, as we need to
       
  1733     // find the size that would be available if we do have one.
       
  1734     TInt layoutVariant = 0;
       
  1735     if( aToolbarAvailable )
       
  1736         {
       
  1737         layoutVariant = 1;
       
  1738         }
       
  1739     else
       
  1740         {
       
  1741         layoutVariant = 0;
       
  1742         }
       
  1743            
       
  1744     AknLayoutUtils::LayoutLabel( dummyLabel, listscroll_cale_day_pane.Rect(),
       
  1745         AknLayoutScalable_Apps::listscroll_cale_day_pane_t1( layoutVariant ).LayoutLine() );        
       
  1746               
       
  1747     TRect infoRect = dummyLabel->Rect();
       
  1748 
       
  1749     // Discard the label
       
  1750     CleanupStack::PopAndDestroy( dummyLabel );
       
  1751     
       
  1752     TRACE_EXIT_POINT;
       
  1753     return infoRect;
       
  1754     }
       
  1755     
       
  1756 // ----------------------------------------------------------------------------
       
  1757 // CCalenDayContainer::PreviewRectL
       
  1758 // Returns an empty rect - Day view does not support preview pane
       
  1759 // ----------------------------------------------------------------------------
       
  1760 TRect CCalenDayContainer::PreviewRectL()
       
  1761     {
       
  1762     TRACE_ENTRY_POINT;
       
  1763 
       
  1764     TRect rect;
       
  1765 
       
  1766     TRACE_EXIT_POINT;
       
  1767     return rect;
       
  1768     }
       
  1769 
       
  1770 // ----------------------------------------------------------------------------
       
  1771 // CCalenDayContainer::IsEventHasMapLocationL
       
  1772 // Stores the necessary information in the context
       
  1773 // and returns ETrue if event has geo coordinates else EFalse
       
  1774 // ----------------------------------------------------------------------------
       
  1775 TBool CCalenDayContainer::IsEventHasMapLocationL()
       
  1776 	{
       
  1777 	MCalenContext& context = iServices.Context();
       
  1778 	TCalLocalUid instanceId = context.InstanceId().iEntryLocalUid;
       
  1779 	
       
  1780 	CCalEntry* entry = iServices.EntryViewL(context.InstanceId().iColId)->FetchL(instanceId);
       
  1781 
       
  1782 	CCalGeoValue* geoValue = entry->GeoValueL();
       
  1783 	if(geoValue)
       
  1784 		{
       
  1785 		delete geoValue;
       
  1786 		delete entry;
       
  1787 		// Event has saved map location, put "Show on Map"
       
  1788 		return 	ETrue;
       
  1789 		}
       
  1790 	else
       
  1791 		{
       
  1792 		return EFalse;
       
  1793 		}
       
  1794 	}
       
  1795 	
       
  1796 // ----------------------------------------------------------------------------
       
  1797 // CCalenDayContainer::IsEventHasNoLocationTextL
       
  1798 // Returns ETrue if event has location text else EFalse
       
  1799 // ----------------------------------------------------------------------------
       
  1800 TBool CCalenDayContainer::IsEventHasNoLocationTextL()
       
  1801 	{
       
  1802 	MCalenContext& context = iServices.Context();
       
  1803 	TCalLocalUid instanceId = context.InstanceId().iEntryLocalUid;
       
  1804 	
       
  1805 	CCalEntry* entry = iServices.EntryViewL(context.InstanceId().iColId)->FetchL(instanceId);
       
  1806 	TPtrC location = entry->LocationL();
       
  1807 	if(!location.Length())
       
  1808 		{
       
  1809 		return ETrue;
       
  1810 		}
       
  1811 	else
       
  1812 		{
       
  1813 		return EFalse;
       
  1814 		}
       
  1815 	}
       
  1816 // ----------------------------------------------------------------------------
       
  1817 // CCalenDayContainer::IsValidEntryL()
       
  1818 // Check whether entry exists or not
       
  1819 // ----------------------------------------------------------------------------
       
  1820 TBool CCalenDayContainer::IsValidEntryL()
       
  1821     {
       
  1822     TRACE_ENTRY_POINT;
       
  1823     
       
  1824     MCalenContext& context = iServices.Context();
       
  1825     TCalLocalUid instanceId = context.InstanceId().iEntryLocalUid;
       
  1826         
       
  1827     CCalEntry* entry = iServices.EntryViewL(context.InstanceId().iColId)->FetchL(instanceId);
       
  1828     CleanupStack::PushL(entry);
       
  1829     TBool iSEntry(EFalse);
       
  1830     if(entry)
       
  1831         {
       
  1832         iSEntry = ETrue;
       
  1833         }
       
  1834     else 
       
  1835         {
       
  1836         iSEntry = EFalse;
       
  1837         }
       
  1838     CleanupStack::PopAndDestroy(entry);
       
  1839     TRACE_EXIT_POINT;
       
  1840     return iSEntry;
       
  1841     }
       
  1842 // End of File