calendarui/views/inc/calencontainer.h
changeset 0 f979ecb2b13e
child 12 38571fd2a704
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:  Container base class of Calendar application.
       
    15  *                This class is the derivation origin of Calendar container.
       
    16  *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CALENCONTAINER_H
       
    21 #define CALENCONTAINER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <babitflags.h>
       
    25 #include <coecntrl.h>
       
    26 #include <coemain.h>
       
    27 #include <caltime.h>
       
    28 
       
    29 #include <aknlongtapdetector.h>
       
    30 #include <AknNaviDecoratorObserver.h>
       
    31 #include <calennavilabel.h>
       
    32 
       
    33 #include <calenservices.h>
       
    34 #include "CalendarVariant.hrh"
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class CCalInstance;
       
    38 class CCalEntry;
       
    39 class CCalenNativeView;
       
    40 class CAknIconArray;
       
    41 class CAknsBasicBackgroundControlContext;
       
    42 class CAknsFrameBackgroundControlContext;
       
    43 class MCalenViewUiExtension;
       
    44 class CEikLabel;
       
    45 class MCalenContext;
       
    46 class CCalenContainerLayoutManager;
       
    47 
       
    48 
       
    49 class MAknNaviDecoratorObserver;
       
    50 class MCCalenNaviLabelObserver;
       
    51 
       
    52 
       
    53 class CCalenPreview;
       
    54 
       
    55 //  CLASS DEFINITIONS
       
    56 
       
    57 /**
       
    58  * Container base class of calendar application.
       
    59  */
       
    60 NONSHARABLE_CLASS( CCalenContainer ) : public CCoeControl,
       
    61                                        public MAknNaviDecoratorObserver,
       
    62                                        public MCCalenNaviLabelObserver,
       
    63                                        public MAknLongTapDetectorCallBack
       
    64 
       
    65     {
       
    66 public:  // Constructors and destructor
       
    67     /**
       
    68      * C++ constructor.
       
    69      */
       
    70     CCalenContainer( CCalenNativeView* aView, MCalenServices& aServices );
       
    71 
       
    72     /**
       
    73      * By default Symbian OS constructor is private.
       
    74      */
       
    75     void ConstructL();
       
    76 
       
    77     /**
       
    78      * Destructor.
       
    79      */
       
    80     virtual ~CCalenContainer();
       
    81 
       
    82 public:     // New function
       
    83     /**
       
    84      * Retrieves the date from the context. If the context is a todo in the past,
       
    85      * today is returned.
       
    86      */
       
    87     static TTime DateFromContextL( const MCalenContext& aContext );
       
    88 
       
    89     /**
       
    90      * Ignore Agenda server notifier.
       
    91      * iIgnoreDocChange is setted ETrue this function.
       
    92      * Then, iIgnoreDocChange is setted EFalse by last code of DoStepL()
       
    93      */
       
    94     void SetIgnoreDocuChange();
       
    95 
       
    96     
       
    97 
       
    98     /**
       
    99      * Called when an item is changed.
       
   100      * @param aId It is changed item's ID
       
   101      */
       
   102     //void DoItemChangedL(const CCalEntry& aEntry,const TCalTime& aInstanceTime,TBool aForceRefresh);
       
   103 
       
   104     /**
       
   105      * Third phase constructor.
       
   106      * Called from CCalendarView::ConstructL().
       
   107      */
       
   108     virtual void ConstructImplL() = 0;
       
   109 
       
   110     /**
       
   111      * Notify that Active date is changed. Each contianer will redraw.
       
   112      */
       
   113     virtual void NotifyChangeDateL();
       
   114 
       
   115    
       
   116     /**
       
   117      * Get the available info bar rect for this container
       
   118      * Default implementation returns empty rect
       
   119      */
       
   120     virtual TRect InfoBarRectL( TBool aToolbarAvailable );
       
   121     
       
   122     /**
       
   123      * Get the available preview pane rect for this container
       
   124      */
       
   125     virtual TRect PreviewRectL();
       
   126     
       
   127     /**
       
   128      * Get the view for this container
       
   129      */
       
   130     CCalenNativeView* View() { return iView; }
       
   131     
       
   132     TBool UseToolbar() const;
       
   133     TBool UseInfobar() const;
       
   134     TBool UsePreview() const;
       
   135 
       
   136 
       
   137     // From MAknLongTapDetectorCallBack
       
   138     virtual void HandleLongTapEventL( const TPoint& aPenEventLocation, 
       
   139                                       const TPoint& aPenEventScreenLocation ) = 0;
       
   140 
       
   141 
       
   142     /**
       
   143      * Remove from Control stack and Make in-visible
       
   144      * @param aMakeInvisible if ETrue is set, container becomes invisible
       
   145      */
       
   146     void RemoveFromStackAndMakeInvisible(TBool aMakeInvisible = ETrue);
       
   147 
       
   148     /**
       
   149      * Add to Control stack and Make visible
       
   150      */
       
   151     void AddToStackAndMakeVisibleL();
       
   152 
       
   153     /**
       
   154      * Is this control exist on stack?
       
   155      * @return If value is ETrue, this control is exist on stack
       
   156      */
       
   157     TBool IsOnStack();
       
   158 
       
   159     /**
       
   160      * This methods is called after calendar settings have changed.
       
   161      * See day, week and month container for implementation.
       
   162      */
       
   163     virtual void UpdateSize() = 0;
       
   164 
       
   165     /**
       
   166     * Creates icon array according to icon index array passed in
       
   167     */
       
   168     CAknIconArray* CreateIconsL( const RArray<MCalenServices::TCalenIcons>& aIndexArray );
       
   169     
       
   170     /**
       
   171      * Creates icon index array
       
   172      */
       
   173     virtual void CreateIconIndicesL( RArray<MCalenServices::TCalenIcons>& aIndexArray) = 0;
       
   174     
       
   175     /**
       
   176      * Get icon index in the icons array
       
   177      */
       
   178     TInt IconIndex( MCalenServices::TCalenIcons aType ) const;
       
   179 
       
   180     /**
       
   181      * Get icon index according to entry type
       
   182      * aAllDayEvent - allday will havew seprate icon,
       
   183      * by defalut value is EFalse if not passed
       
   184      * 
       
   185      */
       
   186     TInt IconIndexFromEntryL( CCalEntry& aEntry, TBool aAllDayEvent = EFalse ) const;
       
   187     
       
   188     
       
   189 
       
   190     /**
       
   191      * Determines if aEntry requires (P)riority, (A)larm, (R)ecurrence or (E)xception icons.
       
   192      * If so, it returns aDes, containing those icons indexes, as created by CalenIcon.
       
   193      * @param aEntry: A Calendar entry
       
   194      * @param aIconFormatDes: i.e. " \t%d" for ToDo view, "%d\t" for Day view
       
   195      * @param aTargetDes: A descriptor, holding icons indexes. Untouched if no Priority, Alarm,
       
   196      *                    Recurrence or Exception icons needed.
       
   197      * @param aPushSingleIconToRight: When ETrue, (aIconFormatDes - "%d") is appended to
       
   198      *          aTargetDes, when there is only one icon to display (i.e. alarm)
       
   199      *
       
   200      *  example:    init  value of aIconFormatDes = "%d\t" (Day view)
       
   201      *              init  value of aTargetDes: "3\t\t\t\ToDoWithAlarm\t"     
       
   202      *  example:    final value of aTargetDes: "3\t\t\t\ToDoWithAlarm\t\t4\t"
       
   203      *                                          (aPushSingleIconToRight = ETrue)
       
   204      *  example:    final value of aTargetDes: "3\t\t\t\ToDoWithAlarm\t4\t"
       
   205      *                                          (aPushSingleIconToRight = EFalse)
       
   206      *
       
   207      * @param aRevertOrder: When ETrue, A,R,P/E appended to aTargetDes.
       
   208      *                      When EFalse, P/E,R,A appended to aTargetDes.
       
   209      *
       
   210      * @leave with KErrArgument if aIconFormatDes does not have "%d" in it
       
   211      * @leave with KErrArgument if aIconFormatDes length is greater than 50
       
   212      * @leave with KErrBadDescriptor if there is not enough free space in aTargetDes
       
   213      *             to hold 2 icon strings with aIconFormatDes
       
   214      */
       
   215     void InsertAdditionalIconsL( const CCalEntry& aEntry,
       
   216                                          const TDesC& aIconFormatDes,
       
   217                                          TPtr& aTargetDes,
       
   218                                          TBool aPushSingleIconToRight = ETrue,
       
   219                                          TBool aRevertOrder = EFalse ) const;
       
   220                          
       
   221      /**
       
   222      * Returns the reduced size of the main pane if the
       
   223      * preview pane is displayed.
       
   224      */                                     
       
   225     TRect ReducePreview(TRect aRect) const;
       
   226 
       
   227     // Methods for view ui extensions
       
   228     /**
       
   229      * When focus has changed, UI container should call
       
   230      * this method. 
       
   231      */ 
       
   232     void UpdateStatusPaneAndExtensionsL();
       
   233     
       
   234 	/*
       
   235 	* Clean instances
       
   236 	*/
       
   237     virtual void CleanupInstances(){ };
       
   238     
       
   239     /**
       
   240      * Hide/Unhide "today" toolbar item based on the focused day 
       
   241      */
       
   242     void UpdateTodayToolbarItemL();
       
   243     
       
   244 private: // New functions
       
   245     /**
       
   246      * Return number of icons needed to be displayed
       
   247      * @return number of icons (between 0 and 3)
       
   248      */    
       
   249     TInt NumberOfIcons( const TBool aException,
       
   250                                const TBool aRepeat,
       
   251                                const TBool aAlarm, 
       
   252                                const TBool aHasPriority ) const;
       
   253     /**
       
   254      * Check if the entry has priority (only ToDos)
       
   255      * @param aEntry : A Calendar Entry
       
   256      * @param aPriHigh : Set aPriHigh ETrue, if aEntry is high priority ToDo
       
   257      * @param aPriLow : Set aPriLow ETrue, if aEntry is low priority ToDo
       
   258      * @return ETrue if high or low priority
       
   259      * @return EFalse otherwise
       
   260      */    
       
   261     TBool NeedsPriorityIconL( const CCalEntry& aEntry,
       
   262                                      TBool& aPriHigh,
       
   263                                      TBool& aPriLow ) const;
       
   264                                      
       
   265 protected:  // New function
       
   266 
       
   267 
       
   268     /**
       
   269      * Long tap animation is handled by calling this method
       
   270      */
       
   271     void NotifyLongTapDetectorL(const TPointerEvent& aPointerEvent);
       
   272 
       
   273 
       
   274 protected:  // Functions from base classes
       
   275     /**
       
   276      * From CCoeControl Handle key event
       
   277      */
       
   278     TKeyResponse OfferKeyEventL(
       
   279         const TKeyEvent& aKeyEvent, TEventCode aType);
       
   280 
       
   281     /**
       
   282      * Called when control size is changed 
       
   283      */
       
   284     void SizeChanged(const TRect& aParent);    
       
   285 
       
   286 
       
   287     // From MAknNaviDecoratorObserver
       
   288     virtual void HandleNaviDecoratorEventL( TInt aEventID ) = 0;
       
   289     // From MCCalenNaviLabelObserver
       
   290     void HandleNaviLabelEventL( TInt aEventID );
       
   291 
       
   292 
       
   293 protected:    // CCoeControl
       
   294     /**
       
   295      * Handler of changing focus
       
   296      * @param aDrawNow ENoDrawNow | EDrawNow
       
   297      */
       
   298     void FocusChanged(TDrawNow aDrawNow);
       
   299 
       
   300 public:    // CCoeControl
       
   301     /**
       
   302      * Handles resource changes.
       
   303      * @param aType Resource change type.
       
   304      **/
       
   305     virtual void HandleResourceChange(TInt aType);
       
   306     
       
   307     /**
       
   308      * Handles command to stop the alarm ,in case of autosnooze for MSK case.
       
   309      **/
       
   310     virtual void HandleStopCommandL(){};
       
   311 
       
   312 protected:  // Data
       
   313     CCalenNativeView* iView;
       
   314 
       
   315     // main area background skin for all views
       
   316     CAknsBasicBackgroundControlContext* iBgContext;
       
   317     // week and month view heading pane skin
       
   318     CAknsFrameBackgroundControlContext* iHeadingBgContext;
       
   319     // week and month view side pane skin
       
   320     CAknsFrameBackgroundControlContext* iSideBgContext;
       
   321 
       
   322     // flag for touch ui long tap functionality
       
   323     TBool    iFirstTap;
       
   324     CAknLongTapDetector* iLongTapDetector; 
       
   325 
       
   326 
       
   327 
       
   328 protected:
       
   329     // Control to show UI extension data. May be either a preview pane or an info bar, or NULL
       
   330     CCoeControl* iUiExtension;
       
   331     
       
   332     MCalenServices& iServices;
       
   333     RArray<MCalenServices::TCalenIcons> iIconIndices;
       
   334     CCalenContainerLayoutManager* iLayoutManager;
       
   335     };
       
   336 
       
   337 #endif // CALENCONTAINER_H
       
   338 
       
   339 
       
   340 // End of File