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:
@@ -41,6 +41,8 @@ class BTitledColumn : public BColumn
|
|||||||
void Title (BString* forTitle) const; // sets the BString arg to be the title
|
void Title (BString* forTitle) const; // sets the BString arg to be the title
|
||||||
float FontHeight () const;
|
float FontHeight () const;
|
||||||
|
|
||||||
|
virtual float GetPreferredWidth(BField* field, BView* parent) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float fFontHeight;
|
float fFontHeight;
|
||||||
BString fTitle;
|
BString fTitle;
|
||||||
|
|||||||
@@ -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 -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
@@ -193,7 +202,9 @@ BStringColumn::GetPreferredWidth(BField *_field, BView* parent) const
|
|||||||
BStringField* field = static_cast<BStringField*>(_field);
|
BStringField* field = static_cast<BStringField*>(_field);
|
||||||
BFont font;
|
BFont font;
|
||||||
parent->GetFont(&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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user