📄 auieditor.c
字号:
/*******************************************************************************
CONDAT (UK)
********************************************************************************
This software product is the property of Condat (UK) Ltd and may not be
disclosed to any third party without the express permission of the owner.
********************************************************************************
$Project name: Basic MMI
$Project code: BMI (6349)
$Module: MMI
$File: AUIEditor.c
$Revision: 1.0
$Author: Condat(UK)
$Date: 22/02/01
********************************************************************************
Description:
********************************************************************************
$History: AUIEditor.c
31/01/02 Original Condat(UK) BMI version.
$End
*******************************************************************************/
#define ENTITY_MFW
/* includes */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#if defined (NEW_FRAME)
#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"
#else
#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#endif
#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_tim.h"
#include "mfw_phb.h"
#include "mfw_sms.h"
#include "mfw_ss.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_lng.h"
#include "mfw_sat.h"
#include "mfw_kbd.h"
#include "mfw_nm.h"
#include "mfw_cm.h"
#include "mfw_edt.h"
#include "dspl.h"
#include "ksd.h"
#include "psa.h"
#include "ATBCommon.h"
#include "ATBDisplay.h"
#include "ATBEditor.h"
#include "AUIEditor.h"
#include "MmiDummy.h"
#include "MmiMmi.h"
#include "MmiDialogs.h"
#include "MmiLists.h"
#include "MmiMenu.h"
#include "MmiSoftKeys.h"
#include "MmiIdle.h"
#include "cus_aci.h"
#include "p_sim.h"
#include "pcm.h"
#include "mmiicons.h"
#include "mmibookshared.h"
#include "mmismsmenu.h"
#include "mfw_ffs.h"
#ifdef EASY_TEXT_ENABLED
#include "MmiDictionary.h"
#endif
#include "MmiColours.h"
#include "MMIDictionary.h"
#include "ATBCommon.h"
#include "ATBDisplay.h"
#include "ATBEditor.h"
#include "AUITextEntry.h"
#include "AUIEditor.h"
#include "AUIEditor_i.h"
#include "AUISymbol.h"
#ifndef MFW_EVENT_PASSED
#define MFW_EVENT_PASSED 0
#endif
#define TRACE_AUIEditor // Def/undef this to show/hide the trace_events for this file
static void AUI_edit_ClearPredText(T_AUI_EDITOR_INFO *data);
/*******************************************************************************
Static Data
********************************************************************************/
/* eZiText icon */
static const unsigned char TextIconeZiTextSmall[] =
{
0x03,0x03,0x18,0x7c,0xcc,0x08,0x10,0x0c
};
#define ED_IND_UPPER "ABC"
#define ED_IND_LOWER "abc"
#define ED_IND_CAPS "Abc"
#define ED_IND_NUM "123"
#define ED_IND_NONE "---"
/*******************************************************************************
$Function: AUI_edit_Start
$Description: Start the editor.
$Returns: None.
$Arguments: None.
*******************************************************************************/
T_MFW_HND AUI_edit_Start(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data)
{
T_MFW_HND win;
TRACE_FUNCTION ("AUI_edit_Start()");
win = AUI_edit_Create(parent, editor_data);
return win;
}
/*******************************************************************************
$Function: AUI_edit_QuickStart
$Description: Start the editor.
$Returns: Dialog handler for the editor.
$Arguments: win - the parent window
TitleId - the text id of the title (or NULL)
TitleString - the text string of the title (or NULL)
buffer - the unicode input buffer
len - maximum length of the text entered
editor_info - the T_AUI_EDITOR_DATA structure (allocated but empty)
*******************************************************************************/
T_MFW_HND AUI_edit_QuickStart(T_MFW_HND win, USHORT TitleId, UBYTE *TitleString, USHORT *buffer, USHORT len,
T_AUI_EDITOR_DATA *editor_info, T_AUI_EDIT_CB editor_cb)
{
TRACE_FUNCTION ("AUI_edit_QuickStart()");
AUI_edit_SetDisplay(editor_info, ZONE_FULL_SK_TITLE, COLOUR_EDITOR, EDITOR_FONT);
AUI_edit_SetEvents(editor_info, 0, TRUE, FOREVER, editor_cb);
AUI_edit_SetBuffer(editor_info, ATB_DCS_UNICODE, (UBYTE *)buffer, len);
AUI_edit_SetTextStr(editor_info, TxtSoftOK, TxtDelete, TitleId, TitleString);
AUI_edit_SetAltTextStr(editor_info, 0, NULL, TRUE, TxtSoftBack);
/* create the dialog handler */
return AUI_edit_Start(win, editor_info); /* start the common editor */
}
/*******************************************************************************
$Function: AUI_edit_Create
$Description: Create the editor.
$Returns: Pointer to the editor's window.
$Arguments: parent - The parent window.
*******************************************************************************/
static T_MFW_HND AUI_edit_Create(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data)
{
T_AUI_EDITOR_INFO *data = (T_AUI_EDITOR_INFO *)ALLOC_MEMORY (sizeof (T_AUI_EDITOR_INFO));
T_MFW_WIN *win_data;
TRACE_FUNCTION ("AUI_edit_Create()");
/* Create window handler */
data->win = win_create(parent, 0, E_WIN_VISIBLE, (T_MFW_CB)AUI_edit_WinCb); // Create window
if (data->win==NULL) // Make sure window exists
{
return NULL;
}
/* Connect the dialog data to the MFW-window */
data->mmi_control.dialog = (T_DIALOG_FUNC)AUI_edit_ExecCb; /* Setup the destination for events */
data->mmi_control.data = data;
data->parent = parent;
win_data = ((T_MFW_HDR *)data->win)->data;
win_data->user = (void *)data;
data->kbd = kbd_create(data->win, KEY_ALL,(T_MFW_CB)AUI_edit_KbdCb);
data->kbd_long = kbd_create(data->win, KEY_ALL|KEY_LONG,(T_MFW_CB)AUI_edit_KbdLongCb);
data->editor = ATB_edit_Create(&data->editor_data.editor_attr,0);
data->editor_data = *editor_data;
AUI_edit_Init(data->win);
SEND_EVENT(data->win, E_ED_INIT, 0, 0);
/* Return window handle */
return data->win;
}
/*******************************************************************************
$Function: AUI_edit_Init
$Description: Initialise the editor.
$Returns: Pointer to the editor's window.
$Arguments: win - The editor window
*******************************************************************************/
static void AUI_edit_Init(T_MFW_HND win)
{
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
T_AUI_EDITOR_INFO *data = (T_AUI_EDITOR_INFO *)win_data->user;
T_ATB_TEXT text;
TRACE_FUNCTION("AUI_edit_Init()");
data->editor->update = ED_UPDATE_FULL;
data->predText.len = 0; /* Blank out predictive text buffer */
/* Set up title information */
data->hasTitle = FALSE;
data->title.len = 0; /* Blank out title buffer */
if (data->editor_data.TitleId!=NULL)
{
data->hasTitle = TRUE;
text.data = (UBYTE *)GET_TEXT(data->editor_data.TitleId);
}
else if (data->editor_data.TitleString!=NULL)
{
data->hasTitle = TRUE;
text.data = data->editor_data.TitleString;
}
/* If title exists, get its dcs and length */
if (data->hasTitle)
{
if (text.data[0]==0x80)
{
text.data += 2; /* Skip over two unicode indicator bytes */
text.dcs = ATB_DCS_UNICODE;
}
#ifdef EASY_TEXT_ENABLED
else if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
{
text.dcs = ATB_DCS_UNICODE;
}
#endif
else
{
text.dcs = ATB_DCS_ASCII;
}
text.len = ATB_string_Length(&text);
/* Allocate memory for the title and copy the text there */
data->title.data = (UBYTE *)ALLOC_MEMORY((text.len + 1)*ATB_string_Size(&text));
ATB_string_Copy(&data->title, &text);
}
/* Set up correct parameters for easytext */
#ifdef EASY_TEXT_ENABLED
if (ATB_edit_Mode(data->editor, ED_MODE_ALPHA))
{
/* Allocate word buffer memory */
data->predText.data = (UBYTE *)ALLOC_MEMORY((ED_PREDTEXT_MAX+1)*sizeof(UBYTE));
data->predText.dcs = ATB_DCS_ASCII;
data->predText.len = 0;
FFS_flashData.PredTextAvailable = TRUE;
Initialize_Dict(Mmi_getCurrentLanguage()/*SPR1508*/, 0);
ResetDictSearch();
}
#endif
/* Initialise editor */
ATB_edit_Init(data->editor);
/* Initialise text entry */
data->entry_data = AUI_entry_Create(data->win, data->editor, E_ED_UPDATE);
/* If there's a timeout, create the timer */
if (data->editor_data.timeout && (data->editor_data.timeout != FOREVER))
{
data->timer = tim_create(data->win, data->editor_data.timeout, (T_MFW_CB)AUI_edit_TimerCb);
tim_start(data->timer);
}
else
{
data->timer = NULL;
}
/* SPR#1597 - SH - Title timer, if required, is now set up in WinCb */
data->title_timer = NULL;
return;
}
/*******************************************************************************
$Function: AUI_edit_Destroy
$Description: Destroy the editor.
$Returns: None.
$Arguments: window - The editor window.
*******************************************************************************/
void AUI_edit_Destroy(T_MFW_HND win)
{
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
T_AUI_EDITOR_INFO *data = (T_AUI_EDITOR_INFO *)win_data->user;
#ifdef TRACE_AUIEditor
TRACE_FUNCTION ("AUI_edit_Destroy()");
#endif
if (win == NULL)
{
#ifdef TRACE_AUIEditor
TRACE_EVENT ("Error : Called with NULL Pointer");
#endif
return;
}
if (data)
{
/* Free memory allocated for easytext buffer */
#ifdef EASY_TEXT_ENABLED
if (ATB_edit_Mode(data->editor, ED_MODE_ALPHA) && data->predText.data )
{
TRACE_EVENT("Freeing predictive text buffer");
FREE_MEMORY((void *)data->predText.data, (ED_PREDTEXT_MAX+1)*sizeof(UBYTE));
}
#endif
/* Free memory allocated for title */
if (data->hasTitle)
{
FREE_MEMORY(data->title.data, (data->title.len + 1)*ATB_string_Size(&data->title));
}
/* SPR#1559 - SH - Delete timers */
if (data->timer)
{
tim_delete(data->timer);
data->timer = NULL;
}
if (data->title_timer)
{
tim_delete(data->title_timer);
data->title_timer = NULL;
}
win_delete (data->win);
/* Free editor memory */
AUI_entry_Destroy(data->entry_data);
ATB_edit_Destroy(data->editor);
FREE_MEMORY ((void *)data, sizeof (T_AUI_EDITOR_INFO));
}
return;
}
/*******************************************************************************
$Function: AUI_edit_ExecCb
$Description: Dialog function for editor.
$Returns: None.
$Arguments: None.
*******************************************************************************/
static void AUI_edit_ExecCb(T_MFW_HND win, USHORT event, USHORT value, void *parameter)
{
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -