mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-10 08:17:51 -06:00
Overrided on_dpi_changed() for some Dialogs:
AboutDialog, ConfigSnapshotDialog, FirmwareDialog, SysInfoDialog + set correct fonts for KBShortcutsDialog
This commit is contained in:
parent
e97e8c6af6
commit
9cd3c594be
12 changed files with 194 additions and 64 deletions
|
@ -32,8 +32,11 @@ void AboutDialogLogo::onRepaint(wxEvent &event)
|
|||
}
|
||||
|
||||
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);
|
||||
SetBackgroundColour(bgr_clr);
|
||||
wxBoxSizer* hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
@ -42,8 +45,10 @@ AboutDialog::AboutDialog()
|
|||
main_sizer->Add(hsizer, 0, wxEXPAND | wxALL, 20);
|
||||
|
||||
// logo
|
||||
auto *logo = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap(this, "Slic3r_192px.png", 192));
|
||||
hsizer->Add(logo, 1, wxALIGN_CENTER_VERTICAL);
|
||||
m_logo_bitmap = PrusaBitmap(this, "Slic3r_192px.png", 192);
|
||||
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);
|
||||
hsizer->Add(vsizer, 2, wxEXPAND|wxLEFT, 20);
|
||||
|
@ -51,8 +56,8 @@ AboutDialog::AboutDialog()
|
|||
// title
|
||||
{
|
||||
wxStaticText* title = new wxStaticText(this, wxID_ANY, "Slic3r Prusa Edition", wxDefaultPosition, wxDefaultSize);
|
||||
wxFont title_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
title_font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
wxFont title_font = GUI::wxGetApp().bold_font();// wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
// title_font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
title_font.SetFamily(wxFONTFAMILY_ROMAN);
|
||||
title_font.SetPointSize(24);
|
||||
title->SetFont(title_font);
|
||||
|
@ -63,9 +68,9 @@ AboutDialog::AboutDialog()
|
|||
{
|
||||
auto version_string = _(L("Version"))+ " " + std::string(SLIC3R_VERSION);
|
||||
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__
|
||||
version_font.SetPointSize(9);
|
||||
version_font.SetPointSize(/*9*/version_font.GetPointSize()-1);
|
||||
#else
|
||||
version_font.SetPointSize(11);
|
||||
#endif
|
||||
|
@ -74,18 +79,18 @@ AboutDialog::AboutDialog()
|
|||
}
|
||||
|
||||
// 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()));
|
||||
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
m_html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit()));
|
||||
wxFont font = GetFont();//GUI::wxGetApp().normal_font(); // wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_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());
|
||||
|
||||
const int fs = font.GetPointSize()-1;
|
||||
int size[] = {fs,fs,fs,fs,fs,fs,fs};
|
||||
html->SetFonts(font.GetFaceName(), font.GetFaceName(), size);
|
||||
html->SetBorders(2);
|
||||
m_html->SetFonts(font.GetFaceName(), font.GetFaceName(), size);
|
||||
m_html->SetBorders(2);
|
||||
const auto text = wxString::Format(
|
||||
"<html>"
|
||||
"<body bgcolor= %s link= %s>"
|
||||
|
@ -101,9 +106,9 @@ AboutDialog::AboutDialog()
|
|||
"</font>"
|
||||
"</body>"
|
||||
"</html>", bgr_clr_str, text_clr_str, text_clr_str);
|
||||
html->SetPage(text);
|
||||
vsizer->Add(html, 1, wxEXPAND | wxBOTTOM, 10);
|
||||
html->Bind(wxEVT_HTML_LINK_CLICKED, &AboutDialog::onLinkClicked, this);
|
||||
m_html->SetPage(text);
|
||||
vsizer->Add(m_html, 1, wxEXPAND | wxBOTTOM, 10);
|
||||
m_html->Bind(wxEVT_HTML_LINK_CLICKED, &AboutDialog::onLinkClicked, this);
|
||||
}
|
||||
|
||||
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxCLOSE);
|
||||
|
@ -118,6 +123,29 @@ AboutDialog::AboutDialog()
|
|||
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)
|
||||
{
|
||||
wxLaunchDefaultBrowser(event.GetLinkInfo().GetHref());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue