landmarksui/uicontrols/inc/CLmkDecimalEditor.h
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2005 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 -    Float editor for editor/viewer form
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef CLMKDECIMALEDITOR_H
       
    24 #define CLMKDECIMALEDITOR_H
       
    25 
       
    26 //  INCLUDES
       
    27 #include <eikmfne.h>
       
    28 
       
    29 // CLASS DECLARATION
       
    30 
       
    31 /**
       
    32 * CLmkDecimalEditor class
       
    33 * Contain two number editor and one separator.
       
    34 */
       
    35 class CLmkDecimalEditor : public CEikMfneField
       
    36 	{
       
    37 public:
       
    38 	enum
       
    39 		{
       
    40 		EFillWithLeadingZeros			=0x1,
       
    41 		EPreserveOldWidthBeforeEditing	=0x2,
       
    42 		ERepresentsYear					=0x4,
       
    43 		EPublicallySettableFlags		=EFillWithLeadingZeros|EPreserveOldWidthBeforeEditing|ERepresentsYear
       
    44 		};
       
    45 private:
       
    46 	enum
       
    47 		{
       
    48 		EIsBeingEditedWithCursor		=0x8,
       
    49 		EIsUninitialised				=0x10
       
    50 		};
       
    51 private:
       
    52 	CLmkDecimalEditor(TInt aMinimumValue, TInt aMaximumValue, TUint32 aFlags);
       
    53 	void ConstructL(TInt aNumberOfZeros);
       
    54 public:
       
    55 	virtual ~CLmkDecimalEditor();
       
    56 	static CLmkDecimalEditor* NewL(const CFont& aFont, TResourceReader& aResourceReader);
       
    57 	static CLmkDecimalEditor* NewL(const CFont& aFont, TInt aMinimumValue, TInt aMaximumValue, TInt aInitialValue, TUint32 aFlags, TInt aNumberOfZeros);
       
    58 	void SetMinimumAndMaximum(TInt aMinimumValue, TInt aMaximumValue, const CFont& aFont); // only values inside the initial minimum and maximum are permitted
       
    59 	void GetMinimumAndMaximum(TInt& aMinimumValue, TInt& aMaximumValue) const;
       
    60 	void SetValue(TInt aValue, const CFont& aFont);
       
    61 	TReal Value() const;
       
    62 	virtual TBool IsValid() const;
       
    63 
       
    64 	void SetUninitialised(TBool aUninitialised);
       
    65 	TBool IsUninitialised() const;
       
    66 
       
    67 public:	// International digit support is only public to to eikstd
       
    68 	void SetDigitType(TDigitType aDigitType, const CFont& aFont);
       
    69 	TDigitType DigitType() const;
       
    70 
       
    71 	// Derive digit display type from locale information
       
    72 	void RefreshDigitType(const CFont& aFont);
       
    73 
       
    74 public:
       
    75 	TBool IsTextNull() const;
       
    76 private: // framework
       
    77 	virtual TInt MaximumWidthInPixels(const CFont& aFont, TBool aShrinkToMinimumSize);
       
    78 	virtual TCoeInputCapabilities InputCapabilities() const;
       
    79 	virtual TBool IsEditable() const;
       
    80 	virtual THighlightType HighlightType() const;
       
    81 	virtual void HandleKey(const CFont& aFont, const TKeyEvent& aKeyEvent, TBool aInterpretLeftAndRightAsEarEvents, TBool& aDataAltered, TInt& aHighlightIncrement);
       
    82 	virtual void HandleDeHighlight(const CFont& aFont, CEikonEnv& aEikonEnv, TBool& aDataAltered, TBool& aError);
       
    83 	virtual const TDesC& Text() const;
       
    84 	void InvalidFieldAlert() const;
       
    85 	TInt AdditionalWidthForHighlights(const CFont& aFont) const;
       
    86 	TInt WidthInPixels(const CFont& aFont) const;
       
    87 
       
    88 private:
       
    89 	TInt MaximumNumberOfDigits() const;
       
    90 	TInt NumberOfDigits() const;
       
    91 	void SetTextToValue(TInt aValue, const CFont& aFont);
       
    92 	TInt ValueFromText() const;
       
    93 	TBool ConvertsIntoValidValue(TInt& aValue) const;
       
    94 
       
    95 private: // International digit support
       
    96 	TChar NormalizeDigit(TChar aChar);
       
    97 	TText ZeroCharacter() const;
       
    98 	TText NegativeCharacter() const;
       
    99 
       
   100 private:
       
   101 	TInt iMinimumValue;
       
   102 	TInt iMaximumValue;
       
   103 	TInt iMaxDigits;
       
   104 	TUint32 iFlags;
       
   105 	HBufC* iText;
       
   106 	TChar iNudgeCharMinus;
       
   107 	TChar iNudgeCharPlus;
       
   108 	TInt iMaxDigitsMinimumValue;
       
   109     TInt iMaxDigitsMaximumValue;
       
   110 	TDigitType	iDigitType;
       
   111 	TInt iNumberOfZeros;
       
   112 
       
   113 protected:
       
   114     // Ref
       
   115     CEikonEnv*	iEnv;
       
   116 	};
       
   117 
       
   118 #endif