📄 auipineditor.c
字号:
$Arguments: event - the event
win - the editor window
*******************************************************************************/
static int AUI_pin_WinCb(T_MFW_EVENT event, T_MFW_WIN *win_data)
{
T_AUI_PIN_DATA *data = (T_AUI_PIN_DATA *)win_data->user;
T_ED_DATA *editor = data->editor;
T_ATB_WIN_SIZE *win_size = &data->editor->attr->win_size;
T_ATB_TEXT text;
T_DS_TEXTFORMAT format;
USHORT titleLen;
if (!data)
return MFW_EVENT_CONSUMED;
switch(event)
{
case E_WIN_VISIBLE: /* window is visible */
if (win_data->flags & E_WIN_VISIBLE)
{
if (editor->update==ED_UPDATE_TRIVIAL)
{
TRACE_EVENT("Only updating editor.");
ATB_edit_Show(data->editor);
}
else
{
TRACE_EVENT("Updating whole screen.");
ATB_edit_Show(data->editor);
/* Set the colour for drawing title */
resources_setTitleColour(COLOUR_EDITOR);
/* TITLE - only display if update type is FULL or DEFAULT*/
if (editor->update!=ED_UPDATE_PARTIAL)
{
dspl_Clear(0,0, SCREEN_SIZE_X-1, win_size->py-1);
if (data->haveTitle)
{
ATB_display_SetFormatAttr(&format, 0, FALSE);
/* Display "Emergency?" prompt in title if emergency call */
if (data->emergency_call)
{
text.dcs = data->title.dcs;
text.data = (UBYTE *)MmiRsrcGetText(TxtEmergency);
text.len = ATB_string_Length(&text);
ATB_display_Text(0,0,&format, &text);
}
/* Otherwise, show title */
else
{
ATB_display_Text(0,0,&format, &data->title);
}
}
}
/* Display Soft Keys */
if (data->emergency_call)
{
displaySoftKeys(TxtSoftCall, data->editor_data.RightSoftKey);
}
else
{
if (data->editor_data.editor_attr.text.len < data->editor_data.min_enter)
{
/* entered less than the required number of chars: Alternate Softkey appears */
if (data->editor_data.editor_attr.text.len > 0)
displaySoftKeys(data->editor_data.AltLeftSoftKey,data->editor_data.RightSoftKey);
else
displaySoftKeys(data->editor_data.AltLeftSoftKey,TxtNull);
}
else
{
/* entered sufficient number of chars: Normal Softkey appears */
if (data->editor_data.editor_attr.text.len > 0)
displaySoftKeys(data->editor_data.LeftSoftKey,data->editor_data.RightSoftKey);
else
displaySoftKeys(data->editor_data.LeftSoftKey, TxtNull);
}
}
}
}
break;
}
data->editor->update = ED_UPDATE_DEFAULT;
return;
}
/*******************************************************************************
$Function: AUI_pin_KbdCb
$Description: PIN editor keyboard event handler
$Returns: None.
$Arguments: event - the keyboard event
keyboard
*******************************************************************************/
static int AUI_pin_KbdCb(T_MFW_EVENT event, T_MFW_KBD *keyboard)
{
T_MFW_HND win = mfw_parent (mfw_header());
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
T_AUI_PIN_DATA *data = (T_AUI_PIN_DATA *)win_data->user;
ED_RES result;
TRACE_FUNCTION("AUI_pin_KbdCb()");
/* Suppress unwanted long keypresses */
data->doNextLongPress = TRUE; /* next Key_long event is correct */
data->editor->update = ED_UPDATE_DEFAULT; /* Default behaviour is just to update text */
switch (keyboard->code)
{
case KCD_STAR:
/* Only possible when the first digit is a '*' */
if (data->editor_data.editor_attr.text.len==0 && ATB_edit_Mode(data->editor, ED_MODE_HIDDEN))
{
data->ss_string = TRUE;
/* The string should now be visible on screen */
ATB_edit_ResetMode(data->editor, ED_MODE_HIDDEN);
AUI_entry_EventKey(data->entry_data, event, keyboard);
win_show(data->win);
}
break;
case KCD_HASH:
/* Send SS string if we're entering one */
if(data->ss_string)
{
AUI_entry_EventKey(data->entry_data, event, keyboard);
switch (AUI_pin_CheckSSString(data))
{
case MFW_SS_MMI:
get_imei((char*)data->imei);
showIMEI(win,(char*)data->imei);
ATB_edit_ClearAll(data->editor);
/* Set back to the default */
data->ss_string = FALSE;
/* go back in the hide mode */
ATB_edit_SetMode(data->editor, ED_MODE_HIDDEN);
win_show(data->win);
return MFW_EVENT_CONSUMED;
break;
}
}
else if (data->editor_data.editor_attr.text.len >= data->editor_data.min_enter)
{
if (ATB_edit_Mode(data->editor, ED_MODE_HIDDEN))
{
ATB_edit_HiddenExit(data->editor);
}
SEND_EVENT (win, E_PIN_DEINIT, INFO_KCD_LEFT, NULL);
}
break;
#ifdef COLOURDISPLAY
/* Menu select has same effect as left soft key */
case KCD_MNUSELECT:
#endif /* COLOURDISPLAY */
case KCD_LEFT:
/* Make an emergency call if an appropriate number entered */
if ( data->emergency_call )
{
/* Copy the actual typed text into the buffer */
if (ATB_edit_Mode(data->editor, ED_MODE_HIDDEN))
{
ATB_edit_HiddenExit(data->editor);
}
SEND_EVENT (win, E_PIN_DEINIT, INFO_EMERGENCY, NULL);
}
/* Submit PIN if sufficient characters entered */
else if (data->editor_data.editor_attr.text.len >= data->editor_data.min_enter)
{
/* Left Softkey is enabled (and entered sufficient number of chars): execute it. */
/* Copy the actual typed text into the buffer */
if (ATB_edit_Mode(data->editor, ED_MODE_HIDDEN))
{
ATB_edit_HiddenExit(data->editor);
}
SEND_EVENT (win, E_PIN_DEINIT, INFO_KCD_LEFT, NULL);
}
break;
case KCD_HUP:
break;
case KCD_CALL:
/* Make an emergency call if an appropriate number entered */
if ( data->emergency_call )
{
/* Copy the actual typed text into the buffer */
if (ATB_edit_Mode(data->editor, ED_MODE_HIDDEN))
{
ATB_edit_HiddenExit(data->editor);
}
SEND_EVENT (win, E_PIN_DEINIT, INFO_EMERGENCY, NULL);
}
break;
case KCD_RIGHT:
if(data->editor_data.editor_attr.text.len!=0)
{
ATB_edit_DeleteLeft(data->editor);
/* For a SS string */
if ( !ATB_edit_Mode(data->editor,ED_MODE_HIDDEN) )
{
if (data->editor_data.editor_attr.text.len==0 && data->ss_string)
{
data->ss_string = FALSE;
/* The string should not be visible on screen */
ATB_edit_SetMode(data->editor, ED_MODE_HIDDEN);
}
}
/* is it a emergency call number ?!*/
AUI_pin_CheckEmergency(data);
win_show(data->win);
}
break;
case KCD_0:
case KCD_1:
case KCD_2:
case KCD_3:
case KCD_4:
case KCD_5:
case KCD_6:
case KCD_7:
case KCD_8:
case KCD_9:
AUI_entry_EventKey(data->entry_data, event, keyboard);
/* is it a emergency call number ?!*/
AUI_pin_CheckEmergency(data);
win_show(data->win);
break;
}
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: AUI_pin_KbdLongCb
$Description: PIN editor long keypress keyboard event handler
$Returns: None.
$Arguments: event - the keyboard event
keyboard
*******************************************************************************/
static int AUI_pin_KbdLongCb(T_MFW_EVENT event, T_MFW_KBD *keyboard)
{
T_MFW_HND win = mfw_parent (mfw_header());
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
T_AUI_PIN_DATA *data = (T_AUI_PIN_DATA *)win_data->user;
ED_RES result;
/* Suppress unwanted long keypresses */
if ( data->doNextLongPress )
data->doNextLongPress = FALSE; /* mark Key_long event as consumed but do current long press */
else
return MFW_EVENT_CONSUMED; /* don't do current long press */
switch (keyboard->code)
{
case KCD_RIGHT:
/* Long press of RSK deletes buffer */
result = ATB_edit_ClearAll(data->editor);
/* If we've deleted on an empty buffer, exit editor */
if (result==ED_DONE)
{
SEND_EVENT(data->win, E_PIN_DEINIT, INFO_KCD_RIGHT, 0);
}
else
{
win_show(data->win);
}
break;
}
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: AUI_pin_CheckEmergency
$Description: Check number to see if it's an emergency number
$Returns: None.
$Arguments: data - The editor data
*******************************************************************************/
static UBYTE AUI_pin_CheckEmergency(T_AUI_PIN_DATA *data)
{
UBYTE previous_emergency = data->emergency_call;
UBYTE previous_entered = data->enteredMinChars;
UBYTE previous_someentered = data->enteredSomeChars;
if(cm_check_emergency(data->editor->hiddenText->data))
{
TRACE_EVENT(" it is a emergency number !");
data->emergency_call = TRUE;
}
else
{
data->emergency_call = FALSE;
}
/* Check if we've entered min_enter characters */
if (data->editor_data.editor_attr.text.len >= data->editor_data.min_enter)
data->enteredMinChars = TRUE;
else
data->enteredMinChars = FALSE;
if (data->editor_data.editor_attr.text.len > 0)
data->enteredSomeChars = TRUE;
else
data->enteredSomeChars = FALSE;
/* Check if the softkeys have changed */
if (data->emergency_call!=previous_emergency)
{
data->editor->update = ED_UPDATE_FULL; /* Update softkeys, title and editor */
}
else if (data->enteredMinChars!=previous_entered || data->enteredSomeChars!=previous_someentered)
{
data->editor->update = ED_UPDATE_PARTIAL; /* Update softkeys and editor */
}
else
{
data->editor->update = ED_UPDATE_TRIVIAL; /* Just update editor */
}
return data->emergency_call;
}
/*******************************************************************************
$Function: AUI_pin_CheckSSString
$Description: Check number to see if it's an ss string
$Returns: None.
$Arguments: event - the keyboard event
keyboard
*******************************************************************************/
T_MFW_SS_RETURN AUI_pin_CheckSSString(T_AUI_PIN_DATA *data)
{
return ss_check_ss_string(data->editor_data.editor_attr.text.data);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -