extras/converter/Ui/Src/CCnvRatesForm.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:  
       
    15 *     An AVKON form class for changing unit names and factors (rates).
       
    16 *     Used with currency units, but is not limited to them.
       
    17 *     Implements the 'Rates State' of the application.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 #ifndef __CCNVRATESFORM_H__
       
    24 #define __CCNVRATESFORM_H__
       
    25 
       
    26 // INCLUDES
       
    27 #include <AknForm.h>
       
    28 #include "CCnvConverter.h"
       
    29 // FORWARD DECLARATIONS
       
    30 class TCnvCategory;
       
    31 
       
    32 // CLASS DEFINITION
       
    33 /**
       
    34 * An AVKON form class for changing unit names and factors (rates).
       
    35 * Used with currency units, but is not limited to them.
       
    36 * Implements the 'Rates State' of the application.
       
    37 */
       
    38 class CCnvRatesForm : public CAknForm
       
    39 	{
       
    40 
       
    41 	public: // Constructors and destructor
       
    42 
       
    43 		/**
       
    44 		* Constructor.
       
    45 		* @param aWantsRelaunch Indicates to the caller if we want
       
    46 		*        to be relaunched.
       
    47 		* @param aShouldExit Indicates to the caller if the application should
       
    48 		*        exit after this form has been closed.
       
    49 		* @param aModelChanged Indicates to the caller that the model data
       
    50 		*		 has changed and needs saving to permanent storage.
       
    51 		* @param aCategory Unit category containing currencies.
       
    52 		*/
       
    53 
       
    54 		CCnvRatesForm( TBool* aWantsRelaunch, TBool* aShouldExit,
       
    55 			TBool* aModelChanged, TCnvCategory& aCategory );
       
    56 
       
    57 		/**
       
    58 		* Destructor.
       
    59 		*/
       
    60 		~CCnvRatesForm();
       
    61 
       
    62 		/**
       
    63 		* 2nd phase constructor.
       
    64 		*/
       
    65 		void ConstructL();
       
    66 
       
    67 	public: // from CCoeControl
       
    68 
       
    69 		/**
       
    70 		* Specifies the help context for this form.
       
    71 		* @param aContext the context IDs are placed here
       
    72 		*/
       
    73 		void GetHelpContext( TCoeHelpContext& aContext ) const;
       
    74 
       
    75 	public: // from MEikCommandObserver
       
    76 
       
    77 		/**
       
    78 		* Handles menu commands.
       
    79 		* @param aCommandId Command identifier.
       
    80 		*/
       
    81 		void ProcessCommandL( TInt aCommandId );
       
    82 
       
    83 	public:	// from MEikDialogPageObserver
       
    84 
       
    85 		/**
       
    86 		* Takes any action required when the current line
       
    87 		* is changed to aControlId.
       
    88 		* @param aControlId Control identifier.
       
    89 		*/
       
    90 		void LineChangedL( TInt aControlId );
       
    91 
       
    92 	public:	// from MEikMenuObserver
       
    93 
       
    94 		/**
       
    95 		* Dynamically initialises a menu pane. The Uikon framework calls this
       
    96 		* function, immediately before the menu pane is activated.
       
    97 		* @param aResourceId Resource ID identifying a menu pane to initialise
       
    98 		* @param aMenuPane The in-memory representation of the menu pane.
       
    99 		*/
       
   100 		void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
       
   101 
       
   102 	protected: // from CAknForm
       
   103 	
       
   104 		/**
       
   105 		* Saves form data to model.
       
   106 		* @return ETrue if the editable state can be left
       
   107 		*         (always in this case).
       
   108 		*/
       
   109 		void DoNotSaveFormDataL();
       
   110 		/**
       
   111 		* Saves form data to model.
       
   112 		* @return ETrue if the editable state can be left
       
   113 		*         (always in this case).
       
   114 		*/
       
   115 		TBool SaveFormDataL();
       
   116 		/**
       
   117 		* Tests if it is OK to exit the dialog.
       
   118 		* @param aButtonId The ID of the button that was activated.
       
   119 		* @return ETrue to validate and exit the dialog,
       
   120 		*         EFalse to keep the dialog active.
       
   121 		*/
       
   122 		TBool OkToExitL(TInt aButtonId);
       
   123 		/**
       
   124 		* Sets the focus to the topmost line of the form.
       
   125 		* when the dialog is activated.
       
   126 		*/
       
   127 		void SetInitialCurrentLine();
       
   128 		
       
   129 		/**
       
   130 		* For Touch Ui implementation
       
   131 		* To prepare for focus transition from the current line.
       
   132 		*/
       
   133 		void PrepareForFocusTransitionL();
       
   134 
       
   135 	protected: // from CEikDialog
       
   136 
       
   137 		/**
       
   138 		* Pre-layout dialog initialisation.
       
   139 		* Populates from with floating point editor controls.
       
   140 		*/
       
   141 		void PreLayoutDynInitL();
       
   142 
       
   143 	private: // Constructors and destructor.
       
   144 
       
   145 		/**
       
   146 		* Default constructor, empty implementation.
       
   147 		*/
       
   148 		CCnvRatesForm();
       
   149 		
       
   150 		/**
       
   151 		* returns ETrue if the the character is an integer
       
   152 		*/
       
   153 		TBool IsDigit(TUint aChar);
       
   154 
       
   155 	private: // new methods
       
   156 
       
   157 		/**
       
   158 		* Handles the ECmdChangeCurrencyName command.
       
   159 		*/
       
   160 		void CmdChangeCurrencyNameL();
       
   161 
       
   162 		/**
       
   163 		* Handles the ECmdSetAsBaseCurrency command.
       
   164 		*/
       
   165 		void CmdSetAsBaseCurrencyL();
       
   166 
       
   167 		/**
       
   168 		* Changes the application title pane text to default.
       
   169 		* Non-leaving.
       
   170 		*/
       
   171 		void SetDefaultTitle();
       
   172 
       
   173 		/**
       
   174 		* Changes the application title pane text.
       
   175 		* @param aNonDefault EFalse = set to default.
       
   176 		*/
       
   177 		void SetTitleL( TBool aNonDefault );
       
   178 
       
   179 		/**
       
   180 		* Handles the Key events for the rates form
       
   181 		* @param aKeyEvent : Key event information
       
   182 		*        aType : EEventKeyDown | EEventKey | EEventKeyUp
       
   183 		* @return : EKeyWasConsumed if keyevent is consumed.   
       
   184 		*           EKeyWasNotConsumed if keyevent is not consumed.
       
   185 		*/
       
   186 		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
       
   187 			TEventCode aType);
       
   188 
       
   189 
       
   190 	private: // data
       
   191 
       
   192 		/**
       
   193 		* Pointer to the flag in the caller object.
       
   194 		* Used to indicate if we want to be relaunched after exit.
       
   195 		*/
       
   196 		TBool* iWantsRelaunch;
       
   197 
       
   198 		/**
       
   199 		* Pointer to the flag in the caller object.
       
   200 		* Used to indicate if the application should close after form exit.
       
   201 		*/
       
   202 		TBool* iShouldExit;
       
   203 
       
   204 		/**
       
   205 		* Shows an error note for invalid value situation
       
   206 		* @param aEditorId Id of the editor that holds the invalid value
       
   207 		* @param aSetValue its value is ETrue or EFalse,
       
   208 		*        if aSetValue equals EFlase that does not set FloatEditor Value
       
   209 		*/
       
   210 		void ShowInvalidValueNoteL(TInt aEditorId, TBool aSetValue);
       
   211 
       
   212 		/**
       
   213 		* Pointer to the flag in the caller object.
       
   214 		* Used to indicate if the model data has changed and needs
       
   215 		* saving to permanent storage.
       
   216 		*/
       
   217 		TBool* iModelChanged;
       
   218 
       
   219 		/**
       
   220 		* Model accessor for the units displayed in this form.
       
   221 		*/
       
   222 		TCnvCategory iCategory;
       
   223 
       
   224 	private:
       
   225 		/**
       
   226 		*Implements the dialog to add a new currency OR rename a currency
       
   227 		*@param aNewname indicates the text that should appear in the dialog as default
       
   228 		*@param aPrompt indicates that title of the dialog
       
   229 		*@param aIsAddNewCurrency if add a new currency aIsAddNewCurrency is ETrue,otherwise EFalsse   
       
   230 		*/
       
   231 		TCurrencyType NewCurrencyNameDialogL(TDes& aNewName,TBool& aNameEntered,TBool aIsAddNewCurrency = EFalse );
       
   232 		/**
       
   233 		* Adds new currency...
       
   234 		*/
       
   235 		void AddNewCurrencyL();
       
   236 		/**
       
   237 		* Deletes the Currency (which is having focus)
       
   238 		*/
       
   239 		void DeleteCurrencyL();
       
   240 
       
   241 		/**
       
   242 		*Checks if the number entered in the editor field is a valid number
       
   243 		*@param aEditroId : Id of the editor that needs to be evaluated
       
   244 		*@return : EFalse if the editor value is not a vaild number	
       
   245 		*		 : ETrue if the number is a valid number
       
   246 		*/
       
   247 		TBool IsVaildNumberEntered(TInt aEditorId);
       
   248 		
       
   249 		/**
       
   250 		*Sets the control as ready to be drawn.
       
   251 		*/		
       
   252 		void ActivateL();
       
   253 		
       
   254 		RArray<TInt> iFormIdMapArray; //Array which has the ids of the form..
       
   255 		RArray<TInt> iFormIdEdwinMapArray; //Array which has the ids of the CEikEdwin editors in the form
       
   256 		/*
       
   257 		* Last active editor line.
       
   258 		*/
       
   259         TInt iLastUsedEditorId;
       
   260 		TBool iEKeyOk;
       
   261 		TBool iError;
       
   262 
       
   263     TUint iSrcUnitIndexForRestore;
       
   264     TUint iDesUnitIndexForRestore;
       
   265     TInt iHistoryBaseUnit;
       
   266 
       
   267 	};
       
   268 
       
   269 #endif // __CCNVRATESFORM_H__
       
   270