|
1 /* |
|
2 * Copyright (c) 2008 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: Pop-up Textbox dialog implementation for S60 |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMIDTEXTBOXQUERYDIALOG_H |
|
20 #define CMIDTEXTBOXQUERYDIALOG_H |
|
21 |
|
22 // INCLUDES |
|
23 |
|
24 #include <lcdui.h> |
|
25 #include <AknQueryDialog.h> |
|
26 #include "CMIDDisplayable.h" |
|
27 |
|
28 #include <eikedwob.h> |
|
29 // for MCoeCaptionRetrieverForFep |
|
30 #include <fepbase.h> |
|
31 |
|
32 #include "CMIDEdwinUtils.h" |
|
33 |
|
34 // CLASS DECLARATION |
|
35 NONSHARABLE_CLASS(CMIDTextBoxQueryDialog) |
|
36 : public CAknTextQueryDialog, MMIDTextBox, public MMIDCommandObserver, |
|
37 public MEikEdwinObserver, public MCoeCaptionRetrieverForFep |
|
38 { |
|
39 |
|
40 public: |
|
41 static CMIDTextBoxQueryDialog* NewLC(TInt aConstraints, |
|
42 TDes& aResult, |
|
43 TInt aMaxSize, |
|
44 CMIDDisplayable* aDisplayable, |
|
45 const TDesC& aText); |
|
46 ~CMIDTextBoxQueryDialog(); |
|
47 |
|
48 private: |
|
49 void ConstructL(TInt aConstraints, |
|
50 TInt aMaxSize, |
|
51 CMIDDisplayable* aDisplayable, |
|
52 const TDesC& aText); |
|
53 |
|
54 CMIDTextBoxQueryDialog(TDes& aResult); |
|
55 |
|
56 public: |
|
57 // |
|
58 //From CAknTextQueryDialog |
|
59 // |
|
60 TInt RouseSleepingDialog(); |
|
61 void ExitSleepingDialog(); |
|
62 void TryExitL(TInt aButtonId); |
|
63 |
|
64 // |
|
65 // From MMIDCommandObserver |
|
66 // |
|
67 TBool ProcessCommandL(CMIDCommand* aCommand); |
|
68 |
|
69 // |
|
70 // From MMIDTextBox |
|
71 // |
|
72 /** |
|
73 * Deletes editor's text. |
|
74 * |
|
75 * @param aOffset the beginning of the region to be deleted |
|
76 * @param aLength the number of characters to be deleted |
|
77 * |
|
78 * @since S60 5.0 |
|
79 */ |
|
80 void DeleteTextL(TInt aOffset,TInt aLength); |
|
81 |
|
82 /** |
|
83 * Sets the contents of the editor in dialog, replacing the previous contents. |
|
84 * |
|
85 * @param aText the new value of the editor |
|
86 * |
|
87 * @since S60 5.0 |
|
88 */ |
|
89 void SetTextL(const TDesC& aText); |
|
90 |
|
91 /** |
|
92 * Inserts a string into the contents of the editor. |
|
93 * |
|
94 * @param aText the text to be inserted in the editor |
|
95 * @param aPosition the position at which insertion is to occur |
|
96 * |
|
97 * @since S60 5.0 |
|
98 */ |
|
99 void InsertTextL(const TDesC& aText,TInt aPosition); |
|
100 |
|
101 /** |
|
102 * Sets constraints for the text editor |
|
103 * |
|
104 * @param aConstraints new input constraints |
|
105 */ |
|
106 void SetConstraintsL(TUint aConstraints); |
|
107 |
|
108 /** |
|
109 * Sets the maximum size (number of characters) that can be contained in editor. |
|
110 * |
|
111 * @param aSize the new maximum size |
|
112 * |
|
113 * @return TInt Indicates assigned maximum capacity - may be smaller than requested. |
|
114 * |
|
115 * @since S60 5.0 |
|
116 */ |
|
117 TInt SetMaxSizeL(TInt aSize); |
|
118 |
|
119 /** |
|
120 * Returns the maximum size (number of characters) that can be stored in editor. |
|
121 * |
|
122 * @return TInt the maximum size in characters |
|
123 * |
|
124 * @since S60 5.0 |
|
125 */ |
|
126 TInt GetMaxSize(); |
|
127 |
|
128 /** |
|
129 * Gets the number of characters that are currently stored in editor. |
|
130 * |
|
131 * @return TInt the number of characters |
|
132 * |
|
133 * @since S60 5.0 |
|
134 */ |
|
135 TInt Size(); |
|
136 |
|
137 /** |
|
138 * Gets the current input position of the editor. |
|
139 * |
|
140 * @return TInt the current caret position, 0 if at the beginning |
|
141 * |
|
142 * @since S60 5.0 |
|
143 */ |
|
144 TInt GetCaretPosition(); |
|
145 |
|
146 /** |
|
147 * Gets a new buffer containing a copy of the whole text of the editor. |
|
148 * Note: Caller is responsible of deleting the buffer. |
|
149 * |
|
150 * @return HBufC* A new copy of the text. |
|
151 * |
|
152 * @since S60 5.0 |
|
153 */ |
|
154 HBufC* GetTextL(); |
|
155 |
|
156 /** |
|
157 * Sets initial input mode for the editor. |
|
158 * |
|
159 * @param aCharacterSubset a string naming a Unicode character subset |
|
160 * |
|
161 * @since S60 5.0 |
|
162 */ |
|
163 void SetInitialInputModeL(const TDesC& aCharacterSubset); |
|
164 |
|
165 /** |
|
166 * Sets prompt (title) for dialog. Accepts null, which indicates empty string. |
|
167 * |
|
168 * @param aString new title |
|
169 * |
|
170 * @since S60 5.0 |
|
171 */ |
|
172 void SetTitleL(const TDesC* aString); |
|
173 |
|
174 /** |
|
175 * Moves cursor position of the editor. |
|
176 * |
|
177 * @param aString new position, if bigger than editor max size then |
|
178 * cursor is set at the end of the editor. |
|
179 * |
|
180 * @since S60 5.0 |
|
181 */ |
|
182 void SetCursorPositionL(TInt aPosition); |
|
183 |
|
184 /** |
|
185 * Size of the dialog. |
|
186 * |
|
187 * @return TSize Size of the dialog. |
|
188 * |
|
189 * @since S60 5.0 |
|
190 */ |
|
191 TSize ContentSize() const; |
|
192 |
|
193 // From MMIDComponent |
|
194 // |
|
195 inline void Dispose(); |
|
196 |
|
197 // |
|
198 // From CCoeControl |
|
199 void FocusChanged(TDrawNow aDrawNow); |
|
200 void MakeVisible(TBool aVisible); |
|
201 void SizeChanged(); |
|
202 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
203 #ifdef RD_SCALABLE_UI_V2 |
|
204 void HandlePointerEventL(const TPointerEvent &aPointerEvent); |
|
205 #endif // RD_SCALABLE_UI_V2 |
|
206 TCoeInputCapabilities InputCapabilities() const; |
|
207 |
|
208 // From MEikEdwinObserver |
|
209 void HandleEdwinEventL(CEikEdwin* aEdwin, TEdwinEvent aEventType); |
|
210 |
|
211 // From MCoeCaptionRetrieverForFep |
|
212 void GetCaptionForFep(TDes& aCaption) const; |
|
213 |
|
214 /** |
|
215 * Set text input modifiers according to TextBox constraints. |
|
216 * |
|
217 * @since S60 5.0 |
|
218 */ |
|
219 void ProcessModifiers(); |
|
220 |
|
221 /** |
|
222 * Either makes dialog visible or hides the dialog. |
|
223 * |
|
224 * @param TBool Show or hide the dialog. |
|
225 * |
|
226 * @since S60 5.0 |
|
227 */ |
|
228 void ShowL(TBool aShow); |
|
229 |
|
230 /** |
|
231 * Tries to add replace text in editor when conmstraints have been changed. |
|
232 * Should be called after changing constraints. |
|
233 * |
|
234 * @param TBool Show or hide the dialog. |
|
235 * |
|
236 * @since S60 5.0 |
|
237 */ |
|
238 void SetTextWithNewConstraintsL(HBufC* aText); |
|
239 |
|
240 /** |
|
241 * Initializes the editor |
|
242 * |
|
243 * @since S60 5.0 |
|
244 */ |
|
245 void SetEditorL(); |
|
246 |
|
247 /** |
|
248 * Returns TextBox current intput constraints |
|
249 * |
|
250 * @param TInt input constraints |
|
251 * |
|
252 * @since S60 5.0 |
|
253 */ |
|
254 TInt Constraints(); |
|
255 |
|
256 /** |
|
257 * Returns whether dialog is currently visible on the display |
|
258 * |
|
259 * @param TBool iShowing |
|
260 * |
|
261 * @since S60 5.0 |
|
262 */ |
|
263 TBool Showing(); |
|
264 |
|
265 protected: |
|
266 // |
|
267 //From CAknTextQueryDialog |
|
268 // |
|
269 void UpdateLeftSoftKeyL(); |
|
270 TBool OkToExitL(TInt aButtonId); |
|
271 |
|
272 private: |
|
273 /** |
|
274 * Sets the input constraints of the editor. |
|
275 * |
|
276 * @since S60 5.0 |
|
277 */ |
|
278 void SetFEPModeAndCharFormat(); |
|
279 |
|
280 void UpdateCbasL(); |
|
281 |
|
282 TBool IsNumberConversionNeeded(); |
|
283 |
|
284 void HandleMinusCharEventL(MEikEdwinObserver::TEdwinEvent aEventType); |
|
285 TPtrC Read() const; |
|
286 |
|
287 void CreateNonMidletCommandsL(); |
|
288 void AddCommandToArrayL(RPointerArray<MMIDCommand>& aArray, |
|
289 TInt aCommandResIdShort, TInt aCommandResIdLong, TInt aCommandId); |
|
290 void AddCommandToArrayL(RPointerArray<MMIDCommand>& aArray, |
|
291 TInt aCommandResId, TInt aCommandId); |
|
292 void RemoveNonMidletCommands(); |
|
293 void AddCommandsToEdwinL(RPointerArray<MMIDCommand>& aArray); |
|
294 void CreatePhoneCallL(); |
|
295 |
|
296 void CreatePasswordTextL(); |
|
297 |
|
298 /** |
|
299 * Updates editor's input mode. Must be called after changing input modes |
|
300 * and after the dialog is set visible. |
|
301 * |
|
302 * @since S60 5.0 |
|
303 */ |
|
304 void UpdateInitialInputModes(); |
|
305 |
|
306 TTypeUid::Ptr MopSupplyObject(TTypeUid aId); |
|
307 |
|
308 private: |
|
309 inline TUint GetConstraints() const; |
|
310 inline TBool IsConstraintSet(TUint aConstraints); |
|
311 |
|
312 private: |
|
313 /** |
|
314 * Pointer to CMIDEdwinUtils |
|
315 */ |
|
316 CMIDEdwinUtils* iEdwinUtils; |
|
317 |
|
318 /** |
|
319 * Pointer to the editor |
|
320 */ |
|
321 CEikEdwin* iEditor; |
|
322 |
|
323 /** |
|
324 * Boolean value indicating whether the dialog is currently visible or not. |
|
325 */ |
|
326 TBool iShowing; |
|
327 |
|
328 /** |
|
329 * Maximum size (number of characters) of the editor. |
|
330 */ |
|
331 TInt iMaxSize; |
|
332 |
|
333 /** |
|
334 * Text input constraints |
|
335 */ |
|
336 TUint iConstraints; |
|
337 |
|
338 /** |
|
339 * Pointer to Displayable |
|
340 */ |
|
341 CMIDDisplayable* iDisplayable; |
|
342 |
|
343 /** |
|
344 * Text case (abc/ABC/etc.) to be set when coming visible |
|
345 */ |
|
346 TInt iInitialCurrentCase; |
|
347 |
|
348 /** |
|
349 * Input mode (text/numeric) to be set when coming visible |
|
350 */ |
|
351 TInt iInitialCurrentInputMode; |
|
352 |
|
353 /** |
|
354 * Input mode language to be set when coming visible |
|
355 */ |
|
356 TLanguage iInitialCurrentLanguage; |
|
357 |
|
358 /** |
|
359 * Stores keycode of the current key; used in multitap transaction exceeding editor limit. |
|
360 */ |
|
361 TInt iThisMultitapKey; |
|
362 |
|
363 /** |
|
364 * stores keycode of the last key; used in multitap transaction exceeding editor limit |
|
365 */ |
|
366 TInt iLastMultitapKey; |
|
367 |
|
368 /** |
|
369 * Decimal separator character based on locale |
|
370 */ |
|
371 TChar iDecimalSeparator; |
|
372 |
|
373 /** |
|
374 * Needed when accessing to phonebook |
|
375 */ |
|
376 CMIDAiwPbk2Client* iAiwPbkClient; |
|
377 |
|
378 /** |
|
379 * Boolean value indicating whether key events are pending. |
|
380 */ |
|
381 TBool iKeyEventsPending; |
|
382 |
|
383 /** |
|
384 * Used key event |
|
385 */ |
|
386 const TKeyEvent* iusedKeyEvent; |
|
387 }; |
|
388 |
|
389 |
|
390 inline void CMIDTextBoxQueryDialog::Dispose() |
|
391 { |
|
392 delete this; |
|
393 } |
|
394 |
|
395 inline TUint CMIDTextBoxQueryDialog::GetConstraints() const |
|
396 { |
|
397 return iConstraints; |
|
398 } |
|
399 |
|
400 inline TBool CMIDTextBoxQueryDialog::IsConstraintSet(TUint aConstraints) |
|
401 { |
|
402 return (iConstraints & MMIDTextField::EConstraintMask) == aConstraints ; |
|
403 } |
|
404 #endif // CMIDTEXTBOXQUERYDIALOG_H |