From e4891ca7c39d1ec78bf7ffd867f83fc755ab1f8b Mon Sep 17 00:00:00 2001 From: Humdinger Date: Wed, 4 Sep 2024 14:02:47 +0200 Subject: [PATCH] Budget: On change, resize all columns to preferred size ResizeAllColumnsToPreferred() is much easier than determine the widest string manually. It also resized the column header... --- src/BudgetWindow.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/BudgetWindow.cpp b/src/BudgetWindow.cpp index 71ca7c3..9f192c5 100644 --- a/src/BudgetWindow.cpp +++ b/src/BudgetWindow.cpp @@ -379,18 +379,6 @@ BudgetWindow::RefreshBudgetSummary(void) irow->SetField(new BStringField(itemp.String()), i + 1); srow->SetField(new BStringField(stemp.String()), i + 1); mrow->SetField(new BStringField(mtemp.String()), i + 1); - - float colwidth = fBudgetSummary->StringWidth(itemp.String()) + 20; - if (fBudgetSummary->ColumnAt(i + 1)->Width() < colwidth) - fBudgetSummary->ColumnAt(i + 1)->SetWidth(colwidth); - - colwidth = fBudgetSummary->StringWidth(stemp.String()) + 20; - if (fBudgetSummary->ColumnAt(i + 1)->Width() < colwidth) - fBudgetSummary->ColumnAt(i + 1)->SetWidth(colwidth); - - colwidth = fBudgetSummary->StringWidth(mtemp.String()) + 20; - if (fBudgetSummary->ColumnAt(i + 1)->Width() < colwidth) - fBudgetSummary->ColumnAt(i + 1)->SetWidth(colwidth); } BString ttemp; @@ -410,6 +398,7 @@ BudgetWindow::RefreshBudgetSummary(void) ttemp.RemoveFirst(gDefaultLocale.CurrencySymbol()); fBudgetSummary->RowAt(2)->SetField(new BStringField(ttemp.String()), 13); + fBudgetSummary->ResizeAllColumnsToPreferred(); fBudgetSummary->Invalidate(); }