Oh boy .. this is getting deeper and deeper.<br><br>Macport's Cairomm port does not contain quartz_surface.h since it is not included in the official 1.2.4 version (<a href="http://cairographics.org/releases/cairomm-1.2.4.tar.gz">
http://cairographics.org/releases/cairomm-1.2.4.tar.gz</a>). I've checked out cairomm from CVS and I've managed to install it with quartz support (freshly checked out version is 1.0). Apart from the versioning mistery so far so good.
<br>Now the stupid-beginner question: how can I use the installed cairomm from Xcode? It is installed under /usr/... that is unfortunatelly unusable from Xcode + I have no experience using 3rd party libraries within Xcode.
<br><br>Could you adwise something?:)<br><br>Cheers,<br>P<br><br><br><div><span class="gmail_quote">On 6/21/07, <b class="gmail_sendername">Hugo Vincent</b> <<a href="mailto:hugo.vincent@gmail.com">hugo.vincent@gmail.com
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Here is a simple example I put together when I went through this<br>exact painful process a couple of months back. I haven't tested it
<br>for a while, but it seems to still run and might be of use still.<br>Also, this uses Cairomm, but you should be able to figure it out the<br>minor changes in API to change it from Cairomm to plain Cairo.<br><br>Cheers,
<br>Hugo Vincent.<br><br>-----------------------------------------------------------<br>testview.h:<br>-----------------------------------------------------------<br><br>#import <Cocoa/Cocoa.h><br><br>// Put one of these views into your layout in Interface Builder.
<br>@interface TestView : NSView<br>{<br> // nothing needed here<br>}<br>@end<br><br>-----------------------------------------------------------<br>testview.m<br>-----------------------------------------------------------
<br><br>#include <cairomm/cairomm.h><br>#include <cairomm/quartz_surface.h><br><br>#ifndef CAIRO_HAS_QUARTZ_SURFACE<br>#error Need to build Cairo with Quartz support (version 1.4.0 or higher)<br>#endif<br><br>
@implementation TestView<br><br>- (id)initWithFrame:(NSRect)frameRect<br>{<br> if ((self = [super initWithFrame:frameRect]) != nil)<br> {<br> // nothing needed here<br> }<br> return self;
<br>}<br><br>- (BOOL)isOpaque<br>{<br> return NO;<br>}<br><br>- (void)drawRect:(NSRect)rect<br>{<br> // Get the size of this NSView<br> NSRect bounds = [self bounds];<br> int width = bounds.size.width
;<br> int height = bounds.size.height;<br><br> // Get CoreGraphcis context reference<br> CGContextRef ctx = (CGContextRef)[[NSGraphicsContext currentContext]<br>graphicsPort];<br><br> // Make the CGContext coordinate system sane, as expected by Cairo
<br> CGContextTranslateCTM (ctx, 0.0, height);<br> CGContextScaleCTM (ctx, 1.0, -1.0);<br><br> // Create the Cairo surface and context<br> Cairo::RefPtr<Cairo::QuartzSurface> surface =<br>
Cairo::QuartzSurface::create(ctx, width, height);<br> Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);<br><br> // Cairo-Quartz fallback surfaces don't work properly, so we need to
<br>create a temp. surface like this:<br> cr->push_group();<br><br> //---------- Drawing stuff (put your code in here)<br>-------------------------------<br> // Draw a radial gradient (copied and pasted, more or less, from
<br><a href="http://cairographics.org/samples/gradient.html">http://cairographics.org/samples/gradient.html</a>)<br> cr->scale(width,height);<br> Cairo::RefPtr<Cairo::RadialGradient> grad2 =<br>Cairo::RadialGradient::create(
0.45, 0.4, 0.1, 0.4, 0.4, 0.5);<br> grad2->add_color_stop_rgba(0, 1,0,0, 1);<br> grad2->add_color_stop_rgba(1, 0,1,0, 1);<br> cr->set_source(grad2);<br> cairo_arc (cr, 0.5, 0.5, 0.3, 0, 2 * M_PI);
<br> cr->fill();<br> //---------------------------------------------------------------------<br>-----------<br><br> // Finally, paint the temporary surface we made<br> cr->pop_group_to_source();
<br> cr->paint();<br>}<br><br>@end<br><br><br>On 21/06/2007, at 7:00 AM, <a href="mailto:cairo-request@cairographics.org">cairo-request@cairographics.org</a> wrote:<br>> Message: 1<br>> Date: Wed, 20 Jun 2007 15:52:51 +0200
<br>> From: " Ipacs P?ter " <<a href="mailto:peter@ipacs.hu">peter@ipacs.hu</a>><br>> Subject: [cairo] [cairo osx] OS X example<br>> To: <a href="mailto:cairo@cairographics.org">cairo@cairographics.org
</a><br>> Message-ID:<br>> <<a href="mailto:6a86db250706200652m24dd6b9di17a881912402da62@mail.gmail.com">6a86db250706200652m24dd6b9di17a881912402da62@mail.gmail.com</a>><br>> Content-Type: text/plain; charset="utf-8"
<br>><br>> Hi there,<br>><br>> I'm quite new to cairo so please excuse me if I ask obvious<br>> questions:)<br>><br>> I'm trying to build the quartz example from the CVS (<br>> <a href="http://webcvs.cairographics.org/cairo-demo/quartz/">
http://webcvs.cairographics.org/cairo-demo/quartz/</a>) but it fails.<br>> This is what I get:<br>> cc -g -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-<br>> declarations<br>> -Wredundant-decls `pkg-config --cflags cairo` -c -o
main.o main.c<br>> main.c: In function 'TestWindowEventHandler':<br>> main.c:65: error: incompatible type for argument 1 of<br>> 'cairo_quartz_surface_create'<br>> main.c: In function 'RedrawTimerCallback':
<br>> main.c:188: warning: 'SetRect' is deprecated (declared at<br>> /System/Library/Frameworks/ApplicationServices.framework/Frameworks/<br>> QD.framework/Headers/Quickdraw.h:2401)<br>> main.c: In function 'CreateTestWindow':
<br>> main.c:205: warning: 'SetRect' is deprecated (declared at<br>> /System/Library/Frameworks/ApplicationServices.framework/Frameworks/<br>> QD.framework/Headers/Quickdraw.h:2401)<br>> make: *** [main.o
] Error 1<br>><br>> What do you think about it?<br>><br>> Another question:<br>> Are there any OS X examples around that can be used out-of-the-box?<br>> I mean<br>> examples that does not require hundreds of dependencies and can be
<br>> compiled<br>> by a simple 'make' or something.<br>><br>> Cheers,<br>> Peter<br><br>_______________________________________________<br>cairo mailing list<br><a href="mailto:cairo@cairographics.org">
cairo@cairographics.org</a><br><a href="http://cairographics.org/cgi-bin/mailman/listinfo/cairo">http://cairographics.org/cgi-bin/mailman/listinfo/cairo</a><br></blockquote></div>