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

@ -32,8 +32,11 @@ void AboutDialogLogo::onRepaint(wxEvent &event)
} }
AboutDialog::AboutDialog() AboutDialog::AboutDialog()
: wxDialog(NULL, wxID_ANY, _(L("About Slic3r")), wxDefaultPosition, wxDefaultSize, wxCAPTION) : DPIDialog(NULL, wxID_ANY, _(L("About Slic3r")), wxDefaultPosition,
wxDefaultSize, /*wxCAPTION*/wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{ {
SetFont(wxGetApp().normal_font());
wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
SetBackgroundColour(bgr_clr); SetBackgroundColour(bgr_clr);
wxBoxSizer* hsizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* hsizer = new wxBoxSizer(wxHORIZONTAL);
@ -42,8 +45,10 @@ AboutDialog::AboutDialog()
main_sizer->Add(hsizer, 0, wxEXPAND | wxALL, 20); main_sizer->Add(hsizer, 0, wxEXPAND | wxALL, 20);
// logo // logo
auto *logo = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap(this, "Slic3r_192px.png", 192)); m_logo_bitmap = PrusaBitmap(this, "Slic3r_192px.png", 192);
hsizer->Add(logo, 1, wxALIGN_CENTER_VERTICAL); m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bitmap.bmp());
// auto *logo = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap(this, "Slic3r_192px.png", 192));
hsizer->Add(m_logo, 1, wxALIGN_CENTER_VERTICAL);
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);
hsizer->Add(vsizer, 2, wxEXPAND|wxLEFT, 20); hsizer->Add(vsizer, 2, wxEXPAND|wxLEFT, 20);
@ -51,8 +56,8 @@ AboutDialog::AboutDialog()
// title // title
{ {
wxStaticText* title = new wxStaticText(this, wxID_ANY, "Slic3r Prusa Edition", wxDefaultPosition, wxDefaultSize); wxStaticText* title = new wxStaticText(this, wxID_ANY, "Slic3r Prusa Edition", wxDefaultPosition, wxDefaultSize);
wxFont title_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont title_font = GUI::wxGetApp().bold_font();// wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
title_font.SetWeight(wxFONTWEIGHT_BOLD); // title_font.SetWeight(wxFONTWEIGHT_BOLD);
title_font.SetFamily(wxFONTFAMILY_ROMAN); title_font.SetFamily(wxFONTFAMILY_ROMAN);
title_font.SetPointSize(24); title_font.SetPointSize(24);
title->SetFont(title_font); title->SetFont(title_font);
@ -63,9 +68,9 @@ AboutDialog::AboutDialog()
{ {
auto version_string = _(L("Version"))+ " " + std::string(SLIC3R_VERSION); auto version_string = _(L("Version"))+ " " + std::string(SLIC3R_VERSION);
wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize); wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize);
wxFont version_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont version_font = GetFont();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
#ifdef __WXMSW__ #ifdef __WXMSW__
version_font.SetPointSize(9); version_font.SetPointSize(/*9*/version_font.GetPointSize()-1);
#else #else
version_font.SetPointSize(11); version_font.SetPointSize(11);
#endif #endif
@ -74,18 +79,18 @@ AboutDialog::AboutDialog()
} }
// text // text
wxHtmlWindow* html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO/*NEVER*/); m_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO/*NEVER*/);
{ {
html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit())); m_html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit()));
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont font = GetFont();//GUI::wxGetApp().normal_font(); // wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
const auto text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); 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 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()); auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
const int fs = font.GetPointSize()-1; const int fs = font.GetPointSize()-1;
int size[] = {fs,fs,fs,fs,fs,fs,fs}; int size[] = {fs,fs,fs,fs,fs,fs,fs};
html->SetFonts(font.GetFaceName(), font.GetFaceName(), size); m_html->SetFonts(font.GetFaceName(), font.GetFaceName(), size);
html->SetBorders(2); m_html->SetBorders(2);
const auto text = wxString::Format( const auto text = wxString::Format(
"<html>" "<html>"
"<body bgcolor= %s link= %s>" "<body bgcolor= %s link= %s>"
@ -101,9 +106,9 @@ AboutDialog::AboutDialog()
"</font>" "</font>"
"</body>" "</body>"
"</html>", bgr_clr_str, text_clr_str, text_clr_str); "</html>", bgr_clr_str, text_clr_str, text_clr_str);
html->SetPage(text); m_html->SetPage(text);
vsizer->Add(html, 1, wxEXPAND | wxBOTTOM, 10); vsizer->Add(m_html, 1, wxEXPAND | wxBOTTOM, 10);
html->Bind(wxEVT_HTML_LINK_CLICKED, &AboutDialog::onLinkClicked, this); m_html->Bind(wxEVT_HTML_LINK_CLICKED, &AboutDialog::onLinkClicked, this);
} }
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxCLOSE); wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxCLOSE);
@ -118,6 +123,29 @@ AboutDialog::AboutDialog()
main_sizer->SetSizeHints(this); main_sizer->SetSizeHints(this);
} }
void AboutDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_logo_bitmap.rescale();
m_logo->SetBitmap(m_logo_bitmap.bmp());
const wxFont& font = GetFont();
const int fs = font.GetPointSize() - 1;
int font_size[] = { fs, fs, fs, fs, fs, fs, fs };
m_html->SetFonts(font.GetFaceName(), font.GetFaceName(), font_size);
const int& em = em_unit();
m_html->SetMinSize(wxSize(-1, 16 * em));
m_html->Refresh();
const wxSize& size = wxSize(65 * em, 30 * em);
SetMinSize(size);
SetSize(size);
Refresh();
}
void AboutDialog::onLinkClicked(wxHtmlLinkEvent &event) void AboutDialog::onLinkClicked(wxHtmlLinkEvent &event)
{ {
wxLaunchDefaultBrowser(event.GetLinkInfo().GetHref()); wxLaunchDefaultBrowser(event.GetLinkInfo().GetHref());

View file

@ -7,6 +7,9 @@
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/html/htmlwin.h> #include <wx/html/htmlwin.h>
#include "GUI_Utils.hpp"
#include "wxExtensions.hpp"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@ -20,10 +23,16 @@ private:
void onRepaint(wxEvent &event); void onRepaint(wxEvent &event);
}; };
class AboutDialog : public wxDialog class AboutDialog : public DPIDialog
{ {
PrusaBitmap m_logo_bitmap;
wxHtmlWindow* m_html;
wxStaticBitmap* m_logo;
public: public:
AboutDialog(); AboutDialog();
protected:
void on_dpi_changed(const wxRect &suggested_rect) override;
private: private:
void onLinkClicked(wxHtmlLinkEvent &event); void onLinkClicked(wxHtmlLinkEvent &event);

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) 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()), wxSize(45 * wxGetApp().em_unit(), 40 * wxGetApp().em_unit()),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX) wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX)
{ {
this->SetFont(wxGetApp().normal_font());
this->SetBackgroundColour(*wxWHITE); this->SetBackgroundColour(*wxWHITE);
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);
this->SetSizer(vsizer); this->SetSizer(vsizer);
// text // 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__ #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 #else
int size[] = {11,11,11,11,14,14,14}; int size[] = {11,11,11,11,14,14,14};
#endif #endif
@ -127,6 +132,26 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db
vsizer->Add(buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3); 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) void ConfigSnapshotDialog::onLinkClicked(wxHtmlLinkEvent &event)
{ {
m_snapshot_to_activate = event.GetLinkInfo().GetHref(); m_snapshot_to_activate = event.GetLinkInfo().GetHref();

View file

@ -2,6 +2,7 @@
#define slic3r_GUI_ConfigSnapshotDialog_hpp_ #define slic3r_GUI_ConfigSnapshotDialog_hpp_
#include "GUI.hpp" #include "GUI.hpp"
#include "GUI_Utils.hpp"
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/intl.h> #include <wx/intl.h>
@ -14,18 +15,23 @@ namespace Config {
class SnapshotDB; class SnapshotDB;
} }
class ConfigSnapshotDialog : public wxDialog class ConfigSnapshotDialog : public DPIDialog
{ {
public: public:
ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db, const wxString &id); ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db, const wxString &id);
const std::string& snapshot_to_activate() const { return m_snapshot_to_activate; } const std::string& snapshot_to_activate() const { return m_snapshot_to_activate; }
protected:
void on_dpi_changed(const wxRect &suggested_rect) override;
private: private:
void onLinkClicked(wxHtmlLinkEvent &event); void onLinkClicked(wxHtmlLinkEvent &event);
void onCloseDialog(wxEvent &); void onCloseDialog(wxEvent &);
// If set, it contains a snapshot ID to be restored after the dialog closes. // If set, it contains a snapshot ID to be restored after the dialog closes.
std::string m_snapshot_to_activate; std::string m_snapshot_to_activate;
wxHtmlWindow* html;
}; };
} // namespace GUI } // namespace GUI

