# gui_state.pkg
# Compiled by:
#
src/lib/tk/src/tk.sublib### "At night, never go to bed without
### knowing what you'll write tomorrow."
###
### -- Ernest Hemingway
# Compiled by:
#
src/lib/tk/src/tk.sublibpackage gui_state
: (weak) Gui_State # Gui_State is from
src/lib/tk/src/gui_state.api{
include package basic_tk_types;
#
Gui = (List( Window ), List( Path_Ass ));
Tcl_Answer = String;
gui_state = REF([]: List( Window ), []:List( Path_Ass ));
stipulate
include package basic_tk_utilities;
herein
fun get_windows_gui ()
=
{ my (windows, _) = *gui_state;
windows;
};
fun get_path_ass_gui ()
=
{ my (_, path_ass) = *gui_state;
path_ass;
};
fun get_window_gui w
=
list_util::getx ((eq w) o get_window_id)
(get_windows_gui())
(WINDOWS ("getWindowGUI with windowId \"" + w + "\""));
# 2C. UPDATING WINDOWS
# updateWin . Window_ID -> Window s -> GUI s -> ((), GUI s)
fun upd_window_gui window newwin
=
{ my (wins, ass) = *gui_state;
gui_state := (list_util::update_val ((eq window) o get_window_id)
newwin wins, ass);
};
end; # local use basic_tk_utilities
fun upd_windows_gui nwins
=
{ my (wins, ass) = *gui_state;
gui_state := (nwins, ass);
};
fun upd_path_ass_gui nass
=
{ my (wins, ass) = *gui_state;
gui_state := (wins, nass);
};
fun upd_gui (nwins, nass)
=
gui_state := (nwins, nass);
# I'm not sure if it could be called before the window is added to
# the internal GUI state. Therefore True as well if no window is
# present as if it really is the first in the GUI state.
#
# isInitWin . Window_ID -> GUI s -> (Bool, GUI s)
fun is_init_window w
=
\\ ([], _) => TRUE;
(window . windows, _) => (w == (get_window_id window));
end
*gui_state;
fun init_gui_state ()
=
( gui_state := ([], [])
);
};