demo_listbox.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
---------------------------> Sather 1.1 source file <--------------------------
-- Author: Matthias Ernst <tisi@beutlin.desy.de>
-- Copyright (C) 1995, International Computer Science Institute
-- $Id: demo_listbox.sa,v 1.3 1996/08/30 22:01:36 borisv Exp $
--
-- COPYRIGHT NOTICE: This code is provided WITHOUT ANY WARRANTY
-- and is subject to the terms of the SATHER LIBRARY GENERAL PUBLIC
-- LICENSE contained in the file: Sather/Doc/License of the
-- Sather distribution. The license is also available from ICSI,
-- 1947 Center St., Suite 600, Berkeley CA 94704, USA.
class DEMO_LISTBOX
class DEMO_LISTBOX is
include GUI_UTIL;
attr listbox: TK_LISTBOX;
attr entry: TK_ENTRY;
attr button: TK_BUTTON;
insert_item(i:TK_EVENT_INFO) is
-- insert the entry's content at the end of the list
listbox.insert(listbox.index_end, entry.get_text);
end;
print_list is
-- print the content of the listbox to stdout
-- two different ways should produce the same
#OUT + "===== with get ! =======\n";
loop
#OUT + listbox.get!(once 0, once listbox.index_end) + "\n";
end;
#OUT + "=== with get(index) ====\n";
loop index ::= listbox.size.times!;
#OUT + listbox.get(index) + "\n"
end;
#OUT + "========================\n";
end;
init is
listbox := #(root_window, "listbox",
TK_LISTBOX_CFG::std.selectmode_multiple, TK_PACK::left);
entry := #(root_window, "entry",
TK_ENTRY_CFG::std, TK_PACK::top);
button := #(root_window, "button",
TK_BUTTON_CFG::std.text("Print list"), TK_PACK::top);
button.command := bind(print_list);
entry.bind_event(TK_KEY_EVENT::Press.Return, bind(insert_item(_)));
end;
end;