📄 asixwin.c
字号:
winptr->task_id = curtask->id;
winptr->ctrl_str = ctrl_str;
winptr->status |= WST_NORMAL | WST_EN_FOCUS; //for Destroy audit. By Lingming 2001/11/27
//we should use "|=", because we maybe already set
//the container focus! By Lingming 2002/04/03
if ( parent_win == NULL ) {
////////////////////////OLD VERSION//////////////////////////////////////////////////////
//if (CurTask->wnd_ptr == NULL ){
// CurTask->wnd_ptr = winptr;
// winptr->prev = NULL;
//} else {
/*for (winlist = CurTask->wnd_ptr; winlist->next != NULL; winlist = winlist->next );
winlist->next = winptr;
winptr->prev = winlist;*/
//}
////////////////////////OLD VERSION/////////////////////////////////////////////////////
/*we insert new created win at the head of the list. LM 2001/10/26*/
winlist = curtask->wnd_ptr;
curtask->wnd_ptr = winptr;
winptr->next = winlist;
if (winlist != NULL)
{
winptr->prev = winlist->prev;
winlist->prev = winptr;
}
else
{
winptr->prev = winptr;
}
curwin = winptr;
SetFocus((U32)curwin); //Initaily, we set the container focus
} else {
///////////////////////OLD VERSION////////////////////////////////////////////////////////
//if (parent_win->child == NULL ){
// parent_win->child = winptr;
// winptr->prev = NULL;
//} else {
//for (winlist = parent_win->child; winlist->next != NULL; winlist = winlist->next );
//winlist->next = winptr;
//winptr->prev = winlist;
//}
///////////////////////OLD VERSION///////////////////////////////////////////////////////
/*we insert new created win at the head of the list. LM 2001/10/26*/
winlist = parent_win->child;
parent_win->child = winptr;
winptr->next = winlist;
if (winlist != NULL)
{
winptr->prev = winlist->prev;
winlist->prev = winptr;
}
else
{
winptr->prev = winptr;
}
}
//winptr->prev = NULL;
if ( (!(Style & WS_DISABLED)) && (ClassName != WNDCLASS_STATIC) )
winptr->status |= WST_ENABLE;
asixoutput( "### Create %s OK ###", WinClassName[ClassName] );
return (U32)winptr;
}
STATUS DestroyWindow(U32 Wndid)
{
ASIX_WINDOW *wndptr;
ASIX_WINDOW *curwin;
ASIX_WINDOW *parent;
SYSTCB *curtask;
DWORD pGC;
U32 repaint_id = 0; //the window id we will repaint
MSG msg;
// ASIX_WINDOW *kbwndptr;
// U16 padx=0,pady=0;
#ifdef ASIX_DEBUG
// char dispstr[20];
#endif
curwin = (ASIX_WINDOW *)GetCurWindow();
curtask = GetCurTask();
/* Only Curwindow can destroy itself and its sub wins*/
if ( IsMyWindow(Wndid, (U32)curwin) != ASIX_OK ) return ASIX_ERROR;
wndptr = (ASIX_WINDOW *)Wndid;
/* if we are destroying a control with children, we will
* not repaint it when destroying the children.
* By Lingming 2002/03/20*/
if (wndptr->child != NULL)
wndptr->status |= WST_FORM_REPAINT;
asixoutput( "### Destroy %s ###", WinClassName[wndptr->wndclass->wndclass_id] );
pGC = GetGC();
GroupOn( pGC );
while (wndptr->child!=NULL) {
if (DestroyWindow((U32)wndptr->child) != ASIX_OK ) {
/* if there has error in this node destroying
we just pass it, and destroy the next */
/*
#ifdef ASIX_DEBUG
sprintf(dispstr,"Des%h ERR",(U32)wndptr->child);
//Disp16String(dispstr,1,30);
//TextOut(0, dispstr, 1, 30, HZK_16X16_FONT, BLACK, REPLACE_STYLE);
while(1);
#endif
*/
wndptr->child = wndptr->child->next;
if (wndptr->child != NULL ) wndptr->child->prev = NULL;
}
}
if ( (*wndptr->wndclass->destroy)(wndptr->ctrl_str) != ASIX_OK )
{
GroupOff( pGC, wndptr->x, wndptr->y, wndptr->x + wndptr->width - 1, wndptr->y + wndptr->hight -1 );
asixoutput( "### Destroy %s Error ###", WinClassName[wndptr->wndclass->wndclass_id] );
return ASIX_ERROR;
}
if (wndptr->style & WS_CHILD) /*it is a sub win*/
{
/*
if ( wndptr->prev == NULL && wndptr->next == NULL)
{
( (ASIX_WINDOW *)(wndptr->parent_id) )->child = NULL;
} else if ( wndptr->prev==NULL ) {
( (ASIX_WINDOW *)(wndptr->parent_id) )->child = wndptr->next;
wndptr->next->prev = NULL;
} else if (wndptr->next == NULL) {
wndptr->prev->next = NULL;
} else {
wndptr->prev->next = wndptr->next;
wndptr->next->prev = wndptr->prev;
}
*/
// longn_qi 2002/09/10 added
if( wndptr->next == NULL ) // delete last node
( (ASIX_WINDOW *)(wndptr->parent_id) )->child->prev = wndptr->prev;
else
wndptr->next->prev = wndptr->prev;
if( wndptr->prev->next == NULL ) // delete first node
( (ASIX_WINDOW *)(wndptr->parent_id) )->child = wndptr->next;
else
wndptr->prev->next = wndptr->next;
} else { /* it is the container*/
//if ( wndptr->prev == NULL ) /* It is the only one */
if (wndptr->next == NULL) /*It is the only one*/
{
curtask->wnd_ptr = NULL;
/////////////////////////////////////////////////////////////////////
//curwin = FocusWindow = NULL;
curwin = NULL;//It seems we donot need this either!!
///////////////By Lingming 2002/03/20//////////////////////////////
//Should we call endoftask() here? Lingming 2002/03/20
GroupOff( pGC, wndptr->x, wndptr->y, wndptr->x + wndptr->width - 1, wndptr->y + wndptr->hight -1 );
//we will return now Lingming 2002/03/20
wndptr->status = WST_DESTROYED;//for destroy audit. by Lingming 2001/11/27
Lfree(wndptr);
asixoutput( "### Destroy %s OK ###", WinClassName[wndptr->wndclass->wndclass_id] );
return ASIX_OK;
} else { /* CurWindow must be the first one */
curwin = wndptr->next;
curwin->prev = NULL; //we are the first one now! By Lingming 2002/03/19
curtask->wnd_ptr = curwin;
PopWindow();
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);
}
}
/* 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)
{
pGC = SysGetGC();
// GroupOn( pGC );
RepaintWindow(repaint_id, 0);
//we only need to refresh the covered area
// GroupOff( pGC, wndptr->x, wndptr->y,
// wndptr->x + wndptr->width - 1, wndptr->y + wndptr->hight -1 );
//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);
}
}
GroupOff( pGC, wndptr->x, wndptr->y, wndptr->x + wndptr->width - 1, wndptr->y + wndptr->hight -1 );
wndptr->status = WST_DESTROYED;//for destroy audit. by Lingming 2001/11/27
Lfree(wndptr);
asixoutput( "### Destroy %s OK ###", WinClassName[wndptr->wndclass->wndclass_id] );
return ASIX_OK;
}
/*the power saving mode in ASIXGetMessage*/
//#define GETMSG_NOMAL 0x0000
//#define GETMSG_NO_ALARM 0x0001 /*no alarm pop up*/
//#define GETMSG_NO_DOZE 0x0002 /*no into doze mode*/
//#define GETMSG_NO_SLEEP 0x0004 /*no into sleep mode*/
STATUS ASIXGetMessage(PMSG pMessage, U32 *pWnd_id, U16 mode, U16 Reserved2)
{
U16 message;
PPSM_MESSAGE Oldmsg;
ASIX_WINDOW *curwin = NULL;
ASIX_WINDOW *wndlist = NULL;
STATUS rv = ASIX_NO_MSG;
curwin = (ASIX_WINDOW *)GetCurWindow();
if ( pMessage == NULL ) return ASIX_ERROR;
memset((void *)pMessage, 0x0, sizeof(MSG));
pMessage->messageType = ASIX_MESSAGE;
//message = IrptGetData((P_U32)&areaid, (P_U32 *)&data, (P_U32)&size);
if( SysRecvMessage(pMessage, -1) != SYS_OK ) return ASIX_ERROR;
message = pMessage->message;
//dangerous code below!!!
// if( message != ASIX_PEN && message != ASIX_INPUT_STATUS && message != ASIX_CHINESE
// && message != ASIX_SOFTKEY && message != WM_AT && message < WM_BEGINMSG)
// (U32 *)pMessage->data = (U32 *)&pMessage->wparam;
msgdbgoutput("AsixGetMessage got message : 0x%4x\n", message);
if(message == 0x400)//phone ring
{
//AnswerCall();
}
if(message > WM_BASE ) return ASIX_OK;
/**************************************************************/
/* there is no control need HER message LM 2001/11/07*/
Oldmsg.message = pMessage->message;
Oldmsg.misc = pMessage->lparam;
Oldmsg.data = pMessage->data;
Oldmsg.size = pMessage->wparam;
if (message == ASIX_ICON || message == ASIX_PEN || message == ASIX_INPUT_STATUS )
{
//here we are handling an Activearea Message, we can call the trans function directly
PowerSavingTimeOut = 30; /* User pressed somthing,so we restore the timer*/
// if( message == ASIX_PEN || message == ASIX_INPUT_STATUS )
// Oldmsg.data = pMessage->data;
// else
// Oldmsg.data = &Oldmsg.size;
if( Oldmsg.misc != 0 )
wndlist = (ASIX_WINDOW *)(((ATV *)(Oldmsg.misc))->wndId);
//if wndlist is not NULL and a valid window pointer we call its msg trans function
if( (wndlist != NULL) && (wndlist->status & WST_NORMAL == WST_NORMAL) )
rv = (*wndlist->wndclass->msg_trans)(wndlist->ctrl_str,Oldmsg.message,
Oldmsg.misc, Oldmsg.data, Oldmsg.size, pMessage);
if ( rv == ASIX_OK ) return ASIX_OK; //the default value is ASIX_NO_MSG
} else if (message == ASIX_KEY || message == ASIX_CHINESE || message == ASIX_SOFTKEY)
{
// we will do the recursive searching, which control I belong to?
PowerSavingTimeOut = 30; /* User pressed somthing,so we restore the timer*/
// if( message == ASIX_CHINESE || message == ASIX_SOFTKEY)
// Oldmsg.data = pMessage->data;
// else
// Oldmsg.data = &Oldmsg.size;
if ( curwin == NULL ) return ASIX_ERROR;
if ( IsMyMessage(curwin, pMessage, (P_MESSAGE)&Oldmsg) == ASIX_OK ) return ASIX_OK;
}
/* Alarm will be connsidered later LM 2001/11/07*/
if ( (CurDispAlarm!=NULL) && (AlarmWinOpened==FALSE) )
AlarmWindow();
return ASIX_OK;
}
STATUS DefWindowProc(U16 MsgCmd, U32 lparam, P_U16 data, U16 wparam)
{
ASIX_WINDOW *wndptr;
STATUS rv;
// S32 stack_avail = 0;
#ifdef ASIX_DEBUG
// S32 old_stack;
// U32 old_mem;
#endif
/*Stack check and mem pool check will be bypassed during Porting LM 2001/11/07*/
/*if ( MsgCmd == ASIX_RTC ) {
//AdvSendMessage(SysDeamonTask->id, NULL, SWAP_TASK);
stack_avail = TaskStackAvail();
if ( stack_avail <= ASIX_STACK_ALARM) {
MessageBox(CurWindow->wnd_id,
"The task's stack is coming tight, there mabye something wrong!","Stack Low!",
MB_OK | MB_ICONEXCLAMATION);
}
#ifdef ASIX_DEBUG
TaskMemUsed(CurTask->id, &CurTask->tskmem_used);
if ( CurTask->stk_watermark == 0 ) CurTask->stk_watermark = stack_avail;
old_stack = CurTask->stk_watermark;
old_mem = CurTask->tskmem_watermark;
CurTask->stk_watermark = min(old_stack, stack_avail);
CurTask->tskmem_watermark = max(old_mem, CurTask->tskmem_used);
#endif
} else if ( MsgCmd == WM_WAKEUP && wparam == PS_POWER_LOW) {
//if we come back with power low, we will return to sleep again
MessageBox(CurWindow->wnd_id,"\n 请更换电池!", NULL, MB_FLOAT);
PowerSavingTimeOut = 0;
}*/
msgdbgprintf("### Default Window Proccess ###\n");
if ( MsgCmd < WM_BASE || MsgCmd > WM_USER )
{
if( MsgCmd == SM_SWITCH || ( MsgCmd == SM_TIMER && lparam == EveryMinuteTimer ) )
{
wndptr = (ASIX_WINDOW *)GetTaskBar( GetCurWindow() );
if( wndptr != NULL )
{
rv = (*wndptr->wndclass->msg_proc)( wndptr->wnd_id, MsgCmd, lparam, (void *)data, wparam, NULL);
}
}
msgdbgprintf( "### Default Window Proccess OK ###\n");
return ASIX_OK; /* it is ppsm message or a user defined msg*/
}
/*************************************************************************************/
if ( IsMyWindow(lparam, GetCurWindow() ) != ASIX_OK )
{
msgdbgprintf( "### Skip Default Window Proccess ###\n");
return ASIX_ERROR; /* not for us*/
}
wndptr = (ASIX_WINDOW *)lparam;
rv = (*wndptr->wndclass->msg_proc)( wndptr->wnd_id, MsgCmd, lparam, (void *)data, wparam, NULL);
wndptr = (ASIX_WINDOW *)wndptr->parent_id;
if ( wndptr != NULL )
{
// (*wndptr->wndclass->msg_proc)(MsgCmd, lparam, (void *)data, wparam, NULL);
// (*wndptr->wndclass->msg_proc)(MsgCmd, lparam, (void *)wndptr->ctrl_str, wparam, NULL);
(*wndptr->wndclass->msg_proc)(wndptr->wnd_id, MsgCmd, lparam, (void *)data, wparam, NULL);
}
msgdbgprintf( "### Default Window Proccess OK ###\n");
return ASIX_OK;
}
STATUS SetWindowText(U32 Wndid, P_U8 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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -