Updating built in Io code to use += instead of x = x + y
[io/quag.git] / addons / Cairo / source / _IoCairoPDFSurface.c
blobc6310966eebadd82c1d36bf529b2492dc1f8f374
1 /*#io
2 CairoPDFSurface ioDoc(
3 docCopyright("Daniel Rosengren", 2007)
4 docLicense("BSD revised")
5 docCategory("Graphics")
6 */
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);
22 return tag;
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},
37 {NULL, NULL},
39 IoObject_addMethodTable_(self, methodTable);
41 return self;
44 IoCairoPDFSurface *IoCairoPDFSurface_rawClone(IoCairoPDFSurface *proto)
46 IoObject *self = IoObject_rawClonePrimitive(proto);
47 if (SURFACE(proto))
48 IoObject_setDataPointer_(self, cairo_surface_reference(SURFACE(proto)));
49 return self;
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);
70 CHECK_STATUS(self);
71 return self;
74 #endif