mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-18 06:55:57 +08:00
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*/)
|
long style/* = wxOK*/)
|
||||||
: MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, style)
|
: 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();
|
finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ RichMessageDialog::RichMessageDialog(wxWindow* parent,
|
|||||||
long style/* = wxOK*/)
|
long style/* = wxOK*/)
|
||||||
: MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, style)
|
: 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);
|
m_checkBox = new wxCheckBox(this, wxID_ANY, m_checkBoxText);
|
||||||
wxGetApp().UpdateDarkUI(m_checkBox);
|
wxGetApp().UpdateDarkUI(m_checkBox);
|
||||||
@ -291,6 +291,43 @@ InfoDialog::InfoDialog(wxWindow* parent, const wxString &title, const wxString&
|
|||||||
finalize();
|
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;
|
virtual ~WarningDialog() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxString get_wraped_wxString(const wxString& text_in, size_t line_len = 80);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Generic static line, used intead of wxStaticLine
|
// Generic static line, used intead of wxStaticLine
|
||||||
class StaticLine: public wxTextCtrl
|
class StaticLine: public wxTextCtrl
|
||||||
@ -283,7 +285,7 @@ public:
|
|||||||
const wxString& message,
|
const wxString& message,
|
||||||
const wxString& caption = wxEmptyString,
|
const wxString& caption = wxEmptyString,
|
||||||
long style = wxOK)
|
long style = wxOK)
|
||||||
: wxMessageDialog(parent, message, caption, style) {}
|
: wxMessageDialog(parent, get_wraped_wxString(message), caption, style) {}
|
||||||
~MessageDialog() {}
|
~MessageDialog() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -295,7 +297,7 @@ public:
|
|||||||
const wxString& message,
|
const wxString& message,
|
||||||
const wxString& caption = wxEmptyString,
|
const wxString& caption = wxEmptyString,
|
||||||
long style = wxOK)
|
long style = wxOK)
|
||||||
: wxRichMessageDialog(parent, message, caption, style) {
|
: wxRichMessageDialog(parent, get_wraped_wxString(message), caption, style) {
|
||||||
this->SetEscapeId(wxID_CANCEL);
|
this->SetEscapeId(wxID_CANCEL);
|
||||||
}
|
}
|
||||||
~RichMessageDialog() {}
|
~RichMessageDialog() {}
|
||||||
|
@ -5265,7 +5265,7 @@ ProjectDropDialog::ProjectDropDialog(const std::string& filename)
|
|||||||
_L("Import config only") };
|
_L("Import config only") };
|
||||||
|
|
||||||
main_sizer->Add(new wxStaticText(this, wxID_ANY,
|
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")),
|
m_action = std::clamp(std::stoi(wxGetApp().app_config->get("drop_project_action")),
|
||||||
static_cast<int>(LoadType::OpenProject), static_cast<int>(LoadType::LoadConfig)) - 1;
|
static_cast<int>(LoadType::OpenProject), static_cast<int>(LoadType::LoadConfig)) - 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user