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

📄 mmicalculatormain.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:		Calculator
 $File:		    MmiCalculatorMain.c
 $Revision:		1.0                                                       
                                                                              
 $Author:		Condat(UK)                                                         
 $Date:		    25/10/00                                                      
                                                                               
********************************************************************************
                                                                              
 Description

    This provides the main calculator functionality

  
********************************************************************************
 $History: MmiCalculatorMain.c

	25/10/00			Original Condat(UK) BMI version.	
	   
 $End

*******************************************************************************/
#define MAX_CALC_TOTAL 999999999
#define MIN_CALC_TOTAL -99999999

/******************************************************************************
                                                                              
                                Include Files
                                                                              
*******************************************************************************/
#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 "message.h"
#include "prim.h"
#include "aci_cmh.h"

#include "p_sim.h"

#include "mfw_mfw.h"
#include "mfw_win.h"
/* SPR#1428 - SH - New Editor changes */
#ifndef NEW_EDITOR
#include "mfw_edt.h"
#endif
#include "mfw_tim.h"
#include "mfw_phb.h"
#include "ksd.h"
#include "psa.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_sms.h"

#include "dspl.h"

#include "MmiMmi.h"
#include "MmiDummy.h"
#include "MmiDialogs.h"
#include "MmiLists.h"
#include "MmiIdle.h"
#include "MmiSoftkeys.h"
#include "MmiIcons.h"
#include "MmiMenu.h"
#include "MmiMain.h"
#include "MmiStart.h"
#include "MmiPins.h"
#include "MmiSettings.h"

/* SPR#1428 - SH - New Editor changes */
#ifdef NEW_EDITOR
#include "ATBCommon.h"
#include "ATBDisplay.h"
#include "ATBEditor.h"
#include "AUIEditor.h"
#include "AUICalcEditor.h"
#else
#include "MmiEditor.h"
#endif
#include "MmiBookShared.h"
#include "MmiSmsMenu.h"
#include "MmiCalculatorMain.h"
#include "MMiColours.h"

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


/*******************************************************************************
                                                                              
                                Function Prototypes
                                                                              
*******************************************************************************/
static T_MFW_HND calc_create(MfwHnd parent_window);
void calc_destroy(MfwHnd own_window);
static void calcGetNumberCB( T_MFW_HND win, USHORT Identifier, SHORT reason );
static void calcGetOperandCB( T_MFW_HND win, USHORT Identifier, SHORT reason );
static void calc_DialogCB( T_MFW_HND win, USHORT event, SHORT identifier, void *parameter);
T_MFW_HND calc_start(T_MFW_HND parent_window);
double calcGetRunningTotal(void);
char operatorSymbol(UBYTE operator);
static void calc_menu_cb(T_MFW_HND parent_win, UBYTE identifier, UBYTE reason);
/*******************************************************************************
                                                                              
                                Static Global Variable(s) 
                                                                              
*******************************************************************************/	

static double running_total;

static T_MFW_HND calculator_win = NULL;

/*******************************************************************************
                                                                              
                                Public Functions
                                                                              
*******************************************************************************/
/*******************************************************************************

 $Function:    	calculator

 $Description:	Starts the calculator function on user selection
 
 $Returns:		MFW_EVENT_CONSUMED if event handled, otherwise
				MFW_EVENT_PASSED

 $Arguments:	menu, menu item
 
*******************************************************************************/
int calculator(MfwMnu* m, MfwMnuItem* i)
{
    T_MFW_HND	    	parent       = mfwParent( mfw_header());
    TRACE_FUNCTION("calculator()");
    calc_start(parent);
    return MFW_EVENT_CONSUMED;
}

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

 $Function:    	calcPlus

 $Description:	Handles the selction of the "Plus" option in the calculator menu
 
 $Returns:		MFW_EVENT_CONSUMED if event handled, otherwise
				MFW_EVENT_PASSED

 $Arguments:	menu, menu item
 
*******************************************************************************/
int calcPlus(MfwMnu* m, MfwMnuItem* i)
{
    T_MFW_WIN*			win_data;
	tCalcData*			data;

    TRACE_FUNCTION("calcPlus()");
	//if new window successfully created
    if (calculator_win NEQ NULL)
        {	win_data   = ( (T_MFW_HDR *) calculator_win )->data;
        	data = (tCalcData*)win_data->user;
        	data->operation = PLUS;//set the arithmetic operation
           	SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0);
        } 
    return MFW_EVENT_CONSUMED;
}

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

 $Function:    	calcMinus

 $Description:	Handles the selection of the "Minus" option in the calculator menu
 
 $Returns:		MFW_EVENT_CONSUMED if event handled, otherwise
				MFW_EVENT_PASSED

 $Arguments:	menu, menu item
 
*******************************************************************************/
int calcMinus(MfwMnu* m, MfwMnuItem* i)
{
    T_MFW_WIN*			win_data;
	tCalcData*			data;

	//if new window successfully created
    TRACE_FUNCTION("calcMinus()");
    if (calculator_win NEQ NULL)
        {	win_data   = ( (T_MFW_HDR *) calculator_win )->data;
        	data = (tCalcData*)win_data->user;
        	data->operation = MINUS;//set the arithmetic operation
           	SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0);
        } 
    return MFW_EVENT_CONSUMED;
}

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

 $Function:    	calcDivide

 $Description:	Handles the selection of the "Divide" option in the calculator menu
 
 $Returns:		MFW_EVENT_CONSUMED if event handled, otherwise
				MFW_EVENT_PASSED

 $Arguments:	menu, menu item
 
