/********************************************************************
版权所有：	
文件版本： V1.00
文件名称： MmiDrv.h
生成日期： 2007年08月26日
作    者：
使用范围：

功    能：菜单驱动处理
更新信息：
更新日志1：
修改者:
修改日期:
修改内容:
修改原因:
*********************************************************************/
#ifndef MMIDRV_DEF
#define MMIDRV_DEF


#define SCREENWIDTH  160
#define SCREENHEIGHT  160
#define  BYTES_PER_LINE		(SCREENWIDTH/8)			/*一线字节数*/
#define  BYTES_SCREEN		(BYTES_PER_LINE*SCREENHEIGHT)	/*整屏字节数*/


#define MAX_DYNAMIC_MENUS 10
#define MAX_LCD_LINE_BYTES 24  /*lcd 液晶一行的最大字符数*/


/*菜单调用函数的返回值*/
enum
{
	M_OK=0,
	M_ERROR,
	M_JUMP0,
	M_JUMP1,
	M_JUMP2,
	M_JUMP3,
	M_JUMP4,
	M_CANCEL=255
};

/*提示信息结构定义*/
typedef struct MESSAGE_FORMS
{
	short x;  // X坐标
	short y;  //Y坐标
	short offX; //X偏移
	short offY;//Y偏移
	short w;   //宽
	short h;   //高
	BYTE bytes; //字节数
	BYTE lines; //行数
	bool bMsg; //存在标志
	short times; //存在时间
}MESSAGE_FORMS_DEF;

typedef struct MenuFieldData     /*菜单结构定义*/
{
	unsigned char	MenuNo;
	unsigned char	FieldNo;
	unsigned short	sAttrib;					/*16进制(唯一) 4	*/
	
	unsigned short	sX;
	unsigned short	sY; /*8*/
	unsigned char	cUpNextMenuNumber;
	unsigned char	cUpNextFieldNumber;	
	
	unsigned char	cDownNextMenuNumber;
	unsigned char	cDownNextFieldNumber; /*12*/
	unsigned char	cLeftNextMenuNumber;
	unsigned char	cLeftNextFieldNumber;	
	
	unsigned char	cRightNextMenuNumber;
	unsigned char	cRightNextFieldNumber;/*16*/
	unsigned char	cEnterNextMenuNumber;
	unsigned char	cEnterNextFieldNumber;	
	
	unsigned char	cEscNextMenuNumber;
	unsigned char	cEscNextFieldNumber;/*20*/
	unsigned char  cJmp0NextMenuNumber;
	unsigned char  cJmp0NextFieldNumber;
	
	unsigned char  cJmp1NextMenuNumber;
	unsigned char  cJmp1NextFieldNumber;/*24*/	
	unsigned char  cJmp2NextMenuNumber;
	unsigned char  cJmp2NextFieldNumber;
	
	unsigned char  cJmp3NextMenuNumber;
	unsigned char  cJmp3NextFieldNumber;/*28*/
	char *	lnFormatStringAddr;     /*对应字符串地址 32*/
	void *	lnVariableAddr;         /*变量地址       36*/
	char *	InfStringAddr;			/*对应字符串地址 40*/
	int (*lnSetFuncAddr)(int);	/*44*/
	int (*lnOnKeyFuncAddr)(int key);	/*48*/
	int (*lnOnTimeFuncAddr)(void);	/*52*/
	uint32_t	lnMmUser;       /*56*/
} MENU_FIELD_DEF;
typedef struct  MenuStartTal            /*260项 1040个字节 000*/
{
	short			sMenuFieldStart;
	unsigned char	sMenuFieldSum;
} MENU_TABLE_DEF;
typedef struct  MenuHead			/*4 个字节 整个菜单信息，最大菜单号，域数统计，410*/
{								/*主要是为了出错处理*/
	short	sMaxMenuNo;
	short	sMaxFieldSum;
} MENU_HEAD_DEF;

typedef struct DataField
{
	void * pData;						/*对应数据地址*/
	char FmtStr[MAX_LCD_LINE_BYTES];    /*格式化描述*/
	UINT para;							/*参数1*/
	bool bEdit;						/*是否可聚焦*/
	UINT    offset;
}DATA_FIELD_DEF;
/*数据菜单显示数据定义*/
typedef struct DataMenu
{    
	int (*GetPrevFuncAddr)(void);	/*44*/
	int (*GetNextFuncAddr)(void);	/*44*/
	void  (*GetValueFuncAddr)(int i,DATA_FIELD_DEF *pF);	
	MENU_FIELD_DEF  tAttribField;   /*菜单定义项保存*/
	DATA_FIELD_DEF tDataFields[MAX_DYNAMIC_MENUS] ; /*一屏内显示的动态数据*/
	short  sFocusIndex; /*第一个显示的动态菜单的索引*/
	short  sTotalNum;     /*总的动态菜单数*/
	short  sScreenNum;     /*每屏菜单数*/
}DATA_MENU_DEF;

typedef struct Forms
{
	DATA_MENU_DEF *pCurrentDataMenu; /*动态菜单地址备份*/
	unsigned char MenuNo;
	unsigned short	sAttrib;					/*16进制(唯一) 4*/
	short  sFormsX;   /*窗体起始坐标*/
	short  sFormsY;
}FORMS_DEF;


typedef struct Screen
{
	unsigned char cActiveMenuNo; /*当前聚焦菜单 */
	unsigned char cActiveFieldNo;

	unsigned char cOldMenuNo;
	unsigned char cOldFieldNo;
	
	unsigned char cPrevMenuNo;
	unsigned char cPrevFiedlNo;

	uint32_t  lnMainTime;        
	uint32_t  lnLightTime;

	unsigned char  lcd_type;
	
	FORMS_DEF     tForm;
}SCREEN_DEF;

extern bool g_bModify;
extern SCREEN_DEF g_tScreen;
extern MESSAGE_FORMS_DEF g_tMessage;
void mmi_get_lcd_type(void);
void  mmi_FormsInit(unsigned char MenuNo,unsigned char FieldNo); /* *p为参数指针*/
void mmi_ScreenInit(void);  /*初始化显示屏幕的数据*/
DATA_MENU_DEF *mmi_GetMenuData(void);
int mmi_GetScreenNum(unsigned char MenuNo,unsigned char FieldNo);
BYTE mmi_GetFloatFactor(void *);
void mmi_ClearMessage(MESSAGE_FORMS_DEF *);
MENU_FIELD_DEF * mmi_GetFieldPointer(unsigned char MenuNo,unsigned char FieldNo);
bool mmi_CheckAutEvent(void);
bool mmi_CheckNoEvent(void);
void mmi_FreshScreen(unsigned char MenuNo,unsigned char FieldNo); /*刷新当前聚焦的窗体*/
void  mmi_Menu_Task(void);
int   mmi_GetActiveFieldPara(void);
int mmi_GetActiveFieldIndex(void);
bool mmi_JumpStrance(int strance,MENU_FIELD_DEF  *pField);
void mmi_zero_passwordstr(void);

#endif

/******************************************************************
								file end
******************************************************************/
