From 08b433012e561f505af71160cb97e29a2addf7a5 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Wed, 27 May 2026 11:23:58 +0200 Subject: [PATCH] Fix volume size unit choice width The volume size page populates the unit wxChoice after the generated base class has already fit the empty control. On macOS this can leave the closed choice too narrow, truncating MiB to .... Measure the localized unit labels after appending them and set a sufficient minimum width. --- src/Main/Forms/VolumeSizeWizardPage.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Main/Forms/VolumeSizeWizardPage.cpp b/src/Main/Forms/VolumeSizeWizardPage.cpp index 893ea1ec..f2305b71 100644 --- a/src/Main/Forms/VolumeSizeWizardPage.cpp +++ b/src/Main/Forms/VolumeSizeWizardPage.cpp @@ -30,6 +30,23 @@ namespace VeraCrypt VolumeSizePrefixChoice->Append (LangString["TB"], reinterpret_cast (4)); VolumeSizePrefixChoice->Select (Prefix::MB); + // The generated base class fits this choice while it is still empty. + // Size it after adding localized labels so Cocoa does not truncate "MiB" to "...". + wxCoord maxPrefixTextWidth = 0; + for (unsigned int i = 0; i < VolumeSizePrefixChoice->GetCount(); ++i) + { + wxCoord textWidth, textHeight; + VolumeSizePrefixChoice->GetTextExtent (VolumeSizePrefixChoice->GetString (i), &textWidth, &textHeight); + if (textWidth > maxPrefixTextWidth) + maxPrefixTextWidth = textWidth; + } + + wxSize prefixChoiceSize = VolumeSizePrefixChoice->GetBestSize(); + int minPrefixChoiceWidth = maxPrefixTextWidth + Gui->GetCharWidth (VolumeSizePrefixChoice) * 6; + if (prefixChoiceSize.GetWidth() < minPrefixChoiceWidth) + prefixChoiceSize.SetWidth (minPrefixChoiceWidth); + VolumeSizePrefixChoice->SetMinSize (prefixChoiceSize); + wxLongLong diskSpace = 0; if (!wxGetDiskSpace (wxFileName (wstring (volumePath)).GetPath(), nullptr, &diskSpace)) {