
--------------------------------------------------------------------------------
--# GtkSpinButton for getting numeric input 
--------------------------------------------------------------------------------

include GtkEngine.e

constant docs = `<b><u>SpinButton</u></b>
For getting integer or floating-point values
from the user.`

constant win = create(GtkWindow,
    "size=100x100,position=1,border_width=10,$destroy=Quit")
 
constant panel = create(GtkBox,"orientation=VERTICAL,spacing=10")
    add(win,panel)
    
constant lbl = create(GtkLabel,{{"markup",docs}})
    add(panel,lbl)
    
constant spinbtn = create(GtkSpinButton,0,100,0.010)
    set(spinbtn,"margin_left=100,margin_right=100")
    add(panel,spinbtn)
    
constant box = create(GtkButtonBox,{
    {"spacing",10},
    {"layout",GTK_BUTTONBOX_END}})
    pack(panel,-box)
    add(box,{
	create(GtkButton,"gtk-quit","Quit"),
	create(GtkButton,"_Value",_("ShowValue"),0),
	create(GtkButton,"_Adjustment",_("ShowAdj"),0)})
		
show_all(win)
main()

----------------------------------------
function ShowValue()
----------------------------------------
return Info(win,"Spin","Value of spin button",
        sprintf("%2.2f",get(spinbtn,"value")))
end function

-- You can get more details by accessing the spin button's adjustment;
-----------------------------------
function ShowAdj()
-----------------------------------
atom adj = get(spinbtn,"adjustment")
Info(win,"Adjustment",
    format("Value [.2]",get(spinbtn,"value")),
    format("Lower limit: [], Upper limit: []\nAs integer: []\nStep increment: [.2]",
        {get(adj,"lower"),
         get(adj,"upper"),
         get(spinbtn,"value as int"),
         get(adj,"step increment")}))
--etc. see GtkAdjustment
return 1
end function
