]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/lablgtkmathview/gMathView.ml
(pre-)porting to gtkmathview 0.6.3 && ocaml 3.08
[helm.git] / helm / DEVEL / lablgtkmathview / gMathView.ml
1 (* Copyright (C) 2000-2003, Luca Padovani <luca.padovani@cs.unibo.it>,
2  *                          Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>.
3  *
4  * This file is part of lablgtkmathview, the Ocaml binding
5  * for the GtkMathView widget.
6  * 
7  * lablgtkmathview 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  * lablgtkmathview 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 lablgtkmathview; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  * 
21  * For details, send a mail to the author.
22  *)
23
24 open Gaux
25 open Gtk_mathview
26 open Gobject
27 open Gtk
28 open GtkBase
29 open GtkMathView
30 open OgtkMathViewProps
31 open GObj
32
33 exception ErrorLoadingFile of string;;
34 exception ErrorWritingFile of string;;
35 exception ErrorLoadingDOM;;
36
37 let option_element_of_option =
38  function
39     None -> None
40   | Some v -> Some (new Gdome.element v)
41
42 class math_view_skel obj = object
43  inherit GObj.widget (obj : Gtk_mathview.math_view obj)
44  method freeze = MathView.freeze obj
45  method thaw = MathView.thaw obj
46  method load_uri ~filename =
47   if not (MathView.load_uri obj ~filename) then raise (ErrorLoadingFile filename)
48  method load_root ~root =
49   if not (MathView.load_root obj ~root:((root : Gdome.element)#as_Element)) then
50    raise ErrorLoadingDOM
51  method unload = MathView.unload obj
52  method select element = MathView.select obj ((element : Gdome.element)#as_Element)
53  method unselect element = MathView.unselect obj ((element : Gdome.element)#as_Element)
54  method is_selected element = MathView.is_selected obj ((element : Gdome.element)#as_Element)
55  method get_element_at x y = option_element_of_option (MathView.get_element_at obj x y)
56  method structure_changed element = MathView.structure_changed obj ((element : Gdome.element)#as_Element)
57  method attribute_changed element ~name = MathView.attribute_changed obj ((element : Gdome.element)#as_Element) ((name : Gdome.domString)#as_DOMString)
58  method get_bounding_box = MathView.get_bounding_box obj
59  method get_size = MathView.get_size obj
60  method get_top = MathView.get_top obj
61  method set_top x y  = MathView.set_top obj x y
62  method set_adjustments adj1 adj2 = MathView.set_adjustments obj (GData.as_adjustment adj1) (GData.as_adjustment adj2)
63  method get_adjustments =
64    let hadj, vadj = MathView.get_adjustments obj in
65    new GData.adjustment hadj, new GData.adjustment vadj
66  method get_buffer = MathView.get_buffer obj
67  method set_font_size = MathView.set_font_size obj
68  method get_font_size = MathView.get_font_size obj
69  method set_log_verbosity = MathView.set_log_verbosity obj
70  method get_log_verbosity = MathView.get_log_verbosity obj
71 end
72
73 class math_view_signals obj = object
74   inherit GObj.widget_signals_impl obj
75   inherit math_view__g_meta_dom_sigs
76 end
77
78 class math_view obj = object
79   inherit math_view_skel (obj : Gtk_mathview.math_view obj)
80   method connect = new math_view_signals obj
81 end
82
83 let math_view ?hadjustment ?vadjustment ?font_size ?log_verbosity =
84   GtkBase.Widget.size_params ~cont:(
85   OgtkMathViewProps.pack_return
86     (fun p -> OgtkMathViewProps.set_params (new math_view (MathView.create p)) ~font_size ~log_verbosity)) []
87 ;;