1 (* Copyright (C) 2000-2003, Luca Padovani <luca.padovani@cs.unibo.it>,
2 * Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>.
4 * This file is part of lablgtkmathview, the Ocaml binding
5 * for the GtkMathView widget.
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.
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.
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.
21 * For details, send a mail to the author.
30 open OgtkMathViewProps
33 exception ErrorLoadingFile of string;;
34 exception ErrorWritingFile of string;;
35 exception ErrorLoadingDOM;;
37 let option_element_of_option =
40 | Some v -> Some (new Gdome.element v)
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
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
73 class math_view_signals obj = object
74 inherit GObj.widget_signals_impl obj
75 inherit math_view__g_meta_dom_sigs
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
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)) []