From 015fc22e0d00b80f5679ea271f71656ea3733d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Wed, 17 Jul 2013 15:28:18 +0100 Subject: [PATCH] fix radiobutton GetOptimalSize for images Incredibly ugly stuff, but this is (as far as I can see) what the drawing is actually doing. e.g. WB_TOP, surely it should be using image align. Change-Id: If2dcb1caf92cd5bbd2f07114ae2c41843b5a7f38 --- vcl/source/control/button.cxx | 42 +++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index de4d7a331de5..55e602436ba0 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -3075,32 +3075,46 @@ Size RadioButton::CalcMinimumSize( long nMaxWidth ) const if ( !maImage ) aSize = ImplGetRadioImageSize(); else + { aSize = maImage.GetSizePixel(); - - nMaxWidth -= aSize.Width(); + aSize.Width() += 8; + aSize.Height() += 8; + } OUString aText = GetText(); if ( !aText.isEmpty() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) ) { + bool bTopImage = (GetStyle() & WB_TOP) != 0; + + if (!bTopImage) + { + nMaxWidth -= aSize.Width(); + nMaxWidth -= ImplGetImageToTextDistance(); + } + // subtract what will be added later nMaxWidth-=2; - nMaxWidth -= ImplGetImageToTextDistance(); Size aTextSize = GetTextRect( Rectangle( Point(), Size( nMaxWidth > 0 ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ), aText, FixedText::ImplGetTextStyle( GetStyle() ) ).GetSize(); + aSize.Width()+=2; // for focus rect - aSize.Width() += ImplGetImageToTextDistance(); - aSize.Width() += aTextSize.Width(); - if ( aSize.Height() < aTextSize.Height() ) - aSize.Height() = aTextSize.Height(); + + if (!bTopImage) + { + aSize.Width() += ImplGetImageToTextDistance(); + aSize.Width() += aTextSize.Width(); + if ( aSize.Height() < aTextSize.Height() ) + aSize.Height() = aTextSize.Height(); + } + else + { + aSize.Height() += 6; + aSize.Height() += GetTextHeight(); + if ( aSize.Width() < aTextSize.Width() ) + aSize.Width() = aTextSize.Width(); + } } -// else if ( !maImage ) -// { -/* da ansonsten im Writer die Control zu weit oben haengen - aSize.Width() += 2; - aSize.Height() += 2; -*/ -// } return CalcWindowSize( aSize ); }