[cairo] using cairo in c++

John Taber jtaber at johntaber.net
Thu Oct 13 03:32:02 PDT 2005


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();
}




More information about the cairo mailing list