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