3 docCopyright("Daniel Rosengren", 2007)
4 docLicense("BSD revised")
5 docCategory("Graphics")
8 #include "IoCairoPDFSurface.h"
10 #if CAIRO_HAS_PDF_SURFACE
11 #include "IoCairoSurface.h"
12 #include "IoCairoSurface_inline.h"
13 #include <cairo-pdf.h>
16 static IoTag
*IoCairoPDFSurface_newTag(void *state
)
18 IoTag
*tag
= IoTag_newWithName_("CairoPDFSurface");
19 IoTag_state_(tag
, state
);
20 IoTag_cloneFunc_(tag
, (IoTagCloneFunc
*)IoCairoPDFSurface_rawClone
);
21 IoTag_freeFunc_(tag
, (IoTagFreeFunc
*)IoCairoSurface_free
);
25 IoCairoPDFSurface
*IoCairoPDFSurface_proto(void *state
)
27 IoObject
*self
= IoObject_new(state
);
28 IoObject_tag_(self
, IoCairoPDFSurface_newTag(state
));
30 IoState_registerProtoWithFunc_(state
, self
, IoCairoPDFSurface_proto
);
32 IoCairoSurface_addMethods(self
);
34 IoMethodTable methodTable
[] = {
35 {"create", IoCairoPDFSurface_create
},
36 {"setSize", IoCairoPDFSurface_setSize
},
39 IoObject_addMethodTable_(self
, methodTable
);
44 IoCairoPDFSurface
*IoCairoPDFSurface_rawClone(IoCairoPDFSurface
*proto
)
46 IoObject
*self
= IoObject_rawClonePrimitive(proto
);
48 IoObject_setDataPointer_(self
, cairo_surface_reference(SURFACE(proto
)));
53 /* ------------------------------------------------------------------------------------------------*/
55 IoObject
*IoCairoPDFSurface_create(IoCairoPDFSurface
*self
, IoObject
*locals
, IoMessage
*m
)
57 char *filename
= CSTRING(IoMessage_locals_symbolArgAt_(m
, locals
, 0));
58 double w
= IoMessage_locals_doubleArgAt_(m
, locals
, 1);
59 double h
= IoMessage_locals_doubleArgAt_(m
, locals
, 2);
61 return IoCairoSurface_newWithRawSurface_(IOSTATE
, m
, cairo_pdf_surface_create(filename
, w
, h
));
64 IoObject
*IoCairoPDFSurface_setSize(IoCairoPDFSurface
*self
, IoObject
*locals
, IoMessage
*m
)
66 double w
= IoMessage_locals_doubleArgAt_(m
, locals
, 0);
67 double h
= IoMessage_locals_doubleArgAt_(m
, locals
, 1);
69 cairo_ps_surface_set_size(SURFACE(self
), w
, h
);