[cairo-commit] cairo-ocaml/test cube.ml,1.6,1.7 Makefile,1.10,1.11

Olivier Andrieu commit at pdx.freedesktop.org
Mon Nov 13 10:46:58 PST 2006


Committed by: oandrieu

Update of /cvs/cairo/cairo-ocaml/test
In directory kemper:/tmp/cvs-serv32496/test

Modified Files:
	cube.ml Makefile 
Log Message:
update the cube.ml example to use cairo_lablgtk instead of gtkcairo.


Index: cube.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/test/cube.ml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cube.ml	2 Mar 2005 18:52:29 -0000	1.6
+++ cube.ml	13 Nov 2006 18:46:55 -0000	1.7
@@ -11,23 +11,28 @@
 let rotate_max = 8. *. atan 1.
 let initial_size = 200
 
-let redraw w range cr =
+let get_cairo w =
+  Cairo_lablgtk.create w#misc#window
+
+let redraw w range _ =
+  let cr = get_cairo w in
   let { Gtk.width = width ; Gtk.height = height } =
     w#misc#allocation in
   let box_size = float (width + height) /. 6. in
 
   Cairo.save cr ; begin
-    Cairo.default_matrix cr ;
+    Cairo.identity_matrix cr ;
     let off = float width /. 2. in
     Cairo.translate cr off off ;
     Cairo.rotate cr range#adjustment#value ;
     Cairo.rectangle cr (~-. box_size) (~-. box_size) box_size box_size ;
-    Cairo.set_rgb_color cr 1. 0. 0. ;
+    Cairo.set_source_rgb cr 1. 0. 0. ;
     Cairo.fill cr end ;
-  Cairo.restore cr
+  Cairo.restore cr ;
+  true
 
-let slider_changed cr () =
-  cr#queue_draw
+let slider_changed w () =
+  GtkBase.Widget.queue_draw w#as_widget
 
 let animate_step range () =
   let nv = range#adjustment#value +. animate_rotate_step in
@@ -47,11 +52,9 @@
 	timeout := None
     | _ -> ()
 
-
-
 let main =
   let w = GWindow.window ~title:"GtkCairo Demo" () in
-  w#connect#destroy GMain.quit ;
+  ignore (w#connect#destroy GMain.quit) ;
   
   let b = GPack.vbox ~spacing:6 ~border_width:12 
       ~packing:w#add () in
@@ -59,7 +62,7 @@
   let f = GBin.frame ~shadow_type:`IN 
       ~packing:(b#pack ~expand:true ~fill:true) () in
 
-  let cairo = Cairo_gtkcairo.cairo 
+  let area = GMisc.drawing_area
       ~width:initial_size ~height:initial_size 
       ~packing:f#add () in
   let slider = GRange.scale `HORIZONTAL 
@@ -70,10 +73,12 @@
   let button = GButton.check_button ~label:"Animate" 
       ~packing:b#pack () in
 
-  cairo#connect#paint (redraw cairo slider) ;
-  slider#connect#value_changed 
-    (slider_changed cairo) ;
-  button#connect#toggled (animate_toggled button slider) ;
+  ignore (area#event#connect#expose
+	    (redraw area slider)) ;
+  ignore (slider#connect#value_changed 
+	    (slider_changed area)) ;
+  ignore (button#connect#toggled
+	    (animate_toggled button slider)) ;
 
   w#show () ;
   GMain.main ()

Index: Makefile
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/test/Makefile,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- Makefile	10 Aug 2005 23:45:15 -0000	1.10
+++ Makefile	13 Nov 2006 18:46:55 -0000	1.11
@@ -3,10 +3,7 @@
 
 TARGETS = basket kapow
 ifdef LABLGTKDIR
-TARGETS += text demo spline knockout font
-ifdef GTKCAIRO_CFLAGS
-TARGETS += cube
-endif
+TARGETS += text demo spline knockout font cube
 endif
 ifdef LIBSVG_CAIRO_CFLAGS
 TARGETS += svg2png 
@@ -30,7 +27,7 @@
 	$(OCAMLOPT) -w s -o $@ -I ../src -I $(LABLGTKDIR) lablgtk.cmxa cairo.cmxa cairo_lablgtk.cmxa gtkInit.cmx $^
 
 cube : cube.ml
-	$(OCAMLOPT) -w s -o $@ -I ../src -I $(LABLGTKDIR) lablgtk.cmxa cairo.cmxa gtkcairo.cmxa gtkInit.cmx $^
+	$(OCAMLOPT) -o $@ -I ../src -I $(LABLGTKDIR) lablgtk.cmxa cairo.cmxa cairo_lablgtk.cmxa gtkInit.cmx $^
 
 spline : spline.ml
 	$(OCAMLOPT) -w s -o $@ -I ../src -I $(LABLGTKDIR) lablgtk.cmxa cairo.cmxa cairo_lablgtk.cmxa gtkInit.cmx $^



More information about the cairo-commit mailing list