From 8ad62dec5afa40d5386d9f711fb5b8de8bcbfa9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 29 Mar 2009 14:23:59 +0000 Subject: [PATCH] Patch by Obaro Ogbo: Provide a PreferredWidth() implementation for the Relation attribute column in the Open With panel. So double clicking will size it properly. Fixes ticket #3035. Thanks a lot! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29779 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/WidgetAttributeText.cpp | 14 ++++++++++++-- src/kits/tracker/WidgetAttributeText.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/kits/tracker/WidgetAttributeText.cpp b/src/kits/tracker/WidgetAttributeText.cpp index c1e8a9b48a..4b9882b490 100644 --- a/src/kits/tracker/WidgetAttributeText.cpp +++ b/src/kits/tracker/WidgetAttributeText.cpp @@ -1772,6 +1772,16 @@ OpenWithRelationAttributeText::ReadValue() } +float +OpenWithRelationAttributeText::PreferredWidth(const BPoseView *pose) const +{ + BString widthString; + TruncString(&widthString, fRelationText.String(), fRelationText.Length(), + pose, 500, B_TRUNCATE_END); + return pose->StringWidth(widthString.String()); +} + + void OpenWithRelationAttributeText::FitValue(BString *result, const BPoseView *view) { @@ -1786,8 +1796,8 @@ OpenWithRelationAttributeText::FitValue(BString *result, const BPoseView *view) launchWithView->OpenWithRelationDescription(fModel, &fRelationText); fOldWidth = fColumn->Width(); - fTruncatedWidth = TruncString(result, fRelationText.String(), fRelationText.Length(), - view, fOldWidth, B_TRUNCATE_END); + fTruncatedWidth = TruncString(result, fRelationText.String(), + fRelationText.Length(), view, fOldWidth, B_TRUNCATE_END); fDirty = false; } diff --git a/src/kits/tracker/WidgetAttributeText.h b/src/kits/tracker/WidgetAttributeText.h index b4206f6129..64b28adeee 100644 --- a/src/kits/tracker/WidgetAttributeText.h +++ b/src/kits/tracker/WidgetAttributeText.h @@ -357,6 +357,7 @@ class OpenWithRelationAttributeText : public ScalarAttributeText { protected: virtual void FitValue(BString *result, const BPoseView *); virtual int64 ReadValue(); + virtual float PreferredWidth(const BPoseView *) const; const BPoseView *fPoseView; BString fRelationText;