Overrided on_dpi_changed() for some Dialogs:

AboutDialog, ConfigSnapshotDialog, FirmwareDialog, SysInfoDialog

+ set correct fonts for KBShortcutsDialog
This commit is contained in:
YuSanka 2019-04-18 15:05:17 +02:00
parent e97e8c6af6
commit 9cd3c594be
12 changed files with 194 additions and 64 deletions

View file

@ -95,21 +95,26 @@ static wxString generate_html_page(const Config::SnapshotDB &snapshot_db, const
}
ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db, const wxString &on_snapshot)
: wxDialog(NULL, wxID_ANY, _(L("Configuration Snapshots")), wxDefaultPosition,
: DPIDialog(NULL, wxID_ANY, _(L("Configuration Snapshots")), wxDefaultPosition,
wxSize(45 * wxGetApp().em_unit(), 40 * wxGetApp().em_unit()),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX)
{
this->SetFont(wxGetApp().normal_font());
this->SetBackgroundColour(*wxWHITE);
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);
this->SetSizer(vsizer);
// text
wxHtmlWindow* html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);
html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);
{
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wxFont font = wxGetApp().normal_font();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
#ifdef __WXMSW__
int size[] = {8,8,8,8,11,11,11};
const int fs = font.GetPointSize();
const int fs1 = static_cast<int>(0.8f*fs);
const int fs2 = static_cast<int>(1.1f*fs);
int size[] = {fs1, fs1, fs1, fs1, fs2, fs2, fs2};
// int size[] = {8,8,8,8,11,11,11};
#else
int size[] = {11,11,11,11,14,14,14};
#endif
@ -127,6 +132,26 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db
vsizer->Add(buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3);
}
void ConfigSnapshotDialog::on_dpi_changed(const wxRect &suggested_rect)
{
wxFont font = GetFont();
const int fs = font.GetPointSize();
const int fs1 = static_cast<int>(0.8f*fs);
const int fs2 = static_cast<int>(1.1f*fs);
int font_size[] = { fs1, fs1, fs1, fs1, fs2, fs2, fs2 };
html->SetFonts(font.GetFaceName(), font.GetFaceName(), font_size);
html->Refresh();
const int& em = em_unit();
const wxSize& size = wxSize(45 * em, 40 * em);
SetMinSize(size);
SetSize(size);
Refresh();
}
void ConfigSnapshotDialog::onLinkClicked(wxHtmlLinkEvent &event)
{
m_snapshot_to_activate = event.GetLinkInfo().GetHref();