It's possible. But either you need to create a bitmap with fixed transparency in PhotoShop or similar. Or you have to manipulate the alpha-values of the bitmap directly before drawing it.So there is no way to get the semi-transparent on Windows? whether it is wxPanle or wxWindow?
How make wxPanel transparent on Windows and Linux?
Re: How make wxPanel transparent on Windows and Linux?
Use the source, Luke!
Re: How make wxPanel transparent on Windows and Linux?
Does this helps?
wxWindow::SetTransparent(wxByte alpha)
http://docs.wxwidgets.org/trunk/classwx ... 0f45a0656f
wxWindow::SetTransparent(wxByte alpha)
http://docs.wxwidgets.org/trunk/classwx ... 0f45a0656f
Re: How make wxPanel transparent on Windows and Linux?
I'm afraid it doesn't work on Windows, and other platform I didn't try...cause I tried CanSetTransparent(), but it returns false...Manolo wrote:Does this helps?
wxWindow::SetTransparent(wxByte alpha)
http://docs.wxwidgets.org/trunk/classwx ... 0f45a0656f
Re: How make wxPanel transparent on Windows and Linux?
And I also tried SetBackgroundColor(wxColour(r,g,b,a))...It also doesn't work.
Re: How make wxPanel transparent on Windows and Linux?
I tried, but just draw the bitmap with alpha channel as background still doesn't work. (I use wxPaintDC, DrawBitmap in the wxPanel's paintEvent...and I the bitmap's HasAlpha() returns true..)doublemax wrote:It's possible. But either you need to create a bitmap with fixed transparency in PhotoShop or similar. Or you have to manipulate the alpha-values of the bitmap directly before drawing it.So there is no way to get the semi-transparent on Windows? whether it is wxPanle or wxWindow?
Then, I tried to make the wxPanel transparent...(1)use the default the wxPanel(); (2)SetBackgroundStyle(wxBG_STYLE_TRANSPARENT); (3)wxPanel::Create(pParent,...) in the ctor. And I got the "semi-transparent" bitmap background......BUT, there is a problem, As my situation is a Big panel on the wxScrollWindow, and some small panel on the Big panel & they are the child of the Big panel....SO the wired problem is the small panel is totoally transparent to the wxScrolllWindow's background, withou show the Big panel ! And I really don't know how to solve this problem...
Re: How make wxPanel transparent on Windows and Linux?
Or this way is easier and more available? But what API should I use to do this? wxGraphicsContext::BeginLayer (which u said yesterday that it doesn't work on Windows)? or some other ways to do it ?doublemax wrote:Or you have to manipulate the alpha-values of the bitmap directly before drawing it.
Re: How make wxPanel transparent on Windows and Linux?
I solved there problem use SetWindowStyle(wxTRANSPARENT_WINDOW) for both the Big and Small panel. And what about another platform, can I directly use SetBackgroundStyle(wxBG_STYLE_TRANSPARENT) on MAC/LINUX instead ?
Then the problem left is how to make the various controls background "transparent"...I found a topic and just read it. http://forums.wxwidgets.org/viewtopic.php?f=1&t=38262 And can the wxStaticText get dealed with the same idea in that topic? I'am tring...by the way, is there any API such as SetWindowStyle and SetBackgroundStyle for various controls including button, statictext, combo, list, etc. I tried them for button, and they didn't work as SetWindowStyle works for panel on Windows.
Then the problem left is how to make the various controls background "transparent"...I found a topic and just read it. http://forums.wxwidgets.org/viewtopic.php?f=1&t=38262 And can the wxStaticText get dealed with the same idea in that topic? I'am tring...by the way, is there any API such as SetWindowStyle and SetBackgroundStyle for various controls including button, statictext, combo, list, etc. I tried them for button, and they didn't work as SetWindowStyle works for panel on Windows.
Re: How make wxPanel transparent on Windows and Linux?
I only work under Windows and don't know about other platforms, you may have to try it out.And what about another platform, can I directly use SetBackgroundStyle(wxBG_STYLE_TRANSPARENT) on MAC/LINUX instead ?
Displaying native controls semi-transparently over custom background is practically impossible.by the way, is there any API such as SetWindowStyle and SetBackgroundStyle for various controls including button, statictext, combo, list, etc. I tried them for button, and they didn't work as SetWindowStyle works for panel on Windows.
Use the source, Luke!
Re: How make wxPanel transparent on Windows and Linux?
not semi-transparent...I saw it override the SetTransparent kinda of API from wxWindow...but it doesn't work like wxPaneldoublemax wrote:Displaying native controls semi-transparently over custom background is practically impossible.
Re: How make wxPanel transparent on Windows and Linux?
I use wxScrollWindow<wxPanel> as the main frame, and it's not transparent or semi-transparent...
the small myPanel I use the bitmap way to make it semi-transparent, but
(1) eg, if i use dc draw sth on the wxScollWindow, expect the 1st I constuct on the thing I drawn on wxScrollWindow it it seems semi-transparent, other situaions if I drag it to another position and refresh() it seems not semi-transparent.
(2) myPanel(include various controls) are just construct as the wxScrollWindow's children, and i just drawn it's background bitmap, which I mean I didn't control the controls' drawing......So if I use wxScrollWindow dc draw sth, they are always on the bottom of the myPanel(and the controls on it)...is there any way to draw the things at the top of them?
the small myPanel I use the bitmap way to make it semi-transparent, but
(1) eg, if i use dc draw sth on the wxScollWindow, expect the 1st I constuct on the thing I drawn on wxScrollWindow it it seems semi-transparent, other situaions if I drag it to another position and refresh() it seems not semi-transparent.
(2) myPanel(include various controls) are just construct as the wxScrollWindow's children, and i just drawn it's background bitmap, which I mean I didn't control the controls' drawing......So if I use wxScrollWindow dc draw sth, they are always on the bottom of the myPanel(and the controls on it)...is there any way to draw the things at the top of them?
Re: How make wxPanel transparent on Windows and Linux?
I have difficulties understanding what exactly you're asking, so i'll answer more generally:
The wxScrolledWindow is the background of everything, so AFAIU it will not be transparent. The panels on top should be semi-transparent so that the background ( the wxScrolledWindow ) shines through.
When you're drawing the panel using the method i suggested earlier, you're actually just faking the transparency. Because first you're drawing the background from the parent ( the wxScrolledWindow ) without transparency, then you draw the other content of the panel with 50% (or whatever) transparency.
The wxScrolledWindow is the background of everything, so AFAIU it will not be transparent. The panels on top should be semi-transparent so that the background ( the wxScrolledWindow ) shines through.
When you're drawing the panel using the method i suggested earlier, you're actually just faking the transparency. Because first you're drawing the background from the parent ( the wxScrolledWindow ) without transparency, then you draw the other content of the panel with 50% (or whatever) transparency.
Use the source, Luke!
Re: How make wxPanel transparent on Windows and Linux?
Yes I know, my problem is when i create the myPanle, it's semi-transparent...but once I move the myPanel(I called Refresh), it seems still semi-transparent, but when I drawed a circle on the wxScrollWindow use paintEve and dc, after I move the myPanel, the circle I can''t see through the semi-transparent myPanel(meanwhile, I think it's still semi-tranparent, but through it I can just see the wxScrollWindow color which I set by SetBackgroundColour)doublemax wrote:I have difficulties understanding what exactly you're asking, so i'll answer more generally:
The wxScrolledWindow is the background of everything, so AFAIU it will not be transparent. The panels on top should be semi-transparent so that the background ( the wxScrolledWindow ) shines through.
When you're drawing the panel using the method i suggested earlier, you're actually just faking the transparency. Because first you're drawing the background from the parent ( the wxScrolledWindow ) without transparency, then you draw the other content of the panel with 50% (or whatever) transparency.
Re: How make wxPanel transparent on Windows and Linux?
In that case, if the parent window contains more than just a background bitmap, you need a way to tell the parent window to render into another wxDC.but when I drawed a circle on the wxScrollWindow use paintEve and dc, after I move the myPanel, the circle I can''t see through the semi-transparent myPanel
Something like this:
Code: Select all
MyScrolledWindow::Render( wxDC &dc, const wxRect &rect )
{
// this code needs to draw the content of the given rect into that wxDC
}
MyChildPanel::OnPaint( wxPaintEvent &event )
{
wxBufferedPaintDC dc(this);
MyScrolledWindow *parent = wxDynamicCast( GetParent(), MyScrolledWindow );
if( parent!=NULL )
{
parent->Render( dc, GetRect() );
// now draw the content of your panel of top of the background
}
}
Use the source, Luke!
Re: How make wxPanel transparent on Windows and Linux?
I tried like this:
the result now is that the Child's background not semi-transparent, and the back groundcolor is black, the bitmap is on the black.
is the DC wrong somewhere ?
Code: Select all
Parent::paintEvent(wxPaintEvent&)
{
wxPaintDC(this); //
Render(dc, GetRect());
}
Parent::Render(wxDC& dc, const wxRect&)
{
dc.setPen();
//draw sth
dc.SetPen(wxNullPen);
}
//////////////////////////////////////
Child::paintEvent(wxPaintEvent&)
{
wxBufferedPaintDC(this); //
Render(dc, GetRect());
}
Child::Render(wxDC& dc, const wxRect&)
{
//..getParent
parent->Render(dc, GetRect());
dc.DrawBitmap; //the semi-transparent background
}
is the DC wrong somewhere ?