diff options
author | B. Stack <bgstack15@gmail.com> | 2023-02-21 12:13:36 -0500 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2023-02-21 12:13:36 -0500 |
commit | 5a6ed4e8eadf3af3d141b246f124d67b62a1357c (patch) | |
tree | 4e49ae80efbe181c46110867fe7cf703efd3fcf5 /wx+/window_layout.h | |
parent | argon2 copyright notice updated (diff) | |
download | FreeFileSync-5a6ed4e8eadf3af3d141b246f124d67b62a1357c.tar.gz FreeFileSync-5a6ed4e8eadf3af3d141b246f124d67b62a1357c.tar.bz2 FreeFileSync-5a6ed4e8eadf3af3d141b246f124d67b62a1357c.zip |
add upstream 12.112.1
Diffstat (limited to 'wx+/window_layout.h')
-rw-r--r-- | wx+/window_layout.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/wx+/window_layout.h b/wx+/window_layout.h new file mode 100644 index 00000000..8a86ec86 --- /dev/null +++ b/wx+/window_layout.h @@ -0,0 +1,85 @@ +// ***************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: https://www.gnu.org/licenses/gpl-3.0 * +// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved * +// ***************************************************************************** + +#ifndef WINDOW_LAYOUT_H_23849632846734343234532 +#define WINDOW_LAYOUT_H_23849632846734343234532 + +#include <zen/basic_math.h> +#include <wx/window.h> +#include <wx/spinctrl.h> +#include <zen/scope_guard.h> + #include <gtk/gtk.h> +#include "dc.h" + + +namespace zen +{ +//set portable font size in multiples of the operating system's default font size +void setRelativeFontSize(wxWindow& control, double factor); +void setMainInstructionFont(wxWindow& control); //following Windows/Gnome/OS X guidelines + +void setDefaultWidth(wxSpinCtrl& m_spinCtrl); + + + + + + + + +//###################### implementation ##################### +inline +void setRelativeFontSize(wxWindow& control, double factor) +{ + wxFont font = control.GetFont(); + font.SetPointSize(std::round(wxNORMAL_FONT->GetPointSize() * factor)); + control.SetFont(font); +} + + +inline +void setMainInstructionFont(wxWindow& control) +{ + wxFont font = control.GetFont(); + font.SetPointSize(std::round(wxNORMAL_FONT->GetPointSize() * 12.0 / 11)); + font.SetWeight(wxFONTWEIGHT_BOLD); + + control.SetFont(font); +} + + +inline +void setDefaultWidth(wxSpinCtrl& m_spinCtrl) +{ +#ifdef __WXGTK3__ + //there's no way to set width using GTK's CSS! => + m_spinCtrl.InvalidateBestSize(); + ::gtk_entry_set_width_chars(GTK_ENTRY(m_spinCtrl.m_widget), 3); + +#if 0 //apparently not needed!? + if (::gtk_check_version(3, 12, 0) == NULL) + ::gtk_entry_set_max_width_chars(GTK_ENTRY(m_spinCtrl.m_widget), 3); +#endif + + //get rid of excessive default width on old GTK3 3.14 (Debian); + //gtk_entry_set_width_chars() not working => mitigate + m_spinCtrl.SetMinSize({fastFromDIP(100), -1}); //must be wider than gtk_entry_set_width_chars(), or it breaks newer GTK e.g. 3.22! + +#if 0 //generic property syntax: + GValue bval = G_VALUE_INIT; + ::g_value_init(&bval, G_TYPE_BOOLEAN); + ::g_value_set_boolean(&bval, false); + ZEN_ON_SCOPE_EXIT(::g_value_unset(&bval)); + ::g_object_set_property(G_OBJECT(m_spinCtrl.m_widget), "visibility", &bval); +#endif +#else + m_spinCtrl.SetMinSize({fastFromDIP(70), -1}); +#endif + +} +} + +#endif //WINDOW_LAYOUT_H_23849632846734343234532 |