Skip to content

Commit d3b5ec6

Browse files
author
Thomas Singer
committed
[Win] Enabled Image+Text button ignores alignment #3277
1 parent 65f43d4 commit d3b5ec6

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,9 @@ LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) {
14031403
gc.dispose ();
14041404
}
14051405

1406-
left += isRadioOrCheck() ? radioOrCheckTextPadding : 0;
1406+
left += isRadioOrCheck()
1407+
? radioOrCheckTextPadding
1408+
: image != null ? MARGIN : 0;
14071409
RECT textRect = new RECT ();
14081410
OS.SetRect (textRect, left, nmcd.top + border, right, nmcd.bottom - border);
14091411

@@ -1420,13 +1422,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) {
14201422
}
14211423
OS.DrawText(nmcd.hdc, buffer, buffer.length, textRect, flags | OS.DT_CALCRECT);
14221424
OS.OffsetRect(textRect, 0, Math.max(0, (nmcd.bottom - textRect.bottom - border) / 2));
1423-
if (image != null) {
1424-
// The default button with an image doesn't respect the text alignment. So we do the same for styled buttons.
1425-
flags |= OS.DT_LEFT;
1426-
if (!isRadioOrCheck()) {
1427-
OS.OffsetRect(textRect, Math.max(MARGIN, (right - textRect.right) / 2 + 1), 0);
1428-
}
1429-
} else if ((style & SWT.LEFT) != 0) {
1425+
if ((style & SWT.LEFT) != 0) {
14301426
flags |= OS.DT_LEFT;
14311427
} else if ((style & SWT.RIGHT) != 0) {
14321428
flags |= OS.DT_RIGHT;

0 commit comments

Comments
 (0)