Salut,

Je souhaite créer une image dans une colonne d'un tableau. J'ai crée un TreeView et une colonne CellRendererPixbuf.
Je fait un appel à set_cell_data_func() pour définir le pixbuf.

Voici le code de ma méthode :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
	int size = 100;
	int height = 13;
	int width = 200;
	Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, size, size);
Cairo::RefPtr<Cairo::ImageSurface> surface = Cairo::ImageSurface::create(pixbuf->get_pixels(), Cairo::FORMAT_ARGB32, size, size, pixbuf->get_rowstride() );
Cairo::RefPtr<Cairo::Context> context = Cairo::Context::create(surface);
		context->save();
		context->set_operator(Cairo::OPERATOR_CLEAR);
		context->paint();
		context->restore();
 
		context->save();
		context->set_source_rgba(1.0, 1.0, .0, 1.0);
		context->select_font_face("Monaco", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_BOLD);
		context->set_font_size(8);
		context->move_to(9, height - 4);
		context->show_text ("categorie");
 
		context->paint_with_alpha(0.6);
		context->restore();
 
	Gdk::Cairo::set_source_pixbuf(context, pixbuf, size, size);
(dynamic_cast<Gtk::CellRendererPixbuf *> (renderer))->property_pixbuf() = pixbuf;
Je ne comprend pas pourquoi le fond prend la dernière couleur utilisée

edit: il faut déplacer la ligne Gdk:Cairo::set_source_pixbuf aec context->paint();