]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/lablgtk_gtkmathview/lablgtk-20001129_gtkmathview-0.2.2/gMathView.ml
- the mathql interpreter is not helm-dependent any more
[helm.git] / helm / DEVEL / lablgtk_gtkmathview / lablgtk-20001129_gtkmathview-0.2.2 / gMathView.ml
1 open Gaux
2 open Gtk
3 open Gtk_mathview
4 open GtkBase
5 open GtkMathView
6 open GObj
7
8 exception ErrorLoadingFile of string;;
9 exception ErrorWritingFile of string;;
10 exception NoSelection;;
11
12 class math_view_signals obj = object
13   inherit GContainer.container_signals obj
14   method clicked = GtkSignal.connect ~sgn:MathView.Signals.clicked obj ~after
15   method jump = GtkSignal.connect ~sgn:MathView.Signals.jump obj ~after
16   method selection_changed =
17   GtkSignal.connect ~sgn:MathView.Signals.selection_changed obj ~after
18 end
19
20 class math_view obj = object
21  inherit GContainer.container (obj : Gtk_mathview.math_view obj)
22  method connect = new math_view_signals obj
23  method load ~filename =
24   if not (MathView.load obj ~filename) then raise (ErrorLoadingFile filename)
25  method unload = MathView.unload obj
26  method get_selection = MathView.get_selection obj
27  method set_selection (node : Ominidom.o_mDOMNode option) = MathView.set_selection obj node
28  method get_width = MathView.get_width obj
29  method get_height = MathView.get_height obj
30  method get_top = MathView.get_top obj
31  method set_top = MathView.set_top obj
32  method set_adjustments =
33   fun adj1 adj2 ->
34    MathView.set_adjustments obj (GData.as_adjustment adj1)
35    (GData.as_adjustment adj2)
36  method get_hadjustment = new GData.adjustment (MathView.get_hadjustment obj)
37  method get_vadjustment = new GData.adjustment (MathView.get_vadjustment obj)
38  method get_buffer = MathView.get_buffer obj
39  method get_frame = new GBin.frame (MathView.get_frame obj)
40  method set_font_size = MathView.set_font_size obj
41  method get_font_size = MathView.get_font_size obj
42  method set_anti_aliasing = MathView.set_anti_aliasing obj
43  method get_anti_aliasing = MathView.get_anti_aliasing obj
44  method set_kerning = MathView.set_kerning obj
45  method get_kerning = MathView.get_kerning obj
46  method set_log_verbosity = MathView.set_log_verbosity obj
47  method get_log_verbosity = MathView.get_log_verbosity obj
48  method export_to_postscript
49         ?(width = 595) ?(height = 822) ?(x_margin = 72) ?(y_margin = 72)
50         ?(disable_colors = false) ~filename () =
51   let result = MathView.export_to_postscript obj
52         ~width ~height ~x_margin ~y_margin ~disable_colors ~filename
53   in
54   if not result then raise (ErrorWritingFile filename)
55  method get_font_manager_type = MathView.get_font_manager_type obj
56  method set_font_manager_type ~fm_type = MathView.set_font_manager_type obj ~fm_type
57 end
58
59 let math_view ?adjustmenth ?adjustmentv ?font_size ?font_manager ?border_width
60  ?width ?height ?packing ?show () =
61  let w =
62    MathView.create
63     ?adjustmenth:(may_map ~f:GData.as_adjustment adjustmenth)
64     ?adjustmentv:(may_map ~f:GData.as_adjustment adjustmentv)
65     ()
66  in
67   Container.set w ?border_width ?width ?height;
68  let mathview = pack_return (new math_view w) ~packing ~show in
69  begin
70     match font_size with
71     | Some size -> mathview#set_font_size size
72     | None      -> ()
73   end;
74   begin
75     match font_manager with
76     | Some manager -> mathview#set_font_manager_type ~fm_type:manager
77     | None         -> ()
78   end;
79   mathview
80 ;;