56 lines
1.9 KiB
Elixir
Raw Permalink Normal View History

2016-11-25 00:33:18 -07:00
-----------------------------------------------------------------------------------
--# Label justification
-- justifies lines within multi-line labels, not single line labels.
-----------------------------------------------------------------------------------
include GtkEngine.e
constant win = create(GtkWindow,"border=10,size=400x300,position=1,$destroy=Quit")
constant panel = add(win,create(GtkBox,VERTICAL))
constant lbl = add(panel,create(GtkLabel,{{"markup",Twain()}}))
-- you remember Markup Twain, don't you?
constant justify = _("Justify") -- link to local function below;
constant box = pack_end(panel,create(GtkButtonBox))
add(box,
-- all call the same function, passing different justification enums as data.
{create(GtkButton,"gtk-justify-left",justify,GTK_JUSTIFY_LEFT),
create(GtkButton,"gtk-justify-center",justify,GTK_JUSTIFY_CENTER),
create(GtkButton,"gtk-justify-right",justify,GTK_JUSTIFY_RIGHT),
create(GtkButton,"gtk-quit","Quit")})
show_all(win)
main()
------------------------------------------------
function Justify(atom ctl, atom j)
------------------------------------------------
set(lbl,"justify",j)
return 1
end function
------------------------
function Twain() -- a function so quoted text can be at end of program;
------------------------
return remove_all("\n\n",
"""<b>In the space</b> of one hundred and seventy-six years the
Mississippi has shortened itself two hundred and forty-two miles.
<b>Therefore</b> ... in the Old Silurian Period the Mississippi River
was upward of one million three hundred thousand miles long ...
<b>Seven hundred and forty-two years</b> from now the Mississippi
will be only a mile and three-quarters long. ...
<b>There is something fascinating about science.</b>
One gets such wholesome returns of conjecture out of such a
trifling investment of fact.
-- <b><i>Mark Twain</i></b>
""")
end function