ENH: add badge for StaticBox and StaticGroup

Change-Id: I8b6e7938de524102809784b078de337da789cde8
Jira: STUDIO-8858
(cherry picked from commit 9733ef0144aebb0c6e711b7d56c36a3d187f628a)
This commit is contained in:
chunmao.guo
2024-11-25 10:47:15 +08:00
committed by Noisyfox
parent c92347ce51
commit c9ed30bc59
7 changed files with 90 additions and 4 deletions

View File

@@ -22,7 +22,7 @@ StaticBox::StaticBox()
, radius(8)
{
border_color = StateColor(
std::make_pair(0xF0F0F1, (int) StateColor::Disabled),
std::make_pair(0xF0F0F1, (int) StateColor::Disabled),
std::make_pair(0x303A3C, (int) StateColor::Normal));
}
@@ -110,6 +110,15 @@ wxColor StaticBox::GetParentBackgroundColor(wxWindow* parent)
return *wxWHITE;
}
void StaticBox::ShowBadge(bool show)
{
if (show)
badge = ScalableBitmap(this, "badge", 18);
else
badge = ScalableBitmap {};
Refresh();
}
void StaticBox::eraseEvent(wxEraseEvent& evt)
{
// for transparent background, but not work
@@ -218,4 +227,9 @@ void StaticBox::doRender(wxDC& dc)
lb += db; while (lb >= size.y) { ++b, lb -= size.y; } while (lb <= -size.y) { --b, lb += size.y; }
}
}
if (badge.bmp().IsOk()) {
auto s = badge.bmp().GetScaledSize();
dc.DrawBitmap(badge.bmp(), size.x - s.x, 0);
}
}