X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Flablgtkmathview%2FgMathView.ml;h=3687c043b22d4d54cbbc72da1f327970f6f01be8;hb=1c7fb836e2af4f2f3d18afd0396701f2094265ff;hp=63a3c234ad998fedfd1e138f9d179f707ff2deca;hpb=5a7485a8f24e457fd4cc091f24c48f3cb8d11fca;p=helm.git diff --git a/helm/DEVEL/lablgtkmathview/gMathView.ml b/helm/DEVEL/lablgtkmathview/gMathView.ml index 63a3c234a..3687c043b 100644 --- a/helm/DEVEL/lablgtkmathview/gMathView.ml +++ b/helm/DEVEL/lablgtkmathview/gMathView.ml @@ -1,4 +1,5 @@ -(* Copyright (C) 2000, Luca Padovani . +(* Copyright (C) 2000-2003, Luca Padovani , + * Claudio Sacerdoti Coen . * * This file is part of lablgtkmathview, the Ocaml binding * for the GtkMathView widget. @@ -32,60 +33,95 @@ exception ErrorWritingFile of string;; exception ErrorLoadingDOM;; exception NoSelection;; +let option_element_of_option = + function + None -> None + | Some v -> Some (new Gdome.element v) + class math_view_signals obj = object inherit GContainer.container_signals obj - method clicked = + method click = + let module S = GtkSignal in + let new_click = + let new_marshaller f x y = + MathView.Signals.click.S.marshaller + (fun e s -> f (option_element_of_option e) s) x y + in + { S.name = "click"; S.classe = `math_view; + S.marshaller = new_marshaller } + in + GtkSignal.connect ~sgn:new_click obj ~after + method select_begin = + let module S = GtkSignal in + let new_select_begin = + let new_marshaller f x y = + MathView.Signals.select_begin.S.marshaller + (fun e s -> f (option_element_of_option e) s) x y + in + { S.name = "select_begin"; S.classe = `math_view; + S.marshaller = new_marshaller } + in + GtkSignal.connect ~sgn:new_select_begin obj ~after + method select_over = + let module S = GtkSignal in + let new_select_over = + let new_marshaller f x y = + MathView.Signals.select_over.S.marshaller + (fun e s -> f (option_element_of_option e) s) x y + in + { S.name = "select_over"; S.classe = `math_view; + S.marshaller = new_marshaller } + in + GtkSignal.connect ~sgn:new_select_over obj ~after + method select_end = let module S = GtkSignal in - let new_clicked = + let new_select_end = let new_marshaller f x y = - MathView.Signals.clicked.S.marshaller - (fun e -> f (new Gdome.element e)) x y + MathView.Signals.select_end.S.marshaller + (fun e s -> f (option_element_of_option e) s) x y in - { S.name = "clicked"; S.marshaller = new_marshaller } + { S.name = "select_end"; S.classe = `math_view; + S.marshaller = new_marshaller } in - GtkSignal.connect ~sgn:new_clicked obj ~after - method selection_changed = + GtkSignal.connect ~sgn:new_select_end obj ~after + method select_abort = let module S = GtkSignal in - let new_selection_changed = + let new_select_abort = let new_marshaller f x y = - MathView.Signals.selection_changed.S.marshaller - (function None -> f None | Some e -> f (Some (new Gdome.element e))) x y + MathView.Signals.select_abort.S.marshaller + (fun () -> f ()) x y in - { S.name = "selection_changed"; S.marshaller = new_marshaller } + { S.name = "select_abort"; S.classe = `math_view; + S.marshaller = new_marshaller } in - GtkSignal.connect ~sgn:new_selection_changed obj ~after - method element_changed = + GtkSignal.connect ~sgn:new_select_abort obj ~after + method element_over = let module S = GtkSignal in - let new_element_changed = + let new_element_over = let new_marshaller f x y = - MathView.Signals.element_changed.S.marshaller - (function None -> f None | Some e -> f (Some (new Gdome.element e))) x y + MathView.Signals.element_over.S.marshaller + (fun e s -> f (option_element_of_option e) s) x y in - { S.name = "element_changed"; S.marshaller = new_marshaller } + { S.name = "element_over"; S.classe = `math_view; + S.marshaller = new_marshaller } in - GtkSignal.connect ~sgn:new_element_changed obj ~after + GtkSignal.connect ~sgn:new_element_over obj ~after end -class math_view obj = object +class math_view_skel obj = object inherit GContainer.container (obj : Gtk_mathview.math_view obj) - method connect = new math_view_signals obj - method load ~filename = - if not (MathView.load obj ~filename) then raise (ErrorLoadingFile filename) - method load_tree ~dom = - if not (MathView.load_tree obj ~dom:((dom : Gdome.document)#as_Document)) then + method freeze = MathView.freeze obj + method thaw = MathView.thaw obj + method load_uri ~filename = + if not (MathView.load_uri obj ~filename) then raise (ErrorLoadingFile filename) + method load_doc ~dom = + if not (MathView.load_doc obj ~dom:((dom : Gdome.document)#as_Document)) then raise ErrorLoadingDOM method unload = MathView.unload obj - method get_selection = - match MathView.get_selection obj with - None -> None - | Some element -> Some (new Gdome.element element) - method set_selection element = - let element = - match element with - None -> None - | Some element -> Some ((element : Gdome.element)#as_Element) - in - MathView.set_selection obj element + method select element = MathView.select obj ((element : Gdome.element)#as_Element) + method unselect element = MathView.unselect obj ((element : Gdome.element)#as_Element) + method is_selected element = MathView.is_selected obj ((element : Gdome.element)#as_Element) + method get_element_at x y = option_element_of_option (MathView.get_element_at obj x y) method get_width = MathView.get_width obj method get_height = MathView.get_height obj method get_top = MathView.get_top obj @@ -98,12 +134,11 @@ class math_view obj = object method get_vadjustment = new GData.adjustment (MathView.get_vadjustment obj) method get_buffer = MathView.get_buffer obj method get_frame = new GBin.frame (MathView.get_frame obj) + method get_drawing_area = new GMisc.drawing_area (MathView.get_drawing_area obj) method set_font_size = MathView.set_font_size obj method get_font_size = MathView.get_font_size obj method set_anti_aliasing = MathView.set_anti_aliasing obj method get_anti_aliasing = MathView.get_anti_aliasing obj - method set_kerning = MathView.set_kerning obj - method get_kerning = MathView.get_kerning obj method set_transparency = MathView.set_transparency obj method get_transparency = MathView.get_transparency obj method set_log_verbosity = MathView.set_log_verbosity obj @@ -117,17 +152,11 @@ class math_view obj = object if not result then raise (ErrorWritingFile filename) method get_font_manager_type = MathView.get_font_manager_type obj method set_font_manager_type ~fm_type = MathView.set_font_manager_type obj ~fm_type - method get_element = - match MathView.get_element obj with - None -> None - | Some element -> Some (new Gdome.element element) - method action_get_selected = MathView.action_get_selected obj - method action_set_selected = MathView.action_set_selected obj - method get_action = - match MathView.get_action obj with - None -> None - | Some ac -> Some (new Gdome.element ac) - method action_toggle = MathView.action_toggle obj +end + +class math_view obj = object + inherit math_view_skel (obj : Gtk_mathview.math_view obj) + method connect = new math_view_signals obj end let math_view ?adjustmenth ?adjustmentv ?font_size ?font_manager ?border_width