X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Flablgtkmathview%2FgMathView.ml;h=ce7edcf10bca151dec471650b44f4c9b318f9a96;hb=bb236c2ac110124de92fa2d0fb2882d273a7f7eb;hp=b937831f7b353c19f875efe6791d8f7b08c73350;hpb=dfb99fda45c1cd87a7c2fedcebb987f3220e0516;p=helm.git diff --git a/helm/DEVEL/lablgtkmathview/gMathView.ml b/helm/DEVEL/lablgtkmathview/gMathView.ml index b937831f7..ce7edcf10 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. @@ -21,82 +22,64 @@ *) open Gaux -open Gtk open Gtk_mathview +open Gobject +open Gtk open GtkBase open GtkMathView +open OgtkMathViewProps open GObj exception ErrorLoadingFile of string;; exception ErrorWritingFile of string;; -exception NoSelection;; +exception ErrorLoadingDOM;; -class math_view_signals obj = object - inherit GContainer.container_signals obj - method clicked = GtkSignal.connect ~sgn:MathView.Signals.clicked obj ~after - method jump = GtkSignal.connect ~sgn:MathView.Signals.jump obj ~after - method selection_changed = - GtkSignal.connect ~sgn:MathView.Signals.selection_changed obj ~after -end +let option_element_of_option = + function + None -> None + | Some v -> Some (new Gdome.element v) -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 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 = MathView.get_selection obj - method set_selection (node : Ominidom.o_mDOMNode option) = MathView.set_selection obj node + 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 - method set_top = MathView.set_top obj - method set_adjustments = - fun adj1 adj2 -> - MathView.set_adjustments obj (GData.as_adjustment adj1) - (GData.as_adjustment adj2) + method set_top x y = MathView.set_top obj x y + method set_adjustments adj1 adj2 = MathView.set_adjustments obj (GData.as_adjustment adj1) (GData.as_adjustment adj2) method get_hadjustment = new GData.adjustment (MathView.get_hadjustment obj) 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_log_verbosity = MathView.set_log_verbosity obj method get_log_verbosity = MathView.get_log_verbosity obj - method export_to_postscript - ?(width = 595) ?(height = 822) ?(x_margin = 72) ?(y_margin = 72) - ?(disable_colors = false) ~filename () = - let result = MathView.export_to_postscript obj - ~width ~height ~x_margin ~y_margin ~disable_colors ~filename - in - 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 end -let math_view ?adjustmenth ?adjustmentv ?font_size ?font_manager ?border_width - ?width ?height ?packing ?show () = - let w = - MathView.create - ?adjustmenth:(may_map ~f:GData.as_adjustment adjustmenth) - ?adjustmentv:(may_map ~f:GData.as_adjustment adjustmentv) - () - in - Container.set w ?border_width ?width ?height; - let mathview = pack_return (new math_view w) ~packing ~show in - begin - match font_size with - | Some size -> mathview#set_font_size size - | None -> () - end; - begin - match font_manager with - | Some manager -> mathview#set_font_manager_type ~fm_type:manager - | None -> () - end; - mathview +class math_view_signals obj = object + inherit GContainer.container_signals_impl obj + inherit math_view_sigs +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 ?hadjustment ?vadjustment ?font_size ?log_verbosity = + GtkBase.Container.make_params ~cont:( + OgtkMathViewProps.pack_return + (fun p -> OgtkMathViewProps.set_params (new math_view (MathView.create p)) ~font_size ~log_verbosity)) [] ;;