]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/lablgtk/lablgtk_20000829-0.1.0/examples/old/progressbar.ml
- the mathql interpreter is not helm-dependent any more
[helm.git] / helm / DEVEL / lablgtk / lablgtk_20000829-0.1.0 / examples / old / progressbar.ml
1 (* $Id$ *)
2
3 open Gtk
4 open GtkBase
5 open GtkMisc
6 open GtkWindow
7 open GtkRange
8 open GtkPack
9 open GtkButton
10 open GtkMain
11
12
13 class bar bar = object
14   val bar : progress_bar obj = bar
15   val mutable pstat = true
16   method progress =
17     let pvalue = Progress.get_percentage bar in
18     let pvalue =
19       if pvalue >= 1.0 || not pstat then (pstat <- true; 0.0)
20       else pvalue +. 0.01
21     in
22     ProgressBar.update bar percent:pvalue;
23     true
24   method progress_r =
25     pstat <- false
26 end
27
28 let main () =
29
30   let window = Window.create `TOPLEVEL in
31   GtkSignal.connect sig:Object.Signals.destroy window callback:Main.quit;
32   Container.set_border_width window 10;
33
34   let table = Table.create rows:3 columns:2 in
35   Container.add window table;
36   
37   let label = Label.create "Progress Bar Example" in
38   Table.attach table label left:0 right:2 top:0 expand:`X shrink:`BOTH;
39   
40   let pbar = ProgressBar.create () in
41   Table.attach table pbar left:0 right:2 top:1 fill:`X shrink:`BOTH;
42
43   let bar = new bar pbar in
44   let ptimer = Timeout.add 100 callback:(fun () -> bar#progress) in
45
46   let button = Button.create label:"Reset" in
47   GtkSignal.connect sig:Button.Signals.clicked button
48     callback:(fun () -> bar#progress_r);
49   Table.attach table button left:0 top:2 expand:`NONE fill:`X shrink:`BOTH;
50
51   let button = Button.create label:"Cancel" in
52   GtkSignal.connect sig:Button.Signals.clicked button callback:Main.quit;
53   Table.attach table button left:1 top:2 expand:`NONE fill:`X shrink:`BOTH;
54
55   Widget.show_all window
56
57
58 let _ =
59   main ();
60   Main.main ()