RosettaCodeData/Task/User-input-Graphical/Phix/user-input-graphical.phix

41 lines
1.4 KiB
Plaintext

--
-- demo\rosetta\User_Input_Graphical.exw
--
include pGUI.e
Ihandle dlg, label1, input1, label2, input2, OK, Cancel
function ok_cb(Ihandle self)
if self=OK then
string in1 = IupGetAttribute(input1,"VALUE")
integer in2 = IupGetInt(input2,"VALUE")
string msg = sprintf("\"%s\" and %d",{in1,in2})
IupMessage("You entered",msg)
-- (return IUP_CONTINUE if unhappy with input)
end if
return IUP_CLOSE
end function
function esc_close(Ihandle /*ih*/, atom c)
return iff(c=K_ESC?IUP_CLOSE:IUP_CONTINUE)
end function
IupOpen()
label1 = IupLabel("Please enter a string")
input1 = IupText("VALUE=\"a string\", EXPAND=HORIZONTAL")
label2 = IupLabel("and the number 75000")
input2 = IupText("VALUE=75000, EXPAND=HORIZONTAL")
IupSetAttribute(input2,"MASK",IUP_MASK_INT)
OK = IupButton("OK", "ACTION", Icallback("ok_cb"))
Cancel = IupButton("Cancel", "ACTION", Icallback("ok_cb"))
dlg = IupDialog(IupVbox({IupHbox({label1,input1},"ALIGNMENT=ACENTER, PADDING=5"),
IupHbox({label2,input2},"ALIGNMENT=ACENTER, PADDING=5"),
IupHbox({IupFill(),OK,Cancel,IupFill()},"PADDING=15")},
"GAP=5,MARGIN=5x5"))
IupSetAttribute(dlg,"TITLE","User Input/Graphical")
IupSetCallback(dlg, "K_ANY", Icallback("esc_close"))
IupDestroy(IupNormalizer({OK,Cancel},"NORMALIZE=BOTH"))
IupShow(dlg)
IupMainLoop()
IupClose()