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.
This commit is contained in:
Mounir IDRASSI
2026-05-27 11:23:58 +02:00
parent ce20a24aa5
commit 08b433012e

View File

@@ -30,6 +30,23 @@ namespace VeraCrypt
VolumeSizePrefixChoice->Append (LangString["TB"], reinterpret_cast <void *> (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))
{