ENH: [STUDIO-1272] handle default filament color in presetcomboxbox

Change-Id: Id78749db063fd222915b1aa5ad6abf47fb4294ca
This commit is contained in:
chunmao.guo 2022-11-10 15:42:11 +08:00 committed by Lane.Wei
parent 8340e1ceec
commit 5761f8c050
5 changed files with 68 additions and 41 deletions

View file

@ -1444,14 +1444,21 @@ void ColourPicker::set_undef_value(wxColourPickerCtrl* field)
field->SetColour(wxTransparentColour);
wxButton* btn = dynamic_cast<wxButton*>(field->GetPickerCtrl());
wxBitmap bmp = btn->GetBitmap();
wxImage image(btn->GetBitmap().GetSize());
image.InitAlpha();
memset(image.GetAlpha(), 0, image.GetWidth() * image.GetHeight());
wxBitmap bmp(std::move(image));
wxMemoryDC dc(bmp);
if (!dc.IsOk()) return;
dc.SetTextForeground(*wxWHITE);
dc.SetFont(wxGetApp().normal_font());
#ifdef __WXMSW__
wxGCDC dc2(dc);
#else
wxDC &dc2(dc);
#endif
dc2.SetPen(wxPen("#F1754E", 1));
const wxRect rect = wxRect(0, 0, bmp.GetWidth(), bmp.GetHeight());
dc.DrawLabel("undef", rect, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL);
dc2.DrawLine(rect.GetLeftBottom(), rect.GetTopRight());
dc.SelectObject(wxNullBitmap);
btn->SetBitmapLabel(bmp);