+* 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
-(* Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+(* Copyright (C) 2000-2003, Luca Padovani <luca.padovani@cs.unibo.it>,
+ * Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>.
*
* This file is part of lablgtkmathview, the Ocaml binding
* for the GtkMathView widget.
-(* Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+(* Copyright (C) 2000-2003, Luca Padovani <luca.padovani@cs.unibo.it>,
+ * Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>.
*
* This file is part of lablgtkmathview, the Ocaml binding
* for the GtkMathView widget.
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
-(* Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+(* Copyright (C) 2000-2003, Luca Padovani <luca.padovani@cs.unibo.it>,
+ * Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>.
*
* This file is part of lablgtkmathview, the Ocaml binding
* for the GtkMathView widget.
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
-(* Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+(* Copyright (C) 2000-2003, Luca Padovani <luca.padovani@cs.unibo.it>,
+ * Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>.
*
* This file is part of lablgtkmathview, the Ocaml binding
* for the GtkMathView widget.
-(* Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+(* Copyright (C) 2000-2003, Luca Padovani <luca.padovani@cs.unibo.it>,
+ * Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>.
*
* This file is part of lablgtkmathview, the Ocaml binding
* for the GtkMathView widget.
-(* Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+(* Copyright (C) 2000-2003, Luca Padovani <luca.padovani@cs.unibo.it>,
+ * Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>.
*
* This file is part of lablgtkmathview, the Ocaml binding
* for the GtkMathView widget.
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 =
-(* Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+(* Copyright (C) 2000-2003, Luca Padovani <luca.padovani@cs.unibo.it>,
+ * Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>.
*
* This file is part of lablgtkmathview, the Ocaml binding
* for the GtkMathView widget.
-/* Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+/* Copyright (C) 2000-2003, Luca Padovani <luca.padovani@cs.unibo.it>,
+ * Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>.
*
* This file is part of lablgtkmathview, the Ocaml binding
* for the GtkMathView widget.
#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))); }
}
}
+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)
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)
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);
CAMLreturn(res);
}
+
-(* Copyright (C) 2000, Luca Padovani <luca.padovani@cs.unibo.it>.
+(* Copyright (C) 2000-2003, Luca Padovani <luca.padovani@cs.unibo.it>,
+ * Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>.
*
* This file is part of lablgtkmathview, the Ocaml binding
* for the GtkMathView widget.
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
- *)
()
;;
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
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)) ;
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 ()