Nokia N97 SDK
Example Applications Guide

ueexform.h

00001 /**
00002  * Copyright (c) 2007 Nokia Corporation.
00003  * This material, including documentation and any related
00004  * computer programs, is protected by
00005  * copyright controlled by Nokia Corporation.
00006  */
00007 
00008 
00009 #ifndef __UEEXFORM_H__
00010 #define __UEEXFORM_H__
00011 
00012 // INCLUDES
00013 #include <aknform.h>
00014 
00015 
00016 // FORWARD DECLARATIONS
00017 class CAknUnitEditor;
00018 
00019 // CLASS DECLARATION
00020 
00021 /**
00022  * CUEExForm
00023  * 
00024  * This is a subclass of CAknForm. In this example it is used as
00025  * a simple container for unit editor. The class' ProcessCommandL()
00026  * contains some usual use cases for the editor. The unit editor itself
00027  * is created by dialog/form, see resource file ueex.rss for details
00028  * on that. Unit editor can also be created dynamically using
00029  * CAknUnitEditor::NewL() and CAknUnitEditor::ConstructL() without
00030  * the need for any resources. In this example the unit editor is
00031  * created with the flag EAknUnitEditorAllowUninitialized which
00032  * in practice means that setting a not a number value to the editor
00033  * is allowed.
00034  *
00035  * Once the unit editor is created, its usage is pretty straightforward.
00036  * See the private DoSet and DoGet functions for details.
00037  */
00038 class CUEExForm : public CAknForm
00039     {
00040 public:
00041     /**
00042     * Function from MEikCommandObserver. Handle user menu commands. If a
00043     * leave occurs the framework generates a Symbian Leave code.
00044     *
00045     * @param aCommandId The command identifier to process.
00046     */ 
00047     void ProcessCommandL( TInt aCommandId );
00048     
00049     /**
00050     * Function from MEikMenuObserver. The framework 
00051     * calls this function. It removes the unused default form options. If a 
00052     * leave occurs the framework generates a Symbian Leave code. 
00053     * @param aResourceId The ID of the menu pane.
00054     * @param aMenuPane The menu pane itself.
00055     */
00056         void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
00057         
00058         /**
00059         * Overriden from CAknForm not to display the save changes query.
00060         *
00061         * @return @c ETrue if changes are requested to be saved and then are 
00062         * successfully saved. Save of data is not performed here but in 
00063         * @c SaveFormDataL().
00064         */
00065     TBool QuerySaveChangesL();
00066     
00067 
00068 private:
00069     /**
00070      * Shows a query and sets the value to the editor. This shows how
00071      * to use the function CAknUnitEditor::SetValue().
00072      *
00073      * @param aUnitEditor Pointer to the unit editor to modify
00074      */
00075     void DoSetValue( CAknUnitEditor* aUnitEditor );
00076     
00077     /**
00078      * Sets a not a number value to the editor. This shows how
00079      * to set a not a number value to the editor. Note that
00080      * this requires the editor to have the flag
00081      * EAknUnitEditorAllowUninitialized set.
00082      *
00083      * @param aUnitEditor Pointer to the unit editor to modify
00084      */
00085     void DoSetNaN( CAknUnitEditor* aUnitEditor );
00086     
00087     /**
00088      * Shows two queries and sets the editor's min and max
00089      * values accordingly. This shows how to use
00090      * CAknUnitEditor::SetMinimumAndMaximum().
00091      *
00092      * @param aUnitEditor Pointer to the unit editor to modify
00093      */
00094     void DoSetMinMax( CAknUnitEditor* aUnitEditor );
00095     
00096     /**
00097      * Sets a hardcoded localized unit to the editor. There
00098      * exists a set a predefined localized units for use with
00099      * the unit editor. These are listed in enum TAknUnitEditorUnits
00100      * in eikon.hrh. Although not used in this example, there's
00101      * TBool CAknUnitEditor::SupportsUnit() which can be used
00102      * to check if the editor supports a certain localized unit in
00103      * case the localized units are extended in future versions.
00104      *
00105      * @param aUnitEditor Pointer to the unit editor to modify
00106      */
00107     void DoSetUnit( CAknUnitEditor* aUnitEditor );
00108     
00109     /**
00110      * Sets a hardcoded custom unit to the editor. This shows how to set
00111      * a custom string as the unit. It also automatically
00112      * sets the unit type (obtainable with CAknUnitEditor::Unit()) as
00113      * EAknUnitEditorCustomUnit.
00114      *
00115      * @param aUnitEditor Pointer to the unit editor to modify
00116      */
00117     void DoSetCustomUnit( CAknUnitEditor* aUnitEditor );
00118     
00119     /**
00120      * Shows a query and sets the maximum fractional digits
00121      * of the editor. The maximum number of fractional digits
00122      * supported in the editor is 8. In debug builds, when
00123      * CAknUnitEditor::SetMaxFractionalDigits() is called with
00124      * a larger (or negative) value, the editor panics with
00125      * AKNUNITEDIT 1. 
00126      *
00127      * @param aUnitEditor Pointer to the unit editor to modify
00128      */
00129     void DoSetMaxFractionalDigits( CAknUnitEditor* aUnitEditor );
00130     
00131     /**
00132      * Shows a query with the current value of the editor. This uses
00133      * how to get the value in the editor and how to format it to a
00134      * string. To recreate the whole string the editor is displaying,
00135      * use CAknUnitEditor::Value() and CAknUnitEditor::GetUnit().
00136      *
00137      * @param aUnitEditor Pointer to the unit editor to get the value from
00138      */
00139     void DoGetValue( CAknUnitEditor* aUnitEditor );
00140     };
00141 
00142 #endif // __UEEXFORM_H__

© Nokia 2009

Back to top