Skip to content

Commit cd3bb9b

Browse files
committed
Tweaked static
1 parent 2fe01bf commit cd3bb9b

File tree

1 file changed

+7
-4
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ public class MenuItem extends Item {
4747
/* Image margin. */
4848
final static int MARGIN_WIDTH = 1;
4949
final static int MARGIN_HEIGHT = 1;
50-
final static int LEFT_TEXT_MARGIN = 5;
51-
final static int IMAGE_TEXT_GAP = 3;
52-
final static int WINDOWS_OVERHEAD = 5;
50+
private final static int LEFT_TEXT_MARGIN = 7;
51+
private final static int IMAGE_TEXT_GAP = 3;
52+
// There is a weird behavior in the Windows API with menus in OWENERDRAW mode that the returned
53+
// value in wmMeasureChild is increased by a fixed value (in points) when wmDrawChild is called
54+
// This static is used to mitigate this increase
55+
private final static int WINDOWS_OVERHEAD = 6;
5356
static {
5457
DPIZoomChangeRegistry.registerHandler(MenuItem::handleDPIChange, MenuItem.class);
5558
}
@@ -1186,7 +1189,7 @@ LRESULT wmDrawChild(long wParam, long lParam) {
11861189
gc.fillRectangle(menuItemArea);
11871190

11881191
int xPositionText = LEFT_TEXT_MARGIN + DPIUtil.scaleDown(x, zoom) + (this.image != null ? this.image.getBounds().width + IMAGE_TEXT_GAP : 0);
1189-
int yPositionText = DPIUtil.scaleDown(struct.top , zoom);
1192+
int yPositionText = DPIUtil.scaleDown(struct.top , zoom) + MARGIN_HEIGHT;
11901193
gc.drawText(drawnText, xPositionText, yPositionText, flags);
11911194
}
11921195
if (image != null) {

0 commit comments

Comments
 (0)