ENH:add "text to image" function in TextInput

jira: none
Change-Id: Ibdb57b74511432e81faa0c556bb6e639d5a174f5
(cherry picked from commit 09323aeed34f29f105b95d3d6a2c7a151e17e42a)
This commit is contained in:
zhou.xu
2025-01-15 12:18:58 +08:00
committed by Noisyfox
parent 2e8a5ecd87
commit 200a811dca
9 changed files with 78 additions and 11 deletions

View File

@@ -121,8 +121,18 @@ void ComboBox::SetLabel(const wxString &value)
{
if (GetTextCtrl()->IsShown() || text_off)
GetTextCtrl()->SetValue(value);
else
TextInput::SetLabel(value);
else {
if (is_replace_text_to_image) {
auto new_value = value;
new_value.Replace(replace_text, "", false);//replace first text
TextInput::SetIcon_1(image_for_text);
TextInput::SetLabel(new_value);
}
else {
TextInput::SetIcon_1("");
TextInput::SetLabel(value);
}
}
}
wxString ComboBox::GetLabel() const
@@ -201,6 +211,13 @@ void ComboBox::DoDeleteOneItem(unsigned int pos)
unsigned int ComboBox::GetCount() const { return items.size(); }
void ComboBox::set_replace_text(wxString text, wxString image_name)
{
replace_text = text;
image_for_text = image_name;
is_replace_text_to_image = true;
}
wxString ComboBox::GetString(unsigned int n) const
{ return n < items.size() ? items[n].text : wxString{}; }