int CItem::gate_id = -1;
-CItem::CItem(const char *filename):Gtk::DrawingArea()
+CItem::CItem(const char *filename)
{
image = Gdk::Pixbuf::create_from_file(filename);
set_size_request(image->get_width(), image->get_height());
+
+ add_events(Gdk::EXPOSURE_MASK);
}
CItem::CItem()
std::cout << "Item Die" << std::endl;
}
+void CItem::on_realize()
+{
+ Gtk::DrawingArea::on_realize();
+ Glib::RefPtr<Gdk::Window> window = get_window();
+ gc = Gdk::GC::create(window);
+
+ Glib::RefPtr<Gdk::Colormap> colormap = get_colormap();
+
+ red = Gdk::Color("red");
+ blue = Gdk::Color("blue");
+
+ colormap->alloc_color(red);
+ colormap->alloc_color(blue);
+}
+
bool CItem::on_expose_event(GdkEventExpose* event)
{
- image->render_to_drawable ( get_window(), get_style()->get_black_gc(), 0, 0, 0, 0, image->get_width() ,image->get_height() ,
+ get_window()->draw_pixbuf(gc, image, 0, 0, 0, 0, image->get_width() ,image->get_height(),
Gdk::RGB_DITHER_NONE, 0, 0);
// XXX Esto no deberia ser necesario! en todo caso devolves false en