meetingrequest/mrgui/mrfieldbuilderplugin/inc/cesmrtimefield.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 time (start-end) field implementation
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CESMRTIMEFIELD_H
       
    20 #define CESMRTIMEFIELD_H
       
    21 
       
    22 #include "cesmriconfield.h"
       
    23 
       
    24 //Forward declarations
       
    25 class CEikLabel;
       
    26 class CTimeContainer;
       
    27 class MESMRFieldValidator;
       
    28 class CEikTimeEditor;
       
    29 
       
    30 /**
       
    31  * Time field for ESMR editor. Time field has start and end time
       
    32  * separated by a '-'. Focus traverses from left to right and right
       
    33  * to left.
       
    34  */
       
    35 NONSHARABLE_CLASS( CESMRTimeField ): public CESMRIconField
       
    36     {
       
    37 public:
       
    38     /**
       
    39      * Creates new CESMRTimeField object. Ownership
       
    40      * is transferred to caller.
       
    41      * @param aValidator validator object
       
    42      * @return Pointer to created object,
       
    43      */
       
    44     static CESMRTimeField* NewL( MESMRFieldValidator* aValidator );
       
    45 
       
    46     /**
       
    47      * Destructor.
       
    48      */
       
    49     ~CESMRTimeField();
       
    50 
       
    51 public: // From CCoeControl
       
    52     void SetContainerWindowL( const CCoeControl& aControl );
       
    53     TKeyResponse OfferKeyEventL(const TKeyEvent& aEvent, TEventCode aType);
       
    54 
       
    55 public: // From ESMRField
       
    56     void InitializeL();
       
    57     TBool OkToLoseFocusL( TESMREntryFieldId aNext );
       
    58     void SetOutlineFocusL( TBool aFocus );
       
    59 
       
    60 private:
       
    61     /**
       
    62      * Constructor.
       
    63      */
       
    64     CESMRTimeField();
       
    65 
       
    66     /**
       
    67      * Second phase constructor.
       
    68      *
       
    69      * @param aValidator validator object
       
    70      */
       
    71     void ConstructL( MESMRFieldValidator* aValidator );
       
    72 
       
    73 private:
       
    74     /**
       
    75      * Own. Container for the time fields.
       
    76      */
       
    77     CTimeContainer* iContainer;
       
    78     };
       
    79 
       
    80 
       
    81 //Forward declarations
       
    82 class MAknsControlContext;
       
    83 class CAknsFrameBackgroundControlContext;
       
    84 
       
    85 /**
       
    86  * Container control for the time fields and the separator.
       
    87  */
       
    88 NONSHARABLE_CLASS( CTimeContainer ): public CCoeControl
       
    89     {
       
    90 
       
    91 public:
       
    92     /**
       
    93      * Creates new CTimeContainer object. Ownership
       
    94      * is transferred to caller.
       
    95      * @param aValidator validator object
       
    96      * @param aParent parent control
       
    97      * @param aFieldId CESMRField id of the control/container
       
    98      * @return Pointer to created object,
       
    99      */
       
   100     static CTimeContainer* NewL(
       
   101             MESMRFieldValidator* aValidator,
       
   102             CCoeControl* aParent,
       
   103             TESMREntryFieldId aFieldId );
       
   104 
       
   105     /**
       
   106      * Destructor.
       
   107      */
       
   108     ~CTimeContainer();
       
   109 
       
   110 public: // From CCoeControl
       
   111     void SetContainerWindowL( const CCoeControl& aControl );
       
   112     TInt CountComponentControls() const;
       
   113     CCoeControl* ComponentControl( TInt aInd ) const;
       
   114     void SizeChanged();
       
   115     TKeyResponse OfferKeyEventL(const TKeyEvent& aEvent, TEventCode aType);
       
   116     void FocusChanged(TDrawNow aDrawNow);
       
   117     void ActivateL();
       
   118     void PositionChanged();
       
   119 
       
   120 public: // interface
       
   121     /**
       
   122      * Sets font and font color for editors.
       
   123      *
       
   124      * @param aFont new font
       
   125      * @param aLayout pointer to layoutmanager
       
   126      */
       
   127     void SetFontL( const CFont* aFont, CESMRLayoutManager* aLayout );
       
   128 
       
   129     /**
       
   130      * Returns currently focused editor.
       
   131      *
       
   132      * @return currently focused editor
       
   133      */
       
   134     CEikTimeEditor* FocusedEditor();
       
   135 
       
   136     /**
       
   137      * Returns ETrue if its ok to change focus.
       
   138      *
       
   139      * @param current field id
       
   140      * @param next field id
       
   141      * @return ETrue if its ok to change focus
       
   142      */
       
   143     TBool OkToLoseFocusL( TESMREntryFieldId aFrom, TESMREntryFieldId aTo );
       
   144 
       
   145 private: // Implementation
       
   146     /**
       
   147      * Constructor.
       
   148      *
       
   149      * @param aValidator validator object
       
   150      */
       
   151     CTimeContainer( MESMRFieldValidator* aValidator, TESMREntryFieldId aFieldId );
       
   152 
       
   153     /**
       
   154      * Second phase constructor.
       
   155      *
       
   156      * @param aParent parent control
       
   157      */
       
   158     void ConstructL( CCoeControl* aParent );
       
   159 
       
   160     /**
       
   161      * Changes focus to left if its possible.
       
   162      *
       
   163      * @param aEvent key event
       
   164      * @param aType event code
       
   165      */
       
   166     TKeyResponse ChangeFocusLeftL(const TKeyEvent& aEvent, TEventCode aType);
       
   167 
       
   168     /**
       
   169      * Changes focus to right if its possible.
       
   170      *
       
   171      * @param aEvent key event
       
   172      * @param aType event code
       
   173      */
       
   174     TKeyResponse ChangeFocusRightL(const TKeyEvent& aEvent, TEventCode aType);
       
   175 
       
   176     void CheckIfValidatingNeededL(
       
   177             TBool aStartFocusedBefore,
       
   178             TInt aStartFieldIndex,
       
   179             TBool aEndFocusedBefore,
       
   180             TInt aEndFieldIndex );
       
   181 
       
   182     void TriggerStartTimeChangedL();
       
   183     void TriggerEndTimeChangedL();
       
   184 
       
   185 private: // data 
       
   186     /**
       
   187      * Own. Start time editor.
       
   188      */
       
   189     CEikTimeEditor* iStartTime;
       
   190 
       
   191     /**
       
   192      * Own. End time editor.
       
   193      */
       
   194     CEikTimeEditor* iEndTime;
       
   195 
       
   196     /**
       
   197      * Own. Separator label between start and end fields.
       
   198      */
       
   199     CEikLabel* iSeparator;
       
   200 
       
   201     /**
       
   202      * Not owned. Validator class for time and sanity checks.
       
   203      */
       
   204     
       
   205     MESMRFieldValidator* iValidator;
       
   206     // Own: Field Id
       
   207     TESMREntryFieldId iFieldId;
       
   208     // Background control context
       
   209     MAknsControlContext* iBackground;
       
   210     // Actual background for the start time editor
       
   211     CAknsFrameBackgroundControlContext* iStartTimeBgContext;
       
   212     // Actual background for the end time editor
       
   213     CAknsFrameBackgroundControlContext* iEndTimeBgContext;
       
   214     // Not owned. Layout manager.
       
   215     CESMRLayoutManager* iLayout;
       
   216     };
       
   217 
       
   218 #endif  // CESMRTIMEFIELD_H
       
   219