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

📄 asixwin.c.bak

📁 C 语言进阶
💻 BAK
📖 第 1 页 / 共 2 页
字号:
			curwin->prev = NULL; //we are the first one now! By Lingming 2002/03/19
			curtask->wnd_ptr = curwin;
				
			PopWindow();
			
					
		}
	}

	/* if the destroyed wnd not saved screen with its creation
	 * we will repaint the backgroud(curwin) while only refresh the coved
	 * physical LCD only.
	 * we will also send a Repaint message to notice the user refresh 
	 * their client area.
	 * By Lingming 2002/03/20
	 */
	if ( !(wndptr->style & WS_SAVESCREEN) ) {
		
		if (wndptr->parent_id == 0)
		{
			//Ok, here we will destroy the container, 
			//we will repaint the background
			repaint_id = (U32)curwin; //Now curwin is the back ground win
			
		} else { //we are destroying a child
			
			parent = (ASIX_WINDOW *)wndptr->parent_id;
			//if we destroy the child only we will repaint the back
			//otherwise, it must be a child of a destryed win we only
			//need to repaint its parent
			if ( (parent->status & WST_FORM_REPAINT) == 0) {
				repaint_id = (U32)parent;
			}
		
		}
		
		if (repaint_id != 0)
		{
			
			RepaintWindow(repaint_id, 0); 
		
			//Send Repaint Message
			//msg.messageType = ASIX_MESSAGE;
			//msg.message = WM_REPAINT;
			//msg.lparam = repaint_id;
			//msg.wparam = 0;
			//msg.data = NULL;

			//AdvSendMessage(curtask->id, (P_MESSAGE)(&msg), NO_SWAP_TASK);
			
		}	
	
					
	}

	
	wndptr->status = WST_DESTROYED;//for destroy audit. by Lingming 2001/11/27
	
	printf( "### Destroy %s 0x%x OK ###\n", WinClassName[wndptr->wndclass->wndclass_id], wndptr );
	SysLfree(wndptr);	
	
	//printf( "### Destroy %s OK ###\n", WinClassName[wndptr->wndclass->wndclass_id] );
	return ASIX_OK;
	
}


STATUS SetWindowText(U32 Wndid, char *Caption, void *exdata)
{
	register ASIX_WINDOW	*wndptr;
	STATUS 					rv = ASIX_OK;
	
	//if ( Caption == NULL && exdata == NULL ) return ASIX_ERROR;
	
	if ( IsMyWindow(Wndid, GetCurWindow() ) != ASIX_OK ) return ASIX_ERROR; 
	
	wndptr = (ASIX_WINDOW *)Wndid;
	
	if (wndptr->wndclass->caption == NULL) return ASIX_OK;
	
	if ( (rv = (*wndptr->wndclass->caption)(wndptr->ctrl_str, Caption, exdata)) == ASIX_OK)
	{
		wndptr->caption = Caption;
		wndptr->exdata  = exdata;
	}	
	
	return rv;
}


STATUS EnableWindow(U32 Wndid, U8 Enable)
{	
	register ASIX_WINDOW	*wndptr;
	STATUS 					rv = ASIX_OK;
	
	if ( IsMyWindow(Wndid, GetCurWindow() ) != ASIX_OK ) return ASIX_ERROR; 
	
	wndptr = (ASIX_WINDOW *)Wndid;
	if (wndptr->wndclass->enable == NULL) return ASIX_OK;
	
	if ( (rv = (*wndptr->wndclass->enable)(wndptr->ctrl_str, Enable)) == ASIX_OK)
	{
		if (Enable) 
			wndptr->status |= WST_ENABLE;
		else
			wndptr->status &= ~WST_ENABLE;	
	}	
	
	return rv;
	
}


U32 SetFocus(U32 Wndid)
{
	U32				oldfocus;
	ASIX_WINDOW 	*oldptr, *newptr;
	//MSG			msg;
	U32  			curwin;
	SYSTCB		 	*curtask;	

	newptr = (ASIX_WINDOW *)Wndid;
	if( newptr == NULL || ( newptr->status & WST_NORMAL ) != WST_NORMAL )
		return 0;

	if( !( newptr->status & WST_EN_FOCUS ) )
		return 0;

	curwin = GetCurWindow();
	curtask = GetCurTask();
	
	if( IsMyWindow(Wndid, curwin) != ASIX_OK ) return 0;
	
	oldfocus = GetFocus(); //(U32)FocusWindow;we will discard the global var By Lingming 2002/03/20
	oldptr = (ASIX_WINDOW *)oldfocus;
	if( oldptr == newptr )
		return oldfocus;
	
	//we need use msg to tell the related controls the focus changed! 
	//By Lingming 2001/11/28	
	//memset( (void *)&msg, 0x0, sizeof(MSG) );
	//msg.messageType = ASIX_MESSAGE;
	//msg.wparam =0;			
	
	
	if ( (oldptr != NULL) && (IsMyWindow(oldfocus, curwin) == ASIX_OK) )
	{
		oldptr->status &= ~WST_FOCUS;
		//msg.message = WM_LOOSEFOCUS;//The old guy lost the focus, and tell it.By Lingming 2001/11/28
		//msg.lparam = (U32)oldptr;
		//msg.data = oldptr->ctrl_str;		
		//AdvSendMessage(curtask->id, (P_MESSAGE)&msg, NO_SWAP_TASK);
	}
		
	newptr->status |= WST_FOCUS;
	//msg.message = WM_GETFOCUS;//we got the focus, tell the control.By Lingming 2001/11/28
	//msg.lparam = (U32)newptr;
	//msg.data = newptr->ctrl_str;		

	//AdvSendMessage(curtask->id, (P_MESSAGE)&msg, NO_SWAP_TASK);
	
	//FocusWindow = newptr;//we will discard the global var By Lingming 2002/03/20
	
	return oldfocus;
}

