2002-04-26 05:16:26 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* MLTk, Tcl/Tk interface of Objective Caml *)
|
|
|
|
(* *)
|
|
|
|
(* Francois Rouaix, Francois Pessaux, Jun Furuse and Pierre Weis *)
|
|
|
|
(* projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* Jacques Garrigue, Kyoto University RIMS *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 2002 Institut National de Recherche en Informatique et *)
|
|
|
|
(* en Automatique and Kyoto University. All rights reserved. *)
|
|
|
|
(* This file is distributed under the terms of the GNU Library *)
|
|
|
|
(* General Public License, with the special exception on linking *)
|
|
|
|
(* described in file LICENSE found in the Objective Caml source tree. *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
1999-12-16 04:25:11 -08:00
|
|
|
|
1999-12-17 01:59:13 -08:00
|
|
|
(* $Id$ *)
|
|
|
|
|
1999-11-30 06:59:39 -08:00
|
|
|
open Widget
|
|
|
|
|
|
|
|
(* Lower level interface *)
|
|
|
|
exception TkError of string
|
|
|
|
(* Raised by the communication functions *)
|
|
|
|
|
|
|
|
val debug : bool ref
|
|
|
|
(* When set to true, displays approximation of intermediate Tcl code *)
|
|
|
|
|
|
|
|
type tkArgs =
|
|
|
|
TkToken of string
|
|
|
|
| TkTokenList of tkArgs list (* to be expanded *)
|
|
|
|
| TkQuote of tkArgs (* mapped to Tcl list *)
|
|
|
|
|
|
|
|
|
|
|
|
(* Misc *)
|
|
|
|
external splitlist : string -> string list
|
|
|
|
= "camltk_splitlist"
|
|
|
|
|
|
|
|
val add_destroy_hook : (any widget -> unit) -> unit
|
|
|
|
|
|
|
|
|
|
|
|
(* Opening, closing, and mainloop *)
|
2002-04-26 05:16:26 -07:00
|
|
|
val default_display : unit -> string
|
|
|
|
|
|
|
|
val opentk : unit -> toplevel widget
|
|
|
|
(* The basic initialization function. [opentk ()] parses automatically
|
|
|
|
the command line options and use the tk related options in them
|
|
|
|
such as "-display localhost:0" to initialize Tk applications.
|
|
|
|
Consult wish manpage about the supported options. *)
|
|
|
|
|
|
|
|
val keywords : (string * Arg.spec * string) list
|
|
|
|
(* Command line parsing specification for Arg.parse, which contains
|
|
|
|
the standard Tcl/Tk command line options such as "-display" and "-name".
|
|
|
|
These Tk command line options are used by opentk *)
|
|
|
|
|
|
|
|
val opentk_with_args : string list -> toplevel widget
|
|
|
|
(* [opentk_with_args argv] invokes [opentk] with the tk related
|
|
|
|
command line options given by [argv] to the executable program. *)
|
|
|
|
|
|
|
|
val openTk : ?display:string -> ?clas:string -> unit -> toplevel widget
|
|
|
|
(* [openTk ~display:display ~clas:clas ()] is equivalent to
|
|
|
|
[opentk ["-display"; display; "-name"; clas]] *)
|
|
|
|
|
|
|
|
(* Legacy opentk functions *)
|
|
|
|
val openTkClass: string -> toplevel widget
|
|
|
|
(* [openTkClass class] is equivalent to [opentk ["-name"; class]] *)
|
|
|
|
val openTkDisplayClass: string -> string -> toplevel widget
|
|
|
|
(* [openTkDisplayClass disp class] is equivalent to
|
|
|
|
[opentk ["-display"; disp; "-name"; class]] *)
|
|
|
|
|
|
|
|
val closeTk : unit -> unit
|
|
|
|
val finalizeTk : unit -> unit
|
|
|
|
(* Finalize tcl/tk before exiting. This function will be automatically
|
|
|
|
called when you call [Pervasives.exit ()] *)
|
|
|
|
|
|
|
|
val mainLoop : unit -> unit
|
1999-11-30 06:59:39 -08:00
|
|
|
|
|
|
|
|
|
|
|
(* Direct evaluation of tcl code *)
|
2002-04-26 05:16:26 -07:00
|
|
|
val tkEval : tkArgs array -> string
|
1999-11-30 06:59:39 -08:00
|
|
|
|
2002-04-26 05:16:26 -07:00
|
|
|
val tkCommand : tkArgs array -> unit
|
2000-02-15 02:12:37 -08:00
|
|
|
|
1999-11-30 06:59:39 -08:00
|
|
|
(* Returning a value from a Tcl callback *)
|
2002-04-26 05:16:26 -07:00
|
|
|
val tkreturn: string -> unit
|
1999-11-30 06:59:39 -08:00
|
|
|
|
|
|
|
|
|
|
|
(* Callbacks: this is private *)
|
|
|
|
|
|
|
|
type cbid
|
|
|
|
|
|
|
|
type callback_buffer = string list
|
|
|
|
(* Buffer for reading callback arguments *)
|
|
|
|
|
|
|
|
val callback_naming_table : (cbid, callback_buffer -> unit) Hashtbl.t
|
|
|
|
val callback_memo_table : (any widget, cbid) Hashtbl.t
|
|
|
|
(* Exported for debug purposes only. Don't use them unless you
|
|
|
|
know what you are doing *)
|
|
|
|
val new_function_id : unit -> cbid
|
|
|
|
val string_of_cbid : cbid -> string
|
|
|
|
val register_callback : 'a widget -> callback:(callback_buffer -> unit) -> string
|
|
|
|
(* Callback support *)
|
|
|
|
val clear_callback : cbid -> unit
|
|
|
|
(* Remove a given callback from the table *)
|
|
|
|
val remove_callbacks : 'a widget -> unit
|
|
|
|
(* Clean up callbacks associated to widget. Must be used only when
|
|
|
|
the Destroy event is bind by the user and masks the default
|
|
|
|
Destroy event binding *)
|
|
|
|
|
|
|
|
val cTKtoCAMLwidget : string -> any widget
|
|
|
|
val cCAMLtoTKwidget : 'a widget -> tkArgs
|
|
|
|
|
|
|
|
val register : string -> callback:(callback_buffer -> unit) -> unit
|
|
|
|
|
|
|
|
(*-*)
|
|
|
|
val prerr_cbid : cbid -> unit
|