diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 950dd642f..176d19fb4 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -7,6 +7,9 @@ #include #include #include +#include + +#include #include "libslic3r/libslic3r.h" #include "libslic3r/Utils.hpp" @@ -50,7 +53,7 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &he btn_sizer->Add(button); } - rightsizer->Add(btn_sizer, 0, wxALIGN_CENTRE_HORIZONTAL); + rightsizer->Add(btn_sizer, 0, wxALIGN_RIGHT); auto *logo = new wxStaticBitmap(this, wxID_ANY, std::move(bitmap)); @@ -72,32 +75,29 @@ ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg) wxID_NONE) , msg(msg) { - auto *panel = new wxScrolledWindow(this); - auto *p_sizer = new wxBoxSizer(wxVERTICAL); - panel->SetSizer(p_sizer); - - auto *text = new wxStaticText(panel, wxID_ANY, msg); - text->Wrap(CONTENT_WIDTH*wxGetApp().em_unit()); - p_sizer->Add(text, 1, wxEXPAND); - - panel->SetMinSize(wxSize(CONTENT_WIDTH*wxGetApp().em_unit(), 0)); - panel->SetScrollRate(0, 5); - - content_sizer->Add(panel, 1, wxEXPAND); - - auto *btn_copy = new wxButton(this, wxID_ANY, _(L("Copy to clipboard"))); - btn_copy->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) { - if (wxTheClipboard->Open()) { - wxTheClipboard->SetData(new wxTextDataObject(this->msg)); // Note: the clipboard takes ownership of the pointer - wxTheClipboard->Close(); - } - }); + // 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); + wxColour text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK); // 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(), font.GetFaceName(), size); + html->SetBorders(2); + std::string msg_escaped = xml_escape(msg.ToUTF8().data()); + boost::replace_all(msg_escaped, "\r\n", "
"); + boost::replace_all(msg_escaped, "\n", "
"); + html->SetPage("" + wxString::FromUTF8(msg_escaped.data()) + ""); + content_sizer->Add(html, 1, wxEXPAND); + } auto *btn_ok = new wxButton(this, wxID_OK); btn_ok->SetFocus(); - - btn_sizer->Add(btn_copy, 0, wxRIGHT, HORIZ_SPACING); - btn_sizer->Add(btn_ok); + btn_sizer->Add(btn_ok, 0, wxRIGHT, HORIZ_SPACING); SetMaxSize(wxSize(-1, CONTENT_MAX_HEIGHT*wxGetApp().em_unit())); Fit();