1 (***********************************************************************)
3 (* MLTk, Tcl/Tk interface of Objective Caml *)
5 (* Francois Rouaix, Francois Pessaux, Jun Furuse and Pierre Weis *)
6 (* projet Cristal, INRIA Rocquencourt *)
7 (* Jacques Garrigue, Kyoto University RIMS *)
9 (* Copyright 2002 Institut National de Recherche en Informatique et *)
10 (* en Automatique and Kyoto University. All rights reserved. *)
11 (* This file is distributed under the terms of the GNU Library *)
12 (* General Public License, with the special exception on linking *)
13 (* described in file LICENSE found in the Objective Caml source tree. *)
15 (***********************************************************************)
22 and pending_resize
= ref false
23 and last_last
= ref 0.0 in
25 pending_resize
:= false;
27 (Printf.eprintf
"%s Resize %d\n"
28 (Widget.name wid
) !newsize; flush stderr
);
29 Text.configure wid
[TextHeight
!newsize];
32 let first, last
= Text.yview_get wid
in
35 and check1
first last
=
36 let curheight = int_of_string
(cget wid CHeight
) in
38 Printf.eprintf
"%s C %d %f %f\n"
39 (Widget.name wid
) curheight first last
;
42 if first = 0.0 && last
= 1.0 then ()
43 (* Don't attempt anything if widget is not visible *)
44 else if not
(Winfo.viewable wid
) then begin
46 (Printf.eprintf
"%s C notviewable\n" (Widget.name wid
);
49 bind wid
[[], Expose
] (BindSet
([], fun _
->
50 bind wid
[[], Expose
] BindRemove
;
56 else if last
= !last_last
then
57 (* it didn't change since our last resize ! *)
61 (* never to more than double *)
62 let visible = max
0.5 (last
-. first) in
63 max
1 (truncate
(float curheight *. (1. -. visible)))
65 newsize := max
(curheight + delta) !newsize;
67 (Printf.eprintf
"%s newsize: %d\n" (Widget.name wid
) !newsize;
69 if !pending_resize
then ()
71 pending_resize
:= true;
72 Timer.set
300 (fun () -> Frx_after.idle
resize)
76 and scroll
first last
=
78 (Printf.eprintf
"%s V %f %f\n" (Widget.name wid
) first last
;
80 if first = 0.0 && last
= 1.0 then ()
81 else check1
first last