landmarksui/uicontrols/inc/CLmkDistanceEditor.h
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     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:    LandmarksUi Content File -    Distance editor for editor/viewer form
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef CLmkDistanceEditor_h
       
    26 #define CLmkDistanceEditor_h
       
    27 
       
    28 //  INCLUDES
       
    29 #include "CLmkFloatEditor.h"
       
    30 #include "landmarks.hrh"
       
    31 
       
    32 /// FORWARD DECLARATION
       
    33 class CEikMfneSymbol;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38  *  CLmkDistanceEditor extends CLmkFloatEditor's functionality.
       
    39  *  Implements both metric and imperial units.
       
    40  *  Underlying floating value is just a value, which user inputs.
       
    41  *  Its limits depend on current unit.
       
    42  *  Number() method returns distance always in meters.
       
    43  */
       
    44 class CLmkDistanceEditor : public CLmkFloatEditor
       
    45     {
       
    46     public:
       
    47         // Constructors and destructor
       
    48         /**
       
    49          * Create CLmkDistanceEditor object
       
    50          * @return newly instantiated object
       
    51          */
       
    52         CLmkDistanceEditor();
       
    53 
       
    54         /**
       
    55          * Destructor.
       
    56          */
       
    57         virtual ~CLmkDistanceEditor();
       
    58 
       
    59     	/**
       
    60     	 * By default Symbian 2nd phase constructor
       
    61          * @param aMinimumValue
       
    62          * @param aMaximumValue
       
    63          * @param aInitialValue
       
    64          * @param aType
       
    65     	 */
       
    66     	void ConstructL(TReal32 aMinimumValue,
       
    67                         TReal32 aMaximumValue,
       
    68                         TReal32 aInitialValue);
       
    69 
       
    70     public: // From CLmkFloatEditor
       
    71 
       
    72         /** Sets value */
       
    73 	    void SetNumber(TReal aNumber);
       
    74 
       
    75         /** Gets value */
       
    76 	    TReal Number() const;
       
    77 
       
    78     protected: // From CLmkFloatEditor
       
    79 
       
    80         void HandleCustomFieldChanged(TInt aCustomFieldIndex);
       
    81 
       
    82         void HandleEnter();
       
    83         void HandleExit();
       
    84 
       
    85     protected: // new functions
       
    86 
       
    87         enum TDistanceUnit
       
    88         	{
       
    89         	EUnitNone,
       
    90         	EUnitMeters,
       
    91         	EUnitKilometers,
       
    92         	EUnitFeet,
       
    93         	EUnitMiles
       
    94         	};
       
    95 
       
    96         /** Converts from meters to given units */
       
    97         TReal32 MetersToUnits(
       
    98             TReal32 aMeters,
       
    99             TDistanceUnit aToUnits) const;
       
   100 
       
   101         /** Converts from given units to meters */
       
   102         TReal32 UnitsToMeters(
       
   103             TReal32 aValue,
       
   104             TDistanceUnit aFromUnits) const;
       
   105 
       
   106 
       
   107         /** Updates min and max limits in editor field according to
       
   108          *  current units
       
   109          */
       
   110         void UpdateValueLimits();
       
   111 
       
   112         void SetUnit(TDistanceUnit aUnit);
       
   113         TDistanceUnit Unit() const;
       
   114         TDistanceUnit DefaultUnit() const;
       
   115 
       
   116         void ConstructUnitFieldL();
       
   117 
       
   118         void ShowUnits(TBool aVisible);
       
   119 
       
   120     private: //data
       
   121         TReal   iMinimumValue;
       
   122         TReal   iMaximumValue;
       
   123 
       
   124         TDistanceUnit iLastUsedUnit;
       
   125 
       
   126         // Ref:
       
   127         CEikMfneSymbol* iUnitsField;
       
   128     };
       
   129 
       
   130 #endif      // CLmkDistanceEditor_h
       
   131 
       
   132 // End of File