diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 4b0a9d863..622b8d930 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -245,7 +245,7 @@ MessageDialog::MessageDialog(wxWindow* parent, long style/* = wxOK*/) : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, style) { - add_msg_content(this, content_sizer, message); + add_msg_content(this, content_sizer, get_wraped_wxString(message)); finalize(); } @@ -258,7 +258,7 @@ RichMessageDialog::RichMessageDialog(wxWindow* parent, long style/* = wxOK*/) : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, style) { - add_msg_content(this, content_sizer, message); + add_msg_content(this, content_sizer, get_wraped_wxString(message)); m_checkBox = new wxCheckBox(this, wxID_ANY, m_checkBoxText); wxGetApp().UpdateDarkUI(m_checkBox); @@ -291,6 +291,43 @@ InfoDialog::InfoDialog(wxWindow* parent, const wxString &title, const wxString& finalize(); } +wxString get_wraped_wxString(const wxString& text_in, size_t line_len /*=80*/) +{ +#ifdef __WXMSW__ + char slash = '\\'; +#else + char slash = '/'; +#endif + char space = ' '; + char new_line = '\n'; + + wxString text = text_in; + + int idx = -1; + size_t cur_len = 0; + size_t text_len = text.Len(); + + for (size_t i = 0; i < text_len; i++) { + cur_len++; + if (text[i] == space || text[i] == slash) + idx = i; + if (text[i] == new_line) { + idx = -1; + cur_len = 0; + continue; + } + if (cur_len >= line_len && idx >= 0) { + if (text[idx] == slash) { + text.insert(static_cast(idx) + 1, 1, new_line); + text_len++; + } + else // space + text[idx] = new_line; + cur_len = i - static_cast(idx); + } + } + return text; +} } } diff --git a/src/slic3r/GUI/MsgDialog.hpp b/src/slic3r/GUI/MsgDialog.hpp index 17d935495..874629343 100644 --- a/src/slic3r/GUI/MsgDialog.hpp +++ b/src/slic3r/GUI/MsgDialog.hpp @@ -89,6 +89,8 @@ public: virtual ~WarningDialog() = default; }; +wxString get_wraped_wxString(const wxString& text_in, size_t line_len = 80); + #ifdef _WIN32 // Generic static line, used intead of wxStaticLine class StaticLine: public wxTextCtrl @@ -283,7 +285,7 @@ public: const wxString& message, const wxString& caption = wxEmptyString, long style = wxOK) - : wxMessageDialog(parent, message, caption, style) {} + : wxMessageDialog(parent, get_wraped_wxString(message), caption, style) {} ~MessageDialog() {} }; @@ -295,7 +297,7 @@ public: const wxString& message, const wxString& caption = wxEmptyString, long style = wxOK) - : wxRichMessageDialog(parent, message, caption, style) { + : wxRichMessageDialog(parent, get_wraped_wxString(message), caption, style) { this->SetEscapeId(wxID_CANCEL); } ~RichMessageDialog() {} diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 2a4ba6f48..26aef38ff 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -5265,7 +5265,7 @@ ProjectDropDialog::ProjectDropDialog(const std::string& filename) _L("Import config only") }; main_sizer->Add(new wxStaticText(this, wxID_ANY, - _L("Select an action to apply to the file") + ": " + from_u8(filename)), 0, wxEXPAND | wxALL, 10); + get_wraped_wxString(_L("Select an action to apply to the file") + ": " + from_u8(filename))), 0, wxEXPAND | wxALL, 10); m_action = std::clamp(std::stoi(wxGetApp().app_config->get("drop_project_action")), static_cast(LoadType::OpenProject), static_cast(LoadType::LoadConfig)) - 1;