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

📄 asixwin.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 3 页
字号:
/*************************************************************************
*
* Copyright  2000 National ASIC Center, All right Reserved
*
* FILE NAME:			asixwin.c
* PROGRAMMER:			Lingming
* Date of Creation:		2001/02/13
* 
* DESCRIPTION: 			The upper part of asix window system. Include the
*						Initial and Creating ,Destroy, DefWindowProc and
*						so on. this file offers the Application Programmer
*                       the ASIX Window API.
*
* NOTE:			 		 
*						 
*
* FUNCTIONS LIST:
* -------------------------------------------------------------------------
* STATUS ASIXInit(void)
* U32 CreateWindow(U8 ClassName, char *Caption, U32 Style, 
*				 	U16 x, U16 y, U16 Width, U16 Height,
*				 	U32 Parent, U32 hMenu, void *exdata)
* STATUS DestroyWindow(U32 Wndid)
* STATUS ASIXGetMessage(PMSG pMessage, U32 *pWnd_id, U16 Reserved1, U16 Reserved2)
* STATUS DefWindowProc(U16 MsgCmd, U32 lparam, P_U16 data, U16 wparam) 
* STATUS IsMyWindow(U32 Wndid, U32 Head)
* STATUS SetWindowText(U32 Wndid, P_U8 Caption, void *exdata);
* STATUS EnableWindow(U32 Wndid, U8 Enable);
* STATUS RepaintWindow(U32 wndid, U32 lparam);
* STATUS PopUpWindow(U32 wndid, U32 reserved );
* STATUS GetWindowStatus(U32 Wndid, P_U32 Status);
*
* GLOBAL VARS LIST:
* 
* WindowClass[]			the window class description const table,which
* 						defines the obj's relevent functions pointer
*
*
**************************************************************************
* MODIFICATION HISTORY
*
* 2001/02/13	by Lingming		Creation of this file
* 2001/05/07	by Lingming		Support window focus
* 2001/08/11	by Lingming		support dynamic shell 										
* 2001/08/29	by Lingming 	seperate task related funs to asixapp.c							
* 2001/09/10	by Lingming		in DefWindowProc(),we filter out the user defined msg
* 2001/10/26	by Lingming 	insert new created win at the list head rather than 
*								at the end that implemented in the old version
* 2001/11/23	by Lingming		bug fixing in CreateWindow, for the failure of the first 
*								win creation of the task.								
* 2001/11/27    by Lingming		add wnd id validation checking in IsMyWindow()
* 2001/11/28    by Lingming		send focus message to related controls in SetFocus()
* 2002/03/09    by Lingming		We add GetCurWindow() to replace the old PPSM version's 
*								CurWindow. This has two advantages: first, we donot need 
*								to handle a gloabl var which is good for a mutitasking 
*								environment and program structure; second, we now can 
*								handle window in backend.
* 2002/3/12     by Xuanhui&Zhuli change [Color Theme Init]
* 2002/03/19	by Lingming		Add group operation during destroy repaint
* 2002/03/20   	by Lingming		discard FocusWindow gloabl var
* 2002/03/22  	by Lingming		Add Repaint Message when destroy a window so that user can
*								repaint their client area.
* 2002/04/03	by longn_qi		bug fixxing in CreateWindow() "winptr->status |= WST_NORMAL;"
*								modification in IsMyMessage() and ASIXGetMessage()
* 2002/09/09	by longn_qi		added function "PopUpWindow"
*************************************************************************/

/* SDS C lib */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* system header file */
#include "ros33.h"
#include "systsk.h"

/* asix window include file*/
#include "asixwin.h"
#include "asixapp.h"

#include "asixdbg.h"

//#include <hc.h>
//#include "uartsvr.h"


#include "button.h"
#include "select.h"
#include "asix_wn.h"
#include "asix_mn.h"
#include "asix_sb.h"
#include "asix_lb.h"
#include "asix_st.h"
#include "alarm_q.h"
#include "asix_ed.h"
#include "asix_key.h"
#include "asix_kb.h"
#include "asix_tb.h"
//#include "reader.h"


