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_gdome,ids_to_terms,ids_to_father_ids,ids_to_hypotheses =
109 SequentPp.XmlPp.print_sequent metasenv sequent in
111 Xml2Gdome.document_of_xml Misc.domImpl sequent_gdome in
113 ApplyStylesheets.apply_sequent_stylesheets sequent_doc
115 self#load_doc ~dom:sequent_mml ;
117 Some (ids_to_terms,ids_to_father_ids,ids_to_hypotheses)
121 let sequent_viewer ?adjustmenth ?adjustmentv ?font_size ?font_manager
122 ?border_width ?width ?height ?packing ?show () =
124 GtkMathView.MathView.create
125 ?adjustmenth:(Gaux.may_map ~f:GData.as_adjustment adjustmenth)
126 ?adjustmentv:(Gaux.may_map ~f:GData.as_adjustment adjustmentv)
129 GtkBase.Container.set w ?border_width ?width ?height;
130 let mathview = GObj.pack_return (new sequent_viewer w) ~packing ~show in
133 | Some size -> mathview#set_font_size size
137 match font_manager with
138 | Some manager -> mathview#set_font_manager_type ~fm_type:manager
145 (** A widget to render proofs **)
147 class proof_viewer obj =
150 inherit GMathViewAux.single_selection_math_view obj
152 val mutable current_infos = None
154 method make_sequent_of_selected_term =
155 match self#get_selection with
158 ((node : Gdome.element)#getAttributeNS
159 ~namespaceURI:Misc.helmns
160 ~localName:(Gdome.domString "xref"))#to_string
162 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
165 match current_infos with
166 Some (ids_to_terms, ids_to_father_ids, _, _) ->
168 LogicalOperations.to_sequent id ids_to_terms ids_to_father_ids
169 | None -> assert false (* "ERROR: No current term!!!" *)
171 | None -> assert false (* "ERROR: No selection!!!" *)
173 method focus_sequent_of_selected_term =
174 match self#get_selection with
177 ((node : Gdome.element)#getAttributeNS
178 ~namespaceURI:Misc.helmns
179 ~localName:(Gdome.domString "xref"))#to_string
181 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
184 match current_infos with
185 Some (ids_to_terms, ids_to_father_ids, _, _) ->
187 LogicalOperations.focus id ids_to_terms ids_to_father_ids
188 | None -> assert false (* "ERROR: No current term!!!" *)
190 | None -> assert false (* "ERROR: No selection!!!" *)
192 method load_proof uri currentproof =
194 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
195 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
197 Cic2acic.acic_object_of_cic_object currentproof
200 ApplyStylesheets.mml_of_cic_object
201 ~explode_all:true uri acic ids_to_inner_sorts ids_to_inner_types
203 self#load_doc ~dom:mml ;
206 (ids_to_terms,ids_to_father_ids,ids_to_conjectures,ids_to_hypotheses) ;
207 (acic, ids_to_inner_types, ids_to_inner_sorts)
211 let proof_viewer ?adjustmenth ?adjustmentv ?font_size ?font_manager
212 ?border_width ?width ?height ?packing ?show () =
214 GtkMathView.MathView.create
215 ?adjustmenth:(Gaux.may_map ~f:GData.as_adjustment adjustmenth)
216 ?adjustmentv:(Gaux.may_map ~f:GData.as_adjustment adjustmentv)
219 GtkBase.Container.set w ?border_width ?width ?height;
220 let mathview = GObj.pack_return (new proof_viewer w) ~packing ~show in
223 | Some size -> mathview#set_font_size size
227 match font_manager with
228 | Some manager -> mathview#set_font_manager_type ~fm_type:manager