meetingrequest/mrgui/mrfieldbuildercommon/inc/cesmrfield.h
changeset 0 8466d47a6819
child 16 4ce476e64c59
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     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 Field item for CESMRListComponent
       
    15 *
       
    16 */
       
    17 #ifndef CESMRFIELD_H
       
    18 #define CESMRFIELD_H
       
    19 
       
    20 //<cmail>
       
    21 #include "esmrdef.h"
       
    22 #include "esmrcommands.h"
       
    23 //</cmail>
       
    24 
       
    25 #include "cesmrlayoutmgr.h"
       
    26 #include "mesmrcalentry.h"
       
    27 #include "mesmrtitlepaneobserver.h"
       
    28 #include "mesmrfieldeventobserver.h"
       
    29 #include "mesmrfieldeventnotifier.h"
       
    30 
       
    31 #include <coecntrl.h>
       
    32 #include <esmrgui.mbg>
       
    33 
       
    34 class MESMRListObserver;
       
    35 class MESMRCalEntry;
       
    36 class CESMRBorderLayer;
       
    37 class CESMRLayoutManager;
       
    38 class CMRBackground;
       
    39 
       
    40 // Enumeration for border type
       
    41 enum TESMRFieldFocusType
       
    42     {
       
    43     EESMRNoFocus = 0,
       
    44     EESMRBorderFocus,
       
    45     EESMRHighlightFocus
       
    46     };
       
    47 
       
    48 /**
       
    49  *  CESMRField defines a list item for CESMRListComponent.
       
    50  *  This is the base class for all fields.
       
    51  *
       
    52  *  @lib esmrgui.lib
       
    53  */
       
    54 class CESMRField : public CCoeControl,
       
    55                    public MESMRFieldEventObserver,
       
    56                    public MESMRFieldEventNotifier
       
    57     {
       
    58 public:
       
    59     /**
       
    60      * Destructor.
       
    61      */
       
    62     IMPORT_C virtual ~CESMRField();
       
    63 
       
    64     /**
       
    65      * Construct field with the given component. Given component
       
    66      * will have outline focus when focused.
       
    67      *
       
    68      * @param aControl Field control, ownership transferred
       
    69      */
       
    70     IMPORT_C void ConstructL( 
       
    71     		CCoeControl* aControl, 
       
    72     		TESMRFieldFocusType aFocusType = EESMRBorderFocus ); 
       
    73 
       
    74     /**
       
    75      * Observer interface is used to notify the list component when
       
    76      * component is added, removed or needs resizing.
       
    77      *
       
    78      * @param aObserver List component observer
       
    79      */
       
    80     IMPORT_C virtual void SetListObserver( MESMRListObserver* aObserver );
       
    81 
       
    82     /**
       
    83      * Set identifier for this field.
       
    84      *
       
    85      * @param aFieldId Id for this field
       
    86      */
       
    87     IMPORT_C virtual void SetFieldId( TESMREntryFieldId aFieldId );
       
    88 
       
    89 public:
       
    90     /**
       
    91      * Layout this field relative to given TRect. Implementation MUST
       
    92      * update the height of this field to given TRect so the calling
       
    93      * list component knows where to place the next field.
       
    94      *
       
    95      * @param aRect Contains the rect for this field. The height must be updated.
       
    96      * @param aMgr LayoutManager (LAF)
       
    97      * @deprecated Use InitializeL() and ExpandableHeight() instead.
       
    98      */
       
    99     IMPORT_C void DoLayout( TRect& aRect, CESMRLayoutManager& aMgr );
       
   100 
       
   101     /**
       
   102      * Method is called by list component to retrieve new height of the field.
       
   103      *
       
   104      * @see SetExpandable()
       
   105      * @return height after expansion
       
   106      */
       
   107     IMPORT_C virtual TInt ExpandedHeight() const;
       
   108 
       
   109     /**
       
   110      * Called in the constuct phase. Font and colors are typically set here
       
   111      */
       
   112     IMPORT_C virtual void InitializeL();
       
   113 
       
   114     /**
       
   115      * Called if the Font needs to be updated from CESMRLayoutManager
       
   116      *
       
   117      * @see InitializeL()
       
   118      */
       
   119     IMPORT_C virtual void FontChangedL();
       
   120 
       
   121     /**
       
   122      * Sets this field to be expandable. After this is called list
       
   123      * component asks the new height of the field every time its size changes.
       
   124      *
       
   125      * @see ExpandedHeight()
       
   126      */
       
   127     IMPORT_C virtual void SetExpandable();
       
   128 
       
   129     /**
       
   130      * Method is called to ask is this field expandable or not.
       
   131      *
       
   132      * @return boolean ETrue/EFalse
       
   133      */
       
   134     IMPORT_C virtual TBool IsExpandable() const;
       
   135 
       
   136     /** Sets the layoutmanager for the field. If overwritten, the derived class MUST
       
   137      *  call iBorder->SetLayoutManager() to enable intended behaviour.
       
   138      *  @param layoutmanager for the field
       
   139      */
       
   140     IMPORT_C virtual void SetLayoutManager( CESMRLayoutManager* aLayout );
       
   141 
       
   142     /**
       
   143      * Identifier for this field.
       
   144      *
       
   145      * @return TESMRField
       
   146      */
       
   147     IMPORT_C virtual TESMREntryFieldId FieldId() const;
       
   148 
       
   149     /**
       
   150      * Called by the list component. Implementations should update the
       
   151      * the field according to MESMRCalEntry argument. Default implementation
       
   152      * does nothing.
       
   153      *
       
   154      * @param aEntry Current calendar entry
       
   155      */
       
   156     IMPORT_C virtual void InternalizeL( MESMRCalEntry& aEntry );
       
   157 
       
   158     /**
       
   159      * Called by the list component. Implementations should update the
       
   160      * the given calendar entry with its data.
       
   161      *
       
   162      * @param aEntry Current calendar entry
       
   163      */
       
   164     IMPORT_C virtual void ExternalizeL( MESMRCalEntry& aEntry );
       
   165 
       
   166     /**
       
   167      * Set this fields focus.
       
   168      * @param aFocus
       
   169      */
       
   170     IMPORT_C virtual void SetOutlineFocusL( TBool aFocus );
       
   171 
       
   172     /**
       
   173      * Subclasses should overwrite this method when any validity
       
   174      * checks are needed.
       
   175      *
       
   176      * @return ETrue if data is valid, EFalse if not (focus not changed)
       
   177      */
       
   178     IMPORT_C virtual TBool OkToLoseFocusL( TESMREntryFieldId aNextItem );
       
   179 
       
   180      /**
       
   181      * Return minimun vertical area that should be shown when
       
   182      * scrolling the list.
       
   183      * @param aUpper, the upper vertical coordinate
       
   184      * @param aLower, the lower vertical coordinate
       
   185      */
       
   186      IMPORT_C virtual void GetMinimumVisibleVerticalArea(TInt& aUpper, TInt& aLower);
       
   187 
       
   188      /**
       
   189       * Trigger for notifying when the list observer is set
       
   190       */
       
   191      IMPORT_C virtual void ListObserverSet();
       
   192 
       
   193      /**
       
   194       * Calculates the shown rect in given rect within the list area
       
   195       */
       
   196      IMPORT_C virtual TRect CalculateVisibleRect( TRect aRect );
       
   197 
       
   198      /**
       
   199       * Executes generic command if needed by the field
       
   200       * @param aCommand, commandId to handle specific command
       
   201       */
       
   202      IMPORT_C virtual void ExecuteGenericCommandL( TInt aCommand );
       
   203 
       
   204      /**
       
   205       * Set titlepane observer to see title pane subject events
       
   206       * @param aObserver title pane observer to be set
       
   207       */
       
   208      IMPORT_C virtual void SetTitlePaneObserver( MESMRTitlePaneObserver* aObserver );
       
   209      
       
   210      /**
       
   211       * From MESMRFieldEventNotifier
       
   212       * Sets field event queue.
       
   213       * @param aObserver observer to receive field events. 
       
   214       */
       
   215      IMPORT_C void SetEventQueueL( MESMRFieldEventQueue* aEventQueue );
       
   216      
       
   217      /**
       
   218       * Getter for retrieving outline focus state.
       
   219       * @return ETrue if field is focused EFalse otherwise.
       
   220       */
       
   221      IMPORT_C TBool HasOutlineFocus() const;
       
   222      
       
   223      /**
       
   224       * Getter for focus rect. CMRBackground uses this to get rectangle
       
   225       * it draws background focus to.
       
   226       * Returned rectangle should be relative to Field's rect.
       
   227       * @return focus rectangle.
       
   228       */
       
   229      IMPORT_C TRect GetFocusRect() const;
       
   230      
       
   231      /**
       
   232       * Setter for background focus area. Every field should set
       
   233       * this in their SizeChanged methods.
       
   234       * Given rectangle should be relative to Field's rect.
       
   235       * @param aFocusRect rectangle for focus.
       
   236       */
       
   237      IMPORT_C void SetFocusRect( const TRect& aFocusRect );
       
   238      
       
   239      /**
       
   240       * Getter for background focus type. CMRBackground uses this
       
   241       * method to determine how to draw focus.
       
   242       * @return focus type.
       
   243       */
       
   244      IMPORT_C TESMRFieldFocusType GetFocusType() const;
       
   245      
       
   246      /**
       
   247       * Setter for focus type. Every field should set this in e.g. their
       
   248       * ConstructL.
       
   249       * @param aFocusType focus type.
       
   250       */
       
   251      IMPORT_C void SetFocusType( TESMRFieldFocusType aFocusType );
       
   252      
       
   253      /**
       
   254       * Setter for field mode. Field is either in viewer or editor mode.
       
   255       * @param aModeOfField Mode of the field
       
   256       */
       
   257      IMPORT_C void SetFieldMode( TESMRFieldMode aMode );
       
   258      
       
   259      /**
       
   260       * Getter for the field mode.
       
   261       * @return Field mode
       
   262       */
       
   263      IMPORT_C TESMRFieldMode FieldMode() const;
       
   264      
       
   265 protected:
       
   266     
       
   267     /**
       
   268      * Sends event to the event queue.
       
   269      * @param aEvent event to send.
       
   270      */
       
   271     IMPORT_C void NotifyEventL( const MESMRFieldEvent& aEvent );
       
   272     
       
   273     /**
       
   274      * Sends command event to the event queue.
       
   275      * @param aCommand command to send
       
   276      */
       
   277     IMPORT_C void NotifyEventL( TInt aCommand );
       
   278     
       
   279     /**
       
   280      * Sends event to the event queue asynchronously.
       
   281      * Ownership of the event is transferred to the event queue.
       
   282      * @param aEvent event to send.
       
   283      */
       
   284     IMPORT_C void NotifyEventAsyncL( MESMRFieldEvent* aEvent );
       
   285 
       
   286     /**
       
   287      * Sends command event to the event queue asynchronously.
       
   288      * Ownership of the event is transferred to the event queue.
       
   289      * @param aEvent event to send.
       
   290      */
       
   291     IMPORT_C void NotifyEventAsyncL( TInt aCommand );
       
   292 
       
   293     /**
       
   294      * Set middle softkey command and name
       
   295      * @param aCommandId, command to execute on MSK press
       
   296      * @param aResourceId, resource string to display on MSK
       
   297      */
       
   298     IMPORT_C void ChangeMiddleSoftKeyL( TInt aCommandId, TInt aResourceId);
       
   299 
       
   300     /**
       
   301      * Set middle softkey command
       
   302      * @param aResourceId, MSK CBA_BUTTON resource id 
       
   303      */
       
   304     IMPORT_C void ChangeMiddleSoftKeyL( TInt aResourceId );
       
   305          
       
   306     /**
       
   307      * Requests dialog to restore middle softkey to the default one.
       
   308      */
       
   309     IMPORT_C void RestoreMiddleSoftKeyL();
       
   310 
       
   311     /**
       
   312      * Sets middle softkey visible in field.
       
   313      * @param aVisible if ETrue sets middle softkey visible.
       
   314      */
       
   315     IMPORT_C void SetMiddleSoftKeyVisible( TBool aVisible );
       
   316 
       
   317 public: // From CCoeControl
       
   318     IMPORT_C void SetContainerWindowL(const CCoeControl& aContainer);
       
   319     IMPORT_C virtual TKeyResponse OfferKeyEventL( const TKeyEvent& aEvent, TEventCode aType );
       
   320     IMPORT_C virtual void SizeChanged();
       
   321     IMPORT_C virtual TInt CountComponentControls() const;
       
   322     IMPORT_C virtual CCoeControl* ComponentControl( TInt aInd ) const;
       
   323     IMPORT_C virtual TSize MinimumSize();     
       
   324 
       
   325 protected:
       
   326     
       
   327     IMPORT_C CESMRField();
       
   328     
       
   329     // From MESMRFieldEventObserver
       
   330     /**
       
   331      * Handles an event from other field.
       
   332      * Default implementation delegates command events to
       
   333      * <c>ExecuteGenericCommandL()</c>
       
   334      * @param aEvent event to handle
       
   335      */
       
   336     IMPORT_C void HandleFieldEventL( const MESMRFieldEvent& aEvent );
       
   337     
       
   338     // From MESMRFieldEventNotifier
       
   339     /**
       
   340      * Returns the event observer interface
       
   341      */
       
   342     IMPORT_C MESMRFieldEventObserver* EventObserver() const;
       
   343     
       
   344 protected:
       
   345     /// Own: Border control. Draws the outline border
       
   346     CESMRBorderLayer* iBorder;
       
   347     /// Ref: Observer for notifying list component
       
   348     MESMRListObserver* iObserver;
       
   349     /// Ref: Id for this field.
       
   350     TESMREntryFieldId iFieldId;
       
   351     /// Ref: Pointer to layoutmanager
       
   352     CESMRLayoutManager* iLayout;
       
   353     /// Own: Flag to inform is this field expandable or not.
       
   354     TBool iExpandable;
       
   355     /// Field event queue. 
       
   356     MESMRFieldEventQueue* iEventQueue;
       
   357     /// Custom MSK flag
       
   358     TBool iCustomMsk;
       
   359     /// Own:
       
   360     TBool iDisableRedraw;
       
   361     /// 
       
   362     TBool iDefaultMskVisible;
       
   363     /// Msk disable/enable flag
       
   364     TBool iMskVisible;
       
   365     /// Own: Background/focus layer
       
   366     CMRBackground* iBackground;
       
   367     /// Boolean whether field has outline focus
       
   368     TBool iOutlineFocus;
       
   369     /// Background focus rect
       
   370     TRect iFocusRect;
       
   371     /// Background focus type
       
   372     TESMRFieldFocusType iFocusType;    
       
   373     /// Field mode (editor or viewer)
       
   374     TESMRFieldMode iFieldMode;
       
   375     };
       
   376 
       
   377 #endif