|
Packit |
bd2e5d |
(***********************************************************************)
|
|
Packit |
bd2e5d |
(* *)
|
|
Packit |
bd2e5d |
(* MLTk, Tcl/Tk interface of OCaml *)
|
|
Packit |
bd2e5d |
(* *)
|
|
Packit |
bd2e5d |
(* Francois Rouaix, Francois Pessaux, Jun Furuse and Pierre Weis *)
|
|
Packit |
bd2e5d |
(* projet Cristal, INRIA Rocquencourt *)
|
|
Packit |
bd2e5d |
(* Jacques Garrigue, Kyoto University RIMS *)
|
|
Packit |
bd2e5d |
(* *)
|
|
Packit |
bd2e5d |
(* Copyright 2002 Institut National de Recherche en Informatique et *)
|
|
Packit |
bd2e5d |
(* en Automatique and Kyoto University. All rights reserved. *)
|
|
Packit |
bd2e5d |
(* This file is distributed under the terms of the GNU Library *)
|
|
Packit |
bd2e5d |
(* General Public License, with the special exception on linking *)
|
|
Packit |
bd2e5d |
(* described in file LICENSE found in the OCaml source tree. *)
|
|
Packit |
bd2e5d |
(* *)
|
|
Packit |
bd2e5d |
(***********************************************************************)
|
|
Packit |
bd2e5d |
module Widget : sig
|
|
Packit |
bd2e5d |
type widget = Widget.any Widget.widget
|
|
Packit |
bd2e5d |
(* widget is an abstract type *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val default_toplevel : widget
|
|
Packit |
bd2e5d |
(* [default_toplevel] is "." in Tk, the toplevel widget that is
|
|
Packit |
bd2e5d |
always existing during a Tk session. Destroying [default_toplevel]
|
|
Packit |
bd2e5d |
ends the main loop
|
|
Packit |
bd2e5d |
*)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val atom : parent: widget -> name: string -> widget
|
|
Packit |
bd2e5d |
(* [atom parent name] returns the widget [parent.name]. The widget is
|
|
Packit |
bd2e5d |
not created. Only its name is returned. In a given parent, there may
|
|
Packit |
bd2e5d |
only exist one children for a given name.
|
|
Packit |
bd2e5d |
This function should only be used to check the existence of a widget
|
|
Packit |
bd2e5d |
with a known name. It doesn't add the widget to the internal tables
|
|
Packit |
bd2e5d |
of CamlTk.
|
|
Packit |
bd2e5d |
*)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val name : widget -> string
|
|
Packit |
bd2e5d |
(* [name w] returns the name (tk "path") of a widget *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
(*--*)
|
|
Packit |
bd2e5d |
(* The following functions are used internally.
|
|
Packit |
bd2e5d |
There is normally no need for them in users programs
|
|
Packit |
bd2e5d |
*)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val known_class : widget -> string
|
|
Packit |
bd2e5d |
(* [known_class w] returns the class of a widget (e.g. toplevel, frame),
|
|
Packit |
bd2e5d |
as known by the CamlTk interface.
|
|
Packit |
bd2e5d |
Not equivalent to "winfo w" in Tk.
|
|
Packit |
bd2e5d |
*)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val dummy : widget
|
|
Packit |
bd2e5d |
(* [dummy] is a widget used as context when we don't have any.
|
|
Packit |
bd2e5d |
It is *not* a real widget.
|
|
Packit |
bd2e5d |
*)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val new_atom : parent: widget -> ?name: string -> string -> widget
|
|
Packit |
bd2e5d |
(* incompatible with the classic camltk *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val get_atom : string -> widget
|
|
Packit |
bd2e5d |
(* [get_atom path] returns the widget with Tk path [path] *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val remove : widget -> unit
|
|
Packit |
bd2e5d |
(* [remove w] removes widget from the internal tables *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
(* Subtypes tables *)
|
|
Packit |
bd2e5d |
val widget_any_table : string list
|
|
Packit |
bd2e5d |
val widget_button_table : string list
|
|
Packit |
bd2e5d |
val widget_canvas_table : string list
|
|
Packit |
bd2e5d |
val widget_checkbutton_table : string list
|
|
Packit |
bd2e5d |
val widget_entry_table : string list
|
|
Packit |
bd2e5d |
val widget_frame_table : string list
|
|
Packit |
bd2e5d |
val widget_label_table : string list
|
|
Packit |
bd2e5d |
val widget_listbox_table : string list
|
|
Packit |
bd2e5d |
val widget_menu_table : string list
|
|
Packit |
bd2e5d |
val widget_menubutton_table : string list
|
|
Packit |
bd2e5d |
val widget_message_table : string list
|
|
Packit |
bd2e5d |
val widget_radiobutton_table : string list
|
|
Packit |
bd2e5d |
val widget_scale_table : string list
|
|
Packit |
bd2e5d |
val widget_scrollbar_table : string list
|
|
Packit |
bd2e5d |
val widget_text_table : string list
|
|
Packit |
bd2e5d |
val widget_toplevel_table : string list
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val chk_sub : string -> 'a list -> 'a -> unit
|
|
Packit |
bd2e5d |
val check_class : widget -> string list -> unit
|
|
Packit |
bd2e5d |
(* Widget subtyping *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
exception IllegalWidgetType of string
|
|
Packit |
bd2e5d |
(* Raised when widget command applied illegally*)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
(* this function is not used, but introduced for the compatibility
|
|
Packit |
bd2e5d |
with labltk. useless for camltk users *)
|
|
Packit |
bd2e5d |
val coe : 'a Widget.widget -> Widget.any Widget.widget
|
|
Packit |
bd2e5d |
end
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
module Protocol : sig
|
|
Packit |
bd2e5d |
open Widget
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
(* Lower level interface *)
|
|
Packit |
bd2e5d |
exception TkError of string
|
|
Packit |
bd2e5d |
(* Raised by the communication functions *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val debug : bool ref
|
|
Packit |
bd2e5d |
(* When set to true, displays approximation of intermediate Tcl code *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
type tkArgs =
|
|
Packit |
bd2e5d |
TkToken of string
|
|
Packit |
bd2e5d |
| TkTokenList of tkArgs list (* to be expanded *)
|
|
Packit |
bd2e5d |
| TkQuote of tkArgs (* mapped to Tcl list *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
(* Misc *)
|
|
Packit |
bd2e5d |
external splitlist : string -> string list
|
|
Packit |
bd2e5d |
= "camltk_splitlist"
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val add_destroy_hook : (widget -> unit) -> unit
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
(* Opening, closing, and mainloop *)
|
|
Packit |
bd2e5d |
val default_display : unit -> string
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val opentk : unit -> widget
|
|
Packit |
bd2e5d |
(* The basic initialization function. [opentk ()] parses automatically
|
|
Packit |
bd2e5d |
the command line options and use the tk related options in them
|
|
Packit |
bd2e5d |
such as "-display localhost:0" to initialize Tk applications.
|
|
Packit |
bd2e5d |
Consult wish manpage about the supported options. *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val keywords : (string * Arg.spec * string) list
|
|
Packit |
bd2e5d |
(* Command line parsing specification for Arg.parse, which contains
|
|
Packit |
bd2e5d |
the standard Tcl/Tk command line options such as "-display" and "-name".
|
|
Packit |
bd2e5d |
These Tk command line options are used by opentk *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val opentk_with_args : string list -> widget
|
|
Packit |
bd2e5d |
(* [opentk_with_args argv] invokes [opentk] with the tk related
|
|
Packit |
bd2e5d |
command line options given by [argv] to the executable program. *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val openTk : ?display:string -> ?clas:string -> unit -> widget
|
|
Packit |
bd2e5d |
(* [openTk ~display:display ~clas:clas ()] is equivalent to
|
|
Packit |
bd2e5d |
[opentk ["-display"; display; "-name"; clas]] *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
(* Legacy opentk functions *)
|
|
Packit |
bd2e5d |
val openTkClass: string -> widget
|
|
Packit |
bd2e5d |
(* [openTkClass class] is equivalent to [opentk ["-name"; class]] *)
|
|
Packit |
bd2e5d |
val openTkDisplayClass: string -> string -> widget
|
|
Packit |
bd2e5d |
(* [openTkDisplayClass disp class] is equivalent to
|
|
Packit |
bd2e5d |
[opentk ["-display"; disp; "-name"; class]] *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val closeTk : unit -> unit
|
|
Packit |
bd2e5d |
val finalizeTk : unit -> unit
|
|
Packit |
bd2e5d |
(* Finalize tcl/tk before exiting. This function will be automatically
|
|
Packit |
bd2e5d |
called when you call [Pervasives.exit ()] *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val mainLoop : unit -> unit
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
(* Direct evaluation of tcl code *)
|
|
Packit |
bd2e5d |
val tkEval : tkArgs array -> string
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val tkCommand : tkArgs array -> unit
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
(* Returning a value from a Tcl callback *)
|
|
Packit |
bd2e5d |
val tkreturn: string -> unit
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
(* Callbacks: this is private *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
type cbid = Protocol.cbid
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
type callback_buffer = string list
|
|
Packit |
bd2e5d |
(* Buffer for reading callback arguments *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val callback_naming_table : (cbid, callback_buffer -> unit) Hashtbl.t
|
|
Packit |
bd2e5d |
(* CAMLTK val callback_memo_table : (widget, cbid) Hashtbl.t *)
|
|
Packit |
bd2e5d |
val callback_memo_table : (widget, cbid) Hashtbl.t
|
|
Packit |
bd2e5d |
(* Exported for debug purposes only. Don't use them unless you
|
|
Packit |
bd2e5d |
know what you are doing *)
|
|
Packit |
bd2e5d |
val new_function_id : unit -> cbid
|
|
Packit |
bd2e5d |
val string_of_cbid : cbid -> string
|
|
Packit |
bd2e5d |
val register_callback : widget -> callback:(callback_buffer -> unit) -> string
|
|
Packit |
bd2e5d |
(* Callback support *)
|
|
Packit |
bd2e5d |
val clear_callback : cbid -> unit
|
|
Packit |
bd2e5d |
(* Remove a given callback from the table *)
|
|
Packit |
bd2e5d |
val remove_callbacks : widget -> unit
|
|
Packit |
bd2e5d |
(* Clean up callbacks associated to widget. Must be used only when
|
|
Packit |
bd2e5d |
the Destroy event is bind by the user and masks the default
|
|
Packit |
bd2e5d |
Destroy event binding *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val cTKtoCAMLwidget : string -> widget
|
|
Packit |
bd2e5d |
val cCAMLtoTKwidget : string list -> widget -> tkArgs
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val register : string -> callback:(callback_buffer -> unit) -> unit
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
(*-*)
|
|
Packit |
bd2e5d |
val prerr_cbid : cbid -> unit
|
|
Packit |
bd2e5d |
end
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
module Textvariable : sig
|
|
Packit |
bd2e5d |
open Widget
|
|
Packit |
bd2e5d |
open Protocol
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
type textVariable = Textvariable.textVariable
|
|
Packit |
bd2e5d |
(* TextVariable is an abstract type *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val create : ?on: widget -> unit -> textVariable
|
|
Packit |
bd2e5d |
(* Allocation of a textVariable with lifetime associated to widget
|
|
Packit |
bd2e5d |
if a widget is specified *)
|
|
Packit |
bd2e5d |
val create_temporary : widget -> textVariable
|
|
Packit |
bd2e5d |
(* for backward compatibility
|
|
Packit |
bd2e5d |
[create_temporary w] is equivalent to [create ~on:w ()] *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val set : textVariable -> string -> unit
|
|
Packit |
bd2e5d |
(* Setting the val of a textVariable *)
|
|
Packit |
bd2e5d |
val get : textVariable -> string
|
|
Packit |
bd2e5d |
(* Reading the val of a textVariable *)
|
|
Packit |
bd2e5d |
val name : textVariable -> string
|
|
Packit |
bd2e5d |
(* Its tcl name *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val cCAMLtoTKtextVariable : textVariable -> tkArgs
|
|
Packit |
bd2e5d |
(* Internal conversion function *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val handle : textVariable -> (unit -> unit) -> unit
|
|
Packit |
bd2e5d |
(* Callbacks on variable modifications *)
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val coerce : string -> textVariable
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
(*-*)
|
|
Packit |
bd2e5d |
val free : textVariable -> unit
|
|
Packit |
bd2e5d |
end
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
module Fileevent : sig
|
|
Packit |
bd2e5d |
open Unix
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val add_fileinput : file_descr -> (unit -> unit) -> unit
|
|
Packit |
bd2e5d |
val remove_fileinput: file_descr -> unit
|
|
Packit |
bd2e5d |
val add_fileoutput : file_descr -> (unit -> unit) -> unit
|
|
Packit |
bd2e5d |
val remove_fileoutput: file_descr -> unit
|
|
Packit |
bd2e5d |
(* see [tk] module *)
|
|
Packit |
bd2e5d |
end
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
module Timer : sig
|
|
Packit |
bd2e5d |
type t = Timer.t
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
val add : int -> (unit -> unit) -> t
|
|
Packit |
bd2e5d |
val set : int -> (unit -> unit) -> unit
|
|
Packit |
bd2e5d |
val remove : t -> unit
|
|
Packit |
bd2e5d |
end
|
|
Packit |
bd2e5d |
|
|
Packit |
bd2e5d |
(*
|
|
Packit |
bd2e5d |
Tkwait exists, but is not used in support
|
|
Packit |
bd2e5d |
module Tkwait : sig
|
|
Packit |
bd2e5d |
val internal_tracevis : string -> Protocol.cbid -> unit
|
|
Packit |
bd2e5d |
val internal_tracedestroy : string -> Protocol.cbid -> unit
|
|
Packit |
bd2e5d |
end
|
|
Packit |
bd2e5d |
*)
|