1
(***********************************************************************)
5
(* Pierre Weis, projet Cristal, INRIA Rocquencourt *)
7
(* Copyright 2001 Institut National de Recherche en Informatique et *)
8
(* en Automatique. All rights reserved. This file is distributed *)
9
(* under the terms of the Q Public License version 1.0. *)
11
(***********************************************************************)
15
let synchronise_zones source dest taux_source taux_dest =
18
let montant_source = float_of_string (Entry.get source) in
20
montant_source *. !taux_source /. !taux_dest in
21
Entry.delete_range dest (At 0) End;
22
Entry.insert dest (At 0)
23
(Printf.sprintf "%.2f" montant_dest)
25
Entry.delete_range dest (At 0) End;
26
Entry.insert dest (At 0) "erreur";;
28
let convertion_en_francs () =
31
let ligne1 = Frame.create fp []
32
and ligne2 = Frame.create fp [] in
34
let �tiq1 = Label.create ligne1 [Text "Francs:"]
35
and entr�e1 = Entry.create ligne1 [TextWidth 10; Relief Sunken]
37
and �tiq2 = Label.create ligne2 [Text "Euros:"]
38
and entr�e2 = Entry.create ligne2 [TextWidth 10; Relief Sunken] in
40
let quit = Button.create fp [Text "Quit"; Command closeTk] in
42
let taux1 = ref 1.0 (* francs pour 1 franc *)
43
and taux2 = ref 6.55957 (* francs pour 1 euro *) in
45
bind entr�e1 [[], KeyRelease]
46
(BindSet([], synchronise_zones entr�e1 entr�e2 taux1 taux2));
47
bind entr�e2 [[], KeyRelease]
48
(BindSet([], synchronise_zones entr�e2 entr�e1 taux2 taux1));
50
pack [�tiq1] [Side Side_Left]; pack [entr�e1] [Side Side_Right];
51
pack [�tiq2] [Side Side_Left]; pack [entr�e2] [Side Side_Right];
52
pack [ligne1; ligne2] [Side Side_Top; Fill Fill_X];
53
pack [quit] [Side Side_Bottom; Fill Fill_X];
56
if !Sys.interactive then () else begin convertion_en_francs (); exit 0 end;;