williamr@2: /*
williamr@2: * Copyright (c) 2002-2006 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:  Numeric Editor derived from Uikon's CEikEdwin
williamr@2: *                These specializations of CEikEdwin maintain a numeric content, 
williamr@2: *                access methods and validation.
williamr@2: *
williamr@2: */
williamr@2: 
williamr@2: 
williamr@2: 
williamr@2: #if !defined(__AKNNUMEDWIN_H__)
williamr@2: #define __AKNNUMEDWIN_H__
williamr@2: 
williamr@2: // INCLUDES
williamr@2: #include <eikedwin.h>
williamr@2: #include <aknnumed.h> // CAknNumericEdwin
williamr@2: 
williamr@2: // CONSTANTS
williamr@2: _LIT( KAknIntegerFormat, "%d" );
williamr@2: 
williamr@2: // CLASS DECLARATION
williamr@2: 
williamr@2: /**
williamr@2: *  The CAknIntegerEdwin class implements an editor for an integer values.
williamr@2: *
williamr@2: *  The editor has an associated resource struct @c AVKON_INTEGER_EDWIN and 
williamr@2: *  control factory identifier @c EAknCtIntegerEdwin.
williamr@2: *
williamr@2: *  @since Series 60 0.9
williamr@2: */
williamr@2: class CAknIntegerEdwin : public CAknNumericEdwin
williamr@2: 	{
williamr@2: public:
williamr@2: 	/**
williamr@2:     * Two-phased constructor.
williamr@2:     * @param aMin The minimum allowable value.
williamr@2:     * @param aMax The maximum allowable value.
williamr@2:     * @param aMaxChars  The maximum allowable number of the digits.
williamr@2:     * @return Pointer to a fully constructed editor object.
williamr@2:     */
williamr@2: 	IMPORT_C static CAknIntegerEdwin* NewL(TInt aMin, 
williamr@2: 	                                       TInt aMax, 
williamr@2: 	                                       TInt aMaxChars);
williamr@2: 	
williamr@2: 	/**
williamr@2:     * Constructs controls from a resource file.
williamr@2:     * Function reads needed values from a @c AVKON_INTEGER_EDWIN resource. 
williamr@2:     * Essential for Dialog/Form construction.
williamr@2:     * @param aReader The resource reader with which to access the control's
williamr@2:     * resource values.
williamr@2:     */
williamr@2: 	IMPORT_C virtual void ConstructFromResourceL(TResourceReader& aReader);
williamr@2: 	
williamr@2: 	/**
williamr@2:     * 2nd phase constructor.
williamr@2:     * @param aMin The minimum allowable value.
williamr@2:     * @param aMax The maximum allowable value.
williamr@2:     * @param aMaxChars  The maximum allowable number of the digits.
williamr@2:     */
williamr@2: 	IMPORT_C void ConstructL( TInt aMin, TInt aMax, TInt aMaxChars );
williamr@2: 
williamr@2: 	// New methods
williamr@2: 	
williamr@2:     /**
williamr@2:     * Sets the current value of the editor.
williamr@2:     * The control is not redrawn. 
williamr@2:     * @param aValue Current value of the editor.
williamr@2:     */
williamr@2: 	IMPORT_C void SetValueL(TInt aValue);
williamr@2: 	
williamr@2: 	/**
williamr@2:     * Sets the value that is returned when the editor field is left empty or
williamr@2:     * is not valid.
williamr@2:     * @param aUnsetValue The default value to be returned.
williamr@2:     */
williamr@2: 	IMPORT_C void SetUnsetValue( TInt aUnsetValue);
williamr@2: 	
williamr@2:     /**
williamr@2:     * Gets the current value of the editor.
williamr@2:     * Validity of the value is checked, if the editor is empty, the unset value
williamr@2:     * is used. The value is put into aValue parameter even if it is not valid.
williamr@2:     * @param aValue Reference to the integer used to store the value got from
williamr@2:     * the editor field.
williamr@2:     * @return Indicates the validation status.
williamr@2:     */
williamr@2: 	IMPORT_C TValidationStatus GetTextAsInteger( TInt& aValue );
williamr@2: 	
williamr@2: 	/**
williamr@2:     * Sets the minimum allowable value of the editor.
williamr@2:     * @param aMinimumValue The minimum value.
williamr@2:     */
williamr@2: 	IMPORT_C void SetMinimumIntegerValue( TInt aMinimumValue );
williamr@2: 	
williamr@2: 	/**
williamr@2:     * Sets the maximum allowable value of the editor.
williamr@2:     * @param aMaximumValue The maximum value.
williamr@2:     */
williamr@2: 	IMPORT_C void SetMaximumIntegerValue( TInt aMaximumValue );
williamr@2: 
williamr@2: 	
williamr@2: 	/**
williamr@2:     * From @c CCoeControl. Prepares for focus loss.
williamr@2:     * Called by the framework just before focus is removed from the control.
williamr@2:     */
williamr@2: 	IMPORT_C void PrepareForFocusLossL();
williamr@2: 	
williamr@2: 	/**
williamr@2:     * From @c CCoeControl. Handles a change to the control's resources.
williamr@2:     * @since Series 60 2.0
williamr@2:     * @param aType a message UID value.
williamr@2:     */
williamr@2: 	IMPORT_C void HandleResourceChange(TInt aType);
williamr@2: 	
williamr@2: 	/**
williamr@2:     * From @c CCoeControl. Handles key events.
williamr@2:     * Called by framework when a key event occurs.
williamr@2:     * @since Series 60 2.0
williamr@2:     * @param aKeyEvent The key event that occured.
williamr@2: 	* @param aType The type of key event that occured.
williamr@2:     * @return @c EKeyWasConsumed if the event was processed,
williamr@2:     * @c EKeyWasNotConsumed if the event was not processed.
williamr@2:     */
williamr@2: 	IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
williamr@2: 	                                     TEventCode aType);
williamr@2: 
williamr@2:     IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);	
williamr@2: 
williamr@2:     /**
williamr@2:     * Checks if the number of the editor is within the min and max boundaries.
williamr@2:     * If not, the method set the number to closest legal value and highlights the 
williamr@2:     * number text in the editor.
williamr@2:     */
williamr@2:     IMPORT_C TBool CheckNumber();    
williamr@2: 
williamr@2: private:
williamr@2: 	void CommonConstructL(TInt aMin, 
williamr@2: 	                      TInt aMax, 
williamr@2: 	                      TInt aMaxChars, 
williamr@2: 	                      TInt aFlags, 
williamr@2: 	                      TInt aUnset);
williamr@2: 	
williamr@2: 	void RefreshFromLocale();
williamr@2: private:
williamr@2:     /**
williamr@2:     * From CAknControl
williamr@2:     */
williamr@2:     IMPORT_C void* ExtensionInterface( TUid aInterface );
williamr@2: 
williamr@2: private: // from CEikEdwin
williamr@2:     IMPORT_C void Reserved_3();
williamr@2: 
williamr@2: private:
williamr@2: 	TInt iMinimumValue;
williamr@2: 	TInt iMaximumValue;
williamr@2: 	TInt iUnsetValue;
williamr@2: 	TAny* iUnsetText;
williamr@2: 	TDigitType iDigitType;
williamr@2: 	TInt iSpare_Integer_2;
williamr@2: 	};
williamr@2: 
williamr@2: #endif