📄 mmitextinput.c
字号:
static T_MFW_HND text_input_create (T_MFW_HND parent_win)
{
T_MFW_WIN * win_data;
T_TEXT_INPUT * data = (T_TEXT_INPUT *)ALLOC_MEMORY (sizeof (T_TEXT_INPUT));
data->input_win = win_create (parent_win, 0, E_WIN_VISIBLE, (T_MFW_CB)text_input_win_cb);
if( data->input_win EQ 0 )
{
return 0;
}
/* Create window handler */
data->mmi_control.dialog = (T_DIALOG_FUNC)text_input_exec_cb;
data->mmi_control.data = data;
data->parent_win = parent_win;
win_data = ((T_MFW_HDR *)data->input_win)->data;
win_data->user = (void *)data;
/*return window handle */
return data->input_win;
}
/*******************************************************************************
$Function: text_input_destroy
$Description: Destruction of an information dialog
$Returns: void
$Arguments: win
*******************************************************************************/
void text_input_destroy (T_MFW_HND own_window)
{
T_MFW_WIN * win = ((T_MFW_HDR *)own_window)->data;
T_TEXT_INPUT * data = (T_TEXT_INPUT *)win->user;
if( data )
{
FirstEnterEditor = 5;
/* Exit TIMER & KEYBOARD Handle */
kbd_delete (data->input_kbd);
/* Delete WIN Handler */
win_delete (data->input_win);
/* Free Memory */
FREE_MEMORY ((void *)data, sizeof (T_TEXT_INPUT));
}
}
/*******************************************************************************
$Function: text_input_exec
$Description:
$Returns: void
$Arguments: win, window handle event, value, parameter
*******************************************************************************/
static void text_input_exec_cb (T_MFW_HND win, USHORT event, SHORT value, T_EDITOR_DATA * parameter)
{
T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
T_TEXT_INPUT * data = (T_TEXT_INPUT *)win_data->user;
T_EDIT_CB Callback = data->editor_data.Callback;
T_MFW_HND parent_win = data->parent_win;
UINT32 oldFontColor;
//MfwHdr * edit_hdr;
//MfwEdt * edit_controll;
USHORT Identifier = data->editor_data.Identifier;
/* operate the event */
switch( event )
{
case TEXT_INPUT_INIT:
/* I have not understood the use of label text */
/*
if ( data->editor_data.TextString NEQ NULL )
{
memcpy (data->LabelText, data->editor_data.TextString, sizeof(data->LabelText));
}
*/
data->editor_data = *parameter;
data->destroyEditor = data->editor_data.destroyEditor;
TEXT_BUFFER_EDIT_SIZE = (data->editor_data.editor_attr.size - 3);
data->input_kbd = kbd_create (data->input_win, KEY_ALL, (T_MFW_CB)text_input_kbd_cb);
data->input_kbd_long = kbd_create (data->input_win, KEY_ALL|KEY_LONG,(T_MFW_CB)text_input_kbd_cb);
data->input_edt = edtCreate (data->input_win, &data->editor_data.editor_attr,MfwEdtVisible,0);
data->input_key_tim = timCreate(data->input_win,750,(MfwCb) text_input_key_tim_cb);
if( data->editor_data.timeout && (data->editor_data.timeout NEQ FOREVER) )
{
data->input_tim = tim_create (data->input_win, data->editor_data.timeout, (T_MFW_CB)text_input_tim_cb);
tim_start (data->input_tim);
}
else
{
data->input_tim = NULL;
}
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;
editor_input_mode = data->editor_data.InputMode;
data->Ime.EditorMode = data->editor_data.InputMode; /* 2004/06/02 sunsj modify */
data->wszTextBuffer = (PZI8WCHAR)data->editor_data.editor_attr.text;
FirstEnterEditor = 5;
TextInputHandle = data->input_edt;
/* alpha input mode initialize */
editAlphaLevel = 0;
editAlphaKey = KCD_MAX;
IMEInitialize(&data->Ime, &data->GetParam, data->wszTextBuffer, TEXT_BUFFER_EDIT_SIZE,
sizeof(data->wszTextBuffer), data->wcCandidates, data->wszElementBuffer, data->DisplayElementBuffer);
/* 2003/12/29 sunsj set phone book editor context */
if( data->editor_data.edtInPbk != 0 )
{
data->Ime.pGetParam->Context = ZI8_GETCONTEXT_SURNAME;
}
win_show (data->input_win);
break;
case TEXT_INPUT_DESTROY:
/* 2004/05/17 sunsj modify the bug. If delete editor win in callback then will not destroy editor other time */
{
T_MFW_HND oldparent = NULL;
oldparent = data->parent_win;
if( Callback )
{
(Callback) (parent_win, Identifier, value);
}
if( data->parent_win == oldparent )
{
if( data->destroyEditor == TRUE )
{
text_input_destroy(data->input_win);
}
}
}
break;
default:
break;
}
}
/*******************************************************************************
$Function: text_input_win_cb
$Description:
$Returns: void
$Arguments: window handle event, win
*******************************************************************************/
static int text_input_win_cb (T_MFW_EVENT event, T_MFW_WIN * win)
{
T_TEXT_INPUT * data = (T_TEXT_INPUT *)win->user;
T_MFW_HND parent_win = data->parent_win;
USHORT Identifier = data->editor_data.Identifier;
T_EDIT_CB Callback = data->editor_data.Callback;
MfwHdr * edit_hdr = (MfwHdr *)data->input_edt;
MfwEdt * edit_controll = (MfwEdt *)edit_hdr->data;
U32 OldBackgroundColor;
U32 OldForegroundColor;
/* 2003/12/29 sunsj modify buffer size */
char DisplayCandidateBufLine1[CANDIDATES_PER_GROUP*2+3];
char DisplayCandidateBufLine2[CANDIDATES_PER_GROUP*2+3];
int i=0;
int fontHeight = Mmi_layout_line_height();
/* if data is wrong then return */
if( data == 0 )
{
return MFW_EVENT_CONSUMED;
}
if( Callback && data->editor_data.edtInPbk )
(Callback) (parent_win, 1, INFO_EDT_UPDATE);
if( Callback && data->editor_data.Identifier == SMSREAD_EDIT )
(Callback) (parent_win, 1, INFO_EDT_UPDATE);
/* 2004/05/08 sunsj modify */
if( (data->editor_data.editor_attr.text[0]=='\0' )&&(data->editor_data.Identifier==SMSSEND_ID_TEXTEDIT) )
{
if( data->Ime.EditorMode == PINYIN_INPUT_MODE || data->Ime.EditorMode == STROKE_INPUT_MODE )
{
/* 2004/06/30 sunsj modify for m288b */
#ifdef _M188_
data->editor_data.editor_attr.e_size = 73;
#endif
#if(MAIN_LCD_SIZE==4)
data->editor_data.editor_attr.e_size = 503;
#elif(MAIN_LCD_SIZE==3)
data->editor_data.editor_attr.e_size = 73;
#endif
}
else
{
/* 2004/06/30 sunsj modify for m288b */
#ifdef _M188_
data->editor_data.editor_attr.e_size = 163;
#endif
#if(MAIN_LCD_SIZE==4)
data->editor_data.editor_attr.e_size = 573;
#elif(MAIN_LCD_SIZE==3)
data->editor_data.editor_attr.e_size = 163;
#endif
}
}
else
{
if( data->Ime.EditorMode == PINYIN_INPUT_MODE || data->Ime.EditorMode == STROKE_INPUT_MODE )
{
if( (((data->editor_data.editor_attr.size - 3)/2)+3) >= 0 )
{
data->editor_data.editor_attr.e_size = (((data->editor_data.editor_attr.size - 3)/2)+3);
}
else
{
data->editor_data.editor_attr.e_size = 0;
}
}
else
{
data->editor_data.editor_attr.e_size = data->editor_data.editor_attr.size;
}
}
/*2003/12/24, wangyan modify*/
switch( event )
{
case E_WIN_VISIBLE:
{
if( win->flags & E_WIN_VISIBLE )
{
/* If the editor is phonebook editor then we only need update window */
/* 2004/03/24 sunsj modify for search window cannot refresh */
if( data->editor_data.edtInPbk )// == 1 )
{
MfwEdt *edt;
updateWindow(edit_controll, 0);
edt = ((MfwHdr *) data->input_edt)->data;
edt->flags |= MfwEdtVisible;
/* 2004/03/11 sunsj modify */
edtShow(data->input_edt);
}
/* display the window */
else
{
/* do the first display */
//if( FirstEnterEditor )
{
edtShow(data->input_edt);
if( data->input_kbd == NULL )
{
dspl_TextOut(1, ELEMENT_LINE,DSPL_TXTATTR_INVERS, "input_kbd is null");
}
//FirstEnterEditor--;
}
}
/* 2004/03/08 sunsj modify */
{
//int currentTheme=FlashSettingData.theme;
//dspl_BitBlt(0, 0, menuup[currentTheme].area.sx, menuup[currentTheme].area.sy, 0, (void*)menuup[currentTheme].icons, 0);
}
/* 2004/04/16 sunsj add */
if( data->editor_data.TextId NEQ 0 )
{
/* 2004/06/08 sunsj modify */
char *title;
MfwEdt *edt;
char spareNum[4];
edt = ((MfwHdr *) data->input_edt)->data;
if( getSymbolNumSpare(edt) >= 0 )
{
sprintf(spareNum, "%3d", getSymbolNumSpare(edt));
}
else
{
sprintf(spareNum, "%3d", 0);
}
title = (char *) MmiRsrcGetText(data->editor_data.TextId);
displayTitle( 15, title, spareNum, TITLE_WITH_NUMBER, 0, 0);
}
else if( data->editor_data.TextString NEQ NULL )
{
/* 2004/06/08 sunsj modify */
MfwEdt *edt;
char spareNum[4];
edt = ((MfwHdr *) data->input_edt)->data;
if( getSymbolNumSpare(edt) >= 0 )
{
sprintf(spareNum, "%3d", getSymbolNumSpare(edt));
}
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -