comparison src/ui/bmi/mmiChineseInput.c @ 3:67bfe9f274f6

src/ui: import of src/ui3 from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:33:10 +0000
parents
children
comparison
equal deleted inserted replaced
2:3a14ee9a9843 3:67bfe9f274f6
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: MmiChineseInput
15 $File: MmiChineseInput.c
16 $Revision: 1.0
17
18 $Author: Condat(UK)
19 $Date: 25/10/00
20
21 ********************************************************************************
22
23 Description:MMI Chinese Input handling.
24
25
26
27 ********************************************************************************
28
29 $History: MmiChineseInput.c
30 Aug 16, 2004 REF: CRR 24323 Deepa M.D
31 Bug:Clenup of sprintf used for tracing
32 Fix:Replace the char buf[]; sprintf (buf, "...", ...); TRACE_EVENT (buf); statements by TRACE_EVENT_PX
33
34 25/10/00 Original Condat(UK) BMI version.
35 03/10/02 Replaced most of the file with version on 3.3.3 line (MC, SPR 1242)
36
37 $End
38
39 *******************************************************************************/
40
41
42 /*******************************************************************************
43
44 Include Files
45
46 *******************************************************************************/
47 #include <stdio.h>
48 #include <string.h>
49
50 #if defined (NEW_FRAME)
51
52 #include "typedefs.h"
53 #include "vsi.h"
54 #include "pei.h"
55 #include "custom.h"
56 #include "gsm.h"
57
58 #else
59
60 #include "STDDEFS.H"
61 #include "custom.h"
62 #include "gsm.h"
63 #include "vsi.h"
64
65 #endif
66
67
68 #include "mfw_mfw.h"
69 #include "mfw_win.h"
70 #include "mfw_kbd.h"
71 /* SPR#1428 - SH - New Editor changes */
72 #ifndef NEW_EDITOR
73 #include "mfw_edt.h"
74 #endif
75 #include "mfw_tim.h"
76 #include "mfw_phb.h"
77 #include "mfw_sms.h"
78 #include "mfw_icn.h"
79 #include "mfw_mnu.h"
80 #include "mfw_lng.h"
81 #include "mfw_sat.h"
82 #include "mfw_kbd.h"
83 #include "mfw_nm.h"
84
85 #include "dspl.h"
86
87 #include "ksd.h"
88 #include "psa.h"
89
90 #include "MmiMain.h"
91 #include "MmiDummy.h"
92 #include "MmiMmi.h"
93
94 #include "MmiDialogs.h"
95 #include "MmiLists.h"
96 #include "MmiMenu.h"
97 #include "MmiSoftKeys.h"
98 #include "MmiChineseInput.h"
99
100 #include "mmiSmsBroadcast.h"
101 #include "mmiSmsMenu.h"
102 #include "mmismssend.h"
103 #include "mmiColours.h"
104
105 /* SPR#1428 - SH - New Editor changes */
106 #ifdef NEW_EDITOR
107 #include "ATBCommon.h"
108 #include "ATBDisplay.h"
109 #include "ATBEditor.h"
110 #include "AUIEditor.h"
111 #include "AUISymbol.h"
112 #else
113 #include "MmiLatinPredText.h"
114 #endif
115
116 #define CHINESE_KEYPAD_TIME 1000 /*one second*/
117 #define MAX_PHONEBOOK_ENTRY_SIZE 10
118 #define LOWER_CASE_ASCII_OFFSET 97 /*ASCII code for 'a'*/
119 #define EZITEXT_OUTPUT_OFFSET 0xF400 /*Add to ASCII to get display code for Jospeh's pinyin font*/
120
121 #define CHI_FONT_WIDTH 12/*mc SPR1319*/
122
123 /* SPR#1428 - SH - New Editor: don't use SymbolChar */
124 #ifndef NEW_EDITOR
125 extern int SymbolChar;
126 #endif
127
128 /*MC 15/07/02 Keypad counters; keep track of how many times a key has been pressed*/
129 static char Counter[KCD_STAR];
130
131
132
133
134 static const unsigned char TextIconeZiTextSmall[] =
135 {
136 0x03,
137 0x03,
138 0x18,
139 0x7c,
140 0xcc,
141 0x08,
142 0x10,
143 0x0c
144 };
145 USHORT TEXT_BUFFER_EDIT_SIZE;
146
147 /*mc SPR1319, makes it easier to keep track of the mfw editor*/
148 #ifdef LSCREEN
149 /* SPR#1428 - SH - New Editor changes */
150 #ifdef NEW_EDITOR
151 T_ED_DATA *editor_pointer;
152 #else /* NEW_EDITOR */
153 T_MFW_HND* editor_pointer;
154 #endif /* NEW_EDITOR */
155 #endif
156
157 const char StrokePrompt[] = {0x7B, 0x14, 0x52, 0x12, 0x00, 0x3A, 0x00, 0x00};
158 const unsigned char PinYinPrompt[] = {0x62, 0xFC, 0x97, 0xF3, 0x00, 0x3A, 0x00, 0x00};
159 ZI8WCHAR const ZiStrokeKeyMap[10][3] = /* table for PINYIN */
160 {
161 {0, ZI8_STROKE_MORE},
162 {1, ZI8_STROKE_OVER},
163 {2, ZI8_STROKE_DOWN},
164 {3, ZI8_STROKE_LEFT},
165 {4, ZI8_STROKE_DOT},
166 {5, ZI8_STROKE_OVER_DOWN},
167 {6, ZI8_STROKE_CURVED_HOOK},
168 {7, ZI8_STROKE_DOWN_OVER},
169 {8, ZI8_STROKE_MORE},
170 {9, ZI8_STROKE_OVER_DOWN_OVER},
171 };
172
173 ZI8WCHAR const ZiPinYinKeyMap[9][6] = /* table for PINYIN */
174 {
175 {ZI8_CODE_TONES_1, ZI8_CODE_TONES_2, ZI8_CODE_TONES_3, ZI8_CODE_TONES_4, ZI8_CODE_TONES_5, 5},
176 {ZI8_CODE_PINYIN_A, ZI8_CODE_PINYIN_B, ZI8_CODE_PINYIN_C, 0, 0, 3},
177 {ZI8_CODE_PINYIN_D, ZI8_CODE_PINYIN_E, ZI8_CODE_PINYIN_F, 0, 0, 3},
178 {ZI8_CODE_PINYIN_G, ZI8_CODE_PINYIN_H, ZI8_CODE_PINYIN_I, 0, 0, 3},
179 {ZI8_CODE_PINYIN_J, ZI8_CODE_PINYIN_K, ZI8_CODE_PINYIN_L, 0, 0, 3},
180 {ZI8_CODE_PINYIN_M, ZI8_CODE_PINYIN_N, ZI8_CODE_PINYIN_O, 0, 0, 3},
181 {ZI8_CODE_PINYIN_P, ZI8_CODE_PINYIN_Q, ZI8_CODE_PINYIN_R, ZI8_CODE_PINYIN_S, 0, 4},
182 {ZI8_CODE_PINYIN_T, ZI8_CODE_PINYIN_U, ZI8_CODE_PINYIN_V, 0, 0, 3},
183 {ZI8_CODE_PINYIN_W, ZI8_CODE_PINYIN_X, ZI8_CODE_PINYIN_Y, ZI8_CODE_PINYIN_Z, 0, 4},
184 };
185
186 typedef struct _IME_DATA
187 {
188 int CandidateCursor; /* the indication of the current candidate highlighted */
189 unsigned short TextBufferCount; // Total number of characters contained in the wszTextBuffer.
190 unsigned char candidates; /* last returned number of candidates */
191 int TextCursor; /* the current test cursor */
192 PZI8WCHAR pTextBuffer; /* the start of the text buffer */
193 int TextBufferEditSize; /* */
194 int TextBufferSize; /* */
195 unsigned char moreCount; /* keeps track of the more count */
196 PZI8WCHAR pDisplayElementBuffer;
197 ZI8UCHAR EditorMode; // To store current editor mode i.e. stroke, PinYin
198 unsigned char InputScreenType; // This variable is to state the different screen type.
199 PZI8GETPARAM pGetParam; /* pointer to Zi8GetParam */
200 } IME_DATA, * PIME_DATA;
201
202 typedef struct
203 {
204 T_MMI_CONTROL mmi_control;
205 T_MFW_HND parent_win;
206 T_MFW_HND input_win;
207 T_MFW_HND input_kbd;
208 USHORT Identifier;
209
210 ZI8UCHAR version;
211 ZI8WCHAR* wszTextBuffer;/*[TEXT_BUFFER_EDIT_SIZE + 1];*/ /* TEXT_BUFFER_EDIT_SIZE = 80 */
212 ZI8WCHAR DisplayElementBuffer[TEXT_BUFFER_EXTRA_SPACE + 1]; /* TEXT_BUFFER_EXTRA_SPACE = 20 */
213 ZI8WCHAR wszElementBuffer[TEXT_BUFFER_EXTRA_SPACE + 1]; /* TEXT_BUFFER_EXTRA_SPACE = 20 */
214 ZI8GETPARAM GetParam;
215 IME_DATA Ime;
216 ZI8WCHAR wcCandidates[CANDIDATES_PER_GROUP+1]; /* CANDIDATES_PER_GROUP = 7 */
217 ZI8WCHAR StartOfDisplayIndex;
218 ZI8WCHAR HighlightedCandidate[2]; // This arrary is used to store the highlighted character pointed by CandidateCursor
219 ZI8WCHAR CursorPosition[2]; //Used to show the cursor Position in the composed text.
220 ZI8UCHAR NumberOfKeyPress;
221 CHAR PerviousKeyPress;
222 T_MFW_HND options_win;
223 /* Start of variable decleared for dummy functions. This is to be removed when eZiText code is received*/
224 /* End */
225 T_CHINESE_DATA Callback_Data;
226 /*MC 15/07/02 keypad timer for Pinyin*/
227 T_MFW_HND KeyPad_Timer_Handle;
228 #ifdef LSCREEN
229 #ifdef NEW_EDITOR /* SPR#1428 - SH - New Editor changes */
230 T_ED_DATA *editor;
231 T_ED_ATTR editor_attr;
232 #else /* NEW_EDITOR */
233 T_MFW_HND editor;/*mc SPR1319, using mfw_editor for colour display*/
234 MfwEdtAttr editor_attr;
235 #endif /* NEW_EDITOR */
236 #endif /* LSCREEN */
237 } T_chinese_input;
238
239
240 static T_MFW_HND chinese_input_create (T_MFW_HND parent_win);
241
242 static void chinese_input_exec (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
243 static int chinese_input_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
244 static int chinese_input_kbd_cb (T_MFW_EVENT event, T_MFW_KBD * keyboard);
245
246 /*mc 15/07/02*/
247 static int chinese_pinyin_timer_cb (MfwEvt e, MfwTim *t);
248
249 /* Initialize the defined structure */
250 void IMEInitialize(PIME_DATA pIME, PZI8GETPARAM pGetParam, PZI8WCHAR wszTextBuffer, int TextBufferEditSize,
251 int TextBufferSize, PZI8WCHAR wcCandidates, PZI8WCHAR wszElementBuffer, PZI8WCHAR DisplayElementBuffer);
252 void IMECursorLeft(PIME_DATA pIME); /* move the cadidate cursor left */
253 void IMECursorRight(PIME_DATA pIME); /* move the cadidate cursor right */
254 void IMESelectCandidate(PIME_DATA pIME, PZI8WCHAR wszElementBuffer); /* Select the candidate at sursor */
255 void IMEMore(PIME_DATA pIME); /* get the next group of candidates */
256 void IMEKeyPress(PIME_DATA pIME, ZI8WCHAR wcStroke); /* enter the stroke and get new candidates */
257 void IMEClear(PIME_DATA pIME, PZI8WCHAR wszElementBuffer); /* Clear the last stroke entered */
258 void CandidateHighlightDisplayContorl(PIME_DATA pIME, PZI8WCHAR HighlightedCandidate);
259 void TextCursorDisplayContorl(PIME_DATA pIME, PZI8WCHAR CursorPosition, int InsertLine);
260 void IMEChangeMode(PIME_DATA pIME, PZI8GETPARAM pGetParam);
261 void DataConvert(PIME_DATA pIME);
262 ZI8WCHAR Uni_strlen(PZI8WCHAR String);
263
264 /*****************************Functions*****************************************/
265 /*******************************************************************************
266
267 $Function: LatinChar
268
269 $Description: Returns true if character is in ASCII range
270
271 $Returns: UBYTE (TRUE/FALSE)
272
273 $Arguments: Wide char in Ezitext format (not our display format)
274
275 *******************************************************************************/
276 UBYTE LatinChar(ZI8WCHAR char_code)
277 { //if last byte is 0x00 and first byte is between 0x20 and 0x7E
278 if ((char_code% 0x100 == 0)&&(char_code>=0x2000) && (char_code<0x7F00))
279 return TRUE;
280 else
281 return FALSE;
282 }
283
284 /*******************************************************************************
285
286 $Function: chinese_input
287
288 $Description: starts chinese editor
289
290 $Returns: Window handle
291
292 $Arguments: parebt window, editor attribute structure
293
294 *******************************************************************************/
295 T_MFW_HND chinese_input (T_MFW_HND parent_win, T_CHINESE_DATA* chinese_data)
296 {
297 T_MFW_HND win;
298 win = chinese_input_create (parent_win);
299 if(win NEQ NULL)
300 {
301 SEND_EVENT (win, CHINESE_INPUT_INIT, 0, chinese_data);
302 }
303 return win;
304 }
305
306
307 /*******************************************************************************
308
309 $Function: chinese_input_create
310
311 $Description: Creates chinese editor window
312
313 $Returns: Dialogue info win
314
315 $Arguments: parent win
316
317 *******************************************************************************/
318 static T_MFW_HND chinese_input_create (T_MFW_HND parent_win)
319 {
320 T_MFW_WIN * win_data;
321 T_chinese_input * data = (T_chinese_input *)ALLOC_MEMORY (sizeof (T_chinese_input));
322
323 TRACE_EVENT ("chinese_input_create()");
324
325 data->input_win = win_create (parent_win, 0, E_WIN_VISIBLE, (T_MFW_CB)chinese_input_win_cb);
326 if(data->input_win EQ 0)
327 return 0;
328 /* Create window handler */
329 data->mmi_control.dialog = (T_DIALOG_FUNC)chinese_input_exec;
330 data->mmi_control.data = data;
331 data->parent_win = parent_win;
332 win_data = ((T_MFW_HDR *)data->input_win)->data;
333 win_data->user = (void *)data;
334
335 /*MC 15/07/02 create timer for pinyin multitap*/
336 data->KeyPad_Timer_Handle = tim_create(data->input_win, CHINESE_KEYPAD_TIME, (MfwCb)chinese_pinyin_timer_cb);
337 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/
338
339 /*return window handle */
340 return data->input_win;
341 }
342
343 /*******************************************************************************
344
345 $Function: chinese_pinyin_timer_cb
346
347 $Description: Keypad timer callback
348
349 $Returns: int
350
351 $Arguments: Event mask and timer structure
352
353 *******************************************************************************/
354 static int chinese_pinyin_timer_cb (MfwEvt e, MfwTim *t)
355 {
356 int i;
357 TRACE_EVENT("chinese_pinyin_timer_cb()");
358 for(i=0; i< KCD_STAR; i++)//MC, set all counters to 0
359 Counter[i] = 0;
360 return MFW_EVENT_CONSUMED;
361 }
362
363
364
365 /*******************************************************************************
366
367 $Function: chinese_input_destroy
368
369 $Description: Destruction of an information dialog
370
371 $Returns: void
372
373 $Arguments: win
374
375 *******************************************************************************/
376 void chinese_input_destroy (T_MFW_HND own_window)
377 {
378 T_MFW_WIN * win = ((T_MFW_HDR *)own_window)->data;
379 T_chinese_input * data = (T_chinese_input *)win->user;
380 TRACE_EVENT ("chinese_input_destroy()");
381
382 if (own_window == NULL)
383 {
384 TRACE_EVENT ("Error :- Called with NULL Pointer");
385 return;
386 }
387
388 if(data)
389 {
390 /* Exit TIMER & KEYBOARD Handle */
391 kbd_delete (data->input_kbd);
392 /* Delete WIN Handler */
393 win_delete (data->input_win);
394 /* Free Memory */
395 /*MC 15/07/02, delete keyboard timer*/
396 tim_delete(data->KeyPad_Timer_Handle);
397 data->KeyPad_Timer_Handle= NULL;
398
399 /* SPR#1428 - SH - New Editor changes */
400 #ifdef LSCREEN
401 #ifdef NEW_EDITOR
402 if (data->editor)
403 {
404 ATB_edit_Destroy(data->editor);
405 }
406 #endif
407 #endif
408
409 FREE_MEMORY ((void *)data, sizeof (T_chinese_input));
410 }
411 else
412 {
413 TRACE_EVENT ("chinese_input_destroy() - data already destroyed") ;
414 }
415 }
416
417
418 /*******************************************************************************
419
420 $Function: chinese_input
421
422 $Description:
423
424 $Returns: void
425
426 $Arguments: win, window handle event, value, parameter
427
428 *******************************************************************************/
429 void chinese_input_exec (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
430 {
431 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
432 T_chinese_input * data = (T_chinese_input *)win_data->user;
433 T_CHINESE_DATA * chinese_data = (T_CHINESE_DATA *)parameter;
434 #ifdef NEW_EDITOR /* SPR#1428 - SH - New Editor changes */
435 T_AUI_EDIT_CB Callback = data->Callback_Data.Callback;
436 #else /* NEW_EDITOR */
437 T_EDIT_CB Callback = data->Callback_Data.Callback;
438 #endif /* NEW_EDITOR */
439 T_MFW_HND parent_win = data->parent_win;
440 USHORT Identifier = data->Callback_Data.Identifier;
441
442 TRACE_EVENT ("chinese_input_exec()");
443 switch (event)
444 {
445 case CHINESE_INPUT_INIT:
446 data->Callback_Data = *chinese_data;
447 TEXT_BUFFER_EDIT_SIZE = data->Callback_Data.EditorSize;
448 /* Initialize dialog */
449 /* Create timer and keyboard handler */
450 data->input_kbd = kbd_create (win, KEY_ALL, (T_MFW_CB)chinese_input_kbd_cb);
451 /* Initialize all data structure and veriables to zero */
452 memset(&data->Ime, 0, sizeof(data->Ime));
453 memset(&data->GetParam, 0, sizeof(data->Ime));
454 memset(&data->wcCandidates, 0, sizeof(data->wcCandidates));
455 memset(&data->HighlightedCandidate, 0, sizeof(data->HighlightedCandidate));
456 memset(&data->CursorPosition, 0, sizeof(data->CursorPosition));
457 memset(&data->DisplayElementBuffer, 0,sizeof(data->DisplayElementBuffer));
458 data->StartOfDisplayIndex = 0;
459 data->NumberOfKeyPress = 0;
460 data->PerviousKeyPress = 0;/*a0393213 warnings removal - -1 changed to 0*/
461
462 /* Now intitialize the Zi8 Core Engine */
463 Zi8Initialize();
464 /* Now initialize the IME */
465 data->wszTextBuffer = (ZI8WCHAR*)&chinese_data->TextString[2]; //ignore first char (Unicode marker)
466 IMEInitialize(&data->Ime, &data->GetParam, data->wszTextBuffer, TEXT_BUFFER_EDIT_SIZE,
467 sizeof(data->wszTextBuffer), data->wcCandidates, data->wszElementBuffer, data->DisplayElementBuffer);
468 /* Store any other data */
469 #ifdef LSCREEN /* SPR 1319 create an mfw editor to display editor content*/
470
471 /* SPR#1428 - SH - New Editor changes */
472 #ifdef NEW_EDITOR
473 AUI_edit_SetAttr(&data->editor_attr, 0, COLOUR_EDITOR, EDITOR_FONT, ED_MODE_ALPHA, ED_CURSOR_BAR, ATB_DCS_UNICODE, (UBYTE *)chinese_data->TextString, TEXT_BUFFER_EDIT_SIZE+1);
474 data->editor_attr.win_size.sy = Mmi_layout_line_height()*8;/*Don't want to cover whole screen*/
475 data->editor = ATB_edit_Create(&data->editor_attr, 0);
476 ATB_edit_Init(data->editor);
477 ATB_edit_Char(data->editor, ctrlBottom, TRUE);
478 #else /* NEW_EDITOR */
479 editor_attr_init(&data->editor_attr, 0, edtCurBar1, NULL, chinese_data->TextString,TEXT_BUFFER_EDIT_SIZE*2+2 , COLOUR_EDITOR );
480 data->editor_attr.win.sy = Mmi_layout_line_height()*8;/*Don't want to cover whole screen*/
481 data->editor =edtCreate(data->input_win, &data->editor_attr, 0, 0);
482 edtChar(data->editor, ecBottom);
483 edtUnhide (data->editor);
484 #endif /* NEW_EDITOR */
485 editor_pointer = data->editor;
486 #endif
487 win_show (win);
488 break;
489
490 /*MC SPR 1752 same as E_ED_DESTROY*/
491 case CHINESE_INPUT_DESTROY:
492 if (data)
493 {
494 chinese_input_destroy(win);
495 }
496 break;
497
498 /*MC SPR 1752, new event*/
499 case CHINESE_INPUT_DEINIT:
500 {/* on DEINIT => selfdestroy; sendevent <value> */
501
502
503
504 //GW-SPR-#1068-After the callback, ensure 'data' is up-to-date
505 if (Callback)
506 {
507 (Callback) (parent_win, Identifier, value);
508 //Callback may have freed data - if so reinit pointer
509 data = (T_chinese_input *)win_data->user;
510 }
511
512 if (data)
513 {
514 if (data->Callback_Data.DestroyEditor == TRUE)
515 {
516 chinese_input_destroy(win);
517 }
518 }
519 }
520 break;
521 case ADD_SYMBOL:/*adding a symbol to chinese editor from symbol selection screen*/
522 if (data->Ime.TextBufferCount < TEXT_BUFFER_EDIT_SIZE)
523 {
524 #ifndef LSCREEN
525
526 int i=0;
527 int j=0;
528
529 if(data->Ime.TextCursor < data->Ime.TextBufferCount) /* locate the text cursor position for correct character insertion */
530 {/* shift and move characters to make room to insert the selected character */
531 for (i=data->Ime.TextCursor; i<data->Ime.TextBufferCount; i++)
532 {
533 data->Ime.pTextBuffer[data->Ime.TextBufferCount - j]=data->Ime.pTextBuffer[data->Ime.TextBufferCount - j - 1];
534 j++;
535 }
536 }
537 /* SPR#1428 - SH - New Editor changes */
538 #ifdef NEW_EDITOR
539 /* Now, value we get is already unicode */
540 data->Ime.pTextBuffer[data->Ime.TextCursor++]= (ZI8WCHAR)((USHORT)value);
541 #else
542 /*Shift char up into Unicode from ASCII*/
543 data->Ime.pTextBuffer[data->Ime.TextCursor++]= (ZI8WCHAR)(SymbolChar << 8);
544 #endif
545 data->Ime.TextBufferCount++;/*increase char count by one*/
546 #else /*SPR 1319*/
547
548 /* SPR#1428 - SH - New Editor changes */
549 #ifdef NEW_EDITOR
550 ATB_edit_Char(data->editor, (USHORT)value, TRUE);
551 #else /* NEW_EDITOR */
552 edtChar(data->editor, SymbolChar<<8);/*pop the symbol in the editor*/
553 #endif /* NEW_EDITOR */
554 data->Ime.TextBufferCount++;/*increase char count by one*/
555 #endif /* COLOURDISPLAY */
556 }
557 win_show(win);
558 break;
559 case LATIN_INPUT:/*return from Latin editor*/
560 /*update size of buffer*/
561 data->Ime.TextBufferCount = Uni_strlen(data->Ime.pTextBuffer);
562 data->Ime.TextCursor = data->Ime.TextBufferCount;/*move cursor to end*/
563 #ifdef LSCREEN
564 #ifdef NEW_EDITOR
565 resources_setColour(COLOUR_EDITOR);
566 ATB_edit_Refresh(data->editor);
567 ATB_edit_MoveCursor(data->editor, ctrlBottom, TRUE);
568 #endif
569 #endif
570 //win_show(data->input_win);
571 break;
572 }
573 }
574
575
576 /*******************************************************************************
577
578 $Function: chinese_input_win_cb
579
580 $Description:
581
582 $Returns: void
583
584 $Arguments: window handle event, win
585 *******************************************************************************/
586 static int chinese_input_win_cb (T_MFW_EVENT event, T_MFW_WIN * win)
587 {
588 T_chinese_input * data = (T_chinese_input *)win->user;
589 int i = 0;
590
591 PZI8WCHAR Temp_ptr;
592 TRACE_EVENT ("chinese_input_win_cb()");
593
594 if(data EQ 0)
595 return 1;
596 switch (event)
597 {
598 case E_WIN_VISIBLE:
599 if (win->flags & E_WIN_VISIBLE)
600 {
601 /*
602 ** Initialise the colours for the editor
603 */
604 resources_setColour(COLOUR_EDITOR);
605
606 /* Print the information dialog */
607 /* Clear Screen */
608 dspl_ClearAll();
609 switch (data->Ime.InputScreenType)
610 {
611 case TEXT_DISPLAY_SCREEN:
612 {
613
614 /* This section of the code was written to display the data stored in the text buffer. The text cursor position */
615 /* was also taken into consideration to display the correct portion of text during editing (when data stored in */
616 /* the text buffer is more than two line display. */
617 ZI8WCHAR TempArray[CANDIDATES_PER_GROUP*2]; //maximum no of chars possible in a line
618
619 dspl_BitBlt(75,0,8,8,0,(char*)TextIconeZiTextSmall,0);
620
621 memset(TempArray, 0, CANDIDATES_PER_GROUP*2);
622 if(data->Ime.TextBufferCount == 0) //If text buffer is empty
623 {
624 displaySoftKeys(data->Callback_Data.LeftSoftKey,TxtSoftBack); /* Softkey display*/
625 }
626 else
627
628 #ifndef LSCREEN
629 {
630 /*a0393213 warnings removal-variable definition for TempArray2, i and j moved from outer scope*/
631 ZI8WCHAR TempArray2[CANDIDATES_PER_GROUP+1];
632 int i;
633 int j = 0;
634 if(data->Ime.TextBufferCount <= (CANDIDATES_PER_GROUP * 2)) // data in text buffer is within 2 lines
635 {
636
637 for(i=0; i<CANDIDATES_PER_GROUP; i++)
638 TempArray[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i];
639 TempArray[CANDIDATES_PER_GROUP] = 0x0000;
640
641 dspl_TextOut(1,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)TempArray);
642 if(data->Ime.TextBufferCount > CANDIDATES_PER_GROUP)
643 {
644 for(i=0; i<CANDIDATES_PER_GROUP; i++)
645 TempArray2[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i+CANDIDATES_PER_GROUP];
646 TempArray2[CANDIDATES_PER_GROUP] = 0x0000;
647 dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char *)TempArray2);
648 }
649 j = (data->Ime.TextCursor / CANDIDATES_PER_GROUP) + 1;
650 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, j);
651 displaySoftKeys(data->Callback_Data.LeftSoftKey,TxtDelete); /* Softkey display*/
652 }
653 else // data in text buffer is more than 14 characters.
654 {
655 if(data->Ime.TextCursor == data->StartOfDisplayIndex)
656 {
657 for(i=0; i<CANDIDATES_PER_GROUP; i++)
658 TempArray[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i];
659 TempArray[CANDIDATES_PER_GROUP] = 0x0000;
660 dspl_TextOut(1,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char *)TempArray);
661 for(i=0; i<CANDIDATES_PER_GROUP; i++)
662 TempArray2[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i +CANDIDATES_PER_GROUP];
663 TempArray2[CANDIDATES_PER_GROUP] = 0x0000;
664 dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char *)TempArray2);
665 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 1);
666 }
667 else if(data->Ime.TextCursor > data->StartOfDisplayIndex)
668 {
669 while(data->Ime.TextCursor - data->StartOfDisplayIndex >= CANDIDATES_PER_GROUP*2)
670 {
671 data->StartOfDisplayIndex = data->StartOfDisplayIndex + CANDIDATES_PER_GROUP;
672 }
673 for(i=0; i<CANDIDATES_PER_GROUP; i++)
674 TempArray[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i];
675 TempArray[CANDIDATES_PER_GROUP] = 0x0000;
676 dspl_TextOut(1,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char *)TempArray);
677
678 for(i=0; i<CANDIDATES_PER_GROUP; i++)
679 TempArray2[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i +CANDIDATES_PER_GROUP];
680 TempArray2[CANDIDATES_PER_GROUP] = 0x0000;
681 dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char *)TempArray2);
682
683 if((data->Ime.TextCursor - data->StartOfDisplayIndex) < CANDIDATES_PER_GROUP)
684 j = 1;
685 else if((data->Ime.TextCursor - data->StartOfDisplayIndex) < CANDIDATES_PER_GROUP * 2)
686 j = 2;
687 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, j);
688 }
689 else if(data->Ime.TextCursor < data->StartOfDisplayIndex && data->StartOfDisplayIndex != 0)
690 {
691 data->StartOfDisplayIndex = data->StartOfDisplayIndex - CANDIDATES_PER_GROUP;
692 for(i=0; i<CANDIDATES_PER_GROUP; i++)
693 TempArray[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i ];
694 TempArray[CANDIDATES_PER_GROUP] = 0x0000;
695 dspl_TextOut(1,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char *)TempArray);
696 for(i=0; i<CANDIDATES_PER_GROUP; i++)
697 TempArray2[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i +CANDIDATES_PER_GROUP];
698 TempArray2[CANDIDATES_PER_GROUP] = 0x0000;
699 dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char *)TempArray2);
700 if((data->Ime.TextCursor - data->StartOfDisplayIndex) < CANDIDATES_PER_GROUP)
701 j = 1;
702 else if((data->Ime.TextCursor - data->StartOfDisplayIndex) < CANDIDATES_PER_GROUP * 2)
703 j = 2;
704 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, j);
705 }
706
707
708 displaySoftKeys(data->Callback_Data.LeftSoftKey,TxtDelete); /* Softkey display*/
709 }
710 }
711 #else /*SPR 1319, show editor and softkeys*/
712 /* SPR#1428 - SH - New Editor changes */
713 #ifdef NEW_EDITOR
714 ATB_edit_Unhide(data->editor);
715 ATB_edit_Show(data->editor);
716 #else /* NEW_EDITOR */
717 edtUnhide(data->editor);
718 edtShow(data->editor);
719 #endif /* NEW_EDITOR */
720 displaySoftKeys(data->Callback_Data.LeftSoftKey,TxtDelete);
721 #endif
722 }
723 break;
724 case STROKE_INPUT_SCREEN:
725 #ifndef LSCREEN
726 /* Display the correct portion composed text stored in wszTextBuffer. If the text cursor is not pointing at */
727 /* the end of the text buffer, the display content is then adjusted to display the correct portion of the */
728 /* text buffer. */
729 if(data->Ime.TextBufferCount <=CANDIDATES_PER_GROUP) //check text buffer count
730 {
731 if(data->Ime.TextBufferCount == data->Ime.TextCursor)
732 {
733 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer);
734 }
735 else
736 {
737 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer);
738 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 0);
739 }
740 }
741 else //when data->Ime.TextBufferCount > CANDIDATES_PER_GROUP
742 {
743 if(data->Ime.TextBufferCount == data->Ime.TextCursor)
744 {
745 Temp_ptr = data->wszTextBuffer;
746 Temp_ptr = Temp_ptr + data->Ime.TextBufferCount - CANDIDATES_PER_GROUP;
747 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char *)Temp_ptr);
748 }
749 else if(data->Ime.TextCursor < CANDIDATES_PER_GROUP)
750 {
751 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer);
752 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 0);
753 }
754 else
755 {
756 Temp_ptr = &data->wszTextBuffer[data->Ime.TextCursor] - CANDIDATES_PER_GROUP + 1;
757 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char *)Temp_ptr);
758 dspl_TextOut(73,0,DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)data->CursorPosition);
759 }
760 }
761 #else /*SPR 1319, show editor*/
762 /* SPR#1428 - SH - New Editor changes */
763 #ifdef NEW_EDITOR
764 ATB_edit_Unhide(data->editor);
765 ATB_edit_Show(data->editor);
766 #else /* NEW_EDITOR */
767 edtUnhide(data->editor);
768 edtShow(data->editor);
769 #endif /* NEW_EDITOR */
770 #endif
771 #ifndef LSCREEN
772 dspl_TextOut(0,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)StrokePrompt);/* Display input prompt */
773 #else
774 /*SPR 1319 show stroke prompt*/
775 dspl_TextOut(0,SCREEN_SIZE_Y-Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)StrokePrompt);/* Display input prompt */
776 #endif
777 /* Display input sequence for stroke */
778 i = Uni_strlen(data->DisplayElementBuffer);
779 if( i <= 4)
780 {
781 #ifndef LSCREEN
782 dspl_TextOut(CHI_FONT_WIDTH*3,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char*)data->DisplayElementBuffer);//data->wszElementBuffer);
783 #else
784 /*mc SPR1319*/
785 dspl_TextOut(CHI_FONT_WIDTH*3,SCREEN_SIZE_Y- Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)data->DisplayElementBuffer);//data->wszElementBuffer);
786 #endif
787 }
788 else
789 {
790 Temp_ptr = data->DisplayElementBuffer;
791 Temp_ptr = Temp_ptr + i - 4;
792 #ifndef LSCREEN
793 dspl_TextOut(CHI_FONT_WIDTH*3,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)Temp_ptr);//data->wszElementBuffer);
794 #else
795 /*mc SPR1319*/
796 dspl_TextOut(CHI_FONT_WIDTH*3,SCREEN_SIZE_Y-Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)Temp_ptr);//data->wszElementBuffer);
797 #endif
798 }
799
800 #ifndef LSCREEN
801 /* Display candidate characters returned from eZiText */
802 dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char*)data->wcCandidates);
803 #else
804 /*mc SPR1319*/
805 dspl_TextOut(1,SCREEN_SIZE_Y-Mmi_layout_line(3),DSPL_TXTATTR_UNICODE,(char*)data->wcCandidates);
806 #endif
807
808 /* Highlight the candidate character pointed by Ime.CandidateCursor */
809 CandidateHighlightDisplayContorl(&data->Ime, data->HighlightedCandidate);
810 if (Uni_strlen(data->DisplayElementBuffer) > 0)
811 displaySoftKeys(TxtSoftSelect,TxtDelete); /* Softkey display*/
812 else
813 displaySoftKeys(TxtSoftSelect,TxtSoftOK); /* Softkey display*/
814
815 break;
816 case PINYIN_INPUT_SCREEN:
817 /* Display the correct portion composed text stored in wszTextBuffer. If the text cursor is not pointing at */
818 /* the end of the text buffer, the display content is then adjusted to display the correct portion of the */
819 /* text buffer.
820 */
821 #ifndef LSCREEN
822 if(data->Ime.TextBufferCount <=CANDIDATES_PER_GROUP) //check text buffer count
823 {
824 if(data->Ime.TextBufferCount == data->Ime.TextCursor)
825 {
826 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer);
827 }
828 else
829 {
830 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer);
831 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 0);
832 }
833 }
834 else //when data->Ime.TextBufferCount > CANDIDATES_PER_GROUP
835 {
836 if(data->Ime.TextBufferCount == data->Ime.TextCursor)
837 {
838 Temp_ptr = data->wszTextBuffer;
839 Temp_ptr = Temp_ptr + data->Ime.TextBufferCount - CANDIDATES_PER_GROUP;
840 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char *)Temp_ptr);
841 }
842 else if(data->Ime.TextCursor < CANDIDATES_PER_GROUP)
843 {
844 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer);
845 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 0);
846 }
847 else
848 {
849 Temp_ptr = &data->wszTextBuffer[data->Ime.TextCursor] - CANDIDATES_PER_GROUP + 1;
850 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char *)Temp_ptr);
851 dspl_TextOut(73,0,DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)data->CursorPosition);
852 }
853 }
854 #else
855 /*mc SPR1319*/
856 /* SPR#1428 - SH - New Editor changes */
857 #ifdef NEW_EDITOR
858 ATB_edit_Unhide(data->editor);
859 ATB_edit_Show(data->editor);
860 #else /* NEW_EDITOR */
861 edtUnhide(data->editor);
862 edtShow(data->editor);
863 #endif /* NEW_EDITOR */
864 #endif
865 #ifndef LSCREEN
866 dspl_TextOut(0,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)PinYinPrompt);/* Display input prompt */
867 #else
868 /*mc SPR1319*/
869 dspl_TextOut(0,SCREEN_SIZE_Y - Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)PinYinPrompt);/* Display input prompt */
870 #endif
871 /* Display input sequence for Pin-yin input */
872 i = Uni_strlen(data->DisplayElementBuffer);
873 if( i <= 4)
874 {
875 #ifndef LSCREEN
876 dspl_TextOut(CHI_FONT_WIDTH*3,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)data->DisplayElementBuffer);//data->wszElementBuffer);
877 #else
878 /*mc SPR1319*/
879 dspl_TextOut(CHI_FONT_WIDTH*3,SCREEN_SIZE_Y-Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)data->DisplayElementBuffer);//data->wszElementBuffer);
880 #endif
881 }
882 else
883 {
884 Temp_ptr = data->DisplayElementBuffer;
885 Temp_ptr = Temp_ptr + i - 4;
886 #ifndef LSCREEN
887 dspl_TextOut(CHI_FONT_WIDTH*3,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)Temp_ptr);//data->wszElementBuffer);
888 #else
889 /*mc SPR1319*/
890 dspl_TextOut(CHI_FONT_WIDTH*3,SCREEN_SIZE_Y -Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)Temp_ptr);//data->wszElementBuffer);
891 #endif
892 }
893 /* Display candidate characters returned from eZiText */
894 #ifndef LSCREEN
895 dspl_TextOut(1,Mmi_layout_second_line(),DSPL_TXTATTR_UNICODE,(char*)data->wcCandidates);
896 #else
897 /*mc SPR1319*/
898 dspl_TextOut(1,SCREEN_SIZE_Y-Mmi_layout_line(3),DSPL_TXTATTR_UNICODE,(char*)data->wcCandidates);
899 #endif
900 /* Highlight the candidate character pointed by Ime.CandidateCursor */
901 CandidateHighlightDisplayContorl(&data->Ime, data->HighlightedCandidate);
902 /*MC should have "Delete" softkey when entering pinyin letters*/
903 if (Uni_strlen(data->DisplayElementBuffer) > 0)
904 displaySoftKeys(TxtSoftSelect,TxtDelete); /* Softkey display*/
905 else
906 displaySoftKeys(TxtSoftSelect,TxtSoftOK); /* Softkey display*/
907 break;
908 case WORD_ASSOCIATION_SCREEN:
909 /* Display the correct portion composed text stored in wszTextBuffer. If the text cursor is not pointing at */
910 /* the end of the text buffer, the display content is then adjusted to display the correct portion of the */
911 /* text buffer.
912 */
913 #ifndef LSCREEN
914 if(data->Ime.TextBufferCount <=CANDIDATES_PER_GROUP) //check text buffer count
915 {
916 if(data->Ime.TextBufferCount == data->Ime.TextCursor)
917 {
918 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer);
919 }
920 else
921 {
922 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer);
923 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 0);
924 }
925 }
926 else //when data->Ime.TextBufferCount > CANDIDATES_PER_GROUP
927 {
928 if(data->Ime.TextBufferCount == data->Ime.TextCursor)
929 {
930 Temp_ptr = data->wszTextBuffer;
931 Temp_ptr = Temp_ptr + data->Ime.TextBufferCount - CANDIDATES_PER_GROUP;
932 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char *)Temp_ptr);
933 }
934 else if(data->Ime.TextCursor < CANDIDATES_PER_GROUP)
935 {
936 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer);
937 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 0);
938 }
939 else
940 {
941 Temp_ptr = &data->wszTextBuffer[data->Ime.TextCursor] - CANDIDATES_PER_GROUP + 1;
942 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char *)Temp_ptr);
943 dspl_TextOut(73,0,DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)data->CursorPosition);
944 }
945 }
946 #else
947 /*mc SPR1319*/
948 /* SPR#1428 - SH - New Editor changes */
949 #ifdef NEW_EDITOR
950 ATB_edit_Unhide(data->editor);
951 ATB_edit_Show(data->editor);
952 #else /* NEW_EDITOR */
953 edtUnhide(data->editor);
954 edtShow(data->editor);
955 #endif /* NEW_EDITOR */
956 #endif
957 if(data->Ime.EditorMode == STROKE_INPUT_MODE)
958 {
959 #ifndef LSCREEN
960 dspl_TextOut(0,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)StrokePrompt); /* Display input prompt */
961 /* Display input sequence for stroke */
962 #else
963 /*mc SPR1319*/
964 dspl_TextOut(0,SCREEN_SIZE_Y -Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)StrokePrompt); /* Display input prompt */
965 /* Display input sequence for stroke */
966
967 #endif
968 }
969 else if(data->Ime.EditorMode == PINYIN_INPUT_MODE)
970 {
971 #ifndef LSCREEN
972 dspl_TextOut(0,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)PinYinPrompt); /* Display input prompt */
973 /* Display input sequence for Pin-yin input */
974 #else
975 dspl_TextOut(0,SCREEN_SIZE_Y-Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)PinYinPrompt); /* Display input prompt */
976 /* Display input sequence for Pin-yin input */
977 #endif
978 }
979 #ifndef LSCREEN
980 /* Display candidate charaters returned from eZiText */
981 dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char*)data->wcCandidates);
982 #else
983
984 dspl_TextOut(1,SCREEN_SIZE_Y-Mmi_layout_line(3),DSPL_TXTATTR_UNICODE,(char*)data->wcCandidates);
985 #endif
986 /* Highlight the candidate character pointed by Ime.CandidateCursor */
987 CandidateHighlightDisplayContorl(&data->Ime, data->HighlightedCandidate);
988
989 displaySoftKeys(TxtSoftSelect,TxtSoftOK); /* Softkey display*/
990 break;
991 default:
992 break;
993 }
994 }
995
996 break;
997 default:
998 return 0;
999 }
1000
1001 return 1;
1002 }
1003
1004
1005 /*******************************************************************************
1006
1007 $Function: chinese_input_kbd_cb
1008
1009 $Description: Keyboard event handler
1010
1011 $Returns: status int
1012
1013 $Arguments: window handle event, keyboard control block
1014
1015 *******************************************************************************/
1016
1017 static int chinese_input_kbd_cb (T_MFW_EVENT event, T_MFW_KBD *keyboard)
1018 {
1019 T_MFW_HND win = mfw_parent (mfw_header());
1020 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
1021 T_chinese_input * data = (T_chinese_input *)win_data->user;
1022
1023 // void (* Callback)() = data->Callback;
1024
1025 TRACE_EVENT("chinese_input_kbd_cb");
1026 /***************************Go-lite Optimization changes Start***********************/
1027 //Aug 16, 2004 REF: CRR 24323 Deepa M.D
1028 TRACE_EVENT_P6("Counters %d:%d:%d:%d:%d:%d", Counter[0], Counter[1], Counter[2], Counter[3],
1029 Counter[4], Counter[5]);
1030 /***************************Go-lite Optimization changes end***********************/
1031 switch (keyboard->code)
1032 {
1033 case KCD_LEFT:
1034 switch(data->Ime.EditorMode)
1035 {
1036 case STROKE_INPUT_MODE:
1037 switch (data->Ime.InputScreenType)
1038 {
1039 case TEXT_DISPLAY_SCREEN:
1040 //access to the option list.
1041 SEND_EVENT(win, CHINESE_INPUT_DEINIT/*SPR 1752*/, INFO_KCD_LEFT, NULL);
1042 break;
1043 case STROKE_INPUT_SCREEN:
1044 case WORD_ASSOCIATION_SCREEN:
1045 IMESelectCandidate(&data->Ime, data->wszElementBuffer);
1046 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1047 break;
1048 default:
1049 break;
1050 }
1051 winShow(win);
1052 break;
1053
1054 case PINYIN_INPUT_MODE:
1055 switch (data->Ime.InputScreenType)
1056 {
1057 case TEXT_DISPLAY_SCREEN:
1058 SEND_EVENT(win, CHINESE_INPUT_DEINIT/*SPR 1752*/, INFO_KCD_LEFT, NULL);
1059 //access to the option list.
1060 break;
1061 case PINYIN_INPUT_SCREEN:
1062 case WORD_ASSOCIATION_SCREEN:
1063 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/
1064 IMESelectCandidate(&data->Ime, data->wszElementBuffer);
1065 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1066
1067 break;
1068 default:
1069 break;
1070 }
1071 winShow(win);
1072 default:
1073 break;
1074 }
1075
1076 break;
1077 case KCD_RIGHT:
1078 switch(data->Ime.EditorMode)
1079 {
1080 case STROKE_INPUT_MODE:
1081 switch (data->Ime.InputScreenType)
1082 {
1083 case TEXT_DISPLAY_SCREEN:
1084 if(data->Ime.TextBufferCount == 0)
1085 { /* When there is no stored data, return back to the menu*/
1086 //GW-SPR-#1068-Destroy using event - execute callback of the function that created the editor
1087 SEND_EVENT(win, CHINESE_INPUT_DEINIT/*SPR 1752*/, INFO_KCD_RIGHT, NULL);
1088 }
1089 else
1090 {
1091 IMEClear(&data->Ime, data->wszElementBuffer);
1092 }
1093 break;
1094 case STROKE_INPUT_SCREEN:
1095 IMEClear(&data->Ime, data->wszElementBuffer);
1096 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1097 break;
1098 case WORD_ASSOCIATION_SCREEN:
1099 data->Ime.InputScreenType = TEXT_DISPLAY_SCREEN;
1100 break;
1101 default:
1102 break;
1103 }
1104 winShow(win);
1105 break;
1106 case PINYIN_INPUT_MODE:
1107 switch (data->Ime.InputScreenType)
1108 {
1109 case TEXT_DISPLAY_SCREEN:
1110 if(data->Ime.TextBufferCount == 0)
1111 { /* When there is no stored data, return back to the menu*/
1112 //GW-SPR-#1068-Destroy using event - execute callback of the function that created the editor
1113 SEND_EVENT(win, CHINESE_INPUT_DEINIT/*SPR 1752*/, INFO_KCD_RIGHT, NULL);
1114 }
1115 else
1116 {
1117 IMEClear(&data->Ime, data->wszElementBuffer);
1118 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1119 }
1120 break;
1121 case PINYIN_INPUT_SCREEN:
1122 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/
1123 IMEClear(&data->Ime, data->wszElementBuffer);
1124 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1125 break;
1126 case WORD_ASSOCIATION_SCREEN:
1127 data->Ime.InputScreenType = TEXT_DISPLAY_SCREEN;
1128 break;
1129 default:
1130 break;
1131 }
1132 winShow(win);
1133 break;
1134
1135 default:
1136 break;
1137 }
1138 break;
1139 case KCD_HUP:
1140 //GW-SPR-#1068-Destroy using event - execute callback of the function that created the editor
1141 SEND_EVENT(win, CHINESE_INPUT_DEINIT/*SPR 1752*/, INFO_KCD_HUP, NULL);
1142 break;
1143 case KCD_MNUUP:
1144 switch(data->Ime.EditorMode)
1145 {
1146 case STROKE_INPUT_MODE:
1147 switch (data->Ime.InputScreenType)
1148 {
1149 case TEXT_DISPLAY_SCREEN:
1150 //update the text cursor
1151 if(data->Ime.TextCursor > 0 && data->Ime.TextCursor <= data->Ime.TextBufferCount)
1152 {
1153 data->CursorPosition[0] = data->wszTextBuffer[data->Ime.TextCursor - 1];
1154 data->Ime.TextCursor--;
1155 }
1156 #ifdef LSCREEN /*SPR 1319 move left along editor*/
1157 /* SPR#1428 - SH - New Editor changes */
1158 #ifdef NEW_EDITOR
1159 ATB_edit_MoveCursor(data->editor, ctrlLeft, TRUE);
1160 #else /* NEW_EDITOR */
1161 edtChar(data->editor, ecLeft);
1162 #endif /* NEW_EDITOR */
1163 #endif
1164 break;
1165 case STROKE_INPUT_SCREEN:
1166 case WORD_ASSOCIATION_SCREEN:
1167 IMECursorLeft(&data->Ime);
1168 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1169 break;
1170 default:
1171 break;
1172 }
1173 winShow(win);
1174 break;
1175
1176 case PINYIN_INPUT_MODE:
1177 switch (data->Ime.InputScreenType)
1178 {
1179 case TEXT_DISPLAY_SCREEN:
1180 //update the text cursor
1181 if(data->Ime.TextCursor > 0 && data->Ime.TextCursor <= data->Ime.TextBufferCount)
1182 {
1183 data->CursorPosition[0] = data->wszTextBuffer[data->Ime.TextCursor - 1];
1184 data->Ime.TextCursor--;
1185
1186 }
1187 #ifdef LSCREEN/*SPR 1319 move left along editor*/
1188 /* SPR#1428 - SH - New Editor changes */
1189 #ifdef NEW_EDITOR
1190 ATB_edit_MoveCursor(data->editor, ctrlLeft, TRUE);
1191 #else /* NEW_EDITOR */
1192 edtCharUnicode(data->editor, ecLeft);
1193 #endif /* NEW_EDITOR */
1194 #endif
1195 break;
1196 case PINYIN_INPUT_SCREEN:
1197 case WORD_ASSOCIATION_SCREEN:
1198 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/
1199 IMECursorLeft(&data->Ime);
1200 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1201 break;
1202 default:
1203 break;
1204 }
1205 winShow(win);
1206 break;
1207 default:
1208 break;
1209 }
1210 break;
1211 case KCD_MNUDOWN:
1212 switch(data->Ime.EditorMode)
1213 {
1214 case STROKE_INPUT_MODE:
1215 switch (data->Ime.InputScreenType)
1216 {
1217 case TEXT_DISPLAY_SCREEN:
1218 //update the text cursor
1219 if(data->Ime.TextCursor < data->Ime.TextBufferCount)
1220 {
1221 data->Ime.TextCursor++;
1222 data->CursorPosition[0] = data->wszTextBuffer[data->Ime.TextCursor];
1223
1224 }
1225 #ifdef LSCREEN/*SPR 1319 move right along editor*/
1226 /* SPR#1428 - SH - New Editor changes */
1227 #ifdef NEW_EDITOR
1228 ATB_edit_MoveCursor(data->editor, ctrlRight, TRUE);
1229 #else /* NEW_EDITOR */
1230 edtCharUnicode(data->editor, ecRight);
1231 #endif /* NEW_EDITOR */
1232 #endif
1233 break;
1234 case STROKE_INPUT_SCREEN:
1235 case WORD_ASSOCIATION_SCREEN:
1236 IMECursorRight(&data->Ime);
1237 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1238 break;
1239 default:
1240 break;
1241 }
1242 winShow(win);
1243 break;
1244
1245 case PINYIN_INPUT_MODE:
1246 switch (data->Ime.InputScreenType)
1247 {
1248 case TEXT_DISPLAY_SCREEN:
1249 //update the text cursor
1250 if(data->Ime.TextCursor < data->Ime.TextBufferCount)
1251 {
1252 data->Ime.TextCursor++;
1253 data->CursorPosition[0] = data->wszTextBuffer[data->Ime.TextCursor];
1254 }
1255 #ifdef LSCREEN /*SPR 1319 move right along editor*/
1256 /* SPR#1428 - SH - New Editor changes */
1257 #ifdef NEW_EDITOR
1258 ATB_edit_MoveCursor(data->editor, ctrlRight, TRUE);
1259 #else /* NEW_EDITOR */
1260 edtCharUnicode(data->editor, ecRight);
1261 #endif /* NEW_EDITOR */
1262 #endif
1263 break;
1264 case PINYIN_INPUT_SCREEN:
1265 case WORD_ASSOCIATION_SCREEN:
1266 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/
1267 IMECursorRight(&data->Ime);
1268 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1269 break;
1270 default:
1271 break;
1272 }
1273 winShow(win);
1274 break;
1275 default:
1276 break;
1277 }
1278 break;
1279 case KCD_CALL:
1280 break;
1281 case KCD_0:
1282 if (data->Ime.TextBufferCount < TEXT_BUFFER_EDIT_SIZE)/*MC*/
1283 {
1284 switch(data->Ime.EditorMode)
1285 {
1286 case STROKE_INPUT_MODE:
1287 data->Ime.InputScreenType = STROKE_INPUT_SCREEN;
1288 IMEMore(&data->Ime);
1289 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1290 winShow(win);
1291 break;
1292 case PINYIN_INPUT_MODE:
1293 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/
1294 data->Ime.InputScreenType = PINYIN_INPUT_SCREEN;
1295 IMEMore(&data->Ime);
1296 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1297 winShow(win);
1298 break;
1299
1300 default:
1301 break;
1302 }
1303 }
1304 break;
1305 case KCD_8:
1306 if (data->Ime.TextBufferCount < TEXT_BUFFER_EDIT_SIZE)/*MC*/
1307 {
1308 switch(data->Ime.EditorMode)
1309 {
1310 case STROKE_INPUT_MODE:
1311 data->Ime.InputScreenType = STROKE_INPUT_SCREEN;
1312 IMEMore(&data->Ime);
1313 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1314 winShow(win);
1315 break;
1316 case PINYIN_INPUT_MODE:
1317 data->Ime.InputScreenType = PINYIN_INPUT_SCREEN;
1318 /* The unclear of eZiText document, it is assumed that multi-key press may required to get to the required letter */
1319 /* To do that a ZiPinYinKeyMap array is defined in ChineseInput.h header file. */
1320 /* When number of keypress from the user is given from the keypad hadler, the key press count can then be */
1321 /* used to work out the relevent code to insert into the element buffer for eZiText search. The variable */
1322 /* data->NumberOfKeyPress is decleared to store the key press count. */
1323
1324 //temp = data->NumberOfKeyPress % ZiPinYinKeyMap[(keyboard->code)-1][5];
1325 //IMEKeyPress(&data->Ime, (ZI8WCHAR) ZiPinYinKeyMap[(keyboard->code)-1][temp - 1]);
1326
1327 /* due to not able to receive key press count, it is assume the first letter assign to the key is selected when key */
1328 /* is pressed. */
1329 /*MC, multitap handling*/
1330 /*if time out or new key pressed*/
1331 /***************************Go-lite Optimization changes Start***********************/
1332 //Aug 16, 2004 REF: CRR 24323 Deepa M.D
1333 TRACE_EVENT_P1("Keypad Counter : %d", Counter[keyboard->code]);
1334 /***************************Go-lite Optimization changes end***********************/
1335 if ( Counter[keyboard->code] == 0)
1336 { tim_stop(data->KeyPad_Timer_Handle);/*stop timer*/
1337 memset( Counter, 0, sizeof(char)*KCD_STAR);/*reset all key counters*/
1338 IMEKeyPress(&data->Ime, (ZI8WCHAR) ZiPinYinKeyMap[(keyboard->code)-1][0]);
1339 Counter[keyboard->code]++; //increment counter
1340 tim_start(data->KeyPad_Timer_Handle);/*restart timer*/
1341 }
1342 else /*if counter is less than MAX for that key*/
1343 { ZI8WCHAR last_element;
1344
1345 if ( Counter[keyboard->code] <ZiPinYinKeyMap[(keyboard->code)-1][5])
1346 { tim_stop(data->KeyPad_Timer_Handle);/*stop timer*/
1347 //if last element is the previous char for this key
1348 last_element = data->Ime.pGetParam->pElements[data->Ime.pGetParam->ElementCount -1];
1349 //should put in check
1350 if (last_element== ZiPinYinKeyMap[(keyboard->code)-1][ Counter[keyboard->code]-1])
1351 { //MC e.g. if we're trying to enter 'I' and the last char was 'H'
1352 IMEClear(&data->Ime, data->Ime.pGetParam->pElements);/*remove last char from elements*/
1353 data->Ime.InputScreenType = PINYIN_INPUT_SCREEN;/*this prevents display problems*/
1354 }
1355 /*so we can add the next char for this key*/
1356 IMEKeyPress(&data->Ime, (ZI8WCHAR) ZiPinYinKeyMap[(keyboard->code)-1][ Counter[keyboard->code]]);
1357 Counter[keyboard->code]++; //increment counter
1358 tim_start(data->KeyPad_Timer_Handle);/*restart timer*/
1359 }
1360 }
1361
1362 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1363 winShow(win);
1364 break;
1365 default:
1366 break;
1367 }
1368 }
1369 break;
1370 case KCD_1:
1371 case KCD_2:
1372 case KCD_3:
1373 case KCD_4:
1374 case KCD_5:
1375 case KCD_6:
1376 case KCD_7:
1377 case KCD_9:
1378 switch(data->Ime.EditorMode)
1379 {
1380 case STROKE_INPUT_MODE:
1381 if (data->Ime.TextBufferCount < TEXT_BUFFER_EDIT_SIZE)/*MC*/
1382 { data->Ime.InputScreenType = STROKE_INPUT_SCREEN;
1383 IMEKeyPress(&data->Ime, (ZI8WCHAR) ZiStrokeKeyMap[keyboard->code][1] + ZI8_BASE_STROKES);
1384 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1385 winShow(win);
1386 }
1387 break;
1388
1389 case PINYIN_INPUT_MODE:
1390 if (data->Ime.TextBufferCount < TEXT_BUFFER_EDIT_SIZE)/*MC*/
1391 {
1392 data->Ime.InputScreenType = PINYIN_INPUT_SCREEN;
1393 /*MC, multitap handling*/
1394 /***************************Go-lite Optimization changes Start***********************/
1395 //Aug 16, 2004 REF: CRR 24323 Deepa M.D
1396 TRACE_EVENT_P1("Keypad Counter : %d", Counter[keyboard->code]);
1397 /***************************Go-lite Optimization changes end***********************/
1398 /*if time out or new key pressed*/
1399 if ( Counter[keyboard->code] == 0)
1400 { tim_stop(data->KeyPad_Timer_Handle);/*stop timer*/
1401 memset( Counter, 0, sizeof(char)*KCD_STAR);/*reset all key counters*/
1402 IMEKeyPress(&data->Ime, (ZI8WCHAR) ZiPinYinKeyMap[(keyboard->code)-1][0]);
1403 Counter[keyboard->code]++; //increment counter
1404 tim_start(data->KeyPad_Timer_Handle);/*restart timer*/
1405 }
1406 else /*if counter is less than MAX for that key*/
1407 { ZI8WCHAR last_element;
1408
1409 if ( Counter[keyboard->code] <ZiPinYinKeyMap[(keyboard->code)-1][5])
1410 { tim_stop(data->KeyPad_Timer_Handle);/*stop timer*/
1411 last_element = data->Ime.pGetParam->pElements[data->Ime.pGetParam->ElementCount -1];
1412 //should put in check
1413 //e.g. if last char was 'a' and we're entering 'b'
1414 if (last_element== ZiPinYinKeyMap[(keyboard->code)-1][ Counter[keyboard->code]-1])
1415 { IMEClear(&data->Ime, data->Ime.pGetParam->pElements);/*remove last char from elements*/
1416 data->Ime.InputScreenType = PINYIN_INPUT_SCREEN;/*this prevents display problems*/
1417 }
1418 /*so we can add the next char for this key*/
1419 IMEKeyPress(&data->Ime, (ZI8WCHAR) ZiPinYinKeyMap[(keyboard->code)-1][ Counter[keyboard->code]]);
1420 Counter[keyboard->code]++; //increment counter
1421 tim_start(data->KeyPad_Timer_Handle);/*restart timer*/
1422 }
1423 }
1424 //IMEKeyPress(&data->Ime, (ZI8WCHAR) ZiPinYinKeyMap[(keyboard->code)-1][/*0*/2]);
1425 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor];
1426 winShow(win);
1427 }
1428 break;
1429
1430 default:
1431 break;
1432 }
1433 break;
1434 case KCD_STAR:
1435 if (data->Ime.TextBufferCount < TEXT_BUFFER_EDIT_SIZE)/*MC*/
1436 {
1437 switch(data->Ime.EditorMode)
1438 {
1439 case STROKE_INPUT_MODE:
1440 /* SPR#1428 - SH - New Editor uses new symbol selector */
1441 #ifdef NEW_EDITOR
1442 AUI_symbol_Start(win, ADD_SYMBOL);
1443 #else /* NEW_EDITOR */
1444 SymbolScreenstart(win, NULL);
1445 #endif /* NEW_EDITOR */
1446 break;
1447 case PINYIN_INPUT_MODE:
1448 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/
1449 /* SPR#1428 - SH - New Editor uses new symbol selector */
1450 #ifdef NEW_EDITOR
1451 AUI_symbol_Start(win, ADD_SYMBOL);
1452 #else /* NEW_EDITOR */
1453 SymbolScreenstart(win, NULL);
1454 #endif /* NEW_EDITOR */
1455 break;
1456 default:
1457 break;
1458 }
1459 }
1460
1461 break;
1462 case KCD_HASH:
1463 if (data->Ime.TextBufferCount < TEXT_BUFFER_EDIT_SIZE)/*MC*/
1464 {
1465 switch(data->Ime.EditorMode)
1466 {
1467 /* SPR#1428 - SH - New Editor changes */
1468 #ifdef NEW_EDITOR
1469 T_AUI_EDITOR_DATA editor_data;
1470 #else /* NEW_EDITOR */
1471 T_EDITOR_DATA editor_data;
1472 #endif /* NEW_EDITOR */
1473 case STROKE_INPUT_MODE:
1474 data->Ime.EditorMode = PINYIN_INPUT_MODE;
1475 break;
1476 case PINYIN_INPUT_MODE:
1477 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/
1478 /* SPR#1428 - SH - New Editor changes */
1479 #ifdef NEW_EDITOR
1480 AUI_edit_SetDefault(&editor_data);
1481 #else /* NEW_EDITOR */
1482 editor_attr_init(&editor_data.editor_attr, NULL, edtCurBar1, 0, 0, 0, 0);
1483 editor_data.hide = FALSE;
1484 editor_data.TextId = '\0';
1485 editor_data.TextString = NULL;
1486 editor_data.timeout = FOREVER; // Avoid to return empty strings
1487 #endif /* NEW_EDITOR */
1488 //set mode to stroke input when Latin editor exited
1489 data->Ime.EditorMode = STROKE_INPUT_MODE;
1490 /* SPR#1428 - SH - New Editor changes */
1491 #ifdef NEW_EDITOR
1492 AUI_edit_SetDisplay(&editor_data, ZONE_FULL_SK_TITLE, COLOUR_EDITOR, EDITOR_FONT);
1493 AUI_edit_SetBuffer(&editor_data, ATB_DCS_UNICODE, (UBYTE *)data->Callback_Data.TextString, data->Callback_Data.EditorSize*2 + 3);
1494 AUI_edit_SetMode(&editor_data, ED_MODE_ALPHA, ED_CURSOR_BAR);
1495 AUI_edit_SetTextStr(&editor_data, TxtChinese, TxtDelete, TxtNull, NULL);
1496 AUI_edit_SetEvents(&editor_data, LATIN_INPUT, TRUE, FOREVER, (T_AUI_EDIT_CB)chinese_input_exec);
1497 AUI_edit_Start(data->input_win, &editor_data);
1498 #else /* NEW_EDITOR */
1499 editor_data.editor_attr.text = (char *)data->Callback_Data.TextString;
1500 editor_data.editor_attr.size = data->Callback_Data.EditorSize*2 + 3;
1501 editor_data.min_enter = 0;
1502 editor_data.mode = ALPHA_MODE;
1503 editor_data.LeftSoftKey = TxtChinese;
1504 editor_data.AlternateLeftSoftKey = TxtSoftBack;
1505 editor_data.RightSoftKey = TxtDelete;
1506 editor_data.Identifier = LATIN_INPUT;
1507 editor_data.Callback = (T_EDIT_CB)chinese_input_exec/*NULL*/;
1508 editor_data.destroyEditor = TRUE;
1509 editor_start(data->input_win, &editor_data);
1510 #endif /* NEW_EDITOR */
1511 break;
1512 default:
1513
1514 break;
1515 }
1516
1517 memset(&data->DisplayElementBuffer, 0,sizeof(data->DisplayElementBuffer));
1518
1519 IMEChangeMode(&data->Ime,&data->GetParam);
1520 winShow(win);
1521 }
1522 break;
1523 default:
1524 break;
1525 }
1526 return MFW_EVENT_CONSUMED;
1527 }
1528
1529
1530 /*******************************************************************************
1531
1532 $Function:
1533
1534 $Description:
1535 $Returns:
1536
1537 $Arguments: menu and menu item (neither used)
1538
1539 *******************************************************************************/
1540 int chinese_input_menu(MfwMnu* m, MfwMnuItem* i)
1541 {
1542 T_MFW_HND parent = mfwParent( mfw_header() );
1543 chinese_input( parent, NULL );
1544 return MFW_EVENT_CONSUMED;
1545 }
1546
1547
1548 /*******************************************************************************
1549
1550 $Function: IMEChangeMode
1551
1552 $Description: This function change some of the setting when user selected to use
1553 different input method. E.g change from Stroke to Pin-yin input.
1554
1555 $Returns: void
1556
1557 $Arguments:
1558
1559 *******************************************************************************/
1560 void IMEChangeMode(PIME_DATA pIME, PZI8GETPARAM pGetParam)
1561 {
1562 /* First initialize the members that will be constant */
1563 switch(pIME->EditorMode)
1564 {
1565 case STROKE_INPUT_MODE:
1566 pGetParam->Language = ZI8_LANG_ZH;
1567 pGetParam->GetMode = ZI8_GETMODE_STROKES;
1568 pGetParam->SubLanguage = ZI8_SUBLANG_ZH;
1569 /*MC, check size of editor to work out context*/
1570 if (TEXT_BUFFER_EDIT_SIZE <= MAX_PHONEBOOK_ENTRY_SIZE)
1571 pGetParam->Context = ZI8_GETCONTEXT_SURNAME;
1572 else
1573 pGetParam->Context = ZI8_GETCONTEXT_SMS;
1574 pGetParam->GetOptions = ZI8_GETOPTION_ALLCOMPONENTS;
1575 break;
1576 case PINYIN_INPUT_MODE:
1577 pGetParam->Language = ZI8_LANG_ZH;
1578 pGetParam->GetMode = ZI8_GETMODE_PINYIN;
1579 pGetParam->SubLanguage = ZI8_SUBLANG_ZH/*ZI8_SUBLANG_ZH_ALL*/;
1580 /*MC, check size of editor to work out context*/
1581 if (TEXT_BUFFER_EDIT_SIZE <= MAX_PHONEBOOK_ENTRY_SIZE)
1582 pGetParam->Context = ZI8_GETCONTEXT_SURNAME;
1583 else
1584 pGetParam->Context = ZI8_GETCONTEXT_SMS;
1585 pGetParam->GetOptions = ZI8_GETOPTION_NOCOMPONENTS/*ZI8_GETOPTION_SAMESOUND*/;
1586 break;
1587 case LATIN_INPUT_MODE:
1588 pIME->InputScreenType = TEXT_DISPLAY_SCREEN;
1589 break;
1590 default:
1591 break;
1592 }
1593 pIME->InputScreenType = TEXT_DISPLAY_SCREEN;
1594 memset(pGetParam->pElements, 0, sizeof(pGetParam->pElements));
1595 memset(pIME->pDisplayElementBuffer, 0,sizeof(pIME->pDisplayElementBuffer));
1596 /* save the pointer to the ZI8GETPARAM structure in the IME data */
1597 pIME->pGetParam = pGetParam;
1598 /* now initialize the text buffer and element buffer */
1599 pIME->moreCount = 0;
1600 pGetParam->ElementCount = 0;
1601 /* initilalize the WordCharacterCount to zero */
1602 pGetParam->WordCharacterCount = 0;
1603 /* initialize the saved number of candidates to zero */
1604 pIME->candidates = 0;
1605 /* initialize the candidate cursor to zero */
1606 pIME->CandidateCursor = 0;
1607 }
1608
1609
1610 /*******************************************************************************
1611
1612 $Function: IMEInitialize
1613
1614 $Description: This function initializes the ZI8GETPARAM structure defined in the API
1615 and the various members of the IME_DATA structure defined in to keep
1616 track of the IME.
1617
1618 $Returns: void
1619
1620 $Arguments:
1621
1622 *******************************************************************************/
1623 /*void IMEInitialize(PIME_DATA pIME, PZI8GETPARAM pGetParam, PZI8WCHAR wszTextBuffer, int TextBufferEditSize,
1624 int TextBufferSize, PZI8WCHAR pCandidates)*/
1625 void IMEInitialize(PIME_DATA pIME, PZI8GETPARAM pGetParam, PZI8WCHAR wszTextBuffer,
1626 int TextBufferEditSize, int TextBufferSize, PZI8WCHAR pCandidates,
1627 PZI8WCHAR wszElementBuffer, PZI8WCHAR DisplayElementBuffer)
1628 {
1629 pIME->EditorMode = STROKE_INPUT_MODE;
1630 /* First initialize the members that will be constant */
1631 switch(pIME->EditorMode)
1632 {
1633 case STROKE_INPUT_MODE:
1634 pGetParam->Language = ZI8_LANG_ZH;
1635 pGetParam->GetMode = ZI8_GETMODE_STROKES;
1636 pGetParam->SubLanguage = ZI8_SUBLANG_ZH;
1637 /*MC, check size of editor to work out context*/
1638 if (TEXT_BUFFER_EDIT_SIZE <= MAX_PHONEBOOK_ENTRY_SIZE)
1639 pGetParam->Context = ZI8_GETCONTEXT_SURNAME;
1640 else
1641 pGetParam->Context = ZI8_GETCONTEXT_SMS;
1642
1643 pGetParam->GetOptions = ZI8_GETOPTION_ALLCOMPONENTS;
1644 break;
1645 case PINYIN_INPUT_MODE:
1646 pGetParam->Language = ZI8_LANG_ZH;
1647 pGetParam->GetMode = ZI8_GETMODE_PINYIN;
1648 pGetParam->SubLanguage = ZI8_SUBLANG_ZH;
1649 if (TEXT_BUFFER_EDIT_SIZE <= MAX_PHONEBOOK_ENTRY_SIZE)
1650 pGetParam->Context = ZI8_GETCONTEXT_SURNAME;
1651 else
1652 pGetParam->Context = ZI8_GETCONTEXT_SMS;
1653 pGetParam->GetOptions = ZI8_GETOPTION_NOCOMPONENTS/*ZI8_GETOPTION_SAMESOUND*/;
1654 break;
1655 case LATIN_INPUT_MODE:
1656 break;
1657 default:
1658 break;
1659 }
1660 /* save the pointer to the ZI8GETPARAM structure in the IME data */
1661 pIME->pGetParam = pGetParam;
1662 /* now initialize the text buffer and element buffer */
1663 pIME->pTextBuffer = wszTextBuffer;
1664 pIME->TextBufferEditSize = TextBufferEditSize;
1665 pIME->TextBufferSize = TextBufferSize;
1666 pIME->moreCount = 0;
1667 pIME->TextBufferCount = Uni_strlen(wszTextBuffer);;
1668 pIME->TextCursor = pIME->TextBufferCount;
1669 pIME->pDisplayElementBuffer = DisplayElementBuffer;
1670 pIME->InputScreenType = TEXT_DISPLAY_SCREEN;
1671
1672 pGetParam->pElements = wszElementBuffer;
1673 pGetParam->ElementCount = 0;
1674 /* initilalize the WordCharacterCount to zero */
1675 pGetParam->WordCharacterCount = 0;
1676 /*initial pointer to the candidate buffer*/
1677 pGetParam->pCandidates = pCandidates;
1678 /* initialize the saved number of candidates to zero */
1679 pIME->candidates = 0;
1680 /* initialize the candidate cursor to zero */
1681 pIME->CandidateCursor = 0;
1682 }
1683
1684
1685 /*******************************************************************************
1686
1687 $Function: IMECursorLeft
1688
1689 $Description: Move the candidate cursor left
1690
1691 $Returns: void
1692
1693 $Arguments:
1694
1695 *******************************************************************************/
1696 /*
1697 GW SPR#1732 - Corrected cursor position from '6' to 'CANDIDATES_PER_GROUP - 1'
1698 */
1699
1700 void IMECursorLeft(PIME_DATA pIME)
1701 {
1702 TRACE_EVENT ("IMECursorLeft()");
1703 if(pIME->CandidateCursor != 0)
1704 {
1705 pIME->CandidateCursor--;
1706 pIME->candidates = Zi8GetCandidates(pIME->pGetParam);
1707 DataConvert(pIME);
1708 }
1709 /* check ElementCount to see whether ElementBuffer is empty and check if where is any more tick in the element buffer. */
1710 else if(pIME->pGetParam->ElementCount != 0 &&
1711 pIME->pGetParam->pElements[pIME->pGetParam->ElementCount-1] == ZI8_CODE_MORE)
1712 {
1713 /* If the last input is a more tick, remove it */
1714 pIME->moreCount--;
1715 /* replace last element with zero */
1716 pIME->pGetParam->pElements[--pIME->pGetParam->ElementCount] = 0;
1717 /* get candidates with the new stroke */
1718 pIME->pGetParam->FirstCandidate = pIME->moreCount * CANDIDATES_PER_GROUP;
1719 pIME->pGetParam->MaxCandidates = CANDIDATES_PER_GROUP + 1;
1720 pIME->candidates = Zi8GetCandidates(pIME->pGetParam);
1721 DataConvert(pIME);
1722 /* initialize the candidate cursor the character position*/
1723 pIME->CandidateCursor =CANDIDATES_PER_GROUP - 1;
1724 }
1725 }
1726
1727
1728 /*******************************************************************************
1729
1730 $Function: IMECursorRight
1731
1732 $Description: Move the candidate cursor right
1733
1734 $Returns: void
1735
1736 $Arguments:
1737
1738 *******************************************************************************/
1739 /*
1740 GW SPR#1732 - Corrected test for cursor position from '6' to 'CANDIDATES_PER_GROUP - 1'
1741 */
1742 void IMECursorRight(PIME_DATA pIME)
1743 {
1744 TRACE_EVENT("IMECursorRight()");
1745 /* If the candidate cursor is greater than the display ability, more tick is add to the element buffer */
1746 /* to request for next set of characters. */
1747 if(pIME->CandidateCursor >= CANDIDATES_PER_GROUP - 1)
1748 {
1749 pIME->moreCount++;
1750 pIME->pGetParam->pElements[pIME->pGetParam->ElementCount++] = ZI8_CODE_MORE;
1751 /* get new candidates */
1752 pIME->pGetParam->FirstCandidate = pIME->moreCount * CANDIDATES_PER_GROUP;
1753 pIME->pGetParam->MaxCandidates = CANDIDATES_PER_GROUP + 1;
1754 pIME->candidates = Zi8GetCandidates(pIME->pGetParam);
1755 DataConvert(pIME);
1756 /* initialize the candidate cursor to zero */
1757 pIME->CandidateCursor = 0;
1758 }
1759 /* Check number of available candidates before increment of candidate cursor is allowed */
1760 else if(pIME->candidates > (pIME->CandidateCursor + 1))
1761 { pIME->CandidateCursor++;
1762 pIME->candidates = Zi8GetCandidates(pIME->pGetParam);
1763 DataConvert(pIME);
1764 }
1765 }
1766
1767
1768 /*******************************************************************************
1769
1770 $Function: IMESelectCandidate
1771
1772 $Description: Select the cadidate at cursor.
1773
1774 $Returns: void
1775
1776 $Arguments:
1777
1778 *******************************************************************************/
1779 void IMESelectCandidate(PIME_DATA pIME, PZI8WCHAR wszElementBuffer)
1780 {
1781 int i = 0;
1782 int j = 0;
1783 ZI8WCHAR HighByte;
1784 ZI8WCHAR Temp;
1785 ZI8WCHAR LowByte;
1786
1787 TRACE_EVENT("IMESelectCandidate()");
1788
1789
1790 /* we can allow selection only if we have candidates*/
1791 if(pIME->candidates == 0)
1792 return;
1793 /* if we have elements in the test we must now remove them */
1794 while(pIME->pGetParam->ElementCount > 0)
1795 {
1796 pIME->pGetParam->pElements[--pIME->pGetParam->ElementCount] = 0;
1797 }
1798 /* the more count must be set to zero */
1799 pIME->moreCount = 0;
1800
1801 /* check the limit of the text buffer. Stop user to enter character when text buffer is full */
1802 if(pIME->TextBufferCount >= TEXT_BUFFER_EDIT_SIZE)
1803 {
1804 //messages can be added to inform user when text buffer is full.
1805 return;
1806 }
1807
1808 /* chek if the selected candidate is a component. To do that the storage format has to be change. */
1809 /* Followin bit shifting procedure is used the perfrom the task. */
1810 LowByte = pIME->pGetParam->pCandidates[pIME->CandidateCursor] & 0x00FF;
1811 HighByte = pIME->pGetParam->pCandidates[pIME->CandidateCursor] & 0xFF00;
1812 Temp = (LowByte << 8) & 0xFF00;
1813 HighByte = (HighByte >> 8) & 0x00FF;
1814 Temp = Temp | HighByte;
1815
1816 if(Temp > ZI8_BASE_COMPONENTS && Temp < ZI8_BASE_BPMF) /* check if the selected candidate is a component */
1817 {
1818 memset(pIME->pDisplayElementBuffer, 0,sizeof(pIME->pDisplayElementBuffer));
1819 pIME->pDisplayElementBuffer[0] = pIME->pGetParam->pCandidates[pIME->CandidateCursor];
1820
1821 pIME->pGetParam->pElements[0] = Temp;
1822 pIME->pGetParam->ElementCount = 1;
1823 }
1824 else /* The selected character is character not a component */
1825 {
1826 if(pIME->TextCursor < pIME->TextBufferCount) /* locate the text cursor position for correct character insertion */
1827 {
1828 for (i=pIME->TextCursor; i<pIME->TextBufferCount; i++) /* shift and move characters to make rooms to insert the selected character */
1829 {
1830 //pIME->pTextBuffer[pIME->TextBufferCount - i + 1]=pIME->pTextBuffer[pIME->TextBufferCount - i];
1831 pIME->pTextBuffer[pIME->TextBufferCount - j]=pIME->pTextBuffer[pIME->TextBufferCount - j - 1];
1832 j++;
1833 }
1834 }
1835 #ifndef LSCREEN
1836 /* now added this character to the text */
1837 pIME->pTextBuffer[pIME->TextCursor++] = pIME->pGetParam->pCandidates[pIME->CandidateCursor];
1838 #else /*SPR 1319 Add candidate to editor*/
1839 /* SPR#1428 - SH - New Editor changes */
1840 #ifdef NEW_EDITOR
1841 ATB_edit_Char(editor_pointer, (USHORT )pIME->pGetParam->pCandidates[pIME->CandidateCursor], TRUE);
1842 #else /* NEW_EDITOR */
1843 edtCharUnicode(editor_pointer, pIME->pGetParam->pCandidates[pIME->CandidateCursor]);
1844 #endif /* NEW_EDITOR */
1845 pIME->TextCursor++;
1846 #endif
1847 /* Change input screen type */
1848 pIME->InputScreenType = WORD_ASSOCIATION_SCREEN;
1849 /* upate the element buffer to its new position */
1850 pIME->pGetParam->pElements = wszElementBuffer;
1851
1852 /* Adjust the word association. If the candidate we selected was a word candidat, */
1853 /* then we continue the word association. Otherwise this character begins a new word */
1854 if(pIME->pGetParam->wordCandidates > pIME->CandidateCursor)
1855 {
1856 pIME->pGetParam->WordCharacterCount++;
1857 }
1858 else
1859 {
1860 pIME->pGetParam->pCurrentWord = &pIME->pTextBuffer[pIME->TextCursor - 1];
1861 pIME->pGetParam->WordCharacterCount = 1;
1862 }
1863 /* get new candidates */
1864 pIME->pGetParam->FirstCandidate = pIME->moreCount * CANDIDATES_PER_GROUP;
1865 pIME->pGetParam->MaxCandidates = CANDIDATES_PER_GROUP + 1;
1866 //increase TextBufferCount by one
1867 pIME->TextBufferCount++;
1868 memset(pIME->pDisplayElementBuffer, 0, sizeof(pIME->pDisplayElementBuffer));
1869 }
1870 pIME->candidates = Zi8GetCandidates(pIME->pGetParam);
1871 DataConvert(pIME);
1872 /* initialize the candidate cursor to zero */
1873 pIME->CandidateCursor = 0;
1874 }
1875
1876
1877 /*******************************************************************************
1878
1879 $Function: IMEMore
1880
1881 $Description: Get the next group of candidates. For this function, we add the more tick
1882 to the element buffer and increase the more count. Then we get the
1883 next group of candidates.
1884
1885 $Returns: void
1886
1887 $Arguments:
1888
1889 *******************************************************************************/
1890 void IMEMore(PIME_DATA pIME)
1891 {
1892 TRACE_EVENT("IMEMore()");
1893
1894 pIME->moreCount++;
1895 pIME->pGetParam->pElements[pIME->pGetParam->ElementCount++] = ZI8_CODE_MORE;
1896 /* get new candidates */
1897 pIME->pGetParam->FirstCandidate = pIME->moreCount * CANDIDATES_PER_GROUP;
1898 pIME->pGetParam->MaxCandidates = CANDIDATES_PER_GROUP + 1;
1899 pIME->candidates = Zi8GetCandidates(pIME->pGetParam);
1900 DataConvert(pIME);
1901 /* initialize the candidate cursor to zero */
1902 pIME->CandidateCursor = 0;
1903 }
1904
1905
1906 /*******************************************************************************
1907
1908 $Function: IMEKeyPress
1909
1910 $Description: Enter the stroke and get new candidates. However, any more ticks from
1911 the element buffer must be removed before any stroke is to be added.
1912
1913 $Returns: void
1914
1915 $Arguments:
1916
1917 *******************************************************************************/
1918 void IMEKeyPress(PIME_DATA pIME, ZI8WCHAR wcStroke)
1919 {
1920 PZI8WCHAR element_buffer;
1921
1922 TRACE_EVENT ("IMEKeyPress()");
1923
1924 /* remove any trailing more ticks and set the more count back to zero */
1925 while((pIME->pGetParam->ElementCount > 0) && pIME->pGetParam->pElements[pIME->pGetParam->ElementCount-1] == ZI8_CODE_MORE)
1926 {
1927 pIME->pGetParam->pElements[--pIME->pGetParam->ElementCount] = 0;
1928 }
1929 pIME->moreCount = 0;
1930
1931 /* Check the limit of the element buffer. Stop user to enter stroke or Pin Yin letter */
1932 /* when element budder is full */
1933 if(pIME->pGetParam->ElementCount >= TEXT_BUFFER_EXTRA_SPACE)
1934 {
1935 return;
1936 }
1937 /* Insert the stroke or the Pin Yin letter into the element buffer for character search */
1938 pIME->pGetParam->pElements[pIME->pGetParam->ElementCount++] = wcStroke;
1939
1940 /*MC, let's check what's in the element buffer*/
1941
1942 element_buffer = pIME->pGetParam->pElements;
1943 /***************************Go-lite Optimization changes Start***********************/
1944 //Aug 16, 2004 REF: CRR 24323 Deepa M.D
1945 TRACE_EVENT_P5("Element List: %c, %c, %c, %c, %c", (element_buffer[0]-ZI8_BASE_PINYIN+65), (element_buffer[1]-ZI8_BASE_PINYIN+65), (element_buffer[2]-ZI8_BASE_PINYIN+65), (element_buffer[3]-ZI8_BASE_PINYIN+65), (element_buffer[4]-ZI8_BASE_PINYIN+65));
1946 /***************************Go-lite Optimization changes end***********************/
1947 /*MC --end debug code*/
1948
1949 /* get candidates with the new stroke */
1950 pIME->pGetParam->FirstCandidate = pIME->moreCount * CANDIDATES_PER_GROUP;
1951 pIME->pGetParam->MaxCandidates = CANDIDATES_PER_GROUP + 1;
1952 pIME->candidates = Zi8GetCandidates(pIME->pGetParam);
1953
1954 if (pIME->candidates > 0 || pIME->EditorMode == PINYIN_INPUT_MODE)//MC
1955 { /* Convert the data storage format for display purpose */
1956 DataConvert(pIME);
1957 /* initialize the candidate cursor to zero */
1958 pIME->CandidateCursor = 0;
1959 }
1960 else
1961 { //remove this keypress
1962 IMEClear(pIME, pIME->pGetParam->pElements);
1963 }
1964 }
1965
1966
1967 /*******************************************************************************
1968
1969 $Function: IMEClear
1970
1971 $Description: Clear the last stroke entered. This function first handle the case where
1972 the last element is a more tick. If there are no elements, it removes
1973 the last text element.
1974
1975 $Returns: void
1976
1977 $Arguments:
1978
1979 *******************************************************************************/
1980 //void IMEClear(PIME_DATA pIME)
1981 void IMEClear(PIME_DATA pIME, PZI8WCHAR wszElementBuffer)
1982 {
1983
1984
1985 TRACE_EVENT("IMEClear()");
1986
1987
1988 /* handle the condition where the last element is a more tick */
1989 if(pIME->pGetParam->ElementCount != 0) //check ElementCount to see whether ElementBuffer is empty
1990 {
1991 /* If the last input is a more tick, remove it */
1992 if(pIME->pGetParam->pElements[pIME->pGetParam->ElementCount-1] == ZI8_CODE_MORE)
1993 {
1994 pIME->moreCount--;
1995
1996 /* replace last element with zero */
1997 pIME->pGetParam->pElements[--pIME->pGetParam->ElementCount] = 0;
1998 }
1999 else
2000 {
2001 pIME->pGetParam->pElements[--pIME->pGetParam->ElementCount] = 0;
2002 pIME->pDisplayElementBuffer[pIME->pGetParam->ElementCount] = 0;
2003 }
2004
2005 /* When ElementCount is zero and InputScreenType is STROKE_INPUT_SCREEN or PINYIN_INPUT_SCREEN, */
2006 /* InputScreenType will be set to WORD_ASSOCIATION_SCREEN to get the associated character. If no associated */
2007 /* characters can be found, the most common used character in chinese writting will be provided. */
2008 if((pIME->pGetParam->ElementCount == 0 && pIME->InputScreenType == STROKE_INPUT_SCREEN) ||
2009 (pIME->pGetParam->ElementCount == 0 && pIME->InputScreenType == PINYIN_INPUT_SCREEN))
2010 {
2011 pIME->InputScreenType = WORD_ASSOCIATION_SCREEN;
2012 }
2013 }
2014 else
2015 {
2016 /* remove the last character from text buffer */
2017 /* first update count for word association */
2018 if(pIME->pGetParam->WordCharacterCount > 0)
2019 pIME->pGetParam->WordCharacterCount--;
2020
2021 /* remove the character at cursor position */
2022 if(pIME->TextCursor != 0)
2023 {
2024 #ifndef LSCREEN
2025 /* replace last character with zero */
2026 if(pIME->TextBufferCount==pIME->TextCursor)
2027 {
2028 pIME->pTextBuffer[--pIME->TextCursor] = 0;
2029 pIME->TextBufferCount--;
2030 }
2031 else if(pIME->TextBufferCount > pIME->TextCursor)
2032 {
2033 for (i=pIME->TextCursor; i<pIME->TextBufferCount; i++)
2034 {
2035 pIME->pTextBuffer[i-1]=pIME->pTextBuffer[i];
2036 }
2037 pIME->pTextBuffer[pIME->TextBufferCount-1]=0;
2038 pIME->TextCursor--;
2039 pIME->TextBufferCount--;
2040 }
2041 #else /*SPR 1319 delete char in front of cursor */
2042 /* SPR#1428 - SH - New Editor changes */
2043 #ifdef NEW_EDITOR
2044 ATB_edit_DeleteLeft(editor_pointer, TRUE); /* SPR#2342 - SH */
2045 #else /* NEW_EDITOR */
2046 edtChar(editor_pointer, ecBack);
2047 #endif /* NEW_EDITOR */
2048 pIME->TextBufferCount--;
2049 #endif
2050
2051 }
2052 /* update location of elements */
2053 pIME->pGetParam->pElements = wszElementBuffer;
2054 }
2055 /* get candidates */
2056 pIME->pGetParam->FirstCandidate = pIME->moreCount * CANDIDATES_PER_GROUP;
2057 pIME->pGetParam->MaxCandidates = CANDIDATES_PER_GROUP + 1;
2058 pIME->candidates = Zi8GetCandidates(pIME->pGetParam);
2059 /* Convert the data storage format for display purpose */
2060 DataConvert(pIME);
2061 /* initialize the candidate cursor to zero */
2062 pIME->CandidateCursor = 0;
2063 }
2064
2065
2066 /*******************************************************************************
2067
2068 $Function: CandidateHighlightDisplayContorl
2069
2070 $Description: With given candidate cursor position, and character stored in the HighlightedCandidate,
2071 this function will invert the colour of the candidate to indicate user the current selected
2072 character.
2073
2074 $Returns: void
2075
2076 $Arguments:
2077
2078 *******************************************************************************/
2079 void CandidateHighlightDisplayContorl(PIME_DATA pIME, PZI8WCHAR HighlightedCandidate)
2080 {
2081 /* Highlight the candidate character pointed by Ime.CandidateCursor */
2082 #ifndef LSCREEN
2083 if(pIME->CandidateCursor == 0)
2084 dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)HighlightedCandidate);
2085 else if(pIME->CandidateCursor == 1)
2086 dspl_TextOut(13,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)HighlightedCandidate);
2087 else if(pIME->CandidateCursor == 2)
2088 dspl_TextOut(25,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)HighlightedCandidate);
2089 else if(pIME->CandidateCursor == 3)
2090 dspl_TextOut(37,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)HighlightedCandidate);
2091 else if(pIME->CandidateCursor == 4)
2092 dspl_TextOut(49,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)HighlightedCandidate);
2093 else if(pIME->CandidateCursor == 5)
2094 dspl_TextOut(61,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)HighlightedCandidate);
2095 else
2096 dspl_TextOut(73,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)HighlightedCandidate);
2097 #else
2098 {
2099 /*
2100 SPR 1319 manually highlight selected candidate
2101 GW SPR#1732 - Added 0x80, 0x00 to the start of the 2 byte unicode string
2102 */
2103 char hChar[10];
2104 memcpy(&hChar[2],HighlightedCandidate,8);
2105 hChar[0] = (char)0x80; hChar[1] = 0x00;
2106 dspl_TextOut(pIME->CandidateCursor*CHI_FONT_WIDTH+1,SCREEN_SIZE_Y-Mmi_layout_line(3),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)hChar);
2107 }
2108 #endif
2109 }
2110
2111
2112 /*******************************************************************************
2113
2114 $Function: TextCursorDisplayContorl
2115
2116 $Description: To display the cursor position to user during text editing.
2117
2118 $Returns: void
2119
2120 $Arguments:
2121
2122 *******************************************************************************/
2123 void TextCursorDisplayContorl(PIME_DATA pIME, PZI8WCHAR CursorPosition, int InsertLine)
2124 {
2125 int TempTextCursor = 0;
2126 int x_position = 1;
2127 int i;
2128 int line;//position of char at start of line
2129
2130 TempTextCursor = pIME->TextCursor % CANDIDATES_PER_GROUP;
2131 line = pIME->TextCursor - TempTextCursor;
2132 for (i=0; i < TempTextCursor; i++)
2133
2134 { //if last byte of word is 0x00, and first byte is between 0x20 and 0x7E
2135 if (LatinChar(pIME->pTextBuffer[line+i]))
2136 x_position +=6;
2137 else
2138 x_position+=CHI_FONT_WIDTH;/*SPR 1319 using macro rather than magic no*/
2139 }
2140 switch(pIME->InputScreenType)
2141 {
2142 case TEXT_DISPLAY_SCREEN:
2143
2144 if(InsertLine == 1)
2145 {
2146
2147 dspl_TextOut(x_position,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)CursorPosition);
2148
2149
2150 }
2151 else
2152 { dspl_TextOut(x_position,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)CursorPosition);
2153
2154 }
2155 break;
2156 case STROKE_INPUT_SCREEN:
2157 case WORD_ASSOCIATION_SCREEN:
2158 dspl_TextOut(x_position,0,DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)CursorPosition);
2159
2160 default:
2161 break;
2162 }
2163 }
2164
2165
2166 /*******************************************************************************
2167
2168 $Function: DataConvert
2169
2170 $Description: To change to data storage format i.e if a unicode is 0x89D5.
2171 The DataConvert function will change storage format to 0xD589 (This format
2172 is required to display UniCode on LCD). The data format is chaged by
2173 byte shifting.
2174
2175 $Returns: void
2176
2177 $Arguments:
2178
2179 *******************************************************************************/
2180 void DataConvert(PIME_DATA pIME)
2181 {
2182 ZI8WCHAR HighByte;
2183 ZI8WCHAR Temp;
2184 ZI8WCHAR LowByte;
2185 ZI8WCHAR tempString[25];
2186 int word_length;
2187 int i = 0;
2188 int count = 0;
2189 TRACE_EVENT("DataConvert");
2190
2191
2192 if((pIME->InputScreenType == STROKE_INPUT_SCREEN) ||
2193 (pIME->InputScreenType == PINYIN_INPUT_SCREEN))
2194 {
2195 count = pIME->pGetParam->ElementCount;
2196 /* The more tick is not to be displayed on LCD therefore it is not considered. */
2197 while((count > 0) && pIME->pGetParam->pElements[count - 1] == ZI8_CODE_MORE)
2198 {
2199 count--;
2200 }
2201
2202 /* Format of the data stored in the array pointed by pElement is converted and */
2203 /* saved in the array pointed by pDisplayElementBuffer. Please note that the */
2204 /* the data format stored in the array pointed by pElement was unchanged. This */
2205 /* is kept that way for eZiText character search.*/
2206 if (pIME->InputScreenType == STROKE_INPUT_SCREEN)
2207 { for(i = 0; i < count; i++)
2208 {
2209 Temp = pIME->pGetParam->pElements[i];
2210 LowByte = pIME->pGetParam->pElements[i] & 0x00FF;
2211 HighByte = pIME->pGetParam->pElements[i] & 0xFF00;
2212 Temp = (LowByte << 8) & 0xFF00;
2213 HighByte = (HighByte >> 8) & 0x00FF;
2214 Temp = Temp | HighByte;
2215 pIME->pDisplayElementBuffer[i] = Temp;
2216 }
2217 pIME->pDisplayElementBuffer[count] = 0x0000; //terminate string
2218 }
2219
2220 if (pIME->InputScreenType == PINYIN_INPUT_SCREEN)
2221 { int no_of_display_chars;
2222 int i;
2223 word_length = count; //let's use user input for display
2224 /*word_length = */Zi8GetCharInfo(pIME->pGetParam->pCandidates[pIME->CandidateCursor], tempString, 12, ZI8_GETMODE_PINYIN);
2225 TRACE_EVENT((char*)tempString);/*MC Tracing first matched pinyin word*/
2226
2227 /*MC convert input elements from EZi element codes to Ezi Pinyin spelling for display*/
2228 for (i=0; i<word_length; i++)
2229 { tempString[i] = (((pIME->pGetParam->pElements[i]-ZI8_BASE_PINYIN)+LOWER_CASE_ASCII_OFFSET)) +EZITEXT_OUTPUT_OFFSET;
2230 }
2231
2232 if (word_length > 0)
2233 {
2234 if (word_length < count)
2235 no_of_display_chars = word_length;
2236 else
2237 no_of_display_chars = count;
2238 /***************************Go-lite Optimization changes Start***********************/
2239 //Aug 16, 2004 REF: CRR 24323 Deepa M.D
2240 TRACE_EVENT_P1("chars returned: %d", word_length);
2241 /***************************Go-lite Optimization changes end***********************/
2242 for(i = 0; i < no_of_display_chars; i++)
2243 {
2244 Temp = tempString[i];
2245 LowByte = tempString[i] & 0x00FF;
2246 HighByte = tempString[i] & 0xFF00;
2247 Temp = (LowByte << 8) & 0xFF00;
2248 HighByte = (HighByte >> 8) & 0x00FF;
2249 Temp = Temp |HighByte;
2250 pIME->pDisplayElementBuffer[i] = Temp;
2251 }
2252 pIME->pDisplayElementBuffer[no_of_display_chars] = 0x0000;//terminate string
2253 }
2254
2255 }
2256 }
2257
2258
2259 /* format of the data stored in the array pointed by pCandidates is coverted for display */
2260 for(i = 0; i < pIME->pGetParam->count; i++)
2261 {
2262 Temp = pIME->pGetParam->pCandidates[i];
2263 LowByte = pIME->pGetParam->pCandidates[i] & 0x00FF;
2264 HighByte = pIME->pGetParam->pCandidates[i] & 0xFF00;
2265 Temp = (LowByte << 8) & 0xFF00;
2266 HighByte = (HighByte >> 8) & 0x00FF;
2267 Temp = Temp | HighByte;
2268 pIME->pGetParam->pCandidates[i] = Temp;
2269 }
2270 pIME->pGetParam->pCandidates[pIME->candidates] = 0x0000;//terminate string
2271
2272 }
2273
2274
2275 /*******************************************************************************
2276
2277 $Function: Uni_strlen
2278
2279 $Description: To count the number of element from the input array
2280
2281 $Returns: number of element
2282
2283 $Arguments:
2284
2285 *******************************************************************************/
2286 ZI8WCHAR Uni_strlen(PZI8WCHAR String)
2287 {
2288 int i = 0;
2289 ZI8WCHAR count = 0;
2290
2291 while(String[i] != 0)
2292 {
2293 i++;
2294 count++;
2295 }
2296 return count;
2297 }
2298