takes into account the column title width

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28461 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2008-11-02 12:33:32 +00:00
parent 60266d74d9
commit 13cb35848b
2 changed files with 14 additions and 1 deletions
+2
View File
@@ -41,6 +41,8 @@ class BTitledColumn : public BColumn
void Title (BString* forTitle) const; // sets the BString arg to be the title
float FontHeight () const;
virtual float GetPreferredWidth(BField* field, BView* parent) const;
private:
float fFontHeight;
BString fTitle;
+12 -1
View File
@@ -103,6 +103,15 @@ BTitledColumn::FontHeight() const
}
float
BTitledColumn::GetPreferredWidth(BField *_field, BView* parent) const
{
BFont font;
parent->GetFont(&font);
return font.StringWidth(fTitle.String()) + 2 * kTEXT_MARGIN;
}
// #pragma mark -
@@ -193,7 +202,9 @@ BStringColumn::GetPreferredWidth(BField *_field, BView* parent) const
BStringField* field = static_cast<BStringField*>(_field);
BFont font;
parent->GetFont(&font);
return font.StringWidth(field->String()) + 2 * kTEXT_MARGIN;
float width = font.StringWidth(field->String()) + 2 * kTEXT_MARGIN;
float parentWidth = BTitledColumn::GetPreferredWidth(_field, parent);
return max_c(width, parentWidth);
}