static STATUS PushWindow(void);
static STATUS PopWindow(void);
static STATUS IsMyMessage(ASIX_WINDOW *Head,PMSG pMessage, P_MESSAGE pOldmsg);


/* Timers */ 
static void DoEveryMinute(void *arg);
static void DoEveryHour(void *arg);
static void DoEveryDay(void *arg);


/*check the timer*/
//STATUS AsixTimerCheck(void);

extern STATUS AnswerCall(void);

// revised 11/07 longn_qi
WNDCLASS			WindowClass[] = {
/* 	id,				create,			destroy,		msg_proc,		msg_trans,
	repaint,		move,			enable,			caption,		information,*/				
	
	{WNDCLASS_WIN,	wn_create,		wn_destroy,		wn_msgproc,	wn_msgtrans,
	wn_repaint,		NULL,			NULL,			wn_caption,		NULL},
	
	{WNDCLASS_BUTTON,Btn_create,	Btn_destroy,		Btn_msg_proc,		Btn_msg_trans,
	Btn_repaint,		NULL,			Btn_enable,		Btn_caption,		NULL},
	
	{WNDCLASS_SELECT,sl_create,		sl_destroy,		sl_msg_proc,	sl_msg_trans,
	sl_repaint,		NULL,			sl_enable,		sl_caption,		NULL},
	
	{WNDCLASS_SELECTCARD,NULL,  	NULL,			NULL,			NULL,
	NULL,			NULL,			NULL,			NULL,			NULL},

	{WNDCLASS_MENU,menu_create,	menu_destroy,	menu_msgproc,	menu_msgtrans,
	mn_repaint,		NULL,			NULL,			NULL,			NULL},
	
	{WNDCLASS_LIST,	Lbox_create,	Lbox_destroy,	Lbox_msgproc,	Lbox_msgtrans,
	lb_repaint,		NULL,			NULL,			NULL,			NULL},
	
// modified by dsa 2002/04/17	
//	{WNDCLASS_COMBO,	NULL,		NULL,			NULL,			NULL,
//	NULL,			NULL,			NULL,			NULL,			NULL},
	{WNDCLASS_KEYBD,	kbd_create,	kbd_destroy,	kbd_msgproc,	kbd_msgtrans,
	kbd_repaint,		NULL,			NULL,			NULL,			NULL},	
	
	{WNDCLASS_PROCESS,NULL,			NULL,			NULL,			NULL,
	NULL,			NULL,			NULL,			NULL,			NULL},
	
	{WNDCLASS_SCROLL,sb_create,		sb_destroy,		sb_msgproc,		sb_msgtrans,
	sb_repaint,		NULL,			sb_enable,		NULL,			NULL},
	
	{WNDCLASS_KEYBAR,kb_create,		kb_destroy,		kb_msgproc,	kb_msgtrans,
	NULL,			NULL,			NULL,			NULL,			NULL},
	
	{WNDCLASS_EDITOR,ed_create,		ed_destroy,		ed_msgproc,		ed_msgtrans,
	ed_repaint,		NULL,			ed_enable,		ed_caption,		NULL},
	
//	{WNDCLASS_MUTIEDIT,NULL,		NULL,			NULL,			NULL,
//	NULL,			NULL,			NULL,			NULL,			NULL},
	
	{WNDCLASS_READER,tst_create,	tst_destroy,		tst_msgproc,	tst_msgtrans,
	NULL,			NULL,			NULL,			NULL,			NULL},
		
	{WNDCLASS_STATIC,st_create,		st_destroy,		st_msgproc,		st_msgtrans,
	st_repaint,		NULL,			NULL,			st_caption,		NULL},

	{WNDCLASS_TSKBAR,tb_create,		tb_destroy,		tb_msgproc,		tb_msgtrans,
	tb_repaint,		NULL,			tb_enable,		tb_caption,		NULL},

#ifdef ASIX_DEBUG	
	{WNDCLASS_TEST,tst_create,		tst_destroy,		tst_msgproc,	tst_msgtrans,
	NULL,			NULL,			NULL,			NULL,			NULL}
#endif	
	
};


