williamr@2: /* williamr@2: * Copyright (c) 1997-2001 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef __EIKFPNE_H__ williamr@2: #define __EIKFPNE_H__ williamr@2: williamr@2: #ifndef __EIKEDWIN_H__ williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #ifndef __AKNNUMEDWIN_H__ williamr@2: #include williamr@2: #endif williamr@2: williamr@2: /** williamr@2: * This class presents an editor modifying a real. The decimal place can occur anywhere. williamr@2: * Exponential notation is allowed. williamr@2: * williamr@2: * Validation, consisting of a check that the contents are parsable as a number williamr@2: * (using TLex::Val()) and a range check, is carried out when PrepareForFocusLossL is called. williamr@2: * Invalid contents cause a leave of that method. williamr@2: * williamr@2: * Value() only returns a value corresponding reliably to the value in the editor after a williamr@2: * non-leaving call to PrepareForFocusLossL. williamr@2: * williamr@2: */ williamr@2: class CEikFloatingPointEditor : public CAknNumericEdwin williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * C++ constructor williamr@2: */ williamr@2: IMPORT_C CEikFloatingPointEditor(); williamr@2: /** williamr@2: * 2nd stage constructor williamr@2: */ williamr@2: IMPORT_C void ConstructL(const TReal& aMin,const TReal& aMax,TInt aTextLimit); williamr@2: /** williamr@2: * Read out the value from the editor as a Real. Value can only be relied on after williamr@2: * a non-leaving call to PrepareForFocusLossL(). williamr@2: * williamr@2: * @return Value in the editor williamr@2: */ williamr@2: IMPORT_C TReal Value() const; williamr@2: /** williamr@2: * Read out the value from the editor as a Real. williamr@2: * @return Validation status of the current value williamr@2: */ williamr@2: IMPORT_C TValidationStatus GetValueAsReal( TReal& aValue ); williamr@2: /** williamr@2: * Set the value in the editor. williamr@2: * williamr@2: * @param aValue pointer to value to set williamr@2: */ williamr@2: IMPORT_C void SetValueL(const TReal* aValue); williamr@2: /** williamr@2: * Set minimum and maximum valid values. williamr@2: * williamr@2: * @param aMin TInt minimum value williamr@2: * @param aMax TInt maximum value williamr@2: */ williamr@2: IMPORT_C void SetMinMax(TReal aMin,TReal aMax); williamr@2: /** williamr@2: * Get minimum and maximum valid values. williamr@2: * williamr@2: * @param aMin TReal& minimum value williamr@2: * @param aMax TReal& maximum value williamr@2: */ williamr@2: IMPORT_C void GetMinMax(TReal& aMin,TReal& aMax) const; williamr@2: public: // framework williamr@2: /** williamr@2: * From resource constructor. Refer to eikon.rh for the FLPTED resource structure williamr@2: * williamr@2: * @param aReader Resource reader positioned at a FLPTED resource location williamr@2: */ williamr@2: IMPORT_C virtual void ConstructFromResourceL(TResourceReader& aReader); williamr@2: /** williamr@2: * Called by framework when focus is being taken off editor. May be called williamr@2: * by client code. williamr@2: */ williamr@2: IMPORT_C virtual void PrepareForFocusLossL(); williamr@2: /** williamr@2: * Sets the input capabilities of the editor williamr@2: */ williamr@2: IMPORT_C virtual TCoeInputCapabilities InputCapabilities() const; williamr@2: williamr@2: williamr@2: /** williamr@2: * Specific Key handling for numeric editor williamr@2: */ williamr@2: IMPORT_C virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); williamr@2: williamr@2: /** williamr@2: * Update contents of editor on certain resource change events williamr@2: */ williamr@2: IMPORT_C virtual void HandleResourceChange(TInt aType); williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * Handles pointer events williamr@2: * @param aPointerEvent The pointer event. williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: private: // from CEikEdwin williamr@2: IMPORT_C void Reserved_3(); williamr@2: williamr@2: private: williamr@2: TReal iValue; williamr@2: TReal iMin; williamr@2: TReal iMax; williamr@2: TInt iSpare; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: * This class presents an editor modifying a real. A fixed number of decimal places is williamr@2: * permitted, set by API. Exponential notation is not permitted. williamr@2: * williamr@2: * Validation, consisting of a check that the contents are parsable as a number williamr@2: * (using TLex::Val()) and a range check, is carried out when PrepareForFocusLossL is called. williamr@2: * Invalid contents cause a leave of that method. williamr@2: * williamr@2: * Value() only returns a value corresponding reliably to the value in the editor after a williamr@2: * non-leaving call to PrepareForFocusLossL. williamr@2: * williamr@2: * All values, defaults, minima and maxima set by API or resource are TInts. The Real value williamr@2: * is obtained by dividing by 10^ williamr@2: * williamr@2: * The number of characters in the editor is calculated from the number of allowed decimal places. williamr@2: * TODO but there is a bug - cannot handle + or - signs in front, nor missing leading 0s williamr@2: * before the decimal place. williamr@2: */ williamr@2: class CEikFixedPointEditor : public CAknNumericEdwin williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * C++ constructor williamr@2: */ williamr@2: IMPORT_C CEikFixedPointEditor(); williamr@2: /** williamr@2: * 2nd stage Constructor williamr@2: */ williamr@2: IMPORT_C void ConstructL(TInt aMin,TInt aMax); williamr@2: /** williamr@2: * Access the value in the editor. The returned value is multiplied by 10^(decimal places) williamr@2: * before formatting to text in the editor. williamr@2: * williamr@2: * The value is reliable only immediately after setting and after a non-leaving call to williamr@2: * PrepareForFocusLossL williamr@2: * williamr@2: * @return TInt current value in the editor. williamr@2: */ williamr@2: IMPORT_C TInt Value() const; williamr@2: /** williamr@2: * Read out the value from the editor as a integer. williamr@2: * @return Validation status of the current value williamr@2: */ williamr@2: IMPORT_C TValidationStatus GetValueAsInteger( TInt& aValue ); williamr@2: /** williamr@2: * Set the value in the editor. The passed value is divided by 10^(decimal places) williamr@2: * before formatting to text in the editor. williamr@2: * williamr@2: * @param TInt* pointer to value to set williamr@2: */ williamr@2: IMPORT_C void SetValueL(const TInt* aValue); williamr@2: /** williamr@2: * Set minimum and maximum valid values. williamr@2: * williamr@2: * @param aMin TInt minimum value multiplied by 10^(number of decimal places) williamr@2: * @param aMax TInt maximum value multiplied by 10^(number of decimal places) williamr@2: */ williamr@2: IMPORT_C void SetMinMax(TInt aMin, TInt aMax); williamr@2: /** williamr@2: * Get minimum and maximum valid values. williamr@2: * williamr@2: * @param aMin TInt& minimum value multiplied by 10^(number of decimal places) williamr@2: * @param aMax TInt& maximum value multiplied by 10^(number of decimal places) williamr@2: */ williamr@2: IMPORT_C void GetMinMax(TInt& aMin, TInt& aMax) const; williamr@2: /** williamr@2: * This sets the number of allowed decimal places in the displayed text. The number williamr@2: * is also used to set the power of 10 by which all integer values in the API are divided williamr@2: * by before use, and the power of 10 by which all displayed values are multiplied by williamr@2: * when turning them into integers. williamr@2: * williamr@2: * @param TInt number of decimal places displayed williamr@2: */ williamr@2: IMPORT_C void SetDecimalPlaces(TInt aDecimalPlaces); williamr@2: /** williamr@2: * This returns the number of allowed decimal places in the displayed text. The number williamr@2: * is that used to set the power of 10 by which all integer values in the API are divided williamr@2: * by before use, and the power of 10 by which all displayed values are multiplied by williamr@2: * when turning them into integers. williamr@2: * williamr@2: * @return TInt number of decimal places displayed williamr@2: */ williamr@2: IMPORT_C TInt DecimalPlaces() const; williamr@2: public: // framework williamr@2: /** williamr@2: * From resource constructor. Refer to eikon.rh for the FIXPTED resource structure williamr@2: * williamr@2: * @param aReader Resource reader positioned at FIXPTED resource location williamr@2: */ williamr@2: IMPORT_C virtual void ConstructFromResourceL(TResourceReader& aReader); williamr@2: /** williamr@2: * Called by framework when focus is being taken off editor. May be called williamr@2: * by client code. williamr@2: */ williamr@2: IMPORT_C virtual void PrepareForFocusLossL(); williamr@2: /** williamr@2: * Sets the input capabilities of the editor williamr@2: */ williamr@2: IMPORT_C virtual TCoeInputCapabilities InputCapabilities() const; williamr@2: williamr@2: /** williamr@2: * Specific Key handling for numeric editor williamr@2: */ williamr@2: IMPORT_C virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); williamr@2: williamr@2: /** williamr@2: * Update contents of editor on certain resource change events williamr@2: */ williamr@2: IMPORT_C virtual void HandleResourceChange(TInt aType); williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * Handles pointer events williamr@2: * @param aPointerEvent The pointer event. williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * Calculates the maximum number of characters needed by the editor. Returned values williamr@2: * is used internally to set CEikEdwin::iTextLimit williamr@2: */ williamr@2: TInt RequiredNumberOfCharacters() const; williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: private: // from CEikEdwin williamr@2: IMPORT_C void Reserved_3(); williamr@2: private: williamr@2: TInt iValue; williamr@2: TInt iMin; williamr@2: TInt iMax; williamr@2: TInt iDecimalPlaces; williamr@2: TInt iSpare; williamr@2: }; williamr@2: #endif