FreeCalypso > hg > tcs211-c139
comparison g23m/condat/ms/src/bmi/AUITextEntry.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /******************************************************************************* | |
2 | |
3 CONDAT (UK) | |
4 | |
5 ******************************************************************************** | |
6 | |
7 This software product is the property of Condat (UK) Ltd and may not be | |
8 disclosed to any third party without the express permission of the owner. | |
9 | |
10 ******************************************************************************** | |
11 | |
12 $Project name: Basic MMI | |
13 $Project code: BMI (6349) | |
14 $Module: MMI | |
15 $File: AUITextEntry.c | |
16 $Revision: 1.0 | |
17 | |
18 $Author: Condat(UK) | |
19 $Date: 22/02/01 | |
20 | |
21 ******************************************************************************** | |
22 | |
23 Description: | |
24 Multi-tap and other text entry methods for AUI Editor. | |
25 | |
26 | |
27 ******************************************************************************** | |
28 | |
29 $History: AUITextEntry.c | |
30 | |
31 31/01/02 Original Condat(UK) BMI version. | |
32 $End | |
33 | |
34 *******************************************************************************/ | |
35 | |
36 #define ENTITY_MFW | |
37 | |
38 /* includes */ | |
39 #include <string.h> | |
40 #include <stdio.h> | |
41 #include <stdlib.h> | |
42 | |
43 #if defined (NEW_FRAME) | |
44 | |
45 #include "typedefs.h" | |
46 #include "vsi.h" | |
47 #include "pei.h" | |
48 #include "custom.h" | |
49 #include "gsm.h" | |
50 | |
51 #else | |
52 | |
53 #include "STDDEFS.H" | |
54 #include "custom.h" | |
55 #include "gsm.h" | |
56 #include "vsi.h" | |
57 | |
58 #endif | |
59 | |
60 #include "mfw_mfw.h" | |
61 #include "mfw_win.h" | |
62 #include "mfw_kbd.h" | |
63 #include "mfw_tim.h" | |
64 #include "mfw_phb.h" | |
65 #include "mfw_sms.h" | |
66 #include "mfw_ss.h" | |
67 #include "mfw_icn.h" | |
68 #include "mfw_mnu.h" | |
69 #include "mfw_lng.h" | |
70 #include "mfw_sat.h" | |
71 #include "mfw_kbd.h" | |
72 #include "mfw_nm.h" | |
73 #include "mfw_cm.h" | |
74 #include "mfw_edt.h" | |
75 | |
76 #include "dspl.h" | |
77 | |
78 #include "ksd.h" | |
79 #include "psa.h" | |
80 | |
81 #include "MmiDummy.h" | |
82 #include "MmiMmi.h" | |
83 #include "MmiDialogs.h" | |
84 #include "MmiMain.h" | |
85 | |
86 #include "cus_aci.h" | |
87 #include "prim.h" | |
88 #ifndef PCM_2_FFS | |
89 #include "pcm.h" | |
90 #endif | |
91 | |
92 | |
93 #include "ATBCommon.h" | |
94 #include "ATBDisplay.h" | |
95 #include "ATBEditor.h" | |
96 #include "AUITextEntry.h" | |
97 | |
98 /******************************************************************************* | |
99 | |
100 STATIC DATA | |
101 | |
102 ********************************************************************************/ | |
103 /*SPR 2175, increased KEY_PAD_MAX and changed tables to allow entry of some | |
104 accented characters*/ | |
105 #define KEY_PAD_MAX 6 | |
106 | |
107 | |
108 /* API - 01/09/03 - SPR2371 - Move the new character to the end of the multitap sequence */ | |
109 /* Alpha mode characters for multi-tap - lower case */ | |
110 | |
111 static UBYTE editAlpha [12][KEY_PAD_MAX] = | |
112 { | |
113 {'.', ',', '+', '-', '=', '0'}, /*Key 0*/ | |
114 | |
115 {' ' ,'?', '!', ';', ':', '1'}, /*Key 1*/ | |
116 /* a grave a umlaut*/ | |
117 {'a', 'b', 'c', '2', '\x85', '\x84'}, /*Key 2*/ | |
118 /* e-grave e-acute*/ | |
119 {'d', 'e', 'f', '3', '\x8a', '\x83'}, /*Key 3*/ | |
120 /* i-grave*/ | |
121 {'g', 'h', 'i', '4', '\x8d', '@'}, /*Key 4*/ | |
122 /**/ | |
123 {'j', 'k', 'l', '5', '&', '*'}, /*Key 5*/ | |
124 /* o-grave o-umlaut*/ | |
125 {'m', 'n', 'o', '6', '\x95', '\x94'}, /*Key 6*/ | |
126 /* SS*/ | |
127 {'p', 'q', 'r', 's', '7', '\xe1'}, /*Key 7*/ | |
128 /* u-grave u-umlaut*/ | |
129 {'t', 'u', 'v', '8', '\x97', '\x82'}, /*Key 8*/ | |
130 /**/ | |
131 {'w', 'x', 'y', 'z', '9', '#'}, /*Key 9*/ | |
132 | |
133 {'*', '*', '*', '*', '*', '*'}, /*Key star, not actually used for multitap*/ | |
134 | |
135 {'#', '#', '#', '#', '#', '#'} /*Key hash, not actually used for multitap*/ | |
136 }; | |
137 | |
138 /* Alpha mode characters for multi-tap - upper case */ | |
139 | |
140 static UBYTE editAlphaU [12][KEY_PAD_MAX] = | |
141 { | |
142 {'.', ',', '+', '-', '=', '0'}, /*Key 0*/ | |
143 | |
144 {' ', '?', '!', ';', ':', '1'}, /*Key 1*/ | |
145 /* A-umlaut cedilla*/ | |
146 {'A', 'B', 'C', '2', '\x8e', '\x81'}, /*Key 2*/ | |
147 /* E-acute*/ | |
148 {'D', 'E', 'F', '3', '\x90', ' '}, /*Key 3*/ | |
149 | |
150 {'G', 'H', 'I', '4', '@', ' '}, /*Key 4*/ | |
151 | |
152 {'J', 'K', 'L', '5', '&', '*'}, /*Key 5*/ | |
153 /* O-umlaut */ | |
154 {'M', 'N', 'O', '6', '\x99', ' '}, /*Key 6*/ | |
155 /* SS*/ | |
156 {'P', 'Q', 'R', 'S', '7', '\xe1'}, /*Key 7*/ | |
157 /* U-umlaut*/ | |
158 {'T', 'U', 'V', '8', '\x9A', ' '}, /*Key 8*/ | |
159 | |
160 {'W', 'X', 'Y', 'Z', '9', '#'}, /*Key 9*/ | |
161 | |
162 {'*', '*', '*' ,'*', '*', '*'}, /*Key star, not actually used for multitap*/ | |
163 | |
164 {'#', '#', '#', '#', '#', '#'} /*Key hash, not actually used for multitap*/ | |
165 }; | |
166 | |
167 /* API - 01/09/03 - SPR2371 - END*/ | |
168 | |
169 static void *MMIdata; /* Temporary storage for MMI pointer */ | |
170 | |
171 /******************************************************************************* | |
172 | |
173 LOCAL FUNCTION PROTOTYPES | |
174 | |
175 ********************************************************************************/ | |
176 | |
177 static int AUI_entry_Timer (MfwEvt event, MfwTim *timer); | |
178 static USHORT AUI_entry_Keypress(T_AUI_ENTRY_DATA *entry_data, MfwEvt event, MfwKbd *key); | |
179 | |
180 /******************************************************************************* | |
181 | |
182 $Function: AUI_entry_Create | |
183 | |
184 $Description: Initialises the text entry data. Allocates memory. Creates the timer. | |
185 | |
186 $Returns: Pointer to the data. | |
187 | |
188 $Arguments: win - The window in which the editor is displayed | |
189 editor - The editor | |
190 update - The event to be sent to the window in order to update it | |
191 | |
192 *******************************************************************************/ | |
193 | |
194 T_AUI_ENTRY_DATA *AUI_entry_Create(T_MFW_HND win, T_ED_DATA *editor, U32 update) | |
195 { | |
196 T_AUI_ENTRY_DATA *entry_data = (T_AUI_ENTRY_DATA *)mfwAlloc(sizeof(T_AUI_ENTRY_DATA)); | |
197 | |
198 entry_data->win = win; | |
199 entry_data->update = update; | |
200 entry_data->editor = editor; | |
201 /* SPR#1597 - SH - Always create this timer */ | |
202 entry_data->editTim = tim_create(win, 1000, (MfwCb) AUI_entry_Timer); | |
203 entry_data->Level = KEY_PAD_MAX-1; | |
204 entry_data->Key = KCD_MAX; | |
205 | |
206 return entry_data; | |
207 } | |
208 | |
209 | |
210 /******************************************************************************* | |
211 | |
212 $Function: AUI_entry_Destroy | |
213 | |
214 $Description: Frees memory associated with text entry. | |
215 | |
216 $Returns: none. | |
217 | |
218 $Arguments: entry_data - The text entry data | |
219 | |
220 *******************************************************************************/ | |
221 | |
222 void AUI_entry_Destroy(T_AUI_ENTRY_DATA *entry_data) | |
223 { | |
224 if (entry_data->editTim) | |
225 { | |
226 timDelete(entry_data->editTim); | |
227 } | |
228 | |
229 mfwFree((void *)entry_data, sizeof(T_AUI_ENTRY_DATA)); | |
230 | |
231 return; | |
232 } | |
233 | |
234 /******************************************************************************* | |
235 | |
236 $Function: AUI_entry_EditChar | |
237 | |
238 $Description: Sends a character to the text editor. | |
239 | |
240 $Returns: None. | |
241 | |
242 $Arguments: data - The editor data | |
243 alphachar - Character to be inserted, or NULL if key tables are to | |
244 be used | |
245 multitap - TRUE if multitap is in progress | |
246 | |
247 *******************************************************************************/ | |
248 | |
249 USHORT AUI_entry_EditChar (T_AUI_ENTRY_DATA *entry_data, USHORT alphachar, BOOL multitap) | |
250 { | |
251 T_ED_DATA *editor = entry_data->editor; | |
252 | |
253 TRACE_FUNCTION("AUITextEntry: AUI_entry_EditChar()"); | |
254 | |
255 /* If character is not provided, get it from the key table */ | |
256 | |
257 if (alphachar==NULL) | |
258 { | |
259 alphachar = AUI_entry_GetKeyChar(entry_data, ATB_edit_GetCasePref(editor)); | |
260 | |
261 if (!(ATB_edit_Mode(entry_data->editor, ED_MODE_ALPHA) && entry_data->Key!=KCD_MAX)) | |
262 alphachar = UNICODE_SPACE; | |
263 } | |
264 | |
265 ATB_edit_MultiTap(editor, alphachar, multitap); | |
266 | |
267 return alphachar; | |
268 } | |
269 | |
270 | |
271 /******************************************************************************* | |
272 | |
273 $Function: AUI_entry_EditDigit | |
274 | |
275 $Description: Sends a numeric digit/symbol to the editor | |
276 | |
277 $Returns: None. | |
278 | |
279 $Arguments: data - The editor data | |
280 code - The key code of the digit to be inserted | |
281 | |
282 *******************************************************************************/ | |
283 | |
284 USHORT AUI_entry_EditDigit (T_AUI_ENTRY_DATA *entry_data, UBYTE code) | |
285 { | |
286 T_ED_DATA *editor = entry_data->editor; | |
287 USHORT alphachar; | |
288 | |
289 TRACE_FUNCTION("AUITextEntry: AUI_entry_EditDigit()"); | |
290 | |
291 alphachar = ATB_char_Unicode(editControls[code]); | |
292 | |
293 ATB_edit_MultiTap(editor, alphachar, FALSE); | |
294 | |
295 return alphachar; | |
296 } | |
297 | |
298 | |
299 /******************************************************************************* | |
300 | |
301 $Function: AUI_entry_Timer | |
302 | |
303 $Description: executes the timer event from the edit component | |
304 | |
305 $Returns: none. | |
306 | |
307 $Arguments: | |
308 | |
309 *******************************************************************************/ | |
310 | |
311 static int AUI_entry_Timer (MfwEvt event, MfwTim *timer) | |
312 { | |
313 T_AUI_ENTRY_DATA *entry_data = (T_AUI_ENTRY_DATA *)MMIdata; | |
314 | |
315 TRACE_FUNCTION("AUIEditor: AUI_entry_Timer()"); | |
316 | |
317 /* SPR#2174 - SH - Only display character if we're still in multi-tap */ | |
318 | |
319 if (entry_data->editor->multitap) | |
320 { | |
321 if (ATB_edit_Mode(entry_data->editor, ED_MODE_ALPHA)) | |
322 { | |
323 AUI_entry_EditChar(entry_data, NULL, FALSE); | |
324 | |
325 entry_data->Level = KEY_PAD_MAX-1; | |
326 entry_data->Key = KCD_MAX; | |
327 } | |
328 | |
329 SEND_EVENT(entry_data->win, entry_data->update,0,0); | |
330 } | |
331 | |
332 return 1; | |
333 } | |
334 | |
335 | |
336 /******************************************************************************* | |
337 | |
338 $Function: AUI_entry_StopMultitap | |
339 | |
340 $Description: Stops a multitap operation going on, cancelling the timer | |
341 SPR#2174 - SH - Added | |
342 | |
343 $Returns: none. | |
344 | |
345 $Arguments: entry_data - The entry data | |
346 | |
347 *******************************************************************************/ | |
348 | |
349 void AUI_entry_StopMultitap(T_AUI_ENTRY_DATA *entry_data) | |
350 { | |
351 TRACE_FUNCTION("AUIEditor: AUI_entry_StopMultitap()"); | |
352 | |
353 timStop(entry_data->editTim); | |
354 | |
355 entry_data->editor->multitap = FALSE; | |
356 | |
357 entry_data->Level = KEY_PAD_MAX-1; | |
358 entry_data->Key = KCD_MAX; | |
359 | |
360 return; | |
361 } | |
362 | |
363 | |
364 /******************************************************************************* | |
365 | |
366 $Function: AUI_entry_EventKey | |
367 | |
368 $Description: Process a keypress event. | |
369 | |
370 $Returns: The character that is entered, or NULL. | |
371 | |
372 $Arguments: | |
373 | |
374 *******************************************************************************/ | |
375 | |
376 USHORT AUI_entry_EventKey (T_AUI_ENTRY_DATA *entry_data, MfwEvt event, MfwKbd *key) | |
377 { | |
378 T_ED_DATA *editor = entry_data->editor; | |
379 USHORT alphachar; // The character entered | |
380 | |
381 TRACE_FUNCTION("AUIEditor: AUI_entry_EventKey"); | |
382 | |
383 alphachar = AUI_entry_Keypress(entry_data, event, key); | |
384 | |
385 ATB_edit_Refresh(editor); | |
386 | |
387 return alphachar; | |
388 } | |
389 | |
390 | |
391 /******************************************************************************* | |
392 | |
393 $Function: AUI_entry_Keypress | |
394 | |
395 $Description: Process a keypress event | |
396 | |
397 $Returns: The character that is entered, or NULL. | |
398 | |
399 $Arguments: | |
400 | |
401 *******************************************************************************/ | |
402 | |
403 static USHORT AUI_entry_Keypress(T_AUI_ENTRY_DATA *entry_data, MfwEvt event, MfwKbd *key) | |
404 { | |
405 T_ED_DATA *editor = entry_data->editor; | |
406 USHORT alphachar; /* Current multi-tap character */ | |
407 T_ED_CASE_PREF casePref; | |
408 | |
409 TRACE_FUNCTION("AUIEditor: AUI_entry_KeypressFormat()"); | |
410 | |
411 alphachar = NULL; | |
412 | |
413 if (key->code!=KCD_HUP && editor->cursor.pos<(editor->attr->size-1)) /* SPR#1995 - SH */ | |
414 { | |
415 /* Multi-tap: The user presses a different key, meaning the previous character must be entered */ | |
416 | |
417 if (entry_data->Key != KCD_MAX && entry_data->Key != key->code) | |
418 { | |
419 timStop(entry_data->editTim); | |
420 | |
421 AUI_entry_EditChar(entry_data, alphachar, FALSE); // Show character, not multi-tap | |
422 entry_data->Level = KEY_PAD_MAX-1; | |
423 entry_data->Key = KCD_MAX; | |
424 } | |
425 | |
426 casePref = ATB_edit_GetCasePref(editor); /* Work out the format character that will govern the format of this keypress */ | |
427 | |
428 if (editor->cursor.pos < (editor->attr->size-1) && casePref!=ED_CASEPREF_NONE) /* SPR#1995 - SH */ // Make sure we can still show a character | |
429 { | |
430 if (key->code <= KCD_HASH) /* SPR#1788 - SH - Now accept 0-9, * and # */ | |
431 { | |
432 entry_data->Key = key->code; // Store the key pressed | |
433 | |
434 /* Numeric */ | |
435 | |
436 if (casePref==ED_CASEPREF_NUM) // A numeric digit is expected | |
437 { | |
438 alphachar = AUI_entry_GetKeyChar(entry_data, casePref); | |
439 entry_data->Level = KEY_PAD_MAX-1; // Reset multi-tap settings | |
440 entry_data->Key = KCD_MAX; | |
441 AUI_entry_EditChar(entry_data, alphachar, FALSE); // Show character, not multi-tap# | |
442 } | |
443 | |
444 /* Multi-tap alphanumeric */ | |
445 | |
446 else // Valid format codes | |
447 { | |
448 alphachar = NULL; | |
449 | |
450 entry_data->Level++; // Increment through list of symbols | |
451 if (entry_data->Level > (KEY_PAD_MAX-1)) // List wraps round | |
452 entry_data->Level = 0; | |
453 | |
454 alphachar = AUI_entry_GetKeyChar(entry_data, casePref); | |
455 | |
456 if (alphachar!=NULL) // If we've found a character, and string isn't max size | |
457 { | |
458 AUI_entry_EditChar(entry_data, alphachar, TRUE); // Add character, multi-tap | |
459 /* Need to store this handle, so timer can get access to | |
460 * entry_data on callback */ | |
461 MMIdata = (void *)entry_data; | |
462 timStart(entry_data->editTim); | |
463 } | |
464 else | |
465 entry_data->Key = KEY_MAX; | |
466 } | |
467 } | |
468 } | |
469 } | |
470 return alphachar; | |
471 } | |
472 | |
473 | |
474 /******************************************************************************* | |
475 | |
476 $Function: AUI_entry_GetKeyChar | |
477 | |
478 $Description: Return the character to be entered, based on the keypress | |
479 | |
480 $Returns: the unicode character to be entered into the text | |
481 | |
482 $Arguments: case - the preference for the case of the output | |
483 | |
484 | |
485 *******************************************************************************/ | |
486 | |
487 USHORT AUI_entry_GetKeyChar(T_AUI_ENTRY_DATA *entry_data, T_ED_CASE_PREF casePref) | |
488 { | |
489 T_ED_DATA *editor = entry_data->editor; | |
490 USHORT alphachar; | |
491 USHORT safetycounter; /* Stops searching forever to find compatible character */ | |
492 BOOL valid; /* flag to indicate whether character is accepted */ | |
493 USHORT upper; | |
494 USHORT lower; | |
495 UBYTE caseSel = ATB_edit_GetCase(editor); /* The case selected by the user */ | |
496 | |
497 TRACE_FUNCTION("AUI_entry_GetKeyChar"); | |
498 | |
499 if (casePref==ED_CASEPREF_NUM || (casePref==ED_CASEPREF_ALPHANUM && caseSel==ED_CASE_NUM)) | |
500 { | |
501 alphachar = editControls[entry_data->Key]; | |
502 if (entry_data->Key<=KCD_HASH) | |
503 alphachar = alphachar << 8; // Gives us the ascii in the upper byte of the unicode | |
504 } | |
505 else | |
506 { | |
507 valid = FALSE; | |
508 alphachar = NULL; | |
509 safetycounter = 0; | |
510 | |
511 while (!valid && safetycounter<KEY_PAD_MAX) | |
512 { | |
513 upper = (USHORT)editAlphaU[entry_data->Key][entry_data->Level]; | |
514 lower = (USHORT)editAlpha[entry_data->Key][entry_data->Level]; | |
515 | |
516 switch(casePref) | |
517 { | |
518 case ED_CASEPREF_ALPHANUM: | |
519 if (caseSel==ED_CASE_UPPER || caseSel==ED_CASE_CAPS) | |
520 alphachar = upper; | |
521 else | |
522 alphachar = lower; | |
523 valid = TRUE; | |
524 break; | |
525 | |
526 case ED_CASEPREF_ALPHANUM_UC: | |
527 alphachar = upper; | |
528 valid = TRUE; | |
529 break; | |
530 | |
531 case ED_CASEPREF_ALPHANUM_LC: | |
532 alphachar = lower; | |
533 valid = TRUE; | |
534 break; | |
535 | |
536 case ED_CASEPREF_ALPHA_UC: | |
537 alphachar = upper; | |
538 valid = !ATB_char_IsNumeric(alphachar); | |
539 break; | |
540 | |
541 case ED_CASEPREF_ALPHA_LC: | |
542 alphachar = lower; | |
543 valid = !ATB_char_IsNumeric(alphachar); | |
544 break; | |
545 } | |
546 | |
547 if (!valid) | |
548 { // find the next one that is, | |
549 alphachar = NULL; | |
550 safetycounter++; // (but don't search forever) | |
551 entry_data->Level++; | |
552 if (entry_data->Level > (KEY_PAD_MAX-1)) | |
553 entry_data->Level = 0; | |
554 } | |
555 } | |
556 | |
557 alphachar = ATB_char_Unicode(alphachar); /* SPR#2342 - SH - Convert from unicode properly */ | |
558 } | |
559 | |
560 TRACE_EVENT_P1(">>> alphachar = %d", alphachar); | |
561 | |
562 return alphachar; | |
563 } |