2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
18 // AknQueryValueNumber.h
20 // Copyright (c) 2001 Symbian Ltd. All rights reserved.
23 #if !defined(__AKNQUERYVALUENUMBER_H__)
24 #define __AKNQUERYVALUENUMBER_H__
28 #include "AknQueryValue.h"
30 class CAknQueryValueNumberArray;
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.
38 NONSHARABLE_CLASS(CAknQueryValueNumber) : public CAknQueryValue
42 * First stage of two stage construction.
45 IMPORT_C static CAknQueryValueNumber* NewL();
48 * First stage of two stage construction.
51 IMPORT_C static CAknQueryValueNumber* NewLC();
53 IMPORT_C virtual ~CAknQueryValueNumber();
58 * @param aArray pointer to array, ownership is not passed
60 IMPORT_C void SetArrayL(const CAknQueryValueNumberArray* aArray);
63 * Set the string used for the query caption to be a string other than the default.
65 * @param aResourceId resource id of string to use for caption.
68 IMPORT_C void SetQueryCaption(TInt aResourceId);
71 * Return the current value, which may have been set by the user
73 * @return The current value
76 IMPORT_C TInt Value() const;
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();
86 CAknQueryValueNumber();
89 * 2nd stage construction.
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.
99 void CalculateCurrentIndex();
100 virtual void AppendValueIfNewL();
101 private: // from MAknQueryValue
102 IMPORT_C void Reserved_MAknQueryValue();
104 // the following are member variables
105 TInt iQueryCaptionId;
108 // the following are not owned
109 const CAknQueryValueNumberArray* iArray;
114 * Wraps an array of numeric values, adapts it into a descriptor array.
117 NONSHARABLE_CLASS(CAknQueryValueNumberArray) : public CBase, public MDesCArray
121 * Typedef for array containing TInt items
124 typedef CArrayFix<TInt> NumberArray;
125 enum {KSafeSizeOfDescriptorForNumberFormat = 32};
129 * Two-phased constructor..
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.
135 IMPORT_C static CAknQueryValueNumberArray* NewL(TInt aResourceId);
141 IMPORT_C static CAknQueryValueNumberArray* NewLC(TInt aResourceId);
143 IMPORT_C ~CAknQueryValueNumberArray();
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)
150 * @param aArray array of values, ownership is not passed
152 IMPORT_C void SetArray(NumberArray& aArray);
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.
159 * @return array of values, ownership is not passed
161 IMPORT_C NumberArray* Array() const;
164 * Return the TTime format string that is used to generate MDesCArray values
166 * @return format string
168 IMPORT_C const HBufC* FormatString() const;
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.
175 * @return length of formatted string.
178 IMPORT_C const TInt FormattedStringSize() const;
180 IMPORT_C TInt FormattedStringSize() const;
186 * @return count of contained array
189 IMPORT_C virtual TInt MdcaCount() const;
192 * Returns array element, converting value to text.
193 * <p> WARNING: the returned pointer is only valid until the next time this
196 * @param aIndex index of element to return
197 * @return descriptor representing array element, ownership is not passed
199 IMPORT_C virtual TPtrC MdcaPoint(TInt aIndex) const;
201 CAknQueryValueNumberArray();
206 * @param aResourceId id of a resource containing a time format string
208 void ConstructL(TInt aResourceId);
210 // the following members are owned
211 HBufC* iLastGeneratedTextValue;
212 HBufC* iFormatString;
213 // the following members are not owned
215 TInt iFormattedStringSize;
219 #endif // __AKNQUERYVALUENUMBER_H__