[wx-dev] Menu Disable: Image becomes distorted

Paul Cornett pc-wx at bullseye.com
Tue Jul 15 16:02:55 PDT 2008


Vadim Zeitlin wrote:
>On Wed, 16 Jul 2008 01:29:45 +0530 Priyank Bolia
><priyank.bolia at gmail.com> wrote:
>
>PB> Finally figured out the root cause, as the wxBitmap constructor
>PB> creates a PixMap by calling SetPixmap, which sets m_pixbuf = NULL.
>PB> This causes the HasPixbuf in the wxMenu::GtkAppend to fail.
>PB> If you look at the bug: http://trac.wxwidgets.org/ticket/4185
>PB> In wxBitmapButton we don't do any such check, hence removing the
>PB> HasPixbuf check from the wxMenu::GtkAppend also, and everything
>PB> works fine.
>
> And I think I now even see why does it work fine. Let me explain how
> do I
>understand it and please correct me if I'm wrong:
>
> You have a wxBitmap which uses a pixmap internally (as is normal for
> all
>bitmaps except those created with Create(w, h, 32)) and also has a
>mask. So HasPixbuf() returns false for it and hence
>gtk_image_new_from_pixmap() is used in wxMenu::GtkAppend(). However
>gtk_image_new_from_pixmap() doesn't know anything about the mask,

It does know about the mask, it is a parameter. I suspect the problem
may be that our convention for interpreting the mask is inverted from
theirs (just a guess, I haven't looked at it yet).

>hence it doesn't take it into account and transparent areas are
>rendered as junk. While if you just use GetPixbuf() it works because
>it creates the pixbuf from pixmap using the same
>gdk_pixbuf_get_from_drawable() function as gtk_image_new_from_pixmap()
>uses internally but then also sets up its alpha channel to be 0 for
>transparent pixels.

It seems like using pixbufs would be better, since that is what
GtkImage uses internally anyway.


More information about the wx-dev mailing list