Re: Wheelbarrow example with Gtkmm on DirectFB



Reposting to list with additional comments:

José Alburquerque said the following:
Phoenix Revived said the following:
Yes, I am able to get it to work on X11. I need some help in making it work on DirectFB.

The problem could be a difference in how the video drivers handle transparency and may not even be related to gtkmm. You might try using the C API and seeing if there's a difference. You could then ask on the gtk list and see if they have some insight.

To help a little more, the following lines that appear in the constructor seem to be relevant:

1  realize(); // the widget must be realized to create the GDK window
2  const Glib::RefPtr<const Gdk::Drawable> drawable = get_window();
3 const Gdk::Color transparent = Gtk::Widget::get_default_style()->get_bg(Gtk::STATE_NORMAL);

4  Glib::RefPtr<Gdk::Bitmap>       mask;
5  const Glib::RefPtr<Gdk::Pixmap> pixmap =
Gdk::Pixmap::create_from_xpm(drawable, mask, transparent, wheelbarrow_xpm);

6  Gtk::Image *const image = new Gtk::Image(pixmap, mask);
7  add(*Gtk::manage(image));

 ...

 // Mask out transparent parts of the pixmap.
8  shape_combine_mask(mask, 0, 0);

The ones that are interesting are the getting of the "transparent" color with the default style[1] (line 3 above), and the creating of the "pixmap" with Gdk::Pixmap::create_from_xpm[2] (line 5 above), which sets the "mask" parameter to a mask that can be used to create a Gtk::Image (line 6 above) and for transparent windows (line 8 above). Also interesting is the actual "masking out" of the background color with the call to Gtk::Widget::shape_combine_mask[3] (line 8 above).

You could try different things with those lines and see if things work for your setup. For example, the Gtk::Style class has methods such as get_white[4] which might do something interesting in your case. The trick might be to understand what the lines do. For that you might look into Gtk::Style, Gdk::Pixmap[5] and the methods in Gtk::widget[6] that deal with masks like the one in line 8 above.

[1] http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1Style.html [2] http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGdk_1_1Pixmap.html#0c8f0c29a699ff740c23414d49598516 [3] http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1Widget.html#62b87786cfecfaf40239a3bdc9118866 [4] http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1Style.html#c21a682c9fddadb11bf38b0a71fec915 [5] http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGdk_1_1Pixmap.html [6] http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1Widget.html

Cheers,
    ---AK


--
José Alburquerque
jaalburquerque cox net



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]