U32 GetFocus(void)
{
	
	ASIX_WINDOW  	*curwin;
	
	curwin = (ASIX_WINDOW *)GetCurWindow();
//	curwin = gSysTcbTbl[gLcdOwnerTskId-1].wnd_ptr;
	return (U32)FocusLookUp(curwin);
}

STATUS EnableFocus( U32 wndid, U8 state )
{
	ASIX_WINDOW  	*wnd = (ASIX_WINDOW *)wndid;
	
	if( wnd == NULL && ( wnd->status & WST_NORMAL ) != WST_NORMAL )
		return ASIX_ERROR;

	if( state )
		wnd->status |= WST_EN_FOCUS;	// enable focus
	else
		wnd->status &= ~WST_EN_FOCUS;	// disable focus
	
	return ASIX_OK;
}

ASIX_WINDOW *FocusLookUp(ASIX_WINDOW *wndhead)
{
	ASIX_WINDOW *wndptr, *rv = NULL;
	
	wndptr = wndhead;
	
	if ( wndptr == NULL ) return NULL;
	
	if ( wndptr->status & WST_FOCUS ) return wndptr;
	
	if (wndptr->child==NULL)
		wndptr = wndptr->next;	//what if this is a empty form? the next
								//one would be the back_end form!!
	else 
		wndptr = wndptr->child;
	
	while(1)
	{
		if(wndptr == NULL) {
			rv = wndptr;
			break;
		}	
		
		if(wndptr->child==NULL)
		{
			if ( wndptr->status & WST_FOCUS) {
				rv = wndptr;
				break;
			}else{ 
				wndptr = wndptr->next;
				continue;
			}	
		}
		
		if( (rv = FocusLookUp(wndptr)) != NULL) 
			break;
		else 
			wndptr = wndptr->next;
	}
	
	
	return rv;	

}

/* CreateWindow calls this func*/
static STATUS PushWindow(void)
{
	/*we need to do this in the back end*/
	/*Test, modified by Lingming 2002/03/07*/
	/*ASIX_WINDOW *wndptr;
    ID			id;

	get_tid( &id );
	wndptr = ( ASIX_WINDOW *)gSysTcbTbl[id-1].wnd_ptr;
	*/
	/*------------------------------------*/

	ASIX_WINDOW *curwin;

	curwin = (ASIX_WINDOW *)GetCurWindow();
	
	if (curwin !=NULL && (!(curwin->status & WST_PUSHED)) )
	{
		//ActiveListPush();
		curwin->status |= WST_PUSHED;
	} else 
		return ASIX_ERROR;
		
	return ASIX_OK;
	
}

/* Destroy Window calls this func*/
static STATUS PopWindow(void)
{
	/*we need to do this in the back end*/
	/*Test, modified by Lingming 2002/03/07*/
	/*ASIX_WINDOW *wndptr;
    ID			id;

	get_tid( &id );
	wndptr = ( ASIX_WINDOW *)gSysTcbTbl[id-1].wnd_ptr;
	*/
	ASIX_WINDOW *curwin;

	curwin = (ASIX_WINDOW *)GetCurWindow();

	
	if (curwin->status & WST_PUSHED)
		//ActiveListPop();
		;
	else 
		return ASIX_ERROR;
			
	curwin->status &= (~WST_PUSHED);
	return ASIX_OK;
}	
	
STATUS RepaintWindow(U32 Wndid, U32 lparam)
{
	register ASIX_WINDOW	*wndptr, *childlist;
	STATUS 					rv = ASIX_OK;
	U32		hGC;
	
	
	if ( IsMyWindow(Wndid, GetCurWindow() ) != ASIX_OK ) return ASIX_ERROR; 
	
	wndptr = (ASIX_WINDOW *)Wndid;
	
	if (wndptr->wndclass->repaint == NULL) return ASIX_OK;

	//hGC = GetGC();
	//GroupOn( hGC );

	rv = (*wndptr->wndclass->repaint)(wndptr->ctrl_str, lparam);
	
	if( wndptr->child == NULL )
	{	
		//GroupOff( hGC, wndptr->x, wndptr->y, wndptr->x + wndptr->width -1, wndptr->y + wndptr->hight -1 );
		return rv;
	}

	childlist = wndptr->child->prev;
	do{
		rv = RepaintWindow((U32)childlist, lparam);
		childlist = childlist->prev;
		
	}while( childlist->next != NULL );
	
	//GroupOff( hGC, wndptr->x, wndptr->y, wndptr->x + wndptr->width -1, wndptr->y + wndptr->hight -1 );

	return rv;
}	