/////////////////////////////////////////////////////////////////////////////////////////
/* CurWindow is the concetp of PPSM version of ASIX Win, We donot use this gloabl anymore 
 * Instead we use the function GetCurWindow() just like GetGC(). By Lingming 2002/03/09*/
//ASIX_WINDOW			*CurWindow;		//point to current window entry	

/////////////////////////////////////////////////////////////////////////////////////////
//we donot use this gloabl either!, we can now use GetFocus() By Lingming 2002/03/20
//ASIX_WINDOW			*FocusWindow;	//point to the focused window
//////////////////////////////////////////////////////////////////////////////////////////


ASIX_COLOR_THEME	ColorTheme =
{
	GPC_DARKGREY,	//ColorTheme.form_title
	GPC_WHITE, 		//ColorTheme.form_caption
	GPC_LIGHTGREY,	//ColorTheme.form_disabletitle
	GPC_BLACK,		//ColorTheme.form_disablecaption
	GPC_BLACK,		//ColorTheme.form_board
	GPC_WHITE,		//ColorTheme.form_client
	GPC_BLACK,		//ColorTheme.form_text
	GPC_WHITE,		//ColorTheme.form_backcolor
	GPC_BLACK,		//ColorTheme.form_frontcolor
	GPC_LIGHTGREY,	//ColorTheme.form_disablecolor
	GPC_LIGHTGREY,	//ColorTheme.form_disabletext
	GPC_WHITE,		//ColorTheme.form_popclient
	GPC_BLACK,		//ColorTheme.form_poptext 
	GPC_BLACK,		//ColorTheme.form_line
	GPC_LIGHTGREY,	//ColorTheme.menu
	GPC_LIGHTGREY,	//ColorTheme.obj3D
	GPC_BLACK,		//ColorTheme.obj3D_text
	GPC_DARKGREY,	//ColorTheme.obj3D_shadow
	GPC_WHITE,		//ColorTheme.obj3D_highlight
	GPC_BLACK,		//ColorTheme.obj3D_frontcolor
	GPC_WHITE,		//ColorTheme.obj3D_disablecolor
	GPC_WHITE,		//ColorTheme.obj3D_disabletext
	GPC_WHITE,		//ColorTheme.highlight
	GPC_WHITE,		//ColorTheme.light_text
};		//Current System level color theme
									//By Lingming 2001/11/28
									
/* we set the font size as var now , so that we 
 * can update the font size at run time 
 * By Lingming 2001/5/08 */

/* In Iris Phone Project the font size changed
 * By Lingming 2001/11/07	
 */ 
extern U8		CHINESE_CHAR_HEIGHT;
extern U8		CHINESE_CHAR_WIDTH;
extern U8		ENGLISH_CHAR_WIDTH;
extern U8		ENGLISH_CHAR_HEIGHT;


/* The seconds left before we run into doze or sleep */
S16	  	PowerSavingTimeOut;

/* The flag that define whether our own UART irpt driver should be used*/
/* We do have our own irpt handler, but in order to compatibal with old 
 * program the programer can select whether the new irpt handler or the 
 * PPSM's handler should be used. The default selection is PPSM's handler 
 */
U8		AsixOwnUartDriver = FALSE;

//static DWORD 	EveryMinuteTimer;
//static DWORD 	EveryHourTimer;
//static DWORD 	EveryDayTimer;
extern DWORD 	EveryMinuteTimer;
extern DWORD 	EveryHourTimer;
extern DWORD 	EveryDayTimer;


/*the test dynamic code which defined in asixapp.c*/
//extern char dyncode[];
/* Dynamic Function pointer initialization */
//extern void DynFuncPtrInit(void);
////////////////////////////////////////////////////

