extras/calcsoft/inc/CalcEditline.h
changeset 0 3ee3dfdd8d69
equal deleted inserted replaced
-1:000000000000 0:3ee3dfdd8d69
       
     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:  Helper class used by CalcDocument,CCalcContainer etc., 
       
    15 *                TCalcEditLine.
       
    16 *                The numerical value and the character sequence of the real 
       
    17 *                number are held. Addition of a numerical character sequence 
       
    18 *                and which clear operation are performed.
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 #ifndef     CALCEDITLINE_H
       
    24 #define     CALCEDITLINE_H
       
    25 
       
    26 
       
    27 //  INCLUDES
       
    28 #include <e32std.h>
       
    29 
       
    30 
       
    31 //  Define maximum charactor number per line
       
    32 const TInt KCalcMaxDigits(8);
       
    33 const TInt KCalcMaxNumberWidth(11);
       
    34 const TInt KCalcMaxEditNumberWidth( 10 );
       
    35 
       
    36 //  CLASS DEFINITIONS 
       
    37 
       
    38 /**
       
    39 TCalcEditLine is Calculation data class.
       
    40 A line data for 'Editor Sub-Pane'
       
    41 */
       
    42 class   TCalcEditLine
       
    43     {
       
    44     public:
       
    45         enum TCalcOperatorType
       
    46             {
       
    47             ECalcAdd,
       
    48             ECalcSubtract,
       
    49             ECalcMultiply,
       
    50             ECalcDivide,
       
    51             ECalcEqual,
       
    52 			ECalcSqrt,
       
    53 			ECalcPercent,
       
    54             ECalcOperatorNone
       
    55             };    
       
    56 
       
    57     public:  // Constructors and destructor
       
    58         /**
       
    59         * C++ default constructor.
       
    60         */
       
    61         TCalcEditLine(); 
       
    62         
       
    63         /**
       
    64         * Destructor.
       
    65         */
       
    66         virtual ~TCalcEditLine(); 
       
    67         
       
    68         /**
       
    69         * Copy constructor.
       
    70         */
       
    71         TCalcEditLine(const TCalcEditLine& aEditLine); 
       
    72         
       
    73         /**
       
    74         * Assignment operator
       
    75         */
       
    76         const TCalcEditLine&  operator=(const TCalcEditLine& aEditLine);  
       
    77 
       
    78     public:     // New functions
       
    79         /**
       
    80         * Return string of number 
       
    81         * @return String of number.
       
    82         */
       
    83         inline const TPtrC NumberString() const;
       
    84         
       
    85         /**
       
    86         * Clear a line
       
    87         */
       
    88         void AllClear();
       
    89         
       
    90         /**
       
    91         * Delete last 1 digit from a line
       
    92         */
       
    93         void ClearL();
       
    94         
       
    95         /**
       
    96         * Clear number from a line
       
    97         */
       
    98         void ClearOperand();
       
    99         
       
   100         /**
       
   101         * Return number of a line  
       
   102         * @return TReal64 : Operand of a line
       
   103         */
       
   104         TReal64 NumberL() const;
       
   105         
       
   106         /**
       
   107         * Parameter aNumber is set to a line 
       
   108         * @param aNumber 
       
   109         */
       
   110         void SetNumber(TReal64 aNumber);
       
   111         
       
   112         /**
       
   113         * Append a charactor to number.
       
   114         * Leave may occur, KCalcErrEditorSpaceFull.
       
   115         * @param aInput : A input which is Appended 
       
   116         */
       
   117         void AppendL(TChar aInput);
       
   118         
       
   119 		/**
       
   120 		* Append any character to number before it is 
       
   121 		* displayed inthe output sheet.
       
   122 		* Leave may occur, KCalcErrEditorSpaceFull.
       
   123         * @param aInput : A char which is Appended 
       
   124         */
       
   125 	    void AppendNumberStringL(TChar aChar);
       
   126 
       
   127         /**
       
   128         * Change sign of number
       
   129         */
       
   130         void ChangeSignL();
       
   131         
       
   132         /**
       
   133         * If number of editor is "iii.ddd000...", set number "iii.ddd".
       
   134         * Example: 
       
   135         *  Number of editor is "12",  number editor is set "12".
       
   136         *  Number of editor is "12." or "12.000...", number editor is set "12".
       
   137         *  Number of editor is "12.27", number editor is set "12.27".
       
   138         *  Number of editor is "12.27000...", number editor is set "12.27".
       
   139         * @param aLine : current editor
       
   140         */
       
   141         void TrimZeroL();  
       
   142         
       
   143         /**
       
   144         * Return operator type of a line.
       
   145         * @return TCalcOperatorType : ECalcAdd || ECalcSubtract || 
       
   146                                       ECalcMultiply || ECalcDivide ||
       
   147                                       ECalcEqual || ECalcOperatorNone
       
   148         */
       
   149         inline TCalcOperatorType Operator() const;
       
   150         
       
   151         
       
   152         /**
       
   153         * Set operator to a line
       
   154         * @param aType : operator enum
       
   155         */
       
   156         inline void SetOperator(const TCalcOperatorType& aType);
       
   157 
       
   158         /**
       
   159         * Check whether buffer of editline is "0" or not. 
       
   160         * @return ETrue :buffer of editline is "0".
       
   161         *         EFalse:buffer of editline is not "0".
       
   162         *         (Ex) If buffer is "0", return ETrue.
       
   163         *              If buffer is "0.0" or "2", return EFalse. 
       
   164         */
       
   165         TBool CheckZeroL() const;
       
   166 
       
   167         /**
       
   168         * Changing decimal separator.
       
   169         * @param aOld : Old decimal separator
       
   170         * @param aNew : New decimal separator  
       
   171         */
       
   172         void ChangeDecimal(TChar aOld, TChar aNew);
       
   173          
       
   174 
       
   175     private:    // New functions
       
   176         /**
       
   177         * Return count of digits.
       
   178         * @param aNumber : String of number
       
   179         * @return Count of digits. 
       
   180         *         E.g argument aNumber is "-226.89", return value is 5.
       
   181         */
       
   182         TInt NumberDigits() const;
       
   183 
       
   184     private:    // Data
       
   185         TBuf<KCalcMaxNumberWidth> iNumber; // Operand of a line
       
   186         TCalcOperatorType   iOperator; // Operator of a line 
       
   187     };
       
   188 
       
   189 #include "CalcEditLine.inl"
       
   190 
       
   191 #endif  // __CALCEDITLINE_H__
       
   192 
       
   193 //  End of File