FreeCalypso > hg > leo2moko-debug
comparison g23m/condat/ms/src/bmi/MmiChineseInput.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /******************************************************************************* | |
2 | |
3 CONDAT (UK) | |
4 | |
5 ******************************************************************************** | |
6 | |
7 This software product is the property of Condat (UK) Ltd and may not be | |
8 disclosed to any third party without the express permission of the owner. | |
9 | |
10 ******************************************************************************** | |
11 | |
12 $Project name: Basic MMI | |
13 $Project code: BMI (6349) | |
14 $Module: 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 /*MC 15/07/02 Keypad counters; keep track of how many times a key has been pressed*/ | |
132 static char Counter[KCD_STAR]; | |
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 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 { T_MFW_WIN * win = (T_MFW_WIN *)mfwParent( mfw_header()); | |
356 T_chinese_input * data = (T_chinese_input *)win->user; | |
357 int i; | |
358 TRACE_EVENT("chinese_pinyin_timer_cb()"); | |
359 for(i=0; i< KCD_STAR; i++)//MC, set all counters to 0 | |
360 Counter[i] = 0; | |
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 = -1; | |
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 int i; | |
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 int j = 0; | |
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 ZI8WCHAR TempArray2[CANDIDATES_PER_GROUP+1]; | |
619 int i; | |
620 int space_counter; | |
621 | |
622 UBYTE first_line= 0; //no of chars in first line(set to minimum) | |
623 UBYTE second_line=0; //no of chars in second line | |
624 | |
625 dspl_BitBlt(75,0,8,8,0,(char*)TextIconeZiTextSmall,0); | |
626 | |
627 memset(TempArray, 0, CANDIDATES_PER_GROUP*2); | |
628 if(data->Ime.TextBufferCount == 0) //If text buffer is empty | |
629 { | |
630 displaySoftKeys(data->Callback_Data.LeftSoftKey,TxtSoftBack); /* Softkey display*/ | |
631 } | |
632 else | |
633 | |
634 #ifndef LSCREEN | |
635 { | |
636 if(data->Ime.TextBufferCount <= (CANDIDATES_PER_GROUP * 2)) // data in text buffer is within 2 lines | |
637 { | |
638 | |
639 for(i=0; i<CANDIDATES_PER_GROUP; i++) | |
640 TempArray[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i]; | |
641 TempArray[CANDIDATES_PER_GROUP] = 0x0000; | |
642 | |
643 dspl_TextOut(1,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)TempArray); | |
644 if(data->Ime.TextBufferCount > CANDIDATES_PER_GROUP) | |
645 { | |
646 for(i=0; i<CANDIDATES_PER_GROUP; i++) | |
647 TempArray2[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i+CANDIDATES_PER_GROUP]; | |
648 TempArray2[CANDIDATES_PER_GROUP] = 0x0000; | |
649 dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char *)TempArray2); | |
650 } | |
651 j = (data->Ime.TextCursor / CANDIDATES_PER_GROUP) + 1; | |
652 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, j); | |
653 displaySoftKeys(data->Callback_Data.LeftSoftKey,TxtDelete); /* Softkey display*/ | |
654 } | |
655 else // data in text buffer is more than 14 characters. | |
656 { | |
657 if(data->Ime.TextCursor == data->StartOfDisplayIndex) | |
658 { | |
659 for(i=0; i<CANDIDATES_PER_GROUP; i++) | |
660 TempArray[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i]; | |
661 TempArray[CANDIDATES_PER_GROUP] = 0x0000; | |
662 dspl_TextOut(1,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char *)TempArray); | |
663 for(i=0; i<CANDIDATES_PER_GROUP; i++) | |
664 TempArray2[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i +CANDIDATES_PER_GROUP]; | |
665 TempArray2[CANDIDATES_PER_GROUP] = 0x0000; | |
666 dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char *)TempArray2); | |
667 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 1); | |
668 } | |
669 else if(data->Ime.TextCursor > data->StartOfDisplayIndex) | |
670 { | |
671 while(data->Ime.TextCursor - data->StartOfDisplayIndex >= CANDIDATES_PER_GROUP*2) | |
672 { | |
673 data->StartOfDisplayIndex = data->StartOfDisplayIndex + CANDIDATES_PER_GROUP; | |
674 } | |
675 for(i=0; i<CANDIDATES_PER_GROUP; i++) | |
676 TempArray[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i]; | |
677 TempArray[CANDIDATES_PER_GROUP] = 0x0000; | |
678 dspl_TextOut(1,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char *)TempArray); | |
679 | |
680 for(i=0; i<CANDIDATES_PER_GROUP; i++) | |
681 TempArray2[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i +CANDIDATES_PER_GROUP]; | |
682 TempArray2[CANDIDATES_PER_GROUP] = 0x0000; | |
683 dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char *)TempArray2); | |
684 | |
685 if((data->Ime.TextCursor - data->StartOfDisplayIndex) < CANDIDATES_PER_GROUP) | |
686 j = 1; | |
687 else if((data->Ime.TextCursor - data->StartOfDisplayIndex) < CANDIDATES_PER_GROUP * 2) | |
688 j = 2; | |
689 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, j); | |
690 } | |
691 else if(data->Ime.TextCursor < data->StartOfDisplayIndex && data->StartOfDisplayIndex != 0) | |
692 { | |
693 data->StartOfDisplayIndex = data->StartOfDisplayIndex - CANDIDATES_PER_GROUP; | |
694 for(i=0; i<CANDIDATES_PER_GROUP; i++) | |
695 TempArray[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i ]; | |
696 TempArray[CANDIDATES_PER_GROUP] = 0x0000; | |
697 dspl_TextOut(1,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char *)TempArray); | |
698 for(i=0; i<CANDIDATES_PER_GROUP; i++) | |
699 TempArray2[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i +CANDIDATES_PER_GROUP]; | |
700 TempArray2[CANDIDATES_PER_GROUP] = 0x0000; | |
701 dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char *)TempArray2); | |
702 if((data->Ime.TextCursor - data->StartOfDisplayIndex) < CANDIDATES_PER_GROUP) | |
703 j = 1; | |
704 else if((data->Ime.TextCursor - data->StartOfDisplayIndex) < CANDIDATES_PER_GROUP * 2) | |
705 j = 2; | |
706 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, j); | |
707 } | |
708 | |
709 | |
710 displaySoftKeys(data->Callback_Data.LeftSoftKey,TxtDelete); /* Softkey display*/ | |
711 } | |
712 } | |
713 #else /*SPR 1319, show editor and softkeys*/ | |
714 /* SPR#1428 - SH - New Editor changes */ | |
715 #ifdef NEW_EDITOR | |
716 ATB_edit_Unhide(data->editor); | |
717 ATB_edit_Show(data->editor); | |
718 #else /* NEW_EDITOR */ | |
719 edtUnhide(data->editor); | |
720 edtShow(data->editor); | |
721 #endif /* NEW_EDITOR */ | |
722 displaySoftKeys(data->Callback_Data.LeftSoftKey,TxtDelete); | |
723 #endif | |
724 } | |
725 break; | |
726 case STROKE_INPUT_SCREEN: | |
727 #ifndef LSCREEN | |
728 /* Display the correct portion composed text stored in wszTextBuffer. If the text cursor is not pointing at */ | |
729 /* the end of the text buffer, the display content is then adjusted to display the correct portion of the */ | |
730 /* text buffer. */ | |
731 if(data->Ime.TextBufferCount <=CANDIDATES_PER_GROUP) //check text buffer count | |
732 { | |
733 if(data->Ime.TextBufferCount == data->Ime.TextCursor) | |
734 { | |
735 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer); | |
736 } | |
737 else | |
738 { | |
739 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer); | |
740 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 0); | |
741 } | |
742 } | |
743 else //when data->Ime.TextBufferCount > CANDIDATES_PER_GROUP | |
744 { | |
745 if(data->Ime.TextBufferCount == data->Ime.TextCursor) | |
746 { | |
747 Temp_ptr = data->wszTextBuffer; | |
748 Temp_ptr = Temp_ptr + data->Ime.TextBufferCount - CANDIDATES_PER_GROUP; | |
749 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char *)Temp_ptr); | |
750 } | |
751 else if(data->Ime.TextCursor < CANDIDATES_PER_GROUP) | |
752 { | |
753 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer); | |
754 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 0); | |
755 } | |
756 else | |
757 { | |
758 Temp_ptr = &data->wszTextBuffer[data->Ime.TextCursor] - CANDIDATES_PER_GROUP + 1; | |
759 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char *)Temp_ptr); | |
760 dspl_TextOut(73,0,DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)data->CursorPosition); | |
761 } | |
762 } | |
763 #else /*SPR 1319, show editor*/ | |
764 /* SPR#1428 - SH - New Editor changes */ | |
765 #ifdef NEW_EDITOR | |
766 ATB_edit_Unhide(data->editor); | |
767 ATB_edit_Show(data->editor); | |
768 #else /* NEW_EDITOR */ | |
769 edtUnhide(data->editor); | |
770 edtShow(data->editor); | |
771 #endif /* NEW_EDITOR */ | |
772 #endif | |
773 #ifndef LSCREEN | |
774 dspl_TextOut(0,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)StrokePrompt);/* Display input prompt */ | |
775 #else | |
776 /*SPR 1319 show stroke prompt*/ | |
777 dspl_TextOut(0,SCREEN_SIZE_Y-Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)StrokePrompt);/* Display input prompt */ | |
778 #endif | |
779 /* Display input sequence for stroke */ | |
780 i = Uni_strlen(data->DisplayElementBuffer); | |
781 if( i <= 4) | |
782 { | |
783 #ifndef LSCREEN | |
784 dspl_TextOut(CHI_FONT_WIDTH*3,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char*)data->DisplayElementBuffer);//data->wszElementBuffer); | |
785 #else | |
786 /*mc SPR1319*/ | |
787 dspl_TextOut(CHI_FONT_WIDTH*3,SCREEN_SIZE_Y- Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)data->DisplayElementBuffer);//data->wszElementBuffer); | |
788 #endif | |
789 } | |
790 else | |
791 { | |
792 Temp_ptr = data->DisplayElementBuffer; | |
793 Temp_ptr = Temp_ptr + i - 4; | |
794 #ifndef LSCREEN | |
795 dspl_TextOut(CHI_FONT_WIDTH*3,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)Temp_ptr);//data->wszElementBuffer); | |
796 #else | |
797 /*mc SPR1319*/ | |
798 dspl_TextOut(CHI_FONT_WIDTH*3,SCREEN_SIZE_Y-Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)Temp_ptr);//data->wszElementBuffer); | |
799 #endif | |
800 } | |
801 | |
802 #ifndef LSCREEN | |
803 /* Display candidate characters returned from eZiText */ | |
804 dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char*)data->wcCandidates); | |
805 #else | |
806 /*mc SPR1319*/ | |
807 dspl_TextOut(1,SCREEN_SIZE_Y-Mmi_layout_line(3),DSPL_TXTATTR_UNICODE,(char*)data->wcCandidates); | |
808 #endif | |
809 | |
810 /* Highlight the candidate character pointed by Ime.CandidateCursor */ | |
811 CandidateHighlightDisplayContorl(&data->Ime, data->HighlightedCandidate); | |
812 if (Uni_strlen(data->DisplayElementBuffer) > 0) | |
813 displaySoftKeys(TxtSoftSelect,TxtDelete); /* Softkey display*/ | |
814 else | |
815 displaySoftKeys(TxtSoftSelect,TxtSoftOK); /* Softkey display*/ | |
816 | |
817 break; | |
818 case PINYIN_INPUT_SCREEN: | |
819 /* Display the correct portion composed text stored in wszTextBuffer. If the text cursor is not pointing at */ | |
820 /* the end of the text buffer, the display content is then adjusted to display the correct portion of the */ | |
821 /* text buffer. | |
822 */ | |
823 #ifndef LSCREEN | |
824 if(data->Ime.TextBufferCount <=CANDIDATES_PER_GROUP) //check text buffer count | |
825 { | |
826 if(data->Ime.TextBufferCount == data->Ime.TextCursor) | |
827 { | |
828 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer); | |
829 } | |
830 else | |
831 { | |
832 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer); | |
833 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 0); | |
834 } | |
835 } | |
836 else //when data->Ime.TextBufferCount > CANDIDATES_PER_GROUP | |
837 { | |
838 if(data->Ime.TextBufferCount == data->Ime.TextCursor) | |
839 { | |
840 Temp_ptr = data->wszTextBuffer; | |
841 Temp_ptr = Temp_ptr + data->Ime.TextBufferCount - CANDIDATES_PER_GROUP; | |
842 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char *)Temp_ptr); | |
843 } | |
844 else if(data->Ime.TextCursor < CANDIDATES_PER_GROUP) | |
845 { | |
846 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer); | |
847 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 0); | |
848 } | |
849 else | |
850 { | |
851 Temp_ptr = &data->wszTextBuffer[data->Ime.TextCursor] - CANDIDATES_PER_GROUP + 1; | |
852 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char *)Temp_ptr); | |
853 dspl_TextOut(73,0,DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)data->CursorPosition); | |
854 } | |
855 } | |
856 #else | |
857 /*mc SPR1319*/ | |
858 /* SPR#1428 - SH - New Editor changes */ | |
859 #ifdef NEW_EDITOR | |
860 ATB_edit_Unhide(data->editor); | |
861 ATB_edit_Show(data->editor); | |
862 #else /* NEW_EDITOR */ | |
863 edtUnhide(data->editor); | |
864 edtShow(data->editor); | |
865 #endif /* NEW_EDITOR */ | |
866 #endif | |
867 #ifndef LSCREEN | |
868 dspl_TextOut(0,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)PinYinPrompt);/* Display input prompt */ | |
869 #else | |
870 /*mc SPR1319*/ | |
871 dspl_TextOut(0,SCREEN_SIZE_Y - Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)PinYinPrompt);/* Display input prompt */ | |
872 #endif | |
873 /* Display input sequence for Pin-yin input */ | |
874 i = Uni_strlen(data->DisplayElementBuffer); | |
875 if( i <= 4) | |
876 { | |
877 #ifndef LSCREEN | |
878 dspl_TextOut(CHI_FONT_WIDTH*3,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)data->DisplayElementBuffer);//data->wszElementBuffer); | |
879 #else | |
880 /*mc SPR1319*/ | |
881 dspl_TextOut(CHI_FONT_WIDTH*3,SCREEN_SIZE_Y-Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)data->DisplayElementBuffer);//data->wszElementBuffer); | |
882 #endif | |
883 } | |
884 else | |
885 { | |
886 Temp_ptr = data->DisplayElementBuffer; | |
887 Temp_ptr = Temp_ptr + i - 4; | |
888 #ifndef LSCREEN | |
889 dspl_TextOut(CHI_FONT_WIDTH*3,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)Temp_ptr);//data->wszElementBuffer); | |
890 #else | |
891 /*mc SPR1319*/ | |
892 dspl_TextOut(CHI_FONT_WIDTH*3,SCREEN_SIZE_Y -Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)Temp_ptr);//data->wszElementBuffer); | |
893 #endif | |
894 } | |
895 /* Display candidate characters returned from eZiText */ | |
896 #ifndef LSCREEN | |
897 dspl_TextOut(1,Mmi_layout_second_line(),DSPL_TXTATTR_UNICODE,(char*)data->wcCandidates); | |
898 #else | |
899 /*mc SPR1319*/ | |
900 dspl_TextOut(1,SCREEN_SIZE_Y-Mmi_layout_line(3),DSPL_TXTATTR_UNICODE,(char*)data->wcCandidates); | |
901 #endif | |
902 /* Highlight the candidate character pointed by Ime.CandidateCursor */ | |
903 CandidateHighlightDisplayContorl(&data->Ime, data->HighlightedCandidate); | |
904 /*MC should have "Delete" softkey when entering pinyin letters*/ | |
905 if (Uni_strlen(data->DisplayElementBuffer) > 0) | |
906 displaySoftKeys(TxtSoftSelect,TxtDelete); /* Softkey display*/ | |
907 else | |
908 displaySoftKeys(TxtSoftSelect,TxtSoftOK); /* Softkey display*/ | |
909 break; | |
910 case WORD_ASSOCIATION_SCREEN: | |
911 /* Display the correct portion composed text stored in wszTextBuffer. If the text cursor is not pointing at */ | |
912 /* the end of the text buffer, the display content is then adjusted to display the correct portion of the */ | |
913 /* text buffer. | |
914 */ | |
915 #ifndef LSCREEN | |
916 if(data->Ime.TextBufferCount <=CANDIDATES_PER_GROUP) //check text buffer count | |
917 { | |
918 if(data->Ime.TextBufferCount == data->Ime.TextCursor) | |
919 { | |
920 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer); | |
921 } | |
922 else | |
923 { | |
924 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer); | |
925 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 0); | |
926 } | |
927 } | |
928 else //when data->Ime.TextBufferCount > CANDIDATES_PER_GROUP | |
929 { | |
930 if(data->Ime.TextBufferCount == data->Ime.TextCursor) | |
931 { | |
932 Temp_ptr = data->wszTextBuffer; | |
933 Temp_ptr = Temp_ptr + data->Ime.TextBufferCount - CANDIDATES_PER_GROUP; | |
934 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char *)Temp_ptr); | |
935 } | |
936 else if(data->Ime.TextCursor < CANDIDATES_PER_GROUP) | |
937 { | |
938 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char*)data->wszTextBuffer); | |
939 TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 0); | |
940 } | |
941 else | |
942 { | |
943 Temp_ptr = &data->wszTextBuffer[data->Ime.TextCursor] - CANDIDATES_PER_GROUP + 1; | |
944 dspl_TextOut(1,0,DSPL_TXTATTR_UNICODE,(char *)Temp_ptr); | |
945 dspl_TextOut(73,0,DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)data->CursorPosition); | |
946 } | |
947 } | |
948 #else | |
949 /*mc SPR1319*/ | |
950 /* SPR#1428 - SH - New Editor changes */ | |
951 #ifdef NEW_EDITOR | |
952 ATB_edit_Unhide(data->editor); | |
953 ATB_edit_Show(data->editor); | |
954 #else /* NEW_EDITOR */ | |
955 edtUnhide(data->editor); | |
956 edtShow(data->editor); | |
957 #endif /* NEW_EDITOR */ | |
958 #endif | |
959 if(data->Ime.EditorMode == STROKE_INPUT_MODE) | |
960 { | |
961 #ifndef LSCREEN | |
962 dspl_TextOut(0,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)StrokePrompt); /* Display input prompt */ | |
963 /* Display input sequence for stroke */ | |
964 #else | |
965 /*mc SPR1319*/ | |
966 dspl_TextOut(0,SCREEN_SIZE_Y -Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)StrokePrompt); /* Display input prompt */ | |
967 /* Display input sequence for stroke */ | |
968 | |
969 #endif | |
970 } | |
971 else if(data->Ime.EditorMode == PINYIN_INPUT_MODE) | |
972 { | |
973 #ifndef LSCREEN | |
974 dspl_TextOut(0,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)PinYinPrompt); /* Display input prompt */ | |
975 /* Display input sequence for Pin-yin input */ | |
976 #else | |
977 dspl_TextOut(0,SCREEN_SIZE_Y-Mmi_layout_line(4),DSPL_TXTATTR_UNICODE,(char*)PinYinPrompt); /* Display input prompt */ | |
978 /* Display input sequence for Pin-yin input */ | |
979 #endif | |
980 } | |
981 #ifndef LSCREEN | |
982 /* Display candidate charaters returned from eZiText */ | |
983 dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char*)data->wcCandidates); | |
984 #else | |
985 | |
986 dspl_TextOut(1,SCREEN_SIZE_Y-Mmi_layout_line(3),DSPL_TXTATTR_UNICODE,(char*)data->wcCandidates); | |
987 #endif | |
988 /* Highlight the candidate character pointed by Ime.CandidateCursor */ | |
989 CandidateHighlightDisplayContorl(&data->Ime, data->HighlightedCandidate); | |
990 | |
991 displaySoftKeys(TxtSoftSelect,TxtSoftOK); /* Softkey display*/ | |
992 break; | |
993 default: | |
994 break; | |
995 } | |
996 } | |
997 | |
998 break; | |
999 default: | |
1000 return 0; | |
1001 } | |
1002 | |
1003 return 1; | |
1004 } | |
1005 | |
1006 | |
1007 /******************************************************************************* | |
1008 | |
1009 $Function: chinese_input_kbd_cb | |
1010 | |
1011 $Description: Keyboard event handler | |
1012 | |
1013 $Returns: status int | |
1014 | |
1015 $Arguments: window handle event, keyboard control block | |
1016 | |
1017 *******************************************************************************/ | |
1018 | |
1019 static int chinese_input_kbd_cb (T_MFW_EVENT event, T_MFW_KBD *keyboard) | |
1020 { | |
1021 T_MFW_HND win = mfw_parent (mfw_header()); | |
1022 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data; | |
1023 T_chinese_input * data = (T_chinese_input *)win_data->user; | |
1024 T_MFW_HND parent_win = data->parent_win; | |
1025 USHORT Identifier = data->Identifier; | |
1026 int temp = 0; | |
1027 // void (* Callback)() = data->Callback; | |
1028 | |
1029 TRACE_EVENT("chinese_input_kbd_cb"); | |
1030 /***************************Go-lite Optimization changes Start***********************/ | |
1031 //Aug 16, 2004 REF: CRR 24323 Deepa M.D | |
1032 TRACE_EVENT_P6("Counters %d:%d:%d:%d:%d:%d", Counter[0], Counter[1], Counter[2], Counter[3], | |
1033 Counter[4], Counter[5]); | |
1034 /***************************Go-lite Optimization changes end***********************/ | |
1035 switch (keyboard->code) | |
1036 { | |
1037 case KCD_LEFT: | |
1038 switch(data->Ime.EditorMode) | |
1039 { | |
1040 case STROKE_INPUT_MODE: | |
1041 switch (data->Ime.InputScreenType) | |
1042 { | |
1043 case TEXT_DISPLAY_SCREEN: | |
1044 //access to the option list. | |
1045 SEND_EVENT(win, CHINESE_INPUT_DEINIT/*SPR 1752*/, INFO_KCD_LEFT, NULL); | |
1046 break; | |
1047 case STROKE_INPUT_SCREEN: | |
1048 case WORD_ASSOCIATION_SCREEN: | |
1049 IMESelectCandidate(&data->Ime, data->wszElementBuffer); | |
1050 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1051 break; | |
1052 default: | |
1053 break; | |
1054 } | |
1055 winShow(win); | |
1056 break; | |
1057 | |
1058 case PINYIN_INPUT_MODE: | |
1059 switch (data->Ime.InputScreenType) | |
1060 { | |
1061 case TEXT_DISPLAY_SCREEN: | |
1062 SEND_EVENT(win, CHINESE_INPUT_DEINIT/*SPR 1752*/, INFO_KCD_LEFT, NULL); | |
1063 //access to the option list. | |
1064 break; | |
1065 case PINYIN_INPUT_SCREEN: | |
1066 case WORD_ASSOCIATION_SCREEN: | |
1067 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/ | |
1068 IMESelectCandidate(&data->Ime, data->wszElementBuffer); | |
1069 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1070 | |
1071 break; | |
1072 default: | |
1073 break; | |
1074 } | |
1075 winShow(win); | |
1076 default: | |
1077 break; | |
1078 } | |
1079 | |
1080 break; | |
1081 case KCD_RIGHT: | |
1082 switch(data->Ime.EditorMode) | |
1083 { | |
1084 case STROKE_INPUT_MODE: | |
1085 switch (data->Ime.InputScreenType) | |
1086 { | |
1087 case TEXT_DISPLAY_SCREEN: | |
1088 if(data->Ime.TextBufferCount == 0) | |
1089 { /* When there is no stored data, return back to the menu*/ | |
1090 //GW-SPR-#1068-Destroy using event - execute callback of the function that created the editor | |
1091 SEND_EVENT(win, CHINESE_INPUT_DEINIT/*SPR 1752*/, INFO_KCD_RIGHT, NULL); | |
1092 } | |
1093 else | |
1094 { | |
1095 IMEClear(&data->Ime, data->wszElementBuffer); | |
1096 } | |
1097 break; | |
1098 case STROKE_INPUT_SCREEN: | |
1099 IMEClear(&data->Ime, data->wszElementBuffer); | |
1100 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1101 break; | |
1102 case WORD_ASSOCIATION_SCREEN: | |
1103 data->Ime.InputScreenType = TEXT_DISPLAY_SCREEN; | |
1104 break; | |
1105 default: | |
1106 break; | |
1107 } | |
1108 winShow(win); | |
1109 break; | |
1110 case PINYIN_INPUT_MODE: | |
1111 switch (data->Ime.InputScreenType) | |
1112 { | |
1113 case TEXT_DISPLAY_SCREEN: | |
1114 if(data->Ime.TextBufferCount == 0) | |
1115 { /* When there is no stored data, return back to the menu*/ | |
1116 //GW-SPR-#1068-Destroy using event - execute callback of the function that created the editor | |
1117 SEND_EVENT(win, CHINESE_INPUT_DEINIT/*SPR 1752*/, INFO_KCD_RIGHT, NULL); | |
1118 } | |
1119 else | |
1120 { | |
1121 IMEClear(&data->Ime, data->wszElementBuffer); | |
1122 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1123 } | |
1124 break; | |
1125 case PINYIN_INPUT_SCREEN: | |
1126 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/ | |
1127 IMEClear(&data->Ime, data->wszElementBuffer); | |
1128 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1129 break; | |
1130 case WORD_ASSOCIATION_SCREEN: | |
1131 data->Ime.InputScreenType = TEXT_DISPLAY_SCREEN; | |
1132 break; | |
1133 default: | |
1134 break; | |
1135 } | |
1136 winShow(win); | |
1137 break; | |
1138 | |
1139 default: | |
1140 break; | |
1141 } | |
1142 break; | |
1143 case KCD_HUP: | |
1144 //GW-SPR-#1068-Destroy using event - execute callback of the function that created the editor | |
1145 SEND_EVENT(win, CHINESE_INPUT_DEINIT/*SPR 1752*/, INFO_KCD_HUP, NULL); | |
1146 break; | |
1147 case KCD_MNUUP: | |
1148 switch(data->Ime.EditorMode) | |
1149 { | |
1150 case STROKE_INPUT_MODE: | |
1151 switch (data->Ime.InputScreenType) | |
1152 { | |
1153 case TEXT_DISPLAY_SCREEN: | |
1154 //update the text cursor | |
1155 if(data->Ime.TextCursor > 0 && data->Ime.TextCursor <= data->Ime.TextBufferCount) | |
1156 { | |
1157 data->CursorPosition[0] = data->wszTextBuffer[data->Ime.TextCursor - 1]; | |
1158 data->Ime.TextCursor--; | |
1159 } | |
1160 #ifdef LSCREEN /*SPR 1319 move left along editor*/ | |
1161 /* SPR#1428 - SH - New Editor changes */ | |
1162 #ifdef NEW_EDITOR | |
1163 ATB_edit_MoveCursor(data->editor, ctrlLeft, TRUE); | |
1164 #else /* NEW_EDITOR */ | |
1165 edtChar(data->editor, ecLeft); | |
1166 #endif /* NEW_EDITOR */ | |
1167 #endif | |
1168 break; | |
1169 case STROKE_INPUT_SCREEN: | |
1170 case WORD_ASSOCIATION_SCREEN: | |
1171 IMECursorLeft(&data->Ime); | |
1172 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1173 break; | |
1174 default: | |
1175 break; | |
1176 } | |
1177 winShow(win); | |
1178 break; | |
1179 | |
1180 case PINYIN_INPUT_MODE: | |
1181 switch (data->Ime.InputScreenType) | |
1182 { | |
1183 case TEXT_DISPLAY_SCREEN: | |
1184 //update the text cursor | |
1185 if(data->Ime.TextCursor > 0 && data->Ime.TextCursor <= data->Ime.TextBufferCount) | |
1186 { | |
1187 data->CursorPosition[0] = data->wszTextBuffer[data->Ime.TextCursor - 1]; | |
1188 data->Ime.TextCursor--; | |
1189 | |
1190 } | |
1191 #ifdef LSCREEN/*SPR 1319 move left along editor*/ | |
1192 /* SPR#1428 - SH - New Editor changes */ | |
1193 #ifdef NEW_EDITOR | |
1194 ATB_edit_MoveCursor(data->editor, ctrlLeft, TRUE); | |
1195 #else /* NEW_EDITOR */ | |
1196 edtCharUnicode(data->editor, ecLeft); | |
1197 #endif /* NEW_EDITOR */ | |
1198 #endif | |
1199 break; | |
1200 case PINYIN_INPUT_SCREEN: | |
1201 case WORD_ASSOCIATION_SCREEN: | |
1202 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/ | |
1203 IMECursorLeft(&data->Ime); | |
1204 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1205 break; | |
1206 default: | |
1207 break; | |
1208 } | |
1209 winShow(win); | |
1210 break; | |
1211 default: | |
1212 break; | |
1213 } | |
1214 break; | |
1215 case KCD_MNUDOWN: | |
1216 switch(data->Ime.EditorMode) | |
1217 { | |
1218 case STROKE_INPUT_MODE: | |
1219 switch (data->Ime.InputScreenType) | |
1220 { | |
1221 case TEXT_DISPLAY_SCREEN: | |
1222 //update the text cursor | |
1223 if(data->Ime.TextCursor < data->Ime.TextBufferCount) | |
1224 { | |
1225 data->Ime.TextCursor++; | |
1226 data->CursorPosition[0] = data->wszTextBuffer[data->Ime.TextCursor]; | |
1227 | |
1228 } | |
1229 #ifdef LSCREEN/*SPR 1319 move right along editor*/ | |
1230 /* SPR#1428 - SH - New Editor changes */ | |
1231 #ifdef NEW_EDITOR | |
1232 ATB_edit_MoveCursor(data->editor, ctrlRight, TRUE); | |
1233 #else /* NEW_EDITOR */ | |
1234 edtCharUnicode(data->editor, ecRight); | |
1235 #endif /* NEW_EDITOR */ | |
1236 #endif | |
1237 break; | |
1238 case STROKE_INPUT_SCREEN: | |
1239 case WORD_ASSOCIATION_SCREEN: | |
1240 IMECursorRight(&data->Ime); | |
1241 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1242 break; | |
1243 default: | |
1244 break; | |
1245 } | |
1246 winShow(win); | |
1247 break; | |
1248 | |
1249 case PINYIN_INPUT_MODE: | |
1250 switch (data->Ime.InputScreenType) | |
1251 { | |
1252 case TEXT_DISPLAY_SCREEN: | |
1253 //update the text cursor | |
1254 if(data->Ime.TextCursor < data->Ime.TextBufferCount) | |
1255 { | |
1256 data->Ime.TextCursor++; | |
1257 data->CursorPosition[0] = data->wszTextBuffer[data->Ime.TextCursor]; | |
1258 } | |
1259 #ifdef LSCREEN /*SPR 1319 move right along editor*/ | |
1260 /* SPR#1428 - SH - New Editor changes */ | |
1261 #ifdef NEW_EDITOR | |
1262 ATB_edit_MoveCursor(data->editor, ctrlRight, TRUE); | |
1263 #else /* NEW_EDITOR */ | |
1264 edtCharUnicode(data->editor, ecRight); | |
1265 #endif /* NEW_EDITOR */ | |
1266 #endif | |
1267 break; | |
1268 case PINYIN_INPUT_SCREEN: | |
1269 case WORD_ASSOCIATION_SCREEN: | |
1270 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/ | |
1271 IMECursorRight(&data->Ime); | |
1272 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1273 break; | |
1274 default: | |
1275 break; | |
1276 } | |
1277 winShow(win); | |
1278 break; | |
1279 default: | |
1280 break; | |
1281 } | |
1282 break; | |
1283 case KCD_CALL: | |
1284 break; | |
1285 case KCD_0: | |
1286 if (data->Ime.TextBufferCount < TEXT_BUFFER_EDIT_SIZE)/*MC*/ | |
1287 { | |
1288 switch(data->Ime.EditorMode) | |
1289 { | |
1290 case STROKE_INPUT_MODE: | |
1291 data->Ime.InputScreenType = STROKE_INPUT_SCREEN; | |
1292 IMEMore(&data->Ime); | |
1293 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1294 winShow(win); | |
1295 break; | |
1296 case PINYIN_INPUT_MODE: | |
1297 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/ | |
1298 data->Ime.InputScreenType = PINYIN_INPUT_SCREEN; | |
1299 IMEMore(&data->Ime); | |
1300 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1301 winShow(win); | |
1302 break; | |
1303 | |
1304 default: | |
1305 break; | |
1306 } | |
1307 } | |
1308 break; | |
1309 case KCD_8: | |
1310 if (data->Ime.TextBufferCount < TEXT_BUFFER_EDIT_SIZE)/*MC*/ | |
1311 { | |
1312 switch(data->Ime.EditorMode) | |
1313 { | |
1314 case STROKE_INPUT_MODE: | |
1315 data->Ime.InputScreenType = STROKE_INPUT_SCREEN; | |
1316 IMEMore(&data->Ime); | |
1317 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1318 winShow(win); | |
1319 break; | |
1320 case PINYIN_INPUT_MODE: | |
1321 data->Ime.InputScreenType = PINYIN_INPUT_SCREEN; | |
1322 /* The unclear of eZiText document, it is assumed that multi-key press may required to get to the required letter */ | |
1323 /* To do that a ZiPinYinKeyMap array is defined in ChineseInput.h header file. */ | |
1324 /* When number of keypress from the user is given from the keypad hadler, the key press count can then be */ | |
1325 /* used to work out the relevent code to insert into the element buffer for eZiText search. The variable */ | |
1326 /* data->NumberOfKeyPress is decleared to store the key press count. */ | |
1327 | |
1328 //temp = data->NumberOfKeyPress % ZiPinYinKeyMap[(keyboard->code)-1][5]; | |
1329 //IMEKeyPress(&data->Ime, (ZI8WCHAR) ZiPinYinKeyMap[(keyboard->code)-1][temp - 1]); | |
1330 | |
1331 /* due to not able to receive key press count, it is assume the first letter assign to the key is selected when key */ | |
1332 /* is pressed. */ | |
1333 /*MC, multitap handling*/ | |
1334 /*if time out or new key pressed*/ | |
1335 /***************************Go-lite Optimization changes Start***********************/ | |
1336 //Aug 16, 2004 REF: CRR 24323 Deepa M.D | |
1337 TRACE_EVENT_P1("Keypad Counter : %d", Counter[keyboard->code]); | |
1338 /***************************Go-lite Optimization changes end***********************/ | |
1339 if ( Counter[keyboard->code] == 0) | |
1340 { tim_stop(data->KeyPad_Timer_Handle);/*stop timer*/ | |
1341 memset( Counter, 0, sizeof(char)*KCD_STAR);/*reset all key counters*/ | |
1342 IMEKeyPress(&data->Ime, (ZI8WCHAR) ZiPinYinKeyMap[(keyboard->code)-1][0]); | |
1343 Counter[keyboard->code]++; //increment counter | |
1344 tim_start(data->KeyPad_Timer_Handle);/*restart timer*/ | |
1345 } | |
1346 else /*if counter is less than MAX for that key*/ | |
1347 { ZI8WCHAR last_element; | |
1348 | |
1349 if ( Counter[keyboard->code] <ZiPinYinKeyMap[(keyboard->code)-1][5]) | |
1350 { tim_stop(data->KeyPad_Timer_Handle);/*stop timer*/ | |
1351 //if last element is the previous char for this key | |
1352 last_element = data->Ime.pGetParam->pElements[data->Ime.pGetParam->ElementCount -1]; | |
1353 //should put in check | |
1354 if (last_element== ZiPinYinKeyMap[(keyboard->code)-1][ Counter[keyboard->code]-1]) | |
1355 { //MC e.g. if we're trying to enter 'I' and the last char was 'H' | |
1356 IMEClear(&data->Ime, data->Ime.pGetParam->pElements);/*remove last char from elements*/ | |
1357 data->Ime.InputScreenType = PINYIN_INPUT_SCREEN;/*this prevents display problems*/ | |
1358 } | |
1359 /*so we can add the next char for this key*/ | |
1360 IMEKeyPress(&data->Ime, (ZI8WCHAR) ZiPinYinKeyMap[(keyboard->code)-1][ Counter[keyboard->code]]); | |
1361 Counter[keyboard->code]++; //increment counter | |
1362 tim_start(data->KeyPad_Timer_Handle);/*restart timer*/ | |
1363 } | |
1364 } | |
1365 | |
1366 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1367 winShow(win); | |
1368 break; | |
1369 default: | |
1370 break; | |
1371 } | |
1372 } | |
1373 break; | |
1374 case KCD_1: | |
1375 case KCD_2: | |
1376 case KCD_3: | |
1377 case KCD_4: | |
1378 case KCD_5: | |
1379 case KCD_6: | |
1380 case KCD_7: | |
1381 case KCD_9: | |
1382 switch(data->Ime.EditorMode) | |
1383 { | |
1384 case STROKE_INPUT_MODE: | |
1385 if (data->Ime.TextBufferCount < TEXT_BUFFER_EDIT_SIZE)/*MC*/ | |
1386 { data->Ime.InputScreenType = STROKE_INPUT_SCREEN; | |
1387 IMEKeyPress(&data->Ime, (ZI8WCHAR) ZiStrokeKeyMap[keyboard->code][1] + ZI8_BASE_STROKES); | |
1388 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1389 winShow(win); | |
1390 } | |
1391 break; | |
1392 | |
1393 case PINYIN_INPUT_MODE: | |
1394 if (data->Ime.TextBufferCount < TEXT_BUFFER_EDIT_SIZE)/*MC*/ | |
1395 { | |
1396 data->Ime.InputScreenType = PINYIN_INPUT_SCREEN; | |
1397 /*MC, multitap handling*/ | |
1398 /***************************Go-lite Optimization changes Start***********************/ | |
1399 //Aug 16, 2004 REF: CRR 24323 Deepa M.D | |
1400 TRACE_EVENT_P1("Keypad Counter : %d", Counter[keyboard->code]); | |
1401 /***************************Go-lite Optimization changes end***********************/ | |
1402 /*if time out or new key pressed*/ | |
1403 if ( Counter[keyboard->code] == 0) | |
1404 { tim_stop(data->KeyPad_Timer_Handle);/*stop timer*/ | |
1405 memset( Counter, 0, sizeof(char)*KCD_STAR);/*reset all key counters*/ | |
1406 IMEKeyPress(&data->Ime, (ZI8WCHAR) ZiPinYinKeyMap[(keyboard->code)-1][0]); | |
1407 Counter[keyboard->code]++; //increment counter | |
1408 tim_start(data->KeyPad_Timer_Handle);/*restart timer*/ | |
1409 } | |
1410 else /*if counter is less than MAX for that key*/ | |
1411 { ZI8WCHAR last_element; | |
1412 | |
1413 if ( Counter[keyboard->code] <ZiPinYinKeyMap[(keyboard->code)-1][5]) | |
1414 { tim_stop(data->KeyPad_Timer_Handle);/*stop timer*/ | |
1415 last_element = data->Ime.pGetParam->pElements[data->Ime.pGetParam->ElementCount -1]; | |
1416 //should put in check | |
1417 //e.g. if last char was 'a' and we're entering 'b' | |
1418 if (last_element== ZiPinYinKeyMap[(keyboard->code)-1][ Counter[keyboard->code]-1]) | |
1419 { IMEClear(&data->Ime, data->Ime.pGetParam->pElements);/*remove last char from elements*/ | |
1420 data->Ime.InputScreenType = PINYIN_INPUT_SCREEN;/*this prevents display problems*/ | |
1421 } | |
1422 /*so we can add the next char for this key*/ | |
1423 IMEKeyPress(&data->Ime, (ZI8WCHAR) ZiPinYinKeyMap[(keyboard->code)-1][ Counter[keyboard->code]]); | |
1424 Counter[keyboard->code]++; //increment counter | |
1425 tim_start(data->KeyPad_Timer_Handle);/*restart timer*/ | |
1426 } | |
1427 } | |
1428 //IMEKeyPress(&data->Ime, (ZI8WCHAR) ZiPinYinKeyMap[(keyboard->code)-1][/*0*/2]); | |
1429 data->HighlightedCandidate[0] = data->wcCandidates[data->Ime.CandidateCursor]; | |
1430 winShow(win); | |
1431 } | |
1432 break; | |
1433 | |
1434 default: | |
1435 break; | |
1436 } | |
1437 break; | |
1438 case KCD_STAR: | |
1439 if (data->Ime.TextBufferCount < TEXT_BUFFER_EDIT_SIZE)/*MC*/ | |
1440 { | |
1441 switch(data->Ime.EditorMode) | |
1442 { | |
1443 case STROKE_INPUT_MODE: | |
1444 /* SPR#1428 - SH - New Editor uses new symbol selector */ | |
1445 #ifdef NEW_EDITOR | |
1446 AUI_symbol_Start(win, ADD_SYMBOL); | |
1447 #else /* NEW_EDITOR */ | |
1448 SymbolScreenstart(win, NULL); | |
1449 #endif /* NEW_EDITOR */ | |
1450 break; | |
1451 case PINYIN_INPUT_MODE: | |
1452 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/ | |
1453 /* SPR#1428 - SH - New Editor uses new symbol selector */ | |
1454 #ifdef NEW_EDITOR | |
1455 AUI_symbol_Start(win, ADD_SYMBOL); | |
1456 #else /* NEW_EDITOR */ | |
1457 SymbolScreenstart(win, NULL); | |
1458 #endif /* NEW_EDITOR */ | |
1459 break; | |
1460 default: | |
1461 break; | |
1462 } | |
1463 } | |
1464 | |
1465 break; | |
1466 case KCD_HASH: | |
1467 if (data->Ime.TextBufferCount < TEXT_BUFFER_EDIT_SIZE)/*MC*/ | |
1468 { | |
1469 switch(data->Ime.EditorMode) | |
1470 { | |
1471 /* SPR#1428 - SH - New Editor changes */ | |
1472 #ifdef NEW_EDITOR | |
1473 T_AUI_EDITOR_DATA editor_data; | |
1474 #else /* NEW_EDITOR */ | |
1475 T_EDITOR_DATA editor_data; | |
1476 #endif /* NEW_EDITOR */ | |
1477 case STROKE_INPUT_MODE: | |
1478 data->Ime.EditorMode = PINYIN_INPUT_MODE; | |
1479 break; | |
1480 case PINYIN_INPUT_MODE: | |
1481 memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/ | |
1482 /* SPR#1428 - SH - New Editor changes */ | |
1483 #ifdef NEW_EDITOR | |
1484 AUI_edit_SetDefault(&editor_data); | |
1485 #else /* NEW_EDITOR */ | |
1486 editor_attr_init(&editor_data.editor_attr, NULL, edtCurBar1, 0, 0, 0, 0); | |
1487 editor_data.hide = FALSE; | |
1488 editor_data.TextId = '\0'; | |
1489 editor_data.TextString = NULL; | |
1490 editor_data.timeout = FOREVER; // Avoid to return empty strings | |
1491 #endif /* NEW_EDITOR */ | |
1492 //set mode to stroke input when Latin editor exited | |
1493 data->Ime.EditorMode = STROKE_INPUT_MODE; | |
1494 /* SPR#1428 - SH - New Editor changes */ | |
1495 #ifdef NEW_EDITOR | |
1496 AUI_edit_SetDisplay(&editor_data, ZONE_FULL_SK_TITLE, COLOUR_EDITOR, EDITOR_FONT); | |
1497 AUI_edit_SetBuffer(&editor_data, ATB_DCS_UNICODE, (UBYTE *)data->Callback_Data.TextString, data->Callback_Data.EditorSize*2 + 3); | |
1498 AUI_edit_SetMode(&editor_data, ED_MODE_ALPHA, ED_CURSOR_BAR); | |
1499 AUI_edit_SetTextStr(&editor_data, TxtChinese, TxtDelete, TxtNull, NULL); | |
1500 AUI_edit_SetEvents(&editor_data, LATIN_INPUT, TRUE, FOREVER, (T_AUI_EDIT_CB)chinese_input_exec); | |
1501 AUI_edit_Start(data->input_win, &editor_data); | |
1502 #else /* NEW_EDITOR */ | |
1503 editor_data.editor_attr.text = (char *)data->Callback_Data.TextString; | |
1504 editor_data.editor_attr.size = data->Callback_Data.EditorSize*2 + 3; | |
1505 editor_data.min_enter = 0; | |
1506 editor_data.mode = ALPHA_MODE; | |
1507 editor_data.LeftSoftKey = TxtChinese; | |
1508 editor_data.AlternateLeftSoftKey = TxtSoftBack; | |
1509 editor_data.RightSoftKey = TxtDelete; | |
1510 editor_data.Identifier = LATIN_INPUT; | |
1511 editor_data.Callback = (T_EDIT_CB)chinese_input_exec/*NULL*/; | |
1512 editor_data.destroyEditor = TRUE; | |
1513 editor_start(data->input_win, &editor_data); | |
1514 #endif /* NEW_EDITOR */ | |
1515 break; | |
1516 default: | |
1517 | |
1518 break; | |
1519 } | |
1520 | |
1521 memset(&data->DisplayElementBuffer, 0,sizeof(data->DisplayElementBuffer)); | |
1522 | |
1523 IMEChangeMode(&data->Ime,&data->GetParam); | |
1524 winShow(win); | |
1525 } | |
1526 break; | |
1527 default: | |
1528 break; | |
1529 } | |
1530 return MFW_EVENT_CONSUMED; | |
1531 } | |
1532 | |
1533 | |
1534 /******************************************************************************* | |
1535 | |
1536 $Function: | |
1537 | |
1538 $Description: | |
1539 $Returns: | |
1540 | |
1541 $Arguments: menu and menu item (neither used) | |
1542 | |
1543 *******************************************************************************/ | |
1544 int chinese_input_menu(MfwMnu* m, MfwMnuItem* i) | |
1545 { | |
1546 T_MFW_HND parent = mfwParent( mfw_header() ); | |
1547 chinese_input( parent, NULL ); | |
1548 return MFW_EVENT_CONSUMED; | |
1549 } | |
1550 | |
1551 | |
1552 /******************************************************************************* | |
1553 | |
1554 $Function: IMEChangeMode | |
1555 | |
1556 $Description: This function change some of the setting when user selected to use | |
1557 different input method. E.g change from Stroke to Pin-yin input. | |
1558 | |
1559 $Returns: void | |
1560 | |
1561 $Arguments: | |
1562 | |
1563 *******************************************************************************/ | |
1564 void IMEChangeMode(PIME_DATA pIME, PZI8GETPARAM pGetParam) | |
1565 { | |
1566 /* First initialize the members that will be constant */ | |
1567 switch(pIME->EditorMode) | |
1568 { | |
1569 case STROKE_INPUT_MODE: | |
1570 pGetParam->Language = ZI8_LANG_ZH; | |
1571 pGetParam->GetMode = ZI8_GETMODE_STROKES; | |
1572 pGetParam->SubLanguage = ZI8_SUBLANG_ZH; | |
1573 /*MC, check size of editor to work out context*/ | |
1574 if (TEXT_BUFFER_EDIT_SIZE <= MAX_PHONEBOOK_ENTRY_SIZE) | |
1575 pGetParam->Context = ZI8_GETCONTEXT_SURNAME; | |
1576 else | |
1577 pGetParam->Context = ZI8_GETCONTEXT_SMS; | |
1578 pGetParam->GetOptions = ZI8_GETOPTION_ALLCOMPONENTS; | |
1579 break; | |
1580 case PINYIN_INPUT_MODE: | |
1581 pGetParam->Language = ZI8_LANG_ZH; | |
1582 pGetParam->GetMode = ZI8_GETMODE_PINYIN; | |
1583 pGetParam->SubLanguage = ZI8_SUBLANG_ZH/*ZI8_SUBLANG_ZH_ALL*/; | |
1584 /*MC, check size of editor to work out context*/ | |
1585 if (TEXT_BUFFER_EDIT_SIZE <= MAX_PHONEBOOK_ENTRY_SIZE) | |
1586 pGetParam->Context = ZI8_GETCONTEXT_SURNAME; | |
1587 else | |
1588 pGetParam->Context = ZI8_GETCONTEXT_SMS; | |
1589 pGetParam->GetOptions = ZI8_GETOPTION_NOCOMPONENTS/*ZI8_GETOPTION_SAMESOUND*/; | |
1590 break; | |
1591 case LATIN_INPUT_MODE: | |
1592 pIME->InputScreenType = TEXT_DISPLAY_SCREEN; | |
1593 break; | |
1594 default: | |
1595 break; | |
1596 } | |
1597 pIME->InputScreenType = TEXT_DISPLAY_SCREEN; | |
1598 memset(pGetParam->pElements, 0, sizeof(pGetParam->pElements)); | |
1599 memset(pIME->pDisplayElementBuffer, 0,sizeof(pIME->pDisplayElementBuffer)); | |
1600 /* save the pointer to the ZI8GETPARAM structure in the IME data */ | |
1601 pIME->pGetParam = pGetParam; | |
1602 /* now initialize the text buffer and element buffer */ | |
1603 pIME->moreCount = 0; | |
1604 pGetParam->ElementCount = 0; | |
1605 /* initilalize the WordCharacterCount to zero */ | |
1606 pGetParam->WordCharacterCount = 0; | |
1607 /* initialize the saved number of candidates to zero */ | |
1608 pIME->candidates = 0; | |
1609 /* initialize the candidate cursor to zero */ | |
1610 pIME->CandidateCursor = 0; | |
1611 } | |
1612 | |
1613 | |
1614 /******************************************************************************* | |
1615 | |
1616 $Function: IMEInitialize | |
1617 | |
1618 $Description: This function initializes the ZI8GETPARAM structure defined in the API | |
1619 and the various members of the IME_DATA structure defined in to keep | |
1620 track of the IME. | |
1621 | |
1622 $Returns: void | |
1623 | |
1624 $Arguments: | |
1625 | |
1626 *******************************************************************************/ | |
1627 /*void IMEInitialize(PIME_DATA pIME, PZI8GETPARAM pGetParam, PZI8WCHAR wszTextBuffer, int TextBufferEditSize, | |
1628 int TextBufferSize, PZI8WCHAR pCandidates)*/ | |
1629 void IMEInitialize(PIME_DATA pIME, PZI8GETPARAM pGetParam, PZI8WCHAR wszTextBuffer, | |
1630 int TextBufferEditSize, int TextBufferSize, PZI8WCHAR pCandidates, | |
1631 PZI8WCHAR wszElementBuffer, PZI8WCHAR DisplayElementBuffer) | |
1632 { | |
1633 pIME->EditorMode = STROKE_INPUT_MODE; | |
1634 /* First initialize the members that will be constant */ | |
1635 switch(pIME->EditorMode) | |
1636 { | |
1637 case STROKE_INPUT_MODE: | |
1638 pGetParam->Language = ZI8_LANG_ZH; | |
1639 pGetParam->GetMode = ZI8_GETMODE_STROKES; | |
1640 pGetParam->SubLanguage = ZI8_SUBLANG_ZH; | |
1641 /*MC, check size of editor to work out context*/ | |
1642 if (TEXT_BUFFER_EDIT_SIZE <= MAX_PHONEBOOK_ENTRY_SIZE) | |
1643 pGetParam->Context = ZI8_GETCONTEXT_SURNAME; | |
1644 else | |
1645 pGetParam->Context = ZI8_GETCONTEXT_SMS; | |
1646 | |
1647 pGetParam->GetOptions = ZI8_GETOPTION_ALLCOMPONENTS; | |
1648 break; | |
1649 case PINYIN_INPUT_MODE: | |
1650 pGetParam->Language = ZI8_LANG_ZH; | |
1651 pGetParam->GetMode = ZI8_GETMODE_PINYIN; | |
1652 pGetParam->SubLanguage = ZI8_SUBLANG_ZH; | |
1653 if (TEXT_BUFFER_EDIT_SIZE <= MAX_PHONEBOOK_ENTRY_SIZE) | |
1654 pGetParam->Context = ZI8_GETCONTEXT_SURNAME; | |
1655 else | |
1656 pGetParam->Context = ZI8_GETCONTEXT_SMS; | |
1657 pGetParam->GetOptions = ZI8_GETOPTION_NOCOMPONENTS/*ZI8_GETOPTION_SAMESOUND*/; | |
1658 break; | |
1659 case LATIN_INPUT_MODE: | |
1660 break; | |
1661 default: | |
1662 break; | |
1663 } | |
1664 /* save the pointer to the ZI8GETPARAM structure in the IME data */ | |
1665 pIME->pGetParam = pGetParam; | |
1666 /* now initialize the text buffer and element buffer */ | |
1667 pIME->pTextBuffer = wszTextBuffer; | |
1668 pIME->TextBufferEditSize = TextBufferEditSize; | |
1669 pIME->TextBufferSize = TextBufferSize; | |
1670 pIME->moreCount = 0; | |
1671 pIME->TextBufferCount = Uni_strlen(wszTextBuffer);; | |
1672 pIME->TextCursor = pIME->TextBufferCount; | |
1673 pIME->pDisplayElementBuffer = DisplayElementBuffer; | |
1674 pIME->InputScreenType = TEXT_DISPLAY_SCREEN; | |
1675 | |
1676 pGetParam->pElements = wszElementBuffer; | |
1677 pGetParam->ElementCount = 0; | |
1678 /* initilalize the WordCharacterCount to zero */ | |
1679 pGetParam->WordCharacterCount = 0; | |
1680 /*initial pointer to the candidate buffer*/ | |
1681 pGetParam->pCandidates = pCandidates; | |
1682 /* initialize the saved number of candidates to zero */ | |
1683 pIME->candidates = 0; | |
1684 /* initialize the candidate cursor to zero */ | |
1685 pIME->CandidateCursor = 0; | |
1686 } | |
1687 | |
1688 | |
1689 /******************************************************************************* | |
1690 | |
1691 $Function: IMECursorLeft | |
1692 | |
1693 $Description: Move the candidate cursor left | |
1694 | |
1695 $Returns: void | |
1696 | |
1697 $Arguments: | |
1698 | |
1699 *******************************************************************************/ | |
1700 /* | |
1701 GW SPR#1732 - Corrected cursor position from '6' to 'CANDIDATES_PER_GROUP - 1' | |
1702 */ | |
1703 | |
1704 void IMECursorLeft(PIME_DATA pIME) | |
1705 { | |
1706 TRACE_EVENT ("IMECursorLeft()"); | |
1707 if(pIME->CandidateCursor != 0) | |
1708 { | |
1709 pIME->CandidateCursor--; | |
1710 pIME->candidates = Zi8GetCandidates(pIME->pGetParam); | |
1711 DataConvert(pIME); | |
1712 } | |
1713 /* check ElementCount to see whether ElementBuffer is empty and check if where is any more tick in the element buffer. */ | |
1714 else if(pIME->pGetParam->ElementCount != 0 && | |
1715 pIME->pGetParam->pElements[pIME->pGetParam->ElementCount-1] == ZI8_CODE_MORE) | |
1716 { | |
1717 /* If the last input is a more tick, remove it */ | |
1718 pIME->moreCount--; | |
1719 /* replace last element with zero */ | |
1720 pIME->pGetParam->pElements[--pIME->pGetParam->ElementCount] = 0; | |
1721 /* get candidates with the new stroke */ | |
1722 pIME->pGetParam->FirstCandidate = pIME->moreCount * CANDIDATES_PER_GROUP; | |
1723 pIME->pGetParam->MaxCandidates = CANDIDATES_PER_GROUP + 1; | |
1724 pIME->candidates = Zi8GetCandidates(pIME->pGetParam); | |
1725 DataConvert(pIME); | |
1726 /* initialize the candidate cursor the character position*/ | |
1727 pIME->CandidateCursor =CANDIDATES_PER_GROUP - 1; | |
1728 } | |
1729 } | |
1730 | |
1731 | |
1732 /******************************************************************************* | |
1733 | |
1734 $Function: IMECursorRight | |
1735 | |
1736 $Description: Move the candidate cursor right | |
1737 | |
1738 $Returns: void | |
1739 | |
1740 $Arguments: | |
1741 | |
1742 *******************************************************************************/ | |
1743 /* | |
1744 GW SPR#1732 - Corrected test for cursor position from '6' to 'CANDIDATES_PER_GROUP - 1' | |
1745 */ | |
1746 void IMECursorRight(PIME_DATA pIME) | |
1747 { | |
1748 TRACE_EVENT("IMECursorRight()"); | |
1749 /* If the candidate cursor is greater than the display ability, more tick is add to the element buffer */ | |
1750 /* to request for next set of characters. */ | |
1751 if(pIME->CandidateCursor >= CANDIDATES_PER_GROUP - 1) | |
1752 { | |
1753 pIME->moreCount++; | |
1754 pIME->pGetParam->pElements[pIME->pGetParam->ElementCount++] = ZI8_CODE_MORE; | |
1755 /* get new candidates */ | |
1756 pIME->pGetParam->FirstCandidate = pIME->moreCount * CANDIDATES_PER_GROUP; | |
1757 pIME->pGetParam->MaxCandidates = CANDIDATES_PER_GROUP + 1; | |
1758 pIME->candidates = Zi8GetCandidates(pIME->pGetParam); | |
1759 DataConvert(pIME); | |
1760 /* initialize the candidate cursor to zero */ | |
1761 pIME->CandidateCursor = 0; | |
1762 } | |
1763 /* Check number of available candidates before increment of candidate cursor is allowed */ | |
1764 else if(pIME->candidates > (pIME->CandidateCursor + 1)) | |
1765 { pIME->CandidateCursor++; | |
1766 pIME->candidates = Zi8GetCandidates(pIME->pGetParam); | |
1767 DataConvert(pIME); | |
1768 } | |
1769 } | |
1770 | |
1771 | |
1772 /******************************************************************************* | |
1773 | |
1774 $Function: IMESelectCandidate | |
1775 | |
1776 $Description: Select the cadidate at cursor. | |
1777 | |
1778 $Returns: void | |
1779 | |
1780 $Arguments: | |
1781 | |
1782 *******************************************************************************/ | |
1783 void IMESelectCandidate(PIME_DATA pIME, PZI8WCHAR wszElementBuffer) | |
1784 { | |
1785 int i = 0; | |
1786 int j = 0; | |
1787 ZI8WCHAR HighByte; | |
1788 ZI8WCHAR Temp; | |
1789 ZI8WCHAR LowByte; | |
1790 | |
1791 TRACE_EVENT("IMESelectCandidate()"); | |
1792 | |
1793 | |
1794 /* we can allow selection only if we have candidates*/ | |
1795 if(pIME->candidates == 0) | |
1796 return; | |
1797 /* if we have elements in the test we must now remove them */ | |
1798 while(pIME->pGetParam->ElementCount > 0) | |
1799 { | |
1800 pIME->pGetParam->pElements[--pIME->pGetParam->ElementCount] = 0; | |
1801 } | |
1802 /* the more count must be set to zero */ | |
1803 pIME->moreCount = 0; | |
1804 | |
1805 /* check the limit of the text buffer. Stop user to enter character when text buffer is full */ | |
1806 if(pIME->TextBufferCount >= TEXT_BUFFER_EDIT_SIZE) | |
1807 { | |
1808 //messages can be added to inform user when text buffer is full. | |
1809 return; | |
1810 } | |
1811 | |
1812 /* chek if the selected candidate is a component. To do that the storage format has to be change. */ | |
1813 /* Followin bit shifting procedure is used the perfrom the task. */ | |
1814 LowByte = pIME->pGetParam->pCandidates[pIME->CandidateCursor] & 0x00FF; | |
1815 HighByte = pIME->pGetParam->pCandidates[pIME->CandidateCursor] & 0xFF00; | |
1816 Temp = (LowByte << 8) & 0xFF00; | |
1817 HighByte = (HighByte >> 8) & 0x00FF; | |
1818 Temp = Temp | HighByte; | |
1819 | |
1820 if(Temp > ZI8_BASE_COMPONENTS && Temp < ZI8_BASE_BPMF) /* check if the selected candidate is a component */ | |
1821 { | |
1822 memset(pIME->pDisplayElementBuffer, 0,sizeof(pIME->pDisplayElementBuffer)); | |
1823 pIME->pDisplayElementBuffer[0] = pIME->pGetParam->pCandidates[pIME->CandidateCursor]; | |
1824 | |
1825 pIME->pGetParam->pElements[0] = Temp; | |
1826 pIME->pGetParam->ElementCount = 1; | |
1827 } | |
1828 else /* The selected character is character not a component */ | |
1829 { | |
1830 if(pIME->TextCursor < pIME->TextBufferCount) /* locate the text cursor position for correct character insertion */ | |
1831 { | |
1832 for (i=pIME->TextCursor; i<pIME->TextBufferCount; i++) /* shift and move characters to make rooms to insert the selected character */ | |
1833 { | |
1834 //pIME->pTextBuffer[pIME->TextBufferCount - i + 1]=pIME->pTextBuffer[pIME->TextBufferCount - i]; | |
1835 pIME->pTextBuffer[pIME->TextBufferCount - j]=pIME->pTextBuffer[pIME->TextBufferCount - j - 1]; | |
1836 j++; | |
1837 } | |
1838 } | |
1839 #ifndef LSCREEN | |
1840 /* now added this character to the text */ | |
1841 pIME->pTextBuffer[pIME->TextCursor++] = pIME->pGetParam->pCandidates[pIME->CandidateCursor]; | |
1842 #else /*SPR 1319 Add candidate to editor*/ | |
1843 /* SPR#1428 - SH - New Editor changes */ | |
1844 #ifdef NEW_EDITOR | |
1845 ATB_edit_Char(editor_pointer, (USHORT )pIME->pGetParam->pCandidates[pIME->CandidateCursor], TRUE); | |
1846 #else /* NEW_EDITOR */ | |
1847 edtCharUnicode(editor_pointer, pIME->pGetParam->pCandidates[pIME->CandidateCursor]); | |
1848 #endif /* NEW_EDITOR */ | |
1849 pIME->TextCursor++; | |
1850 #endif | |
1851 /* Change input screen type */ | |
1852 pIME->InputScreenType = WORD_ASSOCIATION_SCREEN; | |
1853 /* upate the element buffer to its new position */ | |
1854 pIME->pGetParam->pElements = wszElementBuffer; | |
1855 | |
1856 /* Adjust the word association. If the candidate we selected was a word candidat, */ | |
1857 /* then we continue the word association. Otherwise this character begins a new word */ | |
1858 if(pIME->pGetParam->wordCandidates > pIME->CandidateCursor) | |
1859 { | |
1860 pIME->pGetParam->WordCharacterCount++; | |
1861 } | |
1862 else | |
1863 { | |
1864 pIME->pGetParam->pCurrentWord = &pIME->pTextBuffer[pIME->TextCursor - 1]; | |
1865 pIME->pGetParam->WordCharacterCount = 1; | |
1866 } | |
1867 /* get new candidates */ | |
1868 pIME->pGetParam->FirstCandidate = pIME->moreCount * CANDIDATES_PER_GROUP; | |
1869 pIME->pGetParam->MaxCandidates = CANDIDATES_PER_GROUP + 1; | |
1870 //increase TextBufferCount by one | |
1871 pIME->TextBufferCount++; | |
1872 memset(pIME->pDisplayElementBuffer, 0, sizeof(pIME->pDisplayElementBuffer)); | |
1873 } | |
1874 pIME->candidates = Zi8GetCandidates(pIME->pGetParam); | |
1875 DataConvert(pIME); | |
1876 /* initialize the candidate cursor to zero */ | |
1877 pIME->CandidateCursor = 0; | |
1878 } | |
1879 | |
1880 | |
1881 /******************************************************************************* | |
1882 | |
1883 $Function: IMEMore | |
1884 | |
1885 $Description: Get the next group of candidates. For this function, we add the more tick | |
1886 to the element buffer and increase the more count. Then we get the | |
1887 next group of candidates. | |
1888 | |
1889 $Returns: void | |
1890 | |
1891 $Arguments: | |
1892 | |
1893 *******************************************************************************/ | |
1894 void IMEMore(PIME_DATA pIME) | |
1895 { | |
1896 TRACE_EVENT("IMEMore()"); | |
1897 | |
1898 pIME->moreCount++; | |
1899 pIME->pGetParam->pElements[pIME->pGetParam->ElementCount++] = ZI8_CODE_MORE; | |
1900 /* get new candidates */ | |
1901 pIME->pGetParam->FirstCandidate = pIME->moreCount * CANDIDATES_PER_GROUP; | |
1902 pIME->pGetParam->MaxCandidates = CANDIDATES_PER_GROUP + 1; | |
1903 pIME->candidates = Zi8GetCandidates(pIME->pGetParam); | |
1904 DataConvert(pIME); | |
1905 /* initialize the candidate cursor to zero */ | |
1906 pIME->CandidateCursor = 0; | |
1907 } | |
1908 | |
1909 | |
1910 /******************************************************************************* | |
1911 | |
1912 $Function: IMEKeyPress | |
1913 | |
1914 $Description: Enter the stroke and get new candidates. However, any more ticks from | |
1915 the element buffer must be removed before any stroke is to be added. | |
1916 | |
1917 $Returns: void | |
1918 | |
1919 $Arguments: | |
1920 | |
1921 *******************************************************************************/ | |
1922 void IMEKeyPress(PIME_DATA pIME, ZI8WCHAR wcStroke) | |
1923 { char debug[80]; | |
1924 PZI8WCHAR element_buffer; | |
1925 | |
1926 TRACE_EVENT ("IMEKeyPress()"); | |
1927 | |
1928 /* remove any trailing more ticks and set the more count back to zero */ | |
1929 while((pIME->pGetParam->ElementCount > 0) && pIME->pGetParam->pElements[pIME->pGetParam->ElementCount-1] == ZI8_CODE_MORE) | |
1930 { | |
1931 pIME->pGetParam->pElements[--pIME->pGetParam->ElementCount] = 0; | |
1932 } | |
1933 pIME->moreCount = 0; | |
1934 | |
1935 /* Check the limit of the element buffer. Stop user to enter stroke or Pin Yin letter */ | |
1936 /* when element budder is full */ | |
1937 if(pIME->pGetParam->ElementCount >= TEXT_BUFFER_EXTRA_SPACE) | |
1938 { | |
1939 return; | |
1940 } | |
1941 /* Insert the stroke or the Pin Yin letter into the element buffer for character search */ | |
1942 pIME->pGetParam->pElements[pIME->pGetParam->ElementCount++] = wcStroke; | |
1943 | |
1944 /*MC, let's check what's in the element buffer*/ | |
1945 | |
1946 element_buffer = pIME->pGetParam->pElements; | |
1947 /***************************Go-lite Optimization changes Start***********************/ | |
1948 //Aug 16, 2004 REF: CRR 24323 Deepa M.D | |
1949 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)); | |
1950 /***************************Go-lite Optimization changes end***********************/ | |
1951 /*MC --end debug code*/ | |
1952 | |
1953 /* get candidates with the new stroke */ | |
1954 pIME->pGetParam->FirstCandidate = pIME->moreCount * CANDIDATES_PER_GROUP; | |
1955 pIME->pGetParam->MaxCandidates = CANDIDATES_PER_GROUP + 1; | |
1956 pIME->candidates = Zi8GetCandidates(pIME->pGetParam); | |
1957 | |
1958 if (pIME->candidates > 0 || pIME->EditorMode == PINYIN_INPUT_MODE)//MC | |
1959 { /* Convert the data storage format for display purpose */ | |
1960 DataConvert(pIME); | |
1961 /* initialize the candidate cursor to zero */ | |
1962 pIME->CandidateCursor = 0; | |
1963 } | |
1964 else | |
1965 { //remove this keypress | |
1966 IMEClear(pIME, pIME->pGetParam->pElements); | |
1967 } | |
1968 } | |
1969 | |
1970 | |
1971 /******************************************************************************* | |
1972 | |
1973 $Function: IMEClear | |
1974 | |
1975 $Description: Clear the last stroke entered. This function first handle the case where | |
1976 the last element is a more tick. If there are no elements, it removes | |
1977 the last text element. | |
1978 | |
1979 $Returns: void | |
1980 | |
1981 $Arguments: | |
1982 | |
1983 *******************************************************************************/ | |
1984 //void IMEClear(PIME_DATA pIME) | |
1985 void IMEClear(PIME_DATA pIME, PZI8WCHAR wszElementBuffer) | |
1986 { | |
1987 int i = 0; | |
1988 | |
1989 TRACE_EVENT("IMEClear()"); | |
1990 | |
1991 | |
1992 /* handle the condition where the last element is a more tick */ | |
1993 if(pIME->pGetParam->ElementCount != 0) //check ElementCount to see whether ElementBuffer is empty | |
1994 { | |
1995 /* If the last input is a more tick, remove it */ | |
1996 if(pIME->pGetParam->pElements[pIME->pGetParam->ElementCount-1] == ZI8_CODE_MORE) | |
1997 { | |
1998 pIME->moreCount--; | |
1999 | |
2000 /* replace last element with zero */ | |
2001 pIME->pGetParam->pElements[--pIME->pGetParam->ElementCount] = 0; | |
2002 } | |
2003 else | |
2004 { | |
2005 pIME->pGetParam->pElements[--pIME->pGetParam->ElementCount] = 0; | |
2006 pIME->pDisplayElementBuffer[pIME->pGetParam->ElementCount] = 0; | |
2007 } | |
2008 | |
2009 /* When ElementCount is zero and InputScreenType is STROKE_INPUT_SCREEN or PINYIN_INPUT_SCREEN, */ | |
2010 /* InputScreenType will be set to WORD_ASSOCIATION_SCREEN to get the associated character. If no associated */ | |
2011 /* characters can be found, the most common used character in chinese writting will be provided. */ | |
2012 if((pIME->pGetParam->ElementCount == 0 && pIME->InputScreenType == STROKE_INPUT_SCREEN) || | |
2013 (pIME->pGetParam->ElementCount == 0 && pIME->InputScreenType == PINYIN_INPUT_SCREEN)) | |
2014 { | |
2015 pIME->InputScreenType = WORD_ASSOCIATION_SCREEN; | |
2016 } | |
2017 } | |
2018 else | |
2019 { | |
2020 /* remove the last character from text buffer */ | |
2021 /* first update count for word association */ | |
2022 if(pIME->pGetParam->WordCharacterCount > 0) | |
2023 pIME->pGetParam->WordCharacterCount--; | |
2024 | |
2025 /* remove the character at cursor position */ | |
2026 if(pIME->TextCursor != 0) | |
2027 { | |
2028 #ifndef LSCREEN | |
2029 /* replace last character with zero */ | |
2030 if(pIME->TextBufferCount==pIME->TextCursor) | |
2031 { | |
2032 pIME->pTextBuffer[--pIME->TextCursor] = 0; | |
2033 pIME->TextBufferCount--; | |
2034 } | |
2035 else if(pIME->TextBufferCount > pIME->TextCursor) | |
2036 { | |
2037 for (i=pIME->TextCursor; i<pIME->TextBufferCount; i++) | |
2038 { | |
2039 pIME->pTextBuffer[i-1]=pIME->pTextBuffer[i]; | |
2040 } | |
2041 pIME->pTextBuffer[pIME->TextBufferCount-1]=0; | |
2042 pIME->TextCursor--; | |
2043 pIME->TextBufferCount--; | |
2044 } | |
2045 #else /*SPR 1319 delete char in front of cursor */ | |
2046 /* SPR#1428 - SH - New Editor changes */ | |
2047 #ifdef NEW_EDITOR | |
2048 ATB_edit_DeleteLeft(editor_pointer, TRUE); /* SPR#2342 - SH */ | |
2049 #else /* NEW_EDITOR */ | |
2050 edtChar(editor_pointer, ecBack); | |
2051 #endif /* NEW_EDITOR */ | |
2052 pIME->TextBufferCount--; | |
2053 #endif | |
2054 | |
2055 } | |
2056 /* update location of elements */ | |
2057 pIME->pGetParam->pElements = wszElementBuffer; | |
2058 } | |
2059 /* get candidates */ | |
2060 pIME->pGetParam->FirstCandidate = pIME->moreCount * CANDIDATES_PER_GROUP; | |
2061 pIME->pGetParam->MaxCandidates = CANDIDATES_PER_GROUP + 1; | |
2062 pIME->candidates = Zi8GetCandidates(pIME->pGetParam); | |
2063 /* Convert the data storage format for display purpose */ | |
2064 DataConvert(pIME); | |
2065 /* initialize the candidate cursor to zero */ | |
2066 pIME->CandidateCursor = 0; | |
2067 } | |
2068 | |
2069 | |
2070 /******************************************************************************* | |
2071 | |
2072 $Function: CandidateHighlightDisplayContorl | |
2073 | |
2074 $Description: With given candidate cursor position, and character stored in the HighlightedCandidate, | |
2075 this function will invert the colour of the candidate to indicate user the current selected | |
2076 character. | |
2077 | |
2078 $Returns: void | |
2079 | |
2080 $Arguments: | |
2081 | |
2082 *******************************************************************************/ | |
2083 void CandidateHighlightDisplayContorl(PIME_DATA pIME, PZI8WCHAR HighlightedCandidate) | |
2084 { | |
2085 /* Highlight the candidate character pointed by Ime.CandidateCursor */ | |
2086 #ifndef LSCREEN | |
2087 if(pIME->CandidateCursor == 0) | |
2088 dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)HighlightedCandidate); | |
2089 else if(pIME->CandidateCursor == 1) | |
2090 dspl_TextOut(13,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)HighlightedCandidate); | |
2091 else if(pIME->CandidateCursor == 2) | |
2092 dspl_TextOut(25,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)HighlightedCandidate); | |
2093 else if(pIME->CandidateCursor == 3) | |
2094 dspl_TextOut(37,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)HighlightedCandidate); | |
2095 else if(pIME->CandidateCursor == 4) | |
2096 dspl_TextOut(49,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)HighlightedCandidate); | |
2097 else if(pIME->CandidateCursor == 5) | |
2098 dspl_TextOut(61,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)HighlightedCandidate); | |
2099 else | |
2100 dspl_TextOut(73,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)HighlightedCandidate); | |
2101 #else | |
2102 { | |
2103 /* | |
2104 SPR 1319 manually highlight selected candidate | |
2105 GW SPR#1732 - Added 0x80, 0x00 to the start of the 2 byte unicode string | |
2106 */ | |
2107 char hChar[10]; | |
2108 memcpy(&hChar[2],HighlightedCandidate,8); | |
2109 hChar[0] = 0x80; hChar[1] = 0x00; | |
2110 dspl_TextOut(pIME->CandidateCursor*CHI_FONT_WIDTH+1,SCREEN_SIZE_Y-Mmi_layout_line(3),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)hChar); | |
2111 } | |
2112 #endif | |
2113 } | |
2114 | |
2115 | |
2116 /******************************************************************************* | |
2117 | |
2118 $Function: TextCursorDisplayContorl | |
2119 | |
2120 $Description: To display the cursor position to user during text editing. | |
2121 | |
2122 $Returns: void | |
2123 | |
2124 $Arguments: | |
2125 | |
2126 *******************************************************************************/ | |
2127 void TextCursorDisplayContorl(PIME_DATA pIME, PZI8WCHAR CursorPosition, int InsertLine) | |
2128 { | |
2129 int TempTextCursor = 0; | |
2130 int x_position = 1; | |
2131 int i; | |
2132 int line;//position of char at start of line | |
2133 | |
2134 TempTextCursor = pIME->TextCursor % CANDIDATES_PER_GROUP; | |
2135 line = pIME->TextCursor - TempTextCursor; | |
2136 for (i=0; i < TempTextCursor; i++) | |
2137 | |
2138 { //if last byte of word is 0x00, and first byte is between 0x20 and 0x7E | |
2139 if (LatinChar(pIME->pTextBuffer[line+i])) | |
2140 x_position +=6; | |
2141 else | |
2142 x_position+=CHI_FONT_WIDTH;/*SPR 1319 using macro rather than magic no*/ | |
2143 } | |
2144 switch(pIME->InputScreenType) | |
2145 { | |
2146 case TEXT_DISPLAY_SCREEN: | |
2147 | |
2148 if(InsertLine == 1) | |
2149 { | |
2150 | |
2151 dspl_TextOut(x_position,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)CursorPosition); | |
2152 | |
2153 | |
2154 } | |
2155 else | |
2156 { dspl_TextOut(x_position,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)CursorPosition); | |
2157 | |
2158 } | |
2159 break; | |
2160 case STROKE_INPUT_SCREEN: | |
2161 case WORD_ASSOCIATION_SCREEN: | |
2162 dspl_TextOut(x_position,0,DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)CursorPosition); | |
2163 | |
2164 default: | |
2165 break; | |
2166 } | |
2167 } | |
2168 | |
2169 | |
2170 /******************************************************************************* | |
2171 | |
2172 $Function: DataConvert | |
2173 | |
2174 $Description: To change to data storage format i.e if a unicode is 0x89D5. | |
2175 The DataConvert function will change storage format to 0xD589 (This format | |
2176 is required to display UniCode on LCD). The data format is chaged by | |
2177 byte shifting. | |
2178 | |
2179 $Returns: void | |
2180 | |
2181 $Arguments: | |
2182 | |
2183 *******************************************************************************/ | |
2184 void DataConvert(PIME_DATA pIME) | |
2185 { | |
2186 ZI8WCHAR HighByte; | |
2187 ZI8WCHAR Temp; | |
2188 ZI8WCHAR LowByte; | |
2189 ZI8WCHAR tempString[25]; | |
2190 int word_length; | |
2191 int i = 0; | |
2192 int count = 0; | |
2193 TRACE_EVENT("DataConvert"); | |
2194 | |
2195 | |
2196 if((pIME->InputScreenType == STROKE_INPUT_SCREEN) || | |
2197 (pIME->InputScreenType == PINYIN_INPUT_SCREEN)) | |
2198 { | |
2199 count = pIME->pGetParam->ElementCount; | |
2200 /* The more tick is not to be displayed on LCD therefore it is not considered. */ | |
2201 while((count > 0) && pIME->pGetParam->pElements[count - 1] == ZI8_CODE_MORE) | |
2202 { | |
2203 count--; | |
2204 } | |
2205 | |
2206 /* Format of the data stored in the array pointed by pElement is converted and */ | |
2207 /* saved in the array pointed by pDisplayElementBuffer. Please note that the */ | |
2208 /* the data format stored in the array pointed by pElement was unchanged. This */ | |
2209 /* is kept that way for eZiText character search.*/ | |
2210 if (pIME->InputScreenType == STROKE_INPUT_SCREEN) | |
2211 { for(i = 0; i < count; i++) | |
2212 { | |
2213 Temp = pIME->pGetParam->pElements[i]; | |
2214 LowByte = pIME->pGetParam->pElements[i] & 0x00FF; | |
2215 HighByte = pIME->pGetParam->pElements[i] & 0xFF00; | |
2216 Temp = (LowByte << 8) & 0xFF00; | |
2217 HighByte = (HighByte >> 8) & 0x00FF; | |
2218 Temp = Temp | HighByte; | |
2219 pIME->pDisplayElementBuffer[i] = Temp; | |
2220 } | |
2221 pIME->pDisplayElementBuffer[count] = 0x0000; //terminate string | |
2222 } | |
2223 | |
2224 if (pIME->InputScreenType == PINYIN_INPUT_SCREEN) | |
2225 { int no_of_display_chars; | |
2226 int i; | |
2227 word_length = count; //let's use user input for display | |
2228 /*word_length = */Zi8GetCharInfo(pIME->pGetParam->pCandidates[pIME->CandidateCursor], tempString, 12, ZI8_GETMODE_PINYIN); | |
2229 TRACE_EVENT((char*)tempString);/*MC Tracing first matched pinyin word*/ | |
2230 | |
2231 /*MC convert input elements from EZi element codes to Ezi Pinyin spelling for display*/ | |
2232 for (i=0; i<word_length; i++) | |
2233 { tempString[i] = (((pIME->pGetParam->pElements[i]-ZI8_BASE_PINYIN)+LOWER_CASE_ASCII_OFFSET)) +EZITEXT_OUTPUT_OFFSET; | |
2234 } | |
2235 | |
2236 if (word_length > 0) | |
2237 { | |
2238 if (word_length < count) | |
2239 no_of_display_chars = word_length; | |
2240 else | |
2241 no_of_display_chars = count; | |
2242 /***************************Go-lite Optimization changes Start***********************/ | |
2243 //Aug 16, 2004 REF: CRR 24323 Deepa M.D | |
2244 TRACE_EVENT_P1("chars returned: %d", word_length); | |
2245 /***************************Go-lite Optimization changes end***********************/ | |
2246 for(i = 0; i < no_of_display_chars; i++) | |
2247 { | |
2248 Temp = tempString[i]; | |
2249 LowByte = tempString[i] & 0x00FF; | |
2250 HighByte = tempString[i] & 0xFF00; | |
2251 Temp = (LowByte << 8) & 0xFF00; | |
2252 HighByte = (HighByte >> 8) & 0x00FF; | |
2253 Temp = Temp |HighByte; | |
2254 pIME->pDisplayElementBuffer[i] = Temp; | |
2255 } | |
2256 pIME->pDisplayElementBuffer[no_of_display_chars] = 0x0000;//terminate string | |
2257 } | |
2258 | |
2259 } | |
2260 } | |
2261 | |
2262 | |
2263 /* format of the data stored in the array pointed by pCandidates is coverted for display */ | |
2264 for(i = 0; i < pIME->pGetParam->count; i++) | |
2265 { | |
2266 Temp = pIME->pGetParam->pCandidates[i]; | |
2267 LowByte = pIME->pGetParam->pCandidates[i] & 0x00FF; | |
2268 HighByte = pIME->pGetParam->pCandidates[i] & 0xFF00; | |
2269 Temp = (LowByte << 8) & 0xFF00; | |
2270 HighByte = (HighByte >> 8) & 0x00FF; | |
2271 Temp = Temp | HighByte; | |
2272 pIME->pGetParam->pCandidates[i] = Temp; | |
2273 } | |
2274 pIME->pGetParam->pCandidates[pIME->candidates] = 0x0000;//terminate string | |
2275 | |
2276 } | |
2277 | |
2278 | |
2279 /******************************************************************************* | |
2280 | |
2281 $Function: Uni_strlen | |
2282 | |
2283 $Description: To count the number of element from the input array | |
2284 | |
2285 $Returns: number of element | |
2286 | |
2287 $Arguments: | |
2288 | |
2289 *******************************************************************************/ | |
2290 ZI8WCHAR Uni_strlen(PZI8WCHAR String) | |
2291 { | |
2292 int i = 0; | |
2293 ZI8WCHAR count = 0; | |
2294 | |
2295 while(String[i] != 0) | |
2296 { | |
2297 i++; | |
2298 count++; | |
2299 } | |
2300 return count; | |
2301 } | |
2302 |