FIX: [STUDIO-3381] comboxbox drop_down icon

Change-Id: I55d02c534a3f3a41d1f969c99399ff272e43c3cd
This commit is contained in:
chunmao.guo 2023-06-27 18:08:53 +08:00 committed by Lane.Wei
parent 53215d1a62
commit 63029c628a
2 changed files with 6 additions and 6 deletions

View file

@ -24,10 +24,11 @@ static wxWindow *GetScrollParent(wxWindow *pWindow)
wxWindow *pWin = pWindow; wxWindow *pWin = pWindow;
while (pWin->GetParent()) { while (pWin->GetParent()) {
auto pWin2 = pWin->GetParent(); auto pWin2 = pWin->GetParent();
if (auto top = dynamic_cast<wxScrollHelper *>(pWin2)) return dynamic_cast<wxWindow *>(pWin); if (auto top = dynamic_cast<wxScrollHelper *>(pWin2))
return dynamic_cast<wxWindow *>(pWin);
pWin = pWin2; pWin = pWin2;
} }
return pWin; return nullptr;
} }
ComboBox::ComboBox(wxWindow *parent, ComboBox::ComboBox(wxWindow *parent,
@ -58,8 +59,6 @@ ComboBox::ComboBox(wxWindow *parent,
std::make_pair(*wxWHITE, (int) StateColor::Normal))); std::make_pair(*wxWHITE, (int) StateColor::Normal)));
TextInput::SetLabelColor(StateColor(std::make_pair(0x909090, (int) StateColor::Disabled), TextInput::SetLabelColor(StateColor(std::make_pair(0x909090, (int) StateColor::Disabled),
std::make_pair(0x262E30, (int) StateColor::Normal))); std::make_pair(0x262E30, (int) StateColor::Normal)));
} else {
GetTextCtrl()->Bind(wxEVT_KEY_DOWN, &ComboBox::keyDown, this);
} }
if (auto scroll = GetScrollParent(this)) if (auto scroll = GetScrollParent(this))
scroll->Bind(wxEVT_MOVE, &ComboBox::onMove, this); scroll->Bind(wxEVT_MOVE, &ComboBox::onMove, this);
@ -85,7 +84,7 @@ void ComboBox::SetSelection(int n)
return; return;
drop.SetSelection(n); drop.SetSelection(n);
SetLabel(drop.GetValue()); SetLabel(drop.GetValue());
if (drop.selection >= 0) if (drop.selection >= 0 && drop.iconSize.y > 0)
SetIcon(icons[drop.selection]); SetIcon(icons[drop.selection]);
} }
void ComboBox::SelectAndNotify(int n) { void ComboBox::SelectAndNotify(int n) {
@ -108,7 +107,7 @@ void ComboBox::SetValue(const wxString &value)
{ {
drop.SetValue(value); drop.SetValue(value);
SetLabel(value); SetLabel(value);
if (drop.selection >= 0) if (drop.selection >= 0 && drop.iconSize.y > 0)
SetIcon(icons[drop.selection]); SetIcon(icons[drop.selection]);
} }

View file

@ -89,6 +89,7 @@ void DropDown::SetSelection(int n)
n = -1; n = -1;
if (selection == n) return; if (selection == n) return;
selection = n; selection = n;
messureSize();
paintNow(); paintNow();
} }