>_< " This section mainly gets the position of the mouse and sets the window to be movable. Where the Setup window can be moved with framewin_setmoveable (Hframewin, 1) on the line. While getting the mouse position is the location information transmitted by the State structure of the Wm_touch message (see 56, 572 rows).
1 #defineFACTOR 52 #defineEye_x1 183 #defineEYE_X2 544 #defineEye_y 265 #defineEYE_RX 166 #defineEye_ry 247 #defineMin_visibility/* Make sure at least the many pixels stay visible when moved */8 9 Static int_min (intAintb) {Ten return(A < b)?a:b; One } A //the function of drawing eyes - Static void_draweye (intX0,intY0,intRxintRyintX1,inty1) { - intdx, dy, x, y; the floatHyp; - Gui_setcolor (gui_white); - gui_fillellipse (x0, y0, Rx, ry); - Gui_setcolor (gui_black); + gui_drawellipse (x0, y0, Rx, ry); - /*Calculate the coordinates*/ +DX = x1-x0 +1; ADY = y1-y0 +1; atHYP = sqrt (dx * dx + dy *dy); -x = (DX * _min (RX-5, ABS (DX)) * factor/hyp) + x0 *FACTOR; -y = (dy * _min (ry-5, ABS (DY)) * factor/hyp) + y0 *FACTOR; - /*Draw the pupil*/ - Gui_aa_setfactor (FACTOR); - gui_aa_enablehires (); inGui_setcolor (0xd00000); -Gui_aa_fillcircle (x, Y,5.75*FACTOR); to Gui_setcolor (gui_black); +Gui_aa_fillcircle (x, Y,3.75*FACTOR); - Gui_setcolor (gui_gray); theGui_aa_fillcircle (X-1.25* FACTOR, Y-1.25* FACTOR,1.25*FACTOR); * gui_aa_disablehires (); $ }Panax Notoginseng //window message callback function - Static void_cbtranswindow (wm_message*PMSG) { theWm_hwin Hwin = pmsg->Hwin; + gui_pid_state State; AGui_pid_getstate (&State ); the Switch(pmsg->MsgId) { + CaseWM_PAINT: -State.x-= WM_GETWINDOWORGX (Hwin);//returns the x or Y position of the specified window's origin in desktop coordinates, respectively $STATE.Y-=Wm_getwindoworgy (Hwin); $ _draweye (eye_x1, eye_y, Eye_rx, Eye_ry, state.x, state.y); - _draweye (eye_x2, eye_y, Eye_rx, Eye_ry, state.x, state.y); - Break; the CaseWm_touch: - if(pmsg->data.p) {Wuyigui_pid_state* pState = (gui_pid_state*) pmsg->DATA.P; the if(pstate->Pressed) { - intmx, my, x; Wu I32 Sum, SumY; -I32 outconst = Eye_rx * EYE_RX * eye_ry * eye_ry + (EYE_RX * EYE_RX * eye_ry >>1); AboutMX = pstate->x; $my = (Pstate->y < eye_y)? (eye_y-pstate->y): (Pstate->y-eye_y); - if(My >=0&& my <=Eye_ry) { - inty; -x =Eye_rx; A for(y =0; Y <= my; y++) { +SumY = ((I32) (EYE_RX * eye_rx)) * ((I32) (Y *y)); the while(Sum = SumY + ((I32) (Eye_ry * eye_ry)) * ((I32) (x * x)), (X >0) && (Sum >outconst)) { -x--; $ } the } the}Else { thex =-Eye_rx; the } - if(((MX >= eye_x1-x) && (mx <= eye_x1 + x)) | | in((MX >= eye_x2-x) && (mx <= eye_x2 + x)) | |wm_hascaptured (Hwin)) the { the Wm_setcapturemove (Hwin, PState, min_visibility); About}Else { the /*Transfer the message to the underlying window, since the transparent area has been clicked.*/ theWm_hwin Hbelow =Wm_screen2hwinex (Hwin, state.x, state.y); the if(hbelow) { +Pstate->x = state.x-WM_GETWINDOWORGX (hbelow); -Pstate->y = State.y-Wm_getwindoworgy (hbelow); the wm_sendmessage (Hbelow, PMSG);Bayi } the } the } - } - Break; the default: the Wm_defaultproc (PMSG); the } the } - //Interface Creation Function the Static void_demotranswindow (void) { the Wm_hwin Htranswin, Hframewin; the wm_setcreateflags (Wm_cf_memdev);94 Wm_enablememdev (Wm_hbkwin); the Wm_setdesktopcolor (gui_red); theHtranswin = Wm_createwindow (Ten,Ten, the, the, Wm_cf_show | Wm_cf_hastrans |Wm_cf_stayontop, the&_cbtranswindow,0);98Hframewin = Framewin_create ("Framewin",0, Wm_cf_show, -, -, -, -);//Create a Framewin gadget. (deprecated) AboutFramewin_setactive (Hframewin,1);//sets the state of the frame window. (deprecated) -Framewin_setmoveable (Hframewin,1);//Window moveable Functions101 gui_cursor_show ();102 while(1) {103Wm_invalidatewindow (Htranswin);//Invalidates the window. 104Gui_delay ( -); the }106 }107 //Main function108 voidMaintask_eye (void) {109 gui_init (); the _demotranswindow ();111}
[Ucgui] dialog box 5--mouse position and move window