------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 1995 by International Computer Science Institute            --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute  and/or modify it under the terms of the GNU Library General --
-- Public  License (LGPL)  as published  by the  Free  Software  Foundation; --
-- either version 2 of the license, or (at your option) any later version.   --
-- 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 Doc/LGPL for more details.       --
-- The license text is also available from:  Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     --
-------------->  Please email comments to <bug-sather@gnu.org>  <--------------

-- gui.sa: Include classes for widget users
-- Author: Benedict A. Gomes <gomes@samosa.ICSI.Berkeley.EDU>
-- Please look at the file "Documentation"

partial class GUI_UTIL is
   -- An include class for users of the gui. Simplifies
   -- the interface to the GUI.
   -- The idea is to have type safety while still preserving the
   -- convenience of the tk style of specifying events
    
   ----------------------- INTERFACE TO GUI MECHANISM -------------
   startup_gui is GUI_APP_END::startup(true,false) end;
   -- Call this function to start things off, in the common case.
   -- Forks the gui server, and uses Unix-domain sockets.
    
   startup_gui(do_fork:BOOL) is GUI_APP_END::startup(do_fork,~do_fork) end;
   -- Call this function to start things off, when you want to control
   -- whether the gui server is automatically forked.  Uses Internet-domain
   -- sockets if not forking.
    
   startup_gui(do_fork,use_inet_sockets:BOOL) is 
      GUI_APP_END::startup(do_fork,use_inet_sockets)
   end;
   -- Call this function to start things off, when you want to independently
   -- control forking behavior and socket type.
    
   terminate_gui is GUI_APP_END::terminate end;
    
   start_buffering is GUI_APP_END::start_buffering end;
   stop_buffering is GUI_APP_END::stop_buffering end;
   flush_buffer is GUI_APP_END::flush_buffer end;
    
   poll_gui is GUI_APP_END::poll end;
   -- Call this function periodically to handle pending callbacks
    
   gui_loop  is loop poll_gui; end; end; 
   -- If you use this version (rather than intermittent poll_gui calls)
   -- it should be possible to create a single process version of your
   -- user interface with the same functionality by replacing
   -- this call with the Tk main loop 
    
   sleep(n: INT) is discard ::= UNIX::system("sleep "+n) end;
    
   ----------------------- INTERFACE TO WIDGET CONFIGURATIONS ----------
   quit_routine: ROUT is    
      r: ROUT := bind(really_quit);
      return r ;
   end;
    
   root_window: TK_ROOT_WINDOW is return #TK_ROOT_WINDOW end;
    
   really_quit is
      GUI_APP_END::terminate;
      UNIX::exit(0);
   end;

   main
   is
      startup_gui;
      init;
      gui_loop;
   end;
    
   stub init;
    
end;
-------------------------------------------------------------------
