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

📄 mmitimedate.c

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

					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:		    MmiTimeDate.c
 $Revision:		1.0                                                       
                                                                              
 $Author:		Condat(UK)                                                         
 $Date:		    22/02/01                                                      
                                                                               
********************************************************************************
                                                                              
 Description:

  

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

 $History: MmiMain.c

	25/10/00			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_sys.h"
#include "p_sim.h"


#include "mfw_mfw.h"
#include "mfw_win.h"

#include "mfw_kbd.h"
/* SPR#1428 - SH - New Editor changes */
#ifndef NEW_EDITOR
#include "mfw_edt.h"
#endif
#include "mfw_lng.h"
#include "mfw_tim.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_phb.h"
#include "mfw_cm.h"
#include "mfw_sim.h"
#include "mfw_nm.h"
#include "mfw_sat.h"
#include "mfw_phb.h"
#include "ksd.h"
#include "psa.h"
#include "mfw_sms.h"
#include "mfw_sat.h"
#include "Mfw_td.h"/*SPR 1725*/

#include "dspl.h"

#include "gdi.h" //ES!!

#include "MmiMmi.h"
#include "MmiDummy.h"
#include "MmiDialogs.h"
#include "MmiLists.h"

#include "MmiSoftkeys.h"
#include "MmiIcons.h"
#include "MmiMenu.h"
#include "MmiMain.h"
#include "MmiIdle.h"
#include "MmiStart.h"
#include "MmiPins.h"
#include "MmiTimeDate.h"
#include "MmiSounds.h"
/* SPR#1428 - SH - New Editor changes */
#ifdef NEW_EDITOR
#include "ATBCommon.h"
#include "ATBDisplay.h"
#include "ATBEditor.h"
#include "AUIEditor.h"
#else
#include "MmiEditor.h"
#endif

#include "audio.h"
#include "cus_aci.h"
#include "p_sim.h"

#include "mmicolours.h"

void alarm_screen();
int time_date_cb(T_MFW_EVENT event,void* para);/*SPR 1725 handles events from MFW*/

	T_MFW_DATE alarmDate;/*SPR 1725 we need a global to store the alarm date */
#ifdef NEW_EDITOR
	T_MFW_TIME alarmTime; /*SPR 1725*/
#endif

/* SPR#1428 - SH - New Editor changes.
 * Time and date module pretty much rewritten to use new formatted input of editor.
 */
 
#ifdef NEW_EDITOR

/* LOCAL FUNCTION PROTOTYPES */
static int tida_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
static void tida_exec_cb(T_MFW_HND win, USHORT event, SHORT value, void * parameter);
T_MFW_HND tida_edit_create(T_MFW_HND parent, USHORT Identifier, USHORT TitleId, char *buffer, char *formatString);
void tida_edit_cb(T_MFW_HND win, USHORT Identifier, SHORT value);
void tida_show_dlg(T_MFW_HND win, USHORT textId1, USHORT textId2);
UBYTE tida_check_date(char *datestring);
UBYTE tida_check_time(char *timestring);

#define MAX_DIG_TIDA		20	        /* Max size of buffer, arbitrary value  */

/* TIME/DATE main structure */

typedef struct
{
  T_MMI_CONTROL    mmi_control;
  T_MFW_HND        parent_win;
  T_MFW_HND			win;				/* The main time/date window */
  T_MFW_HND			edit_win;			/* The editor window */
  char				buffer[MAX_DIG_TIDA];			/* Buffer to store currently edited time/date */
} T_tida;

#else /* NEW_EDITOR */

/* OLD VERSION */

static int tida_edt_kbd_long_cb (MfwEvt e, MfwKbd *kc);
static void tida_edt_tim_out_cb(T_MFW_EVENT event,T_MFW_TIM * t);
static int check_time (T_MFW_HND win, void * edt_dat);
static int check_date (T_MFW_HND win, void * edt_dat);
static int tida_edt_kbd_cb (MfwEvt e, MfwKbd *kc);
static void tida_editor(T_MFW_HND win, USHORT event, SHORT value, void * parameter);
static int tida_edt_win_cb  (T_MFW_EVENT event,T_MFW_WIN * win);
static int tida_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
static void tida_main(T_MFW_HND win, USHORT event, SHORT value, void * parameter);
static void reset_edt_attr_sett(int editZone, U32 colIndex, U8 font,U8 mode,
					U8 *controls, char *text,U16 size,MfwEdtAttr* attr);

