summaryrefslogtreecommitdiff
path: root/vcl/source/control/button.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/control/button.cxx')
-rw-r--r--vcl/source/control/button.cxx22
1 files changed, 19 insertions, 3 deletions
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 91a4aa4543a3..d0614c4ab96c 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -825,7 +825,11 @@ void PushButton::ImplDrawPushButtonContent(OutputDevice *pDev, DrawFlags nDrawFl
nSymbolSize = aSize.Width() / 2;
nSeparatorX = aInRect.Right() - 2*nSymbolSize;
- aSize.AdjustWidth( -(2*nSymbolSize) );
+
+ // tdf#141761 Minimum width should be (1) Pixel, see comment
+ // with same task number above for more info
+ const tools::Long nWidthAdjust(2*nSymbolSize);
+ aSize.setWidth(std::max(static_cast<tools::Long>(1), aSize.getWidth() - nWidthAdjust));
// center symbol rectangle in the separated area
aSymbolRect.AdjustRight( -(nSymbolSize/2) );
@@ -1982,7 +1986,16 @@ void RadioButton::ImplDraw( OutputDevice* pDev, DrawFlags nDrawFlags,
Size aSize( rSize );
Point aPos( rPos );
aPos.AdjustX(rImageSize.Width() + nImageSep );
- aSize.AdjustWidth( -(rImageSize.Width() + nImageSep) );
+
+ // tdf#141761 Old (convenience?) adjustment of width may lead to empty
+ // or negative(!) Size, that needs to be avoided. The coordinate context
+ // is pixel-oriented (all Paints of Controls are, historically), so
+ // the minimum width should be '1' Pixel.
+ // Hint: nImageSep is based on Zoom (using Window::CalcZoom) and
+ // MapModes (using Window::GetDrawPixel) - so potenially a wide range
+ // of unpredictable values is possible
+ const tools::Long nWidthAdjust(rImageSize.Width() + nImageSep);
+ aSize.setWidth(std::max(static_cast<tools::Long>(1), aSize.getWidth() - nWidthAdjust));
// if the text rect height is smaller than the height of the image
// then for single lines the default should be centered text
@@ -2996,7 +3009,10 @@ void CheckBox::ImplDraw( OutputDevice* pDev, DrawFlags nDrawFlags,
Size aSize( rSize );
Point aPos( rPos );
aPos.AdjustX(rImageSize.Width() + nImageSep );
- aSize.AdjustWidth( -(rImageSize.Width() + nImageSep) );
+
+ // tdf#141761 See comment with same ID above
+ const tools::Long nWidthAdjust(rImageSize.Width() + nImageSep);
+ aSize.setWidth(std::max(static_cast<tools::Long>(1), aSize.getWidth() - nWidthAdjust));
// if the text rect height is smaller than the height of the image
// then for single lines the default should be centered text