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

@@ -0,0 +1,33 @@
#include "StaticGroup.hpp"
StaticGroup::StaticGroup(wxWindow *parent, wxWindowID id, const wxString &label)
: wxStaticBox(parent, id, label)
{
#ifdef __WXMSW__
Bind(wxEVT_PAINT, &StaticGroup::OnPaint, this);
#else
#endif
}
void StaticGroup::ShowBadge(bool show)
{
if (show)
badge = ScalableBitmap(this, "badge", 18);
else
badge = ScalableBitmap{};
Refresh();
}
#ifdef __WXMSW__
void StaticGroup::OnPaint(wxPaintEvent &evt)
{
wxStaticBox::OnPaint(evt);
if (badge.bmp().IsOk()) {
auto s = badge.bmp().GetScaledSize();
wxPaintDC dc(this);
dc.DrawBitmap(badge.bmp(), GetSize().x - s.x, 8);
}
}
#endif