Code cleaning.

+ Use default DPIfont for wxHtmlWindows
This commit is contained in:
YuSanka 2020-09-04 13:00:33 +02:00
parent 436e12e99f
commit c8133b91b7
5 changed files with 7 additions and 54 deletions

View File

@ -52,7 +52,7 @@ CopyrightsDialog::CopyrightsDialog()
m_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition,
wxSize(40 * em_unit(), 20 * em_unit()), wxHW_SCROLLBAR_AUTO);
wxFont font = GetFont();
wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// GetFont();
const int fs = font.GetPointSize();
const int fs2 = static_cast<int>(1.2f*fs);
int size[] = { fs, fs, fs, fs, fs2, fs2, fs2 };
@ -249,7 +249,7 @@ AboutDialog::AboutDialog()
m_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO/*NEVER*/);
{
m_html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit()));
wxFont font = GetFont();
wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// GetFont();
const auto text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());

View File

@ -114,7 +114,7 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db
// text
html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);
{
wxFont font = wxGetApp().normal_font();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// wxGetApp().normal_font();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
#ifdef __WXMSW__
const int fs = font.GetPointSize();
const int fs1 = static_cast<int>(0.8f*fs);
@ -140,7 +140,7 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db
void ConfigSnapshotDialog::on_dpi_changed(const wxRect &suggested_rect)
{
wxFont font = GetFont();
wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// GetFont();
const int fs = font.GetPointSize();
const int fs1 = static_cast<int>(0.8f*fs);
const int fs2 = static_cast<int>(1.1f*fs);

View File

@ -218,19 +218,7 @@ private:
void rescale(const wxRect &suggested_rect)
{
this->Freeze();
/*
#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
if (m_force_rescale) {
#endif // wxVERSION_EQUAL_OR_GREATER_THAN
// rescale fonts of all controls
scale_controls_fonts(this, m_new_font_point_size);
// rescale current window font
scale_win_font(this, m_new_font_point_size);
#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
m_force_rescale = false;
}
#endif // wxVERSION_EQUAL_OR_GREATER_THAN
*/
m_force_rescale = false;
#if !wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
// rescale fonts of all controls

View File

@ -55,29 +55,6 @@ enum class ERescaleTarget
SettingsDialog
};
static void rescale_dialog_after_dpi_change(MainFrame& mainframe, SettingsDialog& dialog, ERescaleTarget target)
{
int mainframe_dpi = get_dpi_for_window(&mainframe);
int dialog_dpi = get_dpi_for_window(&dialog);
if (mainframe_dpi != dialog_dpi) {
if (target == ERescaleTarget::SettingsDialog) {
dialog.enable_force_rescale();
#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
dialog.GetEventHandler()->AddPendingEvent(wxDPIChangedEvent(wxSize(mainframe_dpi, mainframe_dpi), wxSize(dialog_dpi, dialog_dpi)));
#else
dialog.GetEventHandler()->AddPendingEvent(DpiChangedEvent(EVT_DPI_CHANGED_SLICER, dialog_dpi, dialog.GetRect()));
#endif // wxVERSION_EQUAL_OR_GREATER_THAN
} else {
#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
mainframe.GetEventHandler()->AddPendingEvent(wxDPIChangedEvent(wxSize(dialog_dpi, dialog_dpi), wxSize(mainframe_dpi, mainframe_dpi)));
#else
mainframe.enable_force_rescale();
mainframe.GetEventHandler()->AddPendingEvent(DpiChangedEvent(EVT_DPI_CHANGED_SLICER, mainframe_dpi, mainframe.GetRect()));
#endif // wxVERSION_EQUAL_OR_GREATER_THAN
}
}
}
MainFrame::MainFrame() :
DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "mainframe"),
m_printhost_queue_dlg(new PrintHostQueueDialog(this))
@ -310,11 +287,6 @@ void MainFrame::update_layout()
m_plater_page = nullptr;
}
/*
if (m_layout == ESettingsLayout::Dlg)
rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::Mainframe);
*/
clean_sizer(m_main_sizer);
clean_sizer(m_settings_dialog.GetSizer());
@ -393,9 +365,6 @@ void MainFrame::update_layout()
m_main_sizer->Add(m_plater, 1, wxEXPAND);
m_tabpanel->Reparent(&m_settings_dialog);
m_settings_dialog.GetSizer()->Add(m_tabpanel, 1, wxEXPAND);
// rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::SettingsDialog);
m_tabpanel->Show();
m_plater->Show();
break;
@ -825,10 +794,6 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
this->SetSize(sz);
this->Maximize(is_maximized);
/*
if (m_layout == ESettingsLayout::Dlg)
rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::SettingsDialog);
*/
}
void MainFrame::on_sys_color_changed()

View File

@ -109,7 +109,7 @@ SysInfoDialog::SysInfoDialog()
}
// main_info_text
wxFont font = wxGetApp().normal_font();
wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// wxGetApp().normal_font();
const auto text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
@ -175,7 +175,7 @@ void SysInfoDialog::on_dpi_changed(const wxRect &suggested_rect)
m_logo_bmp.msw_rescale();
m_logo->SetBitmap(m_logo_bmp.bmp());
wxFont font = GetFont();
wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// GetFont();
const int fs = font.GetPointSize() - 1;
int font_size[] = { static_cast<int>(fs*1.5), static_cast<int>(fs*1.4), static_cast<int>(fs*1.3), fs, fs, fs, fs };