FIX: focus state of CheckBox

Change-Id: Iceac4b9877a07e4517250255203c2e0ecdbc34ac
This commit is contained in:
chunmao.guo 2022-07-29 13:29:09 +08:00 committed by Lane.Wei
parent ec59446e44
commit 807cc2236d
7 changed files with 38 additions and 16 deletions

View file

@ -0,0 +1,4 @@
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="1" y="1" width="16" height="16" rx="1" fill="#37EE7C"/>
<path d="M4 9L14 9" stroke="white" stroke-linecap="round"/>
</svg>

After

Width:  |  Height:  |  Size: 232 B

View file

@ -1,4 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="0.5" y="0.5" width="15" height="15" rx="0.5" stroke="#ACACAC"/>
</svg>
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="1.5" y="1.5" width="15" height="15" rx="0.5" stroke="#ACACAC"/>
</svg>

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 176 B

View file

@ -0,0 +1,3 @@
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="1.5" y="1.5" width="15" height="15" rx="0.5" stroke="#00AE42"/>
</svg>

After

Width:  |  Height:  |  Size: 176 B

View file

@ -1,5 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="16" height="16" rx="1" fill="#00AE42"/>
<path d="M3.35537 7.5374L7.30284 10.9361C7.71855 11.294 8.34501 11.2502 8.70687 10.838L13.8175 5.01521" stroke="white" stroke-width="1.2" stroke-linecap="round"/>
</svg>
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="1" y="1" width="16" height="16" rx="1" fill="#00AE42"/>
<path d="M4.35537 8.5374L8.30284 11.9361C8.71855 12.294 9.34501 12.2502 9.70687 11.838L14.8175 6.01521" stroke="white" stroke-width="1.2" stroke-linecap="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 335 B

After

Width:  |  Height:  |  Size: 331 B

View file

@ -0,0 +1,4 @@
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="1" y="1" width="16" height="16" rx="1" fill="#37EE7C"/>
<path d="M4.35537 8.5374L8.30284 11.9361C8.71855 12.294 9.34501 12.2502 9.70687 11.838L14.8175 6.01521" stroke="white" stroke-width="1.2" stroke-linecap="round"/>
</svg>

After

Width:  |  Height:  |  Size: 331 B

View file

@ -4,12 +4,15 @@
CheckBox::CheckBox(wxWindow* parent)
: wxBitmapToggleButton(parent, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE)
, m_on(this, "check_on", 16)
, m_half(this, "check_half", 16)
, m_off(this, "check_off", 16)
, m_on_disabled(this, "check_on_disabled", 16)
, m_half_disabled(this, "check_half_disabled", 16)
, m_off_disabled(this, "check_off_disabled", 16)
, m_on(this, "check_on", 18)
, m_half(this, "check_half", 18)
, m_off(this, "check_off", 18)
, m_on_disabled(this, "check_on_disabled", 18)
, m_half_disabled(this, "check_half_disabled", 18)
, m_off_disabled(this, "check_off_disabled", 18)
, m_on_focused(this, "check_on_focused", 18)
, m_half_focused(this, "check_half_focused", 18)
, m_off_focused(this, "check_off_focused", 18)
{
//SetBackgroundStyle(wxBG_STYLE_TRANSPARENT);
if (parent)
@ -42,6 +45,10 @@ void CheckBox::Rescale()
void CheckBox::update()
{
SetBitmap((m_half_checked ? m_half : GetValue() ? m_on : m_off).bmp());
SetBitmapLabel((m_half_checked ? m_half : GetValue() ? m_on : m_off).bmp());
SetBitmapDisabled((m_half_checked ? m_half_disabled : GetValue() ? m_on_disabled : m_off_disabled).bmp());
SetBitmapFocus((m_half_checked ? m_half_focused : GetValue() ? m_on_focused : m_off_focused).bmp());
SetBitmapCurrent((m_half_checked ? m_half_focused : GetValue() ? m_on_focused : m_off_focused).bmp());
}
CheckBox::State CheckBox::GetNormalState() const { return State_Normal; }

View file

@ -17,6 +17,9 @@ public:
void Rescale();
protected:
virtual State GetNormalState() const wxOVERRIDE;
private:
void update();
@ -27,6 +30,9 @@ private:
ScalableBitmap m_on_disabled;
ScalableBitmap m_half_disabled;
ScalableBitmap m_off_disabled;
ScalableBitmap m_on_focused;
ScalableBitmap m_half_focused;
ScalableBitmap m_off_focused;
bool m_half_checked = false;
};