implemented PartitionColumn::GetPreferredWidth()
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28462 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -127,6 +127,35 @@ PartitionColumn::DrawField(BField* field, BRect rect, BView* parent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float
|
||||||
|
PartitionColumn::GetPreferredWidth(BField *_field, BView* parent) const
|
||||||
|
{
|
||||||
|
BBitmapStringField* bitmapField
|
||||||
|
= dynamic_cast<BBitmapStringField*>(_field);
|
||||||
|
BStringField* stringField = dynamic_cast<BStringField*>(_field);
|
||||||
|
|
||||||
|
float parentWidth = Inherited::GetPreferredWidth(_field, parent);
|
||||||
|
float width = 0.0;
|
||||||
|
|
||||||
|
if (bitmapField) {
|
||||||
|
const BBitmap* bitmap = bitmapField->Bitmap();
|
||||||
|
BFont font;
|
||||||
|
parent->GetFont(&font);
|
||||||
|
width = font.StringWidth(bitmapField->String()) + 3 * fTextMargin;
|
||||||
|
if (bitmap)
|
||||||
|
width += bitmap->Bounds().Width();
|
||||||
|
else
|
||||||
|
width += 16;
|
||||||
|
} else if (stringField) {
|
||||||
|
BFont font;
|
||||||
|
parent->GetFont(&font);
|
||||||
|
width = font.StringWidth(stringField->String()) + 2 * fTextMargin;
|
||||||
|
}
|
||||||
|
return max_c(width, parentWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PartitionColumn::AcceptsField(const BField* field) const
|
PartitionColumn::AcceptsField(const BField* field) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public:
|
|||||||
|
|
||||||
virtual void DrawField(BField* field, BRect rect,
|
virtual void DrawField(BField* field, BRect rect,
|
||||||
BView* parent);
|
BView* parent);
|
||||||
|
virtual float GetPreferredWidth(BField* field, BView* parent) const;
|
||||||
|
|
||||||
virtual bool AcceptsField(const BField* field) const;
|
virtual bool AcceptsField(const BField* field) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user