Hi there, I love FLTK and Fluid because I hate wasting my time on the GUI
corner. However, i just wanted to have some fun with Cairo and simply use an
image for rendering and put it in a widget (button in this case), but I have
some troubles to redraw the widget, and there is no problem on the Cairo side
(use pdf output to check it)
Here's my stupid code:
<<
#include <stdlib.h>
#include <unistd.h>
#include <iostream>
using namespace std;
//Cairo
#include <cairo/cairo.h>
#include <cairo/cairo-pdf.h>
//Fluid interface stuff
#include "cairo.h"
#include <Fl/Fl_Image.H>
//Basic cairo test on pdf
void draw_cairo_pdf() {
cairo_surface_t *surface;
cairo_t *cr;
surface = cairo_pdf_surface_create ("foo.pdf",
120,
120);
cr = cairo_create (surface);
cairo_set_line_width (cr, 5);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_rectangle (cr, 5, 5, 100, 100);
cairo_stroke (cr);
cairo_surface_finish (surface);
cairo_surface_destroy (surface);
}
//Fluid call backs
void on_quitButton(Fl_Button*, void*) {
cout << "Bye !" << endl;
exit(0);
}
void on_b(Fl_Button *b, void*) {
cout << "let's burn" << endl;
cairo_surface_t *surface;
cairo_t *cr;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 120, 120);
cr = cairo_create (surface);
cairo_set_line_width (cr, 5);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_rectangle (cr, 5, 5, 100, 100);
cairo_stroke (cr);
if ( cairo_image_surface_get_data(surface) == NULL ) { cout << "cairo problem"
<< endl; }
Fl_RGB_Image *rgb = new Fl_RGB_Image(cairo_image_surface_get_data(surface),0,0
,120,120);
b->image(rgb);
b->deimage(rgb);
b->parent()->redraw();
}
int main(int argc, char **argv) {
Fl_Window *mainWindow = make_mainWindow();
draw_cairo_pdf();
mainWindow->end();
mainWindow->show(argc, argv);
return Fl::run();
}
>>
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk