|
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 // AknQueryValueDate.h |
|
19 // |
|
20 // Copyright (c) 2001 Symbian Ltd. All rights reserved. |
|
21 // |
|
22 |
|
23 #if !defined(__AKNQUERYVALUEDATE_H__) |
|
24 #define __AKNQUERYVALUEDATE_H__ |
|
25 |
|
26 #include <bamdesca.h> |
|
27 #include <eikdialg.h> |
|
28 #include "AknQueryValue.h" |
|
29 |
|
30 class CAknQueryValueDateArray; |
|
31 |
|
32 /** |
|
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. |
|
36 * |
|
37 */ |
|
38 NONSHARABLE_CLASS(CAknQueryValueDate) : public CAknQueryValue |
|
39 { |
|
40 public: |
|
41 /** |
|
42 * Two-phased constructor. |
|
43 * |
|
44 */ |
|
45 IMPORT_C static CAknQueryValueDate* NewL(); |
|
46 |
|
47 /** |
|
48 * Two-phased constructor. |
|
49 * |
|
50 */ |
|
51 IMPORT_C static CAknQueryValueDate* NewLC(); |
|
52 |
|
53 /** |
|
54 * destructor |
|
55 * |
|
56 */ |
|
57 IMPORT_C virtual ~CAknQueryValueDate(); |
|
58 |
|
59 /** |
|
60 * Set the array. |
|
61 * |
|
62 * @param aArray pointer to array, ownership is not passed |
|
63 */ |
|
64 IMPORT_C void SetArrayL(const CAknQueryValueDateArray* aArray); |
|
65 |
|
66 /** |
|
67 * Set the string used for the query caption to be a string other than the default. |
|
68 * |
|
69 * @param aResourceId resource id of string to use for caption. |
|
70 * |
|
71 */ |
|
72 IMPORT_C void SetQueryCaption(TInt aResourceId); |
|
73 |
|
74 /** |
|
75 * Return the current value, which may have been set by the user |
|
76 * |
|
77 */ |
|
78 IMPORT_C TTime Value() const; |
|
79 |
|
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(); |
|
86 |
|
87 protected: |
|
88 CAknQueryValueDate(); |
|
89 |
|
90 /** |
|
91 * 2nd stage construction. |
|
92 * |
|
93 */ |
|
94 void ConstructL(); |
|
95 |
|
96 /** |
|
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. |
|
99 * |
|
100 */ |
|
101 void CalculateCurrentIndex(); |
|
102 |
|
103 virtual void AppendValueIfNewL(); |
|
104 |
|
105 private: // from MAknQueryValue |
|
106 IMPORT_C void Reserved_MAknQueryValue(); |
|
107 |
|
108 private: |
|
109 // the following are member variables |
|
110 TInt iQueryCaptionId; |
|
111 TTime iTime; |
|
112 TInt iCurrentIndex; |
|
113 // the following are not owned |
|
114 const CAknQueryValueDateArray* iArray; |
|
115 }; |
|
116 |
|
117 |
|
118 /** |
|
119 * Wraps an array of dates, adapts it into a descriptor array. |
|
120 * |
|
121 */ |
|
122 NONSHARABLE_CLASS(CAknQueryValueDateArray) : public CBase, public MDesCArray |
|
123 { |
|
124 public: |
|
125 /** |
|
126 * Typedef for array containing TTime items |
|
127 * |
|
128 */ |
|
129 typedef CArrayFix<TTime> TimeArray; |
|
130 |
|
131 |
|
132 enum {KSafeSizeOfDescriptorForTTimeFormat = 128}; |
|
133 |
|
134 public: |
|
135 /** |
|
136 * Two-phased constructor. |
|
137 * |
|
138 */ |
|
139 IMPORT_C static CAknQueryValueDateArray* NewL(TInt aResourceId); |
|
140 |
|
141 /** |
|
142 * Two-phased constructor. |
|
143 * |
|
144 */ |
|
145 IMPORT_C static CAknQueryValueDateArray* NewLC(TInt aResourceId); |
|
146 |
|
147 IMPORT_C ~CAknQueryValueDateArray(); |
|
148 |
|
149 /** |
|
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) |
|
153 * |
|
154 * @param aArray array of values, ownership is not passed |
|
155 */ |
|
156 IMPORT_C void SetArray(TimeArray& aArray); |
|
157 |
|
158 /** |
|
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. |
|
162 * |
|
163 * @return array of values, ownership is not passed |
|
164 */ |
|
165 IMPORT_C TimeArray* Array() const; |
|
166 |
|
167 /** |
|
168 * Return the TTime format string that is used to generate MDesCArray values |
|
169 * |
|
170 * @return format string |
|
171 */ |
|
172 IMPORT_C const HBufC* FormatString() const; |
|
173 |
|
174 #ifdef __WINS__ |
|
175 /** |
|
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. |
|
179 * |
|
180 * @return length of formatted string. |
|
181 */ |
|
182 IMPORT_C const TInt FormattedStringSize() const; |
|
183 #else |
|
184 /** |
|
185 * See const TInt FormattedStringSize() const; |
|
186 * |
|
187 */ |
|
188 IMPORT_C TInt FormattedStringSize() const; |
|
189 #endif // __WINS__ |
|
190 |
|
191 public: |
|
192 // from MDesCArray |
|
193 /** |
|
194 * @return count of contained array |
|
195 * |
|
196 */ |
|
197 IMPORT_C virtual TInt MdcaCount() const; |
|
198 |
|
199 /** |
|
200 * Returns array element, converting value to text. |
|
201 * <p> WARNING: the returned pointer is only valid until the next time this |
|
202 * method is invoked. |
|
203 * |
|
204 * @param aIndex of element to return |
|
205 * @return descriptor representing array element, ownership is not passed |
|
206 */ |
|
207 IMPORT_C virtual TPtrC MdcaPoint(TInt aIndex) const; |
|
208 |
|
209 protected: |
|
210 CAknQueryValueDateArray(); |
|
211 |
|
212 /** |
|
213 * 2nd stage construction. |
|
214 * |
|
215 */ |
|
216 void ConstructL(TInt aResourceId); |
|
217 |
|
218 private: |
|
219 // the following members are owned |
|
220 HBufC* iLastGeneratedTextValue; |
|
221 HBufC* iFormatString; |
|
222 // the following members are not owned |
|
223 TimeArray* iArray; |
|
224 TInt iFormattedStringSize; |
|
225 }; |
|
226 |
|
227 #endif // __AKNQUERYVALUEDATE_H__ |
|
228 |