epoc32/include/mw/aknlocationed.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2006-2007 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:  Location editors 
    15 *
    16 */
    17 
    18 #ifndef AKNLOCATIONED_H
    19 #define AKNLOCATIONED_H
    20 
    21 #include <eikmfne.h>
    22 
    23 class TPosition;
    24 class CLocationStrings;
    25 /**
    26  * Editor for TPosition type; latitude and longitude editor
    27  *
    28  * There exists two ways to construct CAknLocationEditor:
    29  *
    30  * @code
    31  * CAknLocationEditor *editor = CAknLocationEditor::NewL(pos, context);
    32  * @endcode
    33  * 
    34  * Using resources:
    35  *
    36  * @code
    37  * CAknLocationEditor *editor = new (ELeave) CAknLocationEditor
    38  * TResourceReader reader;
    39  * iCoeEnv->CreateResourceReaderLC(reader,R_RES_ID_FOR_EDITOR);
    40  * editor->ConstructFromResourceL(reader);
    41  * editor->Set(pos);
    42  * CleanupStack::PopAndDestroy();
    43  * @endcode
    44  * 
    45  * Resource file format is as follows:
    46  * @code
    47  *     LATITUDE_EDITOR
    48  *        {
    49  *	      flags = ELocationEdFlagLatitude;
    50  *		  latlongresourceid = R_EIK_LATITUDE_AND_LONGITUDE;
    51  *        };
    52  * @endcode
    53  *  or:
    54  * @code
    55  *      LONGITUDE_EDITOR
    56  *        {
    57  *		  flags = ELocationEdFlagLongitude;
    58  *		  latlongresourceid = R_EIK_LATITUDE_AND_LONGITUDE;
    59  *        };
    60  * @endcode
    61  *
    62  *  @lib eikctl.lib
    63  *  @lib lbs.lib (for TPosition class)
    64  *  @since 3.2
    65  *  @see TPosition
    66  */
    67 class CAknLocationEditor : public CEikMfne
    68 	{
    69 public:
    70 	/**
    71 	 * TLocationContext determines what part of TPosition class is used for this editor.
    72      *  ELongitudeOnly means only longitude part of TPosition is used.
    73      *  ELatitudeOnly means only latitude part of TPosition is used.
    74 	 */
    75 	enum TLocationContext
    76 		{
    77 		ELongitudeOnly = 0x1,
    78 		ELatitudeOnly  = 0x2
    79 		};
    80     /**
    81      * Constructor
    82      */
    83 	IMPORT_C CAknLocationEditor();
    84     /**
    85      * Destructor
    86      */
    87 	IMPORT_C ~CAknLocationEditor();
    88     /**
    89      * NewL()
    90      *    Creates location editor and initializes it's value to value determined by the aValue parameter.
    91 	 *
    92      * @param aValue Initial value for location editor.
    93      * @param aContext Which part of the TPosition is used for this location editor
    94      */
    95 	IMPORT_C static CAknLocationEditor* NewL( TPosition &aValue, TLocationContext aContext );
    96 
    97 	/**
    98 	 * ConstructFromResourceL
    99      *     Constructs location editor using information from resource files
   100      *
   101      * @param aResourceReader resource reader
   102 	 */
   103 	IMPORT_C void ConstructFromResourceL( TResourceReader& aResourceReader );
   104 
   105 	/**
   106 	 * DisplayableLocationL()
   107 	 *    Converts TPosition into displayable descriptor usable for listboxes
   108      *
   109 	 * @param aValue value of the location
   110 	 * @param aContext which part of the TPosition is used
   111 	 */
   112 	IMPORT_C static HBufC* DisplayableLocationL( const TPosition &aValue, TLocationContext aContext );
   113 
   114 
   115     /**
   116      * PrepareForFocusLossL()
   117      *     detects focus changes to validate editor contents
   118      */
   119 	IMPORT_C virtual void PrepareForFocusLossL();
   120 
   121 	/**
   122      * Set()
   123      *     Sets either longitude or latitude values of aValue
   124      *
   125 	 *  @param aValue new value for the editor
   126      */
   127 	IMPORT_C void Set(const TPosition &aValue);
   128 	/**
   129 	 * Get()
   130      *      Gets either longitude or latitude values of aValue
   131      *
   132      * @param aValue TPosition object that will be modified
   133      */
   134 	IMPORT_C void Get( TPosition &aValue ) const;
   135 	/**
   136 	 * OfferKeyEventL()
   137 	 *         key event handling of location editor
   138 	 */
   139 	IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
   140 private:
   141 	enum TLocationType
   142 		{
   143 		EDD,
   144 		EDMM,
   145 		EDMSD
   146 		};
   147 	TLocationType Type() const;
   148 	static void Split( const TPosition &aValue, 
   149 					   TLocationContext aContext, 
   150 					   TInt &aDegrees, 
   151 					   TInt &aDeciDegrees, 
   152 					   TInt &aMinutes, 
   153 					   TInt &aDeciMinutes, 
   154 					   TInt &aSeconds, 
   155 					   TInt &aDeciSeconds, 
   156 					   TBool &aNeg, 
   157 					   TBool &aNan );
   158 	static void SplitDD( const TPosition &aValue, 
   159 						 TLocationContext aContext, 
   160 						 TInt &aDegrees,
   161 						 TInt &aDeciDegrees, 
   162 						 TBool &aNeg, 
   163 						 TBool &aNan );
   164 	static void SplitDMM( const TPosition &aValue, 
   165 	                      TLocationContext aContext, 
   166 	                      TInt &aDegrees, 
   167 	                      TInt &aMinutes, 
   168 	                      TInt &aDeciMinutes, 
   169 	                      TBool &aNeg, 
   170 	                      TBool &aNan );
   171 	static void SplitDMSD( const TPosition &aValue, 
   172 						   TLocationContext aContext, 
   173 						   TInt &aDegrees, 
   174 						   TInt &aMinutes, 
   175 						   TInt &aSeconds, 
   176 						   TInt &aDeciSeconds, 
   177 						   TBool &aNeg, 
   178 						   TBool &aNan );
   179 	static void CombineDD( TPosition &aValue, 
   180 						   TLocationContext aContext, 
   181 						   TInt aDegrees, 
   182 						   TInt aDeciDegrees, 
   183 						   TBool aNeg, 
   184 						   TBool aNan );
   185 	static void CombineDMM( TPosition &aValue, 
   186 							TLocationContext aContext, 
   187 							TInt aDegrees, 
   188 							TInt aMinutes, 
   189 							TInt aDeciMinutes, 
   190 							TBool aNeg, 
   191 							TBool aNan );
   192 	static void CombineDMSD( TPosition &aValue, 
   193 							 TLocationContext aContext, 
   194 							 TInt aDegrees, 
   195 							 TInt aMinutes, 
   196 							 TInt aSeconds, 
   197 							 TInt aDeciSeconds, 
   198 							 TBool aNeg, 
   199 							 TBool aNan );
   200 private:
   201 	void SetUninitialised(TBool aInitialised);
   202 	void RefreshFromLocale();
   203 	void ConstructL( TPosition &aValue, TLocationContext aContext );
   204 public:
   205 	void HandleCenRepChangedL(TUint32 aKey, TInt aValue);
   206 	void CreateMfneFieldsL(const TPosition &aValue);
   207 private:
   208 	void LoadStringsL( TInt aResourceId );
   209 	
   210 	/**
   211 	* Maps logical MFNE field order to correct visual order.
   212 	* @param aFieldNumber Field position in logical format.
   213 	* @param aType Used location editor format.
   214 	* @return Field position in visual format.
   215 	*/
   216 	TInt FieldMapping(const TInt aFieldNumber, const TLocationType aType) const;
   217 
   218 protected:
   219 	IMPORT_C virtual void* CAknLocationEditor_ExtensionInterface( TUid aInterface ); 
   220 private:
   221 	CLocationStrings* iStrings;
   222 	TLocationContext iContext;
   223 	};
   224 
   225 
   226 #endif