1 (* Copyright (C) 2000-2005,
2 * Luca Padovani <lpadovan@cs.unibo.it>
3 * Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>
4 * Stefano Zacchiroli <zacchiro@cs.unibo.it>
6 * This file is part of lablgtkmathview, the Ocaml binding for the
9 * lablgtkmathview is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
14 * lablgtkmathview is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with lablgtkmathview; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 * For details, send a mail to the authors.
33 open OgtkMathViewProps
36 exception ErrorLoadingFile of string;;
37 exception ErrorWritingFile of string;;
38 exception ErrorLoadingDOM;;
40 let option_element_of_option =
43 | Some v -> Some (new Gdome.element v)
45 let option_document_of_option =
48 | Some v -> Some (new Gdome.document v)
50 class math_view_skel obj = object
51 inherit GObj.widget (obj : Gtk_mathview.math_view obj)
52 method event = new GObj.event_ops obj
53 method freeze = MathView.freeze obj
54 method thaw = MathView.thaw obj
55 method load_uri ~filename =
56 if not (MathView.load_uri obj ~filename) then raise (ErrorLoadingFile filename)
57 method load_root ~root =
58 if not (MathView.load_root obj ~root:((root : Gdome.element)#as_Element)) then
60 method unload = MathView.unload obj
61 method select element = MathView.select obj ((element : Gdome.element)#as_Element)
62 method unselect element = MathView.unselect obj ((element : Gdome.element)#as_Element)
63 method is_selected element = MathView.is_selected obj ((element : Gdome.element)#as_Element)
64 method get_element_at x y = option_element_of_option (MathView.get_element_at obj x y)
65 method get_document = option_document_of_option (MathView.get_document obj)
66 method structure_changed element = MathView.structure_changed obj ((element : Gdome.element)#as_Element)
67 method attribute_changed element ~name = MathView.attribute_changed obj ((element : Gdome.element)#as_Element) ((name : Gdome.domString)#as_DOMString)
68 method get_bounding_box = MathView.get_bounding_box obj
69 method get_size = MathView.get_size obj
70 method get_top = MathView.get_top obj
71 method set_top x y = MathView.set_top obj x y
72 method set_adjustments adj1 adj2 = MathView.set_adjustments obj (GData.as_adjustment adj1) (GData.as_adjustment adj2)
73 method get_adjustments =
74 let hadj, vadj = MathView.get_adjustments obj in
75 new GData.adjustment hadj, new GData.adjustment vadj
76 method get_buffer = MathView.get_buffer obj
77 method set_font_size = MathView.set_font_size obj
78 method get_font_size = MathView.get_font_size obj
79 method set_log_verbosity = MathView.set_log_verbosity obj
80 method get_log_verbosity = MathView.get_log_verbosity obj
81 method set_t1_opaque_mode = MathView.set_t1_opaque_mode obj
82 method get_t1_opaque_mode = MathView.get_t1_opaque_mode obj
83 method set_t1_anti_aliased_mode = MathView.set_t1_anti_aliased_mode obj
84 method get_t1_anti_aliased_mode = MathView.get_t1_anti_aliased_mode obj
87 class math_view_signals obj = object
88 inherit GObj.widget_signals_impl obj
89 inherit math_view__g_meta_dom_sigs
92 class math_view obj = object
93 inherit math_view_skel (obj : Gtk_mathview.math_view obj)
94 method connect = new math_view_signals obj
97 let math_view ?hadjustment ?vadjustment ?font_size ?log_verbosity =
98 GtkBase.Widget.size_params ~cont:(
99 OgtkMathViewProps.pack_return
100 (fun p -> OgtkMathViewProps.set_params (new math_view (MathView.create p)) ~font_size ~log_verbosity)) []
102 let add_configuration_path = GtkMathView.add_configuration_path