⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 auicalceditor.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************************

	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:       AUICalcEditor.c
 $Revision:   1.0

 $Author:   Condat(UK)
 $Date:       22/02/01

********************************************************************************

 Description: Editor for calculator, or generic floating-point number input



********************************************************************************

 $History: AUICalcEditor.c
 
  14/11/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 "dspl.h"

#include "ksd.h"
#include "psa.h"

#include "MmiDummy.h"
#include "MmiMmi.h"

#include "MmiDialogs.h"
#include "MmiLists.h"
#include "MmiMenu.h"
#include "MmiSoftKeys.h"
#include "MmiIdle.h"
#include "MmiResources.h"

#include "cus_aci.h"
#include "p_sim.h"
#include "pcm.h"

#include "MmiColours.h"

#include "ATBCommon.h"
#include "ATBDisplay.h"
#include "ATBEditor.h"
#include "AUIEditor.h"
#include "AUITextEntry.h"

#include "AUICalcEditor.h"

typedef struct
{
    T_MMI_CONTROL		mmi_control;
    T_MFW_HND			parent;				// The parent window
    T_MFW_HND			win;				// The edit window
    T_MFW_HND			kbd;				// The keyboard handler
    T_MFW_HND			kbd_long;			// The longpress keyboard handler
    T_MFW_HND			timer;				// The timer for timeouts

	T_ED_DATA			*editor;			/* The ATB editor */
	T_AUI_EDITOR_DATA	editor_data;		/* The MMI editor data, provided by caller */
    T_AUI_ENTRY_DATA	*entry_data;		/* The MMI text entry data */

	BOOL				haveTitle;			/* TRUE if a title is supplied */
    T_ATB_TEXT			title;				/* Title of editor */
    BOOL				haveResult;			/* TRUE if a result is supplied */
    T_ATB_TEXT			result;				/* Text of result */

	BOOL				doNextLongPress;	/* Flag used to notice/not notice long keypress */
	BOOL				hasDecimalPoint;	/* Ensures only one decimal point per number */
}
T_AUI_CALC_DATA;

/* LOCAL FUNCTION PROTOTYPES */
static T_MFW_HND AUI_calc_Create(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data);
static void AUI_calc_ExecCb(T_MFW_HND win, USHORT event, SHORT value, void *parameter);
static int AUI_calc_WinCb(T_MFW_EVENT event, T_MFW_WIN *win_data);
static int AUI_calc_KbdCb(T_MFW_EVENT event, T_MFW_KBD *keyboard);
static int AUI_calc_KbdLongCb(T_MFW_EVENT event, T_MFW_KBD *keyboard);




/*******************************************************************************

 $Function:		AUI_calc_Start

 $Description:	Start the Calc editor.

 $Returns:		None.

 $Arguments:	None.

*******************************************************************************/

T_MFW_HND AUI_calc_Start(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data)
{
    T_MFW_HND win;

    TRACE_FUNCTION ("AUI_calc_Start()");

    win = AUI_calc_Create(parent, editor_data);

    return win;
}


/*******************************************************************************

 $Function:		AUI_calc_Create

 $Description:	Create the Calc editor.
 
 $Returns:		Pointer to the editor's window.

 $Arguments:	parent	-	The parent window.

*******************************************************************************/

static T_MFW_HND AUI_calc_Create(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data)
{
    T_AUI_CALC_DATA	*data = (T_AUI_CALC_DATA *)ALLOC_MEMORY(sizeof (T_AUI_CALC_DATA));
    T_MFW_WIN     		*win_data;

    TRACE_FUNCTION ("AUI_calc_Create()");

	/* Create window handler */

    data->win = win_create(parent, 0, E_WIN_VISIBLE, (T_MFW_CB)AUI_calc_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_calc_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_calc_KbdCb);
	data->kbd_long				= kbd_create(data->win, KEY_ALL|KEY_LONG,(T_MFW_CB)AUI_calc_KbdLongCb); 
	data->editor				= ATB_edit_Create(&data->editor_data.editor_attr,0);

	data->editor_data = *editor_data;
	data->entry_data = AUI_entry_Create(data->win, data->editor, E_CALC_UPDATE);

	SEND_EVENT(data->win, E_CALC_INIT, 0, 0);
	
    /* Return window handle */

    return data->win;
}