// longn_qi	2002/09/09 added
STATUS PopUpWindow( U32 Wndid, U32 reserved )
{
	/*
	ID	tskid;
	ASIX_WINDOW	*wndptr;

	wndptr = (ASIX_WINDOW *)Wndid;

	if( wndptr == NULL || wndptr->wndclass == NULL )
		return ASIX_ERROR;
	
	if( wndptr->wndclass->wndclass_id != WNDCLASS_WIN )
		return ASIX_ERROR;

	get_tid( &tskid );

	if( tskid == gLcdOwnerTskId )
		return ASIX_OK;
	else
	{
		U16	xdes = wndptr->x + wndptr->width -1, ydes = wndptr->y + wndptr->hight -1;
		SYSTCB	*pHead;
		
		pHead = TaskHead;
		while( pHead != NULL && pHead->next != &gSysTcbTbl[tskid-1] )
			pHead = pHead->next;
		if( pHead != NULL )
		{
			pHead->next = gSysTcbTbl[tskid-1].next;
		}
		if( TaskHead != &gSysTcbTbl[tskid-1])
		{
			gSysTcbTbl[tskid-1].next = TaskHead;
			TaskHead = &gSysTcbTbl[tskid-1];
		}

		gLcdOwnerTskId = tskid;
		Write2LCD( wndptr->x, wndptr->y, xdes, ydes, gSysTcbTbl[tskid-1].gc->vram );
		{
			//MSG	switchmsg;
			
			//switchmsg.message = SM_SWITCH;
			//switchmsg.wparam = SWAP_TO_FOREGROUND;
			//switchmsg.lparam = gLcdOwnerTskId;
			//SysSendMessage( gLcdOwnerTskId, &switchmsg );
		}
	}
*/
	return ASIX_OK;
}

STATUS  IsMyWindow(U32 Wndid, U32 Head)
{
	// this function is to test whether the Wndid is belongs to the Head
	// here we assume this function always returns ASIX_OK
	return ASIX_OK;			
	
}	

STATUS GetWindowStatus(U32 Wndid, P_U32 Status)
{
	
	ASIX_WINDOW		*wndptr;
	
	if ( Wndid == 0 ) return ASIX_ERROR;
	if ( IsMyWindow(Wndid, GetCurWindow() ) != ASIX_OK ) return ASIX_ERROR; 
	
	wndptr = (ASIX_WINDOW *)Wndid;	
	
	*Status = wndptr->status;
	
	return ASIX_OK;	
	
	
}

/*This function returns the toppest window of the current running task*/
U32 GetCurWindow( void )
{
     
    return (U32)CurWindow;
	
}

SYSTCB *GetCurTask( void )
{

	return (SYSTCB *)&CurTask;
}



void DoEveryMinute(void *arg)
{
/*	
	SYSTCB	*pHead;
	MSG		msg;

	msg.messageType = ASIX_MESSAGE;
	msg.message = WM_TIMER;
	msg.lparam = EveryMinuteTimer;
	msg.wparam = 0;
	msg.data = NULL;

	pHead = TaskHead;
//	while( pHead != NULL )
	{
		SysSendMessage( pHead->description->taskid, &msg );
//		pHead = pHead->next;
	}
*/
	return;
}

void DoEveryHour(void *arg)
{
}

void DoEveryDay(void *arg)
{
}


	
//#ifdef ASIX_DEBUG


/*WNDCLASS_TEST,	tst_create,		tst_destroy,	tst_msgproc,	tst_msgtrans,
  NULL,				NULL,			NULL,			NULL,			NULL,	*/

STATUS tst_create(char *caption, U32 style, U16 x, U16 y, U16 width, U16 hight,
				 U32 parent, U32 menu, void **ctrl_str, void *exdata)
{
	return ASIX_OK;
}
				 
STATUS tst_destroy(void *ctrl_str)
{
	return ASIX_OK;
}

STATUS tst_msgproc( U32 win_id, U16 asix_msg, U32 lparam, void *data, U16 wparam, void *reserved)
{
	return ASIX_OK;
}

STATUS tst_msgtrans(void *ctrl_str, U16 msg_type, U32 areaId, P_U16 data, U32 size, void *trans_msg)
{
	return ASIX_NO_MSG;
}

//#endif 


	
	

	

⌨️ 快捷键说明

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