|
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 // AknQueryValueText.h |
|
19 // |
|
20 // Copyright (c) 2001 Symbian Ltd. All rights reserved. |
|
21 // |
|
22 |
|
23 #if !defined(__AKNQUERYVALUETEXT_H__) |
|
24 #define __AKNQUERYVALUETEXT_H__ |
|
25 |
|
26 #include <bamdesca.h> |
|
27 #include <eikdialg.h> |
|
28 #include "AknQueryValue.h" |
|
29 |
|
30 class CAknQueryValueTextArray; |
|
31 |
|
32 /** |
|
33 * Encapsulates a string. Provides an interface to create a dialog |
|
34 * containing a text 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(CAknQueryValueText) : public CAknQueryValue |
|
39 { |
|
40 public: |
|
41 /** |
|
42 * First stage of two stage construction. |
|
43 */ |
|
44 IMPORT_C static CAknQueryValueText* NewL(); |
|
45 |
|
46 /** |
|
47 * First stage of two stage construction. |
|
48 */ |
|
49 IMPORT_C static CAknQueryValueText* NewLC(); |
|
50 |
|
51 IMPORT_C virtual ~CAknQueryValueText(); |
|
52 |
|
53 /** |
|
54 * Set the array. |
|
55 * |
|
56 * @param aArray pointer to array, ownership is not passed |
|
57 */ |
|
58 IMPORT_C void SetArrayL(const CAknQueryValueTextArray* 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, ownership is not passed |
|
72 * |
|
73 */ |
|
74 IMPORT_C HBufC* 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 CAknQueryValueText(); |
|
85 |
|
86 /** |
|
87 * Two stage construction |
|
88 * |
|
89 */ |
|
90 void ConstructL(); |
|
91 |
|
92 /** |
|
93 * Search for the current value in the list, and set the current 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 /** |
|
100 * Append the current value if it is new |
|
101 * |
|
102 * |
|
103 */ |
|
104 virtual void AppendValueIfNewL(); |
|
105 |
|
106 private: // from MAknQueryValue |
|
107 IMPORT_C void Reserved_MAknQueryValue(); |
|
108 |
|
109 private: |
|
110 // the following are member variables |
|
111 TInt iQueryCaptionId; |
|
112 HBufC* iText; |
|
113 TInt iCurrentIndex; |
|
114 // the following are not owned |
|
115 const CAknQueryValueTextArray* iArray; |
|
116 }; |
|
117 |
|
118 |
|
119 /** |
|
120 * Wraps a descriptor array. |
|
121 * |
|
122 */ |
|
123 NONSHARABLE_CLASS(CAknQueryValueTextArray) : public CBase, public MDesCArray |
|
124 { |
|
125 public: |
|
126 /** |
|
127 * Typedef for array |
|
128 * |
|
129 */ |
|
130 typedef CDesCArray TextArray; |
|
131 |
|
132 enum {KSafeSizeOfDescriptorForTextFormat = 32}; |
|
133 |
|
134 public: |
|
135 /** |
|
136 * Two-phased constructor. |
|
137 * |
|
138 */ |
|
139 IMPORT_C static CAknQueryValueTextArray* NewL(); |
|
140 |
|
141 /** |
|
142 * Two-phased constructor. |
|
143 * |
|
144 */ |
|
145 IMPORT_C static CAknQueryValueTextArray* NewLC(); |
|
146 |
|
147 IMPORT_C ~CAknQueryValueTextArray(); |
|
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 passed |
|
155 */ |
|
156 IMPORT_C void SetArray(TextArray& 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 TextArray* Array() const; |
|
166 |
|
167 /** |
|
168 * Return the size of a maximal time string formated using the format string |
|
169 * that was supplied during construction of this instance. |
|
170 * Two versions to eliminate compiler warnings. |
|
171 * |
|
172 * @return length of formatted string. |
|
173 */ |
|
174 #ifdef __WINS__ |
|
175 IMPORT_C const TInt FormattedStringSize() const; |
|
176 #else |
|
177 IMPORT_C TInt FormattedStringSize() const; |
|
178 #endif // __WINS__ |
|
179 |
|
180 public: |
|
181 // from MDesCArray |
|
182 /** |
|
183 * @return count of contained array |
|
184 * |
|
185 */ |
|
186 IMPORT_C virtual TInt MdcaCount() const; |
|
187 |
|
188 /** |
|
189 * Returns array element, pass through to contained descriptor array |
|
190 * |
|
191 * @param aIndex index of element to return |
|
192 * @return descriptor representing array element, ownership is not passed |
|
193 */ |
|
194 IMPORT_C virtual TPtrC MdcaPoint(TInt aIndex) const; |
|
195 |
|
196 protected: |
|
197 CAknQueryValueTextArray(); |
|
198 |
|
199 /** |
|
200 * 2nd stage construction. |
|
201 * |
|
202 */ |
|
203 void ConstructL(); |
|
204 |
|
205 private: |
|
206 // the following members are not owned |
|
207 TextArray* iArray; |
|
208 TInt iFormattedStringSize; |
|
209 }; |
|
210 |
|
211 #endif // __AKNQUERYVALUETEXT_H__ |
|
212 |