# Makefile for lablgtk_mathview.
-LABLGTKDIR = /usr/local/lib/ocaml/lablgtk
-MLFLAGS += -I $(LABLGTKDIR)
+LABLGTKDIR = /usr/lib/ocaml/lablgtk
+MINIDOMDIR = ./minidom
+MLFLAGS += -I $(LABLGTKDIR) -I $(MINIDOMDIR)
TARGETS = ml_gtk_mathview.o lablgtkmathview.cma
LIBDIR=/usr/lib/ocaml
BINDIR=/usr/bin
INSTALLDIR=/usr/lib/ocaml/lablgtk/mathview
-GTKCFLAGS=-I/usr/lib/glib/include -I/usr/X11R6/include -I/usr/lib/ocaml/lablgtk
+GTKCFLAGS=-I/usr/lib/glib/include -I/usr/X11R6/include -I/usr/include/libxml -I/usr/include -I/usr/local/include/gtkmathview -I/usr/lib/ocaml/lablgtk
GTKLIBS=-ccopt -L/usr/lib -ccopt -L/usr/X11R6/lib -cclib -lgtk -cclib -lgdk -ccopt -rdynamic -cclib -lgmodule -cclib -lglib -cclib -ldl -cclib -lXi -cclib -lXext -cclib -lX11 -cclib -lm
GTKMATHVIEWLIBS=-ccopt -L/usr/local/lib/gtkmathview -cclib -lgtkmathview
GNOMELIBS=
GETRANLIB = which ranlib 2>/dev/null | sed -e 's|.*/ranlib$$|!|' -e 's/^[^!]*$$/:/' -e 's/!/ranlib/'
ifdef USE_GNOME
-GTKGETCFLAGS = gtk-config --cflags`" -I"`gnome-config --includedir
+GTKGETCFLAGS = gtk-config --cflags`" -I"`gnome-config --includedir" "`xml-config --cflags`" "`gtkmathview-config --cflags
GNOMELIBS = `gnome-config --libs gtkxmhtml`
else
-GTKGETCFLAGS = gtk-config --cflags
+GTKGETCFLAGS = gtk-config --cflags`" "`xml-config --cflags`" "`gtkmathview-config --cflags
endif
GTKGETLIBS = gtk-config --libs
class math_view_signals obj = object
inherit GContainer.container_signals obj
- method jump = GtkSignal.connect ~sgn:MathView.Signals.jump obj ~after
method clicked = GtkSignal.connect ~sgn:MathView.Signals.clicked obj ~after
+ method jump = GtkSignal.connect ~sgn:MathView.Signals.jump obj ~after
+ method selection_changed =
+ GtkSignal.connect ~sgn:MathView.Signals.selection_changed obj ~after
end
class math_view obj = object
method connect = new math_view_signals obj
method load ~filename =
if not (MathView.load obj ~filename) then raise (ErrorLoadingFile filename)
- method get_selection = MathView.get_selection obj
method unload = MathView.unload obj
- method dump = MathView.dump obj
+ (*method dump = MathView.dump obj*)
+ method get_selection = MathView.get_selection obj
+ method set_selection = MathView.set_selection obj
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)
method get_buffer = MathView.get_buffer obj
method get_frame = new GBin.frame (MathView.get_frame obj)
method set_font_size = MathView.set_font_size obj
- (*method get_top = MathView.get_top obj
- method set_top = MathView.set_top 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_kerning = MathView.set_kerning obj
+ method get_kerning = MathView.get_kerning obj
+ method log_set_verbosity = MathView.log_set_verbosity obj
+ method log_get_verbosity = MathView.log_get_verbosity obj
+ method export_to_postscript = MathView.export_to_postscript obj
end
-let math_view ?adjustmenth ?adjustmentv ?border_width ?width ?height
- ?packing ?show ()
+let math_view ?adjustmenth ?adjustmentv ?(use_t1_lib=false) ?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)
+ ?use_t1_lib
()
in
Container.set w ?border_width ?width ?height;
open GtkBase
open Gpointer
+external mDOMNode_of_boxed_option : Gpointer.boxed option -> Minidom.mDOMNode =
+ "ml_gtk_math_view_mDOMNode_of_bodex_option"
+
module MathView = struct
let cast w : math_view obj = Object.try_cast w "GtkMathView"
- external create : Gtk.adjustment optobj -> Gtk.adjustment optobj ->
+ external create : Gtk.adjustment optobj -> Gtk.adjustment optobj -> bool ->
math_view obj = "ml_gtk_math_view_new"
- let create ~adjustmenth ~adjustmentv () =
- create (optboxed adjustmenth) (optboxed adjustmentv)
+ let create ~adjustmenth ~adjustmentv ~use_t1_lib () =
+ create (optboxed adjustmenth) (optboxed adjustmentv) use_t1_lib
external load : [>`math_view] obj -> filename:string -> bool =
"ml_gtk_math_view_load"
- external get_selection : [>`math_view] obj -> string option =
- "ml_gtk_math_view_get_selection"
external unload : [>`math_view] obj -> unit =
"ml_gtk_math_view_unload"
- external dump : [>`math_view] obj -> unit =
- "ml_gtk_math_view_dump"
+ (*external dump : [>`math_view] obj -> unit =
+ "ml_gtk_math_view_dump"*)
+ external get_selection : [>`math_view] obj -> Minidom.mDOMNode =
+ "ml_gtk_math_view_get_selection"
+ external set_selection : [>`math_view] obj -> Minidom.mDOMNode -> unit =
+ "ml_gtk_math_view_set_selection"
external get_width : [>`math_view] obj -> int =
"ml_gtk_math_view_get_width"
external get_height : [>`math_view] obj -> int =
"ml_gtk_math_view_get_height"
+ external get_top : [>`math_view] obj -> (int * int) =
+ "ml_gtk_math_view_get_top"
+ external set_top : [>`math_view] obj -> int -> int -> unit =
+ "ml_gtk_math_view_set_top"
external set_adjustments : [>`math_view] obj -> Gtk.adjustment obj -> Gtk.adjustment obj -> unit =
"ml_gtk_math_view_set_adjustments"
external get_hadjustment : [>`math_view] obj -> Gtk.adjustment obj =
"ml_gtk_math_view_get_frame"
external set_font_size : [>`math_view] obj -> int -> unit =
"ml_gtk_math_view_set_font_size"
- (*external get_top : [>`math_view] obj -> (int * int) =
- "ml_gtk_math_view_get_top"
- external set_top : [>`math_view] obj -> int -> int -> unit =
- "ml_gtk_math_view_set_top"*)
+ external get_font_size : [>`math_view] 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_kerning : [>`math_view] obj -> bool -> unit =
+ "ml_gtk_math_view_set_kerning"
+ external get_kerning : [>`math_view] obj -> bool =
+ "ml_gtk_math_view_get_kerning"
+ external log_set_verbosity : [>`math_view] obj -> int -> unit =
+ "ml_gtk_math_view_log_set_verbosity"
+ external log_get_verbosity : [>`math_view] obj -> int =
+ "ml_gtk_math_view_log_get_verbosity"
+ external export_to_postscript : [>`math_view] obj -> int =
+ "ml_gtk_math_view_export_to_postscript"
module Signals = struct
open GtkSignal
+ let clicked : ([>`math_view],_) t =
+ let marshal_clicked f _ =
+ function
+ [GtkArgv.POINTER node] -> f (mDOMNode_of_boxed_option node)
+ | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_clicked"
+ in
+ { name = "clicked"; marshaller = marshal_clicked }
+
let jump : ([>`math_view],_) t =
let marshal_jump f _ =
function
- [GtkArgv.STRING (Some str)] -> f str
+ [GtkArgv.POINTER node] -> f (mDOMNode_of_boxed_option node)
| _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_jump"
in
{ name = "jump"; marshaller = marshal_jump }
- let clicked : ([>`math_view],_) t =
- let marshal_clicked f _ =
+ let selection_changed : ([>`math_view],_) t =
+ let marshal_selection_changed f _ =
function
- [] -> f ()
- | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_clicked"
+ [GtkArgv.POINTER node] -> f (mDOMNode_of_boxed_option node)
+ | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_selection_changed"
in
- { name = "clicked"; marshaller = marshal_clicked }
+ { name = "selection_changed"; marshaller = marshal_selection_changed }
end
end
#include <ml_gtk.h>
#include <gtk_tags.h>
+#include "minidom/ml_minidom.h"
+
/* <CSC/>: Next row should be put in a .h of lablgtk. */
#define GtkAdjustment_val(val) check_cast(GTK_ADJUSTMENT,val)
#define GtkMathView_val(val) check_cast(GTK_MATH_VIEW,val)
-ML_2 (gtk_math_view_new,GtkAdjustment_val, GtkAdjustment_val,Val_GtkWidget_sink)
+ML_3 (gtk_math_view_new,GtkAdjustment_val, GtkAdjustment_val, Bool_val, Val_GtkWidget_sink)
ML_2 (gtk_math_view_load, GtkMathView_val, String_val, Val_bool)
ML_1 (gtk_math_view_unload, GtkMathView_val, Unit)
-ML_1 (gtk_math_view_dump, GtkMathView_val, Unit)
+/*ML_1 (gtk_math_view_dump, GtkMathView_val, Unit)*/
+ML_1 (gtk_math_view_get_selection, GtkMathView_val, Val_ptr)
+ML_2 (gtk_math_view_set_selection, GtkMathView_val, mDOMNode_val, Unit)
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)
+ML_3 (gtk_math_view_set_top, GtkMathView_val, Int_val, Int_val, Unit)
ML_3 (gtk_math_view_set_adjustments, GtkMathView_val, GtkAdjustment_val, GtkAdjustment_val, Unit)
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_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_kerning, GtkMathView_val, Bool_val, Unit)
+ML_1 (gtk_math_view_get_kerning, GtkMathView_val, Val_bool)
+ML_2 (gtk_math_view_log_set_verbosity, GtkMathView_val, Int_val, Unit)
+ML_1 (gtk_math_view_log_get_verbosity, GtkMathView_val, Val_int)
+ML_2 (gtk_math_view_export_to_postscript, GtkMathView_val, Int_val, Unit)
+
-/*
value ml_gtk_math_view_get_top (value arg1)
{
CAMLparam1(arg1);
Store_field(result, 0, Val_int(y));
CAMLreturn (result);
}
-*/
-value ml_gtk_math_view_get_selection (value arg1)
+
+value ml_gtk_math_view_mDOMNode_of_bodex_option (value arg1)
{
- const char *stringa;
- stringa = gtk_math_view_get_selection (GtkMathView_val (arg1));
- return Val_option (stringa, Val_string);
+ CAMLparam1(arg1);
+
+ mDOMNodeRef nr;
+
+ if (arg1==Val_int(0)) {
+ nr = NULL;
+ } else {
+ nr = (mDOMNodeRef) Field(arg1, 0);
+ }
+
+ CAMLreturn((value) nr);
}
-LABLGTK_DIR = ../../lablgtk-20000829
+LABLGTK_DIR = /usr/lib/ocaml/lablgtk
LABLGTK_MATHVIEW_DIR = ..
OCAMLC = ocamlc -I $(LABLGTK_DIR) -I $(LABLGTK_MATHVIEW_DIR) -I mlmathview
OCAMLOPT = ocamlopt -I $(LABLGTK_DIR) -I $(LABLGTK_MATHVIEW_DIR) -I mlmathview
(******************************************************************************)
(* Callbacks *)
-let jump s =
+let jump node =
+(*
print_string ("jump: " ^ s ^ "\n") ;
flush stdout
+*) ()
;;
-let clicked () =
+let clicked node =
+(*
print_string "clicked: IT WORKS\n" ;
flush stdout
+*) ()
;;
let load mathview () =
exception Ok;;
let get_selection mathview () =
+(*
let selection =
match mathview#get_selection with
None -> "NO SELECTION"
in
print_string ("get_selection: " ^ selection ^ "\n") ;
flush stdout
+*) ()
;;
let unload mathview () =
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") ;
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_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
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_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)) ;