/*******************************************************************************

 $Function:		AUI_calc_Destroy

 $Description:	Destroy the Calc editor.

 $Returns:		None.

 $Arguments:	window	-	The editor window.

*******************************************************************************/

void AUI_calc_Destroy(T_MFW_HND win)
{
    T_MFW_WIN		*win_data	= ((T_MFW_HDR *)win)->data;
    T_AUI_CALC_DATA	*data		= (T_AUI_CALC_DATA *)win_data->user;

    if (data)
    {
		AUI_entry_Destroy(data->entry_data);
		
        win_delete (data->win);

		/* Free memory allocated to store result */

		if (data->haveResult)
		{
			FREE_MEMORY(data->result.data, data->result.len*sizeof(char));
		}

		/* Free editor memory */
				
		ATB_edit_Destroy(data->editor);
		FREE_MEMORY ((void *)data, sizeof (T_AUI_CALC_DATA));
    }
    
    return;
}


/*******************************************************************************

 $Function:    	AUI_calc_ExecCb

 $Description:	Dialog function for Calc editor.
 
 $Returns:		None.

 $Arguments:	None.
 
*******************************************************************************/

static void AUI_calc_ExecCb(T_MFW_HND win, USHORT event, SHORT value, void *parameter)
{
    T_MFW_WIN			*win_data	= ((T_MFW_HDR *)win)->data;
    T_AUI_CALC_DATA		*data		= (T_AUI_CALC_DATA *)win_data->user;
    T_MFW_HND			parent_win	= data->parent;
	USHORT				textIndex;
	T_ATB_TEXT			text;
	/* Store these in case editor is destroyed on callback */
    USHORT				Identifier	= data->editor_data.Identifier;
    T_AUI_EDIT_CB		Callback	= data->editor_data.Callback;
    UBYTE				destroyEditor = data->editor_data.destroyEditor;
	
    TRACE_FUNCTION ("AUI_calc_ExecCb()");

    switch (event)
    {
    	/* Initialise */
    
        case E_CALC_INIT:
        	TRACE_EVENT("E_CALC_INIT");
        	ATB_edit_Init(data->editor);

        	data->haveTitle = FALSE;
        	data->haveResult = FALSE;

			/* If we require an output line, shrink editor to fit it at bottom
			 * NB TitleString is assumed here to be a numeric string of ascii digits */

			if (data->editor_data.TitleString)
			{
				data->haveResult = TRUE;
				text.dcs = ATB_DCS_ASCII;
				text.data = data->editor_data.TitleString;
				text.len = ATB_string_Length(&text);

				data->result.data = ALLOC_MEMORY(text.len*sizeof(char));
				ATB_string_Copy(&data->result, &text);

				/* Change size of editor to fit result line in */
				data->editor_data.editor_attr.win_size.sy -= ATB_display_StringHeight(&data->result, NULL);
			}

			/* Set up title */

			if (data->editor_data.TitleId!=NULL)
			{
				data->haveTitle = TRUE;
				data->title.data = (UBYTE *)MmiRsrcGetText(data->editor_data.TitleId);
			}

			/* If title exists, get its dcs and length */
			
			if (data->haveTitle)
			{
				if (data->title.data[0]==0x80)
				{
					data->title.data += 2;		/* Skip over two unicode indicator bytes */
					data->title.dcs = ATB_DCS_UNICODE;
				}
#ifdef EASY_TEXT_ENABLED
				else if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
				{
					data->title.dcs = ATB_DCS_UNICODE;
				}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -