[cairo-commit] rcairo/src cairo.c,1.2,1.3
Evan Martin
commit at pdx.freedesktop.org
Wed Nov 19 10:51:53 PST 2003
Committed by: martine
Update of /cvs/cairo/rcairo/src
In directory pdx:/tmp/cvs-serv21675/src
Modified Files:
cairo.c
Log Message:
Update cairo.h parser to properly handle structs with exposed members, which
recently appeared in Cairo CVS.
(Unfortunately, this means I'll have to write my own getters/setters for each
member. I think I'll wait for the API to settle.)
Add a "ps" test that generates a simple postscript file (mostly to verify my
understanding of the mapping from C's FILE* to Ruby's File objects).
Index: cairo.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/cairo.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** cairo.c 28 Oct 2003 23:31:06 -0000 1.2
--- cairo.c 19 Nov 2003 18:51:51 -0000 1.3
***************
*** 5,9 ****
*/
! #include "shared.h"
VALUE mCairo, cCairo, cCairoSurface, cCairoMatrix;
--- 5,10 ----
*/
! #include "rbcairo.h"
! #include <rubyio.h> /* file pointers. */
VALUE mCairo, cCairo, cCairoSurface, cCairoMatrix;
***************
*** 44,47 ****
--- 45,65 ----
return Qnil;
}
+ static VALUE
+ rcairo_set_target_ps(VALUE vself, VALUE vfile,
+ VALUE vwidth_inches, VALUE vheight_inches,
+ VALUE vx_pixels_per_inch, VALUE vy_pixels_per_inch) {
+ OpenFile *rf;
+ FILE *f;
+
+ rb_check_type(vfile, T_FILE);
+ GetOpenFile(vfile, rf);
+ f = GetWriteFile(rf);
+
+ rb_iv_set(vself, "@target_file", vfile);
+ cairo_set_target_ps(rcairo_get_cairo(vself), f,
+ NUM2DBL(vwidth_inches), NUM2DBL(vheight_inches),
+ NUM2DBL(vx_pixels_per_inch), NUM2DBL(vy_pixels_per_inch));
+ return Qnil;
+ }
static VALUE
***************
*** 75,88 ****
}
- static VALUE
- rcairo_text_extents(VALUE vself, VALUE text) {
- double x, y, w, h, dx, dy;
- cairo_text_extents(rcairo_get_cairo(vself), STR2CSTR(text),
- &x, &y, &w, &h, &dx, &dy);
- return rb_ary_new3(6, rb_float_new(x), rb_float_new(y),
- rb_float_new(w), rb_float_new(h),
- rb_float_new(dx), rb_float_new(dy));
- }
-
/* Ruby-style functions. */
static VALUE
--- 93,96 ----
***************
*** 166,169 ****
--- 174,178 ----
rb_define_method(cCairo, "dup", rcairo_dup, 0);
rb_define_method(cCairo, "target_image=", rcairo_set_target_image, 1);
+ rb_define_method(cCairo, "set_target_ps", rcairo_set_target_ps, 5);
rb_define_method(cCairo, "set_dash", rcairo_set_dash, 2);
rb_define_method(cCairo, "transform_point", rcairo_transform_point, 1);
***************
*** 171,175 ****
rb_define_method(cCairo, "inverse_transform_point", rcairo_inverse_transform_point, 1);
rb_define_method(cCairo, "inverse_transform_distance", rcairo_inverse_transform_distance, 1);
- rb_define_method(cCairo, "text_extents", rcairo_text_extents, 1);
rb_define_method(cCairo, "stack", rcairo_stack, 0);
--- 180,183 ----
More information about the cairo-commit
mailing list