--- /dev/null
+This library is made available under the LGPL.
+You should have got a copy of the LGPL with Objective Caml.
+The LGPL applies to all the files in this directory, but not in
+subdirectories.
+
+For the test subdirectory, there is no specific licensing policy,
+but you may freely take inspiration from the code, and copy parts of
+it in your application.
+
+Author:
+ Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>
--- /dev/null
+# Makefile for lablgtk_mathview.
+
+LABLGTKDIR = /usr/lib/ocaml/lablgtk
+MINIDOMDIR = ./minidom
+MLFLAGS += -I $(LABLGTKDIR) -I $(MINIDOMDIR)
+
+TARGETS = ml_gtk_mathview.o lablgtkmathview.cma
+
+all: $(TARGETS)
+
+opt: lablgtkmathviewopt
+
+configure:
+ @rm -f config.make
+ @$(MAKE) --no-print-directory -f configure.mk
+
+depend:
+ @rm -f .depend
+ @$(MAKE) --no-print-directory -f configure.mk .depend
+
+.depend config.make:
+ @$(MAKE) --no-print-directory -f configure.mk
+
+COMPILER = $(CAMLC) $(MLFLAGS) -w s -labels -c
+LINKER = $(CAMLC) $(MLFLAGS)
+COMPOPT = $(CAMLOPT) $(MLFLAGS) -w s -labels -c
+LINKOPT = $(CAMLOPT) $(MLFLAGS)
+
+include config.make
+
+INSTALLDIR = $(LIBDIR)/lablgtk/mathview
+
+MLLIBS = lablgtkmathview.cma
+CLIBS =
+MLLINK = unix.cma str.cma
+
+ifdef DEBUG
+CFLAGS = -g $(GTKCFLAGS)
+MLLINK += -cclib -lcamlrund
+MLFLAGS += -g
+else
+CFLAGS = -O -DGTK_NO_CHECK_CASTS -DGTK_DISABLE_COMPAT_H $(GTKCFLAGS)
+endif
+
+THFLAGS = -thread
+THLINK = unix.cma threads.cma
+
+ifdef USE_CC
+CCOMPILER = $(CC) -c -I$(LIBDIR) $(CFLAGS)
+else
+CCOMPILER = ocamlc -c -ccopt "$(CFLAGS)"
+endif
+
+# Rules
+.SUFFIXES: .ml .mli .cmo .cmi .cmx .c .o .var .h .opt .def
+.c.o:
+ $(CCOMPILER) $<
+.ml.cmo:
+ $(COMPILER) $<
+.mli.cmi:
+ $(COMPILER) $<
+.ml.cmx:
+ $(COMPOPT) $<
+.var.h:
+ ./var2def < $< > $@
+.var.c:
+ ./var2conv < $< > $@
+
+# Targets
+COBJS = ml_gtk_mathview.o
+MLOBJS = gtk_mathview.cmo gtkMathView.cmo gMathView.cmo
+ALLOBJS = $(MLOBJS)
+
+lablgtkmathviewopt: $(CLIBS) $(MLLIBS:.cma=.cmxa)
+
+install:
+ if test -d $(INSTALLDIR); then : ; else mkdir -p $(INSTALLDIR); fi
+ cp $(ALLOBJS:.cmo=.cmi) $(INSTALLDIR)
+ if test -f *.mli ; then cp *.mli $(INSTALLDIR) ; fi
+ cp $(ALLOBJS:.cmo=.ml) $(INSTALLDIR)
+ cp $(MLLIBS) $(INSTALLDIR)
+ cp $(COBJS) $(INSTALLDIR)
+ if test ! -z "$(CLIBS)" ; then cp $(CLIBS) $(INSTALLDIR) ; fi
+ if test -f lablgtkmathview.cmxa; then \
+ cp $(MLLIBS:.cma=.cmxa) $(MLLIBS:.cma=.a) \
+ $(INSTALLDIR); fi
+
+lablgtkmathview.cma: $(MLOBJS)
+ $(LINKER) -a -custom -o $@ $(MLOBJS) $(GTKLIBS) $(GTKMATHVIEWLIBS)
+lablgtkmathview.cmxa: $(MLOBJS:.cmo=.cmx)
+ $(LINKOPT) -a -o $@ $(MLOBJS:.cmo=.cmx) $(GTKLIBS) $(GTKMATHVIEWLIBS)
+
+ml_gtk.o: $(LABLGTKDIR)/gtk_tags.c $(LABLGTKDIR)/gtk_tags.h \
+ $(LABLGTKDIR)/ml_gtk.h $(LABLGTKDIR)/ml_gdk.h $(LABLGTKDIR)/wrappers.h
+
+clean:
+ rm -f *.cm* *.o *.a *_tags.[ch] $(TARGETS)
+
+include .depend
--- /dev/null
+CAMLC=ocamlc
+CAMLOPT=ocamlopt
+USE_GL=
+USE_GNOME=
+USE_CC=
+DEBUG=
+CC=cc
+RANLIB=ranlib
+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/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=
--- /dev/null
+# makefile for configuring lablGTK_mathview
+
+# Default compilers
+CAMLC = ocamlc
+CAMLOPT = ocamlopt
+
+# Default installation directories
+BINDIR = `$(GETBINDIR)`
+INSTALLDIR = $(LIBDIR)/lablgtk/mathview
+
+# Autoconf
+GETLIBDIR = ocamlc -v | grep "^Standard" | sed 's/^.*: *//'
+LIBDIR = `$(GETLIBDIR)`
+GETBINDIR = $(GETLIBDIR) | sed -e 's|/lib/[^/]*$$|/bin|' -e 's|/lib$$|/bin|'
+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" "`xml-config --cflags`" "`gtkmathview-config --cflags
+GNOMELIBS = `gnome-config --libs gtkxmhtml`
+else
+GTKGETCFLAGS = gtk-config --cflags`" "`xml-config --cflags`" "`gtkmathview-config --cflags
+endif
+
+GTKGETLIBS = gtk-config --libs
+
+configure: .depend config.make
+
+.depend:
+ ocamldep *.ml *.mli > .depend
+
+config.make:
+ @echo CAMLC=$(CAMLC) > config.make
+ @echo CAMLOPT=$(CAMLOPT) >> config.make
+ @echo USE_GL=$(USE_GL) >> config.make
+ @echo USE_GNOME=$(USE_GNOME) >> config.make
+ @echo USE_CC=$(USE_CC) >> config.make
+ @echo DEBUG=$(DEBUG) >> config.make
+ @echo CC=$(CC) >> config.make
+ @echo RANLIB=`$(GETRANLIB)` >> config.make
+ @echo LIBDIR=$(LIBDIR) >> config.make
+ @echo BINDIR=`$(GETBINDIR)` >> config.make
+ @echo INSTALLDIR=$(INSTALLDIR) >> config.make
+ @echo GTKCFLAGS=`$(GTKGETCFLAGS)` -I/usr/lib/ocaml/lablgtk >> config.make
+ @echo GTKLIBS=`$(GTKGETLIBS)` | \
+ sed -e 's/-l/-cclib &/g' -e 's/-[LRWr][^ ]*/-ccopt &/g' \
+ >> config.make
+ #<CSC>
+ echo GTKMATHVIEWLIBS="-ccopt -L/usr/local/lib/gtkmathview -cclib -lgtkmathview " >> config.make
+ #</CSC>
+ @echo GNOMELIBS=$(GNOMELIBS) | \
+ sed -e 's/-l/-cclib &/g' -e 's/-[LRWr][^ ]*/-ccopt &/g' \
+ >> config.make
+ cat config.make
--- /dev/null
+open Gaux
+open Gtk
+open Gtk_mathview
+open GtkBase
+open GtkMathView
+open GObj
+
+exception ErrorLoadingFile of string;;
+exception ErrorWritingFile of string;;
+
+class math_view_signals obj = object
+ inherit GContainer.container_signals obj
+ 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
+ inherit GContainer.container (obj : Gtk_mathview.math_view obj)
+ method connect = new math_view_signals obj
+ method load ~filename =
+ if not (MathView.load obj ~filename) then raise (ErrorLoadingFile filename)
+ method unload = MathView.unload 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)
+ (GData.as_adjustment adj2)
+ method get_hadjustment = new GData.adjustment (MathView.get_hadjustment obj)
+ method get_vadjustment = new GData.adjustment (MathView.get_vadjustment obj)
+ 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_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 set_log_verbosity = MathView.set_log_verbosity obj
+ method get_log_verbosity = MathView.get_log_verbosity obj
+ method export_to_postscript ~filename =
+ if not (MathView.export_to_postscript obj ~filename) then
+ raise (ErrorWritingFile filename)
+end
+
+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;
+ pack_return (new math_view w) ~packing ~show
+;;
--- /dev/null
+open Gtk
+open Gtk_mathview
+open Tags
+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 -> bool ->
+ math_view obj = "ml_gtk_math_view_new"
+ 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 unload : [>`math_view] obj -> unit =
+ "ml_gtk_math_view_unload"
+ (*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_hadjustment"
+ external get_vadjustment : [>`math_view] obj -> Gtk.adjustment obj =
+ "ml_gtk_math_view_get_vadjustment"
+ external get_buffer : [>`math_view] obj -> Gdk.pixmap =
+ "ml_gtk_math_view_get_buffer"
+ external get_frame : [>`math_view] obj -> [`frame] 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_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 set_log_verbosity : [>`math_view] obj -> int -> unit =
+ "ml_gtk_math_view_set_log_verbosity"
+ external get_log_verbosity : [>`math_view] obj -> int =
+ "ml_gtk_math_view_get_log_verbosity"
+ external export_to_postscript : [>`math_view] obj -> filename:string -> bool =
+ "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.POINTER node] -> f (mDOMNode_of_boxed_option node)
+ | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_jump"
+ in
+ { name = "jump"; marshaller = marshal_jump }
+
+ let selection_changed : ([>`math_view],_) t =
+ let marshal_selection_changed f _ =
+ function
+ [GtkArgv.POINTER node] -> f (mDOMNode_of_boxed_option node)
+ | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_selection_changed"
+ in
+ { name = "selection_changed"; marshaller = marshal_selection_changed }
+ end
+end
--- /dev/null
+type math_view = [`widget|`container|`bin|`eventbox|`math_view]