STATUS ASIXInit(void)
{
	TASKDESCRIPTIONLIST	*ptr;
//	U16	year,month,day,hour,minute,second;
	ASIX_DATE	date;
	ASIX_TIME	time;
	SYSTCB	*curTask;
//	U8	i;		
	
// 11/07 longn_qi		
//	TaskHead = CurTask = NULL;

///////We donot use these two global anymore///////////////////////
//	CurWindow = FocusWindow = NULL;
///////By Lingming 2002/03/30///////////////////////////////////////
/*
////////////////////Color Theme Init///by Lingming 2001/11/28////////////////////////////////
	ColorTheme.form_title = GPC_BLUE;
	ColorTheme.form_caption = GPC_WHITE;
	ColorTheme.form_disabletitle = GPC_LIGHTGREY;	//modified by xh&zl 2002.3.12
	ColorTheme.form_disablecaption = GPC_BLACK;		//modified by xh&zl 2002.3.12
	ColorTheme.form_board = GPC_BLACK;
	ColorTheme.form_client = 0xFAFAD2;
	ColorTheme.form_text = GPC_INDIGO;
	ColorTheme.form_backcolor = GPC_WHITE;			//modified by xh&zl 2002.3.12
	ColorTheme.form_frontcolor = GPC_BLACK;			//modified by xh&zl 2002.3.12
	ColorTheme.form_disablecolor = GPC_DARKGREY;	//modified by xh&zl 2002.3.12
	ColorTheme.form_disabletext = GPC_DARKGREY;
	ColorTheme.form_popclient = 0xFAFAD2;
	ColorTheme.form_poptext = GPC_BLACK;
	ColorTheme.form_line = GPC_BLACK;				//modified by xh&zl 2002.3.12
	ColorTheme.menu = GPC_WHITE;//GPC_BURLYWOOD;
	ColorTheme.obj3D = GPC_LIGHTGREY;
	ColorTheme.obj3D_text = GPC_BLACK;
	ColorTheme.obj3D_shadow  = GPC_DARKGREY;		//modified by xh&zl 2002.3.12
	ColorTheme.obj3D_highlight = GPC_WHITE;			//modified by xh&zl 2002.3.12
	ColorTheme.highlight = GPC_ALICEBLUE;
	ColorTheme.light_text = GPC_WHITE;
//////////////////////////////////////////////////////////////////////////////////////////////		
*/
	/* time count before run into sleep*/
	/* this init value will read from system config data struct */
	PowerSavingTimeOut = 30;
	
////	asixprintf("\nAsixwin Init begins\n");
////	asixprintf("       Create and start Minute&Hour&Day timers\n");
	
	/* System start up time*/
	ReadDateTime( &date, &time );
	//AsixStartTime = CountDays(year,month,day)*86400 + hour*3600 + minute*60 + second;
		
	/* every minute timer*/
//	SysCreateTimer(&EveryMinuteTimer, 60*1000, DoEveryMinute, NULL, CYC_MODE|AUTO_START_MODE);
	SysCreateTimer(&EveryMinuteTimer, 60*1000, DoEveryMinute, NULL, CYC_MODE|AUTO_START_MODE);
	
	/* every hour timer*/
	SysCreateTimer(&EveryHourTimer, 3600*1000, DoEveryHour, NULL, CYC_MODE|AUTO_START_MODE);
	
	/* every day timer */
	SysCreateTimer(&EveryDayTimer, ((23-time.hour)*3600 + (59-time.minute)*60 +(59-time.second)+1)*1000,\
					DoEveryDay, NULL, CYC_MODE|AUTO_START_MODE);
	
	
	SysStartTimer(EveryMinuteTimer);
	SysStartTimer(EveryHourTimer);
	SysStartTimer(EveryDayTimer);
	
////	asixprintf("       Clear SysMenu_Item&SysMenu_Taskptr\n");
// 11/07 longn_qi	
	memset(SysMenu_Item, 0x0, MAX_SYSMENU*sizeof(struct MENU_ITEM));/*init the sys menu item*/
	memset(SysMenu_Taskptr, 0x0, MAX_SYSMENU*sizeof(SYSTCB *));/*init the sys menu task ptr array*/  
	
	
	
	
	/* UART initialization */
	//UartInit();
	
	////////////////////////////////////////////////////////////////////////////////////////
	/* The following is task init and shell task start and 
	 * we will bypass this code during porting LM 2001/11/07
	 */
	
	
//	for (i=0; TaskTemplate[i].name!=NULL; i++) {
//		TaskRegist(&TaskTemplate[i]);	
//	}
	
	
	ptr = TaskDescription;	//pessia
//	ptr = &gTskDspTbl[SHELL_ID-1];
	/* Start the shell and deamon task */
	/* the first entry of the Description table must be shell entry*/
	//if ( ptr->mode == ASIX_SHELL && ptr->entry!=NULL )
	{
////		asixprintf("Asixwin create Shell task\n");
		curTask = ASIXCreateTask(ptr->desp);
	}

	
	/* the second entry of the Description table must be SysDeamon */
	//if ( ptr->mode == ASIX_DEAMON && ptr->func != NULL )
	//	SysDeamonTask = ASIXCreateTask(ptr);
	
	//ptr = ptr->next;
	
	/* the third entry of the Description table must be SysSleep */
	//if ( ptr->mode == ASIX_DEAMON && ptr->func != NULL )
	//	SysSleepTask = ASIXCreateTask(ptr);
	
//	asixoutput("Asixwin start current task(%s)\n",asixtskname(GetCurTask()->id));
	TaskStart(curTask->id);
	
	return ASIX_OK;	/*we will never reach here, To saticfiy the lint*/
}


