FIX: [STUDIO-1746] transparent background for images of swtich button

Change-Id: I30012a756242816a69099d211bea444bebc4277d
(cherry picked from commit b1efb320cc4290406001994d45b0ef182d6cce30)
This commit is contained in:
chunmao.guo 2023-02-06 10:47:53 +08:00 committed by Lane.Wei
parent af7c6502f3
commit 3065771b2c
1 changed files with 8 additions and 0 deletions

View File

@ -100,10 +100,18 @@ void SwitchButton::Rescale()
}
for (int i = 0; i < 2; ++i) {
wxMemoryDC memdc(&dc);
#ifdef __WXMSW__
wxBitmap bmp(trackSize.x, trackSize.y);
memdc.SelectObject(bmp);
memdc.SetBackground(wxBrush(GetBackgroundColour()));
memdc.Clear();
#else
wxImage image(trackSize);
image.InitAlpha();
memset(image.GetAlpha(), 0, trackSize.GetWidth() * trackSize.GetHeight());
wxBitmap bmp(std::move(image));
memdc.SelectObject(bmp);
#endif
memdc.SetFont(dc.GetFont());
auto state = i == 0 ? StateColor::Enabled : (StateColor::Checked | StateColor::Enabled);
{