Implemented get_wraped_wxString() to wrap the message text inside the MessageDialog and RichMessageDialog
This commit is contained in:
parent
6b83ded669
commit
667842ec8b
@ -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<size_t>(idx) + 1, 1, new_line);
|
||||
text_len++;
|
||||
}
|
||||
else // space
|
||||
text[idx] = new_line;
|
||||
cur_len = i - static_cast<size_t>(idx);
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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() {}
|
||||
|
@ -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<int>(LoadType::OpenProject), static_cast<int>(LoadType::LoadConfig)) - 1;
|
||||
|
Loading…
Reference in New Issue
Block a user