From ee18ff6db8d49339230b4212e145964b12c5a523 Mon Sep 17 00:00:00 2001 From: Luca Padovani Date: Wed, 29 Jan 2003 18:15:56 +0000 Subject: [PATCH] * some small bug fixes * updated licenses in all source files --- helm/DEVEL/lablgtkmathview/ChangeLog | 5 ++- helm/DEVEL/lablgtkmathview/LICENSE | 3 +- helm/DEVEL/lablgtkmathview/gMathView.ml | 4 +- helm/DEVEL/lablgtkmathview/gMathView.mli | 4 +- helm/DEVEL/lablgtkmathview/gMathViewAux.ml | 3 +- helm/DEVEL/lablgtkmathview/gMathViewAux.mli | 3 +- helm/DEVEL/lablgtkmathview/gtkMathView.ml | 6 ++- helm/DEVEL/lablgtkmathview/gtk_mathview.ml | 3 +- helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c | 39 ++++++++++++++++++-- helm/DEVEL/lablgtkmathview/test/test.ml | 34 ++++++++--------- 10 files changed, 75 insertions(+), 29 deletions(-) diff --git a/helm/DEVEL/lablgtkmathview/ChangeLog b/helm/DEVEL/lablgtkmathview/ChangeLog index 2635a4b00..19ce76012 100644 --- a/helm/DEVEL/lablgtkmathview/ChangeLog +++ b/helm/DEVEL/lablgtkmathview/ChangeLog @@ -1,3 +1,6 @@ +* 0.4.1 + - Upgraded to GtkMathView 0.4.[0,1] + * 0.3.0 - - Upgraded to GtkMathView 3.0 + - Upgraded to GtkMathView 0.3.0 - Now based on the gmetadom (alias gdome2) binding to GDOMe Level 2 diff --git a/helm/DEVEL/lablgtkmathview/LICENSE b/helm/DEVEL/lablgtkmathview/LICENSE index 3781bdacc..691e4e01c 100644 --- a/helm/DEVEL/lablgtkmathview/LICENSE +++ b/helm/DEVEL/lablgtkmathview/LICENSE @@ -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. diff --git a/helm/DEVEL/lablgtkmathview/gMathView.ml b/helm/DEVEL/lablgtkmathview/gMathView.ml index d1028d189..fd505f1dc 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. @@ -120,6 +121,7 @@ class math_view_skel obj = object 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 diff --git a/helm/DEVEL/lablgtkmathview/gMathView.mli b/helm/DEVEL/lablgtkmathview/gMathView.mli index e52a7a484..d8a5dd616 100644 --- a/helm/DEVEL/lablgtkmathview/gMathView.mli +++ b/helm/DEVEL/lablgtkmathview/gMathView.mli @@ -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. @@ -77,6 +78,7 @@ class math_view_skel : method set_log_verbosity : int -> unit method select : Gdome.element -> unit method unselect : Gdome.element -> unit + 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 diff --git a/helm/DEVEL/lablgtkmathview/gMathViewAux.ml b/helm/DEVEL/lablgtkmathview/gMathViewAux.ml index 4d10bf395..ba12fdfdf 100644 --- a/helm/DEVEL/lablgtkmathview/gMathViewAux.ml +++ b/helm/DEVEL/lablgtkmathview/gMathViewAux.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. diff --git a/helm/DEVEL/lablgtkmathview/gMathViewAux.mli b/helm/DEVEL/lablgtkmathview/gMathViewAux.mli index e63c41173..edcf15635 100644 --- a/helm/DEVEL/lablgtkmathview/gMathViewAux.mli +++ b/helm/DEVEL/lablgtkmathview/gMathViewAux.mli @@ -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. diff --git a/helm/DEVEL/lablgtkmathview/gtkMathView.ml b/helm/DEVEL/lablgtkmathview/gtkMathView.ml index dbb1463b7..4af1ae782 100644 --- a/helm/DEVEL/lablgtkmathview/gtkMathView.ml +++ b/helm/DEVEL/lablgtkmathview/gtkMathView.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. @@ -61,6 +62,9 @@ module MathView = struct external is_selected : [>`math_view] obj -> [> `Element] GdomeT.t -> bool = "ml_gtk_math_view_is_selected" + external get_element_at : + [> `math_view] obj -> int -> int -> TElement.t option = + "ml_gtk_math_view_get_element_at" external get_width : [>`math_view] obj -> int = "ml_gtk_math_view_get_width" external get_height : [>`math_view] obj -> int = diff --git a/helm/DEVEL/lablgtkmathview/gtk_mathview.ml b/helm/DEVEL/lablgtkmathview/gtk_mathview.ml index 27ca4c45c..5472acbe5 100644 --- a/helm/DEVEL/lablgtkmathview/gtk_mathview.ml +++ b/helm/DEVEL/lablgtkmathview/gtk_mathview.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. diff --git a/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c b/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c index 7e260cd97..1f6b19b9f 100644 --- a/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c +++ b/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c @@ -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. @@ -46,10 +47,13 @@ #define FontManagerId_val(val) Int_val(val) #define Val_FontManagerId(val) Val_int(val) -// As ML_1, but the result is optional +/* 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_2, but the second argument is optional +/* 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))); } @@ -76,6 +80,17 @@ value_of_font_manager_id(FontManagerId id) } } +value Val_Element_ref(GdomeElement* elem) +{ + if (elem != NULL) + { + GdomeException exc = 0; + gdome_el_ref(elem, &exc); + g_assert(exc == 0); + } + return Val_Element(elem); +} + ML_2 (gtk_math_view_new,GtkAdjustment_val, GtkAdjustment_val, Val_GtkWidget_sink) ML_1 (gtk_math_view_freeze, GtkMathView_val, Unit) ML_1 (gtk_math_view_thaw, GtkMathView_val, Unit) @@ -85,6 +100,7 @@ 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_ref) 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) @@ -140,10 +156,24 @@ value ml_gtk_math_view_get_top (value arg1) gtk_math_view_get_top(GtkMathView_val (arg1), &x, &y); result = alloc(2, 0); Store_field(result, 0, Val_int(x)); - Store_field(result, 0, Val_int(y)); + Store_field(result, 1, Val_int(y)); CAMLreturn (result); } +/* +value ml_gtk_math_view_get_element_coords (value arg1, value arg2) +{ + CAMLparam2(arg1, arg2); + CAMLlocal1 (result); + int x, y; + gtk_math_view_get_element_coords(GtkMathView_val (arg1), Element_val(arg2), &x, &y); + result = alloc(2, 0); + Store_field(result, 0, Val_int(x)); + Store_field(result, 1, Val_int(y)); + CAMLreturn (result); +} +*/ + value ml_gtk_math_view_gdome_element_of_boxed_option (value arg1) { CAMLparam1(arg1); @@ -192,3 +222,4 @@ 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 76b2856d3..0e8eca5cf 100644 --- a/helm/DEVEL/lablgtkmathview/test/test.ml +++ b/helm/DEVEL/lablgtkmathview/test/test.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. @@ -106,22 +107,6 @@ let click mathview (element : Gdome.element) _ = let module G = Gdome in if not (jump element) then if not (mathview#action_toggle element) then - (* - match mathview#get_action with - Some n -> - mathview#action_toggle ; - print_string ("current action selection: " ^ - string_of_int mathview#action_get_selected ^ "\n") ; - flush stdout ; - | None -> - print_string ("mouse is on: " ^ - (match (mathview#get_element : Gdome.element option) with - Some e -> e#get_tagName#to_string - | None -> "NO ELEMENT!\n" - ) ^ "\n") ; - print_endline ("clicked: " ^ element#get_tagName#to_string) ; - flush stdout - *) () ;; @@ -347,6 +332,19 @@ let export_to_postscript (mathview : GMathViewAux.multi_selection_math_view) () flush stdout ;; +let x_coord = ref 0 +;; + +let get_element_at mathview () = + begin + match mathview#get_element_at !x_coord 10 with + None -> print_string ("there is no element at " ^ (string_of_int !x_coord) ^ " 10\n") + | Some e -> print_string ("at " ^ (string_of_int !x_coord) ^ " 10 found element " ^ (e#get_nodeName#to_string) ^ "\n") + end ; + x_coord := !x_coord + 10 ; + flush stdout +;; + (* Widget creation *) let main_window = GWindow.window ~title:"GtkMathView test" () in let vbox = GPack.vbox ~packing:main_window#add () in @@ -381,6 +379,7 @@ let button_get_font_manager_type = GButton.button ~label:"get_font_manager" ~pac 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 (* Signals connection *) ignore(button_gtk#connect#clicked (activate_gtk mathview)) ; ignore(button_load#connect#clicked (load_uri mathview)) ; @@ -413,6 +412,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)) ; (* Main Loop *) main_window#show () ; GMain.Main.main () -- 2.39.2