williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@2
|
5 |
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@2
|
7 |
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description:
|
williamr@2
|
15 |
*
|
williamr@2
|
16 |
*/
|
williamr@2
|
17 |
|
williamr@2
|
18 |
// AknQueryValueDuration.h
|
williamr@2
|
19 |
//
|
williamr@2
|
20 |
// Copyright (c) 2001 Symbian Ltd. All rights reserved.
|
williamr@2
|
21 |
//
|
williamr@2
|
22 |
|
williamr@2
|
23 |
#if !defined(__AKNQUERYVALUEDURATION_H__)
|
williamr@2
|
24 |
#define __AKNQUERYVALUEDURATION_H__
|
williamr@2
|
25 |
|
williamr@2
|
26 |
#include <bamdesca.h>
|
williamr@2
|
27 |
#include <eikdialg.h>
|
williamr@2
|
28 |
#include "AknQueryValue.h"
|
williamr@2
|
29 |
|
williamr@2
|
30 |
class CAknQueryValueDurationArray;
|
williamr@2
|
31 |
|
williamr@2
|
32 |
/**
|
williamr@2
|
33 |
* Encapsulates a TTimeIntervalSeconds. Provides an interface to create a dialog
|
williamr@2
|
34 |
* containing a duration query control, which will edit the value. Optionally
|
williamr@2
|
35 |
* allows the value to be changed by selecting from a list of values.
|
williamr@2
|
36 |
*
|
williamr@2
|
37 |
*/
|
williamr@2
|
38 |
NONSHARABLE_CLASS(CAknQueryValueDuration) : public CAknQueryValue
|
williamr@2
|
39 |
{
|
williamr@2
|
40 |
public:
|
williamr@2
|
41 |
/**
|
williamr@2
|
42 |
* Two-phased constructor.
|
williamr@2
|
43 |
*
|
williamr@2
|
44 |
*/
|
williamr@2
|
45 |
IMPORT_C static CAknQueryValueDuration* NewL();
|
williamr@2
|
46 |
|
williamr@2
|
47 |
/**
|
williamr@2
|
48 |
* Two-phased constructor.
|
williamr@2
|
49 |
*
|
williamr@2
|
50 |
*/
|
williamr@2
|
51 |
IMPORT_C static CAknQueryValueDuration* NewLC();
|
williamr@2
|
52 |
IMPORT_C virtual ~CAknQueryValueDuration();
|
williamr@2
|
53 |
|
williamr@2
|
54 |
/**
|
williamr@2
|
55 |
* Set the array.
|
williamr@2
|
56 |
*
|
williamr@2
|
57 |
* @param aArray pointer to array, ownership is not passed
|
williamr@2
|
58 |
*/
|
williamr@2
|
59 |
IMPORT_C void SetArrayL(const CAknQueryValueDurationArray* aArray);
|
williamr@2
|
60 |
|
williamr@2
|
61 |
/**
|
williamr@2
|
62 |
* Set the string used for the query caption to be a string other than the default.
|
williamr@2
|
63 |
*
|
williamr@2
|
64 |
* @param aResourceId resource id of string to use for caption.
|
williamr@2
|
65 |
*
|
williamr@2
|
66 |
*/
|
williamr@2
|
67 |
IMPORT_C void SetQueryCaption(TInt aResourceId);
|
williamr@2
|
68 |
|
williamr@2
|
69 |
/**
|
williamr@2
|
70 |
* Return the current value, which may have been set by the user
|
williamr@2
|
71 |
*
|
williamr@2
|
72 |
*/
|
williamr@2
|
73 |
IMPORT_C TTimeIntervalSeconds Value() const;
|
williamr@2
|
74 |
|
williamr@2
|
75 |
public: // from MAknQueryValue
|
williamr@2
|
76 |
IMPORT_C virtual const MDesCArray* MdcArray() const;
|
williamr@2
|
77 |
IMPORT_C virtual HBufC* CurrentValueTextLC();
|
williamr@2
|
78 |
IMPORT_C virtual TInt CurrentValueIndex() const;
|
williamr@2
|
79 |
IMPORT_C virtual void SetCurrentValueIndex(const TInt aIndex);
|
williamr@2
|
80 |
IMPORT_C virtual TBool CreateEditorL();
|
williamr@2
|
81 |
protected:
|
williamr@2
|
82 |
CAknQueryValueDuration();
|
williamr@2
|
83 |
|
williamr@2
|
84 |
/**
|
williamr@2
|
85 |
* 2nd stage construction.
|
williamr@2
|
86 |
*
|
williamr@2
|
87 |
*/
|
williamr@2
|
88 |
void ConstructL();
|
williamr@2
|
89 |
|
williamr@2
|
90 |
/**
|
williamr@2
|
91 |
* Search for the current value in the list, and set the curent index
|
williamr@2
|
92 |
* to be the found index. If not found, set current index to 1 after the size of the array.
|
williamr@2
|
93 |
*
|
williamr@2
|
94 |
*/
|
williamr@2
|
95 |
void CalculateCurrentIndex();
|
williamr@2
|
96 |
|
williamr@2
|
97 |
virtual void AppendValueIfNewL();
|
williamr@2
|
98 |
private: // from MAknQueryValue
|
williamr@2
|
99 |
IMPORT_C void Reserved_MAknQueryValue();
|
williamr@2
|
100 |
private:
|
williamr@2
|
101 |
// the following are member variables
|
williamr@2
|
102 |
TInt iQueryCaptionId;
|
williamr@2
|
103 |
TTimeIntervalSeconds iDuration;
|
williamr@2
|
104 |
TInt iCurrentIndex;
|
williamr@2
|
105 |
// the following are not owned
|
williamr@2
|
106 |
const CAknQueryValueDurationArray* iArray;
|
williamr@2
|
107 |
};
|
williamr@2
|
108 |
|
williamr@2
|
109 |
|
williamr@2
|
110 |
/**
|
williamr@2
|
111 |
* Wraps an array of numeric values, adapts it into a descriptor array.
|
williamr@2
|
112 |
*
|
williamr@2
|
113 |
*/
|
williamr@2
|
114 |
NONSHARABLE_CLASS(CAknQueryValueDurationArray) : public CBase, public MDesCArray
|
williamr@2
|
115 |
{
|
williamr@2
|
116 |
public:
|
williamr@2
|
117 |
/**
|
williamr@2
|
118 |
* Typedef for array containing TTimeIntervalSeconds items
|
williamr@2
|
119 |
*
|
williamr@2
|
120 |
*/
|
williamr@2
|
121 |
typedef CArrayFix<TTimeIntervalSeconds> DurationArray;
|
williamr@2
|
122 |
|
williamr@2
|
123 |
enum {KSafeSizeOfDescriptorForDurationFormat = 32};
|
williamr@2
|
124 |
|
williamr@2
|
125 |
public:
|
williamr@2
|
126 |
/**
|
williamr@2
|
127 |
* Two-phased constructor..
|
williamr@2
|
128 |
*
|
williamr@2
|
129 |
* @param aResourceId Recource id of a TBUF containing a duration format string. Client
|
williamr@2
|
130 |
* can use R_AVKON_TBUF_POPUP_FIELD_DEFAULT_DURATION_FORMAT
|
williamr@2
|
131 |
* if desired, or provide its own resource. (must be at least "%d%d%d")
|
williamr@2
|
132 |
*/
|
williamr@2
|
133 |
IMPORT_C static CAknQueryValueDurationArray* NewL(TInt aResourceId);
|
williamr@2
|
134 |
|
williamr@2
|
135 |
/**
|
williamr@2
|
136 |
* See NewL
|
williamr@2
|
137 |
*
|
williamr@2
|
138 |
*/
|
williamr@2
|
139 |
IMPORT_C static CAknQueryValueDurationArray* NewLC(TInt aResourceId);
|
williamr@2
|
140 |
|
williamr@2
|
141 |
IMPORT_C ~CAknQueryValueDurationArray();
|
williamr@2
|
142 |
|
williamr@2
|
143 |
/**
|
williamr@2
|
144 |
* Set the array of values.
|
williamr@2
|
145 |
* Note that client can use any implementation of array class, but must pass in a
|
williamr@2
|
146 |
* TArray generated from it (by calling the Array() method on the array class)
|
williamr@2
|
147 |
*
|
williamr@2
|
148 |
* @param aArray array of values, ownership is not passed
|
williamr@2
|
149 |
*/
|
williamr@2
|
150 |
IMPORT_C void SetArray(DurationArray& aArray);
|
williamr@2
|
151 |
|
williamr@2
|
152 |
/**
|
williamr@2
|
153 |
* Get the array of values as a TArray.
|
williamr@2
|
154 |
* Note that client can use any implementation of array class, but the array is
|
williamr@2
|
155 |
* treated as a TArray.
|
williamr@2
|
156 |
*
|
williamr@2
|
157 |
* @return array of values, ownership is not passed
|
williamr@2
|
158 |
*/
|
williamr@2
|
159 |
IMPORT_C DurationArray* Array() const;
|
williamr@2
|
160 |
|
williamr@2
|
161 |
/**
|
williamr@2
|
162 |
* Return the TTime format string that is used to generate MDesCArray values
|
williamr@2
|
163 |
*
|
williamr@2
|
164 |
* @return format string
|
williamr@2
|
165 |
*/
|
williamr@2
|
166 |
IMPORT_C const HBufC* FormatString() const;
|
williamr@2
|
167 |
|
williamr@2
|
168 |
/**
|
williamr@2
|
169 |
* Return the size of a maximal time string formated using the format string
|
williamr@2
|
170 |
* that was supplied during construction of this instance.
|
williamr@2
|
171 |
* Two versions to eliminate compiler warnings.
|
williamr@2
|
172 |
*
|
williamr@2
|
173 |
* @return length of formatted string.
|
williamr@2
|
174 |
*/
|
williamr@2
|
175 |
#ifdef __WINS__
|
williamr@2
|
176 |
IMPORT_C const TInt FormattedStringSize() const;
|
williamr@2
|
177 |
#else
|
williamr@2
|
178 |
IMPORT_C TInt FormattedStringSize() const;
|
williamr@2
|
179 |
#endif // __WINS__
|
williamr@2
|
180 |
|
williamr@2
|
181 |
/**
|
williamr@2
|
182 |
* Format a descriptor with the textual version of a duration, formated according to the format string.
|
williamr@2
|
183 |
* Number of hours is not bounded.
|
williamr@2
|
184 |
*
|
williamr@2
|
185 |
* @param aText descriptor to be filled, must be of sufficient size
|
williamr@2
|
186 |
* @param aDuration the interval to be formatted
|
williamr@2
|
187 |
*
|
williamr@2
|
188 |
*/
|
williamr@2
|
189 |
IMPORT_C void FormatDuration(TPtr& aText, TTimeIntervalSeconds aDuration) const;
|
williamr@2
|
190 |
|
williamr@2
|
191 |
public:
|
williamr@2
|
192 |
// from MDesCArray
|
williamr@2
|
193 |
/**
|
williamr@2
|
194 |
* @return count of contained array
|
williamr@2
|
195 |
*
|
williamr@2
|
196 |
*/
|
williamr@2
|
197 |
IMPORT_C virtual TInt MdcaCount() const;
|
williamr@2
|
198 |
|
williamr@2
|
199 |
/**
|
williamr@2
|
200 |
* Returns array element, converting value to text.
|
williamr@2
|
201 |
* <p> WARNING: the returned pointer is only valid until the next time this
|
williamr@2
|
202 |
* method is invoked.
|
williamr@2
|
203 |
*
|
williamr@2
|
204 |
* @param aIndex index of element to return
|
williamr@2
|
205 |
* @return descriptor representing array element, ownership is not passed
|
williamr@2
|
206 |
*/
|
williamr@2
|
207 |
IMPORT_C virtual TPtrC MdcaPoint(TInt aIndex) const;
|
williamr@2
|
208 |
|
williamr@2
|
209 |
protected:
|
williamr@2
|
210 |
CAknQueryValueDurationArray();
|
williamr@2
|
211 |
|
williamr@2
|
212 |
/**
|
williamr@2
|
213 |
* 2nd stage construction.
|
williamr@2
|
214 |
*
|
williamr@2
|
215 |
*/
|
williamr@2
|
216 |
void ConstructL(TInt aResourceId);
|
williamr@2
|
217 |
|
williamr@2
|
218 |
private:
|
williamr@2
|
219 |
// the following members are owned
|
williamr@2
|
220 |
HBufC* iLastGeneratedTextValue;
|
williamr@2
|
221 |
HBufC* iFormatString;
|
williamr@2
|
222 |
// the following members are not owned
|
williamr@2
|
223 |
DurationArray* iArray;
|
williamr@2
|
224 |
TInt iFormattedStringSize;
|
williamr@2
|
225 |
};
|
williamr@2
|
226 |
|
williamr@2
|
227 |
|
williamr@2
|
228 |
#endif // __AKNQUERYVALUEDURATION_H__
|
williamr@2
|
229 |
|