View file

@ -732,7 +732,7 @@ const char* FirmwareDialog::priv::avr109_dev_name(Avr109Pid usb_pid) {
// Public // Public
FirmwareDialog::FirmwareDialog(wxWindow *parent) : FirmwareDialog::FirmwareDialog(wxWindow *parent) :
wxDialog(parent, wxID_ANY, _(L("Firmware flasher")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), GUI::DPIDialog(parent, wxID_ANY, _(L("Firmware flasher")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
p(new priv(this)) p(new priv(this))
{ {
enum { enum {
@ -748,7 +748,13 @@ FirmwareDialog::FirmwareDialog(wxWindow *parent) :
int min_height = MIN_HEIGHT * em; int min_height = MIN_HEIGHT * em;
int min_height_expanded = MIN_HEIGHT_EXPANDED * em; int min_height_expanded = MIN_HEIGHT_EXPANDED * em;
wxFont status_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); /* get current font from application,
* because of wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) function
* returns font for primary Display
*/
const wxFont& font = GUI::wxGetApp().normal_font();
SetFont(font);
wxFont status_font = font;//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
status_font.MakeBold(); status_font.MakeBold();
wxFont mono_font(wxFontInfo().Family(wxFONTFAMILY_TELETYPE)); wxFont mono_font(wxFontInfo().Family(wxFONTFAMILY_TELETYPE));
mono_font.MakeSmaller(); mono_font.MakeSmaller();

View file

@ -4,12 +4,13 @@
#include <memory> #include <memory>
#include <wx/dialog.h> #include <wx/dialog.h>
#include "GUI_Utils.hpp"
namespace Slic3r { namespace Slic3r {
class FirmwareDialog: public wxDialog class FirmwareDialog: public GUI::DPIDialog
{ {
public: public:
FirmwareDialog(wxWindow *parent); FirmwareDialog(wxWindow *parent);
@ -20,6 +21,9 @@ public:
~FirmwareDialog(); ~FirmwareDialog();
static void run(wxWindow *parent); static void run(wxWindow *parent);
protected:
void on_dpi_changed(const wxRect &suggested_rect) override{;}
private: private:
struct priv; struct priv;
std::unique_ptr<priv> p; std::unique_ptr<priv> p;

View file

@ -682,6 +682,12 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
// Take a configuration snapshot. // Take a configuration snapshot.
if (check_unsaved_changes()) { if (check_unsaved_changes()) {
wxTextEntryDialog dlg(nullptr, _(L("Taking configuration snapshot")), _(L("Snapshot name"))); wxTextEntryDialog dlg(nullptr, _(L("Taking configuration snapshot")), _(L("Snapshot name")));
// set current normal font for dialog children,
// because of just dlg.SetFont(normal_font()) has no result;
for (auto child : dlg.GetChildren())
child->SetFont(normal_font());
if (dlg.ShowModal() == wxID_OK) if (dlg.ShowModal() == wxID_OK)
app_config->set("on_snapshot", app_config->set("on_snapshot",
Slic3r::GUI::Config::SnapshotDB::singleton().take_snapshot( Slic3r::GUI::Config::SnapshotDB::singleton().take_snapshot(
@ -731,7 +737,6 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
get_installed_languages(names, identifiers); get_installed_languages(names, identifiers);
if (select_language(names, identifiers)) { if (select_language(names, identifiers)) {
save_language(); save_language();
// show_info(mainframe->m_tabpanel, _(L("Application will be restarted")), _(L("Attention!")));
_3DScene::remove_all_canvases();// remove all canvas before recreate GUI _3DScene::remove_all_canvases();// remove all canvas before recreate GUI
recreate_GUI(); recreate_GUI();
} }

View file

@ -58,6 +58,9 @@ public:
: P(parent, id, title, pos, size, style, name) : P(parent, id, title, pos, size, style, name)
{ {
m_scale_factor = (float)get_dpi_for_window(this) / (float)DPI_DEFAULT; m_scale_factor = (float)get_dpi_for_window(this) / (float)DPI_DEFAULT;
m_normal_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
// An analog of em_unit value from GUI_App.
m_em_unit = std::max<size_t>(10, 10 * m_scale_factor);
m_prev_scale_factor = m_scale_factor; m_prev_scale_factor = m_scale_factor;
@ -104,6 +107,7 @@ public:
int em_unit() const { return m_em_unit; } int em_unit() const { return m_em_unit; }
int font_size() const { return m_font_size; } int font_size() const { return m_font_size; }
const wxFont& normal_font() const { return m_normal_font; }
protected: protected:
virtual void on_dpi_changed(const wxRect &suggested_rect) = 0; virtual void on_dpi_changed(const wxRect &suggested_rect) = 0;
@ -113,6 +117,7 @@ private:
int m_em_unit; int m_em_unit;
int m_font_size; int m_font_size;
wxFont m_normal_font;
float m_prev_scale_factor; float m_prev_scale_factor;
bool m_can_rescale{ true }; bool m_can_rescale{ true };
@ -121,7 +126,7 @@ private:
wxClientDC dc(this); wxClientDC dc(this);
const auto metrics = dc.GetFontMetrics(); const auto metrics = dc.GetFontMetrics();
m_font_size = metrics.height; m_font_size = metrics.height;
m_em_unit = metrics.averageWidth; // m_em_unit = metrics.averageWidth;
} }
// check if new scale is differ from previous // check if new scale is differ from previous
@ -143,9 +148,18 @@ private:
void rescale(const wxRect &suggested_rect) void rescale(const wxRect &suggested_rect)
{ {
this->Freeze(); this->Freeze();
const float relative_scale_factor = m_scale_factor / m_prev_scale_factor;
// rescale fonts of all controls // rescale fonts of all controls
scale_controls_fonts(this, m_scale_factor / m_prev_scale_factor); scale_controls_fonts(this, relative_scale_factor);
this->SetFont(this->GetFont().Scaled(relative_scale_factor));
// rescale normal_font value
m_normal_font = m_normal_font.Scaled(relative_scale_factor);
// An analog of em_unit value from GUI_App.
m_em_unit = std::max<size_t>(10, 10 * m_scale_factor);
// rescale missed controls sizes and images // rescale missed controls sizes and images
on_dpi_changed(suggested_rect); on_dpi_changed(suggested_rect);

View file

@ -13,7 +13,7 @@ KBShortcutsDialog::KBShortcutsDialog()
: DPIDialog(NULL, wxID_ANY, _(L("Slic3r Prusa Edition - Keyboard Shortcuts")), : DPIDialog(NULL, wxID_ANY, _(L("Slic3r Prusa Edition - Keyboard Shortcuts")),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{ {
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer = new wxBoxSizer(wxVERTICAL);
@ -21,16 +21,17 @@ KBShortcutsDialog::KBShortcutsDialog()
m_logo_bmp = PrusaBitmap(this, "Slic3r_32px.png", 32); m_logo_bmp = PrusaBitmap(this, "Slic3r_32px.png", 32);
// fonts // fonts
wxFont head_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold(); const wxFont& font = wxGetApp().normal_font();
const wxFont& bold_font = wxGetApp().bold_font();
SetFont(font);
wxFont head_font = bold_font;// wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold();
#ifdef __WXOSX__ #ifdef __WXOSX__
head_font.SetPointSize(14); head_font.SetPointSize(14);
#else #else
head_font.SetPointSize(12); head_font.SetPointSize(/*12*/bold_font.GetPointSize() + 2);
#endif // __WXOSX__ #endif // __WXOSX__
const wxFont& font = wxGetApp().normal_font();
const wxFont& bold_font = wxGetApp().bold_font();
fill_shortcuts(); fill_shortcuts();
auto panel = new wxPanel(this); auto panel = new wxPanel(this);

View file

@ -41,10 +41,12 @@ std::string get_main_info(bool format_as_html)
} }
SysInfoDialog::SysInfoDialog() SysInfoDialog::SysInfoDialog()
: wxDialog(NULL, wxID_ANY, _(L("Slic3r Prusa Edition - System Information")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) : DPIDialog(NULL, wxID_ANY, _(L("Slic3r Prusa Edition - System Information")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
{ {
wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
SetBackgroundColour(bgr_clr); SetBackgroundColour(bgr_clr);
SetFont(wxGetApp().normal_font());
wxBoxSizer* hsizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* hsizer = new wxBoxSizer(wxHORIZONTAL);
hsizer->SetMinSize(wxSize(50 * wxGetApp().em_unit(), -1)); hsizer->SetMinSize(wxSize(50 * wxGetApp().em_unit(), -1));
@ -52,8 +54,10 @@ SysInfoDialog::SysInfoDialog()
main_sizer->Add(hsizer, 1, wxEXPAND | wxALL, 10); main_sizer->Add(hsizer, 1, wxEXPAND | wxALL, 10);
// logo // logo
auto *logo = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap(this, "Slic3r_192px.png", 192)); m_logo_bmp = PrusaBitmap(this, "Slic3r_192px.png", 192);
hsizer->Add(logo, 0, wxALIGN_CENTER_VERTICAL); // auto *logo = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap(this, "Slic3r_192px.png", 192));
m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bmp.bmp());
hsizer->Add(m_logo, 0, wxALIGN_CENTER_VERTICAL);
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);
hsizer->Add(vsizer, 1, wxEXPAND|wxLEFT, 20); hsizer->Add(vsizer, 1, wxEXPAND|wxLEFT, 20);
@ -61,8 +65,8 @@ SysInfoDialog::SysInfoDialog()
// title // title
{ {
wxStaticText* title = new wxStaticText(this, wxID_ANY, SLIC3R_FORK_NAME, wxDefaultPosition, wxDefaultSize); wxStaticText* title = new wxStaticText(this, wxID_ANY, SLIC3R_FORK_NAME, wxDefaultPosition, wxDefaultSize);
wxFont title_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont title_font = wxGetApp().bold_font();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
title_font.SetWeight(wxFONTWEIGHT_BOLD); // title_font.SetWeight(wxFONTWEIGHT_BOLD);
title_font.SetFamily(wxFONTFAMILY_ROMAN); title_font.SetFamily(wxFONTFAMILY_ROMAN);
title_font.SetPointSize(22); title_font.SetPointSize(22);
title->SetFont(title_font); title->SetFont(title_font);
@ -70,7 +74,7 @@ SysInfoDialog::SysInfoDialog()
} }
// main_info_text // main_info_text
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont font = wxGetApp().normal_font();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
const auto text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); 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 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()); auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
@ -78,10 +82,10 @@ SysInfoDialog::SysInfoDialog()
const int fs = font.GetPointSize() - 1; const int fs = font.GetPointSize() - 1;
int size[] = { static_cast<int>(fs*1.5), static_cast<int>(fs*1.4), static_cast<int>(fs*1.3), fs, fs, fs, fs }; int size[] = { static_cast<int>(fs*1.5), static_cast<int>(fs*1.4), static_cast<int>(fs*1.3), fs, fs, fs, fs };
wxHtmlWindow* html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_NEVER); m_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_NEVER);
{ {
html->SetFonts(font.GetFaceName(), font.GetFaceName(), size); m_html->SetFonts(font.GetFaceName(), font.GetFaceName(), size);
html->SetBorders(2); m_html->SetBorders(2);
const auto text = wxString::Format( const auto text = wxString::Format(
"<html>" "<html>"
"<body bgcolor= %s link= %s>" "<body bgcolor= %s link= %s>"
@ -91,16 +95,16 @@ SysInfoDialog::SysInfoDialog()
"</body>" "</body>"
"</html>", bgr_clr_str, text_clr_str, text_clr_str, "</html>", bgr_clr_str, text_clr_str, text_clr_str,
get_main_info(true)); get_main_info(true));
html->SetPage(text); m_html->SetPage(text);
vsizer->Add(html, 1, wxEXPAND | wxBOTTOM, wxGetApp().em_unit()); vsizer->Add(m_html, 1, wxEXPAND | wxBOTTOM, wxGetApp().em_unit());
} }
// opengl_info // opengl_info
wxHtmlWindow* opengl_info_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO); m_opengl_info_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);
{ {
opengl_info_html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit())); m_opengl_info_html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit()));
opengl_info_html->SetFonts(font.GetFaceName(), font.GetFaceName(), size); m_opengl_info_html->SetFonts(font.GetFaceName(), font.GetFaceName(), size);
opengl_info_html->SetBorders(10); m_opengl_info_html->SetBorders(10);
const auto text = wxString::Format( const auto text = wxString::Format(
"<html>" "<html>"
"<body bgcolor= %s link= %s>" "<body bgcolor= %s link= %s>"
@ -110,8 +114,8 @@ SysInfoDialog::SysInfoDialog()
"</body>" "</body>"
"</html>", bgr_clr_str, text_clr_str, text_clr_str, "</html>", bgr_clr_str, text_clr_str, text_clr_str,
_3DScene::get_gl_info(true, true)); _3DScene::get_gl_info(true, true));
opengl_info_html->SetPage(text); m_opengl_info_html->SetPage(text);
main_sizer->Add(opengl_info_html, 1, wxEXPAND | wxBOTTOM, 15); main_sizer->Add(m_opengl_info_html, 1, wxEXPAND | wxBOTTOM, 15);
} }
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxOK); wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxOK);
@ -130,6 +134,32 @@ SysInfoDialog::SysInfoDialog()
main_sizer->SetSizeHints(this); main_sizer->SetSizeHints(this);
} }
void SysInfoDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_logo_bmp.rescale();
m_logo->SetBitmap(m_logo_bmp.bmp());
wxFont font = 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 };
m_html->SetFonts(font.GetFaceName(), font.GetFaceName(), font_size);
m_html->Refresh();
const int& em = em_unit();
m_opengl_info_html->SetMinSize(wxSize(-1, 16 * em));
m_opengl_info_html->SetFonts(font.GetFaceName(), font.GetFaceName(), font_size);
m_opengl_info_html->Refresh();
const wxSize& size = wxSize(65 * em, 55 * em);
SetMinSize(size);
SetSize(size);
Refresh();
}
void SysInfoDialog::onCopyToClipboard(wxEvent &) void SysInfoDialog::onCopyToClipboard(wxEvent &)
{ {
wxTheClipboard->Open(); wxTheClipboard->Open();

View file

@ -4,14 +4,25 @@
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/html/htmlwin.h> #include <wx/html/htmlwin.h>
#include "GUI_Utils.hpp"
#include "wxExtensions.hpp"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
class SysInfoDialog : public wxDialog class SysInfoDialog : public DPIDialog
{ {
wxString text_info {wxEmptyString}; wxString text_info {wxEmptyString};
PrusaBitmap m_logo_bmp;
wxStaticBitmap* m_logo;
wxHtmlWindow* m_opengl_info_html;
wxHtmlWindow* m_html;
public: public:
SysInfoDialog(); SysInfoDialog();
protected:
void on_dpi_changed(const wxRect &suggested_rect) override;
private: private:
void onCopyToClipboard(wxEvent &); void onCopyToClipboard(wxEvent &);

View file

@ -428,16 +428,11 @@ void PrusaCollapsiblePaneMSW::Collapse(bool collapse)
* Displays with different HDPI */ * Displays with different HDPI */
int em_unit(wxWindow* win) int em_unit(wxWindow* win)
{ {
if (win) { if (win)
// get TopLevelWindow for some window {
wxWindow* top_win = win; Slic3r::GUI::DPIDialog* dlg = dynamic_cast<Slic3r::GUI::DPIDialog*>(Slic3r::GUI::find_toplevel_parent(win));
while (!top_win->IsTopLevel())
top_win = top_win->GetParent();
Slic3r::GUI::DPIDialog* dlg = dynamic_cast<Slic3r::GUI::DPIDialog*>(top_win);
if (dlg) if (dlg)
// An analog of em_unit value from GUI_App. return dlg->em_unit();
return 10 * dlg->scale_factor();
} }
return Slic3r::GUI::wxGetApp().em_unit(); return Slic3r::GUI::wxGetApp().em_unit();
@ -2574,10 +2569,6 @@ void PrusaModeButton::SetState(const bool state)
void PrusaModeButton::focus_button(const bool focus) void PrusaModeButton::focus_button(const bool focus)
{ {
// const wxBitmap& bmp = focus ? m_bmp_on : m_bmp_off;
// SetBitmap(bmp);
// const wxFont& new_font = focus ? Slic3r::GUI::wxGetApp().bold_font() : Slic3r::GUI::wxGetApp().small_font();
wxFont font = GetFont(); wxFont font = GetFont();
const wxFont& new_font = focus ? font.Bold() : font.GetBaseFont(); const wxFont& new_font = focus ? font.Bold() : font.GetBaseFont();