1 (* Copyright (C) 2000-2002, HELM Team.
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.
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.
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.
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,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
26 (******************************************************************************)
30 (* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
34 (******************************************************************************)
36 (* List utility functions *)
52 (* End of the list utility functions *)
54 (** A widget to render sequents **)
56 class sequent_viewer obj =
59 inherit GMathViewAux.multi_selection_math_view obj
61 val mutable current_infos = None
63 (* returns the list of selected terms *)
64 (* selections which are not terms are ignored *)
65 method get_selected_terms =
66 let selections = self#get_selections in
70 ((node : Gdome.element)#getAttributeNS
71 ~namespaceURI:Misc.helmns
72 ~localName:(Gdome.domString "xref"))#to_string
74 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
76 match current_infos with
77 Some (ids_to_terms,_,_) ->
80 Hashtbl.find ids_to_terms id
82 | None -> assert false (* "ERROR: No current term!!!" *)
85 (* returns the list of selected hypotheses *)
86 (* selections which are not hypotheses are ignored *)
87 method get_selected_hypotheses =
88 let selections = self#get_selections in
92 ((node : Gdome.element)#getAttributeNS
93 ~namespaceURI:Misc.helmns
94 ~localName:(Gdome.domString "xref"))#to_string
96 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
98 match current_infos with
99 Some (_,_,ids_to_hypotheses) ->
102 Hashtbl.find ids_to_hypotheses id
103 with _ -> raise Skip)
104 | None -> assert false (* "ERROR: No current term!!!" *)
107 method load_sequent metasenv sequent =
108 let sequent_mml,(ids_to_terms,ids_to_father_ids,ids_to_hypotheses) =
109 ApplyStylesheets.mml_of_cic_sequent metasenv sequent
111 self#load_doc ~dom:sequent_mml ;
113 Some (ids_to_terms,ids_to_father_ids,ids_to_hypotheses)
117 let sequent_viewer ?adjustmenth ?adjustmentv ?font_size ?font_manager
118 ?border_width ?width ?height ?packing ?show () =
120 GtkMathView.MathView.create
121 ?adjustmenth:(Gaux.may_map ~f:GData.as_adjustment adjustmenth)
122 ?adjustmentv:(Gaux.may_map ~f:GData.as_adjustment adjustmentv)
125 GtkBase.Container.set w ?border_width ?width ?height;
126 let mathview = GObj.pack_return (new sequent_viewer w) ~packing ~show in
129 | Some size -> mathview#set_font_size size
133 match font_manager with
134 | Some manager -> mathview#set_font_manager_type ~fm_type:manager
141 (** A widget to render proofs **)
143 class proof_viewer obj =
146 inherit GMathViewAux.single_selection_math_view obj
148 initializer self#set_font_size 10
150 val mutable current_infos = None
152 method make_sequent_of_selected_term =
153 match self#get_selection with
156 ((node : Gdome.element)#getAttributeNS
157 ~namespaceURI:Misc.helmns
158 ~localName:(Gdome.domString "xref"))#to_string
160 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
163 match current_infos with
164 Some (ids_to_terms, ids_to_father_ids, _, _) ->
166 LogicalOperations.to_sequent id ids_to_terms ids_to_father_ids
167 | None -> assert false (* "ERROR: No current term!!!" *)
169 | None -> assert false (* "ERROR: No selection!!!" *)
171 method focus_sequent_of_selected_term =
172 match self#get_selection with
175 ((node : Gdome.element)#getAttributeNS
176 ~namespaceURI:Misc.helmns
177 ~localName:(Gdome.domString "xref"))#to_string
179 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
182 match current_infos with
183 Some (ids_to_terms, ids_to_father_ids, _, _) ->
185 LogicalOperations.focus id ids_to_terms ids_to_father_ids
186 | None -> assert false (* "ERROR: No current term!!!" *)
188 | None -> assert false (* "ERROR: No selection!!!" *)
190 method load_proof uri currentproof =
192 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
193 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
195 Cic2acic.acic_object_of_cic_object currentproof
198 ApplyStylesheets.mml_of_cic_object
199 ~explode_all:true uri acic ids_to_inner_sorts ids_to_inner_types
201 self#load_doc ~dom:mml ;
204 (ids_to_terms,ids_to_father_ids,ids_to_conjectures,ids_to_hypotheses) ;
205 (acic, ids_to_inner_types, ids_to_inner_sorts)
209 let proof_viewer ?adjustmenth ?adjustmentv ?font_size ?font_manager
210 ?border_width ?width ?height ?packing ?show () =
212 GtkMathView.MathView.create
213 ?adjustmenth:(Gaux.may_map ~f:GData.as_adjustment adjustmenth)
214 ?adjustmentv:(Gaux.may_map ~f:GData.as_adjustment adjustmentv)
217 GtkBase.Container.set w ?border_width ?width ?height;
218 let mathview = GObj.pack_return (new proof_viewer w) ~packing ~show in
221 | Some size -> mathview#set_font_size size
225 match font_manager with
226 | Some manager -> mathview#set_font_manager_type ~fm_type:manager