📄 mmichineseinput.c
字号:
/*return window handle */
return data->input_win;
}
/*******************************************************************************
$Function: chinese_pinyin_timer_cb
$Description: Keypad timer callback
$Returns: int
$Arguments: Event mask and timer structure
*******************************************************************************/
static int chinese_pinyin_timer_cb (MfwEvt e, MfwTim *t)
{ T_MFW_WIN * win = (T_MFW_WIN *)mfwParent( mfw_header());
T_chinese_input * data = (T_chinese_input *)win->user;
int i;
TRACE_EVENT("chinese_pinyin_timer_cb()");
for(i=0; i< KCD_STAR; i++)//MC, set all counters to 0
Counter[i] = 0;
}
/*******************************************************************************
$Function: chinese_input_destroy
$Description: Destruction of an information dialog
$Returns: void
$Arguments: win
*******************************************************************************/
void chinese_input_destroy (T_MFW_HND own_window)
{
T_MFW_WIN * win = ((T_MFW_HDR *)own_window)->data;
T_chinese_input * data = (T_chinese_input *)win->user;
TRACE_EVENT ("chinese_input_destroy()");
if (own_window == NULL)
{
TRACE_EVENT ("Error :- Called with NULL Pointer");
return;
}
if(data)
{
/* Exit TIMER & KEYBOARD Handle */
kbd_delete (data->input_kbd);
/* Delete WIN Handler */
win_delete (data->input_win);
/* Free Memory */
/*MC 15/07/02, delete keyboard timer*/
tim_delete(data->KeyPad_Timer_Handle);
data->KeyPad_Timer_Handle= NULL;
/* SPR#1428 - SH - New Editor changes */
#ifdef LSCREEN
#ifdef NEW_EDITOR
if (data->editor)
{
ATB_edit_Destroy(data->editor);
}
#endif
#endif
FREE_MEMORY ((void *)data, sizeof (T_chinese_input));
}
else
{
TRACE_EVENT ("chinese_input_destroy() - data already destroyed") ;
}
}
/*******************************************************************************
$Function: chinese_input
$Description:
$Returns: void
$Arguments: win, window handle event, value, parameter
*******************************************************************************/
void chinese_input_exec (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
{
T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
T_chinese_input * data = (T_chinese_input *)win_data->user;
T_CHINESE_DATA * chinese_data = (T_CHINESE_DATA *)parameter;
#ifdef NEW_EDITOR /* SPR#1428 - SH - New Editor changes */
T_AUI_EDIT_CB Callback = data->Callback_Data.Callback;
#else /* NEW_EDITOR */
T_EDIT_CB Callback = data->Callback_Data.Callback;
#endif /* NEW_EDITOR */
T_MFW_HND parent_win = data->parent_win;
USHORT Identifier = data->Callback_Data.Identifier;
TRACE_EVENT ("chinese_input_exec()");
switch (event)
{
case CHINESE_INPUT_INIT:
data->Callback_Data = *chinese_data;
TEXT_BUFFER_EDIT_SIZE = data->Callback_Data.EditorSize;
/* Initialize dialog */
/* Create timer and keyboard handler */
data->input_kbd = kbd_create (win, KEY_ALL, (T_MFW_CB)chinese_input_kbd_cb);
/* Initialize all data structure and veriables to zero */
memset(&data->Ime, 0, sizeof(data->Ime));
memset(&data->GetParam, 0, sizeof(data->Ime));
memset(&data->wcCandidates, 0, sizeof(data->wcCandidates));
memset(&data->HighlightedCandidate, 0, sizeof(data->HighlightedCandidate));
memset(&data->CursorPosition, 0, sizeof(data->CursorPosition));
memset(&data->DisplayElementBuffer, 0,sizeof(data->DisplayElementBuffer));
data->StartOfDisplayIndex = 0;
data->NumberOfKeyPress = 0;
data->PerviousKeyPress = -1;
/* Now intitialize the Zi8 Core Engine */
Zi8Initialize();
/* Now initialize the IME */
data->wszTextBuffer = (ZI8WCHAR*)&chinese_data->TextString[2]; //ignore first char (Unicode marker)
IMEInitialize(&data->Ime, &data->GetParam, data->wszTextBuffer, TEXT_BUFFER_EDIT_SIZE,
sizeof(data->wszTextBuffer), data->wcCandidates, data->wszElementBuffer, data->DisplayElementBuffer);
/* Store any other data */
#ifdef LSCREEN /* SPR 1319 create an mfw editor to display editor content*/
/* SPR#1428 - SH - New Editor changes */
#ifdef NEW_EDITOR
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);
data->editor_attr.win_size.sy = Mmi_layout_line_height()*8;/*Don't want to cover whole screen*/
data->editor = ATB_edit_Create(&data->editor_attr, 0);
ATB_edit_Init(data->editor);
ATB_edit_Char(data->editor, ctrlBottom, TRUE);
#else /* NEW_EDITOR */
editor_attr_init(&data->editor_attr, 0, edtCurBar1, NULL, chinese_data->TextString,TEXT_BUFFER_EDIT_SIZE*2+2 , COLOUR_EDITOR );
data->editor_attr.win.sy = Mmi_layout_line_height()*8;/*Don't want to cover whole screen*/
data->editor =edtCreate(data->input_win, &data->editor_attr, 0, 0);
edtChar(data->editor, ecBottom);
edtUnhide (data->editor);
#endif /* NEW_EDITOR */
editor_pointer = data->editor;
#endif
win_show (win);
break;
/*MC SPR 1752 same as E_ED_DESTROY*/
case CHINESE_INPUT_DESTROY:
if (data)
{
chinese_input_destroy(win);
}
break;
/*MC SPR 1752, new event*/
case CHINESE_INPUT_DEINIT:
{/* on DEINIT => selfdestroy; sendevent <value> */
int i;
//GW-SPR-#1068-After the callback, ensure 'data' is up-to-date
if (Callback)
{
(Callback) (parent_win, Identifier, value);
//Callback may have freed data - if so reinit pointer
data = (T_chinese_input *)win_data->user;
}
if (data)
{
if (data->Callback_Data.DestroyEditor == TRUE)
{
chinese_input_destroy(win);
}
}
}
break;
case ADD_SYMBOL:/*adding a symbol to chinese editor from symbol selection screen*/
if (data->Ime.TextBufferCount < TEXT_BUFFER_EDIT_SIZE)
{
#ifndef LSCREEN
int i=0;
int j=0;
if(data->Ime.TextCursor < data->Ime.TextBufferCount) /* locate the text cursor position for correct character insertion */
{/* shift and move characters to make room to insert the selected character */
for (i=data->Ime.TextCursor; i<data->Ime.TextBufferCount; i++)
{
data->Ime.pTextBuffer[data->Ime.TextBufferCount - j]=data->Ime.pTextBuffer[data->Ime.TextBufferCount - j - 1];
j++;
}
}
/* SPR#1428 - SH - New Editor changes */
#ifdef NEW_EDITOR
/* Now, value we get is already unicode */
data->Ime.pTextBuffer[data->Ime.TextCursor++]= (ZI8WCHAR)((USHORT)value);
#else
/*Shift char up into Unicode from ASCII*/
data->Ime.pTextBuffer[data->Ime.TextCursor++]= (ZI8WCHAR)(SymbolChar << 8);
#endif
data->Ime.TextBufferCount++;/*increase char count by one*/
#else /*SPR 1319*/
/* SPR#1428 - SH - New Editor changes */
#ifdef NEW_EDITOR
ATB_edit_Char(data->editor, (USHORT)value, TRUE);
#else /* NEW_EDITOR */
edtChar(data->editor, SymbolChar<<8);/*pop the symbol in the editor*/
#endif /* NEW_EDITOR */
data->Ime.TextBufferCount++;/*increase char count by one*/
#endif /* COLOURDISPLAY */
}
win_show(win);
break;
case LATIN_INPUT:/*return from Latin editor*/
/*update size of buffer*/
data->Ime.TextBufferCount = Uni_strlen(data->Ime.pTextBuffer);
data->Ime.TextCursor = data->Ime.TextBufferCount;/*move cursor to end*/
#ifdef LSCREEN
#ifdef NEW_EDITOR
resources_setColour(COLOUR_EDITOR);
ATB_edit_Refresh(data->editor);
ATB_edit_MoveCursor(data->editor, ctrlBottom, TRUE);
#endif
#endif
//win_show(data->input_win);
break;
}
}
/*******************************************************************************
$Function: chinese_input_win_cb
$Description:
$Returns: void
$Arguments: window handle event, win
*******************************************************************************/
static int chinese_input_win_cb (T_MFW_EVENT event, T_MFW_WIN * win)
{
T_chinese_input * data = (T_chinese_input *)win->user;
int i = 0;
int j = 0;
PZI8WCHAR Temp_ptr;
TRACE_EVENT ("chinese_input_win_cb()");
if(data EQ 0)
return 1;
switch (event)
{
case E_WIN_VISIBLE:
if (win->flags & E_WIN_VISIBLE)
{
/*
** Initialise the colours for the editor
*/
resources_setColour(COLOUR_EDITOR);
/* Print the information dialog */
/* Clear Screen */
dspl_ClearAll();
switch (data->Ime.InputScreenType)
{
case TEXT_DISPLAY_SCREEN:
{
/* This section of the code was written to display the data stored in the text buffer. The text cursor position */
/* was also taken into consideration to display the correct portion of text during editing (when data stored in */
/* the text buffer is more than two line display. */
ZI8WCHAR TempArray[CANDIDATES_PER_GROUP*2]; //maximum no of chars possible in a line
ZI8WCHAR TempArray2[CANDIDATES_PER_GROUP+1];
int i;
int space_counter;
UBYTE first_line= 0; //no of chars in first line(set to minimum)
UBYTE second_line=0; //no of chars in second line
dspl_BitBlt(75,0,8,8,0,(char*)TextIconeZiTextSmall,0);
memset(TempArray, 0, CANDIDATES_PER_GROUP*2);
if(data->Ime.TextBufferCount == 0) //If text buffer is empty
{
displaySoftKeys(data->Callback_Data.LeftSoftKey,TxtSoftBack); /* Softkey display*/
}
else
#ifndef LSCREEN
{
if(data->Ime.TextBufferCount <= (CANDIDATES_PER_GROUP * 2)) // data in text buffer is within 2 lines
{
for(i=0; i<CANDIDATES_PER_GROUP; i++)
TempArray[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i];
TempArray[CANDIDATES_PER_GROUP] = 0x0000;
dspl_TextOut(1,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char*)TempArray);
if(data->Ime.TextBufferCount > CANDIDATES_PER_GROUP)
{
for(i=0; i<CANDIDATES_PER_GROUP; i++)
TempArray2[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i+CANDIDATES_PER_GROUP];
TempArray2[CANDIDATES_PER_GROUP] = 0x0000;
dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char *)TempArray2);
}
j = (data->Ime.TextCursor / CANDIDATES_PER_GROUP) + 1;
TextCursorDisplayContorl(&data->Ime, data->CursorPosition, j);
displaySoftKeys(data->Callback_Data.LeftSoftKey,TxtDelete); /* Softkey display*/
}
else // data in text buffer is more than 14 characters.
{
if(data->Ime.TextCursor == data->StartOfDisplayIndex)
{
for(i=0; i<CANDIDATES_PER_GROUP; i++)
TempArray[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i];
TempArray[CANDIDATES_PER_GROUP] = 0x0000;
dspl_TextOut(1,Mmi_layout_line(1),DSPL_TXTATTR_UNICODE,(char *)TempArray);
for(i=0; i<CANDIDATES_PER_GROUP; i++)
TempArray2[i]= data->wszTextBuffer[data->StartOfDisplayIndex+ i +CANDIDATES_PER_GROUP];
TempArray2[CANDIDATES_PER_GROUP] = 0x0000;
dspl_TextOut(1,Mmi_layout_line(2),DSPL_TXTATTR_UNICODE,(char *)TempArray2);
TextCursorDisplayContorl(&data->Ime, data->CursorPosition, 1);
}
else if(data->Ime.TextCursor > data->StartOfDisplayIndex)
{
while(data->Ime.TextCursor - data->StartOfDisplayIndex >= CANDIDATES_PER_GROUP*2)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -