meetingrequest/mrgui/inc/cesmrlistcomponent.h
branchRCL_3
changeset 12 4ce476e64c59
parent 11 0396474f30f5
child 13 8592a65ad3fb
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
     1 /*
       
     2 * Copyright (c) 2007-2009 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:  ESMR Custom list component
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CESMRLISTCOMPONENT_H
       
    19 #define CESMRLISTCOMPONENT_H
       
    20 
       
    21 #include <coecntrl.h>
       
    22 #include <eiksbobs.h>
       
    23 #include <eikscrlb.h>
       
    24 #include <aknphysicsobserveriface.h> // MAknPhysicsObserver
       
    25 
       
    26 #include "mesmrlistobserver.h"
       
    27 
       
    28 class CESMRField;
       
    29 class CESMRLayoutManager;
       
    30 class MESMRFieldStorage;
       
    31 class MESMRCalEntry;
       
    32 class CMRListPane;
       
    33 class CAknPhysics;
       
    34 
       
    35 /**
       
    36  * CESMRListComponent is custom list for Meeting Request edtior and viewer.
       
    37  * List contains a List pane of CESMRField items that are stored in CESMRFieldStorage
       
    38  * class.
       
    39  *
       
    40  * @see CESMRField
       
    41  * @lib esmrgui.lib
       
    42  */
       
    43 NONSHARABLE_CLASS( CESMRListComponent ):
       
    44     public CCoeControl,
       
    45     public MESMRListObserver,
       
    46     public MEikScrollBarObserver,
       
    47     public MAknPhysicsObserver
       
    48     {
       
    49 public:
       
    50     /**
       
    51      * Two-phased constructor.
       
    52      *
       
    53      * @param aParent Parent control for this list component
       
    54      * @param aStorage Storage contains all the list items.
       
    55      * @return Pointer to created and initialized esmr list component object.
       
    56      */
       
    57      static CESMRListComponent* NewL( 
       
    58                  const CCoeControl* aParent, 
       
    59                  MESMRFieldStorage* aStorage, 
       
    60                  CESMRLayoutManager* aLayout );
       
    61 
       
    62     /**
       
    63      * Destructor.
       
    64      */
       
    65     ~CESMRListComponent();
       
    66 
       
    67     /**
       
    68      * InternalizeL is used to obtain the data from current CCalEntry.
       
    69      * CCalEntry is wrapped inside MESMRCalEntry object. This call is
       
    70      * propagated to all list items in the list.
       
    71      *
       
    72      * @param aEntry Current entry
       
    73      * @see MESMRCalEntry
       
    74      */
       
    75     void InternalizeL( MESMRCalEntry& aEntry );
       
    76 
       
    77     /**
       
    78      * ExternalizeL is used to store the list item data into current
       
    79      * CCalEntry. CCalEntry is wrapped inside the MESMRCalEntry object.
       
    80      *
       
    81      * @param aEntry Current entry.
       
    82      * @param aForceValidation ETrue if force validation should be used
       
    83      * @see MESMRCalEntry
       
    84      */
       
    85     void ExternalizeL( MESMRCalEntry& aEntry, TBool aForceValidation = EFalse );
       
    86 
       
    87     /**
       
    88      * Return MESMRListObserver interface. Interface allows the caller
       
    89      * to add, remove field and update field size.
       
    90      */
       
    91      MESMRListObserver& ListObserver();
       
    92 
       
    93     /**
       
    94      * Return focused list item.
       
    95      * @return Focused list item or NULL if no focused item
       
    96      */
       
    97      CESMRField* FocusedItem() const;
       
    98 
       
    99     /**
       
   100      * Initializes all fields. Needed when theme changes
       
   101      */
       
   102     void InitializeL();
       
   103 
       
   104     /**
       
   105      * Changes every fields font
       
   106      */
       
   107     void HandleFontChange();
       
   108 
       
   109     void DisableSizeChange(TBool aDisable );
       
   110 
       
   111 public: // From MEikScrollBarObserver
       
   112     void HandleScrollEventL( CEikScrollBar* aScrollBar,
       
   113                              TEikScrollEvent aEventType );
       
   114 
       
   115 public: // from MAknPhysicsObserver
       
   116 
       
   117    /**
       
   118     * @see MAknPhysicsObserver::ViewPositionChanged
       
   119     */
       
   120    virtual void ViewPositionChanged( const TPoint& aNewPosition, TBool aDrawNow, TUint aFlags );
       
   121 
       
   122    /**
       
   123     * @see MAknPhysicsObserver::PhysicEmulationEnded
       
   124     */
       
   125    virtual void PhysicEmulationEnded();
       
   126 
       
   127    /**
       
   128     * @see MAknPhysicsObserver::ViewPosition
       
   129     */
       
   130    virtual TPoint ViewPosition() const;
       
   131 
       
   132 
       
   133 protected: // From MESMRListObserver
       
   134     void ControlSizeChanged( CESMRField* aCtrl );
       
   135     void InsertControl( TESMREntryFieldId aField );
       
   136     void RemoveControl( TESMREntryFieldId aField );
       
   137     TBool IsControlVisible( TESMREntryFieldId aField );
       
   138     void SetControlFocusedL( TESMREntryFieldId aField );
       
   139     // SCROLLING_MOD: These two methods are for CESMRRichTextViewer to 
       
   140     //be able to control view area
       
   141     void MoveListAreaDownL( TInt aAmount );
       
   142     void MoveListAreaUpL( TInt aAmount );
       
   143     TInt ListHeight();
       
   144     TBool IsFieldBottomVisible();
       
   145 
       
   146 public: // From CCoeControl
       
   147     TInt CountComponentControls() const;
       
   148     CCoeControl* ComponentControl( TInt aInd ) const;
       
   149     void SizeChanged();
       
   150     TKeyResponse OfferKeyEventL( const TKeyEvent &aKeyEvent,
       
   151                                  TEventCode aType );
       
   152     virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   153 	void MakeVisible(TBool aVisible);
       
   154 
       
   155 
       
   156 private:
       
   157     /**
       
   158      * Default c++ constuctor
       
   159      */
       
   160     CESMRListComponent( MESMRFieldStorage* aFactory,
       
   161                         CESMRLayoutManager* aLayout );
       
   162     /**
       
   163      * Second phase constructor
       
   164      */
       
   165     void ConstructL( const CCoeControl* aParent );
       
   166 
       
   167 private: // Helper methods
       
   168 
       
   169     /**
       
   170      * Scrolls the specific field to be fully visible
       
   171      *
       
   172      * @param aInd Index of the field that needs to be fully visible
       
   173      * @param aSizeChanged ETrue if the field size has been changed
       
   174      */
       
   175     void ScrollItemVisible( TInt aInd/*, TBool aSizeChanged*/ );
       
   176 
       
   177     /**
       
   178      * Scrolls items in the list up.
       
   179      *
       
   180      * @param aPx Amount of pixels that items are moved up
       
   181      */
       
   182     void ScrollItemsUp( TInt aPx );
       
   183 
       
   184     /**
       
   185      * Scrolls items in the list down.
       
   186      *
       
   187      * @param aPx Amount of pixels that items are moved down
       
   188      */
       
   189     void ScrollItemsDown( TInt aPx );
       
   190 
       
   191     /**
       
   192      * Updates scroll bar
       
   193      */
       
   194     void UpdateScrollBar();
       
   195 
       
   196     /**
       
   197      * Sets physics engine parameters
       
   198      */
       
   199     void UpdatePhysicsL();
       
   200     
       
   201 private:
       
   202     /// Own: scrollbar
       
   203     CAknDoubleSpanScrollBar* iScroll;
       
   204     /// Ref: scrollbar model
       
   205     TAknDoubleSpanScrollBarModel iScrollModel;
       
   206     /// Own: Storage for list items.
       
   207     MESMRFieldStorage* iFactory;
       
   208     /// Own: List item container
       
   209     CMRListPane* iContainer;
       
   210     /// Ref: Pointer to Layout data for list component
       
   211     CESMRLayoutManager* iLayout;
       
   212     // Own: Boolean for disabling SizeChanged handling
       
   213     TBool iDisableSizeChanged;
       
   214     // previous scroll bar thumb position
       
   215     TInt iPrevThumbPos;
       
   216 
       
   217     CAknPhysics* iPhysics;
       
   218     TBool iIsDragging;
       
   219     TBool iIsScrolling;
       
   220     TPoint iPreviousPosition;
       
   221     TPoint iOriginalPosition;
       
   222     TTime iStartTime;
       
   223     TInt iCurrentScrollSpan;
       
   224     };
       
   225 #endif //CESMRLISTCOMPONENT_H