calendarui/views/inc/calendaycontainer.h
changeset 0 f979ecb2b13e
child 20 9c5b1510919f
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:  For Day view container of calendar application.
       
    15  *                The class derived from CCalenContainer.
       
    16  *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CALENDAYCONTAINER_H
       
    21 #define CALENDAYCONTAINER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <eiklbo.h>
       
    25 #include <caleninstanceid.h>            // TCalenInstanceId
       
    26 
       
    27 
       
    28 #include "calencontainer.h"
       
    29 #include "CalendarVariant.hrh"
       
    30 
       
    31 // CONSTANTS
       
    32 const TInt KIndexError = -1;
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CCalenDayListBoxModel;
       
    36 class CCalenDayListBox;
       
    37 class CCalenDayListBoxView;
       
    38 class CCalenDayView;
       
    39 class CCalInstance;
       
    40 class CAknsFrameBackgroundControlContext;
       
    41 class TCalenInstanceId;
       
    42 //  CLASS DEFINITIONS
       
    43 /**
       
    44  * CCalenDayContainer container control class for DayView.
       
    45  */
       
    46 NONSHARABLE_CLASS(  CCalenDayContainer ) : public CCalenContainer,
       
    47                                                    public MEikListBoxObserver
       
    48     {
       
    49 public: // Data
       
    50 
       
    51     NONSHARABLE_STRUCT( SItemInfo )
       
    52         {
       
    53         TTimeIntervalMinutes iStartTime;
       
    54         TCalenInstanceId iId;
       
    55         TBool iTimedNote;
       
    56         TInt iTopLine;
       
    57 
       
    58         // Fetched instance is temporarily stored to iTmpInstance 
       
    59         // This is destroyed after construction phase is over.
       
    60         CCalInstance* iTmpInstance;
       
    61         TUint32 iColor;
       
    62         };
       
    63 
       
    64 public:  // Constructors and destructor
       
    65     /**
       
    66      * C++ default constructor.
       
    67      */
       
    68     CCalenDayContainer( CCalenNativeView* aView,
       
    69                         TTime& aDate,
       
    70                         TInt& aHighlightedRowNumber,
       
    71                         TInt& aFirstEntryOnScreenIndex,
       
    72                         MCalenServices& aServices );
       
    73     /**
       
    74      * Destructor.
       
    75      */
       
    76     virtual ~CCalenDayContainer();
       
    77 
       
    78 public: // From CalenContainer
       
    79     /**
       
    80      * Create icon index
       
    81      */
       
    82     void CreateIconIndicesL( RArray<MCalenServices::TCalenIcons>& aIndexArray );
       
    83 	
       
    84     /**
       
    85      * Handles list box events.
       
    86      * @param aListBox   The originating list box.
       
    87      * @param aEventType A code for the event.
       
    88      */
       
    89     void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
       
    90     
       
    91 public:     // New function
       
    92     /**
       
    93      * Refresh Day view data and draws
       
    94      */
       
    95     void UpdateContainerL();
       
    96 
       
    97     /**
       
    98      * Update time format (12/24)
       
    99      */
       
   100     void UpdateTimeFormat();
       
   101 
       
   102     /**
       
   103      * @return ETrue, if day view doesn't have any instances to show.
       
   104      */ 
       
   105     TBool IsEmptyView() const;
       
   106     
       
   107     /**
       
   108      * Get the available preview pane rect for this container
       
   109      */
       
   110     TRect PreviewRectL();
       
   111     
       
   112     //void SetActiveContextFromHighlightL();
       
   113 
       
   114 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION    
       
   115     TBool IsMidnightVisualization() const;
       
   116 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION
       
   117     
       
   118     /**
       
   119      * Get instances for day. List of instances is processed during construction 
       
   120      * of list box data and destroyed once it's done.
       
   121      * Step 1 of construction of listbox data.
       
   122      */
       
   123     void GetInstanceListL();
       
   124     
       
   125     /**
       
   126      * Setup layout table.
       
   127      * Step 2 of construction of listbox data
       
   128      */
       
   129     void CreateSlotTableL();
       
   130     
       
   131     /**
       
   132      * Completes population.
       
   133      * Step 3 of construction of listbox data.
       
   134      */
       
   135     void CompletePopulationL();
       
   136 
       
   137     /**
       
   138      * Get the available info bar rect for this container
       
   139      */
       
   140     TRect InfoBarRectL( TBool aToolbarAvailable );    
       
   141 
       
   142     /**
       
   143      * Sets the context based on the highlighted item.
       
   144      */
       
   145     void SetContextFromHighlightL();
       
   146 
       
   147     /**
       
   148      * Sets the highlighted item based on the context.
       
   149      */
       
   150     void SetHighlightFromContextL();
       
   151 
       
   152     /**
       
   153      * Delete note command notification handler
       
   154      */
       
   155     void NotifyDeleteItemL();
       
   156     
       
   157     /**
       
   158      * Returns ETrue if event has geo coordinates else EFalse
       
   159      */
       
   160     TBool IsEventHasMapLocationL();
       
   161 	
       
   162 	/**
       
   163      * Returns ETrue if event has location text else EFalse
       
   164      */
       
   165     TBool IsEventHasNoLocationTextL();
       
   166   
       
   167     /**
       
   168      * This method is called after pointer event in Navi
       
   169      * decoration object.
       
   170      * @param aDirection right or left
       
   171      */
       
   172     void HandleNaviDecoratorEventL(TInt aEventID);
       
   173     
       
   174     /**
       
   175      * Handles long tap events
       
   176      */
       
   177     void HandleLongTapEventL( const TPoint& aPenEventLocation, 
       
   178                               const TPoint& aPenEventScreenLocation );
       
   179 
       
   180     /**
       
   181      * Check whether entry exists or not
       
   182      */
       
   183     TBool IsValidEntryL();
       
   184 private:    // New function
       
   185 
       
   186 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION    
       
   187     void GetMidnightVisualizationL();
       
   188 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION
       
   189     /** 
       
   190      * Destroy all CCalInstances. This is called during construction of view data
       
   191      * once we have constructed actual listbox data.
       
   192      */
       
   193     void DestroyInstanceListL();
       
   194 
       
   195     /**
       
   196      * Set Listbox data to ListBox
       
   197      * Part of step 3 of construction of listbox data
       
   198      */
       
   199     void CreateListBoxDataL();
       
   200 
       
   201     /**
       
   202      * Called in the final stage of population. If we've just deleted an entry,
       
   203      * update which row is highlighted
       
   204      */
       
   205     void UpdateHighlightedRowIfDeletedL();
       
   206 
       
   207     // FIXME document these
       
   208     //void SetActiveContextForFreshDayL(TTime& aDay);
       
   209     //void SetActiveContextFromEntryL(const CCalEntry& aEntry,const TCalTime& aInstanceTime);
       
   210     
       
   211     /**
       
   212      * Handles pressing left or right.
       
   213      */
       
   214     void HandleHorizontalScrollL( TTimeIntervalDays aDirection );
       
   215 
       
   216     /**
       
   217      * Handles pressing up or down.
       
   218      */
       
   219     void HandleVerticalScrollL( TInt aNewCursor );
       
   220 
       
   221     /**
       
   222      * Sets highlight item in ListBox
       
   223      * @param aIndex Index of ListBox
       
   224      * @param aTopItem Index of top item
       
   225      */
       
   226     void SetHighlightAndVisibleItem(TInt aIndex, TInt aTopItem = KIndexError);
       
   227 
       
   228     TInt FindItemIndex(const TCalenInstanceId& aId) const;
       
   229 
       
   230     TInt FindItemIndexForRow(TInt aListIndex) const;
       
   231     
       
   232 public:
       
   233     SItemInfo& FindItem(TInt aListIndex) const;
       
   234     
       
   235     MCalenServices& Services();
       
   236     
       
   237 private:
       
   238 
       
   239     
       
   240     /**
       
   241      * Searches list item that is nearest to aTime
       
   242      * @param aTime 
       
   243      * @return if there is such item, index in ListBox is returned
       
   244      *         othwerise returns KIndexError.
       
   245      */
       
   246     TInt SearchNearestItem(TTimeIntervalMinutes aTime) const;
       
   247 
       
   248     void SetVisibleLines(TInt aHighlightFirstLine,
       
   249                          TInt aPreferredTopLine);
       
   250 
       
   251     
       
   252 
       
   253     CCalenDayListBoxView* View();
       
   254 
       
   255     CCalenDayView& DayView() const;
       
   256     public:
       
   257 
       
   258     enum TDayLayoutVariant
       
   259         {
       
   260         ENoLayoutVariantSet = 0,
       
   261         EListScrollCaleDayPane,
       
   262         EPopupToolbarWindowCp02,
       
   263         EScrollPaneCp09,
       
   264         EBgCalePane,
       
   265         EListCalePane,
       
   266         EListScrollCaleDayPaneT1
       
   267         };
       
   268     TInt LayoutVariantIndex(TDayLayoutVariant aLayout) const;
       
   269     
       
   270     /**
       
   271      * From CCalenContainer.
       
   272      * (no implementation)
       
   273      * This methods is called after calendar settings have changed.
       
   274      */
       
   275     void UpdateSize();
       
   276 
       
   277 private:    // From CCoeControl
       
   278     /**
       
   279      * From CCoeControl Resizes child controls
       
   280      */
       
   281     void SizeChanged();
       
   282     void FocusChanged( TDrawNow aDrawNow );
       
   283     void HandleResourceChange(TInt aType);
       
   284 
       
   285     /**
       
   286      * From CCoeControl Gets child control count
       
   287      * @return Child control count
       
   288      */
       
   289     TInt CountComponentControls() const;
       
   290     /**
       
   291      * From CCoeControl Gets child control pointer
       
   292      * @param aIndex Child control index
       
   293      * @return child control pointer
       
   294      */
       
   295     CCoeControl* ComponentControl(TInt aIndex) const;
       
   296     /**
       
   297      * From CCoeControl Process key event
       
   298      * @param aKeyEvent The key event.
       
   299      * @param aType EEventKey | EEventKeyUp | EEventKeyDown.
       
   300      * @return EKeyWasNotConsumed: Key event was not consumed.
       
   301      */
       
   302     TKeyResponse OfferKeyEventL(
       
   303         const TKeyEvent& aKeyEvent, TEventCode aType);
       
   304 
       
   305     /**
       
   306      * From CCoeControl Handle pointer event
       
   307      * @param aPointerEvent Event to be handled.
       
   308      */
       
   309     void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   310 
       
   311     /**
       
   312      * From CCoeControl Drawing day name
       
   313      * @param aRect Clipping rectangle
       
   314      */
       
   315     void Draw(const TRect& aRect) const;
       
   316 
       
   317     /**
       
   318      * Pass skin information if needed
       
   319      */
       
   320     TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
       
   321 
       
   322     /**
       
   323      * From CCoeControl Gets help context
       
   324      * @param aContext Help context
       
   325      */
       
   326     void GetHelpContext(TCoeHelpContext& aContext) const;
       
   327 
       
   328 private:    // From CCalenContainer
       
   329     /**
       
   330      * From CCalenContainer Third phase constructor.
       
   331      * This function was called CCalenView::ConstructL().
       
   332      */
       
   333     void ConstructImplL();
       
   334 
       
   335 
       
   336     
       
   337     /**
       
   338      * From CCalenContainer Date cahnge operation notification handler.
       
   339      * (i.e. GotoDate).
       
   340      */
       
   341     void NotifyChangeDateL();
       
   342 
       
   343     /**
       
   344      * Notify that item is added or changed.
       
   345      * @param aEntry is the entry added or modified.
       
   346      * @param aInstanceTime is time of the modified instance.
       
   347      */ 
       
   348     //void NotifyEntryChangeL(const CCalEntry& aEntry,const TCalTime& aInstanceTime);
       
   349 
       
   350     
       
   351 private: // New Functions
       
   352     /** 
       
   353      * Updates icons after e.g. skin change
       
   354      */ 
       
   355     void UpdateIconsL();
       
   356     
       
   357 private:    // From MActiveStep
       
   358     /**
       
   359      * From MActiveStep Updates DayView data
       
   360      * @return 0 is DoStepL() exit code
       
   361      */
       
   362     //TInt DoStepL();
       
   363 
       
   364 private:    // Data
       
   365     CCalenDayListBox* iListBox;
       
   366     CCalenDayListBoxModel* iListBoxModel;
       
   367 
       
   368     RPointerArray<CCalInstance> iInstanceList;
       
   369     CArrayFixFlat<SItemInfo>* iLayoutTable;
       
   370 
       
   371     /*enum TStepPopulate
       
   372         {
       
   373         ENothingDone,
       
   374         EPopulationDone,
       
   375         ESlotTableDone,
       
   376         EDone
       
   377         };
       
   378     TStepPopulate iStepsCompleted;*/
       
   379     TInt iDeletedIndex;
       
   380     TBool iMidnight;
       
   381     CAknsFrameBackgroundControlContext* iBackgroundSkinContext;
       
   382 
       
   383     TBool iDateWasNull;
       
   384 // View specific data references
       
   385     TTime& iDate;                   // Current day
       
   386     TInt& iHighlightedRowNumber;
       
   387     TInt& iFirstEntryOnScreenIndex;
       
   388     };
       
   389 
       
   390 #endif // CALENDAYCONTAINER_H
       
   391 
       
   392 // End of File