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 // AknQueryValueTime.h
20 // Copyright (c) 2001 Symbian Ltd. All rights reserved.
23 #if !defined(__AKNQUERYVALUETIME_H__)
24 #define __AKNQUERYVALUETIME_H__
28 #include "AknQueryValue.h"
30 class CAknQueryValueTimeArray;
33 * Encapsulates a TTime value. Provides an interface to create a dialog
34 * containing a time 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(CAknQueryValueTime) : public CAknQueryValue
42 * First stage of two stage construction.
44 IMPORT_C static CAknQueryValueTime* NewL();
47 * First stage of two stage construction.
49 IMPORT_C static CAknQueryValueTime* NewLC();
51 IMPORT_C virtual ~CAknQueryValueTime();
56 * @param aArray pointer to array, ownership is not passed
58 IMPORT_C void SetArrayL(const CAknQueryValueTimeArray* aArray);
61 * Set the string used for the query caption to be a string other than the default.
63 * @param aResourceId resource id of string to use for caption.
66 IMPORT_C void SetQueryCaption(TInt aResourceId);
69 * Return the current value, which may have been set by the user
71 * @return The current value
74 IMPORT_C TTime Value() const;
76 public: // from MAknQueryValue
77 IMPORT_C virtual const MDesCArray* MdcArray() const;
78 IMPORT_C virtual HBufC* CurrentValueTextLC();
79 IMPORT_C virtual TInt CurrentValueIndex() const;
80 IMPORT_C virtual void SetCurrentValueIndex(const TInt aIndex);
81 IMPORT_C virtual TBool CreateEditorL();
87 * Two stage construction
93 * Search for the current time in the list, and set the curent index
94 * to be the found index. If not found, set current index to 1 after the size of the array.
97 void CalculateCurrentIndex();
99 virtual void AppendValueIfNewL();
101 private: // from MAknQueryValue
102 IMPORT_C void Reserved_MAknQueryValue();
105 // the following are member variables
106 TInt iQueryCaptionId;
109 // the following are not owned
110 const CAknQueryValueTimeArray* iArray;
115 * Wraps an array of TTime, adapts it into a descriptor array.
118 NONSHARABLE_CLASS(CAknQueryValueTimeArray) : public CBase, public MDesCArray
122 * Typedef for array containing TTime items
125 typedef CArrayFix<TTime> TimeArray;
127 enum {KSafeSizeOfDescriptorForTTimeFormat = 128};
134 * @param aResourceId Recource id of a TBUF containing a TTime format string. Client
135 * can use R_AVKON_TBUF_POPUP_FIELD_DEFAULT_TIME_FORMAT
136 * if desired, or provide its own resource.
138 IMPORT_C static CAknQueryValueTimeArray* NewL(TInt aResourceId);
144 IMPORT_C static CAknQueryValueTimeArray* NewLC(TInt aResourceId);
146 IMPORT_C ~CAknQueryValueTimeArray();
149 * Set the array of values.
150 * Note that client can use any implementation of array class, but must pass in a
151 * TArray generated from it (by calling the Array() method on the array class)
153 * @param aArray array of values, ownership is not passed
155 IMPORT_C void SetArray(TimeArray& aArray);
158 * Get the array of values as a TArray.
159 * Note that client can use any implementation of array class, but the array is
160 * treated as a TArray.
162 * @return array of values, ownership is not passed
164 IMPORT_C TimeArray* Array() const;
167 * Return the TTime format string that is used to generate MDesCArray values
169 * @return format string
171 IMPORT_C const HBufC* FormatString() const;
174 * Return the size of a maximal time string formated using the format string
175 * that was supplied during construction of this instance.
176 * Two versions to eliminate compiler warnings.
178 * @return length of formatted string.
181 IMPORT_C const TInt FormattedStringSize() const;
183 IMPORT_C TInt FormattedStringSize() const;
189 * @return count of contained array
192 IMPORT_C virtual TInt MdcaCount() const;
195 * Returns array element, converting value to text.
196 * <p> WARNING: the returned pointer is only valid until the next time this
199 * @param aIndex index of element to return
200 * @return descriptor representing array element, ownership is not passed
202 IMPORT_C virtual TPtrC MdcaPoint(TInt aIndex) const;
205 CAknQueryValueTimeArray();
210 * @param aResourceId id of a resource containing a time format string
212 void ConstructL(TInt aResourceId);
215 // the following members are owned
216 HBufC* iLastGeneratedTextValue;
217 HBufC* iFormatString;
218 // the following members are not owned
220 TInt iFormattedStringSize;
223 #endif // __AKNQUERYVALUETIME_H__