static MfwHnd win;                      /* our window               */
static DisplayData DisplayInfo;

#define MAX_DIG_TIDA		20	        /* size of buffer (??)  */
#define MAX_LEN_DATE		11	        /* maximum number of digits date*/
#define MAX_LEN_TIME		6	        /* maximum number of digits time*/
#define DATE_TEXT_X         0
#define DATE_TEXT_Y         0

typedef enum
{
	ALARM,
	SETTING
} timeDateMode;

typedef struct
{
  T_MMI_CONTROL    mmi_control;
  T_MFW_HND        parent_win;
  T_MFW_HND        tida_win;
  USHORT		   display_id1;
  USHORT		   display_id2;
  DAT_TIME_CASE    state;               /* setting state            */
} T_tida;

typedef struct
{
  T_MMI_CONTROL    mmi_control;
  T_MFW_HND        parent_win;
  T_MFW_HND        tida_edt_win;
  T_MFW_HND        kbd_handle;
  T_MFW_HND        kbd_long_handle;
  T_MFW_HND        editor_handle;
  T_MFW_HND        tim_out_handle;
  DAT_TIME_CASE    state;               /* setting state            */
  char edtbuf1[MAX_DIG_TIDA];
  MfwEdtAttr edit1Attr;
  UBYTE            index;
}T_tida_edt;



/*
 * Settings menu subs:
 */

#define TIMERCLEAR		2500

//Flag to indicate whether we're setting the current or alarm date/time.
static UBYTE DateTimeEntryMode;

extern UBYTE getcurrentAlarmTone(void);  //mmisounds

#endif /* NEW_EDITOR */
T_MFW_HND td_handle;
/* FUNCTIONS BELOW ARE COMMON TO OLD AND NEW VERSION */

/*SPR 1725 removed function alarm_check()*/


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

 $Function:  time_date_init

 $Description:	 initialises time and date

 $Returns:		none.

 $Arguments:	none
 
*******************************************************************************/
void time_date_init()
{	mfw_td_init();

	td_handle = mfw_td_create(NULL, MFW_TD_ALARM, time_date_cb);
}
/*******************************************************************************

 $Function:  time_date_init

 $Description:	 deletes mfw td 

 $Returns:		none.

 $Arguments:	none
 
*******************************************************************************/
void time_date_delete()
{
	mfw_td_delete(td_handle);
	mfw_td_exit();
}
/*******************************************************************************

 $Function:  time_date_cb

 $Description:	 handles alarm event from MFW

 $Returns:		none.

 $Arguments:	none
 
*******************************************************************************/
int time_date_cb(T_MFW_EVENT event,void* para)
{
	alarm_screen();
}

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

 $Function:  alarm_screen

 $Description:	 displays alarm screen

 $Returns:		none.

 $Arguments:	none
 
*******************************************************************************/
void alarm_screen(void)
{
	T_MFW_HND idle_win = idle_get_window();
	T_DISPLAY_DATA display_info;
	T_MFW_TIME* time;

    static char text[25];
    
  	/*SPR 1725, convert function to use new MFW functions*/
  	time = mfw_td_get_time();

	sprintf(text, "%02d:%02d", time->hour, time->minute);

	dlg_initDisplayData_TextId( &display_info, TxtSoftOK, TxtNull, TxtAlarm, TxtNull , COLOUR_STATUS);
	dlg_initDisplayData_events( &display_info, NULL, FOREVER, KEY_CLEAR|KEY_LEFT|KEY_RIGHT );
    display_info.TextString2  = text;
	
	
    /* Call Info Screen
    */
    info_dialog( idle_win, &display_info );

}




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

 $Function:  clear_alarm 

 $Description:	 handles menu option to cancel any existing alarm setting

 $Returns:		status int

 $Arguments:	menu and item (not used)
 
