calendarui/views/src/calenpreview.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2002 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 //debug
       
    19 #include "calendarui_debug.h"
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "calenpreview.h"
       
    23 
       
    24 #include "calenpreviewdata.h"
       
    25 #include "calenpreviewentry.h"
       
    26 #include "calenpreviewlabel.h"
       
    27 #include "calenpreviewlayoutmanager.h"
       
    28 #include "calenpreviewtimer.h"
       
    29 #include <calenservices.h>
       
    30 
       
    31 #include <calendateutils.h>
       
    32 #include "calenicons.h"
       
    33 #include <AknIconArray.h>
       
    34 #include <calenview.h>
       
    35 #include <StringLoader.h>
       
    36 #include <calenconstants.h>
       
    37 #include <Calendar.rsg>
       
    38 #include "CalenUid.h"
       
    39 
       
    40 #include <AknBidiTextUtils.h>
       
    41 #include <AknIconUtils.h>
       
    42 #include <AknsDrawUtils.h>
       
    43 #include <eiklabel.h>
       
    44 #include <gulicon.h>
       
    45 #include <layoutmetadata.cdl.h>
       
    46 #include <AknPreviewPopUpController.h>
       
    47 #include <AknPictographInterface.h>
       
    48 #include <aknlayoutscalable_apps.cdl.h>
       
    49 #include <aknlayoutscalable_avkon.cdl.h>
       
    50 #include <e32base.h>
       
    51 #include <aknlongtapdetector.h>
       
    52 #include "calendar.hrh"
       
    53 #include <PUAcodes.hrh>
       
    54 #include <AknIconArray.h>
       
    55 #include <aknstyluspopupmenu.h>
       
    56 #include <barsread.h>
       
    57 #include <calencommands.hrh>            // Calendar commands
       
    58 #include <calencontext.h>
       
    59 
       
    60 // CONSTANTS
       
    61 const TInt KCalenPopupTimeout  =  1000000; // 1 sec
       
    62 const TInt KCalenPopupHideTimeout  = 10000000; // 10 sec
       
    63 const TInt KCalenPopupPreviewTimeout =   500000; // 0.5 sec
       
    64 const TInt KCalenMonthLimitMinutes = 30;
       
    65 //const TInt KCalenPreviewIconCount = 4;
       
    66 const TUint KSpecialSpace = KPuaCodeShortSpace;
       
    67 const TInt KShortDayNames[] =
       
    68     {
       
    69     R_QTN_WEEK_TWO_CHARS_MO,
       
    70     R_QTN_WEEK_TWO_CHARS_TU,
       
    71     R_QTN_WEEK_TWO_CHARS_WE,
       
    72     R_QTN_WEEK_TWO_CHARS_TH,
       
    73     R_QTN_WEEK_TWO_CHARS_FR,
       
    74     R_QTN_WEEK_TWO_CHARS_SA,
       
    75     R_QTN_WEEK_TWO_CHARS_SU
       
    76     };
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CCalenPreview::CCalenPreview
       
    80 // ?implementation_description
       
    81 // (other items were commented in a header).
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 CCalenPreview::CCalenPreview(CCalenView* aView, TLocale& aLocale,
       
    85                                      MCalenServices& aServices )
       
    86     : iFlags(0), iLocale(aLocale), iView(aView),
       
    87                  iPluginLabelCount(0),iServices( aServices ),iStylusPopup(NULL)
       
    88     {
       
    89     TRACE_ENTRY_POINT;
       
    90     TRACE_EXIT_POINT;
       
    91     }
       
    92 // ---------------------------------------------------------------------------
       
    93 // CCalenPreview::~CCalenPreview
       
    94 // ?implementation_description
       
    95 // (other items were commented in a header).
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 CCalenPreview::~CCalenPreview()
       
    99     {
       
   100     TRACE_ENTRY_POINT;
       
   101     
       
   102     ResetComponents();
       
   103     
       
   104     iIcons.ResetAndDestroy();
       
   105     delete iTitle;
       
   106     delete iData;
       
   107     delete iPictoInterface;
       
   108     delete iController;
       
   109     delete iMoreIcon;
       
   110     delete iLongTapDetector;
       
   111     delete iExpirationTimer;
       
   112     if ( iStylusPopup )
       
   113            {
       
   114            delete iStylusPopup;
       
   115            iStylusPopup = NULL;
       
   116            }
       
   117     TRACE_EXIT_POINT;
       
   118     }
       
   119 
       
   120 
       
   121 // --------------------------------------------------------------------------
       
   122 // ?classname::?member_function
       
   123 // ?implementation_description
       
   124 // (other items were commented in a header).
       
   125 // --------------------------------------------------------------------------
       
   126 //
       
   127 void CCalenPreview::ResetComponents()
       
   128     {
       
   129     TRACE_ENTRY_POINT;
       
   130     Components().Remove(iTitle);
       
   131     Components().Remove(iPluginControl);
       
   132     Components().ResetAndDestroy();
       
   133     TRACE_EXIT_POINT;
       
   134     }
       
   135 
       
   136 // --------------------------------------------------------------------------
       
   137 // ?classname::?member_function
       
   138 // ?implementation_description
       
   139 // (other items were commented in a header).
       
   140 // --------------------------------------------------------------------------
       
   141 //
       
   142 void CCalenPreview::AddPluginControlL()
       
   143     {  
       
   144     TRACE_ENTRY_POINT;
       
   145     TInt ctrlId = Components().Id(*iPluginControl);
       
   146     if(KErrNotFound == ctrlId)  // check if added already.
       
   147         {
       
   148         Components().AppendLC(iPluginControl) ;
       
   149         CleanupStack::Pop( iPluginControl );
       
   150         }
       
   151 	TRACE_EXIT_POINT;
       
   152     }
       
   153 // --------------------------------------------------------------------------
       
   154 // ?classname::?member_function
       
   155 // ?implementation_description
       
   156 // (other items were commented in a header).
       
   157 // --------------------------------------------------------------------------
       
   158 //
       
   159 void CCalenPreview::InitComponentsL()
       
   160     {
       
   161     TRACE_ENTRY_POINT;
       
   162     Components().Remove(iTitle);
       
   163     Components().Remove(iPluginControl);	
       
   164     Components().ResetAndDestroy();
       
   165     
       
   166     if( iLayoutManager->UsePreview() )
       
   167         {
       
   168         iExpirationTimer->Cancel();
       
   169 		Components().AppendLC(iTitle );
       
   170 		CleanupStack::Pop( iTitle );
       
   171 
       
   172 		TRect rect = Rect(); 
       
   173 		CCoeControl *aControl = iServices.PreviewPane(rect);
       
   174 		
       
   175 		if(iPluginControl && iPluginControl != aControl) 
       
   176 		{
       
   177 			iServices.IssueNotificationL(ECalenNotifyCheckPluginUnloading);
       
   178 			iPluginControl = NULL;
       
   179 		}
       
   180         iPluginLabelCount = 0;
       
   181         
       
   182 		if(aControl)
       
   183 			{
       
   184 			iPluginControl = aControl;
       
   185 			iPluginLabelCount = 1;		
       
   186 			if(Layout_Meta_Data::IsLandscapeOrientation())
       
   187 			    {
       
   188     			if(Rect().iBr.iY  < rect.iBr.iY)
       
   189         		   	{
       
   190         		   	iPluginLabelCount = 2;	
       
   191         		   	}
       
   192 			    }
       
   193 			}
       
   194 		}
       
   195 
       
   196     for(TInt i=0; i < iLayoutManager->LineCount() - iPluginLabelCount; i++)
       
   197         {
       
   198         CCalenPreviewLabel* label = CreateLabelL(CCalenPreviewLabel::ECalenPreviewEmptyRow);
       
   199         Components().AppendLC(label);
       
   200         CleanupStack::Pop( label );
       
   201         }
       
   202     
       
   203     TRACE_EXIT_POINT;
       
   204     }
       
   205 
       
   206 // --------------------------------------------------------------------------
       
   207 // ?classname::?member_function
       
   208 // ?implementation_description
       
   209 // (other items were commented in a header).
       
   210 // --------------------------------------------------------------------------
       
   211 //
       
   212 CCoeControl* CCalenPreview::PluginControl()
       
   213 	{
       
   214 	TRACE_ENTRY_POINT;
       
   215 	
       
   216 	   if(iPluginControl)
       
   217 	   	{
       
   218 	   	return iPluginControl;
       
   219 	   	}
       
   220 	  return NULL;
       
   221 	 
       
   222 	TRACE_EXIT_POINT;
       
   223 	}
       
   224 
       
   225 // --------------------------------------------------------------------------
       
   226 // ?classname::?member_function
       
   227 // ?implementation_description
       
   228 // (other items were commented in a header).
       
   229 // --------------------------------------------------------------------------
       
   230 //
       
   231 CCalenPreview* CCalenPreview::NewL(CCalenView* aView,
       
   232                                    TLocale& aLocale,
       
   233                                      MCalenServices& aServices )
       
   234     {
       
   235     TRACE_ENTRY_POINT;
       
   236     CCalenPreview* self = 
       
   237         new( ELeave ) CCalenPreview(aView, aLocale, aServices );
       
   238     CleanupStack::PushL( self );
       
   239     self->ConstructL();
       
   240     CleanupStack::Pop( self );
       
   241     TRACE_EXIT_POINT;
       
   242     return self;
       
   243     }
       
   244     
       
   245 // ---------------------------------------------------------------------------
       
   246 // CCalenPreview::ConstructL
       
   247 // ?implementation_description
       
   248 // (other items were commented in a header).
       
   249 // ---------------------------------------------------------------------------
       
   250 //
       
   251 void CCalenPreview::ConstructL()
       
   252     {
       
   253     TRACE_ENTRY_POINT;
       
   254     iLayoutManager = CCalenPreviewLayoutManager::NewL(this);
       
   255 
       
   256     if( iLayoutManager->UsePreview() )
       
   257         {
       
   258         iFlags |= CAknPreviewPopUpController::EPermanentMode;
       
   259         }
       
   260     iFlags |= CAknPreviewPopUpController::EExcludeFrames;
       
   261         
       
   262     iController = CAknPreviewPopUpController::NewL(*this, 
       
   263                                                    *this,
       
   264                                                    iFlags);
       
   265     iController->AddObserverL(*this);
       
   266 
       
   267     InitComponentArrayL();
       
   268     SetLayoutManagerL(iLayoutManager);
       
   269 
       
   270     CreateIconArrayL();
       
   271     iMoreIcon = iServices.GetIconL( MCalenServices::ECalenItemNotShownIcon );
       
   272     iPictoInterface = CAknPictographInterface::NewL( *this, *this );
       
   273     iState = EPreviewPopUpHidden;
       
   274 
       
   275     iTitle = CreateLabelL(CCalenPreviewLabel::ECalenPreviewTitleRow);
       
   276     
       
   277     if(iLayoutManager->UsePreview())
       
   278         {
       
   279         iController->SetPopUpShowDelay(0);
       
   280         iLayoutManager->SetContainerLayout();
       
   281         TPoint point = Rect().iTl;
       
   282         point.iX += Rect().Width();
       
   283         iController->SetPosition(point);
       
   284         }
       
   285     else
       
   286         {
       
   287         iController->SetPopUpShowDelay(KCalenPopupTimeout);
       
   288         iController->SetPopUpHideDelay(KCalenPopupHideTimeout);
       
   289         }
       
   290 
       
   291     SetComponentsToInheritVisibility(ETrue);
       
   292     TCallBack expirationCallBack( ExpiredCallBack, this );
       
   293     iExpirationTimer = CCalenPreviewTimer::NewL( expirationCallBack );
       
   294     
       
   295     // to cancel the long tap animation on pointer up event   
       
   296     DrawableWindow()->SetPointerGrab(ETrue);
       
   297     
       
   298     TRACE_EXIT_POINT;
       
   299     }
       
   300 
       
   301 // ---------------------------------------------------------------------------
       
   302 // CCalenPreview::CreateLabelL
       
   303 // ?implementation_description
       
   304 // (other items were commented in a header).
       
   305 // ---------------------------------------------------------------------------
       
   306 //
       
   307 CCalenPreviewLabel* CCalenPreview::CreateLabelL( 
       
   308     CCalenPreviewLabel::TPreviewLabelType aType)
       
   309     {
       
   310     TRACE_ENTRY_POINT;
       
   311    
       
   312     CCalenPreviewLabel* label = CCalenPreviewLabel::NewL();
       
   313     CleanupStack::PushL(label);
       
   314     label->SetLabelType(aType);
       
   315     label->SetContainerWindowL(*this);
       
   316     label->SetMopParent(this);
       
   317     label->SetTextL(_L(""));
       
   318     // Conversion is done, when creating data
       
   319     label->UseLogicalToVisualConversion(EFalse); 
       
   320     if ( iPictoInterface )
       
   321         {
       
   322         label->EnablePictographsL( *iPictoInterface );
       
   323         }
       
   324     CleanupStack::Pop( label );
       
   325     TRACE_EXIT_POINT;
       
   326     return label;
       
   327     }
       
   328 
       
   329 
       
   330 
       
   331 
       
   332 // ---------------------------------------------------------------------------
       
   333 // CCalenPreview::HandleEntryEventL
       
   334 // ?implementation_description
       
   335 // (other items were commented in a header).
       
   336 // ---------------------------------------------------------------------------
       
   337 //
       
   338 void CCalenPreview::HandlePreviewEntryEventL(const TCalenInstanceId& aInstId,
       
   339                                              TPointerEvent::TType aType)
       
   340     {
       
   341     TRACE_ENTRY_POINT;
       
   342 
       
   343     if( AknLayoutUtils::PenEnabled() )
       
   344         {
       
   345         if(iState == EPreviewPopUpShown)
       
   346             {
       
   347             if(aType == TPointerEvent::EDrag) 
       
   348                 {
       
   349                 CCalenPreviewLabel* label = NULL;
       
   350                 TInt labelCount = CountComponentControls();
       
   351                 if(iPluginControl)
       
   352                 {
       
   353                 	labelCount = labelCount -1;
       
   354                 }
       
   355                 for(TInt i(0); i < labelCount; i++)
       
   356                     {
       
   357                     label = 
       
   358                         static_cast<CCalenPreviewLabel*>(ComponentControl(i));
       
   359                     label->HandleVisualisationL(
       
   360                         CCalenPreviewLabel::ERemoveVisualisation);
       
   361                     }
       
   362                 }
       
   363             else
       
   364                 {
       
   365                 MCalenContext& context = iServices.Context();
       
   366                 context.SetInstanceIdL( aInstId, context.ViewId() );
       
   367 
       
   368                 if( aType == TPointerEvent::EButton1Up )
       
   369                     {
       
   370                     // if( !iLayoutManager->UsePreview() )
       
   371                         {
       
   372                         iController->HidePopUp();  
       
   373                         }
       
   374                     iView->HandleCommandL( ECalenEventView );
       
   375                     }
       
   376                 }
       
   377             }
       
   378         }
       
   379        
       
   380     TRACE_EXIT_POINT;
       
   381     }
       
   382 
       
   383 // ---------------------------------------------------------------------------
       
   384 // CCalenPreview::HandlePreviewPopUpEventL
       
   385 // ?implementation_description
       
   386 // (other items were commented in a header).
       
   387 // ---------------------------------------------------------------------------
       
   388 //
       
   389 void CCalenPreview::HandlePreviewPopUpEventL( 
       
   390     CAknPreviewPopUpController* aController,
       
   391     TPreviewPopUpEvent aEvent )
       
   392     {
       
   393     TRACE_ENTRY_POINT;
       
   394     if(aController == iController)
       
   395         iState = aEvent;
       
   396     TRACE_EXIT_POINT;
       
   397     }
       
   398 
       
   399 // ---------------------------------------------------------------------------
       
   400 // CCalenPreview::HandlePreviewPopUpEventL
       
   401 // ?implementation_description
       
   402 // (other items were commented in a header).
       
   403 // ---------------------------------------------------------------------------
       
   404 //
       
   405 void CCalenPreview::HandleResourceChange( TInt aType )
       
   406     {
       
   407     TRACE_ENTRY_POINT;
       
   408     if( aType == KEikDynamicLayoutVariantSwitch )
       
   409 			{
       
   410 			ResetComponents();
       
   411 			iController->HidePopUp();
       
   412 			if(iLayoutManager->UsePreview())
       
   413 				{
       
   414 				iController->SetPopUpShowDelay(0);
       
   415 				iLayoutManager->SetContainerLayout();
       
   416 				TPoint point = Rect().iTl;
       
   417 				point.iX += Rect().Width();
       
   418 				iController->SetPosition(point);
       
   419 				}
       
   420 			else
       
   421 				{
       
   422 				iController->SetPopUpShowDelay(KCalenPopupTimeout);
       
   423 				iController->SetPopUpHideDelay(KCalenPopupHideTimeout);
       
   424 				}
       
   425 		TRAP_IGNORE(InitComponentsL()); // After resetting, initilize the components for redrawing
       
   426         }
       
   427     TRACE_EXIT_POINT;
       
   428     }
       
   429 
       
   430 // ---------------------------------------------------------
       
   431 // CCalenPreview::HandleLongTapEventL
       
   432 // processing of a long tap event
       
   433 // (other items were commented in a header).
       
   434 // ---------------------------------------------------------
       
   435 //
       
   436 void CCalenPreview::HandleLongTapEventL( const TPoint& aLocation,
       
   437                                          const TPoint& aScreenLocation )
       
   438     {
       
   439     TRACE_ENTRY_POINT;
       
   440     TBool handleEvent(EFalse);
       
   441     if(AknLayoutUtils::PenEnabled())
       
   442         {
       
   443         for(TInt i(0); i < iData->EntryCount(); i++)
       
   444             {
       
   445             if(iData->Entry(i)->Contains(aLocation))
       
   446                 {
       
   447                 handleEvent = ETrue;
       
   448                 break;
       
   449                 }
       
   450             }
       
   451         if(handleEvent)
       
   452             {
       
   453             CCalenPreviewLabel* label;
       
   454             TInt labelCount = CountComponentControls();
       
   455             if (iPluginControl)
       
   456                 {   
       
   457             		labelCount = labelCount-1;
       
   458                 }
       
   459             for(TInt i(0); i < labelCount; i++)
       
   460                 {
       
   461                 label = static_cast<CCalenPreviewLabel*>(ComponentControl(i));
       
   462                 label->HandleVisualisationL(
       
   463                     CCalenPreviewLabel::ERemoveVisualisation);
       
   464                 }
       
   465             IgnoreEventsUntilNextPointerUp();
       
   466             if ( iStylusPopup )
       
   467                 {
       
   468                 delete iStylusPopup;
       
   469                 iStylusPopup = NULL;       
       
   470                 }                        
       
   471             iStylusPopup = CAknStylusPopUpMenu::NewL( iView,aScreenLocation );    
       
   472             TResourceReader reader;
       
   473             iCoeEnv->CreateResourceReaderLC( reader, R_CALENDAR_DAY_STYLUS_MENU_TUI );
       
   474             iStylusPopup->ConstructFromResourceL( reader );
       
   475             CleanupStack::PopAndDestroy(); 
       
   476             TCalenInstanceId instId = iServices.Context().InstanceId();
       
   477             TBool isTodoFocused; // true when instId is not null and instId type == todo
       
   478             isTodoFocused = !(instId == TCalenInstanceId::NullInstanceId()) &&
       
   479                                                            instId.iType == CCalEntry::ETodo;
       
   480             if (!isTodoFocused )
       
   481                 {
       
   482                 iStylusPopup->RemoveMenuItem(ECalenCompleteTodo);
       
   483                 }
       
   484             iStylusPopup->SetPosition(aScreenLocation);
       
   485             iStylusPopup->ShowMenu();
       
   486             }
       
   487         }
       
   488 
       
   489     TRACE_EXIT_POINT;
       
   490     }
       
   491 
       
   492 // ---------------------------------------------------------------------------
       
   493 // CCalenPreview::HandlePointerEventL
       
   494 // ?implementation_description
       
   495 // (other items were commented in a header).
       
   496 // ---------------------------------------------------------------------------
       
   497 //
       
   498 void CCalenPreview::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   499     {
       
   500     TRACE_ENTRY_POINT;
       
   501     if(AknLayoutUtils::PenEnabled())
       
   502         {
       
   503         // long tap handling
       
   504         if( iLongTapDetector == NULL )
       
   505             {
       
   506             iLongTapDetector = CAknLongTapDetector::NewL( this );
       
   507             iLongTapDetector->EnableLongTapAnimation(ETrue);
       
   508             }
       
   509          if(iTitle->Rect().Contains(aPointerEvent.iPosition) && aPointerEvent.iType == TPointerEvent::EButton1Up)
       
   510              {
       
   511              iView->HandleCommandL(ECalenForwardsToDayView);
       
   512 
       
   513              }
       
   514         
       
   515         /* Check more entries icon first */
       
   516         if(iData->NotShownEntries() &&
       
   517            aPointerEvent.iType == TPointerEvent::EButton1Up)
       
   518             {
       
   519             TInt lastLine = CountComponentControls() - 1;
       
   520             CCalenPreviewLabel* label =
       
   521                 static_cast<CCalenPreviewLabel*>(ComponentControl(lastLine));
       
   522             if(label->MoreIcon() && label->MoreIconRect().Contains(aPointerEvent.iPosition))
       
   523                 iView->HandleCommandL( ECalenForwardsToDayView );
       
   524             }
       
   525         
       
   526 		     if(iPluginControl && iPluginControl->Rect().Contains(aPointerEvent.iPosition) )
       
   527 	        	{
       
   528 			      iPluginControl->HandlePointerEventL(aPointerEvent);
       
   529 		        }
       
   530          else
       
   531             {
       
   532             TBool eventHandled(EFalse);
       
   533             for(TInt i(0); i < iData->EntryCount(); i++)
       
   534                 {
       
   535                 if(iData->Entry(i)->Contains(aPointerEvent.iPosition))
       
   536                     {
       
   537                     iLongTapDetector->PointerEventL( aPointerEvent );
       
   538                     iData->Entry(i)->HandleLabelPointerEventL( aPointerEvent );
       
   539                     eventHandled = ETrue;
       
   540                     break;
       
   541                     }
       
   542                 }
       
   543             /* then drag outside of entries */
       
   544             if(aPointerEvent.iType == TPointerEvent::EDrag && 
       
   545                eventHandled == EFalse)
       
   546                 {
       
   547                 CCalenPreviewLabel* label = NULL;
       
   548                 TInt labelCount = CountComponentControls();
       
   549                 if(iPluginControl)
       
   550                 {
       
   551                 	labelCount = labelCount - 1;
       
   552                 }
       
   553 
       
   554                 for(TInt i(0); i < labelCount; i++)
       
   555                     {
       
   556                     label = 
       
   557                         static_cast<CCalenPreviewLabel*>(ComponentControl(i));
       
   558                     label->HandleVisualisationL(
       
   559                         CCalenPreviewLabel::ERemoveVisualisation);
       
   560                 }
       
   561             }
       
   562 	        }
       
   563         }
       
   564     TRACE_EXIT_POINT;
       
   565     }
       
   566 
       
   567 // ---------------------------------------------------------------------------
       
   568 // CCalenPreview::MinimumSize
       
   569 // ?implementation_description
       
   570 // (other items were commented in a header).
       
   571 // ---------------------------------------------------------------------------
       
   572 //
       
   573 TSize CCalenPreview::MinimumSize()
       
   574     {
       
   575     TRACE_ENTRY_POINT;
       
   576     TSize asize(Rect().Size());
       
   577     if(asize.iHeight || asize.iWidth)
       
   578         asize = iLayoutManager->MinimumSize();
       
   579     TRACE_EXIT_POINT;
       
   580     return asize;
       
   581     }
       
   582 
       
   583 // ---------------------------------------------------------------------------
       
   584 // CCalenPreview::Draw
       
   585 // ?implementation_description
       
   586 // (other items were commented in a header).
       
   587 // ---------------------------------------------------------------------------
       
   588 //
       
   589 void CCalenPreview::Draw( const TRect& aRect) const
       
   590     {
       
   591     TRACE_ENTRY_POINT;
       
   592     CWindowGc& gc = SystemGc();
       
   593 
       
   594     TRect rect(aRect);
       
   595  
       
   596     TAknWindowComponentLayout temp = 
       
   597         AknLayoutScalable_Avkon::bg_popup_preview_window_pane_g1();
       
   598 
       
   599     rect.iTl.iX -= temp.LayoutLine().il;
       
   600     rect.iTl.iY -= temp.LayoutLine().it;
       
   601     rect.iBr.iX += temp.LayoutLine().ir;
       
   602     rect.iBr.iY += temp.LayoutLine().ib;
       
   603 
       
   604        
       
   605    //    DrawIcons();
       
   606     CCalenPreviewLabel* label = NULL;
       
   607     TInt labelCount = CountComponentControls();
       
   608           
       
   609     gc.SetClippingRect(rect);
       
   610         
       
   611      
       
   612     if(iPluginControl)
       
   613     {
       
   614     	labelCount = labelCount-1;
       
   615     }
       
   616  	
       
   617     for(TInt i(0); i < labelCount ; i++)
       
   618         {
       
   619         label = static_cast<CCalenPreviewLabel*>(ComponentControl(i));
       
   620         
       
   621         if( !iLayoutManager->UsePreview() )
       
   622             {
       
   623             // Get the color strip rect area as per the label's size and color and draw the strip.
       
   624 
       
   625             gc.CancelClippingRect();
       
   626             TRect colorRect;
       
   627                 
       
   628             gc.SetPenColor( TRgb(label->icolor) );
       
   629             gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   630             gc.SetBrushColor( TRgb(label->icolor) );
       
   631          
       
   632                 
       
   633             colorRect.iTl.iX = label->Rect().iTl.iX;
       
   634             colorRect.iBr.iY = label->Rect().iBr.iY;
       
   635             colorRect.iBr.iX = label->Rect().iTl.iX + 5;
       
   636             colorRect.iTl.iY = label->Rect().iTl.iY;
       
   637             
       
   638             gc.DrawRect(colorRect);
       
   639             gc.SetClippingRect(rect);         
       
   640             }
       
   641             
       
   642 
       
   643         if (label->Icon())
       
   644             {
       
   645             gc.SetPenColor( TRgb( label->icolor ) );
       
   646             gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   647             gc.SetBrushColor( TRgb(label->icolor) );
       
   648             
       
   649             TPoint point = label->Position();
       
   650             point.iX -= 25;
       
   651             point.iY += 3;
       
   652             TSize  size( label->Rect().Width()/35, label->Rect().Height() );
       
   653             
       
   654             TRect rect(point,size);
       
   655             gc.DrawRect( rect );
       
   656             }
       
   657         if(label->MoreIcon())
       
   658             {
       
   659             CFbsBitmap* bmp = label->MoreIcon()->Bitmap();
       
   660             TRect rect = label->MoreIconRect();
       
   661             AknIconUtils::SetSize(bmp, rect.Size());
       
   662             gc.BitBltMasked(rect.iTl, 
       
   663                             bmp,
       
   664                             TRect(TPoint(0,0), bmp->SizeInPixels()),
       
   665                             label->MoreIcon()->Mask(), 
       
   666                             ETrue);
       
   667             }
       
   668         }
       
   669         
       
   670     gc.CancelClippingRect();
       
   671     TRACE_EXIT_POINT;
       
   672     }
       
   673 
       
   674 // ---------------------------------------------------------------------------
       
   675 // CCalenPreview::FocusedDayChanged
       
   676 // ?implementation_description
       
   677 // (other items were commented in a header).
       
   678 // ---------------------------------------------------------------------------
       
   679 //
       
   680 void CCalenPreview::FocusChangedL(const TTime& aTime)
       
   681     {
       
   682     TRACE_ENTRY_POINT;
       
   683     iFocusedTime = aTime;
       
   684     iFocusedInst = NULL;
       
   685     UpdateTitleL();
       
   686     InitComponentsL();
       
   687     
       
   688     TBool isMenuDisplayed = EFalse;
       
   689     CEikMenuBar* menuBar = iView->MenuBar();
       
   690     if(menuBar && menuBar->IsDisplayed())
       
   691         {
       
   692         isMenuDisplayed = ETrue;
       
   693         }
       
   694     
       
   695     if(!isMenuDisplayed)
       
   696         {
       
   697         iController->ShowPopUp();    
       
   698         }
       
   699     TRACE_EXIT_POINT;
       
   700     }
       
   701 
       
   702 void CCalenPreview::FocusChangedL(CCalInstance* aInstance)
       
   703     {
       
   704     TRACE_ENTRY_POINT;
       
   705     iFocusedTime = Time::NullTTime();
       
   706     if(aInstance != NULL)
       
   707     	{
       
   708     	iFocusedTime = aInstance->StartTimeL().TimeLocalL();
       
   709     	}
       
   710     iFocusedInst = aInstance;
       
   711     UpdateTitleL();
       
   712     InitComponentsL();
       
   713 
       
   714     TBool isMenuDisplayed = EFalse;
       
   715     CEikMenuBar* menuBar = iView->MenuBar();
       
   716     if(menuBar && menuBar->IsDisplayed())
       
   717         {
       
   718         isMenuDisplayed = ETrue;
       
   719         }
       
   720     
       
   721     if(!isMenuDisplayed)
       
   722         {
       
   723         iController->ShowPopUp();    
       
   724         }
       
   725     TRACE_EXIT_POINT;
       
   726     }
       
   727 
       
   728 // ---------------------------------------------------------------------------
       
   729 // CCalenPreview::StartContentBuildingL
       
   730 // ?implementation_description
       
   731 // (other items were commented in a header).
       
   732 // ---------------------------------------------------------------------------
       
   733 //
       
   734 void CCalenPreview::StartContentBuildingL()
       
   735     {
       
   736     TRACE_ENTRY_POINT;
       
   737 
       
   738    delete iData;
       
   739    iData = NULL;
       
   740    TBool delForMonth = ETrue;
       
   741     if ( iFocusedInst == NULL )
       
   742         {//Month View
       
   743         iData = CCalenPreviewData::NewL(iLayoutManager,
       
   744                                         iServices,
       
   745                                         iLayoutManager->LineCount() - iPluginLabelCount,
       
   746                                         iFocusedTime);
       
   747         TUid viewuid = iView->Id();
       
   748         if( viewuid == KUidCalenMonthView )
       
   749             {
       
   750             BuildMonthCellL(iFocusedTime);
       
   751             }
       
   752         else if( viewuid == KUidCalenWeekView )
       
   753             {
       
   754             BuildWeekCellL(iFocusedTime);
       
   755             }
       
   756         else
       
   757             {
       
   758             User::Leave(KErrCancel);
       
   759             }
       
   760         }
       
   761     else
       
   762         {//Week view
       
   763         iData = CCalenPreviewData::NewL(iLayoutManager,
       
   764                                         iServices,
       
   765                                         iLayoutManager->LineCount() - iPluginLabelCount,
       
   766                                         iFocusedInst);
       
   767         delForMonth = EFalse;
       
   768         }  
       
   769 
       
   770     if( iData->InstanceCount() > 0 || iLayoutManager->UsePreview() )
       
   771         {
       
   772         SetTimerForNextExpiringEventL();
       
   773 
       
   774         if(!iLayoutManager->UsePreview()) 
       
   775             {
       
   776             iController->UpdateContentSize();
       
   777             SetPreviewContentL(iFocusedTime);
       
   778             iLayoutManager->SetContainerLayout();
       
   779             // Following is done because avkon popup draws popup window left and down from given point 
       
   780             TPoint point = Rect().iTl;
       
   781             point.iX += Rect().Width();
       
   782             iController->SetPosition(point);
       
   783             }
       
   784         else
       
   785             {
       
   786             SetPreviewContentL(iFocusedTime);
       
   787             iLayoutManager->PerformLayout();
       
   788             iController->SetPopUpShowDelay(KCalenPopupPreviewTimeout);
       
   789             }        
       
   790         iController->ContentReady();
       
   791         
       
   792         if(delForMonth)
       
   793             {
       
   794             iData->DeleteInstances();
       
   795             }
       
   796         }
       
   797     else
       
   798         {
       
   799         delete iData;
       
   800         iData = NULL;
       
   801         User::Leave(KErrCancel);
       
   802         }
       
   803 
       
   804     TRACE_EXIT_POINT;
       
   805     }
       
   806 
       
   807 // ---------------------------------------------------------------------------
       
   808 // CCalenPreview::CancelContentBuildingL
       
   809 // ?implementation_description
       
   810 // (other items were commented in a header).
       
   811 // ---------------------------------------------------------------------------
       
   812 //
       
   813 void CCalenPreview::CancelContentBuilding()
       
   814     {
       
   815     TRACE_ENTRY_POINT;
       
   816     iExpirationTimer->Cancel();
       
   817     TRACE_EXIT_POINT;
       
   818     }
       
   819 
       
   820 // ---------------------------------------------------------------------------
       
   821 // ?classname::?member_function
       
   822 // ?implementation_description
       
   823 // (other items were commented in a header).
       
   824 // ---------------------------------------------------------------------------
       
   825 //
       
   826 void CCalenPreview::DrawPictographArea() 
       
   827     {
       
   828     TRACE_ENTRY_POINT;
       
   829     DrawNow();
       
   830     TRACE_EXIT_POINT;
       
   831     }
       
   832 
       
   833 // ---------------------------------------------------------------------------
       
   834 // ?classname::?member_function
       
   835 // ?implementation_decription
       
   836 // (other items were commented in a header).
       
   837 // ---------------------------------------------------------------------------
       
   838 //
       
   839 void CCalenPreview::Hide() 
       
   840     {
       
   841     TRACE_ENTRY_POINT;
       
   842     if(!iLayoutManager->UsePreview())
       
   843         iController->HidePopUp();
       
   844     TRACE_EXIT_POINT;
       
   845     }
       
   846 
       
   847 // ---------------------------------------------------------------------------
       
   848 // ?classname::?member_function
       
   849 // ?implementation_description
       
   850 // (other items were commented in a header).
       
   851 // ---------------------------------------------------------------------------
       
   852 //
       
   853 void CCalenPreview::HidePreview() 
       
   854     {
       
   855     TRACE_ENTRY_POINT;
       
   856     if(iLayoutManager->UsePreview())
       
   857         {
       
   858         iController->SetPopUpShowDelay(0);
       
   859         iController->HidePopUp();
       
   860         }
       
   861     TRACE_EXIT_POINT;
       
   862     }
       
   863 
       
   864 // ---------------------------------------------------------------------------
       
   865 // ?classname::?member_function
       
   866 // ?implementation_description
       
   867 // (other items were commented in a header).
       
   868 // ---------------------------------------------------------------------------
       
   869 //
       
   870 void CCalenPreview::ShowPreview() 
       
   871     {
       
   872     TRACE_ENTRY_POINT;
       
   873     if(iLayoutManager->UsePreview())
       
   874         iController->ShowPopUp();
       
   875     TRACE_EXIT_POINT;
       
   876     }
       
   877 
       
   878 // ---------------------------------------------------------------------------
       
   879 // ?classname::?member_function
       
   880 // ?implementation_description
       
   881 // (other items were commented in a header).
       
   882 // ---------------------------------------------------------------------------
       
   883 //
       
   884 void CCalenPreview::SetPreviewContentL(const TTime& aDay)
       
   885     {
       
   886     TRACE_ENTRY_POINT;
       
   887     TInt labelIndex(0);
       
   888     TInt labelCount(CountComponentControls());
       
   889 
       
   890     iData->CreateEntriesL(aDay);
       
   891     if(iLayoutManager->UsePreview())
       
   892      	labelIndex = 1;	// title + plugins
       
   893   
       
   894     for(TInt i(0); i < iData->EntryCount() && labelIndex < labelCount; i++)
       
   895         {
       
   896         if( labelIndex == labelCount -1 && iData->NotShownEntries() )
       
   897             SetLabelContentL(iData->Entry(i), labelIndex, ETrue);
       
   898         else
       
   899             SetLabelContentL(iData->Entry(i), labelIndex, EFalse);
       
   900         }    
       
   901     TRACE_EXIT_POINT;
       
   902     }
       
   903 
       
   904 // ---------------------------------------------------------------------------
       
   905 // ?classname::?member_function
       
   906 // ?implementation_description
       
   907 // (other items were commented in a header).
       
   908 // ---------------------------------------------------------------------------
       
   909 //
       
   910 void CCalenPreview::SetLabelContentL(CCalenPreviewEntry* aEntry, 
       
   911                                      TInt& aLabelIndex, TBool aShortLine)
       
   912     {
       
   913      TRACE_ENTRY_POINT;
       
   914 
       
   915      TInt lines = aEntry->LineCount();
       
   916 
       
   917      CCalenPreviewLabel* label = NULL;
       
   918      
       
   919      for(TInt i = 0; i < lines; i++)
       
   920          {
       
   921          label = 
       
   922              static_cast<CCalenPreviewLabel*>(ComponentControl(aLabelIndex));
       
   923          label->SetTextL(aEntry->GetLine(i));
       
   924          aLabelIndex++;
       
   925          label->SetLabelObserver(aEntry);
       
   926          label->icolor = aEntry->iColor;
       
   927          aEntry->AddObservedLabelL(label);
       
   928          
       
   929          if(aEntry->EntryType() == CCalenPreviewEntry::ECalenPreviewEntryNormal)
       
   930              {
       
   931              if(i > 0 )
       
   932                  label->SetLabelType(CCalenPreviewLabel::ECalenPreviewMiddleRow);
       
   933              else
       
   934                  {
       
   935                  if(aShortLine)
       
   936                      {
       
   937                      label->SetLabelType(CCalenPreviewLabel::ECalenPreviewLastRow);
       
   938                      label->SetMoreIcon(iMoreIcon);
       
   939                      }
       
   940                  else
       
   941                      label->SetLabelType(CCalenPreviewLabel::ECalenPreviewFirstRow);
       
   942                  
       
   943                  if(iLayoutManager->UsePreview())
       
   944                      label->SetIcon(GetIcon(aEntry->EventType()));
       
   945                  }
       
   946              }
       
   947          else if(aEntry->EntryType() == CCalenPreviewEntry::ECalenPreviewEntryPlugin)
       
   948          	{
       
   949          	label->SetLabelType(CCalenPreviewLabel::ECalenPreviewPluginRow);
       
   950          	}
       
   951          else if(aEntry->EntryType() == CCalenPreviewEntry::ECalenPreviewEntryEmpty)
       
   952              {
       
   953 				if(i > 0)
       
   954 				{
       
   955 					if(iPluginControl)
       
   956 					{
       
   957 					label->SetLabelType(CCalenPreviewLabel::ECalenPreviewEmptyRow2WithPlugin);
       
   958 					}
       
   959 					else
       
   960 					{
       
   961 					label->SetLabelType(CCalenPreviewLabel::ECalenPreviewEmptyRow2);
       
   962 					}
       
   963 				}
       
   964 				     
       
   965 				else
       
   966 				{
       
   967 					if(iPluginControl)
       
   968 					{
       
   969 					label->SetLabelType(CCalenPreviewLabel::ECalenPreviewEmptyRowWithPlugin);	
       
   970 					}
       
   971 					else
       
   972 					{
       
   973 					label->SetLabelType(CCalenPreviewLabel::ECalenPreviewEmptyRow);	
       
   974 					}
       
   975 				}
       
   976              }
       
   977          }
       
   978      aEntry->SetEntryObserver(this);
       
   979      
       
   980      TRACE_EXIT_POINT;
       
   981     }
       
   982 
       
   983 // ---------------------------------------------------------------------------
       
   984 // ?classname::?member_function
       
   985 // ?implementation_description
       
   986 // (other items were commented in a header).
       
   987 // ---------------------------------------------------------------------------
       
   988 //
       
   989 CGulIcon* CCalenPreview::GetIcon( CCalEntry::TType aType )
       
   990     {
       
   991     TRACE_ENTRY_POINT;
       
   992     // fetch the icon from the icon array.
       
   993     CGulIcon* icon = iIcons[aType];
       
   994 
       
   995     TRACE_EXIT_POINT;
       
   996     return icon;
       
   997     }
       
   998     
       
   999 // ---------------------------------------------------------------------------
       
  1000 // CCalenPreview::CreateIconArrayL
       
  1001 // Creates the icon array
       
  1002 // (other items were commented in a header).
       
  1003 // ---------------------------------------------------------------------------
       
  1004 //
       
  1005 void CCalenPreview::CreateIconArrayL()
       
  1006     {
       
  1007     TRACE_ENTRY_POINT;
       
  1008     // Create the icons in the order with repect their corresponding 
       
  1009     // CCalEntry::TType
       
  1010         
       
  1011     iIcons.AppendL( iServices.GetIconL( MCalenServices::ECalenMeetingIcon ) );
       
  1012     iIcons.AppendL( iServices.GetIconL( MCalenServices::ECalenToDoIcon ) );
       
  1013 	iIcons.AppendL( iServices.GetIconL( MCalenServices::ECalenDaynoteIcon ) );
       
  1014     iIcons.AppendL( iServices.GetIconL( MCalenServices::ECalenDaynoteIcon ) );
       
  1015     iIcons.AppendL( iServices.GetIconL( MCalenServices::ECalenBirthdayIcon ) );
       
  1016    
       
  1017  
       
  1018     TRACE_EXIT_POINT;
       
  1019     }
       
  1020 
       
  1021 // ---------------------------------------------------------------------------
       
  1022 // ?classname::?member_function
       
  1023 // ?implementation_description
       
  1024 // (other items were commented in a header).
       
  1025 // ---------------------------------------------------------------------------
       
  1026 //
       
  1027 void CCalenPreview::UpdateTitleL()
       
  1028     {
       
  1029     TRACE_ENTRY_POINT;
       
  1030 
       
  1031 
       
  1032     if(iLayoutManager->UsePreview())
       
  1033         {
       
  1034         HBufC* dateFormat = StringLoader::LoadLC(R_QTN_DATE_SHORT_WITH_ZERO);
       
  1035         HBufC* date = HBufC::NewL(KNaviLabelSize);
       
  1036         CleanupStack::PushL(date);
       
  1037 
       
  1038         MCalenContext& context = iServices.Context();
       
  1039         TTime activeDay = context.FocusDateAndTimeL().TimeLocalL();
       
  1040         
       
  1041         HBufC* longDay = StringLoader::LoadLC( 
       
  1042             KDayNames[activeDay.DayNoInWeek()] );
       
  1043         
       
  1044         HBufC* shortDay = StringLoader::LoadLC( 
       
  1045             KShortDayNames[activeDay.DayNoInWeek()] );
       
  1046 
       
  1047         TPtr datePtr = date->Des();
       
  1048 
       
  1049         activeDay.FormatL(datePtr, *dateFormat);
       
  1050 
       
  1051         AknTextUtils::DisplayTextLanguageSpecificNumberConversion(datePtr);
       
  1052 
       
  1053         TBuf<1> space; 
       
  1054         space.Append(TChar(KSpecialSpace));
       
  1055 
       
  1056         HBufC* titleText = HBufC::NewL( longDay->Length() + 
       
  1057                                         date->Length() + 
       
  1058                                         1 );
       
  1059         CleanupStack::PushL(titleText);
       
  1060 
       
  1061         CFont::TMeasureTextInput::TFlags logicalOrder = 
       
  1062             static_cast<CFont::TMeasureTextInput::TFlags>(0);
       
  1063 
       
  1064         TInt longDayWidth = AknBidiTextUtils::MeasureTextBoundsWidth(
       
  1065             *iLayoutManager->TitleFont(),
       
  1066             longDay->Des(),
       
  1067             logicalOrder);
       
  1068         
       
  1069         TInt spaceWidth = AknBidiTextUtils::MeasureTextBoundsWidth(
       
  1070             *iLayoutManager->TitleFont(),
       
  1071             space,
       
  1072             logicalOrder);
       
  1073         TInt dateWidth = AknBidiTextUtils::MeasureTextBoundsWidth(
       
  1074             *iLayoutManager->TitleFont(),
       
  1075             date->Des(),
       
  1076             logicalOrder);
       
  1077 
       
  1078          TPtr textPtr = titleText->Des();
       
  1079 
       
  1080         if(longDayWidth + spaceWidth + dateWidth > iLayoutManager->TitleLineWidth())
       
  1081             {
       
  1082             textPtr.Append(shortDay->Des());
       
  1083             }
       
  1084         else
       
  1085             {
       
  1086             textPtr.Append(longDay->Des());
       
  1087             }
       
  1088        
       
  1089         textPtr.Append(space);
       
  1090         textPtr.Append(date->Des());
       
  1091 
       
  1092         AknBidiTextUtils::ConvertToVisualAndClipL(
       
  1093             textPtr, *iLayoutManager->TitleFont(), 
       
  1094             iLayoutManager->TitleLineWidth(),
       
  1095             iLayoutManager->TitleLineWidth());
       
  1096         iTitle->SetTextL(textPtr);
       
  1097         
       
  1098         
       
  1099         CleanupStack::PopAndDestroy(titleText);
       
  1100         CleanupStack::PopAndDestroy(shortDay);
       
  1101         CleanupStack::PopAndDestroy(longDay);
       
  1102         CleanupStack::PopAndDestroy(date);
       
  1103         CleanupStack::PopAndDestroy(dateFormat);
       
  1104         
       
  1105         Window().Invalidate();
       
  1106         }
       
  1107 
       
  1108     TRACE_EXIT_POINT;
       
  1109     }
       
  1110 
       
  1111 // ---------------------------------------------------------------------------
       
  1112 // ?classname::?member_function
       
  1113 // ?implementation_description
       
  1114 // (other items were commented in a header).
       
  1115 // ---------------------------------------------------------------------------
       
  1116 //
       
  1117 void CCalenPreview::SetTimerForNextExpiringEventL()
       
  1118     {
       
  1119     TRACE_ENTRY_POINT;
       
  1120 
       
  1121     iExpirationTimer->Cancel();
       
  1122 
       
  1123     if( !iLayoutManager->UsePreview() || 
       
  1124         !iData->InstanceCount() > 0 || 
       
  1125         !iData->Today())
       
  1126         {
       
  1127         TRACE_EXIT_POINT;
       
  1128         return;
       
  1129         }
       
  1130 
       
  1131     TTime now;  now.HomeTime();
       
  1132     const TTimeIntervalMinutes thirtyMinutes( 30 );
       
  1133     TTime midnight( 0 );
       
  1134     midnight += now.DaysFrom( midnight );
       
  1135     midnight += TTimeIntervalDays( 1 );
       
  1136 
       
  1137     /**
       
  1138      * Refresh is needed whenever an appointment passes its end 
       
  1139      * time:
       
  1140      * Loop through all EAppt items and find the nearest 
       
  1141      * refresh/expiration time.
       
  1142      **/
       
  1143     TTime expiryTime( midnight ); // initial value
       
  1144     for( TInt i(0), count(iData->InstanceCount()); i < count; i++ )
       
  1145         {
       
  1146         if( iData->Instance(i)->Entry().EntryTypeL() == CCalEntry::EAppt )
       
  1147             {
       
  1148             const TTime endTime( iData->Instance(i)->EndTimeL().TimeLocalL() );
       
  1149             TTime ongoingTime( iData->Instance(i)->StartTimeL().TimeLocalL() + thirtyMinutes );
       
  1150 
       
  1151             // using already expired timer would cause a nasty refresh loop
       
  1152             if( ongoingTime < now  )
       
  1153                 {
       
  1154                 ongoingTime = endTime;
       
  1155                 }
       
  1156             // select the nearest time
       
  1157             if(endTime > now)
       
  1158                 expiryTime = Min( expiryTime, Min( endTime, ongoingTime ) );
       
  1159             }
       
  1160         }
       
  1161     
       
  1162     // timer is set only for times between "now" and end of the day
       
  1163     TDateTime endDate = expiryTime.DateTime();
       
  1164     iExpirationTimer->At( expiryTime );
       
  1165     
       
  1166     TRACE_EXIT_POINT;
       
  1167     }
       
  1168 
       
  1169 // ---------------------------------------------------------------------------
       
  1170 // ?classname::?member_function
       
  1171 // ?implementation_description
       
  1172 // (other items were commented in a header).
       
  1173 // ---------------------------------------------------------------------------
       
  1174 //
       
  1175 TInt CCalenPreview::ExpiredCallBack(TAny* aPtr)
       
  1176     {
       
  1177     TRACE_ENTRY_POINT;
       
  1178     CCalenPreview* thisPtr = static_cast<CCalenPreview*>( aPtr );
       
  1179     PIM_TRAPD_HANDLE(thisPtr->InitComponentsL());
       
  1180     thisPtr->iController->ShowPopUp();
       
  1181     TRACE_EXIT_POINT;
       
  1182     return 0; // ignored
       
  1183     }
       
  1184 
       
  1185 // --------------------------------------------------------------------------
       
  1186 // CCalenPreview::BuildMonthCellL
       
  1187 // ?implementation_description
       
  1188 // (other items were commented in a header).
       
  1189 // --------------------------------------------------------------------------
       
  1190 //
       
  1191 void CCalenPreview::BuildMonthCellL(const TTime& aDay)
       
  1192     {
       
  1193     TRACE_ENTRY_POINT;
       
  1194     TTime preferredTime;
       
  1195     preferredTime.HomeTime();
       
  1196     TBool isToday( EFalse );
       
  1197     iData->SetTimedRangeL(preferredTime, KCalenMonthLimitMinutes);
       
  1198     if( CalenDateUtils::OnSameDay(aDay, preferredTime) )
       
  1199         { // today cell
       
  1200         isToday = ETrue;
       
  1201         preferredTime -= TTimeIntervalMinutes(KCalenMonthLimitMinutes); 
       
  1202         }
       
  1203     else
       
  1204         { // normal cell 
       
  1205         preferredTime = CalenDateUtils::BeginningOfDay(aDay);
       
  1206         }
       
  1207     // remove instances that won't fit...
       
  1208     iData->ProcessMonthInstancesL( preferredTime, isToday );
       
  1209     iData->SetToday(isToday);
       
  1210     TRACE_EXIT_POINT;
       
  1211     }
       
  1212 
       
  1213 
       
  1214 // --------------------------------------------------------------------------
       
  1215 // CCalenPreview::BuildWeekCellL
       
  1216 // ?implementation_description
       
  1217 // (other items were commented in a header).
       
  1218 // --------------------------------------------------------------------------
       
  1219 //
       
  1220 void CCalenPreview::BuildWeekCellL(const TTime& aDay)
       
  1221     {
       
  1222     TRACE_ENTRY_POINT;
       
  1223     TTime hourStart( aDay );
       
  1224     TTime hourEnd( hourStart + TTimeIntervalHours( 1 ) );
       
  1225     iData->ProcessWeekInstancesL( hourStart, hourEnd );
       
  1226     TRACE_EXIT_POINT;
       
  1227     }
       
  1228 
       
  1229 // --------------------------------------------------------------------------
       
  1230 // CCalenPreview::UsePreview
       
  1231 // ?implementation_description
       
  1232 // (other items were commented in a header).
       
  1233 // --------------------------------------------------------------------------
       
  1234 //
       
  1235 TBool CCalenPreview::UsePreview()
       
  1236     {
       
  1237     TRACE_ENTRY_POINT;
       
  1238     TRACE_EXIT_POINT;
       
  1239     return iLayoutManager->UsePreview();
       
  1240     }
       
  1241 
       
  1242 // --------------------------------------------------------------------------
       
  1243 // CCalenPreview::ReducePreview
       
  1244 // Reduces preview area from aRect
       
  1245 // (other items were commented in a header).
       
  1246 // --------------------------------------------------------------------------
       
  1247 //
       
  1248 TRect CCalenPreview::ReducePreview(TRect aRect)
       
  1249     {
       
  1250     TRACE_ENTRY_POINT;
       
  1251     TRACE_EXIT_POINT;
       
  1252     return iLayoutManager->ReducePreview(aRect);
       
  1253     }
       
  1254 
       
  1255 
       
  1256 
       
  1257 
       
  1258 //End of file