*******************************************************************************/
int calcDivide(MfwMnu* m, MfwMnuItem* i)
{
    T_MFW_WIN*			win_data;
	tCalcData*			data;

    TRACE_FUNCTION("calcDivide()");
	//if new window successfully created
    if (calculator_win NEQ NULL)
        {	win_data   = ( (T_MFW_HDR *) calculator_win )->data;
        	data = (tCalcData*)win_data->user;
        	data->operation = DIVIDE;//set the arithmetic operation
           	SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0);
        } 
    return MFW_EVENT_CONSUMED;
}
/*******************************************************************************

 $Function:    	calcMultiply

 $Description:	Handles the selection of the "Multiply" option in the calculator menu
 
 $Returns:		MFW_EVENT_CONSUMED if event handled, otherwise
				MFW_EVENT_PASSED

 $Arguments:	menu, menu item
 
*******************************************************************************/
int calcMultiply(MfwMnu* m, MfwMnuItem* i)
{
    T_MFW_WIN*			win_data;
	tCalcData*			data;

    TRACE_FUNCTION("calcMultiply()");
	//if new window successfully created
    if (calculator_win NEQ NULL)
        {	win_data   = ( (T_MFW_HDR *) calculator_win )->data;
        	data = (tCalcData*)win_data->user;
        	data->operation = MULTIPLY;//set the arithmetic operation
           	SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0);
        } 
    return MFW_EVENT_CONSUMED;
}

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

 $Function:    	calcEquals

 $Description:	Handles the selection of the "Equals" option in the calculator menu
 
 $Returns:		MFW_EVENT_CONSUMED if event handled, otherwise
				MFW_EVENT_PASSED

 $Arguments:	menu, menu item
 
*******************************************************************************/
int calcEquals(MfwMnu* m, MfwMnuItem* i)
{
    TRACE_FUNCTION("calcEquals()");

    if (calculator_win NEQ NULL)
        {	
           	SEND_EVENT (calculator_win, CALC_DISPLAY_RESULT, 0, 0);
        } 

    return MFW_EVENT_CONSUMED;
}

/*******************************************************************************
                                                                              
                                Private Functions
                                                                              
*******************************************************************************/	
/*******************************************************************************

 $Function:    	calcGetRunningTotal

 $Description:	If the calculator's running total value ever needs to be accessed by 
 				code in another file, then this function ought to be made public to prevent 
 				to allow safe access;
 
 $Returns:		Calculator's running total (double)

 $Arguments:	none
 
*******************************************************************************/
double calcGetRunningTotal(void)
{
    TRACE_FUNCTION("calcGetRunningTotal()");
	return running_total;
}

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

 $Function:    	operatorSymbol

 $Description:	returns character corresponding to arithmetic operation 
 
 $Returns:		Operator character

 $Arguments:	Operator enum
 
*******************************************************************************/
char operatorSymbol(UBYTE operator)
{
    TRACE_FUNCTION("operatorSymbol()");
	switch (operator)
	{
		case (PLUS): 	return '+'; break;
		case (MINUS):	return '-'; break;
		case (MULTIPLY): return '*'; break;
		case (DIVIDE):	return '/'; break;
		default: 		return '\0'; break;
	}
		
}


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

 $Function:    	calc_start

 $Description:	Creates the calculator window and calls for it to be initialised 
 
 $Returns:		Window

 $Arguments:	Parent Window
 
*******************************************************************************/

T_MFW_HND calc_start(T_MFW_HND parent_window)
{
  	T_MFW_HND       	win           = calc_create(parent_window);
	TRACE_FUNCTION("calc_start()");
    if (win NEQ NULL)
        {
           	SEND_EVENT (win, CALC_INIT, 0, 0);
        } 

   return win;
}

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

 $Function:    	calc_create

 $Description:	Creates the calculator window and connect the dialog data to it
 
 $Returns:		Window

 $Arguments:	Parent Window
 
*******************************************************************************/	
static T_MFW_HND calc_create(MfwHnd parent_window)
{
	tCalcData     * data = (tCalcData *)ALLOC_MEMORY (sizeof (tCalcData ));
	T_MFW_WIN  * win;

    TRACE_FUNCTION("calc_create()");
	if (data EQ NULL)
	{
		return NULL;
	}

	// Create window handler
	data->win = win_create (parent_window, 0, E_WIN_VISIBLE, NULL);
	if (data->win EQ NULL)
	{
		
		return NULL;
	}
	// connect the dialog data to the MFW-window
	data->mmi_control.dialog = (T_DIALOG_FUNC)calc_DialogCB;
	data->mmi_control.data   = data;
	win                      = ((T_MFW_HDR *)data->win)->data;
	win->user                = (void *)data;
	data->parent_win         = parent_window;
	calculator_win = data->win;
	return data->win;
}

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

 $Function:    	calc_DialogCB

 $Description:	Callback function for the calculator window
 
 $Returns:		nothing

 $Arguments:	Window, event, identifier (not used), parameter (not used)
 
*******************************************************************************/
static void calc_DialogCB(T_MFW_HND win, USHORT e,  SHORT identifier, void *parameter)
{ 	
	T_MFW_WIN       	*win_data   = ( (T_MFW_HDR *) win )->data;
	tCalcData* data = (tCalcData *) win_data->user;
	char display_buffer[28] = "";
#ifdef NEW_EDITOR
	T_AUI_EDITOR_DATA	editor_data;	/* SPR#1428 - SH - New Editor data */
#else

⌨️ 快捷键说明

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