
-----------------------------------------------------------------------------
--# GtkExpander
-----------------------------------------------------------------------------

include GtkEngine.e


constant gpl1 = `This library is free software; you can redistribute it 
and/or modify it under the terms of the GNU Lesser General 
Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later 
version.
`
constant gpl2 = `This library is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
See the GNU Lesser General Public License for more details.
`
constant gpl3 = `You should have received a copy of the GNU Lesser General Public 
License along with this library; if not, write to the Free Software 
Foundation, Inc., 59 Temple Pl, Suite 330, Boston, MA  02111-1307 USA
` 

constant gpl = {gpl1,gpl2,gpl3}

constant docs = "<b><u>LGPL ~ GNU Lesser General Public License version 3.0</u></b>\n"

constant win = create(GtkWindow,"size=570x100,border=10,position=1,$destroy=Quit")

constant panel = create(GtkBox,"orientation=VERTICAL")
    add(win,panel)

constant lbl = create(GtkLabel)
    set(lbl,"markup",docs)
    pack(panel,lbl)

object exp = repeat(0,3)
object lgpl = repeat(0,3)

for i = 1 to 3 do

    exp[i] = create(GtkExpander,{
        {"use markup",TRUE},
	{"label",sprintf("<b>LGPL Paragraph %d</b>",i)},
        {"tooltip text",sprintf("Click to expand paragraph %d",i)}})
        
    lgpl[i] = create(GtkLabel,{
        {"markup",gpl[i]},
        {"line wrap",FALSE},
        {"width chars",40},
        {"justify",GTK_JUSTIFY_LEFT},
        {"padding",1}})
        
    set(exp[i],"label fill",FALSE)
    add(exp[i],lgpl[i])
    set(exp[i],"halign",GTK_ALIGN_START)
    
end for

pack(panel,exp)

constant 
    btn1 = create(GtkButton,"gtk-quit","Quit"),
    btn2 = create(GtkCheckButton,"Expand All","Expand"),
    box = create(GtkButtonBox)
    set(box,"margin top",5)
    
    set(btn2,"tooltip text","Click to expand all paragraphs")
    add(box,{btn1,btn2})
    pack(panel,-box)

show_all(win)
main()

-----------------------------------
global function Expand(atom ctl)
-----------------------------------
for i = 1 to 3 do
    set(exp[i],"expanded",get(ctl,"active"))
    set(win,"restore") 
    -- the above 'restore' call is not a GTK call, it is a EuGTK function
    -- which replaces the deprecated restore_with_initial_size call 
end for
return 1
end function