*******************************************************************************/
int clear_alarm(MfwMnu* m, MfwMnuItem* i)
{	T_MFW_HND win =  mfwParent( mfw_header() );
	T_DISPLAY_DATA display_info;

	
	/*SPR 1725, changed to use new MFW functions*/
	mfw_td_cancel_alarm();
		
	dlg_initDisplayData_TextId( &display_info, TxtSoftOK, TxtNull, TxtAlarm, TxtCancelled , COLOUR_STATUS);
	dlg_initDisplayData_events( &display_info, NULL, THREE_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT );
	
    /* Call Info Screen
    */
    info_dialog( win, &display_info );


    return MFW_EVENT_CONSUMED;

}


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

 $Function:  	twelve_hour_clock

 $Description:	 handles selection of twleve hour clock in menu

 $Returns:		status int

 $Arguments:	menu and item (not used)
 
*******************************************************************************/
int twelve_hour_clock(MfwMnu* m, MfwMnuItem* i)
{	T_MFW_HND win =  mfwParent( mfw_header() );
	T_DISPLAY_DATA display_info;
    char text[25];
  	
  	setClockFormat(MFW_TIME_FORMAT_12HOUR);/*SPR 1725*/
  	
	dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TxtClockSetTo, TxtTwelveHour, COLOUR_STATUS);
	dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)NULL, THREE_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT );

    /* Call Info Screen
    */

    info_dialog( win, &display_info );

    return MFW_EVENT_CONSUMED;

}
/*******************************************************************************

 $Function:  	twentyfour_hour_clock

 $Description:	handles selection of twleve hour clock in menu

 $Returns:		status int

 $Arguments:	menu and item (not used)
*******************************************************************************/
int twentyfour_hour_clock(MfwMnu* m, MfwMnuItem* i)
{	T_MFW_HND win =  mfwParent( mfw_header() );
	T_DISPLAY_DATA display_info;
    char text[25];
  	
  	setClockFormat(MFW_TIME_FORMAT_24HOUR);/*SPR 1725*/
  	
	dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TxtClockSetTo, TxtTwentyfourHour, COLOUR_STATUS);
	dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)NULL, THREE_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT );

    /* Call Info Screen
    */

    info_dialog( win, &display_info );

    return MFW_EVENT_CONSUMED;

}


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

 $Function:  alarmTimeDate  

 $Description:	Called when user selects alarm in menu.  Begins editor to enter
 				desired alarm time and date.

 $Returns:		status int 

 $Arguments:	menu and item (not used)
 
*******************************************************************************/
int alarmTimeDate(MfwMnu* m, MfwMnuItem* i)
{
/* SPR#1428 - SH - New Editor changes */
#ifdef NEW_EDITOR
  T_MFW_HND		idle_win	= idle_get_window();
  T_MFW_HND		win			= tida_create(idle_win); /*  Parent_window is idle */

  T_MFW_WIN		*win_data	= ((T_MFW_HDR *)win)->data;
  T_tida		*data		= (T_tida *)win_data->user;

  TRACE_FUNCTION ("MmiTimeDate:alarmTimeDate()");
  
  if(data->win)
  {
	  SEND_EVENT(data->win, TIDA_ALARMDATE,0,0);

  }
#else /* NEW_EDITOR */
  T_MFW_HND idle_win = idle_get_window();
  T_MFW_HND win = date_time_create(idle_win);//  parent_window is idle

  T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
  T_tida * tida_data = (T_tida *)win_data->user;

  TRACE_FUNCTION ("MmiTimeDate:alarmTimeDate()");

  tida_data->state = DATE_ENTRY;
  DateTimeEntryMode = ALARM;

  if(tida_data->tida_win)
  {
	  SEND_EVENT(tida_data->tida_win,DATE_ENTRY,0,tida_data);

  }
#endif /* NEW_EDITOR */
  return 1;
}

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

 $Function:  	settingsTimeDate  

 $Description:	 settings date and time menu function

 $Returns:		none.

⌨️ 快捷键说明

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