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 "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
18 // AknQueryValueDuration.h
20 // Copyright (c) 2001 Symbian Ltd. All rights reserved.
23 #if !defined(__AKNQUERYVALUEDURATION_H__)
24 #define __AKNQUERYVALUEDURATION_H__
28 #include "AknQueryValue.h"
30 class CAknQueryValueDurationArray;
33 * Encapsulates a TTimeIntervalSeconds. Provides an interface to create a dialog
34 * containing a duration 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(CAknQueryValueDuration) : public CAknQueryValue
42 * Two-phased constructor.
45 IMPORT_C static CAknQueryValueDuration* NewL();
48 * Two-phased constructor.
51 IMPORT_C static CAknQueryValueDuration* NewLC();
52 IMPORT_C virtual ~CAknQueryValueDuration();
57 * @param aArray pointer to array, ownership is not passed
59 IMPORT_C void SetArrayL(const CAknQueryValueDurationArray* aArray);
62 * Set the string used for the query caption to be a string other than the default.
64 * @param aResourceId resource id of string to use for caption.
67 IMPORT_C void SetQueryCaption(TInt aResourceId);
70 * Return the current value, which may have been set by the user
73 IMPORT_C TTimeIntervalSeconds Value() const;
75 public: // from MAknQueryValue
76 IMPORT_C virtual const MDesCArray* MdcArray() const;
77 IMPORT_C virtual HBufC* CurrentValueTextLC();
78 IMPORT_C virtual TInt CurrentValueIndex() const;
79 IMPORT_C virtual void SetCurrentValueIndex(const TInt aIndex);
80 IMPORT_C virtual TBool CreateEditorL();
82 CAknQueryValueDuration();
85 * 2nd stage construction.
91 * Search for the current value in the list, and set the curent index
92 * to be the found index. If not found, set current index to 1 after the size of the array.
95 void CalculateCurrentIndex();
97 virtual void AppendValueIfNewL();
98 private: // from MAknQueryValue
99 IMPORT_C void Reserved_MAknQueryValue();
101 // the following are member variables
102 TInt iQueryCaptionId;
103 TTimeIntervalSeconds iDuration;
105 // the following are not owned
106 const CAknQueryValueDurationArray* iArray;
111 * Wraps an array of numeric values, adapts it into a descriptor array.
114 NONSHARABLE_CLASS(CAknQueryValueDurationArray) : public CBase, public MDesCArray
118 * Typedef for array containing TTimeIntervalSeconds items
121 typedef CArrayFix<TTimeIntervalSeconds> DurationArray;
123 enum {KSafeSizeOfDescriptorForDurationFormat = 32};
127 * Two-phased constructor..
129 * @param aResourceId Recource id of a TBUF containing a duration format string. Client
130 * can use R_AVKON_TBUF_POPUP_FIELD_DEFAULT_DURATION_FORMAT
131 * if desired, or provide its own resource. (must be at least "%d%d%d")
133 IMPORT_C static CAknQueryValueDurationArray* NewL(TInt aResourceId);
139 IMPORT_C static CAknQueryValueDurationArray* NewLC(TInt aResourceId);
141 IMPORT_C ~CAknQueryValueDurationArray();
144 * Set the array of values.
145 * Note that client can use any implementation of array class, but must pass in a
146 * TArray generated from it (by calling the Array() method on the array class)
148 * @param aArray array of values, ownership is not passed
150 IMPORT_C void SetArray(DurationArray& aArray);
153 * Get the array of values as a TArray.
154 * Note that client can use any implementation of array class, but the array is
155 * treated as a TArray.
157 * @return array of values, ownership is not passed
159 IMPORT_C DurationArray* Array() const;
162 * Return the TTime format string that is used to generate MDesCArray values
164 * @return format string
166 IMPORT_C const HBufC* FormatString() const;
169 * Return the size of a maximal time string formated using the format string
170 * that was supplied during construction of this instance.
171 * Two versions to eliminate compiler warnings.
173 * @return length of formatted string.
176 IMPORT_C const TInt FormattedStringSize() const;
178 IMPORT_C TInt FormattedStringSize() const;
182 * Format a descriptor with the textual version of a duration, formated according to the format string.
183 * Number of hours is not bounded.
185 * @param aText descriptor to be filled, must be of sufficient size
186 * @param aDuration the interval to be formatted
189 IMPORT_C void FormatDuration(TPtr& aText, TTimeIntervalSeconds aDuration) const;
194 * @return count of contained array
197 IMPORT_C virtual TInt MdcaCount() const;
200 * Returns array element, converting value to text.
201 * <p> WARNING: the returned pointer is only valid until the next time this
204 * @param aIndex index of element to return
205 * @return descriptor representing array element, ownership is not passed
207 IMPORT_C virtual TPtrC MdcaPoint(TInt aIndex) const;
210 CAknQueryValueDurationArray();
213 * 2nd stage construction.
216 void ConstructL(TInt aResourceId);
219 // the following members are owned
220 HBufC* iLastGeneratedTextValue;
221 HBufC* iFormatString;
222 // the following members are not owned
223 DurationArray* iArray;
224 TInt iFormattedStringSize;
228 #endif // __AKNQUERYVALUEDURATION_H__