RosettaCodeData/Task/Mouse-position/Phix/mouse-position.phix

60 lines
1.9 KiB
Plaintext

-- demo\rosetta\Mouse_position.exw
include pGUI.e
Ihandle global_lbl, canvas_lbl, timer_lbl
function globalmotion_cb(integer x, integer y, atom /*pStatus*/)
IupSetStrAttribute(global_lbl,"TITLE","globalmotion_cb %d, %d",{x,y})
return IUP_DEFAULT
end function
function canvas_motion_cb(Ihandle /*canvas*/, integer x, integer y, atom pStatus)
IupSetStrAttribute(canvas_lbl,"TITLE","canvasmotion_cb %d, %d",{x,y})
return IUP_DEFAULT;
end function
function OnTimer(Ihandle /*ih*/)
integer {x,y} = IupGetIntInt(NULL,"CURSORPOS")
IupSetStrAttribute(timer_lbl,"TITLE","timer %d, %d",{x,y})
return IUP_IGNORE
end function
procedure main()
Ihandle separator1, separator2,
canvas, frame_1, frame_2,
dialog
IupOpen()
global_lbl = IupLabel("Move the mouse anywhere on the window","EXPAND=HORIZONTAL")
separator1 = IupLabel(NULL,"SEPARATOR=HORIZONTAL")
canvas_lbl = IupLabel("Move the mouse anywhere on the canvas","EXPAND=HORIZONTAL")
separator2 = IupLabel(NULL,"SEPARATOR=HORIZONTAL")
timer_lbl = IupLabel("This one runs on a three second timer","EXPAND=HORIZONTAL")
frame_1 = IupFrame(IupVbox({global_lbl,
separator1,
canvas_lbl,
separator2,
timer_lbl}),
"TITLE=IupLabel, SIZE=200x")
canvas = IupCanvas("MOTION_CB", Icallback("canvas_motion_cb"),
"EXPAND=HORIZONTAL, RASTERSIZE=200x200")
frame_2 = IupFrame(canvas, "TITLE=IupCanvas")
dialog = IupDialog(IupHbox({frame_1,frame_2}, "MARGIN=5x5, GAP=5"))
IupSetAttribute(dialog,"TITLE","Mouse motion");
IupSetGlobal("INPUTCALLBACKS", "Yes");
IupSetGlobalFunction("GLOBALMOTION_CB", Icallback("globalmotion_cb"));
Ihandle hTimer = IupTimer(Icallback("OnTimer"), 3000)
IupShow(dialog)
IupMainLoop()
IupClose()
end procedure
main()