From af8a29e7a3382bba50f208094b3d67f9af3e9ebb Mon Sep 17 00:00:00 2001 From: Dima Buzdyk <46728448+buzzhuzz@users.noreply.github.com> Date: Sat, 18 May 2024 19:31:25 +0500 Subject: [PATCH] gui: improve RichMessageDialog (#5371) * gui: improve RichMessageDialog Current implementation of RichMessageDialog creates and pushes extra checkbox widget into button button sizer which already filled in with wxEXPAND items. That pushes position of newly added checkbox to the left-most position which makes it invisibe for some users. Optimize implementation of RichMessageDialog using m_checkbox_dsa of MessageDialog instead of creating a new one. As a result, position of the checkbox is right below the main text section. --- src/slic3r/GUI/MsgDialog.cpp | 23 ++++++++++++----------- src/slic3r/GUI/MsgDialog.hpp | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 4dd700fd46..fa0a13f9a5 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -383,26 +383,27 @@ RichMessageDialog::RichMessageDialog(wxWindow* parent, : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_FULL_NAME) : caption, wxEmptyString, style) { add_msg_content(this, content_sizer, message); - - m_checkBox = new wxCheckBox(this, wxID_ANY, m_checkBoxText); - wxGetApp().UpdateDarkUI(m_checkBox); - m_checkBox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { m_checkBoxValue = m_checkBox->GetValue(); }); - - btn_sizer->Insert(0, m_checkBox, wxALIGN_CENTER_VERTICAL); - finalize(); } int RichMessageDialog::ShowModal() { - if (m_checkBoxText.IsEmpty()) - m_checkBox->Hide(); - else - m_checkBox->SetLabelText(m_checkBoxText); + if (!m_checkBoxText.IsEmpty()) { + show_dsa_button(m_checkBoxText); + m_checkbox_dsa->SetValue(m_checkBoxValue); + } Layout(); return wxDialog::ShowModal(); } + +bool RichMessageDialog::IsCheckBoxChecked() const +{ + if (m_checkbox_dsa) + return m_checkbox_dsa->GetValue(); + + return m_checkBoxValue; +} #endif // InfoDialog diff --git a/src/slic3r/GUI/MsgDialog.hpp b/src/slic3r/GUI/MsgDialog.hpp index a7acc42de2..e62251af7d 100644 --- a/src/slic3r/GUI/MsgDialog.hpp +++ b/src/slic3r/GUI/MsgDialog.hpp @@ -193,7 +193,7 @@ public: } wxString GetCheckBoxText() const { return m_checkBoxText; } - bool IsCheckBoxChecked() const { return m_checkBoxValue; } + bool IsCheckBoxChecked() const; // This part o fcode isported from the "wx\msgdlg.h" using wxMD = wxMessageDialogBase;