Implemented FR #7850 - G-Code Substitutions: move [X Delete all] button or ask for confirmation
+ MsgDialog: * Added processing if the wxNO_DEFAULT and wxCANCEL_DEFAULT flags * Next improvements of get_wraped_wxString() function
This commit is contained in:
parent
1fb41a8e22
commit
fc59a2c1b0
2 changed files with 20 additions and 23 deletions
src/slic3r/GUI
|
@ -94,9 +94,9 @@ wxButton* MsgDialog::get_button(wxWindowID btn_id){
|
||||||
void MsgDialog::apply_style(long style)
|
void MsgDialog::apply_style(long style)
|
||||||
{
|
{
|
||||||
if (style & wxOK) add_button(wxID_OK, true);
|
if (style & wxOK) add_button(wxID_OK, true);
|
||||||
if (style & wxYES) add_button(wxID_YES, true);
|
if (style & wxYES) add_button(wxID_YES, !(style & wxNO_DEFAULT));
|
||||||
if (style & wxNO) add_button(wxID_NO);
|
if (style & wxNO) add_button(wxID_NO, (style & wxNO_DEFAULT));
|
||||||
if (style & wxCANCEL) add_button(wxID_CANCEL);
|
if (style & wxCANCEL) add_button(wxID_CANCEL, (style & wxCANCEL_DEFAULT));
|
||||||
|
|
||||||
logo->SetBitmap( create_scaled_bitmap(style & wxICON_WARNING ? "exclamation" :
|
logo->SetBitmap( create_scaled_bitmap(style & wxICON_WARNING ? "exclamation" :
|
||||||
style & wxICON_INFORMATION ? "info" :
|
style & wxICON_INFORMATION ? "info" :
|
||||||
|
@ -298,25 +298,12 @@ wxString get_wraped_wxString(const wxString& in, size_t line_len /*=80*/)
|
||||||
for (size_t i = 0; i < in.size();) {
|
for (size_t i = 0; i < in.size();) {
|
||||||
// Overwrite the character (space or newline) starting at ibreak?
|
// Overwrite the character (space or newline) starting at ibreak?
|
||||||
bool overwrite = false;
|
bool overwrite = false;
|
||||||
#if wxUSE_UNICODE_WCHAR
|
|
||||||
// On Windows, most likely the internal representation of wxString is wide char.
|
|
||||||
size_t end = std::min(in.size(), i + line_len);
|
|
||||||
size_t ibreak = end;
|
|
||||||
for (size_t j = i; j < end; ++ j) {
|
|
||||||
if (bool newline = in[j] == '\n'; in[j] == ' ' || in[j] == '\t' || newline) {
|
|
||||||
ibreak = j;
|
|
||||||
overwrite = true;
|
|
||||||
if (newline)
|
|
||||||
break;
|
|
||||||
} else if (in[j] == '/' || in[j] == '\\')
|
|
||||||
ibreak = j + 1;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// UTF8 representation of wxString.
|
// UTF8 representation of wxString.
|
||||||
// Where to break the line, index of character at the start of a UTF-8 sequence.
|
// Where to break the line, index of character at the start of a UTF-8 sequence.
|
||||||
size_t ibreak = size_t(-1);
|
size_t ibreak = size_t(-1);
|
||||||
// Overwrite the character at ibreak (it is a whitespace) or not?
|
// Overwrite the character at ibreak (it is a whitespace) or not?
|
||||||
for (size_t cnt = 0, j = i; j < in.size();) {
|
size_t j = i;
|
||||||
|
for (size_t cnt = 0; j < in.size();) {
|
||||||
if (bool newline = in[j] == '\n'; in[j] == ' ' || in[j] == '\t' || newline) {
|
if (bool newline = in[j] == '\n'; in[j] == ' ' || in[j] == '\t' || newline) {
|
||||||
// Overwrite the whitespace.
|
// Overwrite the whitespace.
|
||||||
ibreak = j ++;
|
ibreak = j ++;
|
||||||
|
@ -326,15 +313,22 @@ wxString get_wraped_wxString(const wxString& in, size_t line_len /*=80*/)
|
||||||
} else if (in[j] == '/') {
|
} else if (in[j] == '/') {
|
||||||
// Insert after the slash.
|
// Insert after the slash.
|
||||||
ibreak = ++ j;
|
ibreak = ++ j;
|
||||||
|
overwrite = false;
|
||||||
} else
|
} else
|
||||||
j += get_utf8_sequence_length(in.c_str() + j, in.size() - j);
|
j += get_utf8_sequence_length(in.c_str() + j, in.size() - j);
|
||||||
if (++ cnt == line_len) {
|
if (++ cnt == line_len) {
|
||||||
if (ibreak == size_t(-1))
|
if (ibreak == size_t(-1)) {
|
||||||
ibreak = j;
|
ibreak = j;
|
||||||
|
overwrite = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
if (j == in.size()) {
|
||||||
|
out.append(in.begin() + i, in.end());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
assert(ibreak != size_t(-1));
|
||||||
out.append(in.begin() + i, in.begin() + ibreak);
|
out.append(in.begin() + i, in.begin() + ibreak);
|
||||||
out.append('\n');
|
out.append('\n');
|
||||||
i = ibreak;
|
i = ibreak;
|
||||||
|
|
|
@ -4139,7 +4139,10 @@ wxSizer* TabPrint::create_manage_substitution_widget(wxWindow* parent)
|
||||||
});
|
});
|
||||||
|
|
||||||
create_btn(&m_del_all_substitutions_btn, _L("Delete all"), "cross");
|
create_btn(&m_del_all_substitutions_btn, _L("Delete all"), "cross");
|
||||||
m_del_all_substitutions_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent e) {
|
m_del_all_substitutions_btn->Bind(wxEVT_BUTTON, [this, parent](wxCommandEvent e) {
|
||||||
|
if (MessageDialog(parent, _L("Are you sure you want to delete all substitutions?"), SLIC3R_APP_NAME, wxYES_NO | wxICON_QUESTION).
|
||||||
|
ShowModal() != wxID_YES)
|
||||||
|
return;
|
||||||
m_subst_manager.delete_all();
|
m_subst_manager.delete_all();
|
||||||
m_del_all_substitutions_btn->Hide();
|
m_del_all_substitutions_btn->Hide();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue