eumandy/eugtk/examples/test106.ex

54 lines
1.5 KiB
Elixir
Raw Normal View History

2016-11-25 00:33:18 -07:00
--# Passing Euphoria routines attached to buttons
include GtkEngine.e
constant docs = `<b><u>Passing Euphoria Routines</u></b>
Here, we send upper(), lower(), and proper()
Euphoria routine-ids to our user-written routine,
depending upon which button is pushed.`
constant win = create(GtkWindow,"size=300x100,position=1,border_width=10,$destroy=Quit")
constant panel = create(GtkBox,"orientation=VERTICAL")
add(win,panel)
constant txt = "Now iS tHe timE for alL goOd mEn \nto coMe TO the aID of the pARty"
constant lbl1 = create(GtkLabel)
set(lbl1,"markup",docs)
add(panel,lbl1)
constant sep = create(GtkSeparator,"margin_top=10,margin_bottom=10")
add(panel,sep)
constant lbl2 = create(GtkLabel)
set(lbl2,"markup",txt)
add(panel,lbl2)
constant btnbox = create(GtkButtonBox,"margin_top=10")
pack(panel,-btnbox)
integer x = _("X")
constant btn1 = create(GtkButton,"Proper",x,routine_id("text:proper"))
constant btn2 = create(GtkButton,"Lower",x,routine_id("text:lower"))
constant btn3 = create(GtkButton,"Upper",x,routine_id("text:upper"))
constant btn4 = create(GtkButton,"gtk-revert-to-saved",x,0)
add(btnbox,{btn1,btn2,btn3,btn4})
show_all(win)
main()
------------------------------------------------------------------------
function X(atom ctl, atom fn)
------------------------------------------------------------------------
if fn = 0 then
set(lbl2,"markup",txt)
else
set(lbl2,"markup",call_func(fn,{txt}))
end if
return 1
end function