X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Flablgtkmathview%2FgMathView.ml;h=0ec81f3f9ec53f937aaa0f3f90b5958bae5679b3;hb=4167cea65ca58897d1a3dbb81ff95de5074700cc;hp=41df006325aa26c0da20fbdd839e54518daa5a34;hpb=4a97b3700b140024e1783ac12501ad5dfa4be9b5;p=helm.git diff --git a/helm/DEVEL/lablgtkmathview/gMathView.ml b/helm/DEVEL/lablgtkmathview/gMathView.ml index 41df00632..0ec81f3f9 100644 --- a/helm/DEVEL/lablgtkmathview/gMathView.ml +++ b/helm/DEVEL/lablgtkmathview/gMathView.ml @@ -1,103 +1,103 @@ -(* Copyright (C) 2000, Luca Padovani . +(* Copyright (C) 2000-2005, + * Luca Padovani + * Claudio Sacerdoti Coen + * Stefano Zacchiroli * - * This file is part of lablgtkmathview, the Ocaml binding - * for the GtkMathView widget. + * This file is part of lablgtkmathview, the Ocaml binding for the + * GtkMathView widget. * * lablgtkmathview is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. * * lablgtkmathview is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with lablgtkmathview; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. * - * For details, send a mail to the author. + * For details, send a mail to the authors. *) -(*open Gaux*) -open Gtk +open Gaux open Gtk_mathview +open Gobject +open Gtk open GtkBase open GtkMathView +open OgtkMathViewProps open GObj -open Misc 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 - 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) +let option_document_of_option = + function + None -> None + | Some v -> Some (new Gdome.document v) + +class math_view_skel obj = object + inherit GObj.widget (obj : Gtk_mathview.math_view obj) + method event = new GObj.event_ops obj + 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_root ~root = + if not (MathView.load_root obj ~root:((root : Gdome.element)#as_Element)) 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 get_width = MathView.get_width obj - method get_height = MathView.get_height obj + 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_document = option_document_of_option (MathView.get_document obj) + method structure_changed element = MathView.structure_changed obj ((element : Gdome.element)#as_Element) + method attribute_changed element ~name = MathView.attribute_changed obj ((element : Gdome.element)#as_Element) ((name : Gdome.domString)#as_DOMString) + method get_bounding_box = MathView.get_bounding_box obj + method get_size = MathView.get_size 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 get_hadjustment = new GData.adjustment (MathView.get_hadjustment obj) - method get_vadjustment = new GData.adjustment (MathView.get_vadjustment obj) + 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_adjustments = + let hadj, vadj = MathView.get_adjustments obj in + new GData.adjustment hadj, new GData.adjustment vadj method get_buffer = MathView.get_buffer obj - method get_frame = new GFrame.frame (MathView.get_frame 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 + method set_t1_opaque_mode = MathView.set_t1_opaque_mode obj + method get_t1_opaque_mode = MathView.get_t1_opaque_mode obj + method set_t1_anti_aliased_mode = MathView.set_t1_anti_aliased_mode obj + method get_t1_anti_aliased_mode = MathView.get_t1_anti_aliased_mode obj +end + +class math_view_signals obj = object + inherit GObj.widget_signals_impl obj + inherit math_view__g_meta_dom_sigs 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 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.Widget.size_params ~cont:( + OgtkMathViewProps.pack_return + (fun p -> OgtkMathViewProps.set_params (new math_view (MathView.create p)) ~font_size ~log_verbosity)) [] + +let add_configuration_path = GtkMathView.add_configuration_path +