extras/calcsoft/inc/CalcCont.h
changeset 13 83b3f7c09925
parent 2 c4c2ac0facfd
equal deleted inserted replaced
2:c4c2ac0facfd 13:83b3f7c09925
     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:  Header file of "CCalcContainer",  CCalcContainer class 
       
    15 *                which derived from CCoeControl class. Role of this class 
       
    16 *                is to update the calculator data and display on user's input.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef     CALCCONT_H
       
    22 #define     CALCCONT_H
       
    23 
       
    24 
       
    25 //  INCLUDES
       
    26 #include <coecntrl.h>
       
    27 
       
    28 #include "CalcEditline.h"
       
    29 #include "CalcView.h"
       
    30 
       
    31 
       
    32 //  FORWARD DECLARATIONS
       
    33 class   CCalcEditorSubPane;
       
    34 class   CCalcFuncmapSubPane;
       
    35 class   CCalcOutputSheet; 
       
    36 class   CCalcView;
       
    37 class   CCalcDocument;
       
    38 class   CPeriodic;
       
    39 class   CAknsBasicBackgroundControlContext;
       
    40 //Enum declarations for touch values
       
    41 enum enlayout_values
       
    42 {
       
    43     enTouch_disabled = 0,
       
    44     enTouch_enabled,
       
    45     enTouch_with_prt,
       
    46     enTouch_with_lsc
       
    47 };
       
    48 //  CLASS DEFINITIONS 
       
    49 
       
    50 /**
       
    51 CCalcContainer : 'Main-Pane' class
       
    52 */
       
    53 class   CCalcContainer
       
    54         :public CCoeControl
       
    55     {
       
    56     public:  // Constructors and destructor   
       
    57         /**
       
    58         * Two-phased constructor.
       
    59         */
       
    60         static CCalcContainer* NewL(CCalcView* aView); 
       
    61     
       
    62         /**
       
    63         * Destructor.
       
    64         */
       
    65         virtual ~CCalcContainer();  
       
    66 
       
    67 
       
    68     public:  // New functions
       
    69         /**
       
    70         * Return pointer of FunctionMap subpane class
       
    71         * @return Pointer of FunctionMap subpane class 
       
    72         */
       
    73         inline CCalcFuncmapSubPane* FuncmapSubPane() const; 
       
    74 
       
    75         /**
       
    76         * Return pointer of editor subpane.
       
    77         * @return Pointer of Editor subpane class 
       
    78         */
       
    79         inline CCalcEditorSubPane* EditorPane() const;
       
    80         
       
    81         /**
       
    82         * Return pointer of OutputSheet.
       
    83         * @return Pointer of OutputSheet class 
       
    84         */
       
    85         inline CCalcOutputSheet* OutputSheet() const;
       
    86         
       
    87         /**
       
    88         * Return pointer of CCalcView.
       
    89         * @return Pointer of CCalcView class 
       
    90         */
       
    91         inline CCalcView* View() const;
       
    92 
       
    93         /**
       
    94         * The pretreatment of a numerical input is performed.
       
    95         */
       
    96         void ProcessPreinputL();
       
    97         
       
    98         /**
       
    99         * Clear editor,
       
   100         * and if need, empty line is added to calculation history. 
       
   101         */
       
   102         void InputClearL();
       
   103         
       
   104         /**
       
   105         * Redraw scroll-up and down button on scrolling enable.
       
   106         */
       
   107         void ScrollArrowUpdate();
       
   108 
       
   109         /**
       
   110         * Redraw ChangeSign button on ChangeSign enable.
       
   111         */
       
   112         void SetChangeSignEnableL();
       
   113         
       
   114         /**
       
   115         * Redraw ChangeSign button on ChangeSign disable.
       
   116         */
       
   117         void SetChangeSignDisable();
       
   118   
       
   119         /**
       
   120         * Redraw Clear button on ClearKey enable.
       
   121         */
       
   122         void SetClearKeyEnable();
       
   123 
       
   124 		/**
       
   125         * Show square root button only if no 0 in editor.
       
   126         */
       
   127 		void SetSqrtEnableL();
       
   128 
       
   129 		/**
       
   130         * Show percent button only if no 0 in editor.
       
   131         */
       
   132 		void SetPercentEnableL();
       
   133 
       
   134 		/**
       
   135         * Redraw square root button.
       
   136         */
       
   137 		void ShowSqrtButton(TBool aEnable);
       
   138 
       
   139 		/**
       
   140         * Redraw percent button.
       
   141         */
       
   142 		void ShowPercentButton(TBool aEnable);
       
   143 
       
   144 		/**
       
   145 		* Returns the state of the calculator.
       
   146 		*/
       
   147 		CCalcView::TStateNo GetState();
       
   148 
       
   149         /**
       
   150         * Time out CallBack function for *-key press
       
   151         * @param aObject this class.
       
   152         * @return always 0
       
   153         */
       
   154         static TInt TimeoutCallbackL(TAny* aObject);
       
   155      
       
   156         /**
       
   157         * Time out CallBack function for * /key press
       
   158         * @param aObject this class.
       
   159         * @return always 0
       
   160         */
       
   161         static TInt TimeoutCallbackChrL( TAny* aObject );
       
   162         /**
       
   163         * Time out CallBack function for +#key press
       
   164         * @param aObject this class.
       
   165         * @return always 0
       
   166         */
       
   167         static TInt TimeoutCallbackShiftL( TAny* aObject );
       
   168         
       
   169         /**
       
   170         * Notify changing decimal separator.
       
   171         * @param aOld : Old decimal separator
       
   172         * @param aNew : New decimal separator  
       
   173         */
       
   174         void NotifyChangeDecimal(TChar aOld, TChar aNew);
       
   175         
       
   176     public: // Functions from base classes
       
   177         /**
       
   178         * From CCoeControl : Get help context
       
   179         * @param aContext : help context. 
       
   180         */
       
   181         void GetHelpContext(TCoeHelpContext& aContext) const;
       
   182 
       
   183 		/**
       
   184 		*Returns functionMap subpane
       
   185 		*/
       
   186 		inline CCalcFuncmapSubPane* FunctionSubPane() const; 
       
   187 		
       
   188 		/**
       
   189         * HandleMiddleSoftKey
       
   190         * Handled when MSK is selected 
       
   191         */	
       
   192 		void HandleMiddleSoftKey();
       
   193 
       
   194 		/**
       
   195         * SetOperatorFromTouch
       
   196         * To handle the addition of Touch Input values for digits
       
   197         */	
       
   198 		void SetOperatorFromTouchL(TInt akey);
       
   199 		
       
   200 		/**
       
   201         * ClearInputKey
       
   202         * To handle the clear input key through the touch UI 
       
   203         */	
       
   204 		void ClearInputKeyL(TInt aRepeat = 0);
       
   205 		
       
   206 		/**
       
   207         * ClearInputKey
       
   208         * To handle the '.' key press
       
   209         */	
       
   210 		
       
   211 		void SetSeparatorFromTouchL();
       
   212 
       
   213 		// From CCoeControl		
       
   214 		void ActivateL();
       
   215     private:  // New functions 
       
   216         /**
       
   217         * C++ default constructor.
       
   218         * @param aView : Pointer of CCalcView
       
   219         */
       
   220         CCalcContainer();  
       
   221 
       
   222         /**
       
   223         * Second-phase constructor.
       
   224         */
       
   225         void ConstructL(CCalcView* aView);   
       
   226 
       
   227         /**
       
   228         * If no key is pressed until timeout of *-key,
       
   229         * this function is called.
       
   230         */
       
   231         void DoTimeoutL();
       
   232 
       
   233         /**
       
   234         * If no key is pressed until timeout of * /key,
       
   235         * this function is called.
       
   236         */
       
   237         void DoTimeoutChrL();
       
   238         /**
       
   239         * If no key is pressed until timeout of +#key,
       
   240         * this function is called.
       
   241         */
       
   242         void DoTimeoutShiftL();        
       
   243 
       
   244         /**
       
   245         * Called when any key is pressed.
       
   246         * If timeout notifier for *-key is active, make calculation or
       
   247         * stop notifier according to user's input.
       
   248         * @param aKeyEvent : The key event
       
   249         * @param aType     : The type of the event
       
   250         * @return : If ETrue, the key event is used only for *-key timeout.
       
   251         *           If EFalse, the key event is used not only for *-key 
       
   252         *           timeout but also for other effect of each key. 
       
   253         */
       
   254         TBool HandleAsterKeyTimeoutForKeyPressL(
       
   255              const TKeyEvent& aKeyEvent, TEventCode aType);
       
   256         
       
   257         /**
       
   258         * Called when any key is pressed.
       
   259         * If timeout notifier for * /key is active, make calculation or
       
   260         * stop notifier according to user's input.
       
   261         * @param aKeyEvent : The key event
       
   262         * @param aType     : The type of the event
       
   263         * @return : If ETrue, the key event is used only for * /key timeout.
       
   264         *           If EFalse, the key event is used not only for *+key 
       
   265         *           timeout but also for other effect of each key. 
       
   266         */
       
   267         TBool HandleChrKeyTimeoutForKeyPressL(
       
   268              const TKeyEvent& aKeyEvent, TEventCode aType );
       
   269         /**
       
   270         * Called when any key is pressed.
       
   271         * If timeout notifier for +#key is active, make calculation or
       
   272         * stop notifier according to user's input.
       
   273         * @param aKeyEvent : The key event
       
   274         * @param aType     : The type of the event
       
   275         * @return : If ETrue, the key event is used only for +#key timeout.
       
   276         *           If EFalse, the key event is used not only for +#key 
       
   277         *           timeout but also for other effect of each key. 
       
   278         */
       
   279         TBool HandleShiftKeyTimeoutForKeyPressL(
       
   280              const TKeyEvent& aKeyEvent, TEventCode aType );    
       
   281 
       
   282     private:  // Functions from base classes 
       
   283         /**
       
   284         * From CCoeControl : Return count of controls contained in a compound control.
       
   285         * @return Count of controls contained in a compound control 
       
   286         */
       
   287         TInt CountComponentControls() const;
       
   288         
       
   289         /**
       
   290         * From CCoeControl : Get the components of a compound control
       
   291         * @param aIndex : index of control
       
   292         * @return Control of argument aIndex  
       
   293         */
       
   294         CCoeControl* ComponentControl(TInt aIndex) const;
       
   295         
       
   296         /**
       
   297         * From CCoeControl : Handling key event
       
   298         * @param aKeyEvent : The key event
       
   299         * @param aType     : The type of the event
       
   300         * @return EKeyWasConsumed    : Key event is used. 
       
   301         *         EKeyWasNotConsumed : Key event is not used.
       
   302         */
       
   303         TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, 
       
   304                                     TEventCode aType);
       
   305 
       
   306         /**
       
   307         * From CCoeControl : Notifier for changing language
       
   308         * @param aType : Type of resource change
       
   309         */
       
   310         void HandleResourceChange(TInt aType);
       
   311         
       
   312         /**
       
   313         * @param aType : Type of resource change
       
   314         */
       
   315         void HandleResourceChangeCalSoftL(TInt aType);
       
   316  
       
   317         /**
       
   318         * From CCoeControl : Control size is set.
       
   319         */
       
   320         void SizeChanged();
       
   321 
       
   322         /**
       
   323         * From CCoeControl : Clear whole rectangle. 
       
   324         * @param aRect : rectangle of control
       
   325         */
       
   326         void Draw(const TRect& aRect) const;
       
   327 
       
   328         /**
       
   329         * From CCoeControl.
       
   330         * Pass skin information if need.
       
   331         * @param aId : Type of supplied object.
       
   332         */
       
   333         TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
       
   334          /**
       
   335         * From CCoeControl : Handling pointer event
       
   336         * @param aKeyEvent : The key event
       
   337         * 
       
   338         */
       
   339         void HandlePointerEventL
       
   340                 ( const TPointerEvent& aKeyEvent );
       
   341 
       
   342     private:    // Data
       
   343         CCalcEditorSubPane*  iEditorPane;  // Editor subpane 
       
   344         CCalcFuncmapSubPane* iFuncmapPane; // FunctionMap subpane
       
   345         CCalcOutputSheet*    iSheetPane;   // OutputSheet
       
   346         CCalcView*           iView;        // Calculator view 
       
   347         CCalcDocument*       iCalcDocument;
       
   348         CPeriodic*           iTimeout;     // For handling *-key
       
   349        
       
   350         CPeriodic*           iTimeoutChr;     // For handling */key
       
   351         CPeriodic*           iTimeoutShift;     // For handling +#key   
       
   352 
       
   353         TUint                iPrevInput;   // Key code of previous input
       
   354         CAknsBasicBackgroundControlContext* iSkinContext; // skin data
       
   355         TInt iValue ; 
       
   356     };
       
   357 
       
   358 #include "CalcCont.inl"
       
   359 
       
   360 #endif      //  CALCCONT_H
       
   361             
       
   362 // End of File