[cairo] using cairo in c++
John Taber
jtaber at johntaber.net
Thu Oct 13 09:18:36 PDT 2005
Thanks Justin, Bill, & Carl - it's now working (Reordering the define
worked, except I had to comment out snippet, I don't think it is a cairo
command and the arc parameters then need to be actual x,y's - I took the
original code from the samples). I'll work up a nice little demo (with
saving to png screenshot) and put it in the wiki.
Next stop: testing it on Windows & OSX. I tested on Debian Linux.
Justin Carlson wrote:
> Looks like an order error. I think you want to do this instead:
>
>
> ******* test.cxx ********
>
> #define USE_CAIRO 1
>
> #include <fltk/run.h>
> #include <fltk/DoubleBufferWindow.h>
> #include <fltk/draw.h>
> #include <fltk/x.h>
>
>
> Otherwise USE_CAIRO is still undefined when you include x.h, meaning the cairo headers aren't built.
>
> -J
>
>
> On Thu, 2005-10-13 at 04:32 -0600, John Taber wrote:
>
>>Carl Worth wrote:
>>
>>>On Wed, 12 Oct 2005 09:58:21 -0700, Bill Spitzak wrote:
>>>
>>>
>>>> typedef struct cairo cairo_t;
>>>>
>>>>will work. However this should not be necessary. I believe the
>>>>definition of cairo_t has changed in cairo 1.0.0 and the x.h file needs
>>>>to be changed to match.
>>>
>>>
>>>Yes. It is now:
>>>
>>> typedef struct _cairo cairo_t;
>>>
>>
>>okay - made the above change in fltk/x.h - it recompiles without errors.
>> And added the #define but still the cairo commands are undefined -
>>here is code - am I calling cairo commands incorrectly ?
>>
>>******* new fltk/x.h ******
>>.....
>># if USE_CAIRO
>># include <cairo.h>
>># include <cairo-xlib.h>
>># else
>> typedef struct _cairo cairo_t;
>># endif
>>.......
>>
>>******* test.cxx ********
>>#include <fltk/run.h>
>>#include <fltk/DoubleBufferWindow.h>
>>#include <fltk/draw.h>
>>#include <fltk/x.h>
>>
>>#define USE_CAIRO 1
>>
>>class Drawing : public fltk::Widget {
>> void draw() {
>> fltk::push_clip(Rectangle(w(), h()));
>> snippet_normalize(fltk::cc,w(),h());
>> cairo_arc(fltk::cc, 0.5, 0.5,0.4,45.0,180.0);
>> cairo_stroke(fltk::cc);
>> fltk::pop_clip();
>> }
>>public:
>> Drawing(int X,int Y,int W,int H) : fltk::Widget(X,Y,W,H) {}
>>};
>>
>>Drawing *d;
>>
>>int main(int argc, char** argv) {
>> fltk::DoubleBufferWindow window(300,500);
>> window.begin();
>> Drawing drawing(10,10,280,280);
>> d = &drawing;
>>
>> window.end();
>> window.resizable(drawing);
>> window.show(argc,argv);
>> return fltk::run();
>>}
>>
>>
>>_______________________________________________
>>cairo mailing list
>>cairo at cairographics.org
>>http://cairographics.org/cgi-bin/mailman/listinfo/cairo
>>
More information about the cairo
mailing list