Substitutions : Implemented InfoDialog

This commit is contained in:
YuSanka 2021-06-28 17:20:04 +02:00 committed by Vojtech Bubnik
parent 731ac9287e
commit 1e60acde12
10 changed files with 214 additions and 35 deletions

View file

@ -211,5 +211,43 @@ MessageDialog::MessageDialog(wxWindow* parent,
}
#endif
// InfoDialog
InfoDialog::InfoDialog(wxWindow* parent, const wxString& msg)
: MsgDialog(parent, wxString::Format(_L("%s information"), SLIC3R_APP_NAME), _L("Note that"))
, msg(msg)
{
this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
// Text shown as HTML, so that mouse selection and Ctrl-V to copy will work.
wxHtmlWindow* html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);
{
html->SetMinSize(wxSize(40 * wxGetApp().em_unit(), -1));
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wxFont monospace = wxGetApp().code_font();
wxColour text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
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 font_size = font.GetPointSize() - 1;
int size[] = { font_size, font_size, font_size, font_size, font_size, font_size, font_size };
html->SetFonts(font.GetFaceName(), monospace.GetFaceName(), size);
html->SetBorders(2);
std::string msg_escaped = xml_escape(msg.ToUTF8().data(), true);
boost::replace_all(msg_escaped, "\r\n", "<br>");
boost::replace_all(msg_escaped, "\n", "<br>");
html->SetPage("<html><body bgcolor=\"" + bgr_clr_str + "\"><font color=\"" + text_clr_str + "\">" + wxString::FromUTF8(msg_escaped.data()) + "</font></body></html>");
content_sizer->Add(html, 1, wxEXPAND);
}
// Set info bitmap
logo->SetBitmap(create_scaled_bitmap("info", this, 84));
SetMinSize(wxSize(60 * wxGetApp().em_unit(), 30 * wxGetApp().em_unit()));
Fit();
}
}
}