From 652243dade7ecb968920d7e6abe9d8090ba9d52d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 2 Jul 2003 02:13:13 +0000 Subject: [PATCH] Added workaround for a misbehaving BOptionPopUp class (doesn't resize itself properly - it obviously needs the correct size at creation time...). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3799 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/media/DefaultMediaTheme.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/kits/media/DefaultMediaTheme.cpp b/src/kits/media/DefaultMediaTheme.cpp index bb8e3605fe..1959fdc73b 100644 --- a/src/kits/media/DefaultMediaTheme.cpp +++ b/src/kits/media/DefaultMediaTheme.cpp @@ -389,6 +389,20 @@ DefaultMediaTheme::MakeViewFor(BParameter *parameter, const BRect *hintRect) } else { // create a pop up menu field + // ToDo: replace BOptionPopUp (or fix it in OpenBeOS...) + // this is a workaround for a bug in BOptionPopUp - you need to + // know the actual width before creating the object - very nice... + + BFont font; + float width = 0; + for (int32 i = 0; i < discrete.CountItems(); i++) { + float labelWidth = font.StringWidth(discrete.ItemNameAt(i)); + if (labelWidth > width) + width = labelWidth; + } + width += font.StringWidth(discrete.Name()) + 55; + rect.right = rect.left + width; + BOptionPopUp *popUp = new BOptionPopUp(rect, discrete.Name(), discrete.Name(), NULL); for (int32 i = 0; i < discrete.CountItems(); i++) {