Discussion:
transparent images/image buttons revisited
Kevin Altis
2004-10-01 10:38:58 UTC
Permalink
I've brought this up before, but since wxMac is coming along I thought it
time to bring it up again to see if a solution might finally present itself.

In the images below, the trash can is a wxStaticBitmap, the edit image is a
wxBitmapButton. Both are transparent GIFs.

Loading Image...

Loading Image...

The transparency was achieved on the wxBitmapButton by assigning a null
event to EVT_ERASE_BACKGROUND. That doesn't appear to work for GTK or the
Mac, so it is a Windows-specific hack for wxBitmapButton. Binding
EVT_ERASE_BACKGROUND doesn't appear to have any effect with a wxStaticBitmap
on Windows. Mac OS X displays outlines for both wxBitmapButton and
wxStaticBitmap.

What wxWindows needs is some way of displaying non-rectangular and/or
roundrect buttons when given an image with transparency. That is needed for
displaying a variety of buttons, including the standard style of an
icon/image with text underneath the icon typical in toolbars and icon file
system listings. It would be nice if wxBitmapButton was the control for
displaying the transparent images since it has an associated command event,
but if necessary a new control that doesn't map to an underlying native
control could be devised.

If we ever want image maps or other clickable areas in wxHtml, we'll
probably need the ability to display transparent images overlapping other
objects too.

By using just a wxStaticBitmap you can get close if you have a solid
background since there is no 3D button style applied when drawing the image.
Giving true transparency probably requires a more complex solution which
eludes me.

The wxDragImage in wxPython is probably pretty close to what is needed, but
it needs to be wrapped up to simplify its use and might need some
refactoring to reduce flickering and memory usage.

Suggestions?

ka
Vadim Zeitlin
2004-10-01 10:39:25 UTC
Permalink
On Wed, 17 Jul 2002 13:44:34 -0700 Kevin Altis <altis-***@public.gmane.org> wrote:

KA> I've brought this up before, but since wxMac is coming along I thought it
KA> time to bring it up again to see if a solution might finally present itself.

Unfortunately I have no idea about how do these things work under Mac nor
GTK so solvign this problem would require a concerted effort from at least
3 persons...

KA> The transparency was achieved on the wxBitmapButton by assigning a null
KA> event to EVT_ERASE_BACKGROUND.

I.e. not doing anything in it?

KA> That doesn't appear to work for GTK

I think EVT_ERASE_BACKGROUND under GTK only works for custom widgets, not
the standard ones.

KA> BitmapButton. Binding EVT_ERASE_BACKGROUND doesn't appear to have any
KA> effect with a wxStaticBitmap on Windows.

Strange. But wxStaticBitmap is so simple control that you could have your
own control instead -- and for it EVT_ERASE_BACKGROUND should work (under
both Windows and GTK).

KA> Mac OS X displays outlines for both wxBitmapButton and wxStaticBitmap.

Even with wxBORDER_NONE?

KA> What wxWindows needs is some way of displaying non-rectangular and/or
KA> roundrect buttons when given an image with transparency.

Support for non rectangular windows != transparency support. I think the
latter can be achieved without the former.

Regards,
VZ
Kevin Altis
2004-10-01 10:40:08 UTC
Permalink
From: Vadim Zeitlin
On Wed, 17 Jul 2002 13:44:34 -0700 Kevin Altis
KA> I've brought this up before, but since wxMac is coming along I thought it
KA> time to bring it up again to see if a solution might finally present itself.
Unfortunately I have no idea about how do these things work under Mac nor
GTK so solvign this problem would require a concerted effort from at least
3 persons...
KA> The transparency was achieved on the wxBitmapButton by
assigning a null
KA> event to EVT_ERASE_BACKGROUND.
I.e. not doing anything in it?
Correct.
KA> That doesn't appear to work for GTK
I think EVT_ERASE_BACKGROUND under GTK only works for custom widgets, not
the standard ones.
KA> BitmapButton. Binding EVT_ERASE_BACKGROUND doesn't appear to have any
KA> effect with a wxStaticBitmap on Windows.
Strange. But wxStaticBitmap is so simple control that you could have your
own control instead -- and for it EVT_ERASE_BACKGROUND should work (under
both Windows and GTK).
KA> Mac OS X displays outlines for both wxBitmapButton and wxStaticBitmap.
Even with wxBORDER_NONE?
Ah, I didn't try that.
KA> What wxWindows needs is some way of displaying non-rectangular and/or
KA> roundrect buttons when given an image with transparency.
Support for non rectangular windows != transparency support. I think the
latter can be achieved without the former.
Sorry, I should have been more clear. Non-rectangular windows aren't needed.
I think that it is okay to have a rectangular window/region. Of course, it
would be nice if non-rectangular regions were supported, but transparency is
the first order of business.

ka
Stefan Csomor
2004-10-01 10:40:10 UTC
Permalink
Post by Kevin Altis
Post by Vadim Zeitlin
Even with wxBORDER_NONE?
Ah, I didn't try that.
I don't think you have to try :-( but even if this were displaying the
flat button, the erase problem remains, root of the problem is the fact
that the control manager itself is clearing the background behind my
back, so I'd have to reroute an internal event and expose it, I am
already hooked on it in order to have proper background
colours/patterns, but exposing it via EVT_ERASE_BACKGROUND might lead to
even more problems, I have moved it to my todo list, I'll have to
experiment...

Stefan

Continue reading on narkive:
Loading...