-gMathView.cmo: gtkMathView.cmo gtk_mathview.cmo gMathView.cmi
-gMathView.cmx: gtkMathView.cmx gtk_mathview.cmx gMathView.cmi
-gMathViewAux.cmo: gMathView.cmi gtkMathView.cmo gtk_mathview.cmo \
- gMathViewAux.cmi
-gMathViewAux.cmx: gMathView.cmx gtkMathView.cmx gtk_mathview.cmx \
- gMathViewAux.cmi
-gtkMathView.cmo: gtk_mathview.cmo
-gtkMathView.cmx: gtk_mathview.cmx
+gMathView.cmo: gtkMathView.cmo gtk_mathview.cmo ogtkMathViewProps.cmo \
+ gMathView.cmi
+gMathView.cmx: gtkMathView.cmx gtk_mathview.cmx ogtkMathViewProps.cmx \
+ gMathView.cmi
+gMathViewAux.cmo: gMathView.cmi gtkMathView.cmo gMathViewAux.cmi
+gMathViewAux.cmx: gMathView.cmx gtkMathView.cmx gMathViewAux.cmi
+gtkMathView.cmo: gtkMathViewProps.cmo gtk_mathview.cmo
+gtkMathView.cmx: gtkMathViewProps.cmx gtk_mathview.cmx
+gtkMathViewProps.cmo: gtk_mathview.cmo
+gtkMathViewProps.cmx: gtk_mathview.cmx
+ogtkMathViewProps.cmo: gtkMathViewProps.cmo
+ogtkMathViewProps.cmx: gtkMathViewProps.cmx
gMathView.cmi: gtk_mathview.cmo
-gMathViewAux.cmi: gMathView.cmi
+gMathViewAux.cmi: gMathView.cmi gtk_mathview.cmo
PACKAGE = @PACKAGE@
VERSION = @VERSION@
INCLUDEDIR = @OCAML_INCLUDE_DIR@
+PROPCC = /home/luca/builds/lablgtk2/src/propcc
PREFIX =
OBJECTS_C = ml_gtk_mathview.o
-OBJECTS = gtk_mathview.cmo gtkMathView.cmo gMathView.cmo gMathViewAux.cmo
-OBJECTS_OPT = gtkMathView.cmx gtk_mathview.cmx gMathView.cmx gMathViewAux.cmx
+OBJECTS = gtkMathViewProps.cmo ogtkMathViewProps.cmo gtk_mathview.cmo gtkMathView.cmo gMathView.cmo gMathViewAux.cmo
+OBJECTS_OPT = gtkMathViewProps.cmx ogtkMathViewProps.cmx gtkMathView.cmx gtk_mathview.cmx gMathView.cmx gMathViewAux.cmx
+GENERATED_FILES = gtkMathViewProps.ml ogtkMathViewProps.ml
INST = \
META gMathView.mli gMathView.cmi gtkMathView.cmi gtk_mathview.cmi \
gMathViewAux.cmi gMathViewAux.mli
configure lablgtkmathview.spec lablgtkmathview.spec.in
DIST_DIR = $(PACKAGE)-$(VERSION)
DOC_FILES = AUTHORS COPYING ChangeLog NEWS README LICENSE
-REQUIRES = gdome2 lablgtk
+REQUIRES = gdome2 lablgtk2
PREDICATES =
SHARED_LIBS = @GDOME_LIBS@ @GTKMATHVIEW_LIBS@ -lmlgdome
(cd $(DIST_DIR)/ && debuild)
rm -rf $(DIST_DIR)
+$(GENERATED_FILES): gtkMathView.props
+
ml_gtk_mathview.o: ml_gtk_mathview.c
gcc -c -I$(INCLUDEDIR) -fPIC `ocamlfind query -i-format lablgtk` @GTKMATHVIEW_CFLAGS@ @GDOME_CFLAGS@ `ocamlfind query -i-format gdome2` $<
.ml.cmx:
$(OCAMLOPT) -package "$(REQUIRES)" -predicates "$(PREDICATES)" -c $<
-depend: *.ml *.mli
+%Props.ml o%Props.ml: %.props $(PROPCC)
+ $(PROPCC) $<
+
+depend: *.ml *.mli $(GENERATED_FILES)
$(OCAMLDEP) *.ml *.mli >.depend
include .depend
fi
clean:
- rm -f *.[ao] *.cm[iaxo] *.cmxa *.so
+ rm -f *.[ao] *.cm[iaxo] *.cmxa *.so $(GENERATED_FILES)
cd $(TESTDIR) ; make clean
rm -rf $(TMPDIR)
*)
open Gaux
-open Gtk
open Gtk_mathview
+open Gobject
+open Gtk
open GtkBase
open GtkMathView
+open OgtkMathViewProps
open GObj
exception ErrorLoadingFile of string;;
exception ErrorWritingFile of string;;
exception ErrorLoadingDOM;;
-exception NoSelection;;
let option_element_of_option =
function
None -> None
| Some v -> Some (new Gdome.element v)
-class math_view_signals obj = object
- inherit GContainer.container_signals obj
- method click =
- let module S = GtkSignal in
- let new_click =
- let new_marshaller f x y =
- MathView.Signals.click.S.marshaller
- (fun e s -> f (option_element_of_option e) s) x y
- in
- { S.name = "click"; S.classe = `math_view;
- S.marshaller = new_marshaller }
- in
- GtkSignal.connect ~sgn:new_click obj ~after
- method select_begin =
- let module S = GtkSignal in
- let new_select_begin =
- let new_marshaller f x y =
- MathView.Signals.select_begin.S.marshaller
- (fun e s -> f (option_element_of_option e) s) x y
- in
- { S.name = "select_begin"; S.classe = `math_view;
- S.marshaller = new_marshaller }
- in
- GtkSignal.connect ~sgn:new_select_begin obj ~after
- method select_over =
- let module S = GtkSignal in
- let new_select_over =
- let new_marshaller f x y =
- MathView.Signals.select_over.S.marshaller
- (fun e s -> f (option_element_of_option e) s) x y
- in
- { S.name = "select_over"; S.classe = `math_view;
- S.marshaller = new_marshaller }
- in
- GtkSignal.connect ~sgn:new_select_over obj ~after
- method select_end =
- let module S = GtkSignal in
- let new_select_end =
- let new_marshaller f x y =
- MathView.Signals.select_end.S.marshaller
- (fun e s -> f (option_element_of_option e) s) x y
- in
- { S.name = "select_end"; S.classe = `math_view;
- S.marshaller = new_marshaller }
- in
- GtkSignal.connect ~sgn:new_select_end obj ~after
- method select_abort =
- let module S = GtkSignal in
- let new_select_abort =
- let new_marshaller f x y =
- MathView.Signals.select_abort.S.marshaller
- (fun () -> f ()) x y
- in
- { S.name = "select_abort"; S.classe = `math_view;
- S.marshaller = new_marshaller }
- in
- GtkSignal.connect ~sgn:new_select_abort obj ~after
- method element_over =
- let module S = GtkSignal in
- let new_element_over =
- let new_marshaller f x y =
- MathView.Signals.element_over.S.marshaller
- (fun e s -> f (option_element_of_option e) s) x y
- in
- { S.name = "element_over"; S.classe = `math_view;
- S.marshaller = new_marshaller }
- in
- GtkSignal.connect ~sgn:new_element_over obj ~after
-end
-
class math_view_skel obj = object
inherit GContainer.container (obj : Gtk_mathview.math_view obj)
method freeze = MathView.freeze 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 set_top x y = MathView.set_top obj x y
+ method set_adjustments 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 get_drawing_area = new GMisc.drawing_area (MathView.get_drawing_area 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_transparency = MathView.set_transparency obj
- method get_transparency = MathView.get_transparency obj
method set_log_verbosity = MathView.set_log_verbosity obj
method get_log_verbosity = MathView.get_log_verbosity obj
- method export_to_postscript
- ?(width = 595) ?(height = 822) ?(x_margin = 72) ?(y_margin = 72)
- ?(disable_colors = false) ~filename () =
- let result = MathView.export_to_postscript obj
- ~width ~height ~x_margin ~y_margin ~disable_colors ~filename
- in
- if not result then raise (ErrorWritingFile filename)
- method get_font_manager_type = MathView.get_font_manager_type obj
- method set_font_manager_type ~fm_type = MathView.set_font_manager_type obj ~fm_type
+end
+
+class math_view_signals obj = object
+ inherit GContainer.container_signals_impl obj
+ inherit math_view_sigs
end
class math_view obj = object
- inherit math_view_skel (obj : Gtk_mathview.math_view obj)
- method connect = new math_view_signals obj
+ inherit math_view_skel (obj : Gtk_mathview.math_view obj)
+ method connect = new math_view_signals obj
end
-let math_view ?adjustmenth ?adjustmentv ?font_size ?font_manager ?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)
- ()
- in
- Container.set w ?border_width ?width ?height;
- let mathview = pack_return (new math_view w) ~packing ~show in
- begin
- match font_size with
- | Some size -> mathview#set_font_size size
- | None -> ()
- end;
- begin
- match font_manager with
- | Some manager -> mathview#set_font_manager_type ~fm_type:manager
- | None -> ()
- end;
- mathview
+let math_view ?hadjustment ?vadjustment ?font_size ?log_verbosity =
+ GtkBase.Container.make_params ~cont:(
+ OgtkMathViewProps.pack_return
+ (fun p -> OgtkMathViewProps.set_params (new math_view (MathView.create p)) ~font_size ~log_verbosity)) []
;;
exception ErrorLoadingFile of string
exception ErrorWritingFile of string
exception ErrorLoadingDOM
-exception NoSelection
class math_view_signals :
- ([> `container | `widget | `base | `math_view] as 'b) Gtk.obj ->
+ ([> `container | `gtk | `mathview | `widget] as 'b) Gtk.obj ->
object ('a)
inherit GContainer.container_signals
+ val after: bool
val obj: 'b Gtk.obj
method click :
callback:(Gdome.element option -> int -> unit) -> GtkSignal.id
inherit GContainer.container
method freeze : unit
method thaw : unit
- method export_to_postscript :
- ?width:int ->
- ?height:int ->
- ?x_margin:int ->
- ?y_margin:int ->
- ?disable_colors:bool -> filename:string -> unit -> unit
- method get_anti_aliasing : bool
method get_buffer : Gdk.pixmap
- method get_font_manager_type : [ `font_manager_gtk | `font_manager_t1]
method get_font_size : int
- method get_frame : GBin.frame
method get_drawing_area : GMisc.drawing_area
method get_hadjustment : GData.adjustment
method get_height : int
method get_log_verbosity : int
method get_top : int * int
- method get_transparency : bool
method get_vadjustment : GData.adjustment
method get_width : int
method load_uri : filename:string -> unit
method load_doc : dom:Gdome.document -> unit
method set_adjustments : GData.adjustment -> GData.adjustment -> unit
- method set_anti_aliasing : bool -> unit
- method set_font_manager_type :
- fm_type:[ `font_manager_gtk | `font_manager_t1] -> unit
method set_font_size : int -> unit
method set_log_verbosity : int -> unit
method select : 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
method unload : unit
val obj : 'a
end
end
val math_view :
- ?adjustmenth:GData.adjustment ->
- ?adjustmentv:GData.adjustment ->
+ ?hadjustment:GData.adjustment ->
+ ?vadjustment:GData.adjustment ->
?font_size:int ->
- ?font_manager:[ `font_manager_gtk | `font_manager_t1] ->
+ ?log_verbosity:int ->
?border_width:int ->
?width:int ->
?height:int ->
end
;;
-let single_selection_math_view ?adjustmenth ?adjustmentv ?font_size ?font_manager ?border_width
- ?width ?height ?packing ?show () =
- let w =
- GtkMathView.MathView.create
- ?adjustmenth:(Gaux.may_map ~f:GData.as_adjustment adjustmenth)
- ?adjustmentv:(Gaux.may_map ~f:GData.as_adjustment adjustmentv)
- ()
- in
- GtkBase.Container.set w ?border_width ?width ?height;
- let mathview =
- GObj.pack_return (new single_selection_math_view w) ~packing ~show
- in
- begin
- match font_size with
- | Some size -> mathview#set_font_size size
- | None -> ()
- end;
- begin
- match font_manager with
- | Some manager -> mathview#set_font_manager_type ~fm_type:manager
- | None -> ()
- end;
- mathview
+let single_selection_math_view ?hadjustment ?vadjustment ?font_size ?log_verbosity =
+ GtkBase.Container.make_params ~cont:(
+ OgtkMathViewProps.pack_return
+ (fun p -> OgtkMathViewProps.set_params (new single_selection_math_view (GtkMathViewProps.MathView.create p)) ~font_size ~log_verbosity)) []
;;
class multi_selection_math_view_signals obj
end
;;
-let multi_selection_math_view ?adjustmenth ?adjustmentv ?font_size ?font_manager ?border_width
- ?width ?height ?packing ?show () =
- let w =
- GtkMathView.MathView.create
- ?adjustmenth:(Gaux.may_map ~f:GData.as_adjustment adjustmenth)
- ?adjustmentv:(Gaux.may_map ~f:GData.as_adjustment adjustmentv)
- ()
- in
- GtkBase.Container.set w ?border_width ?width ?height;
- let mathview = GObj.pack_return (new multi_selection_math_view w) ~packing ~show in
- begin
- match font_size with
- | Some size -> mathview#set_font_size size
- | None -> ()
- end;
- begin
- match font_manager with
- | Some manager -> mathview#set_font_manager_type ~fm_type:manager
- | None -> ()
- end;
- mathview
+let multi_selection_math_view ?hadjustment ?vadjustment ?font_size ?log_verbosity =
+ GtkBase.Container.make_params ~cont:(
+ OgtkMathViewProps.pack_return
+ (fun p -> OgtkMathViewProps.set_params (new multi_selection_math_view (GtkMathViewProps.MathView.create p)) ~font_size ~log_verbosity)) []
;;
-
*)
class single_selection_math_view_signals :
- ([> `container | `widget | `base | `math_view] as 'b) Gtk.obj ->
+ ([> `container | `gtk | `mathview | `widget] as 'b) Gtk.obj ->
((Gdome.element option -> unit) -> unit) ->
object
inherit GMathView.math_view_signals
end
val single_selection_math_view :
- ?adjustmenth:GData.adjustment ->
- ?adjustmentv:GData.adjustment ->
+ ?hadjustment:GData.adjustment ->
+ ?vadjustment:GData.adjustment ->
?font_size:int ->
- ?font_manager:[ `font_manager_gtk | `font_manager_t1] ->
+ ?log_verbosity:int ->
?border_width:int ->
?width:int ->
?height:int ->
end
val multi_selection_math_view :
- ?adjustmenth:GData.adjustment ->
- ?adjustmentv:GData.adjustment ->
+ ?hadjustment:GData.adjustment ->
+ ?vadjustment:GData.adjustment ->
?font_size:int ->
- ?font_manager:[ `font_manager_gtk | `font_manager_t1] ->
+ ?log_verbosity:int ->
?border_width:int ->
?width:int ->
?height:int ->
* For details, send a mail to the author.
*)
-open Gtk
open Gtk_mathview
+open Gaux
+open Gobject
+open Gtk
open Tags
+open GtkMathViewProps
open GtkBase
-open Gpointer
-
-external gdome_element_of_boxed_option :
- Gpointer.boxed option -> TElement.t =
- "ml_gtk_math_view_gdome_element_of_boxed_option"
-external gdome_element_option_of_boxed_option :
- Gpointer.boxed option -> TElement.t option =
- "ml_gtk_math_view_gdome_element_option_of_boxed_option"
+external _gtkmathview_init : unit -> unit = "ml_gtk_mathview_init"
+let () = _gtkmathview_init ()
module MathView = struct
- exception NoSelection
-
- let cast w : math_view obj = Object.try_cast w "GtkMathView"
- external create : Gtk.adjustment optobj -> Gtk.adjustment optobj ->
- math_view obj = "ml_gtk_math_view_new"
- let create ~adjustmenth ~adjustmentv () =
- create (optboxed adjustmenth) (optboxed adjustmentv)
- external freeze : [>`math_view] obj -> unit =
+ include MathView
+ external freeze : [>`mathview] obj -> unit =
"ml_gtk_math_view_freeze"
- external thaw : [>`math_view] obj -> unit =
+ external thaw : [>`mathview] obj -> unit =
"ml_gtk_math_view_thaw"
- external load_uri : [>`math_view] obj -> filename:string -> bool =
+ external load_uri : [>`mathview] obj -> filename:string -> bool =
"ml_gtk_math_view_load_uri"
- external load_doc : [>`math_view] obj -> dom:[> `Document] GdomeT.t -> bool =
+ external load_doc : [>`mathview] obj -> dom:[> `Document] GdomeT.t -> bool =
"ml_gtk_math_view_load_doc"
- external unload : [>`math_view] obj -> unit =
+ external unload : [>`mathview] obj -> unit =
"ml_gtk_math_view_unload"
external select :
- [>`math_view] obj -> [> `Element] GdomeT.t -> unit =
+ [>`mathview] obj -> [> `Element] GdomeT.t -> unit =
"ml_gtk_math_view_select"
external unselect :
- [>`math_view] obj -> [> `Element] GdomeT.t -> unit =
+ [>`mathview] obj -> [> `Element] GdomeT.t -> unit =
"ml_gtk_math_view_unselect"
external is_selected :
- [>`math_view] obj -> [> `Element] GdomeT.t -> bool =
+ [>`mathview] obj -> [> `Element] GdomeT.t -> bool =
"ml_gtk_math_view_is_selected"
external get_element_at :
- [> `math_view] obj -> int -> int -> TElement.t option =
+ [> `mathview] obj -> int -> int -> TElement.t option =
"ml_gtk_math_view_get_element_at"
- external get_width : [>`math_view] obj -> int =
+ (* beginning of prop-like methods *)
+ external get_width : [>`mathview] obj -> int =
"ml_gtk_math_view_get_width"
- external get_height : [>`math_view] obj -> int =
+ external get_height : [>`mathview] obj -> int =
"ml_gtk_math_view_get_height"
- external get_top : [>`math_view] obj -> (int * int) =
+ external get_top : [>`mathview] obj -> (int * int) =
"ml_gtk_math_view_get_top"
- external set_top : [>`math_view] obj -> int -> int -> unit =
+ external set_top : [>`mathview] obj -> int -> int -> unit =
"ml_gtk_math_view_set_top"
- external set_adjustments : [>`math_view] obj -> Gtk.adjustment obj -> Gtk.adjustment obj -> unit =
+ external set_adjustments : [>`mathview] obj -> Gtk.adjustment obj -> Gtk.adjustment obj -> unit =
"ml_gtk_math_view_set_adjustments"
- external get_hadjustment : [>`math_view] obj -> Gtk.adjustment obj =
+ external get_hadjustment : [>`mathview] obj -> Gtk.adjustment obj =
"ml_gtk_math_view_get_hadjustment"
- external get_vadjustment : [>`math_view] obj -> Gtk.adjustment obj =
+ external get_vadjustment : [>`mathview] obj -> Gtk.adjustment obj =
"ml_gtk_math_view_get_vadjustment"
- external get_buffer : [>`math_view] obj -> Gdk.pixmap =
+ external get_buffer : [>`mathview] obj -> Gdk.pixmap =
"ml_gtk_math_view_get_buffer"
- external get_frame : [>`math_view] obj -> Gtk.frame obj =
- "ml_gtk_math_view_get_frame"
- external get_drawing_area : [>`math_view] obj -> Gtk.drawing_area obj =
+ external get_drawing_area : [>`mathview] obj -> Gtk.drawing_area obj =
"ml_gtk_math_view_get_drawing_area"
- external set_font_size : [>`math_view] obj -> int -> unit =
+ external set_font_size : [>`mathview] obj -> int -> unit =
"ml_gtk_math_view_set_font_size"
- external get_font_size : [>`math_view] obj -> int =
+ external get_font_size : [>`mathview] 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_transparency : [>`math_view] obj -> bool -> unit =
- "ml_gtk_math_view_set_transparency"
- external get_transparency : [>`math_view] obj -> bool =
- "ml_gtk_math_view_get_transparency"
- external set_log_verbosity : [>`math_view] obj -> int -> unit =
+ external set_log_verbosity : [>`mathview] obj -> int -> unit =
"ml_gtk_math_view_set_log_verbosity"
- external get_log_verbosity : [>`math_view] obj -> int =
+ external get_log_verbosity : [>`mathview] obj -> int =
"ml_gtk_math_view_get_log_verbosity"
- external export_to_postscript :
- [>`math_view] obj -> width:int -> height:int -> x_margin:int -> y_margin:int -> disable_colors:bool -> filename:string -> bool =
- "ml_gtk_math_view_export_to_postscript_bytecode" "ml_gtk_math_view_export_to_postscript_native"
- external get_font_manager_type : [>`math_view] obj ->
- [`font_manager_gtk | `font_manager_t1] =
- "ml_gtk_math_view_get_font_manager_type"
- external set_font_manager_type : [>`math_view] obj ->
- fm_type:[`font_manager_gtk | `font_manager_t1] -> unit =
- "ml_gtk_math_view_set_font_manager_type"
-
- module Signals = struct
- open GtkSignal
-
- let click : ([>`math_view],_) t =
- let marshal_click f _ =
- function
- [GtkArgv.POINTER element; GtkArgv.INT state] ->
- f (gdome_element_option_of_boxed_option element) state
- | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_click"
- in
- { name = "click"; classe = `math_view; marshaller = marshal_click }
-
- let element_over : ([>`math_view],_) t =
- let marshal_element_over f _ =
- function
- [GtkArgv.POINTER element; GtkArgv.INT state] ->
- f (gdome_element_option_of_boxed_option element) state
- | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_element_over"
- in
- { name = "element_over"; classe = `math_view;
- marshaller = marshal_element_over }
-
- let select_begin : ([>`math_view],_) t =
- let marshal_select_begin f _ =
- function
- [GtkArgv.POINTER element; GtkArgv.INT state] ->
- f (gdome_element_option_of_boxed_option element) state
- | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_select_begin"
- in
- { name = "select_begin"; classe = `math_view;
- marshaller = marshal_select_begin }
-
- let select_over : ([>`math_view],_) t =
- let marshal_select_over f _ =
- function
- [GtkArgv.POINTER element; GtkArgv.INT state] ->
- f (gdome_element_option_of_boxed_option element) state
- | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_select_over"
- in
- { name = "select_over"; classe = `math_view;
- marshaller = marshal_select_over }
-
- let select_end : ([>`math_view],_) t =
- let marshal_select_end f _ =
- function
- [GtkArgv.POINTER element; GtkArgv.INT state] ->
- f (gdome_element_option_of_boxed_option element) state
- | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_select_end"
- in
- { name = "select_end"; classe = `math_view;
- marshaller = marshal_select_end }
-
- let select_abort : ([>`math_view],_) t =
- let marshal_select_abort f _ =
- function
- [] -> f ()
- | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_select_abort"
- in
- { name = "select_abort"; classe = `math_view;
- marshaller = marshal_select_abort }
- end
end
* For details, send a mail to the author.
*)
-type math_view = [`widget|`container|`bin|`eventbox|`math_view|`base]
+type math_view = [Gtk.event_box|`mathview]
*/
#include <assert.h>
-#include <string.h>
-#include <assert.h>
+
+#include <gtkmathview.h>
#include <gtk/gtk.h>
+
#include <caml/mlvalues.h>
#include <caml/alloc.h>
#include <caml/memory.h>
#include <caml/callback.h>
#include <caml/fail.h>
-
-#include <gtkmathview/gtkmathview.h>
-#include <ml_gtk.h>
+#include <caml/custom.h>
+#include <caml/callback.h>
#include <wrappers.h>
#include <ml_glib.h>
#include <ml_gdk.h>
#include <ml_gtk.h>
+#include <ml_gobject.h>
+#include <ml_gdkpixbuf.h>
+#include <ml_pango.h>
#include <gtk_tags.h>
+#include <gdk_tags.h>
#include <mlgdomevalue.h>
-#define GtkMathView_val(val) check_cast(GTK_MATH_VIEW,val)
-
-#define FontManagerId_val(val) Int_val(val)
-#define Val_FontManagerId(val) Val_int(val)
+/* Init all */
-/* 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_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))); }
-
-FontManagerId
-font_manager_id_of_value(value v)
+CAMLprim value ml_gtk_mathview_init(value unit)
{
- if (v == hash_variant("font_manager_gtk")) return FONT_MANAGER_GTK;
- else if (v == hash_variant("font_manager_t1")) return FONT_MANAGER_T1;
- else assert(0);
+ /* Since these are declared const, must force gcc to call them! */
+ GType t = gtk_math_view_get_type();
+ return Val_GType(t);
}
-value
-value_of_font_manager_id(FontManagerId id)
-{
- switch (id) {
- case FONT_MANAGER_GTK:
- return hash_variant("font_manager_gtk");
- case FONT_MANAGER_T1:
- return hash_variant("font_manager_t1");
- default:
- assert(0);
- break;
- }
-}
+#define GtkMathView_val(val) check_cast(GTK_MATH_VIEW,val)
+
+//#####################################
+//
+//#define FontManagerId_val(val) Int_val(val)
+//#define Val_FontManagerId(val) Val_int(val)
+//
+///* 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_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)
{
return Val_Element(elem);
}
-ML_2 (gtk_math_view_new,GtkAdjustment_val, GtkAdjustment_val, Val_GtkWidget_sink)
+OML_3 (gtk_math_view_get_element_at, GtkMathView_val, Int_val, Int_val, Val_Element)
ML_1 (gtk_math_view_freeze, GtkMathView_val, Unit)
ML_1 (gtk_math_view_thaw, GtkMathView_val, Unit)
ML_2 (gtk_math_view_load_uri, GtkMathView_val, String_val, Val_bool)
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)
+/*
+ML_2 (gtk_math_view_new,GtkAdjustment_val, GtkAdjustment_val, Val_GtkWidget_sink)
+*/
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_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_1 (gtk_math_view_get_drawing_area, 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_transparency, GtkMathView_val, Bool_val, Unit)
-ML_1 (gtk_math_view_get_transparency, GtkMathView_val, Val_bool)
ML_2 (gtk_math_view_set_log_verbosity, GtkMathView_val, Int_val, Unit)
ML_1 (gtk_math_view_get_log_verbosity, GtkMathView_val, Val_int)
-ML_2 (gtk_math_view_set_font_manager_type, GtkMathView_val, font_manager_id_of_value, Unit)
-ML_1 (gtk_math_view_get_font_manager_type, GtkMathView_val, value_of_font_manager_id)
-
-value
-ml_gtk_math_view_export_to_postscript_native(value arg1,
- value w, value h, value x0, value y0, value disable_colors, value arg2)
-{
- CAMLparam5(arg1,w,h,x0,y0);
- CAMLxparam2(disable_colors, arg2);
-
- char *filename;
- FILE *fd;
- int res;
- filename = String_val (arg2);
- if ((fd = fopen(filename, "w"))) {
- gtk_math_view_export_to_postscript(GtkMathView_val (arg1),
- Int_val(w), Int_val(h), Int_val(x0), Int_val(y0), Bool_val(disable_colors), fd);
- fclose (fd);
- res = 1;
- } else {
- fprintf(stderr, "Error opening file %s for writing\n", filename);
- res = 0;
- }
- CAMLreturn (Val_bool(res));
-}
-
-value ml_gtk_math_view_export_to_postscript_bytecode (value* arg, int argn)
-{
- return ml_gtk_math_view_export_to_postscript_native(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6]);
-}
value ml_gtk_math_view_get_top (value arg1)
{
CAMLreturn(res);
}
-
;;
-let activate_t1 mathview () =
- mathview#set_font_manager_type ~fm_type:`font_manager_t1;
- print_string "WIDGET SET WITH T1 FONTS\n" ;
- flush stdout
-;;
-
-let activate_gtk mathview () =
- mathview#set_font_manager_type ~fm_type:`font_manager_gtk ;
- print_string "WIDGET SET WITH GTK FONTS\n" ;
- flush stdout
-;;
-
-let get_font_manager_type mathview () =
- print_string "CURRENT FONT MANAGER TYPE: ";
- begin
- match mathview#get_font_manager_type with
- | `font_manager_t1 -> print_string "T1"
- | `font_manager_gtk -> print_string "GTK"
- end;
- print_newline();
- flush stdout
-;;
-
-let get_transparency mathview () =
- print_string ("CURRENT TRANSPARENCY: " ^
- (if mathview#get_transparency then "ON" else "OFF") ^ "\n") ;
- flush stdout
-;;
-
-let set_transparency mathview () =
- mathview#set_transparency (not mathview#get_transparency) ;
- print_string "TRANSPARENCY CHANGED\n" ;
- flush stdout
-;;
-
-
let load_uri mathview () =
mathview#load_uri ~filename:"test.xml" ;
print_string "load: SEEMS TO WORK\n" ;
Some element -> element#get_tagName#to_string
| None -> "no selection!"
in
- print_string ("get_selection: " ^ selection ^ "\n") ;
+ print_string ("selection: " ^ selection ^ "\n") ;
flush stdout
;;
;;
let get_width mathview () =
- print_string ("get_width: " ^ string_of_int (mathview#get_width) ^ "\n") ;
+ print_string ("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 ("height: " ^ string_of_int (mathview#get_height) ^ "\n") ;
flush stdout
;;
let get_top mathview () =
let (x,y) = mathview#get_top in
- print_string ("get_top: ("^ string_of_int x ^ "," ^ string_of_int y ^ ")\n") ;
+ print_string ("top: ("^ string_of_int x ^ "," ^ string_of_int y ^ ")\n") ;
flush stdout
;;
let get_hadjustment mathview () =
let adj = mathview#get_hadjustment in
adj#set_value ((adj#lower +. adj#upper) /. 2.0) ;
- print_string "get_hadjustment: SEEM TO WORK\n" ;
+ print_string "hadjustment: SEEM TO WORK\n" ;
flush stdout
;;
let get_vadjustment mathview () =
let adj = mathview#get_vadjustment in
adj#set_value ((adj#lower +. adj#upper) /. 2.0) ;
- print_string "get_vadjustment: SEEM TO WORK\n" ;
+ print_string "vadjustment: SEEM TO WORK\n" ;
flush stdout
;;
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";
- flush stdout
-;;
-
-let get_frame mathview () =
- let frame = mathview#get_frame in
- frame#set_shadow_type `NONE ;
- print_string "get_frame: SEEMS TO WORK\n" ;
+ print_string "buffer: SEEMS TO WORK (hint: force the widget redrawing)\n";
flush stdout
;;
;;
let get_font_size mathview () =
- print_string ("get_font_size: " ^ string_of_int (mathview#get_font_size) ^ "\n") ;
- flush stdout
-;;
-
-let set_anti_aliasing mathview () =
- mathview#set_anti_aliasing true ;
- print_string "set_anti_aliasing: ON\n" ;
- flush stdout
-;;
-
-let get_anti_aliasing mathview () =
- print_string ("get_anti_aliasing: " ^
- (match mathview#get_anti_aliasing with true -> "ON" | false -> "OFF") ^
- "\n") ;
+ print_string ("font_size: " ^ string_of_int (mathview#get_font_size) ^ "\n") ;
flush stdout
;;
- (*
-let set_kerning mathview () =
- mathview#set_kerning true ;
- print_string "set_kerning: ON\n" ;
- flush stdout
-;;
-
-let get_kerning mathview () =
- print_string ("get_kerning: " ^
- (match mathview#get_kerning with true -> "ON" | false -> "OFF") ^
- "\n") ;
- flush stdout
-;;
-*)
-
let set_log_verbosity mathview () =
mathview#set_log_verbosity 3 ;
print_string "set_log_verbosity: NOW IS 3\n" ;
;;
let get_log_verbosity mathview () =
- print_string ("get_log_verbosity: " ^
+ print_string ("log_verbosity: " ^
string_of_int mathview#get_log_verbosity ^
"\n") ;
flush stdout
;;
-let export_to_postscript (mathview : GMathViewAux.multi_selection_math_view) () =
- mathview#export_to_postscript ~filename:"test.ps" ();
- print_string "expor_to_postscript: SEEMS TO WORK (hint: look at test.ps)\n";
- flush stdout
-;;
-
let x_coord = ref 0
;;
let sw = GBin.scrolled_window ~width:50 ~height:50 ~packing:vbox#pack () in
let mathview= GMathViewAux.multi_selection_math_view ~packing:sw#add ~width:50 ~height:50 () in
let table = GPack.table ~rows:6 ~columns:5 ~packing:vbox#pack () in
-let button_gtk=GButton.button ~label:"activate Gtk fonts" ~packing:(table#attach ~left:0 ~top:0) () in
let button_load = GButton.button ~label:"load" ~packing:(table#attach ~left:1 ~top:0) () in
let button_unload = GButton.button ~label:"unload" ~packing:(table#attach ~left:2 ~top:0) () in
-let button_get_selection = GButton.button ~label:"get_selection" ~packing:(table#attach ~left:3 ~top:0) () in
+let button_selection = GButton.button ~label:"get_selection" ~packing:(table#attach ~left:3 ~top:0) () in
let button_set_selection = GButton.button ~label:"set_selection" ~packing:(table#attach ~left:4 ~top:0) () in
let button_add_selection = GButton.button ~label:"add_selection" ~packing:(table#attach ~left:3 ~top:3) () in
let button_reset_selections = GButton.button ~label:"reset_selections" ~packing:(table#attach ~left:4 ~top:3) () in
let button_get_hadjustment = GButton.button ~label:"get_hadjustment" ~packing:(table#attach ~left:0 ~top:2) () in
let button_get_vadjustment = GButton.button ~label:"get_vadjustment" ~packing:(table#attach ~left:1 ~top:2) () in
let button_get_buffer = GButton.button ~label:"get_buffer" ~packing:(table#attach ~left:2 ~top:2) () in
-let button_get_frame = GButton.button ~label:"get_frame" ~packing:(table#attach ~left:3 ~top:2) () in
let button_set_font_size = GButton.button ~label:"set_font_size" ~packing:(table#attach ~left:4 ~top:2) () in
let button_get_font_size = GButton.button ~label:"get_font_size" ~packing:(table#attach ~left:0 ~top:3) () in
-let button_set_anti_aliasing = GButton.button ~label:"set_anti_aliasing" ~packing:(table#attach ~left:1 ~top:3) () in
-let button_get_anti_aliasing = GButton.button ~label:"get_anti_aliasing" ~packing:(table#attach ~left:2 ~top:3) () in
let button_set_log_verbosity = GButton.button ~label:"set_log_verbosity" ~packing:(table#attach ~left:0 ~top:4) () in
let button_get_log_verbosity = GButton.button ~label:"get_log_verbosity" ~packing:(table#attach ~left:1 ~top:4) () in
-let button_export_to_postscript = GButton.button ~label:"export_to_postscript" ~packing:(table#attach ~left:2 ~top:4) () in
-let button_t1 = GButton.button ~label:"activate T1 fonts" ~packing:(table#attach ~left:3 ~top:4) () in
-let button_get_font_manager_type = GButton.button ~label:"get_font_manager" ~packing:(table#attach ~left:4 ~top:4) () 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
let button_get_drawing_area = GButton.button ~label:"get_drawing_area" ~packing:(table#attach ~left:4 ~top:5) () in
(* Signals connection *)
-ignore(button_gtk#connect#clicked (activate_gtk mathview)) ;
ignore(button_load#connect#clicked (load_uri mathview)) ;
ignore(button_unload#connect#clicked (unload mathview)) ;
-ignore(button_get_selection#connect#clicked (test_get_selection mathview)) ;
+ignore(button_selection#connect#clicked (test_get_selection mathview)) ;
ignore(button_set_selection#connect#clicked (test_set_selection mathview)) ;
ignore(button_add_selection#connect#clicked (test_add_selection mathview)) ;
ignore(button_reset_selections#connect#clicked (test_reset_selections mathview)) ;
ignore(button_get_hadjustment#connect#clicked (get_hadjustment mathview)) ;
ignore(button_get_vadjustment#connect#clicked (get_vadjustment 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(button_get_font_size#connect#clicked (get_font_size mathview)) ;
-ignore(button_set_anti_aliasing#connect#clicked (set_anti_aliasing mathview)) ;
-ignore(button_get_anti_aliasing#connect#clicked (get_anti_aliasing mathview)) ;
ignore(button_set_log_verbosity#connect#clicked (set_log_verbosity mathview)) ;
ignore(button_get_log_verbosity#connect#clicked (get_log_verbosity mathview)) ;
-ignore(button_export_to_postscript#connect#clicked (export_to_postscript mathview)) ;
-ignore(button_t1#connect#clicked (activate_t1 mathview)) ;
-ignore(button_get_font_manager_type#connect#clicked (get_font_manager_type mathview)) ;
-ignore(button_get_transparency#connect#clicked (get_transparency mathview)) ;
-ignore(button_set_transparency#connect#clicked (set_transparency mathview)) ;
ignore(mathview#connect#click (click mathview)) ;
ignore(mathview#connect#selection_changed (selection_changed mathview));
ignore(mathview#connect#element_over (element_over mathview)) ;