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 // AknQueryValueDate.h
20 // Copyright (c) 2001 Symbian Ltd. All rights reserved.
23 #if !defined(__AKNQUERYVALUEDATE_H__)
24 #define __AKNQUERYVALUEDATE_H__
28 #include "AknQueryValue.h"
30 class CAknQueryValueDateArray;
33 * Encapsulates a date 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(CAknQueryValueDate) : public CAknQueryValue
42 * Two-phased constructor.
45 IMPORT_C static CAknQueryValueDate* NewL();
48 * Two-phased constructor.
51 IMPORT_C static CAknQueryValueDate* NewLC();
57 IMPORT_C virtual ~CAknQueryValueDate();
62 * @param aArray pointer to array, ownership is not passed
64 IMPORT_C void SetArrayL(const CAknQueryValueDateArray* aArray);
67 * Set the string used for the query caption to be a string other than the default.
69 * @param aResourceId resource id of string to use for caption.
72 IMPORT_C void SetQueryCaption(TInt aResourceId);
75 * Return the current value, which may have been set by the user
78 IMPORT_C TTime Value() const;
80 public: // from MAknQueryValue
81 IMPORT_C virtual const MDesCArray* MdcArray() const;
82 IMPORT_C virtual HBufC* CurrentValueTextLC();
83 IMPORT_C virtual TInt CurrentValueIndex() const;
84 IMPORT_C virtual void SetCurrentValueIndex(const TInt aIndex);
85 IMPORT_C virtual TBool CreateEditorL();
91 * 2nd stage construction.
97 * Search for the current time in the list, and set the current index
98 * to be the found index. If not found, set current index to 1 after the size of the array.
101 void CalculateCurrentIndex();
103 virtual void AppendValueIfNewL();
105 private: // from MAknQueryValue
106 IMPORT_C void Reserved_MAknQueryValue();
109 // the following are member variables
110 TInt iQueryCaptionId;
113 // the following are not owned
114 const CAknQueryValueDateArray* iArray;
119 * Wraps an array of dates, adapts it into a descriptor array.
122 NONSHARABLE_CLASS(CAknQueryValueDateArray) : public CBase, public MDesCArray
126 * Typedef for array containing TTime items
129 typedef CArrayFix<TTime> TimeArray;
132 enum {KSafeSizeOfDescriptorForTTimeFormat = 128};
136 * Two-phased constructor.
139 IMPORT_C static CAknQueryValueDateArray* NewL(TInt aResourceId);
142 * Two-phased constructor.
145 IMPORT_C static CAknQueryValueDateArray* NewLC(TInt aResourceId);
147 IMPORT_C ~CAknQueryValueDateArray();
150 * Set the array of values.
151 * Note that client can use any implementation of array class, but must pass in a
152 * TArray generated from it (by calling the Array() method on the array class)
154 * @param aArray array of values, ownership is not passed
156 IMPORT_C void SetArray(TimeArray& aArray);
159 * Get the array of values as a TArray.
160 * Note that client can use any implementation of array class, but the array is
161 * treated as a TArray.
163 * @return array of values, ownership is not passed
165 IMPORT_C TimeArray* Array() const;
168 * Return the TTime format string that is used to generate MDesCArray values
170 * @return format string
172 IMPORT_C const HBufC* FormatString() const;
176 * Return the size of a maximal time string formated using the format string
177 * that was supplied during construction of this instance.
178 * Two versions to eliminate compiler warnings.
180 * @return length of formatted string.
182 IMPORT_C const TInt FormattedStringSize() const;
185 * See const TInt FormattedStringSize() const;
188 IMPORT_C TInt FormattedStringSize() 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 of element to return
205 * @return descriptor representing array element, ownership is not passed
207 IMPORT_C virtual TPtrC MdcaPoint(TInt aIndex) const;
210 CAknQueryValueDateArray();
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
224 TInt iFormattedStringSize;
227 #endif // __AKNQUERYVALUEDATE_H__