FIX: StaticBox background color

Change-Id: Ifbb0bc4ac3e0a69675f16dc3234b4190fff698fb
This commit is contained in:
chunmao.guo 2022-09-05 17:24:32 +08:00 committed by Lane.Wei
parent b03a16054b
commit dd0ccfb6e9
2 changed files with 12 additions and 4 deletions

View File

@ -169,7 +169,10 @@ void StaticBox::doRender(wxDC& dc)
} else {
dc.SetPen(wxPen(background_color.colorForStates(states)));
}
dc.SetBrush(wxBrush(background_color.colorForStates(states)));
if (background_color.count() > 0)
dc.SetBrush(wxBrush(background_color.colorForStates(states)));
else
dc.SetBrush(wxBrush(GetBackgroundColour()));
if (radius == 0) {
dc.DrawRectangle(rc);
}

View File

@ -144,7 +144,13 @@ void StepCtrl::mouseMove(wxMouseEvent &event)
wxPoint pt;
event.GetPosition(&pt.x, &pt.y);
pos_thumb.x = pt.x + drag_offset.x;
Refresh();
wxSize size = GetSize();
int itemWidth = size.x / steps.size();
int index = pos_thumb.x / itemWidth;
if (index != pos_thumb.y) {
pos_thumb.y = index;
Refresh();
}
}
void StepCtrl::mouseUp(wxMouseEvent &event)
@ -160,7 +166,6 @@ void StepCtrl::mouseUp(wxMouseEvent &event)
void StepCtrl::doRender(wxDC &dc)
{
if (steps.empty()) return;
StaticBox::doRender(dc);
wxSize size = GetSize();
@ -177,7 +182,7 @@ void StepCtrl::doRender(wxDC &dc)
dc.SetPen(wxPen(clr_step.colorForStates(states)));
dc.SetBrush(wxBrush(clr_step.colorForStates(states)));
for (int i = 0; i < steps.size(); ++i) {
bool check = pos_thumb == wxPoint{0, 0} ? step == i : (pos_thumb.x >= circleX - itemWidth / 2 && pos_thumb.x < circleX + itemWidth / 2);
bool check = (pos_thumb == wxPoint{0, 0} ? step : pos_thumb.y) == i;
dc.DrawEllipse(circleX - radius, circleY - radius, radius * 2, radius * 2);
dc.SetFont(GetFont());
dc.SetTextForeground(clr_text.colorForStates(states | (check ? StateColor::Checked : 0)));