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.
This commit is contained in:
Dima Buzdyk
2024-05-18 19:31:25 +05:00
committed by GitHub
parent f7671af7b9
commit af8a29e7a3
2 changed files with 13 additions and 12 deletions

View File

@@ -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

View File

@@ -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;