/* ***************************************************************************
# Compiled by:
#
src/lib/tk/src/tk.sublib tk Export API. ``All you ever wanted to know about tk''
Part II: Functions
$Date: 2001/03/30 13:39:11 $
$Revision: 3.0 $
Author: bu/cxl (Last modification by $Author: 2cxl $)
(C) 1996, Bremen Institute for Safe Systems, Universitaet Bremen
************************************************************************** */
api Tk {
include api Tk_Types; # Tk_Types is from
src/lib/tk/src/tk_types.pkg # 1. Identifiers
make_window_id: Void -> Window_Id;
make_image_id: Void -> Image_Id;
make_widget_id: Void -> Widget_Id;
make_canvas_item_id: Void -> Canvas_Item_Id;
make_canvas_item_frame_id: Void -> Widget_Id;
make_text_item_id: Void -> Text_Item_Id;
# to generate more meaningful names
make_tagged_window_id: String -> Window_Id;
make_tagged_image_id: String -> Image_Id;
make_tagged_canvas_item_id: String -> Canvas_Item_Id;
make_tagged_widget_id: String -> Widget_Id;
make_title: String -> Title;
make_simple_callback: (Void -> Void) -> Void_Callback;
null_callback: Void_Callback;
make_callback: (Tk_Event -> Void) -> Callback;
make_widget: String -> Widget_Id;
# reconvert to string - needed by file to handle output
make_window_string: Window_Id -> String;
make_widget_string: Widget_Id -> String;
make_canvas_item_string: Canvas_Item_Id -> String;
make_text_item_id_string: Text_Item_Id -> String;
# Conversion between different id's
widget_id_to_canvas_item_id: Widget_Id -> Canvas_Item_Id;
canvas_item_id_to_widget_id: Canvas_Item_Id -> Widget_Id;
# to generate dependent identifiers
make_sub_window_id: (Window_Id, String) -> Window_Id;
make_sub_widget_id: (Widget_Id, String) -> Widget_Id;
make_sub_canvas_item_id: (Canvas_Item_Id, String) -> Canvas_Item_Id;
# 2. Control
start_tcl: List( Window ) -> Void;
start_tcl_and_trap_tcl_exceptions: List( Window ) -> String;
# Same as closing the main window with close_window
exit_tcl: Void -> Void;
reset: Void -> Void;
set_font_base_size: Int -> Void;
# 3. Windows
make_window: { window_id: Window_Id,
traits: List( Window_Trait ),
subwidgets: Widgets,
event_callbacks: List( Event_Callback ),
init: Void_Callback } -> Window;
get_window: Window_Id -> Window;
get_all_windows: Void -> List( Window );
open_window: Window -> Void;
close_window: Window_Id -> Void;
change_title: Window_Id -> Title -> Void;
is_open: Window_Id -> Bool;
# 4. Widgets
# 4.1 General Operations
widget_exists: Widget_Id -> Bool;
get_widget: Widget_Id -> Widget;
# -- the second argument is the FRAME into which the widget is inserted
add_widget: Window_Id -> Widget_Id -> Widget -> Void;
delete_widget: Widget_Id -> Void;
add_event_callbacks: Widget_Id -> List( Event_Callback ) -> Void;
add_trait: Widget_Id -> List( Trait ) -> Void;
set_event_callbacks: Widget_Id -> List( Event_Callback ) -> Void;
set_traits: Widget_Id -> List( Trait ) -> Void;
get_text_wid_widgets: Widget -> List( Widget );
get_canvas_widgets: Widget -> List( Widget );
# 4.2. Trait, Event_Callback, ... for Widgets
# Are all derived from selectWidget
get_traits: Widget_Id -> List( Trait );
get_relief_kind: Widget_Id -> Relief_Kind;
get_callback: Widget_Id -> Void_Callback;
get_event_callbacks: Widget_Id -> List( Event_Callback );
get_width: Widget_Id -> Int;
get_height: Widget_Id -> Int;
get_menu_callback: Widget_Id -> List( Int ) -> Void_Callback;
# 4.3 Operations for Widget containing text (TEXT_WIDGET, LIST_BOX, TEXT_ENTRY)
# 4.3.2 Manipulation of Text
# Low-level access: no annotation, fails for read-only text widgets.
# On the other hand, works for List boxes etc. as well, but for
# text widgets, better use ..annoText below
insert_text: Widget_Id -> String -> Mark -> Void;
insert_text_end: Widget_Id -> String -> Void;
clear_text: Widget_Id -> Void;
delete_text: Widget_Id -> (Mark, Mark) -> Void;
# Not for TEXT_ENTRY
get_tcl_selected_text: Widget_Id -> (Mark, Mark) -> String;
get_tcl_text: Widget_Id -> String;
get_tcl_text_widget_read_only_flag: Widget_Id -> Bool;
set_tcl_text_widget_read_only_flag: Widget_Id -> Bool -> Void;
# Recommended functions to manipulate text widgets. Handles
# read-only text widgets correctly
clear_livetext: Widget_Id -> Void;
replace_livetext: Widget_Id -> Live_Text -> Void;
delete_marked_livetext: Widget_Id -> (Mark, Mark) -> Void;
insert_livetext_at_mark: Widget_Id -> Live_Text -> Mark -> Void;
append_livetext: Widget_Id -> Live_Text -> Void; # use discouraged--
# very inefficient!
# 4.3.3 Selection of postions and ranges
get_tcl_cursor: Widget_Id -> Mark;
get_tcl_selection_range: Widget_Id -> List( (Mark, Mark) );
# 4.4 Annotated texts"
string_to_livetext: String -> Live_Text;
empty_livetext: Live_Text;
# infix 70 ++
+++ : (Live_Text, Live_Text) -> Live_Text;
append_newline_to_livetext: Live_Text -> Live_Text;
join_livetext: String -> List( Live_Text ) -> Live_Text;
# 4.5 text_item
get_text_item: Widget_Id -> Text_Item_Id -> Text_Item;
add_text_item: Widget_Id -> Text_Item -> Void;
delete_text_item: Widget_Id -> Text_Item_Id -> Void;
# These are casualties of an accidental (re)naming collision. Should pick new names and restore them:
# my get_text_item_event_callbacks: Widget_ID -> Text_Item_ID -> List( Event_Callback ) # was getAnnotationBind
# my get_text_item_traits: Widget_ID -> Text_Item_ID -> List( Trait ) # was getAnnotationConf
add_text_item_event_callbacks: Widget_Id -> Text_Item_Id -> List( Event_Callback ) -> Void;
add_text_item_traits: Widget_Id -> Text_Item_Id -> List( Trait) -> Void;
get_tcl_text_item_marks: Widget_Id -> Text_Item_Id -> List( (Mark, Mark) );
read_selection: Widget_Id -> List ((Mark, Mark));
# 4.6 Canvases incl. Canvas Items
get_canvas_item: Widget_Id -> Canvas_Item_Id -> Canvas_Item;
add_canvas_item: Widget_Id -> Canvas_Item -> Void;
delete_canvas_item: Widget_Id -> Canvas_Item_Id -> Void;
# These are casualties of an accidental (re)naming collision. Should pick new names and restore them:
# my get_canvas_item_event_callbacks: Widget_ID -> Canvas_Item_ID -> List( Event_Callback )
# my get_canvas_item_traits: Widget_ID -> Canvas_Item_ID -> List( Trait )
add_canvas_item_event_callbacks: Widget_Id -> Canvas_Item_Id -> List( Event_Callback ) -> Void;
add_canvas_item_traits: Widget_Id -> Canvas_Item_Id -> List( Trait ) -> Void;
canvas_to_postscript: tk_types::Canvas_Item_Id -> List( tk_types::Trait ) -> Void;
get_tcl_canvas_item_coordinates: Widget_Id -> Canvas_Item_Id -> List( Coordinate );
get_tcl_canvas_item_height: Widget_Id -> Canvas_Item_Id -> Int;
get_tcl_canvas_item_width: Widget_Id -> Canvas_Item_Id -> Int;
move_canvas_item: Widget_Id -> Canvas_Item_Id -> Coordinate -> Void;
set_canvas_item_coordinates: Widget_Id -> Canvas_Item_Id -> List( Coordinate ) -> Void;
# 4.7 Menues
pop_up_menu: Widget_Id -> null_or::Null_Or( Int ) -> Coordinate -> Void;
make_and_pop_up_window: Widget -> null_or::Null_Or( Int ) -> Coordinate -> Void;
# ********* still buggy ??? *********** siehe Popup_ex
# 4.8 Buttons and Tcl Vaues
set_var_value: String -> String -> Void;
get_tcl_var_value: String -> String;
set_tcl_scale: Widget_Id -> Float -> Void;
# 4.9 Coordinate
coordinate: (Int, Int) -> Coordinate;
add_coordinates: Coordinate -> Coordinate -> Coordinate;
subtract_coordinates: Coordinate -> Coordinate -> Coordinate;
scale_coordinate: Coordinate -> Int -> Coordinate;
show_coordinate: List( Coordinate ) -> String;
coordinates_from_string: String -> List( Coordinate );
Rectangle = (Coordinate, Coordinate);
inside: Coordinate -> Rectangle -> Bool;
intersect: Rectangle -> Rectangle -> Bool;
move_rectangle: Rectangle -> Coordinate -> Rectangle;
show_rectangle: Rectangle -> String;
# 4.10. Checks
# my check: Window -> Bool
# my checkMItem: Menu_Item -> Bool
check_widget_id: Widget_Id -> Bool;
# my checkWidget: Widget -> Bool
# my check_window: Window -> Bool
check_window_id: Window_Id -> Bool;
check_window_title: Title -> Bool;
# 4.11. Focus and Grabs
focus: Window_Id -> Void;
de_focus: Window_Id -> Void;
grab: Window_Id -> Void;
de_grab: Window_Id -> Void;
# 4.12. Selection
get_tcl_selection_window: Void -> null_or::Null_Or( (Window_Id, Widget_Id) );
# 4.13. Interrupt handling
Intr_Listener
; register_signal_callback: (Void -> Void) -> Intr_Listener;
deregister_signal_callback: Intr_Listener -> Void;
# 4.14. GUI state
init: Void -> Void;
set_up_fonts: Void -> Void;
# get/update the library path (SMLTK_LIB)
get_lib_path: Void -> String;
update_lib_path: String -> Void;
# get/update the wish path (SMLTK_TCL)
get_tcl_path: Void -> String;
update_tcl_path: String -> Void;
# get/update the logfile path (SMLTK_LOGFILE
get_logfile_path: Void -> String;
update_logfile_path: String -> Void;
# 4.15. Miscellenea
show_mark_list: List( (Mark, Mark) ) -> String;
# Produce dumped image
dump_executable_heap_image: { banner: String, imagefile: String } -> Void;
# Environment variable settings (can be overriden from the cmd line)
getenv: String -> null_or::Null_Or( String );
# 7. Debugging
package debug: Debug; # Debug is from
src/lib/tk/src/debug.api# These are needed for debugging as well, if you want to print an id
canvas_item_id_to_string: Canvas_Item_Id -> String;
widget_id_to_string: Widget_Id -> String;
window_id_to_string: Window_Id -> String;
text_item_id_to_string: Text_Item_Id -> String;
make_cursor_name: String -> Cursor_Name;
make_rectangle: ((((Int, Int)), ((Int, Int)))) -> Rectangle;
};
package tk: Tk { # Tk is from
src/lib/tk/src/export.pkg include package basic_utilities;
include package com_state;
include package com;
include package coordinate;
include package canvas_item;
include package canvas_item_tree;
include package text_item;
include package text_item_tree;
include package paths;
include package config;
include package tk_event;
include package live_text;
include package widget_tree;
include package window;
include package event_loop;
include package widget_ops;
include package tk_types;
get_lib_path = com_state::get_lib_path;
update_lib_path = com_state::update_lib_path;
get_tcl_path = com_state::get_wish_path;
update_tcl_path = com_state::upd_wish_path;
fun get_logfile_path () = null_or::the_else (com_state::get_logfilename(), "");
fun update_logfile_path "" => com_state::upd_logfilename NULL;
update_logfile_path p => com_state::upd_logfilename (THE p); end;
is_open = occurs_window_gui;
change_title = window::change_title;
check_window = window::check;
check_window_id = window::check_window_id;
check_window_title = window::check_title;
open_window = window::open_w;
close_window = window::close;
get_window = gui_state::get_window_gui;
get_all_windows = gui_state::get_windows_gui;
fun coordinate (x, y) = (x, y);
add_coordinates = coordinate::add;
subtract_coordinates = coordinate::sub;
scale_coordinate = coordinate::smult;
show_coordinate = coordinate::show;
coordinates_from_string = coordinate::read;
fun coordinate_to_tuple (x, y) = (x, y);
fun make_rectangle r = r;
show_mark = mark::show;
show_mark_list = mark::show_l;
widget_exists = paths::occurs_widget_gui;
delete_widget = widget_tree::delete_widget;
add_trait = widget_tree::configure;
add_event_callbacks = widget_tree::add_namings;
set_event_callbacks = widget_tree::new_namings;
set_traits = widget_tree::newconfigure;
get_widget = select_widget;
get_traits = select;
get_relief_kind = select_relief;
get_callback = select_command;
get_width = select_width;
get_height = select_height;
get_event_callbacks = select_namings;
get_menu_callback = select_mcommand;
add_canvas_item = canvas_item_tree::add;
delete_canvas_item = canvas_item_tree::delete;
add_canvas_item_event_callbacks = canvas_item_tree::add_naming;
add_canvas_item_traits = canvas_item_tree::add_configure;
get_canvas_item = canvas_item_tree::get;
# These are casualties of an accidental (re)naming collision. Should pick new names and restore them:
# get_canvas_item_event_callbacks = canvas_item_tree::getNaming
# get_canvas_item_traits = canvas_item_tree::get_configure
canvas_to_postscript = canvas_item_tree::print_canvas;
move_canvas_item = canvas_item_tree::move;
set_canvas_item_coordinates = canvas_item_tree::set_coords;
update_canvas_item = canvas_item_tree::upd;
string_to_livetext = make;
append_newline_to_livetext = nl;
empty_livetext = empty_livetext;
join_livetext = join_at;
my +++ = +++;
get_text_item = text_item_tree::get;
update_text_item2= text_item_tree::upd;
add_text_item = text_item_tree::add;
delete_text_item = text_item_tree::delete;
# These are casualties of an accidental (re)naming collision. Should pick new names and restore them:
# get_text_item_event_callbacks = text_item_tree::getNaming ( * was getAnnotationBind
# get_text_item_traits = text_item_tree::get_configure ( * was getAnnotationConf
add_text_item_event_callbacks = text_item_tree::add_naming;
add_text_item_traits = text_item_tree::add_configure;
# The get_tcl_* functions read values out of the
# tcl wish process, requiring a round-trip through
# the connecting pipe. Accordingly, they are slower,
# but sometimes they are the only way to know if a user
# changed something over there:
get_tcl_text_item_marks = text_item_tree::read_marks;
get_tcl_selection_window = get_selection_window_and_widget;
get_tcl_var_value = get_var_value;
get_tcl_selected_text = get_marked_text;
get_tcl_text = get_text;
get_tcl_cursor = widget_ops::get_cursor_mark;
get_tcl_selection_range = widget_ops::get_widget_selections;
set_tcl_scale = widget_ops::set_scale_value;
get_tcl_canvas_item_coordinates = canvas_item_tree::get_coords;
get_tcl_canvas_item_height = canvas_item_tree::get_height;
get_tcl_canvas_item_width = canvas_item_tree::get_width;
get_tcl_icon_height = get_icon_height;
get_tcl_icon_width = get_icon_width;
make_canvas_item_id = canvas_item::new_id;
make_canvas_item_frame_id = new_fr_id;
make_text_item_id = text_item::new_id;
make_text_item_frame_id = text_item::new_fr_id;
make_window_id = make_widget_id; # Dodgy
make_image_id = make_widget_id; # me too
# These also have to check their arguments
# for non-alphanumerical characters etc:
#
fun make_tagged_window_id str = str + make_window_id ();
fun make_tagged_image_id str = str + make_image_id();
fun make_tagged_frame_id str = str + new_fr_id();
fun make_tagged_canvas_item_id str = str + canvas_item::new_id();
fun make_tagged_widget_id str = str + make_widget_id();
fun make_window { window_id, subwidgets, traits, event_callbacks, init }
=
(window_id, traits, subwidgets, event_callbacks, init);
fun make_title string = string;
fun make_simple_callback f = f;
my
null_callback
=
\\ _=> (); end ;
fun make_callback f = f;
fun make_quit_callback f = f;
fun make_widget w = w;
fun make_window_string w = w;
fun make_widget_string w = w;
fun make_canvas_item_string c = c;
fun make_text_item_id_string a = a;
fun make_sub_window_id (w, str) = w + str;
fun make_sub_widget_id (w, str) = w + str;
fun make_sub_canvas_item_id (c, str) = c + str;
fun widget_id_to_canvas_item_id c = c;
fun canvas_item_id_to_widget_id c = c;
fun init()
=
{ reset_tcl ();
sys_init::init_sml_tk ();
};
my
reset = reset_tcl;
my
set_up_fonts = fonts::init o get_lib_path;
fun set_font_base_size x
=
{ .base_size (fonts::font_config) := x;
set_up_fonts()
;};
fun dump_executable_heap_image { imagefile, banner }
=
sys_dep::export_ml {
init => sys_init::init_sml_tk,
banner,
imagefile
};
my
getenv = sys_init::getenv;
package debug = debug;
/* These con-/destructors and converters are needed
for the new version */
fun widget_id_to_string c=c;
fun window_id_to_string c=c;
fun canvas_item_id_to_string c = c;
fun text_item_id_to_string c = c;
fun make_cursor_name c = c;
};