Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2019-02-22 13:13:48 +0300
committerbubnikv <bubnikv@gmail.com>2019-02-22 13:13:48 +0300
commitde86e6ec9a4d34f1e29df445ee5bad0c2af5b12a (patch)
tree425babe9fa27ed351d167b1d090cb3b5dc32350a /src
parent586ccad8f0b20534990fb2c5394a21bf0fdf4b05 (diff)
Replaced the static text control in error dialog with HTML control,
which supports copying of the text into clipboard. Removed the "copy to clipboard" button from the error dialog.
Diffstat (limited to 'src')
-rw-r--r--src/slic3r/GUI/MsgDialog.cpp48
1 files changed, 24 insertions, 24 deletions
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 <wx/statbmp.h>
#include <wx/scrolwin.h>
#include <wx/clipbrd.h>
+#include <wx/html/htmlwin.h>
+
+#include <boost/algorithm/string/replace.hpp>
#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", "<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);
+ }
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();