From 278d9954e80f952f7cde793e33e01bacce1cd40c Mon Sep 17 00:00:00 2001 From: Luca Padovani Date: Mon, 6 Oct 2003 09:01:48 +0000 Subject: [PATCH] * upgrade to lablgtk2 --- helm/DEVEL/lablgtkmathview/.depend | 22 +-- helm/DEVEL/lablgtkmathview/Makefile.in | 17 ++- helm/DEVEL/lablgtkmathview/gMathView.ml | 130 ++-------------- helm/DEVEL/lablgtkmathview/gMathView.mli | 24 +-- helm/DEVEL/lablgtkmathview/gMathViewAux.ml | 53 +------ helm/DEVEL/lablgtkmathview/gMathViewAux.mli | 14 +- helm/DEVEL/lablgtkmathview/gtkMathView.ml | 149 ++++--------------- helm/DEVEL/lablgtkmathview/gtk_mathview.ml | 2 +- helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c | 111 +++++--------- helm/DEVEL/lablgtkmathview/test/test.ml | 117 ++------------- 10 files changed, 138 insertions(+), 501 deletions(-) diff --git a/helm/DEVEL/lablgtkmathview/.depend b/helm/DEVEL/lablgtkmathview/.depend index 9d1c6ed82..186c66f3a 100644 --- a/helm/DEVEL/lablgtkmathview/.depend +++ b/helm/DEVEL/lablgtkmathview/.depend @@ -1,10 +1,14 @@ -gMathView.cmo: gtkMathView.cmo gtk_mathview.cmo gMathView.cmi -gMathView.cmx: gtkMathView.cmx gtk_mathview.cmx gMathView.cmi -gMathViewAux.cmo: gMathView.cmi gtkMathView.cmo gtk_mathview.cmo \ - gMathViewAux.cmi -gMathViewAux.cmx: gMathView.cmx gtkMathView.cmx gtk_mathview.cmx \ - gMathViewAux.cmi -gtkMathView.cmo: gtk_mathview.cmo -gtkMathView.cmx: gtk_mathview.cmx +gMathView.cmo: gtkMathView.cmo gtk_mathview.cmo ogtkMathViewProps.cmo \ + gMathView.cmi +gMathView.cmx: gtkMathView.cmx gtk_mathview.cmx ogtkMathViewProps.cmx \ + gMathView.cmi +gMathViewAux.cmo: gMathView.cmi gtkMathView.cmo gMathViewAux.cmi +gMathViewAux.cmx: gMathView.cmx gtkMathView.cmx gMathViewAux.cmi +gtkMathView.cmo: gtkMathViewProps.cmo gtk_mathview.cmo +gtkMathView.cmx: gtkMathViewProps.cmx gtk_mathview.cmx +gtkMathViewProps.cmo: gtk_mathview.cmo +gtkMathViewProps.cmx: gtk_mathview.cmx +ogtkMathViewProps.cmo: gtkMathViewProps.cmo +ogtkMathViewProps.cmx: gtkMathViewProps.cmx gMathView.cmi: gtk_mathview.cmo -gMathViewAux.cmi: gMathView.cmi +gMathViewAux.cmi: gMathView.cmi gtk_mathview.cmo diff --git a/helm/DEVEL/lablgtkmathview/Makefile.in b/helm/DEVEL/lablgtkmathview/Makefile.in index 8607be867..38846e83f 100644 --- a/helm/DEVEL/lablgtkmathview/Makefile.in +++ b/helm/DEVEL/lablgtkmathview/Makefile.in @@ -1,10 +1,12 @@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ INCLUDEDIR = @OCAML_INCLUDE_DIR@ +PROPCC = /home/luca/builds/lablgtk2/src/propcc PREFIX = OBJECTS_C = ml_gtk_mathview.o -OBJECTS = gtk_mathview.cmo gtkMathView.cmo gMathView.cmo gMathViewAux.cmo -OBJECTS_OPT = gtkMathView.cmx gtk_mathview.cmx gMathView.cmx gMathViewAux.cmx +OBJECTS = gtkMathViewProps.cmo ogtkMathViewProps.cmo gtk_mathview.cmo gtkMathView.cmo gMathView.cmo gMathViewAux.cmo +OBJECTS_OPT = gtkMathViewProps.cmx ogtkMathViewProps.cmx gtkMathView.cmx gtk_mathview.cmx gMathView.cmx gMathViewAux.cmx +GENERATED_FILES = gtkMathViewProps.ml ogtkMathViewProps.ml INST = \ META gMathView.mli gMathView.cmi gtkMathView.cmi gtk_mathview.cmi \ gMathViewAux.cmi gMathViewAux.mli @@ -15,7 +17,7 @@ DIST_FILES = \ configure lablgtkmathview.spec lablgtkmathview.spec.in DIST_DIR = $(PACKAGE)-$(VERSION) DOC_FILES = AUTHORS COPYING ChangeLog NEWS README LICENSE -REQUIRES = gdome2 lablgtk +REQUIRES = gdome2 lablgtk2 PREDICATES = SHARED_LIBS = @GDOME_LIBS@ @GTKMATHVIEW_LIBS@ -lmlgdome @@ -54,6 +56,8 @@ deb: dist (cd $(DIST_DIR)/ && debuild) rm -rf $(DIST_DIR) +$(GENERATED_FILES): gtkMathView.props + ml_gtk_mathview.o: ml_gtk_mathview.c gcc -c -I$(INCLUDEDIR) -fPIC `ocamlfind query -i-format lablgtk` @GTKMATHVIEW_CFLAGS@ @GDOME_CFLAGS@ `ocamlfind query -i-format gdome2` $< @@ -66,7 +70,10 @@ ml_gtk_mathview.o: ml_gtk_mathview.c .ml.cmx: $(OCAMLOPT) -package "$(REQUIRES)" -predicates "$(PREDICATES)" -c $< -depend: *.ml *.mli +%Props.ml o%Props.ml: %.props $(PROPCC) + $(PROPCC) $< + +depend: *.ml *.mli $(GENERATED_FILES) $(OCAMLDEP) *.ml *.mli >.depend include .depend @@ -107,7 +114,7 @@ uninstall: fi clean: - rm -f *.[ao] *.cm[iaxo] *.cmxa *.so + rm -f *.[ao] *.cm[iaxo] *.cmxa *.so $(GENERATED_FILES) cd $(TESTDIR) ; make clean rm -rf $(TMPDIR) diff --git a/helm/DEVEL/lablgtkmathview/gMathView.ml b/helm/DEVEL/lablgtkmathview/gMathView.ml index 3687c043b..ce7edcf10 100644 --- a/helm/DEVEL/lablgtkmathview/gMathView.ml +++ b/helm/DEVEL/lablgtkmathview/gMathView.ml @@ -22,92 +22,23 @@ *) 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 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 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_select_end = - let new_marshaller f x y = - MathView.Signals.select_end.S.marshaller - (fun e s -> f (option_element_of_option e) s) x y - in - { S.name = "select_end"; S.classe = `math_view; - S.marshaller = new_marshaller } - in - GtkSignal.connect ~sgn:new_select_end obj ~after - method select_abort = - let module S = GtkSignal in - let new_select_abort = - let new_marshaller f x y = - MathView.Signals.select_abort.S.marshaller - (fun () -> f ()) x y - in - { S.name = "select_abort"; S.classe = `math_view; - S.marshaller = new_marshaller } - in - GtkSignal.connect ~sgn:new_select_abort obj ~after - method element_over = - let module S = GtkSignal in - let new_element_over = - let new_marshaller f x y = - MathView.Signals.element_over.S.marshaller - (fun e s -> f (option_element_of_option e) s) x y - in - { S.name = "element_over"; S.classe = `math_view; - S.marshaller = new_marshaller } - in - GtkSignal.connect ~sgn:new_element_over obj ~after -end - class math_view_skel obj = object inherit GContainer.container (obj : Gtk_mathview.math_view obj) method freeze = MathView.freeze obj @@ -125,59 +56,30 @@ class math_view_skel obj = object 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_transparency = MathView.set_transparency obj - method get_transparency = MathView.get_transparency 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 + +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 + 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 - ?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 +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)) [] ;; diff --git a/helm/DEVEL/lablgtkmathview/gMathView.mli b/helm/DEVEL/lablgtkmathview/gMathView.mli index 5ffffa4be..1fb5b821d 100644 --- a/helm/DEVEL/lablgtkmathview/gMathView.mli +++ b/helm/DEVEL/lablgtkmathview/gMathView.mli @@ -24,12 +24,12 @@ exception ErrorLoadingFile of string exception ErrorWritingFile of string exception ErrorLoadingDOM -exception NoSelection class math_view_signals : - ([> `container | `widget | `base | `math_view] as 'b) Gtk.obj -> + ([> `container | `gtk | `mathview | `widget] as 'b) Gtk.obj -> object ('a) inherit GContainer.container_signals + val after: bool val obj: 'b Gtk.obj method click : callback:(Gdome.element option -> int -> unit) -> GtkSignal.id @@ -51,31 +51,18 @@ class math_view_skel : inherit GContainer.container method freeze : unit method thaw : unit - method export_to_postscript : - ?width:int -> - ?height:int -> - ?x_margin:int -> - ?y_margin:int -> - ?disable_colors:bool -> filename:string -> unit -> unit - method get_anti_aliasing : bool method get_buffer : Gdk.pixmap - method get_font_manager_type : [ `font_manager_gtk | `font_manager_t1] method get_font_size : int - method get_frame : GBin.frame method get_drawing_area : GMisc.drawing_area method get_hadjustment : GData.adjustment method get_height : int method get_log_verbosity : int method get_top : int * int - method get_transparency : bool method get_vadjustment : GData.adjustment method get_width : int method load_uri : filename:string -> unit method load_doc : dom:Gdome.document -> unit method set_adjustments : GData.adjustment -> GData.adjustment -> unit - method set_anti_aliasing : bool -> unit - method set_font_manager_type : - fm_type:[ `font_manager_gtk | `font_manager_t1] -> unit method set_font_size : int -> unit method set_log_verbosity : int -> unit method select : Gdome.element -> unit @@ -83,7 +70,6 @@ class math_view_skel : method get_element_at : int -> int -> Gdome.element option method is_selected : Gdome.element -> bool method set_top : int -> int -> unit - method set_transparency : bool -> unit method unload : unit val obj : 'a end @@ -96,10 +82,10 @@ class math_view : end val math_view : - ?adjustmenth:GData.adjustment -> - ?adjustmentv:GData.adjustment -> + ?hadjustment:GData.adjustment -> + ?vadjustment:GData.adjustment -> ?font_size:int -> - ?font_manager:[ `font_manager_gtk | `font_manager_t1] -> + ?log_verbosity:int -> ?border_width:int -> ?width:int -> ?height:int -> diff --git a/helm/DEVEL/lablgtkmathview/gMathViewAux.ml b/helm/DEVEL/lablgtkmathview/gMathViewAux.ml index 928e21965..84f34b5bf 100644 --- a/helm/DEVEL/lablgtkmathview/gMathViewAux.ml +++ b/helm/DEVEL/lablgtkmathview/gMathViewAux.ml @@ -188,29 +188,10 @@ class single_selection_math_view obj = end ;; -let single_selection_math_view ?adjustmenth ?adjustmentv ?font_size ?font_manager ?border_width - ?width ?height ?packing ?show () = - let w = - GtkMathView.MathView.create - ?adjustmenth:(Gaux.may_map ~f:GData.as_adjustment adjustmenth) - ?adjustmentv:(Gaux.may_map ~f:GData.as_adjustment adjustmentv) - () - in - GtkBase.Container.set w ?border_width ?width ?height; - let mathview = - GObj.pack_return (new single_selection_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 +let single_selection_math_view ?hadjustment ?vadjustment ?font_size ?log_verbosity = + GtkBase.Container.make_params ~cont:( + OgtkMathViewProps.pack_return + (fun p -> OgtkMathViewProps.set_params (new single_selection_math_view (GtkMathViewProps.MathView.create p)) ~font_size ~log_verbosity)) [] ;; class multi_selection_math_view_signals obj @@ -304,26 +285,8 @@ class multi_selection_math_view obj = end ;; -let multi_selection_math_view ?adjustmenth ?adjustmentv ?font_size ?font_manager ?border_width - ?width ?height ?packing ?show () = - let w = - GtkMathView.MathView.create - ?adjustmenth:(Gaux.may_map ~f:GData.as_adjustment adjustmenth) - ?adjustmentv:(Gaux.may_map ~f:GData.as_adjustment adjustmentv) - () - in - GtkBase.Container.set w ?border_width ?width ?height; - let mathview = GObj.pack_return (new multi_selection_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 +let multi_selection_math_view ?hadjustment ?vadjustment ?font_size ?log_verbosity = + GtkBase.Container.make_params ~cont:( + OgtkMathViewProps.pack_return + (fun p -> OgtkMathViewProps.set_params (new multi_selection_math_view (GtkMathViewProps.MathView.create p)) ~font_size ~log_verbosity)) [] ;; - diff --git a/helm/DEVEL/lablgtkmathview/gMathViewAux.mli b/helm/DEVEL/lablgtkmathview/gMathViewAux.mli index edcf15635..d8eb283cc 100644 --- a/helm/DEVEL/lablgtkmathview/gMathViewAux.mli +++ b/helm/DEVEL/lablgtkmathview/gMathViewAux.mli @@ -22,7 +22,7 @@ *) class single_selection_math_view_signals : - ([> `container | `widget | `base | `math_view] as 'b) Gtk.obj -> + ([> `container | `gtk | `mathview | `widget] as 'b) Gtk.obj -> ((Gdome.element option -> unit) -> unit) -> object inherit GMathView.math_view_signals @@ -40,10 +40,10 @@ class single_selection_math_view : end val single_selection_math_view : - ?adjustmenth:GData.adjustment -> - ?adjustmentv:GData.adjustment -> + ?hadjustment:GData.adjustment -> + ?vadjustment:GData.adjustment -> ?font_size:int -> - ?font_manager:[ `font_manager_gtk | `font_manager_t1] -> + ?log_verbosity:int -> ?border_width:int -> ?width:int -> ?height:int -> @@ -64,10 +64,10 @@ class multi_selection_math_view : end val multi_selection_math_view : - ?adjustmenth:GData.adjustment -> - ?adjustmentv:GData.adjustment -> + ?hadjustment:GData.adjustment -> + ?vadjustment:GData.adjustment -> ?font_size:int -> - ?font_manager:[ `font_manager_gtk | `font_manager_t1] -> + ?log_verbosity:int -> ?border_width:int -> ?width:int -> ?height:int -> diff --git a/helm/DEVEL/lablgtkmathview/gtkMathView.ml b/helm/DEVEL/lablgtkmathview/gtkMathView.ml index 2420c94c1..50de7a72f 100644 --- a/helm/DEVEL/lablgtkmathview/gtkMathView.ml +++ b/helm/DEVEL/lablgtkmathview/gtkMathView.ml @@ -21,155 +21,66 @@ * For details, send a mail to the author. *) -open Gtk open Gtk_mathview +open Gaux +open Gobject +open Gtk open Tags +open GtkMathViewProps open GtkBase -open Gpointer - -external gdome_element_of_boxed_option : - Gpointer.boxed option -> TElement.t = - "ml_gtk_math_view_gdome_element_of_boxed_option" -external gdome_element_option_of_boxed_option : - Gpointer.boxed option -> TElement.t option = - "ml_gtk_math_view_gdome_element_option_of_boxed_option" +external _gtkmathview_init : unit -> unit = "ml_gtk_mathview_init" +let () = _gtkmathview_init () module MathView = struct - exception NoSelection - - let cast w : math_view obj = Object.try_cast w "GtkMathView" - external create : Gtk.adjustment optobj -> Gtk.adjustment optobj -> - math_view obj = "ml_gtk_math_view_new" - let create ~adjustmenth ~adjustmentv () = - create (optboxed adjustmenth) (optboxed adjustmentv) - external freeze : [>`math_view] obj -> unit = + include MathView + external freeze : [>`mathview] obj -> unit = "ml_gtk_math_view_freeze" - external thaw : [>`math_view] obj -> unit = + external thaw : [>`mathview] obj -> unit = "ml_gtk_math_view_thaw" - external load_uri : [>`math_view] obj -> filename:string -> bool = + external load_uri : [>`mathview] obj -> filename:string -> bool = "ml_gtk_math_view_load_uri" - external load_doc : [>`math_view] obj -> dom:[> `Document] GdomeT.t -> bool = + external load_doc : [>`mathview] obj -> dom:[> `Document] GdomeT.t -> bool = "ml_gtk_math_view_load_doc" - external unload : [>`math_view] obj -> unit = + external unload : [>`mathview] obj -> unit = "ml_gtk_math_view_unload" external select : - [>`math_view] obj -> [> `Element] GdomeT.t -> unit = + [>`mathview] obj -> [> `Element] GdomeT.t -> unit = "ml_gtk_math_view_select" external unselect : - [>`math_view] obj -> [> `Element] GdomeT.t -> unit = + [>`mathview] obj -> [> `Element] GdomeT.t -> unit = "ml_gtk_math_view_unselect" external is_selected : - [>`math_view] obj -> [> `Element] GdomeT.t -> bool = + [>`mathview] obj -> [> `Element] GdomeT.t -> bool = "ml_gtk_math_view_is_selected" external get_element_at : - [> `math_view] obj -> int -> int -> TElement.t option = + [> `mathview] obj -> int -> int -> TElement.t option = "ml_gtk_math_view_get_element_at" - external get_width : [>`math_view] obj -> int = + (* beginning of prop-like methods *) + external get_width : [>`mathview] obj -> int = "ml_gtk_math_view_get_width" - external get_height : [>`math_view] obj -> int = + external get_height : [>`mathview] obj -> int = "ml_gtk_math_view_get_height" - external get_top : [>`math_view] obj -> (int * int) = + external get_top : [>`mathview] obj -> (int * int) = "ml_gtk_math_view_get_top" - external set_top : [>`math_view] obj -> int -> int -> unit = + external set_top : [>`mathview] obj -> int -> int -> unit = "ml_gtk_math_view_set_top" - external set_adjustments : [>`math_view] obj -> Gtk.adjustment obj -> Gtk.adjustment obj -> unit = + external set_adjustments : [>`mathview] obj -> Gtk.adjustment obj -> Gtk.adjustment obj -> unit = "ml_gtk_math_view_set_adjustments" - external get_hadjustment : [>`math_view] obj -> Gtk.adjustment obj = + external get_hadjustment : [>`mathview] obj -> Gtk.adjustment obj = "ml_gtk_math_view_get_hadjustment" - external get_vadjustment : [>`math_view] obj -> Gtk.adjustment obj = + external get_vadjustment : [>`mathview] obj -> Gtk.adjustment obj = "ml_gtk_math_view_get_vadjustment" - external get_buffer : [>`math_view] obj -> Gdk.pixmap = + external get_buffer : [>`mathview] obj -> Gdk.pixmap = "ml_gtk_math_view_get_buffer" - external get_frame : [>`math_view] obj -> Gtk.frame obj = - "ml_gtk_math_view_get_frame" - external get_drawing_area : [>`math_view] obj -> Gtk.drawing_area obj = + external get_drawing_area : [>`mathview] obj -> Gtk.drawing_area obj = "ml_gtk_math_view_get_drawing_area" - external set_font_size : [>`math_view] obj -> int -> unit = + external set_font_size : [>`mathview] obj -> int -> unit = "ml_gtk_math_view_set_font_size" - external get_font_size : [>`math_view] obj -> int = + external get_font_size : [>`mathview] obj -> int = "ml_gtk_math_view_get_font_size" - external set_anti_aliasing : [>`math_view] obj -> bool -> unit = - "ml_gtk_math_view_set_anti_aliasing" - external get_anti_aliasing : [>`math_view] obj -> bool = - "ml_gtk_math_view_get_anti_aliasing" - external set_transparency : [>`math_view] obj -> bool -> unit = - "ml_gtk_math_view_set_transparency" - external get_transparency : [>`math_view] obj -> bool = - "ml_gtk_math_view_get_transparency" - external set_log_verbosity : [>`math_view] obj -> int -> unit = + external set_log_verbosity : [>`mathview] obj -> int -> unit = "ml_gtk_math_view_set_log_verbosity" - external get_log_verbosity : [>`math_view] obj -> int = + external get_log_verbosity : [>`mathview] obj -> int = "ml_gtk_math_view_get_log_verbosity" - external export_to_postscript : - [>`math_view] obj -> width:int -> height:int -> x_margin:int -> y_margin:int -> disable_colors:bool -> filename:string -> bool = - "ml_gtk_math_view_export_to_postscript_bytecode" "ml_gtk_math_view_export_to_postscript_native" - external get_font_manager_type : [>`math_view] obj -> - [`font_manager_gtk | `font_manager_t1] = - "ml_gtk_math_view_get_font_manager_type" - external set_font_manager_type : [>`math_view] obj -> - fm_type:[`font_manager_gtk | `font_manager_t1] -> unit = - "ml_gtk_math_view_set_font_manager_type" - - module Signals = struct - open GtkSignal - - let click : ([>`math_view],_) t = - let marshal_click f _ = - function - [GtkArgv.POINTER element; GtkArgv.INT state] -> - f (gdome_element_option_of_boxed_option element) state - | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_click" - in - { name = "click"; classe = `math_view; marshaller = marshal_click } - - let element_over : ([>`math_view],_) t = - let marshal_element_over f _ = - function - [GtkArgv.POINTER element; GtkArgv.INT state] -> - f (gdome_element_option_of_boxed_option element) state - | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_element_over" - in - { name = "element_over"; classe = `math_view; - marshaller = marshal_element_over } - - let select_begin : ([>`math_view],_) t = - let marshal_select_begin f _ = - function - [GtkArgv.POINTER element; GtkArgv.INT state] -> - f (gdome_element_option_of_boxed_option element) state - | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_select_begin" - in - { name = "select_begin"; classe = `math_view; - marshaller = marshal_select_begin } - - let select_over : ([>`math_view],_) t = - let marshal_select_over f _ = - function - [GtkArgv.POINTER element; GtkArgv.INT state] -> - f (gdome_element_option_of_boxed_option element) state - | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_select_over" - in - { name = "select_over"; classe = `math_view; - marshaller = marshal_select_over } - - let select_end : ([>`math_view],_) t = - let marshal_select_end f _ = - function - [GtkArgv.POINTER element; GtkArgv.INT state] -> - f (gdome_element_option_of_boxed_option element) state - | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_select_end" - in - { name = "select_end"; classe = `math_view; - marshaller = marshal_select_end } - - let select_abort : ([>`math_view],_) t = - let marshal_select_abort f _ = - function - [] -> f () - | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_select_abort" - in - { name = "select_abort"; classe = `math_view; - marshaller = marshal_select_abort } - end end diff --git a/helm/DEVEL/lablgtkmathview/gtk_mathview.ml b/helm/DEVEL/lablgtkmathview/gtk_mathview.ml index 5472acbe5..a5d366194 100644 --- a/helm/DEVEL/lablgtkmathview/gtk_mathview.ml +++ b/helm/DEVEL/lablgtkmathview/gtk_mathview.ml @@ -21,4 +21,4 @@ * For details, send a mail to the author. *) -type math_view = [`widget|`container|`bin|`eventbox|`math_view|`base] +type math_view = [Gtk.event_box|`mathview] diff --git a/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c b/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c index 9a7f98fcf..51fded25e 100644 --- a/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c +++ b/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c @@ -22,63 +22,56 @@ */ #include -#include -#include + +#include #include + #include #include #include #include #include - -#include -#include +#include +#include #include #include #include #include +#include +#include +#include #include +#include #include -#define GtkMathView_val(val) check_cast(GTK_MATH_VIEW,val) - -#define FontManagerId_val(val) Int_val(val) -#define Val_FontManagerId(val) Val_int(val) +/* Init all */ -/* As ML_1, but the result is optional */ -#define OML_1(cname, conv1, conv) \ -value ml_##cname (value arg1) { return Val_option_ptr((cname (conv1 (arg1))),conv); } -/* As ML_3, but the result is optional */ -#define OML_3(cname, conv1, conv2, conv3, conv) \ -value ml_##cname (value arg1, value arg2, value arg3) { return Val_option_ptr((cname (conv1 (arg1), conv2 (arg2), conv3 (arg3))),conv); } -/* As ML_2, but the second argument is optional */ -#define ML_2O(cname, conv1, conv2, conv) \ -value ml_##cname (value arg1, value arg2) \ -{ return conv (cname (conv1(arg1), ptr_val_option(arg2,conv2))); } - -FontManagerId -font_manager_id_of_value(value v) +CAMLprim value ml_gtk_mathview_init(value unit) { - if (v == hash_variant("font_manager_gtk")) return FONT_MANAGER_GTK; - else if (v == hash_variant("font_manager_t1")) return FONT_MANAGER_T1; - else assert(0); + /* Since these are declared const, must force gcc to call them! */ + GType t = gtk_math_view_get_type(); + return Val_GType(t); } -value -value_of_font_manager_id(FontManagerId id) -{ - switch (id) { - case FONT_MANAGER_GTK: - return hash_variant("font_manager_gtk"); - case FONT_MANAGER_T1: - return hash_variant("font_manager_t1"); - default: - assert(0); - break; - } -} +#define GtkMathView_val(val) check_cast(GTK_MATH_VIEW,val) + +//##################################### +// +//#define FontManagerId_val(val) Int_val(val) +//#define Val_FontManagerId(val) Val_int(val) +// +///* As ML_1, but the result is optional */ +//#define OML_1(cname, conv1, conv) \ +//value ml_##cname (value arg1) { return Val_option_ptr((cname (conv1 (arg1))),conv); } +///* As ML_3, but the result is optional */ +#define OML_3(cname, conv1, conv2, conv3, conv) \ +value ml_##cname (value arg1, value arg2, value arg3) { return Val_option_ptr((cname (conv1 (arg1), conv2 (arg2), conv3 (arg3))),conv); } +///* As ML_2, but the second argument is optional */ +//#define ML_2O(cname, conv1, conv2, conv) \ +//value ml_##cname (value arg1, value arg2) \ +//{ return conv (cname (conv1(arg1), ptr_val_option(arg2,conv2))); } value Val_Element_ref(GdomeElement* elem) { @@ -91,7 +84,7 @@ value Val_Element_ref(GdomeElement* elem) return Val_Element(elem); } -ML_2 (gtk_math_view_new,GtkAdjustment_val, GtkAdjustment_val, Val_GtkWidget_sink) +OML_3 (gtk_math_view_get_element_at, GtkMathView_val, Int_val, Int_val, Val_Element) ML_1 (gtk_math_view_freeze, GtkMathView_val, Unit) ML_1 (gtk_math_view_thaw, GtkMathView_val, Unit) ML_2 (gtk_math_view_load_uri, GtkMathView_val, String_val, Val_bool) @@ -100,7 +93,9 @@ ML_1 (gtk_math_view_unload, GtkMathView_val, Unit) ML_2 (gtk_math_view_select, GtkMathView_val, Element_val, Unit) ML_2 (gtk_math_view_unselect, GtkMathView_val, Element_val, Unit) ML_2 (gtk_math_view_is_selected, GtkMathView_val, Element_val, Val_bool) -OML_3 (gtk_math_view_get_element_at, GtkMathView_val, Int_val, Int_val, Val_Element) +/* +ML_2 (gtk_math_view_new,GtkAdjustment_val, GtkAdjustment_val, Val_GtkWidget_sink) +*/ ML_1 (gtk_math_view_get_width, GtkMathView_val, Val_int) ML_1 (gtk_math_view_get_height, GtkMathView_val, Val_int) ML_3 (gtk_math_view_set_top, GtkMathView_val, Int_val, Int_val, Unit) @@ -108,46 +103,11 @@ ML_3 (gtk_math_view_set_adjustments, GtkMathView_val, GtkAdjustment_val, GtkAdju ML_1 (gtk_math_view_get_hadjustment, GtkMathView_val, Val_GtkWidget) ML_1 (gtk_math_view_get_vadjustment, GtkMathView_val, Val_GtkWidget) ML_1 (gtk_math_view_get_buffer, GtkMathView_val, Val_GdkPixmap) -ML_1 (gtk_math_view_get_frame, GtkMathView_val, Val_GtkWidget) ML_1 (gtk_math_view_get_drawing_area, GtkMathView_val, Val_GtkWidget) ML_2 (gtk_math_view_set_font_size, GtkMathView_val, Int_val, Unit) ML_1 (gtk_math_view_get_font_size, GtkMathView_val, Val_int) -ML_2 (gtk_math_view_set_anti_aliasing, GtkMathView_val, Bool_val, Unit) -ML_1 (gtk_math_view_get_anti_aliasing, GtkMathView_val, Val_bool) -ML_2 (gtk_math_view_set_transparency, GtkMathView_val, Bool_val, Unit) -ML_1 (gtk_math_view_get_transparency, GtkMathView_val, Val_bool) ML_2 (gtk_math_view_set_log_verbosity, GtkMathView_val, Int_val, Unit) ML_1 (gtk_math_view_get_log_verbosity, GtkMathView_val, Val_int) -ML_2 (gtk_math_view_set_font_manager_type, GtkMathView_val, font_manager_id_of_value, Unit) -ML_1 (gtk_math_view_get_font_manager_type, GtkMathView_val, value_of_font_manager_id) - -value -ml_gtk_math_view_export_to_postscript_native(value arg1, - value w, value h, value x0, value y0, value disable_colors, value arg2) -{ - CAMLparam5(arg1,w,h,x0,y0); - CAMLxparam2(disable_colors, arg2); - - char *filename; - FILE *fd; - int res; - filename = String_val (arg2); - if ((fd = fopen(filename, "w"))) { - gtk_math_view_export_to_postscript(GtkMathView_val (arg1), - Int_val(w), Int_val(h), Int_val(x0), Int_val(y0), Bool_val(disable_colors), fd); - fclose (fd); - res = 1; - } else { - fprintf(stderr, "Error opening file %s for writing\n", filename); - res = 0; - } - CAMLreturn (Val_bool(res)); -} - -value ml_gtk_math_view_export_to_postscript_bytecode (value* arg, int argn) -{ - return ml_gtk_math_view_export_to_postscript_native(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6]); -} value ml_gtk_math_view_get_top (value arg1) { @@ -216,4 +176,3 @@ value ml_gtk_math_view_gdome_element_option_of_boxed_option (value arg1) CAMLreturn(res); } - diff --git a/helm/DEVEL/lablgtkmathview/test/test.ml b/helm/DEVEL/lablgtkmathview/test/test.ml index 936f962b5..e6bfc9d1d 100644 --- a/helm/DEVEL/lablgtkmathview/test/test.ml +++ b/helm/DEVEL/lablgtkmathview/test/test.ml @@ -161,42 +161,6 @@ let click mathview (element : Gdome.element option) _ = ;; -let activate_t1 mathview () = - mathview#set_font_manager_type ~fm_type:`font_manager_t1; - print_string "WIDGET SET WITH T1 FONTS\n" ; - flush stdout -;; - -let activate_gtk mathview () = - mathview#set_font_manager_type ~fm_type:`font_manager_gtk ; - print_string "WIDGET SET WITH GTK FONTS\n" ; - flush stdout -;; - -let get_font_manager_type mathview () = - print_string "CURRENT FONT MANAGER TYPE: "; - begin - match mathview#get_font_manager_type with - | `font_manager_t1 -> print_string "T1" - | `font_manager_gtk -> print_string "GTK" - end; - print_newline(); - flush stdout -;; - -let get_transparency mathview () = - print_string ("CURRENT TRANSPARENCY: " ^ - (if mathview#get_transparency then "ON" else "OFF") ^ "\n") ; - flush stdout -;; - -let set_transparency mathview () = - mathview#set_transparency (not mathview#get_transparency) ; - print_string "TRANSPARENCY CHANGED\n" ; - flush stdout -;; - - let load_uri mathview () = mathview#load_uri ~filename:"test.xml" ; print_string "load: SEEMS TO WORK\n" ; @@ -215,7 +179,7 @@ let test_get_selection mathview () = Some element -> element#get_tagName#to_string | None -> "no selection!" in - print_string ("get_selection: " ^ selection ^ "\n") ; + print_string ("selection: " ^ selection ^ "\n") ; flush stdout ;; @@ -264,18 +228,18 @@ let unload mathview () = ;; let get_width mathview () = - print_string ("get_width: " ^ string_of_int (mathview#get_width) ^ "\n") ; + print_string ("width: " ^ string_of_int (mathview#get_width) ^ "\n") ; flush stdout ;; let get_height mathview () = - print_string ("get_height: " ^ string_of_int (mathview#get_height) ^ "\n") ; + print_string ("height: " ^ string_of_int (mathview#get_height) ^ "\n") ; flush stdout ;; let get_top mathview () = let (x,y) = mathview#get_top in - print_string ("get_top: ("^ string_of_int x ^ "," ^ string_of_int y ^ ")\n") ; + print_string ("top: ("^ string_of_int x ^ "," ^ string_of_int y ^ ")\n") ; flush stdout ;; @@ -298,14 +262,14 @@ let set_adjustments mathview () = let get_hadjustment mathview () = let adj = mathview#get_hadjustment in adj#set_value ((adj#lower +. adj#upper) /. 2.0) ; - print_string "get_hadjustment: SEEM TO WORK\n" ; + print_string "hadjustment: SEEM TO WORK\n" ; flush stdout ;; let get_vadjustment mathview () = let adj = mathview#get_vadjustment in adj#set_value ((adj#lower +. adj#upper) /. 2.0) ; - print_string "get_vadjustment: SEEM TO WORK\n" ; + print_string "vadjustment: SEEM TO WORK\n" ; flush stdout ;; @@ -313,14 +277,7 @@ let get_buffer mathview () = let buffer = mathview#get_buffer in Gdk.Draw.rectangle buffer (Gdk.GC.create buffer) ~x:0 ~y:0 ~width:50 ~height:50 ~filled:true () ; - print_string "get_buffer: SEEMS TO WORK (hint: force the widget redrawing)\n"; - flush stdout -;; - -let get_frame mathview () = - let frame = mathview#get_frame in - frame#set_shadow_type `NONE ; - print_string "get_frame: SEEMS TO WORK\n" ; + print_string "buffer: SEEMS TO WORK (hint: force the widget redrawing)\n"; flush stdout ;; @@ -331,38 +288,10 @@ let set_font_size mathview () = ;; let get_font_size mathview () = - print_string ("get_font_size: " ^ string_of_int (mathview#get_font_size) ^ "\n") ; - flush stdout -;; - -let set_anti_aliasing mathview () = - mathview#set_anti_aliasing true ; - print_string "set_anti_aliasing: ON\n" ; - flush stdout -;; - -let get_anti_aliasing mathview () = - print_string ("get_anti_aliasing: " ^ - (match mathview#get_anti_aliasing with true -> "ON" | false -> "OFF") ^ - "\n") ; + print_string ("font_size: " ^ string_of_int (mathview#get_font_size) ^ "\n") ; flush stdout ;; - (* -let set_kerning mathview () = - mathview#set_kerning true ; - print_string "set_kerning: ON\n" ; - flush stdout -;; - -let get_kerning mathview () = - print_string ("get_kerning: " ^ - (match mathview#get_kerning with true -> "ON" | false -> "OFF") ^ - "\n") ; - flush stdout -;; -*) - let set_log_verbosity mathview () = mathview#set_log_verbosity 3 ; print_string "set_log_verbosity: NOW IS 3\n" ; @@ -370,18 +299,12 @@ let set_log_verbosity mathview () = ;; let get_log_verbosity mathview () = - print_string ("get_log_verbosity: " ^ + print_string ("log_verbosity: " ^ string_of_int mathview#get_log_verbosity ^ "\n") ; flush stdout ;; -let export_to_postscript (mathview : GMathViewAux.multi_selection_math_view) () = - mathview#export_to_postscript ~filename:"test.ps" (); - print_string "expor_to_postscript: SEEMS TO WORK (hint: look at test.ps)\n"; - flush stdout -;; - let x_coord = ref 0 ;; @@ -409,10 +332,9 @@ let vbox = GPack.vbox ~packing:main_window#add () in let sw = GBin.scrolled_window ~width:50 ~height:50 ~packing:vbox#pack () in let mathview= GMathViewAux.multi_selection_math_view ~packing:sw#add ~width:50 ~height:50 () in let table = GPack.table ~rows:6 ~columns:5 ~packing:vbox#pack () in -let button_gtk=GButton.button ~label:"activate Gtk fonts" ~packing:(table#attach ~left:0 ~top:0) () in let button_load = GButton.button ~label:"load" ~packing:(table#attach ~left:1 ~top:0) () in let button_unload = GButton.button ~label:"unload" ~packing:(table#attach ~left:2 ~top:0) () in -let button_get_selection = GButton.button ~label:"get_selection" ~packing:(table#attach ~left:3 ~top:0) () in +let button_selection = GButton.button ~label:"get_selection" ~packing:(table#attach ~left:3 ~top:0) () in let button_set_selection = GButton.button ~label:"set_selection" ~packing:(table#attach ~left:4 ~top:0) () in let button_add_selection = GButton.button ~label:"add_selection" ~packing:(table#attach ~left:3 ~top:3) () in let button_reset_selections = GButton.button ~label:"reset_selections" ~packing:(table#attach ~left:4 ~top:3) () in @@ -424,26 +346,17 @@ let button_set_adjustments = GButton.button ~label:"set_adjustments" ~packing:(t let button_get_hadjustment = GButton.button ~label:"get_hadjustment" ~packing:(table#attach ~left:0 ~top:2) () in let button_get_vadjustment = GButton.button ~label:"get_vadjustment" ~packing:(table#attach ~left:1 ~top:2) () in let button_get_buffer = GButton.button ~label:"get_buffer" ~packing:(table#attach ~left:2 ~top:2) () in -let button_get_frame = GButton.button ~label:"get_frame" ~packing:(table#attach ~left:3 ~top:2) () in let button_set_font_size = GButton.button ~label:"set_font_size" ~packing:(table#attach ~left:4 ~top:2) () in let button_get_font_size = GButton.button ~label:"get_font_size" ~packing:(table#attach ~left:0 ~top:3) () in -let button_set_anti_aliasing = GButton.button ~label:"set_anti_aliasing" ~packing:(table#attach ~left:1 ~top:3) () in -let button_get_anti_aliasing = GButton.button ~label:"get_anti_aliasing" ~packing:(table#attach ~left:2 ~top:3) () in let button_set_log_verbosity = GButton.button ~label:"set_log_verbosity" ~packing:(table#attach ~left:0 ~top:4) () in let button_get_log_verbosity = GButton.button ~label:"get_log_verbosity" ~packing:(table#attach ~left:1 ~top:4) () in -let button_export_to_postscript = GButton.button ~label:"export_to_postscript" ~packing:(table#attach ~left:2 ~top:4) () in -let button_t1 = GButton.button ~label:"activate T1 fonts" ~packing:(table#attach ~left:3 ~top:4) () in -let button_get_font_manager_type = GButton.button ~label:"get_font_manager" ~packing:(table#attach ~left:4 ~top:4) () in -let button_get_transparency = GButton.button ~label:"get_transparency" ~packing:(table#attach ~left:0 ~top:5) () in -let button_set_transparency = GButton.button ~label:"set_transparency" ~packing:(table#attach ~left:1 ~top:5) () in let button_load_dom = GButton.button ~label:"load from DOM" ~packing:(table#attach ~left:2 ~top:5) () in let button_get_element_at = GButton.button ~label:"get_element_at" ~packing:(table#attach ~left:3 ~top:5) () in let button_get_drawing_area = GButton.button ~label:"get_drawing_area" ~packing:(table#attach ~left:4 ~top:5) () in (* Signals connection *) -ignore(button_gtk#connect#clicked (activate_gtk mathview)) ; ignore(button_load#connect#clicked (load_uri mathview)) ; ignore(button_unload#connect#clicked (unload mathview)) ; -ignore(button_get_selection#connect#clicked (test_get_selection mathview)) ; +ignore(button_selection#connect#clicked (test_get_selection mathview)) ; ignore(button_set_selection#connect#clicked (test_set_selection mathview)) ; ignore(button_add_selection#connect#clicked (test_add_selection mathview)) ; ignore(button_reset_selections#connect#clicked (test_reset_selections mathview)) ; @@ -455,18 +368,10 @@ ignore(button_set_adjustments#connect#clicked (set_adjustments mathview)) ; ignore(button_get_hadjustment#connect#clicked (get_hadjustment mathview)) ; ignore(button_get_vadjustment#connect#clicked (get_vadjustment mathview)) ; ignore(button_get_buffer#connect#clicked (get_buffer mathview)) ; -ignore(button_get_frame#connect#clicked (get_frame mathview)) ; ignore(button_set_font_size#connect#clicked (set_font_size mathview)) ; ignore(button_get_font_size#connect#clicked (get_font_size mathview)) ; -ignore(button_set_anti_aliasing#connect#clicked (set_anti_aliasing mathview)) ; -ignore(button_get_anti_aliasing#connect#clicked (get_anti_aliasing mathview)) ; ignore(button_set_log_verbosity#connect#clicked (set_log_verbosity mathview)) ; ignore(button_get_log_verbosity#connect#clicked (get_log_verbosity mathview)) ; -ignore(button_export_to_postscript#connect#clicked (export_to_postscript mathview)) ; -ignore(button_t1#connect#clicked (activate_t1 mathview)) ; -ignore(button_get_font_manager_type#connect#clicked (get_font_manager_type mathview)) ; -ignore(button_get_transparency#connect#clicked (get_transparency mathview)) ; -ignore(button_set_transparency#connect#clicked (set_transparency mathview)) ; ignore(mathview#connect#click (click mathview)) ; ignore(mathview#connect#selection_changed (selection_changed mathview)); ignore(mathview#connect#element_over (element_over mathview)) ; -- 2.39.2