//-- Show Window void aw_show(AWINDOWP win){ win->threadnum = 0; win->isActived = 1; //-- Find First Focus if (win->controln>0){ int i; for (i=0;i<win->controln;i++){ ACONTROLP ctl = (ACONTROLP) win->controls[i]; if (ctl->onfocus!=NULL){ if (ctl->onfocus(ctl)){ win->focusIndex = i; break; } } } } aw_redraw(win); ag_sync_fade(acfg_var.fadeframes); }
//-- Set Focus byte aw_setfocus(AWINDOWP win,ACONTROLP ctl){ if (!win->isActived) return 0; int i; for (i=0;i<win->controln;i++){ ACONTROLP fctl = (ACONTROLP) win->controls[i]; if (fctl==ctl){ if (fctl->onfocus!=NULL){ if (fctl->onfocus(fctl)){ int pf = win->focusIndex; win->focusIndex = i; if ((pf!=-1)&&(pf!=i)){ ACONTROLP pctl = (ACONTROLP) win->controls[pf]; pctl->onblur(pctl); } aw_draw(win); return 1; } } } } return 0; }
//-- Dispatch Messages dword aw_dispatch(AWINDOWP win){ dword msg; int i; ui_clear_key_queue(); while(1){ //-- Wait For Event ATEV atev; int action =atouch_wait(&atev); //-- Reset Message Value msg = aw_msg(0,0,0,0); //-- Check an Action Value switch (action){ case ATEV_MESSAGE:{ msg = atev.msg; } break; case ATEV_BACK:{ if (!atev.d){ msg = aw_msg(5,0,0,0); } } break; case ATEV_DOWN: case ATEV_RIGHT: if (!atev.d){ if (win->focusIndex!=-1){ ACONTROLP ctl = (ACONTROLP) win->controls[win->focusIndex]; if (ctl->oninput!=NULL){ msg = ctl->oninput((void*)ctl,action,&atev); } if (aw_gl(msg)==0){ for (i=win->focusIndex+1;i<win->controln;i++){ ACONTROLP fctl = (ACONTROLP) win->controls[i]; if (fctl->onfocus!=NULL){ if (fctl->onfocus(fctl)){ win->focusIndex = i; ctl->onblur(ctl); aw_draw(win); break; } } } } } } break; case ATEV_UP: case ATEV_LEFT: if (!atev.d){ if (win->focusIndex!=-1){ ACONTROLP ctl = (ACONTROLP) win->controls[win->focusIndex]; if (ctl->oninput!=NULL){ msg = ctl->oninput((void*)ctl,action,&atev); } if (aw_gl(msg)==0){ for (i=win->focusIndex-1;i>=0;i--){ ACONTROLP fctl = (ACONTROLP) win->controls[i]; if (fctl->onfocus!=NULL){ if (fctl->onfocus(fctl)){ win->focusIndex = i; ctl->onblur(ctl); aw_draw(win); break; } } } } } } break; case ATEV_MENU: case ATEV_SEARCH: case ATEV_HOME: case ATEV_SELECT:{ if (win->focusIndex!=-1){ ACONTROLP ctl = (ACONTROLP) win->controls[win->focusIndex]; if (ctl->oninput!=NULL){ msg = ctl->oninput((void*)ctl,action,&atev); } } } break; case ATEV_MOUSEDN: { if (win->controln>0){ int i; for (i=win->controln-1;i>=0;i--){ ACONTROLP ctl = (ACONTROLP) win->controls[i]; if (aw_touchoncontrol(ctl,atev.x,atev.y)){ if (ctl->oninput!=NULL){ msg = ctl->oninput((void*)ctl,action,&atev); win->touchIndex = i; break; } } } } } break; case ATEV_MOUSEUP:{ if (win->touchIndex!=-1){ ACONTROLP ctl = (ACONTROLP) win->controls[win->touchIndex]; if (ctl->oninput!=NULL) msg = ctl->oninput((void*)ctl,action,&atev); win->touchIndex = -1; } } break; case ATEV_MOUSEMV:{ if (win->touchIndex!=-1){ ACONTROLP ctl = (ACONTROLP) win->controls[win->touchIndex]; if (ctl->oninput!=NULL) msg = ctl->oninput((void*)ctl,action,&atev); } } break; } if (aw_gd(msg)==1) aw_draw(win); if (aw_gm(msg)!=0) return msg; } return msg; }