diff options
author | Daniel Wilhelm <shieldwed@outlook.com> | 2017-02-13 21:25:04 -0700 |
---|---|---|
committer | Daniel Wilhelm <shieldwed@outlook.com> | 2017-02-13 21:25:04 -0700 |
commit | 9d071d2a2cec9a7662a02669488569a017f0ea35 (patch) | |
tree | c83a623fbdff098339b66d21ea2e81f3f67344ae /wx+/no_flicker.h | |
parent | 8.8 (diff) | |
download | FreeFileSync-9d071d2a2cec9a7662a02669488569a017f0ea35.tar.gz FreeFileSync-9d071d2a2cec9a7662a02669488569a017f0ea35.tar.bz2 FreeFileSync-9d071d2a2cec9a7662a02669488569a017f0ea35.zip |
8.9
Diffstat (limited to 'wx+/no_flicker.h')
-rwxr-xr-x[-rw-r--r--] | wx+/no_flicker.h | 82 |
1 files changed, 39 insertions, 43 deletions
diff --git a/wx+/no_flicker.h b/wx+/no_flicker.h index ed3396e1..6794b8bd 100644..100755 --- a/wx+/no_flicker.h +++ b/wx+/no_flicker.h @@ -1,43 +1,39 @@ -// ***************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * -// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved * -// ***************************************************************************** - -#ifndef NO_FLICKER_H_893421590321532 -#define NO_FLICKER_H_893421590321532 - -#include <wx/textctrl.h> -#include <wx/stattext.h> - -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 = label.length() != newText.length(); //avoid screen flicker: update layout only when necessary - - if (label != newText) - control.ChangeValue(newText); -} - -inline -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 = label.length() != newText.length(); //avoid screen flicker: update layout only when necessary - - if (label != newText) - control.SetLabel(newText); -} -} - -#endif //NO_FLICKER_H_893421590321532 +// *****************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 *
+// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved *
+// *****************************************************************************
+
+#ifndef NO_FLICKER_H_893421590321532
+#define NO_FLICKER_H_893421590321532
+
+#include <wx/textctrl.h>
+#include <wx/stattext.h>
+
+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 = label.length() != newText.length(); //avoid screen flicker: update layout only when necessary
+
+ if (label != newText)
+ control.ChangeValue(newText);
+}
+
+inline
+void setText(wxStaticText& control, wxString newText, bool* additionalLayoutChange = nullptr)
+{
+
+ const wxString& label = control.GetLabel(); //perf: don't call twice!
+ if (additionalLayoutChange && !*additionalLayoutChange)
+ *additionalLayoutChange = label.length() != newText.length(); //avoid screen flicker: update layout only when necessary
+
+ if (label != newText)
+ control.SetLabel(newText);
+}
+}
+
+#endif //NO_FLICKER_H_893421590321532
|