From 30321de51742b359e6186b0388c183b2adb5e36a Mon Sep 17 00:00:00 2001 From: Luca Padovani Date: Tue, 27 Jul 2004 12:59:11 +0000 Subject: [PATCH] * update to version 0.6.4 of the widget * not tested --- helm/DEVEL/lablgtkmathview/configure.in | 6 ++-- helm/DEVEL/lablgtkmathview/gMathView.ml | 7 ++-- helm/DEVEL/lablgtkmathview/gMathView.mli | 5 ++- helm/DEVEL/lablgtkmathview/gtkMathView.ml | 13 ++++++-- helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c | 34 ++++++++++++++++++-- helm/DEVEL/lablgtkmathview/test/test.ml | 11 +++++-- helm/DEVEL/lablgtkmathview/test/test.xml | 2 +- 7 files changed, 63 insertions(+), 15 deletions(-) diff --git a/helm/DEVEL/lablgtkmathview/configure.in b/helm/DEVEL/lablgtkmathview/configure.in index b4ab4ff8b..26cd3f9b7 100644 --- a/helm/DEVEL/lablgtkmathview/configure.in +++ b/helm/DEVEL/lablgtkmathview/configure.in @@ -3,8 +3,8 @@ AC_INIT(gMathView.ml) PACKAGE=lablgtkmathview LABLGTKMATHVIEW_MAJOR_VERSION=0 -LABLGTKMATHVIEW_MINOR_VERSION=5 -LABLGTKMATHVIEW_MICRO_VERSION=1 +LABLGTKMATHVIEW_MINOR_VERSION=6 +LABLGTKMATHVIEW_MICRO_VERSION=2 LABLGTKMATHVIEW_VERSION=$LABLGTKMATHVIEW_MAJOR_VERSION.$LABLGTKMATHVIEW_MINOR_VERSION.$LABLGTKMATHVIEW_MICRO_VERSION VERSION=$LABLGTKMATHVIEW_VERSION @@ -12,7 +12,7 @@ PKG_CHECK_MODULES(GDOME, gdome2 >= 0.7.0,, AC_MSG_ERROR(could not find Gdome2)) AC_SUBST(GDOME_CFLAGS) AC_SUBST(GDOME_LIBS) -PKG_CHECK_MODULES(GTKMATHVIEW, gtkmathview >= 0.5.1,, AC_MSG_ERROR(could not find gtkmathview)) +PKG_CHECK_MODULES(GTKMATHVIEW, gtkmathview-gmetadom >= 0.6.2,, AC_MSG_ERROR(could not find gtkmathview-gmetadom)) AC_SUBST(GTKMATHVIEW_CFLAGS) AC_SUBST(GTKMATHVIEW_LIBS) diff --git a/helm/DEVEL/lablgtkmathview/gMathView.ml b/helm/DEVEL/lablgtkmathview/gMathView.ml index ce7edcf10..751674bbe 100644 --- a/helm/DEVEL/lablgtkmathview/gMathView.ml +++ b/helm/DEVEL/lablgtkmathview/gMathView.ml @@ -45,14 +45,17 @@ class math_view_skel obj = object 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 + 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 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 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_width = MathView.get_width obj method get_height = MathView.get_height obj method get_top = MathView.get_top obj diff --git a/helm/DEVEL/lablgtkmathview/gMathView.mli b/helm/DEVEL/lablgtkmathview/gMathView.mli index 1fb5b821d..62b31d35d 100644 --- a/helm/DEVEL/lablgtkmathview/gMathView.mli +++ b/helm/DEVEL/lablgtkmathview/gMathView.mli @@ -61,10 +61,13 @@ class math_view_skel : method get_vadjustment : GData.adjustment method get_width : int method load_uri : filename:string -> unit - method load_doc : dom:Gdome.document -> unit + method load_root : root:Gdome.element -> unit method set_adjustments : GData.adjustment -> GData.adjustment -> unit method set_font_size : int -> unit method set_log_verbosity : int -> unit + method structure_changed : Gdome.element -> unit + method attribute_changed : Gdome.element -> name:Gdome.domString -> unit + method get_bounding_box : int * int * int method select : Gdome.element -> unit method unselect : Gdome.element -> unit method get_element_at : int -> int -> Gdome.element option diff --git a/helm/DEVEL/lablgtkmathview/gtkMathView.ml b/helm/DEVEL/lablgtkmathview/gtkMathView.ml index 50de7a72f..e337bdf10 100644 --- a/helm/DEVEL/lablgtkmathview/gtkMathView.ml +++ b/helm/DEVEL/lablgtkmathview/gtkMathView.ml @@ -40,8 +40,8 @@ module MathView = struct "ml_gtk_math_view_thaw" external load_uri : [>`mathview] obj -> filename:string -> bool = "ml_gtk_math_view_load_uri" - external load_doc : [>`mathview] obj -> dom:[> `Document] GdomeT.t -> bool = - "ml_gtk_math_view_load_doc" + external load_root : [>`mathview] obj -> root:[> `Element] GdomeT.t -> bool = + "ml_gtk_math_view_load_root" external unload : [>`mathview] obj -> unit = "ml_gtk_math_view_unload" external select : @@ -53,6 +53,15 @@ module MathView = struct external is_selected : [>`mathview] obj -> [> `Element] GdomeT.t -> bool = "ml_gtk_math_view_is_selected" + external structure_changed : + [>`mathview] obj -> [> `Element] GdomeT.t -> unit = + "ml_gtk_math_view_structure_changed" + external attribute_changed : + [>`mathview] obj -> [> `Element] GdomeT.t -> name:TDOMString.t -> unit = + "ml_gtk_math_view_attribute_changed" + external get_bounding_box : + [>`mathview] obj -> (int * int * int) = + "ml_gtk_math_view_get_bounding_box" external get_element_at : [> `mathview] obj -> int -> int -> TElement.t option = "ml_gtk_math_view_get_element_at" diff --git a/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c b/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c index 51fded25e..41175584d 100644 --- a/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c +++ b/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c @@ -23,7 +23,7 @@ #include -#include +#include #include #include @@ -84,11 +84,13 @@ value Val_Element_ref(GdomeElement* elem) return Val_Element(elem); } -OML_3 (gtk_math_view_get_element_at, GtkMathView_val, Int_val, Int_val, Val_Element) +ML_2 (gtk_math_view_structure_changed, GtkMathView_val, Element_val, Unit) +ML_3 (gtk_math_view_attribute_changed, GtkMathView_val, Element_val, DOMString_val, Unit) +/* 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) -ML_2 (gtk_math_view_load_doc, GtkMathView_val, Document_val, Val_bool) +ML_2 (gtk_math_view_load_root, GtkMathView_val, Element_val, Val_bool) 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) @@ -109,6 +111,32 @@ ML_1 (gtk_math_view_get_font_size, GtkMathView_val, Val_int) 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) +value ml_gtk_math_view_get_element_at (value arg1, value arg2, value arg3) +{ + CAMLparam3(arg1, arg2, arg3); + CAMLlocal1 (result); + GdomeElement* el; + if (gtk_math_view_get_element_at(GtkMathView_val (arg1), Int_val(arg2), Int_val(arg3), &el, NULL, NULL)) + result = Val_option_ptr(el, Val_Element); + else + result = Val_unit; + CAMLreturn (result); +} + +value ml_gtk_math_view_get_bounding_box (value arg1) +{ + CAMLparam1(arg1); + CAMLlocal1 (result); + int width, height, depth; + GtkMathViewBoundingBox gbox; + gtk_math_view_get_bounding_box(GtkMathView_val (arg1), &gbox); + result = alloc(3, 0); + Store_field(result, 0, Val_int(gbox.width)); + Store_field(result, 1, Val_int(gbox.height)); + Store_field(result, 2, Val_int(gbox.depth)); + CAMLreturn (result); +} + value ml_gtk_math_view_get_top (value arg1) { CAMLparam1(arg1); diff --git a/helm/DEVEL/lablgtkmathview/test/test.ml b/helm/DEVEL/lablgtkmathview/test/test.ml index e6bfc9d1d..1c077846b 100644 --- a/helm/DEVEL/lablgtkmathview/test/test.ml +++ b/helm/DEVEL/lablgtkmathview/test/test.ml @@ -168,7 +168,7 @@ let load_uri mathview () = ;; let load_doc mathview () = - mathview#load_doc ~dom:((Gdome.domImplementation ())#createDocumentFromURI ~uri:"test.xml" ()) ; + mathview#load_root ~root:(((Gdome.domImplementation ())#createDocumentFromURI ~uri:"test.xml" ())#get_documentElement) ; print_string "load from DOM: SEEMS TO WORK\n" ; flush stdout ;; @@ -308,6 +308,7 @@ let get_log_verbosity mathview () = let x_coord = ref 0 ;; +(* let get_element_at mathview () = begin match mathview#get_element_at !x_coord 10 with @@ -317,6 +318,7 @@ let get_element_at mathview () = x_coord := !x_coord + 10 ; flush stdout ;; +*) let get_drawing_area mathview () = begin @@ -326,6 +328,9 @@ let get_drawing_area mathview () = flush stdout ;; +let _ = (GtkMain.Main.init ()) +;; + (* Widget creation *) let main_window = GWindow.window ~title:"GtkMathView test" () in let vbox = GPack.vbox ~packing:main_window#add () in @@ -351,7 +356,7 @@ let button_get_font_size = GButton.button ~label:"get_font_size" ~packing:(table 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_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_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_load#connect#clicked (load_uri mathview)) ; @@ -376,7 +381,7 @@ ignore(mathview#connect#click (click mathview)) ; ignore(mathview#connect#selection_changed (selection_changed mathview)); ignore(mathview#connect#element_over (element_over mathview)) ; ignore(button_load_dom#connect#clicked (load_doc mathview)) ; -ignore(button_get_element_at#connect#clicked (get_element_at mathview)) ; +(* ignore(button_get_element_at#connect#clicked (get_element_at mathview)) ; *) ignore(button_get_drawing_area#connect#clicked (get_drawing_area mathview)) ; (* Main Loop *) main_window#show () ; diff --git a/helm/DEVEL/lablgtkmathview/test/test.xml b/helm/DEVEL/lablgtkmathview/test/test.xml index a29bcdac0..9f3d906a7 100644 --- a/helm/DEVEL/lablgtkmathview/test/test.xml +++ b/helm/DEVEL/lablgtkmathview/test/test.xml @@ -11,7 +11,7 @@ - + It's a secret! -- 2.39.2