classicui_pub/queries_api/inc/AknQueryValueNumber.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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 *
       
    16 */
       
    17 
       
    18 // AknQueryValueNumber.h
       
    19 //
       
    20 // Copyright (c) 2001 Symbian Ltd.  All rights reserved.
       
    21 //
       
    22 
       
    23 #if !defined(__AKNQUERYVALUENUMBER_H__)
       
    24 #define __AKNQUERYVALUENUMBER_H__
       
    25 
       
    26 #include <bamdesca.h>
       
    27 #include <eikdialg.h>
       
    28 #include "AknQueryValue.h"
       
    29 
       
    30 class CAknQueryValueNumberArray;
       
    31 
       
    32 /**
       
    33  * Encapsulates a TInt. Provides an interface to create a dialog
       
    34  * containing a number query control, which will edit the value. Optionally 
       
    35  * allows the value to be changed by selecting from a list of values. 
       
    36  *
       
    37  */
       
    38 NONSHARABLE_CLASS(CAknQueryValueNumber) : public CAknQueryValue
       
    39     {
       
    40 public:
       
    41     /**
       
    42      * First stage of two stage construction.
       
    43      *
       
    44     */
       
    45 	IMPORT_C static CAknQueryValueNumber* NewL();
       
    46 	
       
    47     /**
       
    48      * First stage of two stage construction.
       
    49      *
       
    50     */
       
    51 	IMPORT_C static CAknQueryValueNumber* NewLC();
       
    52 	
       
    53     IMPORT_C virtual ~CAknQueryValueNumber();
       
    54 	
       
    55 	/**
       
    56      * Set the array.
       
    57      * 
       
    58      * @param aArray pointer to array, ownership is not passed
       
    59     */
       
    60 	IMPORT_C void SetArrayL(const CAknQueryValueNumberArray* aArray);
       
    61 	
       
    62     /**
       
    63      * Set the string used for the query caption to be a string other than the default.
       
    64      *
       
    65      * @param aResourceId		resource id of string to use for caption.
       
    66      *
       
    67     */
       
    68 	IMPORT_C void SetQueryCaption(TInt aResourceId);
       
    69 	
       
    70     /**
       
    71      * Return the current value, which may have been set by the user
       
    72      *
       
    73      * @return The current value
       
    74      *
       
    75     */
       
    76 	IMPORT_C TInt Value() const;
       
    77 	
       
    78 public: // from MAknQueryValue
       
    79     IMPORT_C virtual const MDesCArray* MdcArray() const;       
       
    80     IMPORT_C virtual HBufC* CurrentValueTextLC();    
       
    81     IMPORT_C virtual TInt CurrentValueIndex() const;     
       
    82     IMPORT_C virtual void SetCurrentValueIndex(const TInt aIndex);    
       
    83     IMPORT_C virtual TBool CreateEditorL();
       
    84     
       
    85 protected:
       
    86 	CAknQueryValueNumber();
       
    87 	
       
    88     /**
       
    89      * 2nd stage construction.
       
    90      *
       
    91     */
       
    92 	void ConstructL();
       
    93 	
       
    94 	/**
       
    95      * Search for the current value in the list, and set the curent index 
       
    96      * to be the found index. If not found, set current index to 1 after the size of the array.
       
    97      *
       
    98     */
       
    99 	void CalculateCurrentIndex();
       
   100 	virtual void AppendValueIfNewL();
       
   101 private: // from MAknQueryValue
       
   102 	IMPORT_C void Reserved_MAknQueryValue();
       
   103 private:
       
   104 	// the following are member variables
       
   105 	TInt iQueryCaptionId;
       
   106 	TInt iNumber;
       
   107 	TInt iCurrentIndex;
       
   108 	// the following are not owned
       
   109 	const CAknQueryValueNumberArray* iArray;
       
   110     };
       
   111 
       
   112 
       
   113 /**
       
   114  * Wraps an array of numeric values, adapts it into a descriptor array.
       
   115  *
       
   116  */
       
   117 NONSHARABLE_CLASS(CAknQueryValueNumberArray) : public CBase, public MDesCArray
       
   118 	{
       
   119 public:
       
   120     /**
       
   121      * Typedef for array containing TInt items
       
   122      *
       
   123     */
       
   124 	typedef CArrayFix<TInt> NumberArray;
       
   125 	enum {KSafeSizeOfDescriptorForNumberFormat = 32};
       
   126 public:
       
   127 
       
   128     /**
       
   129      * Two-phased constructor..
       
   130      *
       
   131      * @param aResourceId	Recource id of a TBUF containing a number format string. Client
       
   132      *							can use R_AVKON_TBUF_POPUP_FIELD_DEFAULT_NUMBER_FORMAT
       
   133      *							if desired, or provide its own resource. 
       
   134     */
       
   135 	IMPORT_C static CAknQueryValueNumberArray* NewL(TInt aResourceId);
       
   136 	
       
   137     /**
       
   138      * See NewL
       
   139      *
       
   140     */	
       
   141 	IMPORT_C static CAknQueryValueNumberArray* NewLC(TInt aResourceId);
       
   142 	
       
   143 	IMPORT_C ~CAknQueryValueNumberArray();
       
   144 	
       
   145 	/**
       
   146      * Set the array of values. 
       
   147      * Note that client can use any implementation of array class, but must pass in a 
       
   148      * TArray generated from it (by calling the Array() method on the array class)
       
   149      *
       
   150      * @param aArray    array of values, ownership is not passed
       
   151     */
       
   152 	IMPORT_C void SetArray(NumberArray& aArray);
       
   153 	
       
   154 	/**
       
   155      * Get the array of values as a TArray. 
       
   156      * Note that client can use any implementation of array class, but the array is 
       
   157      * treated as a TArray.
       
   158      *
       
   159      * @return array of values, ownership is not passed
       
   160     */
       
   161 	IMPORT_C NumberArray* Array() const;
       
   162 	
       
   163 	/**
       
   164      * Return the TTime format string that is used to generate MDesCArray values
       
   165      *
       
   166      * @return format string
       
   167     */
       
   168 	IMPORT_C const HBufC* FormatString() const;
       
   169 	
       
   170     /**
       
   171      * Return the size of a maximal time string formated using the format string 
       
   172      * that was supplied during construction of this instance.
       
   173      * Two versions to eliminate compiler warnings.
       
   174      *
       
   175      * @return length of formatted string.
       
   176     */
       
   177 #ifdef __WINS__
       
   178 	IMPORT_C const TInt FormattedStringSize() const;
       
   179 #else
       
   180 	IMPORT_C TInt FormattedStringSize() const;
       
   181 #endif // __WINS__
       
   182 
       
   183 public:
       
   184 	// from MDesCArray
       
   185 	/**
       
   186      * @return count of contained array
       
   187      *
       
   188     */
       
   189     IMPORT_C virtual TInt MdcaCount() const;
       
   190     
       
   191     /**
       
   192      * Returns array element, converting value to text. 
       
   193      * <p> WARNING: the returned pointer is only valid until the next time this
       
   194      * method is invoked. 
       
   195      *
       
   196      * @param aIndex   index of element to return
       
   197      * @return descriptor representing array element, ownership is not passed
       
   198     */
       
   199     IMPORT_C virtual TPtrC MdcaPoint(TInt aIndex) const;
       
   200 protected:
       
   201 	CAknQueryValueNumberArray();
       
   202 	
       
   203 	/**
       
   204      * ConstructL
       
   205      *
       
   206      * @param aResourceId	id of a resource containing a time format string
       
   207     */
       
   208 	void ConstructL(TInt aResourceId);
       
   209 private:
       
   210 	// the following members are owned
       
   211 	HBufC* iLastGeneratedTextValue;
       
   212 	HBufC* iFormatString;
       
   213 	// the following members are not owned
       
   214 	NumberArray* iArray;
       
   215 	TInt iFormattedStringSize;
       
   216 	};
       
   217 
       
   218 
       
   219 #endif // __AKNQUERYVALUENUMBER_H__
       
   220