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@4
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@4
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.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 |
// AknQueryValueNumber.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(__AKNQUERYVALUENUMBER_H__)
|
williamr@2
|
24 |
#define __AKNQUERYVALUENUMBER_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 CAknQueryValueNumberArray;
|
williamr@2
|
31 |
|
williamr@2
|
32 |
/**
|
williamr@2
|
33 |
* Encapsulates a TInt. Provides an interface to create a dialog
|
williamr@2
|
34 |
* containing a number 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(CAknQueryValueNumber) : public CAknQueryValue
|
williamr@2
|
39 |
{
|
williamr@2
|
40 |
public:
|
williamr@2
|
41 |
/**
|
williamr@2
|
42 |
* First stage of two stage construction.
|
williamr@2
|
43 |
*
|
williamr@2
|
44 |
*/
|
williamr@2
|
45 |
IMPORT_C static CAknQueryValueNumber* NewL();
|
williamr@2
|
46 |
|
williamr@2
|
47 |
/**
|
williamr@2
|
48 |
* First stage of two stage construction.
|
williamr@2
|
49 |
*
|
williamr@2
|
50 |
*/
|
williamr@2
|
51 |
IMPORT_C static CAknQueryValueNumber* NewLC();
|
williamr@2
|
52 |
|
williamr@2
|
53 |
IMPORT_C virtual ~CAknQueryValueNumber();
|
williamr@2
|
54 |
|
williamr@2
|
55 |
/**
|
williamr@2
|
56 |
* Set the array.
|
williamr@2
|
57 |
*
|
williamr@2
|
58 |
* @param aArray pointer to array, ownership is not passed
|
williamr@2
|
59 |
*/
|
williamr@2
|
60 |
IMPORT_C void SetArrayL(const CAknQueryValueNumberArray* aArray);
|
williamr@2
|
61 |
|
williamr@2
|
62 |
/**
|
williamr@2
|
63 |
* Set the string used for the query caption to be a string other than the default.
|
williamr@2
|
64 |
*
|
williamr@2
|
65 |
* @param aResourceId resource id of string to use for caption.
|
williamr@2
|
66 |
*
|
williamr@2
|
67 |
*/
|
williamr@2
|
68 |
IMPORT_C void SetQueryCaption(TInt aResourceId);
|
williamr@2
|
69 |
|
williamr@2
|
70 |
/**
|
williamr@2
|
71 |
* Return the current value, which may have been set by the user
|
williamr@2
|
72 |
*
|
williamr@2
|
73 |
* @return The current value
|
williamr@2
|
74 |
*
|
williamr@2
|
75 |
*/
|
williamr@2
|
76 |
IMPORT_C TInt Value() const;
|
williamr@2
|
77 |
|
williamr@2
|
78 |
public: // from MAknQueryValue
|
williamr@2
|
79 |
IMPORT_C virtual const MDesCArray* MdcArray() const;
|
williamr@2
|
80 |
IMPORT_C virtual HBufC* CurrentValueTextLC();
|
williamr@2
|
81 |
IMPORT_C virtual TInt CurrentValueIndex() const;
|
williamr@2
|
82 |
IMPORT_C virtual void SetCurrentValueIndex(const TInt aIndex);
|
williamr@2
|
83 |
IMPORT_C virtual TBool CreateEditorL();
|
williamr@2
|
84 |
|
williamr@2
|
85 |
protected:
|
williamr@2
|
86 |
CAknQueryValueNumber();
|
williamr@2
|
87 |
|
williamr@2
|
88 |
/**
|
williamr@2
|
89 |
* 2nd stage construction.
|
williamr@2
|
90 |
*
|
williamr@2
|
91 |
*/
|
williamr@2
|
92 |
void ConstructL();
|
williamr@2
|
93 |
|
williamr@2
|
94 |
/**
|
williamr@2
|
95 |
* Search for the current value in the list, and set the curent index
|
williamr@2
|
96 |
* to be the found index. If not found, set current index to 1 after the size of the array.
|
williamr@2
|
97 |
*
|
williamr@2
|
98 |
*/
|
williamr@2
|
99 |
void CalculateCurrentIndex();
|
williamr@2
|
100 |
virtual void AppendValueIfNewL();
|
williamr@2
|
101 |
private: // from MAknQueryValue
|
williamr@2
|
102 |
IMPORT_C void Reserved_MAknQueryValue();
|
williamr@2
|
103 |
private:
|
williamr@2
|
104 |
// the following are member variables
|
williamr@2
|
105 |
TInt iQueryCaptionId;
|
williamr@2
|
106 |
TInt iNumber;
|
williamr@2
|
107 |
TInt iCurrentIndex;
|
williamr@2
|
108 |
// the following are not owned
|
williamr@2
|
109 |
const CAknQueryValueNumberArray* iArray;
|
williamr@2
|
110 |
};
|
williamr@2
|
111 |
|
williamr@2
|
112 |
|
williamr@2
|
113 |
/**
|
williamr@2
|
114 |
* Wraps an array of numeric values, adapts it into a descriptor array.
|
williamr@2
|
115 |
*
|
williamr@2
|
116 |
*/
|
williamr@2
|
117 |
NONSHARABLE_CLASS(CAknQueryValueNumberArray) : public CBase, public MDesCArray
|
williamr@2
|
118 |
{
|
williamr@2
|
119 |
public:
|
williamr@2
|
120 |
/**
|
williamr@2
|
121 |
* Typedef for array containing TInt items
|
williamr@2
|
122 |
*
|
williamr@2
|
123 |
*/
|
williamr@2
|
124 |
typedef CArrayFix<TInt> NumberArray;
|
williamr@2
|
125 |
enum {KSafeSizeOfDescriptorForNumberFormat = 32};
|
williamr@2
|
126 |
public:
|
williamr@2
|
127 |
|
williamr@2
|
128 |
/**
|
williamr@2
|
129 |
* Two-phased constructor..
|
williamr@2
|
130 |
*
|
williamr@2
|
131 |
* @param aResourceId Recource id of a TBUF containing a number format string. Client
|
williamr@2
|
132 |
* can use R_AVKON_TBUF_POPUP_FIELD_DEFAULT_NUMBER_FORMAT
|
williamr@2
|
133 |
* if desired, or provide its own resource.
|
williamr@2
|
134 |
*/
|
williamr@2
|
135 |
IMPORT_C static CAknQueryValueNumberArray* NewL(TInt aResourceId);
|
williamr@2
|
136 |
|
williamr@2
|
137 |
/**
|
williamr@2
|
138 |
* See NewL
|
williamr@2
|
139 |
*
|
williamr@2
|
140 |
*/
|
williamr@2
|
141 |
IMPORT_C static CAknQueryValueNumberArray* NewLC(TInt aResourceId);
|
williamr@2
|
142 |
|
williamr@2
|
143 |
IMPORT_C ~CAknQueryValueNumberArray();
|
williamr@2
|
144 |
|
williamr@2
|
145 |
/**
|
williamr@2
|
146 |
* Set the array of values.
|
williamr@2
|
147 |
* Note that client can use any implementation of array class, but must pass in a
|
williamr@2
|
148 |
* TArray generated from it (by calling the Array() method on the array class)
|
williamr@2
|
149 |
*
|
williamr@2
|
150 |
* @param aArray array of values, ownership is not passed
|
williamr@2
|
151 |
*/
|
williamr@2
|
152 |
IMPORT_C void SetArray(NumberArray& aArray);
|
williamr@2
|
153 |
|
williamr@2
|
154 |
/**
|
williamr@2
|
155 |
* Get the array of values as a TArray.
|
williamr@2
|
156 |
* Note that client can use any implementation of array class, but the array is
|
williamr@2
|
157 |
* treated as a TArray.
|
williamr@2
|
158 |
*
|
williamr@2
|
159 |
* @return array of values, ownership is not passed
|
williamr@2
|
160 |
*/
|
williamr@2
|
161 |
IMPORT_C NumberArray* Array() const;
|
williamr@2
|
162 |
|
williamr@2
|
163 |
/**
|
williamr@2
|
164 |
* Return the TTime format string that is used to generate MDesCArray values
|
williamr@2
|
165 |
*
|
williamr@2
|
166 |
* @return format string
|
williamr@2
|
167 |
*/
|
williamr@2
|
168 |
IMPORT_C const HBufC* FormatString() const;
|
williamr@2
|
169 |
|
williamr@2
|
170 |
/**
|
williamr@2
|
171 |
* Return the size of a maximal time string formated using the format string
|
williamr@2
|
172 |
* that was supplied during construction of this instance.
|
williamr@2
|
173 |
* Two versions to eliminate compiler warnings.
|
williamr@2
|
174 |
*
|
williamr@2
|
175 |
* @return length of formatted string.
|
williamr@2
|
176 |
*/
|
williamr@2
|
177 |
#ifdef __WINS__
|
williamr@2
|
178 |
IMPORT_C const TInt FormattedStringSize() const;
|
williamr@2
|
179 |
#else
|
williamr@2
|
180 |
IMPORT_C TInt FormattedStringSize() const;
|
williamr@2
|
181 |
#endif // __WINS__
|
williamr@2
|
182 |
|
williamr@2
|
183 |
public:
|
williamr@2
|
184 |
// from MDesCArray
|
williamr@2
|
185 |
/**
|
williamr@2
|
186 |
* @return count of contained array
|
williamr@2
|
187 |
*
|
williamr@2
|
188 |
*/
|
williamr@2
|
189 |
IMPORT_C virtual TInt MdcaCount() const;
|
williamr@2
|
190 |
|
williamr@2
|
191 |
/**
|
williamr@2
|
192 |
* Returns array element, converting value to text.
|
williamr@2
|
193 |
* <p> WARNING: the returned pointer is only valid until the next time this
|
williamr@2
|
194 |
* method is invoked.
|
williamr@2
|
195 |
*
|
williamr@2
|
196 |
* @param aIndex index of element to return
|
williamr@2
|
197 |
* @return descriptor representing array element, ownership is not passed
|
williamr@2
|
198 |
*/
|
williamr@2
|
199 |
IMPORT_C virtual TPtrC MdcaPoint(TInt aIndex) const;
|
williamr@2
|
200 |
protected:
|
williamr@2
|
201 |
CAknQueryValueNumberArray();
|
williamr@2
|
202 |
|
williamr@2
|
203 |
/**
|
williamr@2
|
204 |
* ConstructL
|
williamr@2
|
205 |
*
|
williamr@2
|
206 |
* @param aResourceId id of a resource containing a time format string
|
williamr@2
|
207 |
*/
|
williamr@2
|
208 |
void ConstructL(TInt aResourceId);
|
williamr@2
|
209 |
private:
|
williamr@2
|
210 |
// the following members are owned
|
williamr@2
|
211 |
HBufC* iLastGeneratedTextValue;
|
williamr@2
|
212 |
HBufC* iFormatString;
|
williamr@2
|
213 |
// the following members are not owned
|
williamr@2
|
214 |
NumberArray* iArray;
|
williamr@2
|
215 |
TInt iFormattedStringSize;
|
williamr@2
|
216 |
};
|
williamr@2
|
217 |
|
williamr@2
|
218 |
|
williamr@2
|
219 |
#endif // __AKNQUERYVALUENUMBER_H__
|
williamr@2
|
220 |
|