RcStyle::set_bg_pixmap_name() working only for some classes



I'd like to install a pixmap (not known until runtime) as the
background image for a widget.

Using a custom RcStyle with the "bg_pixmap" property set seems like it
ought to do the chore:

 Gtk::Widget w = ...;
 const Glib::RefPtr<Gtk::RcStyle> style = Gtk::RcStyle::create ();
 style->set_bg_pixmap_name (Gtk::STATE_NORMAL, "/path/to/image.png");
 w.modify_style (style);

This only seems to work for those classes (and not their derived
classes) which are not GTK_WIDGET_NO_WINDOW. That is, it works for
Gtk::DrawingArea, Gtk::EventBox, and a couple of others.

If I try to instantiate "w" above as an instance of the following class:

   class DerivedEventBox : public Gtk::EventBox
   {
       public:
           DerivedEventBox () : Gtk::EventBox () {}
           virtual ~DerivedEventBox() {}
   };

the background PNG does not appear. Yet if I do a trivial
GObject-based subclass of GtkEventBox and use the result of
Glib::wrap() as the value of "w" above, the pixmap appears [as
expected?].

Is there some subtlety to the way that the GType inheritance works in
parallel with the C++ inheritance?



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