comparison src/aci2/bmi/MmiBookInputWindow.c @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
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: PhoneBook
15 $File: MmiBookInputWindow.h
16 $Revision: 1.0
17
18 $Author: Condat(UK)
19 $Date: 25/10/00
20
21 ********************************************************************************
22
23 Description:
24
25 This module provides the functionality for the input window of the
26 phone book module.
27
28 ********************************************************************************
29 $History: MmiBookInputWindow.h
30
31 25/10/00 Original Condat(UK) BMI version.
32
33 $End
34
35 *******************************************************************************/
36
37
38
39
40
41 /*******************************************************************************
42
43 Include Files
44
45 *******************************************************************************/
46 #define ENTITY_MFW
47
48 /* includes */
49 #include <string.h>
50 #include <stdio.h>
51 #include <stdlib.h>
52
53 #if defined (NEW_FRAME)
54
55 #include "typedefs.h"
56 #include "vsi.h"
57 #include "pei.h"
58 #include "custom.h"
59 #include "gsm.h"
60
61 #else
62
63 #include "STDDEFS.H"
64 #include "custom.h"
65 #include "gsm.h"
66 #include "vsi.h"
67
68 #endif
69
70 #include "mfw_sys.h"
71
72 #include "mfw_mfw.h"
73 #include "mfw_win.h"
74 #include "mfw_kbd.h"
75 #include "mfw_lng.h"
76 /* SPR#1428 - SH - New Editor changes */
77 #ifndef NEW_EDITOR
78 #include "mfw_edt.h"
79 #endif
80 #include "mfw_icn.h"
81 #include "mfw_mnu.h"
82 #include "mfw_tim.h"
83
84 #include "mfw_sim.h"
85 #include "mfw_cm.h"
86 #include "mfw_nm.h"
87 #include "mfw_phb.h"
88 #include "mfw_mme.h"
89 #include "mfw_sat.h"
90 #include "mfw_sms.h"
91
92 #include "dspl.h"
93
94 #include "ksd.h"
95 #include "psa.h"
96
97 #include "MmiMain.h"
98 #include "MmiBookController.h"
99 #include "MmiDummy.h"
100 #include "MmiDialogs.h"
101 #include "MmiLists.h"
102
103
104
105 #include "MmiMenu.h"
106 #include "mmiCall.h"
107 #include "Mmiicons.h"
108 #include "MmiIdle.h"
109
110 #include "MmiSoftKeys.h"
111 #include "MmiSounds.h"
112 #include "MmiIdle.h"
113 #include "MmiNetwork.h"
114 #include "mmiSat_i.h"
115 #include "MmiAoc.h"
116
117 #include "gdi.h"
118 #include "audio.h"
119
120 #include "cus_aci.h"
121 #include "mfw_ffs.h"
122 #include "MmiTimers.h"
123
124 #include "MmiBookShared.h"
125 #ifdef EASY_TEXT_ENABLED
126 #include "MmiChineseInput.h"
127 #endif
128
129 #include "mmiColours.h"
130 /* SPR#1428 - SH - New Editor
131 * This file is obsolete with new editor and should not be compiled */
132 #ifndef NEW_EDITOR
133
134 #define NAME 0
135 #define NUMBER 1
136
137 static int DoNextLongPress = FALSE;
138 static UBYTE UPPER_CASE = TRUE;
139 static UBYTE MODE;
140 extern int upCase;
141
142
143 /*******************************************************************************
144
145 Private Methods
146
147 *******************************************************************************/
148
149 /*******************************************************************************
150
151 $Function: bookInputDialog
152
153 $Description: Dialog function for the input window
154
155 $Returns: None
156
157 $Arguments: win, window handle
158 event, event to be handled
159 value, not used
160 parameter, not used
161
162 *******************************************************************************/
163
164 static void bookInputDialog( T_MFW_HND win, USHORT event, SHORT value, void *parameter )
165 {
166 T_MFW_WIN *win_data = ((T_MFW_HDR *) win)->data;
167 tBookStandard *data = (tBookStandard *) win_data->user;
168 tInputSpecifics *properties = (tInputSpecifics *) parameter;
169
170 TRACE_FUNCTION ("bookInputDialog()");
171
172 /* Handle the input event, ew only deal with initialise and
173 destroy of the window in here
174 */
175 switch( event )
176 {
177 case INPUT_INIT:
178 {
179 /* Initialise the input window
180 */
181 data->properties.abc = properties->abc;
182 data->properties.text = properties->text;
183 data->properties.edt_attr_input = properties->edt_attr_input;
184 data->properties.left_soft_key = properties->left_soft_key;
185 data->properties.right_soft_key = properties->right_soft_key;
186 data->properties.callback = properties->callback;
187 data->edt = edtCreate( data->win, data->properties.edt_attr_input, 0, 0 );
188
189 /* activate our editor, stopping any others before doing so
190 */
191 editDeactivate();
192 editActivate( data->edt, properties->abc );
193 edtChar( data->edt, ecBottom );
194
195 /* show the window
196 */
197 winShow( data->win );
198 }
199 break;
200
201 case INPUT_DESTROY:
202 {
203 /* destroy the input window
204 */
205 bookInputDestroy( win );
206 }
207 break;
208 }
209 }
210
211
212
213
214
215
216 /*******************************************************************************
217
218 $Function: bookInputWindowCB
219
220 $Description: Window event handler
221
222 $Returns: MFW_CONSUMED for the visible event, MFW_PASSED otherwise
223
224 $Arguments: e, event, w, window handle
225
226 *******************************************************************************/
227
228 static int bookInputWindowCB( MfwEvt e, MfwWin *w )
229 {
230 tBookStandard *data = (tBookStandard *) w->user;
231
232 TRACE_FUNCTION ("bookInputWindowCB()");
233
234 /* Handle the visible event, otherwise return MFW_EVENT_PASSED
235 */
236 switch( e )
237 {
238 case MfwWinVisible:
239 {
240 /* Window visible
241 */
242 MmiBookShowDefault();
243 edtShow( data->edt );
244 PROMPT( MmiBookMenuArea().px, MmiBookMenuArea().py, 0, data->properties.text );
245 softKeys_displayId(data->properties.left_soft_key, data->properties.right_soft_key, 0, COLOUR_LIST_SUBMENU);
246 }
247 break;
248
249 default:
250 {
251 /* unabel to handle event, pass handling of event back up tree
252 */
253 return MFW_EVENT_PASSED;
254 }
255 }
256
257 /* if we get here, we have handled the event
258 */
259 return MFW_EVENT_CONSUMED;
260 }
261
262
263
264
265
266
267 /*******************************************************************************
268
269 $Function: bookInputKbdCB
270
271 $Description: Input window keyboard handler
272
273 $Returns: MFW_EVENT_CONSUMED always, this will pass LEFT, RIGHT and CLEAR
274 events back to the calling window using the installed callback
275 method
276
277 $Arguments: e, event, k, key handle
278
279 *******************************************************************************/
280
281 static int bookInputKbdCB( MfwEvt e, MfwKbd *k )
282 {
283 T_MFW_HND win = mfwParent( mfw_header() );
284 T_MFW_WIN *win_data = ((T_MFW_HDR *) win)->data;
285 tBookStandard *data = (tBookStandard *) win_data->user;
286
287 TRACE_FUNCTION ("bookInputKbdCB()");
288
289 /* make sure the active editor is ours
290 */
291 if ( activeEditor() != data->edt )
292 editActivate( data->edt, data->properties.abc );
293
294 /* Handle the key press
295 */
296 switch (k->code)
297 {
298 case KCD_MNUUP:
299 {
300 /* move right
301 */
302 edtChar( data->edt, ecRight );
303 }
304 break;
305
306 case KCD_MNUDOWN:
307 {
308 /* move left
309 */
310 edtChar( data->edt, ecLeft );
311 }
312 break;
313
314 case KCD_MNUSELECT:
315 case KCD_LEFT:
316 {
317 /* select the entry using the parent window callback
318 */
319 data->properties.callback( data->parent_win, INPUT_LEFT );
320
321 }
322 break;
323
324 case KCD_HUP:
325 {
326 /* get edit control block
327 */
328 MfwEdt *edt = ( (MfwHdr *) data->edt )->data;
329
330 data->properties.callback( data->parent_win, INPUT_CLEAR );
331 }
332 break;
333
334 case KCD_RIGHT:
335 {
336 MfwEdt *edt = ( (MfwHdr *) data->edt )->data;
337 /* select the entry using the parent windows callback
338 */
339 //If we have any data input, delete the char before cursor
340 if ( edt->attr->text[0] )
341 edtChar( data->edt, ecBack );
342 else
343 {
344 data->properties.callback( data->parent_win, INPUT_RIGHT );
345 displaySoftKeys_edition (TxtNull, TxtNull ,TxtNull);
346 MODE = NUMBER;
347 }
348
349 }
350 break;
351
352 case KCD_HASH:
353 {
354 /* deal with hash key
355 */
356 edtChar( data->edt, '#' );
357 }
358 break;
359
360 case KCD_STAR:
361 {
362 /* deal with star key
363 */
364 edtChar( data->edt, '*' );
365 }
366 break;
367
368 default:
369 {
370 /* default handling for the key being pressed
371 */
372
373 /*NM, p015a */
374 /* it is better to use these two function for different mode*/
375 if (data->properties.abc EQ TRUE)
376 editEventKey(e, k); /* alpha-mode*/
377 else
378 edtChar(data->edt ,editControls[k->code]); /*digit -mode*/
379
380 edtShow(data->edt);
381 /*p015a end */
382
383 }
384 break;
385 }
386
387 /* always consume the event
388 */
389 return MFW_EVENT_CONSUMED;
390 }
391
392
393
394
395
396
397 /*******************************************************************************
398
399 $Function: bookInputKbdLongCB
400
401 $Description: Keyboard long event handler
402
403 $Returns: MFW_EVENT_CONSUMED always
404
405 $Arguments: e, event, k, key handle
406
407 *******************************************************************************/
408
409 static int bookInputKbdLongCB( MfwEvt e, MfwKbd *k )
410 {
411 T_MFW_HND win = mfwParent( mfw_header() );
412 T_MFW_WIN *win_data = ((T_MFW_HDR *) win)->data;
413 tBookStandard *data = (tBookStandard *) win_data->user;
414
415 TRACE_FUNCTION ("bookInputKbdLongCB()");
416
417
418 /* subpress unwanted longpresses (mfw throws more than one long press event for one long press on a key)*/
419 if ( e & KEY_LONG )
420 {
421 if ( DoNextLongPress EQ FALSE )
422 DoNextLongPress = TRUE;
423 else
424 DoNextLongPress = FALSE;
425 }
426 if ( !DoNextLongPress )
427 return MFW_EVENT_CONSUMED; /* don't do current long press */
428
429
430
431 /* Handling the long keypress events needs to deal with a
432 number of characters in the input window, not just the
433 normal clear event
434 */
435
436 /* if the event is long key clear and the buffer is not empty then
437 clear the buffer. Otherwise if the buffer is empty then destroy
438 the input editor
439 */
440
441 switch(k->code)
442 {
443 case KCD_HUP:
444 {
445 MfwEdt *edt;
446
447 /* get edit control block
448 */
449 edt = ((MfwHdr *) data->edt)->data;
450
451 /* if buffer empty then kill the editor window, otherwise clear the buffer
452 */
453 if ( edt->attr->text[0] )
454 {
455 char *c_ptr = data->properties.edt_attr_input->text;
456 memset( c_ptr, '\0', strlen( c_ptr ) );
457 edtReset( data->edt );
458 edtShow( data->edt );
459 }
460 else
461 bookInputDestroy( data->win );
462 }
463 break;
464
465 case KCD_HASH:
466 edtChar( data->edt, ecBack );
467 edtChar( data->edt, 'p' );
468 break;
469
470 case KCD_0:
471 edtChar( data->edt, ecBack );
472 edtChar( data->edt, '+' );
473 break;
474
475
476 default:
477 if (MODE EQ NAME)
478 {
479
480 if (UPPER_CASE EQ FALSE)
481 {
482 TRACE_EVENT("UPPER_CASE EQ FALSE");
483 UPPER_CASE = TRUE;
484 upCase = FALSE;
485 displaySoftKeys_edition (TxtLowercase, TxtNull ,TxtNull);
486
487 }
488 else
489 {
490 TRACE_EVENT("UPPER_CASE EQ TRUE");
491 UPPER_CASE = FALSE;
492 upCase = TRUE;
493 displaySoftKeys_edition (TxtUppercase, TxtNull ,TxtNull);
494 }
495 edtChar(data->edt, ecBack);
496 }
497 break;
498
499 }
500
501 /* always handle the event
502 */
503 return MFW_EVENT_CONSUMED;
504 }
505
506
507
508
509
510 /*******************************************************************************
511
512 $Function: bookInputCreate
513
514 $Description: Create the input window and asociate it's handlers
515
516 $Returns: handle of new window, or NULL if failure
517
518 $Arguments: parent, handle of the parent window
519
520 *******************************************************************************/
521
522 static T_MFW_HND bookInputCreate( MfwHnd parent )
523 {
524 T_MFW_WIN *parent_win_data = ( (T_MFW_HDR *) parent )->data;
525 tBookStandard *parent_data = (tBookStandard *) parent_win_data->user;
526 T_phbk *phbk = parent_data->phbk;
527 T_MFW_WIN *win_data;
528 tBookStandard *data;
529
530 TRACE_FUNCTION ("bookInputCreate()");
531
532 /* allocate memory for our control block
533 */
534 if ( ( data = (tBookStandard *) ALLOC_MEMORY( sizeof( tBookStandard ) ) ) == NULL )
535 return NULL;
536
537 /* Create the window if we can
538 */
539 if ( ( data->win = win_create( parent, 0, E_WIN_VISIBLE, (T_MFW_CB) bookInputWindowCB ) ) == NULL )
540 {
541 FREE_MEMORY( (void *)data, sizeof( tBookStandard ) );
542 return NULL;
543 }
544
545 /* Okay, we have created the control block and the window, so
546 we now need to configure the dialog and data pointers
547 */
548 data->mmi_control.dialog = (T_DIALOG_FUNC) bookInputDialog;
549 data->mmi_control.data = data;
550 win_data = ((T_MFW_HDR *)data->win)->data;
551 win_data->user = (void *) data;
552 data->phbk = phbk;
553 data->parent_win = parent;
554
555 /* create keyboards and menus for our window
556 */
557 data->kbd = kbdCreate( data->win, KEY_ALL, (MfwCb) bookInputKbdCB );
558 data->kbd_long = kbdCreate( data->win, KEY_ALL | KEY_LONG, (MfwCb) bookInputKbdLongCB );
559
560 /* And return the handle of the newly created window
561 */
562 return data->win;
563 }
564
565
566
567
568
569 /*******************************************************************************
570
571 Public Methods
572
573 *******************************************************************************/
574
575 /*******************************************************************************
576
577 $Function: bookInputStart
578
579 $Description: Start the input handler
580
581 $Returns: Handle of newly created window, or NULL if failure
582
583 $Arguments: parent, parent window handle, properties, input window property
584 control block.
585
586 *******************************************************************************/
587
588 MfwHnd bookInputStart( MfwHnd parent,tInputSpecifics *properties )
589 {
590 T_MFW_HND win;
591
592 TRACE_FUNCTION ("bookInputStart()");
593
594 /* allocate window, and if successful initialise it
595 */
596 if ( ( win = bookInputCreate( parent ) ) != NULL )
597 SEND_EVENT( win, INPUT_INIT, 0, properties );
598 return win;
599 }
600
601
602 /*******************************************************************************
603
604 $Function: bookInputStartNumberEditor
605
606 $Description: Start the input handler using default properties
607
608 $Returns: Handle of newly created window, or NULL if failure
609
610 $Arguments: parent, parent window handle, buffer, input buffer
611
612 *******************************************************************************/
613
614 MfwHnd bookInputStartNumberEditor( MfwHnd parent, void *buffer )
615 {
616 T_MFW_HND win = parent;
617 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
618 tBookStandard *data = (tBookStandard *) win_data->user;
619 T_phbk *Phbk = data->phbk;
620 tInputSpecifics DefaultParameters;
621
622 TRACE_FUNCTION ("bookInputStartNumberEditor()");
623 MODE = NUMBER;
624
625 /* Set up the default parameters for the input window
626 */
627 bookSetEditAttributes( NUMBER_EDITOR, COLOUR_EDITOR_XX, 0, edtCurBar1, 0,
628 (char *) buffer, NUMBER_LENGTH, &Phbk->edt_attr_number );
629
630 DefaultParameters.abc = FALSE;
631 DefaultParameters.text = TxtEnterNumber;
632 DefaultParameters.edt_attr_input = &Phbk->edt_attr_number;
633 DefaultParameters.left_soft_key = TxtSoftOK;
634 DefaultParameters.right_soft_key = TxtDelete;//Changed text
635 // dunno if that changes softkey functionality
636 DefaultParameters.callback = bookAddNumberCB;
637
638 /* allocate window, and if successful initialise it
639 */
640 return bookInputStart( parent, &DefaultParameters );
641 }
642
643
644
645 /*******************************************************************************
646
647 $Function: bookInputStartNameEditor
648
649 $Description: Start the input handler using default properties
650
651 $Returns: Handle of newly created window, or NULL if failure
652
653 $Arguments: parent, parent window handle, buffer, input buffer
654
655 *******************************************************************************/
656
657 MfwHnd bookInputStartNameEditor( MfwHnd parent, void *buffer )
658 {
659 T_MFW_WIN *win_data = ( (T_MFW_HDR *) parent )->data;
660 tBookStandard *data = (tBookStandard *) win_data->user;
661 T_phbk *Phbk = data->phbk;
662
663 tInputSpecifics DefaultParameters;
664
665 MODE = NAME;
666
667 TRACE_FUNCTION ("bookInputStartNameEditor()");
668
669 /* Set up the default parameters for the input window */
670
671 /*MC 1957, name strings should use MAX_ALPHA_LEN*/
672 bookSetEditAttributes( NUMBER_EDITOR, COLOUR_EDITOR_XX, 0, edtCurBar1, 0,
673 (char *) buffer, MAX_ALPHA_LEN, &Phbk->edt_attr_name );
674
675 /*SPR 1434*/
676
677 /*SPR 1526, changed #ifdef to #if*/
678 #if defined(CHINESE_MMI) && defined(EASY_TEXT_ENABLED)
679 /*MC, the chinese editor MUST have a unicode string as input*/
680 /*MC , SPR 1242 merged in from b-sample build*/
681 if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
682 { T_CHINESE_DATA chinese_data;
683 chinese_data.TextString = (char*) Phbk->edt_buf_name;
684 if (chinese_data.TextString[0]== 0)//if, empty string
685 { chinese_data.TextString[0] = 0x80;//give string Unicode tag
686 chinese_data.TextString[1] = 0x7F;
687 }
688 else
689 { char l_name[MAX_ALPHA_LEN];
690 int ascii_len = strlen(chinese_data.TextString);
691 int i;
692 if (chinese_data.TextString[0]!= 0x80)/*If ASCII string*/
693 { memset(l_name, '\0', MAX_ALPHA_LEN);
694 l_name[0] = 0x80;//give Unicode tag
695 l_name[1] = 0x7F;
696 /*convert ascii string to unicode*/
697 { for (i =0; i < (ascii_len); i++)
698 { if ((2+2*i+1)>=MAX_ALPHA_LEN)
699 break;
700 l_name[2+2*i] = 0x00;
701 l_name[2+2*i+1] = chinese_data.TextString[i];
702 }
703 if ((2+2*i+1)<=MAX_ALPHA_LEN)
704 { l_name[2+2*i] = 0x00; //double null termination
705 l_name[2+2*i+1] = 0x00;
706 }
707 }
708 memcpy(chinese_data.TextString, l_name, MAX_ALPHA_LEN);
709 }
710 }
711 /*MC end*/
712
713 chinese_data.Callback = (T_EDIT_CB)bookAddNameCB;
714 chinese_data.Identifier = INPUT_LEFT ;
715 chinese_data.LeftSoftKey = TxtSave;
716 chinese_data.DestroyEditor = TRUE;
717 chinese_data.EditorSize = (USHORT)((MAX_ALPHA_LEN-4)/2);//i.e.8
718 return chinese_input(parent, &chinese_data);
719 }
720 else
721 #endif
722 {
723 DefaultParameters.abc = TRUE;
724 DefaultParameters.text = TxtEnterName;
725 DefaultParameters.edt_attr_input = &Phbk->edt_attr_name;
726 DefaultParameters.left_soft_key = TxtSoftOK;
727 DefaultParameters.right_soft_key = TxtDelete;//Changed text - MC
728 DefaultParameters.callback = bookAddNameCB;
729
730 /* allocate window, and if successful initialise it
731 */
732 return bookInputStart( parent, &DefaultParameters );
733 }
734 }
735
736
737
738 /*******************************************************************************
739
740 $Function: bookInputDestroy
741
742 $Description: Destroy Input Window
743
744 $Returns: None
745
746 $Arguments: Handle of window to be destroyed
747
748 *******************************************************************************/
749
750 void bookInputDestroy( MfwHnd window )
751 {
752 T_MFW_WIN *win = ((T_MFW_HDR *) window)->data;
753 tBookStandard *data = (tBookStandard *) win->user;
754
755 TRACE_FUNCTION ("bookInputDestroy()");
756
757 if (data)
758 {
759 editDeactivate();
760
761 winDelete ( data->win );
762 FREE_MEMORY( (void *) data, sizeof( tBookStandard ) );
763 }
764 }
765
766 #endif /* NEW_EDITOR */
767
768 /*******************************************************************************
769
770 End of File
771
772 *******************************************************************************/