*) ()
;;
+let selection_changed node =
+(*
+ print_string ("jump: " ^ s ^ "\n") ;
+ flush stdout
+*) ()
+;;
+
let clicked node =
(*
print_string "clicked: IT WORKS\n" ;
*) ()
;;
+let activate_t1 mathview sw () =
+ mathview :=
+ (GMathView.math_view ~packing:sw#add ~width:50 ~height:50
+ ~use_t1_lib:true ()) ;
+ ignore(!mathview#connect#jump jump) ;
+ ignore(!mathview#connect#clicked clicked) ;
+ ignore(!mathview#connect#selection_changed selection_changed) ;
+ print_string "WIDGET RECREATED WITH T1 FONTS ACTIVATED\n" ;
+;;
+
let load mathview () =
- mathview#load "test.xml" ;
+ !mathview#load "test.xml" ;
print_string "load: SEEMS TO WORK\n" ;
flush stdout
;;
let get_selection mathview () =
(*
let selection =
- match mathview#get_selection with
+ match !mathview#get_selection with
None -> "NO SELECTION"
| Some s -> s
in
;;
let unload mathview () =
- mathview#unload ;
+ !mathview#unload ;
print_string "unload: SEEMS TO WORK\n" ;
flush stdout
;;
-(*
-let dump mathview () =
- mathview#dump ;
- print_string "dump: SEEMS TO WORK\n" ;
- flush stdout
-;;
-*)
-
let get_width mathview () =
- print_string ("get_width: " ^ string_of_int (mathview#get_width) ^ "\n") ;
+ print_string ("get_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 ("get_height: " ^ string_of_int (!mathview#get_height) ^ "\n") ;
flush stdout
;;
let set_adjustments mathview () =
let adj1 = GData.adjustment () in
let adj2 = GData.adjustment () in
- mathview#set_adjustments adj1 adj2 ;
+ !mathview#set_adjustments adj1 adj2 ;
adj1#set_value ((adj1#lower +. adj1#upper) /. 2.0) ;
adj2#set_value ((adj2#lower +. adj2#upper) /. 2.0) ;
print_string "set_adjustments: SEEM TO WORK\n" ;
;;
let get_hadjustment mathview () =
- let adj = mathview#get_hadjustment in
+ let adj = !mathview#get_hadjustment in
adj#set_value ((adj#lower +. adj#upper) /. 2.0) ;
print_string "get_hadjustment: SEEM TO WORK\n" ;
flush stdout
;;
let get_vadjustment mathview () =
- let adj = mathview#get_vadjustment in
+ let adj = !mathview#get_vadjustment in
adj#set_value ((adj#lower +. adj#upper) /. 2.0) ;
print_string "get_vadjustment: SEEM TO WORK\n" ;
flush stdout
;;
let get_buffer mathview () =
- let buffer = mathview#get_buffer in
+ 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";
;;
let get_frame mathview () =
- let frame = mathview#get_frame in
+ let frame = !mathview#get_frame in
frame#set_shadow_type `NONE ;
print_string "get_frame: SEEMS TO WORK\n" ;
flush stdout
;;
let set_font_size mathview () =
- mathview#set_font_size 24 ;
+ !mathview#set_font_size 24 ;
print_string "set_font_size: FONT IS NOW 24\n" ;
flush stdout
;;
let main_window = GWindow.window ~title:"GtkMathView test" () in
let vbox = GPack.vbox ~packing:main_window#add () in
let sw = GBin.scrolled_window ~width:50 ~height:50 ~packing:vbox#pack () in
-(*let mathview = GMathView.math_view ~packing:sw#add_with_viewport ~width:50 ~height:50 () in*)
-let mathview = GMathView.math_view ~packing:sw#add ~width:50 ~height:50 () in
+let mathview= ref (GMathView.math_view ~packing:sw#add ~width:50 ~height:50 ()) in
let hbox = GPack.hbox ~packing:vbox#pack () in
+let button_t1=GButton.button ~label:"activate t1 fonts" ~packing:hbox#pack () in
let button_load = GButton.button ~label:"load" ~packing:hbox#pack () in
let button_get_selection = GButton.button ~label:"get_selection" ~packing:hbox#pack () in
let button_unload = GButton.button ~label:"unload" ~packing:hbox#pack () in
-(*let button_dump = GButton.button ~label:"dump" ~packing:hbox#pack () in*)
let button_get_width = GButton.button ~label:"get_width" ~packing:hbox#pack () in
let button_get_height = GButton.button ~label:"get_height" ~packing:hbox#pack () in
let button_set_adjustments = GButton.button ~label:"set_adjustments" ~packing:hbox#pack () in
let button_get_frame = GButton.button ~label:"get_frame" ~packing:hbox#pack () in
let button_set_font_size = GButton.button ~label:"set_font_size" ~packing:hbox#pack () in
(* Signals connection *)
+ignore(button_t1#connect#clicked (activate_t1 mathview sw)) ;
ignore(button_load#connect#clicked (load mathview)) ;
ignore(button_get_selection#connect#clicked (get_selection mathview)) ;
ignore(button_unload#connect#clicked (unload mathview)) ;
-(*ignore(button_dump#connect#clicked (dump mathview)) ;*)
ignore(button_get_width#connect#clicked (get_width mathview)) ;
ignore(button_get_height#connect#clicked (get_height mathview)) ;
ignore(button_set_adjustments#connect#clicked (set_adjustments 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(mathview#connect#jump jump) ;
-ignore(mathview#connect#clicked clicked) ;
+ignore(!mathview#connect#jump jump) ;
+ignore(!mathview#connect#clicked clicked) ;
+ignore(!mathview#connect#selection_changed selection_changed) ;
(* Main Loop *)
main_window#show () ;
GMain.Main.main ()