U32 CreateWindow(U8 ClassName, char *Caption, U32 Style, 
				 U16 x, U16 y, U16 Width, U16 Height,
				 U32 Parent, U32 hMenu, void *exdata)
{
	
	void		 	*ctrl_str = NULL;
	ASIX_WINDOW		*parent_win, *winptr; //*kbwndptr;
	ASIX_WINDOW		*winlist;
	ASIX_WINDOW		*curwin; //The equalvalent local var of CurWindow. Lingming 2002/03/09
	SYSTCB			*curtask;//The equalvalent local var of CurTask.				
	U32				old_curwindow = 0;
	//U16				padx=0,pady=0;
	U16				cursor;
	

	curwin =(ASIX_WINDOW *)GetCurWindow();
	curtask = GetCurTask();

	// Only in the Current window can we create the sub win
	// if task_id is 0, it maybe the recurse entry, so we donot check. 
	if (Parent!=0 && ((ASIX_WINDOW *)Parent)->task_id != 0 )
		if ( IsMyWindow(Parent, (U32)curwin)!= ASIX_OK) 
			return (U32)NULL;
	
	parent_win = (ASIX_WINDOW *)Parent;
	
	if ( ClassName >= WNDCLASS_MAX ) return (U32)NULL;
	
	asixoutput( "### Create %s ###", WinClassName[ClassName] );
	// allocate the window structure
	if ( (winptr = (ASIX_WINDOW *)SysLcalloc( sizeof(ASIX_WINDOW) ))==NULL )
	{
		asixoutput( "### Create %s Error ###", WinClassName[ClassName] );
		return (U32)NULL;
	}
	
	if ( parent_win == NULL ) {
		// the top layer link of windows must be WNDCLASS_WIN
		//if ( ClassName != WNDCLASS_WIN ) {//pessia: test
		if ( ClassName != WNDCLASS_WIN && ClassName != WNDCLASS_TEST ) {
			SysLfree(winptr);
			asixoutput( "### Create %s Error ###", WinClassName[ClassName] );
			return (U32)NULL;
		}
		if ( curwin !=NULL )
		{
			/* only the current window can own the input pad */
			if (curwin->status & WST_HANDWRITE){
				//Now we will not using handwriting LM 2001/11/07
				//PenIrptDisable();
				//CloseInputPad(); /* Close it temperaly, when we come back, we will reopen it*/
				//PenIrptEnable();
			
			}
			//we still have not cursor LM 2001/11/07
			// longn_qi 2001/12/14 now we have cursor
			CursorGetStatus(&cursor);
			if (cursor == PPSM_CURSOR_ON)
				curwin->status |= WST_CURSOR_ON;
			else if (cursor == PPSM_CURSOR_REVERSED)
				curwin->status |= WST_CURSOR_REVERSED;
			CursorSetStatus(PPSM_CURSOR_OFF);
			
			PushWindow();

			old_curwindow = (U32)curwin;
			curwin = winptr;
			
		}	
			
	} else {
		// the sub win's class can not be WNDCLASS_WIN
		// the sub win must has the WS_CHILD style
		if ( ClassName == WNDCLASS_WIN || !(Style & WS_CHILD) ){
			SysLfree(winptr);	
			asixoutput( "### Create %s Error ###", WinClassName[ClassName] );
			return (U32)NULL;
		}	
	}	
	
	winptr->wndclass = &WindowClass[ClassName];
	winptr->wnd_id = (U32)winptr;
	winptr->parent_id = Parent;
	winptr->x = x;
	winptr->y = y;
	winptr->width = Width;
	winptr->hight = Height;
	winptr->caption = Caption;
	winptr->tag = NULL;// we should consider this
	winptr->style = Style;
	winptr->hmenu = hMenu;
	winptr->exdata = exdata;
	
	if ( (*WindowClass[ClassName].create)(Caption, Style, x, y, Width,
	 Height, (U32)winptr, hMenu,(void **)&ctrl_str, exdata) != ASIX_OK )
	{
		if ( parent_win == NULL ){		/* Only WNDCLASS_WIN creation failure should restore*/
			curwin = (ASIX_WINDOW *)old_curwindow;	/* we will restore the old CurWindow and pop it */
			
			if (curwin != NULL)
				PopWindow();
			else { 	//The creation of first window of this task failed
					//we have no choice but exit this task. By Lingming 2001/11/23
				Lfree(winptr);
				EndofTask();
				asixoutput( "### Create %s Error ###", WinClassName[ClassName] );
				return (U32)NULL; //we will never get to here!!!		
			}
			
			if (curwin->status & WST_HANDWRITE) {
				/* reopen the closed inputpad, this operation cross the layer, but 
				for special control we have to do this*/
				//Now we will not using handwriting LM 2001/11/07
				//for (kbwndptr = CurWindow->child; kbwndptr!= NULL && kbwndptr->wndclass->wndclass_id!=WNDCLASS_KEYBD;
				//	kbwndptr = kbwndptr->next);				
				//if ( kbwndptr != NULL ){
				//	padx = ((struct kb_ctrl *)(kbwndptr->ctrl_str))->inputpad_x;
				//	pady = ((struct kb_ctrl *)(kbwndptr->ctrl_str))->inputpad_y;
					//PenIrptDisable();
				//	AdvOpenInputPad(padx,pady,1,2,65,75,BLACK,2,800,50,1,2048);
					//PenIrptEnable();
				//}	
			}
			
			//we still have not cursor LM 2001/11/07
			// longn_qi 2001/12/17 now we have
			if (curwin->status & WST_CURSOR_ON )
				CursorSetStatus(PPSM_CURSOR_ON);
			else if (curwin->status & WST_CURSOR_REVERSED)
				CursorSetStatus(PPSM_CURSOR_REVERSED);	
						
		}	
		
		SysLfree(winptr);
		asixoutput( "### Create %s Error ###", WinClassName[ClassName] );
		return (U32)NULL;
	}

⌨️ 快捷键说明

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