diff options
Diffstat (limited to 'wx+/no_flicker.h')
-rw-r--r-- | wx+/no_flicker.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/wx+/no_flicker.h b/wx+/no_flicker.h index ea9efb4d..fd64628f 100644 --- a/wx+/no_flicker.h +++ b/wx+/no_flicker.h @@ -15,20 +15,27 @@ namespace zen inline void setText(wxTextCtrl& control, const wxString& newText, bool* additionalLayoutChange = nullptr) { + const wxString& label = control.GetValue(); //perf: don't call twice! if (additionalLayoutChange && !*additionalLayoutChange) //never revert from true to false! - *additionalLayoutChange = control.GetValue().length() != newText.length(); //avoid screen flicker: update layout only when necessary + *additionalLayoutChange = label.length() != newText.length(); //avoid screen flicker: update layout only when necessary - if (control.GetValue() != newText) + if (label != newText) control.ChangeValue(newText); } inline -void setText(wxStaticText& control, const wxString& newText, bool* additionalLayoutChange = nullptr) +void setText(wxStaticText& control, wxString newText, bool* additionalLayoutChange = nullptr) { +#ifdef ZEN_WIN + //wxStaticText handles ampersands incorrectly: https://sourceforge.net/p/freefilesync/bugs/279/ + replace(newText, L'&', L"&&"); +#endif + + const wxString& label = control.GetLabel(); //perf: don't call twice! if (additionalLayoutChange && !*additionalLayoutChange) - *additionalLayoutChange = control.GetLabel().length() != newText.length(); //avoid screen flicker: update layout only when necessary + *additionalLayoutChange = label.length() != newText.length(); //avoid screen flicker: update layout only when necessary - if (control.GetLabel() != newText) + if (label != newText) control.SetLabel(newText); } } |