From af9e7fd4609381e2086a13a603e5e46e64718a77 Mon Sep 17 00:00:00 2001 From: taler21 Date: Wed, 23 Mar 2022 14:40:56 +0100 Subject: [PATCH] Fix truncation of translated "Finish" button label in wxWizard Ensure that the button is wide enough to show both "Next" and "Finish" and also make all the buttons of the same size, as they look better like this. Co-authored-by: Vadim Zeitlin Closes #22200. Closes #22221. --- src/generic/wizard.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/generic/wizard.cpp b/src/generic/wizard.cpp index c221ac7ae1..d0ae77094b 100644 --- a/src/generic/wizard.cpp +++ b/src/generic/wizard.cpp @@ -439,6 +439,37 @@ void wxWizard::AddButtonRow(wxBoxSizer *mainColumn) #endif m_btnPrev = new wxButton(this, wxID_BACKWARD, _("< &Back"), wxDefaultPosition, wxDefaultSize, buttonStyle); + // compute the maximum width of the buttons and use it for all of them + // (except for the "Help" button under Mac which is special there) + wxSize buttonSize; + buttonSize.IncTo(m_btnPrev->GetBestSize()); + buttonSize.IncTo(m_btnNext->GetBestSize()); + buttonSize.IncTo(btnCancel->GetBestSize()); + + // use the other possible label for the "Next" button temporarily, so that + // we could make it big enough to fit it too if it's longer + m_btnNext->SetLabel(m_finishLabel); + buttonSize.IncTo(m_btnNext->GetBestSize()); + +#ifndef __WXMAC__ + if (btnHelp) + buttonSize.IncTo(btnHelp->GetBestSize()); +#endif + + // now do make all buttons of the same (and big enough) size + m_btnPrev->SetMinSize(buttonSize); + m_btnNext->SetMinSize(buttonSize); + btnCancel->SetMinSize(buttonSize); + +#ifndef __WXMAC__ + if (btnHelp) + btnHelp->SetMinSize(buttonSize); +#endif + + // restore the initial label of the 'next' button after temporarily + // changing it above + m_btnNext->SetLabel(m_nextLabel); + if (btnHelp) { buttonRow->Add(