From 75c552811f3871f81c8b0d12ea2de54381e87df1 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 14 Mar 2023 23:55:31 +0000 Subject: [PATCH] Wrap wxGenericMessageDialog text to make it more readable Prevent the text from being clipped and also improve readability by wrapping it at (arbitrarily hard coded) 70 characters boundary. Closes #24412. --- src/generic/msgdlgg.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/generic/msgdlgg.cpp b/src/generic/msgdlgg.cpp index da77e4ec5a..4e256c8587 100644 --- a/src/generic/msgdlgg.cpp +++ b/src/generic/msgdlgg.cpp @@ -184,6 +184,12 @@ void wxGenericMessageDialog::DoCreateMsgdialog() wxBoxSizer * const textsizer = new wxBoxSizer(wxVERTICAL); + // To prevent clipping + int maxWidth = wxSystemSettings::GetMetric(wxSYS_SCREEN_X, this) - FromDIP(25); + + // To enhance readability + maxWidth = wxMin( maxWidth, GetCharWidth() * 70 ); + // We want to show the main message in a different font to make it stand // out if the extended message is used as well. This looks better and is // more consistent with the native dialogs under MSW and GTK. @@ -191,7 +197,7 @@ void wxGenericMessageDialog::DoCreateMsgdialog() if ( !m_extendedMessage.empty() ) { wxTitleTextWrapper titleWrapper(this); - textsizer->Add(CreateTextSizer(GetMessage(), titleWrapper), + textsizer->Add(CreateTextSizer(GetMessage(), titleWrapper, maxWidth), wxSizerFlags().Border(wxBOTTOM, 20)); lowerMessage = GetExtendedMessage(); @@ -201,7 +207,7 @@ void wxGenericMessageDialog::DoCreateMsgdialog() lowerMessage = GetMessage(); } - textsizer->Add(CreateTextSizer(lowerMessage)); + textsizer->Add(CreateTextSizer(lowerMessage, maxWidth)); icon_text->Add(textsizer, 0, wxALIGN_CENTER, 10); topsizer->Add( icon_text, 1, wxLEFT|wxRIGHT|wxTOP, 10 );