]> matita.cs.unibo.it Git - helm.git/blob - helm/mathita/mathitaGui.ml
cda4a474f1082dd9bafe582a158badc9666591d7
[helm.git] / helm / mathita / mathitaGui.ml
1 (* Copyright (C) 2004, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 open MathitaGeneratedGui
27 open MathitaGtkMisc
28
29 class gui file =
30     (* creation order _is_ relevant for windows placement *)
31   let toolbar = new toolBarWin ~file () in
32   let main = new mainWin ~file () in
33   let about = new aboutWin ~file () in
34   let dialog = new genericDialog ~file () in
35   let uriChoice = new uriChoiceDialog ~file () in
36   let interpChoice = new interpChoiceDialog ~file () in
37   let fileSel = new fileSelectionWin ~file () in
38   let proof = new proofWin ~file () in
39   let keyBindingBoxes = (* event boxes which should receive global key events *)
40     [ toolbar#toolBarEventBox; proof#proofWinEventBox ]
41   in
42   object (self)
43     initializer
44         (* glade's check widgets *)
45       List.iter (fun w -> w#check_widgets ())
46         (let c w = (w :> <check_widgets: unit -> unit>) in
47          [ c about; c dialog; c fileSel; c main; c proof; c toolbar;
48            c uriChoice; c interpChoice ]);
49         (* show/hide commands *)
50       toggle_visibility toolbar#toolBarWin main#showToolBarMenuItem;
51       toggle_visibility proof#proofWin main#showProofMenuItem;
52         (* "global" key bindings *)
53       List.iter (fun (key, callback) -> self#addKeyBinding key callback)
54         [ GdkKeysyms._F3,
55             toggle_win ~check:main#showProofMenuItem proof#proofWin;
56         ];
57         (* about win *)
58       ignore (about#aboutWin#event#connect#delete (fun _ -> true));
59       ignore (main#aboutMenuItem#connect#activate (fun _ ->
60         about#aboutWin#show ()));
61       ignore (about#aboutDismissButton#connect#clicked (fun _ ->
62         about#aboutWin#misc#hide ()));
63         (* menus *)
64       List.iter (fun w -> w#misc#set_sensitive false)
65         [ main#saveMenuItem; main#saveAsMenuItem ];
66       main#helpMenu#set_right_justified true;
67         (* uri choice *)
68       ()
69
70     method toolbar = toolbar
71     method main = main
72     method about = about
73     method dialog = dialog
74     method uriChoice = uriChoice
75     method interpChoice = interpChoice
76     method fileSel = fileSel
77     method proof = proof
78
79     method private addKeyBinding key callback =
80       List.iter (fun evbox -> add_key_binding key callback evbox)
81         keyBindingBoxes
82
83     method setQuitCallback callback =
84       ignore (main#toplevel#connect#destroy callback);
85       ignore (main#quitMenuItem#connect#activate callback);
86       self#addKeyBinding GdkKeysyms._q callback
87
88   end
89