How make wxPanel transparent on Windows and Linux?
Re: How make wxPanel transparent on Windows and Linux?
In principle it should work this way, but i can't tell you where exactly it fails.
First try without the child panels and make sure that the parent window redraws correctly. Then add the panel, try commenting out parts of the paining process to see where it fails.
First try without the child panels and make sure that the parent window redraws correctly. Then add the panel, try commenting out parts of the paining process to see where it fails.
Use the source, Luke!
Re: How make wxPanel transparent on Windows and Linux?
the parent is ok...but when I use wxBufferedPaintDC in Child, the background is black, it seems that the bitmap draws on a blackground buffer.....doublemax wrote:In principle it should work this way, but i can't tell you where exactly it fails.
First try without the child panels and make sure that the parent window redraws correctly. Then add the panel, try commenting out parts of the paining process to see where it fails.
Re: How make wxPanel transparent on Windows and Linux?
Yes, by default it's empty (=black). You shouldn't rely on any content there, the rendering code from the parent would usually draw a background bitmap there or clear it with the background color.the parent is ok...but when I use wxBufferedPaintDC in Child, the background is black, it seems that the bitmap draws on a blackground buffer.....
Use the source, Luke!
Re: How make wxPanel transparent on Windows and Linux?
the parent is just set a background color, and draw some simple geometry,
the child panel have a semi-transparent bitmap...but the background is still black, is there any API should be called else?
the child panel have a semi-transparent bitmap...but the background is still black, is there any API should be called else?
Re: How make wxPanel transparent on Windows and Linux?
Maybe show a screenshot and/or more real code. Ideally a minimal compilable sample that shows the problem.
Use the source, Luke!
Re: How make wxPanel transparent on Windows and Linux?
Code: Select all
Parent::paintEvent(wxPaintEvent&)
{
wxPaintDC(this); //
Render(dc, GetRect());
}
Parent::Render(wxDC& dc, const wxRect&)
{
//dc.setPen();
//HERE, just draw some simple line for test now
//dc.SetPen(wxNullPen);
}
//////////////////////////////////////
Child::paintEvent(wxPaintEvent&)
{
wxBufferedPaintDC(this); //
Render(dc, GetRect());
}
Child::Render(wxDC& dc, const wxRect&)
{
//..getParent
parent->Render(dc, GetRect());
dc.DrawBitmap; //draw the child's semi-transparent background
}
And i don't use the rect got from GetRect(), is there problem?
Re: How make wxPanel transparent on Windows and Linux?
Code: Select all
Parent::Render(wxDC& dc, const wxRect&)
{
//dc.setPen();
//HERE, just draw some simple line for test now
//dc.SetPen(wxNullPen);
}
Code: Select all
Parent::Render(wxDC& dc, const wxRect&)
{
dc.SetBrush( *wxWHITE_BRUSH);
dc.SetPen( *wxWHITE_PEN);
dc.DrawRectangle( rect );
dc.SetPen( *wxBLACK_PEN );
...
// more drawing here
}
This will definitely be a problem in the final code, because the background of the panel will contain the same drawing as the upper left corner of the parent.And i don't use the rect got from GetRect(), is there problem?
Use the source, Luke!
Re: How make wxPanel transparent on Windows and Linux?
But where should I use it ?This will definitely be a problem in the final code, because the background of the panel will contain the same drawing as the upper left corner of the parent.
Re: How make wxPanel transparent on Windows and Linux?
Use wxDC::SetDeviceOrigin(...) so that you're drawing the correct portion of the parent background into the panel's background.
Use the source, Luke!
Re: How make wxPanel transparent on Windows and Linux?
I don't clear the background...I just use dc.DrawLine draw some lines, that's all i did, the only API i call.doublemax wrote: Parent::Render(wxDC& dc, const wxRect&)
{
//dc.setPen();
//HERE, just draw some simple line for test now
//dc.SetPen(wxNullPen);
}
The question is what exactly you're drawing here, i.e. do you clear the background before drawing any lines?
Re: How make wxPanel transparent on Windows and Linux?
the problem is solved, it's the SetdeviceOrigin problem
and I used wxPaintDC for both the parent and child, cause if use wxBufferedDC for the Child , the Child's background is always black!
thanks!
and I used wxPaintDC for both the parent and child, cause if use wxBufferedDC for the Child , the Child's background is always black!
thanks!