Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java318
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java48
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java62
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java69
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java438
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java272
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java623
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java93
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java113
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java200
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java937
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java70
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java415
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java48
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java99
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java282
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java849
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java256
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java159
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java106
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java46
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java50
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java97
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java449
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java70
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java211
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java101
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java825
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java177
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java343
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskItem.java61
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java450
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java222
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java98
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolTip.java24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java72
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java1146
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java259
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java420
50 files changed, 5394 insertions, 5473 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
index 20fcc839ba..592eaedc40 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
@@ -50,20 +50,18 @@ import org.eclipse.swt.internal.win32.*;
*/
public class Button extends Control {
String text = "", message = "";
- Image image, image2, disabledImage;
+ Image image, disabledImage;
ImageList imageList;
- boolean ignoreMouse, grayed;
- int buttonBackground = -1;
- // we need our own field, because setting Control.background causes two colored pixels around the button.
- int buttonBackgroundAlpha = 255;
+ boolean ignoreMouse, grayed, useDarkModeExplorerTheme;
static final int MARGIN = 4;
static final int CHECK_WIDTH, CHECK_HEIGHT;
static final int ICON_WIDTH = 128, ICON_HEIGHT = 128;
static /*final*/ boolean COMMAND_LINK = false;
- static final long /*int*/ ButtonProc;
+ static final char[] STRING_WITH_ZERO_CHAR = new char[] {'0'};
+ static final long ButtonProc;
static final TCHAR ButtonClass = new TCHAR (0, "BUTTON", true);
static {
- long /*int*/ hBitmap = OS.LoadBitmap (0, OS.OBM_CHECKBOXES);
+ long hBitmap = OS.LoadBitmap (0, OS.OBM_CHECKBOXES);
if (hBitmap == 0) {
CHECK_WIDTH = OS.GetSystemMetrics (OS.SM_CXVSCROLL);
CHECK_HEIGHT = OS.GetSystemMetrics (OS.SM_CYVSCROLL);
@@ -250,7 +248,7 @@ public void addSelectionListener (SelectionListener listener) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
return OS.CallWindowProc (ButtonProc, hwnd, msg, wParam, lParam);
}
@@ -289,9 +287,9 @@ int computeLeftMargin () {
if (image != null && text.length () != 0) {
Rectangle bounds = image.getBoundsInPixels ();
margin += bounds.width + MARGIN * 2;
- long /*int*/ oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ long oldFont = 0;
+ long hDC = OS.GetDC (handle);
+ long newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
char [] buffer = text.toCharArray ();
RECT rect = new RECT ();
@@ -351,9 +349,9 @@ int computeLeftMargin () {
}
}
if (hasText) {
- long /*int*/ oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ long oldFont = 0;
+ long hDC = OS.GetDC (handle);
+ long newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
TEXTMETRIC lptm = new TEXTMETRIC ();
OS.GetTextMetrics (hDC, lptm);
@@ -445,11 +443,14 @@ void createHandle () {
if ((style & SWT.RADIO) != 0) {
state |= DRAW_BACKGROUND;
}
+
+ useDarkModeExplorerTheme = display.useDarkModeExplorerTheme;
+ maybeEnableDarkSystemTheme();
}
}
private boolean customBackgroundDrawing() {
- return buttonBackground != -1 && !isRadioOrCheck();
+ return background != -1 && !isRadioOrCheck();
}
private boolean customDrawing() {
@@ -536,18 +537,6 @@ public int getAlignment () {
return SWT.LEFT;
}
-@Override
-public Color getBackground () {
- if (isRadioOrCheck()) {
- return super.getBackground();
- }
- checkWidget ();
- if (buttonBackground != -1) {
- return Color.win32_new (display, buttonBackground, buttonBackgroundAlpha);
- }
- return Color.win32_new (display, defaultBackground());
-}
-
boolean getDefault () {
if ((style & SWT.PUSH) == 0) return false;
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
@@ -655,7 +644,7 @@ public String getText () {
}
private boolean isChecked() {
- long /*int*/ flags = OS.SendMessage (handle, OS.BM_GETCHECK, 0, 0);
+ long flags = OS.SendMessage (handle, OS.BM_GETCHECK, 0, 0);
return flags != OS.BST_UNCHECKED;
}
@@ -696,8 +685,6 @@ void releaseWidget () {
imageList = null;
if (disabledImage != null) disabledImage.dispose ();
disabledImage = null;
- if (image2 != null) image2.dispose ();
- image2 = null;
text = null;
image = null;
}
@@ -733,25 +720,7 @@ int resolveTextDirection() {
}
void selectRadio () {
- /*
- * This code is intentionally commented. When two groups
- * of radio buttons with the same parent are separated by
- * another control, the correct behavior should be that
- * the two groups act independently. This is consistent
- * with radio tool and menu items. The commented code
- * implements this behavior.
- */
-// int index = 0;
-// Control [] children = parent._getChildren ();
-// while (index < children.length && children [index] != this) index++;
-// int i = index - 1;
-// while (i >= 0 && children [i].setRadioSelection (false)) --i;
-// int j = index + 1;
-// while (j < children.length && children [j].setRadioSelection (false)) j++;
-// setSelection (true);
- Control [] children = parent._getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
+ for (Control child : parent._getChildren ()) {
if (this != child) child.setRadioSelection (false);
}
setSelection (true);
@@ -834,31 +803,13 @@ public void setAlignment (int alignment) {
*/
@Override
public void setBackground (Color color) {
- checkWidget ();
- if (isRadioOrCheck()) {
- super.setBackground(color);
- } else {
- setButtonBackground (color);
- }
-}
-
-private void setButtonBackground (Color color) {
- int pixel = -1;
- int alpha = 255;
- if (color != null) {
- if (color.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- pixel = color.handle;
- alpha = color.getAlpha();
- }
- if (pixel == buttonBackground && alpha == buttonBackgroundAlpha) return;
- buttonBackground = pixel;
- buttonBackgroundAlpha = alpha;
- updateBackgroundColor ();
+ // This method only exists in order to provide custom documentation
+ super.setBackground(color);
}
void setDefault (boolean value) {
if ((style & SWT.PUSH) == 0) return;
- long /*int*/ hwndShell = menuShell ().handle;
+ long hwndShell = menuShell ().handle;
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
if (value) {
bits |= OS.BS_DEFPUSHBUTTON;
@@ -878,7 +829,7 @@ public boolean setFocus () {
* it selects the button in WM_SETFOCUS. The fix is to
* not assign focus to an unselected radio button.
*/
- if ((style & SWT.RADIO) != 0 && !isChecked () && display.fixFocus) return false;
+ if ((style & SWT.RADIO) != 0 && !isChecked ()) return false;
return super.setFocus ();
}
@@ -906,13 +857,6 @@ public void setImage (Image image) {
if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
if ((style & SWT.ARROW) != 0) return;
this.image = image;
- /* This code is intentionally commented */
-// if (OS.COMCTL32_MAJOR < 6) {
-// if (image == null || text.length () != 0) {
-// _setText (text);
-// return;
-// }
-// }
_setImage (image);
}
@@ -934,7 +878,7 @@ public void setGrayed (boolean grayed) {
checkWidget ();
if ((style & SWT.CHECK) == 0) return;
this.grayed = grayed;
- long /*int*/ flags = OS.SendMessage (handle, OS.BM_GETCHECK, 0, 0);
+ long flags = OS.SendMessage (handle, OS.BM_GETCHECK, 0, 0);
if (grayed) {
if (flags == OS.BST_CHECKED) updateSelection (OS.BST_INDETERMINATE);
} else {
@@ -1052,13 +996,6 @@ public void setText (String string) {
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if ((style & SWT.ARROW) != 0) return;
text = string;
- /* This code is intentionally commented */
-// if (OS.COMCTL32_MAJOR < 6) {
-// if (text.length () == 0 && image != null) {
-// _setImage (image);
-// return;
-// }
-// }
_setText (string);
}
@@ -1159,12 +1096,27 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return ButtonProc;
}
@Override
-LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmColorChild (long wParam, long lParam) {
+ if (isRadioOrCheck()) {
+ // In order to match old SWT behavior and SWT behavior on other
+ // platforms, Radio and Check have their own background instead
+ // of showing parent's background.
+ return super.wmColorChild(wParam, lParam);
+ } else {
+ // Button has "transparent" portions which need to be filled with
+ // parent's (and not Button's) background. For example, SWT.PUSH
+ // button ~2px transparent area around the button.
+ return parent.wmColorChild(wParam, lParam);
+ }
+}
+
+@Override
+LRESULT WM_GETDLGCODE (long wParam, long lParam) {
LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
if (result != null) return result;
if ((style & SWT.ARROW) != 0) {
@@ -1174,7 +1126,7 @@ LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_GETOBJECT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETOBJECT (long wParam, long lParam) {
/*
* Ensure that there is an accessible object created for this
* control because support for radio button position in group
@@ -1187,7 +1139,7 @@ LRESULT WM_GETOBJECT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KILLFOCUS (long wParam, long lParam) {
LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
if ((style & SWT.PUSH) != 0 && getDefault ()) {
menuShell ().setDefaultButton (null, false);
@@ -1196,19 +1148,19 @@ LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDOWN (long wParam, long lParam) {
if (ignoreMouse) return null;
return super.WM_LBUTTONDOWN (wParam, lParam);
}
@Override
-LRESULT WM_LBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONUP (long wParam, long lParam) {
if (ignoreMouse) return null;
return super.WM_LBUTTONUP (wParam, lParam);
}
@Override
-LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFOCUS (long wParam, long lParam) {
/*
* Feature in Windows. When Windows sets focus to
* a radio button, it sets the WS_TABSTOP style.
@@ -1230,7 +1182,7 @@ LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
LRESULT result = super.WM_SIZE (wParam, lParam);
if (result != null) return result;
if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) {
@@ -1247,15 +1199,14 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SYSCOLORCHANGE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SYSCOLORCHANGE (long wParam, long lParam) {
LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
if (result != null) return result;
- if (image2 != null) _setImage (image);
return result;
}
@Override
-LRESULT WM_UPDATEUISTATE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_UPDATEUISTATE (long wParam, long lParam) {
LRESULT result = super.WM_UPDATEUISTATE (wParam, lParam);
if (result != null) return result;
/*
@@ -1281,7 +1232,7 @@ LRESULT WM_UPDATEUISTATE (long /*int*/ wParam, long /*int*/ lParam) {
}
if (redraw) {
OS.InvalidateRect (handle, null, false);
- long /*int*/ code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam);
+ long code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam);
return new LRESULT (code);
}
}
@@ -1301,7 +1252,7 @@ LRESULT WM_UPDATEUISTATE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmCommandChild (long wParam, long lParam) {
int code = OS.HIWORD (wParam);
switch (code) {
case OS.BN_CLICKED:
@@ -1322,8 +1273,27 @@ LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
return super.wmCommandChild (wParam, lParam);
}
+private int getCheckboxTextOffset(long hdc) {
+ int result = 0;
+
+ SIZE size = new SIZE();
+
+ if (OS.IsAppThemed ()) {
+ OS.GetThemePartSize(display.hButtonTheme(), hdc, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, null, OS.TS_TRUE, size);
+ result += size.cx;
+ } else {
+ result += DPIUtil.autoScaleUpUsingNativeDPI(13);
+ }
+
+ // Windows uses half width of '0' as checkbox-to-text distance.
+ OS.GetTextExtentPoint32(hdc, STRING_WITH_ZERO_CHAR, 1, size);
+ result += size.cx / 2;
+
+ return result;
+}
+
@Override
-LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) {
switch (hdr.code) {
case OS.NM_CUSTOMDRAW:
// this message will not appear for owner-draw buttons (currently the ARROW button).
@@ -1335,30 +1305,51 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
case OS.CDDS_PREPAINT: {
// buttons are ignoring SetBkColor, SetBkMode and SetTextColor
if (customBackgroundDrawing()) {
- int pixel = buttonBackground;
+ int pixel = background;
if ((nmcd.uItemState & OS.CDIS_SELECTED) != 0) {
- pixel = getDifferentColor(buttonBackground);
+ pixel = getDifferentColor(background);
} else if ((nmcd.uItemState & OS.CDIS_HOT) != 0) {
- pixel = getSlightlyDifferentColor(buttonBackground);
+ pixel = getSlightlyDifferentColor(background);
}
if ((style & SWT.TOGGLE) != 0 && isChecked()) {
- pixel = getDifferentColor(buttonBackground);
+ pixel = getDifferentColor(background);
+ }
+
+ long brush = OS.CreateSolidBrush(pixel);
+
+ int inset = 2;
+ int radius = 3;
+ if (useDarkModeExplorerTheme && (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN11_21H2)) {
+ // On Win11, Light theme and Dark theme images have different sizes
+ inset = 1;
+ radius = 4;
}
- RECT rect = new RECT ();
- OS.SetRect (rect, nmcd.left+2, nmcd.top+2, nmcd.right-2, nmcd.bottom-2);
- long /*int*/ brush = OS.CreateSolidBrush(pixel);
- OS.FillRect(nmcd.hdc, rect, brush);
+
+ int l = nmcd.left + inset;
+ int t = nmcd.top + inset;
+ int r = nmcd.right - inset;
+ int b = nmcd.bottom - inset;
+
+ if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN11_21H2) {
+ // 'RoundRect' has left/top pixel reserved for border
+ l += 1;
+ t += 1;
+
+ // Win11 has buttons with rounded corners
+ OS.SaveDC(nmcd.hdc);
+ OS.SelectObject(nmcd.hdc, brush);
+ OS.SelectObject(nmcd.hdc, OS.GetStockObject(OS.NULL_PEN));
+ OS.RoundRect(nmcd.hdc, l, t, r, b, radius, radius);
+ OS.RestoreDC(nmcd.hdc, -1);
+ } else {
+ RECT rect = new RECT (l, t, r, b);
+ OS.FillRect(nmcd.hdc, rect, brush);
+ }
+
OS.DeleteObject(brush);
}
if (customForegroundDrawing()) {
- /*
- * Check-box/Radio buttons are native widget which honors
- * the Win OS zoom level for both 'Square' and 'Text' part
- * [Note: By-design SWT doesn't control native auto-scaling]
- * Hence, custom fore-ground draw logic should auto-scale
- * text-padding as per OS Native DPI level to fix bug 506371
- */
- int radioOrCheckTextPadding = DPIUtil.autoScaleUpUsingNativeDPI(16);
+ int radioOrCheckTextPadding = getCheckboxTextOffset(nmcd.hdc);
int border = isRadioOrCheck() ? 0 : 3;
int left = nmcd.left + border;
int right = nmcd.right - border;
@@ -1428,7 +1419,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
OS.SetRect (focusRect, nmcd.left+1+radioOrCheckTextPadding, nmcd.top, nmcd.right-2, nmcd.bottom-1);
}
} else {
- OS.SetRect (focusRect, nmcd.left+2, nmcd.top+3, nmcd.right-2, nmcd.bottom-3);
+ OS.SetRect (focusRect, nmcd.left+4, nmcd.top+4, nmcd.right-4, nmcd.bottom-4);
}
OS.DrawFocusRect(nmcd.hdc, focusRect);
}
@@ -1442,37 +1433,82 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
return super.wmNotifyChild (hdr, wParam, lParam);
}
+static int getThemeStateId(int style, boolean pressed, boolean enabled) {
+ int direction = style & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT);
+
+ /*
+ * Feature in Windows. DrawThemeBackground() does not mirror the drawing.
+ * The fix is switch left to right and right to left.
+ */
+ if ((style & SWT.MIRRORED) != 0) {
+ if (direction == SWT.LEFT) {
+ direction = SWT.RIGHT;
+ } else if (direction == SWT.RIGHT) {
+ direction = SWT.LEFT;
+ }
+ }
+
+ /*
+ * On Win11, scrollbars no longer show arrows by default.
+ * Arrows only show up when hot/disabled/pushed.
+ * The workaround is to use hot image in place of default.
+ */
+ boolean hot = false;
+ if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN11_21H2) {
+ if (!pressed && enabled) {
+ hot = true;
+ }
+ }
+
+ if (hot) {
+ switch (direction) {
+ case SWT.UP: return OS.ABS_UPHOT;
+ case SWT.DOWN: return OS.ABS_DOWNHOT;
+ case SWT.LEFT: return OS.ABS_LEFTHOT;
+ case SWT.RIGHT: return OS.ABS_RIGHTHOT;
+ }
+ }
+
+ if (pressed) {
+ switch (direction) {
+ case SWT.UP: return OS.ABS_UPPRESSED;
+ case SWT.DOWN: return OS.ABS_DOWNPRESSED;
+ case SWT.LEFT: return OS.ABS_LEFTPRESSED;
+ case SWT.RIGHT: return OS.ABS_RIGHTPRESSED;
+ }
+ }
+
+ if (!enabled) {
+ switch (direction) {
+ case SWT.UP: return OS.ABS_UPDISABLED;
+ case SWT.DOWN: return OS.ABS_DOWNDISABLED;
+ case SWT.LEFT: return OS.ABS_LEFTDISABLED;
+ case SWT.RIGHT: return OS.ABS_RIGHTDISABLED;
+ }
+ }
+
+ switch (direction) {
+ case SWT.UP: return OS.ABS_UPNORMAL;
+ case SWT.DOWN: return OS.ABS_DOWNNORMAL;
+ case SWT.LEFT: return OS.ABS_LEFTNORMAL;
+ case SWT.RIGHT: return OS.ABS_RIGHTNORMAL;
+ }
+
+ // Have some sane value if all else fails
+ return OS.ABS_LEFTNORMAL;
+}
+
@Override
-LRESULT wmDrawChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmDrawChild (long wParam, long lParam) {
if ((style & SWT.ARROW) == 0) return super.wmDrawChild (wParam, lParam);
DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ();
OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof);
RECT rect = new RECT ();
OS.SetRect (rect, struct.left, struct.top, struct.right, struct.bottom);
if (OS.IsAppThemed ()) {
- int iStateId = OS.ABS_LEFTNORMAL;
- switch (style & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT)) {
- case SWT.UP: iStateId = OS.ABS_UPNORMAL; break;
- case SWT.DOWN: iStateId = OS.ABS_DOWNNORMAL; break;
- case SWT.LEFT: iStateId = OS.ABS_LEFTNORMAL; break;
- case SWT.RIGHT: iStateId = OS.ABS_RIGHTNORMAL; break;
- }
- /*
- * Feature in Windows. DrawThemeBackground() does not mirror the drawing.
- * The fix is switch left to right and right to left.
- */
- if ((style & SWT.MIRRORED) != 0) {
- if ((style & (SWT.LEFT | SWT.RIGHT)) != 0) {
- iStateId = iStateId == OS.ABS_RIGHTNORMAL ? OS.ABS_LEFTNORMAL : OS.ABS_RIGHTNORMAL;
- }
- }
- /*
- * NOTE: The normal, hot, pressed and disabled state is
- * computed relying on the fact that the increment between
- * the direction states is invariant (always separated by 4).
- */
- if (!getEnabled ()) iStateId += OS.ABS_UPDISABLED - OS.ABS_UPNORMAL;
- if ((struct.itemState & OS.ODS_SELECTED) != 0) iStateId += OS.ABS_UPPRESSED - OS.ABS_UPNORMAL;
+ boolean pressed = ((struct.itemState & OS.ODS_SELECTED) != 0);
+ boolean enabled = getEnabled ();
+ int iStateId = getThemeStateId(style, pressed, enabled);
OS.DrawThemeBackground (display.hScrollBarTheme (), struct.hDC, OS.SBP_ARROWBTN, iStateId, rect, null);
} else {
int uState = OS.DFCS_SCROLLLEFT;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
index b88d7ad5ed..699ac814c1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
@@ -81,17 +81,6 @@ public Canvas (Composite parent, int style) {
super (parent, style);
}
-void clearArea (int x, int y, int width, int height) {
- checkWidget ();
- if (OS.IsWindowVisible (handle)) {
- RECT rect = new RECT ();
- OS.SetRect (rect, x, y, x + width, y + height);
- long /*int*/ hDC = OS.GetDCEx (handle, 0, OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS);
- drawBackground (hDC, rect);
- OS.ReleaseDC (handle, hDC);
- }
-}
-
/**
* Fills the interior of the rectangle specified by the arguments,
* with the receiver's background.
@@ -162,6 +151,11 @@ public IME getIME () {
}
@Override
+boolean isUseWsBorder () {
+ return super.isUseWsBorder () || ((display != null) && display.useWsBorderCanvas);
+}
+
+@Override
void releaseChildren (boolean destroy) {
if (caret != null) {
caret.release (false);
@@ -253,9 +247,7 @@ void scrollInPixels (int destX, int destY, int x, int y, int width, int height,
OS.ScrollWindowEx (handle, deltaX, deltaY, sourceRect, null, 0, null, flags);
}
if (all) {
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
+ for (Control child : _getChildren ()) {
Rectangle rect = child.getBoundsInPixels ();
if (Math.min (x + width, rect.x + rect.width) >= Math.max (x, rect.x) &&
Math.min (y + height, rect.y + rect.height) >= Math.max (y, rect.y)) {
@@ -335,7 +327,7 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long windowProc (long hwnd, int msg, long wParam, long lParam) {
if (msg == Display.SWT_RESTORECARET) {
if ((state & CANVAS) != 0) {
if (caret != null) {
@@ -349,11 +341,11 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
}
@Override
-LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CHAR (long wParam, long lParam) {
LRESULT result = super.WM_CHAR (wParam, lParam);
if (result != null) return result;
if (caret != null) {
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case SWT.DEL:
case SWT.BS:
case SWT.ESC:
@@ -372,7 +364,7 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_IME_COMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_IME_COMPOSITION (long wParam, long lParam) {
if (ime != null) {
LRESULT result = ime.WM_IME_COMPOSITION (wParam, lParam);
if (result != null) return result;
@@ -381,7 +373,7 @@ LRESULT WM_IME_COMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_IME_COMPOSITION_START (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_IME_COMPOSITION_START (long wParam, long lParam) {
if (ime != null) {
LRESULT result = ime.WM_IME_COMPOSITION_START (wParam, lParam);
if (result != null) return result;
@@ -390,7 +382,7 @@ LRESULT WM_IME_COMPOSITION_START (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_IME_ENDCOMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_IME_ENDCOMPOSITION (long wParam, long lParam) {
if (ime != null) {
LRESULT result = ime.WM_IME_ENDCOMPOSITION (wParam, lParam);
if (result != null) return result;
@@ -399,7 +391,7 @@ LRESULT WM_IME_ENDCOMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_INPUTLANGCHANGE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_INPUTLANGCHANGE (long wParam, long lParam) {
LRESULT result = super.WM_INPUTLANGCHANGE (wParam, lParam);
if (caret != null && caret.isFocusCaret ()) {
caret.setIMEFont ();
@@ -410,7 +402,7 @@ LRESULT WM_INPUTLANGCHANGE (long /*int*/ wParam, long /*int*/ lParam) {
@Override
-LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KEYDOWN (long wParam, long lParam) {
LRESULT result = super.WM_KEYDOWN (wParam, lParam);
if (result != null) return result;
if (ime != null) {
@@ -420,7 +412,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KILLFOCUS (long wParam, long lParam) {
if (ime != null) {
LRESULT result = ime.WM_KILLFOCUS (wParam, lParam);
if (result != null) return result;
@@ -432,7 +424,7 @@ LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDOWN (long wParam, long lParam) {
if (ime != null) {
LRESULT result = ime.WM_LBUTTONDOWN (wParam, lParam);
if (result != null) return result;
@@ -441,21 +433,21 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFOCUS (long wParam, long lParam) {
LRESULT result = super.WM_SETFOCUS (wParam, lParam);
if (caret != null && caret.isFocusCaret ()) caret.setFocus ();
return result;
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
LRESULT result = super.WM_SIZE (wParam, lParam);
if (caret != null && caret.isFocusCaret ()) caret.resizeIME ();
return result;
}
@Override
-LRESULT WM_WINDOWPOSCHANGED (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_WINDOWPOSCHANGED (long wParam, long lParam) {
LRESULT result = super.WM_WINDOWPOSCHANGED (wParam, lParam);
//if (result != null) return result;
/*
@@ -471,7 +463,7 @@ LRESULT WM_WINDOWPOSCHANGED (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_WINDOWPOSCHANGING (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_WINDOWPOSCHANGING (long wParam, long lParam) {
LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam);
if (result != null) return result;
/*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java
index 2e2be436dd..5b5342b940 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -38,6 +38,9 @@ import org.eclipse.swt.internal.win32.*;
* @noextend This class is not intended to be subclassed by clients.
*/
public class Caret extends Widget {
+ /** The Caret last updated on the OS-level */
+ private static Caret currentCaret;
+
Canvas parent;
int x, y, width, height;
boolean moved, resized;
@@ -87,10 +90,10 @@ void createWidget () {
}
}
-long /*int*/ defaultFont () {
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hwndIME = OS.ImmGetDefaultIMEWnd (hwnd);
- long /*int*/ hFont = 0;
+long defaultFont () {
+ long hwnd = parent.handle;
+ long hwndIME = OS.ImmGetDefaultIMEWnd (hwnd);
+ long hFont = 0;
if (hwndIME != 0) {
hFont = OS.SendMessage (hwndIME, OS.WM_GETFONT, 0, 0);
}
@@ -144,7 +147,7 @@ Rectangle getBoundsInPixels () {
public Font getFont () {
checkWidget();
if (font == null) {
- long /*int*/ hFont = defaultFont ();
+ long hFont = defaultFont ();
return Font.win32_new (display, hFont);
}
return font;
@@ -285,6 +288,7 @@ void killFocus () {
void move () {
moved = false;
+ setCurrentCaret(this);
if (!OS.SetCaretPos (x, y)) return;
resizeIME ();
}
@@ -293,8 +297,8 @@ void resizeIME () {
if (!OS.IsDBLocale) return;
POINT ptCurrentPos = new POINT ();
if (!OS.GetCaretPos (ptCurrentPos)) return;
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hIMC = OS.ImmGetContext (hwnd);
+ long hwnd = parent.handle;
+ long hIMC = OS.ImmGetContext (hwnd);
IME ime = parent.getIME ();
if (ime != null && ime.isInlineEnabled ()) {
Point size = getSizeInPixels ();
@@ -323,12 +327,18 @@ void resizeIME () {
@Override
void releaseParent () {
super.releaseParent ();
- if (this == parent.getCaret ()) parent.setCaret (null);
+ if (parent != null && this == parent.caret) {
+ if (!parent.isDisposed()) parent.setCaret (null);
+ else parent.caret = null;
+ }
}
@Override
void releaseWidget () {
super.releaseWidget ();
+ if (isCurrentCaret()) {
+ setCurrentCaret(null);
+ }
parent = null;
image = null;
font = null;
@@ -337,9 +347,9 @@ void releaseWidget () {
void resize () {
resized = false;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
OS.DestroyCaret ();
- long /*int*/ hBitmap = image != null ? image.handle : 0;
+ long hBitmap = image != null ? image.handle : 0;
int width = this.width;
if (image == null && width == 0) {
int [] buffer = new int [1];
@@ -356,8 +366,8 @@ void resize () {
void restoreIMEFont () {
if (!OS.IsDBLocale) return;
if (oldFont == null) return;
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hIMC = OS.ImmGetContext (hwnd);
+ long hwnd = parent.handle;
+ long hIMC = OS.ImmGetContext (hwnd);
OS.ImmSetCompositionFont (hIMC, oldFont);
OS.ImmReleaseContext (hwnd, hIMC);
oldFont = null;
@@ -387,7 +397,7 @@ public void setBounds (int x, int y, int width, int height) {
void setBoundsInPixels (int x, int y, int width, int height) {
boolean samePosition = this.x == x && this.y == y;
boolean sameExtent = this.width == width && this.height == height;
- if (samePosition && sameExtent) return;
+ if (samePosition && sameExtent && isCurrentCaret()) return;
this.x = x;
this.y = y;
this.width = width;
@@ -424,8 +434,8 @@ void setBoundsInPixels (Rectangle rect) {
}
void setFocus () {
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hBitmap = 0;
+ long hwnd = parent.handle;
+ long hBitmap = 0;
if (image != null) hBitmap = image.handle;
int width = this.width;
if (image == null && width == 0) {
@@ -490,11 +500,11 @@ public void setImage (Image image) {
void setIMEFont () {
if (!OS.IsDBLocale) return;
- long /*int*/ hFont = 0;
+ long hFont = 0;
if (font != null) hFont = font.handle;
if (hFont == 0) hFont = defaultFont ();
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hIMC = OS.ImmGetContext (hwnd);
+ long hwnd = parent.handle;
+ long hIMC = OS.ImmGetContext (hwnd);
/* Save the current IME font */
if (oldFont == null) {
oldFont = new LOGFONT ();
@@ -527,12 +537,20 @@ public void setLocation (int x, int y) {
}
void setLocationInPixels (int x, int y) {
- if (this.x == x && this.y == y) return;
+ if (this.x == x && this.y == y && isCurrentCaret()) return;
this.x = x; this.y = y;
moved = true;
if (isVisible && hasFocus ()) move ();
}
+private boolean isCurrentCaret() {
+ return Caret.currentCaret == this;
+}
+
+private void setCurrentCaret(Caret caret) {
+ Caret.currentCaret = caret;
+}
+
/**
* Sets the receiver's location to the point specified by
* the argument which is relative to the receiver's
@@ -569,7 +587,7 @@ public void setSize (int width, int height) {
}
void setSizeInPixels (int width, int height) {
- if (this.width == width && this.height == height) return;
+ if (this.width == width && this.height == height && isCurrentCaret()) return;
this.width = width; this.height = height;
resized = true;
if (isVisible && hasFocus ()) resize ();
@@ -615,7 +633,7 @@ public void setVisible (boolean visible) {
checkWidget();
if (visible == isVisible) return;
isVisible = visible;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
if (OS.GetFocus () != hwnd) return;
if (!isVisible) {
OS.HideCaret (hwnd);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java
index 6c951d4a9b..77f7422904 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java
@@ -14,10 +14,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class allow the user to select a color
@@ -38,8 +38,6 @@ import org.eclipse.swt.graphics.*;
*/
public class ColorDialog extends Dialog {
static final int CUSTOM_COLOR_COUNT = 16; // from the MS spec for CHOOSECOLOR.lpCustColors
- Display display;
- int width, height;
RGB rgb;
RGB [] rgbs;
int [] colors = new int [CUSTOM_COLOR_COUNT];
@@ -98,34 +96,15 @@ public ColorDialog (Shell parent, int style) {
checkSubclass ();
}
-long /*int*/ CCHookProc (long /*int*/ hdlg, long /*int*/ uiMsg, long /*int*/ lParam, long /*int*/ lpData) {
- switch ((int)/*64*/uiMsg) {
+long CCHookProc (long hdlg, long uiMsg, long lParam, long lpData) {
+ switch ((int)uiMsg) {
case OS.WM_INITDIALOG: {
- RECT rect = new RECT ();
- OS.GetWindowRect (hdlg, rect);
- width = rect.right - rect.left;
- height = rect.bottom - rect.top;
if (title != null && title.length () != 0) {
- /* Use the character encoding for the default locale */
TCHAR buffer = new TCHAR (0, title, true);
OS.SetWindowText (hdlg, buffer);
}
break;
}
- case OS.WM_DESTROY: {
- RECT rect = new RECT ();
- OS.GetWindowRect (hdlg, rect);
- int newWidth = rect.right - rect.left;
- int newHeight = rect.bottom - rect.top;
- if (newWidth < width || newHeight < height) {
- //display.fullOpen = false;
- } else {
- if (newWidth > width || newHeight > height) {
- //display.fullOpen = true;
- }
- }
- break;
- }
}
return 0;
}
@@ -170,8 +149,8 @@ public RGB[] getRGBs() {
public RGB open () {
/* Get the owner HWND for the dialog */
- long /*int*/ hwndOwner = parent.handle;
- long /*int*/ hwndParent = parent.handle;
+ long hwndOwner = parent.handle;
+ long hwndParent = parent.handle;
/*
* Feature in Windows. There is no API to set the orientation of a
@@ -201,13 +180,12 @@ public RGB open () {
/* Create the CCHookProc */
Callback callback = new Callback (this, "CCHookProc", 4); //$NON-NLS-1$
- long /*int*/ lpfnHook = callback.getAddress ();
- if (lpfnHook == 0) error(SWT.ERROR_NO_MORE_CALLBACKS);
+ long lpfnHook = callback.getAddress ();
/* Allocate the Custom Colors and initialize to white */
- display = parent.display;
+ Display display = parent.display;
if (display.lpCustColors == 0) {
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
display.lpCustColors = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, CUSTOM_COLOR_COUNT * 4);
for (int i=0; i < CUSTOM_COLOR_COUNT; i++) {
colors[i] = 0x00FFFFFF;
@@ -235,7 +213,6 @@ public RGB open () {
CHOOSECOLOR lpcc = new CHOOSECOLOR ();
lpcc.lStructSize = CHOOSECOLOR.sizeof;
lpcc.Flags = OS.CC_ANYCOLOR | OS.CC_ENABLEHOOK;
- //if (display.fullOpen) lpcc.Flags |= OS.CC_FULLOPEN;
lpcc.lpfnHook = lpfnHook;
lpcc.hwndOwner = hwndOwner;
lpcc.lpCustColors = display.lpCustColors;
@@ -254,9 +231,11 @@ public RGB open () {
display.setModalDialog (this);
}
+ display.externalEventLoop = true;
display.sendPreExternalEventDispatchEvent ();
/* Open the dialog */
boolean success = OS.ChooseColor (lpcc);
+ display.externalEventLoop = false;
display.sendPostExternalEventDispatchEvent ();
/* Clear the temporary dialog modal parent */
@@ -267,8 +246,8 @@ public RGB open () {
/* Get the Custom Colors (if the user defined any) from the dialog */
boolean customColor = false;
OS.MoveMemory (colors, display.lpCustColors, colors.length * 4);
- for (int i=0; i<colors.length; i++) {
- if (colors[i] != 0x00FFFFFF) {
+ for (int color : colors) {
+ if (color != 0x00FFFFFF) {
customColor = true;
break;
}
@@ -294,15 +273,6 @@ public RGB open () {
/* Free the CCHookProc */
callback.dispose ();
- /* Free the Custom Colors */
- /*
- * This code is intentionally commented. Currently,
- * there is exactly one set of custom colors per display.
- * The memory associated with these colors is released
- * when the display is disposed.
- */
-// if (lpCustColors != 0) OS.HeapFree (hHeap, 0, lpCustColors);
-
/* Destroy the BIDI orientation window */
if (hwndParent != hwndOwner) {
if (enabled) OS.EnableWindow (hwndParent, true);
@@ -310,15 +280,6 @@ public RGB open () {
OS.DestroyWindow (hwndOwner);
}
- /*
- * This code is intentionally commented. On some
- * platforms, the owner window is repainted right
- * away when a dialog window exits. This behavior
- * is currently unspecified.
- */
-// if (hwndOwner != 0) OS.UpdateWindow (hwndOwner);
-
- display = null;
if (!success) return null;
return rgb;
}
@@ -350,8 +311,8 @@ public void setRGB (RGB rgb) {
*/
public void setRGBs(RGB[] rgbs) {
if (rgbs != null) {
- for (int i=0; i<rgbs.length; i++) {
- if (rgbs [i] == null) error (SWT.ERROR_INVALID_ARGUMENT);
+ for (RGB rgb : rgbs) {
+ if (rgb == null) error (SWT.ERROR_INVALID_ARGUMENT);
}
}
this.rgbs = rgbs;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
index 66623517f1..4d5cb5c78d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -63,7 +63,7 @@ import org.eclipse.swt.internal.win32.*;
public class Combo extends Composite {
boolean noSelection, ignoreDefaultSelection, ignoreCharacter, ignoreModify, ignoreResize, lockText;
int scrollWidth, visibleCount;
- long /*int*/ cbtHook;
+ long cbtHook;
String [] items = new String [0];
int[] segments;
int clearSegmentsCount = 0;
@@ -96,9 +96,9 @@ public class Combo extends Composite {
*/
static final int CBID_LIST = 1000;
static final int CBID_EDIT = 1001;
- static /*final*/ long /*int*/ EditProc, ListProc;
+ static /*final*/ long EditProc, ListProc;
- static final long /*int*/ ComboProc;
+ static final long ComboProc;
static final TCHAR ComboClass = new TCHAR (0, "COMBOBOX", true);
static {
WNDCLASS lpWndClass = new WNDCLASS ();
@@ -142,8 +142,6 @@ public class Combo extends Composite {
*/
public Combo (Composite parent, int style) {
super (parent, checkStyle (style));
- /* This code is intentionally commented */
- //if ((style & SWT.H_SCROLL) != 0) this.style |= SWT.H_SCROLL;
this.style |= SWT.H_SCROLL;
}
@@ -169,7 +167,7 @@ public void add (String string) {
checkWidget ();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
TCHAR buffer = new TCHAR (getCodePage (), string, true);
- int result = (int)/*64*/OS.SendMessage (handle, OS.CB_ADDSTRING, 0, buffer);
+ int result = (int)OS.SendMessage (handle, OS.CB_ADDSTRING, 0, buffer);
if (result == OS.CB_ERR) error (SWT.ERROR_ITEM_NOT_ADDED);
if (result == OS.CB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);
if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer.chars, true);
@@ -204,12 +202,12 @@ public void add (String string) {
public void add (String string, int index) {
checkWidget ();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
if (!(0 <= index && index <= count)) {
error (SWT.ERROR_INVALID_RANGE);
}
TCHAR buffer = new TCHAR (getCodePage (), string, true);
- int result = (int)/*64*/OS.SendMessage (handle, OS.CB_INSERTSTRING, index, buffer);
+ int result = (int)OS.SendMessage (handle, OS.CB_INSERTSTRING, index, buffer);
if (result == OS.CB_ERRSPACE || result == OS.CB_ERR) {
error (SWT.ERROR_ITEM_NOT_ADDED);
}
@@ -282,7 +280,7 @@ public void addSegmentListener (SegmentListener listener) {
addListener (SWT.Segments, new TypedListener (listener));
int selection = OS.CB_ERR;
if (!noSelection) {
- selection = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ selection = (int)OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
}
clearSegments (true);
applyEditSegments ();
@@ -355,7 +353,7 @@ public void addVerifyListener (VerifyListener listener) {
void applyEditSegments () {
if (--clearSegmentsCount != 0) return;
if (!hooks (SWT.Segments) && !filters (SWT.Segments) && (state & HAS_AUTO_DIRECTION) == 0) return;
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
int length = OS.GetWindowTextLength (hwndText);
char [] buffer = new char [length + 1];
if (length > 0) OS.GetWindowText (hwndText, buffer, length + 1);
@@ -368,7 +366,7 @@ void applyEditSegments () {
int nSegments = segments.length;
if (nSegments == 0) return;
char [] segmentsChars = event.segmentsChars;
- int/*64*/ limit = (int/*64*/)OS.SendMessage (hwndText, OS.EM_GETLIMITTEXT, 0, 0) & 0x7fffffff;
+ int limit = (int)OS.SendMessage (hwndText, OS.EM_GETLIMITTEXT, 0, 0) & 0x7fffffff;
OS.SendMessage (hwndText, OS.EM_SETLIMITTEXT, limit + Math.min (nSegments, LIMIT - limit), 0);
length += nSegments;
char [] newChars = new char [length + 1];
@@ -400,7 +398,7 @@ void applyEditSegments () {
*/
newChars [length] = 0;
OS.SendMessage (hwndText, OS.EM_SETSEL, 0, -1);
- long /*int*/ undo = OS.SendMessage (hwndText, OS.EM_CANUNDO, 0, 0);
+ long undo = OS.SendMessage (hwndText, OS.EM_CANUNDO, 0, 0);
OS.SendMessage (hwndText, OS.EM_REPLACESEL, undo, newChars);
/* Restore selection */
start [0] = translateOffset (start [0]);
@@ -426,7 +424,7 @@ void applyEditSegments () {
}
void applyListSegments () {
- int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
if (count == OS.CB_ERR) return;
boolean add = items.length != count;
if (add) items = new String [count];
@@ -436,19 +434,19 @@ void applyListSegments () {
String string;
TCHAR buffer;
if (!noSelection) {
- selection = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ selection = (int)OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
}
while (index-- > 0) {
buffer = null;
- if (add) {
- int length = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0);
+ if (add) {
+ int length = (int)OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0);
if (length == OS.CB_ERR) error (SWT.ERROR);
buffer = new TCHAR (cp, length + 1);
if (OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer) == OS.CB_ERR) return;
items [index] = string = buffer.toString (0, length);
- } else {
- string = items [index];
- }
+ } else {
+ string = items [index];
+ }
if (OS.SendMessage (handle, OS.CB_DELETESTRING, index, 0) == OS.CB_ERR) return;
if (buffer == null) buffer = new TCHAR (cp, string, true);
if (OS.SendMessage (handle, OS.CB_INSERTSTRING, index, buffer) == OS.CB_ERR) return;
@@ -459,7 +457,7 @@ void applyListSegments () {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
if (hwnd == handle) {
switch (msg) {
@@ -467,7 +465,7 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
ignoreResize = true;
boolean oldLockText = lockText;
if ((style & SWT.READ_ONLY) == 0) lockText = true;
- long /*int*/ result = OS.CallWindowProc (ComboProc, hwnd, msg, wParam, lParam);
+ long result = OS.CallWindowProc (ComboProc, hwnd, msg, wParam, lParam);
if ((style & SWT.READ_ONLY) == 0) lockText = oldLockText;
ignoreResize = false;
return result;
@@ -475,31 +473,31 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
}
return OS.CallWindowProc (ComboProc, hwnd, msg, wParam, lParam);
}
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwnd == hwndText) {
if (lockText && msg == OS.WM_SETTEXT) {
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
int length = OS.GetWindowTextLength (handle);
char [] buffer = new char [length + 1];
OS.GetWindowText (handle, buffer, length + 1);
int byteCount = buffer.length * TCHAR.sizeof;
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (pszText, buffer, byteCount);
- long /*int*/ code = OS.CallWindowProc (EditProc, hwndText, msg, wParam, pszText);
+ long code = OS.CallWindowProc (EditProc, hwndText, msg, wParam, pszText);
OS.HeapFree (hHeap, 0, pszText);
return code;
}
return OS.CallWindowProc (EditProc, hwnd, msg, wParam, lParam);
}
- long /*int*/ hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ long hwndList = OS.GetDlgItem (handle, CBID_LIST);
if (hwnd == hwndList) {
return OS.CallWindowProc (ListProc, hwnd, msg, wParam, lParam);
}
return OS.DefWindowProc (hwnd, msg, wParam, lParam);
}
-long /*int*/ CBTProc (long /*int*/ nCode, long /*int*/ wParam, long /*int*/ lParam) {
- if ((int)/*64*/nCode == OS.HCBT_CREATEWND) {
+long CBTProc (long nCode, long wParam, long lParam) {
+ if ((int)nCode == OS.HCBT_CREATEWND) {
char [] buffer = new char [128];
int length = OS.GetClassName (wParam, buffer, buffer.length);
String className = new String (buffer, 0, length);
@@ -508,12 +506,7 @@ long /*int*/ CBTProc (long /*int*/ nCode, long /*int*/ wParam, long /*int*/ lPar
OS.SetWindowLong (wParam, OS.GWL_STYLE, bits & ~OS.ES_NOHIDESEL);
}
}
- return OS.CallNextHookEx (cbtHook, (int)/*64*/nCode, wParam, lParam);
-}
-
-@Override
-boolean checkHandle (long /*int*/ hwnd) {
- return hwnd == handle || hwnd == OS.GetDlgItem (handle, CBID_EDIT) || hwnd == OS.GetDlgItem (handle, CBID_LIST);
+ return OS.CallNextHookEx (cbtHook, (int)nCode, wParam, lParam);
}
@Override
@@ -554,9 +547,9 @@ void clearSegments (boolean applyText) {
if (segments == null) return;
int nSegments = segments.length;
if (nSegments == 0) return;
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
- int/*64*/ limit = (int/*64*/)OS.SendMessage (hwndText, OS.EM_GETLIMITTEXT, 0, 0) & 0x7fffffff;
- if (limit < LIMIT) {
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ int limit = (int)OS.SendMessage (hwndText, OS.EM_GETLIMITTEXT, 0, 0) & 0x7fffffff;
+ if (limit < LIMIT) {
OS.SendMessage (hwndText, OS.EM_SETLIMITTEXT, Math.max (1, limit - nSegments), 0);
}
if (!applyText) {
@@ -582,7 +575,7 @@ void clearSegments (boolean applyText) {
* menu. Sending OS.EM_REPLACESEL message instead.
*/
OS.SendMessage (hwndText, OS.EM_SETSEL, 0, -1);
- long /*int*/ undo = OS.SendMessage (hwndText, OS.EM_CANUNDO, 0, 0);
+ long undo = OS.SendMessage (hwndText, OS.EM_CANUNDO, 0, 0);
OS.SendMessage (hwndText, OS.EM_REPLACESEL, undo, buffer);
OS.SendMessage (hwndText, OS.EM_SETSEL, start [0], end [0]);
ignoreCharacter = oldIgnoreCharacter;
@@ -615,11 +608,11 @@ public void clearSelection () {
checkWidget ();
int width = 0, height = 0;
if (wHint == SWT.DEFAULT) {
- long /*int*/ newFont, oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
+ long newFont, oldFont = 0;
+ long hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
- int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
RECT rect = new RECT ();
int flags = OS.DT_CALCRECT | OS.DT_NOPREFIX;
if ((style & SWT.READ_ONLY) == 0) flags |= OS.DT_EDITCONTROL;
@@ -632,10 +625,10 @@ public void clearSelection () {
width = Math.max (width, scrollWidth);
} else {
for (int i=0; i<count; i++) {
- length = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, i, 0);
+ length = (int)OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, i, 0);
if (length != OS.CB_ERR) {
if (length + 1 > buffer.length) buffer = new char [length + 1];
- int result = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXT, i, buffer);
+ int result = (int)OS.SendMessage (handle, OS.CB_GETLBTEXT, i, buffer);
if (result != OS.CB_ERR) {
OS.DrawText (hDC, buffer, length, rect, flags);
width = Math.max (width, rect.right - rect.left);
@@ -648,8 +641,8 @@ public void clearSelection () {
}
if (hHint == SWT.DEFAULT) {
if ((style & SWT.SIMPLE) != 0) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
- int itemHeight = (int)/*64*/OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int itemHeight = (int)OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, 0, 0);
height = count * itemHeight;
}
}
@@ -660,9 +653,9 @@ public void clearSelection () {
if ((style & SWT.READ_ONLY) != 0) {
width += 8;
} else {
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwndText != 0) {
- long /*int*/ margins = OS.SendMessage (hwndText, OS.EM_GETMARGINS, 0, 0);
+ long margins = OS.SendMessage (hwndText, OS.EM_GETMARGINS, 0, 0);
int marginWidth = OS.LOWORD (margins) + OS.HIWORD (margins);
width += marginWidth + 3;
}
@@ -675,7 +668,7 @@ public void clearSelection () {
} else {
int border = OS.GetSystemMetrics (OS.SM_CXEDGE);
width += OS.GetSystemMetrics (OS.SM_CXVSCROLL) + border * 2;
- int textHeight = (int)/*64*/OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, -1, 0);
+ int textHeight = (int)OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, -1, 0);
if ((style & SWT.DROP_DOWN) != 0) {
height = textHeight + 6;
} else {
@@ -723,9 +716,7 @@ void createHandle () {
} else {
int threadId = OS.GetCurrentThreadId ();
Callback cbtCallback = new Callback (this, "CBTProc", 3); //$NON-NLS-1$
- long /*int*/ cbtProc = cbtCallback.getAddress ();
- if (cbtProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- cbtHook = OS.SetWindowsHookEx (OS.WH_CBT, cbtProc, 0, threadId);
+ cbtHook = OS.SetWindowsHookEx (OS.WH_CBT, cbtCallback.getAddress (), 0, threadId);
super.createHandle ();
if (cbtHook != 0) OS.UnhookWindowsHookEx (cbtHook);
cbtHook = 0;
@@ -733,14 +724,19 @@ void createHandle () {
}
state &= ~(CANVAS | THEME_BACKGROUND);
+ if (display.comboUseDarkTheme) {
+ OS.AllowDarkModeForWindow(handle, true);
+ OS.SetWindowTheme(handle, "CFD\0".toCharArray(), null);
+ }
+
stateFlagsUsable = stateFlagsTest();
/* Get the text and list window procs */
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwndText != 0 && EditProc == 0) {
EditProc = OS.GetWindowLongPtr (hwndText, OS.GWLP_WNDPROC);
}
- long /*int*/ hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ long hwndList = OS.GetDlgItem (handle, CBID_LIST);
if (hwndList != 0 && ListProc == 0) {
ListProc = OS.GetWindowLongPtr (hwndList, OS.GWLP_WNDPROC);
}
@@ -763,10 +759,10 @@ void createWidget() {
super.createWidget();
visibleCount = VISIBLE_COUNT;
if ((style & SWT.SIMPLE) == 0) {
- int itemHeight = (int)/*64*/OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, 0, 0);
+ int itemHeight = (int)OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, 0, 0);
if (itemHeight != OS.CB_ERR && itemHeight != 0) {
int maxHeight = 0;
- long /*int*/ hmonitor = OS.MonitorFromWindow (handle, OS.MONITOR_DEFAULTTONEAREST);
+ long hmonitor = OS.MonitorFromWindow (handle, OS.MONITOR_DEFAULTTONEAREST);
MONITORINFO lpmi = new MONITORINFO ();
lpmi.cbSize = MONITORINFO.sizeof;
OS.GetMonitorInfo (hmonitor, lpmi);
@@ -836,9 +832,9 @@ TCHAR deprocessText (TCHAR text, int start, int end, boolean terminate) {
@Override
void deregister () {
super.deregister ();
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwndText != 0) display.removeControl (hwndText);
- long /*int*/ hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ long hwndList = OS.GetDlgItem (handle, CBID_LIST);
if (hwndList != 0) display.removeControl (hwndList);
}
@@ -856,7 +852,7 @@ void deregister () {
*/
public void deselect (int index) {
checkWidget ();
- int selection = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ int selection = (int)OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
if (index != selection) return;
OS.SendMessage (handle, OS.CB_SETCURSEL, -1, 0);
sendEvent (SWT.Modify);
@@ -889,14 +885,14 @@ public void deselectAll () {
}
@Override
-boolean dragDetect (long /*int*/ hwnd, int x, int y, boolean filter, boolean [] detect, boolean [] consume) {
+boolean dragDetect (long hwnd, int x, int y, boolean filter, boolean [] detect, boolean [] consume) {
if (filter && (style & SWT.READ_ONLY) == 0) {
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwndText != 0) {
int [] start = new int [1], end = new int [1];
OS.SendMessage (handle, OS.CB_GETEDITSEL, start, end);
if (start [0] != end [0]) {
- long /*int*/ lParam = OS.MAKELPARAM (x, y);
+ long lParam = OS.MAKELPARAM (x, y);
int position = OS.LOWORD (OS.SendMessage (hwndText, OS.EM_CHARFROMPOS, 0, lParam));
if (start [0] <= position && position < end [0]) {
if (super.dragDetect (hwnd, x, y, filter, detect, consume)) {
@@ -942,8 +938,8 @@ Point getCaretLocationInPixels () {
* pixel coordinates (0,0).
*/
int position = translateOffset (getCaretPosition ());
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
- long /*int*/ caretPos = OS.SendMessage (hwndText, OS.EM_POSFROMCHAR, position, 0);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long caretPos = OS.SendMessage (hwndText, OS.EM_POSFROMCHAR, position, 0);
if (caretPos == -1) {
caretPos = 0;
if (position >= OS.GetWindowTextLength (hwndText)) {
@@ -996,7 +992,7 @@ Point getCaretLocationInPixels () {
public int getCaretPosition () {
checkWidget ();
int [] start = new int [1], end = new int [1];
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
OS.SendMessage (hwndText, OS.EM_GETSEL, start, end);
/*
* In Windows, there is no API to get the position of the caret
@@ -1017,9 +1013,9 @@ public int getCaretPosition () {
if (lpgui.hwndCaret == hwndText || lpgui.hwndCaret == 0) {
POINT ptCurrentPos = new POINT ();
if (OS.GetCaretPos (ptCurrentPos)) {
- long /*int*/ endPos = OS.SendMessage (hwndText, OS.EM_POSFROMCHAR, end [0], 0);
+ long endPos = OS.SendMessage (hwndText, OS.EM_POSFROMCHAR, end [0], 0);
if (endPos == -1) {
- long /*int*/ startPos = OS.SendMessage (hwndText, OS.EM_POSFROMCHAR, start [0], 0);
+ long startPos = OS.SendMessage (hwndText, OS.EM_POSFROMCHAR, start [0], 0);
int startX = OS.GET_X_LPARAM (startPos);
if (ptCurrentPos.x > startX) caret = end [0];
} else {
@@ -1051,14 +1047,14 @@ public int getCaretPosition () {
*/
public String getItem (int index) {
checkWidget ();
- int length = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0);
+ int length = (int)OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0);
if (length != OS.CB_ERR) {
if (hooks (SWT.Segments) || filters (SWT.Segments) || (state & HAS_AUTO_DIRECTION) != 0) return items [index];
char [] buffer = new char [length + 1];
- int result = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer);
+ int result = (int)OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer);
if (result != OS.CB_ERR) return new String (buffer, 0, length);
}
- int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
if (0 <= index && index < count) error (SWT.ERROR_CANNOT_GET_ITEM);
error (SWT.ERROR_INVALID_RANGE);
return "";
@@ -1076,7 +1072,7 @@ public String getItem (int index) {
*/
public int getItemCount () {
checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
if (count == OS.CB_ERR) error (SWT.ERROR_CANNOT_GET_COUNT);
return count;
}
@@ -1098,7 +1094,7 @@ public int getItemHeight () {
}
int getItemHeightInPixels () {
- int result = (int)/*64*/OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, 0, 0);
+ int result = (int)OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, 0, 0);
if (result == OS.CB_ERR) error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT);
return result;
}
@@ -1319,7 +1315,7 @@ public Point getSelection () {
public int getSelectionIndex () {
checkWidget ();
if (noSelection) return -1;
- return (int)/*64*/OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ return (int)OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
}
/**
@@ -1369,7 +1365,7 @@ int getTextHeightInPixels () {
if (((style & SWT.SIMPLE) == 0) && OS.GetComboBoxInfo (handle, pcbi)) {
return (pcbi.buttonBottom - pcbi.buttonTop) + pcbi.buttonTop * 2;
}
- int result = (int)/*64*/OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, -1, 0);
+ int result = (int)OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, -1, 0);
if (result == OS.CB_ERR) error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT);
return (style & SWT.DROP_DOWN) != 0 ? result + 6 : result + 10;
}
@@ -1391,9 +1387,9 @@ int getTextHeightInPixels () {
*/
public int getTextLimit () {
checkWidget ();
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwndText == 0) return LIMIT;
- int/*64*/ limit = (int)/*64*/OS.SendMessage (hwndText, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF;
+ int limit = (int)OS.SendMessage (hwndText, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF;
if (segments != null && limit < LIMIT) limit = Math.max (1, limit - segments.length);
return limit;
}
@@ -1422,12 +1418,12 @@ public int getVisibleItemCount () {
@Override
boolean hasFocus () {
- long /*int*/ hwndFocus = OS.GetFocus ();
+ long hwndFocus = OS.GetFocus ();
if (hwndFocus == handle) return true;
if (hwndFocus == 0) return false;
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwndFocus == hwndText) return true;
- long /*int*/ hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ long hwndList = OS.GetDlgItem (handle, CBID_LIST);
if (hwndFocus == hwndList) return true;
return false;
}
@@ -1491,12 +1487,12 @@ public int indexOf (String string, int start) {
}
/* Use CB_FINDSTRINGEXACT to search for the item */
- int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
if (!(0 <= start && start < count)) return -1;
int index = start - 1, last = 0;
TCHAR buffer = new TCHAR (getCodePage (), string, true);
do {
- index = (int)/*64*/OS.SendMessage (handle, OS.CB_FINDSTRINGEXACT, last = index, buffer);
+ index = (int)OS.SendMessage (handle, OS.CB_FINDSTRINGEXACT, last = index, buffer);
if (index == OS.CB_ERR || index <= last) return -1;
} while (!string.equals (getItem (index)));
return index;
@@ -1523,8 +1519,14 @@ public void paste () {
}
void stateFlagsAdd(int flags) {
- final long /*int*/ tagCBoxPtr = OS.GetWindowLongPtr(handle, 0);
- final long /*int*/ stateFlagsPtr = tagCBoxPtr + stateFlagsOffset;
+ final long tagCBoxPtr = OS.GetWindowLongPtr(handle, 0);
+ /*
+ * Bug 550423: When non-XP-theme COMMCTL32.DLL gets loaded, undocumented
+ * internal data is not there. We do not support that and in such case
+ * GetWindowLongPtr function fails and return zero.
+ */
+ if (tagCBoxPtr == 0) return;
+ final long stateFlagsPtr = tagCBoxPtr + stateFlagsOffset;
int stateFlags[] = new int[1];
OS.MoveMemory(stateFlags, stateFlagsPtr, 4);
@@ -1538,8 +1540,14 @@ void stateFlagsAdd(int flags) {
* For simplicity, only SWT.READ_ONLY combos are handled.
*/
boolean stateFlagsTest() {
- final long /*int*/ tagCBoxPtr = OS.GetWindowLongPtr(handle, 0);
- final long /*int*/ stateFlagsPtr = tagCBoxPtr + stateFlagsOffset;
+ final long tagCBoxPtr = OS.GetWindowLongPtr(handle, 0);
+ /*
+ * Bug 550423: When non-XP-theme COMMCTL32.DLL gets loaded, undocumented
+ * internal data is not there. We do not support that and in such case
+ * GetWindowLongPtr function fails and return zero.
+ */
+ if (tagCBoxPtr == 0) return false;
+ final long stateFlagsPtr = tagCBoxPtr + stateFlagsOffset;
int stateFlags[] = new int[1];
OS.MoveMemory(stateFlags, stateFlagsPtr, 4);
@@ -1556,9 +1564,9 @@ boolean stateFlagsTest() {
@Override
void register () {
super.register ();
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwndText != 0) display.addControl (hwndText, this);
- long /*int*/ hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ long hwndList = OS.GetDlgItem (handle, CBID_LIST);
if (hwndList != 0) display.addControl (hwndList, this);
}
@@ -1584,24 +1592,24 @@ public void remove (int index) {
void remove (int index, boolean notify) {
char [] buffer = null;
if ((style & SWT.H_SCROLL) != 0) {
- int length = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0);
+ int length = (int)OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0);
if (length == OS.CB_ERR) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
error (SWT.ERROR_INVALID_RANGE);
}
buffer = new char [length + 1];
- int result = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer);
+ int result = (int)OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer);
if (result == OS.CB_ERR) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
error (SWT.ERROR_INVALID_RANGE);
}
}
int length = OS.GetWindowTextLength (handle);
- int code = (int)/*64*/OS.SendMessage (handle, OS.CB_DELETESTRING, index, 0);
+ int code = (int)OS.SendMessage (handle, OS.CB_DELETESTRING, index, 0);
if (code == OS.CB_ERR) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
error (SWT.ERROR_INVALID_RANGE);
}
@@ -1639,13 +1647,13 @@ void remove (int index, boolean notify) {
public void remove (int start, int end) {
checkWidget ();
if (start > end) return;
- int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
if (!(0 <= start && start <= end && end < count)) {
error (SWT.ERROR_INVALID_RANGE);
}
int textLength = OS.GetWindowTextLength (handle);
RECT rect = null;
- long /*int*/ hDC = 0, oldFont = 0, newFont = 0;
+ long hDC = 0, oldFont = 0, newFont = 0;
int newWidth = 0;
if ((style & SWT.H_SCROLL) != 0) {
rect = new RECT ();
@@ -1657,13 +1665,13 @@ public void remove (int start, int end) {
for (int i=start; i<=end; i++) {
char [] buffer = null;
if ((style & SWT.H_SCROLL) != 0) {
- int length = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, start, 0);
+ int length = (int)OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, start, 0);
if (length == OS.CB_ERR) break;
buffer = new char [length + 1];
- int result = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXT, start, buffer);
+ int result = (int)OS.SendMessage (handle, OS.CB_GETLBTEXT, start, buffer);
if (result == OS.CB_ERR) break;
}
- int result = (int)/*64*/OS.SendMessage (handle, OS.CB_DELETESTRING, start, 0);
+ int result = (int)OS.SendMessage (handle, OS.CB_DELETESTRING, start, 0);
if (result == OS.CB_ERR) {
error (SWT.ERROR_ITEM_NOT_REMOVED);
}
@@ -1781,7 +1789,7 @@ public void removeSegmentListener (SegmentListener listener) {
eventTable.unhook (SWT.Segments, listener);
int selection = OS.CB_ERR;
if (!noSelection) {
- selection = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ selection = (int)OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
}
clearSegments (true);
applyEditSegments ();
@@ -1842,7 +1850,7 @@ public void removeVerifyListener (VerifyListener listener) {
}
@Override
-boolean sendKeyEvent (int type, int msg, long /*int*/ wParam, long /*int*/ lParam, Event event) {
+boolean sendKeyEvent (int type, int msg, long wParam, long lParam, Event event) {
if (!super.sendKeyEvent (type, msg, wParam, lParam, event)) {
return false;
}
@@ -1883,7 +1891,7 @@ boolean sendKeyEvent (int type, int msg, long /*int*/ wParam, long /*int*/ lPara
/* Verify the character */
String oldText = "";
int [] start = new int [1], end = new int [1];
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwndText == 0) return true;
OS.SendMessage (hwndText, OS.EM_GETSEL, start, end);
switch (key) {
@@ -1932,16 +1940,16 @@ boolean sendKeyEvent (int type, int msg, long /*int*/ wParam, long /*int*/ lPara
*/
public void select (int index) {
checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
if (0 <= index && index < count) {
- int selection = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ int selection = (int)OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
//corner case for single elements combo boxes for Bug 222752
if (OS.WIN32_VERSION < OS.VERSION (6, 2) && getListVisible() && (style & SWT.READ_ONLY) != 0 && count==1 && selection == OS.CB_ERR) {
OS.SendMessage (handle, OS.WM_KEYDOWN, OS.VK_DOWN, 0);
sendEvent (SWT.Modify);
return;
}
- int code = (int)/*64*/OS.SendMessage (handle, OS.CB_SETCURSEL, index, 0);
+ int code = (int)OS.SendMessage (handle, OS.CB_SETCURSEL, index, 0);
if (code != OS.CB_ERR && code != selection) {
//Workaround for Bug 222752
if (OS.WIN32_VERSION < OS.VERSION (6, 2) && getListVisible() && (style & SWT.READ_ONLY) != 0) {
@@ -1961,20 +1969,20 @@ public void select (int index) {
}
@Override
-void setBackgroundImage (long /*int*/ hBitmap) {
+void setBackgroundImage (long hBitmap) {
super.setBackgroundImage (hBitmap);
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwndText != 0) OS.InvalidateRect (hwndText, null, true);
- long /*int*/ hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ long hwndList = OS.GetDlgItem (handle, CBID_LIST);
if (hwndList != 0) OS.InvalidateRect (hwndList, null, true);
}
@Override
void setBackgroundPixel (int pixel) {
super.setBackgroundPixel (pixel);
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwndText != 0) OS.InvalidateRect (hwndText, null, true);
- long /*int*/ hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ long hwndList = OS.GetDlgItem (handle, CBID_LIST);
if (hwndList != 0) OS.InvalidateRect (hwndList, null, true);
}
@@ -2050,9 +2058,9 @@ public void setFont (Font font) {
@Override
void setForegroundPixel (int pixel) {
super.setForegroundPixel (pixel);
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwndText != 0) OS.InvalidateRect (hwndText, null, true);
- long /*int*/ hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ long hwndList = OS.GetDlgItem (handle, CBID_LIST);
if (hwndList != 0) OS.InvalidateRect (hwndList, null, true);
}
@@ -2099,11 +2107,11 @@ public void setItem (int index, String string) {
public void setItems (String... items) {
checkWidget ();
if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<items.length; i++) {
- if (items [i] == null) error (SWT.ERROR_INVALID_ARGUMENT);
+ for (String item : items) {
+ if (item == null) error (SWT.ERROR_INVALID_ARGUMENT);
}
RECT rect = null;
- long /*int*/ hDC = 0, oldFont = 0, newFont = 0;
+ long hDC = 0, oldFont = 0, newFont = 0;
int newWidth = 0;
if ((style & SWT.H_SCROLL) != 0) {
rect = new RECT ();
@@ -2114,10 +2122,9 @@ public void setItems (String... items) {
}
OS.SendMessage (handle, OS.CB_RESETCONTENT, 0, 0);
int codePage = getCodePage ();
- for (int i=0; i<items.length; i++) {
- String string = items [i];
- TCHAR buffer = new TCHAR (codePage, string, true);
- int code = (int)/*64*/OS.SendMessage (handle, OS.CB_ADDSTRING, 0, buffer);
+ for (String item : items) {
+ TCHAR buffer = new TCHAR (codePage, item, true);
+ int code = (int)OS.SendMessage (handle, OS.CB_ADDSTRING, 0, buffer);
if (code == OS.CB_ERR) error (SWT.ERROR_ITEM_NOT_ADDED);
if (code == OS.CB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);
if ((style & SWT.H_SCROLL) != 0) {
@@ -2157,17 +2164,17 @@ public void setOrientation (int orientation) {
void setScrollWidth () {
int newWidth = 0;
RECT rect = new RECT ();
- long /*int*/ newFont, oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
+ long newFont, oldFont = 0;
+ long hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
- int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
for (int i=0; i<count; i++) {
- int length = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, i, 0);
+ int length = (int)OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, i, 0);
if (length != OS.CB_ERR) {
char [] buffer = new char [length + 1];
- int result = (int)/*64*/OS.SendMessage (handle, OS.CB_GETLBTEXT, i, buffer);
+ int result = (int)OS.SendMessage (handle, OS.CB_GETLBTEXT, i, buffer);
if (result != OS.CB_ERR) {
OS.DrawText (hDC, buffer, -1, rect, flags);
newWidth = Math.max (newWidth, rect.right - rect.left);
@@ -2186,9 +2193,9 @@ void setScrollWidth (int scrollWidth) {
return;
}
boolean scroll = false;
- int count = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
if (count > 3) {
- long /*int*/ hmonitor = OS.MonitorFromWindow (handle, OS.MONITOR_DEFAULTTONEAREST);
+ long hmonitor = OS.MonitorFromWindow (handle, OS.MONITOR_DEFAULTTONEAREST);
MONITORINFO lpmi = new MONITORINFO ();
lpmi.cbSize = MONITORINFO.sizeof;
OS.GetMonitorInfo (hmonitor, lpmi);
@@ -2219,8 +2226,8 @@ void setScrollWidth (int scrollWidth) {
void setScrollWidth (char[] buffer, boolean grow) {
RECT rect = new RECT ();
- long /*int*/ newFont, oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
+ long newFont, oldFont = 0;
+ long hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
@@ -2260,7 +2267,7 @@ public void setSelection (Point selection) {
checkWidget ();
if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
int start = translateOffset (selection.x), end = translateOffset (selection.y);
- long /*int*/ bits = OS.MAKELPARAM (start, end);
+ long bits = OS.MAKELPARAM (start, end);
OS.SendMessage (handle, OS.CB_SETEDITSEL, 0, bits);
}
@@ -2302,9 +2309,9 @@ public void setText (String string) {
}
clearSegments (false);
int limit = LIMIT;
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwndText != 0) {
- limit = (int)/*64*/OS.SendMessage (hwndText, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF;
+ limit = (int)OS.SendMessage (hwndText, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF;
}
if (string.length () > limit) string = string.substring (0, limit);
TCHAR buffer = new TCHAR (getCodePage (), string, true);
@@ -2347,8 +2354,8 @@ public void setTextLimit (int limit) {
@Override
void setToolTipText (Shell shell, String string) {
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
- long /*int*/ hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndList = OS.GetDlgItem (handle, CBID_LIST);
if (hwndText != 0) shell.setToolTipText (hwndText, string);
if (hwndList != 0) shell.setToolTipText (hwndList, string);
shell.setToolTipText (handle, string);
@@ -2381,12 +2388,12 @@ public void setVisibleItemCount (int count) {
@Override
void subclass () {
super.subclass ();
- long /*int*/ newProc = display.windowProc;
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long newProc = display.windowProc;
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwndText != 0) {
OS.SetWindowLongPtr (hwndText, OS.GWLP_WNDPROC, newProc);
}
- long /*int*/ hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ long hwndList = OS.GetDlgItem (handle, CBID_LIST);
if (hwndList != 0) {
OS.SetWindowLongPtr (hwndList, OS.GWLP_WNDPROC, newProc);
}
@@ -2407,7 +2414,7 @@ boolean translateTraversal (MSG msg) {
* to select an item in the list and escape to close
* the combo box.
*/
- switch ((int)/*64*/(msg.wParam)) {
+ switch ((int)(msg.wParam)) {
case OS.VK_RETURN:
case OS.VK_ESCAPE:
if ((style & SWT.DROP_DOWN) != 0) {
@@ -2444,11 +2451,11 @@ boolean traverseReturn () {
@Override
void unsubclass () {
super.unsubclass ();
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
if (hwndText != 0 && EditProc != 0) {
OS.SetWindowLongPtr (hwndText, OS.GWLP_WNDPROC, EditProc);
}
- long /*int*/ hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ long hwndList = OS.GetDlgItem (handle, CBID_LIST);
if (hwndList != 0 && ListProc != 0) {
OS.SetWindowLongPtr (hwndList, OS.GWLP_WNDPROC, ListProc);
}
@@ -2483,6 +2490,18 @@ void updateDropDownHeight () {
}
}
+void updateDropDownTheme () {
+ COMBOBOXINFO pcbi = new COMBOBOXINFO ();
+ pcbi.cbSize = COMBOBOXINFO.sizeof;
+ if (!OS.GetComboBoxInfo(handle, pcbi))
+ return;
+
+ if (pcbi.hwndList == 0)
+ return;
+
+ maybeEnableDarkSystemTheme(pcbi.hwndList);
+}
+
@Override
boolean updateTextDirection(int textDirection) {
if (super.updateTextDirection(textDirection)) {
@@ -2504,7 +2523,7 @@ void updateOrientation () {
}
bits &= ~OS.WS_EX_RTLREADING;
OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits);
- long /*int*/ hwndText = 0, hwndList = 0;
+ long hwndText = 0, hwndList = 0;
COMBOBOXINFO pcbi = new COMBOBOXINFO ();
pcbi.cbSize = COMBOBOXINFO.sizeof;
if (OS.GetComboBoxInfo (handle, pcbi)) {
@@ -2595,16 +2614,16 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return ComboProc;
}
@Override
-long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long windowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
if (hwnd != handle) {
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
- long /*int*/ hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndList = OS.GetDlgItem (handle, CBID_LIST);
if ((hwndText != 0 && hwnd == hwndText) || (hwndList != 0 && hwnd == hwndList)) {
LRESULT result = null;
boolean processSegments = false, redraw = false;
@@ -2675,11 +2694,18 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
OS.DefWindowProc (hwndText, OS.WM_SETREDRAW, 0, 0);
}
clearSegments (true);
- long /*int*/ code = callWindowProc (hwnd, msg, wParam, lParam);
+ long code = callWindowProc (hwnd, msg, wParam, lParam);
applyEditSegments ();
if (redraw) {
OS.DefWindowProc (hwndText, OS.WM_SETREDRAW, 1, 0);
OS.InvalidateRect (hwndText, null, true);
+ /*
+ * When setting longer text on AUTO_TEXT_DIRECTION styled Combo orientation:
+ * Combo should automatically scrolls selection's end into view. We need to
+ * force it to do such scrolling, to make sure Caret no longer goes out of view.
+ * For more details refer bug 575171.
+ */
+ forceScrollingToCaret();
}
return code;
}
@@ -2688,8 +2714,8 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
}
switch (msg) {
case OS.CB_SETCURSEL: {
- long /*int*/ code = OS.CB_ERR;
- int index = (int)/*64*/ wParam;
+ long code = OS.CB_ERR;
+ int index = (int) wParam;
if ((style & SWT.READ_ONLY) != 0) {
if (hooks (SWT.Verify) || filters (SWT.Verify)) {
String oldText = getText (), newText = null;
@@ -2697,7 +2723,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
newText = "";
} else {
if (0 <= wParam && wParam < getItemCount ()) {
- newText = getItem ((int)/*64*/wParam);
+ newText = getItem ((int)wParam);
}
}
if (newText != null && !newText.equals (oldText)) {
@@ -2719,7 +2745,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
if (!(code == OS.CB_ERR || code == OS.CB_ERRSPACE)) {
Event event = getSegments (items [index]);
segments = event != null ? event.segments : null;
- if (event.segmentsChars != null) {
+ if (event != null && event.segmentsChars != null) {
int auto = state & HAS_AUTO_DIRECTION;
if (event.segmentsChars[0] == RLE) {
super.updateTextDirection(SWT.RIGHT_TO_LEFT);
@@ -2737,7 +2763,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
case OS.CB_INSERTSTRING:
case OS.CB_FINDSTRINGEXACT:
if (lParam != 0 && (hooks (SWT.Segments) || filters (SWT.Segments) || ((state & HAS_AUTO_DIRECTION) != 0))) {
- long /*int*/ code = OS.CB_ERR;
+ long code = OS.CB_ERR;
int length = OS.wcslen (lParam);
TCHAR buffer = new TCHAR (getCodePage (), length);
OS.MoveMemory (buffer, lParam, buffer.length () * TCHAR.sizeof);
@@ -2745,15 +2771,15 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
Event event = getSegments (string);
if (event != null && event.segments != null) {
buffer = new TCHAR (getCodePage (), getSegmentsText (string, event), true);
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
length = buffer.length() * TCHAR.sizeof;
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, length);
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, length);
OS.MoveMemory (pszText, buffer, length);
code = super.windowProc (hwnd, msg, wParam, pszText);
OS.HeapFree (hHeap, 0, pszText);
}
if (msg == OS.CB_ADDSTRING || msg == OS.CB_INSERTSTRING) {
- int index = msg == OS.CB_ADDSTRING ? items.length : (int)/*64*/ wParam;
+ int index = msg == OS.CB_ADDSTRING ? items.length : (int) wParam;
String [] newItems = new String [items.length + 1];
System.arraycopy (items, 0, newItems, 0, index);
newItems [index] = string;
@@ -2765,9 +2791,9 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
break;
case OS.CB_DELETESTRING: {
if (hooks (SWT.Segments) || filters (SWT.Segments) || ((state & HAS_AUTO_DIRECTION) != 0)) {
- long /*int*/ code = super.windowProc (hwnd, msg, wParam, lParam);
+ long code = super.windowProc (hwnd, msg, wParam, lParam);
if (code != OS.CB_ERR && code != OS.CB_ERRSPACE) {
- int index = (int)/*64*/ wParam;
+ int index = (int) wParam;
if (items.length == 1) {
items = new String[0];
} else if (items.length > 1) {
@@ -2777,7 +2803,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
items = newItems;
}
if (!noSelection) {
- index = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ index = (int)OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
if (index == wParam) {
clearSegments (false);
applyEditSegments ();
@@ -2801,7 +2827,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
}
@Override
-LRESULT wmColorChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmColorChild (long wParam, long lParam) {
LRESULT result = super.wmColorChild(wParam, lParam);
/*
@@ -2831,30 +2857,18 @@ LRESULT wmColorChild (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_CTLCOLOR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CTLCOLOR (long wParam, long lParam) {
return wmColorChild (wParam, lParam);
}
@Override
-LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
- long /*int*/ code = callWindowProc (handle, OS.WM_GETDLGCODE, wParam, lParam);
+LRESULT WM_GETDLGCODE (long wParam, long lParam) {
+ long code = callWindowProc (handle, OS.WM_GETDLGCODE, wParam, lParam);
return new LRESULT (code | OS.DLGC_WANTARROWS);
}
@Override
-LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
- /*
- * Bug in Windows. When a combo box that is read only
- * is disposed in CBN_KILLFOCUS, Windows segment faults.
- * The fix is to send focus from WM_KILLFOCUS instead
- * of CBN_KILLFOCUS.
- *
- * NOTE: In version 6 of COMCTL32.DLL, the bug is fixed.
- */
- if ((style & SWT.READ_ONLY) != 0) {
- return super.WM_KILLFOCUS (wParam, lParam);
- }
-
+LRESULT WM_KILLFOCUS (long wParam, long lParam) {
/*
* Return NULL - Focus notification is
* done in WM_COMMAND by CBN_KILLFOCUS.
@@ -2863,7 +2877,7 @@ LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDOWN (long wParam, long lParam) {
/*
* Feature in Windows. When an editable combo box is dropped
* down and the text in the entry field partially matches an
@@ -2871,11 +2885,11 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
* WM_COMMAND with CBN_SELCHANGE. The fix is to detect that
* the selection has changed and issue the notification.
*/
- int oldSelection = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ int oldSelection = (int)OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
LRESULT result = super.WM_LBUTTONDOWN (wParam, lParam);
if (result == LRESULT.ZERO) return result;
if ((style & SWT.READ_ONLY) == 0) {
- int newSelection = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ int newSelection = (int)OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
if (oldSelection != newSelection) {
sendEvent (SWT.Modify);
if (isDisposed ()) return LRESULT.ZERO;
@@ -2887,7 +2901,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFOCUS (long wParam, long lParam) {
/*
* Return NULL - Focus notification is
* done by WM_COMMAND with CBN_SETFOCUS.
@@ -2896,7 +2910,7 @@ LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
/*
* Feature in Windows. When a combo box is resized,
* the size of the drop down rectangle is specified
@@ -2955,6 +2969,12 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
* This is just another form of problem 1.
* 3) Caret no longer goes out of view when shrinking control.
*/
+ forceScrollingToCaret();
+
+ return result;
+}
+
+void forceScrollingToCaret() {
if ((style & SWT.READ_ONLY) == 0) {
Point oldSelection = this.getSelection();
Point tmpSelection = new Point(0, 0);
@@ -2963,12 +2983,10 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
this.setSelection(oldSelection);
}
}
-
- return result;
}
@Override
-LRESULT WM_UPDATEUISTATE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_UPDATEUISTATE (long wParam, long lParam) {
LRESULT result = super.WM_UPDATEUISTATE (wParam, lParam);
if (result != null) return result;
OS.InvalidateRect (handle, null, true);
@@ -2976,7 +2994,7 @@ LRESULT WM_UPDATEUISTATE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_WINDOWPOSCHANGING (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_WINDOWPOSCHANGING (long wParam, long lParam) {
LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam);
if (result != null) return result;
/*
@@ -3004,15 +3022,15 @@ LRESULT WM_WINDOWPOSCHANGING (long /*int*/ wParam, long /*int*/ lParam) {
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
if (width != 0 && height != 0) {
- long /*int*/ hwndParent = parent.handle;
- long /*int*/ hwndChild = OS.GetWindow (hwndParent, OS.GW_CHILD);
+ long hwndParent = parent.handle;
+ long hwndChild = OS.GetWindow (hwndParent, OS.GW_CHILD);
OS.MapWindowPoints (0, hwndParent, rect, 2);
- long /*int*/ rgn1 = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom);
+ long rgn1 = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom);
while (hwndChild != 0) {
if (hwndChild != handle) {
OS.GetWindowRect (hwndChild, rect);
OS.MapWindowPoints (0, hwndParent, rect, 2);
- long /*int*/ rgn2 = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom);
+ long rgn2 = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom);
OS.CombineRgn (rgn1, rgn1, rgn2, OS.RGN_DIFF);
OS.DeleteObject (rgn2);
}
@@ -3028,11 +3046,11 @@ LRESULT WM_WINDOWPOSCHANGING (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmChar (long hwnd, long wParam, long lParam) {
if (ignoreCharacter) return null;
LRESULT result = super.wmChar (hwnd, wParam, lParam);
if (result != null) return result;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
/*
* Feature in Windows. For some reason, when the
* widget is a single line text widget, when the
@@ -3074,7 +3092,7 @@ LRESULT wmChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
if (OS.GetKeyState (OS.VK_CONTROL) < 0) {
if ((style & SWT.READ_ONLY) != 0) return LRESULT.ZERO;
Point selection = getSelection ();
- long /*int*/ hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ long hwndText = OS.GetDlgItem (handle, CBID_EDIT);
int x = selection.x;
int y = selection.y;
if (x == y) {
@@ -3099,7 +3117,7 @@ LRESULT wmChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
return result;
}
-LRESULT wmClipboard (long /*int*/ hwndText, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmClipboard (long hwndText, int msg, long wParam, long lParam) {
if ((style & SWT.READ_ONLY) != 0) return null;
if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return null;
boolean call = false;
@@ -3158,11 +3176,11 @@ LRESULT wmClipboard (long /*int*/ hwndText, int msg, long /*int*/ wParam, long /
}
TCHAR buffer = new TCHAR (getCodePage (), newText, true);
if (msg == OS.WM_SETTEXT) {
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
int byteCount = buffer.length () * TCHAR.sizeof;
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (pszText, buffer, byteCount);
- long /*int*/ code = OS.CallWindowProc (EditProc, hwndText, msg, wParam, pszText);
+ long code = OS.CallWindowProc (EditProc, hwndText, msg, wParam, pszText);
OS.HeapFree (hHeap, 0, pszText);
return new LRESULT (code);
} else {
@@ -3175,7 +3193,7 @@ LRESULT wmClipboard (long /*int*/ hwndText, int msg, long /*int*/ wParam, long /
}
@Override
-LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmCommandChild (long wParam, long lParam) {
int code = OS.HIWORD (wParam);
switch (code) {
case OS.CBN_EDITCHANGE:
@@ -3204,7 +3222,7 @@ LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
* match the list selection. The fix is to force the text field
* to match the list selection by re-selecting the list item.
*/
- int index = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ int index = (int)OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
if (index != OS.CB_ERR) {
OS.SendMessage (handle, OS.CB_SETCURSEL, index, 0);
}
@@ -3226,17 +3244,9 @@ LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
case OS.CBN_DROPDOWN:
setCursor ();
updateDropDownHeight ();
+ updateDropDownTheme ();
break;
case OS.CBN_KILLFOCUS:
- /*
- * Bug in Windows. When a combo box that is read only
- * is disposed in CBN_KILLFOCUS, Windows segment faults.
- * The fix is to send focus from WM_KILLFOCUS instead
- * of CBN_KILLFOCUS.
- *
- * NOTE: In version 6 of COMCTL32.DLL, the bug is fixed.
- */
- if ((style & SWT.READ_ONLY) != 0) break;
sendFocusEvent (SWT.FocusOut);
if (isDisposed ()) return LRESULT.ZERO;
break;
@@ -3246,7 +3256,7 @@ LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
event.doit = true;
sendEvent (SWT.OrientationChange, event);
if (!event.doit) {
- long /*int*/ hwnd = lParam;
+ long hwnd = lParam;
int bits1 = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE);
int bits2 = OS.GetWindowLong (hwnd, OS.GWL_STYLE);
if (code == OS.EN_ALIGN_LTR_EC) {
@@ -3274,12 +3284,12 @@ LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmIMEChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmIMEChar (long hwnd, long wParam, long lParam) {
/* Process a DBCS character */
Display display = this.display;
display.lastKey = 0;
- display.lastAscii = (int)/*64*/wParam;
+ display.lastAscii = (int)wParam;
display.lastVirtual = display.lastNull = display.lastDead = false;
if (!sendKeyEvent (SWT.KeyDown, OS.WM_IME_CHAR, wParam, lParam)) {
return LRESULT.ZERO;
@@ -3293,7 +3303,7 @@ LRESULT wmIMEChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
* them to the application.
*/
ignoreCharacter = true;
- long /*int*/ result = callWindowProc (hwnd, OS.WM_IME_CHAR, wParam, lParam);
+ long result = callWindowProc (hwnd, OS.WM_IME_CHAR, wParam, lParam);
MSG msg = new MSG ();
int flags = OS.PM_REMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE;
while (OS.PeekMessage (msg, hwnd, OS.WM_CHAR, OS.WM_CHAR, flags)) {
@@ -3309,18 +3319,18 @@ LRESULT wmIMEChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
}
@Override
-LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmKeyDown (long hwnd, long wParam, long lParam) {
if (ignoreCharacter) return null;
LRESULT result = super.wmKeyDown (hwnd, wParam, lParam);
if (result != null) return result;
ignoreDefaultSelection = false;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_LEFT:
case OS.VK_UP:
case OS.VK_RIGHT:
case OS.VK_DOWN:
if (segments != null) {
- long /*int*/ code = 0;
+ long code = 0;
int [] start = new int [1], end = new int [1], newStart = new int [1], newEnd = new int [1];
OS.SendMessage (handle, OS.CB_GETEDITSEL, start, end);
while (true) {
@@ -3351,7 +3361,7 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
}
@Override
-LRESULT wmSysKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmSysKeyDown (long hwnd, long wParam, long lParam) {
/*
* Feature in Windows. When an editable combo box is dropped
* down using Alt+Down and the text in the entry field partially
@@ -3359,13 +3369,13 @@ LRESULT wmSysKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lPara
* send WM_COMMAND with CBN_SELCHANGE. The fix is to detect that
* the selection has changed and issue the notification.
*/
- int oldSelection = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ int oldSelection = (int)OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
LRESULT result = super.wmSysKeyDown (hwnd, wParam, lParam);
if (result != null) return result;
if ((style & SWT.READ_ONLY) == 0) {
if (wParam == OS.VK_DOWN) {
- long /*int*/ code = callWindowProc (hwnd, OS.WM_SYSKEYDOWN, wParam, lParam);
- int newSelection = (int)/*64*/OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ long code = callWindowProc (hwnd, OS.WM_SYSKEYDOWN, wParam, lParam);
+ int newSelection = (int)OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
if (oldSelection != newSelection) {
sendEvent (SWT.Modify);
if (isDisposed ()) return LRESULT.ZERO;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
index f5751e7861..63dab140ae 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -101,7 +101,7 @@ public Composite (Composite parent, int style) {
Control [] _getChildren () {
int count = 0;
- long /*int*/ hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
+ long hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
if (hwndChild == 0) return new Control [0];
while (hwndChild != 0) {
count++;
@@ -126,15 +126,15 @@ Control [] _getChildren () {
Control [] _getTabList () {
if (tabList == null) return tabList;
int count = 0;
- for (int i=0; i<tabList.length; i++) {
- if (!tabList [i].isDisposed ()) count++;
+ for (Control element : tabList) {
+ if (!element.isDisposed ()) count++;
}
if (count == tabList.length) return tabList;
Control [] newList = new Control [count];
int index = 0;
- for (int i=0; i<tabList.length; i++) {
- if (!tabList [i].isDisposed ()) {
- newList [index++] = tabList [i];
+ for (Control element : tabList) {
+ if (!element.isDisposed ()) {
+ newList [index++] = element;
}
}
tabList = newList;
@@ -176,7 +176,7 @@ void checkBuffered () {
void checkComposited () {
if ((state & CANVAS) != 0) {
if ((style & SWT.TRANSPARENT) != 0) {
- long /*int*/ hwndParent = parent.handle;
+ long hwndParent = parent.handle;
int bits = OS.GetWindowLong (hwndParent, OS.GWL_EXSTYLE);
bits |= OS.WS_EX_COMPOSITED;
OS.SetWindowLong (hwndParent, OS.GWL_EXSTYLE, bits);
@@ -194,8 +194,7 @@ Widget [] computeTabList () {
Widget result [] = super.computeTabList ();
if (result.length == 0) return result;
Control [] list = tabList != null ? _getTabList () : _getChildren ();
- for (int i=0; i<list.length; i++) {
- Control child = list [i];
+ for (Control child : list) {
Widget [] childList = child.computeTabList ();
if (childList.length != 0) {
Widget [] newResult = new Widget [result.length + childList.length];
@@ -262,13 +261,13 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
//#define PW_CLIENTONLY 0x00000001
//DCOrg() wrong
//topHandle wrong for Tree?
- long /*int*/ hDC = gc.handle;
+ long hDC = gc.handle;
int nSavedDC = OS.SaveDC (hDC);
OS.IntersectClipRect (hDC, 0, 0, width, height);
//WRONG PARENT
POINT lpPoint = new POINT ();
- long /*int*/ hwndParent = OS.GetParent (handle);
+ long hwndParent = OS.GetParent (handle);
OS.MapWindowPoints (handle, hwndParent, lpPoint, 1);
RECT rect = new RECT ();
OS.GetWindowRect (handle, rect);
@@ -364,7 +363,7 @@ void drawBackgroundInPixels(GC gc, int x, int y, int width, int height, int offs
if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
RECT rect = new RECT ();
OS.SetRect (rect, x, y, x + width, y + height);
- long /*int*/ hDC = gc.handle;
+ long hDC = gc.handle;
int pixel = background == -1 ? gc.getBackground ().handle : -1;
drawBackground (hDC, rect, pixel, offsetX, offsetY);
}
@@ -377,9 +376,7 @@ Composite findDeferredControl () {
Menu [] findMenus (Control control) {
if (control == this) return new Menu [0];
Menu result [] = super.findMenus (control);
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
+ for (Control child : _getChildren ()) {
Menu [] menuList = child.findMenus (control);
if (menuList.length != 0) {
Menu [] newResult = new Menu [result.length + menuList.length];
@@ -394,17 +391,16 @@ Menu [] findMenus (Control control) {
@Override
void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
super.fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- children [i].fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
+ for (Control child : _getChildren ()) {
+ child.fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
}
}
void fixTabList (Control control) {
if (tabList == null) return;
int count = 0;
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == control) count++;
+ for (Control element : tabList) {
+ if (element == control) count++;
}
if (count == 0) return;
Control [] newList = null;
@@ -412,9 +408,9 @@ void fixTabList (Control control) {
if (length != 0) {
newList = new Control [length];
int index = 0;
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] != control) {
- newList [index++] = tabList [i];
+ for (Control element : tabList) {
+ if (element != control) {
+ newList [index++] = element;
}
}
}
@@ -476,7 +472,7 @@ int getChildrenCount () {
* non-registered children.
*/
int count = 0;
- long /*int*/ hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
+ long hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
while (hwndChild != 0) {
count++;
hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT);
@@ -518,14 +514,14 @@ public Control [] getTabList () {
if (tabList == null) {
int count = 0;
Control [] list =_getChildren ();
- for (int i=0; i<list.length; i++) {
- if (list [i].isTabGroup ()) count++;
+ for (Control element : list) {
+ if (element.isTabGroup ()) count++;
}
tabList = new Control [count];
int index = 0;
- for (int i=0; i<list.length; i++) {
- if (list [i].isTabGroup ()) {
- tabList [index++] = list [i];
+ for (Control element : list) {
+ if (element.isTabGroup ()) {
+ tabList [index++] = element;
}
}
}
@@ -806,8 +802,7 @@ public void layout (Control [] changed) {
public void layout (Control [] changed, int flags) {
checkWidget ();
if (changed != null) {
- for (int i=0; i<changed.length; i++) {
- Control control = changed [i];
+ for (Control control : changed) {
if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
boolean ancestor = false;
@@ -821,8 +816,8 @@ public void layout (Control [] changed, int flags) {
}
int updateCount = 0;
Composite [] update = new Composite [16];
- for (int i=0; i<changed.length; i++) {
- Control child = changed [i];
+ for (Control element : changed) {
+ Control child = element;
Composite composite = child.parent;
// Update layout when the list of children has changed.
// See bug 497812.
@@ -843,7 +838,7 @@ public void layout (Control [] changed, int flags) {
composite = child.parent;
}
}
- if ((flags & SWT.DEFER) != 0) {
+ if (!display.externalEventLoop && (flags & SWT.DEFER) != 0) {
setLayoutDeferred (true);
display.addLayoutDeferred (this);
}
@@ -853,7 +848,7 @@ public void layout (Control [] changed, int flags) {
} else {
if (layout == null && (flags & SWT.ALL) == 0) return;
markLayout ((flags & SWT.CHANGED) != 0, (flags & SWT.ALL) != 0);
- if ((flags & SWT.DEFER) != 0) {
+ if (!display.externalEventLoop && (flags & SWT.DEFER) != 0) {
setLayoutDeferred (true);
display.addLayoutDeferred (this);
}
@@ -868,23 +863,21 @@ void markLayout (boolean changed, boolean all) {
if (changed) state |= LAYOUT_CHANGED;
}
if (all) {
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- children [i].markLayout (changed, all);
+ for (Control element : _getChildren ()) {
+ element.markLayout (changed, all);
}
}
}
Point minimumSize (int wHint, int hHint, boolean changed) {
- Control [] children = _getChildren ();
/*
* Since getClientArea can be overridden by subclasses, we cannot
* call getClientAreaInPixels directly.
*/
Rectangle clientArea = DPIUtil.autoScaleUp(getClientArea ());
int width = 0, height = 0;
- for (int i=0; i<children.length; i++) {
- Rectangle rect = DPIUtil.autoScaleUp(children [i].getBounds ());
+ for (Control element : _getChildren ()) {
+ Rectangle rect = DPIUtil.autoScaleUp(element.getBounds ());
width = Math.max (width, rect.x - clientArea.x + rect.width);
height = Math.max (height, rect.y - clientArea.y + rect.height);
}
@@ -894,9 +887,8 @@ Point minimumSize (int wHint, int hHint, boolean changed) {
@Override
boolean redrawChildren () {
if (!super.redrawChildren ()) return false;
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- children [i].redrawChildren ();
+ for (Control element : _getChildren ()) {
+ element.redrawChildren ();
}
return true;
}
@@ -906,8 +898,8 @@ void releaseParent () {
super.releaseParent ();
if ((state & CANVAS) != 0) {
if ((style & SWT.TRANSPARENT) != 0) {
- long /*int*/ hwndParent = parent.handle;
- long /*int*/ hwndChild = OS.GetWindow (hwndParent, OS.GW_CHILD);
+ long hwndParent = parent.handle;
+ long hwndChild = OS.GetWindow (hwndParent, OS.GW_CHILD);
while (hwndChild != 0) {
if (hwndChild != handle) {
int bits = OS.GetWindowLong (hwndParent, OS.GWL_EXSTYLE);
@@ -924,21 +916,26 @@ void releaseParent () {
@Override
void releaseChildren (boolean destroy) {
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child != null && !child.isDisposed ()) {
- child.release (false);
+ try (ExceptionStash exceptions = new ExceptionStash ()) {
+ for (Control child : _getChildren ()) {
+ if (child == null || child.isDisposed ())
+ continue;
+
+ try {
+ child.release (false);
+ } catch (Error | RuntimeException ex) {
+ exceptions.stash (ex);
+ }
}
+ super.releaseChildren (destroy);
}
- super.releaseChildren (destroy);
}
@Override
void releaseWidget () {
super.releaseWidget ();
if ((state & CANVAS) != 0 && (style & SWT.EMBEDDED) != 0) {
- long /*int*/ hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
+ long hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
if (hwndChild != 0) {
int threadId = OS.GetWindowThreadProcessId (hwndChild, null);
if (threadId != OS.GetCurrentThreadId ()) {
@@ -960,9 +957,7 @@ void removeControl (Control control) {
@Override
void reskinChildren (int flags) {
super.reskinChildren (flags);
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
+ for (Control child : _getChildren ()) {
if (child != null) child.reskin (flags);
}
}
@@ -980,24 +975,13 @@ void resizeChildren () {
boolean resizeChildren (boolean defer, WINDOWPOS [] pwp) {
if (pwp == null) return true;
- long /*int*/ hdwp = 0;
+ long hdwp = 0;
if (defer) {
hdwp = OS.BeginDeferWindowPos (pwp.length);
if (hdwp == 0) return false;
}
- for (int i=0; i<pwp.length; i++) {
- WINDOWPOS wp = pwp [i];
+ for (WINDOWPOS wp : pwp) {
if (wp != null) {
- /*
- * This code is intentionally commented. All widgets that
- * are created by SWT have WS_CLIPSIBLINGS to ensure that
- * application code does not draw outside of the control.
- */
-// int count = parent.getChildrenCount ();
-// if (count > 1) {
-// int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
-// if ((bits & OS.WS_CLIPSIBLINGS) == 0) wp.flags |= OS.SWP_NOCOPYBITS;
-// }
if (defer) {
hdwp = OS.DeferWindowPos (hdwp, wp.hwnd, 0, wp.x, wp.y, wp.cx, wp.cy, wp.flags);
if (hdwp == 0) return false;
@@ -1010,7 +994,7 @@ boolean resizeChildren (boolean defer, WINDOWPOS [] pwp) {
return true;
}
-void resizeEmbeddedHandle(long /*int*/ embeddedHandle, int width, int height) {
+void resizeEmbeddedHandle(long embeddedHandle, int width, int height) {
if (embeddedHandle == 0) return;
int [] processID = new int [1];
int threadId = OS.GetWindowThreadProcessId (embeddedHandle, processID);
@@ -1019,7 +1003,6 @@ void resizeEmbeddedHandle(long /*int*/ embeddedHandle, int width, int height) {
if (display.msgHook == 0) {
display.getMsgCallback = new Callback (display, "getMsgProc", 3);
display.getMsgProc = display.getMsgCallback.getAddress ();
- if (display.getMsgProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
display.msgHook = OS.SetWindowsHookEx (OS.WH_GETMESSAGE, display.getMsgProc, OS.GetLibraryHandle(), threadId);
OS.PostThreadMessage (threadId, OS.WM_NULL, 0, 0);
}
@@ -1061,9 +1044,8 @@ void sendResize () {
public void setBackgroundMode (int mode) {
checkWidget ();
backgroundMode = mode;
- Control [] children = _getChildren ();
- for (int i = 0; i < children.length; i++) {
- children [i].updateBackgroundMode ();
+ for (Control element : _getChildren ()) {
+ element.updateBackgroundMode ();
}
}
@@ -1090,12 +1072,10 @@ void setBoundsInPixels (int x, int y, int width, int height, int flags, boolean
public boolean setFocus () {
checkWidget ();
Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
+ for (Control child : children) {
if (child.setRadioFocus (false)) return true;
}
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
+ for (Control child : children) {
if (child.setFocus ()) return true;
}
return super.setFocus ();
@@ -1169,8 +1149,7 @@ public void setLayoutDeferred (boolean defer) {
public void setTabList (Control [] tabList) {
checkWidget ();
if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- Control control = tabList [i];
+ for (Control control : tabList) {
if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
@@ -1206,13 +1185,15 @@ boolean setTabGroupFocus () {
}
if (takeFocus && setTabItemFocus ()) return true;
Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child.isTabItem () && child.setRadioFocus (true)) return true;
+ for (Control child : children) {
+ /*
+ * It is unlikely but possible that a child is disposed at this point, for more
+ * details refer bug 381668.
+ */
+ if (!child.isDisposed() && child.isTabItem() && child.setRadioFocus (true)) return true;
}
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child.isTabItem () && !child.isTabGroup () && child.setTabItemFocus ()) {
+ for (Control child : children) {
+ if (!child.isDisposed() && child.isTabItem () && !child.isTabGroup () && child.setTabItemFocus ()) {
return true;
}
}
@@ -1245,7 +1226,7 @@ String toolTipText (NMTTDISPINFO hdr) {
Shell shell = getShell ();
if ((hdr.uFlags & OS.TTF_IDISHWND) == 0) {
String string = null;
- ToolTip toolTip = shell.findToolTip ((int)/*64*/hdr.idFrom);
+ ToolTip toolTip = shell.findToolTip ((int)hdr.idFrom);
if (toolTip != null) {
string = toolTip.message;
if (string == null || string.length () == 0) string = " ";
@@ -1269,9 +1250,7 @@ String toolTipText (NMTTDISPINFO hdr) {
boolean translateMnemonic (Event event, Control control) {
if (super.translateMnemonic (event, control)) return true;
if (control != null) {
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
+ for (Control child : _getChildren ()) {
if (child.translateMnemonic (event, control)) return true;
}
}
@@ -1282,14 +1261,14 @@ boolean translateMnemonic (Event event, Control control) {
boolean translateTraversal (MSG msg) {
if ((state & CANVAS) != 0 ) {
if ((style & SWT.EMBEDDED) != 0) return false;
- switch ((int)/*64*/msg.wParam) {
+ switch ((int)msg.wParam) {
case OS.VK_UP:
case OS.VK_LEFT:
case OS.VK_DOWN:
case OS.VK_RIGHT:
case OS.VK_PRIOR:
case OS.VK_NEXT:
- int uiState = (int)/*64*/OS.SendMessage (msg.hwnd, OS.WM_QUERYUISTATE, 0, 0);
+ int uiState = (int)OS.SendMessage (msg.hwnd, OS.WM_QUERYUISTATE, 0, 0);
if ((uiState & OS.UISF_HIDEFOCUS) != 0) {
OS.SendMessage (msg.hwnd, OS.WM_UPDATEUISTATE, OS.MAKEWPARAM (OS.UIS_CLEAR, OS.UISF_HIDEFOCUS), 0);
}
@@ -1302,10 +1281,9 @@ boolean translateTraversal (MSG msg) {
@Override
void updateBackgroundColor () {
super.updateBackgroundColor ();
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- if ((children [i].state & PARENT_BACKGROUND) != 0) {
- children [i].updateBackgroundColor ();
+ for (Control element : _getChildren ()) {
+ if ((element.state & PARENT_BACKGROUND) != 0) {
+ element.updateBackgroundColor ();
}
}
}
@@ -1313,10 +1291,9 @@ void updateBackgroundColor () {
@Override
void updateBackgroundImage () {
super.updateBackgroundImage ();
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- if ((children [i].state & PARENT_BACKGROUND) != 0) {
- children [i].updateBackgroundImage ();
+ for (Control element : _getChildren ()) {
+ if ((element.state & PARENT_BACKGROUND) != 0) {
+ element.updateBackgroundImage ();
}
}
}
@@ -1324,18 +1301,15 @@ void updateBackgroundImage () {
@Override
void updateBackgroundMode () {
super.updateBackgroundMode ();
- Control [] children = _getChildren ();
- for (int i = 0; i < children.length; i++) {
- children [i].updateBackgroundMode ();
+ for (Control element : _getChildren ()) {
+ element.updateBackgroundMode ();
}
}
@Override
void updateFont (Font oldFont, Font newFont) {
super.updateFont (oldFont, newFont);
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control control = children [i];
+ for (Control control : _getChildren ()) {
if (!control.isDisposed ()) {
control.updateFont (oldFont, newFont);
}
@@ -1363,9 +1337,8 @@ void updateLayout (boolean resize, boolean all) {
}
if (all) {
state &= ~LAYOUT_CHILD;
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- children [i].updateLayout (resize, all);
+ for (Control element : _getChildren ()) {
+ element.updateLayout (resize, all);
}
}
}
@@ -1393,8 +1366,8 @@ void updateOrientation () {
}
void updateUIState () {
- long /*int*/ hwndShell = getShell ().handle;
- int uiState = /*64*/(int)OS.SendMessage (hwndShell, OS.WM_QUERYUISTATE, 0, 0);
+ long hwndShell = getShell ().handle;
+ int uiState = (int)OS.SendMessage (hwndShell, OS.WM_QUERYUISTATE, 0, 0);
if ((uiState & OS.UISF_HIDEFOCUS) != 0) {
OS.SendMessage (hwndShell, OS.WM_CHANGEUISTATE, OS.MAKEWPARAM (OS.UIS_CLEAR, OS.UISF_HIDEFOCUS), 0);
}
@@ -1407,7 +1380,7 @@ int widgetStyle () {
}
@Override
-LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ERASEBKGND (long wParam, long lParam) {
LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
if (result != null) return result;
if ((state & CANVAS) != 0) {
@@ -1420,7 +1393,7 @@ LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETDLGCODE (long wParam, long lParam) {
LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
if (result != null) return result;
if ((state & CANVAS) != 0) {
@@ -1436,16 +1409,16 @@ LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_GETFONT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETFONT (long wParam, long lParam) {
LRESULT result = super.WM_GETFONT (wParam, lParam);
if (result != null) return result;
- long /*int*/ code = callWindowProc (handle, OS.WM_GETFONT, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_GETFONT, wParam, lParam);
if (code != 0) return new LRESULT (code);
return new LRESULT (font != null ? font.handle : defaultFont ());
}
@Override
-LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDOWN (long wParam, long lParam) {
LRESULT result = super.WM_LBUTTONDOWN (wParam, lParam);
if (result == LRESULT.ZERO) return result;
@@ -1459,7 +1432,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_NCHITTEST (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NCHITTEST (long wParam, long lParam) {
LRESULT result = super.WM_NCHITTEST (wParam, lParam);
if (result != null) return result;
/*
@@ -1476,7 +1449,7 @@ LRESULT WM_NCHITTEST (long /*int*/ wParam, long /*int*/ lParam) {
*/
if (OS.IsAppThemed ()) {
if ((state & CANVAS)!= 0) {
- long /*int*/ code = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
if (code == OS.HTCLIENT) {
RECT rect = new RECT ();
OS.GetClientRect (handle, rect);
@@ -1496,7 +1469,7 @@ LRESULT WM_NCHITTEST (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_PARENTNOTIFY (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PARENTNOTIFY (long wParam, long lParam) {
if ((state & CANVAS) != 0 && (style & SWT.EMBEDDED) != 0) {
if (OS.LOWORD (wParam) == OS.WM_CREATE) {
RECT rect = new RECT ();
@@ -1508,7 +1481,7 @@ LRESULT WM_PARENTNOTIFY (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PAINT (long wParam, long lParam) {
if ((state & DISPOSE_SENT) != 0) return LRESULT.ZERO;
if ((state & CANVAS) == 0 || (state & FOREIGN_HANDLE) != 0) {
return super.WM_PAINT (wParam, lParam);
@@ -1531,15 +1504,15 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
}
}
if (bufferedPaint) {
- long /*int*/ hDC = OS.BeginPaint (handle, ps);
+ long hDC = OS.BeginPaint (handle, ps);
int width = ps.right - ps.left;
int height = ps.bottom - ps.top;
if (width != 0 && height != 0) {
- long /*int*/ [] phdc = new long /*int*/ [1];
+ long [] phdc = new long [1];
int flags = OS.BPBF_COMPATIBLEBITMAP;
RECT prcTarget = new RECT ();
OS.SetRect (prcTarget, ps.left, ps.top, ps.right, ps.bottom);
- long /*int*/ hBufferedPaint = OS.BeginBufferedPaint (hDC, prcTarget, flags, null, phdc);
+ long hBufferedPaint = OS.BeginBufferedPaint (hDC, prcTarget, flags, null, phdc);
GCData data = new GCData ();
data.device = display;
data.foreground = getForegroundPixel ();
@@ -1547,7 +1520,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
if (control == null) control = this;
data.background = control.getBackgroundPixel ();
data.font = Font.win32_new(display, OS.SendMessage (handle, OS.WM_GETFONT, 0, 0));
- data.uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ data.uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
if ((style & SWT.NO_BACKGROUND) != 0) {
/* This code is intentionally commented because it may be slow to copy bits from the screen */
//paintGC.copyArea (image, ps.left, ps.top);
@@ -1575,7 +1548,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
GC gc = GC.win32_new (this, data);
/* Get the system region for the paint HDC */
- long /*int*/ sysRgn = 0;
+ long sysRgn = 0;
if ((style & (SWT.DOUBLE_BUFFERED | SWT.TRANSPARENT)) != 0 || (style & SWT.NO_MERGE_PAINTS) != 0) {
sysRgn = OS.CreateRectRgn (0, 0, 0, 0);
if (OS.GetRandomRgn (gc.handle, sysRgn, OS.SYSRGN) == 1) {
@@ -1583,7 +1556,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
int nBytes = OS.GetRegionData (sysRgn, 0, null);
int [] lpRgnData = new int [nBytes / 4];
OS.GetRegionData (sysRgn, nBytes, lpRgnData);
- long /*int*/ newSysRgn = OS.ExtCreateRegion (new float [] {-1, 0, 0, 1, 0, 0}, nBytes, lpRgnData);
+ long newSysRgn = OS.ExtCreateRegion (new float [] {-1, 0, 0, 1, 0, 0}, nBytes, lpRgnData);
OS.DeleteObject (sysRgn);
sysRgn = newSysRgn;
}
@@ -1673,7 +1646,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
gc.dispose ();
}
} else {
- long /*int*/ hDC = OS.BeginPaint (handle, ps);
+ long hDC = OS.BeginPaint (handle, ps);
if ((style & (SWT.NO_BACKGROUND | SWT.TRANSPARENT)) == 0) {
RECT rect = new RECT ();
OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom);
@@ -1700,7 +1673,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_PRINTCLIENT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PRINTCLIENT (long wParam, long lParam) {
LRESULT result = super.WM_PRINTCLIENT (wParam, lParam);
if (result != null) return result;
if ((state & CANVAS) != 0) {
@@ -1719,7 +1692,7 @@ LRESULT WM_PRINTCLIENT (long /*int*/ wParam, long /*int*/ lParam) {
if (control == null) control = this;
data.background = control.getBackgroundPixel ();
data.font = Font.win32_new(display, OS.SendMessage (handle, OS.WM_GETFONT, 0, 0));
- data.uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ data.uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
GC gc = GC.win32_new (wParam, data);
Event event = new Event ();
event.gc = gc;
@@ -1734,13 +1707,13 @@ LRESULT WM_PRINTCLIENT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETFONT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFONT (long wParam, long lParam) {
if (lParam != 0) OS.InvalidateRect (handle, null, true);
return super.WM_SETFONT (wParam, lParam);
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
LRESULT result = null;
if ((state & RESIZE_DEFERRED) != 0) {
result = super.WM_SIZE (wParam, lParam);
@@ -1789,10 +1762,10 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SYSCOLORCHANGE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SYSCOLORCHANGE (long wParam, long lParam) {
LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
if (result != null) return result;
- long /*int*/ hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
+ long hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
while (hwndChild != 0) {
OS.SendMessage (hwndChild, OS.WM_SYSCOLORCHANGE, 0, 0);
hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT);
@@ -1801,7 +1774,7 @@ LRESULT WM_SYSCOLORCHANGE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SYSCOMMAND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SYSCOMMAND (long wParam, long lParam) {
LRESULT result = super.WM_SYSCOMMAND (wParam, lParam);
if (result != null) return result;
@@ -1820,13 +1793,13 @@ LRESULT WM_SYSCOMMAND (long /*int*/ wParam, long /*int*/ lParam) {
* does not redraw properly. The fix is to detect this case and
* redraw the non-client area.
*/
- int cmd = (int)/*64*/wParam & 0xFFF0;
+ int cmd = (int)wParam & 0xFFF0;
switch (cmd) {
case OS.SC_HSCROLL:
case OS.SC_VSCROLL:
boolean showHBar = horizontalBar != null && horizontalBar.getVisible ();
boolean showVBar = verticalBar != null && verticalBar.getVisible ();
- long /*int*/ code = callWindowProc (handle, OS.WM_SYSCOMMAND, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_SYSCOMMAND, wParam, lParam);
if ((showHBar != (horizontalBar != null && horizontalBar.getVisible ())) ||
(showVBar != (verticalBar != null && verticalBar.getVisible ()))) {
int flags = OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_UPDATENOW;
@@ -1841,7 +1814,7 @@ LRESULT WM_SYSCOMMAND (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_UPDATEUISTATE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_UPDATEUISTATE (long wParam, long lParam) {
LRESULT result = super.WM_UPDATEUISTATE (wParam, lParam);
if (result != null) return result;
if ((state & CANVAS) != 0 && hooks (SWT.Paint)) {
@@ -1851,20 +1824,20 @@ LRESULT WM_UPDATEUISTATE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmNCPaint (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNCPaint (long hwnd, long wParam, long lParam) {
LRESULT result = super.wmNCPaint (hwnd, wParam, lParam);
if (result != null) return result;
- long /*int*/ borderHandle = borderHandle ();
+ long borderHandle = borderHandle ();
if ((state & CANVAS) != 0 || (hwnd == borderHandle && handle != borderHandle)) {
if (OS.IsAppThemed ()) {
int bits1 = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE);
if ((bits1 & OS.WS_EX_CLIENTEDGE) != 0) {
- long /*int*/ code = 0;
+ long code = 0;
int bits2 = OS.GetWindowLong (hwnd, OS.GWL_STYLE);
if ((bits2 & (OS.WS_HSCROLL | OS.WS_VSCROLL)) != 0) {
code = callWindowProc (hwnd, OS.WM_NCPAINT, wParam, lParam);
}
- long /*int*/ hDC = OS.GetWindowDC (hwnd);
+ long hDC = OS.GetWindowDC (hwnd);
RECT rect = new RECT ();
OS.GetWindowRect (hwnd, rect);
rect.right -= rect.left;
@@ -1882,7 +1855,7 @@ LRESULT wmNCPaint (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
}
@Override
-LRESULT wmNotify (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotify (NMHDR hdr, long wParam, long lParam) {
switch (hdr.code) {
/*
* Feature in Windows. When the tool tip control is
@@ -1907,7 +1880,7 @@ LRESULT wmNotify (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
* check if the parent is already on top and neither set or clear
* the topmost status of the tool tip.
*/
- long /*int*/ hwndParent = hdr.hwndFrom;
+ long hwndParent = hdr.hwndFrom;
do {
hwndParent = OS.GetParent (hwndParent);
if (hwndParent == 0) break;
@@ -1929,7 +1902,7 @@ LRESULT wmNotify (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
display.lockActiveWindow = true;
int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOSIZE;
- long /*int*/ hwndInsertAfter = hdr.code == OS.TTN_SHOW ? OS.HWND_TOPMOST : OS.HWND_NOTOPMOST;
+ long hwndInsertAfter = hdr.code == OS.TTN_SHOW ? OS.HWND_TOPMOST : OS.HWND_NOTOPMOST;
OS.SetWindowPos (hdr.hwndFrom, hwndInsertAfter, 0, 0, 0, 0, flags);
display.lockActiveWindow = false;
break;
@@ -1961,12 +1934,12 @@ LRESULT wmNotify (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
* the orientation of the control.
*/
Widget widget = null;
- long /*int*/ hwnd = hdr.idFrom;
+ long hwnd = hdr.idFrom;
if ((lpnmtdi.uFlags & OS.TTF_IDISHWND) != 0) {
widget = display.getControl (hwnd);
} else {
if (hdr.hwndFrom == shell.toolTipHandle || hdr.hwndFrom == shell.balloonTipHandle) {
- widget = shell.findToolTip ((int)/*64*/hdr.idFrom);
+ widget = shell.findToolTip ((int)hdr.idFrom);
}
}
if (widget != null) {
@@ -1988,4 +1961,9 @@ LRESULT wmNotify (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
return super.wmNotify (hdr, wParam, lParam);
}
+@Override
+public String toString() {
+ return super.toString() + " [layout=" + layout + "]";
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index c0ef868153..7bddfb010f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,6 +15,8 @@
package org.eclipse.swt.widgets;
+import java.util.*;
+
import org.eclipse.swt.*;
import org.eclipse.swt.accessibility.*;
import org.eclipse.swt.events.*;
@@ -60,7 +62,7 @@ public abstract class Control extends Widget implements Drawable {
*
* @noreference This field is not intended to be referenced by clients.
*/
- public long /*int*/ handle;
+ public long handle;
Composite parent;
Cursor cursor;
Menu menu, activeMenu;
@@ -541,7 +543,7 @@ int binarySearch (int [] indices, int start, int end, int index) {
return -low - 1;
}
-long /*int*/ borderHandle () {
+long borderHandle () {
return handle;
}
@@ -582,10 +584,6 @@ void checkComposited () {
/* Do nothing */
}
-boolean checkHandle (long /*int*/ hwnd) {
- return hwnd == handle;
-}
-
void checkMirrored () {
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
int bits = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
@@ -706,7 +704,7 @@ Widget [] computeTabList () {
}
void createHandle () {
- long /*int*/ hwndParent = widgetParent ();
+ long hwndParent = widgetParent ();
handle = OS.CreateWindowEx (
widgetExtStyle (),
windowClass (),
@@ -722,12 +720,6 @@ void createHandle () {
if ((bits & OS.WS_CHILD) != 0) {
OS.SetWindowLongPtr (handle, OS.GWLP_ID, handle);
}
- if (OS.IsDBLocale && hwndParent != 0) {
- long /*int*/ hIMC = OS.ImmGetContext (hwndParent);
- OS.ImmAssociateContext (handle, hIMC);
- OS.ImmReleaseContext (hwndParent, hIMC);
- }
-
}
void checkGesture () {
@@ -738,17 +730,11 @@ void checkGesture () {
* Feature in Windows 7: All gestures are enabled by default except GID_ROTATE.
* Enable it explicitly by calling SetGestureConfig.
*/
- long /*int*/ hHeap = OS.GetProcessHeap ();
- long /*int*/ pConfigs = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, GESTURECONFIG.sizeof);
- if (pConfigs != 0) {
- GESTURECONFIG config = new GESTURECONFIG();
- config.dwID = OS.GID_ROTATE;
- config.dwWant = 1;
- config.dwBlock = 0;
- OS.MoveMemory (pConfigs, config, GESTURECONFIG.sizeof);
- OS.SetGestureConfig (handle, 0, 1, pConfigs, GESTURECONFIG.sizeof);
- OS.HeapFree (hHeap, 0, pConfigs);
- }
+ GESTURECONFIG config = new GESTURECONFIG();
+ config.dwID = OS.GID_ROTATE;
+ config.dwWant = 1;
+ config.dwBlock = 0;
+ OS.SetGestureConfig (handle, 0, 1, config, GESTURECONFIG.sizeof);
}
}
}
@@ -776,7 +762,7 @@ int defaultBackground () {
return OS.GetSysColor (OS.COLOR_BTNFACE);
}
-long /*int*/ defaultFont () {
+long defaultFont () {
return display.getSystemFont ().handle;
}
@@ -790,7 +776,7 @@ void deregister () {
@Override
void destroyWidget () {
- long /*int*/ hwnd = topHandle ();
+ long hwnd = topHandle ();
releaseHandle ();
if (hwnd != 0) {
OS.DestroyWindow (hwnd);
@@ -919,7 +905,7 @@ boolean dragDetect (int button, int count, int stateMask, int x, int y) {
if ((stateMask & SWT.BUTTON3) != 0) wParam |= OS.MK_RBUTTON;
if ((stateMask & SWT.BUTTON4) != 0) wParam |= OS.MK_XBUTTON1;
if ((stateMask & SWT.BUTTON5) != 0) wParam |= OS.MK_XBUTTON2;
- long /*int*/ lParam = OS.MAKELPARAM (x, y);
+ long lParam = OS.MAKELPARAM (x, y);
OS.SendMessage (handle, OS.WM_LBUTTONUP, wParam, lParam);
}
return false;
@@ -927,17 +913,17 @@ boolean dragDetect (int button, int count, int stateMask, int x, int y) {
return sendDragEvent (button, stateMask, x, y);
}
-void drawBackground (long /*int*/ hDC) {
+void drawBackground (long hDC) {
RECT rect = new RECT ();
OS.GetClientRect (handle, rect);
drawBackground (hDC, rect);
}
-void drawBackground (long /*int*/ hDC, RECT rect) {
+void drawBackground (long hDC, RECT rect) {
drawBackground (hDC, rect, -1, 0, 0);
}
-void drawBackground (long /*int*/ hDC, RECT rect, int pixel, int tx, int ty) {
+void drawBackground (long hDC, RECT rect, int pixel, int tx, int ty) {
Control control = findBackgroundControl ();
if (control != null) {
if (control.backgroundImage != null) {
@@ -961,21 +947,21 @@ void drawBackground (long /*int*/ hDC, RECT rect, int pixel, int tx, int ty) {
fillBackground (hDC, pixel, rect);
}
-void drawImageBackground (long /*int*/ hDC, long /*int*/ hwnd, long /*int*/ hBitmap, RECT rect, int tx, int ty) {
+void drawImageBackground (long hDC, long hwnd, long hBitmap, RECT rect, int tx, int ty) {
RECT rect2 = new RECT ();
OS.GetClientRect (hwnd, rect2);
OS.MapWindowPoints (hwnd, handle, rect2, 2);
- long /*int*/ hBrush = findBrush (hBitmap, OS.BS_PATTERN);
+ long hBrush = findBrush (hBitmap, OS.BS_PATTERN);
POINT lpPoint = new POINT ();
OS.GetWindowOrgEx (hDC, lpPoint);
OS.SetBrushOrgEx (hDC, -rect2.left - lpPoint.x - tx, -rect2.top - lpPoint.y - ty, lpPoint);
- long /*int*/ hOldBrush = OS.SelectObject (hDC, hBrush);
+ long hOldBrush = OS.SelectObject (hDC, hBrush);
OS.PatBlt (hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY);
OS.SetBrushOrgEx (hDC, lpPoint.x, lpPoint.y, null);
OS.SelectObject (hDC, hOldBrush);
}
-void drawThemeBackground (long /*int*/ hDC, long /*int*/ hwnd, RECT rect) {
+void drawThemeBackground (long hDC, long hwnd, RECT rect) {
/* Do nothing */
}
@@ -983,21 +969,20 @@ void enableDrag (boolean enabled) {
/* Do nothing */
}
+void maybeEnableDarkSystemTheme() {
+ maybeEnableDarkSystemTheme(handle);
+}
+
void enableWidget (boolean enabled) {
OS.EnableWindow (handle, enabled);
}
-void fillBackground (long /*int*/ hDC, int pixel, RECT rect) {
+void fillBackground (long hDC, int pixel, RECT rect) {
if (rect.left > rect.right || rect.top > rect.bottom) return;
- long /*int*/ hPalette = display.hPalette;
- if (hPalette != 0) {
- OS.SelectPalette (hDC, hPalette, false);
- OS.RealizePalette (hDC);
- }
OS.FillRect (hDC, rect, findBrush (pixel, OS.BS_SOLID));
}
-void fillImageBackground (long /*int*/ hDC, Control control, RECT rect, int tx, int ty) {
+void fillImageBackground (long hDC, Control control, RECT rect, int tx, int ty) {
if (rect.left > rect.right || rect.top > rect.bottom) return;
if (control != null) {
Image image = control.backgroundImage;
@@ -1007,7 +992,7 @@ void fillImageBackground (long /*int*/ hDC, Control control, RECT rect, int tx,
}
}
-void fillThemeBackground (long /*int*/ hDC, Control control, RECT rect) {
+void fillThemeBackground (long hDC, Control control, RECT rect) {
if (rect.left > rect.right || rect.top > rect.bottom) return;
if (control != null) {
control.drawThemeBackground (hDC, handle, rect);
@@ -1019,7 +1004,7 @@ Control findBackgroundControl () {
return (parent != null && (state & PARENT_BACKGROUND) != 0) ? parent.findBackgroundControl () : null;
}
-long /*int*/ findBrush (long /*int*/ value, int lbStyle) {
+long findBrush (long value, int lbStyle) {
return parent.findBrush (value, lbStyle);
}
@@ -1051,7 +1036,7 @@ char findMnemonic (String string) {
if (string.charAt (index) != '&') return string.charAt (index);
index++;
} while (index < length);
- return '\0';
+ return '\0';
}
void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
@@ -1062,15 +1047,8 @@ void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, De
void fixFocus (Control focusControl) {
Shell shell = getShell ();
Control control = this;
- Display display = this.display;
- boolean oldFixFocus = display.fixFocus;
- display.fixFocus = true;
- try {
- while (control != shell && (control = control.parent) != null) {
- if (control.setFocus ()) return;
- }
- } finally {
- display.fixFocus = oldFixFocus;
+ while (control != shell && (control = control.parent) != null) {
+ if (control.setFocus ()) return;
}
shell.setSavedFocus (focusControl);
OS.SetFocus (0);
@@ -1125,16 +1103,6 @@ void forceResize () {
for (int i=0; i<lpwp.length; i++) {
WINDOWPOS wp = lpwp [i];
if (wp != null && wp.hwnd == handle) {
- /*
- * This code is intentionally commented. All widgets that
- * are created by SWT have WS_CLIPSIBLINGS to ensure that
- * application code does not draw outside of the control.
- */
-// int count = parent.getChildrenCount ();
-// if (count > 1) {
-// int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
-// if ((bits & OS.WS_CLIPSIBLINGS) == 0) wp.flags |= OS.SWP_NOCOPYBITS;
-// }
OS.SetWindowPos (wp.hwnd, 0, wp.x, wp.y, wp.cx, wp.cy, wp.flags);
lpwp [i] = null;
return;
@@ -1234,12 +1202,24 @@ public int getBorderWidth () {
}
int getBorderWidthInPixels () {
- long /*int*/ borderHandle = borderHandle ();
+ long borderHandle = borderHandle ();
int bits1 = OS.GetWindowLong (borderHandle, OS.GWL_EXSTYLE);
if ((bits1 & OS.WS_EX_CLIENTEDGE) != 0) return OS.GetSystemMetrics (OS.SM_CXEDGE);
if ((bits1 & OS.WS_EX_STATICEDGE) != 0) return OS.GetSystemMetrics (OS.SM_CXBORDER);
int bits2 = OS.GetWindowLong (borderHandle, OS.GWL_STYLE);
- if ((bits2 & OS.WS_BORDER) != 0) return OS.GetSystemMetrics (OS.SM_CXBORDER);
+
+ if ((bits2 & OS.WS_BORDER) != 0) {
+ /*
+ * For compatibility reasons, isUseWsBorder() shall not change layout size
+ * compared to previously used WS_EX_CLIENTEDGE. Removing this workaround
+ * saves screen space, but could break some layouts.
+ */
+ if (isUseWsBorder ())
+ return OS.GetSystemMetrics (OS.SM_CXEDGE);
+
+ return OS.GetSystemMetrics (OS.SM_CXBORDER);
+ }
+
return 0;
}
@@ -1265,7 +1245,7 @@ Rectangle getBoundsInPixels () {
forceResize ();
RECT rect = new RECT ();
OS.GetWindowRect (topHandle (), rect);
- long /*int*/ hwndParent = parent == null ? 0 : parent.handle;
+ long hwndParent = parent == null ? 0 : parent.handle;
OS.MapWindowPoints (0, hwndParent, rect, 2);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
@@ -1279,13 +1259,12 @@ int getCodePage () {
String getClipboardText () {
String string = "";
if (OS.OpenClipboard (0)) {
- long /*int*/ hMem = OS.GetClipboardData (OS.CF_UNICODETEXT);
+ long hMem = OS.GetClipboardData (OS.CF_UNICODETEXT);
if (hMem != 0) {
/* Ensure byteCount is a multiple of 2 bytes on UNICODE platforms */
int byteCount = OS.GlobalSize (hMem) / TCHAR.sizeof * TCHAR.sizeof;
- long /*int*/ ptr = OS.GlobalLock (hMem);
+ long ptr = OS.GlobalLock (hMem);
if (ptr != 0) {
- /* Use the character encoding for the default locale */
TCHAR buffer = new TCHAR (0, byteCount / TCHAR.sizeof);
OS.MoveMemory (buffer, ptr, byteCount);
string = buffer.toString (0, buffer.strlen ());
@@ -1373,7 +1352,7 @@ public boolean getEnabled () {
public Font getFont () {
checkWidget ();
if (font != null) return font;
- long /*int*/ hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ long hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (hFont == 0) hFont = defaultFont ();
return Font.win32_new (display, hFont);
}
@@ -1434,7 +1413,7 @@ Point getLocationInPixels () {
forceResize ();
RECT rect = new RECT ();
OS.GetWindowRect (topHandle (), rect);
- long /*int*/ hwndParent = parent == null ? 0 : parent.handle;
+ long hwndParent = parent == null ? 0 : parent.handle;
OS.MapWindowPoints (0, hwndParent, rect, 2);
return new Point (rect.left, rect.top);
}
@@ -1474,7 +1453,7 @@ public Menu getMenu () {
*/
public Monitor getMonitor () {
checkWidget ();
- long /*int*/ hmonitor = OS.MonitorFromWindow (handle, OS.MONITOR_DEFAULTTONEAREST);
+ long hmonitor = OS.MonitorFromWindow (handle, OS.MONITOR_DEFAULTTONEAREST);
return display.getMonitor (hmonitor);
}
@@ -1756,7 +1735,7 @@ boolean hasFocus () {
* then this control is considered to have focus
* even though it does not have focus in Windows.
*/
- long /*int*/ hwndFocus = OS.GetFocus ();
+ long hwndFocus = OS.GetFocus ();
while (hwndFocus != 0) {
if (hwndFocus == handle) return true;
if (display.getControl (hwndFocus) != null) {
@@ -1783,12 +1762,12 @@ boolean hasFocus () {
* @noreference This method is not intended to be referenced by clients.
*/
@Override
-public long /*int*/ internal_new_GC (GCData data) {
+public long internal_new_GC (GCData data) {
checkWidget();
- long /*int*/ hwnd = handle;
+ long hwnd = handle;
if (data != null && data.hwnd != 0) hwnd = data.hwnd;
if (data != null) data.hwnd = hwnd;
- long /*int*/ hDC = 0;
+ long hDC = 0;
if (data == null || data.ps == null) {
hDC = OS.GetDC (hwnd);
} else {
@@ -1815,7 +1794,7 @@ public long /*int*/ internal_new_GC (GCData data) {
int background = control.getBackgroundPixel ();
if (background != OS.GetBkColor (hDC)) data.background = background;
data.font = font != null ? font : Font.win32_new (display, OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0));
- data.uiState = (int)/*64*/OS.SendMessage (hwnd, OS.WM_QUERYUISTATE, 0, 0);
+ data.uiState = (int)OS.SendMessage (hwnd, OS.WM_QUERYUISTATE, 0, 0);
}
return hDC;
}
@@ -1836,9 +1815,9 @@ public long /*int*/ internal_new_GC (GCData data) {
* @noreference This method is not intended to be referenced by clients.
*/
@Override
-public void internal_dispose_GC (long /*int*/ hDC, GCData data) {
+public void internal_dispose_GC (long hDC, GCData data) {
checkWidget ();
- long /*int*/ hwnd = handle;
+ long hwnd = handle;
if (data != null && data.hwnd != 0) {
hwnd = data.hwnd;
}
@@ -1969,7 +1948,7 @@ boolean isShowing () {
*/
// if (!OS.IsWindowVisible (handle)) return false;
// int flags = OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS;
-// long /*int*/ hDC = OS.GetDCEx (handle, 0, flags);
+// long hDC = OS.GetDCEx (handle, 0, flags);
// int result = OS.GetClipBox (hDC, new RECT ());
// OS.ReleaseDC (handle, hDC);
// return result != OS.NULLREGION;
@@ -1978,8 +1957,8 @@ boolean isShowing () {
boolean isTabGroup () {
Control [] tabList = parent._getTabList ();
if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == this) return true;
+ for (Control element : tabList) {
+ if (element == this) return true;
}
}
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
@@ -1989,13 +1968,13 @@ boolean isTabGroup () {
boolean isTabItem () {
Control [] tabList = parent._getTabList ();
if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == this) return false;
+ for (Control element : tabList) {
+ if (element == this) return false;
}
}
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
if ((bits & OS.WS_TABSTOP) != 0) return false;
- long /*int*/ code = OS.SendMessage (handle, OS.WM_GETDLGCODE, 0, 0);
+ long code = OS.SendMessage (handle, OS.WM_GETDLGCODE, 0, 0);
if ((code & OS.DLGC_STATIC) != 0) return false;
if ((code & OS.DLGC_WANTALLKEYS) != 0) return false;
if ((code & OS.DLGC_WANTARROWS) != 0) return false;
@@ -2023,8 +2002,16 @@ public boolean isVisible () {
return getVisible () && parent.isVisible ();
}
+/**
+ * Custom theming: whether to use WS_BORDER instead of WS_EX_CLIENTEDGE for SWT.BORDER
+ * Intended for override.
+ */
+boolean isUseWsBorder () {
+ return (display != null) && display.useWsBorderAll;
+}
+
@Override
-void mapEvent (long /*int*/ hwnd, Event event) {
+void mapEvent (long hwnd, Event event) {
if (hwnd != handle) {
POINT point = new POINT ();
Point loc = event.getLocationInPixels();
@@ -2073,11 +2060,11 @@ boolean mnemonicMatch (char key) {
*/
public void moveAbove (Control control) {
checkWidget ();
- long /*int*/ topHandle = topHandle (), hwndAbove = OS.HWND_TOP;
+ long topHandle = topHandle (), hwndAbove = OS.HWND_TOP;
if (control != null) {
if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
if (parent != control.parent) return;
- long /*int*/ hwnd = control.topHandle ();
+ long hwnd = control.topHandle ();
if (hwnd == 0 || hwnd == topHandle) return;
hwndAbove = OS.GetWindow (hwnd, OS.GW_HWNDPREV);
/*
@@ -2117,7 +2104,7 @@ public void moveAbove (Control control) {
*/
public void moveBelow (Control control) {
checkWidget ();
- long /*int*/ topHandle = topHandle (), hwndAbove = OS.HWND_BOTTOM;
+ long topHandle = topHandle (), hwndAbove = OS.HWND_BOTTOM;
if (control != null) {
if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
if (parent != control.parent) return;
@@ -2141,7 +2128,7 @@ public void moveBelow (Control control) {
* this case and do nothing because the control is already
* at the bottom.
*/
- long /*int*/ hwndParent = parent.handle, hwnd = hwndParent;
+ long hwndParent = parent.handle, hwnd = hwndParent;
hwndAbove = OS.GetWindow (hwnd, OS.GW_HWNDPREV);
while (hwndAbove != 0 && hwndAbove != hwnd) {
if (OS.GetWindow (hwndAbove, OS.GW_OWNER) == hwndParent) break;
@@ -2232,14 +2219,14 @@ public boolean print (GC gc) {
checkWidget ();
if (gc == null) error (SWT.ERROR_NULL_ARGUMENT);
if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- long /*int*/ topHandle = topHandle ();
- long /*int*/ hdc = gc.handle;
+ long topHandle = topHandle ();
+ long hdc = gc.handle;
int state = 0;
- long /*int*/ gdipGraphics = gc.getGCData().gdipGraphics;
+ long gdipGraphics = gc.getGCData().gdipGraphics;
if (gdipGraphics != 0) {
- long /*int*/ clipRgn = 0;
+ long clipRgn = 0;
Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeNone);
- long /*int*/ rgn = Gdip.Region_new();
+ long rgn = Gdip.Region_new();
if (rgn == 0) error(SWT.ERROR_NO_HANDLES);
Gdip.Graphics_GetClip(gdipGraphics, rgn);
if (!Gdip.Region_IsInfinite(rgn, gdipGraphics)) {
@@ -2248,7 +2235,7 @@ public boolean print (GC gc) {
Gdip.Region_delete(rgn);
Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf);
float[] lpXform = null;
- long /*int*/ matrix = Gdip.Matrix_new(1, 0, 0, 1, 0, 0);
+ long matrix = Gdip.Matrix_new(1, 0, 0, 1, 0, 0);
if (matrix == 0) error(SWT.ERROR_NO_HANDLES);
Gdip.Graphics_GetTransform(gdipGraphics, matrix);
if (!Gdip.Matrix_IsIdentity(matrix)) {
@@ -2277,7 +2264,7 @@ public boolean print (GC gc) {
return true;
}
-void printWidget (long /*int*/ hwnd, long /*int*/ hdc, GC gc) {
+void printWidget (long hwnd, long hdc, GC gc) {
/*
* Bug in Windows. For some reason, PrintWindow()
* returns success but does nothing when it is called
@@ -2292,8 +2279,8 @@ void printWidget (long /*int*/ hwnd, long /*int*/ hdc, GC gc) {
* The fix is temporarily reparent the window to the desktop,
* call PrintWindow() then reparent the window back.
*/
- long /*int*/ hwndParent = OS.GetParent (hwnd);
- long /*int*/ hwndShell = hwndParent;
+ long hwndParent = OS.GetParent (hwnd);
+ long hwndShell = hwndParent;
while (OS.GetParent (hwndShell) != 0) {
if (OS.GetWindow (hwndShell, OS.GW_OWNER) != 0) break;
hwndShell = OS.GetParent (hwndShell);
@@ -2315,8 +2302,8 @@ void printWidget (long /*int*/ hwnd, long /*int*/ hdc, GC gc) {
* back.
*/
if (!fixPrintWindow) {
- long /*int*/ rgn = OS.CreateRectRgn(0, 0, 0, 0);
- long /*int*/ parent = OS.GetParent(hwnd);
+ long rgn = OS.CreateRectRgn(0, 0, 0, 0);
+ long parent = OS.GetParent(hwnd);
while (parent != hwndShell && !fixPrintWindow) {
if (OS.GetWindowRgn(parent, rgn) != 0) {
fixPrintWindow = true;
@@ -2327,7 +2314,7 @@ void printWidget (long /*int*/ hwnd, long /*int*/ hdc, GC gc) {
}
int bits1 = OS.GetWindowLong (hwnd, OS.GWL_STYLE);
int bits2 = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE);
- long /*int*/ hwndInsertAfter = OS.GetWindow (hwnd, OS.GW_HWNDPREV);
+ long hwndInsertAfter = OS.GetWindow (hwnd, OS.GW_HWNDPREV);
/*
* Bug in Windows. For some reason, when GetWindow ()
* with GW_HWNDPREV is used to query the previous window
@@ -2441,16 +2428,9 @@ public void requestLayout () {
*/
public void redraw () {
checkWidget ();
- redraw (false);
+ redrawInPixels (null,false);
}
-void redraw (boolean all) {
-// checkWidget ();
- if (!OS.IsWindowVisible (handle)) return;
- int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;
- if (all) flags |= OS.RDW_ALLCHILDREN;
- OS.RedrawWindow (handle, null, 0, flags);
-}
/**
* Causes the rectangular area of the receiver specified by
* the arguments to be marked as needing to be redrawn.
@@ -2494,15 +2474,23 @@ public void redraw (int x, int y, int width, int height, boolean all) {
y = DPIUtil.autoScaleUp(y);
width = DPIUtil.autoScaleUp(width);
height = DPIUtil.autoScaleUp(height);
- redrawInPixels(x, y, width, height, all);
-}
-
-void redrawInPixels (int x, int y, int width, int height, boolean all) {
if (width <= 0 || height <= 0) return;
- if (!OS.IsWindowVisible (handle)) return;
+
RECT rect = new RECT ();
OS.SetRect (rect, x, y, x + width, y + height);
- int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;
+
+ redrawInPixels(rect, all);
+}
+
+void redrawInPixels (RECT rect, boolean all) {
+ if (!OS.IsWindowVisible (handle)) return;
+ /*
+ * For many years, it also used RDW_FRAME here for no apparent reason.
+ * This caused Bug 565613, and also is a performance issue. Should the
+ * need for RDW_FRAME arise again, add a function parameter and only
+ * use it where it is indeed necessary.
+ */
+ int flags = OS.RDW_ERASE | OS.RDW_INVALIDATE;
if (all) flags |= OS.RDW_ALLCHILDREN;
OS.RedrawWindow (handle, rect, 0, flags);
}
@@ -2545,9 +2533,6 @@ void releaseParent () {
@Override
void releaseWidget () {
super.releaseWidget ();
- if (OS.IsDBLocale) {
- OS.ImmAssociateContext (handle, 0);
- }
if (toolTipText != null) {
setToolTipText (getShell (), null);
}
@@ -2932,7 +2917,7 @@ int resolveTextDirection() {
}
void showWidget (boolean visible) {
- long /*int*/ topHandle = topHandle ();
+ long topHandle = topHandle ();
OS.ShowWindow (topHandle, visible ? OS.SW_SHOW : OS.SW_HIDE);
if (handle != topHandle) OS.ShowWindow (handle, visible ? OS.SW_SHOW : OS.SW_HIDE);
}
@@ -2995,7 +2980,7 @@ boolean sendGestureEvent (GESTUREINFO gi) {
case OS.GID_ZOOM:
type = SWT.Gesture;
event.detail = SWT.GESTURE_MAGNIFY;
- int fingerDistance = OS.LODWORD (gi.ullArguments);
+ int fingerDistance = (int)gi.ullArguments;
if ((gi.dwFlags & OS.GF_BEGIN) != 0) {
event.detail = SWT.GESTURE_BEGIN;
display.magStartDistance = display.lastDistance = fingerDistance;
@@ -3030,7 +3015,7 @@ boolean sendGestureEvent (GESTUREINFO gi) {
case OS.GID_ROTATE:
type = SWT.Gesture;
event.detail = SWT.GESTURE_ROTATE;
- double rotationInRadians = OS.GID_ROTATE_ANGLE_FROM_ARGUMENT (OS.LODWORD (gi.ullArguments));
+ double rotationInRadians = OS.GID_ROTATE_ANGLE_FROM_ARGUMENT (gi.ullArguments);
if ((gi.dwFlags & OS.GF_BEGIN) != 0) {
event.detail = SWT.GESTURE_BEGIN;
display.rotationAngle = rotationInRadians;
@@ -3051,7 +3036,7 @@ boolean sendGestureEvent (GESTUREINFO gi) {
break;
}
- if (type == 0) return true;
+ if (type == 0) return true;
setInputState (event, type);
sendEvent (type, event);
return event.doit;
@@ -3081,8 +3066,8 @@ void sendTouchEvent (TOUCHINPUT touchInput []) {
if ((ti.dwFlags & OS.TOUCHEVENTF_UP) != 0) state = SWT.TOUCHSTATE_UP;
if ((ti.dwFlags & OS.TOUCHEVENTF_MOVE) != 0) state = SWT.TOUCHSTATE_MOVE;
boolean primary = (ti.dwFlags & OS.TOUCHEVENTF_PRIMARY) != 0;
- int x = (int)OS.TOUCH_COORD_TO_PIXEL (ti.x);
- int y = (int)OS.TOUCH_COORD_TO_PIXEL (ti.y);
+ int x = OS.TOUCH_COORD_TO_PIXEL (ti.x);
+ int y = OS.TOUCH_COORD_TO_PIXEL (ti.y);
touches [i] = new Touch (ti.dwID, inputSource, state, primary, x, y);
}
event.touches = touches;
@@ -3178,7 +3163,7 @@ public void setBackgroundImage (Image image) {
updateBackgroundImage ();
}
-void setBackgroundImage (long /*int*/ hBitmap) {
+void setBackgroundImage (long hBitmap) {
int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;
OS.RedrawWindow (handle, null, 0, flags);
}
@@ -3244,7 +3229,7 @@ void setBoundsInPixels (int x, int y, int width, int height, int flags, boolean
}
}
}
- long /*int*/ topHandle = topHandle ();
+ long topHandle = topHandle ();
if (defer && parent != null) {
forceResize ();
if (parent.lpwp != null) {
@@ -3331,7 +3316,7 @@ public void setCapture (boolean capture) {
}
void setCursor () {
- long /*int*/ lParam = OS.MAKELPARAM (OS.HTCLIENT, OS.WM_MOUSEMOVE);
+ long lParam = OS.MAKELPARAM (OS.HTCLIENT, OS.WM_MOUSEMOVE);
OS.SendMessage (handle, OS.WM_SETCURSOR, handle, lParam);
}
@@ -3358,11 +3343,11 @@ public void setCursor (Cursor cursor) {
checkWidget ();
if (cursor != null && cursor.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
this.cursor = cursor;
- long /*int*/ hwndCursor = OS.GetCapture ();
+ long hwndCursor = OS.GetCapture ();
if (hwndCursor == 0) {
POINT pt = new POINT ();
if (!OS.GetCursorPos (pt)) return;
- long /*int*/ hwnd = hwndCursor = OS.WindowFromPoint (pt);
+ long hwnd = hwndCursor = OS.WindowFromPoint (pt);
while (hwnd != 0 && hwnd != handle) {
hwnd = OS.GetParent (hwnd);
}
@@ -3374,7 +3359,7 @@ public void setCursor (Cursor cursor) {
}
void setDefaultFont () {
- long /*int*/ hFont = display.getSystemFont ().handle;
+ long hFont = display.getSystemFont ().handle;
OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);
}
@@ -3473,7 +3458,7 @@ public boolean setFocus () {
*/
public void setFont (Font font) {
checkWidget ();
- long /*int*/ hFont = 0;
+ long hFont = 0;
if (font != null) {
if (font.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
hFont = font.handle;
@@ -3692,7 +3677,7 @@ public void setRedraw (boolean redraw) {
}
if (redraw) {
if (--drawCount == 0) {
- long /*int*/ topHandle = topHandle ();
+ long topHandle = topHandle ();
OS.SendMessage (topHandle, OS.WM_SETREDRAW, 1, 0);
if (handle != topHandle) OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
if ((state & HIDDEN) != 0) {
@@ -3706,7 +3691,7 @@ public void setRedraw (boolean redraw) {
}
} else {
if (drawCount++ == 0) {
- long /*int*/ topHandle = topHandle ();
+ long topHandle = topHandle ();
OS.SendMessage (topHandle, OS.WM_SETREDRAW, 0, 0);
if (handle != topHandle) OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
}
@@ -3733,7 +3718,7 @@ public void setRedraw (boolean redraw) {
public void setRegion (Region region) {
checkWidget ();
if (region != null && region.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- long /*int*/ hRegion = 0;
+ long hRegion = 0;
if (region != null) {
hRegion = OS.CreateRectRgn (0, 0, 0, 0);
OS.CombineRgn (hRegion, region.handle, hRegion, OS.RGN_OR);
@@ -3876,8 +3861,10 @@ public void setTextDirection(int textDirection) {
*/
public void setToolTipText (String string) {
checkWidget ();
- toolTipText = string;
- setToolTipText (getShell (), string);
+ if (!Objects.equals(string, toolTipText)) {
+ toolTipText = string;
+ setToolTipText (getShell (), string);
+ }
}
void setToolTipText (Shell shell, String string) {
@@ -3973,19 +3960,19 @@ void sort (int [] items) {
for (int gap=length/2; gap>0; gap/=2) {
for (int i=gap; i<length; i++) {
for (int j=i-gap; j>=0; j-=gap) {
- if (items [j] <= items [j + gap]) {
+ if (items [j] <= items [j + gap]) {
int swap = items [j];
items [j] = items [j + gap];
items [j + gap] = swap;
- }
- }
- }
+ }
+ }
+ }
}
}
void subclass () {
- long /*int*/ oldProc = windowProc ();
- long /*int*/ newProc = display.windowProc;
+ long oldProc = windowProc ();
+ long newProc = display.windowProc;
if (oldProc == newProc) return;
OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, newProc);
}
@@ -4108,7 +4095,7 @@ public Point toDisplay (Point point) {
return DPIUtil.autoScaleDown(toDisplayInPixels(point.x, point.y));
}
-long /*int*/ topHandle () {
+long topHandle () {
return handle;
}
@@ -4125,15 +4112,15 @@ boolean translateMnemonic (Event event, Control control) {
boolean translateMnemonic (MSG msg) {
if (msg.wParam < 0x20) return false;
- long /*int*/ hwnd = msg.hwnd;
+ long hwnd = msg.hwnd;
if (OS.GetKeyState (OS.VK_MENU) >= 0) {
- long /*int*/ code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
+ long code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
if ((code & OS.DLGC_WANTALLKEYS) != 0) return false;
if ((code & OS.DLGC_BUTTON) == 0) return false;
}
Decorations shell = menuShell ();
if (shell.isVisible () && shell.isEnabled ()) {
- display.lastAscii = (int)/*64*/msg.wParam;
+ display.lastAscii = (int)msg.wParam;
display.lastNull = display.lastDead = false;
Event event = new Event ();
event.detail = SWT.TRAVERSE_MNEMONIC;
@@ -4145,8 +4132,8 @@ boolean translateMnemonic (MSG msg) {
}
boolean translateTraversal (MSG msg) {
- long /*int*/ hwnd = msg.hwnd;
- int key = (int)/*64*/msg.wParam;
+ long hwnd = msg.hwnd;
+ int key = (int)msg.wParam;
if (key == OS.VK_MENU) {
if ((msg.lParam & 0x40000000) == 0) {
OS.SendMessage (hwnd, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0);
@@ -4161,7 +4148,7 @@ boolean translateTraversal (MSG msg) {
case OS.VK_ESCAPE: {
all = true;
lastAscii = 27;
- long /*int*/ code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
+ long code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
if ((code & OS.DLGC_WANTALLKEYS) != 0) {
/*
* Use DLGC_HASSETSEL to determine that the control
@@ -4178,7 +4165,7 @@ boolean translateTraversal (MSG msg) {
case OS.VK_RETURN: {
all = true;
lastAscii = '\r';
- long /*int*/ code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
+ long code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
if ((code & OS.DLGC_WANTALLKEYS) != 0) doit = false;
detail = SWT.TRAVERSE_RETURN;
break;
@@ -4186,7 +4173,7 @@ boolean translateTraversal (MSG msg) {
case OS.VK_TAB: {
lastAscii = '\t';
boolean next = OS.GetKeyState (OS.VK_SHIFT) >= 0;
- long /*int*/ code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
+ long code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
if ((code & (OS.DLGC_WANTTAB | OS.DLGC_WANTALLKEYS)) != 0) {
/*
* Use DLGC_HASSETSEL to determine that the control is a
@@ -4212,7 +4199,7 @@ boolean translateTraversal (MSG msg) {
case OS.VK_DOWN:
case OS.VK_RIGHT: {
lastVirtual = true;
- long /*int*/ code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
+ long code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
if ((code & (OS.DLGC_WANTARROWS /*| OS.DLGC_WANTALLKEYS*/)) != 0) doit = false;
boolean next = key == OS.VK_DOWN || key == OS.VK_RIGHT;
if (parent != null && (parent.style & SWT.MIRRORED) != 0) {
@@ -4226,7 +4213,7 @@ boolean translateTraversal (MSG msg) {
all = true;
lastVirtual = true;
if (OS.GetKeyState (OS.VK_CONTROL) >= 0) return false;
- long /*int*/ code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
+ long code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
if ((code & OS.DLGC_WANTALLKEYS) != 0) {
/*
* Use DLGC_HASSETSEL to determine that the control is a
@@ -4563,8 +4550,8 @@ boolean traverseReturn () {
}
void unsubclass () {
- long /*int*/ newProc = windowProc ();
- long /*int*/ oldProc = display.windowProc;
+ long newProc = windowProc ();
+ long oldProc = display.windowProc;
if (oldProc == newProc) return;
OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, newProc);
}
@@ -4574,9 +4561,12 @@ void unsubclass () {
* to be processed before this method returns. If there
* are no outstanding paint request, this method does
* nothing.
- * <p>
- * Note: This method does not cause a redraw.
- * </p>
+ * <p>Note:</p>
+ * <ul>
+ * <li>This method does not cause a redraw.</li>
+ * <li>Some OS versions forcefully perform automatic deferred painting.
+ * This method does nothing in that case.</li>
+ * </ul>
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
@@ -4678,38 +4668,30 @@ CREATESTRUCT widgetCreateStruct () {
int widgetExtStyle () {
int bits = 0;
- if ((style & SWT.BORDER) != 0) bits |= OS.WS_EX_CLIENTEDGE;
-// if ((style & SWT.BORDER) != 0) {
-// if ((style & SWT.FLAT) == 0) bits |= OS.WS_EX_CLIENTEDGE;
-// }
+
+ if (!isUseWsBorder ()) {
+ if ((style & SWT.BORDER) != 0) bits |= OS.WS_EX_CLIENTEDGE;
+ }
+
bits |= OS.WS_EX_NOINHERITLAYOUT;
if ((style & SWT.RIGHT_TO_LEFT) != 0) bits |= OS.WS_EX_LAYOUTRTL;
if ((style & SWT.FLIP_TEXT_DIRECTION) != 0) bits |= OS.WS_EX_RTLREADING;
return bits;
}
-long /*int*/ widgetParent () {
+long widgetParent () {
return parent.handle;
}
int widgetStyle () {
/* Force clipping of siblings by setting WS_CLIPSIBLINGS */
int bits = OS.WS_CHILD | OS.WS_VISIBLE | OS.WS_CLIPSIBLINGS;
-// if ((style & SWT.BORDER) != 0) {
-// if ((style & SWT.FLAT) != 0) bits |= OS.WS_BORDER;
-// }
- return bits;
- /*
- * This code is intentionally commented. When clipping
- * of both siblings and children is not enforced, it is
- * possible for application code to draw outside of the
- * control.
- */
-// int bits = OS.WS_CHILD | OS.WS_VISIBLE;
-// if ((style & SWT.CLIP_SIBLINGS) != 0) bits |= OS.WS_CLIPSIBLINGS;
-// if ((style & SWT.CLIP_CHILDREN) != 0) bits |= OS.WS_CLIPCHILDREN;
-// return bits;
+ if (isUseWsBorder ()) {
+ if ((style & SWT.BORDER) != 0) bits |= OS.WS_BORDER;
+ }
+
+ return bits;
}
/**
@@ -4741,7 +4723,7 @@ public boolean setParent (Composite parent) {
Menu [] menus = oldShell.findMenus (this);
fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
}
- long /*int*/ topHandle = topHandle ();
+ long topHandle = topHandle ();
if (OS.SetParent (topHandle, parent.handle) == 0) return false;
this.parent = parent;
int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
@@ -4752,9 +4734,9 @@ public boolean setParent (Composite parent) {
abstract TCHAR windowClass ();
-abstract long /*int*/ windowProc ();
+abstract long windowProc ();
-long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long windowProc (long hwnd, int msg, long wParam, long lParam) {
Display display = this.display;
LRESULT result = null;
switch (msg) {
@@ -4819,13 +4801,15 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
case OS.WM_NCPAINT: result = WM_NCPAINT (wParam, lParam); break;
case OS.WM_NOTIFY: result = WM_NOTIFY (wParam, lParam); break;
case OS.WM_PAINT: result = WM_PAINT (wParam, lParam); break;
- case OS.WM_PALETTECHANGED: result = WM_PALETTECHANGED (wParam, lParam); break;
+ case OS.WM_ENTERMENULOOP: result = WM_ENTERMENULOOP (wParam, lParam); break;
+ case OS.WM_EXITMENULOOP: result = WM_EXITMENULOOP (wParam, lParam); break;
+ case OS.WM_ENTERSIZEMOVE: result = WM_ENTERSIZEMOVE (wParam, lParam); break;
+ case OS.WM_EXITSIZEMOVE: result = WM_EXITSIZEMOVE (wParam, lParam); break;
case OS.WM_PARENTNOTIFY: result = WM_PARENTNOTIFY (wParam, lParam); break;
case OS.WM_PASTE: result = WM_PASTE (wParam, lParam); break;
case OS.WM_PRINT: result = WM_PRINT (wParam, lParam); break;
case OS.WM_PRINTCLIENT: result = WM_PRINTCLIENT (wParam, lParam); break;
case OS.WM_QUERYENDSESSION: result = WM_QUERYENDSESSION (wParam, lParam); break;
- case OS.WM_QUERYNEWPALETTE: result = WM_QUERYNEWPALETTE (wParam, lParam); break;
case OS.WM_QUERYOPEN: result = WM_QUERYOPEN (wParam, lParam); break;
case OS.WM_RBUTTONDBLCLK: result = WM_RBUTTONDBLCLK (wParam, lParam); break;
case OS.WM_RBUTTONDOWN: result = WM_RBUTTONDOWN (wParam, lParam); break;
@@ -4867,32 +4851,32 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
}
}
-LRESULT WM_ACTIVATE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ACTIVATE (long wParam, long lParam) {
return null;
}
-LRESULT WM_CAPTURECHANGED (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CAPTURECHANGED (long wParam, long lParam) {
return wmCaptureChanged (handle, wParam, lParam);
}
-LRESULT WM_CHANGEUISTATE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CHANGEUISTATE (long wParam, long lParam) {
if ((state & IGNORE_WM_CHANGEUISTATE) != 0) return LRESULT.ZERO;
return null;
}
-LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CHAR (long wParam, long lParam) {
return wmChar (handle, wParam, lParam);
}
-LRESULT WM_CLEAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CLEAR (long wParam, long lParam) {
return null;
}
-LRESULT WM_CLOSE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CLOSE (long wParam, long lParam) {
return null;
}
-LRESULT WM_COMMAND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_COMMAND (long wParam, long lParam) {
/*
* When the WM_COMMAND message is sent from a
* menu, the HWND parameter in LPARAM is zero.
@@ -4913,31 +4897,26 @@ LRESULT WM_COMMAND (long /*int*/ wParam, long /*int*/ lParam) {
return control.wmCommandChild (wParam, lParam);
}
-LRESULT WM_CONTEXTMENU (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CONTEXTMENU (long wParam, long lParam) {
return wmContextMenu (handle, wParam, lParam);
}
-LRESULT WM_CTLCOLOR (long /*int*/ wParam, long /*int*/ lParam) {
- long /*int*/ hPalette = display.hPalette;
- if (hPalette != 0) {
- OS.SelectPalette (wParam, hPalette, false);
- OS.RealizePalette (wParam);
- }
+LRESULT WM_CTLCOLOR (long wParam, long lParam) {
Control control = display.getControl (lParam);
if (control == null) return null;
return control.wmColorChild (wParam, lParam);
}
-LRESULT WM_CUT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CUT (long wParam, long lParam) {
return null;
}
-LRESULT WM_DESTROY (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_DESTROY (long wParam, long lParam) {
OS.KillTimer (this.handle, Menu.ID_TOOLTIP_TIMER);
return null;
}
-LRESULT WM_DPICHANGED (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_DPICHANGED (long wParam, long lParam) {
// Map DPI to Zoom and compare
int nativeZoom = DPIUtil.mapDPIToZoom (OS.HIWORD (wParam));
int newSWTZoom = DPIUtil.getZoomForAutoscaleProperty (nativeZoom);
@@ -4956,7 +4935,7 @@ LRESULT WM_DPICHANGED (long /*int*/ wParam, long /*int*/ lParam) {
return LRESULT.ONE;
}
-LRESULT WM_DRAWITEM (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_DRAWITEM (long wParam, long lParam) {
DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ();
OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof);
if (struct.CtlType == OS.ODT_MENU) {
@@ -4969,15 +4948,25 @@ LRESULT WM_DRAWITEM (long /*int*/ wParam, long /*int*/ lParam) {
return control.wmDrawChild (wParam, lParam);
}
-LRESULT WM_ENDSESSION (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ENDSESSION (long wParam, long lParam) {
return null;
}
-LRESULT WM_ENTERIDLE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ENTERIDLE (long wParam, long lParam) {
return null;
}
-LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ENTERMENULOOP (long wParam, long lParam) {
+ display.externalEventLoop = true;
+ return null;
+}
+
+LRESULT WM_ENTERSIZEMOVE (long wParam, long lParam) {
+ display.externalEventLoop = true;
+ return null;
+}
+
+LRESULT WM_ERASEBKGND (long wParam, long lParam) {
if ((state & DRAW_BACKGROUND) != 0) {
if (findImageControl () != null) return LRESULT.ONE;
}
@@ -4989,7 +4978,17 @@ LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT WM_GESTURE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_EXITMENULOOP (long wParam, long lParam) {
+ display.externalEventLoop = false;
+ return null;
+}
+
+LRESULT WM_EXITSIZEMOVE (long wParam, long lParam) {
+ display.externalEventLoop = false;
+ return null;
+}
+
+LRESULT WM_GESTURE (long wParam, long lParam) {
if (hooks (SWT.Gesture) || filters (SWT.Gesture)) {
GESTUREINFO gi = new GESTUREINFO ();
gi.cbSize = GESTUREINFO.sizeof;
@@ -5003,31 +5002,31 @@ LRESULT WM_GESTURE (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETDLGCODE (long wParam, long lParam) {
return null;
}
-LRESULT WM_GETFONT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETFONT (long wParam, long lParam) {
return null;
}
-LRESULT WM_GETOBJECT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETOBJECT (long wParam, long lParam) {
if (accessible != null) {
- long /*int*/ result = accessible.internal_WM_GETOBJECT (wParam, lParam);
+ long result = accessible.internal_WM_GETOBJECT (wParam, lParam);
if (result != 0) return new LRESULT (result);
}
return null;
}
-LRESULT WM_GETMINMAXINFO (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETMINMAXINFO (long wParam, long lParam) {
return null;
}
-LRESULT WM_HOTKEY (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_HOTKEY (long wParam, long lParam) {
return null;
}
-LRESULT WM_HELP (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_HELP (long wParam, long lParam) {
HELPINFO lphi = new HELPINFO ();
OS.MoveMemory (lphi, lParam, HELPINFO.sizeof);
Decorations shell = menuShell ();
@@ -5043,7 +5042,7 @@ LRESULT WM_HELP (long /*int*/ wParam, long /*int*/ lParam) {
if (menu.hooks (SWT.Help)) widget = menu;
}
if (widget != null) {
- long /*int*/ hwndShell = shell.handle;
+ long hwndShell = shell.handle;
OS.SendMessage (hwndShell, OS.WM_CANCELMODE, 0, 0);
widget.postEvent (SWT.Help);
return LRESULT.ONE;
@@ -5058,29 +5057,29 @@ LRESULT WM_HELP (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT WM_HSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_HSCROLL (long wParam, long lParam) {
Control control = display.getControl (lParam);
if (control == null) return null;
return control.wmScrollChild (wParam, lParam);
}
-LRESULT WM_IME_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_IME_CHAR (long wParam, long lParam) {
return wmIMEChar (handle, wParam, lParam);
}
-LRESULT WM_IME_COMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_IME_COMPOSITION (long wParam, long lParam) {
return null;
}
-LRESULT WM_IME_COMPOSITION_START (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_IME_COMPOSITION_START (long wParam, long lParam) {
return null;
}
-LRESULT WM_IME_ENDCOMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_IME_ENDCOMPOSITION (long wParam, long lParam) {
return null;
}
-LRESULT WM_UNINITMENUPOPUP (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_UNINITMENUPOPUP (long wParam, long lParam) {
Menu hiddenMenu = menuShell ().findMenu (wParam);
if (hiddenMenu != null) {
Shell shell = getShell ();
@@ -5090,7 +5089,7 @@ LRESULT WM_UNINITMENUPOPUP (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT WM_INITMENUPOPUP (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_INITMENUPOPUP (long wParam, long lParam) {
/* Ignore WM_INITMENUPOPUP for an accelerator */
if (display.accelKeyHit) return null;
@@ -5147,48 +5146,54 @@ LRESULT WM_INITMENUPOPUP (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT WM_INPUTLANGCHANGE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_INPUTLANGCHANGE (long wParam, long lParam) {
menuShell().destroyAccelerators();
return null;
}
-LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KEYDOWN (long wParam, long lParam) {
return wmKeyDown (handle, wParam, lParam);
}
-LRESULT WM_KEYUP (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KEYUP (long wParam, long lParam) {
return wmKeyUp (handle, wParam, lParam);
}
-LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KILLFOCUS (long wParam, long lParam) {
+ /*
+ * Feature in Windows. File and directory dialogs might reset focus
+ * to NULL before they open. As a result, Shell is unable to save
+ * focus control in WM_ACTIVATE. The fix is to save focus here.
+ */
+ if (wParam == 0) menuShell().setSavedFocus(this);
return wmKillFocus (handle, wParam, lParam);
}
-LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDBLCLK (long wParam, long lParam) {
return wmLButtonDblClk (handle, wParam, lParam);
}
-LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDOWN (long wParam, long lParam) {
return wmLButtonDown (handle, wParam, lParam);
}
-LRESULT WM_LBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONUP (long wParam, long lParam) {
return wmLButtonUp (handle, wParam, lParam);
}
-LRESULT WM_MBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MBUTTONDBLCLK (long wParam, long lParam) {
return wmMButtonDblClk (handle, wParam, lParam);
}
-LRESULT WM_MBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MBUTTONDOWN (long wParam, long lParam) {
return wmMButtonDown (handle, wParam, lParam);
}
-LRESULT WM_MBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MBUTTONUP (long wParam, long lParam) {
return wmMButtonUp (handle, wParam, lParam);
}
-LRESULT WM_MEASUREITEM (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MEASUREITEM (long wParam, long lParam) {
MEASUREITEMSTRUCT struct = new MEASUREITEMSTRUCT ();
OS.MoveMemory (struct, lParam, MEASUREITEMSTRUCT.sizeof);
if (struct.CtlType == OS.ODT_MENU) {
@@ -5196,13 +5201,13 @@ LRESULT WM_MEASUREITEM (long /*int*/ wParam, long /*int*/ lParam) {
if (item == null) return null;
return item.wmMeasureChild (wParam, lParam);
}
- long /*int*/ hwnd = OS.GetDlgItem (handle, struct.CtlID);
+ long hwnd = OS.GetDlgItem (handle, struct.CtlID);
Control control = display.getControl (hwnd);
if (control == null) return null;
return control.wmMeasureChild (wParam, lParam);
}
-LRESULT WM_MENUCHAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MENUCHAR (long wParam, long lParam) {
/*
* Feature in Windows. When the user types Alt+<key>
* and <key> does not match a mnemonic in the System
@@ -5219,7 +5224,7 @@ LRESULT WM_MENUCHAR (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT WM_MENUSELECT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MENUSELECT (long wParam, long lParam) {
int code = OS.HIWORD (wParam);
Shell shell = getShell ();
OS.KillTimer (this.handle, Menu.ID_TOOLTIP_TIMER);
@@ -5292,32 +5297,32 @@ LRESULT WM_MENUSELECT (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT WM_MOUSEACTIVATE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSEACTIVATE (long wParam, long lParam) {
return null;
}
-LRESULT WM_MOUSEHOVER (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSEHOVER (long wParam, long lParam) {
return wmMouseHover (handle, wParam, lParam);
}
-LRESULT WM_MOUSELEAVE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSELEAVE (long wParam, long lParam) {
getShell ().fixToolTip ();
return wmMouseLeave (handle, wParam, lParam);
}
-LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSEMOVE (long wParam, long lParam) {
return wmMouseMove (handle, wParam, lParam);
}
-LRESULT WM_MOUSEWHEEL (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSEWHEEL (long wParam, long lParam) {
return wmMouseWheel (handle, wParam, lParam);
}
-LRESULT WM_MOUSEHWHEEL (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSEHWHEEL (long wParam, long lParam) {
return wmMouseHWheel (handle, wParam, lParam);
}
-LRESULT WM_MOVE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOVE (long wParam, long lParam) {
state |= MOVE_OCCURRED;
if (findImageControl () != null) {
if (this != getShell ()) redrawChildren ();
@@ -5335,86 +5340,78 @@ LRESULT WM_MOVE (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT WM_NCACTIVATE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NCACTIVATE (long wParam, long lParam) {
return null;
}
-LRESULT WM_NCCALCSIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NCCALCSIZE (long wParam, long lParam) {
return null;
}
-LRESULT WM_NCHITTEST (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NCHITTEST (long wParam, long lParam) {
if (!OS.IsWindowEnabled (handle)) return null;
if (!isActive ()) return new LRESULT (OS.HTTRANSPARENT);
return null;
}
-LRESULT WM_NCLBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NCLBUTTONDOWN (long wParam, long lParam) {
return null;
}
-LRESULT WM_NCPAINT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NCPAINT (long wParam, long lParam) {
return wmNCPaint (handle, wParam, lParam);
}
-LRESULT WM_NOTIFY (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NOTIFY (long wParam, long lParam) {
NMHDR hdr = new NMHDR ();
OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
return wmNotify (hdr, wParam, lParam);
}
-LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PAINT (long wParam, long lParam) {
if ((state & DISPOSE_SENT) != 0) return LRESULT.ZERO;
return wmPaint (handle, wParam, lParam);
}
-LRESULT WM_PALETTECHANGED (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PARENTNOTIFY (long wParam, long lParam) {
return null;
}
-LRESULT WM_PARENTNOTIFY (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PASTE (long wParam, long lParam) {
return null;
}
-LRESULT WM_PASTE (long /*int*/ wParam, long /*int*/ lParam) {
- return null;
-}
-
-LRESULT WM_PRINT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PRINT (long wParam, long lParam) {
return wmPrint (handle, wParam, lParam);
}
-LRESULT WM_PRINTCLIENT (long /*int*/ wParam, long /*int*/ lParam) {
- return null;
-}
-
-LRESULT WM_QUERYENDSESSION (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PRINTCLIENT (long wParam, long lParam) {
return null;
}
-LRESULT WM_QUERYNEWPALETTE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_QUERYENDSESSION (long wParam, long lParam) {
return null;
}
-LRESULT WM_QUERYOPEN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_QUERYOPEN (long wParam, long lParam) {
return null;
}
-LRESULT WM_RBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_RBUTTONDBLCLK (long wParam, long lParam) {
return wmRButtonDblClk (handle, wParam, lParam);
}
-LRESULT WM_RBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_RBUTTONDOWN (long wParam, long lParam) {
return wmRButtonDown (handle, wParam, lParam);
}
-LRESULT WM_RBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_RBUTTONUP (long wParam, long lParam) {
return wmRButtonUp (handle, wParam, lParam);
}
-LRESULT WM_SETCURSOR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETCURSOR (long wParam, long lParam) {
int hitTest = (short) OS.LOWORD (lParam);
- if (hitTest == OS.HTCLIENT) {
+ if (hitTest == OS.HTCLIENT) {
Control control = display.getControl (wParam);
if (control == null) return null;
Cursor cursor = control.findCursor ();
@@ -5426,42 +5423,42 @@ LRESULT WM_SETCURSOR (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFOCUS (long wParam, long lParam) {
return wmSetFocus (handle, wParam, lParam);
}
-LRESULT WM_SETTINGCHANGE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETTINGCHANGE (long wParam, long lParam) {
return null;
}
-LRESULT WM_SETFONT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFONT (long wParam, long lParam) {
return null;
}
-LRESULT WM_SETREDRAW (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETREDRAW (long wParam, long lParam) {
return null;
}
-LRESULT WM_SHOWWINDOW (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SHOWWINDOW (long wParam, long lParam) {
return null;
}
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
state |= RESIZE_OCCURRED;
if ((state & RESIZE_DEFERRED) == 0) sendEvent (SWT.Resize);
// widget could be disposed at this point
return null;
}
-LRESULT WM_SYSCHAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SYSCHAR (long wParam, long lParam) {
return wmSysChar (handle, wParam, lParam);
}
-LRESULT WM_SYSCOLORCHANGE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SYSCOLORCHANGE (long wParam, long lParam) {
return null;
}
-LRESULT WM_SYSCOMMAND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SYSCOMMAND (long wParam, long lParam) {
/*
* Check to see if the command is a system command or
* a user menu item that was added to the System menu.
@@ -5480,7 +5477,7 @@ LRESULT WM_SYSCOMMAND (long /*int*/ wParam, long /*int*/ lParam) {
}
/* Process the System Command */
- int cmd = (int)/*64*/wParam & 0xFFF0;
+ int cmd = (int)wParam & 0xFFF0;
switch (cmd) {
case OS.SC_KEYMENU:
/*
@@ -5531,9 +5528,7 @@ LRESULT WM_SYSCOMMAND (long /*int*/ wParam, long /*int*/ lParam) {
char key = (char) lParam;
if (key != 0) {
key = Character.toUpperCase (key);
- MenuItem [] items = menu.getItems ();
- for (int i=0; i<items.length; i++) {
- MenuItem item = items [i];
+ for (MenuItem item : menu.getItems ()) {
String text = item.getText ();
char mnemonic = findMnemonic (text);
if (text.length () > 0 && mnemonic == 0) {
@@ -5571,19 +5566,19 @@ LRESULT WM_SYSCOMMAND (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT WM_SYSKEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SYSKEYDOWN (long wParam, long lParam) {
return wmSysKeyDown (handle, wParam, lParam);
}
-LRESULT WM_SYSKEYUP (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SYSKEYUP (long wParam, long lParam) {
return wmSysKeyUp (handle, wParam, lParam);
}
-LRESULT WM_TABLET_FLICK (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_TABLET_FLICK (long wParam, long lParam) {
if (!hooks (SWT.Gesture) && !filters (SWT.Gesture)) return null;
Event event = new Event ();
FLICK_DATA fData = new FLICK_DATA ();
- long /*int*/ [] source = new long /*int*/ [1];
+ long [] source = new long [1];
source[0] = wParam;
OS.MoveMemory (fData, source, OS.FLICK_DATA_sizeof ());
FLICK_POINT fPoint = new FLICK_POINT ();
@@ -5632,12 +5627,12 @@ LRESULT WM_TABLET_FLICK (long /*int*/ wParam, long /*int*/ lParam) {
return event.doit ? null : LRESULT.ONE;
}
-LRESULT WM_TOUCH (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_TOUCH (long wParam, long lParam) {
LRESULT result = null;
if (hooks (SWT.Touch) || filters (SWT.Touch)) {
int cInputs = OS.LOWORD (wParam);
- long /*int*/ hHeap = OS.GetProcessHeap ();
- long /*int*/ pInputs = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, cInputs * TOUCHINPUT.sizeof);
+ long hHeap = OS.GetProcessHeap ();
+ long pInputs = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, cInputs * TOUCHINPUT.sizeof);
if (pInputs != 0) {
if (OS.GetTouchInputInfo (lParam, cInputs, pInputs, TOUCHINPUT.sizeof)) {
TOUCHINPUT ti [] = new TOUCHINPUT [cInputs];
@@ -5655,7 +5650,7 @@ LRESULT WM_TOUCH (long /*int*/ wParam, long /*int*/ lParam) {
return result;
}
-LRESULT WM_TIMER (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_TIMER (long wParam, long lParam) {
if (wParam == Menu.ID_TOOLTIP_TIMER && activeMenu != null) {
OS.KillTimer (this.handle, Menu.ID_TOOLTIP_TIMER);
activeMenu.wmTimer (wParam, lParam);
@@ -5663,31 +5658,31 @@ LRESULT WM_TIMER (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT WM_UNDO (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_UNDO (long wParam, long lParam) {
return null;
}
-LRESULT WM_UPDATEUISTATE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_UPDATEUISTATE (long wParam, long lParam) {
return null;
}
-LRESULT WM_VSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_VSCROLL (long wParam, long lParam) {
Control control = display.getControl (lParam);
if (control == null) return null;
return control.wmScrollChild (wParam, lParam);
}
-LRESULT WM_WINDOWPOSCHANGED (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_WINDOWPOSCHANGED (long wParam, long lParam) {
try {
display.resizeCount++;
- long /*int*/ code = callWindowProc (handle, OS.WM_WINDOWPOSCHANGED, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_WINDOWPOSCHANGED, wParam, lParam);
return code == 0 ? LRESULT.ZERO : new LRESULT (code);
} finally {
--display.resizeCount;
}
}
-LRESULT WM_WINDOWPOSCHANGING (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_WINDOWPOSCHANGING (long wParam, long lParam) {
/*
* Bug in Windows. When WM_SETREDRAW is used to turn off drawing
* for a control and the control is moved or resized, Windows does
@@ -5705,10 +5700,10 @@ LRESULT WM_WINDOWPOSCHANGING (long /*int*/ wParam, long /*int*/ lParam) {
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
if (width != 0 && height != 0) {
- long /*int*/ hwndParent = parent == null ? 0 : parent.handle;
+ long hwndParent = parent == null ? 0 : parent.handle;
OS.MapWindowPoints (0, hwndParent, rect, 2);
- long /*int*/ rgn1 = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom);
- long /*int*/ rgn2 = OS.CreateRectRgn (lpwp.x, lpwp.y, lpwp.x + lpwp.cx, lpwp.y + lpwp.cy);
+ long rgn1 = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom);
+ long rgn2 = OS.CreateRectRgn (lpwp.x, lpwp.y, lpwp.x + lpwp.cx, lpwp.y + lpwp.cy);
OS.CombineRgn (rgn1, rgn1, rgn2, OS.RGN_DIFF);
int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN;
OS.RedrawWindow (hwndParent, null, rgn1, flags);
@@ -5721,19 +5716,19 @@ LRESULT WM_WINDOWPOSCHANGING (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT WM_XBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_XBUTTONDBLCLK (long wParam, long lParam) {
return wmXButtonDblClk (handle, wParam, lParam);
}
-LRESULT WM_XBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_XBUTTONDOWN (long wParam, long lParam) {
return wmXButtonDown (handle, wParam, lParam);
}
-LRESULT WM_XBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_XBUTTONUP (long wParam, long lParam) {
return wmXButtonUp (handle, wParam, lParam);
}
-LRESULT wmColorChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmColorChild (long wParam, long lParam) {
Control control = findBackgroundControl ();
if (control == null) {
if ((state & THEME_BACKGROUND) != 0) {
@@ -5760,15 +5755,15 @@ LRESULT wmColorChild (long /*int*/ wParam, long /*int*/ lParam) {
if (control.backgroundImage != null) {
RECT rect = new RECT ();
OS.GetClientRect (handle, rect);
- long /*int*/ hwnd = control.handle;
- long /*int*/ hBitmap = control.backgroundImage.handle;
+ long hwnd = control.handle;
+ long hBitmap = control.backgroundImage.handle;
OS.MapWindowPoints (handle, hwnd, rect, 2);
POINT lpPoint = new POINT ();
OS.GetWindowOrgEx (wParam, lpPoint);
OS.SetBrushOrgEx (wParam, -rect.left - lpPoint.x, -rect.top - lpPoint.y, lpPoint);
- long /*int*/ hBrush = findBrush (hBitmap, OS.BS_PATTERN);
+ long hBrush = findBrush (hBitmap, OS.BS_PATTERN);
if ((state & DRAW_BACKGROUND) != 0) {
- long /*int*/ hOldBrush = OS.SelectObject (wParam, hBrush);
+ long hOldBrush = OS.SelectObject (wParam, hBrush);
OS.MapWindowPoints (hwnd, handle, rect, 2);
OS.PatBlt (wParam, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY);
OS.SelectObject (wParam, hOldBrush);
@@ -5776,40 +5771,40 @@ LRESULT wmColorChild (long /*int*/ wParam, long /*int*/ lParam) {
OS.SetBkMode (wParam, OS.TRANSPARENT);
return new LRESULT (hBrush);
}
- long /*int*/ hBrush = findBrush (backPixel, OS.BS_SOLID);
+ long hBrush = findBrush (backPixel, OS.BS_SOLID);
if ((state & DRAW_BACKGROUND) != 0) {
RECT rect = new RECT ();
OS.GetClientRect (handle, rect);
- long /*int*/ hOldBrush = OS.SelectObject (wParam, hBrush);
+ long hOldBrush = OS.SelectObject (wParam, hBrush);
OS.PatBlt (wParam, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY);
OS.SelectObject (wParam, hOldBrush);
}
return new LRESULT (hBrush);
}
-LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmCommandChild (long wParam, long lParam) {
return null;
}
-LRESULT wmDrawChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmDrawChild (long wParam, long lParam) {
return null;
}
-LRESULT wmMeasureChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmMeasureChild (long wParam, long lParam) {
return null;
}
-LRESULT wmNotify (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotify (NMHDR hdr, long wParam, long lParam) {
Control control = display.getControl (hdr.hwndFrom);
if (control == null) return null;
return control.wmNotifyChild (hdr, wParam, lParam);
}
-LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) {
return null;
}
-LRESULT wmScrollChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmScrollChild (long wParam, long lParam) {
return null;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
index 296641ef03..ec12e6c504 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
@@ -52,13 +52,9 @@ public class CoolBar extends Composite {
CoolItem [] originalItems;
boolean locked;
boolean ignoreResize;
- static final long /*int*/ ReBarProc;
+ static final long ReBarProc;
static final TCHAR ReBarClass = new TCHAR (0, OS.REBARCLASSNAME, true);
static {
- INITCOMMONCONTROLSEX icex = new INITCOMMONCONTROLSEX ();
- icex.dwSize = INITCOMMONCONTROLSEX.sizeof;
- icex.dwICC = OS.ICC_COOL_CLASSES;
- OS.InitCommonControlsEx (icex);
WNDCLASS lpWndClass = new WNDCLASS ();
OS.GetClassInfo (0, ReBarClass, lpWndClass);
ReBarProc = lpWndClass.lpfnWndProc;
@@ -122,7 +118,7 @@ public CoolBar (Composite parent, int style) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
return OS.CallWindowProc (ReBarProc, hwnd, msg, wParam, lParam);
}
@@ -149,7 +145,7 @@ protected void checkSubclass () {
int border = getBorderWidthInPixels ();
int newWidth = wHint == SWT.DEFAULT ? 0x3FFF : wHint + (border * 2);
int newHeight = hHint == SWT.DEFAULT ? 0x3FFF : hHint + (border * 2);
- int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
if (count != 0) {
ignoreResize = true;
boolean redraw = false;
@@ -217,12 +213,12 @@ void createHandle () {
* The control will not destroy a font that it did not
* create.
*/
- long /*int*/ hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ long hFont = OS.GetStockObject (OS.SYSTEM_FONT);
OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);
}
void createItem (CoolItem item, int index) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
int id = 0;
while (id < items.length && items [id] != null) id++;
@@ -231,8 +227,8 @@ void createItem (CoolItem item, int index) {
System.arraycopy (items, 0, newItems, 0, items.length);
items = newItems;
}
- long /*int*/ hHeap = OS.GetProcessHeap ();
- long /*int*/ lpText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof);
+ long hHeap = OS.GetProcessHeap ();
+ long lpText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof);
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_TEXT | OS.RBBIM_STYLE | OS.RBBIM_ID;
@@ -297,8 +293,8 @@ void createWidget () {
}
void destroyItem (CoolItem item) {
- int index = (int)/*64*/OS.SendMessage (handle, OS.RB_IDTOINDEX, item.id, 0);
- int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int index = (int)OS.SendMessage (handle, OS.RB_IDTOINDEX, item.id, 0);
+ int count = (int)OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
if (count != 0) {
int lastIndex = getLastIndexOfRow (index);
if (index == lastIndex) {
@@ -363,7 +359,7 @@ void destroyItem (CoolItem item) {
}
@Override
-void drawThemeBackground (long /*int*/ hDC, long /*int*/ hwnd, RECT rect) {
+void drawThemeBackground (long hDC, long hwnd, RECT rect) {
if (OS.IsAppThemed ()) {
if (background == -1 && (style & SWT.FLAT) != 0) {
Control control = findBackgroundControl ();
@@ -439,7 +435,7 @@ int getMargin (int index) {
*/
public CoolItem getItem (int index) {
checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
@@ -460,7 +456,7 @@ public CoolItem getItem (int index) {
*/
public int getItemCount () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ return (int)OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
}
/**
@@ -486,7 +482,7 @@ public int getItemCount () {
*/
public int [] getItemOrder () {
checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
int [] indices = new int [count];
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
@@ -523,7 +519,7 @@ public int [] getItemOrder () {
*/
public CoolItem [] getItems () {
checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
CoolItem [] result = new CoolItem [count];
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
@@ -559,7 +555,7 @@ public Point [] getItemSizes () {
}
Point [] getItemSizesInPixels () {
- int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
Point [] sizes = new Point [count];
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
@@ -584,7 +580,7 @@ Point [] getItemSizesInPixels () {
}
int getLastIndexOfRow (int index) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
if (count == 0) return -1;
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
@@ -599,7 +595,7 @@ int getLastIndexOfRow (int index) {
}
boolean isLastItemOfRow (int index) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
if (index + 1 == count) return true;
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
@@ -674,7 +670,7 @@ public int indexOf (CoolItem item) {
checkWidget ();
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- return (int)/*64*/OS.SendMessage (handle, OS.RB_IDTOINDEX, item.id, 0);
+ return (int)OS.SendMessage (handle, OS.RB_IDTOINDEX, item.id, 0);
}
void resizeToPreferredWidth (int index) {
@@ -683,7 +679,7 @@ void resizeToPreferredWidth (int index) {
* with an index out of range, Windows GP's. The
* fix is to ensure the index is in range.
*/
- int count = (int)/*64*/OS.SendMessage(handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int count = (int)OS.SendMessage(handle, OS.RB_GETBANDCOUNT, 0, 0);
if (0 <= index && index < count) {
REBARBANDINFO rbBand = new REBARBANDINFO();
rbBand.cbSize = REBARBANDINFO.sizeof;
@@ -709,8 +705,7 @@ void resizeToMaximumWidth (int index) {
@Override
void releaseChildren (boolean destroy) {
if (items != null) {
- for (int i=0; i<items.length; i++) {
- CoolItem item = items [i];
+ for (CoolItem item : items) {
if (item != null && !item.isDisposed ()) {
item.release (false);
}
@@ -723,8 +718,7 @@ void releaseChildren (boolean destroy) {
@Override
void removeControl (Control control) {
super.removeControl (control);
- for (int i=0; i<items.length; i++) {
- CoolItem item = items [i];
+ for (CoolItem item : items) {
if (item != null && item.control == control) {
item.setControl (null);
}
@@ -734,8 +728,7 @@ void removeControl (Control control) {
@Override
void reskinChildren (int flags) {
if (items != null) {
- for (int i=0; i<items.length; i++) {
- CoolItem item = items [i];
+ for (CoolItem item : items) {
if (item != null) item.reskin (flags);
}
}
@@ -746,7 +739,7 @@ void reskinChildren (int flags) {
void setBackgroundPixel (int pixel) {
if (pixel == -1) pixel = defaultBackground ();
OS.SendMessage (handle, OS.RB_SETBKCOLOR, 0, pixel);
- setItemColors ((int)/*64*/OS.SendMessage (handle, OS.RB_GETTEXTCOLOR, 0, 0), pixel);
+ setItemColors ((int)OS.SendMessage (handle, OS.RB_GETTEXTCOLOR, 0, 0), pixel);
/*
* Feature in Windows. For some reason, Windows
* does not fully erase the coolbar area and coolbar
@@ -762,11 +755,11 @@ void setBackgroundPixel (int pixel) {
void setForegroundPixel (int pixel) {
if (pixel == -1) pixel = defaultForeground ();
OS.SendMessage (handle, OS.RB_SETTEXTCOLOR, 0, pixel);
- setItemColors (pixel, (int)/*64*/OS.SendMessage (handle, OS.RB_GETBKCOLOR, 0, 0));
+ setItemColors (pixel, (int)OS.SendMessage (handle, OS.RB_GETBKCOLOR, 0, 0));
}
void setItemColors (int foreColor, int backColor) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_COLORS;
@@ -847,13 +840,12 @@ void setItemLayoutInPixels (int [] itemOrder, int [] wrapIndices, Point [] sizes
*/
void setItemOrder (int [] itemOrder) {
if (itemOrder == null) error (SWT.ERROR_NULL_ARGUMENT);
- int itemCount = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int itemCount = (int)OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
if (itemOrder.length != itemCount) error (SWT.ERROR_INVALID_ARGUMENT);
/* Ensure that itemOrder does not contain any duplicates. */
boolean [] set = new boolean [itemCount];
- for (int i=0; i<itemOrder.length; i++) {
- int index = itemOrder [i];
+ for (int index : itemOrder) {
if (index < 0 || index >= itemCount) error (SWT.ERROR_INVALID_RANGE);
if (set [index]) error (SWT.ERROR_INVALID_ARGUMENT);
set [index] = true;
@@ -863,7 +855,7 @@ void setItemOrder (int [] itemOrder) {
rbBand.cbSize = REBARBANDINFO.sizeof;
for (int i=0; i<itemOrder.length; i++) {
int id = originalItems [itemOrder [i]].id;
- int index = (int)/*64*/OS.SendMessage (handle, OS.RB_IDTOINDEX, id, 0);
+ int index = (int)OS.SendMessage (handle, OS.RB_IDTOINDEX, id, 0);
if (index != i) {
int lastItemSrcRow = getLastIndexOfRow (index);
int lastItemDstRow = getLastIndexOfRow (i);
@@ -906,7 +898,7 @@ void setItemOrder (int [] itemOrder) {
*/
void setItemSizes (Point [] sizes) {
if (sizes == null) error (SWT.ERROR_NULL_ARGUMENT);
- int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
if (sizes.length != count) error (SWT.ERROR_INVALID_ARGUMENT);
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
@@ -933,7 +925,7 @@ void setItemSizes (Point [] sizes) {
public void setLocked (boolean locked) {
checkWidget ();
this.locked = locked;
- int count = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_STYLE;
@@ -967,8 +959,8 @@ public void setWrapIndices (int [] indices) {
checkWidget ();
if (indices == null) indices = new int [0];
int count = getItemCount ();
- for (int i=0; i<indices.length; i++) {
- if (indices [i] < 0 || indices [i] >= count) {
+ for (int index : indices) {
+ if (index < 0 || index >= count) {
error (SWT.ERROR_INVALID_RANGE);
}
}
@@ -982,8 +974,7 @@ public void setWrapIndices (int [] indices) {
}
}
resizeToMaximumWidth (count - 1);
- for (int i=0; i<indices.length; i++) {
- int index = indices [i];
+ for (int index : indices) {
if (0 <= index && index < items.length) {
CoolItem item = items [index];
item.setWrap (true);
@@ -1007,12 +998,12 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return ReBarProc;
}
@Override
-LRESULT WM_COMMAND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_COMMAND (long wParam, long lParam) {
/*
* Feature in Windows. When the coolbar window
* proc processes WM_COMMAND, it forwards this
@@ -1037,7 +1028,7 @@ LRESULT WM_COMMAND (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ERASEBKGND (long wParam, long lParam) {
LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
/*
* Feature in Windows. For some reason, Windows
@@ -1060,7 +1051,7 @@ LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_NOTIFY (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NOTIFY (long wParam, long lParam) {
/*
* Feature in Windows. When the cool bar window
* proc processes WM_NOTIFY, it forwards this
@@ -1085,7 +1076,7 @@ LRESULT WM_NOTIFY (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETREDRAW (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETREDRAW (long wParam, long lParam) {
LRESULT result = super.WM_SETREDRAW (wParam, lParam);
if (result != null) return result;
/*
@@ -1111,9 +1102,9 @@ LRESULT WM_SETREDRAW (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
if (ignoreResize) {
- long /*int*/ code = callWindowProc (handle, OS.WM_SIZE, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_SIZE, wParam, lParam);
if (code == 0) return LRESULT.ZERO;
return new LRESULT (code);
}
@@ -1127,7 +1118,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) {
switch (hdr.code) {
case OS.RBN_BEGINDRAG: {
int pos = OS.GetMessagePos ();
@@ -1165,7 +1156,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
if (!ignoreResize) {
Point size = getSizeInPixels ();
int border = getBorderWidthInPixels ();
- int barHeight = (int)/*64*/OS.SendMessage (handle, OS.RB_GETBARHEIGHT, 0, 0);
+ int barHeight = (int)OS.SendMessage (handle, OS.RB_GETBARHEIGHT, 0, 0);
if ((style & SWT.VERTICAL) != 0) {
setSizeInPixels (barHeight + 2 * border, size.y);
} else {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
index 05bbc0aa80..52e6a2cc7a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
@@ -232,7 +232,7 @@ public Rectangle getBounds () {
Rectangle getBoundsInPixels () {
int index = parent.indexOf (this);
if (index == -1) return new Rectangle (0, 0, 0, 0);
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
RECT rect = new RECT ();
OS.SendMessage (hwnd, OS.RB_GETRECT, index, rect);
MARGINS margins = new MARGINS ();
@@ -254,7 +254,7 @@ Rectangle getClientArea () {
checkWidget ();
int index = parent.indexOf (this);
if (index == -1) return new Rectangle (0, 0, 0, 0);
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
RECT insetRect = new RECT ();
OS.SendMessage (hwnd, OS.RB_GETBANDBORDERS, index, insetRect);
RECT rect = new RECT ();
@@ -343,8 +343,8 @@ public void setControl (Control control) {
this.control = null;
}
Control oldControl = this.control, newControl = control;
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hwndChild = newControl != null ? control.topHandle () : 0;
+ long hwnd = parent.handle;
+ long hwndChild = newControl != null ? control.topHandle () : 0;
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_CHILD;
@@ -357,7 +357,7 @@ public void setControl (Control control) {
* moves the new child to the top of the Z-order. The fix is
* to save and restore the visibility and Z-order.
*/
- long /*int*/ hwndAbove = 0;
+ long hwndAbove = 0;
if (newControl != null) {
hwndAbove = OS.GetWindow (hwndChild, OS.GW_HWNDPREV);
}
@@ -392,7 +392,7 @@ public Point getPreferredSize () {
Point getPreferredSizeInPixels () {
int index = parent.indexOf (this);
if (index == -1) return new Point (0, 0);
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;
@@ -426,7 +426,7 @@ void setPreferredSizeInPixels (int width, int height) {
width = Math.max (0, width);
height = Math.max (0, height);
ideal = true;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
int cxIdeal, cyMaxChild;
if ((parent.style & SWT.VERTICAL) != 0) {
cxIdeal = Math.max (0, height - parent.getMargin (index));
@@ -490,8 +490,8 @@ public Point getSize () {
Point getSizeInPixels() {
int index = parent.indexOf (this);
- if (index == -1) new Point (0, 0);
- long /*int*/ hwnd = parent.handle;
+ if (index == -1) return new Point (0, 0);
+ long hwnd = parent.handle;
RECT rect = new RECT ();
OS.SendMessage (hwnd, OS.RB_GETRECT, index, rect);
MARGINS margins = new MARGINS ();
@@ -535,7 +535,7 @@ void setSizeInPixels (int width, int height) {
if (index == -1) return;
width = Math.max (0, width);
height = Math.max (0, height);
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
int cx, cyChild, cxIdeal;
if ((parent.style & SWT.VERTICAL) != 0) {
cx = height;
@@ -618,7 +618,7 @@ public Point getMinimumSize () {
Point getMinimumSizeInPixels () {
int index = parent.indexOf (this);
if (index == -1) return new Point (0, 0);
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_CHILDSIZE;
@@ -654,7 +654,7 @@ void setMinimumSizeInPixels (int width, int height) {
width = Math.max (0, width);
height = Math.max (0, height);
minimum = true;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
int cxMinChild, cyMinChild;
if ((parent.style & SWT.VERTICAL) != 0) {
cxMinChild = height;
@@ -701,7 +701,7 @@ public void setMinimumSize (Point size) {
boolean getWrap() {
int index = parent.indexOf (this);
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_STYLE;
@@ -711,7 +711,7 @@ boolean getWrap() {
void setWrap(boolean wrap) {
int index = parent.indexOf (this);
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_STYLE;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java
index ffadd410a2..1b45d44cf0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java
@@ -53,17 +53,11 @@ public class DateTime extends Composite {
boolean doubleClick, ignoreSelection;
SYSTEMTIME lastSystemTime;
SYSTEMTIME time = new SYSTEMTIME (); // only used in calendar mode
- static final long /*int*/ DateTimeProc;
+ static final long DateTimeProc;
static final TCHAR DateTimeClass = new TCHAR (0, OS.DATETIMEPICK_CLASS, true);
- static final long /*int*/ CalendarProc;
+ static final long CalendarProc;
static final TCHAR CalendarClass = new TCHAR (0, OS.MONTHCAL_CLASS, true);
static {
- INITCOMMONCONTROLSEX icex = new INITCOMMONCONTROLSEX ();
- icex.dwSize = INITCOMMONCONTROLSEX.sizeof;
- icex.dwICC = OS.ICC_DATE_CLASSES;
- OS.InitCommonControlsEx (icex);
- }
- static {
WNDCLASS lpWndClass = new WNDCLASS ();
OS.GetClassInfo (0, DateTimeClass, lpWndClass);
DateTimeProc = lpWndClass.lpfnWndProc;
@@ -202,7 +196,7 @@ public void addSelectionListener (SelectionListener listener) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
return OS.CallWindowProc (windowProc (), hwnd, msg, wParam, lParam);
}
@@ -286,7 +280,7 @@ String getCustomShortDateFormat () {
}
String getCustomShortTimeFormat () {
- StringBuffer buffer = new StringBuffer (getTimeFormat ());
+ StringBuilder buffer = new StringBuilder (getTimeFormat ());
int length = buffer.length ();
boolean inQuotes = false;
int start = 0, end = 0;
@@ -735,12 +729,12 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return (style & SWT.CALENDAR) != 0 ? CalendarProc : DateTimeProc;
}
@Override
-LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) {
switch (hdr.code) {
case OS.DTN_CLOSEUP: {
/*
@@ -776,7 +770,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CHAR (long wParam, long lParam) {
LRESULT result = super.WM_CHAR (wParam, lParam);
if (result != null) return result;
/*
@@ -785,7 +779,7 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
* The fix is to look for these keys and not call
* the window proc.
*/
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case SWT.CR:
sendSelectionEvent (SWT.DefaultSelection);
// FALL THROUGH
@@ -796,7 +790,7 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDBLCLK (long wParam, long lParam) {
LRESULT result = super.WM_LBUTTONDBLCLK (wParam, lParam);
if (isDisposed ()) return LRESULT.ZERO;
if ((style & SWT.CALENDAR) != 0) {
@@ -806,14 +800,14 @@ LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
pt.x = OS.GET_X_LPARAM (lParam);
pt.y = OS.GET_Y_LPARAM (lParam);
pMCHitTest.pt = pt;
- long /*int*/ code = OS.SendMessage (handle, OS.MCM_HITTEST, 0, pMCHitTest);
+ long code = OS.SendMessage (handle, OS.MCM_HITTEST, 0, pMCHitTest);
if ((code & OS.MCHT_CALENDARDATE) == OS.MCHT_CALENDARDATE) doubleClick = true;
}
return result;
}
@Override
-LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDOWN (long wParam, long lParam) {
LRESULT result = super.WM_LBUTTONDOWN (wParam, lParam);
if (result == LRESULT.ZERO) return result;
doubleClick = false;
@@ -829,7 +823,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_LBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONUP (long wParam, long lParam) {
LRESULT result = super.WM_LBUTTONUP (wParam, lParam);
if (isDisposed ()) return LRESULT.ZERO;
if (doubleClick) sendSelectionEvent (SWT.DefaultSelection);
@@ -838,7 +832,7 @@ LRESULT WM_LBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_TIMER (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_TIMER (long wParam, long lParam) {
LRESULT result = super.WM_TIMER (wParam, lParam);
if (result != null) return result;
/*
@@ -847,7 +841,7 @@ LRESULT WM_TIMER (long /*int*/ wParam, long /*int*/ lParam) {
* to ignore MCN_SELCHANGE during WM_TIMER.
*/
ignoreSelection = true;
- long /*int*/ code = callWindowProc(handle, OS.WM_TIMER, wParam, lParam);
+ long code = callWindowProc(handle, OS.WM_TIMER, wParam, lParam);
ignoreSelection = false;
return code == 0 ? LRESULT.ZERO : new LRESULT(code);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
index 97e04a6c81..4d8ad21228 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
@@ -106,7 +106,7 @@ public class Decorations extends Canvas {
Control savedFocus;
Button defaultButton, saveDefault;
int swFlags, nAccel;
- long /*int*/ hAccel;
+ long hAccel;
boolean moved, resized, opened;
int oldX = OS.CW_USEDEFAULT, oldY = OS.CW_USEDEFAULT;
int oldWidth = OS.CW_USEDEFAULT, oldHeight = OS.CW_USEDEFAULT;
@@ -236,21 +236,6 @@ static int checkStyle (int style) {
*/
if ((style & SWT.CLOSE) != 0) style |= SWT.TITLE;
- /*
- * Bug in Windows. The WS_CAPTION style must be
- * set when the window is resizable or it does not
- * draw properly.
- */
- /*
- * This code is intentionally commented. It seems
- * that this problem originally in Windows 3.11,
- * has been fixed in later versions. Because the
- * exact nature of the drawing problem is unknown,
- * keep the commented code around in case it comes
- * back.
- */
-// if ((style & SWT.RESIZE) != 0) style |= SWT.TITLE;
-
return style;
}
@@ -274,7 +259,7 @@ protected void checkSubclass () {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
return OS.DefMDIChildProc (hwnd, msg, wParam, lParam);
}
@@ -354,8 +339,7 @@ void createAccelerators () {
ACCEL accel = new ACCEL ();
byte [] buffer1 = new byte [ACCEL.sizeof];
byte [] buffer2 = new byte [items.length * ACCEL.sizeof];
- for (int i=0; i<items.length; i++) {
- MenuItem item = items [i];
+ for (MenuItem item : items) {
if (item != null && item.accelerator != 0) {
Menu menu = item.parent;
if (menu.parent == this) {
@@ -408,10 +392,9 @@ public void dispose () {
super.dispose ();
}
-Menu findMenu (long /*int*/ hMenu) {
+Menu findMenu (long hMenu) {
if (menus == null) return null;
- for (int i=0; i<menus.length; i++) {
- Menu menu = menus [i];
+ for (Menu menu : menus) {
if (menu != null && hMenu == menu.handle) return menu;
}
return null;
@@ -729,8 +712,7 @@ void releaseChildren (boolean destroy) {
}
super.releaseChildren (destroy);
if (menus != null) {
- for (int i=0; i<menus.length; i++) {
- Menu menu = menus [i];
+ for (Menu menu : menus) {
if (menu != null && !menu.isDisposed ()) {
menu.dispose ();
}
@@ -766,8 +748,7 @@ void removeMenu (Menu menu) {
void reskinChildren (int flags) {
if (menuBar != null) menuBar.reskin (flags);
if (menus != null) {
- for (int i=0; i<menus.length; i++) {
- Menu menu = menus [i];
+ for (Menu menu : menus) {
if (menu != null) menu.reskin (flags);
}
}
@@ -903,7 +884,7 @@ void setImages (Image image, Image [] images) {
if (smallImage != null) smallImage.dispose ();
if (largeImage != null) largeImage.dispose ();
smallImage = largeImage = null;
- long /*int*/ hSmallIcon = 0, hLargeIcon = 0;
+ long hSmallIcon = 0, hLargeIcon = 0;
Image smallIcon = null, largeIcon = null;
if (image != null) {
smallIcon = largeIcon = image;
@@ -993,8 +974,8 @@ void setImages (Image image, Image [] images) {
public void setImages (Image [] images) {
checkWidget ();
if (images == null) error (SWT.ERROR_INVALID_ARGUMENT);
- for (int i = 0; i < images.length; i++) {
- if (images [i] == null || images [i].isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+ for (Image image : images) {
+ if (image == null || image.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
}
this.images = images;
setImages (null, images);
@@ -1054,7 +1035,7 @@ public void setMenuBar (Menu menu) {
}
if (menu != null) display.removeBar (menu);
menuBar = menu;
- long /*int*/ hMenu = menuBar != null ? menuBar.handle: 0;
+ long hMenu = menuBar != null ? menuBar.handle: 0;
OS.SetMenu (handle, hMenu);
destroyAccelerators ();
}
@@ -1073,7 +1054,7 @@ public void setMenuBar (Menu menu) {
* always. This should be avoided if possible.
* </p>
*
- * @param minimized the new maximized state
+ * @param minimized the new minimized state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
@@ -1090,15 +1071,14 @@ public void setMinimized (boolean minimized) {
@Override
public void setOrientation (int orientation) {
- super.setOrientation (orientation);
- if (menus != null) {
- for (int i=0; i<menus.length; i++) {
- Menu menu = menus [i];
- if (menu != null && !menu.isDisposed () && (menu.getStyle () & SWT.POP_UP) != 0) {
- menu._setOrientation (menu.getOrientation ());
- }
- }
- }
+ super.setOrientation (orientation);
+ if (menus != null) {
+ for (Menu menu : menus) {
+ if (menu != null && !menu.isDisposed () && (menu.getStyle () & SWT.POP_UP) != 0) {
+ menu._setOrientation (menu.getOrientation ());
+ }
+ }
+ }
}
void setParent () {
@@ -1110,7 +1090,7 @@ void setParent () {
* undocumented and possibly dangerous Windows
* feature.
*/
- long /*int*/ hwndParent = parent.handle;
+ long hwndParent = parent.handle;
display.lockActiveWindow = true;
OS.SetParent (handle, hwndParent);
if (!OS.IsWindowVisible (hwndParent)) {
@@ -1181,7 +1161,7 @@ void setSavedFocus (Control control) {
}
void setSystemMenu () {
- long /*int*/ hMenu = OS.GetSystemMenu (handle, false);
+ long hMenu = OS.GetSystemMenu (handle, false);
if (hMenu == 0) return;
int oldCount = OS.GetMenuItemCount (hMenu);
if ((style & SWT.RESIZE) == 0) {
@@ -1240,13 +1220,12 @@ void setSystemMenu () {
public void setText (String string) {
checkWidget ();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- /* Use the character encoding for the default locale */
TCHAR buffer = new TCHAR (0, string, true);
/* Ensure that the title appears in the task bar.*/
if ((state & FOREIGN_HANDLE) != 0) {
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
int byteCount = buffer.length () * TCHAR.sizeof;
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (pszText, buffer, byteCount);
OS.DefWindowProc (handle, OS.WM_SETTEXT, 0, pszText);
if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
@@ -1339,16 +1318,16 @@ void sort (Image [] images, ImageData [] datas, int width, int height, int depth
for (int gap=length/2; gap>0; gap/=2) {
for (int i=gap; i<length; i++) {
for (int j=i-gap; j>=0; j-=gap) {
- if (compare (datas [j], datas [j + gap], width, height, depth) >= 0) {
+ if (compare (datas [j], datas [j + gap], width, height, depth) >= 0) {
Image swap = images [j];
images [j] = images [j + gap];
images [j + gap] = swap;
ImageData swapData = datas [j];
datas [j] = datas [j + gap];
datas [j + gap] = swapData;
- }
- }
- }
+ }
+ }
+ }
}
}
@@ -1369,13 +1348,13 @@ boolean translateMenuAccelerator (MSG msg) {
boolean translateMDIAccelerator (MSG msg) {
if (!(this instanceof Shell)) {
Shell shell = getShell ();
- long /*int*/ hwndMDIClient = shell.hwndMDIClient;
+ long hwndMDIClient = shell.hwndMDIClient;
if (hwndMDIClient != 0 && OS.TranslateMDISysAccel (hwndMDIClient, msg)) {
return true;
}
if (msg.message == OS.WM_KEYDOWN) {
if (OS.GetKeyState (OS.VK_CONTROL) >= 0) return false;
- switch ((int)/*64*/(msg.wParam)) {
+ switch ((int)(msg.wParam)) {
case OS.VK_F4:
OS.PostMessage (handle, OS.WM_CLOSE, 0, 0);
return true;
@@ -1385,7 +1364,7 @@ boolean translateMDIAccelerator (MSG msg) {
return false;
}
if (msg.message == OS.WM_SYSKEYDOWN) {
- switch ((int)/*64*/(msg.wParam)) {
+ switch ((int)(msg.wParam)) {
case OS.VK_F4:
OS.PostMessage (shell.handle, OS.WM_CLOSE, 0, 0);
return true;
@@ -1449,7 +1428,7 @@ int widgetExtStyle () {
}
@Override
-long /*int*/ widgetParent () {
+long widgetParent () {
Shell shell = getShell ();
return shell.hwndMDIClient ();
}
@@ -1491,7 +1470,7 @@ int widgetStyle () {
}
@Override
-long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long windowProc (long hwnd, int msg, long wParam, long lParam) {
switch (msg) {
case Display.SWT_GETACCEL:
case Display.SWT_GETACCELCOUNT:
@@ -1502,7 +1481,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
}
@Override
-LRESULT WM_ACTIVATE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ACTIVATE (long wParam, long lParam) {
LRESULT result = super.WM_ACTIVATE (wParam, lParam);
if (result != null) return result;
/*
@@ -1567,7 +1546,7 @@ LRESULT WM_ACTIVATE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_CLOSE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CLOSE (long wParam, long lParam) {
LRESULT result = super.WM_CLOSE (wParam, lParam);
if (result != null) return result;
if (isEnabled () && isActive ()) closeWidget ();
@@ -1575,14 +1554,14 @@ LRESULT WM_CLOSE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KILLFOCUS (long wParam, long lParam) {
LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
saveFocus ();
return result;
}
@Override
-LRESULT WM_MOVE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOVE (long wParam, long lParam) {
if (moved) {
Point location = getLocationInPixels ();
if (location.x == oldX && location.y == oldY) {
@@ -1595,7 +1574,7 @@ LRESULT WM_MOVE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_NCACTIVATE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NCACTIVATE (long wParam, long lParam) {
LRESULT result = super.WM_NCACTIVATE (wParam, lParam);
if (result != null) return result;
if (wParam == 0) {
@@ -1615,14 +1594,14 @@ LRESULT WM_NCACTIVATE (long /*int*/ wParam, long /*int*/ lParam) {
}
}
if (!(this instanceof Shell)) {
- long /*int*/ hwndShell = getShell().handle;
+ long hwndShell = getShell().handle;
OS.SendMessage (hwndShell, OS.WM_NCACTIVATE, wParam, lParam);
}
return result;
}
@Override
-LRESULT WM_QUERYOPEN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_QUERYOPEN (long wParam, long lParam) {
LRESULT result = super.WM_QUERYOPEN (wParam, lParam);
if (result != null) return result;
sendEvent (SWT.Deiconify);
@@ -1631,7 +1610,7 @@ LRESULT WM_QUERYOPEN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFOCUS (long wParam, long lParam) {
LRESULT result = super.WM_SETFOCUS (wParam, lParam);
if (isDisposed ()) return result;
if (savedFocus != this) restoreFocus ();
@@ -1639,12 +1618,12 @@ LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
LRESULT result = null;
boolean changed = true;
if (resized) {
int newWidth = 0, newHeight = 0;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.SIZE_MAXIMIZED:
OS.GetWindowRect (handle, maxRect);
case OS.SIZE_RESTORED:
@@ -1675,11 +1654,11 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SYSCOMMAND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SYSCOMMAND (long wParam, long lParam) {
LRESULT result = super.WM_SYSCOMMAND (wParam, lParam);
if (result != null) return result;
if (!(this instanceof Shell)) {
- int cmd = (int)/*64*/wParam & 0xFFF0;
+ int cmd = (int)wParam & 0xFFF0;
switch (cmd) {
case OS.SC_CLOSE: {
OS.PostMessage (handle, OS.WM_CLOSE, 0, 0);
@@ -1695,7 +1674,7 @@ LRESULT WM_SYSCOMMAND (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_WINDOWPOSCHANGING (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_WINDOWPOSCHANGING (long wParam, long lParam) {
LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam);
if (result != null) return result;
if (display.lockActiveWindow) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java
index 4cf84ac2cb..c6fe9f7e32 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -16,8 +16,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.com.win32.*;
+import org.eclipse.swt.internal.ole.win32.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -39,15 +38,6 @@ import org.eclipse.swt.internal.win32.*;
* @noextend This class is not intended to be subclassed by clients.
*/
public class DirectoryDialog extends Dialog {
- static final byte[] CLSID_FileOpenDialog = new byte[16];
- static final byte[] IID_IFileOpenDialog = new byte[16];
- static final byte[] IID_IShellItem = new byte[16];
- static {
- OS.IIDFromString("{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}\0".toCharArray(), CLSID_FileOpenDialog); //$NON-NLS-1$
- OS.IIDFromString("{d57c7288-d4ad-4768-be02-9d969532d960}\0".toCharArray(), IID_IFileOpenDialog); //$NON-NLS-1$
- OS.IIDFromString("{43826d1e-e718-42ee-bc55-a1e261c37bfe}\0".toCharArray(), IID_IShellItem); //$NON-NLS-1$
- }
-
String message = "", filterPath = ""; //$NON-NLS-1$//$NON-NLS-2$
String directoryPath;
@@ -97,32 +87,6 @@ public DirectoryDialog (Shell parent, int style) {
checkSubclass ();
}
-long /*int*/ BrowseCallbackProc (long /*int*/ hwnd, long /*int*/ uMsg, long /*int*/ lParam, long /*int*/ lpData) {
- switch ((int)/*64*/uMsg) {
- case OS.BFFM_INITIALIZED:
- if (filterPath != null && filterPath.length () != 0) {
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, filterPath.replace ('/', '\\'), true);
- OS.SendMessage (hwnd, OS.BFFM_SETSELECTION, 1, buffer);
- }
- if (title != null && title.length () != 0) {
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, title, true);
- OS.SetWindowText (hwnd, buffer);
- }
- break;
- case OS.BFFM_VALIDATEFAILED:
- /* Use the character encoding for the default locale */
- int length = OS.wcslen (lParam);
- TCHAR buffer = new TCHAR (0, length);
- int byteCount = buffer.length () * TCHAR.sizeof;
- OS.MoveMemory (buffer, lParam, byteCount);
- directoryPath = buffer.toString (0, length);
- break;
- }
- return 0;
-}
-
/**
* Returns the path which the dialog will use to filter
* the directories it shows.
@@ -159,169 +123,50 @@ public String getMessage () {
* </ul>
*/
public String open() {
- if (OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
- return openCommonItemDialog();
- }
- return openCommonFileDialog();
-}
-
-private String openCommonFileDialog () {
- long /*int*/ hHeap = OS.GetProcessHeap ();
-
- /* Get the owner HWND for the dialog */
- long /*int*/ hwndOwner = 0;
- if (parent != null) hwndOwner = parent.handle;
-
- /* Copy the message to OS memory */
- long /*int*/ lpszTitle = 0;
- if (message.length () != 0) {
- String string = message;
- if (string.indexOf ('&') != -1) {
- int length = string.length ();
- char [] buffer = new char [length * 2];
- int index = 0;
- for (int i=0; i<length; i++) {
- char ch = string.charAt (i);
- if (ch == '&') buffer [index++] = '&';
- buffer [index++] = ch;
- }
- string = new String (buffer, 0, index);
- }
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, string, true);
- int byteCount = buffer.length () * TCHAR.sizeof;
- lpszTitle = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (lpszTitle, buffer, byteCount);
- }
-
- /* Create the BrowseCallbackProc */
- Callback callback = new Callback (this, "BrowseCallbackProc", 4); //$NON-NLS-1$
- long /*int*/ lpfn = callback.getAddress ();
- if (lpfn == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
-
- /* Make the parent shell be temporary modal */
- Dialog oldModal = null;
- Display display = parent.getDisplay ();
- if ((style & (SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) != 0) {
- oldModal = display.getModalDialog ();
- display.setModalDialog (this);
- }
-
- directoryPath = null;
- BROWSEINFO lpbi = new BROWSEINFO ();
- lpbi.hwndOwner = hwndOwner;
- lpbi.lpszTitle = lpszTitle;
- lpbi.ulFlags = OS.BIF_NEWDIALOGSTYLE | OS.BIF_RETURNONLYFSDIRS | OS.BIF_EDITBOX | OS.BIF_VALIDATE;
- lpbi.lpfn = lpfn;
- /*
- * Bug in Windows. On some hardware configurations, SHBrowseForFolder()
- * causes warning dialogs with the message "There is no disk in the drive
- * Please insert a disk into \Device\Harddisk0\DR0". This is possibly
- * caused by SHBrowseForFolder() calling internally GetVolumeInformation().
- * MSDN for GetVolumeInformation() says:
- *
- * "If you are attempting to obtain information about a floppy drive
- * that does not have a floppy disk or a CD-ROM drive that does not
- * have a compact disc, the system displays a message box asking the
- * user to insert a floppy disk or a compact disc, respectively.
- * To prevent the system from displaying this message box, call the
- * SetErrorMode function with SEM_FAILCRITICALERRORS."
- *
- * The fix is to save and restore the error mode using SetErrorMode()
- * with the SEM_FAILCRITICALERRORS flag around SHBrowseForFolder().
- */
- int oldErrorMode = OS.SetErrorMode (OS.SEM_FAILCRITICALERRORS);
-
- display.sendPreExternalEventDispatchEvent ();
- long /*int*/ lpItemIdList = OS.SHBrowseForFolder (lpbi);
- display.sendPostExternalEventDispatchEvent ();
- OS.SetErrorMode (oldErrorMode);
-
- /* Clear the temporary dialog modal parent */
- if ((style & (SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) != 0) {
- display.setModalDialog (oldModal);
- }
-
- boolean success = lpItemIdList != 0;
- if (success) {
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, OS.MAX_PATH);
- if (OS.SHGetPathFromIDList (lpItemIdList, buffer)) {
- directoryPath = buffer.toString (0, buffer.strlen ());
- filterPath = directoryPath;
- }
- }
-
- /* Free the BrowseCallbackProc */
- callback.dispose ();
-
- /* Free the OS memory */
- if (lpszTitle != 0) OS.HeapFree (hHeap, 0, lpszTitle);
-
- /* Free the pointer to the ITEMIDLIST */
- long /*int*/ [] ppMalloc = new long /*int*/ [1];
- if (OS.SHGetMalloc (ppMalloc) == OS.S_OK) {
- /* void Free (struct IMalloc *this, void *pv); */
- OS.VtblCall (5, ppMalloc [0], lpItemIdList);
- }
-
- /*
- * This code is intentionally commented. On some
- * platforms, the owner window is repainted right
- * away when a dialog window exits. This behavior
- * is currently unspecified.
- */
-// if (hwndOwner != 0) OS.UpdateWindow (hwndOwner);
-
- /* Return the directory path */
- if (!success) return null;
- return directoryPath;
-}
-
-private String openCommonItemDialog() {
this.directoryPath = null;
- long /*int*/ [] ppv = new long /*int*/ [1];
- if (OS.CoCreateInstance(CLSID_FileOpenDialog, 0, OS.CLSCTX_INPROC_SERVER, IID_IFileOpenDialog, ppv) == OS.S_OK) {
- long /*int*/ fileDialog = ppv[0];
+ long [] ppv = new long [1];
+ if (COM.CoCreateInstance(COM.CLSID_FileOpenDialog, 0, COM.CLSCTX_INPROC_SERVER, COM.IID_IFileOpenDialog, ppv) == OS.S_OK) {
+ IFileDialog fileDialog = new IFileDialog(ppv[0]);
int[] options = new int[1];
- if ((OS.VtblCall(FileDialogVtbl.GET_OPTIONS, fileDialog, options)) == OS.S_OK) {
+ if (fileDialog.GetOptions(options) == OS.S_OK) {
options[0] |= OS.FOS_PICKFOLDERS | OS.FOS_FORCEFILESYSTEM | OS.FOS_NOCHANGEDIR;
-
- OS.VtblCall(FileDialogVtbl.SET_OPTIONS, fileDialog, options[0]);
+ fileDialog.SetOptions(options[0]);
}
if (title == null) title = "";
if (title.length() > 0) {
char[] buffer = new char[title.length() + 1];
title.getChars(0, title.length(), buffer, 0);
- OS.VtblCall(FileDialogVtbl.SET_TITLE, fileDialog, buffer);
+ fileDialog.SetTitle(buffer);
}
if (filterPath != null && filterPath.length() > 0) {
String path = filterPath.replace('/', '\\');
char[] buffer = new char[path.length() + 1];
path.getChars(0, path.length(), buffer, 0);
- if (OS.SHCreateItemFromParsingName(buffer, 0, IID_IShellItem, ppv) == OS.S_OK) {
- long /*int*/ psi = ppv[0];
+ if (COM.SHCreateItemFromParsingName(buffer, 0, COM.IID_IShellItem, ppv) == OS.S_OK) {
+ IShellItem psi = new IShellItem(ppv[0]);
/*
* SetDefaultDirectory does not work if the dialog has
* persisted recently used folder. The fix is to clear the
* persisted data.
*/
- OS.VtblCall(FileDialogVtbl.CLEAR_CLIENT_DATA, fileDialog);
- OS.VtblCall(FileDialogVtbl.SET_DEFAULT_FOLDER, fileDialog, psi);
- OS.VtblCall(FileDialogVtbl.RELEASE, psi);
+ fileDialog.ClearClientData();
+ fileDialog.SetDefaultFolder(psi);
+ psi.Release();
}
}
- long /*int*/ hwndOwner = parent.handle;
- if (OS.VtblCall(FileDialogVtbl.SHOW, fileDialog, hwndOwner) == OS.S_OK) {
- if (OS.VtblCall(FileDialogVtbl.GET_RESULT, fileDialog, ppv) == OS.S_OK) {
- long /*int*/ psi = ppv[0];
- if (OS.VtblCall(ShellItemVtbl.GET_DISPLAY_NAME, psi, OS.SIGDN_FILESYSPATH, ppv) == OS.S_OK) {
- long /*int*/ wstr = ppv[0];
+ Display display = parent.getDisplay();
+ long hwndOwner = parent.handle;
+ display.externalEventLoop = true;
+ if (fileDialog.Show(hwndOwner) == OS.S_OK) {
+ if (fileDialog.GetResult(ppv) == OS.S_OK) {
+ IShellItem psi = new IShellItem(ppv[0]);
+ if (psi.GetDisplayName(OS.SIGDN_FILESYSPATH, ppv) == OS.S_OK) {
+ long wstr = ppv[0];
int length = OS.wcslen(wstr);
char[] buffer = new char[length];
OS.MoveMemory(buffer, wstr, length * 2);
@@ -329,11 +174,12 @@ private String openCommonItemDialog() {
directoryPath = new String(buffer);
}
- OS.VtblCall(FileDialogVtbl.RELEASE, psi);
+ psi.Release();
}
}
+ display.externalEventLoop = false;
- OS.VtblCall(FileDialogVtbl.RELEASE, fileDialog);
+ fileDialog.Release();
}
return directoryPath;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
index c19d155ddf..2e71ec17df 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -20,6 +20,7 @@ import java.util.function.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.ole.win32.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -119,11 +120,12 @@ public class Display extends Device {
static String APP_NAME = "SWT"; //$NON-NLS-1$
static String APP_VERSION = ""; //$NON-NLS-1$
+ String appLocalDir;
/* Windows and Events */
Event [] eventQueue;
Callback windowCallback;
- long /*int*/ windowProc;
+ long windowProc;
int threadId;
TCHAR windowClass, windowShadowClass, windowOwnDCClass;
static int WindowClassCount;
@@ -132,12 +134,13 @@ public class Display extends Device {
static final String WindowOwnDCName = "SWT_WindowOwnDC"; //$NON-NLS-1$
EventTable eventTable, filterTable;
boolean useOwnDC;
+ boolean externalEventLoop; // events are dispatched outside SWT, e.g. TrackPopupMenu or DoDragDrop
/* Widget Table */
int freeSlot;
int [] indexTable;
Control lastControl, lastGetControl;
- long /*int*/ lastHwnd, lastGetHwnd;
+ long lastHwnd, lastGetHwnd;
Control [] controlTable;
static final int GROW_SIZE = 1024;
static final int SWT_OBJECT_INDEX = OS.GlobalAddAtom (new TCHAR (0, "SWT_OBJECT_INDEX", true)); //$NON-NLS-1$
@@ -151,7 +154,7 @@ public class Display extends Device {
}
/* XP Themes */
- long /*int*/ hButtonTheme, hEditTheme, hExplorerBarTheme, hScrollBarTheme, hTabTheme;
+ long hButtonTheme, hEditTheme, hExplorerBarTheme, hScrollBarTheme, hTabTheme;
static final char [] BUTTON = new char [] {'B', 'U', 'T', 'T', 'O', 'N', 0};
static final char [] EDIT = new char [] {'E', 'D', 'I', 'T', 0};
static final char [] EXPLORER = new char [] {'E', 'X', 'P', 'L', 'O', 'R', 'E', 'R', 0};
@@ -160,11 +163,118 @@ public class Display extends Device {
static final char [] LISTVIEW = new char [] {'L', 'I', 'S', 'T', 'V', 'I', 'E', 'W', 0};
static final char [] TAB = new char [] {'T', 'A', 'B', 0};
static final char [] TREEVIEW = new char [] {'T', 'R', 'E', 'E', 'V', 'I', 'E', 'W', 0};
+ /* Emergency switch to be used in case of regressions. Not supposed to be changed when app is running. */
+ static final boolean disableCustomThemeTweaks = Boolean.valueOf(System.getProperty("org.eclipse.swt.internal.win32.disableCustomThemeTweaks")); //$NON-NLS-1$
+ /**
+ * Changes Windows theme to 'DarkMode_Explorer' for Controls that can benefit from it.
+ * Effects as of Windows 10 version 1909:<br>
+ * <ul>
+ * <li>Button - default background/foreground colors</li>
+ * <li>Scrollbars in controls tha have them - this is the most important change for many applications.</li>
+ * <li>Tree - dark theme compatible expander icon.</li>
+ * <li>Tree - dark theme compatible colors for selected and hovered items.</li>
+ * <li>The list is not exhaustive. Also, effects can change, because Windows dark theme is not yet official.</li>
+ * </ul>
+ * Limitations:<br>
+ * <ul>
+ * <li>Only available since Win10 version 1903.</li>
+ * <li>Does not affect already created controls.</li>
+ * </ul>
+ * All Scrollable-based Controls are affected.
+ */
+ static final String USE_DARKMODE_EXPLORER_THEME_KEY = "org.eclipse.swt.internal.win32.useDarkModeExplorerTheme";
+ boolean useDarkModeExplorerTheme;
+ /**
+ * Sets Shell titles to match theme selected in Windows. That is, dark is system is dark.
+ * Limitations:<br>
+ * <ul>
+ * <li>Only available since Win10.</li>
+ * <li>Does not affect already created Shells.</li>
+ * </ul>
+ */
+ static final String USE_SHELL_TITLE_COLORING = "org.eclipse.swt.internal.win32.useShellTitleColoring";
+ boolean useShellTitleColoring;
+ /**
+ * Configures background/foreground colors of Menu(SWT.BAR).<br>
+ * Side effects:
+ * <ul>
+ * <li>Menu items are no longer highlighted when mouse hovers over</li>
+ * </ul>
+ * Expects a <code>Color</code> value.
+ */
+ static final String MENUBAR_FOREGROUND_COLOR_KEY = "org.eclipse.swt.internal.win32.menuBarForegroundColor"; //$NON-NLS-1$
+ int menuBarForegroundPixel = -1;
+ static final String MENUBAR_BACKGROUND_COLOR_KEY = "org.eclipse.swt.internal.win32.menuBarBackgroundColor"; //$NON-NLS-1$
+ int menuBarBackgroundPixel = -1;
+ /**
+ * Color of the 1px separator between Menu(SWT.BAR) and Shell's client area.<br>
+ * Expects a <code>Color</code> value.
+ */
+ static final String MENUBAR_BORDER_COLOR_KEY = "org.eclipse.swt.internal.win32.menuBarBorderColor"; //$NON-NLS-1$
+ long menuBarBorderPen;
+ /**
+ * Use a different border for Controls.
+ * This often gives better results for dark themes.
+ * The effect is slightly different for different controls.
+ */
+ static final String USE_WS_BORDER_ALL_KEY = "org.eclipse.swt.internal.win32.all.use_WS_BORDER"; //$NON-NLS-1$
+ boolean useWsBorderAll = false;
+ static final String USE_WS_BORDER_CANVAS_KEY = "org.eclipse.swt.internal.win32.Canvas.use_WS_BORDER"; //$NON-NLS-1$
+ boolean useWsBorderCanvas = false;
+ static final String USE_WS_BORDER_LABEL_KEY = "org.eclipse.swt.internal.win32.Label.use_WS_BORDER"; //$NON-NLS-1$
+ boolean useWsBorderLabel = false;
+ static final String USE_WS_BORDER_LIST_KEY = "org.eclipse.swt.internal.win32.List.use_WS_BORDER"; //$NON-NLS-1$
+ boolean useWsBorderList = false;
+ static final String USE_WS_BORDER_TABLE_KEY = "org.eclipse.swt.internal.win32.Table.use_WS_BORDER"; //$NON-NLS-1$
+ boolean useWsBorderTable = false;
+ static final String USE_WS_BORDER_TEXT_KEY = "org.eclipse.swt.internal.win32.Text.use_WS_BORDER"; //$NON-NLS-1$
+ boolean useWsBorderText = false;
+ /**
+ * Changes the color of Table header's column delimiters.
+ * Only affects custom-drawn header, that is when background/foreground header color is set.
+ * Expects a <code>Color</code> value.
+ */
+ static final String TABLE_HEADER_LINE_COLOR_KEY = "org.eclipse.swt.internal.win32.Table.headerLineColor"; //$NON-NLS-1$
+ int tableHeaderLinePixel = -1;
+ /**
+ * Disabled Label is drawn with specified foreground color.
+ * Expects a <code>Color</code> value.
+ */
+ static final String LABEL_DISABLED_FOREGROUND_COLOR_KEY = "org.eclipse.swt.internal.win32.Label.disabledForegroundColor"; //$NON-NLS-1$
+ int disabledLabelForegroundPixel = -1;
+ /**
+ * Use dark theme for Combo.
+ * Limitations:<br>
+ * <ul>
+ * <li>Only available since Win10 version 1903.</li>
+ * <li>Does not affect already created controls.</li>
+ * </ul>
+ * Expects a <code>boolean</code> value.
+ */
+ static final String COMBO_USE_DARK_THEME = "org.eclipse.swt.internal.win32.Combo.useDarkTheme"; //$NON-NLS-1$
+ boolean comboUseDarkTheme = false;
+ /**
+ * Use .setForeground() .setBackground() theme for ProgressBar.
+ * Limitations:<br>
+ * <ul>
+ * <li>Does not affect already created controls.</li>
+ * </ul>
+ * Side effects:
+ * <ul>
+ * <li>ProgressBar's shine animation is lost.</li>
+ * </ul>
+ * Expects a <code>boolean</code> value.
+ */
+ static final String PROGRESSBAR_USE_COLORS = "org.eclipse.swt.internal.win32.ProgressBar.useColors"; //$NON-NLS-1$
+ boolean progressbarUseColors = false;
+
+ /* Custom icons */
+ long hIconSearch;
+ long hIconCancel;
/* Focus */
int focusEvent;
Control focusControl;
- boolean fixFocus;
/* Menus */
Menu [] bars, popups;
@@ -181,18 +291,18 @@ public class Display extends Device {
/* Filter Hook */
Callback msgFilterCallback;
- long /*int*/ msgFilterProc, filterHook;
+ long msgFilterProc, filterHook;
MSG hookMsg = new MSG ();
boolean runDragDrop = true, dragCancelled = false;
/* Idle Hook */
Callback foregroundIdleCallback;
- long /*int*/ foregroundIdleProc, idleHook;
+ long foregroundIdleProc, idleHook;
/* Message Hook and Embedding */
boolean ignoreNextKey;
Callback getMsgCallback, embeddedCallback;
- long /*int*/ getMsgProc, msgHook, embeddedHwnd, embeddedProc;
+ long getMsgProc, msgHook, embeddedHwnd, embeddedProc;
static final String AWT_WINDOW_CLASS = "SunAwtWindow"; //$NON-NLS-1$
static final short [] ACCENTS = new short [] {'~', '`', '\'', '^', '"'};
@@ -205,6 +315,8 @@ public class Display extends Device {
static final String RUN_MESSAGES_IN_MESSAGE_PROC_KEY = "org.eclipse.swt.internal.win32.runMessagesInMessageProc"; //$NON-NLS-1$
static final String USE_OWNDC_KEY = "org.eclipse.swt.internal.win32.useOwnDC"; //$NON-NLS-1$
static final String ACCEL_KEY_HIT = "org.eclipse.swt.internal.win32.accelKeyHit"; //$NON-NLS-1$
+ static final String EXTERNAL_EVENT_LOOP_KEY = "org.eclipse.swt.internal.win32.externalEventLoop"; //$NON-NLS-1$
+ static final String APPLOCAL_DIR_KEY = "org.eclipse.swt.internal.win32.appLocalDir"; //$NON-NLS-1$
Thread thread;
/* Display Shutdown */
@@ -224,19 +336,20 @@ public class Display extends Device {
static final String LAUNCHER_PREFIX = "--launcher.openFile "; //$NON-NLS-1$
/* Timers */
- long /*int*/ [] timerIds;
+ long [] timerIds;
Runnable [] timerList;
- long /*int*/ nextTimerId = SETTINGS_ID + 1;
+ long nextTimerId = SETTINGS_ID + 1;
/* Settings */
- static final long /*int*/ SETTINGS_ID = 100;
+ static final long SETTINGS_ID = 100;
static final int SETTINGS_DELAY = 2000;
/* Keyboard and Mouse */
RECT clickRect;
int clickCount, lastTime, lastButton;
- long /*int*/ lastClickHwnd;
- int scrollRemainder, scrollHRemainder;
+ long lastClickHwnd;
+ Point scrollRemainderEvt = new Point(0, 0);
+ Point scrollRemainderBar = new Point(0, 0);
int lastKey, lastMouse, lastAscii;
boolean lastVirtual, lastNull, lastDead;
byte [] keyboard = new byte [256];
@@ -261,7 +374,7 @@ public class Display extends Device {
/* Message Only Window */
Callback messageCallback;
- long /*int*/ hwndMessage, messageProc;
+ long hwndMessage, messageProc;
/* System Resources */
LOGFONT lfSystemFont;
@@ -275,7 +388,7 @@ public class Display extends Device {
ImageList[] imageList, toolImageList, toolHotImageList, toolDisabledImageList;
/* Custom Colors for ChooseColor */
- long /*int*/ lpCustColors;
+ long lpCustColors;
/* Table */
char [] tableBuffer;
@@ -407,17 +520,6 @@ public class Display extends Device {
/* Package Name */
static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$
- /*
- * This code is intentionally commented. In order
- * to support CLDC, .class cannot be used because
- * it does not compile on some Java compilers when
- * they are targeted for CLDC.
- */
-// static {
-// String name = Display.class.getName ();
-// int index = name.lastIndexOf ('.');
-// PACKAGE_PREFIX = name.substring (0, index + 1);
-// }
/*
* TEMPORARY CODE. Install the runnable that
@@ -496,7 +598,7 @@ void addBar (Menu menu) {
bars [index] = menu;
}
-void addControl (long /*int*/ handle, Control control) {
+void addControl (long handle, Control control) {
if (handle == 0) return;
if (freeSlot == -1) {
int length = (freeSlot = indexTable.length) + GROW_SIZE;
@@ -518,7 +620,7 @@ void addControl (long /*int*/ handle, Control control) {
void addSkinnableWidget (Widget widget) {
if (skinCount >= skinList.length) {
- Widget[] newSkinWidgets = new Widget [skinList.length + GROW_SIZE];
+ Widget[] newSkinWidgets = new Widget [(skinList.length + 1) * 3 / 2];
System.arraycopy (skinList, 0, newSkinWidgets, 0, skinList.length);
skinList = newSkinWidgets;
}
@@ -650,9 +752,14 @@ int asciiKey (int key) {
if (!OS.GetKeyboardState (keyboard)) return 0;
/* Translate the key to ASCII or UNICODE using the virtual keyboard */
- char [] result = new char [1];
- if (OS.ToUnicode (key, key, keyboard, result, 1, 0) == 1) return result [0];
- return 0;
+ char [] buffer = new char [1];
+ int len = OS.ToUnicode (key, key, keyboard, buffer, 1, 0);
+
+ /* If the key is a dead key, flush dead key state. */
+ while (len == -1) {
+ len = OS.ToUnicode (key, key, keyboard, buffer, 1, 0);
+ }
+ return (len != 0) ? buffer [0] : 0;
}
/**
@@ -717,36 +824,16 @@ protected void checkSubclass () {
@Override
protected void checkDevice () {
if (thread == null) error (SWT.ERROR_WIDGET_DISPOSED);
- if (thread != Thread.currentThread ()) {
- /*
- * Bug in IBM JVM 1.6. For some reason, under
- * conditions that are yet to be full understood,
- * Thread.currentThread() is either returning null
- * or a different instance from the one that was
- * saved when the Display was created. This is
- * possibly a JIT problem because modifying this
- * method to print logging information when the
- * error happens seems to fix the problem. The
- * fix is to use operating system calls to verify
- * that the current thread is not the Display thread.
- *
- * NOTE: Despite the fact that Thread.currentThread()
- * is used in other places, the failure has not been
- * observed in all places where it is called.
- */
- if (threadId != OS.GetCurrentThreadId ()) {
- error (SWT.ERROR_THREAD_INVALID_ACCESS);
- }
- }
+ if (thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
}
static void checkDisplay (Thread thread, boolean multiple) {
synchronized (Device.class) {
- for (int i=0; i<Displays.length; i++) {
- if (Displays [i] != null) {
+ for (Display display : Displays) {
+ if (display != null) {
if (!multiple) SWT.error (SWT.ERROR_NOT_IMPLEMENTED, null, " [multiple displays]"); //$NON-NLS-1$
- if (Displays [i].thread == thread) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (display.thread == thread) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
}
}
}
@@ -764,12 +851,12 @@ void clearModal (Shell shell) {
System.arraycopy (modalShells, index + 1, modalShells, index, --length - index);
modalShells [length] = null;
if (index == 0 && modalShells [0] == null) modalShells = null;
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) shells [i].updateModal ();
+ for (Shell activeShell : getShells ())
+ activeShell.updateModal ();
}
int controlKey (int key) {
- int upper = (int)/*64*/OS.CharUpper ((short) key);
+ int upper = (int)OS.CharUpper ((short) key);
if (64 <= upper && upper <= 95) return upper & 0xBF;
return key;
}
@@ -818,9 +905,9 @@ protected void create (DeviceData data) {
void createDisplay (DeviceData data) {
}
-static long /*int*/ create32bitDIB (Image image) {
+static long create32bitDIB (Image image) {
int transparentPixel = -1, alpha = -1;
- long /*int*/ hMask = 0, hBitmap = 0;
+ long hMask = 0, hBitmap = 0;
byte[] alphaData = null;
switch (image.type) {
case SWT.ICON:
@@ -841,10 +928,10 @@ static long /*int*/ create32bitDIB (Image image) {
OS.GetObject (hBitmap, BITMAP.sizeof, bm);
int imgWidth = bm.bmWidth;
int imgHeight = bm.bmHeight;
- long /*int*/ hDC = OS.GetDC (0);
- long /*int*/ srcHdc = OS.CreateCompatibleDC (hDC);
- long /*int*/ oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap);
- long /*int*/ memHdc = OS.CreateCompatibleDC (hDC);
+ long hDC = OS.GetDC (0);
+ long srcHdc = OS.CreateCompatibleDC (hDC);
+ long oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap);
+ long memHdc = OS.CreateCompatibleDC (hDC);
BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER ();
bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
bmiHeader.biWidth = imgWidth;
@@ -854,16 +941,16 @@ static long /*int*/ create32bitDIB (Image image) {
bmiHeader.biCompression = OS.BI_RGB;
byte [] bmi = new byte [BITMAPINFOHEADER.sizeof];
OS.MoveMemory (bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
- long /*int*/ [] pBits = new long /*int*/ [1];
- long /*int*/ memDib = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
+ long [] pBits = new long [1];
+ long memDib = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
if (memDib == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- long /*int*/ oldMemBitmap = OS.SelectObject (memHdc, memDib);
+ long oldMemBitmap = OS.SelectObject (memHdc, memDib);
BITMAP dibBM = new BITMAP ();
OS.GetObject (memDib, BITMAP.sizeof, dibBM);
int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight;
- OS.BitBlt (memHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY);
- byte red = 0, green = 0, blue = 0;
- if (transparentPixel != -1) {
+ OS.BitBlt (memHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY);
+ byte red = 0, green = 0, blue = 0;
+ if (transparentPixel != -1) {
if (bm.bmBitsPixel <= 8) {
byte [] color = new byte [4];
OS.GetDIBColorTable (srcHdc, transparentPixel, 1, color);
@@ -889,8 +976,8 @@ static long /*int*/ create32bitDIB (Image image) {
break;
}
}
- }
- byte [] srcData = new byte [sizeInBytes];
+ }
+ byte [] srcData = new byte [sizeInBytes];
OS.MoveMemory (srcData, pBits [0], sizeInBytes);
if (hMask != 0) {
OS.SelectObject(srcHdc, hMask);
@@ -904,39 +991,6 @@ static long /*int*/ create32bitDIB (Image image) {
dp += 4;
}
}
- } else if (alpha != -1) {
- for (int y = 0, dp = 0; y < imgHeight; ++y) {
- for (int x = 0; x < imgWidth; ++x) {
- int r = ((srcData[dp + 0] & 0xFF) * alpha) + 128;
- r = (r + (r >> 8)) >> 8;
- int g = ((srcData[dp + 1] & 0xFF) * alpha) + 128;
- g = (g + (g >> 8)) >> 8;
- int b = ((srcData[dp + 2] & 0xFF) * alpha) + 128;
- b = (b + (b >> 8)) >> 8;
- srcData[dp+0] = (byte)r;
- srcData[dp+1] = (byte)g;
- srcData[dp+2] = (byte)b;
- srcData[dp+3] = (byte)alpha;
- dp += 4;
- }
- }
- } else if (alphaData != null) {
- for (int y = 0, dp = 0, ap = 0; y < imgHeight; ++y) {
- for (int x = 0; x < imgWidth; ++x) {
- int a = alphaData[ap++] & 0xFF;
- int r = ((srcData[dp + 0] & 0xFF) * a) + 128;
- r = (r + (r >> 8)) >> 8;
- int g = ((srcData[dp + 1] & 0xFF) * a) + 128;
- g = (g + (g >> 8)) >> 8;
- int b = ((srcData[dp + 2] & 0xFF) * a) + 128;
- b = (b + (b >> 8)) >> 8;
- srcData[dp+0] = (byte)r;
- srcData[dp+1] = (byte)g;
- srcData[dp+2] = (byte)b;
- srcData[dp+3] = (byte)a;
- dp += 4;
- }
- }
} else if (transparentPixel != -1) {
for (int y = 0, dp = 0; y < imgHeight; ++y) {
for (int x = 0; x < imgWidth; ++x) {
@@ -948,7 +1002,7 @@ static long /*int*/ create32bitDIB (Image image) {
dp += 4;
}
}
- } else {
+ } else if (alpha == -1 && alphaData == null) {
for (int y = 0, dp = 0; y < imgHeight; ++y) {
for (int x = 0; x < imgWidth; ++x) {
srcData [dp + 3] = (byte)0xFF;
@@ -966,15 +1020,15 @@ static long /*int*/ create32bitDIB (Image image) {
if (hMask != 0) OS.DeleteObject (hMask);
return memDib;
}
-static long /*int*/ create32bitDIB (long /*int*/ hBitmap, int alpha, byte [] alphaData, int transparentPixel) {
+static long create32bitDIB (long hBitmap, int alpha, byte [] alphaData, int transparentPixel) {
BITMAP bm = new BITMAP ();
OS.GetObject (hBitmap, BITMAP.sizeof, bm);
int imgWidth = bm.bmWidth;
int imgHeight = bm.bmHeight;
- long /*int*/ hDC = OS.GetDC (0);
- long /*int*/ srcHdc = OS.CreateCompatibleDC (hDC);
- long /*int*/ oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap);
- long /*int*/ memHdc = OS.CreateCompatibleDC (hDC);
+ long hDC = OS.GetDC (0);
+ long srcHdc = OS.CreateCompatibleDC (hDC);
+ long oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap);
+ long memHdc = OS.CreateCompatibleDC (hDC);
BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER ();
bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
bmiHeader.biWidth = imgWidth;
@@ -984,16 +1038,16 @@ static long /*int*/ create32bitDIB (long /*int*/ hBitmap, int alpha, byte [] alp
bmiHeader.biCompression = OS.BI_RGB;
byte [] bmi = new byte [BITMAPINFOHEADER.sizeof];
OS.MoveMemory (bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
- long /*int*/ [] pBits = new long /*int*/ [1];
- long /*int*/ memDib = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
+ long [] pBits = new long [1];
+ long memDib = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
if (memDib == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- long /*int*/ oldMemBitmap = OS.SelectObject (memHdc, memDib);
+ long oldMemBitmap = OS.SelectObject (memHdc, memDib);
BITMAP dibBM = new BITMAP ();
OS.GetObject (memDib, BITMAP.sizeof, dibBM);
int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight;
- OS.BitBlt (memHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY);
- byte red = 0, green = 0, blue = 0;
- if (transparentPixel != -1) {
+ OS.BitBlt (memHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY);
+ byte red = 0, green = 0, blue = 0;
+ if (transparentPixel != -1) {
if (bm.bmBitsPixel <= 8) {
byte [] color = new byte [4];
OS.GetDIBColorTable (srcHdc, transparentPixel, 1, color);
@@ -1019,17 +1073,22 @@ static long /*int*/ create32bitDIB (long /*int*/ hBitmap, int alpha, byte [] alp
break;
}
}
- }
+ }
OS.SelectObject (srcHdc, oldSrcBitmap);
OS.SelectObject (memHdc, oldMemBitmap);
OS.DeleteObject (srcHdc);
OS.DeleteObject (memHdc);
OS.ReleaseDC (0, hDC);
- byte [] srcData = new byte [sizeInBytes];
+ byte [] srcData = new byte [sizeInBytes];
OS.MoveMemory (srcData, pBits [0], sizeInBytes);
if (alpha != -1) {
for (int y = 0, dp = 0; y < imgHeight; ++y) {
for (int x = 0; x < imgWidth; ++x) {
+ if (alpha != 0) {
+ srcData [dp ] = (byte)((((srcData[dp ] & 0xFF) * 0xFF) + alpha / 2) / alpha);
+ srcData [dp + 1] = (byte)((((srcData[dp + 1] & 0xFF) * 0xFF) + alpha / 2) / alpha);
+ srcData [dp + 2] = (byte)((((srcData[dp + 2] & 0xFF) * 0xFF) + alpha / 2) / alpha);
+ }
srcData [dp + 3] = (byte)alpha;
dp += 4;
}
@@ -1037,7 +1096,13 @@ static long /*int*/ create32bitDIB (long /*int*/ hBitmap, int alpha, byte [] alp
} else if (alphaData != null) {
for (int y = 0, dp = 0, ap = 0; y < imgHeight; ++y) {
for (int x = 0; x < imgWidth; ++x) {
- srcData [dp + 3] = alphaData [ap++];
+ int a = alphaData [ap++] & 0xFF;
+ if (a != 0) {
+ srcData [dp ] = (byte)((((srcData[dp ] & 0xFF) * 0xFF) + a / 2) / a);
+ srcData [dp + 1] = (byte)((((srcData[dp + 1] & 0xFF) * 0xFF) + a / 2) / a);
+ srcData [dp + 2] = (byte)((((srcData[dp + 2] & 0xFF) * 0xFF) + a / 2) / a);
+ }
+ srcData [dp + 3] = (byte)a;
dp += 4;
}
}
@@ -1065,9 +1130,9 @@ static Image createIcon (Image image) {
return new Image (device, data, mask);
}
int width = data.width, height = data.height;
- long /*int*/ hMask, hBitmap;
- long /*int*/ hDC = device.internal_new_GC (null);
- long /*int*/ dstHdc = OS.CreateCompatibleDC (hDC), oldDstBitmap;
+ long hMask, hBitmap;
+ long hDC = device.internal_new_GC (null);
+ long dstHdc = OS.CreateCompatibleDC (hDC), oldDstBitmap;
hBitmap = Display.create32bitDIB (image.handle, data.alpha, data.alphaData, data.transparentPixel);
hMask = OS.CreateBitmap (width, height, 1, 1, null);
oldDstBitmap = OS.SelectObject (dstHdc, hMask);
@@ -1079,7 +1144,7 @@ static Image createIcon (Image image) {
info.fIcon = true;
info.hbmColor = hBitmap;
info.hbmMask = hMask;
- long /*int*/ hIcon = OS.CreateIconIndirect (info);
+ long hIcon = OS.CreateIconIndirect (info);
if (hIcon == 0) SWT.error(SWT.ERROR_NO_HANDLES);
OS.DeleteObject (hBitmap);
OS.DeleteObject (hMask);
@@ -1144,21 +1209,20 @@ public void disposeExec (Runnable runnable) {
void drawMenuBars () {
if (bars == null) return;
- for (int i=0; i<bars.length; i++) {
- Menu menu = bars [i];
+ for (Menu menu : bars) {
if (menu != null && !menu.isDisposed ()) menu.update ();
}
bars = null;
}
-long /*int*/ embeddedProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wParam, long /*int*/ lParam) {
- switch ((int)/*64*/msg) {
+long embeddedProc (long hwnd, long msg, long wParam, long lParam) {
+ switch ((int)msg) {
case SWT_KEYMSG: {
MSG keyMsg = new MSG ();
OS.MoveMemory (keyMsg, lParam, MSG.sizeof);
OS.TranslateMessage (keyMsg);
OS.DispatchMessage (keyMsg);
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
OS.HeapFree (hHeap, 0, lParam);
break;
}
@@ -1171,7 +1235,7 @@ long /*int*/ embeddedProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wPa
break;
}
}
- return OS.DefWindowProc (hwnd, (int)/*64*/msg, wParam, lParam);
+ return OS.DefWindowProc (hwnd, (int)msg, wParam, lParam);
}
/**
@@ -1219,9 +1283,9 @@ boolean filterMessage (MSG msg) {
return false;
}
-Control findControl (long /*int*/ handle) {
+Control findControl (long handle) {
if (handle == 0) return null;
- long /*int*/ hwndOwner = 0;
+ long hwndOwner = 0;
do {
Control control = getControl (handle);
if (control != null) return control;
@@ -1251,7 +1315,7 @@ Control findControl (long /*int*/ handle) {
*
* @noreference This method is not intended to be referenced by clients.
*/
-public Widget findWidget (long /*int*/ handle) {
+public Widget findWidget (long handle) {
checkDevice ();
return getControl (handle);
}
@@ -1280,7 +1344,7 @@ public Widget findWidget (long /*int*/ handle) {
*
* @since 3.1
*/
-public Widget findWidget (long /*int*/ handle, long /*int*/ id) {
+public Widget findWidget (long handle, long id) {
checkDevice ();
Control control = getControl (handle);
return control != null ? control.findItem (id) : null;
@@ -1305,7 +1369,7 @@ public Widget findWidget (long /*int*/ handle, long /*int*/ id) {
*
* @since 3.3
*/
-public Widget findWidget (Widget widget, long /*int*/ id) {
+public Widget findWidget (Widget widget, long id) {
checkDevice ();
if (widget instanceof Control) {
return findWidget (((Control) widget).handle, id);
@@ -1313,7 +1377,7 @@ public Widget findWidget (Widget widget, long /*int*/ id) {
return null;
}
-long /*int*/ foregroundIdleProc (long /*int*/ code, long /*int*/ wParam, long /*int*/ lParam) {
+long foregroundIdleProc (long code, long wParam, long lParam) {
if (code >= 0) {
if (getMessageCount () != 0) {
sendPostExternalEventDispatchEvent ();
@@ -1343,7 +1407,7 @@ long /*int*/ foregroundIdleProc (long /*int*/ code, long /*int*/ wParam, long /*
sendPreExternalEventDispatchEvent ();
}
}
- return OS.CallNextHookEx (idleHook, (int)/*64*/code, wParam, lParam);
+ return OS.CallNextHookEx (idleHook, (int)code, wParam, lParam);
}
/**
@@ -1358,8 +1422,7 @@ long /*int*/ foregroundIdleProc (long /*int*/ code, long /*int*/ wParam, long /*
*/
public static Display findDisplay (Thread thread) {
synchronized (Device.class) {
- for (int i=0; i<Displays.length; i++) {
- Display display = Displays [i];
+ for (Display display : Displays) {
if (display != null && display.thread == thread) {
return display;
}
@@ -1368,7 +1431,7 @@ public static Display findDisplay (Thread thread) {
}
}
-TouchSource findTouchSource (long /*int*/ touchDevice, Monitor monitor) {
+TouchSource findTouchSource (long touchDevice, Monitor monitor) {
if (touchSources == null) touchSources = new TouchSource [4];
int length = touchSources.length;
for (int i=0; i<length; i++) {
@@ -1466,7 +1529,7 @@ public static Display getCurrent () {
return findDisplay (Thread.currentThread ());
}
-int getClickCount (int type, int button, long /*int*/ hwnd, long /*int*/ lParam) {
+int getClickCount (int type, int button, long hwnd, long lParam) {
switch (type) {
case SWT.MouseDown:
int doubleClick = OS.GetDoubleClickTime ();
@@ -1530,7 +1593,7 @@ Rectangle getClientAreaInPixels () {
return new Rectangle (x, y, width, height);
}
-Control getControl (long /*int*/ handle) {
+Control getControl (long handle) {
if (handle == 0) return null;
if (lastControl != null && lastHwnd == handle) {
return lastControl;
@@ -1538,22 +1601,10 @@ Control getControl (long /*int*/ handle) {
if (lastGetControl != null && lastGetHwnd == handle) {
return lastGetControl;
}
- int index = (int)/*64*/OS.GetProp (handle, SWT_OBJECT_INDEX) - 1;
+ int index = (int)OS.GetProp (handle, SWT_OBJECT_INDEX) - 1;
if (0 <= index && index < controlTable.length) {
- Control control = controlTable [index];
- /*
- * Because GWL_USERDATA can be used by native widgets that
- * do not belong to SWT, it is possible that GWL_USERDATA
- * could return an index that is in the range of the table,
- * but was not put there by SWT. Therefore, it is necessary
- * to check the handle of the control that is in the table
- * against the handle that provided the GWL_USERDATA.
- */
- if (control != null && control.checkHandle (handle)) {
- lastGetHwnd = handle;
- lastGetControl = control;
- return control;
- }
+ lastGetHwnd = handle;
+ return lastGetControl = controlTable [index];
}
return null;
}
@@ -1693,6 +1744,9 @@ public Object getData (String key) {
if (key.equals (ACCEL_KEY_HIT)) {
return accelKeyHit;
}
+ if (key.equals (APPLOCAL_DIR_KEY)) {
+ return appLocalDir;
+ }
if (keys == null) return null;
for (int i=0; i<keys.length; i++) {
if (keys [i].equals (key)) return values [i];
@@ -1841,16 +1895,13 @@ public int getIconDepth () {
checkDevice ();
if (getDepth () >= 24) return 32;
- /* Use the character encoding for the default locale */
TCHAR buffer1 = new TCHAR (0, "Control Panel\\Desktop\\WindowMetrics", true); //$NON-NLS-1$
-
- long /*int*/ [] phkResult = new long /*int*/ [1];
+ long [] phkResult = new long [1];
int result = OS.RegOpenKeyEx (OS.HKEY_CURRENT_USER, buffer1, 0, OS.KEY_READ, phkResult);
if (result != 0) return 4;
int depth = 4;
int [] lpcbData = new int [1];
- /* Use the character encoding for the default locale */
TCHAR buffer2 = new TCHAR (0, "Shell Icon BPP", true); //$NON-NLS-1$
result = OS.RegQueryValueEx (phkResult [0], buffer2, 0, null, (TCHAR) null, lpcbData);
if (result == 0) {
@@ -2008,6 +2059,40 @@ ImageList getImageListToolBarHot (int style, int width, int height) {
return list;
}
+/**
+ * Returns <code>true</code> if the current OS theme has a dark appearance, else
+ * returns <code>false</code>.
+ * <p>
+ * Note: This operation is a hint and is not supported on platforms that do not
+ * have this concept.
+ * </p>
+ * <p>
+ * Note: Windows 10 onwards users can separately configure the theme for OS and
+ * Application level and this can be read from the Windows registry. Since the
+ * application needs to honor the application level theme, this API reads the
+ * Application level theme setting.
+ * </p>
+ *
+ * @return <code>true</code> if the current OS theme has a dark appearance, else
+ * returns <code>false</code>.
+ *
+ * @since 3.112
+ */
+public static boolean isSystemDarkTheme () {
+ boolean isDarkTheme = false;
+ /*
+ * The registry settings, and Dark Theme itself, is present since Win10 1809
+ */
+ if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN10_1809) {
+ int[] result = OS.readRegistryDwords(OS.HKEY_CURRENT_USER,
+ "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", "AppsUseLightTheme");
+ if (result!=null) {
+ isDarkTheme = (result[0] == 0);
+ }
+ }
+ return isDarkTheme;
+}
+
int getLastEventTime () {
return OS.GetMessageTime ();
}
@@ -2044,7 +2129,7 @@ Dialog getModalDialog () {
return modalDialog;
}
-Monitor getMonitor (long /*int*/ hmonitor) {
+Monitor getMonitor (long hmonitor) {
MONITORINFO lpmi = new MONITORINFO ();
lpmi.cbSize = MONITORINFO.sizeof;
OS.GetMonitorInfo (hmonitor, lpmi);
@@ -2081,9 +2166,7 @@ public Monitor [] getMonitors () {
checkDevice ();
monitors = new Monitor [4];
Callback callback = new Callback (this, "monitorEnumProc", 4); //$NON-NLS-1$
- long /*int*/ lpfnEnum = callback.getAddress ();
- if (lpfnEnum == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- OS.EnumDisplayMonitors (0, null, lpfnEnum, 0);
+ OS.EnumDisplayMonitors (0, null, callback.getAddress (), 0);
callback.dispose ();
Monitor [] result = new Monitor [monitorCount];
System.arraycopy (monitors, 0, result, 0, monitorCount);
@@ -2092,9 +2175,9 @@ public Monitor [] getMonitors () {
return result;
}
-long /*int*/ getMsgProc (long /*int*/ code, long /*int*/ wParam, long /*int*/ lParam) {
+long getMsgProc (long code, long wParam, long lParam) {
if (embeddedHwnd == 0) {
- long /*int*/ hInstance = OS.GetModuleHandle (null);
+ long hInstance = OS.GetModuleHandle (null);
embeddedHwnd = OS.CreateWindowEx (0,
windowClass,
null,
@@ -2106,7 +2189,6 @@ long /*int*/ getMsgProc (long /*int*/ code, long /*int*/ wParam, long /*int*/ lP
null);
embeddedCallback = new Callback (this, "embeddedProc", 4); //$NON-NLS-1$
embeddedProc = embeddedCallback.getAddress ();
- if (embeddedProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
OS.SetWindowLongPtr (embeddedHwnd, OS.GWLP_WNDPROC, embeddedProc);
}
if (code >= 0 && (wParam & OS.PM_REMOVE) != 0) {
@@ -2119,11 +2201,11 @@ long /*int*/ getMsgProc (long /*int*/ code, long /*int*/ wParam, long /*int*/ lP
case OS.WM_SYSKEYUP: {
Control control = findControl (msg.hwnd);
if (control != null) {
- long /*int*/ hHeap = OS.GetProcessHeap ();
- long /*int*/ keyMsg = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, MSG.sizeof);
+ long hHeap = OS.GetProcessHeap ();
+ long keyMsg = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, MSG.sizeof);
OS.MoveMemory (keyMsg, msg, MSG.sizeof);
OS.PostMessage (hwndMessage, SWT_KEYMSG, wParam, keyMsg);
- switch ((int)/*64*/msg.wParam) {
+ switch ((int)msg.wParam) {
case OS.VK_SHIFT:
case OS.VK_MENU:
case OS.VK_CONTROL:
@@ -2139,7 +2221,7 @@ long /*int*/ getMsgProc (long /*int*/ code, long /*int*/ wParam, long /*int*/ lP
}
}
}
- return OS.CallNextHookEx (msgHook, (int)/*64*/code, wParam, lParam);
+ return OS.CallNextHookEx (msgHook, (int)code, wParam, lParam);
}
/**
@@ -2151,7 +2233,7 @@ long /*int*/ getMsgProc (long /*int*/ code, long /*int*/ wParam, long /*int*/ lP
*/
public Monitor getPrimaryMonitor () {
checkDevice ();
- long /*int*/ hmonitor = OS.MonitorFromWindow (0, OS.MONITOR_DEFAULTTOPRIMARY);
+ long hmonitor = OS.MonitorFromWindow (0, OS.MONITOR_DEFAULTTOPRIMARY);
return getMonitor (hmonitor);
}
@@ -2170,9 +2252,8 @@ public Shell [] getShells () {
checkDevice ();
int index = 0;
Shell [] result = new Shell [16];
- for (int i = 0; i < controlTable.length; i++) {
- Control control = controlTable [i];
- if (control != null && control instanceof Shell) {
+ for (Control control : controlTable) {
+ if (control instanceof Shell) {
int j = 0;
while (j < index) {
if (result [j] == control) break;
@@ -2258,9 +2339,11 @@ public Color getSystemColor (int id) {
int pixel = 0x00000000;
switch (id) {
case SWT.COLOR_WIDGET_DARK_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DDKSHADOW); break;
+ case SWT.COLOR_WIDGET_DISABLED_FOREGROUND: pixel = OS.GetSysColor(OS.COLOR_GRAYTEXT); break;
case SWT.COLOR_WIDGET_NORMAL_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DSHADOW); break;
case SWT.COLOR_WIDGET_LIGHT_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DLIGHT); break;
case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DHIGHLIGHT); break;
+ case SWT.COLOR_TEXT_DISABLED_BACKGROUND:
case SWT.COLOR_WIDGET_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_3DFACE); break;
case SWT.COLOR_WIDGET_BORDER: pixel = OS.GetSysColor (OS.COLOR_WINDOWFRAME); break;
case SWT.COLOR_WIDGET_FOREGROUND:
@@ -2365,7 +2448,7 @@ public Cursor getSystemCursor (int id) {
public Font getSystemFont () {
checkDevice ();
if (systemFont != null) return systemFont;
- long /*int*/ hFont = 0;
+ long hFont = 0;
NONCLIENTMETRICS info = new NONCLIENTMETRICS ();
info.cbSize = NONCLIENTMETRICS.sizeof;
if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) {
@@ -2409,23 +2492,23 @@ public Image getSystemImage (int id) {
switch (id) {
case SWT.ICON_ERROR: {
if (errorImage != null) return errorImage;
- long /*int*/ hIcon = OS.LoadImage (0, OS.OIC_HAND, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
+ long hIcon = OS.LoadImage (0, OS.OIC_HAND, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
return errorImage = Image.win32_new (this, SWT.ICON, hIcon);
}
case SWT.ICON_WORKING:
case SWT.ICON_INFORMATION: {
if (infoImage != null) return infoImage;
- long /*int*/ hIcon = OS.LoadImage (0, OS.OIC_INFORMATION, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
+ long hIcon = OS.LoadImage (0, OS.OIC_INFORMATION, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
return infoImage = Image.win32_new (this, SWT.ICON, hIcon);
}
case SWT.ICON_QUESTION: {
if (questionImage != null) return questionImage;
- long /*int*/ hIcon = OS.LoadImage (0, OS.OIC_QUES, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
+ long hIcon = OS.LoadImage (0, OS.OIC_QUES, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
return questionImage = Image.win32_new (this, SWT.ICON, hIcon);
}
case SWT.ICON_WARNING: {
if (warningIcon != null) return warningIcon;
- long /*int*/ hIcon = OS.LoadImage (0, OS.OIC_BANG, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
+ long hIcon = OS.LoadImage (0, OS.OIC_BANG, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
return warningIcon = Image.win32_new (this, SWT.ICON, hIcon);
}
}
@@ -2466,7 +2549,15 @@ public TaskBar getSystemTaskBar () {
checkDevice ();
if (taskBar != null) return taskBar;
if (OS.WIN32_VERSION >= OS.VERSION (6, 1)) {
- taskBar = new TaskBar (this, SWT.NONE);
+ try {
+ taskBar = new TaskBar (this, SWT.NONE);
+ } catch (SWTError e) {
+ if (e.code == SWT.ERROR_NOT_IMPLEMENTED) {
+ // Windows Server Core doesn't have a Taskbar
+ return null;
+ }
+ throw e;
+ }
}
return taskBar;
}
@@ -2524,27 +2615,27 @@ public boolean getTouchEnabled () {
return (value & (OS.NID_READY | OS.NID_MULTI_INPUT)) == (OS.NID_READY | OS.NID_MULTI_INPUT);
}
-long /*int*/ hButtonTheme () {
+long hButtonTheme () {
if (hButtonTheme != 0) return hButtonTheme;
return hButtonTheme = OS.OpenThemeData (hwndMessage, BUTTON);
}
-long /*int*/ hEditTheme () {
+long hEditTheme () {
if (hEditTheme != 0) return hEditTheme;
return hEditTheme = OS.OpenThemeData (hwndMessage, EDIT);
}
-long /*int*/ hExplorerBarTheme () {
+long hExplorerBarTheme () {
if (hExplorerBarTheme != 0) return hExplorerBarTheme;
return hExplorerBarTheme = OS.OpenThemeData (hwndMessage, EXPLORERBAR);
}
-long /*int*/ hScrollBarTheme () {
+long hScrollBarTheme () {
if (hScrollBarTheme != 0) return hScrollBarTheme;
return hScrollBarTheme = OS.OpenThemeData (hwndMessage, SCROLLBAR);
}
-long /*int*/ hTabTheme () {
+long hTabTheme () {
if (hTabTheme != 0) return hTabTheme;
return hTabTheme = OS.OpenThemeData (hwndMessage, TAB);
}
@@ -2572,9 +2663,9 @@ long /*int*/ hTabTheme () {
* @noreference This method is not intended to be referenced by clients.
*/
@Override
-public long /*int*/ internal_new_GC (GCData data) {
+public long internal_new_GC (GCData data) {
if (isDisposed()) error(SWT.ERROR_DEVICE_DISPOSED);
- long /*int*/ hDC = OS.GetDC (0);
+ long hDC = OS.GetDC (0);
if (hDC == 0) error (SWT.ERROR_NO_HANDLES);
if (data != null) {
int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
@@ -2610,7 +2701,7 @@ protected void init () {
int length = APP_NAME.length ();
appName = new char [length + 1];
APP_NAME.getChars (0, length, appName, 0);
- long /*int*/ [] appID = new long /*int*/ [1];
+ long [] appID = new long [1];
if (OS.GetCurrentProcessExplicitAppUserModelID(appID) != 0) {
OS.SetCurrentProcessExplicitAppUserModelID (appName);
}
@@ -2621,19 +2712,17 @@ protected void init () {
/* Create the callbacks */
windowCallback = new Callback (this, "windowProc", 4); //$NON-NLS-1$
windowProc = windowCallback.getAddress ();
- if (windowProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
/* Remember the current thread id */
threadId = OS.GetCurrentThreadId ();
- /* Use the character encoding for the default locale */
windowClass = new TCHAR (0, WindowName + WindowClassCount, true);
windowShadowClass = new TCHAR (0, WindowShadowName + WindowClassCount, true);
windowOwnDCClass = new TCHAR (0, WindowOwnDCName + WindowClassCount, true);
WindowClassCount++;
/* Register the SWT window class */
- long /*int*/ hInstance = OS.GetModuleHandle (null);
+ long hInstance = OS.GetModuleHandle (null);
WNDCLASS lpWndClass = new WNDCLASS ();
lpWndClass.hInstance = hInstance;
lpWndClass.lpfnWndProc = windowProc;
@@ -2664,19 +2753,16 @@ protected void init () {
OS.SetWindowText(hwndMessage, new TCHAR(0, title, true));
messageCallback = new Callback (this, "messageProc", 4); //$NON-NLS-1$
messageProc = messageCallback.getAddress ();
- if (messageProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
OS.SetWindowLongPtr (hwndMessage, OS.GWLP_WNDPROC, messageProc);
/* Create the filter hook */
msgFilterCallback = new Callback (this, "msgFilterProc", 3); //$NON-NLS-1$
msgFilterProc = msgFilterCallback.getAddress ();
- if (msgFilterProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
filterHook = OS.SetWindowsHookEx (OS.WH_MSGFILTER, msgFilterProc, 0, threadId);
/* Create the idle hook */
foregroundIdleCallback = new Callback (this, "foregroundIdleProc", 3); //$NON-NLS-1$
foregroundIdleProc = foregroundIdleCallback.getAddress ();
- if (foregroundIdleProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
idleHook = OS.SetWindowsHookEx (OS.WH_FOREGROUNDIDLE, foregroundIdleProc, 0, threadId);
/* Register window messages */
@@ -2691,16 +2777,18 @@ protected void init () {
if (appName != null) {
/* Delete any old jump list set for the ID */
- long /*int*/ [] ppv = new long /*int*/ [1];
- int hr = OS.CoCreateInstance (TaskBar.CLSID_DestinationList, 0, OS.CLSCTX_INPROC_SERVER, TaskBar.IID_ICustomDestinationList, ppv);
+ long [] ppv = new long [1];
+ int hr = COM.CoCreateInstance (COM.CLSID_DestinationList, 0, COM.CLSCTX_INPROC_SERVER, COM.IID_ICustomDestinationList, ppv);
if (hr == OS.S_OK) {
- /*ICustomDestinationList::DeleteList*/
- OS.VtblCall (10, ppv [0], appName);
- /*IUnknown::Release*/
- OS.VtblCall (2, ppv [0]);
+ ICustomDestinationList pList = new ICustomDestinationList (ppv [0]);
+ pList.DeleteList (appName);
+ pList.Release ();
}
}
+ /* Application-specific data directory. */
+ appLocalDir = System.getenv("LOCALAPPDATA") + "\\" + Display.APP_NAME.replaceAll("[\\\\/:*?\"<>|]", "_");
+
/* Initialize buffered painting */
OS.BufferedPaintInit ();
@@ -2727,24 +2815,18 @@ protected void init () {
* @noreference This method is not intended to be referenced by clients.
*/
@Override
-public void internal_dispose_GC (long /*int*/ hDC, GCData data) {
+public void internal_dispose_GC (long hDC, GCData data) {
OS.ReleaseDC (0, hDC);
}
boolean isXMouseActive () {
/*
* NOTE: X-Mouse is active when bit 1 of the UserPreferencesMask is set.
- */
+ */
boolean xMouseActive = false;
- TCHAR key = new TCHAR (0, "Control Panel\\Desktop", true); //$NON-NLS-1$
- long /*int*/ [] phKey = new long /*int*/ [1];
- int result = OS.RegOpenKeyEx (OS.HKEY_CURRENT_USER, key, 0, OS.KEY_READ, phKey);
- if (result == 0) {
- TCHAR lpValueName = new TCHAR (0, "UserPreferencesMask", true); //$NON-NLS-1$
- int [] lpcbData = new int [] {4}, lpData = new int [1];
- result = OS.RegQueryValueEx (phKey [0], lpValueName, 0, null, lpData, lpcbData);
- if (result == 0) xMouseActive = (lpData [0] & 0x01) != 0;
- OS.RegCloseKey (phKey [0]);
+ int[] result = OS.readRegistryDwords(OS.HKEY_CURRENT_USER, "Control Panel\\Desktop", "UserPreferencesMask");
+ if (result!=null) {
+ xMouseActive = (result[0] & 0x01) != 0;
}
return xMouseActive;
}
@@ -2847,8 +2929,8 @@ Point mapInPixels (Control from, Control to, int x, int y) {
if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (from == to) return new Point (x, y);
- long /*int*/ hwndFrom = from != null ? from.handle : 0;
- long /*int*/ hwndTo = to != null ? to.handle : 0;
+ long hwndFrom = from != null ? from.handle : 0;
+ long hwndTo = to != null ? to.handle : 0;
POINT point = new POINT ();
point.x = x;
point.y = y;
@@ -2954,8 +3036,8 @@ Rectangle mapInPixels (Control from, Control to, int x, int y, int width, int he
if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (from == to) return new Rectangle (x, y, width, height);
- long /*int*/ hwndFrom = from != null ? from.handle : 0;
- long /*int*/ hwndTo = to != null ? to.handle : 0;
+ long hwndFrom = from != null ? from.handle : 0;
+ long hwndTo = to != null ? to.handle : 0;
RECT rect = new RECT ();
rect.left = x;
rect.top = y;
@@ -2965,8 +3047,8 @@ Rectangle mapInPixels (Control from, Control to, int x, int y, int width, int he
return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
}
-long /*int*/ messageProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wParam, long /*int*/ lParam) {
- switch ((int)/*64*/msg) {
+long messageProc (long hwnd, long msg, long wParam, long lParam) {
+ switch ((int)msg) {
case SWT_RUNASYNC: {
if (runMessagesInIdle) runAsyncMessages (false);
break;
@@ -2990,7 +3072,7 @@ long /*int*/ messageProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wPar
switch (keyMsg.message) {
case OS.WM_KEYDOWN:
case OS.WM_SYSKEYDOWN: {
- switch ((int)/*64*/keyMsg.wParam) {
+ switch ((int)keyMsg.wParam) {
case OS.VK_SHIFT:
case OS.VK_MENU:
case OS.VK_CONTROL:
@@ -2999,12 +3081,12 @@ long /*int*/ messageProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wPar
case OS.VK_SCROLL:
break;
default: {
- int mapKey = OS.MapVirtualKey ((int)/*64*/keyMsg.wParam, 2);
+ int mapKey = OS.MapVirtualKey ((int)keyMsg.wParam, 2);
if (mapKey != 0) {
accentKey = (mapKey & 0x80000000) != 0;
if (!accentKey) {
- for (int i=0; i<ACCENTS.length; i++) {
- int value = OS.VkKeyScan (ACCENTS [i]);
+ for (short accent : ACCENTS) {
+ int value = OS.VkKeyScan (accent);
if (value != -1 && (value & 0xFF) == keyMsg.wParam) {
int state = value >> 8;
if ((OS.GetKeyState (OS.VK_SHIFT) < 0) == ((state & 0x1) != 0) &&
@@ -3036,7 +3118,7 @@ long /*int*/ messageProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wPar
switch (keyMsg.message) {
case OS.WM_KEYDOWN:
case OS.WM_SYSKEYDOWN: {
- switch ((int)/*64*/keyMsg.wParam) {
+ switch ((int)keyMsg.wParam) {
case OS.VK_SHIFT:
case OS.VK_MENU:
case OS.VK_CONTROL:
@@ -3052,7 +3134,7 @@ long /*int*/ messageProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wPar
}
}
}
- switch ((int)/*64*/keyMsg.wParam) {
+ switch ((int)keyMsg.wParam) {
case OS.VK_SHIFT:
case OS.VK_MENU:
case OS.VK_CONTROL:
@@ -3062,7 +3144,7 @@ long /*int*/ messageProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wPar
consumed = true;
}
if (consumed) {
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
OS.HeapFree (hHeap, 0, lParam);
} else {
OS.PostMessage (embeddedHwnd, SWT_KEYMSG, wParam, lParam);
@@ -3071,11 +3153,9 @@ long /*int*/ messageProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wPar
}
case SWT_TRAYICONMSG: {
if (tray != null) {
- TrayItem [] items = tray.items;
- for (int i=0; i<items.length; i++) {
- TrayItem item = items [i];
+ for (TrayItem item : tray.items) {
if (item != null && item.id == wParam) {
- return item.messageProc (hwnd, (int)/*64*/msg, wParam, lParam);
+ return item.messageProc (hwnd, (int)msg, wParam, lParam);
}
}
}
@@ -3103,16 +3183,16 @@ long /*int*/ messageProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wPar
*/
if (wParam != 0) {
if (!isXMouseActive ()) {
- long /*int*/ hwndActive = OS.GetActiveWindow ();
+ long hwndActive = OS.GetActiveWindow ();
if (hwndActive != 0 && OS.IsWindowEnabled (hwndActive)) break;
Shell modal = modalDialog != null ? modalDialog.parent : getModalShell ();
if (modal != null && !modal.isDisposed ()) {
- long /*int*/ hwndModal = modal.handle;
+ long hwndModal = modal.handle;
if (OS.IsWindowEnabled (hwndModal)) {
modal.bringToTop ();
if (modal.isDisposed ()) break;
}
- long /*int*/ hwndPopup = OS.GetLastActivePopup (hwndModal);
+ long hwndPopup = OS.GetLastActivePopup (hwndModal);
if (hwndPopup != 0 && hwndPopup != modal.handle) {
if (getControl (hwndPopup) == null) {
if (OS.IsWindowEnabled (hwndPopup)) {
@@ -3128,13 +3208,6 @@ long /*int*/ messageProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wPar
case OS.WM_ENDSESSION: {
if (wParam != 0) {
dispose ();
- /*
- * When the session is ending, no SWT program can continue
- * to run. In order to avoid running code after the display
- * has been disposed, exit from Java.
- */
- /* This code is intentionally commented */
-// System.exit (0);
}
break;
}
@@ -3169,17 +3242,15 @@ long /*int*/ messageProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wPar
break;
}
default: {
- if ((int)/*64*/msg == TASKBARCREATED) {
+ if ((int)msg == TASKBARCREATED) {
if (tray != null) {
- TrayItem [] items = tray.items;
- for (int i=0; i<items.length; i++) {
- TrayItem item = items [i];
+ for (TrayItem item : tray.items) {
if (item != null) item.recreate ();
}
}
}
- if ((int)/*64*/msg == SWT_OPENDOC) {
- String filename = getSharedData((int)/*64*/wParam, (int)/*64*/lParam);
+ if ((int)msg == SWT_OPENDOC) {
+ String filename = getSharedData((int)wParam, (int)lParam);
if (filename != null) {
if (filename.startsWith (TASKBAR_EVENT)) {
String text = filename.substring (TASKBAR_EVENT.length ());
@@ -3203,21 +3274,21 @@ long /*int*/ messageProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wPar
}
}
}
- return OS.DefWindowProc (hwnd, (int)/*64*/msg, wParam, lParam);
+ return OS.DefWindowProc (hwnd, (int)msg, wParam, lParam);
}
String getSharedData(int pid, int handle) {
- long /*int*/ [] mapHandle = new long /*int*/ [1];
+ long [] mapHandle = new long [1];
if (pid == OS.GetCurrentProcessId()) {
mapHandle[0] = handle;
} else {
- long /*int*/ processHandle = OS.OpenProcess(OS.PROCESS_VM_READ|OS.PROCESS_DUP_HANDLE, false, pid);
+ long processHandle = OS.OpenProcess(OS.PROCESS_VM_READ|OS.PROCESS_DUP_HANDLE, false, pid);
if (processHandle == 0) return null;
OS.DuplicateHandle(processHandle, handle, OS.GetCurrentProcess(), mapHandle, OS.DUPLICATE_SAME_ACCESS, false, OS.DUPLICATE_SAME_ACCESS);
OS.CloseHandle(processHandle);
}
- long /*int*/ sharedData = OS.MapViewOfFile(mapHandle[0], OS.FILE_MAP_READ, 0, 0, 0);
+ long sharedData = OS.MapViewOfFile(mapHandle[0], OS.FILE_MAP_READ, 0, 0, 0);
if (sharedData == 0) return null;
int length = OS.wcslen (sharedData);
TCHAR buffer = new TCHAR (0, length);
@@ -3231,7 +3302,7 @@ String getSharedData(int pid, int handle) {
return result;
}
-long /*int*/ monitorEnumProc (long /*int*/ hmonitor, long /*int*/ hdc, long /*int*/ lprcMonitor, long /*int*/ dwData) {
+long monitorEnumProc (long hmonitor, long hdc, long lprcMonitor, long dwData) {
if (monitorCount >= monitors.length) {
Monitor[] newMonitors = new Monitor [monitors.length + 4];
System.arraycopy (monitors, 0, newMonitors, 0, monitors.length);
@@ -3241,8 +3312,8 @@ long /*int*/ monitorEnumProc (long /*int*/ hmonitor, long /*int*/ hdc, long /*in
return 1;
}
-long /*int*/ msgFilterProc (long /*int*/ code, long /*int*/ wParam, long /*int*/ lParam) {
- switch ((int)/*64*/code) {
+long msgFilterProc (long code, long wParam, long lParam) {
+ switch ((int)code) {
case OS.MSGF_COMMCTRL_BEGINDRAG: {
if (!runDragDrop && !dragCancelled) {
OS.MoveMemory (hookMsg, lParam, MSG.sizeof);
@@ -3279,7 +3350,7 @@ long /*int*/ msgFilterProc (long /*int*/ code, long /*int*/ wParam, long /*int*/
break;
}
}
- return OS.CallNextHookEx (filterHook, (int)/*64*/code, wParam, lParam);
+ return OS.CallNextHookEx (filterHook, (int)code, wParam, lParam);
}
int numpadKey (int key) {
@@ -3416,14 +3487,10 @@ public boolean post (Event event) {
case OS.VK_DIVIDE:
inputs.dwFlags |= OS.KEYEVENTF_EXTENDEDKEY;
}
- long /*int*/ hHeap = OS.GetProcessHeap ();
- long /*int*/ pInputs = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof);
- OS.MoveMemory(pInputs, new int[] {OS.INPUT_KEYBOARD}, 4);
- //TODO - DWORD type of INPUT structure aligned to 8 bytes on 64 bit
- OS.MoveMemory (pInputs + C.PTR_SIZEOF, inputs, KEYBDINPUT.sizeof);
- boolean result = OS.SendInput (1, pInputs, INPUT.sizeof) != 0;
- OS.HeapFree (hHeap, 0, pInputs);
- return result;
+ INPUT pInputs = new INPUT ();
+ pInputs.type = OS.INPUT_KEYBOARD;
+ pInputs.ki = inputs;
+ return OS.SendInput (1, pInputs, INPUT.sizeof) != 0;
}
case SWT.MouseDown:
case SWT.MouseMove:
@@ -3472,14 +3539,10 @@ public boolean post (Event event) {
}
}
}
- long /*int*/ hHeap = OS.GetProcessHeap ();
- long /*int*/ pInputs = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof);
- OS.MoveMemory(pInputs, new int[] {OS.INPUT_MOUSE}, 4);
- //TODO - DWORD type of INPUT structure aligned to 8 bytes on 64 bit
- OS.MoveMemory (pInputs + C.PTR_SIZEOF, inputs, MOUSEINPUT.sizeof);
- boolean result = OS.SendInput (1, pInputs, INPUT.sizeof) != 0;
- OS.HeapFree (hHeap, 0, pInputs);
- return result;
+ INPUT pInputs = new INPUT ();
+ pInputs.type = OS.INPUT_MOUSE;
+ pInputs.mi = inputs;
+ return OS.SendInput (1, pInputs, INPUT.sizeof) != 0;
}
}
return false;
@@ -3591,36 +3654,61 @@ static void register (Display display) {
*/
@Override
protected void release () {
- sendEvent (SWT.Dispose, new Event ());
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
- if (!shell.isDisposed ()) shell.dispose ();
- }
- if (tray != null) tray.dispose ();
- tray = null;
- if (taskBar != null) taskBar.dispose ();
- taskBar = null;
- while (readAndDispatch ()) {}
- if (disposeList != null) {
- for (int i=0; i<disposeList.length; i++) {
- Runnable next = disposeList [i];
- if (next != null) {
+ try (ExceptionStash exceptions = new ExceptionStash ()) {
+ try {
+ sendEvent (SWT.Dispose, new Event ());
+ } catch (Error | RuntimeException ex) {
+ exceptions.stash (ex);
+ }
+
+ for (Shell shell : getShells ()) {
+ try {
+ if (!shell.isDisposed ()) shell.dispose ();
+ } catch (Error | RuntimeException ex) {
+ exceptions.stash (ex);
+ }
+ }
+
+ try {
+ if (tray != null) tray.dispose ();
+ } catch (Error | RuntimeException ex) {
+ exceptions.stash (ex);
+ }
+ tray = null;
+
+ try {
+ if (taskBar != null) taskBar.dispose ();
+ } catch (Error | RuntimeException ex) {
+ exceptions.stash (ex);
+ }
+ taskBar = null;
+
+ for (;;) {
+ try {
+ if (!readAndDispatch ()) break;
+ } catch (Error | RuntimeException ex) {
+ exceptions.stash (ex);
+ }
+ }
+
+ if (disposeList != null) {
+ for (Runnable next : disposeList) {
+ if (next == null) continue;
+
try {
next.run ();
- } catch (RuntimeException exception) {
- runtimeExceptionHandler.accept (exception);
- } catch (Error error) {
- errorHandler.accept (error);
+ } catch (Error | RuntimeException ex) {
+ exceptions.stash (ex);
}
}
}
+ disposeList = null;
+
+ synchronizer.releaseSynchronizer ();
+ synchronizer = null;
+ releaseDisplay ();
+ super.release ();
}
- disposeList = null;
- synchronizer.releaseSynchronizer ();
- synchronizer = null;
- releaseDisplay ();
- super.release ();
}
void releaseDisplay () {
@@ -3628,6 +3716,10 @@ void releaseDisplay () {
OS.PostMessage (embeddedHwnd, SWT_DESTROY, 0, 0);
}
+ /* Free custom icons */
+ if (hIconSearch != 0) OS.DestroyIcon (hIconSearch);
+ if (hIconCancel != 0) OS.DestroyIcon (hIconCancel);
+
/* Release XP Themes */
if (hButtonTheme != 0) OS.CloseThemeData (hButtonTheme);
if (hEditTheme != 0) OS.CloseThemeData (hEditTheme);
@@ -3635,6 +3727,8 @@ void releaseDisplay () {
if (hScrollBarTheme != 0) OS.CloseThemeData (hScrollBarTheme);
if (hTabTheme != 0) OS.CloseThemeData (hTabTheme);
hButtonTheme = hEditTheme = hExplorerBarTheme = hScrollBarTheme = hTabTheme = 0;
+ if (menuBarBorderPen != 0) OS.DeleteObject (menuBarBorderPen);
+ menuBarBorderPen = 0;
/* Unhook the message hook */
if (msgHook != 0) OS.UnhookWindowsHookEx (msgHook);
@@ -3665,8 +3759,8 @@ void releaseDisplay () {
messageProc = 0;
/* Unregister the SWT window class */
- long /*int*/ hHeap = OS.GetProcessHeap ();
- long /*int*/ hInstance = OS.GetModuleHandle (null);
+ long hHeap = OS.GetProcessHeap ();
+ long hInstance = OS.GetModuleHandle (null);
OS.UnregisterClass (windowClass, hInstance);
/* Unregister the SWT drop shadow and CS_OWNDC window class */
@@ -3690,15 +3784,15 @@ void releaseDisplay () {
errorImage = infoImage = questionImage = warningIcon = null;
/* Release the System Cursors */
- for (int i = 0; i < cursors.length; i++) {
- if (cursors [i] != null) cursors [i].dispose ();
+ for (Cursor cursor : cursors) {
+ if (cursor != null) cursor.dispose ();
}
cursors = null;
/* Release Acquired Resources */
if (resources != null) {
- for (int i=0; i<resources.length; i++) {
- if (resources [i] != null) resources [i].dispose ();
+ for (Resource resource : resources) {
+ if (resource != null) resource.dispose ();
}
resources = null;
}
@@ -3886,11 +3980,11 @@ void removeBar (Menu menu) {
}
}
-Control removeControl (long /*int*/ handle) {
+Control removeControl (long handle) {
if (handle == 0) return null;
lastControl = lastGetControl = null;
Control control = null;
- int index = (int)/*64*/OS.RemoveProp (handle, SWT_OBJECT_INDEX) - 1;
+ int index = (int)OS.RemoveProp (handle, SWT_OBJECT_INDEX) - 1;
if (0 <= index && index < controlTable.length) {
control = controlTable [index];
controlTable [index] = null;
@@ -3995,15 +4089,11 @@ void runSettings () {
sendEvent (SWT.Settings, null);
Font newFont = getSystemFont ();
boolean sameFont = oldFont.equals (newFont);
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
+ for (Shell shell : getShells ()) {
if (!shell.isDisposed ()) {
if (!sameFont) {
shell.updateFont (oldFont, newFont);
}
- /* This code is intentionally commented */
- //shell.redraw (true);
shell.layout (true, true);
}
}
@@ -4032,7 +4122,7 @@ boolean runSkin () {
return false;
}
-boolean runTimer (long /*int*/ id) {
+boolean runTimer (long id) {
if (timerList != null && timerIds != null) {
int index = 0;
while (index <timerIds.length) {
@@ -4225,6 +4315,15 @@ public void setCursorLocation (Point point) {
setCursorLocation (point.x, point.y);
}
+boolean _toBoolean (Object value) {
+ return value != null && ((Boolean)value).booleanValue ();
+}
+
+int _toColorPixel (Object value) {
+ if (value == null) return -1;
+ return ((Color)value).handle;
+}
+
/**
* Sets the application defined property of the receiver
* with the specified name to the given argument.
@@ -4254,26 +4353,102 @@ public void setData (String key, Object value) {
checkDevice ();
if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (key.equals (RUN_MESSAGES_IN_IDLE_KEY)) {
- Boolean data = (Boolean) value;
- runMessagesInIdle = data != null && data.booleanValue ();
- return;
- }
- if (key.equals (RUN_MESSAGES_IN_MESSAGE_PROC_KEY)) {
- Boolean data = (Boolean) value;
- runMessagesInMessageProc = data != null && data.booleanValue ();
- return;
- }
- if (key.equals (USE_OWNDC_KEY)) {
- Boolean data = (Boolean) value;
- useOwnDC = data != null && data.booleanValue ();
- return;
- }
- if (key.equals (ACCEL_KEY_HIT)) {
- Boolean data = (Boolean) value;
- accelKeyHit = data != null && data.booleanValue ();
- return;
+ switch (key) {
+ case RUN_MESSAGES_IN_IDLE_KEY:
+ runMessagesInIdle = _toBoolean (value);
+ return;
+ case RUN_MESSAGES_IN_MESSAGE_PROC_KEY:
+ runMessagesInMessageProc = _toBoolean (value);
+ return;
+ case USE_OWNDC_KEY:
+ useOwnDC = _toBoolean (value);
+ return;
+ case ACCEL_KEY_HIT:
+ accelKeyHit = _toBoolean (value);
+ return;
+ case EXTERNAL_EVENT_LOOP_KEY:
+ externalEventLoop = _toBoolean (value);
+ return;
+ case USE_DARKMODE_EXPLORER_THEME_KEY:
+ useDarkModeExplorerTheme = _toBoolean (value) &&
+ !disableCustomThemeTweaks &&
+ OS.IsDarkModeAvailable ();
+
+ /* Modify the per-application flag. Note that as of Windows 2004,
+ * APIs are still undocumented, and two more steps are needed to
+ * make window dark, see Control.enableDarkSystemTheme()
+ *
+ * Undocumented argument is:
+ * enum class PreferredAppMode
+ * {
+ * Default = 0,
+ * AllowDark = 1,
+ * ForceDark = 2,
+ * ForceLight = 3,
+ * Max = 4,
+ * };
+ */
+ final int PreferredAppMode_Default = 0;
+ final int PreferredAppMode_ForceDark = 2;
+ if (useDarkModeExplorerTheme) {
+ OS.SetPreferredAppMode(PreferredAppMode_ForceDark);
+ } else {
+ OS.SetPreferredAppMode(PreferredAppMode_Default);
+ }
+ return;
+ case USE_SHELL_TITLE_COLORING:
+ useShellTitleColoring = !disableCustomThemeTweaks && _toBoolean(value);
+ return;
+ case MENUBAR_FOREGROUND_COLOR_KEY:
+ menuBarForegroundPixel = disableCustomThemeTweaks ? -1 : _toColorPixel(value);
+ return;
+ case MENUBAR_BACKGROUND_COLOR_KEY:
+ menuBarBackgroundPixel = disableCustomThemeTweaks ? -1 : _toColorPixel(value);
+ return;
+ case MENUBAR_BORDER_COLOR_KEY:
+ if (menuBarBorderPen != 0)
+ OS.DeleteObject(menuBarBorderPen);
+
+ int pixel = _toColorPixel(value);
+ if (disableCustomThemeTweaks || (pixel == -1))
+ menuBarBorderPen = 0;
+ else
+ menuBarBorderPen = OS.CreatePen (OS.PS_SOLID, 1, pixel);
+ return;
+ case USE_WS_BORDER_ALL_KEY:
+ useWsBorderAll = !disableCustomThemeTweaks && _toBoolean(value);
+ return;
+ case USE_WS_BORDER_CANVAS_KEY:
+ useWsBorderCanvas = !disableCustomThemeTweaks && _toBoolean(value);
+ return;
+ case USE_WS_BORDER_LABEL_KEY:
+ useWsBorderLabel = !disableCustomThemeTweaks && _toBoolean(value);
+ return;
+ case USE_WS_BORDER_LIST_KEY:
+ useWsBorderList = !disableCustomThemeTweaks && _toBoolean(value);
+ return;
+ case USE_WS_BORDER_TABLE_KEY:
+ useWsBorderTable = !disableCustomThemeTweaks && _toBoolean(value);
+ return;
+ case USE_WS_BORDER_TEXT_KEY:
+ useWsBorderText = !disableCustomThemeTweaks && _toBoolean(value);
+ return;
+ case TABLE_HEADER_LINE_COLOR_KEY:
+ tableHeaderLinePixel = disableCustomThemeTweaks ? -1 : _toColorPixel(value);
+ return;
+ case LABEL_DISABLED_FOREGROUND_COLOR_KEY:
+ disabledLabelForegroundPixel = disableCustomThemeTweaks ? -1 : _toColorPixel(value);
+ break;
+ case COMBO_USE_DARK_THEME:
+ comboUseDarkTheme = _toBoolean(value) &&
+ !disableCustomThemeTweaks &&
+ OS.IsDarkModeAvailable();
+ break;
+ case PROGRESSBAR_USE_COLORS:
+ progressbarUseColors = !disableCustomThemeTweaks && _toBoolean(value);
+ break;
}
+
/* Remove the key/value pair */
if (value == null) {
if (keys == null) return;
@@ -4404,10 +4579,11 @@ public static void setAppVersion (String version) {
APP_VERSION = version;
}
-void setModalDialog (Dialog modalDailog) {
+void setModalDialog(Dialog modalDailog) {
this.modalDialog = modalDailog;
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) shells [i].updateModal ();
+ for (Shell shell : getShells()) {
+ shell.updateModal();
+ }
}
void setModalShell (Shell shell) {
@@ -4424,8 +4600,9 @@ void setModalShell (Shell shell) {
modalShells = newModalShells;
}
modalShells [index] = shell;
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) shells [i].updateModal ();
+ for (Shell activeShell : getShells ()) {
+ activeShell.updateModal ();
+ }
}
/**
@@ -4581,6 +4758,54 @@ public void syncExec (Runnable runnable) {
}
/**
+ * Calls the callable on the user-interface thread at the next reasonable
+ * opportunity, and returns the its result from this method. The thread which
+ * calls this method is suspended until the callable completes.
+ * <p>
+ * Note that at the time the callable is invoked, widgets that have the receiver
+ * as their display may have been disposed. Therefore, it is necessary to check
+ * for this case inside the callable before accessing the widget.
+ * </p>
+ * <p>
+ * Any exception that is thrown from the callable is re-thrown in the calling
+ * thread. Note: The exception retains its original stack trace from the
+ * throwing thread. The call to {@code syncCall} will not be present in the
+ * stack trace.
+ * </p>
+ *
+ * @param callable the code to call on the user-interface thread
+ *
+ * @exception SWTException <code>ERROR_DEVICE_DISPOSED</code> - if the receiver
+ * has been disposed
+ * @exception E An exception that is thrown by the callable on the
+ * user-interface thread, and re-thrown on the calling
+ * thread
+ *
+ * @see #syncExec(Runnable)
+ * @see SwtCallable#call()
+ * @since 3.118
+ */
+public <T, E extends Exception> T syncCall(SwtCallable<T, E> callable) throws E {
+ Objects.nonNull(callable);
+ @SuppressWarnings("unchecked")
+ T[] t = (T[]) new Object[1];
+ Object[] ex = new Object[1];
+ syncExec(() -> {
+ try {
+ t[0] = callable.call();
+ } catch (Exception e) {
+ ex[0] = e;
+ }
+ });
+ if (ex[0] != null) {
+ @SuppressWarnings("unchecked")
+ E e = (E) ex[0];
+ throw e;
+ }
+ return t[0];
+}
+
+/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread after the specified
* number of milliseconds have elapsed. If milliseconds is less
@@ -4609,13 +4834,13 @@ public void timerExec (int milliseconds, Runnable runnable) {
checkDevice ();
if (runnable == null) error (SWT.ERROR_NULL_ARGUMENT);
if (timerList == null) timerList = new Runnable [4];
- if (timerIds == null) timerIds = new long /*int*/ [4];
+ if (timerIds == null) timerIds = new long [4];
int index = 0;
while (index < timerList.length) {
if (timerList [index] == runnable) break;
index++;
}
- long /*int*/ timerId = 0;
+ long timerId = 0;
if (index != timerList.length) {
timerId = timerIds [index];
if (milliseconds < 0) {
@@ -4636,12 +4861,12 @@ public void timerExec (int milliseconds, Runnable runnable) {
Runnable [] newTimerList = new Runnable [timerList.length + 4];
System.arraycopy (timerList, 0, newTimerList, 0, timerList.length);
timerList = newTimerList;
- long /*int*/ [] newTimerIds = new long /*int*/ [timerIds.length + 4];
+ long [] newTimerIds = new long [timerIds.length + 4];
System.arraycopy (timerIds, 0, newTimerIds, 0, timerIds.length);
timerIds = newTimerIds;
}
}
- long /*int*/ newTimerID = OS.SetTimer (hwndMessage, timerId, milliseconds, 0);
+ long newTimerID = OS.SetTimer (hwndMessage, timerId, milliseconds, 0);
if (newTimerID != 0) {
timerList [index] = runnable;
timerIds [index] = newTimerID;
@@ -4656,8 +4881,8 @@ boolean translateAccelerator (MSG msg, Control control) {
}
static int translateKey (int key) {
- for (int i=0; i<KeyTable.length; i++) {
- if (KeyTable [i] [0] == key) return KeyTable [i] [1];
+ for (int[] element : KeyTable) {
+ if (element [0] == key) return element [1];
}
return 0;
}
@@ -4674,7 +4899,7 @@ boolean translateMnemonic (MSG msg, Control control) {
boolean translateTraversal (MSG msg, Control control) {
switch (msg.message) {
case OS.WM_KEYDOWN:
- switch ((int)/*64*/msg.wParam) {
+ switch ((int)msg.wParam) {
case OS.VK_RETURN:
case OS.VK_ESCAPE:
case OS.VK_TAB:
@@ -4688,7 +4913,7 @@ boolean translateTraversal (MSG msg, Control control) {
}
break;
case OS.WM_SYSKEYDOWN:
- switch ((int)/*64*/msg.wParam) {
+ switch ((int)msg.wParam) {
case OS.VK_MENU:
return control.translateTraversal (msg);
}
@@ -4698,8 +4923,8 @@ boolean translateTraversal (MSG msg, Control control) {
}
static int untranslateKey (int key) {
- for (int i=0; i<KeyTable.length; i++) {
- if (KeyTable [i] [1] == key) return KeyTable [i] [0];
+ for (int[] element : KeyTable) {
+ if (element [1] == key) return element [0];
}
return 0;
}
@@ -4735,9 +4960,7 @@ public void update() {
int flags = OS.PM_REMOVE | OS.PM_NOYIELD;
OS.PeekMessage (msg, hwndMessage, SWT_NULL, SWT_NULL, flags);
}
- Shell[] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
+ for (Shell shell : getShells ()) {
if (!shell.isDisposed ()) shell.update (true);
}
}
@@ -4765,27 +4988,27 @@ void wakeThread () {
OS.PostThreadMessage (threadId, OS.WM_NULL, 0, 0);
}
-long /*int*/ windowProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wParam, long /*int*/ lParam) {
+long windowProc (long hwnd, long msg, long wParam, long lParam) {
if (lastControl != null && lastHwnd == hwnd) {
- return lastControl.windowProc (hwnd, (int)/*64*/msg, wParam, lParam);
+ return lastControl.windowProc (hwnd, (int)msg, wParam, lParam);
}
- int index = (int)/*64*/OS.GetProp (hwnd, SWT_OBJECT_INDEX) - 1;
+ int index = (int)OS.GetProp (hwnd, SWT_OBJECT_INDEX) - 1;
if (0 <= index && index < controlTable.length) {
Control control = controlTable [index];
if (control != null) {
lastHwnd = hwnd;
lastControl = control;
- return control.windowProc (hwnd, (int)/*64*/msg, wParam, lParam);
+ return control.windowProc (hwnd, (int)msg, wParam, lParam);
}
}
- return OS.DefWindowProc (hwnd, (int)/*64*/msg, wParam, lParam);
+ return OS.DefWindowProc (hwnd, (int)msg, wParam, lParam);
}
-int textWidth (String text, long /*int*/ handle) {
- long /*int*/ oldFont = 0;
+int textWidth (String text, long handle) {
+ long oldFont = 0;
RECT rect = new RECT ();
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ long hDC = OS.GetDC (handle);
+ long newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
char [] buffer = text.toCharArray ();
@@ -4795,12 +5018,12 @@ int textWidth (String text, long /*int*/ handle) {
return (rect.right - rect.left);
}
-String wrapText (String text, long /*int*/ handle, int width) {
+String wrapText (String text, long handle, int width) {
String Lf = "\r\n"; //$NON-NLS-1$
text = withCrLf (text);
int length = text.length ();
if (width <= 0 || length == 0 || length == 1) return text;
- StringBuffer result = new StringBuffer ();
+ StringBuilder result = new StringBuilder ();
int lineStart = 0, lineEnd = 0;
while (lineStart < length) {
lineEnd = text.indexOf (Lf, lineStart);
@@ -4883,7 +5106,7 @@ static String withCrLf (String string) {
/* Create a new string with the CR/LF line terminator. */
i = 0;
- StringBuffer result = new StringBuffer (count);
+ StringBuilder result = new StringBuilder (count);
while (i < length) {
int j = string.indexOf ('\n', i);
if (j == -1) j = length;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
index 053a20d1ab..d32e364b81 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
@@ -53,7 +53,7 @@ public class ExpandBar extends Composite {
ExpandItem focusItem;
int spacing = 4;
int yCurrentScroll;
- long /*int*/ hFont;
+ long hFont;
/**
@@ -116,7 +116,7 @@ public void addExpandListener (ExpandListener listener) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
return OS.DefWindowProc (hwnd, msg, wParam, lParam);
}
@@ -135,12 +135,12 @@ static int checkStyle (int style) {
int height = 0, width = 0;
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
if (itemCount > 0) {
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ hTheme = 0;
+ long hDC = OS.GetDC (handle);
+ long hTheme = 0;
if (isAppThemed ()) {
hTheme = display.hExplorerBarTheme ();
}
- long /*int*/ hCurrentFont = 0, oldFont = 0;
+ long hCurrentFont = 0, oldFont = 0;
if (hTheme == 0) {
if (hFont != 0) {
hCurrentFont = hFont;
@@ -244,7 +244,7 @@ void destroyItem (ExpandItem item) {
}
@Override
-void drawThemeBackground (long /*int*/ hDC, long /*int*/ hwnd, RECT rect) {
+void drawThemeBackground (long hDC, long hwnd, RECT rect) {
RECT rect2 = new RECT ();
OS.GetClientRect (handle, rect2);
OS.MapWindowPoints (handle, hwnd, rect2, 2);
@@ -252,7 +252,7 @@ void drawThemeBackground (long /*int*/ hDC, long /*int*/ hwnd, RECT rect) {
}
void drawWidget (GC gc, RECT clipRect) {
- long /*int*/ hTheme = 0;
+ long hTheme = 0;
if (isAppThemed ()) {
hTheme = display.hExplorerBarTheme ();
}
@@ -265,10 +265,10 @@ void drawWidget (GC gc, RECT clipRect) {
}
boolean drawFocus = false;
if (handle == OS.GetFocus ()) {
- int uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ int uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
drawFocus = (uiState & OS.UISF_HIDEFOCUS) == 0;
}
- long /*int*/ hCurrentFont = 0, oldFont = 0;
+ long hCurrentFont = 0, oldFont = 0;
if (hTheme == 0) {
if (hFont != 0) {
hCurrentFont = hFont;
@@ -312,8 +312,8 @@ Control findThemeControl () {
}
int getBandHeight () {
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ oldHFont = OS.SelectObject (hDC, hFont == 0 ? defaultFont () : hFont);
+ long hDC = OS.GetDC (handle);
+ long oldHFont = OS.SelectObject (hDC, hFont == 0 ? defaultFont () : hFont);
TEXTMETRIC lptm = new TEXTMETRIC ();
OS.GetTextMetrics (hDC, lptm);
OS.SelectObject (hDC, oldHFont);
@@ -454,8 +454,7 @@ void layoutItems (int index, boolean setScrollbar) {
@Override
void releaseChildren (boolean destroy) {
if (items != null) {
- for (int i=0; i<items.length; i++) {
- ExpandItem item = items [i];
+ for (ExpandItem item : items) {
if (item != null && !item.isDisposed ()) {
item.release (false);
}
@@ -494,8 +493,7 @@ public void removeExpandListener (ExpandListener listener) {
@Override
void reskinChildren (int flags) {
if (items != null) {
- for (int i=0; i<items.length; i++) {
- ExpandItem item = items [i];
+ for (ExpandItem item : items) {
if (item != null ) item.reskin (flags);
}
}
@@ -585,9 +583,9 @@ void setSpacingInPixels (int spacing) {
@Override
boolean updateTextDirection(int textDirection) {
if (super.updateTextDirection(textDirection)) {
- for (int i = 0, n = items.length; i < n; i++) {
- if (items[i] != null) {
- items[i].updateTextDirection(textDirection == AUTO_TEXT_DIRECTION ? AUTO_TEXT_DIRECTION : style & SWT.FLIP_TEXT_DIRECTION);
+ for (ExpandItem item : items) {
+ if (item != null) {
+ item.updateTextDirection(textDirection == AUTO_TEXT_DIRECTION ? AUTO_TEXT_DIRECTION : style & SWT.FLIP_TEXT_DIRECTION);
}
}
return true;
@@ -647,16 +645,16 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return display.windowProc;
}
@Override
-LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KEYDOWN (long wParam, long lParam) {
LRESULT result = super.WM_KEYDOWN (wParam, lParam);
if (result != null) return result;
if (focusItem == null) return result;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_SPACE:
case OS.VK_RETURN:
Event event = new Event ();
@@ -692,14 +690,14 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KILLFOCUS (long wParam, long lParam) {
LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
if (focusItem != null) focusItem.redraw (true);
return result;
}
@Override
-LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDOWN (long wParam, long lParam) {
LRESULT result = super.WM_LBUTTONDOWN (wParam, lParam);
if (result == LRESULT.ZERO) return result;
int x = OS.GET_X_LPARAM (lParam);
@@ -719,7 +717,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_LBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONUP (long wParam, long lParam) {
LRESULT result = super.WM_LBUTTONUP (wParam, lParam);
if (result == LRESULT.ZERO) return result;
if (focusItem == null) return result;
@@ -737,7 +735,7 @@ LRESULT WM_LBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_MOUSELEAVE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSELEAVE (long wParam, long lParam) {
LRESULT result = super.WM_MOUSELEAVE (wParam, lParam);
if (result != null) return result;
for (int i = 0; i < itemCount; i++) {
@@ -752,7 +750,7 @@ LRESULT WM_MOUSELEAVE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSEMOVE (long wParam, long lParam) {
LRESULT result = super.WM_MOUSEMOVE (wParam, lParam);
if (result == LRESULT.ZERO) return result;
int x = OS.GET_X_LPARAM (lParam);
@@ -769,12 +767,12 @@ LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_MOUSEWHEEL (long /*int*/ wParam, long /*int*/ lParam) {
- return wmScrollWheel (true, wParam, lParam);
+LRESULT WM_MOUSEWHEEL (long wParam, long lParam) {
+ return wmScrollWheel (true, wParam, lParam, false);
}
@Override
-LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PAINT (long wParam, long lParam) {
if ((state & DISPOSE_SENT) != 0) return LRESULT.ZERO;
PAINTSTRUCT ps = new PAINTSTRUCT ();
@@ -803,7 +801,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_PRINTCLIENT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PRINTCLIENT (long wParam, long lParam) {
LRESULT result = super.WM_PRINTCLIENT (wParam, lParam);
RECT rect = new RECT ();
OS.GetClientRect (handle, rect);
@@ -817,15 +815,15 @@ LRESULT WM_PRINTCLIENT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETCURSOR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETCURSOR (long wParam, long lParam) {
LRESULT result = super.WM_SETCURSOR (wParam, lParam);
if (result != null) return result;
int hitTest = (short) OS.LOWORD (lParam);
- if (hitTest == OS.HTCLIENT) {
+ if (hitTest == OS.HTCLIENT) {
for (int i = 0; i < itemCount; i++) {
ExpandItem item = items [i];
if (item.hover) {
- long /*int*/ hCursor = OS.LoadCursor (0, OS.IDC_HAND);
+ long hCursor = OS.LoadCursor (0, OS.IDC_HAND);
OS.SetCursor (hCursor);
return LRESULT.ONE;
}
@@ -835,14 +833,14 @@ LRESULT WM_SETCURSOR (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFOCUS (long wParam, long lParam) {
LRESULT result = super.WM_SETFOCUS (wParam, lParam);
if (focusItem != null) focusItem.redraw (true);
return result;
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
LRESULT result = super.WM_SIZE (wParam, lParam);
RECT rect = new RECT ();
OS.GetClientRect (handle, rect);
@@ -857,7 +855,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmScroll (ScrollBar bar, boolean update, long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmScroll (ScrollBar bar, boolean update, long hwnd, int msg, long wParam, long lParam) {
LRESULT result = super.wmScroll (bar, true, hwnd, msg, wParam, lParam);
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java
index 086c471e92..a092e41093 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java
@@ -119,16 +119,16 @@ static ExpandBar checkNull (ExpandBar control) {
return control;
}
-private void drawChevron (long /*int*/ hDC, RECT rect) {
- long /*int*/ oldBrush = OS.SelectObject (hDC, OS.GetSysColorBrush (OS.COLOR_BTNFACE));
+private void drawChevron (long hDC, RECT rect) {
+ long oldBrush = OS.SelectObject (hDC, OS.GetSysColorBrush (OS.COLOR_BTNFACE));
OS.PatBlt (hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY);
OS.SelectObject (hDC, oldBrush);
rect.left += 4;
rect.top += 4;
rect.right -= 4;
rect.bottom -= 4;
- long /*int*/ hPen = OS.CreatePen (OS.PS_SOLID, 1, parent.getForegroundPixel ());
- long /*int*/ oldPen = OS.SelectObject (hDC, hPen);
+ long hPen = OS.CreatePen (OS.PS_SOLID, 1, parent.getForegroundPixel ());
+ long oldPen = OS.SelectObject (hDC, hPen);
int [] polyline1, polyline2;
if (expanded) {
int px = rect.left + 5;
@@ -154,8 +154,8 @@ private void drawChevron (long /*int*/ hDC, RECT rect) {
OS.Polyline (hDC, polyline1, polyline1.length / 2);
OS.Polyline (hDC, polyline2, polyline2.length / 2);
if (hover) {
- long /*int*/ whitePen = OS.CreatePen (OS.PS_SOLID, 1, OS.GetSysColor (OS.COLOR_3DHILIGHT));
- long /*int*/ darkGrayPen = OS.CreatePen (OS.PS_SOLID, 1, OS.GetSysColor (OS.COLOR_3DSHADOW));
+ long whitePen = OS.CreatePen (OS.PS_SOLID, 1, OS.GetSysColor (OS.COLOR_3DHILIGHT));
+ long darkGrayPen = OS.CreatePen (OS.PS_SOLID, 1, OS.GetSysColor (OS.COLOR_3DSHADOW));
OS.SelectObject (hDC, whitePen);
int [] points1 = {
rect.left, rect.bottom,
@@ -177,15 +177,15 @@ private void drawChevron (long /*int*/ hDC, RECT rect) {
OS.DeleteObject (hPen);
}
-void drawItem (GC gc, long /*int*/ hTheme, RECT clipRect, boolean drawFocus) {
- long /*int*/ hDC = gc.handle;
+void drawItem (GC gc, long hTheme, RECT clipRect, boolean drawFocus) {
+ long hDC = gc.handle;
int headerHeight = parent.getBandHeight ();
RECT rect = new RECT ();
OS.SetRect (rect, x, y, x + width, y + headerHeight);
if (hTheme != 0) {
OS.DrawThemeBackground (hTheme, hDC, OS.EBP_NORMALGROUPHEAD, 0, rect, clipRect);
} else {
- long /*int*/ oldBrush = OS.SelectObject (hDC, OS.GetSysColorBrush (OS.COLOR_BTNFACE));
+ long oldBrush = OS.SelectObject (hDC, OS.GetSysColorBrush (OS.COLOR_BTNFACE));
OS.PatBlt (hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY);
OS.SelectObject (hDC, oldBrush);
}
@@ -237,8 +237,8 @@ void drawItem (GC gc, long /*int*/ hTheme, RECT clipRect, boolean drawFocus) {
}
if (expanded) {
if (!parent.isAppThemed ()) {
- long /*int*/ pen = OS.CreatePen (OS.PS_SOLID, 1, OS.GetSysColor (OS.COLOR_BTNFACE));
- long /*int*/ oldPen = OS.SelectObject (hDC, pen);
+ long pen = OS.CreatePen (OS.PS_SOLID, 1, OS.GetSysColor (OS.COLOR_BTNFACE));
+ long oldPen = OS.SelectObject (hDC, pen);
int [] points = {
x, y + headerHeight,
x, y + headerHeight + height,
@@ -342,7 +342,7 @@ public ExpandBar getParent () {
return parent;
}
-int getPreferredWidth (long /*int*/ hTheme, long /*int*/ hDC) {
+int getPreferredWidth (long hTheme, long hDC) {
int width = ExpandItem.TEXT_INSET * 2 + ExpandItem.CHEVRON_SIZE;
if (image != null) {
width += ExpandItem.TEXT_INSET + imageWidth;
@@ -366,7 +366,7 @@ boolean isHover (int x, int y) {
}
void redraw (boolean all) {
- long /*int*/ parentHandle = parent.handle;
+ long parentHandle = parent.handle;
int headerHeight = parent.getBandHeight ();
RECT rect = new RECT ();
int left = all ? x : x + width - headerHeight;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java
index 9c7e8fd3d8..18b44e4cf8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2022 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,9 +13,10 @@
*******************************************************************************/
package org.eclipse.swt.widgets;
+import java.nio.file.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.ole.win32.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -45,20 +46,8 @@ public class FileDialog extends Dialog {
String filterPath = "", fileName = "";
int filterIndex = 0;
boolean overwrite = false;
- static final String FILTER = "*.*";
- static int BUFFER_SIZE = 1024 * 32;
- static boolean USE_HOOK = true;
- static {
- /*
- * Feature in Vista. When OFN_ENABLEHOOK is set in the
- * save or open file dialog, Vista uses the old XP look
- * and feel. OFN_ENABLEHOOK is used to grow the file
- * name buffer in a multi-select file dialog. The fix
- * is to only use OFN_ENABLEHOOK when the buffer has
- * overrun.
- */
- USE_HOOK = false;
- }
+ static final String DEFAULT_FILTER = "*.*";
+ static final String LONG_PATH_PREFIX = "\\\\?\\";
/**
* Constructs a new instance of this class given only its parent.
@@ -197,32 +186,21 @@ public boolean getOverwrite () {
return overwrite;
}
-long /*int*/ OFNHookProc (long /*int*/ hdlg, long /*int*/ uiMsg, long /*int*/ wParam, long /*int*/ lParam) {
- switch ((int)/*64*/uiMsg) {
- case OS.WM_NOTIFY:
- OFNOTIFY ofn = new OFNOTIFY ();
- OS.MoveMemory (ofn, lParam, OFNOTIFY.sizeof);
- if (ofn.code == OS.CDN_SELCHANGE) {
- int lResult = (int)/*64*/OS.SendMessage (ofn.hwndFrom, OS.CDM_GETSPEC, 0, 0);
- if (lResult > 0) {
- lResult += OS.MAX_PATH;
- OPENFILENAME lpofn = new OPENFILENAME ();
- OS.MoveMemory (lpofn, ofn.lpOFN, OPENFILENAME.sizeof);
- if (lpofn.nMaxFile < lResult) {
- long /*int*/ hHeap = OS.GetProcessHeap ();
- long /*int*/ lpstrFile = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, lResult * TCHAR.sizeof);
- if (lpstrFile != 0) {
- if (lpofn.lpstrFile != 0) OS.HeapFree (hHeap, 0, lpofn.lpstrFile);
- lpofn.lpstrFile = lpstrFile;
- lpofn.nMaxFile = lResult;
- OS.MoveMemory (ofn.lpOFN, lpofn, OPENFILENAME.sizeof);
- }
- }
- }
- }
- break;
+static Path getItemPath (IShellItem psi) {
+ long [] ppsz = new long [1];
+ if (psi.GetDisplayName(OS.SIGDN_FILESYSPATH, ppsz) == COM.S_OK) {
+ int length = OS.wcslen(ppsz[0]);
+ char[] buffer = new char[length];
+ OS.MoveMemory(buffer, ppsz[0], length * Character.BYTES);
+ OS.CoTaskMemFree(ppsz[0]);
+ String path = String.valueOf(buffer);
+ /* Feature in Windows. Paths longer than MAX_PATH are returned with a \\?\ prefix */
+ if (path.startsWith(LONG_PATH_PREFIX)) {
+ path = path.substring(LONG_PATH_PREFIX.length());
+ }
+ return Paths.get(path);
}
- return 0;
+ return null;
}
/**
@@ -238,242 +216,169 @@ long /*int*/ OFNHookProc (long /*int*/ hdlg, long /*int*/ uiMsg, long /*int*/ wP
* </ul>
*/
public String open () {
- long /*int*/ hHeap = OS.GetProcessHeap ();
-
- /* Get the owner HWND for the dialog */
- long /*int*/ hwndOwner = parent.handle;
- long /*int*/ hwndParent = parent.handle;
-
- /*
- * Feature in Windows. There is no API to set the orientation of a
- * file dialog. It is always inherited from the parent. The fix is
- * to create a hidden parent and set the orientation in the hidden
- * parent for the dialog to inherit.
- */
- boolean enabled = false;
- int dialogOrientation = style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
- int parentOrientation = parent.style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
- if (dialogOrientation != parentOrientation) {
- int exStyle = OS.WS_EX_NOINHERITLAYOUT;
- if (dialogOrientation == SWT.RIGHT_TO_LEFT) exStyle |= OS.WS_EX_LAYOUTRTL;
- hwndOwner = OS.CreateWindowEx (
- exStyle,
- Shell.DialogClass,
- null,
- 0,
- OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0,
- hwndParent,
- 0,
- OS.GetModuleHandle (null),
- null);
- enabled = OS.IsWindowEnabled (hwndParent);
- if (enabled) OS.EnableWindow (hwndParent, false);
+ /* Create Common Item Dialog */
+ long[] ppv = new long[1];
+ int hr;
+ if ((style & SWT.SAVE) != 0) {
+ hr = COM.CoCreateInstance(COM.CLSID_FileSaveDialog, 0, COM.CLSCTX_INPROC_SERVER, COM.IID_IFileSaveDialog, ppv);
+ } else {
+ hr = COM.CoCreateInstance(COM.CLSID_FileOpenDialog, 0, COM.CLSCTX_INPROC_SERVER, COM.IID_IFileOpenDialog, ppv);
}
+ if (hr != COM.S_OK) SWT.error(SWT.ERROR_NO_HANDLES);
+ IFileDialog fileDialog = new IFileDialog(ppv[0]);
+
+ /* Update dialog options */
+ int[] options = new int[1];
+ fileDialog.GetOptions(options);
+ options[0] |= OS.FOS_FORCEFILESYSTEM | OS.FOS_NOCHANGEDIR;
+ if ((style & SWT.SAVE) != 0) {
+ if (!overwrite) options[0] &= ~OS.FOS_OVERWRITEPROMPT;
+ } else {
+ if ((style & SWT.MULTI) != 0) options[0] |= OS.FOS_ALLOWMULTISELECT;
+ }
+ fileDialog.SetOptions(options[0]);
- /* Convert the title and copy it into lpstrTitle */
- if (title == null) title = "";
- /* Use the character encoding for the default locale */
- TCHAR buffer3 = new TCHAR (0, title, true);
- int byteCount3 = buffer3.length () * TCHAR.sizeof;
- long /*int*/ lpstrTitle = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount3);
- OS.MoveMemory (lpstrTitle, buffer3, byteCount3);
-
- /* Compute filters and copy into lpstrFilter */
- String strFilter = "";
- if (filterNames == null) filterNames = new String [0];
- if (filterExtensions == null) filterExtensions = new String [0];
- for (int i=0; i<filterExtensions.length; i++) {
- String filterName = filterExtensions [i];
- if (i < filterNames.length) filterName = filterNames [i];
- strFilter = strFilter + filterName + '\0' + filterExtensions [i] + '\0';
+ /* Set dialog title */
+ if (!title.isEmpty()) {
+ fileDialog.SetTitle((title + "\0").toCharArray());
}
- if (filterExtensions.length == 0) {
- strFilter = strFilter + FILTER + '\0' + FILTER + '\0';
+
+ /* Apply extension filters */
+ String[] filterExtensions = this.filterExtensions;
+ String[] filterNames = this.filterNames;
+ if (filterExtensions == null || filterExtensions.length == 0) {
+ filterExtensions = filterNames = new String[] { DEFAULT_FILTER };
}
- /* Use the character encoding for the default locale */
- TCHAR buffer4 = new TCHAR (0, strFilter, true);
- int byteCount4 = buffer4.length () * TCHAR.sizeof;
- long /*int*/ lpstrFilter = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount4);
- OS.MoveMemory (lpstrFilter, buffer4, byteCount4);
-
- /* Convert the fileName and filterName to C strings */
- if (fileName == null) fileName = "";
- /* Use the character encoding for the default locale */
- TCHAR name = new TCHAR (0, fileName, true);
-
- /*
- * Copy the name into lpstrFile and ensure that the
- * last byte is NULL and the buffer does not overrun.
- */
- int nMaxFile = OS.MAX_PATH;
- if ((style & SWT.MULTI) != 0) nMaxFile = Math.max (nMaxFile, BUFFER_SIZE);
- int byteCount = nMaxFile * TCHAR.sizeof;
- long /*int*/ lpstrFile = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- int byteCountFile = Math.min (name.length () * TCHAR.sizeof, byteCount - TCHAR.sizeof);
- OS.MoveMemory (lpstrFile, name, byteCountFile);
-
- /*
- * Copy the path into lpstrInitialDir and ensure that
- * the last byte is NULL and the buffer does not overrun.
- */
- if (filterPath == null) filterPath = "";
- /* Use the character encoding for the default locale */
- TCHAR path = new TCHAR (0, filterPath.replace ('/', '\\'), true);
- int byteCount5 = OS.MAX_PATH * TCHAR.sizeof;
- long /*int*/ lpstrInitialDir = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount5);
- int byteCountDir = Math.min (path.length () * TCHAR.sizeof, byteCount5 - TCHAR.sizeof);
- OS.MoveMemory (lpstrInitialDir, path, byteCountDir);
-
- /* Create the file dialog struct */
- OPENFILENAME struct = new OPENFILENAME ();
- struct.lStructSize = OPENFILENAME.sizeof;
- struct.Flags = OS.OFN_HIDEREADONLY | OS.OFN_NOCHANGEDIR;
- boolean save = (style & SWT.SAVE) != 0;
- if (save && overwrite) struct.Flags |= OS.OFN_OVERWRITEPROMPT;
- Callback callback = null;
- if ((style & SWT.MULTI) != 0) {
- struct.Flags |= OS.OFN_ALLOWMULTISELECT | OS.OFN_EXPLORER | OS.OFN_ENABLESIZING;
- if (USE_HOOK) {
- callback = new Callback (this, "OFNHookProc", 4); //$NON-NLS-1$
- long /*int*/ lpfnHook = callback.getAddress ();
- if (lpfnHook == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- struct.lpfnHook = lpfnHook;
- struct.Flags |= OS.OFN_ENABLEHOOK;
+ long hHeap = OS.GetProcessHeap();
+ long[] filterSpec = new long[filterExtensions.length * 2];
+ for (int i = 0; i < filterExtensions.length; i++) {
+ String extension = filterExtensions[i];
+ String name = (filterNames != null && i < filterNames.length) ? filterNames[i] : extension;
+ /*
+ * Feature in Windows. If a filter name doesn't contain "*.", FileDialog appends
+ * the filter pattern to the name. This might cause filters like (*) to appear
+ * twice. The fix is to strip the pattern and let FileDialog re-append it.
+ *
+ * Note: Registry entry for "Hide extensions for known file types" needs to be
+ * checked before we apply above work-around.
+ */
+ if (!name.contains("*.")) {
+ /* By default value is on, in case of missing registry entry assumed to be on */
+ int[] result = OS.readRegistryDwords(OS.HKEY_CURRENT_USER,
+ "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", "HideFileExt");
+ if (result != null && result[0] == 0) {
+ name = name.replace(" (" + extension + ")", "");
+ }
+ }
+ long lpstrName = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, (name.length() + 1) * Character.BYTES);
+ long lpstrExt = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, (extension.length() + 1) * Character.BYTES);
+ OS.MoveMemory(lpstrName, name.toCharArray(), name.length() * Character.BYTES);
+ OS.MoveMemory(lpstrExt, extension.toCharArray(), extension.length() * Character.BYTES);
+ filterSpec[i*2] = lpstrName;
+ filterSpec[i*2 + 1] = lpstrExt;
+ }
+ fileDialog.SetFileTypes(filterExtensions.length, filterSpec);
+ for (int i = 0; i < filterSpec.length; i++) {
+ OS.HeapFree(hHeap, 0, filterSpec[i]);
+ }
+
+ /* Enable automatic appending of extensions to saved file names */
+ fileDialog.SetDefaultExtension(new char[1]);
+
+ /* Set initial filter */
+ fileDialog.SetFileTypeIndex(filterIndex + 1);
+
+ /* Set initial folder */
+ if (filterPath != null) {
+ char[] path = (filterPath.replace('/', '\\') + "\0").toCharArray();
+ if (COM.SHCreateItemFromParsingName(path, 0, COM.IID_IShellItem, ppv) == COM.S_OK) {
+ IShellItem psi = new IShellItem(ppv[0]);
+ // Bug 577190: Hard override the filter path using SetFolder.
+ fileDialog.SetFolder(psi);
+ psi.Release();
}
}
- struct.hwndOwner = hwndOwner;
- struct.lpstrTitle = lpstrTitle;
- struct.lpstrFile = lpstrFile;
- struct.nMaxFile = nMaxFile;
- struct.lpstrInitialDir = lpstrInitialDir;
- struct.lpstrFilter = lpstrFilter;
- struct.nFilterIndex = filterIndex == 0 ? filterIndex : filterIndex + 1;
-
- /*
- * Set the default extension to an empty string. If the
- * user fails to type an extension and this extension is
- * empty, Windows uses the current value of the filter
- * extension at the time that the dialog is closed.
- */
- long /*int*/ lpstrDefExt = 0;
- if (save) {
- lpstrDefExt = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof);
- struct.lpstrDefExt = lpstrDefExt;
+
+ /* Set initial filename */
+ if (fileName != null) {
+ char[] name = (fileName.replace('/', '\\') + "\0").toCharArray();
+ fileDialog.SetFileName(name);
}
/* Make the parent shell be temporary modal */
Dialog oldModal = null;
- Display display = parent.getDisplay ();
+ Display display = parent.getDisplay();
if ((style & (SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) != 0) {
- oldModal = display.getModalDialog ();
- display.setModalDialog (this);
+ oldModal = display.getModalDialog();
+ display.setModalDialog(this);
}
- /*
- * Feature in Windows. For some reason, the WH_MSGFILTER filter
- * does not run for GetSaveFileName() or GetOpenFileName(). The
- * fix is to allow async messages to run in the WH_FOREGROUNDIDLE
- * hook instead.
- */
- boolean oldRunMessagesInIdle = display.runMessagesInIdle;
- display.runMessagesInIdle = true;
- display.sendPreExternalEventDispatchEvent ();
- /*
- * Open the dialog. If the open fails due to an invalid
- * file name, use an empty file name and open it again.
- */
- boolean success = (save) ? OS.GetSaveFileName (struct) : OS.GetOpenFileName (struct);
- display.sendPostExternalEventDispatchEvent ();
- switch (OS.CommDlgExtendedError ()) {
- case OS.FNERR_INVALIDFILENAME:
- OS.MoveMemory (lpstrFile, new char [1], TCHAR.sizeof);
- display.sendPreExternalEventDispatchEvent ();
- success = (save) ? OS.GetSaveFileName (struct) : OS.GetOpenFileName (struct);
- display.sendPostExternalEventDispatchEvent ();
- break;
- case OS.FNERR_BUFFERTOOSMALL:
- USE_HOOK = true;
- break;
- }
- display.runMessagesInIdle = oldRunMessagesInIdle;
+ /* Open the dialog */
+ display.externalEventLoop = true;
+ display.sendPreExternalEventDispatchEvent();
+ hr = fileDialog.Show(parent.handle);
+ display.externalEventLoop = false;
+ display.sendPostExternalEventDispatchEvent();
/* Clear the temporary dialog modal parent */
if ((style & (SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) != 0) {
- display.setModalDialog (oldModal);
+ display.setModalDialog(oldModal);
}
- /* Dispose the callback and reassign the buffer */
- if (callback != null) callback.dispose ();
- lpstrFile = struct.lpstrFile;
-
- /* Set the new path, file name and filter */
- fileNames = new String [0];
+ /* Extract result paths */
String fullPath = null;
- if (success) {
- char [] buffer = new char [struct.nMaxFile];
- OS.MoveMemory (buffer, lpstrFile, buffer.length * TCHAR.sizeof);
- int nFileOffset = struct.nFileOffset;
- if (nFileOffset > 0) {
- filterPath = new String (buffer, 0, nFileOffset - 1);
-
- /*
- * Get each file from the buffer. Files are delimited
- * by a NULL character with 2 NULL characters at the end.
- */
- int count = 0;
- fileNames = new String [(style & SWT.MULTI) != 0 ? 4 : 1];
- int start = nFileOffset;
- do {
- int end = start;
- while (end < buffer.length && buffer [end] != 0) end++;
- String string = new String (buffer, start, end - start);
- start = end + 1;
- if (count == fileNames.length) {
- String [] newFileNames = new String [fileNames.length + 4];
- System.arraycopy (fileNames, 0, newFileNames, 0, fileNames.length);
- fileNames = newFileNames;
- }
- fileNames [count++] = string;
- if ((style & SWT.MULTI) == 0) break;
- } while (start < buffer.length && buffer[start] != 0);
-
- if (fileNames.length > 0) fileName = fileNames [0];
- String separator = "";
- int length = filterPath.length ();
- if (length > 0 && filterPath.charAt (length - 1) != '\\') {
- separator = "\\";
+ fileNames = new String[0];
+ if (hr == COM.S_OK) {
+ if ((style & SWT.SAVE) != 0) {
+ if (fileDialog.GetResult(ppv) == COM.S_OK) {
+ IShellItem psi = new IShellItem(ppv[0]);
+ Path itemPath = getItemPath(psi);
+ psi.Release();
+ fileName = itemPath.getFileName().toString();
+ filterPath = itemPath.getParent().toString();
+ fileNames = new String[] { fileName };
+ fullPath = itemPath.toString();
}
- fullPath = filterPath + separator + fileName;
- if (count < fileNames.length) {
- String [] newFileNames = new String [count];
- System.arraycopy (fileNames, 0, newFileNames, 0, count);
- fileNames = newFileNames;
+ } else {
+ if (fileDialog.GetResults(ppv) == COM.S_OK) {
+ IShellItemArray psia = new IShellItemArray(ppv[0]);
+ int[] piCount = new int[1];
+ psia.GetCount(piCount);
+ fileNames = new String[piCount[0]];
+ Path parentPath = null;
+ for (int i = 0; i < piCount[0]; i++) {
+ psia.GetItemAt(i, ppv);
+ IShellItem psi = new IShellItem(ppv[0]);
+ Path itemPath = getItemPath(psi);
+ psi.Release();
+ if (parentPath == null) {
+ parentPath = itemPath.getParent();
+ filterPath = parentPath.toString();
+ fullPath = itemPath.toString();
+ }
+ /*
+ * Feature in Windows. Returned items might have different parent folders.
+ * (E.g. when selecting from a virtual folder like Recent Files).
+ * Return full paths names in this case.
+ */
+ if (itemPath.getParent().equals(parentPath)) {
+ fileNames[i] = itemPath.getFileName().toString();
+ } else {
+ fileNames[i] = itemPath.toString();
+ }
+ }
+ fileName = fileNames[0];
+ psia.Release();
}
}
- filterIndex = struct.nFilterIndex - 1;
- }
- /* Free the memory that was allocated. */
- OS.HeapFree (hHeap, 0, lpstrFile);
- OS.HeapFree (hHeap, 0, lpstrFilter);
- OS.HeapFree (hHeap, 0, lpstrInitialDir);
- OS.HeapFree (hHeap, 0, lpstrTitle);
- if (lpstrDefExt != 0) OS.HeapFree (hHeap, 0, lpstrDefExt);
-
- /* Destroy the BIDI orientation window */
- if (hwndParent != hwndOwner) {
- if (enabled) OS.EnableWindow (hwndParent, true);
- OS.SetActiveWindow (hwndParent);
- OS.DestroyWindow (hwndOwner);
+ int[] piIndex = new int[1];
+ if (fileDialog.GetFileTypeIndex(piIndex) == COM.S_OK) {
+ filterIndex = piIndex[0] - 1;
+ }
}
- /*
- * This code is intentionally commented. On some
- * platforms, the owner window is repainted right
- * away when a dialog window exits. This behavior
- * is currently unspecified.
- */
-// if (hwndOwner != 0) OS.UpdateWindow (hwndOwner);
+ fileDialog.Release();
/* Answer the full path or null */
return fullPath;
@@ -583,6 +488,11 @@ public void setFilterPath (String string) {
* Sets the flag that the dialog will use to
* determine whether to prompt the user for file
* overwrite if the selected file already exists.
+ * <p>
+ * Note: On some platforms where suppressing the overwrite prompt
+ * is not supported, the prompt is shown even when invoked with
+ * overwrite false.
+ * </p>
*
* @param overwrite true if the dialog will prompt for file overwrite, false otherwise
*
@@ -591,4 +501,5 @@ public void setFilterPath (String string) {
public void setOverwrite (boolean overwrite) {
this.overwrite = overwrite;
}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java
index 2728b9f2dd..10598c0a1b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java
@@ -157,8 +157,8 @@ public RGB getRGB () {
*/
public FontData open () {
/* Get the owner HWND for the dialog */
- long /*int*/ hwndOwner = parent.handle;
- long /*int*/ hwndParent = parent.handle;
+ long hwndOwner = parent.handle;
+ long hwndParent = parent.handle;
/*
* Feature in Windows. There is no API to set the orientation of a
@@ -187,7 +187,7 @@ public FontData open () {
}
/* Open the dialog */
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
CHOOSEFONT lpcf = new CHOOSEFONT ();
lpcf.lStructSize = CHOOSEFONT.sizeof;
lpcf.hwndOwner = hwndOwner;
@@ -196,11 +196,11 @@ public FontData open () {
lpcf.Flags |= OS.CF_EFFECTS;
}
- long /*int*/ lpLogFont = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, LOGFONT.sizeof);
+ long lpLogFont = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, LOGFONT.sizeof);
if (fontData != null && fontData.data != null) {
LOGFONT logFont = fontData.data;
int lfHeight = logFont.lfHeight;
- long /*int*/ hDC = OS.GetDC (0);
+ long hDC = OS.GetDC (0);
int pixels = -(int)(0.5f + (fontData.height * OS.GetDeviceCaps(hDC, OS.LOGPIXELSY) / 72));
OS.ReleaseDC (0, hDC);
logFont.lfHeight = pixels;
@@ -224,9 +224,11 @@ public FontData open () {
display.setModalDialog (this);
}
+ display.externalEventLoop = true;
display.sendPreExternalEventDispatchEvent ();
/* Open the dialog */
boolean success = OS.ChooseFont (lpcf);
+ display.externalEventLoop = false;
display.sendPostExternalEventDispatchEvent ();
/* Clear the temporary dialog modal parent */
@@ -243,7 +245,7 @@ public FontData open () {
* This will not work on multiple screens or
* for printing. Should use DC for the proper device.
*/
- long /*int*/ hDC = OS.GetDC(0);
+ long hDC = OS.GetDC(0);
int logPixelsY = OS.GetDeviceCaps(hDC, OS.LOGPIXELSY);
int pixels = 0;
if (logFont.lfHeight > 0) {
@@ -255,8 +257,8 @@ public FontData open () {
* we must subtract the internal leading, which requires a TEXTMETRIC,
* which in turn requires font creation.
*/
- long /*int*/ hFont = OS.CreateFontIndirect(logFont);
- long /*int*/ oldFont = OS.SelectObject(hDC, hFont);
+ long hFont = OS.CreateFontIndirect(logFont);
+ long oldFont = OS.SelectObject(hDC, hFont);
TEXTMETRIC lptm = new TEXTMETRIC ();
OS.GetTextMetrics(hDC, lptm);
OS.SelectObject(hDC, oldFont);
@@ -287,14 +289,6 @@ public FontData open () {
OS.DestroyWindow (hwndOwner);
}
- /*
- * This code is intentionally commented. On some
- * platforms, the owner window is repainted right
- * away when a dialog window exits. This behavior
- * is currently unspecified.
- */
-// if (hwndOwner != 0) OS.UpdateWindow (hwndOwner);
-
if (!success) return null;
return fontData;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
index 9cfb4ba2a0..0277d353de 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
@@ -46,7 +46,7 @@ import org.eclipse.swt.internal.win32.*;
public class Group extends Composite {
String text = "";
static final int CLIENT_INSET = 3;
- static final long /*int*/ GroupProc;
+ static final long GroupProc;
static final TCHAR GroupClass = new TCHAR (0, "SWT_GROUP", true);
static {
/*
@@ -61,7 +61,7 @@ public class Group extends Composite {
TCHAR WC_BUTTON = new TCHAR (0, "BUTTON", true);
OS.GetClassInfo (0, WC_BUTTON, lpWndClass);
GroupProc = lpWndClass.lpfnWndProc;
- long /*int*/ hInstance = OS.GetModuleHandle (null);
+ long hInstance = OS.GetModuleHandle (null);
if (!OS.GetClassInfo (hInstance, GroupClass, lpWndClass)) {
lpWndClass.hInstance = hInstance;
lpWndClass.style &= ~(OS.CS_HREDRAW | OS.CS_VREDRAW);
@@ -106,7 +106,7 @@ public Group (Composite parent, int style) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
/*
* Feature in Windows. When the user clicks on the group
@@ -150,8 +150,8 @@ protected void checkSubclass () {
* client area, pad the width so the text is not clipped.
*/
char [] buffer = (string == null ? text : string).toCharArray ();
- long /*int*/ newFont, oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
+ long newFont, oldFont = 0;
+ long hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
RECT rect = new RECT ();
@@ -168,8 +168,8 @@ protected void checkSubclass () {
@Override Rectangle computeTrimInPixels (int x, int y, int width, int height) {
checkWidget ();
Rectangle trim = super.computeTrimInPixels (x, y, width, height);
- long /*int*/ newFont, oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
+ long newFont, oldFont = 0;
+ long hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
TEXTMETRIC tm = new TEXTMETRIC ();
@@ -244,8 +244,8 @@ String fixText (boolean enabled) {
forceResize ();
RECT rect = new RECT ();
OS.GetClientRect (handle, rect);
- long /*int*/ newFont, oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
+ long newFont, oldFont = 0;
+ long hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
TEXTMETRIC tm = new TEXTMETRIC ();
@@ -294,7 +294,7 @@ boolean mnemonicMatch (char key) {
}
@Override
-void printWidget (long /*int*/ hwnd, long /*int*/ hdc, GC gc) {
+void printWidget (long hwnd, long hdc, GC gc) {
/*
* Bug in Windows. For some reason, PrintWindow()
* returns success but does nothing when it is called
@@ -343,7 +343,7 @@ void printWidget (long /*int*/ hwnd, long /*int*/ hdc, GC gc) {
} else {
OS.SetWindowOrgEx (hdc, -location.x, -location.y, null);
}
- long /*int*/ topHandle = children [i].topHandle();
+ long topHandle = children [i].topHandle();
int bits = OS.GetWindowLong (topHandle, OS.GWL_STYLE);
if ((bits & OS.WS_VISIBLE) != 0) {
children [i].printWidget (topHandle, hdc, gc);
@@ -448,12 +448,12 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return GroupProc;
}
@Override
-LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ERASEBKGND (long wParam, long lParam) {
LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
if (result != null) return result;
/*
@@ -466,7 +466,7 @@ LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_NCHITTEST (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NCHITTEST (long wParam, long lParam) {
LRESULT result = super.WM_NCHITTEST (wParam, lParam);
if (result != null) return result;
/*
@@ -478,13 +478,13 @@ LRESULT WM_NCHITTEST (long /*int*/ wParam, long /*int*/ lParam) {
* allow children, answer HTCLIENT to allow mouse messages
* to be delivered to the children.
*/
- long /*int*/ code = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
if (code == OS.HTTRANSPARENT) code = OS.HTCLIENT;
return new LRESULT (code);
}
@Override
-LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSEMOVE (long wParam, long lParam) {
LRESULT result = super.WM_MOUSEMOVE (wParam, lParam);
if (result != null) return result;
/*
@@ -497,7 +497,7 @@ LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PAINT (long wParam, long lParam) {
LRESULT result = super.WM_PAINT(wParam, lParam);
if (hasCustomForeground() && text.length () != 0) {
@@ -505,12 +505,12 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
char [] buffer = (string == null ? text : string).toCharArray ();
// We cannot use BeginPaint and EndPaint, because that removes the group border
- long /*int*/ hDC = OS.GetDC(handle);
+ long hDC = OS.GetDC(handle);
RECT rect = new RECT ();
OS.GetClientRect (handle, rect);
rect.left += 3*CLIENT_INSET;
- long /*int*/ newFont, oldFont = 0;
+ long newFont, oldFont = 0;
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
@@ -531,7 +531,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_PRINTCLIENT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PRINTCLIENT (long wParam, long lParam) {
LRESULT result = super.WM_PRINTCLIENT (wParam, lParam);
if (result != null) return result;
/*
@@ -546,7 +546,7 @@ LRESULT WM_PRINTCLIENT (long /*int*/ wParam, long /*int*/ lParam) {
*/
if (OS.IsAppThemed ()) {
int nSavedDC = OS.SaveDC (wParam);
- long /*int*/ code = callWindowProc (handle, OS.WM_PRINTCLIENT, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_PRINTCLIENT, wParam, lParam);
OS.RestoreDC (wParam, nSavedDC);
return new LRESULT (code);
}
@@ -554,7 +554,7 @@ LRESULT WM_PRINTCLIENT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_UPDATEUISTATE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_UPDATEUISTATE (long wParam, long lParam) {
LRESULT result = super.WM_UPDATEUISTATE (wParam, lParam);
if (result != null) return result;
/*
@@ -576,14 +576,14 @@ LRESULT WM_UPDATEUISTATE (long /*int*/ wParam, long /*int*/ lParam) {
}
if (redraw) {
OS.InvalidateRect (handle, null, false);
- long /*int*/ code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam);
+ long code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam);
return new LRESULT (code);
}
return result;
}
@Override
-LRESULT WM_WINDOWPOSCHANGING (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_WINDOWPOSCHANGING (long wParam, long lParam) {
LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam);
if (result != null) return result;
/*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java
index 9e3e860ae6..8468050917 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java
@@ -16,6 +16,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.ole.win32.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -50,17 +51,6 @@ public class IME extends Widget {
static final int WM_MSIME_MOUSE = OS.RegisterWindowMessage (new TCHAR (0, "MSIMEMouseOperation", true)); //$NON-NLS-1$
- static final byte [] IID_ITfInputProcessorProfiles = new byte [16];
- static final byte [] IID_ITfDisplayAttributeProvider = new byte [16];
- static final byte [] CLSID_TF_InputProcessorProfiles = new byte [16];
- static final byte [] GUID_TFCAT_TIP_KEYBOARD = new byte [16];
- static {
- OS.IIDFromString ("{1F02B6C5-7842-4EE6-8A0B-9A24183A95CA}\0".toCharArray (), IID_ITfInputProcessorProfiles); //$NON-NLS-1$
- OS.IIDFromString ("{fee47777-163c-4769-996a-6e9c50ad8f54}\0".toCharArray (), IID_ITfDisplayAttributeProvider); //$NON-NLS-1$
- OS.IIDFromString ("{33C53A50-F456-4884-B049-85FD643ECFED}\0".toCharArray (), CLSID_TF_InputProcessorProfiles); //$NON-NLS-1$
- OS.IIDFromString ("{34745C63-B2F0-4784-8B67-5E12C8701A31}\0".toCharArray (), GUID_TFCAT_TIP_KEYBOARD); //$NON-NLS-1$
- }
-
/* TextLayout has a copy of these constants */
static final int UNDERLINE_IME_DOT = 1 << 16;
static final int UNDERLINE_IME_DASH = 2 << 16;
@@ -169,44 +159,37 @@ public int getCompositionOffset () {
}
TF_DISPLAYATTRIBUTE getDisplayAttribute (short langid, int attInfo) {
- long /*int*/ [] pProfiles = new long /*int*/ [1];
- int hr = OS.CoCreateInstance (CLSID_TF_InputProcessorProfiles, 0, OS.CLSCTX_INPROC_SERVER, IID_ITfInputProcessorProfiles, pProfiles);
+ long [] ppv = new long [1];
+ int hr = COM.CoCreateInstance (COM.CLSID_TF_InputProcessorProfiles, 0, COM.CLSCTX_INPROC_SERVER, COM.IID_ITfInputProcessorProfiles, ppv);
TF_DISPLAYATTRIBUTE pda = null;
if (hr == OS.S_OK) {
- byte [] pclsid = new byte [16];
- byte [] pguidProfile = new byte [16];
- /* pProfiles.GetDefaultLanguageProfile () */
- hr = OS.VtblCall (8, pProfiles [0], langid, GUID_TFCAT_TIP_KEYBOARD, pclsid, pguidProfile);
+ ITfInputProcessorProfiles pProfiles = new ITfInputProcessorProfiles (ppv [0]);
+ GUID pclsid = new GUID ();
+ GUID pguidProfile = new GUID ();
+ hr = pProfiles.GetDefaultLanguageProfile (langid, COM.GUID_TFCAT_TIP_KEYBOARD, pclsid, pguidProfile);
if (hr == OS.S_OK) {
- long /*int*/ [] pProvider = new long /*int*/ [1];
- hr = OS.CoCreateInstance (pclsid, 0, OS.CLSCTX_INPROC_SERVER, IID_ITfDisplayAttributeProvider, pProvider);
+ hr = COM.CoCreateInstance (pclsid, 0, COM.CLSCTX_INPROC_SERVER, COM.IID_ITfDisplayAttributeProvider, ppv);
if (hr == OS.S_OK) {
- long /*int*/ [] pEnum = new long /*int*/ [1];
- /* pProvider.EnumDisplayAttributeInfo () */
- hr = OS.VtblCall (3, pProvider [0], pEnum);
+ ITfDisplayAttributeProvider pProvider = new ITfDisplayAttributeProvider (ppv [0]);
+ hr = pProvider.EnumDisplayAttributeInfo (ppv);
if (hr == OS.S_OK) {
- long /*int*/ [] pDispInfo = new long /*int*/ [1];
+ IEnumTfDisplayAttributeInfo pEnum = new IEnumTfDisplayAttributeInfo (ppv [0]);
TF_DISPLAYATTRIBUTE tempPda = new TF_DISPLAYATTRIBUTE ();
- /* pEnum.Next () */
- while ((hr = OS.VtblCall (4, pEnum [0], 1, pDispInfo, (int[])null)) == OS.S_OK) {
- /* pDispInfo.GetAttributeInfo(); */
- OS.VtblCall (5, pDispInfo [0], tempPda);
- /* pDispInfo.Release () */
- OS.VtblCall (2, pDispInfo [0]);
+ while ((hr = pEnum.Next (1, ppv, null)) == OS.S_OK) {
+ ITfDisplayAttributeInfo pDispInfo = new ITfDisplayAttributeInfo (ppv [0]);
+ pDispInfo.GetAttributeInfo (tempPda);
+ pDispInfo.Release ();
if (tempPda.bAttr == attInfo) {
pda = tempPda;
break;
}
}
- /* pEnum.Release () */
- hr = OS.VtblCall (2, pEnum [0]);
+ pEnum.Release ();
}
- /* pProvider.Release () */
- hr = OS.VtblCall (2, pProvider [0]);
+ pProvider.Release ();
}
}
- /* pProfiles.Release () */
- hr = OS.VtblCall (2, pProfiles [0]);
+ pProfiles.Release ();
}
if (pda == null) {
pda = new TF_DISPLAYATTRIBUTE ();
@@ -314,7 +297,7 @@ public String getText () {
*/
public boolean getWideCaret() {
checkWidget ();
- long /*int*/ layout = OS.GetKeyboardLayout (0);
+ long layout = OS.GetKeyboardLayout (0);
short langID = (short)OS.LOWORD (layout);
return OS.PRIMARYLANGID (langID) == OS.LANG_KOREAN;
}
@@ -362,13 +345,13 @@ public void setCompositionOffset (int offset) {
}
}
-LRESULT WM_IME_COMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_IME_COMPOSITION (long wParam, long lParam) {
if (!isInlineEnabled ()) return null;
ranges = null;
styles = null;
caretOffset = commitCount = 0;
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hIMC = OS.ImmGetContext (hwnd);
+ long hwnd = parent.handle;
+ long hIMC = OS.ImmGetContext (hwnd);
if (hIMC != 0) {
char [] buffer = null;
if ((lParam & OS.GCS_RESULTSTR) != 0) {
@@ -434,7 +417,7 @@ LRESULT WM_IME_COMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
length = clauses.length - 1;
ranges = new int [length * 2];
styles = new TextStyle [length];
- long /*int*/ layout = OS.GetKeyboardLayout (0);
+ long layout = OS.GetKeyboardLayout (0);
short langID = (short)OS.LOWORD (layout);
TF_DISPLAYATTRIBUTE attr = null;
TextStyle style = null;
@@ -519,20 +502,20 @@ LRESULT WM_IME_COMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
return LRESULT.ONE;
}
-LRESULT WM_IME_COMPOSITION_START (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_IME_COMPOSITION_START (long wParam, long lParam) {
return isInlineEnabled () ? LRESULT.ONE : null;
}
-LRESULT WM_IME_ENDCOMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_IME_ENDCOMPOSITION (long wParam, long lParam) {
// Reset defaults. Otherwise the next composition overwrites the previous one.
startOffset = -1;
caretOffset = 0;
return isInlineEnabled () ? LRESULT.ONE : null;
}
-LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KEYDOWN (long wParam, long lParam) {
if (wParam == OS.VK_HANJA) {
- long /*int*/ hKL = OS.GetKeyboardLayout (0);
+ long hKL = OS.GetKeyboardLayout (0);
short langID = (short)OS.LOWORD (hKL);
if (OS.PRIMARYLANGID (langID) == OS.LANG_KOREAN) {
Event event = new Event ();
@@ -545,13 +528,13 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
if (event.text != null && event.text.length() > 0) {
int length = event.text.length();
- if (length > 1) {
- event.end = event.start + 1;
- }
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hIMC = OS.ImmGetContext (hwnd);
+ if (length > 1) {
+ event.end = event.start + 1;
+ }
+ long hwnd = parent.handle;
+ long hIMC = OS.ImmGetContext (hwnd);
TCHAR buffer = new TCHAR (0, event.text, true);
- long /*int*/ rc = OS.ImmEscape(hKL, hIMC, OS.IME_ESC_HANJA_MODE, buffer);
+ long rc = OS.ImmEscape(hKL, hIMC, OS.IME_ESC_HANJA_MODE, buffer);
if (rc != 0) {
sendEvent (SWT.ImeComposition, event);
}
@@ -561,10 +544,10 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KILLFOCUS (long wParam, long lParam) {
if (!isInlineEnabled ()) return null;
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hIMC = OS.ImmGetContext (hwnd);
+ long hwnd = parent.handle;
+ long hIMC = OS.ImmGetContext (hwnd);
if (hIMC != 0) {
if (OS.ImmGetOpenStatus (hIMC)) {
OS.ImmNotifyIME (hIMC, OS.NI_COMPOSITIONSTR, OS.CPS_COMPLETE, 0);
@@ -574,10 +557,10 @@ LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDOWN (long wParam, long lParam) {
if (!isInlineEnabled ()) return null;
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hIMC = OS.ImmGetContext (hwnd);
+ long hwnd = parent.handle;
+ long hIMC = OS.ImmGetContext (hwnd);
if (hIMC != 0) {
if (OS.ImmGetOpenStatus (hIMC)) {
if (OS.ImmGetCompositionString (hIMC, OS.GCS_COMPSTR, (char [])null, 0) > 0) {
@@ -588,10 +571,10 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
int offset = event.index;
int length = text.length();
if (offset != -1 && startOffset != -1 && startOffset <= offset && offset < startOffset + length) {
- long /*int*/ imeWnd = OS.ImmGetDefaultIMEWnd (hwnd);
+ long imeWnd = OS.ImmGetDefaultIMEWnd (hwnd);
offset = event.index + event.count - startOffset;
int trailing = event.count > 0 ? 1 : 2;
- long /*int*/ param = OS.MAKEWPARAM (OS.MAKEWORD (OS.IMEMOUSE_LDOWN, trailing), offset);
+ long param = OS.MAKEWPARAM (OS.MAKEWORD (OS.IMEMOUSE_LDOWN, trailing), offset);
OS.SendMessage (imeWnd, WM_MSIME_MOUSE, param, hIMC);
} else {
OS.ImmNotifyIME (hIMC, OS.NI_COMPOSITIONSTR, OS.CPS_COMPLETE, 0);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
index 4c8ddfeaec..4ae061cb21 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Paul Pazderski - Bug 205199: setImage(null) on Label overrides text
*******************************************************************************/
package org.eclipse.swt.widgets;
@@ -54,9 +55,9 @@ import org.eclipse.swt.internal.win32.*;
public class Label extends Control {
String text = "";
Image image;
+ boolean isImageMode; // Resolves ambiguity when both image and text are set
static final int MARGIN = 4;
- static /*final*/ boolean IMAGE_AND_TEXT = false;
- static final long /*int*/ LabelProc;
+ static final long LabelProc;
static final TCHAR LabelClass = new TCHAR (0, "STATIC", true);
static {
WNDCLASS lpWndClass = new WNDCLASS ();
@@ -106,7 +107,7 @@ public Label (Composite parent, int style) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
/*
* Feature in Windows 7. When the user double clicks
@@ -146,25 +147,14 @@ static int checkStyle (int style) {
width += border * 2; height += border * 2;
return new Point (width, height);
}
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- boolean drawText = true;
- boolean drawImage = (bits & OS.SS_OWNERDRAW) == OS.SS_OWNERDRAW;
- if (drawImage) {
- if (image != null) {
- Rectangle rect = image.getBoundsInPixels();
- width += rect.width;
- height += rect.height;
- if (IMAGE_AND_TEXT) {
- if (text.length () != 0) width += MARGIN;
- } else {
- drawText = false;
- }
- }
- }
- if (drawText) {
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
- long /*int*/ oldFont = OS.SelectObject (hDC, newFont);
+ if (isImageMode) {
+ Rectangle rect = image.getBoundsInPixels();
+ width += rect.width;
+ height += rect.height;
+ } else {
+ long hDC = OS.GetDC (handle);
+ long newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ long oldFont = OS.SelectObject (hDC, newFont);
int length = OS.GetWindowTextLength (handle);
if (length == 0) {
TEXTMETRIC tm = new TEXTMETRIC ();
@@ -262,6 +252,11 @@ public String getText () {
}
@Override
+boolean isUseWsBorder () {
+ return super.isUseWsBorder () || ((display != null) && display.useWsBorderLabel);
+}
+
+@Override
boolean mnemonicHit (char key) {
Control control = this;
while (control.parent != null) {
@@ -318,23 +313,25 @@ public void setAlignment (int alignment) {
if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- if ((bits & OS.SS_OWNERDRAW) != OS.SS_OWNERDRAW) {
- bits &= ~(OS.SS_LEFTNOWORDWRAP | OS.SS_CENTER | OS.SS_RIGHT);
- if ((style & SWT.LEFT) != 0) {
- if ((style & SWT.WRAP) != 0) {
- bits |= OS.SS_LEFT;
- } else {
- bits |= OS.SS_LEFTNOWORDWRAP;
- }
- }
- if ((style & SWT.CENTER) != 0) bits |= OS.SS_CENTER;
- if ((style & SWT.RIGHT) != 0) bits |= OS.SS_RIGHT;
- OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
- }
+ updateStyleBits(getEnabled());
OS.InvalidateRect (handle, null, true);
}
+@Override
+public void setEnabled (boolean enabled) {
+ if ((style & SWT.SEPARATOR) != 0) return;
+ /*
+ * Style may need to be changed if Display#disabledLabelForegroundPixel
+ * is active. At the same time, #setEnabled() will cause a repaint with
+ * current style. Therefore, style needs to be changed before #setEnabled().
+ * Note that adding redraw() after #setEnabled() is a worse solution
+ * because it still causes brief old style painting in #setEnabled().
+ */
+ updateStyleBits(enabled);
+
+ super.setEnabled(enabled);
+}
+
/**
* Sets the receiver's image to the argument, which may be
* null indicating that no image should be displayed.
@@ -354,12 +351,8 @@ public void setImage (Image image) {
if ((style & SWT.SEPARATOR) != 0) return;
if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
this.image = image;
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- if ((bits & OS.SS_OWNERDRAW) != OS.SS_OWNERDRAW) {
- bits &= ~(OS.SS_LEFTNOWORDWRAP | OS.SS_CENTER | OS.SS_RIGHT);
- bits |= OS.SS_OWNERDRAW;
- OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
- }
+ isImageMode = (image != null);
+ updateStyleBits(getEnabled());
OS.InvalidateRect (handle, null, true);
}
@@ -398,6 +391,8 @@ public void setText (String string) {
checkWidget ();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if ((style & SWT.SEPARATOR) != 0) return;
+ isImageMode = false;
+ updateStyleBits(getEnabled());
/*
* Feature in Windows. For some reason, SetWindowText() for
* static controls redraws the control, even when the text has
@@ -406,9 +401,29 @@ public void setText (String string) {
*/
if (string.equals (text)) return;
text = string;
- if (image == null || !IMAGE_AND_TEXT) {
- int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE), newBits = oldBits;
- newBits &= ~OS.SS_OWNERDRAW;
+ string = Display.withCrLf (string);
+ TCHAR buffer = new TCHAR (getCodePage (), string, true);
+ OS.SetWindowText (handle, buffer);
+ if ((state & HAS_AUTO_DIRECTION) != 0) {
+ updateTextDirection (AUTO_TEXT_DIRECTION);
+ }
+}
+
+void updateStyleBits(boolean isEnabled) {
+ boolean useOwnerDraw = isImageMode;
+
+ if (!useOwnerDraw && (display.disabledLabelForegroundPixel != -1) && !isEnabled)
+ useOwnerDraw = true;
+
+ int oldBits = OS.GetWindowLong(handle, OS.GWL_STYLE);
+
+ int newBits = oldBits;
+ newBits &= ~OS.SS_OWNERDRAW;
+ newBits &= ~(OS.SS_LEFTNOWORDWRAP | OS.SS_CENTER | OS.SS_RIGHT);
+
+ if (useOwnerDraw) {
+ newBits |= OS.SS_OWNERDRAW;
+ } else {
if ((style & SWT.LEFT) != 0) {
if ((style & SWT.WRAP) != 0) {
newBits |= OS.SS_LEFT;
@@ -418,14 +433,9 @@ public void setText (String string) {
}
if ((style & SWT.CENTER) != 0) newBits |= OS.SS_CENTER;
if ((style & SWT.RIGHT) != 0) newBits |= OS.SS_RIGHT;
- if (oldBits != newBits) OS.SetWindowLong (handle, OS.GWL_STYLE, newBits);
- }
- string = Display.withCrLf (string);
- TCHAR buffer = new TCHAR (getCodePage (), string, true);
- OS.SetWindowText (handle, buffer);
- if ((state & HAS_AUTO_DIRECTION) != 0) {
- updateTextDirection (AUTO_TEXT_DIRECTION);
}
+
+ if (oldBits != newBits) OS.SetWindowLong (handle, OS.GWL_STYLE, newBits);
}
@Override
@@ -452,12 +462,12 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return LabelProc;
}
@Override
-LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ERASEBKGND (long wParam, long lParam) {
LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
if (result != null) return result;
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
@@ -468,7 +478,7 @@ LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
LRESULT result = super.WM_SIZE (wParam, lParam);
if (isDisposed ()) return result;
if ((style & SWT.SEPARATOR) != 0) {
@@ -495,7 +505,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_UPDATEUISTATE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_UPDATEUISTATE (long wParam, long lParam) {
LRESULT result = super.WM_UPDATEUISTATE (wParam, lParam);
if (result != null) return result;
/*
@@ -516,90 +526,98 @@ LRESULT WM_UPDATEUISTATE (long /*int*/ wParam, long /*int*/ lParam) {
}
if (redraw) {
OS.InvalidateRect (handle, null, false);
- long /*int*/ code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam);
+ long code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam);
return new LRESULT (code);
}
return result;
}
+void wmDrawChildSeparator(DRAWITEMSTRUCT struct) {
+ if ((style & SWT.SHADOW_NONE) != 0) return;
+
+ RECT rect = new RECT ();
+ int lineWidth = OS.GetSystemMetrics (OS.SM_CXBORDER);
+ int flags = (style & SWT.SHADOW_IN) != 0 ? OS.EDGE_SUNKEN : OS.EDGE_ETCHED;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ int bottom = struct.top + Math.max (lineWidth * 2, (struct.bottom - struct.top) / 2);
+ OS.SetRect (rect, struct.left, struct.top, struct.right, bottom);
+ OS.DrawEdge (struct.hDC, rect, flags, OS.BF_BOTTOM);
+ } else {
+ int right = struct.left + Math.max (lineWidth * 2, (struct.right - struct.left) / 2);
+ OS.SetRect (rect, struct.left, struct.top, right, struct.bottom);
+ OS.DrawEdge (struct.hDC, rect, flags, OS.BF_RIGHT);
+ }
+}
+
+void wmDrawChildImage(DRAWITEMSTRUCT struct) {
+ int width = struct.right - struct.left;
+ int height = struct.bottom - struct.top;
+ if (width == 0 || height == 0) return;
+
+ Rectangle imageRect = image.getBoundsInPixels ();
+
+ int x = 0;
+ if ((style & SWT.CENTER) != 0) {
+ x = Math.max (0, (width - imageRect.width) / 2);
+ } else if ((style & SWT.RIGHT) != 0) {
+ x = width - imageRect.width;
+ }
+
+ GCData data = new GCData();
+ data.device = display;
+ GC gc = GC.win32_new (struct.hDC, data);
+ Image image = getEnabled () ? this.image : new Image (display, this.image, SWT.IMAGE_DISABLE);
+ gc.drawImage (image, DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(Math.max (0, (height - imageRect.height) / 2)));
+ if (image != this.image) image.dispose ();
+ gc.dispose ();
+}
+
+void wmDrawChildText(DRAWITEMSTRUCT struct) {
+ int width = struct.right - struct.left;
+ int height = struct.bottom - struct.top;
+ if (width == 0 || height == 0) return;
+
+ RECT rect = new RECT ();
+ rect.left = struct.left;
+ rect.top = struct.top;
+ rect.right = struct.right;
+ rect.bottom = struct.bottom;
+
+ int flags = OS.DT_EDITCONTROL | OS.DT_EXPANDTABS;
+ if ((style & SWT.LEFT) != 0) flags |= OS.DT_LEFT;
+ if ((style & SWT.CENTER) != 0) flags |= OS.DT_CENTER;
+ if ((style & SWT.RIGHT) != 0) flags |= OS.DT_RIGHT;
+ if ((style & SWT.WRAP) != 0) flags |= OS.DT_WORDBREAK;
+
+ // Mnemonics are usually not shown on Labels until Alt is pressed.
+ long uiState = OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ if ((uiState & OS.UISF_HIDEACCEL) != 0)
+ flags |= OS.DT_HIDEPREFIX;
+
+ if (!getEnabled()) {
+ int foregroundPixel = OS.GetSysColor(OS.COLOR_GRAYTEXT);
+ if (display.disabledLabelForegroundPixel != -1)
+ foregroundPixel = display.disabledLabelForegroundPixel;
+
+ OS.SetTextColor(struct.hDC, foregroundPixel);
+ }
+
+ char [] buffer = text.toCharArray ();
+ OS.DrawText (struct.hDC, buffer, buffer.length, rect, flags);
+}
+
@Override
-LRESULT wmDrawChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmDrawChild (long wParam, long lParam) {
DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ();
OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof);
drawBackground (struct.hDC);
- if ((style & SWT.SEPARATOR) != 0) {
- if ((style & SWT.SHADOW_NONE) != 0) return null;
- RECT rect = new RECT ();
- int lineWidth = OS.GetSystemMetrics (OS.SM_CXBORDER);
- int flags = (style & SWT.SHADOW_IN) != 0 ? OS.EDGE_SUNKEN : OS.EDGE_ETCHED;
- if ((style & SWT.HORIZONTAL) != 0) {
- int bottom = struct.top + Math.max (lineWidth * 2, (struct.bottom - struct.top) / 2);
- OS.SetRect (rect, struct.left, struct.top, struct.right, bottom);
- OS.DrawEdge (struct.hDC, rect, flags, OS.BF_BOTTOM);
- } else {
- int right = struct.left + Math.max (lineWidth * 2, (struct.right - struct.left) / 2);
- OS.SetRect (rect, struct.left, struct.top, right, struct.bottom);
- OS.DrawEdge (struct.hDC, rect, flags, OS.BF_RIGHT);
- }
- } else {
- int width = struct.right - struct.left;
- int height = struct.bottom - struct.top;
- if (width != 0 && height != 0) {
- boolean drawImage = image != null;
- boolean drawText = IMAGE_AND_TEXT && text.length () != 0;
- int margin = drawText && drawImage ? MARGIN : 0;
- int imageWidth = 0, imageHeight = 0;
- if (drawImage) {
- Rectangle rect = image.getBoundsInPixels ();
- imageWidth = rect.width;
- imageHeight = rect.height;
- }
- RECT rect = null;
- char [] buffer = null;
- int textWidth = 0, textHeight = 0, flags = 0;
- if (drawText) {
- rect = new RECT ();
- flags = OS.DT_CALCRECT | OS.DT_EDITCONTROL | OS.DT_EXPANDTABS;
- if ((style & SWT.LEFT) != 0) flags |= OS.DT_LEFT;
- if ((style & SWT.CENTER) != 0) flags |= OS.DT_CENTER;
- if ((style & SWT.RIGHT) != 0) flags |= OS.DT_RIGHT;
- if ((style & SWT.WRAP) != 0) {
- flags |= OS.DT_WORDBREAK;
- rect.right = Math.max (0, width - imageWidth - margin);
- }
- buffer = text.toCharArray ();
- OS.DrawText (struct.hDC, buffer, buffer.length, rect, flags);
- textWidth = rect.right - rect.left;
- textHeight = rect.bottom - rect.top;
- }
- int x = 0;
- if ((style & SWT.CENTER) != 0) {
- x = Math.max (0, (width - imageWidth - textWidth - margin) / 2);
- } else {
- if ((style & SWT.RIGHT) != 0) {
- x = width - imageWidth - textWidth - margin;
- }
- }
- if (drawImage) {
- GCData data = new GCData();
- data.device = display;
- GC gc = GC.win32_new (struct.hDC, data);
- Image image = getEnabled () ? this.image : new Image (display, this.image, SWT.IMAGE_DISABLE);
- gc.drawImage (image, DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(Math.max (0, (height - imageHeight) / 2)));
- if (image != this.image) image.dispose ();
- gc.dispose ();
- x += imageWidth + margin;
- }
- if (drawText) {
- flags &= ~OS.DT_CALCRECT;
- rect.left = x;
- rect.right += rect.left;
- rect.top = Math.max (0, (height - textHeight) / 2);
- rect.bottom += rect.top;
- OS.DrawText (struct.hDC, buffer, buffer.length, rect, flags);
- }
- }
- }
+ if ((style & SWT.SEPARATOR) != 0)
+ wmDrawChildSeparator(struct);
+ else if (isImageMode)
+ wmDrawChildImage(struct);
+ else
+ wmDrawChildText(struct);
+
return null;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
index 11ffbedc50..36f9b5695c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
@@ -14,8 +14,9 @@
*******************************************************************************/
package org.eclipse.swt.widgets;
+import java.util.*;
+
import org.eclipse.swt.*;
-import org.eclipse.swt.accessibility.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
@@ -44,17 +45,11 @@ import org.eclipse.swt.internal.win32.*;
*/
public class Link extends Control {
String text;
- TextLayout layout; // always track the current layout, even if we don't need it.
- Color disabledColor;
int linkForeground = -1;
- Point [] offsets;
- Point selection;
String [] ids;
- int [] mnemonics;
- int focusIndex, mouseDownIndex;
- long /*int*/ font;
- static final RGB LAST_FALLBACK_LINK_FOREGROUND = new RGB (0, 51, 153);
- static final long /*int*/ LinkProc;
+ char [] mnemonics;
+ int nextFocusItem = -1;
+ static final long LinkProc;
static final TCHAR LinkClass = new TCHAR (0, OS.WC_LINK, true);
static {
WNDCLASS lpWndClass = new WNDCLASS ();
@@ -147,7 +142,7 @@ public void addSelectionListener (SelectionListener listener) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
/*
* Feature in Windows. By convention, native Windows controls
@@ -166,49 +161,30 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
return OS.CallWindowProc (LinkProc, hwnd, msg, wParam, lParam);
}
-@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
+@Override
+Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
- if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
- if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
int width, height;
- if (useCommonControl()) {
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
- long /*int*/ oldFont = OS.SelectObject (hDC, newFont);
- if (text.length () > 0) {
- char [] buffer = parse (text).toCharArray ();
- RECT rect = new RECT ();
- int flags = OS.DT_CALCRECT | OS.DT_NOPREFIX;
- if (wHint != SWT.DEFAULT) {
- flags |= OS.DT_WORDBREAK;
- rect.right = wHint;
- }
- OS.DrawText (hDC, buffer, buffer.length, rect, flags);
- width = rect.right - rect.left;
- height = rect.bottom;
- } else {
- TEXTMETRIC lptm = new TEXTMETRIC ();
- OS.GetTextMetrics (hDC, lptm);
- width = 0;
- height = lptm.tmHeight;
- }
+ /*
+ * When the text is empty, LM_GETIDEALSIZE returns zero width and height,
+ * but SWT convention is to return zero width and line height.
+ */
+ if (text.isEmpty()) {
+ long hDC = OS.GetDC (handle);
+ long newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ long oldFont = OS.SelectObject (hDC, newFont);
+ TEXTMETRIC lptm = new TEXTMETRIC ();
+ OS.GetTextMetrics (hDC, lptm);
+ width = 0;
+ height = lptm.tmHeight;
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (handle, hDC);
} else {
- int layoutWidth = layout.getWidth ();
- //TEMPORARY CODE
- if (wHint == 0) {
- layout.setWidth (1);
- Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds ());
- width = 0;
- height = rect.height;
- } else {
- layout.setWidth (DPIUtil.autoScaleDown(wHint));
- Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds ());
- width = rect.width;
- height = rect.height;
- }
- layout.setWidth (layoutWidth);
+ SIZE size = new SIZE ();
+ int maxWidth = (wHint == SWT.DEFAULT) ? 0x7fffffff : wHint;
+ OS.SendMessage (handle, OS.LM_GETIDEALSIZE, maxWidth, size);
+ width = size.cx;
+ height = size.cy;
}
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
@@ -222,131 +198,37 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
void createHandle () {
super.createHandle ();
state |= THEME_BACKGROUND;
- layout = new TextLayout (display);
- disabledColor = Color.win32_new (display, OS.GetSysColor (OS.COLOR_GRAYTEXT));
- offsets = new Point [0];
- ids = new String [0];
- mnemonics = new int [0];
- selection = new Point (-1, -1);
- focusIndex = mouseDownIndex = -1;
}
@Override
void createWidget () {
super.createWidget ();
text = "";
- if ((style & SWT.MIRRORED) != 0) {
- layout.setOrientation (SWT.RIGHT_TO_LEFT);
- }
- initAccessible ();
-}
-
-void drawWidget (GC gc, RECT rect) {
- drawBackground (gc.handle, rect);
- int selStart = selection.x;
- int selEnd = selection.y;
- if (selStart > selEnd) {
- selStart = selection.y;
- selEnd = selection.x;
- }
- // temporary code to disable text selection
- selStart = selEnd = -1;
- if (!OS.IsWindowEnabled (handle)) gc.setForeground (disabledColor);
- layout.draw (gc, 0, 0, selStart, selEnd, null, null);
- if (hasFocus () && focusIndex != -1) {
- Rectangle [] rects = getRectanglesInPixels (focusIndex);
- for (int i = 0; i < rects.length; i++) {
- Rectangle rectangle = DPIUtil.autoScaleDown(rects [i]);
- gc.drawFocus (rectangle.x, rectangle.y, rectangle.width, rectangle.height);
- }
- }
- if (hooks (SWT.Paint) || filters (SWT.Paint)) {
- Event event = new Event ();
- event.gc = gc;
- event.setBoundsInPixels(new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top));
- sendEvent (SWT.Paint, event);
- event.gc = null;
- }
+ ids = new String[0];
+ mnemonics = new char[0];
}
@Override
void enableWidget (boolean enabled) {
- if (useCommonControl(enabled)) {
- LITEM item = new LITEM ();
- item.mask = OS.LIF_ITEMINDEX | OS.LIF_STATE;
- item.stateMask = OS.LIS_ENABLED;
- item.state = enabled ? OS.LIS_ENABLED : 0;
- while (OS.SendMessage (handle, OS.LM_SETITEM, 0, item) != 0) {
- item.iLink++;
- }
- }
- styleLinkParts(enabled);
- redraw ();
- /*
- * Feature in Windows. For some reason, setting
- * LIS_ENABLED state using LM_SETITEM causes the
- * SysLink to become enabled. To be specific,
- * calling IsWindowEnabled() returns true. The
- * fix is disable the SysLink after LM_SETITEM.
- */
super.enableWidget (enabled);
+ /*
+ * Feature in Windows. SysLink32 control doesn't natively
+ * provide disabled state. Emulate it with custom draw.
+ */
+ OS.InvalidateRect (handle, null, true);
}
-void initAccessible () {
- Accessible accessible = getAccessible ();
- accessible.addAccessibleListener (new AccessibleAdapter () {
- @Override
- public void getName (AccessibleEvent e) {
- e.result = parse (text);
- }
- });
-
- accessible.addAccessibleControlListener (new AccessibleControlAdapter () {
- @Override
- public void getChildAtPoint (AccessibleControlEvent e) {
- e.childID = ACC.CHILDID_SELF;
- }
-
- @Override
- public void getLocation (AccessibleControlEvent e) {
- Rectangle rect = display.mapInPixels (getParent (), null, getBoundsInPixels ());
- e.x = rect.x;
- e.y = rect.y;
- e.width = rect.width;
- e.height = rect.height;
+int getFocusItem () {
+ LITEM item = new LITEM ();
+ item.mask = OS.LIF_ITEMINDEX | OS.LIF_STATE;
+ item.stateMask = OS.LIS_FOCUSED;
+ while (OS.SendMessage (handle, OS.LM_GETITEM, 0, item) != 0) {
+ if ((item.state & OS.LIS_FOCUSED) != 0) {
+ return item.iLink;
}
-
- @Override
- public void getChildCount (AccessibleControlEvent e) {
- e.detail = 0;
- }
-
- @Override
- public void getRole (AccessibleControlEvent e) {
- e.detail = ACC.ROLE_LINK;
- }
-
- @Override
- public void getState (AccessibleControlEvent e) {
- e.detail = ACC.STATE_FOCUSABLE;
- if (hasFocus ()) e.detail |= ACC.STATE_FOCUSED;
- }
-
- @Override
- public void getDefaultAction (AccessibleControlEvent e) {
- e.result = SWT.getMessage ("SWT_Press"); //$NON-NLS-1$
- }
-
- @Override
- public void getSelection (AccessibleControlEvent e) {
- if (hasFocus ()) e.childID = ACC.CHILDID_SELF;
- }
-
- @Override
- public void getFocus (AccessibleControlEvent e) {
- if (hasFocus ()) e.childID = ACC.CHILDID_SELF;
- }
- });
+ item.iLink++;
+ }
+ return -1;
}
/**
@@ -362,10 +244,6 @@ void initAccessible () {
*/
public Color getLinkForeground () {
checkWidget ();
- return internalGetLinkForeground();
-}
-
-Color internalGetLinkForeground() {
if (linkForeground != -1) {
return Color.win32_new (display, linkForeground);
}
@@ -377,35 +255,6 @@ String getNameText () {
return getText ();
}
-Rectangle [] getRectanglesInPixels (int linkIndex) {
- int lineCount = layout.getLineCount ();
- Rectangle [] rects = new Rectangle [lineCount];
- int [] lineOffsets = layout.getLineOffsets ();
- Point point = offsets [linkIndex];
- int lineStart = 1;
- while (point.x > lineOffsets [lineStart]) lineStart++;
- int lineEnd = 1;
- while (point.y > lineOffsets [lineEnd]) lineEnd++;
- int index = 0;
- if (lineStart == lineEnd) {
- rects [index++] = DPIUtil.autoScaleUp(layout.getBounds (point.x, point.y));
- } else {
- rects [index++] = DPIUtil.autoScaleUp(layout.getBounds (point.x, lineOffsets [lineStart]-1));
- rects [index++] = DPIUtil.autoScaleUp(layout.getBounds (lineOffsets [lineEnd-1], point.y));
- if (lineEnd - lineStart > 1) {
- for (int i = lineStart; i < lineEnd - 1; i++) {
- rects [index++] = DPIUtil.autoScaleUp(layout.getLineBounds (i));
- }
- }
- }
- if (rects.length != index) {
- Rectangle [] tmp = new Rectangle [index];
- System.arraycopy (rects, 0, tmp, 0, index);
- rects = tmp;
- }
- return rects;
-}
-
/**
* Returns the receiver's text, which will be an empty
* string if it has never been set.
@@ -424,39 +273,11 @@ public String getText () {
@Override
boolean mnemonicHit (char key) {
- if (mnemonics != null) {
- char uckey = Character.toUpperCase (key);
- String parsedText = parse(text);
- for (int i = 0; i < mnemonics.length - 1; i++) {
- if (mnemonics[i] != -1) {
- char mnemonic = parsedText.charAt(mnemonics[i]);
- if (uckey == Character.toUpperCase (mnemonic)) {
- if (!setFocus ()) return false;
- if (useCommonControl()) {
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- LITEM item = new LITEM ();
- item.mask = OS.LIF_ITEMINDEX | OS.LIF_STATE;
- item.stateMask = OS.LIS_FOCUSED;
- while (item.iLink < mnemonics.length) {
- if (item.iLink != i) OS.SendMessage (handle, OS.LM_SETITEM, 0, item);
- item.iLink++;
- }
- item.iLink = i;
- item.state = OS.LIS_FOCUSED;
- OS.SendMessage (handle, OS.LM_SETITEM, 0, item);
-
- /* Feature in Windows. For some reason, setting the focus to
- * any item but first causes the control to clear the WS_TABSTOP
- * bit. The fix is always to reset the bit.
- */
- OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
- } else {
- focusIndex = i;
- redraw ();
- }
- return true;
- }
- }
+ char uckey = Character.toUpperCase (key);
+ for (int i = 0; i < mnemonics.length; i++) {
+ if (uckey == mnemonics[i]) {
+ nextFocusItem = i;
+ return setFocus () && setFocusItem (i);
}
}
return false;
@@ -464,38 +285,31 @@ boolean mnemonicHit (char key) {
@Override
boolean mnemonicMatch (char key) {
- if (mnemonics != null) {
- char uckey = Character.toUpperCase (key);
- String parsedText = parse(text);
- for (int i = 0; i < mnemonics.length - 1; i++) {
- if (mnemonics[i] != -1) {
- char mnemonic = parsedText.charAt(mnemonics[i]);
- if (uckey == Character.toUpperCase (mnemonic)) {
- return true;
- }
- }
+ char uckey = Character.toUpperCase (key);
+ for (char mnemonic : mnemonics) {
+ if (uckey == mnemonic) {
+ return true;
}
}
return false;
}
-String parse (String string) {
+void parse (String string) {
int length = string.length ();
- offsets = new Point [length / 4];
- ids = new String [length / 4];
- mnemonics = new int [length / 4 + 1];
- StringBuffer result = new StringBuffer ();
- char [] buffer = new char [length];
- string.getChars (0, string.length (), buffer, 0);
+ // The shortest link length is 7 characters (<a></a>).
+ ids = new String [length / 7];
+ mnemonics = new char [length / 7];
int index = 0, state = 0, linkIndex = 0;
- int start = 0, tagStart = 0, linkStart = 0, endtagStart = 0, refStart = 0;
+ int linkStart = 0, linkEnd = 0, refStart = 0, refEnd = 0;
+ char mnemonic = 0;
while (index < length) {
- char c = Character.toLowerCase (buffer [index]);
+ char c = Character.toLowerCase (string.charAt (index));
switch (state) {
case 0:
if (c == '<') {
- tagStart = index;
state++;
+ } else if (c == '&') {
+ state = 16;
}
break;
case 1:
@@ -517,7 +331,7 @@ String parse (String string) {
break;
case 3:
if (c == '<') {
- endtagStart = index;
+ linkEnd = index;
state++;
}
break;
@@ -529,15 +343,16 @@ String parse (String string) {
break;
case 6:
if (c == '>') {
- mnemonics [linkIndex] = parseMnemonics (buffer, start, tagStart, result);
- int offset = result.length ();
- parseMnemonics (buffer, linkStart, endtagStart, result);
- offsets [linkIndex] = new Point (offset, result.length () - 1);
- if (ids [linkIndex] == null) {
- ids [linkIndex] = new String (buffer, linkStart, endtagStart - linkStart);
+ if (refStart == 0) {
+ refStart = linkStart;
+ refEnd = linkEnd;
+ }
+ ids [linkIndex] = string.substring(refStart, refEnd);
+ if (mnemonic != 0) {
+ mnemonics [linkIndex] = mnemonic;
}
linkIndex++;
- start = tagStart = linkStart = endtagStart = refStart = index + 1;
+ linkStart = linkEnd = refStart = refEnd = mnemonic = 0;
state = 0;
} else {
state = 3;
@@ -565,7 +380,7 @@ String parse (String string) {
break;
case 12:
if (c == '"') {
- ids[linkIndex] = new String (buffer, refStart, index - refStart);
+ refEnd = index;
state = 2;
}
break;
@@ -582,59 +397,27 @@ String parse (String string) {
case 15:
if (c == '"') state = 2;
break;
+ case 16:
+ if (c == '<') {
+ state = 1;
+ } else {
+ state = 0;
+ if (c != '&') mnemonic = Character.toUpperCase (c);
+ }
+ break;
default:
state = 0;
break;
}
index++;
}
- if (start < length) {
- int tmp = parseMnemonics (buffer, start, tagStart, result);
- int mnemonic = parseMnemonics (buffer, Math.max (tagStart, linkStart), length, result);
- if (mnemonic == -1) mnemonic = tmp;
- mnemonics [linkIndex] = mnemonic;
- } else {
- mnemonics [linkIndex] = -1;
- }
- if (offsets.length != linkIndex) {
- Point [] newOffsets = new Point [linkIndex];
- System.arraycopy (offsets, 0, newOffsets, 0, linkIndex);
- offsets = newOffsets;
- String [] newIDs = new String [linkIndex];
- System.arraycopy (ids, 0, newIDs, 0, linkIndex);
- ids = newIDs;
- int [] newMnemonics = new int [linkIndex + 1];
- System.arraycopy (mnemonics, 0, newMnemonics, 0, linkIndex + 1);
- mnemonics = newMnemonics;
- }
- return result.toString ();
-}
-
-int parseMnemonics (char[] buffer, int start, int end, StringBuffer result) {
- int mnemonic = -1, index = start;
- while (index < end) {
- if (buffer [index] == '&') {
- if (index + 1 < end && buffer [index + 1] == '&') {
- result.append (buffer [index]);
- index++;
- } else {
- mnemonic = result.length();
- }
- } else {
- result.append (buffer [index]);
- }
- index++;
- }
- return mnemonic;
+ ids = Arrays.copyOf(ids, linkIndex);
+ mnemonics = Arrays.copyOf(mnemonics, linkIndex);
}
@Override
void releaseWidget () {
super.releaseWidget ();
- if (layout != null) layout.dispose ();
- layout = null;
- disabledColor = null;
- offsets = null;
ids = null;
mnemonics = null;
text = null;
@@ -665,6 +448,40 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection, listener);
}
+boolean setFocusItem (int index) {
+ int bits = 0;
+ if (index > 0) {
+ bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ }
+ LITEM item = new LITEM ();
+ item.mask = OS.LIF_ITEMINDEX | OS.LIF_STATE;
+ item.stateMask = OS.LIS_FOCUSED;
+ int activeIndex = getFocusItem ();
+ if (activeIndex == index) return true;
+ if (activeIndex >= 0) {
+ /* Feature in Windows. Unfocus any element unfocus all elements.
+ * For example if item 2 is focused and we set unfocus (state = 0)
+ * for item 0 Windows will remove the focus state for item 2
+ * (getFocusItem() == -1) but fail to remove the focus border around
+ * the link. The fix is to only unfocus the element which has focus.
+ */
+ item.iLink = activeIndex;
+ OS.SendMessage (handle, OS.LM_SETITEM, 0, item);
+ }
+ item.iLink = index;
+ item.state = OS.LIS_FOCUSED;
+ long result = OS.SendMessage (handle, OS.LM_SETITEM, 0, item);
+
+ if (index > 0) {
+ /* Feature in Windows. For some reason, setting the focus to
+ * any item but first causes the control to clear the WS_TABSTOP
+ * bit. The fix is always to reset the bit.
+ */
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ }
+ return result != 0;
+}
+
/**
* Sets the link foreground color to the color specified
* by the argument, or to the default system color for the link
@@ -692,9 +509,6 @@ public void setLinkForeground (Color color) {
}
if (pixel == linkForeground) return;
linkForeground = pixel;
- if (OS.IsWindowEnabled (handle)) {
- styleLinkParts(true);
- }
OS.InvalidateRect (handle, null, true);
}
@@ -744,44 +558,9 @@ public void setText (String string) {
if ((state & HAS_AUTO_DIRECTION) != 0) {
updateTextDirection (AUTO_TEXT_DIRECTION);
}
-
- boolean enabled = OS.IsWindowEnabled (handle);
- String parsedText = parse (text);
- /*
- * Bug in Windows. For some reason, when SetWindowText()
- * is used to set the text of a link control to the empty
- * string, the old text remains. The fix is to set the
- * text to a space instead.
- */
- if (string.length () == 0) string = " "; //$NON-NLS-1$
TCHAR buffer = new TCHAR (getCodePage (), string, true);
OS.SetWindowText (handle, buffer);
-
- layout.setText (parsedText);
- focusIndex = offsets.length > 0 ? 0 : -1;
- selection.x = selection.y = -1;
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- if (offsets.length > 0) {
- bits |= OS.WS_TABSTOP;
- } else {
- bits &= ~OS.WS_TABSTOP;
- }
- OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
- styleLinkParts(enabled);
- TextStyle mnemonicStyle = new TextStyle (null, null, null);
- mnemonicStyle.underline = true;
- for (int i = 0; i < mnemonics.length; i++) {
- int mnemonic = mnemonics [i];
- if (mnemonic != -1) {
- layout.setStyle (mnemonicStyle, mnemonic, mnemonic);
- }
- }
-
- if (useCommonControl()) {
- enableWidget (enabled);
- } else {
- redraw ();
- }
+ parse(string);
}
@Override
@@ -789,15 +568,6 @@ int resolveTextDirection() {
return BidiUtil.resolveTextDirection(text);
}
-void styleLinkParts(boolean enabled) {
- TextStyle linkStyle = new TextStyle (null, enabled ? internalGetLinkForeground() : disabledColor, null);
- linkStyle.underline = true;
- for (int i = 0; i < offsets.length; i++) {
- Point point = offsets [i];
- layout.setStyle (linkStyle, point.x, point.y);
- }
-}
-
@Override
boolean updateTextDirection(int textDirection) {
if (super.updateTextDirection(textDirection)) {
@@ -812,14 +582,6 @@ boolean updateTextDirection(int textDirection) {
return false;
}
-boolean useCommonControl() {
- return useCommonControl(OS.IsWindowEnabled(handle));
-}
-
-boolean useCommonControl(boolean enabled) {
- return linkForeground == -1 && !enabled;
-}
-
@Override
int widgetStyle () {
int bits = super.widgetStyle ();
@@ -832,195 +594,72 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return LinkProc;
}
@Override
-LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CHAR (long wParam, long lParam) {
LRESULT result = super.WM_CHAR (wParam, lParam);
if (result != null) return result;
- if (!useCommonControl()) {
- if (focusIndex == -1) return result;
- switch ((int)/*64*/wParam) {
- case ' ':
- case SWT.CR:
- Event event = new Event ();
- event.text = ids [focusIndex];
- sendSelectionEvent (SWT.Selection, event, true);
- break;
- case SWT.TAB:
- boolean next = OS.GetKeyState (OS.VK_SHIFT) >= 0;
- if (next) {
- if (focusIndex < offsets.length - 1) {
- focusIndex++;
- redraw ();
- }
- } else {
- if (focusIndex > 0) {
- focusIndex--;
- redraw ();
- }
- }
- break;
- }
- } else {
- switch ((int)/*64*/wParam) {
- case ' ':
- case SWT.CR:
- case SWT.TAB:
- /*
- * NOTE: Call the window proc with WM_KEYDOWN rather than WM_CHAR
- * so that the key that was ignored during WM_KEYDOWN is processed.
- * This allows the application to cancel an operation that is normally
- * performed in WM_KEYDOWN from WM_CHAR.
- */
- long /*int*/ code = callWindowProc (handle, OS.WM_KEYDOWN, wParam, lParam);
- return new LRESULT (code);
- }
-
+ switch ((int)wParam) {
+ case SWT.SPACE:
+ case SWT.CR:
+ case SWT.TAB:
+ /*
+ * NOTE: Call the window proc with WM_KEYDOWN rather than WM_CHAR
+ * so that the key that was ignored during WM_KEYDOWN is processed.
+ * This allows the application to cancel an operation that is normally
+ * performed in WM_KEYDOWN from WM_CHAR.
+ */
+ long code = callWindowProc (handle, OS.WM_KEYDOWN, wParam, lParam);
+ return new LRESULT (code);
}
return result;
}
@Override
-LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
- LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
- if (result != null) return result;
- int index, count;
- long /*int*/ code = 0;
- if (useCommonControl()) {
- LITEM item = new LITEM ();
- item.mask = OS.LIF_ITEMINDEX | OS.LIF_STATE;
- item.stateMask = OS.LIS_FOCUSED;
- index = 0;
- while (OS.SendMessage (handle, OS.LM_GETITEM, 0, item) != 0) {
- if ((item.state & OS.LIS_FOCUSED) != 0) {
- index = item.iLink;
- }
- item.iLink++;
- }
- count = item.iLink;
- code = callWindowProc (handle, OS.WM_GETDLGCODE, wParam, lParam);
- } else {
- index = focusIndex;
- count = offsets.length;
- }
+LRESULT WM_GETDLGCODE (long wParam, long lParam) {
+ long code = callWindowProc (handle, OS.WM_GETDLGCODE, wParam, lParam);
+ int count = ids.length;
if (count == 0) {
- return new LRESULT (code | OS.DLGC_STATIC);
- }
- boolean next = OS.GetKeyState (OS.VK_SHIFT) >= 0;
- if (next && index < count - 1) {
- return new LRESULT (code | OS.DLGC_WANTTAB);
- }
- if (!next && index > 0) {
- return new LRESULT (code | OS.DLGC_WANTTAB);
+ code |= OS.DLGC_STATIC;
+ } else if (count > 1) {
+ int limit = (OS.GetKeyState (OS.VK_SHIFT) < 0) ? 0 : count - 1;
+ if (getFocusItem() != limit) {
+ code |= OS.DLGC_WANTTAB;
+ }
}
- return result;
+ return new LRESULT (code);
}
@Override
-LRESULT WM_GETFONT (long /*int*/ wParam, long /*int*/ lParam) {
- LRESULT result = super.WM_GETFONT (wParam, lParam);
- if (result != null) return result;
- long /*int*/ code = callWindowProc (handle, OS.WM_GETFONT, wParam, lParam);
- if (code != 0) return new LRESULT (code);
- if (font == 0) font = defaultFont ();
- return new LRESULT (font);
-}
-
-@Override
-LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KEYDOWN (long wParam, long lParam) {
LRESULT result = super.WM_KEYDOWN (wParam, lParam);
if (result != null) return result;
- if (useCommonControl()) {
- switch ((int)/*64*/wParam) {
- case OS.VK_SPACE:
- case OS.VK_RETURN:
- case OS.VK_TAB:
- /*
- * Ensure that the window proc does not process VK_SPACE,
- * VK_RETURN or VK_TAB so that it can be handled in WM_CHAR.
- * This allows the application to cancel an operation that
- * is normally performed in WM_KEYDOWN from WM_CHAR.
- */
- return LRESULT.ZERO;
- }
- }
- return result;
-}
-
-@Override
-LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
- LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
- if (!useCommonControl()) redraw ();
- return result;
-}
-
-@Override
-LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
- LRESULT result = super.WM_LBUTTONDOWN (wParam, lParam);
- if (result == LRESULT.ZERO) return result;
- if (!useCommonControl()) {
- if (focusIndex != -1) setFocus ();
- int x = OS.GET_X_LPARAM (lParam);
- int y = OS.GET_Y_LPARAM (lParam);
- int offset = layout.getOffset (DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(y), null);
- int oldSelectionX = selection.x;
- int oldSelectionY = selection.y;
- selection.x = offset;
- selection.y = -1;
- if (oldSelectionX != -1 && oldSelectionY != -1) {
- if (oldSelectionX > oldSelectionY) {
- int temp = oldSelectionX;
- oldSelectionX = oldSelectionY;
- oldSelectionY = temp;
- }
- Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds (oldSelectionX, oldSelectionY)); // To Pixels
- redrawInPixels (rect.x, rect.y, rect.width, rect.height, false);
- }
- for (int j = 0; j < offsets.length; j++) {
- Rectangle [] rects = getRectanglesInPixels (j);
- for (int i = 0; i < rects.length; i++) {
- Rectangle rect = rects [i];
- if (rect.contains (x, y)) {
- if (j != focusIndex) {
- redraw ();
- }
- focusIndex = mouseDownIndex = j;
- return result;
- }
- }
- }
+ switch ((int)wParam) {
+ case OS.VK_SPACE:
+ case OS.VK_RETURN:
+ case OS.VK_TAB:
+ /*
+ * Ensure that the window proc does not process VK_SPACE,
+ * VK_RETURN or VK_TAB so that it can be handled in WM_CHAR.
+ * This allows the application to cancel an operation that
+ * is normally performed in WM_KEYDOWN from WM_CHAR.
+ */
+ return LRESULT.ZERO;
}
return result;
}
@Override
-LRESULT WM_LBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
- LRESULT result = super.WM_LBUTTONUP (wParam, lParam);
- if (result == LRESULT.ZERO) return result;
- if (!useCommonControl()) {
- if (mouseDownIndex == -1) return result;
- int x = OS.GET_X_LPARAM (lParam);
- int y = OS.GET_Y_LPARAM (lParam);
- Rectangle [] rects = getRectanglesInPixels (mouseDownIndex);
- for (int i = 0; i < rects.length; i++) {
- Rectangle rect = rects [i];
- if (rect.contains (x, y)) {
- Event event = new Event ();
- event.text = ids [mouseDownIndex];
- sendSelectionEvent (SWT.Selection, event, true);
- break;
- }
- }
- }
- mouseDownIndex = -1;
- return result;
+LRESULT WM_KILLFOCUS (long wParam, long lParam) {
+ nextFocusItem = getFocusItem();
+ return super.WM_KILLFOCUS(wParam, lParam);
}
@Override
-LRESULT WM_NCHITTEST (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NCHITTEST (long wParam, long lParam) {
LRESULT result = super.WM_NCHITTEST (wParam, lParam);
if (result != null) return result;
@@ -1033,153 +672,69 @@ LRESULT WM_NCHITTEST (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
- LRESULT result = super.WM_MOUSEMOVE (wParam, lParam);
- if (!useCommonControl()) {
- int x = OS.GET_X_LPARAM (lParam);
- int y = OS.GET_Y_LPARAM (lParam);
- if (OS.GetKeyState (OS.VK_LBUTTON) < 0) {
- int oldSelection = selection.y;
- selection.y = layout.getOffset (DPIUtil.autoScaleDown(x), DPIUtil.autoScaleDown(y), null);
- if (selection.y != oldSelection) {
- int newSelection = selection.y;
- if (oldSelection > newSelection) {
- int temp = oldSelection;
- oldSelection = newSelection;
- newSelection = temp;
- }
- Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds (oldSelection, newSelection));// To Pixels
- redrawInPixels (rect.x, rect.y, rect.width, rect.height, false);
- }
- } else {
- for (int j = 0; j < offsets.length; j++) {
- Rectangle [] rects = getRectanglesInPixels (j);
- for (int i = 0; i < rects.length; i++) {
- Rectangle rect = rects [i];
- if (rect.contains (x, y)) {
- setCursor (display.getSystemCursor (SWT.CURSOR_HAND));
- return result;
- }
- }
- }
- setCursor (null);
- }
- }
- return result;
-}
-
-@Override
-LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
- if ((state & DISPOSE_SENT) != 0) return LRESULT.ZERO;
- if (useCommonControl()) {
- return super.WM_PAINT (wParam, lParam);
- }
-
- PAINTSTRUCT ps = new PAINTSTRUCT ();
- GCData data = new GCData ();
- data.ps = ps;
- data.hwnd = handle;
- GC gc = new_GC (data);
- if (gc != null) {
- int width = ps.right - ps.left;
- int height = ps.bottom - ps.top;
- if (width != 0 && height != 0) {
- RECT rect = new RECT ();
- OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom);
- drawWidget (gc, rect);
- }
- gc.dispose ();
- }
- return LRESULT.ZERO;
-}
-
-@Override
-LRESULT WM_PRINTCLIENT (long /*int*/ wParam, long /*int*/ lParam) {
- LRESULT result = super.WM_PRINTCLIENT (wParam, lParam);
- if (!useCommonControl()) {
- RECT rect = new RECT ();
- OS.GetClientRect (handle, rect);
- GCData data = new GCData ();
- data.device = display;
- data.foreground = getForegroundPixel ();
- GC gc = GC.win32_new (wParam, data);
- drawWidget (gc, rect);
- gc.dispose ();
- }
- return result;
-}
-
-@Override
-LRESULT WM_SETCURSOR(long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETCURSOR(long wParam, long lParam) {
LRESULT result = super.WM_SETCURSOR (wParam, lParam);
if (result != null) return result;
- long /*int*/ fDone = callWindowProc (handle, OS.WM_SETCURSOR, wParam, lParam);
+ long fDone = callWindowProc (handle, OS.WM_SETCURSOR, wParam, lParam);
/* Take responsibility for cursor over plain text after overriding WM_NCHITTEST. */
if (fDone == 0) OS.DefWindowProc (handle, OS.WM_SETCURSOR, wParam, lParam);
return LRESULT.ONE;
}
@Override
-LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
- LRESULT result = super.WM_SETFOCUS (wParam, lParam);
- if (!useCommonControl()) redraw ();
- return result;
-}
-
-@Override
-LRESULT WM_SETFONT (long /*int*/ wParam, long /*int*/ lParam) {
- layout.setFont (Font.win32_new (display, wParam));
- if (lParam != 0) OS.InvalidateRect (handle, null, true);
- return super.WM_SETFONT (font = wParam, lParam);
-}
-
-@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
- LRESULT result = super.WM_SIZE (wParam, lParam);
- RECT rect = new RECT ();
- OS.GetClientRect (handle, rect);
- layout.setWidth (DPIUtil.autoScaleDown(rect.right > 0 ? rect.right : -1));
- if (!useCommonControl()) {
- redraw ();
- }
- return result;
-}
-
-@Override
-LRESULT wmColorChild (long /*int*/ wParam, long /*int*/ lParam) {
- LRESULT result = super.wmColorChild (wParam, lParam);
+LRESULT WM_SETFOCUS (long wParam, long lParam) {
/*
- * Feature in Windows. When a SysLink is disabled, it does
- * not gray out the non-link portion of the text. The fix
- * is to set the text color to the system gray color.
+ * Feature in Windows. Upon receiving focus, SysLink control
+ * always activates the first link. This leads to surprising
+ * behavior in multi-link controls.
*/
- if (useCommonControl()) {
- if (!OS.IsWindowEnabled (handle)) {
- OS.SetTextColor (wParam, OS.GetSysColor (OS.COLOR_GRAYTEXT));
- if (result == null) {
- int backPixel = getBackgroundPixel ();
- OS.SetBkColor (wParam, backPixel);
- long /*int*/ hBrush = findBrush (backPixel, OS.BS_SOLID);
- return new LRESULT (hBrush);
+ if (ids.length > 1) {
+ if (OS.GetKeyState (OS.VK_TAB) < 0) {
+ if (OS.GetKeyState (OS.VK_SHIFT) < 0) {
+ // reverse tab; focus on last item
+ setFocusItem(ids.length - 1);
}
+ } else if (nextFocusItem > 0) {
+ setFocusItem(nextFocusItem);
}
}
- return result;
+ return super.WM_SETFOCUS (wParam, lParam);
}
@Override
-LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
- if (useCommonControl()) {
- switch (hdr.code) {
- case OS.NM_RETURN:
- case OS.NM_CLICK:
- NMLINK item = new NMLINK ();
- OS.MoveMemory (item, lParam, NMLINK.sizeof);
- Event event = new Event ();
- event.text = ids [item.iLink];
- sendSelectionEvent (SWT.Selection, event, true);
- break;
- }
+LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) {
+ switch (hdr.code) {
+ case OS.NM_RETURN:
+ case OS.NM_CLICK:
+ NMLINK item = new NMLINK ();
+ OS.MoveMemory (item, lParam, NMLINK.sizeof);
+ Event event = new Event ();
+ event.text = ids [item.iLink];
+ sendSelectionEvent (SWT.Selection, event, true);
+ break;
+ case OS.NM_CUSTOMDRAW:
+ NMCUSTOMDRAW nmcd = new NMCUSTOMDRAW ();
+ OS.MoveMemory (nmcd, lParam, NMCUSTOMDRAW.sizeof);
+ switch (nmcd.dwDrawStage) {
+ case OS.CDDS_PREPAINT:
+ if (!OS.IsWindowEnabled (handle) || linkForeground != -1) {
+ return new LRESULT(OS.CDRF_NOTIFYITEMDRAW);
+ }
+ break;
+ case OS.CDDS_ITEMPREPAINT:
+ /*
+ * Feature in Windows. SysLink32 control doesn't natively
+ * provide disabled state. Emulate it with custom draw.
+ */
+ if (!OS.IsWindowEnabled (handle)) {
+ OS.SetTextColor (nmcd.hdc, OS.GetSysColor (OS.COLOR_GRAYTEXT));
+ }
+ else if (linkForeground != -1 && nmcd.dwItemSpec != -1) {
+ OS.SetTextColor(nmcd.hdc, linkForeground);
+ }
+ break;
+ }
+ break;
}
return super.wmNotifyChild (hdr, wParam, lParam);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
index 0aa83f7cb3..5de5feaeb3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
@@ -43,7 +43,7 @@ import org.eclipse.swt.internal.win32.*;
*/
public class List extends Scrollable {
static final int INSET = 3;
- static final long /*int*/ ListProc;
+ static final long ListProc;
static final TCHAR ListClass = new TCHAR (0, "LISTBOX", true);
boolean addedUCC = false; // indicates whether Bidi UCC were added; 'state & HAS_AUTO_DIRECTION' isn't a sufficient indicator
static {
@@ -106,7 +106,7 @@ public void add (String string) {
checkWidget ();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
TCHAR buffer = new TCHAR (getCodePage (), string, true);
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer);
+ int result = (int)OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer);
if (result == OS.LB_ERR) error (SWT.ERROR_ITEM_NOT_ADDED);
if (result == OS.LB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);
if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer.chars, true);
@@ -142,10 +142,10 @@ public void add (String string, int index) {
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if (index == -1) error (SWT.ERROR_INVALID_RANGE);
TCHAR buffer = new TCHAR (getCodePage (), string, true);
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_INSERTSTRING, index, buffer);
+ int result = (int)OS.SendMessage (handle, OS.LB_INSERTSTRING, index, buffer);
if (result == OS.LB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);
if (result == OS.LB_ERR) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (0 <= index && index <= count) {
error (SWT.ERROR_ITEM_NOT_ADDED);
} else {
@@ -188,7 +188,7 @@ public void addSelectionListener(SelectionListener listener) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
boolean redraw = false;
switch (msg) {
@@ -199,7 +199,7 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
break;
}
}
- long /*int*/ code = OS.CallWindowProc (ListProc, hwnd, msg, wParam, lParam);
+ long code = OS.CallWindowProc (ListProc, hwnd, msg, wParam, lParam);
switch (msg) {
case OS.WM_HSCROLL:
case OS.WM_VSCROLL: {
@@ -222,24 +222,24 @@ static int checkStyle (int style) {
int width = 0, height = 0;
if (wHint == SWT.DEFAULT) {
if ((style & SWT.H_SCROLL) != 0) {
- width = (int)/*64*/OS.SendMessage (handle, OS.LB_GETHORIZONTALEXTENT, 0, 0);
+ width = (int)OS.SendMessage (handle, OS.LB_GETHORIZONTALEXTENT, 0, 0);
width -= INSET;
} else {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
- long /*int*/ newFont, oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ long newFont, oldFont = 0;
+ long hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
RECT rect = new RECT ();
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
char [] buffer = new char [64 + 1];
for (int i=0; i<count; i++) {
- int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, i, 0);
+ int length = (int)OS.SendMessage (handle, OS.LB_GETTEXTLEN, i, 0);
if (length != OS.LB_ERR) {
if (length + 1 > buffer.length) {
buffer = new char [length + 1];
}
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXT, i, buffer);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETTEXT, i, buffer);
if (result != OS.LB_ERR) {
OS.DrawText (hDC, buffer, length, rect, flags);
width = Math.max (width, rect.right - rect.left);
@@ -251,9 +251,9 @@ static int checkStyle (int style) {
}
}
if (hHint == SWT.DEFAULT) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
- int itemHeight = (int)/*64*/OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
- height = count * itemHeight;
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int itemHeight = (int)OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
+ height = count * itemHeight;
}
if (width == 0) width = DEFAULT_WIDTH;
if (height == 0) height = DEFAULT_HEIGHT;
@@ -298,18 +298,17 @@ public void deselect (int [] indices) {
if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
if (indices.length == 0) return;
if ((style & SWT.SINGLE) != 0) {
- int oldIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ int oldIndex = (int)OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
if (oldIndex == OS.LB_ERR) return;
- for (int i=0; i<indices.length; i++) {
- if (oldIndex == indices [i]) {
+ for (int index : indices) {
+ if (oldIndex == index) {
OS.SendMessage (handle, OS.LB_SETCURSEL, -1, 0);
return;
}
}
return;
}
- for (int i=0; i<indices.length; i++) {
- int index = indices [i];
+ for (int index : indices) {
if (index != -1) {
OS.SendMessage (handle, OS.LB_SETSEL, 0, index);
}
@@ -332,7 +331,7 @@ public void deselect (int index) {
checkWidget ();
if (index == -1) return;
if ((style & SWT.SINGLE) != 0) {
- int oldIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ int oldIndex = (int)OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
if (oldIndex == OS.LB_ERR) return;
if (oldIndex == index) OS.SendMessage (handle, OS.LB_SETCURSEL, -1, 0);
return;
@@ -359,7 +358,7 @@ public void deselect (int start, int end) {
checkWidget ();
if (start > end) return;
if ((style & SWT.SINGLE) != 0) {
- int oldIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ int oldIndex = (int)OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
if (oldIndex == OS.LB_ERR) return;
if (start <= oldIndex && oldIndex <= end) {
OS.SendMessage (handle, OS.LB_SETCURSEL, -1, 0);
@@ -372,7 +371,7 @@ public void deselect (int start, int end) {
* start = end, LB_SELITEMRANGEEX deselects the
* item.
*/
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (start < 0 && end < 0) return;
if (start >= count && end >= count) return;
start = Math.min (count - 1, Math.max (0, start));
@@ -410,9 +409,9 @@ public void deselectAll () {
*/
public int getFocusIndex () {
checkWidget ();
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
if (result == 0) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (count == 0) return -1;
}
return result;
@@ -435,13 +434,13 @@ public int getFocusIndex () {
*/
public String getItem (int index) {
checkWidget ();
- int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
+ int length = (int)OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
if (length != OS.LB_ERR) {
char [] buffer = new char [length + 1];
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer);
if (result != OS.LB_ERR) return ((state & HAS_AUTO_DIRECTION) != 0) ? new String (buffer, 1, length - 1) : new String (buffer, 0, length);
}
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (0 <= index && index < count) error (SWT.ERROR_CANNOT_GET_ITEM);
error (SWT.ERROR_INVALID_RANGE);
return "";
@@ -459,7 +458,7 @@ public String getItem (int index) {
*/
public int getItemCount () {
checkWidget ();
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (result == OS.LB_ERR) error (SWT.ERROR_CANNOT_GET_COUNT);
return result;
}
@@ -481,7 +480,7 @@ public int getItemHeight () {
}
int getItemHeightInPixels () {
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
if (result == OS.LB_ERR) error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT);
return result;
}
@@ -549,11 +548,11 @@ public String [] getSelection () {
public int getSelectionCount () {
checkWidget ();
if ((style & SWT.SINGLE) != 0) {
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
if (result == OS.LB_ERR) return 0;
return 1;
}
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETSELCOUNT, 0, 0);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETSELCOUNT, 0, 0);
if (result == OS.LB_ERR) error (SWT.ERROR_CANNOT_GET_COUNT);
return result;
}
@@ -572,17 +571,17 @@ public int getSelectionCount () {
public int getSelectionIndex () {
checkWidget ();
if ((style & SWT.SINGLE) != 0) {
- return (int)/*64*/OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ return (int)OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
}
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETSELCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETSELCOUNT, 0, 0);
if (count == OS.LB_ERR) error (SWT.ERROR_CANNOT_GET_SELECTION);
if (count == 0) return -1;
- int index = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETSEL, index, 0);
+ int index = (int)OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETSEL, index, 0);
if (result == OS.LB_ERR) error (SWT.ERROR_CANNOT_GET_SELECTION);
if (result != 0) return index;
int [] buffer = new int[1];
- result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETSELITEMS, 1, buffer);
+ result = (int)OS.SendMessage (handle, OS.LB_GETSELITEMS, 1, buffer);
if (result != 1) error (SWT.ERROR_CANNOT_GET_SELECTION);
return buffer [0];
}
@@ -606,14 +605,14 @@ public int getSelectionIndex () {
public int [] getSelectionIndices () {
checkWidget ();
if ((style & SWT.SINGLE) != 0) {
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
if (result == OS.LB_ERR) return new int [0];
return new int [] {result};
}
- int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETSELCOUNT, 0, 0);
+ int length = (int)OS.SendMessage (handle, OS.LB_GETSELCOUNT, 0, 0);
if (length == OS.LB_ERR) error (SWT.ERROR_CANNOT_GET_SELECTION);
int [] indices = new int [length];
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETSELITEMS, length, indices);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETSELITEMS, length, indices);
if (result != length) error (SWT.ERROR_CANNOT_GET_SELECTION);
return indices;
}
@@ -632,7 +631,7 @@ public int [] getSelectionIndices () {
*/
public int getTopIndex () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ return (int)OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
}
/**
@@ -696,12 +695,12 @@ public int indexOf (String string, int start) {
}
/* Use LB_FINDSTRINGEXACT to search for the item */
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (!(0 <= start && start < count)) return -1;
int index = start - 1, last;
TCHAR buffer = new TCHAR (getCodePage (), string, true);
do {
- index = (int)/*64*/OS.SendMessage (handle, OS.LB_FINDSTRINGEXACT, last = index, buffer);
+ index = (int)OS.SendMessage (handle, OS.LB_FINDSTRINGEXACT, last = index, buffer);
if (index == OS.LB_ERR || index <= last) return -1;
} while (!string.equals (getItem (index)));
return index;
@@ -722,10 +721,15 @@ public int indexOf (String string, int start) {
*/
public boolean isSelected (int index) {
checkWidget ();
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETSEL, index, 0);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETSEL, index, 0);
return (result != 0) && (result != OS.LB_ERR);
}
+@Override
+boolean isUseWsBorder () {
+ return super.isUseWsBorder () || ((display != null) && display.useWsBorderList);
+}
+
/**
* Removes the items from the receiver at the given
* zero-relative indices.
@@ -749,13 +753,13 @@ public void remove (int [] indices) {
System.arraycopy (indices, 0, newIndices, 0, indices.length);
sort (newIndices);
int start = newIndices [newIndices.length - 1], end = newIndices [0];
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (!(0 <= start && start <= end && end < count)) {
error (SWT.ERROR_INVALID_RANGE);
}
- int topIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ int topIndex = (int)OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
RECT rect = null;
- long /*int*/ hDC = 0, oldFont = 0, newFont = 0;
+ long hDC = 0, oldFont = 0, newFont = 0;
int newWidth = 0;
if ((style & SWT.H_SCROLL) != 0) {
rect = new RECT ();
@@ -770,13 +774,13 @@ public void remove (int [] indices) {
char [] buffer = null;
int length = 0;
if ((style & SWT.H_SCROLL) != 0) {
- length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
+ length = (int)OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
if (length == OS.LB_ERR) break;
buffer = new char [length + 1];
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer);
if (result == OS.LB_ERR) break;
}
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_DELETESTRING, index, 0);
+ int result = (int)OS.SendMessage (handle, OS.LB_DELETESTRING, index, 0);
if (result == OS.LB_ERR) break;
if ((style & SWT.H_SCROLL) != 0) {
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
@@ -818,24 +822,24 @@ public void remove (int index) {
checkWidget ();
char [] buffer = null;
if ((style & SWT.H_SCROLL) != 0) {
- int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
+ int length = (int)OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
if (length == OS.LB_ERR) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
error (SWT.ERROR_INVALID_RANGE);
}
buffer = new char [length + 1];
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer);
if (result == OS.LB_ERR) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
error (SWT.ERROR_INVALID_RANGE);
}
}
- int topIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_DELETESTRING, index, 0);
+ int topIndex = (int)OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ int result = (int)OS.SendMessage (handle, OS.LB_DELETESTRING, index, 0);
if (result == OS.LB_ERR) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
error (SWT.ERROR_INVALID_RANGE);
}
@@ -865,7 +869,7 @@ public void remove (int index) {
public void remove (int start, int end) {
checkWidget ();
if (start > end) return;
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (!(0 <= start && start <= end && end < count)) {
error (SWT.ERROR_INVALID_RANGE);
}
@@ -873,9 +877,9 @@ public void remove (int start, int end) {
removeAll ();
return;
}
- int topIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ int topIndex = (int)OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
RECT rect = null;
- long /*int*/ hDC = 0, oldFont = 0, newFont = 0;
+ long hDC = 0, oldFont = 0, newFont = 0;
int newWidth = 0;
if ((style & SWT.H_SCROLL) != 0) {
rect = new RECT ();
@@ -889,13 +893,13 @@ public void remove (int start, int end) {
char [] buffer = null;
int length = 0;
if ((style & SWT.H_SCROLL) != 0) {
- length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, start, 0);
+ length = (int)OS.SendMessage (handle, OS.LB_GETTEXTLEN, start, 0);
if (length == OS.LB_ERR) break;
buffer = new char [length + 1];
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXT, start, buffer);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETTEXT, start, buffer);
if (result == OS.LB_ERR) break;
}
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_DELETESTRING, start, 0);
+ int result = (int)OS.SendMessage (handle, OS.LB_DELETESTRING, start, 0);
if (result == OS.LB_ERR) break;
if ((style & SWT.H_SCROLL) != 0) {
OS.DrawText (hDC, buffer, length, rect, flags);
@@ -941,7 +945,7 @@ public void remove (String string) {
/**
* Removes all of the items from the receiver.
- *
+ *
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
@@ -1041,7 +1045,7 @@ public void select (int index) {
void select (int index, boolean scroll) {
if (index < 0) return;
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (index >= count) return;
if (scroll) {
if ((style & SWT.SINGLE) != 0) {
@@ -1051,7 +1055,7 @@ void select (int index, boolean scroll) {
}
return;
}
- int topIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ int topIndex = (int)OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
RECT itemRect = new RECT (), selectedRect = null;
OS.SendMessage (handle, OS.LB_GETITEMRECT, index, itemRect);
boolean redraw = getDrawing () && OS.IsWindowVisible (handle);
@@ -1061,14 +1065,14 @@ void select (int index, boolean scroll) {
}
int focusIndex = -1;
if ((style & SWT.SINGLE) != 0) {
- int oldIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ int oldIndex = (int)OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
if (oldIndex != -1) {
selectedRect = new RECT ();
OS.SendMessage (handle, OS.LB_GETITEMRECT, oldIndex, selectedRect);
}
OS.SendMessage (handle, OS.LB_SETCURSEL, index, 0);
} else {
- focusIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
+ focusIndex = (int)OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
OS.SendMessage (handle, OS.LB_SETSEL, 1, index);
}
if ((style & SWT.MULTI) != 0) {
@@ -1112,7 +1116,7 @@ void select (int index, boolean scroll) {
public void select (int start, int end) {
checkWidget ();
if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && start != end)) return;
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (count == 0 || start >= count) return;
start = Math.max (0, start);
end = Math.min (end, count - 1);
@@ -1154,7 +1158,7 @@ public void selectAll () {
void setFocusIndex (int index) {
// checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (!(0 <= index && index < count)) return;
OS.SendMessage (handle, OS.LB_SETCARETINDEX, index, 0);
}
@@ -1210,17 +1214,17 @@ public void setItem (int index, String string) {
public void setItems (String... items) {
checkWidget ();
if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<items.length; i++) {
- if (items [i] == null) error (SWT.ERROR_INVALID_ARGUMENT);
+ for (String item : items) {
+ if (item == null) error (SWT.ERROR_INVALID_ARGUMENT);
}
- long /*int*/ oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
+ long oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, ListProc);
boolean redraw = getDrawing () && OS.IsWindowVisible (handle);
if (redraw) {
OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
}
RECT rect = null;
- long /*int*/ hDC = 0, oldFont = 0, newFont = 0;
+ long hDC = 0, oldFont = 0, newFont = 0;
int newWidth = 0;
if ((style & SWT.H_SCROLL) != 0) {
rect = new RECT ();
@@ -1237,7 +1241,7 @@ public void setItems (String... items) {
while (index < length) {
String string = items [index];
TCHAR buffer = new TCHAR (cp, string, true);
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer);
+ int result = (int)OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer);
if (result == OS.LB_ERR || result == OS.LB_ERRSPACE) break;
if ((style & SWT.H_SCROLL) != 0) {
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
@@ -1271,17 +1275,17 @@ public void setItems (String... items) {
void setScrollWidth () {
int newWidth = 0;
RECT rect = new RECT ();
- long /*int*/ newFont, oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
+ long newFont, oldFont = 0;
+ long hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
for (int i=0; i<count; i++) {
- int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, i, 0);
+ int length = (int)OS.SendMessage (handle, OS.LB_GETTEXTLEN, i, 0);
if (length != OS.LB_ERR) {
char [] buffer = new char [length + 1];
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXT, i, buffer);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETTEXT, i, buffer);
if (result != OS.LB_ERR) {
OS.DrawText (hDC, buffer, length, rect, flags);
newWidth = Math.max (newWidth, rect.right - rect.left);
@@ -1295,8 +1299,8 @@ void setScrollWidth () {
void setScrollWidth (char[] buffer, boolean grow) {
RECT rect = new RECT ();
- long /*int*/ newFont, oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
+ long newFont, oldFont = 0;
+ long hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
@@ -1308,7 +1312,7 @@ void setScrollWidth (char[] buffer, boolean grow) {
void setScrollWidth (int newWidth, boolean grow) {
newWidth += INSET;
- int width = (int)/*64*/OS.SendMessage (handle, OS.LB_GETHORIZONTALEXTENT, 0, 0);
+ int width = (int)OS.SendMessage (handle, OS.LB_GETHORIZONTALEXTENT, 0, 0);
if (grow) {
if (newWidth <= width) return;
OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, newWidth, 0);
@@ -1456,7 +1460,7 @@ public void setSelection (int start, int end) {
checkWidget ();
deselectAll ();
if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && start != end)) return;
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (count == 0 || start >= count) return;
start = Math.max (0, start);
end = Math.min (end, count - 1);
@@ -1482,9 +1486,9 @@ public void setSelection (int start, int end) {
*/
public void setTopIndex (int index) {
checkWidget ();
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_SETTOPINDEX, index, 0);
+ int result = (int)OS.SendMessage (handle, OS.LB_SETTOPINDEX, index, 0);
if (result == OS.LB_ERR) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
index = Math.min (count - 1, Math.max (0, index));
OS.SendMessage (handle, OS.LB_SETTOPINDEX, index, 0);
}
@@ -1504,21 +1508,21 @@ public void showSelection () {
checkWidget ();
int index;
if ((style & SWT.SINGLE) != 0) {
- index = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ index = (int)OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
} else {
int [] indices = new int [1];
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETSELITEMS, 1, indices);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETSELITEMS, 1, indices);
index = indices [0];
if (result != 1) index = -1;
}
if (index == -1) return;
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (count == 0) return;
- int height = (int)/*64*/OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
+ int height = (int)OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
forceResize ();
RECT rect = new RECT ();
OS.GetClientRect (handle, rect);
- int topIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ int topIndex = (int)OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
int visibleCount = Math.max (rect.bottom / height, 1);
int bottomIndex = Math.min (topIndex + visibleCount, count) - 1;
if (topIndex <= index && index <= bottomIndex) return;
@@ -1533,18 +1537,18 @@ void updateMenuLocation (Event event) {
int focusIndex = getFocusIndex();
if (focusIndex != -1) {
RECT rect = new RECT ();
- long /*int*/ newFont, oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
+ long newFont, oldFont = 0;
+ long hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
char [] buffer = new char [64 + 1];
- int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, focusIndex, 0);
+ int length = (int)OS.SendMessage (handle, OS.LB_GETTEXTLEN, focusIndex, 0);
if (length != OS.LB_ERR) {
if (length + 1 > buffer.length) {
buffer = new char [length + 1];
}
- int result = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXT, focusIndex, buffer);
+ int result = (int)OS.SendMessage (handle, OS.LB_GETTEXT, focusIndex, buffer);
if (result != OS.LB_ERR) {
OS.DrawText (hDC, buffer, length, rect, flags);
}
@@ -1574,12 +1578,12 @@ boolean updateTextDirection (int textDirection) {
return super.updateTextDirection (textDirection);
}
}
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (count == OS.LB_ERR) return false;
- int selection = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ int selection = (int)OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
addedUCC = false;
while (count-- > 0) {
- int length = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTEXTLEN, count, 0);
+ int length = (int)OS.SendMessage (handle, OS.LB_GETTEXTLEN, count, 0);
if (length == OS.LB_ERR) break;
if (length == 0) continue;
char [] buffer = new char [length + 1];
@@ -1615,12 +1619,12 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return ListProc;
}
@Override
-long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long windowProc (long hwnd, int msg, long wParam, long lParam) {
/* Below code is to support auto text direction. */
if (handle != 0 && lParam != 0 && (state & HAS_AUTO_DIRECTION) != 0) {
switch (msg) {
@@ -1643,11 +1647,11 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
}
string = (direction == SWT.RIGHT_TO_LEFT ? RLE : LRE) + string;
buffer = new TCHAR (cp, string, true);
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
length = buffer.length() * TCHAR.sizeof;
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, length);
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, length);
OS.MoveMemory (pszText, buffer, length);
- long /*int*/ code = super.windowProc (hwnd, msg, wParam, pszText);
+ long code = super.windowProc (hwnd, msg, wParam, pszText);
OS.HeapFree (hHeap, 0, pszText);
addedUCC = true;
return code;
@@ -1657,7 +1661,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
}
@Override
-LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CHAR (long wParam, long lParam) {
LRESULT result = super.WM_CHAR (wParam, lParam);
if (result != null) return result;
/*
@@ -1669,10 +1673,10 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
if (OS.GetKeyState (OS.VK_CONTROL) < 0 && OS.GetKeyState (OS.VK_SHIFT) >= 0) {
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
if ((bits & OS.LBS_EXTENDEDSEL) != 0) {
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_SPACE: {
- int index = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
- int code = (int)/*64*/OS.SendMessage (handle, OS.LB_GETSEL, index, 0);
+ int index = (int)OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
+ int code = (int)OS.SendMessage (handle, OS.LB_GETSEL, index, 0);
if (code == OS.LB_ERR) break;
OS.SendMessage (handle, OS.LB_SETSEL, code != 0 ? 0 : 1, index);
OS.SendMessage (handle, OS.LB_SETANCHORINDEX, index, 0);
@@ -1686,7 +1690,7 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KEYDOWN (long wParam, long lParam) {
LRESULT result = super.WM_KEYDOWN (wParam, lParam);
if (result != null) return result;
/*
@@ -1699,7 +1703,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
if ((bits & OS.LBS_EXTENDEDSEL) != 0) {
int newIndex = -1;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_SPACE: {
/*
* Ensure that the window proc does not process VK_SPACE
@@ -1711,32 +1715,32 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
case OS.VK_UP:
case OS.VK_DOWN: {
- int oldIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
- newIndex = Math.max (0, oldIndex + (((int)/*64*/wParam) == OS.VK_UP ? -1 : 1));
+ int oldIndex = (int)OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
+ newIndex = Math.max (0, oldIndex + (((int)wParam) == OS.VK_UP ? -1 : 1));
break;
}
case OS.VK_PRIOR: {
- int topIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
- int oldIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
+ int topIndex = (int)OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ int oldIndex = (int)OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
if (oldIndex != topIndex) {
newIndex = topIndex;
} else {
forceResize ();
RECT rect = new RECT ();
OS.GetClientRect (handle, rect);
- int itemHeight = (int)/*64*/OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
+ int itemHeight = (int)OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
int pageSize = Math.max (2, (rect.bottom / itemHeight));
newIndex = Math.max (0, topIndex - (pageSize - 1));
}
break;
}
case OS.VK_NEXT: {
- int topIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
- int oldIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
+ int topIndex = (int)OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ int oldIndex = (int)OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
forceResize ();
RECT rect = new RECT ();
OS.GetClientRect (handle, rect);
- int itemHeight = (int)/*64*/OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
+ int itemHeight = (int)OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
int pageSize = Math.max (2, (rect.bottom / itemHeight));
int bottomIndex = topIndex + pageSize - 1;
if (oldIndex != bottomIndex) {
@@ -1744,7 +1748,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
} else {
newIndex = bottomIndex + pageSize - 1;
}
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (count != OS.LB_ERR) newIndex = Math.min (count - 1, newIndex);
break;
}
@@ -1753,7 +1757,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
break;
}
case OS.VK_END: {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
if (count == OS.LB_ERR) break;
newIndex = count - 1;
break;
@@ -1767,7 +1771,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
* the focus indicator changes as a result of something
* the user types.
*/
- int uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ int uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
if ((uiState & OS.UISF_HIDEFOCUS) != 0) {
OS.SendMessage (handle, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0);
/*
@@ -1778,7 +1782,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
* control.
*/
RECT itemRect = new RECT ();
- int oldIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
+ int oldIndex = (int)OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
OS.SendMessage (handle, OS.LB_GETITEMRECT, oldIndex, itemRect);
OS.InvalidateRect (handle, itemRect, true);
}
@@ -1791,7 +1795,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETREDRAW (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETREDRAW (long wParam, long lParam) {
LRESULT result = super.WM_SETREDRAW (wParam, lParam);
if (result != null) return result;
/*
@@ -1805,7 +1809,7 @@ LRESULT WM_SETREDRAW (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
/*
* Bug in Windows. If the top index is changed while the
* list is being resized, Windows does not redraw properly
@@ -1818,7 +1822,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
* is to redraw the control when the horizontal scroll bar is
* not at the beginning.
*/
- int oldIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ int oldIndex = (int)OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
LRESULT result = super.WM_SIZE (wParam, lParam);
if (!isDisposed ()) {
SCROLLINFO info = new SCROLLINFO ();
@@ -1827,14 +1831,14 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
if (OS.GetScrollInfo (handle, OS.SB_HORZ, info)) {
if (info.nPos != 0) OS.InvalidateRect (handle, null, true);
}
- int newIndex = (int)/*64*/OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ int newIndex = (int)OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
if (oldIndex != newIndex) OS.InvalidateRect (handle, null, true);
}
return result;
}
@Override
-LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmCommandChild (long wParam, long lParam) {
int code = OS.HIWORD (wParam);
switch (code) {
case OS.LBN_SELCHANGE:
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
index 3a7bb7164b..a4d73580b1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
@@ -55,11 +55,10 @@ public class Menu extends Widget {
*
* @noreference This field is not intended to be referenced by clients.
*/
- public long /*int*/ handle;
+ public long handle;
int x, y;
- long /*int*/ hBrush;
- int id0, id1;
+ long hBrush;
int foreground = -1, background = -1;
Image backgroundImage;
boolean hasLocation;
@@ -195,31 +194,16 @@ public Menu (MenuItem parentItem) {
this (checkNull (parentItem).parent);
}
-Menu (Decorations parent, int style, long /*int*/ handle) {
+Menu (Decorations parent, int style, long handle) {
super (parent, checkStyle (style));
this.parent = parent;
this.handle = handle;
- /*
- * Bug in IBM JVM 1.3.1. For some reason, when the checkOrientation() is
- * called from createWidget(), the JVM issues this error:
- *
- * JVM Exception 0x2 (subcode 0x0) occurred in thread "main" (TID:0x9F19D8)
- *
- * In addition, on Windows XP, a dialog appears with following error message,
- * indicating that the problem may be in the JIT:
- *
- * AppName: java.exe AppVer: 0.0.0.0 ModName: jitc.dll
- * ModVer: 0.0.0.0 Offset: 000b6912
- *
- * The fix is to call checkOrientation() from here.
- */
- checkOrientation (parent);
createWidget ();
}
void _setVisible (boolean visible) {
if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
- long /*int*/ hwndParent = parent.handle;
+ long hwndParent = parent.handle;
if (visible) {
int flags = OS.TPM_LEFTBUTTON;
if (OS.GetKeyState (OS.VK_LBUTTON) >= 0) flags |= OS.TPM_RIGHTBUTTON;
@@ -264,7 +248,7 @@ void _setVisible (boolean visible) {
* is not returned to the focus control. This causes confusion for AT users.
* The fix is to explicitly set the accessibility focus back to the focus control.
*/
- long /*int*/ hFocus = OS.GetFocus();
+ long hFocus = OS.GetFocus();
if (hFocus != 0) {
OS.NotifyWinEvent (OS.EVENT_OBJECT_FOCUS, hFocus, OS.OBJID_CLIENT, 0);
}
@@ -350,6 +334,7 @@ void createHandle () {
handle = OS.CreatePopupMenu ();
}
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ updateBackground ();
}
void createItem (MenuItem item, int index) {
@@ -368,8 +353,8 @@ void createItem (MenuItem item, int index) {
* becomes unexpectedly disabled. The fix is to insert a
* space.
*/
- long /*int*/ hHeap = OS.GetProcessHeap ();
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, 4);
+ long hHeap = OS.GetProcessHeap ();
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, 4);
OS.MoveMemory (pszText, new char [] {' ', '\0'}, 4);
MENUITEMINFO info = new MENUITEMINFO ();
info.cbSize = MENUITEMINFO.sizeof;
@@ -384,25 +369,25 @@ void createItem (MenuItem item, int index) {
display.removeMenuItem (item);
error (SWT.ERROR_ITEM_NOT_ADDED);
}
+
+ if (needsMenuCallback()) {
+ /*
+ * Bug in Windows: when MIIM_BITMAP is used together with MFT_STRING,
+ * InsertMenuItem() fails. The workaround is to set MIIM_BITMAP with
+ * a separate SetMenuItemInfo().
+ */
+
+ info.fMask = OS.MIIM_BITMAP;
+ info.hbmpItem = OS.HBMMENU_CALLBACK;
+ OS.SetMenuItemInfo (handle, index, true, info);
+ }
+
redraw ();
}
void createWidget () {
- /*
- * Bug in IBM JVM 1.3.1. For some reason, when the following code is called
- * from this method, the JVM issues this error:
- *
- * JVM Exception 0x2 (subcode 0x0) occurred in thread "main" (TID:0x9F19D8)
- *
- * In addition, on Windows XP, a dialog appears with following error message,
- * indicating that the problem may be in the JIT:
- *
- * AppName: java.exe AppVer: 0.0.0.0 ModName: jitc.dll
- * ModVer: 0.0.0.0 Offset: 000b6912
- *
- * The fix is to move the code to the caller of this method.
- */
-// checkOrientation (parent);
+ checkOrientation (parent);
+ initThemeColors ();
createHandle ();
parent.addMenu (this);
}
@@ -429,7 +414,7 @@ void destroyItem (MenuItem item) {
@Override
void destroyWidget () {
MenuItem cascade = this.cascade;
- long /*int*/ hMenu = handle;
+ long hMenu = handle;
releaseHandle ();
if (cascade != null) {
cascade.setMenu (null, true);
@@ -442,9 +427,8 @@ void fixMenus (Decorations newParent) {
if (isDisposed()) {
return;
}
- MenuItem [] items = getItems ();
- for (int i=0; i<items.length; i++) {
- items [i].fixMenus (newParent);
+ for (MenuItem item : getItems ()) {
+ item.fixMenus (newParent);
}
parent.removeMenu (this);
newParent.addMenu (this);
@@ -511,7 +495,7 @@ void fixMenus (Decorations newParent) {
if (parent.menuBar != this) {
return new Rectangle (0, 0, 0, 0);
}
- long /*int*/ hwndShell = parent.handle;
+ long hwndShell = parent.handle;
MENUBARINFO info = new MENUBARINFO ();
info.cbSize = MENUBARINFO.sizeof;
if (OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, 0, info)) {
@@ -620,7 +604,7 @@ public MenuItem getItem (int index) {
if (!OS.GetMenuItemInfo (handle, index, true, info)) {
error (SWT.ERROR_INVALID_RANGE);
}
- id = (int)/*64*/info.dwItemData;
+ id = (int)info.dwItemData;
return display.getMenuItem (id);
}
@@ -673,7 +657,7 @@ public MenuItem [] getItems () {
System.arraycopy (items, 0, newItems, 0, count);
items = newItems;
}
- MenuItem item = display.getMenuItem ((int)/*64*/info.dwItemData);
+ MenuItem item = display.getMenuItem ((int)info.dwItemData);
if (item != null) items [count++] = item;
index++;
}
@@ -811,8 +795,8 @@ public boolean getVisible () {
if ((style & SWT.POP_UP) != 0) {
Menu [] popups = display.popups;
if (popups == null) return false;
- for (int i=0; i<popups.length; i++) {
- if (popups [i] == this) return true;
+ for (Menu popup : popups) {
+ if (popup == this) return true;
}
}
Shell shell = getShell ();
@@ -862,6 +846,13 @@ public int indexOf (MenuItem item) {
return -1;
}
+void initThemeColors () {
+ if ((style & SWT.BAR) != 0) {
+ foreground = display.menuBarForegroundPixel;
+ background = display.menuBarBackgroundPixel;
+ }
+}
+
/**
* Returns <code>true</code> if the receiver is enabled and all
* of the receiver's ancestors are enabled, and <code>false</code>
@@ -905,6 +896,34 @@ public boolean isVisible () {
return getVisible ();
}
+
+boolean needsMenuCallback() {
+ /*
+ * Note: using `HBMMENU_CALLBACK` disables XP theme for entire menu
+ * containing the menu item. This has at least the following side
+ * effects:
+ * 1) Menu bar: items are no longer highlighted when mouse hovers
+ * 2) Menu bar: text is now left-aligned without any margin
+ * 3) Popup menu: Images and checkboxes are no longer merged into a single column
+ */
+
+ if ((background != -1) || (backgroundImage != null)) {
+ /*
+ * Since XP theming, `MENUINFO.hbrBack` has two issues:
+ * 1) Menu bar completely ignores it
+ * 2) Popup menus ignore it for image/checkbox area
+ * The workaround is to disable XP theme via `HBMMENU_CALLBACK`.
+ */
+ return true;
+ }
+
+ /*
+ * Otherwise, if menu has foreground color configured, use
+ * `HBMMENU_CALLBACK` to set color in `MenuItem.wmDrawChild` callback.
+ */
+ return (foreground != -1);
+}
+
void redraw () {
if (!isVisible ()) return;
if ((style & SWT.BAR) != 0) {
@@ -923,9 +942,7 @@ void releaseHandle () {
@Override
void releaseChildren (boolean destroy) {
- MenuItem [] items = getItems ();
- for (int i=0; i<items.length; i++) {
- MenuItem item = items [i];
+ for (MenuItem item : getItems ()) {
if (item != null && !item.isDisposed ()) {
item.release (false);
}
@@ -1009,9 +1026,7 @@ public void removeMenuListener (MenuListener listener) {
@Override
void reskinChildren (int flags) {
- MenuItem [] items = getItems ();
- for (int i=0; i<items.length; i++) {
- MenuItem item = items [i];
+ for (MenuItem item : getItems ()) {
item.reskin (flags);
}
super.reskinChildren (flags);
@@ -1232,21 +1247,20 @@ public void setLocation (Point location) {
* @since 3.7
*/
public void setOrientation (int orientation) {
- checkWidget ();
- if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
- _setOrientation (orientation);
+ checkWidget ();
+ if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
+ _setOrientation (orientation);
}
void _setOrientation (int orientation) {
- int flags = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT;
- if ((orientation & flags) == 0 || (orientation & flags) == flags) return;
- style &= ~flags;
- style |= orientation & flags;
- style &= ~SWT.FLIP_TEXT_DIRECTION;
- MenuItem [] itms = getItems ();
- for (int i=0; i<itms.length; i++) {
- itms [i].setOrientation (orientation);
- }
+ int flags = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT;
+ if ((orientation & flags) == 0 || (orientation & flags) == flags) return;
+ style &= ~flags;
+ style |= orientation & flags;
+ style &= ~SWT.FLIP_TEXT_DIRECTION;
+ for (MenuItem itm : getItems ()) {
+ itm.setOrientation (orientation);
+ }
}
/**
@@ -1282,9 +1296,7 @@ void update () {
return;
}
boolean hasCheck = false, hasImage = false;
- MenuItem [] items = getItems ();
- for (int i=0; i<items.length; i++) {
- MenuItem item = items [i];
+ for (MenuItem item : getItems ()) {
if (item.image != null) {
if ((hasImage = true) && hasCheck) break;
}
@@ -1309,11 +1321,12 @@ void update () {
void updateBackground () {
if (hBrush != 0) OS.DeleteObject (hBrush);
hBrush = 0;
- if (backgroundImage != null) {
+
+ if (backgroundImage != null)
hBrush = OS.CreatePatternBrush (backgroundImage.handle);
- } else {
- if (background != -1) hBrush = OS.CreateSolidBrush (background);
- }
+ else if (background != -1)
+ hBrush = OS.CreateSolidBrush (background);
+
MENUINFO lpcmi = new MENUINFO ();
lpcmi.cbSize = MENUINFO.sizeof;
lpcmi.fMask = OS.MIM_BACKGROUND;
@@ -1334,7 +1347,7 @@ void updateForeground () {
redraw ();
}
-LRESULT wmTimer (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmTimer (long wParam, long lParam) {
if (wParam == ID_TOOLTIP_TIMER) {
POINT pt = new POINT ();
OS.GetCursorPos (pt);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
index 97138d6755..eb61d275a8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -41,7 +41,7 @@ import org.eclipse.swt.internal.win32.*;
*/
public class MenuItem extends Item {
Menu parent, menu;
- long /*int*/ hBitmap;
+ long hBitmap;
int id, accelerator, userId, index;
ToolTip itemToolTip;
/* Image margin. */
@@ -267,7 +267,7 @@ boolean fillAccel (ACCEL accel) {
if (key == 0) return false;
vKey = OS.VkKeyScan ((short) key);
if (vKey == -1) {
- if (key != (int)/*64*/OS.CharUpper ((short) key)) {
+ if (key != (int)OS.CharUpper ((short) key)) {
fVirt = 0;
}
} else {
@@ -330,7 +330,7 @@ public int getAccelerator () {
if (shell.menuBar != parent) {
return new Rectangle (0, 0, 0, 0);
}
- long /*int*/ hwndShell = shell.handle;
+ long hwndShell = shell.handle;
MENUBARINFO info1 = new MENUBARINFO ();
info1.cbSize = MENUBARINFO.sizeof;
if (!OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, 1, info1)) {
@@ -347,7 +347,7 @@ public int getAccelerator () {
int height = info2.bottom - info2.top;
return new Rectangle (x, y, width, height);
} else {
- long /*int*/ hMenu = parent.handle;
+ long hMenu = parent.handle;
RECT rect1 = new RECT ();
if (!OS.GetMenuItemRect (0, hMenu, 0, rect1)) {
return new Rectangle (0, 0, 0, 0);
@@ -390,7 +390,7 @@ public boolean getEnabled () {
if ((style & SWT.SEPARATOR) != 0) {
return (state & DISABLED) == 0;
}
- long /*int*/ hMenu = parent.handle;
+ long hMenu = parent.handle;
MENUITEMINFO info = new MENUITEMINFO ();
info.cbSize = MENUITEMINFO.sizeof;
info.fMask = OS.MIIM_STATE;
@@ -474,7 +474,7 @@ public Menu getParent () {
public boolean getSelection () {
checkWidget ();
if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;
- long /*int*/ hMenu = parent.handle;
+ long hMenu = parent.handle;
MENUITEMINFO info = new MENUITEMINFO ();
info.cbSize = MENUITEMINFO.sizeof;
info.fMask = OS.MIIM_STATE;
@@ -497,11 +497,11 @@ public boolean getSelection () {
*/
public String getToolTipText () {
checkWidget();
- return (itemToolTip == null) ? null : itemToolTip.getMessage();
+ return (itemToolTip == null || itemToolTip.isDisposed()) ? null : itemToolTip.getMessage();
}
void hideToolTip () {
- if (itemToolTip == null) return;
+ if (itemToolTip == null || itemToolTip.isDisposed()) return;
itemToolTip.setVisible (false);
}
@@ -556,6 +556,11 @@ void releaseWidget () {
parent.destroyAccelerators ();
}
accelerator = 0;
+ if (itemToolTip!= null && !itemToolTip.isDisposed()) {
+ itemToolTip.setVisible (false);
+ itemToolTip.dispose();
+ itemToolTip = null;
+ }
display.removeMenuItem (this);
}
@@ -700,7 +705,7 @@ public void setEnabled (boolean enabled) {
state |= DISABLED;
}
}
- long /*int*/ hMenu = parent.handle;
+ long hMenu = parent.handle;
MENUITEMINFO info = new MENUITEMINFO ();
info.cbSize = MENUITEMINFO.sizeof;
info.fMask = OS.MIIM_STATE;
@@ -762,10 +767,7 @@ public void setID (int id) {
* <p>
* Note: This operation is a <em>HINT</em> and is not supported on
* platforms that do not have this concept (for example, Windows NT).
- * Furthermore, some platforms (such as GTK2), cannot display both
- * a check box and an image at the same time. Instead, they hide
- * the image and display the check box. Some platforms (such as GTK3)
- * support images alongside check boxes.
+ * Some platforms (such as GTK3) support images alongside check boxes.
* </p>
*
* @param image the image to display on the receiver (may be null)
@@ -778,12 +780,13 @@ public void setID (int id) {
@Override
public void setImage (Image image) {
checkWidget ();
+ if (this.image == image) return;
if ((style & SWT.SEPARATOR) != 0) return;
super.setImage (image);
MENUITEMINFO info = new MENUITEMINFO ();
info.cbSize = MENUITEMINFO.sizeof;
info.fMask = OS.MIIM_BITMAP;
- if (parent.foreground != -1) {
+ if (parent.needsMenuCallback()) {
info.hbmpItem = OS.HBMMENU_CALLBACK;
} else {
if (OS.IsAppThemed ()) {
@@ -793,7 +796,7 @@ public void setImage (Image image) {
info.hbmpItem = image != null ? OS.HBMMENU_CALLBACK : 0;
}
}
- long /*int*/ hMenu = parent.handle;
+ long hMenu = parent.handle;
OS.SetMenuItemInfo (hMenu, id, false, info);
parent.redraw ();
}
@@ -850,7 +853,7 @@ void setMenu (Menu menu, boolean dispose) {
if (oldMenu != null) oldMenu.cascade = null;
this.menu = menu;
- long /*int*/ hMenu = parent.handle;
+ long hMenu = parent.handle;
MENUITEMINFO info = new MENUITEMINFO ();
info.cbSize = MENUITEMINFO.sizeof;
info.fMask = OS.MIIM_DATA;
@@ -861,9 +864,9 @@ void setMenu (Menu menu, boolean dispose) {
}
if (info.dwItemData != id) return;
int cch = 128;
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
int byteCount = cch * 2;
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
info.fMask = OS.MIIM_STATE | OS.MIIM_ID | OS.MIIM_DATA;
/*
* Bug in Windows. When GetMenuItemInfo() is used to get the text,
@@ -913,13 +916,13 @@ boolean setRadioSelection (boolean value) {
}
void setOrientation (int orientation) {
- long /*int*/ hMenu = parent.handle;
- MENUITEMINFO info = new MENUITEMINFO ();
- info.cbSize = MENUITEMINFO.sizeof;
- info.fMask = OS.MIIM_FTYPE;
- info.fType = widgetStyle ();
- OS.SetMenuItemInfo (hMenu, id, false, info);
- if (menu != null) menu._setOrientation (orientation);
+ long hMenu = parent.handle;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_FTYPE;
+ info.fType = widgetStyle ();
+ OS.SetMenuItemInfo (hMenu, id, false, info);
+ if (menu != null) menu._setOrientation (orientation);
}
/**
@@ -938,7 +941,7 @@ void setOrientation (int orientation) {
public void setSelection (boolean selected) {
checkWidget ();
if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
- long /*int*/ hMenu = parent.handle;
+ long hMenu = parent.handle;
MENUITEMINFO info = new MENUITEMINFO ();
info.cbSize = MENUITEMINFO.sizeof;
info.fMask = OS.MIIM_STATE;
@@ -1008,13 +1011,12 @@ public void setText (String string) {
if ((style & SWT.SEPARATOR) != 0) return;
if (text.equals (string)) return;
super.setText (string);
- long /*int*/ hHeap = OS.GetProcessHeap ();
- long /*int*/ pszText = 0;
+ long hHeap = OS.GetProcessHeap ();
+ long pszText = 0;
MENUITEMINFO info = new MENUITEMINFO ();
info.cbSize = MENUITEMINFO.sizeof;
- long /*int*/ hMenu = parent.handle;
+ long hMenu = parent.handle;
- /* Use the character encoding for the default locale */
TCHAR buffer = new TCHAR (0, string, true);
int byteCount = buffer.length () * TCHAR.sizeof;
pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
@@ -1069,20 +1071,24 @@ public void setToolTipText (String toolTip) {
checkWidget ();
if (toolTip == null && itemToolTip != null) {
- itemToolTip.setVisible (false);
+ if(!itemToolTip.isDisposed()) {
+ itemToolTip.setVisible (false);
+ itemToolTip.dispose();
+ }
itemToolTip = null;
}
if (toolTip == null || toolTip.trim().length() == 0
|| (itemToolTip != null && toolTip.equals(itemToolTip.getMessage()))) return;
+ if (itemToolTip != null) itemToolTip.dispose();
itemToolTip = new MenuItemToolTip (this.getParent().getShell());
itemToolTip.setMessage (toolTip);
itemToolTip.setVisible (false);
}
void showTooltip (int x, int y) {
- if (itemToolTip == null) return;
+ if (itemToolTip == null || itemToolTip.isDisposed()) return;
itemToolTip.setLocationInPixels (x, y);
itemToolTip.setVisible (true);
}
@@ -1104,7 +1110,7 @@ int widgetStyle () {
return bits | OS.MFT_STRING;
}
-LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmCommandChild (long wParam, long lParam) {
if ((style & SWT.CHECK) != 0) {
setSelection (!getSelection ());
} else {
@@ -1120,7 +1126,7 @@ LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT wmDrawChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmDrawChild (long wParam, long lParam) {
DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ();
OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof);
if (image != null) {
@@ -1143,9 +1149,28 @@ LRESULT wmDrawChild (long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT wmMeasureChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmMeasureChild (long wParam, long lParam) {
MEASUREITEMSTRUCT struct = new MEASUREITEMSTRUCT ();
OS.MoveMemory (struct, lParam, MEASUREITEMSTRUCT.sizeof);
+
+ if ((parent.style & SWT.BAR) != 0) {
+ if (parent.needsMenuCallback()) {
+ /*
+ * Weirdness in Windows. Setting `HBMMENU_CALLBACK` causes
+ * item sizes to mean something else. It seems that it is
+ * the size of left margin before the text. At the same time,
+ * if menu item has a mnemonic, it's always drawn at a fixed
+ * position. I have tested on Win7, Win8.1, Win10 and found
+ * that value of 5 works well in matching text to mnemonic.
+ * NOTE: autoScaleUpUsingNativeDPI() is used to avoid problems
+ * with applications that disable automatic scaling.
+ */
+ struct.itemWidth = DPIUtil.autoScaleUpUsingNativeDPI(5);
+ OS.MoveMemory (lParam, struct, MEASUREITEMSTRUCT.sizeof);
+ return null;
+ }
+ }
+
int width = 0, height = 0;
if (image != null) {
Rectangle rect = image.getBoundsInPixels ();
@@ -1165,12 +1190,10 @@ LRESULT wmMeasureChild (long /*int*/ wParam, long /*int*/ lParam) {
MENUINFO lpcmi = new MENUINFO ();
lpcmi.cbSize = MENUINFO.sizeof;
lpcmi.fMask = OS.MIM_STYLE;
- long /*int*/ hMenu = parent.handle;
+ long hMenu = parent.handle;
OS.GetMenuInfo (hMenu, lpcmi);
if ((lpcmi.dwStyle & OS.MNS_CHECKORBMP) == 0) {
- MenuItem [] items = parent.getItems ();
- for (int i=0; i<items.length; i++) {
- MenuItem item = items [i];
+ for (MenuItem item : parent.getItems ()) {
if (item.image != null) {
Rectangle rect = item.image.getBoundsInPixels ();
width = Math.max (width, rect.width);
@@ -1190,10 +1213,11 @@ private static final class MenuItemToolTip extends ToolTip {
public MenuItemToolTip(Shell parent) {
super(parent, 0);
+ maybeEnableDarkSystemTheme(hwndToolTip ());
}
@Override
- long /*int*/ hwndToolTip() {
+ long hwndToolTip() {
return parent.menuItemToolTipHandle();
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java
index 4c045bd894..cae28106ed 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java
@@ -14,8 +14,8 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class are used to inform or warn the user.
@@ -186,7 +186,7 @@ public int open () {
* anyway and not rely on MB_MODAL to work by making the
* parent be temporarily modal.
*/
- long /*int*/ hwndOwner = parent != null ? parent.handle : 0;
+ long hwndOwner = parent != null ? parent.handle : 0;
Display display = parent != null ? parent.getDisplay (): Display.getCurrent ();
Dialog oldModal = null;
if ((bits & OS.MB_TASKMODAL) != 0) {
@@ -196,10 +196,11 @@ public int open () {
/* Open the message box */
display.sendPreExternalEventDispatchEvent ();
- /* Use the character encoding for the default locale */
TCHAR buffer1 = new TCHAR (0, message, true);
TCHAR buffer2 = new TCHAR (0, title, true);
+ display.externalEventLoop = true;
int code = OS.MessageBox (hwndOwner, buffer1, buffer2, bits);
+ display.externalEventLoop = false;
display.sendPostExternalEventDispatchEvent ();
/* Clear the temporarily dialog modal parent */
@@ -207,14 +208,6 @@ public int open () {
display.setModalDialog (oldModal);
}
- /*
- * This code is intentionally commented. On some
- * platforms, the owner window is repainted right
- * away when a dialog window exits. This behavior
- * is currently unspecified.
- */
-// if (hwndOwner != 0) OS.UpdateWindow (hwndOwner);
-
/* Compute and return the result */
if (code != 0) {
int type = bits & 0x0F;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
index 739c790e01..88124e9178 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
@@ -43,7 +43,7 @@ public class ProgressBar extends Control {
static final int DELAY = 100;
static final int TIMER_ID = 100;
static final int MINIMUM_WIDTH = 100;
- static final long /*int*/ ProgressBarProc;
+ static final long ProgressBarProc;
static final TCHAR ProgressBarClass = new TCHAR (0, OS.PROGRESS_CLASS, true);
static {
WNDCLASS lpWndClass = new WNDCLASS ();
@@ -108,7 +108,7 @@ public ProgressBar (Composite parent, int style) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
return OS.CallWindowProc (ProgressBarProc, hwnd, msg, wParam, lParam);
}
@@ -137,6 +137,12 @@ static int checkStyle (int style) {
@Override
void createHandle () {
super.createHandle ();
+
+ if (display.progressbarUseColors) {
+ char[] noTheme = new char[]{0};
+ OS.SetWindowTheme(handle, noTheme, noTheme);
+ }
+
startTimer ();
}
@@ -157,7 +163,7 @@ int defaultForeground () {
*/
public int getMaximum () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.PBM_GETRANGE, 0, 0);
+ return (int)OS.SendMessage (handle, OS.PBM_GETRANGE, 0, 0);
}
/**
@@ -172,7 +178,7 @@ public int getMaximum () {
*/
public int getMinimum () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.PBM_GETRANGE, 1, 0);
+ return (int)OS.SendMessage (handle, OS.PBM_GETRANGE, 1, 0);
}
/**
@@ -187,7 +193,7 @@ public int getMinimum () {
*/
public int getSelection () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.PBM_GETPOS, 0, 0);
+ return (int)OS.SendMessage (handle, OS.PBM_GETPOS, 0, 0);
}
/**
@@ -209,7 +215,7 @@ public int getSelection () {
*/
public int getState () {
checkWidget ();
- int state = (int)/*64*/OS.SendMessage (handle, OS.PBM_GETSTATE, 0, 0);
+ int state = (int)OS.SendMessage (handle, OS.PBM_GETSTATE, 0, 0);
switch (state) {
case OS.PBST_NORMAL: return SWT.NORMAL;
case OS.PBST_ERROR: return SWT.ERROR;
@@ -273,7 +279,7 @@ void setForegroundPixel (int pixel) {
*/
public void setMaximum (int value) {
checkWidget ();
- int minimum = (int)/*64*/OS.SendMessage (handle, OS.PBM_GETRANGE, 1, 0);
+ int minimum = (int)OS.SendMessage (handle, OS.PBM_GETRANGE, 1, 0);
if (0 <= minimum && minimum < value) {
OS.SendMessage (handle, OS.PBM_SETRANGE32, minimum, value);
}
@@ -294,7 +300,7 @@ public void setMaximum (int value) {
*/
public void setMinimum (int value) {
checkWidget ();
- int maximum = (int)/*64*/OS.SendMessage (handle, OS.PBM_GETRANGE, 0, 0);
+ int maximum = (int)OS.SendMessage (handle, OS.PBM_GETRANGE, 0, 0);
if (0 <= value && value < maximum) {
OS.SendMessage (handle, OS.PBM_SETRANGE32, value, maximum);
}
@@ -322,7 +328,7 @@ public void setSelection (int value) {
* PBM_SETPOS. This is undocumented. The fix is to call PBM_SETPOS
* a second time.
*/
- long /*int*/ state = OS.SendMessage (handle, OS.PBM_GETSTATE, 0, 0);
+ long state = OS.SendMessage (handle, OS.PBM_GETSTATE, 0, 0);
if (state != OS.PBST_NORMAL) {
OS.SendMessage (handle, OS.PBM_SETPOS, value, 0);
}
@@ -379,12 +385,12 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return ProgressBarProc;
}
@Override
-LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETDLGCODE (long wParam, long lParam) {
LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
if (result != null) return result;
/*
@@ -400,7 +406,7 @@ LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
LRESULT result = super.WM_SIZE (wParam, lParam);
if (result != null) return result;
/*
@@ -437,7 +443,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_TIMER (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_TIMER (long wParam, long lParam) {
LRESULT result = super.WM_TIMER (wParam, lParam);
if (result != null) return result;
if ((style & SWT.INDETERMINATE) != 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
index 959fc05a01..59eb302b26 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
@@ -114,7 +114,7 @@ public void addSelectionListener (SelectionListener listener) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
return OS.DefWindowProc (hwnd, msg, wParam, lParam);
}
@@ -145,12 +145,12 @@ static int checkStyle (int style) {
void drawBand (int x, int y, int width, int height) {
if ((style & SWT.SMOOTH) != 0) return;
- long /*int*/ hwndTrack = parent.handle;
+ long hwndTrack = parent.handle;
byte [] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
- long /*int*/ stippleBitmap = OS.CreateBitmap (8, 8, 1, 1, bits);
- long /*int*/ stippleBrush = OS.CreatePatternBrush (stippleBitmap);
- long /*int*/ hDC = OS.GetDCEx (hwndTrack, 0, OS.DCX_CACHE);
- long /*int*/ oldBrush = OS.SelectObject (hDC, stippleBrush);
+ long stippleBitmap = OS.CreateBitmap (8, 8, 1, 1, bits);
+ long stippleBrush = OS.CreatePatternBrush (stippleBitmap);
+ long hDC = OS.GetDCEx (hwndTrack, 0, OS.DCX_CACHE);
+ long oldBrush = OS.SelectObject (hDC, stippleBrush);
OS.PatBlt (hDC, x, y, width, height, OS.PATINVERT);
OS.SelectObject (hDC, oldBrush);
OS.ReleaseDC (hwndTrack, hDC);
@@ -189,22 +189,22 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return display.windowProc;
}
@Override
-LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ERASEBKGND (long wParam, long lParam) {
super.WM_ERASEBKGND (wParam, lParam);
drawBackground (wParam);
return LRESULT.ONE;
}
@Override
-LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KEYDOWN (long wParam, long lParam) {
LRESULT result = super.WM_KEYDOWN (wParam, lParam);
if (result != null) return result;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_LEFT:
case OS.VK_RIGHT:
case OS.VK_UP:
@@ -225,7 +225,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
OS.GetWindowRect (handle, rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
- long /*int*/ hwndTrack = parent.handle;
+ long hwndTrack = parent.handle;
RECT clientRect = new RECT ();
OS.GetClientRect (hwndTrack, clientRect);
int clientWidth = clientRect.right - clientRect.left;
@@ -261,17 +261,17 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETDLGCODE (long wParam, long lParam) {
return new LRESULT (OS.DLGC_STATIC);
}
@Override
-LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDOWN (long wParam, long lParam) {
LRESULT result = super.WM_LBUTTONDOWN (wParam, lParam);
if (result == LRESULT.ZERO) return result;
/* Compute the banding rectangle */
- long /*int*/ hwndTrack = parent.handle;
+ long hwndTrack = parent.handle;
POINT pt = new POINT ();
OS.POINTSTOPOINT (pt, lParam);
RECT rect = new RECT ();
@@ -314,7 +314,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_LBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONUP (long wParam, long lParam) {
LRESULT result = super.WM_LBUTTONUP (wParam, lParam);
if (result == LRESULT.ZERO) return result;
@@ -343,7 +343,7 @@ LRESULT WM_LBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSEMOVE (long wParam, long lParam) {
LRESULT result = super.WM_MOUSEMOVE (wParam, lParam);
if (result != null) return result;
if (!dragging || (wParam & OS.MK_LBUTTON) == 0) return result;
@@ -351,7 +351,7 @@ LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
/* Compute the banding rectangle */
POINT pt = new POINT ();
OS.POINTSTOPOINT (pt, lParam);
- long /*int*/ hwndTrack = parent.handle;
+ long hwndTrack = parent.handle;
OS.MapWindowPoints (handle, hwndTrack, pt, 1);
RECT rect = new RECT (), clientRect = new RECT ();
OS.GetWindowRect (handle, rect);
@@ -393,17 +393,17 @@ LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETCURSOR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETCURSOR (long wParam, long lParam) {
LRESULT result = super.WM_SETCURSOR (wParam, lParam);
if (result != null) return result;
int hitTest = (short) OS.LOWORD (lParam);
- if (hitTest == OS.HTCLIENT) {
- long /*int*/ hCursor = 0;
- if ((style & SWT.HORIZONTAL) != 0) {
+ if (hitTest == OS.HTCLIENT) {
+ long hCursor = 0;
+ if ((style & SWT.HORIZONTAL) != 0) {
hCursor = OS.LoadCursor (0, OS.IDC_SIZENS);
- } else {
+ } else {
hCursor = OS.LoadCursor (0, OS.IDC_SIZEWE);
- }
+ }
OS.SetCursor (hCursor);
return LRESULT.ONE;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
index 2b78ffd3e4..65d41a87af 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
@@ -43,7 +43,7 @@ import org.eclipse.swt.internal.win32.*;
*/
public class Scale extends Control {
boolean ignoreResize, ignoreSelection;
- static final long /*int*/ TrackBarProc;
+ static final long TrackBarProc;
static final TCHAR TrackBarClass = new TCHAR (0, OS.TRACKBAR_CLASS, true);
boolean createdAsRTL;
static {
@@ -138,7 +138,7 @@ public void addSelectionListener(SelectionListener listener) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
return OS.CallWindowProc (TrackBarProc, hwnd, msg, wParam, lParam);
}
@@ -196,7 +196,7 @@ int defaultForeground () {
*/
public int getIncrement () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.TBM_GETLINESIZE, 0, 0);
+ return (int)OS.SendMessage (handle, OS.TBM_GETLINESIZE, 0, 0);
}
/**
@@ -211,7 +211,7 @@ public int getIncrement () {
*/
public int getMaximum () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);
+ return (int)OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);
}
/**
@@ -243,7 +243,7 @@ public int getMinimum () {
*/
public int getPageIncrement () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.TBM_GETPAGESIZE, 0, 0);
+ return (int)OS.SendMessage (handle, OS.TBM_GETPAGESIZE, 0, 0);
}
/**
@@ -258,7 +258,7 @@ public int getPageIncrement () {
*/
public int getSelection () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.TBM_GETPOS, 0, 0);
+ return (int)OS.SendMessage (handle, OS.TBM_GETPOS, 0, 0);
}
/**
@@ -287,7 +287,7 @@ public void removeSelectionListener(SelectionListener listener) {
}
@Override
-void setBackgroundImage (long /*int*/ hImage) {
+void setBackgroundImage (long hImage) {
super.setBackgroundImage (hImage);
/*
* Bug in Windows. Changing the background color of the Scale
@@ -358,8 +358,8 @@ void setBoundsInPixels (int x, int y, int width, int height, int flags, boolean
public void setIncrement (int increment) {
checkWidget ();
if (increment < 1) return;
- int minimum = (int)/*64*/OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0);
- int maximum = (int)/*64*/OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);
+ int minimum = (int)OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0);
+ int maximum = (int)OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);
if (increment > maximum - minimum) return;
OS.SendMessage (handle, OS.TBM_SETLINESIZE, 0, increment);
}
@@ -379,7 +379,7 @@ public void setIncrement (int increment) {
*/
public void setMaximum (int value) {
checkWidget ();
- int minimum = (int)/*64*/OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0);
+ int minimum = (int)OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0);
if (0 <= minimum && minimum < value) {
OS.SendMessage (handle, OS.TBM_SETRANGEMAX, 1, value);
}
@@ -400,7 +400,7 @@ public void setMaximum (int value) {
*/
public void setMinimum (int value) {
checkWidget ();
- int maximum = (int)/*64*/OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);
+ int maximum = (int)OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);
if (0 <= value && value < maximum) {
OS.SendMessage (handle, OS.TBM_SETRANGEMIN, 1, value);
}
@@ -422,8 +422,8 @@ public void setMinimum (int value) {
public void setPageIncrement (int pageIncrement) {
checkWidget ();
if (pageIncrement < 1) return;
- int minimum = (int)/*64*/OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0);
- int maximum = (int)/*64*/OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);
+ int minimum = (int)OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0);
+ int maximum = (int)OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);
if (pageIncrement > maximum - minimum) return;
OS.SendMessage (handle, OS.TBM_SETPAGESIZE, 0, pageIncrement);
OS.SendMessage (handle, OS.TBM_SETTICFREQ, pageIncrement, 0);
@@ -458,15 +458,15 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return TrackBarProc;
}
@Override
-LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KEYDOWN (long wParam, long lParam) {
LRESULT result = super.WM_KEYDOWN (wParam, lParam);
if (result != null) return result;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_LEFT:
case OS.VK_RIGHT:
/*
@@ -475,10 +475,10 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
* The fix is to replace VK_LEFT by VK_RIGHT and VK_RIGHT by VK_LEFT
* when the current orientation differs from the orientation used to
* create the control.
- */
+ */
boolean isRTL = (style & SWT.RIGHT_TO_LEFT) != 0;
if (isRTL != createdAsRTL) {
- long /*int*/ code = callWindowProc (handle, OS.WM_KEYDOWN, wParam == OS.VK_RIGHT ? OS.VK_LEFT : OS.VK_RIGHT, lParam);
+ long code = callWindowProc (handle, OS.WM_KEYDOWN, wParam == OS.VK_RIGHT ? OS.VK_LEFT : OS.VK_RIGHT, lParam);
return new LRESULT (code);
}
break;
@@ -487,7 +487,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_MOUSEWHEEL (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSEWHEEL (long wParam, long lParam) {
LRESULT result = super.WM_MOUSEWHEEL (wParam, lParam);
if (result != null) return result;
/*
@@ -498,11 +498,11 @@ LRESULT WM_MOUSEWHEEL (long /*int*/ wParam, long /*int*/ lParam) {
* has changed and that notification has not been issued
* and send the selection event.
*/
- int oldPosition = (int)/*64*/OS.SendMessage (handle, OS.TBM_GETPOS, 0, 0);
+ int oldPosition = (int)OS.SendMessage (handle, OS.TBM_GETPOS, 0, 0);
ignoreSelection = true;
- long /*int*/ code = callWindowProc (handle, OS.WM_MOUSEWHEEL, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_MOUSEWHEEL, wParam, lParam);
ignoreSelection = false;
- int newPosition = (int)/*64*/OS.SendMessage (handle, OS.TBM_GETPOS, 0, 0);
+ int newPosition = (int)OS.SendMessage (handle, OS.TBM_GETPOS, 0, 0);
if (oldPosition != newPosition) {
/*
* Send the event because WM_HSCROLL and WM_VSCROLL
@@ -516,7 +516,7 @@ LRESULT WM_MOUSEWHEEL (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PAINT (long wParam, long lParam) {
if ((state & DISPOSE_SENT) != 0) return LRESULT.ZERO;
/*
@@ -551,13 +551,13 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
if (ignoreResize) return null;
return super.WM_SIZE (wParam, lParam);
}
@Override
-LRESULT wmScrollChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmScrollChild (long wParam, long lParam) {
/* Do nothing when scrolling is ending */
int code = OS.LOWORD (wParam);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
index 058f25a9fb..347214f2c9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
@@ -187,13 +187,11 @@ void createWidget () {
@Override
void destroyWidget () {
- long /*int*/ hwnd = hwndScrollBar ();
+ long hwnd = hwndScrollBar ();
int type = scrollBarType ();
OS.ShowScrollBar (hwnd, type, false);
parent.destroyScrollBar (style);
releaseHandle ();
- //This code is intentionally commented
- //parent.sendEvent (SWT.Resize);
}
Rectangle getBounds () {
@@ -266,7 +264,7 @@ public int getMaximum () {
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
info.fMask = OS.SIF_RANGE;
- long /*int*/ hwnd = hwndScrollBar ();
+ long hwnd = hwndScrollBar ();
int type = scrollBarType ();
OS.GetScrollInfo (hwnd, type, info);
return info.nMax;
@@ -287,7 +285,7 @@ public int getMinimum () {
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
info.fMask = OS.SIF_RANGE;
- long /*int*/ hwnd = hwndScrollBar ();
+ long hwnd = hwndScrollBar ();
int type = scrollBarType ();
OS.GetScrollInfo (hwnd, type, info);
return info.nMin;
@@ -340,7 +338,7 @@ public int getSelection () {
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
info.fMask = OS.SIF_POS;
- long /*int*/ hwnd = hwndScrollBar ();
+ long hwnd = hwndScrollBar ();
int type = scrollBarType ();
OS.GetScrollInfo (hwnd, type, info);
return info.nPos;
@@ -396,7 +394,7 @@ public int getThumb () {
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
info.fMask = OS.SIF_PAGE;
- long /*int*/ hwnd = hwndScrollBar ();
+ long hwnd = hwndScrollBar ();
int type = scrollBarType ();
OS.GetScrollInfo (hwnd, type, info);
if (info.nPage != 0) --info.nPage;
@@ -534,7 +532,7 @@ public boolean getVisible () {
return (psbi.rgstate [0] & OS.STATE_SYSTEM_INVISIBLE) == 0;
}
-long /*int*/ hwndScrollBar () {
+long hwndScrollBar () {
return parent.scrolledHandle ();
}
@@ -634,7 +632,7 @@ int scrollBarType () {
*/
public void setEnabled (boolean enabled) {
checkWidget();
- long /*int*/ hwnd = hwndScrollBar ();
+ long hwnd = hwndScrollBar ();
int type = scrollBarType ();
int flags = enabled ? OS.ESB_ENABLE_BOTH : OS.ESB_DISABLE_BOTH;
OS.EnableScrollBar (hwnd, type, flags);
@@ -682,7 +680,7 @@ public void setMaximum (int value) {
if (value < 0) return;
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
- long /*int*/ hwnd = hwndScrollBar ();
+ long hwnd = hwndScrollBar ();
int type = scrollBarType ();
info.fMask = OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL;
OS.GetScrollInfo (hwnd, type, info);
@@ -709,7 +707,7 @@ public void setMinimum (int value) {
if (value < 0) return;
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
- long /*int*/ hwnd = hwndScrollBar ();
+ long hwnd = hwndScrollBar ();
int type = scrollBarType ();
info.fMask = OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL;
OS.GetScrollInfo (hwnd, type, info);
@@ -737,7 +735,7 @@ public void setPageIncrement (int value) {
pageIncrement = value;
}
-boolean SetScrollInfo (long /*int*/ hwnd, int flags, SCROLLINFO info, boolean fRedraw) {
+boolean SetScrollInfo (long hwnd, int flags, SCROLLINFO info, boolean fRedraw) {
/*
* Bug in Windows. For some reason, when SetScrollInfo()
* is used with SIF_POS and the scroll bar is hidden,
@@ -820,7 +818,7 @@ public void setSelection (int selection) {
checkWidget();
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
- long /*int*/ hwnd = hwndScrollBar ();
+ long hwnd = hwndScrollBar ();
int type = scrollBarType ();
info.fMask = OS.SIF_POS;
info.nPos = selection;
@@ -849,7 +847,7 @@ public void setThumb (int value) {
if (value < 1) return;
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
- long /*int*/ hwnd = hwndScrollBar ();
+ long hwnd = hwndScrollBar ();
int type = scrollBarType ();
info.fMask = OS.SIF_PAGE | OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL;
OS.GetScrollInfo (hwnd, type, info);
@@ -896,7 +894,7 @@ public void setValues (int selection, int minimum, int maximum, int thumb, int i
info.nMax = maximum;
info.nPage = thumb;
if (info.nPage != 0) info.nPage++;
- long /*int*/ hwnd = hwndScrollBar ();
+ long hwnd = hwndScrollBar ();
int type = scrollBarType ();
SetScrollInfo (hwnd, type, info, true);
}
@@ -929,7 +927,7 @@ public void setVisible (boolean visible) {
* of the scroll bar will get the correct value.
*/
state = visible ? state & ~HIDDEN : state | HIDDEN;
- long /*int*/ hwnd = hwndScrollBar ();
+ long hwnd = hwndScrollBar ();
int type = scrollBarType ();
/*
* Bug in Windows 7. Windows will cause pixel corruption
@@ -977,7 +975,7 @@ public void setVisible (boolean visible) {
}
}
-LRESULT wmScrollChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmScrollChild (long wParam, long lParam) {
/* Do nothing when scrolling is ending */
int code = OS.LOWORD (wParam);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
index aa3ccf42e5..6570d9df97 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
@@ -43,7 +43,7 @@ public abstract class Scrollable extends Control {
* The regular expression used to determine the string which should be deleted
* when Ctrl+Bs is hit.
*/
- static final java.util.regex.Pattern CTRL_BS_PATTERN =
+ static final java.util.regex.Pattern CTRL_BS_PATTERN =
java.util.regex.Pattern.compile ("\\r?\\n\\z|[\\p{Punct}]+[\\t ]*\\z|[^\\p{Punct}\\s\\n\\r]*[\\t ]*\\z");
/**
@@ -86,7 +86,7 @@ public Scrollable (Composite parent, int style) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
return OS.DefWindowProc (hwnd, msg, wParam, lParam);
}
@@ -128,7 +128,7 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
}
Rectangle computeTrimInPixels (int x, int y, int width, int height) {
- long /*int*/ scrolledHandle = scrolledHandle ();
+ long scrolledHandle = scrolledHandle ();
RECT rect = new RECT ();
OS.SetRect (rect, x, y, x + width, y + height);
int bits1 = OS.GetWindowLong (scrolledHandle, OS.GWL_STYLE);
@@ -140,6 +140,12 @@ Rectangle computeTrimInPixels (int x, int y, int width, int height) {
return new Rectangle (rect.left, rect.top, nWidth, nHeight);
}
+@Override
+void createHandle () {
+ super.createHandle();
+ maybeEnableDarkSystemTheme();
+}
+
ScrollBar createScrollBar (int type) {
ScrollBar bar = new ScrollBar (this, type);
if ((state & CANVAS) != 0) {
@@ -177,7 +183,7 @@ int applyThemeBackground () {
}
void destroyScrollBar (int type) {
- long /*int*/ hwnd = scrolledHandle ();
+ long hwnd = scrolledHandle ();
int bits = OS.GetWindowLong (hwnd, OS.GWL_STYLE);
if ((type & SWT.HORIZONTAL) != 0) {
style &= ~SWT.H_SCROLL;
@@ -212,7 +218,7 @@ public Rectangle getClientArea () {
Rectangle getClientAreaInPixels () {
forceResize ();
RECT rect = new RECT ();
- long /*int*/ scrolledHandle = scrolledHandle ();
+ long scrolledHandle = scrolledHandle ();
OS.GetClientRect (scrolledHandle, rect);
int x = rect.left, y = rect.top;
int width = rect.right - rect.left;
@@ -306,26 +312,11 @@ void reskinChildren (int flags) {
super.reskinChildren (flags);
}
-long /*int*/ scrolledHandle () {
+long scrolledHandle () {
return handle;
}
@Override
-int widgetExtStyle () {
- return super.widgetExtStyle ();
- /*
- * This code is intentionally commented. In future,
- * we may wish to support different standard Windows
- * edge styles. The issue here is that not all of
- * these styles are available on the other platforms
- * this would need to be a hint.
- */
-// if ((style & SWT.BORDER) != 0) return OS.WS_EX_CLIENTEDGE;
-// if ((style & SWT.SHADOW_IN) != 0) return OS.WS_EX_STATICEDGE;
-// return super.widgetExtStyle ();
-}
-
-@Override
int widgetStyle () {
int bits = super.widgetStyle () | OS.WS_TABSTOP;
if ((style & SWT.H_SCROLL) != 0) bits |= OS.WS_HSCROLL;
@@ -339,12 +330,12 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return display.windowProc;
}
@Override
-LRESULT WM_HSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_HSCROLL (long wParam, long lParam) {
LRESULT result = super.WM_HSCROLL (wParam, lParam);
if (result != null) return result;
if (horizontalBar != null && lParam == 0) {
@@ -354,13 +345,18 @@ LRESULT WM_HSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_MOUSEWHEEL (long /*int*/ wParam, long /*int*/ lParam) {
- return wmScrollWheel ((state & CANVAS) != 0, wParam, lParam);
+LRESULT WM_MOUSEWHEEL (long wParam, long lParam) {
+ return wmScrollWheel ((state & CANVAS) != 0, wParam, lParam, false);
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
- long /*int*/ code = callWindowProc (handle, OS.WM_SIZE, wParam, lParam);
+LRESULT WM_MOUSEHWHEEL (long wParam, long lParam) {
+ return wmScrollWheel ((state & CANVAS) != 0, -1 * wParam, lParam, true);
+}
+
+@Override
+LRESULT WM_SIZE (long wParam, long lParam) {
+ long code = callWindowProc (handle, OS.WM_SIZE, wParam, lParam);
super.WM_SIZE (wParam, lParam);
// widget may be disposed at this point
if (code == 0) return LRESULT.ZERO;
@@ -368,7 +364,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_VSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_VSCROLL (long wParam, long lParam) {
LRESULT result = super.WM_VSCROLL (wParam, lParam);
if (result != null) return result;
if (verticalBar != null && lParam == 0) {
@@ -377,31 +373,42 @@ LRESULT WM_VSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
return result;
}
-LRESULT wmScrollWheel (boolean update, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmScrollWheel (boolean update, long wParam, long lParam, boolean horzWheel) {
LRESULT result = super.WM_MOUSEWHEEL (wParam, lParam);
if (result != null) return result;
/*
- * Translate WM_MOUSEWHEEL to WM_VSCROLL or WM_HSCROLL.
+ * Translate WM_MOUSEWHEEL and WM_MOUSEHWHEEL to WM_VSCROLL or WM_HSCROLL.
*/
if (update) {
- if ((wParam & (OS.MK_SHIFT | OS.MK_CONTROL)) != 0) return result;
- boolean vertical = verticalBar != null && verticalBar.getEnabled ();
- boolean horizontal = horizontalBar != null && horizontalBar.getEnabled ();
- int msg = vertical ? OS.WM_VSCROLL : horizontal ? OS.WM_HSCROLL : 0;
- if (msg == 0) return result;
- int [] linesToScroll = new int [1];
- OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, linesToScroll, 0);
- int delta = OS.GET_WHEEL_DELTA_WPARAM (wParam);
- boolean pageScroll = linesToScroll [0] == OS.WHEEL_PAGESCROLL;
+ if ((wParam & OS.MK_CONTROL) != 0) {
+ return null;
+ }
+ if ((wParam & OS.MK_SHIFT) != 0) {
+ horzWheel = !horzWheel;
+ }
+
+ boolean vertical;
+ if (verticalBar != null && verticalBar.getEnabled () && !horzWheel) {
+ vertical = true;
+ } else if (horizontalBar != null && horizontalBar.getEnabled () && horzWheel) {
+ vertical = false;
+ } else {
+ return null;
+ }
+
ScrollBar bar = vertical ? verticalBar : horizontalBar;
+ MouseWheelData wheelData = new MouseWheelData(vertical, bar, wParam, display.scrollRemainderBar);
+
+ if (wheelData.count == 0) return null;
+
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
info.fMask = OS.SIF_POS;
OS.GetScrollInfo (handle, bar.scrollBarType (), info);
- if (vertical && !pageScroll) delta *= linesToScroll [0];
- int increment = pageScroll ? bar.getPageIncrement () : bar.getIncrement ();
- info.nPos -= increment * delta / OS.WHEEL_DELTA;
+ info.nPos -= wheelData.count;
OS.SetScrollInfo (handle, bar.scrollBarType (), info, true);
+
+ int msg = vertical ? OS.WM_VSCROLL : OS.WM_HSCROLL;
OS.SendMessage (handle, msg, OS.SB_THUMBPOSITION, 0);
return LRESULT.ZERO;
}
@@ -419,7 +426,7 @@ LRESULT wmScrollWheel (boolean update, long /*int*/ wParam, long /*int*/ lParam)
*/
int vPosition = verticalBar == null ? 0 : verticalBar.getSelection ();
int hPosition = horizontalBar == null ? 0 : horizontalBar.getSelection ();
- long /*int*/ code = callWindowProc (handle, OS.WM_MOUSEWHEEL, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_MOUSEWHEEL, wParam, lParam);
if (verticalBar != null) {
int position = verticalBar.getSelection ();
if (position != vPosition) {
@@ -439,7 +446,7 @@ LRESULT wmScrollWheel (boolean update, long /*int*/ wParam, long /*int*/ lParam)
return new LRESULT (code);
}
-LRESULT wmScroll (ScrollBar bar, boolean update, long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmScroll (ScrollBar bar, boolean update, long hwnd, int msg, long wParam, long lParam) {
LRESULT result = null;
if (update) {
int type = msg == OS.WM_HSCROLL ? OS.SB_HORZ : OS.SB_VERT;
@@ -478,7 +485,7 @@ LRESULT wmScroll (ScrollBar bar, boolean update, long /*int*/ hwnd, int msg, lon
}
OS.SetScrollInfo (hwnd, type, info, true);
} else {
- long /*int*/ code = callWindowProc (hwnd, msg, wParam, lParam);
+ long code = callWindowProc (hwnd, msg, wParam, lParam);
result = code == 0 ? LRESULT.ZERO : new LRESULT (code);
}
bar.wmScrollChild (wParam, lParam);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
index 4d5c2d3294..8be1e4314e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -123,16 +123,16 @@ import org.eclipse.swt.internal.win32.*;
public class Shell extends Decorations {
Menu activeMenu;
ToolTip [] toolTips;
- long /*int*/ hIMC, hwndMDIClient, lpstrTip, toolTipHandle, balloonTipHandle, menuItemToolTipHandle;
- int minWidth = SWT.DEFAULT, minHeight = SWT.DEFAULT;
- long /*int*/ [] brushes;
+ long hwndMDIClient, lpstrTip, toolTipHandle, balloonTipHandle, menuItemToolTipHandle;
+ int minWidth = SWT.DEFAULT, minHeight = SWT.DEFAULT, maxWidth = SWT.DEFAULT, maxHeight = SWT.DEFAULT;
+ long [] brushes;
boolean showWithParent, fullScreen, wasMaximized, modified, center;
String toolTitle, balloonTitle;
- long /*int*/ toolIcon, balloonIcon;
- long /*int*/ windowProc;
+ long toolIcon, balloonIcon;
+ long windowProc;
Control lastActive;
- static /*final*/ long /*int*/ ToolTipProc;
- static final long /*int*/ DialogProc;
+ static /*final*/ long ToolTipProc;
+ static final long DialogProc;
static final TCHAR DialogClass = new TCHAR (0, "#32770", true);
final static int [] SYSTEM_COLORS = {
OS.COLOR_BTNFACE,
@@ -279,7 +279,7 @@ public Shell (Display display, int style) {
this (display, null, style, 0, false);
}
-Shell (Display display, Shell parent, int style, long /*int*/ handle, boolean embedded) {
+Shell (Display display, Shell parent, int style, long handle, boolean embedded) {
super ();
checkSubclass ();
if (display == null) display = Display.getCurrent ();
@@ -398,7 +398,7 @@ public Shell (Shell parent, int style) {
*
* @noreference This method is not intended to be referenced by clients.
*/
-public static Shell win32_new (Display display, long /*int*/ handle) {
+public static Shell win32_new (Display display, long handle) {
return new Shell (display, null, SWT.NO_TRIM, handle, true);
}
@@ -421,7 +421,7 @@ public static Shell win32_new (Display display, long /*int*/ handle) {
*
* @since 3.3
*/
-public static Shell internal_new (Display display, long /*int*/ handle) {
+public static Shell internal_new (Display display, long handle) {
return new Shell (display, null, SWT.NO_TRIM, handle, false);
}
@@ -473,13 +473,13 @@ public void addShellListener (ShellListener listener) {
addListener (SWT.Deactivate, typedListener);
}
-long /*int*/ balloonTipHandle () {
+long balloonTipHandle () {
if (balloonTipHandle == 0) createBalloonTipHandle ();
return balloonTipHandle;
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
if (hwnd == toolTipHandle || hwnd == balloonTipHandle || hwnd == menuItemToolTipHandle) {
return OS.CallWindowProc (ToolTipProc, hwnd, msg, wParam, lParam);
@@ -575,6 +575,24 @@ void createBalloonTipHandle () {
OS.SetWindowLongPtr (balloonTipHandle, OS.GWLP_WNDPROC, display.windowProc);
}
+void setTitleColoring() {
+ int attributeID = 0;
+ if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN10_2004) {
+ // Documented since build 20348, but was already present since build 19041
+ final int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
+ attributeID = DWMWA_USE_IMMERSIVE_DARK_MODE;
+ } else if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN10_1809) {
+ // Undocumented value
+ attributeID = 19;
+ } else {
+ // Not supported
+ return;
+ }
+
+ int[] value = new int[] {1};
+ OS.DwmSetWindowAttribute (handle, attributeID, value, 4);
+}
+
@Override
void createHandle () {
boolean embedded = handle != 0 && (state & FOREIGN_HANDLE) == 0;
@@ -607,6 +625,10 @@ void createHandle () {
// if ((style & SWT.ON_TOP) != 0) display.lockActiveWindow = false;
if (!embedded) {
+ if (display.useShellTitleColoring) {
+ setTitleColoring();
+ }
+
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
bits &= ~(OS.WS_OVERLAPPED | OS.WS_CAPTION);
bits |= OS.WS_POPUP;
@@ -625,10 +647,6 @@ void createHandle () {
int flags = OS.SWP_DRAWFRAME | OS.SWP_NOMOVE | OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE;
OS.SetWindowPos (handle, 0, 0, 0, 0, 0, flags);
}
- if (OS.IsDBLocale) {
- hIMC = OS.ImmCreateContext ();
- if (hIMC != 0) OS.ImmAssociateContext (handle, hIMC);
- }
}
void createMenuItemToolTipHandle() {
@@ -659,8 +677,8 @@ void createToolTipHandle () {
toolTipHandle = createToolTipHandle (handle);
}
-long /*int*/ createToolTipHandle (long /*int*/ parent) {
- long /*int*/ toolTipHandle = OS.CreateWindowEx (
+long createToolTipHandle (long parent) {
+ long toolTipHandle = OS.CreateWindowEx (
0,
new TCHAR (0, OS.TOOLTIPS_CLASS, true),
null,
@@ -712,36 +730,6 @@ void destroyToolTip (ToolTip toolTip) {
void destroyWidget () {
fixActiveShell ();
super.destroyWidget ();
-
- /*
- * Destroy context only after the controls that used it were destroyed.
- * Technically, that shouldn't be necessary, because 'Control.releaseWidget'
- * clears up association by calling 'OS.ImmAssociateContext (handle, 0)'.
- * However, there's a bug in Windows 10 (see bug 526758), and this is the workaround.
- */
- if (OS.IsDBLocale) {
- if (hIMC != 0) OS.ImmDestroyContext (hIMC);
- }
-}
-
-@Override
-public void dispose () {
- /*
- * This code is intentionally commented. On some
- * platforms, the owner window is repainted right
- * away when a dialog window exits. This behavior
- * is currently unspecified.
- */
-// /*
-// * Note: It is valid to attempt to dispose a widget
-// * more than once. If this happens, fail silently.
-// */
-// if (!isValidWidget ()) return;
-// if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
-// Display oldDisplay = display;
- super.dispose ();
- // widget is disposed at this point
-// if (oldDisplay != null) oldDisplay.update ();
}
@Override
@@ -759,18 +747,17 @@ void enableWidget (boolean enabled) {
}
@Override
-long /*int*/ findBrush (long /*int*/ value, int lbStyle) {
+long findBrush (long value, int lbStyle) {
if (lbStyle == OS.BS_SOLID) {
- for (int i=0; i<SYSTEM_COLORS.length; i++) {
- if (value == OS.GetSysColor (SYSTEM_COLORS [i])) {
- return OS.GetSysColorBrush (SYSTEM_COLORS [i]);
+ for (int element : SYSTEM_COLORS) {
+ if (value == OS.GetSysColor (element)) {
+ return OS.GetSysColorBrush (element);
}
}
}
- if (brushes == null) brushes = new long /*int*/ [BRUSHES_SIZE];
+ if (brushes == null) brushes = new long [BRUSHES_SIZE];
LOGBRUSH logBrush = new LOGBRUSH ();
- for (int i=0; i<brushes.length; i++) {
- long /*int*/ hBrush = brushes [i];
+ for (long hBrush : brushes) {
if (hBrush == 0) break;
OS.GetObject (hBrush, LOGBRUSH.sizeof, logBrush);
switch (logBrush.lbStyle) {
@@ -787,12 +774,12 @@ long /*int*/ findBrush (long /*int*/ value, int lbStyle) {
}
}
int length = brushes.length;
- long /*int*/ hBrush = brushes [--length];
+ long hBrush = brushes [--length];
if (hBrush != 0) OS.DeleteObject (hBrush);
System.arraycopy (brushes, 0, brushes, 1, length);
switch (lbStyle) {
case OS.BS_SOLID:
- hBrush = OS.CreateSolidBrush ((int)/*64*/value);
+ hBrush = OS.CreateSolidBrush ((int)value);
break;
case OS.BS_PATTERN:
hBrush = OS.CreatePatternBrush (value);
@@ -832,7 +819,7 @@ void fixActiveShell () {
* application). The fix is to activate the disabled parent
* shell before disposing or hiding the active shell.
*/
- long /*int*/ hwndParent = OS.GetParent (handle);
+ long hwndParent = OS.GetParent (handle);
if (hwndParent != 0 && handle == OS.GetActiveWindow ()) {
if (!OS.IsWindowEnabled (hwndParent) && OS.IsWindowVisible (hwndParent)) {
OS.SetActiveWindow (hwndParent);
@@ -960,13 +947,13 @@ ToolTip getCurrentToolTip () {
return null;
}
-ToolTip getCurrentToolTip (long /*int*/ hwndToolTip) {
+ToolTip getCurrentToolTip (long hwndToolTip) {
if (hwndToolTip == 0) return null;
if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, 0) != 0) {
TOOLINFO lpti = new TOOLINFO ();
lpti.cbSize = TOOLINFO.sizeof;
if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, lpti) != 0) {
- if ((lpti.uFlags & OS.TTF_IDISHWND) == 0) return findToolTip ((int)/*64*/lpti.uId);
+ if ((lpti.uFlags & OS.TTF_IDISHWND) == 0) return findToolTip ((int)lpti.uId);
}
}
return null;
@@ -1017,7 +1004,7 @@ public boolean getFullScreen () {
public int getImeInputMode () {
checkWidget ();
if (!OS.IsDBLocale) return 0;
- long /*int*/ hIMC = OS.ImmGetContext (handle);
+ long hIMC = OS.ImmGetContext (handle);
int [] lpfdwConversion = new int [1], lpfdwSentence = new int [1];
boolean open = OS.ImmGetOpenStatus (hIMC);
if (open) open = OS.ImmGetConversionStatus (hIMC, lpfdwConversion, lpfdwSentence);
@@ -1045,6 +1032,47 @@ public boolean getMaximized () {
}
/**
+ * Returns a point describing the maximum receiver's size. The
+ * x coordinate of the result is the maximum width of the receiver.
+ * The y coordinate of the result is the maximum height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.116
+ */
+public Point getMaximumSize () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown(getMaximumSizeInPixels());
+}
+
+Point getMaximumSizeInPixels () {
+ int width = Math.min (Integer.MAX_VALUE, maxWidth);
+ int trim = SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.MAX;
+ if ((style & SWT.NO_TRIM) == 0 && (style & trim) != 0) {
+ width = Math.min (width, OS.GetSystemMetrics (OS.SM_CXMAXTRACK));
+ }
+ int height = Math.min (Integer.MAX_VALUE, maxHeight);
+ if ((style & SWT.NO_TRIM) == 0 && (style & trim) != 0) {
+ if ((style & SWT.RESIZE) != 0) {
+ height = Math.min (height, OS.GetSystemMetrics (OS.SM_CYMAXTRACK));
+ } else {
+ RECT rect = new RECT ();
+ int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
+ OS.AdjustWindowRectEx (rect, bits1, false, bits2);
+ height = Math.min (height, rect.bottom - rect.top);
+ }
+ }
+ return new Point (width, height);
+}
+
+/**
* Returns a point describing the minimum receiver's size. The
* x coordinate of the result is the minimum width of the receiver.
* The y coordinate of the result is the minimum height of the
@@ -1153,22 +1181,22 @@ public Shell [] getShells () {
checkWidget ();
int count = 0;
Shell [] shells = display.getShells ();
- for (int i=0; i<shells.length; i++) {
- Control shell = shells [i];
+ for (Shell activeshell : shells) {
+ Control shell = activeshell;
do {
- shell = shell.parent;
+ shell = shell.getParent ();
} while (shell != null && shell != this);
if (shell == this) count++;
}
int index = 0;
Shell [] result = new Shell [count];
- for (int i=0; i<shells.length; i++) {
- Control shell = shells [i];
+ for (Shell activeshell : shells) {
+ Control shell = activeshell;
do {
- shell = shell.parent;
+ shell = shell.getParent ();
} while (shell != null && shell != this);
if (shell == this) {
- result [index++] = shells [i];
+ result [index++] = activeshell;
}
}
return result;
@@ -1212,7 +1240,7 @@ public boolean isVisible () {
return getVisible ();
}
-long /*int*/ hwndMDIClient () {
+long hwndMDIClient () {
if (hwndMDIClient == 0) {
int widgetStyle = OS.MDIS_ALLCHILDSTYLES | OS.WS_CHILD | OS.WS_CLIPCHILDREN | OS.WS_CLIPSIBLINGS;
hwndMDIClient = OS.CreateWindowEx (
@@ -1230,7 +1258,7 @@ long /*int*/ hwndMDIClient () {
return hwndMDIClient;
}
-long /*int*/ menuItemToolTipHandle () {
+long menuItemToolTipHandle () {
if (menuItemToolTipHandle == 0) createMenuItemToolTipHandle ();
return menuItemToolTipHandle;
}
@@ -1325,8 +1353,8 @@ void register () {
void releaseBrushes () {
if (brushes != null) {
- for (int i=0; i<brushes.length; i++) {
- if (brushes [i] != 0) OS.DeleteObject (brushes [i]);
+ for (long brush : brushes) {
+ if (brush != 0) OS.DeleteObject (brush);
}
}
brushes = null;
@@ -1334,16 +1362,13 @@ void releaseBrushes () {
@Override
void releaseChildren (boolean destroy) {
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
+ for (Shell shell : getShells ()) {
if (shell != null && !shell.isDisposed ()) {
shell.release (false);
}
}
if (toolTips != null) {
- for (int i=0; i<toolTips.length; i++) {
- ToolTip toolTip = toolTips [i];
+ for (ToolTip toolTip : toolTips) {
if (toolTip != null && !toolTip.isDisposed ()) {
toolTip.release (false);
}
@@ -1371,7 +1396,7 @@ void releaseWidget () {
activeMenu = null;
display.clearModal (this);
if (lpstrTip != 0) {
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
OS.HeapFree (hHeap, 0, lpstrTip);
}
lpstrTip = 0;
@@ -1421,36 +1446,19 @@ public void requestLayout () {
@Override
void reskinChildren (int flags) {
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
+ for (Shell shell : getShells ()) {
if (shell != null) shell.reskin (flags);
}
if (toolTips != null) {
- for (int i=0; i<toolTips.length; i++) {
- ToolTip toolTip = toolTips [i];
+ for (ToolTip toolTip : toolTips) {
if (toolTip != null) toolTip.reskin (flags);
}
}
super.reskinChildren (flags);
}
-LRESULT selectPalette (long /*int*/ hPalette) {
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ hOld = OS.SelectPalette (hDC, hPalette, false);
- int result = OS.RealizePalette (hDC);
- if (result > 0) {
- OS.InvalidateRect (handle, null, true);
- } else {
- OS.SelectPalette (hDC, hOld, true);
- OS.RealizePalette (hDC);
- }
- OS.ReleaseDC (handle, hDC);
- return (result > 0) ? LRESULT.ONE : LRESULT.ZERO;
-}
-
@Override
-boolean sendKeyEvent (int type, int msg, long /*int*/ wParam, long /*int*/ lParam, Event event) {
+boolean sendKeyEvent (int type, int msg, long wParam, long lParam, Event event) {
if (!isEnabled () || !isActive ()) return false;
return super.sendKeyEvent (type, msg, wParam, lParam, event);
}
@@ -1594,8 +1602,9 @@ public void setEnabled (boolean enabled) {
* to either the maximized or normal states.
* <p>
* Note: The result of intermixing calls to <code>setFullScreen(true)</code>,
- * <code>setMaximized(true)</code> and <code>setMinimized(true)</code> will
- * vary by platform. Typically, the behavior will match the platform user's
+ * <code>setMaximized(true)</code>, <code>setMinimized(true)</code> and
+ * <code>setMaximumSize</code> will vary by platform.
+ * Typically, the behavior will match the platform user's
* expectations, but not always. This should be avoided if possible.
* </p>
*
@@ -1626,6 +1635,9 @@ public void setFullScreen (boolean fullScreen) {
}
if (fullScreen) wasMaximized = getMaximized ();
boolean visible = isVisible ();
+ if (!visible && !wasMaximized) {
+ swFlags = stateFlags;
+ }
OS.SetWindowLong (handle, OS.GWL_STYLE, styleFlags);
if (wasMaximized) {
OS.ShowWindow (handle, OS.SW_HIDE);
@@ -1656,7 +1668,7 @@ public void setImeInputMode (int mode) {
checkWidget ();
if (!OS.IsDBLocale) return;
boolean imeOn = mode != SWT.NONE;
- long /*int*/ hIMC = OS.ImmGetContext (handle);
+ long hIMC = OS.ImmGetContext (handle);
OS.ImmSetOpenStatus (hIMC, imeOn);
if (imeOn) {
int [] lpfdwConversion = new int [1], lpfdwSentence = new int [1];
@@ -1674,7 +1686,7 @@ public void setImeInputMode (int mode) {
}
boolean fullShape = (mode & SWT.DBCS) != 0;
if ((mode & SWT.NATIVE) != 0) {
- long /*int*/ hkl = OS.GetKeyboardLayout (0);
+ long hkl = OS.GetKeyboardLayout (0);
int langid = OS.PRIMARYLANGID (OS.LOWORD (hkl));
if (langid == OS.LANG_JAPANESE) {
fullShape = true;
@@ -1699,6 +1711,85 @@ public void setImeInputMode (int mode) {
}
/**
+ * Sets the receiver's maximum size to the size specified by the arguments.
+ * If the new maximum size is smaller than the current size of the receiver,
+ * the receiver is resized to the new maximum size.
+ * <p>
+ * Note: The result of intermixing calls to <code>setMaximumSize</code> and
+ * <code>setFullScreen(true)</code> will vary by platform.
+ * Typically, the behavior will match the platform user's
+ * expectations, but not always. This should be avoided if possible.
+ * </p>
+ * @param width the new maximum width for the receiver
+ * @param height the new maximum height for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.116
+ */
+public void setMaximumSize (int width, int height) {
+ checkWidget ();
+ setMaximumSizeInPixels(DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+}
+
+/**
+ * Sets the receiver's maximum size to the size specified by the argument.
+ * If the new maximum size is smaller than the current size of the receiver,
+ * the receiver is resized to the new maximum size.
+ * <p>
+ * Note: The result of intermixing calls to <code>setMaximumSize</code> and
+ * <code>setFullScreen(true)</code> will vary by platform.
+ * Typically, the behavior will match the platform user's
+ * expectations, but not always. This should be avoided if possible.
+ * </p>
+ * @param size the new maximum size for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.116
+ */
+public void setMaximumSize (Point size) {
+ checkWidget ();
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ size = DPIUtil.autoScaleUp(size);
+ setMaximumSizeInPixels(size.x, size.y);
+}
+
+void setMaximumSizeInPixels (int width, int height) {
+ int widthLimit = 0, heightLimit = 0;
+ int trim = SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.MAX;
+ if ((style & SWT.NO_TRIM) == 0 && (style & trim) != 0) {
+ widthLimit = OS.GetSystemMetrics (OS.SM_CXMAXTRACK);
+ if ((style & SWT.RESIZE) != 0) {
+ heightLimit = OS.GetSystemMetrics (OS.SM_CYMAXTRACK);
+ } else {
+ RECT rect = new RECT ();
+ int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
+ OS.AdjustWindowRectEx (rect, bits1, false, bits2);
+ heightLimit = rect.bottom - rect.top;
+ }
+ }
+ maxWidth = Math.min (widthLimit, width);
+ maxHeight = Math.min (heightLimit, height);
+ Point size = getSizeInPixels ();
+ int newWidth = Math.min (size.x, maxWidth);
+ int newHeight = Math.min (size.y, maxHeight);
+ if (maxWidth >= widthLimit) maxWidth = SWT.DEFAULT;
+ if (maxHeight >= heightLimit) maxHeight = SWT.DEFAULT;
+ if (newWidth != size.x || newHeight != size.y) setSizeInPixels (newWidth, newHeight);
+}
+
+/**
* Sets the receiver's minimum size to the size specified by the arguments.
* If the new minimum size is larger than the current size of the receiver,
* the receiver is resized to the new minimum size.
@@ -1785,7 +1876,7 @@ public void setModified (boolean modified) {
}
void setItemEnabled (int cmd, boolean enabled) {
- long /*int*/ hMenu = OS.GetSystemMenu (handle, false);
+ long hMenu = OS.GetSystemMenu (handle, false);
if (hMenu == 0) return;
int flags = OS.MF_ENABLED;
if (!enabled) flags = OS.MF_DISABLED | OS.MF_GRAYED;
@@ -1832,21 +1923,22 @@ public void setRegion (Region region) {
super.setRegion (region);
}
-void setToolTipText (long /*int*/ hwnd, String text) {
+void setToolTipText (long hwnd, String text) {
TOOLINFO lpti = new TOOLINFO ();
lpti.cbSize = TOOLINFO.sizeof;
lpti.hwnd = handle;
lpti.uId = hwnd;
- long /*int*/ hwndToolTip = toolTipHandle ();
+ long hwndToolTip = toolTipHandle ();
+ maybeEnableDarkSystemTheme(hwndToolTip);
if (text == null) {
OS.SendMessage (hwndToolTip, OS.TTM_DELTOOL, 0, lpti);
- } else {
- if (OS.SendMessage (hwndToolTip, OS.TTM_GETTOOLINFO, 0, lpti) != 0) {
+ } else if (OS.SendMessage (hwndToolTip, OS.TTM_GETTOOLINFO, 0, lpti) == 0) {
+ lpti.uFlags = OS.TTF_IDISHWND | OS.TTF_SUBCLASS;
+ lpti.lpszText = OS.LPSTR_TEXTCALLBACK;
+ OS.SendMessage (hwndToolTip, OS.TTM_ADDTOOL, 0, lpti);
+ } else if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, lpti) != 0) {
+ if (lpti.uId == hwnd) {
OS.SendMessage (hwndToolTip, OS.TTM_UPDATE, 0, 0);
- } else {
- lpti.uFlags = OS.TTF_IDISHWND | OS.TTF_SUBCLASS;
- lpti.lpszText = OS.LPSTR_TEXTCALLBACK;
- OS.SendMessage (hwndToolTip, OS.TTM_ADDTOOL, 0, lpti);
}
}
}
@@ -1859,7 +1951,7 @@ void setToolTipText (NMTTDISPINFO lpnmtdi, char [] buffer) {
* shell trimmings.
*/
if (!hasCursor ()) return;
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
if (lpstrTip != 0) OS.HeapFree (hHeap, 0, lpstrTip);
int byteCount = buffer.length * 2;
lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
@@ -1867,7 +1959,7 @@ void setToolTipText (NMTTDISPINFO lpnmtdi, char [] buffer) {
lpnmtdi.lpszText = lpstrTip;
}
-void setToolTipTitle (long /*int*/ hwndToolTip, String text, int icon) {
+void setToolTipTitle (long hwndToolTip, String text, int icon) {
/*
* Bug in Windows. For some reason, when TTM_SETTITLE
* is used to set the title of a tool tip, Windows leaks
@@ -1940,7 +2032,7 @@ public void setVisible (boolean visible) {
bringToTop ();
if (isDisposed ()) return;
}
- long /*int*/ hwndShell = OS.GetActiveWindow ();
+ long hwndShell = OS.GetActiveWindow ();
if (hwndShell == 0) {
if (parent != null) hwndShell = parent.handle;
}
@@ -1981,7 +2073,7 @@ public void setVisible (boolean visible) {
/* Make the foreign window parent appear in the task bar */
if (visible) {
if (parent != null && (parent.state & FOREIGN_HANDLE) != 0) {
- long /*int*/ hwndParent = parent.handle;
+ long hwndParent = parent.handle;
int style = OS.GetWindowLong (hwndParent, OS.GWL_EXSTYLE);
if ((style & OS.WS_EX_TOOLWINDOW) != 0) {
OS.SetWindowLong (hwndParent, OS.GWL_EXSTYLE, style & ~OS.WS_EX_TOOLWINDOW);
@@ -2001,7 +2093,7 @@ public void setVisible (boolean visible) {
void subclass () {
super.subclass ();
if (ToolTipProc != 0) {
- long /*int*/ newProc = display.windowProc;
+ long newProc = display.windowProc;
if (toolTipHandle != 0) {
OS.SetWindowLongPtr (toolTipHandle, OS.GWLP_WNDPROC, newProc);
}
@@ -2014,7 +2106,7 @@ void subclass () {
}
}
-long /*int*/ toolTipHandle () {
+long toolTipHandle () {
if (toolTipHandle == 0) createToolTipHandle ();
return toolTipHandle;
}
@@ -2064,7 +2156,7 @@ CREATESTRUCT widgetCreateStruct () {
}
@Override
-long /*int*/ widgetParent () {
+long widgetParent () {
if (handle != 0) return handle;
return parent != null ? parent.handle : 0;
}
@@ -2103,7 +2195,7 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
if (windowProc != 0) return windowProc;
if ((style & SWT.TOOL) != 0) {
int trim = SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.MAX | SWT.BORDER | SWT.RESIZE;
@@ -2112,8 +2204,39 @@ long /*int*/ windowProc () {
return parent != null ? DialogProc : super.windowProc ();
}
+Rectangle getClientRectInWindow () {
+ RECT windowRect = new RECT ();
+ OS.GetWindowRect (handle, windowRect);
+
+ POINT clientWindowLT = new POINT ();
+ OS.ClientToScreen (handle, clientWindowLT);
+ clientWindowLT.x -= windowRect.left;
+ clientWindowLT.y -= windowRect.top;
+
+ RECT clientRect = new RECT ();
+ OS.GetClientRect (handle, clientRect);
+
+ return new Rectangle(
+ clientWindowLT.x + clientRect.left,
+ clientWindowLT.y + clientRect.top,
+ clientRect.right - clientRect.left,
+ clientRect.bottom - clientRect.top);
+}
+
+void overpaintMenuBorder () {
+ if ((menuBar == null) || (display.menuBarBorderPen == 0)) return;
+
+ Rectangle clientArea = getClientRectInWindow();
+ long dc = OS.GetWindowDC (handle);
+ long oldPen = OS.SelectObject (dc, display.menuBarBorderPen);
+ OS.MoveToEx (dc, clientArea.x, clientArea.y - 1, 0);
+ OS.LineTo (dc, clientArea.x + clientArea.width, clientArea.y - 1);
+ OS.SelectObject (dc, oldPen);
+ OS.ReleaseDC (handle, dc);
+}
+
@Override
-long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long windowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
if((style & SWT.NO_MOVE) != 0 && msg == OS.WM_NCLBUTTONDOWN && wParam == OS.HTCAPTION) return 0;
if (hwnd == toolTipHandle || hwnd == balloonTipHandle || hwnd == menuItemToolTipHandle) {
@@ -2138,7 +2261,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
return callWindowProc (hwnd, msg, wParam, lParam);
}
if (hwnd == handle) {
- if ((int)/*64*/msg == Display.TASKBARBUTTONCREATED) {
+ if (msg == Display.TASKBARBUTTONCREATED) {
if (display.taskBar != null) {
for (TaskItem item : display.taskBar.items) {
if (item != null && item.shell == this) {
@@ -2149,6 +2272,17 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
}
}
}
+
+ switch (msg) {
+ case OS.WM_NCACTIVATE:
+ case OS.WM_NCPAINT:
+ {
+ long ret = super.windowProc (hwnd, msg, wParam, lParam);
+ overpaintMenuBorder();
+ return ret;
+ }
+ }
+
return super.windowProc (hwnd, msg, wParam, lParam);
}
@@ -2175,19 +2309,7 @@ int widgetStyle () {
}
@Override
-LRESULT WM_ACTIVATE (long /*int*/ wParam, long /*int*/ lParam) {
- /*
- * Bug in Windows XP. When a Shell is deactivated, the
- * IME composition window does not go away. This causes
- * repaint issues. The fix is to commit the composition
- * string.
- */
- if (OS.LOWORD (wParam) == 0 && OS.IsDBLocale && hIMC != 0) {
- if (OS.ImmGetOpenStatus (hIMC)) {
- OS.ImmNotifyIME (hIMC, OS.NI_COMPOSITIONSTR, OS.CPS_COMPLETE, 0);
- }
- }
-
+LRESULT WM_ACTIVATE (long wParam, long lParam) {
/* Process WM_ACTIVATE */
LRESULT result = super.WM_ACTIVATE (wParam, lParam);
if (OS.LOWORD (wParam) == 0) {
@@ -2201,7 +2323,7 @@ LRESULT WM_ACTIVATE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_DESTROY (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_DESTROY (long wParam, long lParam) {
LRESULT result = super.WM_DESTROY (wParam, lParam);
/*
* When the shell is a WS_CHILD window of a non-SWT
@@ -2218,7 +2340,7 @@ LRESULT WM_DESTROY (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ERASEBKGND (long wParam, long lParam) {
LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
if (result != null) return result;
/*
@@ -2237,7 +2359,7 @@ LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_ENTERIDLE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ENTERIDLE (long wParam, long lParam) {
LRESULT result = super.WM_ENTERIDLE (wParam, lParam);
if (result != null) return result;
Display display = this.display;
@@ -2246,14 +2368,17 @@ LRESULT WM_ENTERIDLE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_GETMINMAXINFO (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETMINMAXINFO (long wParam, long lParam) {
LRESULT result = super.WM_GETMINMAXINFO (wParam, lParam);
if (result != null) return result;
- if (minWidth != SWT.DEFAULT || minHeight != SWT.DEFAULT) {
+ if (minWidth != SWT.DEFAULT || minHeight != SWT.DEFAULT
+ || maxWidth != SWT.DEFAULT || maxHeight != SWT.DEFAULT) {
MINMAXINFO info = new MINMAXINFO ();
OS.MoveMemory (info, lParam, MINMAXINFO.sizeof);
if (minWidth != SWT.DEFAULT) info.ptMinTrackSize_x = minWidth;
if (minHeight != SWT.DEFAULT) info.ptMinTrackSize_y = minHeight;
+ if (maxWidth != SWT.DEFAULT) info.ptMaxTrackSize_x = maxWidth;
+ if (maxHeight != SWT.DEFAULT) info.ptMaxTrackSize_y = maxHeight;
OS.MoveMemory (lParam, info, MINMAXINFO.sizeof);
return LRESULT.ZERO;
}
@@ -2261,7 +2386,7 @@ LRESULT WM_GETMINMAXINFO (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_MOUSEACTIVATE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSEACTIVATE (long wParam, long lParam) {
LRESULT result = super.WM_MOUSEACTIVATE (wParam, lParam);
if (result != null) return result;
@@ -2312,7 +2437,7 @@ LRESULT WM_MOUSEACTIVATE (long /*int*/ wParam, long /*int*/ lParam) {
int pos = OS.GetMessagePos ();
OS.POINTSTOPOINT (pt, pos);
}
- long /*int*/ hwnd = OS.WindowFromPoint (pt);
+ long hwnd = OS.WindowFromPoint (pt);
if (hwnd == 0) return null;
Control control = display.findControl (hwnd);
@@ -2333,13 +2458,13 @@ LRESULT WM_MOUSEACTIVATE (long /*int*/ wParam, long /*int*/ lParam) {
}
}
- long /*int*/ code = callWindowProc (handle, OS.WM_MOUSEACTIVATE, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_MOUSEACTIVATE, wParam, lParam);
setActiveControl (control, SWT.MouseDown);
return new LRESULT (code);
}
@Override
-LRESULT WM_MOVE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOVE (long wParam, long lParam) {
LRESULT result = super.WM_MOVE (wParam, lParam);
if (result != null) return result;
ToolTip tip = getCurrentToolTip ();
@@ -2348,16 +2473,16 @@ LRESULT WM_MOVE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_NCHITTEST (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NCHITTEST (long wParam, long lParam) {
if (!OS.IsWindowEnabled (handle)) return null;
if (!isEnabled () || !isActive ()) {
if (!Display.TrimEnabled) return new LRESULT (OS.HTNOWHERE);
- long /*int*/ hittest = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
+ long hittest = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
if (hittest == OS.HTCLIENT || hittest == OS.HTMENU) hittest = OS.HTBORDER;
return new LRESULT (hittest);
}
if (menuBar != null && !menuBar.getEnabled ()) {
- long /*int*/ hittest = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
+ long hittest = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
if (hittest == OS.HTMENU) hittest = OS.HTBORDER;
return new LRESULT (hittest);
}
@@ -2365,7 +2490,7 @@ LRESULT WM_NCHITTEST (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_NCLBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NCLBUTTONDOWN (long wParam, long lParam) {
LRESULT result = super.WM_NCLBUTTONDOWN (wParam, lParam);
if (result != null) return result;
/*
@@ -2378,7 +2503,7 @@ LRESULT WM_NCLBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
if (!display.ignoreRestoreFocus) return result;
Display display = this.display;
display.lockActiveWindow = true;
- long /*int*/ code = callWindowProc (handle, OS.WM_NCLBUTTONDOWN, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_NCLBUTTONDOWN, wParam, lParam);
display.lockActiveWindow = false;
Control focusControl = display.lastHittestControl;
if (focusControl != null && !focusControl.isDisposed ()) {
@@ -2390,23 +2515,7 @@ LRESULT WM_NCLBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_PALETTECHANGED (long /*int*/ wParam, long /*int*/ lParam) {
- if (wParam != handle) {
- long /*int*/ hPalette = display.hPalette;
- if (hPalette != 0) return selectPalette (hPalette);
- }
- return super.WM_PALETTECHANGED (wParam, lParam);
-}
-
-@Override
-LRESULT WM_QUERYNEWPALETTE (long /*int*/ wParam, long /*int*/ lParam) {
- long /*int*/ hPalette = display.hPalette;
- if (hPalette != 0) return selectPalette (hPalette);
- return super.WM_QUERYNEWPALETTE (wParam, lParam);
-}
-
-@Override
-LRESULT WM_SETCURSOR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETCURSOR (long wParam, long lParam) {
/*
* Feature in Windows. When the shell is disabled
* by a Windows standard dialog (like a MessageBox
@@ -2420,14 +2529,14 @@ LRESULT WM_SETCURSOR (long /*int*/ wParam, long /*int*/ lParam) {
if (!Display.TrimEnabled) {
Shell modalShell = display.getModalShell ();
if (modalShell != null && !isActive ()) {
- long /*int*/ hwndModal = modalShell.handle;
+ long hwndModal = modalShell.handle;
if (OS.IsWindowEnabled (hwndModal)) {
OS.SetActiveWindow (hwndModal);
}
}
}
if (!OS.IsWindowEnabled (handle)) {
- long /*int*/ hwndPopup = OS.GetLastActivePopup (handle);
+ long hwndPopup = OS.GetLastActivePopup (handle);
if (hwndPopup != 0 && hwndPopup != handle) {
if (display.getControl (hwndPopup) == null) {
if (OS.IsWindowEnabled (hwndPopup)) {
@@ -2477,7 +2586,7 @@ LRESULT WM_SETCURSOR (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SHOWWINDOW (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SHOWWINDOW (long wParam, long lParam) {
LRESULT result = super.WM_SHOWWINDOW (wParam, lParam);
if (result != null) return result;
/*
@@ -2500,7 +2609,7 @@ LRESULT WM_SHOWWINDOW (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_WINDOWPOSCHANGING (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_WINDOWPOSCHANGING (long wParam, long lParam) {
LRESULT result = super.WM_WINDOWPOSCHANGING (wParam,lParam);
if (result != null) return result;
WINDOWPOS lpwp = new WINDOWPOS ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
index a3e9d04da7..66d6f7a6d3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
@@ -14,10 +14,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class are selectable user interface
@@ -76,7 +76,7 @@ import org.eclipse.swt.events.*;
public class Slider extends Control {
int increment, pageIncrement;
boolean ignoreFocus;
- static final long /*int*/ ScrollBarProc;
+ static final long ScrollBarProc;
static final TCHAR ScrollBarClass = new TCHAR (0, "SCROLLBAR", true);
static {
WNDCLASS lpWndClass = new WNDCLASS ();
@@ -158,7 +158,7 @@ public void addSelectionListener (SelectionListener listener) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
/*
* Feature in Windows. Windows runs a modal message
@@ -197,6 +197,12 @@ static int checkStyle (int style) {
}
@Override
+void createHandle () {
+ super.createHandle();
+ maybeEnableDarkSystemTheme();
+}
+
+@Override
void createWidget () {
super.createWidget ();
increment = 1;
@@ -483,7 +489,7 @@ public void setPageIncrement (int value) {
pageIncrement = value;
}
-boolean SetScrollInfo (long /*int*/ hwnd, int flags, SCROLLINFO info, boolean fRedraw) {
+boolean SetScrollInfo (long hwnd, int flags, SCROLLINFO info, boolean fRedraw) {
/*
* Feature in Windows. Using SIF_DISABLENOSCROLL,
* SetScrollInfo () can change enabled and disabled
@@ -637,39 +643,39 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return ScrollBarProc;
}
@Override
-LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
- LRESULT result = super.WM_KEYDOWN (wParam, lParam);
- if (result != null) return result;
- if ((style & SWT.VERTICAL) != 0) return result;
- /*
- * Bug in Windows. When a horizontal scroll bar is mirrored,
- * the native control does not correctly swap the arrow keys.
- * The fix is to swap them before calling the scroll bar window
- * proc.
- *
- * NOTE: This fix is not ideal. It breaks when the bug is fixed
- * in the operating system.
- */
+LRESULT WM_KEYDOWN (long wParam, long lParam) {
+ LRESULT result = super.WM_KEYDOWN (wParam, lParam);
+ if (result != null) return result;
+ if ((style & SWT.VERTICAL) != 0) return result;
+ /*
+ * Bug in Windows. When a horizontal scroll bar is mirrored,
+ * the native control does not correctly swap the arrow keys.
+ * The fix is to swap them before calling the scroll bar window
+ * proc.
+ *
+ * NOTE: This fix is not ideal. It breaks when the bug is fixed
+ * in the operating system.
+ */
if ((style & SWT.MIRRORED) != 0) {
- switch ((int)/*64*/wParam) {
- case OS.VK_LEFT:
+ switch ((int)wParam) {
+ case OS.VK_LEFT:
case OS.VK_RIGHT: {
int key = wParam == OS.VK_LEFT ? OS.VK_RIGHT : OS.VK_LEFT;
- long /*int*/ code = callWindowProc (handle, OS.WM_KEYDOWN, key, lParam);
- return new LRESULT (code);
- }
- }
+ long code = callWindowProc (handle, OS.WM_KEYDOWN, key, lParam);
+ return new LRESULT (code);
+ }
+ }
}
- return result;
+ return result;
}
@Override
-LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDBLCLK (long wParam, long lParam) {
/*
* Feature in Windows. Windows uses the WS_TABSTOP
* style for the scroll bar to decide that focus
@@ -694,14 +700,14 @@ LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
* release the automatic capture.
*/
if (OS.GetCapture () == handle) OS.ReleaseCapture ();
- if (!sendMouseEvent (SWT.MouseUp, 1, handle, OS.WM_LBUTTONUP, wParam, lParam)) {
+ if (!sendMouseEvent (SWT.MouseUp, 1, handle, lParam)) {
return LRESULT.ZERO;
}
return result;
}
@Override
-LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDOWN (long wParam, long lParam) {
/*
* Feature in Windows. Windows uses the WS_TABSTOP
* style for the scroll bar to decide that focus
@@ -726,20 +732,20 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
* release the automatic capture.
*/
if (OS.GetCapture () == handle) OS.ReleaseCapture ();
- if (!sendMouseEvent (SWT.MouseUp, 1, handle, OS.WM_LBUTTONUP, wParam, lParam)) {
+ if (!sendMouseEvent (SWT.MouseUp, 1, handle, lParam)) {
return LRESULT.ONE;
}
return result;
}
@Override
-LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFOCUS (long wParam, long lParam) {
if (ignoreFocus) return null;
return super.WM_SETFOCUS (wParam, lParam);
}
@Override
-LRESULT wmScrollChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmScrollChild (long wParam, long lParam) {
/* Do nothing when scrolling is ending */
int code = OS.LOWORD (wParam);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
index 1c5c4cb0b0..da0746e1d6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
@@ -45,12 +45,12 @@ import org.eclipse.swt.internal.win32.*;
* @noextend This class is not intended to be subclassed by clients.
*/
public class Spinner extends Composite {
- long /*int*/ hwndText, hwndUpDown;
+ long hwndText, hwndUpDown;
boolean ignoreModify, ignoreCharacter;
int pageIncrement, digits;
- static final long /*int*/ EditProc;
+ static final long EditProc;
static final TCHAR EditClass = new TCHAR (0, "EDIT", true);
- static final long /*int*/ UpDownProc;
+ static final long UpDownProc;
static final TCHAR UpDownClass = new TCHAR (0, OS.UPDOWN_CLASS, true);
static {
WNDCLASS lpWndClass = new WNDCLASS ();
@@ -111,7 +111,7 @@ public Spinner (Composite parent, int style) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
if (hwnd == hwndText) {
return OS.CallWindowProc (EditProc, hwnd, msg, wParam, lParam);
@@ -134,11 +134,6 @@ static int checkStyle (int style) {
}
@Override
-boolean checkHandle (long /*int*/ hwnd) {
- return hwnd == handle || hwnd == hwndText || hwnd == hwndUpDown;
-}
-
-@Override
protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
@@ -147,52 +142,39 @@ protected void checkSubclass () {
void createHandle () {
super.createHandle ();
state &= ~(CANVAS | THEME_BACKGROUND);
- long /*int*/ hInstance = OS.GetModuleHandle (null);
- int textExStyle = (style & SWT.BORDER) != 0 ? OS.WS_EX_CLIENTEDGE : 0;
+ long hInstance = OS.GetModuleHandle (null);
+ int textExStyle = 0;
int textStyle = OS.WS_CHILD | OS.WS_VISIBLE | OS.ES_AUTOHSCROLL | OS.WS_CLIPSIBLINGS;
if ((style & SWT.READ_ONLY) != 0) textStyle |= OS.ES_READONLY;
if ((style & SWT.RIGHT_TO_LEFT) != 0) textExStyle |= OS.WS_EX_LAYOUTRTL;
hwndText = OS.CreateWindowEx (
- textExStyle,
- EditClass,
- null,
- textStyle,
- 0, 0, 0, 0,
- handle,
- 0,
- hInstance,
- null);
+ textExStyle,
+ EditClass,
+ null,
+ textStyle,
+ 0, 0, 0, 0,
+ handle,
+ 0,
+ hInstance,
+ null);
if (hwndText == 0) error (SWT.ERROR_NO_HANDLES);
OS.SetWindowLongPtr (hwndText, OS.GWLP_ID, hwndText);
int upDownStyle = OS.WS_CHILD | OS.WS_VISIBLE | OS.UDS_AUTOBUDDY;
if ((style & SWT.WRAP) != 0) upDownStyle |= OS.UDS_WRAP;
- if ((style & SWT.BORDER) != 0) {
- if ((style & SWT.RIGHT_TO_LEFT) != 0) {
- upDownStyle |= OS.UDS_ALIGNLEFT;
- } else {
- upDownStyle |= OS.UDS_ALIGNRIGHT;
- }
- }
hwndUpDown = OS.CreateWindowEx (
- 0,
- UpDownClass,
- null,
- upDownStyle,
- 0, 0, 0, 0,
- handle,
- 0,
- hInstance,
- null);
+ 0,
+ UpDownClass,
+ null,
+ upDownStyle,
+ 0, 0, 0, 0,
+ handle,
+ 0,
+ hInstance,
+ null);
if (hwndUpDown == 0) error (SWT.ERROR_NO_HANDLES);
int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
OS.SetWindowPos (hwndText, hwndUpDown, 0, 0, 0, 0, flags);
OS.SetWindowLongPtr (hwndUpDown, OS.GWLP_ID, hwndUpDown);
- if (OS.IsDBLocale) {
- long /*int*/ hIMC = OS.ImmGetContext (handle);
- OS.ImmAssociateContext (hwndText, hIMC);
- OS.ImmAssociateContext (hwndUpDown, hIMC);
- OS.ImmReleaseContext (handle, hIMC);
- }
OS.SendMessage (hwndUpDown, OS.UDM_SETRANGE32, 0, 100);
OS.SendMessage (hwndUpDown, OS.UDM_SETPOS32, 0, 0);
pageIncrement = 10;
@@ -284,17 +266,12 @@ void addVerifyListener (VerifyListener listener) {
addListener (SWT.Verify, typedListener);
}
-@Override
-long /*int*/ borderHandle () {
- return hwndText;
-}
-
@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
checkWidget ();
int width = 0, height = 0;
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
- long /*int*/ newFont, oldFont = 0;
- long /*int*/ hDC = OS.GetDC (hwndText);
+ long newFont, oldFont = 0;
+ long hDC = OS.GetDC (hwndText);
newFont = OS.SendMessage (hwndText, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
TEXTMETRIC tm = new TEXTMETRIC ();
@@ -305,7 +282,7 @@ long /*int*/ borderHandle () {
OS.SendMessage (hwndUpDown , OS.UDM_GETRANGE32, null, max);
String string = String.valueOf (max [0]);
if (digits > 0) {
- StringBuffer buffer = new StringBuffer ();
+ StringBuilder buffer = new StringBuilder ();
buffer.append (string);
buffer.append (getDecimalSeparator ());
int count = digits - string.length ();
@@ -325,13 +302,15 @@ long /*int*/ borderHandle () {
if (width == 0) width = DEFAULT_WIDTH;
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
- if (hHint != SWT.DEFAULT) height = hHint;
- Rectangle trim = computeTrimInPixels (0, 0, width, height);
- if (hHint == SWT.DEFAULT) {
- int upDownHeight = OS.GetSystemMetrics (OS.SM_CYVSCROLL) + 2 * getBorderWidthInPixels ();
- upDownHeight += (style & SWT.BORDER) != 0 ? 1 : 3;
- trim.height = Math.max (trim.height, upDownHeight);
+ if (hHint != SWT.DEFAULT)
+ height = hHint;
+ else {
+ int borderAdjustment = (style & SWT.BORDER) != 0 ? -1 : 3;
+ int upDownHeight = OS.GetSystemMetrics (OS.SM_CYVSCROLL);
+ height = Math.max(height, upDownHeight + borderAdjustment);
}
+
+ Rectangle trim = computeTrimInPixels (0, 0, width, height);
return new Point (trim.width, trim.height);
}
@@ -341,8 +320,16 @@ long /*int*/ borderHandle () {
/* Get the trim of the text control */
RECT rect = new RECT ();
OS.SetRect (rect, x, y, x + width, y + height);
- int bits0 = OS.GetWindowLong (hwndText, OS.GWL_STYLE);
- int bits1 = OS.GetWindowLong (hwndText, OS.GWL_EXSTYLE);
+ int bits0 = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int bits1 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
+ /*
+ * For a very long time, border was WS_EX_CLIENTEDGE. Now that is was
+ * changed to WS_BORDER, preserve old size for compatibility reasons.
+ */
+ if ((bits0 & OS.WS_BORDER) != 0) {
+ bits0 &= ~OS.WS_BORDER;
+ bits1 |= OS.WS_EX_CLIENTEDGE;
+ }
OS.AdjustWindowRectEx (rect, bits0, false, bits1);
width = rect.right - rect.left;
height = rect.bottom - rect.top;
@@ -353,7 +340,7 @@ long /*int*/ borderHandle () {
* the single-line text widget in an editable combo
* box.
*/
- long /*int*/ margins = OS.SendMessage (hwndText, OS.EM_GETMARGINS, 0, 0);
+ long margins = OS.SendMessage (hwndText, OS.EM_GETMARGINS, 0, 0);
x -= OS.LOWORD (margins);
width += OS.LOWORD (margins) + OS.HIWORD (margins);
if ((style & SWT.BORDER) != 0) {
@@ -421,7 +408,7 @@ void deregister () {
@Override
boolean hasFocus () {
- long /*int*/ hwndFocus = OS.GetFocus ();
+ long hwndFocus = OS.GetFocus ();
if (hwndFocus == handle) return true;
if (hwndFocus == hwndText) return true;
if (hwndFocus == hwndUpDown) return true;
@@ -529,7 +516,7 @@ public int getPageIncrement () {
*/
public int getSelection () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
+ return (int)OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
}
int getSelectionText (boolean [] parseFail) {
@@ -617,7 +604,12 @@ public String getText () {
*/
public int getTextLimit () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (hwndText, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF;
+ return (int)OS.SendMessage (hwndText, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF;
+}
+
+@Override
+boolean isUseWsBorder () {
+ return true;
}
/**
@@ -725,7 +717,7 @@ void removeVerifyListener (VerifyListener listener) {
}
@Override
-boolean sendKeyEvent (int type, int msg, long /*int*/ wParam, long /*int*/ lParam, Event event) {
+boolean sendKeyEvent (int type, int msg, long wParam, long lParam, Event event) {
if (!super.sendKeyEvent (type, msg, wParam, lParam, event)) {
return false;
}
@@ -797,7 +789,7 @@ boolean sendKeyEvent (int type, int msg, long /*int*/ wParam, long /*int*/ lPara
}
@Override
-void setBackgroundImage (long /*int*/ hBitmap) {
+void setBackgroundImage (long hBitmap) {
super.setBackgroundImage (hBitmap);
OS.InvalidateRect (hwndText, null, true);
}
@@ -833,7 +825,7 @@ public void setDigits (int value) {
if (value < 0) error (SWT.ERROR_INVALID_ARGUMENT);
if (value == this.digits) return;
this.digits = value;
- int pos = (int)/*64*/OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
+ int pos = (int)OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
setSelection (pos, false, true, false);
}
@@ -858,14 +850,14 @@ void setForegroundPixel (int pixel) {
public void setIncrement (int value) {
checkWidget ();
if (value < 1) return;
- long /*int*/ hHeap = OS.GetProcessHeap ();
- int count = (int)/*64*/OS.SendMessage (hwndUpDown, OS.UDM_GETACCEL, 0, (UDACCEL)null);
- long /*int*/ udaccels = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, UDACCEL.sizeof * count);
+ long hHeap = OS.GetProcessHeap ();
+ int count = (int)OS.SendMessage (hwndUpDown, OS.UDM_GETACCEL, 0, (UDACCEL)null);
+ long udaccels = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, UDACCEL.sizeof * count);
OS.SendMessage (hwndUpDown, OS.UDM_GETACCEL, count, udaccels);
int first = -1;
UDACCEL udaccel = new UDACCEL ();
for (int i = 0; i < count; i++) {
- long /*int*/ offset = udaccels + (i * UDACCEL.sizeof);
+ long offset = udaccels + (i * UDACCEL.sizeof);
OS.MoveMemory (udaccel, offset, UDACCEL.sizeof);
if (first == -1) first = udaccel.nInc;
udaccel.nInc = udaccel.nInc / first * value;
@@ -893,7 +885,7 @@ public void setMaximum (int value) {
int [] min = new int [1];
OS.SendMessage (hwndUpDown , OS.UDM_GETRANGE32, min, null);
if (value < min [0]) return;
- int pos = (int)/*64*/OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
+ int pos = (int)OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
OS.SendMessage (hwndUpDown , OS.UDM_SETRANGE32, min [0], value);
if (pos > value) setSelection (value, true, true, false);
}
@@ -916,7 +908,7 @@ public void setMinimum (int value) {
int [] max = new int [1];
OS.SendMessage (hwndUpDown , OS.UDM_GETRANGE32, null, max);
if (value > max [0]) return;
- int pos = (int)/*64*/OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
+ int pos = (int)OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
OS.SendMessage (hwndUpDown , OS.UDM_SETRANGE32, value, max [0]);
if (pos < value) setSelection (value, true, true, false);
}
@@ -972,7 +964,7 @@ void setSelection (int value, boolean setPos, boolean setText, boolean notify) {
string = String.valueOf (Math.abs (value));
String decimalSeparator = getDecimalSeparator ();
int index = string.length () - digits;
- StringBuffer buffer = new StringBuffer ();
+ StringBuilder buffer = new StringBuilder ();
if (value < 0) buffer.append ("-");
if (index > 0) {
buffer.append (string.substring (0, index));
@@ -1073,7 +1065,7 @@ public void setValues (int selection, int minimum, int maximum, int digits, int
@Override
void subclass () {
super.subclass ();
- long /*int*/ newProc = display.windowProc;
+ long newProc = display.windowProc;
OS.SetWindowLongPtr (hwndText, OS.GWLP_WNDPROC, newProc);
OS.SetWindowLongPtr (hwndUpDown, OS.GWLP_WNDPROC, newProc);
}
@@ -1142,12 +1134,7 @@ String verifyText (String string, int start, int end, Event keyEvent) {
}
@Override
-int widgetExtStyle () {
- return super.widgetExtStyle () & ~OS.WS_EX_CLIENTEDGE;
-}
-
-@Override
-long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long windowProc (long hwnd, int msg, long wParam, long lParam) {
if (hwnd == hwndText || hwnd == hwndUpDown) {
LRESULT result = null;
switch (msg) {
@@ -1208,26 +1195,26 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
}
@Override
-LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ERASEBKGND (long wParam, long lParam) {
super.WM_ERASEBKGND (wParam, lParam);
drawBackground (wParam);
return LRESULT.ONE;
}
@Override
-LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KILLFOCUS (long wParam, long lParam) {
return null;
}
@Override
-LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFOCUS (long wParam, long lParam) {
OS.SetFocus (hwndText);
OS.SendMessage (hwndText, OS.EM_SETSEL, 0, -1);
return null;
}
@Override
-LRESULT WM_SETFONT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFONT (long wParam, long lParam) {
LRESULT result = super.WM_SETFONT (wParam, lParam);
if (result != null) return result;
OS.SendMessage (hwndText, OS.WM_SETFONT, wParam, lParam);
@@ -1235,26 +1222,38 @@ LRESULT WM_SETFONT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
LRESULT result = super.WM_SIZE (wParam, lParam);
if (isDisposed ()) return result;
int width = OS.LOWORD (lParam), height = OS.HIWORD (lParam);
- int upDownWidth = OS.GetSystemMetrics (OS.SM_CXVSCROLL);
+ int upDownWidth = OS.GetSystemMetrics (OS.SM_CXVSCROLL) - 1;
int textWidth = width - upDownWidth;
- int border = OS.GetSystemMetrics (OS.SM_CXEDGE);
+
+ /*
+ * For consistency, make text's vertical position the same as in
+ * Text control. The difference only occurs when Spinner uses
+ * WS_BORDER while Text uses WS_EX_CLIENTEDGE.
+ */
+ int borderAdjustment = 0;
+ if (((style & SWT.BORDER) != 0) && !display.useWsBorderText) {
+ borderAdjustment = OS.GetSystemMetrics (OS.SM_CYEDGE) - OS.GetSystemMetrics (OS.SM_CYBORDER);
+ /* There is an unexplained 1px additional offset in Windows */
+ borderAdjustment++;
+ }
+
int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE;
- OS.SetWindowPos (hwndText, 0, 0, 0, textWidth + border, height, flags);
+ OS.SetWindowPos (hwndText, 0, 0, borderAdjustment, textWidth, height - borderAdjustment, flags);
OS.SetWindowPos (hwndUpDown, 0, textWidth, 0, upDownWidth, height, flags);
return result;
}
@Override
-LRESULT wmIMEChar(long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmIMEChar(long hwnd, long wParam, long lParam) {
/* Process a DBCS character */
Display display = this.display;
display.lastKey = 0;
- display.lastAscii = (int)/*64*/wParam;
+ display.lastAscii = (int)wParam;
display.lastVirtual = display.lastNull = display.lastDead = false;
if (!sendKeyEvent (SWT.KeyDown, OS.WM_IME_CHAR, wParam, lParam)) {
return LRESULT.ZERO;
@@ -1268,7 +1267,7 @@ LRESULT wmIMEChar(long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
* them to the application.
*/
ignoreCharacter = true;
- long /*int*/ result = callWindowProc (hwnd, OS.WM_IME_CHAR, wParam, lParam);
+ long result = callWindowProc (hwnd, OS.WM_IME_CHAR, wParam, lParam);
MSG msg = new MSG ();
int flags = OS.PM_REMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE;
while (OS.PeekMessage (msg, hwnd, OS.WM_CHAR, OS.WM_CHAR, flags)) {
@@ -1284,7 +1283,7 @@ LRESULT wmIMEChar(long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmChar (long hwnd, long wParam, long lParam) {
if (ignoreCharacter) return null;
LRESULT result = super.wmChar (hwnd, wParam, lParam);
if (result != null) return result;
@@ -1295,7 +1294,7 @@ LRESULT wmChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
* The fix is to look for these keys and not call
* the window proc.
*/
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case SWT.CR:
sendSelectionEvent (SWT.DefaultSelection);
// FALL THROUGH
@@ -1305,7 +1304,7 @@ LRESULT wmChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
return result;
}
-LRESULT wmClipboard (long /*int*/ hwndText, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmClipboard (long hwndText, int msg, long wParam, long lParam) {
if ((style & SWT.READ_ONLY) != 0) return null;
// if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return null;
boolean call = false;
@@ -1355,11 +1354,11 @@ LRESULT wmClipboard (long /*int*/ hwndText, int msg, long /*int*/ wParam, long /
}
TCHAR buffer = new TCHAR (getCodePage (), newText, true);
if (msg == OS.WM_SETTEXT) {
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
int byteCount = buffer.length () * TCHAR.sizeof;
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (pszText, buffer, byteCount);
- long /*int*/ code = OS.CallWindowProc (EditProc, hwndText, msg, wParam, pszText);
+ long code = OS.CallWindowProc (EditProc, hwndText, msg, wParam, pszText);
OS.HeapFree (hHeap, 0, pszText);
return new LRESULT (code);
} else {
@@ -1372,7 +1371,7 @@ LRESULT wmClipboard (long /*int*/ hwndText, int msg, long /*int*/ wParam, long /
}
@Override
-LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmCommandChild (long wParam, long lParam) {
int code = OS.HIWORD (wParam);
switch (code) {
case OS.EN_CHANGE:
@@ -1380,7 +1379,7 @@ LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
boolean [] parseFail = new boolean [1];
int value = getSelectionText (parseFail);
if (!parseFail [0]) {
- int pos = (int)/*64*/OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
+ int pos = (int)OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
if (pos != value) setSelection (value, true, false, true);
}
sendEvent (SWT.Modify);
@@ -1391,7 +1390,7 @@ LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmKeyDown (long hwnd, long wParam, long lParam) {
if (ignoreCharacter) return null;
LRESULT result = super.wmKeyDown (hwnd, wParam, lParam);
if (result != null) return result;
@@ -1400,7 +1399,7 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
UDACCEL udaccel = new UDACCEL ();
OS.SendMessage (hwndUpDown, OS.UDM_GETACCEL, 1, udaccel);
int delta = 0;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_UP: delta = udaccel.nInc; break;
case OS.VK_DOWN: delta = -udaccel.nInc; break;
case OS.VK_PRIOR: delta = pageIncrement; break;
@@ -1410,7 +1409,7 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
boolean [] parseFail = new boolean [1];
int value = getSelectionText (parseFail);
if (parseFail [0]) {
- value = (int)/*64*/OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
+ value = (int)OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
}
int newValue = value + delta;
int [] max = new int [1], min = new int [1];
@@ -1424,7 +1423,7 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
}
/* Stop the edit control from moving the caret */
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_UP:
case OS.VK_DOWN:
return LRESULT.ZERO;
@@ -1433,18 +1432,18 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
}
@Override
-LRESULT wmKillFocus (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmKillFocus (long hwnd, long wParam, long lParam) {
boolean [] parseFail = new boolean [1];
int value = getSelectionText (parseFail);
if (parseFail [0]) {
- value = (int)/*64*/OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
+ value = (int)OS.SendMessage (hwndUpDown, OS.UDM_GETPOS32, 0, 0);
setSelection (value, false, true, false);
}
return super.wmKillFocus (hwnd, wParam, lParam);
}
@Override
-LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) {
switch (hdr.code) {
case OS.UDN_DELTAPOS:
NMUPDOWN lpnmud = new NMUPDOWN ();
@@ -1474,7 +1473,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmScrollChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmScrollChild (long wParam, long lParam) {
int code = OS.LOWORD (wParam);
switch (code) {
case OS.SB_THUMBPOSITION:
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
index ea336bef0c..ddd8df6bc8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
@@ -53,7 +53,7 @@ import org.eclipse.swt.internal.win32.*;
public class TabFolder extends Composite {
TabItem [] items;
ImageList imageList;
- static final long /*int*/ TabFolderProc;
+ static final long TabFolderProc;
static final TCHAR TabFolderClass = new TCHAR (0, OS.WC_TABCONTROL, true);
boolean createdAsRTL;
@@ -159,7 +159,7 @@ public void addSelectionListener(SelectionListener listener) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
return OS.CallWindowProc (TabFolderProc, hwnd, msg, wParam, lParam);
}
@@ -188,7 +188,7 @@ protected void checkSubclass () {
RECT insetRect = new RECT (), itemRect = new RECT ();
OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, insetRect);
int width = insetRect.left - insetRect.right;
- int count = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
if (count != 0) {
OS.SendMessage (handle, OS.TCM_GETITEMRECT, count - 1, itemRect);
width = Math.max (width, itemRect.right - insetRect.right);
@@ -217,7 +217,7 @@ protected void checkSubclass () {
}
void createItem (TabItem item, int index) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
if (count == items.length) {
TabItem [] newItems = new TabItem [items.length + 4];
@@ -256,7 +256,7 @@ void createHandle () {
* is set. The fix is to set TTM_SETMAXTIPWIDTH to
* a large value.
*/
- long /*int*/ hwndToolTip = OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);
+ long hwndToolTip = OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);
OS.SendMessage (hwndToolTip, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);
createdAsRTL = (style & SWT.RIGHT_TO_LEFT) != 0;
@@ -269,14 +269,14 @@ void createWidget () {
}
void destroyItem (TabItem item) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
int index = 0;
while (index < count) {
if (items [index] == item) break;
index++;
}
if (index == count) return;
- int selectionIndex = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+ int selectionIndex = (int)OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
if (OS.SendMessage (handle, OS.TCM_DELETEITEM, index, 0) == 0) {
error (SWT.ERROR_ITEM_NOT_REMOVED);
}
@@ -296,7 +296,7 @@ void destroyItem (TabItem item) {
}
@Override
-void drawThemeBackground (long /*int*/ hDC, long /*int*/ hwnd, RECT rect) {
+void drawThemeBackground (long hDC, long hwnd, RECT rect) {
RECT rect2 = new RECT ();
OS.GetClientRect (handle, rect2);
OS.MapWindowPoints (handle, hwnd, rect2, 2);
@@ -339,7 +339,7 @@ Control findThemeControl () {
*/
public TabItem getItem (int index) {
checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
return items [index];
}
@@ -368,7 +368,7 @@ public TabItem getItem (Point point) {
TCHITTESTINFO pinfo = new TCHITTESTINFO ();
pinfo.x = point.x;
pinfo.y = point.y;
- int index = (int)/*64*/OS.SendMessage (handle, OS.TCM_HITTEST, 0, pinfo);
+ int index = (int)OS.SendMessage (handle, OS.TCM_HITTEST, 0, pinfo);
if (index == -1) return null;
return items [index];
}
@@ -385,7 +385,7 @@ public TabItem getItem (Point point) {
*/
public int getItemCount () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ return (int)OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
}
/**
@@ -406,7 +406,7 @@ public int getItemCount () {
*/
public TabItem [] getItems () {
checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
TabItem [] result = new TabItem [count];
System.arraycopy (items, 0, result, 0, count);
return result;
@@ -430,7 +430,7 @@ public TabItem [] getItems () {
*/
public TabItem [] getSelection () {
checkWidget ();
- int index = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+ int index = (int)OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
if (index == -1) return new TabItem [0];
return new TabItem [] {items [index]};
}
@@ -448,7 +448,7 @@ public TabItem [] getSelection () {
*/
public int getSelectionIndex () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+ return (int)OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
}
int imageIndex (Image image) {
@@ -461,7 +461,7 @@ int imageIndex (Image image) {
Rectangle bounds = image.getBoundsInPixels ();
imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, bounds.width, bounds.height);
int index = imageList.add (image);
- long /*int*/ hImageList = imageList.getHandle ();
+ long hImageList = imageList.getHandle ();
OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, hImageList);
return index;
}
@@ -494,7 +494,7 @@ int imageIndex (Image image) {
public int indexOf (TabItem item) {
checkWidget ();
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- int count = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
for (int i=0; i<count; i++) {
if (items [i] == item) return i;
}
@@ -503,12 +503,10 @@ public int indexOf (TabItem item) {
@Override
Point minimumSize (int wHint, int hHint, boolean flushCache) {
- Control [] children = _getChildren ();
int width = 0, height = 0;
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
+ for (Control child : _getChildren ()) {
int index = 0;
- int count = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
while (index < count) {
if (items [index].control == child) break;
index++;
@@ -549,8 +547,7 @@ boolean mnemonicHit (char key) {
@Override
boolean mnemonicMatch (char key) {
- for (int i=0; i<items.length; i++) {
- TabItem item = items [i];
+ for (TabItem item : items) {
if (item != null) {
char ch = findMnemonic (item.getText ());
if (Character.toUpperCase (key) == Character.toUpperCase (ch)) {
@@ -564,7 +561,7 @@ boolean mnemonicMatch (char key) {
@Override
void releaseChildren (boolean destroy) {
if (items != null) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
for (int i=0; i<count; i++) {
TabItem item = items [i];
if (item != null && !item.isDisposed ()) {
@@ -589,7 +586,7 @@ void releaseWidget () {
@Override
void removeControl (Control control) {
super.removeControl (control);
- int count = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
for (int i=0; i<count; i++) {
TabItem item = items [i];
if (item.control == control) item.setControl (null);
@@ -625,7 +622,7 @@ public void removeSelectionListener (SelectionListener listener) {
@Override
void reskinChildren (int flags) {
if (items != null) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
for (int i=0; i<count; i++) {
TabItem item = items [i];
if (item != null) item.reskin (flags);
@@ -693,7 +690,7 @@ public void setFont (Font font) {
Rectangle newRect = getClientAreaInPixels ();
if (!oldRect.equals (newRect)) {
sendResize ();
- int index = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+ int index = (int)OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
if (index != -1) {
TabItem item = items [index];
Control control = item.control;
@@ -719,13 +716,13 @@ public void setFont (Font font) {
*/
public void setSelection (int index) {
checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
if (!(0 <= index && index < count)) return;
setSelection (index, false);
}
void setSelection (int index, boolean notify) {
- int oldIndex = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+ int oldIndex = (int)OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
if (oldIndex == index) return;
if (oldIndex != -1) {
TabItem item = items [oldIndex];
@@ -735,7 +732,7 @@ void setSelection (int index, boolean notify) {
}
}
OS.SendMessage (handle, OS.TCM_SETCURSEL, index, 0);
- int newIndex = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+ int newIndex = (int)OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
if (newIndex != -1) {
TabItem item = items [newIndex];
Control control = item.control;
@@ -770,8 +767,8 @@ String toolTipText (NMTTDISPINFO hdr) {
if ((hdr.uFlags & OS.TTF_IDISHWND) != 0) {
return null;
}
- int index = (int)/*64*/hdr.idFrom;
- long /*int*/ hwndToolTip = OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);
+ int index = (int)hdr.idFrom;
+ long hwndToolTip = OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);
if (hwndToolTip == hdr.hwndFrom) {
/*
* Bug in Windows. For some reason the reading order
@@ -817,7 +814,7 @@ boolean traversePage (boolean next) {
@Override
void updateOrientation () {
super.updateOrientation ();
- long /*int*/ hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
+ long hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
while (hwndChild != 0) {
char [] buffer = new char [128];
int length = OS.GetClassName (hwndChild, buffer, buffer.length);
@@ -845,7 +842,7 @@ void updateOrientation () {
Point size = imageList.getImageSize ();
display.releaseImageList (imageList);
imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, size.x, size.y);
- long /*int*/ hImageList = imageList.getHandle ();
+ long hImageList = imageList.getHandle ();
OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, hImageList);
TCITEM tcItem = new TCITEM ();
tcItem.mask = OS.TCIF_IMAGE;
@@ -882,12 +879,12 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return TabFolderProc;
}
@Override
-LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETDLGCODE (long wParam, long lParam) {
LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
/*
* Return DLGC_BUTTON so that mnemonics will be
@@ -899,7 +896,7 @@ LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_GETOBJECT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETOBJECT (long wParam, long lParam) {
/*
* Ensure that there is an accessible object created for this
* control because support for publishing the keyboard shortcut
@@ -910,10 +907,10 @@ LRESULT WM_GETOBJECT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KEYDOWN (long wParam, long lParam) {
LRESULT result = super.WM_KEYDOWN (wParam, lParam);
if (result != null) return result;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_LEFT:
case OS.VK_RIGHT:
/*
@@ -922,10 +919,10 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
* The fix is to replace VK_LEFT by VK_RIGHT and VK_RIGHT by VK_LEFT
* when the current orientation differs from the orientation used to
* create the control.
- */
+ */
boolean isRTL = (style & SWT.RIGHT_TO_LEFT) != 0;
if (isRTL != createdAsRTL) {
- long /*int*/ code = callWindowProc (handle, OS.WM_KEYDOWN, wParam == OS.VK_RIGHT ? OS.VK_LEFT : OS.VK_RIGHT, lParam);
+ long code = callWindowProc (handle, OS.WM_KEYDOWN, wParam == OS.VK_RIGHT ? OS.VK_LEFT : OS.VK_RIGHT, lParam);
return new LRESULT (code);
}
break;
@@ -934,7 +931,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_MOUSELEAVE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSELEAVE (long wParam, long lParam) {
LRESULT result = super.WM_MOUSELEAVE (wParam, lParam);
if (result != null) return result;
/*
@@ -950,7 +947,7 @@ LRESULT WM_MOUSELEAVE (long /*int*/ wParam, long /*int*/ lParam) {
*/
TOOLINFO lpti = new TOOLINFO ();
lpti.cbSize = TOOLINFO.sizeof;
- long /*int*/ hwndToolTip = OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);
+ long hwndToolTip = OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);
if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, lpti) != 0) {
if ((lpti.uFlags & OS.TTF_IDISHWND) == 0) {
OS.SendMessage (hwndToolTip, OS.TTM_DELTOOL, 0, lpti);
@@ -961,7 +958,7 @@ LRESULT WM_MOUSELEAVE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_NCHITTEST (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NCHITTEST (long wParam, long lParam) {
LRESULT result = super.WM_NCHITTEST (wParam, lParam);
if (result != null) return result;
/*
@@ -976,12 +973,12 @@ LRESULT WM_NCHITTEST (long /*int*/ wParam, long /*int*/ lParam) {
* default window proc that returns HTCLIENT when
* the mouse is in the client area.
*/
- long /*int*/ hittest = OS.DefWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
+ long hittest = OS.DefWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
return new LRESULT (hittest);
}
@Override
-LRESULT WM_NOTIFY (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NOTIFY (long wParam, long lParam) {
/*
* Feature in Windows. When the tab folder window
* proc processes WM_NOTIFY, it forwards this
@@ -1006,7 +1003,7 @@ LRESULT WM_NOTIFY (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_PARENTNOTIFY (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PARENTNOTIFY (long wParam, long lParam) {
LRESULT result = super.WM_PARENTNOTIFY (wParam, lParam);
if (result != null) return result;
/*
@@ -1022,7 +1019,7 @@ LRESULT WM_PARENTNOTIFY (long /*int*/ wParam, long /*int*/ lParam) {
switch (code) {
case OS.WM_CREATE: {
int id = OS.HIWORD (wParam);
- long /*int*/ hwnd = lParam;
+ long hwnd = lParam;
if (id == ID_UPDOWN) {
int bits = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE);
OS.SetWindowLong (hwnd, OS.GWL_EXSTYLE, bits | OS.WS_EX_LAYOUTRTL);
@@ -1035,7 +1032,7 @@ LRESULT WM_PARENTNOTIFY (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
LRESULT result = super.WM_SIZE (wParam, lParam);
/*
* It is possible (but unlikely), that application
@@ -1045,7 +1042,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
* WM_SIZE message.
*/
if (isDisposed ()) return result;
- int index = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+ int index = (int)OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
if (index != -1) {
TabItem item = items [index];
Control control = item.control;
@@ -1057,7 +1054,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_WINDOWPOSCHANGING (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_WINDOWPOSCHANGING (long wParam, long lParam) {
LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam);
if (result != null) return result;
if (!OS.IsWindowVisible (handle)) return result;
@@ -1107,13 +1104,13 @@ LRESULT WM_WINDOWPOSCHANGING (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) {
int code = hdr.code;
switch (code) {
case OS.TCN_SELCHANGE:
case OS.TCN_SELCHANGING:
TabItem item = null;
- int index = (int)/*64*/OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+ int index = (int)OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
if (index != -1) item = items [index];
if (item != null) {
Control control = item.control;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
index adec2a5955..ac4a3f89b6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
@@ -135,11 +135,11 @@ void _setText (int index, String string) {
if (j < i) string = new String (text, 0, j);
}
}
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hwnd = parent.handle;
+ long hHeap = OS.GetProcessHeap ();
TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
int byteCount = buffer.length () * TCHAR.sizeof;
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (pszText, buffer, byteCount);
TCITEM tcItem = new TCITEM ();
tcItem.mask = OS.TCIF_TEXT;
@@ -314,7 +314,7 @@ public void setImage (Image image) {
* whenever the image or text is changed.
*/
if (text.indexOf ('&') != -1) _setText (index, text);
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TCITEM tcItem = new TCITEM ();
tcItem.mask = OS.TCIF_IMAGE;
tcItem.iImage = parent.imageIndex (image);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
index 90f908fd0b..73e0392dd2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -84,7 +84,7 @@ public class Table extends Composite {
TableColumn sortColumn;
RECT focusRect;
boolean [] columnVisible;
- long /*int*/ headerToolTipHandle, hwndHeader;
+ long headerToolTipHandle, hwndHeader, itemToolTipHandle;
boolean ignoreCustomDraw, ignoreDrawForeground, ignoreDrawBackground, ignoreDrawFocus, ignoreDrawSelection, ignoreDrawHot;
boolean customDraw, dragStarted, explorerTheme, firstColumnImage, fixScrollWidth, tipRequested, wasSelected, wasResized, painted;
boolean ignoreActivate, ignoreSelect, ignoreShrink, ignoreResize, ignoreColumnMove, ignoreColumnResize, fullRowSelect, settingItemHeight;
@@ -92,7 +92,7 @@ public class Table extends Composite {
int itemHeight, lastIndexOf, lastWidth, sortDirection, resizeCount, selectionForeground, hotIndex;
int headerBackground = -1;
int headerForeground = -1;
- static /*final*/ long /*int*/ HeaderProc;
+ static /*final*/ long HeaderProc;
static final int INSET = 4;
static final int GRID_WIDTH = 1;
static final int SORT_WIDTH = 10;
@@ -104,7 +104,7 @@ public class Table extends Composite {
static final int V_SCROLL_LIMIT = 16;
static final int DRAG_IMAGE_SIZE = 301;
static boolean COMPRESS_ITEMS = true;
- static final long /*int*/ TableProc;
+ static final long TableProc;
static final TCHAR TableClass = new TCHAR (0, OS.WC_LISTVIEW, true);
static final TCHAR HeaderClass = new TCHAR (0, OS.WC_HEADER, true);
static {
@@ -221,7 +221,7 @@ void _checkShrink () {
if (keys == null) {
if (!ignoreShrink) {
/* Resize the item array to match the item count */
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
/*
* Bug in Windows. Call to OS.LVM_GETITEMCOUNT unexpectedly returns zero,
@@ -288,26 +288,26 @@ TableItem _getItem (int index, boolean create, int count) {
if ((style & SWT.VIRTUAL) == 0 || !create) {
return keyIndex < 0 ? null : items [keyIndex];
}
- if (keyIndex < 0) {
- if (count == -1) {
- count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
- }
- //TODO - _checkGrow() doesn't return a value, check keys == null instead
- if (_checkGrow (count)) {
- if (items [index] != null) return items [index];
- return items [index] = new TableItem (this, SWT.NONE, -1, false);
- }
- keyIndex = -keyIndex - 1;
- if (keyIndex < keyCount) {
- System.arraycopy(keys, keyIndex, keys, keyIndex + 1, keyCount - keyIndex);
- System.arraycopy(items, keyIndex, items, keyIndex + 1, keyCount - keyIndex);
- }
- keyCount++;
- keys [keyIndex] = index;
- } else {
- if (items [keyIndex] != null) return items [keyIndex];
- }
- return items [keyIndex] = new TableItem (this, SWT.NONE, -1, false);
+ if (keyIndex < 0) {
+ if (count == -1) {
+ count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ }
+ //TODO - _checkGrow() doesn't return a value, check keys == null instead
+ if (_checkGrow (count)) {
+ if (items [index] != null) return items [index];
+ return items [index] = new TableItem (this, SWT.NONE, -1, false);
+ }
+ keyIndex = -keyIndex - 1;
+ if (keyIndex < keyCount) {
+ System.arraycopy(keys, keyIndex, keys, keyIndex + 1, keyCount - keyIndex);
+ System.arraycopy(items, keyIndex, items, keyIndex + 1, keyCount - keyIndex);
+ }
+ keyCount++;
+ keys [keyIndex] = index;
+ } else {
+ if (items [keyIndex] != null) return items [keyIndex];
+ }
+ return items [keyIndex] = new TableItem (this, SWT.NONE, -1, false);
}
}
@@ -344,13 +344,13 @@ void _insertItem (int index, TableItem item, int count) {
items [index] = item;
} else {
int keyIndex = binarySearch (keys, 0, keyCount, index);
- if (keyIndex < 0) keyIndex = -keyIndex - 1;
- System.arraycopy(keys, keyIndex, keys, keyIndex + 1, keyCount - keyIndex);
- keys [keyIndex] = index;
- System.arraycopy(items, keyIndex, items, keyIndex + 1, keyCount - keyIndex);
- items [keyIndex] = item;
- keyCount++;
- for (int i=keyIndex + 1; i<keyCount; i++) keys[i]++;
+ if (keyIndex < 0) keyIndex = -keyIndex - 1;
+ System.arraycopy(keys, keyIndex, keys, keyIndex + 1, keyCount - keyIndex);
+ keys [keyIndex] = index;
+ System.arraycopy(items, keyIndex, items, keyIndex + 1, keyCount - keyIndex);
+ items [keyIndex] = item;
+ keyCount++;
+ for (int i=keyIndex + 1; i<keyCount; i++) keys[i]++;
}
}
@@ -360,16 +360,16 @@ void _removeItem (int index, int count) {
items [count] = null;
} else {
int keyIndex = binarySearch (keys, 0, keyCount, index);
- if (keyIndex < 0) {
- keyIndex = -keyIndex - 1;
- } else {
- --keyCount;
- System.arraycopy (keys, keyIndex + 1, keys, keyIndex, keyCount - keyIndex);
- keys [keyCount] = 0;
- System.arraycopy (items, keyIndex + 1, items, keyIndex, keyCount - keyIndex);
- items [keyCount] = null;
- }
- for (int i=keyIndex; i<keyCount; i++) --keys[i];
+ if (keyIndex < 0) {
+ keyIndex = -keyIndex - 1;
+ } else {
+ --keyCount;
+ System.arraycopy (keys, keyIndex + 1, keys, keyIndex, keyCount - keyIndex);
+ keys [keyCount] = 0;
+ System.arraycopy (items, keyIndex + 1, items, keyIndex, keyCount - keyIndex);
+ items [keyCount] = null;
+ }
+ for (int i=keyIndex; i<keyCount; i++) --keys[i];
}
}
@@ -403,9 +403,9 @@ void _setItemCount (int count, int itemCount) {
} else {
int index = Math.min (count, itemCount);
keyCount = binarySearch (keys, 0, keyCount, index);
- if (keyCount < 0) keyCount = -keyCount - 1;
- int length = Math.max (4, (keyCount + 3) / 4 * 4);
- int [] newKeys = new int [length];
+ if (keyCount < 0) keyCount = -keyCount - 1;
+ int length = Math.max (4, (keyCount + 3) / 4 * 4);
+ int [] newKeys = new int [length];
System.arraycopy (keys, 0, newKeys, 0, keyCount);
keys = newKeys;
TableItem [] newItems = new TableItem [length];
@@ -450,11 +450,11 @@ public void addSelectionListener (SelectionListener listener) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
return callWindowProc (hwnd, msg, wParam, lParam, false);
}
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam, boolean forceSelect) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam, boolean forceSelect) {
if (handle == 0) return 0;
if (hwndHeader != 0 && hwnd == hwndHeader) {
return OS.CallWindowProc (HeaderProc, hwnd, msg, wParam, lParam);
@@ -525,7 +525,7 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
case OS.WM_SETFONT:
case OS.WM_TIMER: {
if (findImageControl () != null) {
- topIndex = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETTOPINDEX, 0, 0);
+ topIndex = (int)OS.SendMessage (handle, OS.LVM_GETTOPINDEX, 0, 0);
}
}
}
@@ -544,7 +544,7 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
if (msg == OS.WM_PAINT) {
int bits0 = OS.GetWindowLong (handle, OS.GWL_STYLE);
if ((bits0 & OS.LVS_NOCOLUMNHEADER) == 0) {
- long /*int*/ hwndParent = OS.GetParent (handle), hwndOwner = 0;
+ long hwndParent = OS.GetParent (handle), hwndOwner = 0;
while (hwndParent != 0) {
int bits1 = OS.GetWindowLong (hwndParent, OS.GWL_EXSTYLE);
if ((bits1 & OS.WS_EX_COMPOSITED) != 0) {
@@ -578,10 +578,10 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
}
}
}
- long /*int*/ code = 0;
+ long code = 0;
if (fixPaint) {
PAINTSTRUCT ps = new PAINTSTRUCT ();
- long /*int*/ hDC = OS.BeginPaint (hwnd, ps);
+ long hDC = OS.BeginPaint (hwnd, ps);
code = OS.CallWindowProc (TableProc, hwnd, OS.WM_PAINT, hDC, lParam);
OS.EndPaint (hwnd, ps);
} else {
@@ -596,7 +596,7 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
if (checkSelection) {
if (wasSelected || forceSelect) {
Event event = new Event ();
- int index = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
+ int index = (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
if (index != -1) event.item = _getItem (index);
sendSelectionEvent (SWT.Selection, event, false);
}
@@ -624,7 +624,7 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
OS.SendMessage (handle, OS.LVM_SETBKCOLOR, 0, OS.CLR_NONE);
OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
OS.InvalidateRect (handle, null, true);
- long /*int*/ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
if (hwndHeader != 0) OS.InvalidateRect (hwndHeader, null, true);
}
//FALL THROUGH
@@ -682,8 +682,8 @@ static int checkStyle (int style) {
return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
}
-LRESULT CDDS_ITEMPOSTPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lParam) {
- long /*int*/ hDC = nmcd.hdc;
+LRESULT CDDS_ITEMPOSTPAINT (NMLVCUSTOMDRAW nmcd, long wParam, long lParam) {
+ long hDC = nmcd.hdc;
if (explorerTheme && !ignoreCustomDraw) {
hotIndex = -1;
if (hooks (SWT.EraseItem) && nmcd.left != nmcd.right) {
@@ -705,21 +705,21 @@ LRESULT CDDS_ITEMPOSTPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
if (!ignoreCustomDraw && !ignoreDrawFocus && nmcd.left != nmcd.right) {
if (OS.IsWindowVisible (handle) && OS.IsWindowEnabled (handle)) {
if (!explorerTheme && (style & SWT.FULL_SELECTION) != 0) {
- if ((int)/*64*/OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) == OS.CLR_NONE) {
- int dwExStyle = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ if ((int)OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) == OS.CLR_NONE) {
+ int dwExStyle = (int)OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
if ((dwExStyle & OS.LVS_EX_FULLROWSELECT) == 0) {
// if ((nmcd.uItemState & OS.CDIS_FOCUS) != 0) {
if (OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED) == nmcd.dwItemSpec) {
if (handle == OS.GetFocus ()) {
- int uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ int uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
if ((uiState & OS.UISF_HIDEFOCUS) == 0) {
RECT rect = new RECT ();
rect.left = OS.LVIR_BOUNDS;
boolean oldIgnore = ignoreCustomDraw;
ignoreCustomDraw = true;
OS.SendMessage (handle, OS. LVM_GETITEMRECT, nmcd.dwItemSpec, rect);
- long /*int*/ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
- int index = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
+ long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ int index = (int)OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
RECT itemRect = new RECT ();
if (index == 0) {
itemRect.left = OS.LVIR_LABEL;
@@ -743,7 +743,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
return null;
}
-LRESULT CDDS_ITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT CDDS_ITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long wParam, long lParam) {
/*
* Bug in Windows. When the table has the extended style
* LVS_EX_FULLROWSELECT and LVM_SETBKCOLOR is used with
@@ -759,8 +759,8 @@ LRESULT CDDS_ITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
if (!ignoreCustomDraw) {
if (OS.IsWindowVisible (handle) && OS.IsWindowEnabled (handle)) {
if (!explorerTheme && (style & SWT.FULL_SELECTION) != 0) {
- if ((int)/*64*/OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) == OS.CLR_NONE) {
- int dwExStyle = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ if ((int)OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) == OS.CLR_NONE) {
+ int dwExStyle = (int)OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
if ((dwExStyle & OS.LVS_EX_FULLROWSELECT) == 0) {
if ((nmcd.uItemState & OS.CDIS_FOCUS) != 0) {
nmcd.uItemState &= ~OS.CDIS_FOCUS;
@@ -772,10 +772,10 @@ LRESULT CDDS_ITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
}
}
if (explorerTheme && !ignoreCustomDraw) {
- hotIndex = (nmcd.uItemState & OS.CDIS_HOT) != 0 ? (int)/*64*/nmcd.dwItemSpec : -1;
+ hotIndex = (nmcd.uItemState & OS.CDIS_HOT) != 0 ? (int)nmcd.dwItemSpec : -1;
if (hooks (SWT.EraseItem) && nmcd.left != nmcd.right) {
OS.SaveDC (nmcd.hdc);
- long /*int*/ hrgn = OS.CreateRectRgn (0, 0, 0, 0);
+ long hrgn = OS.CreateRectRgn (0, 0, 0, 0);
OS.SelectClipRgn (nmcd.hdc, hrgn);
OS.DeleteObject (hrgn);
}
@@ -783,7 +783,7 @@ LRESULT CDDS_ITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
return new LRESULT (OS.CDRF_NOTIFYSUBITEMDRAW | OS.CDRF_NOTIFYPOSTPAINT);
}
-LRESULT CDDS_POSTPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT CDDS_POSTPAINT (NMLVCUSTOMDRAW nmcd, long wParam, long lParam) {
if (ignoreCustomDraw) return null;
/*
* Bug in Windows. When the table has the extended style
@@ -795,8 +795,8 @@ LRESULT CDDS_POSTPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ l
*/
if (--customCount == 0 && OS.IsWindowVisible (handle)) {
if (!explorerTheme && (style & SWT.FULL_SELECTION) != 0) {
- if ((int)/*64*/OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) == OS.CLR_NONE) {
- int dwExStyle = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ if ((int)OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) == OS.CLR_NONE) {
+ int dwExStyle = (int)OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
if ((dwExStyle & OS.LVS_EX_FULLROWSELECT) == 0) {
int bits = OS.LVS_EX_FULLROWSELECT;
/*
@@ -805,8 +805,8 @@ LRESULT CDDS_POSTPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ l
* has a tooltip, the tooltip is hidden. The fix is to clear
* the tooltip before setting the bits and then reset it.
*/
- long /*int*/ hwndToolTip = OS.SendMessage (handle, OS.LVM_SETTOOLTIPS, 0, 0);
- long /*int*/ rgn = OS.CreateRectRgn (0, 0, 0, 0);
+ long hwndToolTip = OS.SendMessage (handle, OS.LVM_SETTOOLTIPS, 0, 0);
+ long rgn = OS.CreateRectRgn (0, 0, 0, 0);
int result = OS.GetUpdateRgn (handle, rgn, true);
OS.SendMessage (handle, OS.LVM_SETEXTENDEDLISTVIEWSTYLE, bits, bits);
OS.ValidateRect (handle, null);
@@ -825,7 +825,7 @@ LRESULT CDDS_POSTPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ l
return null;
}
-LRESULT CDDS_PREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT CDDS_PREPAINT (NMLVCUSTOMDRAW nmcd, long wParam, long lParam) {
if (ignoreCustomDraw) {
return new LRESULT (OS.CDRF_NOTIFYITEMDRAW | OS.CDRF_NOTIFYPOSTPAINT);
}
@@ -839,8 +839,8 @@ LRESULT CDDS_PREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lP
*/
if (customCount++ == 0 && OS.IsWindowVisible (handle)) {
if (!explorerTheme && (style & SWT.FULL_SELECTION) != 0) {
- if ((int)/*64*/OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) == OS.CLR_NONE) {
- int dwExStyle = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ if ((int)OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) == OS.CLR_NONE) {
+ int dwExStyle = (int)OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
if ((dwExStyle & OS.LVS_EX_FULLROWSELECT) != 0) {
int bits = OS.LVS_EX_FULLROWSELECT;
/*
@@ -849,8 +849,8 @@ LRESULT CDDS_PREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lP
* has a tooltip, the tooltip is hidden. The fix is to clear
* the tooltip before setting the bits and then reset it.
*/
- long /*int*/ hwndToolTip = OS.SendMessage (handle, OS.LVM_SETTOOLTIPS, 0, 0);
- long /*int*/ rgn = OS.CreateRectRgn (0, 0, 0, 0);
+ long hwndToolTip = OS.SendMessage (handle, OS.LVM_SETTOOLTIPS, 0, 0);
+ long rgn = OS.CreateRectRgn (0, 0, 0, 0);
int result = OS.GetUpdateRgn (handle, rgn, true);
OS.SendMessage (handle, OS.LVM_SETEXTENDEDLISTVIEWSTYLE, bits, 0);
OS.ValidateRect (handle, null);
@@ -876,8 +876,8 @@ LRESULT CDDS_PREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lP
RECT rect = new RECT ();
OS.SetRect (rect, nmcd.left, nmcd.top, nmcd.right, nmcd.bottom);
if (explorerTheme && columnCount == 0) {
- long /*int*/ hDC = nmcd.hdc;
- if (OS.IsWindowEnabled (handle) || findImageControl () != null) {
+ long hDC = nmcd.hdc;
+ if (OS.IsWindowEnabled (handle) || findImageControl () != null || hasCustomBackground()) {
drawBackground (hDC, rect);
} else {
fillBackground (hDC, OS.GetSysColor (OS.COLOR_3DFACE), rect);
@@ -888,7 +888,7 @@ LRESULT CDDS_PREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lP
fillImageBackground (nmcd.hdc, control, rect, 0, 0);
} else {
final boolean enabled = OS.IsWindowEnabled (handle);
- if (enabled && (int)/*64*/OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) == OS.CLR_NONE || !enabled && hasCustomBackground()) {
+ if (enabled && (int)OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) == OS.CLR_NONE || !enabled && hasCustomBackground()) {
if (control == null) control = this;
fillBackground (nmcd.hdc, control.getBackgroundPixel (), rect);
if (OS.IsAppThemed ()) {
@@ -899,7 +899,7 @@ LRESULT CDDS_PREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lP
int clrSortBk = getSortColumnPixel ();
RECT columnRect = new RECT (), headerRect = new RECT ();
OS.GetClientRect (handle, columnRect);
- long /*int*/ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect) != 0) {
OS.MapWindowPoints (hwndHeader, handle, headerRect, 2);
columnRect.left = headerRect.left;
@@ -918,10 +918,10 @@ LRESULT CDDS_PREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lP
return new LRESULT (OS.CDRF_NOTIFYITEMDRAW | OS.CDRF_NOTIFYPOSTPAINT);
}
-LRESULT CDDS_SUBITEMPOSTPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT CDDS_SUBITEMPOSTPAINT (NMLVCUSTOMDRAW nmcd, long wParam, long lParam) {
if (ignoreCustomDraw) return null;
if (nmcd.left == nmcd.right) return new LRESULT (OS.CDRF_DODEFAULT);
- long /*int*/ hDC = nmcd.hdc;
+ long hDC = nmcd.hdc;
if (ignoreDrawForeground) OS.RestoreDC (hDC, -1);
if (OS.IsWindowVisible (handle)) {
/*
@@ -933,13 +933,13 @@ LRESULT CDDS_SUBITEMPOSTPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*
* Update region is saved and restored around LVM_SETSELECTEDCOLUMN
* to prevent infinite WM_PAINT on Vista.
*/
- if ((int)/*64*/OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) != OS.CLR_NONE) {
+ if ((int)OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) != OS.CLR_NONE) {
if ((sortDirection & (SWT.UP | SWT.DOWN)) != 0) {
if (sortColumn != null && !sortColumn.isDisposed ()) {
- int oldColumn = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETSELECTEDCOLUMN, 0, 0);
+ int oldColumn = (int)OS.SendMessage (handle, OS.LVM_GETSELECTEDCOLUMN, 0, 0);
if (oldColumn == -1) {
int newColumn = indexOf (sortColumn);
- long /*int*/ rgn = OS.CreateRectRgn (0, 0, 0, 0);
+ long rgn = OS.CreateRectRgn (0, 0, 0, 0);
int result = OS.GetUpdateRgn (handle, rgn, true);
OS.SendMessage (handle, OS.LVM_SETSELECTEDCOLUMN, newColumn, 0);
OS.ValidateRect (handle, null);
@@ -950,7 +950,7 @@ LRESULT CDDS_SUBITEMPOSTPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*
}
}
if (hooks (SWT.PaintItem)) {
- TableItem item = _getItem ((int)/*64*/nmcd.dwItemSpec);
+ TableItem item = _getItem ((int)nmcd.dwItemSpec);
sendPaintItemEvent (item, nmcd);
//widget could be disposed at this point
}
@@ -964,8 +964,8 @@ LRESULT CDDS_SUBITEMPOSTPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*
return null;
}
-LRESULT CDDS_SUBITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lParam) {
- long /*int*/ hDC = nmcd.hdc;
+LRESULT CDDS_SUBITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long wParam, long lParam) {
+ long hDC = nmcd.hdc;
if (explorerTheme && !ignoreCustomDraw && hooks (SWT.EraseItem) && (nmcd.left != nmcd.right)) {
OS.RestoreDC (hDC, -1);
}
@@ -979,9 +979,9 @@ LRESULT CDDS_SUBITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*i
*
* NOTE: Force the item to be created if it does not exist.
*/
- TableItem item = _getItem ((int)/*64*/nmcd.dwItemSpec);
+ TableItem item = _getItem ((int)nmcd.dwItemSpec);
if (item == null || item.isDisposed ()) return null;
- long /*int*/ hFont = item.fontHandle (nmcd.iSubItem);
+ long hFont = item.fontHandle (nmcd.iSubItem);
if (hFont != -1) OS.SelectObject (hDC, hFont);
if (ignoreCustomDraw || (nmcd.left == nmcd.right)) {
return new LRESULT (hFont == -1 ? OS.CDRF_DODEFAULT : OS.CDRF_NEWFONT);
@@ -992,7 +992,7 @@ LRESULT CDDS_SUBITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*i
if (OS.IsWindowVisible (handle)) {
Event measureEvent = null;
if (hooks (SWT.MeasureItem)) {
- measureEvent = sendMeasureItemEvent (item, (int)/*64*/nmcd.dwItemSpec, nmcd.iSubItem, nmcd.hdc);
+ measureEvent = sendMeasureItemEvent (item, (int)nmcd.dwItemSpec, nmcd.iSubItem, nmcd.hdc);
if (isDisposed () || item.isDisposed ()) return null;
}
if (hooks (SWT.EraseItem)) {
@@ -1018,7 +1018,7 @@ LRESULT CDDS_SUBITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*i
final boolean enabled = OS.IsWindowEnabled (handle);
if (OS.IsWindowVisible (handle) && enabled) {
if (!explorerTheme && !ignoreDrawSelection && (style & SWT.FULL_SELECTION) != 0) {
- int bits = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ int bits = (int)OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
if ((bits & OS.LVS_EX_FULLROWSELECT) == 0) {
/*
* Bug in Windows. For some reason, CDIS_SELECTED always set,
@@ -1028,8 +1028,8 @@ LRESULT CDDS_SUBITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*i
LVITEM lvItem = new LVITEM ();
lvItem.mask = OS.LVIF_STATE;
lvItem.stateMask = OS.LVIS_SELECTED;
- lvItem.iItem = (int)/*64*/nmcd.dwItemSpec;
- long /*int*/ result = OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
+ lvItem.iItem = (int)nmcd.dwItemSpec;
+ long result = OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
if ((result != 0 && (lvItem.state & OS.LVIS_SELECTED) != 0)) {
int clrSelection = -1;
if (nmcd.iSubItem == 0) {
@@ -1051,7 +1051,7 @@ LRESULT CDDS_SUBITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*i
}
}
if (clrSelection != -1) {
- RECT rect = item.getBounds ((int)/*64*/nmcd.dwItemSpec, nmcd.iSubItem, true, nmcd.iSubItem != 0, true, false, hDC);
+ RECT rect = item.getBounds ((int)nmcd.dwItemSpec, nmcd.iSubItem, true, nmcd.iSubItem != 0, true, false, hDC);
fillBackground (hDC, clrSelection, rect);
}
}
@@ -1069,7 +1069,7 @@ LRESULT CDDS_SUBITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*i
boolean hasAttributes = true;
if (hFont == -1 && clrText == -1 && clrTextBk == -1) {
if (item.cellForeground == null && item.cellBackground == null && item.cellFont == null) {
- int count = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
if (count == 1) hasAttributes = false;
}
}
@@ -1084,7 +1084,7 @@ LRESULT CDDS_SUBITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*i
Control control = findBackgroundControl ();
if (control == null) control = this;
if (control.backgroundImage == null) {
- if ((int)/*64*/OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) != OS.CLR_NONE) {
+ if ((int)OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) != OS.CLR_NONE) {
nmcd.clrTextBk = control.getBackgroundPixel ();
}
}
@@ -1107,9 +1107,9 @@ LRESULT CDDS_SUBITEMPREPAINT (NMLVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*i
* to prevent infinite WM_PAINT on Vista.
*/
if ((enabled && clrTextBk != -1) || (!enabled && hasCustomBackground())) {
- int oldColumn = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETSELECTEDCOLUMN, 0, 0);
+ int oldColumn = (int)OS.SendMessage (handle, OS.LVM_GETSELECTEDCOLUMN, 0, 0);
if (oldColumn != -1 && oldColumn == nmcd.iSubItem) {
- long /*int*/ rgn = OS.CreateRectRgn (0, 0, 0, 0);
+ long rgn = OS.CreateRectRgn (0, 0, 0, 0);
int result = OS.GetUpdateRgn (handle, rgn, true);
OS.SendMessage (handle, OS.LVM_SETSELECTEDCOLUMN, -1, 0);
OS.ValidateRect (handle, null);
@@ -1168,12 +1168,6 @@ boolean checkData (TableItem item, int index, boolean redraw) {
}
@Override
-boolean checkHandle (long /*int*/ hwnd) {
- if (hwnd == handle) return true;
- return hwnd == OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
-}
-
-@Override
protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
@@ -1201,7 +1195,7 @@ protected void checkSubclass () {
*/
public void clear (int index) {
checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
TableItem item = _getItem (index, false);
if (item != null) {
@@ -1258,7 +1252,7 @@ public void clear (int index) {
public void clear (int start, int end) {
checkWidget ();
if (start > end) return;
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (!(0 <= start && start <= end && end < count)) {
error (SWT.ERROR_INVALID_RANGE);
}
@@ -1333,7 +1327,7 @@ public void clear (int [] indices) {
checkWidget ();
if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
if (indices.length == 0) return;
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
for (int i=0; i<indices.length; i++) {
if (!(0 <= indices [i] && indices [i] < count)) {
error (SWT.ERROR_INVALID_RANGE);
@@ -1398,7 +1392,7 @@ public void clearAll () {
checkWidget ();
LVITEM lvItem = null;
boolean cleared = false;
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
for (int i=0; i<count; i++) {
TableItem item = _getItem (i, false);
if (item != null) {
@@ -1469,18 +1463,18 @@ public void clearAll () {
bits |= wHint & 0xFFFF;
} else {
int width = 0;
- int count = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
for (int i=0; i<count; i++) {
width += OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, i, 0);
}
bits |= width & 0xFFFF;
}
- long /*int*/ result = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, -1, OS.MAKELPARAM (bits, 0xFFFF));
+ long result = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, -1, OS.MAKELPARAM (bits, 0xFFFF));
int width = OS.LOWORD (result);
- long /*int*/ empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
- long /*int*/ oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
+ long empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
+ long oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
int itemHeight = OS.HIWORD (oneItem) - OS.HIWORD (empty);
- height += (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0) * itemHeight;
+ height += (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0) * itemHeight;
if (width == 0) width = DEFAULT_WIDTH;
if (height == 0) height = DEFAULT_HEIGHT;
if (wHint != SWT.DEFAULT) width = wHint;
@@ -1509,19 +1503,12 @@ void createHandle () {
/* Get the header window handle */
hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
-
- /*
- * This code is intentionally commented. According to
- * the documentation, setting the default item size is
- * supposed to improve performance. By experimentation,
- * this does not seem to have much of an effect.
- */
-// OS.SendMessage (handle, OS.LVM_SETITEMCOUNT, 1024 * 2, 0);
+ maybeEnableDarkSystemTheme(hwndHeader);
/* Set the checkbox image list */
if ((style & SWT.CHECK) != 0) {
- long /*int*/ empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
- long /*int*/ oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
+ long empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
+ long oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
int width = OS.HIWORD (oneItem) - OS.HIWORD (empty), height = width;
setCheckboxImageList (width, height, false);
OS.SendMessage (handle, OS. LVM_SETCALLBACKMASK, OS.LVIS_STATEIMAGEMASK, 0);
@@ -1539,7 +1526,7 @@ void createHandle () {
* The control will not destroy a font that it did not
* create.
*/
- long /*int*/ hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ long hFont = OS.GetStockObject (OS.SYSTEM_FONT);
OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);
/*
@@ -1551,8 +1538,8 @@ void createHandle () {
*/
LVCOLUMN lvColumn = new LVCOLUMN ();
lvColumn.mask = OS.LVCF_TEXT | OS.LVCF_WIDTH;
- long /*int*/ hHeap = OS.GetProcessHeap ();
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof);
+ long hHeap = OS.GetProcessHeap ();
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof);
lvColumn.pszText = pszText;
OS.SendMessage (handle, OS.LVM_INSERTCOLUMN, 0, lvColumn);
OS.HeapFree (hHeap, 0, pszText);
@@ -1573,9 +1560,9 @@ void createHandle () {
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
int bits2 = OS.GetWindowLong (hwndHeader, OS.GWL_EXSTYLE);
OS.SetWindowLong (hwndHeader, OS.GWL_EXSTYLE, bits2 | OS.WS_EX_LAYOUTRTL);
- long /*int*/ hwndTooltop = OS.SendMessage (handle, OS.LVM_GETTOOLTIPS, 0, 0);
- int bits3 = OS.GetWindowLong (hwndTooltop, OS.GWL_EXSTYLE);
- OS.SetWindowLong (hwndTooltop, OS.GWL_EXSTYLE, bits3 | OS.WS_EX_LAYOUTRTL);
+ long hwndTooltip = OS.SendMessage (handle, OS.LVM_GETTOOLTIPS, 0, 0);
+ int bits3 = OS.GetWindowLong (hwndTooltip, OS.GWL_EXSTYLE);
+ OS.SetWindowLong (hwndTooltip, OS.GWL_EXSTYLE, bits3 | OS.WS_EX_LAYOUTRTL);
}
}
@@ -1603,6 +1590,7 @@ void createHeaderToolTips () {
OS.GetModuleHandle (null),
null);
if (headerToolTipHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ maybeEnableDarkSystemTheme(headerToolTipHandle);
/*
* Feature in Windows. Despite the fact that the
* tool tip text contains \r\n, the tooltip will
@@ -1615,7 +1603,7 @@ void createHeaderToolTips () {
void createItem (TableColumn column, int index) {
if (!(0 <= index && index <= columnCount)) error (SWT.ERROR_INVALID_RANGE);
- int oldColumn = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETSELECTEDCOLUMN, 0, 0);
+ int oldColumn = (int)OS.SendMessage (handle, OS.LVM_GETSELECTEDCOLUMN, 0, 0);
if (oldColumn >= index) {
OS.SendMessage (handle, OS.LVM_SETSELECTEDCOLUMN, oldColumn + 1, 0);
}
@@ -1624,7 +1612,7 @@ void createItem (TableColumn column, int index) {
System.arraycopy (columns, 0, newColumns, 0, columns.length);
columns = newColumns;
}
- int itemCount = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int itemCount = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
for (int i=0; i<itemCount; i++) {
TableItem item = _getItem (i, false);
if (item != null) {
@@ -1705,9 +1693,9 @@ void createItem (TableColumn column, int index) {
OS.SendMessage (handle, OS.LVM_GETCOLUMN, 1, lvColumn);
int width = lvColumn.cx;
int cchTextMax = 1024;
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
int byteCount = cchTextMax * TCHAR.sizeof;
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
lvColumn.mask = OS.LVCF_TEXT | OS.LVCF_IMAGE | OS.LVCF_WIDTH | OS.LVCF_FMT;
lvColumn.pszText = pszText;
lvColumn.cchTextMax = cchTextMax;
@@ -1777,7 +1765,7 @@ void createItem (TableColumn column, int index) {
}
void createItem (TableItem item, int index) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
_checkGrow (count);
LVITEM lvItem = new LVITEM ();
@@ -1799,7 +1787,7 @@ void createItem (TableItem item, int index) {
/* Insert the item */
setDeferResize (true);
ignoreSelect = ignoreShrink = true;
- int result = (int)/*64*/OS.SendMessage (handle, OS.LVM_INSERTITEM, 0, lvItem);
+ int result = (int)OS.SendMessage (handle, OS.LVM_INSERTITEM, 0, lvItem);
ignoreSelect = ignoreShrink = false;
if (result == -1) error (SWT.ERROR_ITEM_NOT_ADDED);
_insertItem (index, item, count);
@@ -1855,14 +1843,14 @@ public void deselect (int [] indices) {
if (indices.length == 0) return;
LVITEM lvItem = new LVITEM ();
lvItem.stateMask = OS.LVIS_SELECTED;
- for (int i=0; i<indices.length; i++) {
+ for (int index : indices) {
/*
* An index of -1 will apply the change to all
* items. Ensure that indices are greater than -1.
*/
- if (indices [i] >= 0) {
+ if (index >= 0) {
ignoreSelect = true;
- OS.SendMessage (handle, OS.LVM_SETITEMSTATE, indices [i], lvItem);
+ OS.SendMessage (handle, OS.LVM_SETITEMSTATE, index, lvItem);
ignoreSelect = false;
}
}
@@ -1911,7 +1899,7 @@ public void deselect (int index) {
*/
public void deselect (int start, int end) {
checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (start == 0 && end == count - 1) {
deselectAll ();
} else {
@@ -1954,7 +1942,7 @@ void destroyItem (TableColumn column) {
if (columns [index] == column) break;
index++;
}
- int oldColumn = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETSELECTEDCOLUMN, 0, 0);
+ int oldColumn = (int)OS.SendMessage (handle, OS.LVM_GETSELECTEDCOLUMN, 0, 0);
if (oldColumn == index) {
OS.SendMessage (handle, OS.LVM_SETSELECTEDCOLUMN, -1, 0);
} else {
@@ -1984,9 +1972,9 @@ void destroyItem (TableColumn column) {
if (columnCount > 1) {
index = 1;
int cchTextMax = 1024;
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
int byteCount = cchTextMax * TCHAR.sizeof;
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
LVCOLUMN lvColumn = new LVCOLUMN ();
lvColumn.mask = OS.LVCF_TEXT | OS.LVCF_IMAGE | OS.LVCF_WIDTH | OS.LVCF_FMT;
lvColumn.pszText = pszText;
@@ -1997,8 +1985,8 @@ void destroyItem (TableColumn column) {
OS.SendMessage (handle, OS.LVM_SETCOLUMN, 0, lvColumn);
if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
} else {
- long /*int*/ hHeap = OS.GetProcessHeap ();
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof);
+ long hHeap = OS.GetProcessHeap ();
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof);
LVCOLUMN lvColumn = new LVCOLUMN ();
lvColumn.mask = OS.LVCF_TEXT | OS.LVCF_IMAGE | OS.LVCF_WIDTH | OS.LVCF_FMT;
lvColumn.pszText = pszText;
@@ -2009,7 +1997,7 @@ void destroyItem (TableColumn column) {
HDITEM hdItem = new HDITEM ();
hdItem.mask = OS.HDI_FORMAT;
hdItem.fmt = OS.HDF_LEFT;
- long /*int*/ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
OS.SendMessage (hwndHeader, OS.HDM_SETITEM, index, hdItem);
}
setRedraw (true);
@@ -2029,7 +2017,7 @@ void destroyItem (TableColumn column) {
lvItem.mask = OS.LVIF_TEXT | OS.LVIF_IMAGE;
lvItem.pszText = OS.LPSTR_TEXTCALLBACK;
lvItem.iImage = OS.I_IMAGECALLBACK;
- int itemCount = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int itemCount = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
for (int i=0; i<itemCount; i++) {
lvItem.iItem = i;
OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
@@ -2044,7 +2032,7 @@ void destroyItem (TableColumn column) {
if (first) index = 0;
System.arraycopy (columns, index + 1, columns, index, --columnCount - index);
columns [columnCount] = null;
- int itemCount = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int itemCount = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
for (int i=0; i<itemCount; i++) {
TableItem item = _getItem (i, false);
if (item != null) {
@@ -2119,9 +2107,9 @@ void destroyItem (TableColumn column) {
int count = 0;
int oldIndex = oldOrder [orderIndex];
int [] newOrder = new int [columnCount];
- for (int i=0; i<oldOrder.length; i++) {
- if (oldOrder [i] != oldIndex) {
- int newIndex = oldOrder [i] <= oldIndex ? oldOrder [i] : oldOrder [i] - 1;
+ for (int element : oldOrder) {
+ if (element != oldIndex) {
+ int newIndex = element <= oldIndex ? element : element - 1;
newOrder [count++] = newIndex;
}
}
@@ -2145,9 +2133,9 @@ void destroyItem (TableColumn column) {
newColumns [i - orderIndex] = columns [newOrder [i]];
newColumns [i - orderIndex].updateToolTip (newOrder [i]);
}
- for (int i=0; i<newColumns.length; i++) {
- if (!newColumns [i].isDisposed ()) {
- newColumns [i].sendEvent (SWT.Move);
+ for (TableColumn newColumn : newColumns) {
+ if (!newColumn.isDisposed ()) {
+ newColumn.sendEvent (SWT.Move);
}
}
}
@@ -2163,7 +2151,7 @@ void destroyItem (TableColumn column) {
}
void destroyItem (TableItem item) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
int index = 0;
while (index < count) {
if (_getItem (index, false) == item) break;
@@ -2172,7 +2160,7 @@ void destroyItem (TableItem item) {
if (index == count) return;
setDeferResize (true);
ignoreSelect = ignoreShrink = true;
- long /*int*/ code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
+ long code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
ignoreSelect = ignoreShrink = false;
if (code == 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
_removeItem (index, count);
@@ -2189,11 +2177,11 @@ void fixCheckboxImageList (boolean fixScroll) {
* the state image list to be the same size as the image list.
*/
if ((style & SWT.CHECK) == 0) return;
- long /*int*/ hImageList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0);
+ long hImageList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0);
if (hImageList == 0) return;
int [] cx = new int [1], cy = new int [1];
OS.ImageList_GetIconSize (hImageList, cx, cy);
- long /*int*/ hStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
+ long hStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
if (hStateList == 0) return;
int [] stateCx = new int [1], stateCy = new int [1];
OS.ImageList_GetIconSize (hStateList, stateCx, stateCy);
@@ -2203,7 +2191,7 @@ void fixCheckboxImageList (boolean fixScroll) {
void fixCheckboxImageListColor (boolean fixScroll) {
if ((style & SWT.CHECK) == 0) return;
- long /*int*/ hStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
+ long hStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
if (hStateList == 0) return;
int [] cx = new int [1], cy = new int [1];
OS.ImageList_GetIconSize (hStateList, cx, cy);
@@ -2334,7 +2322,7 @@ public TableColumn [] getColumns () {
int getFocusIndex () {
// checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
+ return (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
}
/**
@@ -2460,7 +2448,7 @@ public boolean getHeaderVisible () {
*/
public TableItem getItem (int index) {
checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
return _getItem (index);
}
@@ -2495,7 +2483,7 @@ public TableItem getItem (Point point) {
}
TableItem getItemInPixels (Point point) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (count == 0) return null;
LVHITTESTINFO pinfo = new LVHITTESTINFO ();
pinfo.x = point.x;
@@ -2512,7 +2500,7 @@ TableItem getItemInPixels (Point point) {
RECT rect = new RECT ();
rect.left = OS.LVIR_ICON;
ignoreCustomDraw = true;
- long /*int*/ code = OS.SendMessage (handle, OS.LVM_GETITEMRECT, 0, rect);
+ long code = OS.SendMessage (handle, OS.LVM_GETITEMRECT, 0, rect);
ignoreCustomDraw = false;
if (code != 0) {
pinfo.x = rect.left;
@@ -2575,7 +2563,7 @@ TableItem getItemInPixels (Point point) {
*/
public int getItemCount () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ return (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
}
/**
@@ -2596,8 +2584,8 @@ public int getItemHeight () {
int getItemHeightInPixels () {
if (!painted && hooks (SWT.MeasureItem)) hitTestSelection (0, 0, 0);
- long /*int*/ empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
- long /*int*/ oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
+ long empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
+ long oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
return OS.HIWORD (oneItem) - OS.HIWORD (empty);
}
@@ -2619,7 +2607,7 @@ int getItemHeightInPixels () {
*/
public TableItem [] getItems () {
checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
TableItem [] result = new TableItem [count];
if ((style & SWT.VIRTUAL) != 0) {
for (int i=0; i<count; i++) {
@@ -2655,7 +2643,7 @@ public boolean getLinesVisible () {
}
private boolean _getLinesVisible() {
- int bits = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ int bits = (int)OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
return (bits & OS.LVS_EX_GRIDLINES) != 0;
}
@@ -2677,9 +2665,9 @@ private boolean _getLinesVisible() {
*/
public TableItem [] getSelection () {
checkWidget ();
- int i = -1, j = 0, count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETSELECTEDCOUNT, 0, 0);
+ int i = -1, j = 0, count = (int)OS.SendMessage (handle, OS.LVM_GETSELECTEDCOUNT, 0, 0);
TableItem [] result = new TableItem [count];
- while ((i = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, i, OS.LVNI_SELECTED)) != -1) {
+ while ((i = (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, i, OS.LVNI_SELECTED)) != -1) {
result [j++] = _getItem (i);
}
return result;
@@ -2697,7 +2685,7 @@ public TableItem [] getSelection () {
*/
public int getSelectionCount () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.LVM_GETSELECTEDCOUNT, 0, 0);
+ return (int)OS.SendMessage (handle, OS.LVM_GETSELECTEDCOUNT, 0, 0);
}
/**
@@ -2713,11 +2701,11 @@ public int getSelectionCount () {
*/
public int getSelectionIndex () {
checkWidget ();
- int focusIndex = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
- int selectedIndex = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_SELECTED);
+ int focusIndex = (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
+ int selectedIndex = (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_SELECTED);
if (focusIndex == selectedIndex) return selectedIndex;
int i = -1;
- while ((i = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, i, OS.LVNI_SELECTED)) != -1) {
+ while ((i = (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, i, OS.LVNI_SELECTED)) != -1) {
if (i == focusIndex) return i;
}
return selectedIndex;
@@ -2741,10 +2729,16 @@ public int getSelectionIndex () {
*/
public int [] getSelectionIndices () {
checkWidget ();
- int i = -1, j = 0, count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETSELECTEDCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETSELECTEDCOUNT, 0, 0);
int [] result = new int [count];
- while ((i = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, i, OS.LVNI_SELECTED)) != -1) {
- result [j++] = i;
+ int lastIndex = -1;
+ for (int i = 0; i < count; i++) {
+ lastIndex = (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, lastIndex, OS.LVNI_SELECTED);
+ if (lastIndex == -1) {
+ break;
+ }
+
+ result[i] = lastIndex;
}
return result;
}
@@ -2816,11 +2810,11 @@ public int getTopIndex () {
* is displaying blank lines at the top of the controls. The
* fix is to check for a negative number and return zero instead.
*/
- return Math.max (0, (int)/*64*/OS.SendMessage (handle, OS.LVM_GETTOPINDEX, 0, 0));
+ return Math.max (0, (int)OS.SendMessage (handle, OS.LVM_GETTOPINDEX, 0, 0));
}
boolean hasChildren () {
- long /*int*/ hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
+ long hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
while (hwndChild != 0) {
if (hwndChild != hwndHeader) return true;
hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT);
@@ -2829,16 +2823,16 @@ boolean hasChildren () {
}
boolean hitTestSelection (int index, int x, int y) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (count == 0) return false;
if (!hooks (SWT.MeasureItem)) return false;
boolean result = false;
if (0 <= index && index < count) {
TableItem item = _getItem (index);
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ oldFont = 0, newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ long hDC = OS.GetDC (handle);
+ long oldFont = 0, newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
- long /*int*/ hFont = item.fontHandle (0);
+ long hFont = item.fontHandle (0);
if (hFont != -1) hFont = OS.SelectObject (hDC, hFont);
Event event = sendMeasureItemEvent (item, index, 0, hDC);
if (event.getBoundsInPixels ().contains (x, y)) result = true;
@@ -2862,7 +2856,7 @@ int imageIndex (Image image, int column) {
imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, bounds.width, bounds.height);
int index = imageList.indexOf (image);
if (index == -1) index = imageList.add (image);
- long /*int*/ hImageList = imageList.getHandle ();
+ long hImageList = imageList.getHandle ();
/*
* Bug in Windows. Making any change to an item that
* changes the item height of a table while the table
@@ -2879,7 +2873,7 @@ int imageIndex (Image image, int column) {
}
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
if (headerImageList != null) {
- long /*int*/ hHeaderImageList = headerImageList.getHandle ();
+ long hHeaderImageList = headerImageList.getHandle ();
OS.SendMessage (hwndHeader, OS.HDM_SETIMAGELIST, 0, hHeaderImageList);
}
fixCheckboxImageList (false);
@@ -2902,7 +2896,7 @@ int imageIndexHeader (Image image) {
headerImageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, bounds.width, bounds.height);
int index = headerImageList.indexOf (image);
if (index == -1) index = headerImageList.add (image);
- long /*int*/ hImageList = headerImageList.getHandle ();
+ long hImageList = headerImageList.getHandle ();
OS.SendMessage (hwndHeader, OS.HDM_SETIMAGELIST, 0, hImageList);
return index;
}
@@ -2959,7 +2953,7 @@ public int indexOf (TableItem item) {
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
//TODO - find other loops that can be optimized
if (keys == null) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (1 <= lastIndexOf && lastIndexOf < count - 1) {
if (_getItem (lastIndexOf, false) == item) return lastIndexOf;
if (_getItem (lastIndexOf + 1, false) == item) return ++lastIndexOf;
@@ -3010,11 +3004,16 @@ public boolean isSelected (int index) {
lvItem.mask = OS.LVIF_STATE;
lvItem.stateMask = OS.LVIS_SELECTED;
lvItem.iItem = index;
- long /*int*/ result = OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
+ long result = OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
return (result != 0) && ((lvItem.state & OS.LVIS_SELECTED) != 0);
}
@Override
+boolean isUseWsBorder () {
+ return super.isUseWsBorder () || ((display != null) && display.useWsBorderTable);
+}
+
+@Override
void register () {
super.register ();
if (hwndHeader != 0) display.addControl (hwndHeader, this);
@@ -3023,7 +3022,7 @@ void register () {
@Override
void releaseChildren (boolean destroy) {
if (_hasItems ()) {
- int itemCount = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int itemCount = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (keys == null) {
for (int i=0; i<itemCount; i++) {
TableItem item = _getItem (i, false);
@@ -3061,7 +3060,7 @@ void releaseWidget () {
display.releaseImageList (headerImageList);
}
imageList = headerImageList = null;
- long /*int*/ hStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
+ long hStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, 0);
if (hStateList != 0) OS.ImageList_Destroy (hStateList);
if (headerToolTipHandle != 0) OS.DestroyWindow (headerToolTipHandle);
@@ -3091,19 +3090,18 @@ public void remove (int [] indices) {
System.arraycopy (indices, 0, newIndices, 0, indices.length);
sort (newIndices);
int start = newIndices [newIndices.length - 1], end = newIndices [0];
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (!(0 <= start && start <= end && end < count)) {
error (SWT.ERROR_INVALID_RANGE);
}
setDeferResize (true);
int last = -1;
- for (int i=0; i<newIndices.length; i++) {
- int index = newIndices [i];
+ for (int index : newIndices) {
if (index != last) {
TableItem item = _getItem (index, false);
if (item != null && !item.isDisposed ()) item.release (false);
ignoreSelect = ignoreShrink = true;
- long /*int*/ code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
+ long code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
ignoreSelect = ignoreShrink = false;
if (code == 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
_removeItem(index, count);
@@ -3131,13 +3129,13 @@ public void remove (int [] indices) {
*/
public void remove (int index) {
checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
TableItem item = _getItem (index, false);
if (item != null && !item.isDisposed ()) item.release (false);
setDeferResize (true);
ignoreSelect = ignoreShrink = true;
- long /*int*/ code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
+ long code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
ignoreSelect = ignoreShrink = false;
if (code == 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
_removeItem (index, count);
@@ -3165,7 +3163,7 @@ public void remove (int index) {
public void remove (int start, int end) {
checkWidget ();
if (start > end) return;
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (!(0 <= start && start <= end && end < count)) {
error (SWT.ERROR_INVALID_RANGE);
}
@@ -3178,7 +3176,7 @@ public void remove (int start, int end) {
TableItem item = _getItem (index, false);
if (item != null && !item.isDisposed ()) item.release (false);
ignoreSelect = ignoreShrink = true;
- long /*int*/ code = OS.SendMessage (handle, OS.LVM_DELETEITEM, start, 0);
+ long code = OS.SendMessage (handle, OS.LVM_DELETEITEM, start, 0);
ignoreSelect = ignoreShrink = false;
if (code == 0) break;
index++;
@@ -3205,14 +3203,14 @@ public void remove (int start, int end) {
*/
public void removeAll () {
checkWidget ();
- int itemCount = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int itemCount = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
for (int i=0; i<itemCount; i++) {
TableItem item = _getItem (i, false);
if (item != null && !item.isDisposed ()) item.release (false);
}
setDeferResize (true);
ignoreSelect = ignoreShrink = true;
- long /*int*/ code = OS.SendMessage (handle, OS.LVM_DELETEALLITEMS, 0, 0);
+ long code = OS.SendMessage (handle, OS.LVM_DELETEALLITEMS, 0, 0);
ignoreSelect = ignoreShrink = false;
if (code == 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
setTableEmpty ();
@@ -3278,8 +3276,8 @@ public void select (int [] indices) {
for (int i=length-1; i>=0; --i) {
/*
* An index of -1 will apply the change to all
- * items. Ensure that indices are greater than -1.
- */
+ * items. Ensure that indices are greater than -1.
+ */
if (indices [i] >= 0) {
ignoreSelect = true;
OS.SendMessage (handle, OS.LVM_SETITEMSTATE, indices [i], lvItem);
@@ -3291,7 +3289,7 @@ public void select (int [] indices) {
@Override
void reskinChildren (int flags) {
if (_hasItems ()) {
- int itemCount = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int itemCount = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
for (int i=0; i<itemCount; i++) {
TableItem item = _getItem (i, false);
if (item != null) item.reskin (flags);
@@ -3359,7 +3357,7 @@ public void select (int index) {
public void select (int start, int end) {
checkWidget ();
if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && start != end)) return;
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (count == 0 || start >= count) return;
start = Math.max (0, start);
end = Math.min (end, count - 1);
@@ -3404,21 +3402,11 @@ public void selectAll () {
ignoreSelect = false;
}
-void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long /*int*/ lParam, Event measureEvent) {
- long /*int*/ hDC = nmcd.hdc;
+void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long lParam, Event measureEvent) {
+ long hDC = nmcd.hdc;
int clrText = item.cellForeground != null ? item.cellForeground [nmcd.iSubItem] : -1;
if (clrText == -1) clrText = item.foreground;
- int clrTextBk = -1;
- if (OS.IsAppThemed ()) {
- if (sortColumn != null && sortDirection != SWT.NONE) {
- if (findImageControl () == null) {
- if (indexOf (sortColumn) == nmcd.iSubItem) {
- clrTextBk = getSortColumnPixel ();
- }
- }
- }
- }
- clrTextBk = item.cellBackground != null ? item.cellBackground [nmcd.iSubItem] : -1;
+ int clrTextBk = item.cellBackground != null ? item.cellBackground [nmcd.iSubItem] : -1;
if (clrTextBk == -1) clrTextBk = item.background;
/*
* Bug in Windows. For some reason, CDIS_SELECTED always set,
@@ -3428,8 +3416,8 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long /*int*/ lPara
LVITEM lvItem = new LVITEM ();
lvItem.mask = OS.LVIF_STATE;
lvItem.stateMask = OS.LVIS_SELECTED;
- lvItem.iItem = (int)/*64*/nmcd.dwItemSpec;
- long /*int*/ result = OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
+ lvItem.iItem = (int)nmcd.dwItemSpec;
+ long result = OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
boolean selected = (result != 0 && (lvItem.state & OS.LVIS_SELECTED) != 0);
GCData data = new GCData ();
data.device = display;
@@ -3477,10 +3465,10 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long /*int*/ lPara
if (selected) clrSelectionBk = data.background;
}
data.font = item.getFont (nmcd.iSubItem);
- data.uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ data.uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
int nSavedDC = OS.SaveDC (hDC);
GC gc = GC.win32_new (hDC, data);
- RECT cellRect = item.getBounds ((int)/*64*/nmcd.dwItemSpec, nmcd.iSubItem, true, true, true, true, hDC);
+ RECT cellRect = item.getBounds ((int)nmcd.dwItemSpec, nmcd.iSubItem, true, true, true, true, hDC);
Event event = new Event ();
event.item = item;
event.gc = gc;
@@ -3490,7 +3478,7 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long /*int*/ lPara
if (OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED) == nmcd.dwItemSpec) {
if (nmcd.iSubItem == 0 || (style & SWT.FULL_SELECTION) != 0) {
if (handle == OS.GetFocus ()) {
- int uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ int uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
if ((uiState & OS.UISF_HIDEFOCUS) == 0) event.detail |= SWT.FOCUSED;
}
}
@@ -3535,14 +3523,14 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long /*int*/ lPara
boolean firstColumn = nmcd.iSubItem == OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
if (ignoreDrawForeground && ignoreDrawHot && !drawDrophilited) {
if (!ignoreDrawBackground && drawBackground) {
- RECT backgroundRect = item.getBounds ((int)/*64*/nmcd.dwItemSpec, nmcd.iSubItem, true, false, true, false, hDC);
+ RECT backgroundRect = item.getBounds ((int)nmcd.dwItemSpec, nmcd.iSubItem, true, false, true, false, hDC);
fillBackground (hDC, clrTextBk, backgroundRect);
}
}
focusRect = null;
if (!ignoreDrawHot || !ignoreDrawSelection || !ignoreDrawFocus || drawDrophilited) {
boolean fullText = (style & SWT.FULL_SELECTION) != 0 || !firstColumn;
- RECT textRect = item.getBounds ((int)/*64*/nmcd.dwItemSpec, nmcd.iSubItem, true, false, fullText, false, hDC);
+ RECT textRect = item.getBounds ((int)nmcd.dwItemSpec, nmcd.iSubItem, true, false, fullText, false, hDC);
if ((style & SWT.FULL_SELECTION) == 0) {
if (measureEvent != null) {
Rectangle boundInPixels = measureEvent.getBoundsInPixels();
@@ -3554,20 +3542,24 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long /*int*/ lPara
focusRect = textRect;
}
}
+
+ // Draw selection background
if (explorerTheme) {
- if (!ignoreDrawHot || drawDrophilited || (!ignoreDrawSelection && clrSelectionBk != -1)) {
+ boolean backgroundWanted = !ignoreDrawHot || drawDrophilited || (!ignoreDrawSelection && clrSelectionBk != -1);
+
+ if (backgroundWanted) {
RECT pClipRect = new RECT ();
OS.SetRect (pClipRect, nmcd.left, nmcd.top, nmcd.right, nmcd.bottom);
RECT rect = new RECT ();
OS.SetRect (rect, nmcd.left, nmcd.top, nmcd.right, nmcd.bottom);
if ((style & SWT.FULL_SELECTION) != 0) {
- int count = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
- int index = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, count - 1, 0);
+ int count = (int)OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ int index = (int)OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, count - 1, 0);
RECT headerRect = new RECT ();
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect);
OS.MapWindowPoints (hwndHeader, handle, headerRect, 2);
rect.right = headerRect.right;
- index = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
+ index = (int)OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect);
OS.MapWindowPoints (hwndHeader, handle, headerRect, 2);
rect.left = headerRect.left;
@@ -3577,7 +3569,7 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long /*int*/ lPara
rect.right += EXPLORER_EXTRA;
pClipRect.right += EXPLORER_EXTRA;
}
- long /*int*/ hTheme = OS.OpenThemeData (handle, Display.LISTVIEW);
+ long hTheme = OS.OpenThemeData (handle, Display.TREEVIEW);
int iStateId = selected ? OS.LISS_SELECTED : OS.LISS_HOT;
if (OS.GetFocus () != handle && selected && !drawHot) iStateId = OS.LISS_SELECTEDNOTFOCUS;
if (drawDrophilited) iStateId = OS.LISS_SELECTED;
@@ -3593,7 +3585,7 @@ void sendEraseItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd, long /*int*/ lPara
OS.MoveMemory (lParam, nmcd, NMLVCUSTOMDRAW.sizeof);
}
if (ignoreDrawForeground) {
- RECT clipRect = item.getBounds ((int)/*64*/nmcd.dwItemSpec, nmcd.iSubItem, true, true, true, false, hDC);
+ RECT clipRect = item.getBounds ((int)nmcd.dwItemSpec, nmcd.iSubItem, true, true, true, false, hDC);
OS.SaveDC (hDC);
OS.SelectClipRgn (hDC, 0);
OS.ExcludeClipRect (hDC, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
@@ -3609,7 +3601,7 @@ Event sendEraseItemEvent (TableItem item, NMTTCUSTOMDRAW nmcd, int column, RECT
data.foreground = OS.GetTextColor (nmcd.hdc);
data.background = OS.GetBkColor (nmcd.hdc);
data.font = item.getFont (column);
- data.uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ data.uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
GC gc = GC.win32_new (nmcd.hdc, data);
Event event = new Event ();
event.item = item;
@@ -3626,7 +3618,7 @@ Event sendEraseItemEvent (TableItem item, NMTTCUSTOMDRAW nmcd, int column, RECT
return event;
}
-Event sendMeasureItemEvent (TableItem item, int row, int column, long /*int*/ hDC) {
+Event sendMeasureItemEvent (TableItem item, int row, int column, long hDC) {
GCData data = new GCData ();
data.device = display;
data.font = item.getFont (column);
@@ -3643,8 +3635,8 @@ Event sendMeasureItemEvent (TableItem item, int row, int column, long /*int*/ hD
LVITEM lvItem = new LVITEM ();
lvItem.mask = OS.LVIF_STATE;
lvItem.stateMask = OS.LVIS_SELECTED;
- lvItem.iItem = (int)/*64*/row;
- long /*int*/ result = OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
+ lvItem.iItem = row;
+ long result = OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
boolean selected = (result != 0 && (lvItem.state & OS.LVIS_SELECTED) != 0);
if (selected && (column == 0 || (style & SWT.FULL_SELECTION) != 0)) {
if (OS.GetFocus () == handle || display.getHighContrast ()) {
@@ -3662,11 +3654,11 @@ Event sendMeasureItemEvent (TableItem item, int row, int column, long /*int*/ hD
if (!isDisposed () && !item.isDisposed ()) {
Rectangle boundsInPixels = event.getBoundsInPixels();
if (columnCount == 0) {
- int width = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0);
+ int width = (int)OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0);
if (boundsInPixels.x + boundsInPixels.width > width) setScrollWidth (boundsInPixels.x + boundsInPixels.width);
}
- long /*int*/ empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
- long /*int*/ oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
+ long empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
+ long oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
int itemHeight = OS.HIWORD (oneItem) - OS.HIWORD (empty);
/*
* Possible recursion: when setItemHeight() is called during
@@ -3682,10 +3674,10 @@ Event sendMeasureItemEvent (TableItem item, int row, int column, long /*int*/ hD
return event;
}
-LRESULT sendMouseDownEvent (int type, int button, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT sendMouseDownEvent (int type, int button, int msg, long wParam, long lParam) {
Display display = this.display;
display.captureChanged = false;
- if (!sendMouseEvent (type, button, handle, msg, wParam, lParam)) {
+ if (!sendMouseEvent (type, button, handle, lParam)) {
if (!display.captureChanged && !isDisposed ()) {
if (OS.GetCapture () != handle) OS.SetCapture (handle);
}
@@ -3717,12 +3709,12 @@ LRESULT sendMouseDownEvent (int type, int button, int msg, long /*int*/ wParam,
* The fix is to consider any value that is negative a failure.
*/
if (OS.SendMessage (handle, OS.LVM_SUBITEMHITTEST, 0, pinfo) < 0) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (count != 0) {
RECT rect = new RECT ();
rect.left = OS.LVIR_ICON;
ignoreCustomDraw = true;
- long /*int*/ code = OS.SendMessage (handle, OS.LVM_GETITEMRECT, 0, rect);
+ long code = OS.SendMessage (handle, OS.LVM_GETITEMRECT, 0, rect);
ignoreCustomDraw = false;
if (code != 0) {
pinfo.x = rect.left;
@@ -3744,16 +3736,6 @@ LRESULT sendMouseDownEvent (int type, int button, int msg, long /*int*/ wParam,
}
/*
- * Force the table to have focus so that when the user
- * reselects the focus item, the LVIS_FOCUSED state bits
- * for the item will be set. If the user did not click on
- * an item, then set focus to the table so that it will
- * come to the front and take focus in the work around
- * below.
- */
- OS.SetFocus (handle);
-
- /*
* Feature in Windows. When the user selects outside of
* a table item, Windows deselects all the items, even
* when the table is multi-select. While not strictly
@@ -3765,6 +3747,8 @@ LRESULT sendMouseDownEvent (int type, int button, int msg, long /*int*/ wParam,
if (!display.captureChanged && !isDisposed ()) {
if (OS.GetCapture () != handle) OS.SetCapture (handle);
}
+ /* We're skipping default processing, but at least set focus to control */
+ OS.SetFocus (handle);
return LRESULT.ZERO;
}
}
@@ -3779,7 +3763,7 @@ LRESULT sendMouseDownEvent (int type, int button, int msg, long /*int*/ wParam,
* it as selected.
*/
boolean forceSelect = false;
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETSELECTEDCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETSELECTEDCOUNT, 0, 0);
if (count == 1 && pinfo.iItem != -1) {
LVITEM lvItem = new LVITEM ();
lvItem.mask = OS.LVIF_STATE;
@@ -3833,7 +3817,7 @@ LRESULT sendMouseDownEvent (int type, int button, int msg, long /*int*/ wParam,
dragStarted = false;
display.dragCancelled = false;
if (!dragDetect) display.runDragDrop = false;
- long /*int*/ code = callWindowProc (handle, msg, wParam, lParam, forceSelect);
+ long code = callWindowProc (handle, msg, wParam, lParam, forceSelect);
if (!dragDetect) display.runDragDrop = true;
if (fullRowSelect) {
fullRowSelect = false;
@@ -3852,14 +3836,14 @@ LRESULT sendMouseDownEvent (int type, int button, int msg, long /*int*/ wParam,
fakeMouseUp = (pinfo.flags & OS.LVHT_ONITEMSTATEICON) == 0;
}
if (fakeMouseUp) {
- sendMouseEvent (SWT.MouseUp, button, handle, msg, wParam, lParam);
+ sendMouseEvent (SWT.MouseUp, button, handle, lParam);
}
}
return new LRESULT (code);
}
void sendPaintItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd) {
- long /*int*/ hDC = nmcd.hdc;
+ long hDC = nmcd.hdc;
GCData data = new GCData ();
data.device = display;
data.font = item.getFont (nmcd.iSubItem);
@@ -3871,8 +3855,8 @@ void sendPaintItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd) {
LVITEM lvItem = new LVITEM ();
lvItem.mask = OS.LVIF_STATE;
lvItem.stateMask = OS.LVIS_SELECTED;
- lvItem.iItem = (int)/*64*/nmcd.dwItemSpec;
- long /*int*/ result = OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
+ lvItem.iItem = (int)nmcd.dwItemSpec;
+ long result = OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
boolean selected = result != 0 && (lvItem.state & OS.LVIS_SELECTED) != 0;
boolean drawSelected = false, drawBackground = false, drawHot = false;
if (nmcd.iSubItem == 0 || (style & SWT.FULL_SELECTION) != 0) {
@@ -3924,10 +3908,10 @@ void sendPaintItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd) {
data.foreground = OS.GetSysColor (OS.COLOR_GRAYTEXT);
data.background = OS.GetSysColor (OS.COLOR_3DFACE);
}
- data.uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ data.uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
int nSavedDC = OS.SaveDC (hDC);
GC gc = GC.win32_new (hDC, data);
- RECT itemRect = item.getBounds ((int)/*64*/nmcd.dwItemSpec, nmcd.iSubItem, true, true, false, false, hDC);
+ RECT itemRect = item.getBounds ((int)nmcd.dwItemSpec, nmcd.iSubItem, true, true, false, false, hDC);
Event event = new Event ();
event.item = item;
event.gc = gc;
@@ -3937,7 +3921,7 @@ void sendPaintItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd) {
if (OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED) == nmcd.dwItemSpec) {
if (nmcd.iSubItem == 0 || (style & SWT.FULL_SELECTION) != 0) {
if (handle == OS.GetFocus ()) {
- int uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ int uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
if ((uiState & OS.UISF_HIDEFOCUS) == 0) event.detail |= SWT.FOCUSED;
}
}
@@ -3946,7 +3930,7 @@ void sendPaintItemEvent (TableItem item, NMLVCUSTOMDRAW nmcd) {
if (drawSelected) event.detail |= SWT.SELECTED;
if (drawBackground) event.detail |= SWT.BACKGROUND;
event.setBoundsInPixels(new Rectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top));
- RECT cellRect = item.getBounds ((int)/*64*/nmcd.dwItemSpec, nmcd.iSubItem, true, true, true, true, hDC);
+ RECT cellRect = item.getBounds ((int)nmcd.dwItemSpec, nmcd.iSubItem, true, true, true, true, hDC);
int cellWidth = cellRect.right - cellRect.left;
int cellHeight = cellRect.bottom - cellRect.top;
gc.setClipping (DPIUtil.autoScaleDown(new Rectangle (cellRect.left, cellRect.top, cellWidth, cellHeight)));
@@ -3966,7 +3950,7 @@ Event sendPaintItemEvent (TableItem item, NMTTCUSTOMDRAW nmcd, int column, RECT
data.font = item.getFont (column);
data.foreground = OS.GetTextColor (nmcd.hdc);
data.background = OS.GetBkColor (nmcd.hdc);
- data.uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ data.uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
GC gc = GC.win32_new (nmcd.hdc, data);
Event event = new Event ();
event.item = item;
@@ -3983,7 +3967,7 @@ Event sendPaintItemEvent (TableItem item, NMTTCUSTOMDRAW nmcd, int column, RECT
}
@Override
-void setBackgroundImage (long /*int*/ hBitmap) {
+void setBackgroundImage (long hBitmap) {
super.setBackgroundImage (hBitmap);
if (hBitmap != 0) {
setBackgroundTransparent (true);
@@ -3996,7 +3980,7 @@ void setBackgroundImage (long /*int*/ hBitmap) {
@Override
void setBackgroundPixel (int newPixel) {
- int oldPixel = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0);
+ int oldPixel = (int)OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0);
if (oldPixel != OS.CLR_NONE) {
if (findImageControl () != null) return;
if (newPixel == -1) newPixel = defaultBackground ();
@@ -4029,7 +4013,7 @@ void setBackgroundTransparent (boolean transparent) {
* other custom drawing. The fix is to clear the selected
* column.
*/
- int oldPixel = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0);
+ int oldPixel = (int)OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0);
if (transparent) {
if (oldPixel != OS.CLR_NONE) {
/*
@@ -4248,11 +4232,11 @@ void setCheckboxImageList (int width, int height, boolean fixScroll) {
int count = 8, flags = OS.ILC_COLOR32;
if ((style & SWT.RIGHT_TO_LEFT) != 0) flags |= OS.ILC_MIRROR;
if (!OS.IsAppThemed ()) flags |= OS.ILC_MASK;
- long /*int*/ hStateList = OS.ImageList_Create (width, height, flags, count, count);
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ memDC = OS.CreateCompatibleDC (hDC);
- long /*int*/ hBitmap = OS.CreateCompatibleBitmap (hDC, width * count, height);
- long /*int*/ hOldBitmap = OS.SelectObject (memDC, hBitmap);
+ long hStateList = OS.ImageList_Create (width, height, flags, count, count);
+ long hDC = OS.GetDC (handle);
+ long memDC = OS.CreateCompatibleDC (hDC);
+ long hBitmap = OS.CreateCompatibleBitmap (hDC, width * count, height);
+ long hOldBitmap = OS.SelectObject (memDC, hBitmap);
RECT rect = new RECT ();
OS.SetRect (rect, 0, 0, width * count, height);
int clrBackground;
@@ -4266,10 +4250,10 @@ void setCheckboxImageList (int width, int height, boolean fixScroll) {
clrBackground = 0x0200FF00;
}
}
- long /*int*/ hBrush = OS.CreateSolidBrush (clrBackground);
+ long hBrush = OS.CreateSolidBrush (clrBackground);
OS.FillRect (memDC, rect, hBrush);
OS.DeleteObject (hBrush);
- long /*int*/ oldFont = OS.SelectObject (hDC, defaultFont ());
+ long oldFont = OS.SelectObject (hDC, defaultFont ());
TEXTMETRIC tm = new TEXTMETRIC ();
OS.GetTextMetrics (hDC, tm);
OS.SelectObject (hDC, oldFont);
@@ -4289,7 +4273,7 @@ void setCheckboxImageList (int width, int height, boolean fixScroll) {
int left = (width - itemWidth) / 2, top = (height - itemHeight) / 2;
OS.SetRect (rect, left, top, left + itemWidth, top + itemHeight);
if (OS.IsAppThemed ()) {
- long /*int*/ hTheme = display.hButtonTheme ();
+ long hTheme = display.hButtonTheme ();
OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, rect, null);
rect.left += width; rect.right += width;
OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_CHECKEDNORMAL, rect, null);
@@ -4345,7 +4329,7 @@ void setCheckboxImageList (int width, int height, boolean fixScroll) {
setRedraw (false);
setTopIndex (0);
}
- long /*int*/ hOldStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
+ long hOldStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, hStateList);
if (hOldStateList != 0) OS.ImageList_Destroy (hOldStateList);
/*
@@ -4354,7 +4338,7 @@ void setCheckboxImageList (int width, int height, boolean fixScroll) {
* pixel corruption of the images. The fix is to reset the
* LVSIL_SMALL image list.
*/
- long /*int*/ hImageList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0);
+ long hImageList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0);
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
if (fixScroll && topIndex != 0) {
setTopIndex (topIndex);
@@ -4569,7 +4553,7 @@ public void setHeaderVisible (boolean show) {
public void setItemCount (int count) {
checkWidget ();
count = Math.max (0, count);
- int itemCount = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int itemCount = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (count == itemCount) return;
setDeferResize (true);
boolean isVirtual = (style & SWT.VIRTUAL) != 0;
@@ -4580,7 +4564,7 @@ public void setItemCount (int count) {
if (item != null && !item.isDisposed ()) item.release (false);
if (!isVirtual) {
ignoreSelect = ignoreShrink = true;
- long /*int*/ code = OS.SendMessage (handle, OS.LVM_DELETEITEM, count, 0);
+ long code = OS.SendMessage (handle, OS.LVM_DELETEITEM, count, 0);
ignoreSelect = ignoreShrink = false;
if (code == 0) break;
}
@@ -4634,7 +4618,7 @@ void setItemHeight (boolean fixScroll) {
* WM_SETFONT which recomputes and assigns the default item
* height.
*/
- long /*int*/ hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ long hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);
} else {
/*
@@ -4786,7 +4770,7 @@ public void setRedraw (boolean redraw) {
}
void setScrollWidth (int width) {
- if (width != (int)/*64*/OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0)) {
+ if (width != (int)OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0)) {
/*
* Feature in Windows. When LVM_SETCOLUMNWIDTH is sent,
* Windows draws right away instead of queuing a WM_PAINT.
@@ -4827,10 +4811,10 @@ boolean setScrollWidth (TableItem item, boolean force) {
*/
if (columnCount == 0) {
int newWidth = 0, imageIndent = 0, index = 0;
- int itemCount = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int itemCount = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
while (index < itemCount) {
String string = null;
- long /*int*/ hFont = -1;
+ long hFont = -1;
if (item != null) {
string = item.text;
imageIndent = Math.max (imageIndent, item.imageIndent);
@@ -4845,8 +4829,8 @@ boolean setScrollWidth (TableItem item, boolean force) {
}
if (string != null && string.length () != 0) {
if (hFont != -1) {
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ oldFont = OS.SelectObject (hDC, hFont);
+ long hDC = OS.GetDC (handle);
+ long oldFont = OS.SelectObject (hDC, hFont);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
char [] buffer = string.toCharArray ();
RECT rect = new RECT ();
@@ -4856,7 +4840,7 @@ boolean setScrollWidth (TableItem item, boolean force) {
newWidth = Math.max (newWidth, rect.right - rect.left);
} else {
TCHAR buffer = new TCHAR (getCodePage (), string, true);
- newWidth = Math.max (newWidth, (int)/*64*/OS.SendMessage (handle, OS.LVM_GETSTRINGWIDTH, 0, buffer));
+ newWidth = Math.max (newWidth, (int)OS.SendMessage (handle, OS.LVM_GETSTRINGWIDTH, 0, buffer));
}
}
if (item != null) break;
@@ -4874,15 +4858,15 @@ boolean setScrollWidth (TableItem item, boolean force) {
*/
if (newWidth == 0) {
char [] buffer = {' ', '\0'};
- newWidth = Math.max (newWidth, (int)/*64*/OS.SendMessage (handle, OS.LVM_GETSTRINGWIDTH, 0, buffer));
+ newWidth = Math.max (newWidth, (int)OS.SendMessage (handle, OS.LVM_GETSTRINGWIDTH, 0, buffer));
}
- long /*int*/ hStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
+ long hStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
if (hStateList != 0) {
int [] cx = new int [1], cy = new int [1];
OS.ImageList_GetIconSize (hStateList, cx, cy);
newWidth += cx [0] + INSET;
}
- long /*int*/ hImageList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0);
+ long hImageList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0);
if (hImageList != 0) {
int [] cx = new int [1], cy = new int [1];
OS.ImageList_GetIconSize (hImageList, cx, cy);
@@ -4901,7 +4885,7 @@ boolean setScrollWidth (TableItem item, boolean force) {
newWidth++;
}
newWidth += INSET * 2 + VISTA_EXTRA;
- int oldWidth = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0);
+ int oldWidth = (int)OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0);
if (newWidth > oldWidth) {
setScrollWidth (newWidth);
return true;
@@ -5064,7 +5048,7 @@ public void setSelection (int start, int end) {
checkWidget ();
deselectAll ();
if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && start != end)) return;
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (count == 0 || start >= count) return;
start = Math.max (0, start);
end = Math.min (end, count - 1);
@@ -5125,7 +5109,7 @@ public void setSortDirection (int direction) {
}
void setSubImagesVisible (boolean visible) {
- int dwExStyle = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ int dwExStyle = (int)OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
if ((dwExStyle & OS.LVS_EX_SUBITEMIMAGES) != 0 == visible) return;
int bits = visible ? OS.LVS_EX_SUBITEMIMAGES : 0;
OS.SendMessage (handle, OS.LVM_SETEXTENDEDLISTVIEWSTYLE, OS.LVS_EX_SUBITEMIMAGES, bits);
@@ -5142,12 +5126,12 @@ void setTableEmpty () {
* Windows to reserve the smallest possible space when an image
* list is removed.
*/
- long /*int*/ hImageList = OS.ImageList_Create (1, 1, 0, 0, 0);
+ long hImageList = OS.ImageList_Create (1, 1, 0, 0, 0);
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
if (headerImageList != null) {
- long /*int*/ hHeaderImageList = headerImageList.getHandle ();
- long /*int*/ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ long hHeaderImageList = headerImageList.getHandle ();
+ long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
OS.SendMessage (hwndHeader, OS.HDM_SETIMAGELIST, 0, hHeaderImageList);
}
OS.ImageList_Destroy (hImageList);
@@ -5184,7 +5168,7 @@ void setTableEmpty () {
*/
public void setTopIndex (int index) {
checkWidget ();
- int topIndex = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETTOPINDEX, 0, 0);
+ int topIndex = (int)OS.SendMessage (handle, OS.LVM_GETTOPINDEX, 0, 0);
if (index == topIndex) return;
if (!painted && hooks (SWT.MeasureItem)) hitTestSelection (index, 0, 0);
@@ -5279,7 +5263,7 @@ public void showColumn (TableColumn column) {
OS.SendMessage (handle, OS.LVM_GETSUBITEMRECT, -1, itemRect);
ignoreCustomDraw = false;
itemRect.right = itemRect.left;
- int width = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0);
+ int width = (int)OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0);
itemRect.left = itemRect.right - width;
} else {
itemRect.top = index;
@@ -5345,7 +5329,7 @@ void showItem (int index) {
* of visible items is zero and use LVM_ENSUREVISIBLE with the
* fPartialOK flag set to true to scroll the table.
*/
- long /*int*/ counterPage = OS.SendMessage (handle, OS.LVM_GETCOUNTPERPAGE, 0, 0);
+ long counterPage = OS.SendMessage (handle, OS.LVM_GETCOUNTPERPAGE, 0, 0);
if (counterPage <= 0) {
/*
* Bug in Windows. For some reason, LVM_ENSUREVISIBLE can
@@ -5366,7 +5350,7 @@ void showItem (int index) {
* LVM_ENSUREVISIBLE command scrolls the table to the leftmost
* column even if the item is already visible, refer Bug 334234
*/
- long /*int*/ topIndex = OS.SendMessage (handle, OS.LVM_GETTOPINDEX, 0, 0);
+ long topIndex = OS.SendMessage (handle, OS.LVM_GETTOPINDEX, 0, 0);
if (topIndex > index || index >= topIndex + counterPage ) {
OS.SendMessage (handle, OS.LVM_ENSUREVISIBLE, index, 0);
}
@@ -5413,7 +5397,7 @@ public void showItem (TableItem item) {
*/
public void showSelection () {
checkWidget ();
- int index = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_SELECTED);
+ int index = (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_SELECTED);
if (index != -1) {
/*
* Bug in Windows. For some reason, when a table had vertically
@@ -5475,7 +5459,7 @@ RECT toolTipRect (RECT rect) {
@Override
String toolTipText (NMTTDISPINFO hdr) {
- long /*int*/ hwndToolTip = OS.SendMessage (handle, OS.LVM_GETTOOLTIPS, 0, 0);
+ long hwndToolTip = OS.SendMessage (handle, OS.LVM_GETTOOLTIPS, 0, 0);
if (hwndToolTip == hdr.hwndFrom && toolTipText != null) return ""; //$NON-NLS-1$
if (headerToolTipHandle == hdr.hwndFrom) {
for (int i=0; i<columnCount; i++) {
@@ -5508,7 +5492,7 @@ void update (boolean all) {
* NOTE: The header tooltip can subclass the header proc so the
* current proc must be restored or header tooltips stop working.
*/
- long /*int*/ oldHeaderProc = 0, oldTableProc = 0;
+ long oldHeaderProc = 0, oldTableProc = 0;
boolean fixSubclass = isOptimizedRedraw ();
if (fixSubclass) {
oldTableProc = OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, TableProc);
@@ -5523,7 +5507,7 @@ void update (boolean all) {
void updateHeaderToolTips () {
if (headerToolTipHandle == 0) return;
- long /*int*/ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
RECT rect = new RECT ();
TOOLINFO lpti = new TOOLINFO ();
lpti.cbSize = TOOLINFO.sizeof;
@@ -5576,7 +5560,7 @@ void updateMoveable () {
@Override
void updateOrientation () {
super.updateOrientation ();
- long /*int*/ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
if (hwndHeader != 0) {
int bits = OS.GetWindowLong (hwndHeader, OS.GWL_EXSTYLE);
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
@@ -5598,9 +5582,9 @@ void updateOrientation () {
Point size = imageList.getImageSize ();
display.releaseImageList (imageList);
imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, size.x, size.y);
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
for (int i = 0; i < count; i++) {
- TableItem item = _getItem (i, false);
+ TableItem item = _getItem (i, false);
if (item != null) {
Image image = item.image;
if (image != null) {
@@ -5609,7 +5593,7 @@ void updateOrientation () {
}
}
}
- long /*int*/ hImageList = imageList.getHandle ();
+ long hImageList = imageList.getHandle ();
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
}
if (hwndHeader != 0) {
@@ -5637,7 +5621,7 @@ void updateOrientation () {
}
}
}
- long /*int*/ hHeaderImageList = headerImageList.getHandle ();
+ long hHeaderImageList = headerImageList.getHandle ();
OS.SendMessage (hwndHeader, OS.HDM_SETIMAGELIST, 0, hHeaderImageList);
}
}
@@ -5647,9 +5631,9 @@ void updateOrientation () {
boolean updateTextDirection(int textDirection) {
if (super.updateTextDirection(textDirection)) {
if (textDirection == AUTO_TEXT_DIRECTION || (state & HAS_AUTO_DIRECTION) != 0) {
- for (int i = 0, n = items.length; i < n; i++) {
- if (items[i] != null) {
- items[i].updateTextDirection(textDirection == AUTO_TEXT_DIRECTION ? AUTO_TEXT_DIRECTION : style & SWT.FLIP_TEXT_DIRECTION);
+ for (TableItem item : items) {
+ if (item != null) {
+ item.updateTextDirection(textDirection == AUTO_TEXT_DIRECTION ? AUTO_TEXT_DIRECTION : style & SWT.FLIP_TEXT_DIRECTION);
}
}
}
@@ -5681,12 +5665,12 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return TableProc;
}
@Override
-long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long windowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
if (hwnd != handle) {
switch (msg) {
@@ -5729,8 +5713,8 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
OS.ScreenToClient (hwnd, pt);
pinfo.x = pt.x;
pinfo.y = pt.y;
- long /*int*/ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
- int index = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_HITTEST, 0, pinfo);
+ long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ int index = (int)OS.SendMessage (hwndHeader, OS.HDM_HITTEST, 0, pinfo);
if (0 <= index && index < columnCount && !columns [index].resizable) {
if ((pinfo.flags & (OS.HHT_ONDIVIDER | OS.HHT_ONDIVOPEN)) != 0) {
OS.SetCursor (OS.LoadCursor (0, OS.IDC_ARROW));
@@ -5754,8 +5738,8 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
*
* The fix for both cases is to create the image using PrintWindow().
*/
- int topIndex = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETTOPINDEX, 0, 0);
- int selection = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, topIndex - 1, OS.LVNI_SELECTED);
+ int topIndex = (int)OS.SendMessage (handle, OS.LVM_GETTOPINDEX, 0, 0);
+ int selection = (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, topIndex - 1, OS.LVNI_SELECTED);
if (selection == -1) return 0;
POINT mousePos = new POINT ();
OS.POINTSTOPOINT (mousePos, OS.GetMessagePos ());
@@ -5774,12 +5758,12 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
rect.left = Math.max (clientRect.left, rect.right - width);
}
}
- long /*int*/ hRgn = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom);
- while ((selection = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, selection, OS.LVNI_SELECTED)) != -1) {
+ long hRgn = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom);
+ while ((selection = (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, selection, OS.LVNI_SELECTED)) != -1) {
if (rect.bottom - rect.top > DRAG_IMAGE_SIZE) break;
if (rect.bottom > clientRect.bottom) break;
RECT itemRect = item.getBounds (selection, 0, true, true, true);
- long /*int*/ rectRgn = OS.CreateRectRgn (rect.left, itemRect.top, rect.right, itemRect.bottom);
+ long rectRgn = OS.CreateRectRgn (rect.left, itemRect.top, rect.right, itemRect.bottom);
OS.CombineRgn (hRgn, hRgn, rectRgn, OS.RGN_OR);
OS.DeleteObject (rectRgn);
rect.bottom = itemRect.bottom;
@@ -5787,8 +5771,8 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
OS.GetRgnBox (hRgn, rect);
/* Create resources */
- long /*int*/ hdc = OS.GetDC (handle);
- long /*int*/ memHdc = OS.CreateCompatibleDC (hdc);
+ long hdc = OS.GetDC (handle);
+ long memHdc = OS.CreateCompatibleDC (hdc);
BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER ();
bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
bmiHeader.biWidth = rect.right - rect.left;
@@ -5798,10 +5782,10 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
bmiHeader.biCompression = OS.BI_RGB;
byte [] bmi = new byte [BITMAPINFOHEADER.sizeof];
OS.MoveMemory (bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
- long /*int*/ [] pBits = new long /*int*/ [1];
- long /*int*/ memDib = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
+ long [] pBits = new long [1];
+ long memDib = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
if (memDib == 0) error (SWT.ERROR_NO_HANDLES);
- long /*int*/ oldMemBitmap = OS.SelectObject (memHdc, memDib);
+ long oldMemBitmap = OS.SelectObject (memHdc, memDib);
int colorKey = 0x0000FD;
POINT pt = new POINT();
OS.SetWindowOrgEx (memHdc, rect.left, rect.top, pt);
@@ -5832,14 +5816,14 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
}
@Override
-LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CHAR (long wParam, long lParam) {
LRESULT result = super.WM_CHAR (wParam, lParam);
if (result != null) return result;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case ' ':
if ((style & SWT.CHECK) != 0) {
- int index = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
- if (index != -1) {
+ int index = -1;
+ while ((index = (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, index, OS.LVNI_SELECTED)) != -1) {
TableItem item = _getItem (index);
item.setChecked (!item.getChecked (), true);
OS.NotifyWinEvent (OS.EVENT_OBJECT_FOCUS, handle, OS.OBJID_CLIENT, index + 1);
@@ -5851,7 +5835,7 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
* This allows the application to cancel an operation that is normally
* performed in WM_KEYDOWN from WM_CHAR.
*/
- long /*int*/ code = callWindowProc (handle, OS.WM_KEYDOWN, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_KEYDOWN, wParam, lParam);
return new LRESULT (code);
case SWT.CR:
/*
@@ -5861,7 +5845,7 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
* event will fail. The fix is to ignore LVN_ITEMACTIVATE when it is
* caused by WM_KEYDOWN and send SWT.DefaultSelection from WM_CHAR.
*/
- int index = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
+ int index = (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
if (index != -1) {
Event event = new Event ();
event.item = _getItem (index);
@@ -5873,7 +5857,7 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_CONTEXTMENU (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CONTEXTMENU (long wParam, long lParam) {
/*
* Feature in Windows. For some reason, when the right
* mouse button is pressed over an item, Windows sends
@@ -5891,14 +5875,14 @@ LRESULT WM_CONTEXTMENU (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ERASEBKGND (long wParam, long lParam) {
LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
if (findImageControl () != null) return LRESULT.ONE;
return result;
}
@Override
-LRESULT WM_GETOBJECT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETOBJECT (long wParam, long lParam) {
/*
* Ensure that there is an accessible object created for this
* control because support for checked item accessibility is
@@ -5911,10 +5895,10 @@ LRESULT WM_GETOBJECT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KEYDOWN (long wParam, long lParam) {
LRESULT result = super.WM_KEYDOWN (wParam, lParam);
if (result != null) return result;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_SPACE:
/*
* Ensure that the window proc does not process VK_SPACE
@@ -5933,8 +5917,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
if (index != columnCount || hooks (SWT.MeasureItem)) {
TableColumn [] newColumns = new TableColumn [columnCount];
System.arraycopy (columns, 0, newColumns, 0, columnCount);
- for (int i=0; i<newColumns.length; i++) {
- TableColumn column = newColumns [i];
+ for (TableColumn column : newColumns) {
if (!column.isDisposed () && column.getResizable ()) {
column.pack ();
}
@@ -5957,14 +5940,14 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
* NOTE: The header tooltip can subclass the header proc so the
* current proc must be restored or header tooltips stop working.
*/
- long /*int*/ oldHeaderProc = 0, oldTableProc = 0;
- long /*int*/ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ long oldHeaderProc = 0, oldTableProc = 0;
+ long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
boolean fixSubclass = isOptimizedRedraw ();
if (fixSubclass) {
oldTableProc = OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, TableProc);
oldHeaderProc = OS.SetWindowLongPtr (hwndHeader, OS.GWLP_WNDPROC, HeaderProc);
}
- long /*int*/ code = callWindowProc (handle, OS.WM_KEYDOWN, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_KEYDOWN, wParam, lParam);
result = code == 0 ? LRESULT.ZERO : new LRESULT (code);
if (fixSubclass) {
OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, oldTableProc);
@@ -5980,7 +5963,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KILLFOCUS (long wParam, long lParam) {
LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
/*
* Bug in Windows. When focus is lost, Windows does not
@@ -5995,7 +5978,7 @@ LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDBLCLK (long wParam, long lParam) {
/*
* Feature in Windows. When the user selects outside of
@@ -6007,11 +5990,11 @@ LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
LVHITTESTINFO pinfo = new LVHITTESTINFO ();
pinfo.x = OS.GET_X_LPARAM (lParam);
pinfo.y = OS.GET_Y_LPARAM (lParam);
- int index = (int)/*64*/OS.SendMessage (handle, OS.LVM_HITTEST, 0, pinfo);
+ int index = (int)OS.SendMessage (handle, OS.LVM_HITTEST, 0, pinfo);
Display display = this.display;
display.captureChanged = false;
- sendMouseEvent (SWT.MouseDown, 1, handle, OS.WM_LBUTTONDOWN, wParam, lParam);
- if (!sendMouseEvent (SWT.MouseDoubleClick, 1, handle, OS.WM_LBUTTONDBLCLK, wParam, lParam)) {
+ sendMouseEvent (SWT.MouseDown, 1, handle, lParam);
+ if (!sendMouseEvent (SWT.MouseDoubleClick, 1, handle, lParam)) {
if (!display.captureChanged && !isDisposed ()) {
if (OS.GetCapture () != handle) OS.SetCapture (handle);
}
@@ -6044,7 +6027,7 @@ LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDOWN (long wParam, long lParam) {
/*
* Feature in Windows. For some reason, capturing
* the mouse after processing the mouse event for the
@@ -6068,7 +6051,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
* the correct way to determine that the user has selected
* the check box, equality is needed.
*/
- int index = (int)/*64*/OS.SendMessage (handle, OS.LVM_HITTEST, 0, pinfo);
+ int index = (int)OS.SendMessage (handle, OS.LVM_HITTEST, 0, pinfo);
if (index != -1 && pinfo.flags == OS.LVHT_ONITEMSTATEICON) {
TableItem item = _getItem (index);
if (item != null && !item.isDisposed ()) {
@@ -6081,7 +6064,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_MOUSEHOVER (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSEHOVER (long wParam, long lParam) {
/*
* Feature in Windows. Despite the fact that hot
* tracking is not enabled, the hot tracking code
@@ -6090,14 +6073,14 @@ LRESULT WM_MOUSEHOVER (long /*int*/ wParam, long /*int*/ lParam) {
* avoid calling the window proc.
*/
LRESULT result = super.WM_MOUSEHOVER (wParam, lParam);
- int bits = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ int bits = (int)OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
int mask = OS.LVS_EX_ONECLICKACTIVATE | OS.LVS_EX_TRACKSELECT | OS.LVS_EX_TWOCLICKACTIVATE;
if ((bits & mask) != 0) return result;
return LRESULT.ZERO;
}
@Override
-LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PAINT (long wParam, long lParam) {
if ((state & DISPOSE_SENT) != 0) return LRESULT.ZERO;
_checkShrink();
@@ -6106,7 +6089,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_RBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_RBUTTONDBLCLK (long wParam, long lParam) {
/*
* Feature in Windows. When the user selects outside of
* a table item, Windows deselects all the items, even
@@ -6120,8 +6103,8 @@ LRESULT WM_RBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
OS.SendMessage (handle, OS.LVM_HITTEST, 0, pinfo);
Display display = this.display;
display.captureChanged = false;
- sendMouseEvent (SWT.MouseDown, 3, handle, OS.WM_RBUTTONDOWN, wParam, lParam);
- if (sendMouseEvent (SWT.MouseDoubleClick, 3, handle, OS.WM_RBUTTONDBLCLK, wParam, lParam)) {
+ sendMouseEvent (SWT.MouseDown, 3, handle, lParam);
+ if (sendMouseEvent (SWT.MouseDoubleClick, 3, handle, lParam)) {
if (pinfo.iItem != -1) callWindowProc (handle, OS.WM_RBUTTONDBLCLK, wParam, lParam);
}
if (!display.captureChanged && !isDisposed ()) {
@@ -6131,7 +6114,7 @@ LRESULT WM_RBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_RBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_RBUTTONDOWN (long wParam, long lParam) {
/*
* Feature in Windows. For some reason, capturing
* the mouse after processing the mouse event for the
@@ -6143,7 +6126,7 @@ LRESULT WM_RBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFOCUS (long wParam, long lParam) {
LRESULT result = super.WM_SETFOCUS (wParam, lParam);
/*
* Bug in Windows. When focus is gained after the
@@ -6164,9 +6147,9 @@ LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
* no selected item. The fix to make the first item
* be the focus item.
*/
- int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (count == 0) return result;
- int index = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
+ int index = (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
if (index == -1) {
LVITEM lvItem = new LVITEM ();
lvItem.state = OS.LVIS_FOCUSED;
@@ -6179,7 +6162,7 @@ LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETFONT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFONT (long wParam, long lParam) {
LRESULT result = super.WM_SETFONT (wParam, lParam);
if (result != null) return result;
@@ -6203,7 +6186,7 @@ LRESULT WM_SETFONT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETREDRAW (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETREDRAW (long wParam, long lParam) {
LRESULT result = super.WM_SETREDRAW (wParam, lParam);
if (result != null) return result;
/*
@@ -6213,7 +6196,7 @@ LRESULT WM_SETREDRAW (long /*int*/ wParam, long /*int*/ lParam) {
* turned off.
*/
if (wParam == 1) {
- if ((int)/*64*/OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) != OS.CLR_NONE) {
+ if ((int)OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) != OS.CLR_NONE) {
if (hooks (SWT.MeasureItem) || hooks (SWT.EraseItem) || hooks (SWT.PaintItem)) {
OS.SendMessage (handle, OS.LVM_SETBKCOLOR, 0, OS.CLR_NONE);
}
@@ -6226,9 +6209,9 @@ LRESULT WM_SETREDRAW (long /*int*/ wParam, long /*int*/ lParam) {
* which stops all graphics output to the control.
*/
OS.DefWindowProc (handle, OS.WM_SETREDRAW, wParam, lParam);
- long /*int*/ code = callWindowProc (handle, OS.WM_SETREDRAW, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_SETREDRAW, wParam, lParam);
if (wParam == 0) {
- if ((int)/*64*/OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) == OS.CLR_NONE) {
+ if ((int)OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) == OS.CLR_NONE) {
OS.SendMessage (handle, OS.LVM_SETBKCOLOR, 0, 0xFFFFFF);
}
}
@@ -6236,7 +6219,7 @@ LRESULT WM_SETREDRAW (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
if (ignoreResize) return null;
if (hooks (SWT.EraseItem) || hooks (SWT.PaintItem)) {
OS.InvalidateRect (handle, null, true);
@@ -6249,13 +6232,13 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SYSCOLORCHANGE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SYSCOLORCHANGE (long wParam, long lParam) {
LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
if (result != null) return result;
if (findBackgroundControl () == null) {
setBackgroundPixel (defaultBackground ());
} else {
- int oldPixel = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0);
+ int oldPixel = (int)OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0);
if (oldPixel != OS.CLR_NONE) {
if (findImageControl () == null) {
if ((style & SWT.CHECK) != 0) fixCheckboxImageListColor (true);
@@ -6266,7 +6249,7 @@ LRESULT WM_SYSCOLORCHANGE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_HSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_HSCROLL (long wParam, long lParam) {
/*
* Bug in Windows. When a table that is drawing grid lines
* is slowly scrolled horizontally to the left, the table does
@@ -6294,8 +6277,8 @@ LRESULT WM_HSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
* NOTE: The header tooltip can subclass the header proc so the
* current proc must be restored or header tooltips stop working.
*/
- long /*int*/ oldHeaderProc = 0, oldTableProc = 0;
- long /*int*/ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ long oldHeaderProc = 0, oldTableProc = 0;
+ long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
boolean fixSubclass = isOptimizedRedraw ();
if (fixSubclass) {
oldTableProc = OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, TableProc);
@@ -6314,7 +6297,7 @@ LRESULT WM_HSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
boolean fixScroll = false;
if (OS.LOWORD (wParam) != OS.SB_ENDSCROLL) {
if (columnCount > H_SCROLL_LIMIT) {
- int rowCount = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETCOUNTPERPAGE, 0, 0);
+ int rowCount = (int)OS.SendMessage (handle, OS.LVM_GETCOUNTPERPAGE, 0, 0);
if (rowCount > V_SCROLL_LIMIT) fixScroll = getDrawing () && OS.IsWindowVisible (handle);
}
}
@@ -6382,7 +6365,7 @@ LRESULT WM_HSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_VSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_VSCROLL (long wParam, long lParam) {
/*
* When there are many columns in a table, scrolling performance
* can be improved by temporarily unsubclassing the window proc
@@ -6394,8 +6377,8 @@ LRESULT WM_VSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
* NOTE: The header tooltip can subclass the header proc so the
* current proc must be restored or header tooltips stop working.
*/
- long /*int*/ oldHeaderProc = 0, oldTableProc = 0;
- long /*int*/ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ long oldHeaderProc = 0, oldTableProc = 0;
+ long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
boolean fixSubclass = isOptimizedRedraw ();
if (fixSubclass) {
oldTableProc = OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, TableProc);
@@ -6414,7 +6397,7 @@ LRESULT WM_VSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
boolean fixScroll = false;
if (OS.LOWORD (wParam) != OS.SB_ENDSCROLL) {
if (columnCount > H_SCROLL_LIMIT) {
- int rowCount = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETCOUNTPERPAGE, 0, 0);
+ int rowCount = (int)OS.SendMessage (handle, OS.LVM_GETCOUNTPERPAGE, 0, 0);
if (rowCount > V_SCROLL_LIMIT) fixScroll = getDrawing () && OS.IsWindowVisible (handle);
}
}
@@ -6481,8 +6464,8 @@ LRESULT WM_VSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
RECT clientRect = new RECT ();
OS.GetClientRect (handle, clientRect);
clientRect.top += headerHeight;
- long /*int*/ empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
- long /*int*/ oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
+ long empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
+ long oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
int itemHeight = OS.HIWORD (oneItem) - OS.HIWORD (empty);
if (code == OS.SB_LINEDOWN) {
clientRect.top = clientRect.bottom - itemHeight - GRID_WIDTH;
@@ -6501,12 +6484,12 @@ LRESULT WM_VSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmMeasureChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmMeasureChild (long wParam, long lParam) {
MEASUREITEMSTRUCT struct = new MEASUREITEMSTRUCT ();
OS.MoveMemory (struct, lParam, MEASUREITEMSTRUCT.sizeof);
if (itemHeight == -1) {
- long /*int*/ empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
- long /*int*/ oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
+ long empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
+ long oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
struct.itemHeight = OS.HIWORD (oneItem) - OS.HIWORD (empty);
} else {
struct.itemHeight = itemHeight;
@@ -6516,9 +6499,13 @@ LRESULT wmMeasureChild (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmNotify (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
- long /*int*/ hwndToolTip = OS.SendMessage (handle, OS.LVM_GETTOOLTIPS, 0, 0);
+LRESULT wmNotify (NMHDR hdr, long wParam, long lParam) {
+ long hwndToolTip = OS.SendMessage (handle, OS.LVM_GETTOOLTIPS, 0, 0);
if (hdr.hwndFrom == hwndToolTip) {
+ if (hdr.hwndFrom != itemToolTipHandle) {
+ maybeEnableDarkSystemTheme(hdr.hwndFrom);
+ itemToolTipHandle = hdr.hwndFrom;
+ }
LRESULT result = wmNotifyToolTip (hdr, wParam, lParam);
if (result != null) return result;
}
@@ -6530,7 +6517,7 @@ LRESULT wmNotify (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) {
switch (hdr.code) {
case OS.LVN_ODFINDITEM: {
if ((style & SWT.VIRTUAL) != 0) return new LRESULT (-1);
@@ -6594,7 +6581,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
RECT rect = new RECT ();
rect.left = OS.LVIR_BOUNDS;
ignoreCustomDraw = true;
- long /*int*/ code = OS.SendMessage (handle, OS. LVM_GETITEMRECT, plvfi.iItem, rect);
+ long code = OS.SendMessage (handle, OS. LVM_GETITEMRECT, plvfi.iItem, rect);
ignoreCustomDraw = false;
if (code != 0) OS.InvalidateRect (handle, rect, true);
break;
@@ -6727,7 +6714,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
break;
}
case OS.NM_CUSTOMDRAW: {
- long /*int*/ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
if (hdr.hwndFrom == hwndHeader) break;
if (!customDraw && findImageControl () == null) {
/*
@@ -6820,8 +6807,8 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
}
}
if (hooks (SWT.EraseItem) || hooks (SWT.PaintItem)) {
- long /*int*/ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
- int count = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ int count = (int)OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
if (count != 0) {
forceResize ();
RECT rect = new RECT ();
@@ -6835,7 +6822,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
OS.SendMessage (handle, OS. LVM_GETITEMRECT, pnmlv.iItem, itemRect);
ignoreCustomDraw = false;
RECT headerRect = new RECT ();
- int index = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, count - 1, 0);
+ int index = (int)OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, count - 1, 0);
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect);
OS.MapWindowPoints (hwndHeader, handle, headerRect, 2);
rect.left = headerRect.right;
@@ -6851,7 +6838,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
return super.wmNotifyChild (hdr, wParam, lParam);
}
-LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotifyHeader (NMHDR hdr, long wParam, long lParam) {
/*
* Feature in Windows. On NT, the automatically created
* header control is created as a UNICODE window, not an
@@ -6901,10 +6888,16 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
int pixel = getHeaderBackgroundPixel();
if ((nmcd.uItemState & OS.CDIS_SELECTED) != 0) {
pixel = getDifferentColor(pixel);
- } else if (columns[(int) nmcd.dwItemSpec] == sortColumn && sortDirection != SWT.NONE) {
- pixel = getSlightlyDifferentColor(pixel);
}
- long /*int*/ brush = OS.CreateSolidBrush(pixel);
+ /*
+ * Don't change the header background color for set selected column, similar to
+ * Windows 10 which itself does not use any different color for sort header. For
+ * more details refer bug 536020
+ */
+// else if (columns[(int) nmcd.dwItemSpec] == sortColumn && sortDirection != SWT.NONE) {
+// pixel = getSlightlyDifferentColor(pixel);
+// }
+ long brush = OS.CreateSolidBrush(pixel);
OS.FillRect(nmcd.hdc, rect, brush);
OS.DeleteObject(brush);
@@ -6929,8 +6922,8 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
if (columns[i] == sortColumn && sortDirection != SWT.NONE) {
// the display.getSortImage looks terrible after scaling up.
- long /*int*/ pen = OS.CreatePen (OS.PS_SOLID, 1, getHeaderForegroundPixel());
- long /*int*/ oldPen = OS.SelectObject (nmcd.hdc, pen);
+ long pen = OS.CreatePen (OS.PS_SOLID, 1, getHeaderForegroundPixel());
+ long oldPen = OS.SelectObject (nmcd.hdc, pen);
int center = rects[i].left + (rects[i].right - rects[i].left) / 2;
/*
* Sort indicator size needs to scale as per the Native Windows OS DPI level
@@ -6948,18 +6941,24 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
OS.DeleteObject (pen);
}
+ int alignmentCorrection = _getLinesVisible () ? 0 : 1;
+
/* Windows 7 and 10 always draw a nearly invisible vertical line between the columns, even if lines are disabled.
This line uses no fixed color constant, but calculates it from the background color.
- The method getSlightlyDifferentColor gives us a color, that is near enough to the windows algorithm. */
- long /*int*/ pen = OS.CreatePen (OS.PS_SOLID, getGridLineWidthInPixels(), getSlightlyDifferentColor(getHeaderBackgroundPixel()));
- long /*int*/ oldPen = OS.SelectObject (nmcd.hdc, pen);
- int alignmentCorrection = _getLinesVisible () ? 0 : 1;
+ The method getSlightlyDifferentColor gives us a color, that is near enough to the windows algorithm.
+
+ NOTE: This code has no effect since Bug 517003, because next OS.Polyline() draws over the same coords.
+
+ long pen = OS.CreatePen (OS.PS_SOLID, getGridLineWidthInPixels(), getSlightlyDifferentColor(getHeaderBackgroundPixel()));
+ long oldPen = OS.SelectObject (nmcd.hdc, pen);
OS.Polyline(nmcd.hdc, new int[] {rects[i].right-alignmentCorrection, rects[i].top, rects[i].right-alignmentCorrection, rects[i].bottom}, 2);
OS.SelectObject (nmcd.hdc, oldPen);
OS.DeleteObject (pen);
+ */
- pen = OS.CreatePen (OS.PS_SOLID, getGridLineWidthInPixels(), OS.GetSysColor(OS.COLOR_3DFACE));
- oldPen = OS.SelectObject (nmcd.hdc, pen);
+ int lineColor = (display.tableHeaderLinePixel != -1) ? display.tableHeaderLinePixel : OS.GetSysColor(OS.COLOR_3DFACE);
+ long pen = OS.CreatePen (OS.PS_SOLID, getGridLineWidthInPixels(), lineColor);
+ long oldPen = OS.SelectObject (nmcd.hdc, pen);
/* To differentiate headers, always draw header column separator. */
OS.Polyline(nmcd.hdc, new int[] {rects[i].right - alignmentCorrection, rects[i].top, rects[i].right - alignmentCorrection, rects[i].bottom}, 2);
/* To differentiate header & content area, always draw the line separator between header & first row. */
@@ -7008,15 +7007,15 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
RECT rect = new RECT();
lastColumnRight += _getLinesVisible() ? 1 : 0;
OS.SetRect(rect, lastColumnRight, nmcd.top, nmcd.right, nmcd.bottom-1);
- long /*int*/ brush = OS.CreateSolidBrush(getHeaderBackgroundPixel());
+ long brush = OS.CreateSolidBrush(getHeaderBackgroundPixel());
OS.FillRect(nmcd.hdc, rect, brush);
OS.DeleteObject(brush);
}
// always draw the highlighted border at the end, to avoid overdrawing by other borders.
if (highlightedHeaderDividerX != -1) {
- long /*int*/ pen = OS.CreatePen (OS.PS_SOLID, 4, OS.GetSysColor(OS.COLOR_HIGHLIGHT));
- long /*int*/ oldPen = OS.SelectObject (nmcd.hdc, pen);
+ long pen = OS.CreatePen (OS.PS_SOLID, 4, OS.GetSysColor(OS.COLOR_HIGHLIGHT));
+ long oldPen = OS.SelectObject (nmcd.hdc, pen);
OS.Polyline(nmcd.hdc, new int[] {highlightedHeaderDividerX, nmcd.top, highlightedHeaderDividerX, nmcd.bottom}, 2);
OS.SelectObject (nmcd.hdc, oldPen);
OS.DeleteObject (pen);
@@ -7039,7 +7038,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
}
case OS.HDN_BEGINDRAG: {
if (ignoreColumnMove) return LRESULT.ONE;
- int bits = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ int bits = (int)OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
if ((bits & OS.LVS_EX_HEADERDRAGDROP) != 0) {
if (columnCount == 0) return LRESULT.ONE;
NMHEADER phdn = new NMHEADER ();
@@ -7057,7 +7056,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
}
case OS.HDN_ENDDRAG: {
headerItemDragging = false;
- int bits = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ int bits = (int)OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
if ((bits & OS.LVS_EX_HEADERDRAGDROP) == 0) break;
NMHEADER phdn = new NMHEADER ();
OS.MoveMemory (phdn, lParam, NMHEADER.sizeof);
@@ -7070,7 +7069,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
OS.SendMessage (handle, OS.LVM_GETCOLUMNORDERARRAY, columnCount, order);
int index = 0;
while (index < order.length) {
- if (order [index] == phdn.iItem) break;
+ if (order [index] == phdn.iItem) break;
index++;
}
if (index == order.length) index = 0;
@@ -7097,7 +7096,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
* lines are not redrawn. The fix is to detect the case and force
* a redraw of the first column.
*/
- int width = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0);
+ int width = (int)OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0);
if (lastWidth == 0 && width > 0) {
if (_getLinesVisible()) {
RECT rect = new RECT ();
@@ -7157,7 +7156,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT wmNotifyToolTip (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotifyToolTip (NMHDR hdr, long wParam, long lParam) {
switch (hdr.code) {
case OS.NM_CUSTOMDRAW: {
if (toolTipText != null) break;
@@ -7173,7 +7172,7 @@ LRESULT wmNotifyToolTip (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
LRESULT result = super.wmNotify (hdr, wParam, lParam);
if (result != null) return result;
if (hdr.code != OS.TTN_SHOW) tipRequested = true;
- long /*int*/ code = callWindowProc (handle, OS.WM_NOTIFY, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_NOTIFY, wParam, lParam);
if (hdr.code != OS.TTN_SHOW) tipRequested = false;
if (toolTipText != null) break;
if (isCustomToolTip ()) {
@@ -7192,10 +7191,10 @@ LRESULT wmNotifyToolTip (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
*/
if (OS.SendMessage (handle, OS.LVM_SUBITEMHITTEST, 0, pinfo) >= 0) {
TableItem item = _getItem (pinfo.iItem);
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ oldFont = 0, newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ long hDC = OS.GetDC (handle);
+ long oldFont = 0, newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
- long /*int*/ hFont = item.fontHandle (pinfo.iSubItem);
+ long hFont = item.fontHandle (pinfo.iSubItem);
if (hFont != -1) hFont = OS.SelectObject (hDC, hFont);
Event event = sendMeasureItemEvent (item, pinfo.iItem, pinfo.iSubItem, hDC);
if (!isDisposed () && !item.isDisposed ()) {
@@ -7205,7 +7204,7 @@ LRESULT wmNotifyToolTip (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
if (hdr.code == OS.TTN_SHOW) {
RECT toolRect = toolTipRect (itemRect);
OS.MapWindowPoints (handle, 0, toolRect, 2);
- long /*int*/ hwndToolTip = OS.SendMessage (handle, OS.LVM_GETTOOLTIPS, 0, 0);
+ long hwndToolTip = OS.SendMessage (handle, OS.LVM_GETTOOLTIPS, 0, 0);
int flags = OS.SWP_NOACTIVATE | OS.SWP_NOZORDER;
int width = toolRect.right - toolRect.left, height = toolRect.bottom - toolRect.top;
OS.SetWindowPos (hwndToolTip, 0, toolRect.left , toolRect.top, width, height, flags);
@@ -7250,7 +7249,7 @@ LRESULT wmNotifyToolTip (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long /*int*/ lParam) {
+LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) {
switch (nmcd.dwDrawStage) {
case OS.CDDS_PREPAINT: {
if (isCustomToolTip ()) {
@@ -7277,10 +7276,10 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long /*int*/ lParam) {
*/
if (OS.SendMessage (handle, OS.LVM_SUBITEMHITTEST, 0, pinfo) >= 0) {
TableItem item = _getItem (pinfo.iItem);
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ hFont = item.fontHandle (pinfo.iSubItem);
+ long hDC = OS.GetDC (handle);
+ long hFont = item.fontHandle (pinfo.iSubItem);
if (hFont == -1) hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
- long /*int*/ oldFont = OS.SelectObject (hDC, hFont);
+ long oldFont = OS.SelectObject (hDC, hFont);
boolean drawForeground = true;
RECT cellRect = item.getBounds (pinfo.iItem, pinfo.iSubItem, true, true, false, false, hDC);
if (hooks (SWT.EraseItem)) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
index b6bc0cb37e..097ab46efa 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
@@ -319,8 +319,77 @@ public int getWidth () {
int getWidthInPixels () {
int index = parent.indexOf (this);
if (index == -1) return 0;
- long /*int*/ hwnd = parent.handle;
- return (int)/*64*/OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);
+ long hwnd = parent.handle;
+ return (int)OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);
+}
+
+/**
+ * WINAPI doesn't provide any means to request column's optimal size.
+ * There is only an API to resize to optimal size. The workaround is to
+ * 1) disable redraw
+ * 2) resize to optimal
+ * 3) query new column size
+ * 4) set old column size
+ * 5) enable redraw
+ * This preserves old column size. As a consequence, no painting is
+ * needed after enabling redraw.
+ */
+private int calcAutoWidth(int index, boolean withHeader) {
+ long hwnd = parent.handle;
+
+ // WM_SETREDRAW has a side effect of forcing Control to be visible.
+ // On the other hand, if control is invisible, 'WM_SETREDRAW' is not needed.
+ int style = OS.GetWindowLong (hwnd, OS.GWL_STYLE);
+ boolean isTableVisible = ((style & OS.WS_VISIBLE) != 0);
+ boolean isTableDrawing = parent.getDrawing ();
+ boolean needsDisableRedraw = isTableVisible && isTableDrawing;
+
+ try {
+ if (needsDisableRedraw) {
+ // WM_SETREDRAW is used directly, because 'Control.setRedraw()'
+ // also repaints, which is to be avoided in this function.
+ OS.SendMessage (hwnd, OS.WM_SETREDRAW, 0, 0);
+ }
+
+ int oldWidth = (int)OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);
+
+ /*
+ * Feature in Windows. When LVSCW_AUTOSIZE_USEHEADER is used
+ * with LVM_SETCOLUMNWIDTH to resize the last column, the last
+ * column is expanded to fill the client area. The fix is to
+ * resize the table to be small, set the column width and then
+ * restore the table to its original size.
+ *
+ * Note: temporarily setting LVS_EX_COLUMNSNAPPOINTS may be a
+ * less intrusive workaround.
+ */
+ RECT rect = null;
+ boolean fixWidth = index == parent.getColumnCount () - 1;
+ if (fixWidth) {
+ rect = new RECT ();
+ OS.GetWindowRect (hwnd, rect);
+ OS.UpdateWindow (hwnd);
+ int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOREDRAW | OS.SWP_NOZORDER;
+ OS.SetWindowPos (hwnd, 0, 0, 0, 0, rect.bottom - rect.top, flags);
+ }
+
+ int resizeType = withHeader ? OS.LVSCW_AUTOSIZE_USEHEADER : OS.LVSCW_AUTOSIZE;
+ OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, resizeType);
+
+ if (fixWidth) {
+ int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOZORDER;
+ OS.SetWindowPos (hwnd, 0, 0, 0, rect.right - rect.left, rect.bottom - rect.top, flags);
+ }
+
+ int newWidth = (int)OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);
+ OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, oldWidth);
+
+ return newWidth;
+ } finally {
+ if (needsDisableRedraw) {
+ OS.SendMessage (hwnd, OS.WM_SETREDRAW, 1, 0);
+ }
+ }
}
/**
@@ -338,10 +407,10 @@ public void pack () {
checkWidget ();
int index = parent.indexOf (this);
if (index == -1) return;
- long /*int*/ hwnd = parent.handle;
- int oldWidth = (int)/*64*/OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);
+ long hwnd = parent.handle;
+ int oldWidth = (int)OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);
TCHAR buffer = new TCHAR (parent.getCodePage (), text, true);
- int headerWidth = (int)/*64*/OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer) + Table.HEADER_MARGIN;
+ int headerWidth = (int)OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer) + Table.HEADER_MARGIN;
if (OS.IsAppThemed ()) headerWidth += Table.HEADER_EXTRA;
boolean hasHeaderImage = false;
if (image != null || parent.sortColumn == this) {
@@ -352,25 +421,25 @@ public void pack () {
Rectangle bounds = image.getBoundsInPixels ();
headerWidth += bounds.width;
}
- long /*int*/ hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
- int margin = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_GETBITMAPMARGIN, 0, 0);
+ long hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
+ int margin = (int)OS.SendMessage (hwndHeader, OS.HDM_GETBITMAPMARGIN, 0, 0);
headerWidth += margin * 4;
}
parent.ignoreColumnResize = true;
int columnWidth = 0;
if (parent.hooks (SWT.MeasureItem)) {
RECT headerRect = new RECT ();
- long /*int*/ hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
+ long hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect);
OS.MapWindowPoints (hwndHeader, hwnd, headerRect, 2);
- long /*int*/ hDC = OS.GetDC (hwnd);
- long /*int*/ oldFont = 0, newFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
+ long hDC = OS.GetDC (hwnd);
+ long oldFont = 0, newFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
- int count = (int)/*64*/OS.SendMessage (hwnd, OS.LVM_GETITEMCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (hwnd, OS.LVM_GETITEMCOUNT, 0, 0);
for (int i=0; i<count; i++) {
TableItem item = parent._getItem (i, false);
if (item != null) {
- long /*int*/ hFont = item.fontHandle (index);
+ long hFont = item.fontHandle (index);
if (hFont != -1) hFont = OS.SelectObject (hDC, hFont);
Event event = parent.sendMeasureItemEvent (item, i, index, hDC);
if (hFont != -1) hFont = OS.SelectObject (hDC, hFont);
@@ -381,10 +450,8 @@ public void pack () {
}
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (hwnd, hDC);
- OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, columnWidth);
} else {
- OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, OS.LVSCW_AUTOSIZE);
- columnWidth = (int)/*64*/OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);
+ columnWidth = calcAutoWidth (index, false);
if (index == 0) {
/*
* Bug in Windows. When LVM_SETCOLUMNWIDTH is used with LVSCW_AUTOSIZE
@@ -401,7 +468,7 @@ public void pack () {
* width by the width of the image list.
*/
if ((parent.style & SWT.CHECK) != 0) {
- long /*int*/ hStateList = OS.SendMessage (hwnd, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
+ long hStateList = OS.SendMessage (hwnd, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
if (hStateList != 0) {
int [] cx = new int [1], cy = new int [1];
OS.ImageList_GetIconSize (hStateList, cx, cy);
@@ -412,48 +479,28 @@ public void pack () {
}
if (headerWidth > columnWidth) {
if (!hasHeaderImage) {
- /*
- * Feature in Windows. When LVSCW_AUTOSIZE_USEHEADER is used
- * with LVM_SETCOLUMNWIDTH to resize the last column, the last
- * column is expanded to fill the client area. The fix is to
- * resize the table to be small, set the column width and then
- * restore the table to its original size.
- */
- RECT rect = null;
- boolean fixWidth = index == parent.getColumnCount () - 1;
- if (fixWidth) {
- rect = new RECT ();
- OS.GetWindowRect (hwnd, rect);
- OS.UpdateWindow (hwnd);
- int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOREDRAW | OS.SWP_NOZORDER;
- OS.SetWindowPos (hwnd, 0, 0, 0, 0, rect.bottom - rect.top, flags);
- }
- OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, OS.LVSCW_AUTOSIZE_USEHEADER);
- if (fixWidth) {
- int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOZORDER;
- OS.SetWindowPos (hwnd, 0, 0, 0, rect.right - rect.left, rect.bottom - rect.top, flags);
- }
+ // The code has been there for years and it's no longer clear why
+ // not just use 'headerWidth' here. Maybe because SWT's size
+ // calculation is imperfect and WINAPI will do it better?
+ columnWidth = calcAutoWidth (index, true);
} else {
- OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, headerWidth);
- }
- } else {
- if (index == 0) {
- OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, columnWidth);
+ columnWidth = headerWidth;
}
}
+
+ OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, columnWidth);
+
parent.ignoreColumnResize = false;
- int newWidth = (int)/*64*/OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);
- if (oldWidth != newWidth) {
+ if (oldWidth != columnWidth) {
updateToolTip (index);
sendEvent (SWT.Resize);
if (isDisposed ()) return;
boolean moved = false;
- int [] order = parent.getColumnOrder ();
TableColumn [] columns = parent.getColumns ();
- for (int i=0; i<order.length; i++) {
- TableColumn column = columns [order [i]];
+ for (int columnindex : parent.getColumnOrder ()) {
+ TableColumn column = columns [columnindex];
if (moved && !column.isDisposed ()) {
- column.updateToolTip (order [i]);
+ column.updateToolTip (columnindex);
column.sendEvent (SWT.Move);
}
if (column == this) moved = true;
@@ -547,7 +594,7 @@ public void setAlignment (int alignment) {
if (index == -1 || index == 0) return;
style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
LVCOLUMN lvColumn = new LVCOLUMN ();
lvColumn.mask = OS.LVCF_FMT;
OS.SendMessage (hwnd, OS.LVM_GETCOLUMN, index, lvColumn);
@@ -568,7 +615,7 @@ public void setAlignment (int alignment) {
parent.forceResize ();
RECT rect = new RECT (), headerRect = new RECT ();
OS.GetClientRect (hwnd, rect);
- long /*int*/ hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
+ long hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect);
OS.MapWindowPoints (hwndHeader, hwnd, headerRect, 2);
rect.left = headerRect.left;
@@ -592,7 +639,7 @@ public void setImage (Image image) {
void setImage (Image image, boolean sort, boolean right) {
int index = parent.indexOf (this);
if (index == -1) return;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
LVCOLUMN lvColumn = new LVCOLUMN ();
lvColumn.mask = OS.LVCF_FMT | OS.LVCF_IMAGE;
OS.SendMessage (hwnd, OS.LVM_GETCOLUMN, index, lvColumn);
@@ -656,8 +703,8 @@ public void setResizable (boolean resizable) {
void setSortDirection (int direction) {
int index = parent.indexOf (this);
if (index == -1) return;
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
+ long hwnd = parent.handle;
+ long hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
HDITEM hdItem = new HDITEM ();
hdItem.mask = OS.HDI_FORMAT | OS.HDI_IMAGE;
OS.SendMessage (hwndHeader, OS.HDM_GETITEM, index, hdItem);
@@ -700,8 +747,8 @@ void setSortDirection (int direction) {
parent.forceResize ();
RECT rect = new RECT ();
OS.GetClientRect (hwnd, rect);
- if ((int)/*64*/OS.SendMessage (hwnd, OS.LVM_GETBKCOLOR, 0, 0) != OS.CLR_NONE) {
- int oldColumn = (int)/*64*/OS.SendMessage (hwnd, OS.LVM_GETSELECTEDCOLUMN, 0, 0);
+ if ((int)OS.SendMessage (hwnd, OS.LVM_GETBKCOLOR, 0, 0) != OS.CLR_NONE) {
+ int oldColumn = (int)OS.SendMessage (hwnd, OS.LVM_GETSELECTEDCOLUMN, 0, 0);
int newColumn = direction == SWT.NONE ? -1 : index;
OS.SendMessage (hwnd, OS.LVM_SETSELECTEDCOLUMN, newColumn, 0);
RECT headerRect = new RECT ();
@@ -739,7 +786,7 @@ public void setText (String string) {
* text does not draw. The fix is to query and then
* set the alignment.
*/
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
LVCOLUMN lvColumn = new LVCOLUMN ();
lvColumn.mask = OS.LVCF_FMT;
OS.SendMessage (hwnd, OS.LVM_GETCOLUMN, index, lvColumn);
@@ -751,14 +798,14 @@ public void setText (String string) {
* at the end of the text. The fix is to remove
* mnemonic characters.
*/
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
char [] buffer = fixMnemonic (string);
int byteCount = buffer.length * TCHAR.sizeof;
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (pszText, buffer, byteCount);
lvColumn.mask |= OS.LVCF_TEXT;
lvColumn.pszText = pszText;
- long /*int*/ result = OS.SendMessage (hwnd, OS.LVM_SETCOLUMN, index, lvColumn);
+ long result = OS.SendMessage (hwnd, OS.LVM_SETCOLUMN, index, lvColumn);
if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
if (result == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
}
@@ -793,7 +840,7 @@ public void setText (String string) {
public void setToolTipText (String string) {
checkWidget();
toolTipText = string;
- long /*int*/ hwndHeaderToolTip = parent.headerToolTipHandle;
+ long hwndHeaderToolTip = parent.headerToolTipHandle;
if (hwndHeaderToolTip == 0) {
parent.createHeaderToolTips ();
parent.updateHeaderToolTips ();
@@ -819,17 +866,17 @@ void setWidthInPixels (int width) {
if (width < 0) return;
int index = parent.indexOf (this);
if (index == -1) return;
- long /*int*/ hwnd = parent.handle;
- if (width != (int)/*64*/OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0)) {
+ long hwnd = parent.handle;
+ if (width != (int)OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0)) {
OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, width);
}
}
void updateToolTip (int index) {
- long /*int*/ hwndHeaderToolTip = parent.headerToolTipHandle;
+ long hwndHeaderToolTip = parent.headerToolTipHandle;
if (hwndHeaderToolTip != 0) {
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
+ long hwnd = parent.handle;
+ long hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
RECT rect = new RECT ();
if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, rect) != 0) {
TOOLINFO lpti = new TOOLINFO ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
index c58affa272..0206d30cb3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
@@ -152,7 +152,7 @@ void destroyWidget () {
releaseHandle ();
}
-long /*int*/ fontHandle (int index) {
+long fontHandle (int index) {
if (cellFont != null && cellFont [index] != null) return cellFont [index].handle;
if (font != null) return font.handle;
return -1;
@@ -256,7 +256,7 @@ RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean
return getBounds (row, column, getText, getImage, fullText, false, 0);
}
-RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean fullText, boolean fullImage, long /*int*/ hDC) {
+RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean fullText, boolean fullImage, long hDC) {
if (!getText && !getImage) return new RECT ();
int columnCount = parent.getColumnCount ();
if (!(0 <= column && column < Math.max (1, columnCount))) {
@@ -264,24 +264,24 @@ RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean
}
if (parent.fixScrollWidth) parent.setScrollWidth (null, true);
RECT rect = new RECT ();
- long /*int*/ hwnd = parent.handle;
- int bits = (int)/*64*/OS.SendMessage (hwnd, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ long hwnd = parent.handle;
+ int bits = (int)OS.SendMessage (hwnd, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
if (column == 0 && (bits & OS.LVS_EX_FULLROWSELECT) == 0) {
if (parent.explorerTheme) {
rect.left = OS.LVIR_ICON;
parent.ignoreCustomDraw = true;
- long /*int*/ code = OS.SendMessage (hwnd, OS. LVM_GETITEMRECT, row, rect);
+ long code = OS.SendMessage (hwnd, OS. LVM_GETITEMRECT, row, rect);
parent.ignoreCustomDraw = false;
if (code == 0) return new RECT ();
if (getText) {
int width = 0;
- long /*int*/ hFont = fontHandle (column);
+ long hFont = fontHandle (column);
if (hFont == -1 && hDC == 0) {
TCHAR buffer = new TCHAR (parent.getCodePage (), text, true);
- width = (int)/*64*/OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer);
+ width = (int)OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer);
} else {
char [] buffer = text.toCharArray ();
- long /*int*/ textDC = hDC != 0 ? hDC : OS.GetDC (hwnd), oldFont = -1;
+ long textDC = hDC != 0 ? hDC : OS.GetDC (hwnd), oldFont = -1;
if (hDC == 0) {
if (hFont == -1) hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
oldFont = OS.SelectObject (textDC, hFont);
@@ -302,7 +302,7 @@ RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean
if (getText) {
rect.left = OS.LVIR_SELECTBOUNDS;
parent.ignoreCustomDraw = true;
- long /*int*/ code = OS.SendMessage (hwnd, OS.LVM_GETITEMRECT, row, rect);
+ long code = OS.SendMessage (hwnd, OS.LVM_GETITEMRECT, row, rect);
parent.ignoreCustomDraw = false;
if (code == 0) return new RECT ();
if (!getImage) {
@@ -316,14 +316,14 @@ RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean
} else {
rect.left = OS.LVIR_ICON;
parent.ignoreCustomDraw = true;
- long /*int*/ code = OS.SendMessage (hwnd, OS.LVM_GETITEMRECT, row, rect);
+ long code = OS.SendMessage (hwnd, OS.LVM_GETITEMRECT, row, rect);
parent.ignoreCustomDraw = false;
if (code == 0) return new RECT ();
}
}
if (fullText || fullImage) {
RECT headerRect = new RECT ();
- long /*int*/ hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
+ long hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, 0, headerRect);
OS.MapWindowPoints (hwndHeader, hwnd, headerRect, 2);
if (getText && fullText) rect.right = headerRect.right;
@@ -347,7 +347,7 @@ RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean
*/
rect.left = getText ? OS.LVIR_LABEL : OS.LVIR_ICON;
parent.ignoreCustomDraw = true;
- long /*int*/ code = OS.SendMessage (hwnd, OS. LVM_GETSUBITEMRECT, row, rect);
+ long code = OS.SendMessage (hwnd, OS. LVM_GETSUBITEMRECT, row, rect);
parent.ignoreCustomDraw = false;
if (code == 0) return new RECT ();
/*
@@ -381,7 +381,7 @@ RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean
}
if (column == 0 && fullImage) {
RECT headerRect = new RECT ();
- long /*int*/ hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
+ long hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, 0, headerRect);
OS.MapWindowPoints (hwndHeader, hwnd, headerRect, 2);
rect.left = headerRect.left;
@@ -389,7 +389,7 @@ RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean
} else {
rect.left = OS.LVIR_ICON;
parent.ignoreCustomDraw = true;
- long /*int*/ code = OS.SendMessage (hwnd, OS. LVM_GETSUBITEMRECT, row, rect);
+ long code = OS.SendMessage (hwnd, OS. LVM_GETSUBITEMRECT, row, rect);
parent.ignoreCustomDraw = false;
if (code == 0) return new RECT ();
if (!hasImage) rect.right = rect.left;
@@ -706,7 +706,7 @@ Rectangle getTextBoundsInPixels (int index) {
void redraw () {
if (parent.currentItem == this || !parent.getDrawing ()) return;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
if (!OS.IsWindowVisible (hwnd)) return;
int index = parent.indexOf (this);
if (index == -1) return;
@@ -715,7 +715,7 @@ void redraw () {
void redraw (int column, boolean drawText, boolean drawImage) {
if (parent.currentItem == this || !parent.getDrawing ()) return;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
if (!OS.IsWindowVisible (hwnd)) return;
int index = parent.indexOf (this);
if (index == -1) return;
@@ -885,7 +885,7 @@ public void setFont (Font font){
if ((parent.style & SWT.VIRTUAL) == 0 && cached) {
int itemIndex = parent.indexOf (this);
if (itemIndex != -1) {
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
LVITEM lvItem = new LVITEM ();
lvItem.mask = OS.LVIF_TEXT;
lvItem.iItem = itemIndex;
@@ -949,7 +949,7 @@ public void setFont (int index, Font font) {
if ((parent.style & SWT.VIRTUAL) == 0 && cached) {
int itemIndex = parent.indexOf (this);
if (itemIndex != -1) {
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
LVITEM lvItem = new LVITEM ();
lvItem.mask = OS.LVIF_TEXT;
lvItem.iItem = itemIndex;
@@ -1159,7 +1159,7 @@ public void setImageIndent (int indent) {
} else {
int index = parent.indexOf (this);
if (index != -1) {
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
LVITEM lvItem = new LVITEM ();
lvItem.mask = OS.LVIF_INDENT;
lvItem.iItem = index;
@@ -1246,7 +1246,7 @@ public void setText (int index, String string) {
if ((parent.style & SWT.VIRTUAL) == 0 && cached) {
int itemIndex = parent.indexOf (this);
if (itemIndex != -1) {
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
LVITEM lvItem = new LVITEM ();
lvItem.mask = OS.LVIF_TEXT;
lvItem.iItem = itemIndex;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java
index ed3c218b2c..e0bc571bad 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskBar.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2017 IBM Corporation and others.
+ * Copyright (c) 2010, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,9 +15,12 @@
package org.eclipse.swt.widgets;
+import java.io.*;
+
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.ole.win32.*;
import org.eclipse.swt.internal.win32.*;
/**
@@ -40,45 +43,17 @@ import org.eclipse.swt.internal.win32.*;
public class TaskBar extends Widget {
int itemCount;
TaskItem [] items = new TaskItem [4];
- long /*int*/ mTaskbarList3;
+ ITaskbarList3 mTaskbarList3;
+ String iconsDir;
static final char [] EXE_PATH;
- static final char [] ICO_DIR = {'i','c','o','_','d','i','r','\0'};
static final PROPERTYKEY PKEY_Title = new PROPERTYKEY ();
static final PROPERTYKEY PKEY_AppUserModel_IsDestListSeparator = new PROPERTYKEY ();
static final String EXE_PATH_KEY = "org.eclipse.swt.win32.taskbar.executable"; //$NON-NLS-1$
static final String EXE_ARGS_KEY = "org.eclipse.swt.win32.taskbar.arguments"; //$NON-NLS-1$
static final String ICON_KEY = "org.eclipse.swt.win32.taskbar.icon"; //$NON-NLS-1$
static final String ICON_INDEX_KEY = "org.eclipse.swt.win32.taskbar.icon.index"; //$NON-NLS-1$
- static final byte [] CLSID_TaskbarList = new byte [16];
- static final byte [] CLSID_DestinationList = new byte[16];
- static final byte [] CLSID_EnumerableObjectCollection = new byte[16];
- static final byte [] CLSID_ShellLink = new byte[16];
- static final byte [] CLSID_FileOperation = new byte [16];
- static final byte [] IID_ITaskbarList3 = new byte [16];
- static final byte [] IID_ICustomDestinationList = new byte[16];
- static final byte [] IID_IObjectArray = new byte[16];
- static final byte [] IID_IObjectCollection = new byte[16];
- static final byte [] IID_IShellLinkW = new byte[16];
- static final byte [] IID_IPropertyStore = new byte[16];
- static final byte [] IID_IShellItem = new byte [16];
- static final byte [] IID_IFileOperation = new byte [16];
- static final byte [] FOLDERID_LocalAppData = new byte [16];
static {
- OS.IIDFromString ("{56FDF344-FD6D-11d0-958A-006097C9A090}\0".toCharArray (), CLSID_TaskbarList); //$NON-NLS-1$
- OS.IIDFromString ("{77f10cf0-3db5-4966-b520-b7c54fd35ed6}\0".toCharArray (), CLSID_DestinationList); //$NON-NLS-1$
- OS.IIDFromString ("{2d3468c1-36a7-43b6-ac24-d3f02fd9607a}\0".toCharArray (), CLSID_EnumerableObjectCollection); //$NON-NLS-1$
- OS.IIDFromString ("{00021401-0000-0000-C000-000000000046}\0".toCharArray (), CLSID_ShellLink); //$NON-NLS-1$
- OS.IIDFromString ("{3ad05575-8857-4850-9277-11b85bdb8e09}\0".toCharArray (), CLSID_FileOperation);
- OS.IIDFromString ("{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}\0".toCharArray (), IID_ITaskbarList3); //$NON-NLS-1$
- OS.IIDFromString ("{6332debf-87b5-4670-90c0-5e57b408a49e}\0".toCharArray (), IID_ICustomDestinationList); //$NON-NLS-1$
- OS.IIDFromString ("{92CA9DCD-5622-4bba-A805-5E9F541BD8C9}\0".toCharArray (), IID_IObjectArray); //$NON-NLS-1$
- OS.IIDFromString ("{5632b1a4-e38a-400a-928a-d4cd63230295}\0".toCharArray (), IID_IObjectCollection); //$NON-NLS-1$
- OS.IIDFromString ("{000214F9-0000-0000-C000-000000000046}\0".toCharArray (), IID_IShellLinkW); //$NON-NLS-1$
- OS.IIDFromString ("{886d8eeb-8cf2-4446-8d02-cdba1dbdcf99}\0".toCharArray (), IID_IPropertyStore); //$NON-NLS-1$
- OS.IIDFromString ("{43826d1e-e718-42ee-bc55-a1e261c37bfe}\0".toCharArray (), IID_IShellItem); //$NON-NLS-1$
- OS.IIDFromString ("{947aab5f-0a5c-4c13-b4d6-4bf7836fc9f8}\0".toCharArray (), IID_IFileOperation); //$NON-NLS-1$
- OS.IIDFromString ("{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}\0".toCharArray (), FOLDERID_LocalAppData); //$NON-NLS-1$
OS.PSPropertyKeyFromString ("{F29F85E0-4FF9-1068-AB91-08002B27B3D9} 2\0".toCharArray (), PKEY_Title); //$NON-NLS-1$
OS.PSPropertyKeyFromString ("{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}, 6\0".toCharArray (), PKEY_AppUserModel_IsDestListSeparator); //$NON-NLS-1$
char [] buffer = new char [OS.MAX_PATH];
@@ -95,10 +70,11 @@ TaskBar (Display display, int style) {
}
void createHandle () {
- long /*int*/[] ppv = new long /*int*/ [1];
- int hr = OS.CoCreateInstance (CLSID_TaskbarList, 0, OS.CLSCTX_INPROC_SERVER, IID_ITaskbarList3, ppv);
+ long[] ppv = new long [1];
+ int hr = COM.CoCreateInstance (COM.CLSID_TaskbarList, 0, COM.CLSCTX_INPROC_SERVER, COM.IID_ITaskbarList3, ppv);
+ if (hr == COM.REGDB_E_CLASSNOTREG) error (SWT.ERROR_NOT_IMPLEMENTED);
if (hr != OS.S_OK) error (SWT.ERROR_NO_HANDLES);
- mTaskbarList3 = ppv [0];
+ mTaskbarList3 = new ITaskbarList3 (ppv [0]);
}
void createItem (TaskItem item, int index) {
@@ -114,24 +90,23 @@ void createItem (TaskItem item, int index) {
}
void createItems () {
- Shell [] shells = display.getShells ();
- for (int i = 0; i < shells.length; i++) {
- getItem (shells[i]);
+ for (Shell shell : display.getShells ()) {
+ getItem (shell);
}
getItem (null);
}
-long /*int*/ createShellLink (MenuItem item, String directory) {
+IShellLink createShellLink (MenuItem item) {
int style = item.getStyle ();
- if ((style & SWT.CASCADE) != 0) return 0;
- long /*int*/ [] ppv = new long /*int*/ [1];
- int hr = OS.CoCreateInstance (CLSID_ShellLink, 0, OS.CLSCTX_INPROC_SERVER, IID_IShellLinkW, ppv);
+ if ((style & SWT.CASCADE) != 0) return null;
+ long [] ppv = new long [1];
+ int hr = COM.CoCreateInstance (COM.CLSID_ShellLink, 0, COM.CLSCTX_INPROC_SERVER, COM.IID_IShellLinkW, ppv);
if (hr != OS.S_OK) error (SWT.ERROR_NO_HANDLES);
- long /*int*/ pLink = ppv [0];
+ IShellLink pLink = new IShellLink (ppv [0]);
- long /*int*/ hHeap = OS.GetProcessHeap ();
- long /*int*/ pv = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, OS.PROPVARIANT_sizeof());
- long /*int*/ titlePtr = 0;
+ long hHeap = OS.GetProcessHeap ();
+ long pv = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, OS.PROPVARIANT_sizeof());
+ long titlePtr = 0;
PROPERTYKEY key;
if ((style & SWT.SEPARATOR) != 0) {
OS.MoveMemory (pv, new short [] {OS.VT_BOOL}, 2);
@@ -145,10 +120,9 @@ long /*int*/ createShellLink (MenuItem item, String directory) {
titlePtr = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length * 2);
OS.MoveMemory (titlePtr, buffer, buffer.length * 2);
OS.MoveMemory (pv, new short [] {OS.VT_LPWSTR}, 2);
- OS.MoveMemory (pv + 8, new long /*int*/ [] {titlePtr}, C.PTR_SIZEOF);
+ OS.MoveMemory (pv + 8, new long [] {titlePtr}, C.PTR_SIZEOF);
key = PKEY_Title;
- /*IShellLink::SetPath*/
String exePath = (String)item.getData (EXE_PATH_KEY);
if (exePath != null) {
length = exePath.length ();
@@ -157,16 +131,15 @@ long /*int*/ createShellLink (MenuItem item, String directory) {
} else {
buffer = EXE_PATH;
}
- hr = OS.VtblCall (20, pLink, buffer);
+ hr = pLink.SetPath(buffer);
if (hr != OS.S_OK) error (SWT.ERROR_INVALID_ARGUMENT);
- text = (String)item.getData (EXE_ARGS_KEY);
+ text = (String)item.getData (EXE_ARGS_KEY);
if (text == null) text = Display.LAUNCHER_PREFIX + Display.TASKBAR_EVENT + item.id;
length = text.length ();
buffer = new char [length + 1];
text.getChars (0, length, buffer, 0);
- /*IShellLink::SetArguments*/
- hr = OS.VtblCall (11, pLink, buffer);
+ hr = pLink.SetArguments(buffer);
if (hr != OS.S_OK) error (SWT.ERROR_INVALID_ARGUMENT);
/* This code is intentionally commented */
@@ -175,8 +148,7 @@ long /*int*/ createShellLink (MenuItem item, String directory) {
// length = tooltip.length ();
// buffer = new char [length + 1];
// tooltip.getChars (0, length, buffer, 0);
-// /*IShellLink::SetDescription*/
-// hr = OS.VtblCall (7, pLink, buffer);
+// hr = pLink.SetDescription (buffer);
// if (hr != OS.S_OK) error (SWT.ERROR_INVALID_ARGUMENT);
// }
@@ -186,13 +158,20 @@ long /*int*/ createShellLink (MenuItem item, String directory) {
text = (String)item.getData (ICON_INDEX_KEY);
if (text != null) index = Integer.parseInt (text);
} else {
+ String directory = null;
Image image = item.getImage ();
- if (image != null && directory != null) {
- icon = directory + "\\menu" + item.id + ".ico" ;
+ if (image != null) directory = getIconsDir ();
+ if (directory != null) {
+ icon = directory + "\\" + "menu" + item.id + ".ico";
ImageData data;
if (item.hBitmap != 0) {
Image image2 = Image.win32_new (display, SWT.BITMAP, item.hBitmap);
data = image2.getImageData (DPIUtil.getDeviceZoom ());
+ /*
+ * image2 instance doesn't own the handle and shall not be disposed. Make it
+ * appear disposed to cause leak trackers to ignore it.
+ */
+ image2.handle = 0;
} else {
data = image.getImageData (DPIUtil.getDeviceZoom ());
}
@@ -205,52 +184,43 @@ long /*int*/ createShellLink (MenuItem item, String directory) {
length = icon.length ();
buffer = new char [length + 1];
icon.getChars (0, length, buffer, 0);
- /*IShellLink::SetIconLocation*/
- hr = OS.VtblCall (17, pLink, buffer, index);
+ hr = pLink.SetIconLocation(buffer, index);
if (hr != OS.S_OK) error (SWT.ERROR_INVALID_ARGUMENT);
}
}
- /*IUnknown::QueryInterface*/
- hr = OS.VtblCall (0, pLink, IID_IPropertyStore, ppv);
+ hr = pLink.QueryInterface(COM.IID_IPropertyStore, ppv);
if (hr != OS.S_OK) error (SWT.ERROR_NO_HANDLES);
- long /*int*/ pPropStore = ppv [0];
- /*IPropertyStore::SetValue*/
- hr = OS.VtblCall (6, pPropStore, key, pv);
+ IPropertyStore pPropStore = new IPropertyStore (ppv [0]);
+ hr = pPropStore.SetValue(key, pv);
if (hr != OS.S_OK) error (SWT.ERROR_INVALID_ARGUMENT);
- /*IPropertyStore::Commit*/
- OS.VtblCall (7, pPropStore);
- /*IUnknown::Release*/
- OS.VtblCall (2, pPropStore);
+ pPropStore.Commit();
+ pPropStore.Release();
OS.HeapFree (hHeap, 0, pv);
if (titlePtr != 0) OS.HeapFree (hHeap, 0, titlePtr);
return pLink;
}
-long /*int*/ createShellLinkArray (MenuItem [] items, String directory) {
- if (items == null) return 0;
- if (items.length == 0) return 0;
- long /*int*/ [] ppv = new long /*int*/ [1];
- int hr = OS.CoCreateInstance (CLSID_EnumerableObjectCollection, 0, OS.CLSCTX_INPROC_SERVER, IID_IObjectCollection, ppv);
+IObjectArray createShellLinkArray (MenuItem [] items) {
+ if (items == null) return null;
+ if (items.length == 0) return null;
+ long [] ppv = new long [1];
+ int hr = COM.CoCreateInstance (COM.CLSID_EnumerableObjectCollection, 0, COM.CLSCTX_INPROC_SERVER, COM.IID_IObjectCollection, ppv);
if (hr != OS.S_OK) error (SWT.ERROR_NO_HANDLES);
- long /*int*/ pObjColl = ppv [0];
- for (int i = 0; i < items.length; i++) {
- long /*int*/ pLink = createShellLink (items[i], directory);
- if (pLink != 0) {
- /*IObjectCollection::AddObject*/
- hr = OS.VtblCall (5, pObjColl, pLink);
+ IObjectCollection pObjColl = new IObjectCollection (ppv [0]);
+ for (MenuItem item : items) {
+ IShellLink pLink = createShellLink (item);
+ if (pLink != null) {
+ pObjColl.AddObject (pLink);
if (hr != OS.S_OK) error (SWT.ERROR_INVALID_ARGUMENT);
- /*IUnknown::Release*/
- OS.VtblCall (2, pLink);
+ pLink.Release ();
}
}
- /*IUnknown::QueryInterface*/
- hr = OS.VtblCall (0, pObjColl, IID_IObjectArray, ppv);
+ hr = pObjColl.QueryInterface(COM.IID_IObjectArray, ppv);
if (hr != OS.S_OK) error (SWT.ERROR_NO_HANDLES);
- long /*int*/ poa = ppv [0];
- /*IUnknown::Release*/
- OS.VtblCall (2, pObjColl);
+ IObjectArray poa = new IObjectArray (ppv [0]);
+ pObjColl.Release ();
return poa;
}
@@ -265,108 +235,16 @@ void destroyItem (TaskItem item) {
items [itemCount] = null;
}
-String getDirectory (char[] appName) {
- char [] appDir = new char [appName.length];
- for (int i = 0; i < appName.length; i++) {
- char c = appName [i];
- switch (c) {
- case '\\':
- case '/':
- case ':':
- case '*':
- case '?':
- case '\"':
- case '<':
- case '>':
- case '|':
- appDir [i] = '_';
- break;
- default:
- appDir [i] = c;
- }
- }
- String result = null;
- long /*int*/ [] ppv = new long /*int*/ [1];
- int hr = OS.SHCreateItemInKnownFolder (FOLDERID_LocalAppData, 0, null, IID_IShellItem, ppv);
- if (hr == OS.S_OK) {
- long /*int*/ psiRoot = ppv [0];
- hr = OS.CoCreateInstance (CLSID_FileOperation, 0, OS.CLSCTX_INPROC_SERVER, IID_IFileOperation, ppv);
- if (hr == OS.S_OK) {
- long /*int*/ pfo = ppv [0];
- /*IFileOperation.SetOperationFlags*/
- hr = OS.VtblCall (5, pfo, OS.FOF_NO_UI);
- if (hr == OS.S_OK) {
- long /*int*/ psiAppDir = getDirectory (psiRoot, pfo, appDir, false);
- if (psiAppDir != 0) {
- long /*int*/ psiIcoDir = getDirectory (psiAppDir, pfo, ICO_DIR, true);
- if (psiIcoDir != 0) {
- /*IShellItem::GetDisplayName*/
- hr = OS.VtblCall (5, psiIcoDir, OS.SIGDN_FILESYSPATH, ppv);
- if (hr == OS.S_OK) {
- long /*int*/ wstr = ppv [0];
- int length = OS.wcslen (wstr);
- char [] buffer = new char [length];
- OS.MoveMemory (buffer, wstr, length * 2);
- result = new String (buffer);
- OS.CoTaskMemFree (wstr);
- }
- /*IUnknown::Release*/
- OS.VtblCall (2, psiIcoDir);
- }
- /*IUnknown::Release*/
- OS.VtblCall (2, psiAppDir);
- }
- }
- /*IUnknown::Release*/
- OS.VtblCall(2, pfo);
- }
- /*IUnknown::Release*/
- OS.VtblCall (2, psiRoot);
+String getIconsDir() {
+ if (iconsDir != null) return iconsDir;
+ File dir = new File(display.appLocalDir + "\\ico_dir");
+ if (dir.exists()) {
+ // remove old icons
+ for (File file : dir.listFiles()) file.delete();
+ } else if (!dir.mkdirs()) {
+ return null;
}
- return result;
-}
-
-long /*int*/ getDirectory (long /*int*/ parent, long /*int*/ pfo, char [] name, boolean delete) {
- long /*int*/ [] ppv = new long /*int*/ [1];
- int hr = OS.SHCreateItemFromRelativeName (parent, name, 0, IID_IShellItem, ppv);
- if (hr == OS.S_OK) {
- if (delete) {
- /*IFileOperation.Delete*/
- hr = OS.VtblCall (18, pfo, ppv [0], 0);
- /*IUnknown::Release*/
- OS.VtblCall (2, ppv [0]);
- if (hr == OS.S_OK) {
- /*IFileOperation.NewItem */
- hr = OS.VtblCall (20, pfo, parent, OS.FILE_ATTRIBUTE_DIRECTORY, name, null, 0);
- if (hr == OS.S_OK) {
- /*IFileOperation.PerformOperations */
- hr = OS.VtblCall (21, pfo);
- if (hr == OS.S_OK) {
- hr = OS.SHCreateItemFromRelativeName (parent, name, 0, IID_IShellItem, ppv);
- if (hr == OS.S_OK) {
- return ppv [0];
- }
- }
- }
- }
- } else {
- return ppv [0];
- }
- } else {
- /*IFileOperation.NewItem */
- hr = OS.VtblCall (20, pfo, parent, OS.FILE_ATTRIBUTE_DIRECTORY, name, null, 0);
- if (hr == OS.S_OK) {
- /*IFileOperation.PerformOperations */
- hr = OS.VtblCall (21, pfo);
- if (hr == OS.S_OK) {
- hr = OS.SHCreateItemFromRelativeName (parent, name, 0, IID_IShellItem, ppv);
- if (hr == OS.S_OK) {
- return ppv [0];
- }
- }
- }
- }
- return 0;
+ return iconsDir = dir.getPath();
}
/**
@@ -406,9 +284,9 @@ public TaskItem getItem (int index) {
*/
public TaskItem getItem (Shell shell) {
checkWidget ();
- for (int i = 0; i < items.length; i++) {
- if (items [i] != null && items [i].shell == shell) {
- return items [i];
+ for (TaskItem item : items) {
+ if (item != null && item.shell == shell) {
+ return item;
}
}
TaskItem item = new TaskItem (this, SWT.NONE);
@@ -459,8 +337,7 @@ public TaskItem [] getItems () {
@Override
void releaseChildren (boolean destroy) {
if (items != null) {
- for (int i=0; i<items.length; i++) {
- TaskItem item = items [i];
+ for (TaskItem item : items) {
if (item != null && !item.isDisposed ()) {
item.release (false);
}
@@ -479,18 +356,14 @@ void releaseParent () {
@Override
void releaseWidget () {
super.releaseWidget ();
- if (mTaskbarList3 != 0) {
- /* Release() */
- OS.VtblCall (2, mTaskbarList3);
- mTaskbarList3 = 0;
- }
+ mTaskbarList3.Release();
+ mTaskbarList3 = null;
}
@Override
void reskinChildren (int flags) {
if (items != null) {
- for (int i=0; i<items.length; i++) {
- TaskItem item = items [i];
+ for (TaskItem item : items) {
if (item != null) item.reskin (flags);
}
}
@@ -498,10 +371,10 @@ void reskinChildren (int flags) {
}
void setMenu (Menu menu) {
- long /*int*/ [] ppv = new long /*int*/ [1];
- int hr = OS.CoCreateInstance (CLSID_DestinationList, 0, OS.CLSCTX_INPROC_SERVER, IID_ICustomDestinationList, ppv);
+ long [] ppv = new long [1];
+ int hr = COM.CoCreateInstance (COM.CLSID_DestinationList, 0, COM.CLSCTX_INPROC_SERVER, COM.IID_ICustomDestinationList, ppv);
if (hr != OS.S_OK) error (SWT.ERROR_NO_HANDLES);
- long /*int*/ pDestList = ppv[0];
+ ICustomDestinationList pDestList = new ICustomDestinationList (ppv [0]);
String appName = Display.APP_NAME;
char [] buffer = {'S', 'W', 'T', '\0'};
if (appName != null && appName.length () > 0) {
@@ -509,90 +382,56 @@ void setMenu (Menu menu) {
buffer = new char [length + 1];
appName.getChars (0, length, buffer, 0);
}
-
MenuItem [] items = null;
if (menu != null && (items = menu.getItems ()).length != 0) {
- String directory = null;
- for (int i = 0; i < items.length; i++) {
- MenuItem item = items [i];
- if (item.getImage () != null && item.getData (ICON_KEY) == null) {
- directory = getDirectory (buffer);
- break;
- }
- }
- long /*int*/ poa = createShellLinkArray (items, directory);
- if (poa != 0) {
-
- /*ICustomDestinationList::SetAppID*/
- hr = OS.VtblCall (3, pDestList, buffer);
+ IObjectArray poa = createShellLinkArray (items);
+ if (poa != null) {
+ hr = pDestList.SetAppID (buffer);
if (hr != OS.S_OK) error (SWT.ERROR_INVALID_ARGUMENT);
- /*ICustomDestinationList::BeginList*/
int [] cMaxSlots = new int [1];
- OS.VtblCall (4, pDestList, cMaxSlots, IID_IObjectArray, ppv);
+ pDestList.BeginList(cMaxSlots, COM.IID_IObjectArray, ppv);
if (hr != OS.S_OK) error (SWT.ERROR_INVALID_ARGUMENT);
- long /*int*/ pRemovedItems = ppv [0];
+ IObjectArray pRemovedItems = new IObjectArray (ppv [0]);
int [] count = new int [1];
- /*IObjectArray::GetCount*/
- OS.VtblCall (3, poa, count);
+ poa.GetCount (count);
if (count [0] != 0) {
- /*ICustomDestinationList::AddUserTasks*/
- hr = OS.VtblCall (7, pDestList, poa);
+ hr = pDestList.AddUserTasks (poa);
if (hr != OS.S_OK) error (SWT.ERROR_INVALID_ARGUMENT);
}
- for (int i = 0; i < items.length; i++) {
- MenuItem item = items [i];
+ for (MenuItem item : items) {
if ((item.getStyle () & SWT.CASCADE) != 0) {
Menu subMenu = item.getMenu ();
if (subMenu != null) {
MenuItem [] subItems = subMenu.getItems ();
- if (directory == null) {
- for (int j = 0; j < subItems.length; j++) {
- MenuItem subItem = subItems [j];
- if (subItem.getImage () != null && subItem.getData (ICON_KEY) == null) {
- directory = getDirectory (buffer);
- break;
- }
- }
- }
- long /*int*/ poa2 = createShellLinkArray (subItems, directory);
- if (poa2 != 0) {
- /*IObjectArray::GetCount*/
- OS.VtblCall (3, poa2, count);
+ IObjectArray poa2 = createShellLinkArray (subItems);
+ if (poa2 != null) {
+ poa2.GetCount (count);
if (count [0] != 0) {
String text = item.getText ();
int length = text.length ();
char [] buffer2 = new char [length + 1];
text.getChars (0, length, buffer2, 0);
- /*ICustomDestinationList::AppendCategory*/
- hr = OS.VtblCall (5, pDestList, buffer2, poa2);
+ hr = pDestList.AppendCategory (buffer2, poa2);
if (hr != OS.S_OK) error (SWT.ERROR_INVALID_ARGUMENT);
}
- /*IUnknown::Release*/
- OS.VtblCall (2, poa2);
+ poa2.Release ();
}
}
}
}
-
- /*ICustomDestinationList::CommitList*/
- hr = OS.VtblCall (8, pDestList);
+ poa.Release();
+ hr = pDestList.CommitList ();
if (hr != OS.S_OK) error (SWT.ERROR_INVALID_ARGUMENT);
-
- /*IUnknown::Release*/
- if (pRemovedItems != 0) OS.VtblCall (2, pRemovedItems);
- /*IUnknown::Release*/
- OS.VtblCall (2, poa);
+ pRemovedItems.Release ();
}
} else {
- /*ICustomDestinationList::DeleteList*/
- hr = OS.VtblCall (10, pDestList, buffer);
+ hr = pDestList.DeleteList (buffer);
if (hr != OS.S_OK) error (SWT.ERROR_INVALID_ARGUMENT);
}
- /*IUnknown::Release*/
- OS.VtblCall (2, pDestList);
+ pDestList.Release ();
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskItem.java
index 575c6fdd02..e1c26b5a82 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TaskItem.java
@@ -15,9 +15,9 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.win32.*;
/**
* Instances of this class represent a task item.
@@ -293,10 +293,7 @@ public void setOverlayImage (Image overlayImage) {
if (overlayText.length () != 0) {
updateText ();
} else {
- long /*int*/ mTaskbarList3 = parent.mTaskbarList3;
- long /*int*/ hwnd = shell.handle;
- /* ITaskbarList3::SetOverlayIcon */
- OS.VtblCall (18, mTaskbarList3, hwnd, 0, 0);
+ parent.mTaskbarList3.SetOverlayIcon(shell.handle, 0, 0);
}
}
}
@@ -338,10 +335,7 @@ public void setOverlayText (String overlayText) {
if (overlayImage != null) {
updateImage ();
} else {
- long /*int*/ mTaskbarList3 = parent.mTaskbarList3;
- long /*int*/ hwnd = shell.handle;
- /* ITaskbarList3::SetOverlayIcon */
- OS.VtblCall (18, mTaskbarList3, hwnd, 0, 0);
+ parent.mTaskbarList3.SetOverlayIcon(shell.handle, 0, 0);
}
}
}
@@ -437,7 +431,7 @@ void setShell (Shell shell) {
void updateImage () {
showingText = false;
Image image2 = null;
- long /*int*/ hIcon = 0;
+ long hIcon = 0;
switch (overlayImage.type) {
case SWT.BITMAP:
image2 = Display.createIcon (overlayImage);
@@ -447,20 +441,14 @@ void updateImage () {
hIcon = overlayImage.handle;
break;
}
- long /*int*/ mTaskbarList3 = parent.mTaskbarList3;
- long /*int*/ hwnd = shell.handle;
- /* ITaskbarList3::SetOverlayIcon */
- OS.VtblCall (18, mTaskbarList3, hwnd, hIcon, 0);
+ parent.mTaskbarList3.SetOverlayIcon(shell.handle, hIcon, 0);
if (image2 != null) image2.dispose ();
}
void updateProgress () {
if (progressState == SWT.INDETERMINATE) return;
if (progressState == SWT.DEFAULT) return;
- long /*int*/ mTaskbarList3 = parent.mTaskbarList3;
- long /*int*/ hwnd = shell.handle;
- /* ITaskbarList3::SetProgressValue */
- OS.VtblCall (9, mTaskbarList3, hwnd, (long)progress, (long)PROGRESS_MAX);
+ parent.mTaskbarList3.SetProgressValue(shell.handle, progress, PROGRESS_MAX);
}
void updateProgressState () {
@@ -471,19 +459,15 @@ void updateProgressState () {
case SWT.PAUSED: tbpFlags = OS.TBPF_PAUSED; break;
case SWT.INDETERMINATE: tbpFlags = OS.TBPF_INDETERMINATE; break;
}
- long /*int*/ mTaskbarList3 = parent.mTaskbarList3;
- long /*int*/ hwnd = shell.handle;
- /* ITaskbarList3::SetProgressValue */
- OS.VtblCall (9, mTaskbarList3, hwnd, (long)progress, (long)PROGRESS_MAX);
- /* ITaskbarList3::SetProgressState */
- OS.VtblCall (10, mTaskbarList3, hwnd, tbpFlags);
+ parent.mTaskbarList3.SetProgressValue(shell.handle, progress, PROGRESS_MAX);
+ parent.mTaskbarList3.SetProgressState(shell.handle, tbpFlags);
}
void updateText () {
showingText = true;
/* Create resources */
int width = 16, height = 16;
- long /*int*/ hdc = OS.GetDC (0);
+ long hdc = OS.GetDC (0);
BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER ();
bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
bmiHeader.biWidth = width;
@@ -493,23 +477,23 @@ void updateText () {
bmiHeader.biCompression = OS.BI_RGB;
byte [] bmi = new byte [BITMAPINFOHEADER.sizeof];
OS.MoveMemory (bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
- long /*int*/ [] pBits = new long /*int*/ [1];
- long /*int*/ hBitmap = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
+ long [] pBits = new long [1];
+ long hBitmap = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
if (hBitmap == 0) error (SWT.ERROR_NO_HANDLES);
- long /*int*/ dstHdc = OS.CreateCompatibleDC (hdc);
- long /*int*/ oldBitmap = OS.SelectObject (dstHdc, hBitmap);
- long /*int*/ hMask = OS.CreateBitmap (width, height, 1, 1, null);
+ long dstHdc = OS.CreateCompatibleDC (hdc);
+ long oldBitmap = OS.SelectObject (dstHdc, hBitmap);
+ long hMask = OS.CreateBitmap (width, height, 1, 1, null);
if (hMask == 0) error (SWT.ERROR_NO_HANDLES);
- long /*int*/ maskHdc = OS.CreateCompatibleDC (hdc);
- long /*int*/ oldMask = OS.SelectObject (maskHdc, hMask);
+ long maskHdc = OS.CreateCompatibleDC (hdc);
+ long oldMask = OS.SelectObject (maskHdc, hMask);
/* Draw content */
OS.PatBlt (maskHdc, 0, 0, width, height, OS.WHITENESS);
- long /*int*/ oldBrush = OS.SelectObject (maskHdc, OS.GetStockObject (OS.BLACK_BRUSH));
+ long oldBrush = OS.SelectObject (maskHdc, OS.GetStockObject (OS.BLACK_BRUSH));
OS.RoundRect (maskHdc, 0, 0, width, height, 8, 8);
OS.SelectObject (maskHdc, oldBrush);
- long /*int*/ brush = OS.CreateSolidBrush (OS.GetSysColor (OS.COLOR_HIGHLIGHT));
+ long brush = OS.CreateSolidBrush (OS.GetSysColor (OS.COLOR_HIGHLIGHT));
oldBrush = OS.SelectObject (dstHdc, brush);
OS.RoundRect (dstHdc, 0, 0, width, height, 8, 8);
OS.SelectObject (dstHdc, oldBrush);
@@ -519,7 +503,7 @@ void updateText () {
RECT rect = new RECT ();
char [] buffer = overlayText.toCharArray ();
int length = buffer.length;
- long /*int*/ hFont = 0, oldHFont = 0;
+ long hFont = 0, oldHFont = 0;
NONCLIENTMETRICS info = new NONCLIENTMETRICS ();
info.cbSize = NONCLIENTMETRICS.sizeof;
if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) {
@@ -558,15 +542,12 @@ void updateText () {
iconInfo.fIcon = true;
iconInfo.hbmColor = hBitmap;
iconInfo.hbmMask = hMask;
- long /*int*/ hIcon = OS.CreateIconIndirect (iconInfo);
+ long hIcon = OS.CreateIconIndirect (iconInfo);
if (hIcon == 0) error (SWT.ERROR_NO_HANDLES);
OS.DeleteObject (hBitmap);
OS.DeleteObject (hMask);
- long /*int*/ mTaskbarList3 = parent.mTaskbarList3;
- long /*int*/ hwnd = shell.handle;
- /* ITaskbarList3::SetOverlayIcon */
- OS.VtblCall (18, mTaskbarList3, hwnd, hIcon, 0);
+ parent.mTaskbarList3.SetOverlayIcon(shell.handle, hIcon, 0);
OS.DestroyIcon (hIcon);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
index 020f5bf972..0fc6ce5b26 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
@@ -68,10 +68,15 @@ public class Text extends Scrollable {
String message;
int[] segments;
int clearSegmentsCount = 0;
+ long hwndActiveIcon;
static final char LTR_MARK = '\u200e';
static final char RTL_MARK = '\u200f';
+ /* Custom icons defined in swt.rc */
+ static final int IDI_SEARCH = 101;
+ static final int IDI_CANCEL = 102;
+
/**
* The maximum number of characters that can be entered
* into a text widget.
@@ -90,11 +95,6 @@ public class Text extends Scrollable {
public static final String DELIMITER;
/*
- * This code is intentionally commented.
- */
-// static final char PASSWORD;
-
- /*
* These values can be different on different platforms.
* Therefore they are not initialized in the declaration
* to stop the compiler from inlining.
@@ -104,27 +104,12 @@ public class Text extends Scrollable {
DELIMITER = "\r\n";
}
- static final long /*int*/ EditProc;
+ static final long EditProc;
static final TCHAR EditClass = new TCHAR (0, "EDIT", true);
static {
WNDCLASS lpWndClass = new WNDCLASS ();
OS.GetClassInfo (0, EditClass, lpWndClass);
EditProc = lpWndClass.lpfnWndProc;
- /*
- * This code is intentionally commented.
- */
-// long /*int*/ hwndText = OS.CreateWindowEx (0,
-// EditClass,
-// null,
-// OS.WS_OVERLAPPED | OS.ES_PASSWORD,
-// 0, 0, 0, 0,
-// 0,
-// 0,
-// OS.GetModuleHandle (null),
-// null);
-// char echo = (char) OS.SendMessage (hwndText, OS.EM_GETPASSWORDCHAR, 0, 0);
-// OS.DestroyWindow (hwndText);
-// PASSWORD = echo != 0 ? echo : '*';
}
/**
@@ -170,7 +155,7 @@ public Text (Composite parent, int style) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
boolean redraw = false;
switch (msg) {
@@ -191,13 +176,13 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
drawMessage = hwnd != OS.GetFocus () && OS.GetWindowTextLength (handle) == 0;
}
if (doubleBuffer || drawMessage) {
- long /*int*/ paintDC = 0;
+ long paintDC = 0;
PAINTSTRUCT ps = new PAINTSTRUCT ();
paintDC = OS.BeginPaint (handle, ps);
int width = ps.right - ps.left;
int height = ps.bottom - ps.top;
if (width != 0 && height != 0) {
- long /*int*/ hDC = paintDC, hBitmap = 0, hOldBitmap = 0;
+ long hDC = paintDC, hBitmap = 0, hOldBitmap = 0;
POINT lpPoint1 = null, lpPoint2 = null;
if (doubleBuffer) {
hDC = OS.CreateCompatibleDC (paintDC);
@@ -220,7 +205,7 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
if (drawMessage) {
RECT rect = new RECT();
OS.GetClientRect(handle, rect);
- long /*int*/ margins = OS.SendMessage (handle, OS.EM_GETMARGINS, 0, 0);
+ long margins = OS.SendMessage (handle, OS.EM_GETMARGINS, 0, 0);
rect.left += OS.LOWORD (margins);
rect.right -= OS.HIWORD (margins);
if ((style & SWT.BORDER) != 0) {
@@ -239,8 +224,8 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
case SWT.CENTER: uFormat |= OS.DT_CENTER;
case SWT.RIGHT: uFormat |= (rtl ? OS.DT_LEFT : OS.DT_RIGHT); break;
}
- long /*int*/ hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
- long /*int*/ hOldFont = OS.SelectObject (hDC, hFont);
+ long hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
+ long hOldFont = OS.SelectObject (hDC, hFont);
OS.SetTextColor (hDC, OS.GetSysColor (OS.COLOR_GRAYTEXT));
OS.SetBkMode (hDC, OS.TRANSPARENT);
OS.DrawText (hDC, buffer, buffer.length, rect, uFormat);
@@ -262,7 +247,50 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
break;
}
}
- long /*int*/ code = OS.CallWindowProc (EditProc, hwnd, msg, wParam, lParam);
+ if ((style & SWT.SEARCH) != 0) {
+ switch (msg) {
+ case OS.WM_MOUSEMOVE: {
+ POINT pt = new POINT ();
+ OS.POINTSTOPOINT(pt, lParam);
+ long hwndIcon = OS.ChildWindowFromPointEx (handle, pt, OS.CWP_SKIPINVISIBLE);
+ if (hwndIcon == handle) hwndIcon = 0;
+ if (hwndIcon != hwndActiveIcon) {
+ if (hwndActiveIcon != 0) OS.InvalidateRect (hwndActiveIcon, null, false);
+ if (hwndIcon != 0) OS.InvalidateRect (hwndIcon, null, false);
+ hwndActiveIcon = hwndIcon;
+ }
+ break;
+ }
+ case OS.WM_MOUSELEAVE:
+ if (hwndActiveIcon != 0) {
+ OS.InvalidateRect (hwndActiveIcon, null, false);
+ hwndActiveIcon = 0;
+ }
+ break;
+ case OS.WM_LBUTTONDOWN:
+ if (hwndActiveIcon != 0) {
+ OS.InvalidateRect (hwndActiveIcon, null, false);
+ return 0; // prevent mouse selection
+ }
+ break;
+ case OS.WM_LBUTTONUP: {
+ if (hwndActiveIcon != 0) {
+ Event e = new Event();
+ if (hwndActiveIcon == OS.GetDlgItem (handle, SWT.ICON_SEARCH)) {
+ e.detail = SWT.ICON_SEARCH;
+ } else {
+ e.detail = SWT.ICON_CANCEL;
+ setText ("");
+ }
+ setFocus ();
+ selectAll ();
+ sendSelectionEvent (SWT.DefaultSelection, e, false);
+ }
+ break;
+ }
+ }
+ }
+ long code = OS.CallWindowProc (EditProc, hwnd, msg, wParam, lParam);
switch (msg) {
case OS.WM_HSCROLL:
case OS.WM_VSCROLL: {
@@ -278,13 +306,71 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
@Override
void createHandle () {
- super.createHandle ();
+ long editStyle = widgetStyle ();
+ if ((editStyle & OS.WS_BORDER) == 0)
+ super.createHandle ();
+ else {
+ /*
+ * Feature on Windows: when `Edit` control is created, it removes
+ * `WS_BORDER`, but then internally draws the border over the client
+ * area. This is undesirable because all SWT coordinates will then
+ * need to be adjusted by the border size. The workaround is to create
+ * control without `WS_BORDER` and add it just after creating.
+ */
+ style &= ~SWT.BORDER;
+ super.createHandle ();
+ style |= SWT.BORDER;
+
+ editStyle = OS.GetWindowLongPtr(handle, OS.GWL_STYLE);
+ editStyle |= OS.WS_BORDER;
+ OS.SetWindowLongPtr(handle, OS.GWL_STYLE, editStyle);
+
+ OS.SetWindowPos(handle, 0, 0, 0, 0, 0, OS.SWP_NOMOVE | OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_FRAMECHANGED);
+ }
+
OS.SendMessage (handle, OS.EM_LIMITTEXT, 0, 0);
if ((style & SWT.READ_ONLY) != 0) {
if (applyThemeBackground () == 1) {
state |= THEME_BACKGROUND;
}
}
+ if ((style & SWT.SEARCH) != 0) {
+ if (display.hIconSearch == 0) {
+ long [] phicon = new long [1];
+ int hresult = OS.LoadIconMetric (OS.GetLibraryHandle (), IDI_SEARCH, OS.LIM_SMALL, phicon);
+ if (hresult != OS.S_OK) error (SWT.ERROR_NO_HANDLES);
+ display.hIconSearch = phicon [0];
+ hresult = OS.LoadIconMetric (OS.GetLibraryHandle (), IDI_CANCEL, OS.LIM_SMALL, phicon);
+ if (hresult != OS.S_OK) error (SWT.ERROR_NO_HANDLES);
+ display.hIconCancel = phicon [0];
+ }
+ if ((style & SWT.ICON_SEARCH) != 0) {
+ long hwndSearch = OS.CreateWindowEx (
+ 0,
+ Label.LabelClass,
+ null,
+ OS.WS_CHILD | OS.WS_VISIBLE | OS.WS_CLIPSIBLINGS | OS.SS_OWNERDRAW,
+ 0, 0, 0, 0,
+ handle,
+ SWT.ICON_SEARCH,
+ OS.GetModuleHandle (null),
+ null);
+ if (hwndSearch == 0) error (SWT.ERROR_NO_HANDLES);
+ }
+ if ((style & SWT.ICON_CANCEL) != 0) {
+ state |= TRACK_MOUSE;
+ long hwndCancel = OS.CreateWindowEx (
+ 0,
+ Label.LabelClass, null,
+ OS.WS_CHILD | OS.WS_CLIPSIBLINGS | OS.SS_OWNERDRAW,
+ 0, 0, 0, 0,
+ handle,
+ SWT.ICON_CANCEL,
+ OS.GetModuleHandle (null),
+ null);
+ if (hwndCancel == 0) error (SWT.ERROR_NO_HANDLES);
+ }
+ }
}
@Override
@@ -515,7 +601,7 @@ void applySegments () {
segmentsChars = segmentsCharsCrLf;
}
- int/*64*/ limit = (int/*64*/)OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) & 0x7fffffff;
+ int limit = (int)OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) & 0x7fffffff;
OS.SendMessage (handle, OS.EM_SETLIMITTEXT, limit + Math.min (nSegments, LIMIT - limit), 0);
length += nSegments;
char [] newChars = new char [length + 1];
@@ -547,7 +633,7 @@ void applySegments () {
*/
newChars [length] = 0;
OS.SendMessage (handle, OS.EM_SETSEL, 0, -1);
- long /*int*/ undo = OS.SendMessage (handle, OS.EM_CANUNDO, 0, 0);
+ long undo = OS.SendMessage (handle, OS.EM_CANUNDO, 0, 0);
OS.SendMessage (handle, OS.EM_REPLACESEL, undo, newChars);
/* Restore selection */
start [0] = translateOffset (start [0]);
@@ -559,20 +645,20 @@ void applySegments () {
}
static int checkStyle (int style) {
- if ((style & SWT.SEARCH) != 0) {
- style |= SWT.SINGLE | SWT.BORDER;
- style &= ~SWT.PASSWORD;
- /*
- * NOTE: ICON_CANCEL has the same value as H_SCROLL and
- * ICON_SEARCH has the same value as V_SCROLL so they are
- * cleared because SWT.SINGLE is set.
- */
- }
if ((style & SWT.SINGLE) != 0 && (style & SWT.MULTI) != 0) {
style &= ~SWT.MULTI;
}
style = checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
- if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP);
+ /*
+ * NOTE: ICON_CANCEL and ICON_SEARCH have the same value as H_SCROLL and
+ * V_SCROLL. The meaning is determined by whether SWT.SEARCH is set.
+ */
+ if ((style & SWT.SEARCH) != 0) {
+ style |= SWT.SINGLE | SWT.BORDER;
+ style &= ~(SWT.PASSWORD | SWT.WRAP);
+ } else if ((style & SWT.SINGLE) != 0) {
+ style &= ~(SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP);
+ }
if ((style & SWT.WRAP) != 0) {
style |= SWT.MULTI;
style &= ~SWT.H_SCROLL;
@@ -588,7 +674,7 @@ void clearSegments (boolean applyText) {
if (segments == null) return;
int nSegments = segments.length;
if (nSegments == 0) return;
- int/*64*/ limit = (int/*64*/)OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) & 0x7fffffff;
+ int limit = (int)OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) & 0x7fffffff;
if (limit < LIMIT) {
OS.SendMessage (handle, OS.EM_SETLIMITTEXT, Math.max (1, limit - nSegments), 0);
}
@@ -614,7 +700,7 @@ void clearSegments (boolean applyText) {
* menu. Sending OS.EM_REPLACESEL message instead.
*/
OS.SendMessage (handle, OS.EM_SETSEL, 0, -1);
- long /*int*/ undo = OS.SendMessage (handle, OS.EM_CANUNDO, 0, 0);
+ long undo = OS.SendMessage (handle, OS.EM_CANUNDO, 0, 0);
OS.SendMessage (handle, OS.EM_REPLACESEL, undo, buffer);
OS.SendMessage (handle, OS.EM_SETSEL, start [0], end [0]);
ignoreCharacter = oldIgnoreCharacter;
@@ -639,13 +725,13 @@ public void clearSelection () {
checkWidget ();
int height = 0, width = 0;
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
- long /*int*/ newFont, oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
+ long newFont, oldFont = 0;
+ long hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
TEXTMETRIC tm = new TEXTMETRIC ();
OS.GetTextMetrics (hDC, tm);
- int count = (style & SWT.SINGLE) != 0 ? 1 : (int)/*64*/OS.SendMessage (handle, OS.EM_GETLINECOUNT, 0, 0);
+ int count = (style & SWT.SINGLE) != 0 ? 1 : (int)OS.SendMessage (handle, OS.EM_GETLINECOUNT, 0, 0);
height = count * tm.tmHeight;
RECT rect = new RECT ();
int flags = OS.DT_CALCRECT | OS.DT_EDITCONTROL | OS.DT_NOPREFIX;
@@ -692,7 +778,7 @@ public void clearSelection () {
* the single-line text widget in an editable combo
* box.
*/
- long /*int*/ margins = OS.SendMessage(handle, OS.EM_GETMARGINS, 0, 0);
+ long margins = OS.SendMessage(handle, OS.EM_GETMARGINS, 0, 0);
rect.x -= OS.LOWORD (margins);
rect.width += OS.LOWORD (margins) + OS.HIWORD (margins);
if ((style & SWT.H_SCROLL) != 0) rect.width++;
@@ -701,7 +787,18 @@ public void clearSelection () {
rect.y -= 1;
rect.width += 2;
rect.height += 2;
+
+ // When WS_BORDER is used instead of WS_EX_CLIENTEDGE, compensate the size difference
+ if (isUseWsBorder ()) {
+ int dx = OS.GetSystemMetrics (OS.SM_CXEDGE) - OS.GetSystemMetrics (OS.SM_CXBORDER);
+ int dy = OS.GetSystemMetrics (OS.SM_CYEDGE) - OS.GetSystemMetrics (OS.SM_CYBORDER);
+ rect.x -= dx;
+ rect.y -= dy;
+ rect.width += 2*dx;
+ rect.height += 2*dy;
+ }
}
+
return rect;
}
@@ -722,6 +819,11 @@ public void copy () {
}
@Override
+ScrollBar createScrollBar (int type) {
+ return (style & SWT.SEARCH) == 0 ? super.createScrollBar(type) : null;
+}
+
+@Override
void createWidget () {
super.createWidget ();
message = "";
@@ -751,7 +853,10 @@ public void cut () {
@Override
int defaultBackground () {
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- return OS.GetSysColor ((bits & OS.ES_READONLY) != 0 ? OS.COLOR_3DFACE : OS.COLOR_WINDOW);
+ if ((bits & OS.ES_READONLY) != 0 || !OS.IsWindowEnabled (handle)) {
+ return OS.GetSysColor (OS.COLOR_3DFACE);
+ }
+ return OS.GetSysColor (OS.COLOR_WINDOW);
}
TCHAR deprocessText (TCHAR text, int start, int end, boolean terminate) {
@@ -787,12 +892,12 @@ TCHAR deprocessText (TCHAR text, int start, int end, boolean terminate) {
}
@Override
-boolean dragDetect (long /*int*/ hwnd, int x, int y, boolean filter, boolean [] detect, boolean [] consume) {
+boolean dragDetect (long hwnd, int x, int y, boolean filter, boolean [] detect, boolean [] consume) {
if (filter) {
int [] start = new int [1], end = new int [1];
OS.SendMessage (handle, OS.EM_GETSEL, start, end);
if (start [0] != end [0]) {
- long /*int*/ lParam = OS.MAKELPARAM (x, y);
+ long lParam = OS.MAKELPARAM (x, y);
int position = OS.LOWORD (OS.SendMessage (handle, OS.EM_CHARFROMPOS, 0, lParam));
if (start [0] <= position && position < end [0]) {
if (super.dragDetect (hwnd, x, y, filter, detect, consume)) {
@@ -806,6 +911,18 @@ boolean dragDetect (long /*int*/ hwnd, int x, int y, boolean filter, boolean []
return super.dragDetect (hwnd, x, y, filter, detect, consume);
}
+@Override
+void maybeEnableDarkSystemTheme() {
+ /*
+ * Feature in Windows. If the control has default foreground and
+ * background, the background gets black without focus and white with
+ * focus, but the foreground color always stays black.
+ */
+ if (hasCustomBackground() || hasCustomForeground()) {
+ super.maybeEnableDarkSystemTheme();
+ }
+}
+
void fixAlignment () {
/*
* Feature in Windows. When the edit control is not
@@ -880,7 +997,7 @@ void fixAlignment () {
*/
public int getCaretLineNumber () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.EM_LINEFROMCHAR, -1, 0);
+ return (int)OS.SendMessage (handle, OS.EM_LINEFROMCHAR, -1, 0);
}
/**
@@ -912,7 +1029,7 @@ Point getCaretLocationInPixels () {
* pixel coordinates (0,0).
*/
int position = translateOffset (getCaretPosition ());
- long /*int*/ caretPos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, position, 0);
+ long caretPos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, position, 0);
if (caretPos == -1) {
caretPos = 0;
if (position >= OS.GetWindowTextLength (handle)) {
@@ -972,8 +1089,8 @@ public int getCaretPosition () {
*/
int caret = start [0];
if (start [0] != end [0]) {
- int startLine = (int)/*64*/OS.SendMessage (handle, OS.EM_LINEFROMCHAR, start [0], 0);
- int endLine = (int)/*64*/OS.SendMessage (handle, OS.EM_LINEFROMCHAR, end [0], 0);
+ int startLine = (int)OS.SendMessage (handle, OS.EM_LINEFROMCHAR, start [0], 0);
+ int endLine = (int)OS.SendMessage (handle, OS.EM_LINEFROMCHAR, end [0], 0);
if (startLine == endLine) {
int idThread = OS.GetWindowThreadProcessId (handle, null);
GUITHREADINFO lpgui = new GUITHREADINFO ();
@@ -982,9 +1099,9 @@ public int getCaretPosition () {
if (lpgui.hwndCaret == handle || lpgui.hwndCaret == 0) {
POINT ptCurrentPos = new POINT ();
if (OS.GetCaretPos (ptCurrentPos)) {
- long /*int*/ endPos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, end [0], 0);
+ long endPos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, end [0], 0);
if (endPos == -1) {
- long /*int*/ startPos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, start [0], 0);
+ long startPos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, start [0], 0);
int startX = OS.GET_X_LPARAM (startPos);
if (ptCurrentPos.x > startX) caret = end [0];
} else {
@@ -995,8 +1112,8 @@ public int getCaretPosition () {
}
}
} else {
- int caretPos = (int)/*64*/OS.SendMessage (handle, OS.EM_LINEINDEX, -1, 0);
- int caretLine = (int)/*64*/OS.SendMessage (handle, OS.EM_LINEFROMCHAR, caretPos, 0);
+ int caretPos = (int)OS.SendMessage (handle, OS.EM_LINEINDEX, -1, 0);
+ int caretLine = (int)OS.SendMessage (handle, OS.EM_LINEFROMCHAR, caretPos, 0);
if (caretLine == endLine) caret = end [0];
}
}
@@ -1089,7 +1206,7 @@ public boolean getEditable () {
*/
public int getLineCount () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.EM_GETLINECOUNT, 0, 0);
+ return (int)OS.SendMessage (handle, OS.EM_GETLINECOUNT, 0, 0);
}
/**
@@ -1125,8 +1242,8 @@ public int getLineHeight () {
}
int getLineHeightInPixels () {
- long /*int*/ newFont, oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
+ long newFont, oldFont = 0;
+ long hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
TEXTMETRIC tm = new TEXTMETRIC ();
@@ -1196,7 +1313,7 @@ public String getMessage () {
/*public*/ int getPosition (Point point) {
checkWidget();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- long /*int*/ lParam = OS.MAKELPARAM (point.x, point.y);
+ long lParam = OS.MAKELPARAM (point.x, point.y);
int position = OS.LOWORD (OS.SendMessage (handle, OS.EM_CHARFROMPOS, 0, lParam));
return untranslateOffset (position);
}
@@ -1289,10 +1406,10 @@ public int getTabs () {
}
int getTabWidth (int tabs) {
- long /*int*/ oldFont = 0;
+ long oldFont = 0;
RECT rect = new RECT ();
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ long hDC = OS.GetDC (handle);
+ long newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
OS.DrawText (hDC, new char [] {' '}, 1, rect, flags);
@@ -1417,7 +1534,7 @@ public String getText (int start, int end) {
*/
public int getTextLimit () {
checkWidget ();
- int/*64*/ limit = (int)/*64*/OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF;
+ int limit = (int)OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF;
if (segments != null && limit < LIMIT) limit = Math.max (1, limit - segments.length);
return limit;
}
@@ -1439,7 +1556,7 @@ public int getTextLimit () {
public int getTopIndex () {
checkWidget ();
if ((style & SWT.SINGLE) != 0) return 0;
- return (int)/*64*/OS.SendMessage (handle, OS.EM_GETFIRSTVISIBLELINE, 0, 0);
+ return (int)OS.SendMessage (handle, OS.EM_GETFIRSTVISIBLELINE, 0, 0);
}
/**
@@ -1474,7 +1591,7 @@ int getTopPixelInPixels () {
* of Rich Edit return zero.
*/
int [] buffer = new int [2];
- long /*int*/ code = OS.SendMessage (handle, OS.EM_GETSCROLLPOS, 0, buffer);
+ long code = OS.SendMessage (handle, OS.EM_GETSCROLLPOS, 0, buffer);
if (code == 1) return buffer [1];
return getTopIndex () * getLineHeightInPixels ();
}
@@ -1527,6 +1644,11 @@ public void insert (String string) {
applySegments ();
}
+@Override
+boolean isUseWsBorder () {
+ return super.isUseWsBorder () || ((display != null) && display.useWsBorderText);
+}
+
/**
* Pastes text from clipboard.
* <p>
@@ -1689,7 +1811,7 @@ public void selectAll () {
}
@Override
-boolean sendKeyEvent (int type, int msg, long /*int*/ wParam, long /*int*/ lParam, Event event) {
+boolean sendKeyEvent (int type, int msg, long wParam, long lParam, Event event) {
if (!super.sendKeyEvent (type, msg, wParam, lParam, event)) {
return false;
}
@@ -1736,7 +1858,7 @@ boolean sendKeyEvent (int type, int msg, long /*int*/ wParam, long /*int*/ lPara
case 0x08: /* Bs */
if (start [0] == end [0]) {
if (start [0] == 0) return true;
- int lineStart = (int)/*64*/OS.SendMessage (handle, OS.EM_LINEINDEX, -1, 0);
+ int lineStart = (int)OS.SendMessage (handle, OS.EM_LINEINDEX, -1, 0);
if (start [0] == lineStart) {
start [0] = start [0] - DELIMITER.length ();
} else {
@@ -1749,8 +1871,8 @@ boolean sendKeyEvent (int type, int msg, long /*int*/ wParam, long /*int*/ lPara
if (start [0] == end [0]) {
int length = OS.GetWindowTextLength (handle);
if (start [0] == length) return true;
- int line = (int)/*64*/OS.SendMessage (handle, OS.EM_LINEFROMCHAR, end [0], 0);
- int lineStart = (int)/*64*/OS.SendMessage (handle, OS.EM_LINEINDEX, line + 1, 0);
+ int line = (int)OS.SendMessage (handle, OS.EM_LINEFROMCHAR, end [0], 0);
+ int lineStart = (int)OS.SendMessage (handle, OS.EM_LINEINDEX, line + 1, 0);
if (end [0] == lineStart - DELIMITER.length ()) {
end [0] = end [0] + DELIMITER.length ();
} else {
@@ -1792,6 +1914,19 @@ boolean sendKeyEvent (int type, int msg, long /*int*/ wParam, long /*int*/ lPara
}
@Override
+void setBackgroundImage (long hBitmap) {
+ int flags = OS.RDW_ERASE | OS.RDW_ALLCHILDREN | OS.RDW_INVALIDATE;
+ OS.RedrawWindow (handle, null, 0, flags);
+}
+
+@Override
+void setBackgroundPixel (int pixel) {
+ maybeEnableDarkSystemTheme();
+ int flags = OS.RDW_ERASE | OS.RDW_ALLCHILDREN | OS.RDW_INVALIDATE;
+ OS.RedrawWindow (handle, null, 0, flags);
+}
+
+@Override
void setBoundsInPixels (int x, int y, int width, int height, int flags) {
/*
* Feature in Windows. When the caret is moved,
@@ -1811,7 +1946,7 @@ void setBoundsInPixels (int x, int y, int width, int height, int flags) {
if ((flags & OS.SWP_NOSIZE) == 0 && width != 0) {
RECT rect = new RECT ();
OS.GetWindowRect (handle, rect);
- long /*int*/ margins = OS.SendMessage (handle, OS.EM_GETMARGINS, 0, 0);
+ long margins = OS.SendMessage (handle, OS.EM_GETMARGINS, 0, 0);
int marginWidth = OS.LOWORD (margins) + OS.HIWORD (margins);
if (rect.right - rect.left <= marginWidth) {
int [] start = new int [1], end = new int [1];
@@ -1835,8 +1970,8 @@ void setBoundsInPixels (int x, int y, int width, int height, int flags) {
if ((flags & OS.SWP_NOSIZE) == 0) {
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
if ((bits & OS.ES_MULTILINE) != 0) {
- long /*int*/ newFont, oldFont = 0;
- long /*int*/ hDC = OS.GetDC (handle);
+ long newFont, oldFont = 0;
+ long hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
TEXTMETRIC tm = new TEXTMETRIC ();
@@ -1846,7 +1981,7 @@ void setBoundsInPixels (int x, int y, int width, int height, int flags) {
RECT rect = new RECT();
OS.GetClientRect (handle, rect);
if ((rect.bottom - rect.top) < tm.tmHeight) {
- long /*int*/ margins = OS.SendMessage (handle, OS.EM_GETMARGINS, 0, 0);
+ long margins = OS.SendMessage (handle, OS.EM_GETMARGINS, 0, 0);
rect.left += OS.LOWORD (margins);
rect.right -= OS.HIWORD (margins);
rect.top = 0;
@@ -1946,15 +2081,24 @@ public void setFont (Font font) {
setMargins ();
}
+@Override
+void setForegroundPixel (int pixel) {
+ maybeEnableDarkSystemTheme();
+ super.setForegroundPixel(pixel);
+}
+
void setMargins () {
- /*
- * Bug in Windows. When EM_SETCUEBANNER is used to set the
- * banner text, the control does not take into account the
- * margins, causing the first character to be clipped. The
- * fix is to set the margins to zero.
- */
if ((style & SWT.SEARCH) != 0) {
- OS.SendMessage (handle, OS.EM_SETMARGINS, OS.EC_LEFTMARGIN | OS.EC_RIGHTMARGIN, 0);
+ boolean rtl = (style & SWT.RIGHT_TO_LEFT) != 0;
+ int fLeading = rtl ? OS.EC_RIGHTMARGIN : OS.EC_LEFTMARGIN;
+ int fTrailing = rtl ? OS.EC_LEFTMARGIN : OS.EC_RIGHTMARGIN;
+ int flags = 0;
+ if ((style & SWT.ICON_SEARCH) != 0) flags |= fLeading;
+ if ((style & SWT.ICON_CANCEL) != 0) flags |= fTrailing;
+ if (flags != 0) {
+ int iconWidth = OS.GetSystemMetrics (OS.SM_CXSMICON);
+ OS.SendMessage (handle, OS.EM_SETMARGINS, flags, OS.MAKELPARAM(iconWidth, iconWidth));
+ }
}
}
@@ -2192,7 +2336,7 @@ public void setText (String string) {
if (string == null) return;
}
clearSegments (false);
- int limit = (int)/*64*/OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF;
+ int limit = (int)OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF;
if (string.length () > limit) string = string.substring (0, limit);
TCHAR buffer = new TCHAR (getCodePage (), string, true);
OS.SetWindowText (handle, buffer);
@@ -2252,10 +2396,10 @@ public void setTextChars (char[] text) {
string.getChars (0, text.length, text, 0);
}
clearSegments (false);
- int limit = (int)/*64*/OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF;
+ int limit = (int)OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF;
if (text.length > limit) {
char [] temp = new char [limit];
- for (int i = 0; i < limit; i++) temp [i] = text [i];
+ System.arraycopy(text, 0, temp, 0, limit);
text = temp;
}
TCHAR buffer = new TCHAR (getCodePage (), text, true);
@@ -2328,9 +2472,9 @@ public void setTextLimit (int limit) {
public void setTopIndex (int index) {
checkWidget ();
if ((style & SWT.SINGLE) != 0) return;
- int count = (int)/*64*/OS.SendMessage (handle, OS.EM_GETLINECOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.EM_GETLINECOUNT, 0, 0);
index = Math.min (Math.max (index, 0), count - 1);
- int topIndex = (int)/*64*/OS.SendMessage (handle, OS.EM_GETFIRSTVISIBLELINE, 0, 0);
+ int topIndex = (int)OS.SendMessage (handle, OS.EM_GETFIRSTVISIBLELINE, 0, 0);
OS.SendMessage (handle, OS.EM_LINESCROLL, 0, index - topIndex);
}
@@ -2424,10 +2568,19 @@ String verifyText (String string, int start, int end, Event keyEvent) {
@Override
int widgetStyle () {
int bits = super.widgetStyle () | OS.ES_AUTOHSCROLL;
+ /*
+ * NOTE: ICON_CANCEL and ICON_SEARCH have the same value as H_SCROLL and
+ * V_SCROLL. The meaning is determined by whether SWT.SEARCH is set.
+ */
+ if ((style & SWT.SEARCH) != 0) {
+ bits &= ~OS.WS_HSCROLL;
+ bits &= ~OS.WS_VSCROLL;
+ }
if ((style & SWT.PASSWORD) != 0) bits |= OS.ES_PASSWORD;
if ((style & SWT.CENTER) != 0) bits |= OS.ES_CENTER;
if ((style & SWT.RIGHT) != 0) bits |= OS.ES_RIGHT;
if ((style & SWT.READ_ONLY) != 0) bits |= OS.ES_READONLY;
+ if ((style & SWT.SEARCH) != 0) bits |= OS.WS_CLIPCHILDREN;
if ((style & SWT.SINGLE) != 0) {
/*
* Feature in Windows. When a text control is read-only,
@@ -2460,14 +2613,14 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return EditProc;
}
@Override
-long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long windowProc (long hwnd, int msg, long wParam, long lParam) {
boolean processSegments = hooks (SWT.Segments) || filters (SWT.Segments), redraw = false, updateDirection = (state & HAS_AUTO_DIRECTION) != 0;
- long /*int*/ code;
+ long code;
if (processSegments || updateDirection) {
switch (msg) {
case OS.EM_CANUNDO:
@@ -2541,7 +2694,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
}
@Override
-LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CHAR (long wParam, long lParam) {
if (ignoreCharacter) return null;
LRESULT result = super.WM_CHAR (wParam, lParam);
if (result != null) return result;
@@ -2553,7 +2706,7 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
* is inserted into the control. The fix is to detect
* this case and not call the window proc.
*/
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case SWT.DEL:
if (OS.GetKeyState (OS.VK_CONTROL) < 0) {
if ((style & SWT.READ_ONLY) != 0 || (style & SWT.PASSWORD) != 0) return LRESULT.ZERO;
@@ -2561,8 +2714,8 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
int x = selection.x;
int y = selection.y;
if (x == y) {
- String actText = getText (0, x - 1);
- java.util.regex.Matcher m = CTRL_BS_PATTERN.matcher (actText);
+ String actText = getText (0, x - 1);
+ java.util.regex.Matcher m = CTRL_BS_PATTERN.matcher (actText);
if (m.find ()) {
x = m.start ();
y = m.end ();
@@ -2588,7 +2741,7 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
* the window proc.
*/
if ((style & SWT.SINGLE) != 0) {
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case SWT.CR:
sendSelectionEvent (SWT.DefaultSelection);
// FALL THROUGH
@@ -2600,21 +2753,40 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_CLEAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CLEAR (long wParam, long lParam) {
LRESULT result = super.WM_CLEAR (wParam, lParam);
if (result != null) return result;
return wmClipboard (OS.WM_CLEAR, wParam, lParam);
}
@Override
-LRESULT WM_CUT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CUT (long wParam, long lParam) {
LRESULT result = super.WM_CUT (wParam, lParam);
if (result != null) return result;
return wmClipboard (OS.WM_CUT, wParam, lParam);
}
@Override
-LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_DRAWITEM (long wParam, long lParam) {
+ DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ();
+ OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof);
+ RECT rect = new RECT ();
+ OS.SetRect (rect, struct.left, struct.top, struct.right, struct.bottom);
+ POINT pt = new POINT ();
+ OS.MapWindowPoints (struct.hwndItem, handle, pt, 1);
+ drawBackground (struct.hDC, rect, -1, pt.x, pt.y);
+ if (struct.CtlID == SWT.ICON_CANCEL && struct.hwndItem == hwndActiveIcon && OS.IsAppThemed()) {
+ int state = OS.GetKeyState (OS.VK_LBUTTON) < 0 ? OS.PBS_PRESSED : OS.PBS_HOT;
+ OS.DrawThemeBackground (display.hButtonTheme (), struct.hDC, OS.BP_PUSHBUTTON, state, rect, null);
+ }
+ long hIcon = (struct.CtlID == SWT.ICON_SEARCH) ? display.hIconSearch : display.hIconCancel;
+ int y = (rect.bottom - rect.right) / 2;
+ OS.DrawIconEx (struct.hDC, 0, y, hIcon, 0, 0, 0, 0, OS.DI_NORMAL);
+ return LRESULT.ONE;
+}
+
+@Override
+LRESULT WM_ERASEBKGND (long wParam, long lParam) {
LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
if ((style & SWT.READ_ONLY) != 0) {
if ((style & (SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL)) == 0) {
@@ -2641,7 +2813,7 @@ LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETDLGCODE (long wParam, long lParam) {
LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
if (result != null) return result;
@@ -2655,7 +2827,7 @@ LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
* so DLGC_WANTARROWS should not be cleared.
*/
if ((style & SWT.READ_ONLY) != 0) {
- long /*int*/ code = callWindowProc (handle, OS.WM_GETDLGCODE, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_GETDLGCODE, wParam, lParam);
code &= ~(OS.DLGC_WANTALLKEYS | OS.DLGC_WANTTAB);
return new LRESULT (code);
}
@@ -2663,7 +2835,7 @@ LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_GETOBJECT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETOBJECT (long wParam, long lParam) {
/*
* Ensure that there is an accessible object created for this
* control because support for search text accessibility is
@@ -2676,12 +2848,12 @@ LRESULT WM_GETOBJECT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_IME_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_IME_CHAR (long wParam, long lParam) {
/* Process a DBCS character */
Display display = this.display;
display.lastKey = 0;
- display.lastAscii = (int)/*64*/wParam;
+ display.lastAscii = (int)wParam;
display.lastVirtual = display.lastNull = display.lastDead = false;
if (!sendKeyEvent (SWT.KeyDown, OS.WM_IME_CHAR, wParam, lParam)) {
return LRESULT.ZERO;
@@ -2695,7 +2867,7 @@ LRESULT WM_IME_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
* them to the application.
*/
ignoreCharacter = true;
- long /*int*/ result = callWindowProc (handle, OS.WM_IME_CHAR, wParam, lParam);
+ long result = callWindowProc (handle, OS.WM_IME_CHAR, wParam, lParam);
MSG msg = new MSG ();
int flags = OS.PM_REMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE;
while (OS.PeekMessage (msg, handle, OS.WM_CHAR, OS.WM_CHAR, flags)) {
@@ -2711,15 +2883,15 @@ LRESULT WM_IME_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDBLCLK (long wParam, long lParam) {
/*
* Prevent Windows from processing WM_LBUTTONDBLCLK
* when double clicking behavior is disabled by not
* calling the window proc.
*/
LRESULT result = null;
- sendMouseEvent (SWT.MouseDown, 1, handle, OS.WM_LBUTTONDOWN, wParam, lParam);
- if (!sendMouseEvent (SWT.MouseDoubleClick, 1, handle, OS.WM_LBUTTONDBLCLK, wParam, lParam)) {
+ sendMouseEvent (SWT.MouseDown, 1, handle, lParam);
+ if (!sendMouseEvent (SWT.MouseDoubleClick, 1, handle, lParam)) {
result = LRESULT.ZERO;
}
if (!display.captureChanged && !isDisposed ()) {
@@ -2742,7 +2914,7 @@ LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
if (start [0] == end [0]) {
int length = OS.GetWindowTextLength (handle);
if (length == start [0]) {
- int code = (int)/*64*/OS.SendMessage (handle, OS.EM_LINELENGTH, length, 0);
+ int code = (int)OS.SendMessage (handle, OS.EM_LINELENGTH, length, 0);
if (code == 0) return LRESULT.ZERO;
}
}
@@ -2750,20 +2922,59 @@ LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_PASTE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PASTE (long wParam, long lParam) {
LRESULT result = super.WM_PASTE (wParam, lParam);
if (result != null) return result;
return wmClipboard (OS.WM_PASTE, wParam, lParam);
}
@Override
-LRESULT WM_UNDO (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETCURSOR (long wParam, long lParam) {
+ LRESULT result = super.WM_SETCURSOR(wParam, lParam);
+ if (result != null) return result;
+ if ((style & SWT.SEARCH) != 0) {
+ int hitTest = (short) OS.LOWORD (lParam);
+ if (hitTest == OS.HTCLIENT) {
+ POINT pt = new POINT ();
+ OS.GetCursorPos (pt);
+ OS.ScreenToClient (handle, pt);
+ long hwndIcon = OS.ChildWindowFromPointEx (handle, pt, OS.CWP_SKIPINVISIBLE);
+ if (hwndIcon != handle) {
+ OS.SetCursor (OS.LoadCursor (0, OS.IDC_ARROW));
+ return LRESULT.ONE;
+ }
+ }
+ }
+ return null;
+}
+
+@Override
+LRESULT WM_SIZE(long wParam, long lParam) {
+ LRESULT result = super.WM_SIZE (wParam, lParam);
+ if (isDisposed ()) return result;
+ if ((style & SWT.SEARCH) != 0) {
+ /* NOTE: EDIT controls don't support mirrored layout. */
+ boolean rtl = (style & SWT.RIGHT_TO_LEFT) != 0;
+ long hwndLeading = OS.GetDlgItem (handle, rtl ? SWT.ICON_CANCEL : SWT.ICON_SEARCH);
+ long hwndTrailing = OS.GetDlgItem (handle, rtl ? SWT.ICON_SEARCH : SWT.ICON_CANCEL);
+ int width = OS.LOWORD (lParam);
+ int height = OS.HIWORD (lParam);
+ int iconWidth = OS.GetSystemMetrics (OS.SM_CXSMICON);
+ int flags = OS.SWP_NOZORDER | OS.SWP_NOACTIVATE | OS.SWP_NOCOPYBITS;
+ if (hwndLeading != 0) OS.SetWindowPos (hwndLeading, 0, 0, 0, iconWidth, height, flags);
+ if (hwndTrailing != 0) OS.SetWindowPos (hwndTrailing, 0, width - iconWidth, 0, iconWidth, height, flags);
+ }
+ return result;
+}
+
+@Override
+LRESULT WM_UNDO (long wParam, long lParam) {
LRESULT result = super.WM_UNDO (wParam, lParam);
if (result != null) return result;
return wmClipboard (OS.WM_UNDO, wParam, lParam);
}
-LRESULT wmClipboard (int msg, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmClipboard (int msg, long wParam, long lParam) {
if ((style & SWT.READ_ONLY) != 0) return null;
if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return null;
boolean call = false;
@@ -2840,7 +3051,7 @@ LRESULT wmClipboard (int msg, long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmColorChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmColorChild (long wParam, long lParam) {
if ((style & SWT.READ_ONLY) != 0) {
if ((style & (SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL)) == 0) {
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
@@ -2866,13 +3077,18 @@ LRESULT wmColorChild (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmCommandChild (long wParam, long lParam) {
int code = OS.HIWORD (wParam);
switch (code) {
case OS.EN_CHANGE:
if (findImageControl () != null) {
OS.InvalidateRect (handle, null, true);
}
+ if ((style & SWT.SEARCH) != 0) {
+ boolean showCancel = OS.GetWindowTextLength (handle) != 0;
+ long hwndCancel = OS.GetDlgItem (handle, SWT.ICON_CANCEL);
+ if (hwndCancel != 0) OS.ShowWindow (hwndCancel, showCancel ? OS.SW_SHOW : OS.SW_HIDE);
+ }
if (ignoreModify) break;
/*
* It is possible (but unlikely), that application
@@ -2924,17 +3140,17 @@ LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmKeyDown (long hwnd, long wParam, long lParam) {
LRESULT result = super.wmKeyDown (hwnd, wParam, lParam);
if (result != null) return result;
if (segments != null) {
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_LEFT:
case OS.VK_UP:
case OS.VK_RIGHT:
case OS.VK_DOWN:
- long /*int*/ code = 0;
+ long code = 0;
int [] start = new int [1], end = new int [1], newStart = new int [1], newEnd = new int [1];
OS.SendMessage (handle, OS.EM_GETSEL, start, end);
while (true) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
index 1fddaf9833..9b01250ba7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -48,12 +48,13 @@ import org.eclipse.swt.internal.win32.*;
* @noextend This class is not intended to be subclassed by clients.
*/
public class ToolBar extends Composite {
- int lastFocusId, lastArrowId, lastHotId;
+ int lastFocusId, lastArrowId, lastHotId, _width, _height, _count = -1, _wHint = -1, _hHint = -1;
+ long currentToolItemToolTip;
ToolItem [] items;
ToolItem [] tabItemList;
boolean ignoreResize, ignoreMouse;
ImageList imageList, disabledImageList, hotImageList;
- static final long /*int*/ ToolBarProc;
+ static final long ToolBarProc;
static final TCHAR ToolBarClass = new TCHAR (0, OS.TOOLBARCLASSNAME, true);
static {
WNDCLASS lpWndClass = new WNDCLASS ();
@@ -143,7 +144,7 @@ public ToolBar (Composite parent, int style) {
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
/*
* Bug in Windows. For some reason, during the processing
@@ -191,12 +192,33 @@ protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
+@Override
+public void layout (boolean changed) {
+ checkWidget ();
+ clearSizeCache(changed);
+ super.layout(changed);
+}
+
+void clearSizeCache(boolean changed) {
+ // If changed, discard the cached layout information
+ if (changed) {
+ _count = _wHint = _hHint = -1;
+ }
+}
+
@Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
+ int count = (int)OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ if (count == this._count && wHint == this._wHint && hHint == this._hHint) {
+ // Return already cached values calculated previously
+ return new Point (_width, _height);
+ }
+ this._count = count;
+ this._wHint = wHint;
+ this._hHint = hHint;
int width = 0, height = 0;
if ((style & SWT.VERTICAL) != 0) {
RECT rect = new RECT ();
TBBUTTON lpButton = new TBBUTTON ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
for (int i=0; i<count; i++) {
OS.SendMessage (handle, OS.TB_GETITEMRECT, i, rect);
height = Math.max (height, rect.bottom);
@@ -224,7 +246,6 @@ protected void checkSubclass () {
if (redraw) OS.UpdateWindow (handle);
int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOREDRAW | OS.SWP_NOZORDER;
OS.SetWindowPos (handle, 0, 0, 0, newWidth, newHeight, flags);
- int count = (int)/*64*/OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
if (count != 0) {
RECT rect = new RECT ();
OS.SendMessage (handle, OS.TB_GETITEMRECT, count - 1, rect);
@@ -249,6 +270,12 @@ protected void checkSubclass () {
if (hHint != SWT.DEFAULT) height = hHint;
Rectangle trim = computeTrimInPixels (0, 0, width, height);
width = trim.width; height = trim.height;
+ /*
+ * Cache this size information for possible re-use as this method gets called
+ * too many times, for more details see performance Bug 574641
+ */
+ this._width = width;
+ this._height = height;
return new Point (width, height);
}
@@ -267,7 +294,7 @@ Widget computeTabGroup () {
while (i < items.length && items [i].control == null) i++;
if (i == items.length) return super.computeTabGroup ();
}
- int index = (int)/*64*/OS.SendMessage (handle, OS.TB_GETHOTITEM, 0, 0);
+ int index = (int)OS.SendMessage (handle, OS.TB_GETHOTITEM, 0, 0);
if (index == -1) index = lastHotId;
while (index >= 0) {
ToolItem item = items [index];
@@ -288,8 +315,7 @@ Widget [] computeTabList () {
Widget result [] = {};
if (!isTabGroup () || !isEnabled () || !isVisible ()) return result;
ToolItem [] list = tabList != null ? _getTabItemList () : items;
- for (int i=0; i<list.length; i++) {
- ToolItem child = list [i];
+ for (ToolItem child : list) {
Widget [] childList = child.computeTabList ();
if (childList.length != 0) {
Widget [] newResult = new Widget [result.length + childList.length];
@@ -337,7 +363,7 @@ void createHandle () {
* bar currently sets this value to 300 so it is not
* necessary to set TTM_SETMAXTIPWIDTH.
*/
-// long /*int*/ hwndToolTip = OS.SendMessage (handle, OS.TB_GETTOOLTIPS, 0, 0);
+// long hwndToolTip = OS.SendMessage (handle, OS.TB_GETTOOLTIPS, 0, 0);
// OS.SendMessage (hwndToolTip, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);
/*
@@ -352,7 +378,7 @@ void createHandle () {
* The control will not destroy a font that it did not
* create.
*/
- long /*int*/ hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ long hFont = OS.GetStockObject (OS.SYSTEM_FONT);
OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);
/* Set the button struct, bitmap and button sizes */
@@ -361,12 +387,12 @@ void createHandle () {
OS.SendMessage (handle, OS.TB_SETBUTTONSIZE, 0, 0);
/* Set the extended style bits */
- int bits = OS.TBSTYLE_EX_DRAWDDARROWS | OS.TBSTYLE_EX_MIXEDBUTTONS | OS.TBSTYLE_EX_HIDECLIPPEDBUTTONS | OS.TBSTYLE_EX_DOUBLEBUFFER;
+ int bits = OS.TBSTYLE_EX_DRAWDDARROWS | OS.TBSTYLE_EX_MIXEDBUTTONS | OS.TBSTYLE_EX_DOUBLEBUFFER;
OS.SendMessage (handle, OS.TB_SETEXTENDEDSTYLE, 0, bits);
}
void createItem (ToolItem item, int index) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
int id = 0;
while (id < items.length && items [id] != null) id++;
@@ -418,7 +444,7 @@ void destroyItem (ToolItem item) {
TBBUTTONINFO info = new TBBUTTONINFO ();
info.cbSize = TBBUTTONINFO.sizeof;
info.dwMask = OS.TBIF_IMAGE | OS.TBIF_STYLE;
- int index = (int)/*64*/OS.SendMessage (handle, OS.TB_GETBUTTONINFO, item.id, info);
+ int index = (int)OS.SendMessage (handle, OS.TB_GETBUTTONINFO, item.id, info);
/*
* Feature in Windows. For some reason, a tool item that has
* the style BTNS_SEP does not return I_IMAGENONE when queried
@@ -440,7 +466,7 @@ void destroyItem (ToolItem item) {
if (item.id == lastHotId) lastHotId = -1;
items [item.id] = null;
item.id = -1;
- int count = (int)/*64*/OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
if (count == 0) {
if (imageList != null) {
OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, 0);
@@ -476,8 +502,7 @@ void enableWidget (boolean enabled) {
* The fix is to use the disabled image in all image
* lists for all items.
*/
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
+ for (ToolItem item : items) {
if (item != null) {
if ((item.style & SWT.SEPARATOR) == 0) {
item.updateImages (enabled && item.getEnabled ());
@@ -515,10 +540,10 @@ ImageList getImageList () {
*/
public ToolItem getItem (int index) {
checkWidget ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
TBBUTTON lpButton = new TBBUTTON ();
- long /*int*/ result = OS.SendMessage (handle, OS.TB_GETBUTTON, index, lpButton);
+ long result = OS.SendMessage (handle, OS.TB_GETBUTTON, index, lpButton);
if (result == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
return items [lpButton.idCommand];
}
@@ -546,10 +571,9 @@ public ToolItem getItem (Point point) {
}
ToolItem getItemInPixels (Point point) {
- ToolItem [] items = getItems ();
- for (int i=0; i<items.length; i++) {
- Rectangle rect = items [i].getBoundsInPixels ();
- if (rect.contains (point)) return items [i];
+ for (ToolItem item : getItems ()) {
+ Rectangle rect = item.getBoundsInPixels ();
+ if (rect.contains (point)) return item;
}
return null;
}
@@ -566,7 +590,7 @@ ToolItem getItemInPixels (Point point) {
*/
public int getItemCount () {
checkWidget ();
- return (int)/*64*/OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ return (int)OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
}
/**
@@ -591,7 +615,7 @@ public ToolItem [] getItems () {
}
ToolItem [] _getItems () {
- int count = (int)/*64*/OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
TBBUTTON lpButton = new TBBUTTON ();
ToolItem [] result = new ToolItem [count];
for (int i=0; i<count; i++) {
@@ -617,23 +641,23 @@ ToolItem [] _getItems () {
public int getRowCount () {
checkWidget ();
if ((style & SWT.VERTICAL) != 0) {
- return (int)/*64*/OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ return (int)OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
}
- return (int)/*64*/OS.SendMessage (handle, OS.TB_GETROWS, 0, 0);
+ return (int)OS.SendMessage (handle, OS.TB_GETROWS, 0, 0);
}
ToolItem [] _getTabItemList () {
if (tabItemList == null) return tabItemList;
int count = 0;
- for (int i=0; i<tabItemList.length; i++) {
- if (!tabItemList [i].isDisposed ()) count++;
+ for (ToolItem item : tabItemList) {
+ if (!item.isDisposed ()) count++;
}
if (count == tabItemList.length) return tabItemList;
ToolItem [] newList = new ToolItem [count];
int index = 0;
- for (int i=0; i<tabItemList.length; i++) {
- if (!tabItemList [i].isDisposed ()) {
- newList [index++] = tabItemList [i];
+ for (ToolItem item : tabItemList) {
+ if (!item.isDisposed ()) {
+ newList [index++] = item;
}
}
tabItemList = newList;
@@ -662,10 +686,11 @@ public int indexOf (ToolItem item) {
checkWidget ();
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- return (int)/*64*/OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, item.id, 0);
+ return (int)OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, item.id, 0);
}
void layoutItems () {
+ clearSizeCache(true);
/*
* Feature in Windows. When a tool bar has the style
* TBSTYLE_LIST and has a drop down item, Window leaves
@@ -682,8 +707,7 @@ void layoutItems () {
if (OS.IsAppThemed ()) {
if ((style & SWT.RIGHT) != 0 && (style & SWT.VERTICAL) == 0) {
boolean hasText = false, hasImage = false;
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
+ for (ToolItem item : items) {
if (item != null) {
if (!hasText) hasText = item.text.length () != 0;
if (!hasImage) hasImage = item.image != null;
@@ -705,7 +729,7 @@ void layoutItems () {
* the tool items. The fix is to use WM_SETFONT to force
* the tool bar to redraw and lay out.
*/
- long /*int*/ hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ long hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);
setDropDownItems (true);
}
@@ -722,12 +746,12 @@ void layoutItems () {
* into account extra padding.
*/
if ((style & SWT.VERTICAL) != 0) {
- int itemCount = (int)/*64*/OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ int itemCount = (int)OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
if (itemCount > 1) {
TBBUTTONINFO info = new TBBUTTONINFO ();
info.cbSize = TBBUTTONINFO.sizeof;
info.dwMask = OS.TBIF_SIZE;
- long /*int*/ size = OS.SendMessage (handle, OS.TB_GETBUTTONSIZE, 0, 0);
+ long size = OS.SendMessage (handle, OS.TB_GETBUTTONSIZE, 0, 0);
info.cx = (short) OS.LOWORD (size);
int index = 0, extraPadding = 0;
while (index < items.length) {
@@ -745,11 +769,10 @@ void layoutItems () {
index++;
}
if (index < items.length) {
- long /*int*/ padding = OS.SendMessage (handle, OS.TB_GETPADDING, 0, 0);
+ long padding = OS.SendMessage (handle, OS.TB_GETPADDING, 0, 0);
info.cx += OS.LOWORD (padding + extraPadding) * 2;
}
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
+ for (ToolItem item : items) {
if (item != null && (item.style & SWT.SEPARATOR) == 0) {
OS.SendMessage (handle, OS.TB_SETBUTTONINFO, item.id, info);
}
@@ -773,8 +796,7 @@ void layoutItems () {
TBBUTTONINFO info = new TBBUTTONINFO ();
info.cbSize = TBBUTTONINFO.sizeof;
info.dwMask = OS.TBIF_SIZE;
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
+ for (ToolItem item : items) {
if (item != null && item.cx > 0) {
info.cx = item.cx;
OS.SendMessage (handle, OS.TB_SETBUTTONINFO, item.id, info);
@@ -783,8 +805,7 @@ void layoutItems () {
}
}
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
+ for (ToolItem item : items) {
if (item != null) item.resizeControl ();
}
}
@@ -796,7 +817,7 @@ boolean mnemonicHit (char ch) {
return false;
}
if ((style & SWT.FLAT) != 0 && !setTabGroupFocus ()) return false;
- int index = (int)/*64*/OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, id [0], 0);
+ int index = (int)OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, id [0], 0);
if (index == -1) return false;
OS.SendMessage (handle, OS.TB_SETHOTITEM, index, 0);
items [id [0]].click (false);
@@ -815,7 +836,7 @@ boolean mnemonicMatch (char ch) {
* undocumented and unwanted. The fix is to ensure that the tool item
* contains a mnemonic when TB_MAPACCELERATOR returns true.
*/
- int index = (int)/*64*/OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, id [0], 0);
+ int index = (int)OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, id [0], 0);
if (index == -1) return false;
return findMnemonic (items [id [0]].text) != '\0';
}
@@ -823,8 +844,7 @@ boolean mnemonicMatch (char ch) {
@Override
void releaseChildren (boolean destroy) {
if (items != null) {
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
+ for (ToolItem item : items) {
if (item != null && !item.isDisposed ()) {
item.release (false);
}
@@ -855,8 +875,7 @@ void releaseWidget () {
@Override
void removeControl (Control control) {
super.removeControl (control);
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
+ for (ToolItem item : items) {
if (item != null && item.control == control) {
item.setControl (null);
}
@@ -866,8 +885,7 @@ void removeControl (Control control) {
@Override
void reskinChildren (int flags) {
if (items != null) {
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
+ for (ToolItem item : items) {
if (item != null) item.reskin (flags);
}
}
@@ -875,7 +893,7 @@ void reskinChildren (int flags) {
}
@Override
-void setBackgroundImage (long /*int*/ hBitmap) {
+void setBackgroundImage (long hBitmap) {
super.setBackgroundImage (hBitmap);
setBackgroundTransparent (hBitmap != 0);
}
@@ -952,8 +970,7 @@ void setDropDownItems (boolean set) {
*/
if (OS.IsAppThemed ()) {
boolean hasText = false, hasImage = false;
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
+ for (ToolItem item : items) {
if (item != null) {
if (!hasText) hasText = item.text.length () != 0;
if (!hasImage) hasImage = item.image != null;
@@ -961,8 +978,7 @@ void setDropDownItems (boolean set) {
}
}
if (hasImage && !hasText) {
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
+ for (ToolItem item : items) {
if (item != null && (item.style & SWT.DROP_DOWN) != 0) {
TBBUTTONINFO info = new TBBUTTONINFO ();
info.cbSize = TBBUTTONINFO.sizeof;
@@ -982,7 +998,7 @@ void setDropDownItems (boolean set) {
void setDisabledImageList (ImageList imageList) {
if (disabledImageList == imageList) return;
- long /*int*/ hImageList = 0;
+ long hImageList = 0;
if ((disabledImageList = imageList) != null) {
hImageList = disabledImageList.getHandle ();
}
@@ -1019,7 +1035,7 @@ public void setFont (Font font) {
void setHotImageList (ImageList imageList) {
if (hotImageList == imageList) return;
- long /*int*/ hImageList = 0;
+ long hImageList = 0;
if ((hotImageList = imageList) != null) {
hImageList = hotImageList.getHandle ();
}
@@ -1030,7 +1046,7 @@ void setHotImageList (ImageList imageList) {
void setImageList (ImageList imageList) {
if (this.imageList == imageList) return;
- long /*int*/ hImageList = 0;
+ long hImageList = 0;
if ((this.imageList = imageList) != null) {
hImageList = imageList.getHandle ();
}
@@ -1043,7 +1059,7 @@ void setImageList (ImageList imageList) {
public boolean setParent (Composite parent) {
checkWidget ();
if (!super.setParent (parent)) return false;
- long /*int*/ hwndParent = parent.handle;
+ long hwndParent = parent.handle;
OS.SendMessage (handle, OS.TB_SETPARENT, hwndParent, 0);
/*
* Bug in Windows. When a tool bar is reparented, the tooltip
@@ -1052,8 +1068,8 @@ public boolean setParent (Composite parent) {
* over using SetWindowLongPtr(). Note that for some reason,
* SetParent() does not work.
*/
- long /*int*/ hwndShell = parent.getShell ().handle;
- long /*int*/ hwndToolTip = OS.SendMessage (handle, OS.TB_GETTOOLTIPS, 0, 0);
+ long hwndShell = parent.getShell ().handle;
+ long hwndToolTip = OS.SendMessage (handle, OS.TB_GETTOOLTIPS, 0, 0);
OS.SetWindowLongPtr (hwndToolTip, OS.GWLP_HWNDPARENT, hwndShell);
return true;
}
@@ -1104,8 +1120,7 @@ void setRowCount (int count) {
/*public*/ void setTabItemList (ToolItem [] tabList) {
checkWidget ();
if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- ToolItem item = tabList [i];
+ for (ToolItem item : tabList) {
if (item == null) error (SWT.ERROR_INVALID_ARGUMENT);
if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
if (item.parent != this) error (SWT.ERROR_INVALID_PARENT);
@@ -1157,9 +1172,13 @@ String toolTipText (NMTTDISPINFO hdr) {
* provide the string, causing no tool tip to be displayed.
*/
if (!hasCursor ()) return ""; //$NON-NLS-1$
- int index = (int)/*64*/hdr.idFrom;
- long /*int*/ hwndToolTip = OS.SendMessage (handle, OS.TB_GETTOOLTIPS, 0, 0);
+ int index = (int)hdr.idFrom;
+ long hwndToolTip = OS.SendMessage (handle, OS.TB_GETTOOLTIPS, 0, 0);
if (hwndToolTip == hdr.hwndFrom) {
+ if (currentToolItemToolTip != hwndToolTip) {
+ maybeEnableDarkSystemTheme(hdr.hwndFrom);
+ currentToolItemToolTip = hdr.hwndFrom;
+ }
/*
* Bug in Windows. For some reason the reading order
* in NMTTDISPINFO is sometimes set incorrectly. The
@@ -1203,7 +1222,7 @@ void updateOrientation () {
TBBUTTONINFO info = new TBBUTTONINFO ();
info.cbSize = TBBUTTONINFO.sizeof;
info.dwMask = OS.TBIF_IMAGE;
- int count = (int)/*64*/OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
for (int i=0; i<count; i++) {
ToolItem item = items [i];
if ((item.style & SWT.SEPARATOR) != 0) continue;
@@ -1267,12 +1286,12 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return ToolBarProc;
}
@Override
-LRESULT WM_CAPTURECHANGED (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CAPTURECHANGED (long wParam, long lParam) {
LRESULT result = super.WM_CAPTURECHANGED (wParam, lParam);
if (result != null) return result;
/*
@@ -1280,10 +1299,9 @@ LRESULT WM_CAPTURECHANGED (long /*int*/ wParam, long /*int*/ lParam) {
* item is pressed, the item remains pressed. The fix is
* unpress all items using TB_SETSTATE and TBSTATE_PRESSED.
*/
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
+ for (ToolItem item : items) {
if (item != null) {
- int fsState = (int)/*64*/OS.SendMessage (handle, OS.TB_GETSTATE, item.id, 0);
+ int fsState = (int)OS.SendMessage (handle, OS.TB_GETSTATE, item.id, 0);
if ((fsState & OS.TBSTATE_PRESSED) != 0) {
fsState &= ~OS.TBSTATE_PRESSED;
OS.SendMessage (handle, OS.TB_SETSTATE, item.id, fsState);
@@ -1294,15 +1312,15 @@ LRESULT WM_CAPTURECHANGED (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CHAR (long wParam, long lParam) {
LRESULT result = super.WM_CHAR (wParam, lParam);
if (result != null) return result;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case ' ':
- int index = (int)/*64*/OS.SendMessage (handle, OS.TB_GETHOTITEM, 0, 0);
+ int index = (int)OS.SendMessage (handle, OS.TB_GETHOTITEM, 0, 0);
if (index != -1) {
TBBUTTON lpButton = new TBBUTTON ();
- long /*int*/ code = OS.SendMessage (handle, OS.TB_GETBUTTON, index, lpButton);
+ long code = OS.SendMessage (handle, OS.TB_GETBUTTON, index, lpButton);
if (code != 0) {
items [lpButton.idCommand].click (false);
return LRESULT.ZERO;
@@ -1313,7 +1331,7 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_COMMAND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_COMMAND (long wParam, long lParam) {
/*
* Feature in Windows. When the toolbar window
* proc processes WM_COMMAND, it forwards this
@@ -1338,7 +1356,7 @@ LRESULT WM_COMMAND (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETDLGCODE (long wParam, long lParam) {
LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
/*
* Return DLGC_BUTTON so that mnemonics will be
@@ -1350,10 +1368,10 @@ LRESULT WM_GETDLGCODE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KEYDOWN (long wParam, long lParam) {
LRESULT result = super.WM_KEYDOWN (wParam, lParam);
if (result != null) return result;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_SPACE:
/*
* Ensure that the window proc does not process VK_SPACE
@@ -1366,28 +1384,28 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
- int index = (int)/*64*/OS.SendMessage (handle, OS.TB_GETHOTITEM, 0, 0);
+LRESULT WM_KILLFOCUS (long wParam, long lParam) {
+ int index = (int)OS.SendMessage (handle, OS.TB_GETHOTITEM, 0, 0);
TBBUTTON lpButton = new TBBUTTON ();
- long /*int*/ code = OS.SendMessage (handle, OS.TB_GETBUTTON, index, lpButton);
+ long code = OS.SendMessage (handle, OS.TB_GETBUTTON, index, lpButton);
if (code != 0) lastFocusId = lpButton.idCommand;
return super.WM_KILLFOCUS (wParam, lParam);
}
@Override
-LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDOWN (long wParam, long lParam) {
if (ignoreMouse) return null;
return super.WM_LBUTTONDOWN (wParam, lParam);
}
@Override
-LRESULT WM_LBUTTONUP (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONUP (long wParam, long lParam) {
if (ignoreMouse) return null;
return super.WM_LBUTTONUP (wParam, lParam);
}
@Override
-LRESULT WM_MOUSELEAVE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSELEAVE (long wParam, long lParam) {
LRESULT result = super.WM_MOUSELEAVE (wParam, lParam);
if (result != null) return result;
/*
@@ -1403,7 +1421,7 @@ LRESULT WM_MOUSELEAVE (long /*int*/ wParam, long /*int*/ lParam) {
*/
TOOLINFO lpti = new TOOLINFO ();
lpti.cbSize = TOOLINFO.sizeof;
- long /*int*/ hwndToolTip = OS.SendMessage (handle, OS.TB_GETTOOLTIPS, 0, 0);
+ long hwndToolTip = OS.SendMessage (handle, OS.TB_GETTOOLTIPS, 0, 0);
if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, lpti) != 0) {
if ((lpti.uFlags & OS.TTF_IDISHWND) == 0) {
OS.SendMessage (hwndToolTip, OS.TTM_DELTOOL, 0, lpti);
@@ -1414,13 +1432,13 @@ LRESULT WM_MOUSELEAVE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSEMOVE (long wParam, long lParam) {
if (OS.GetMessagePos () != display.lastMouse) lastArrowId = -1;
return super.WM_MOUSEMOVE (wParam, lParam);
}
@Override
-LRESULT WM_NOTIFY (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_NOTIFY (long wParam, long lParam) {
/*
* Feature in Windows. When the toolbar window
* proc processes WM_NOTIFY, it forwards this
@@ -1445,19 +1463,19 @@ LRESULT WM_NOTIFY (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFOCUS (long wParam, long lParam) {
LRESULT result = super.WM_SETFOCUS (wParam, lParam);
if (lastFocusId != -1 && handle == OS.GetFocus ()) {
- int index = (int)/*64*/OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, lastFocusId, 0);
+ int index = (int)OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, lastFocusId, 0);
OS.SendMessage (handle, OS.TB_SETHOTITEM, index, 0);
}
return result;
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
if (ignoreResize) {
- long /*int*/ code = callWindowProc (handle, OS.WM_SIZE, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_SIZE, wParam, lParam);
if (code == 0) return LRESULT.ZERO;
return new LRESULT (code);
}
@@ -1478,14 +1496,14 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
OS.GetWindowRect (handle, windowRect);
int index = 0, border = getBorderWidthInPixels () * 2;
RECT rect = new RECT ();
- int count = (int)/*64*/OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
while (index < count) {
OS.SendMessage (handle, OS.TB_GETITEMRECT, index, rect);
OS.MapWindowPoints (handle, 0, rect, 2);
if (rect.right > windowRect.right - border * 2) break;
index++;
}
- int bits = (int)/*64*/OS.SendMessage (handle, OS.TB_GETEXTENDEDSTYLE, 0, 0);
+ int bits = (int)OS.SendMessage (handle, OS.TB_GETEXTENDEDSTYLE, 0, 0);
if (index == count) {
bits |= OS.TBSTYLE_EX_HIDECLIPPEDBUTTONS;
} else {
@@ -1498,7 +1516,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_WINDOWPOSCHANGING (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_WINDOWPOSCHANGING (long wParam, long lParam) {
LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam);
if (result != null) return result;
if (ignoreResize) return result;
@@ -1541,7 +1559,7 @@ LRESULT WM_WINDOWPOSCHANGING (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmCommandChild (long wParam, long lParam) {
ToolItem child = items [OS.LOWORD (wParam)];
if (child == null) return null;
return child.wmCommandChild (wParam, lParam);
@@ -1552,7 +1570,7 @@ private boolean customDrawing() {
}
@Override
-LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) {
switch (hdr.code) {
case OS.TBN_DROPDOWN:
NMTOOLBAR lpnmtb = new NMTOOLBAR ();
@@ -1561,7 +1579,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
if (child != null) {
Event event = new Event ();
event.detail = SWT.ARROW;
- int index = (int)/*64*/OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, lpnmtb.iItem, 0);
+ int index = (int)OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, lpnmtb.iItem, 0);
RECT rect = new RECT ();
OS.SendMessage (handle, OS.TB_GETITEMRECT, index, rect);
event.setLocationInPixels(rect.left, rect.bottom);
@@ -1631,7 +1649,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
case OS.HICF_ARROWKEYS: {
RECT client = new RECT ();
OS.GetClientRect (handle, client);
- int index = (int)/*64*/OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, lpnmhi.idNew, 0);
+ int index = (int)OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, lpnmhi.idNew, 0);
RECT rect = new RECT ();
OS.SendMessage (handle, OS.TB_GETITEMRECT, index, rect);
if (rect.right > client.right || rect.bottom > client.bottom) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
index 690810de79..736e479880 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -180,12 +180,12 @@ protected void checkSubclass () {
}
void click (boolean dropDown) {
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
if (OS.GetKeyState (OS.VK_LBUTTON) < 0) return;
- int index = (int)/*64*/OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, id, 0);
+ int index = (int)OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, id, 0);
RECT rect = new RECT ();
OS.SendMessage (hwnd, OS.TB_GETITEMRECT, index, rect);
- int hotIndex = (int)/*64*/OS.SendMessage (hwnd, OS.TB_GETHOTITEM, 0, 0);
+ int hotIndex = (int)OS.SendMessage (hwnd, OS.TB_GETHOTITEM, 0, 0);
/*
* In order to emulate all the processing that
@@ -195,7 +195,7 @@ void click (boolean dropDown) {
* properly.
*/
int y = rect.top + (rect.bottom - rect.top) / 2;
- long /*int*/ lParam = OS.MAKELPARAM (dropDown ? rect.right - 1 : rect.left, y);
+ long lParam = OS.MAKELPARAM (dropDown ? rect.right - 1 : rect.left, y);
parent.ignoreMouse = true;
OS.SendMessage (hwnd, OS.WM_LBUTTONDOWN, 0, lParam);
OS.SendMessage (hwnd, OS.WM_LBUTTONUP, 0, lParam);
@@ -242,8 +242,8 @@ public Rectangle getBounds () {
}
Rectangle getBoundsInPixels () {
- long /*int*/ hwnd = parent.handle;
- int index = (int)/*64*/OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, id, 0);
+ long hwnd = parent.handle;
+ int index = (int)OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, id, 0);
RECT rect = new RECT ();
OS.SendMessage (hwnd, OS.TB_GETITEMRECT, index, rect);
int width = rect.right - rect.left;
@@ -306,8 +306,8 @@ public boolean getEnabled () {
if ((style & SWT.SEPARATOR) != 0) {
return (state & DISABLED) == 0;
}
- long /*int*/ hwnd = parent.handle;
- long /*int*/ fsState = OS.SendMessage (hwnd, OS.TB_GETSTATE, id, 0);
+ long hwnd = parent.handle;
+ long fsState = OS.SendMessage (hwnd, OS.TB_GETSTATE, id, 0);
return (fsState & OS.TBSTATE_ENABLED) != 0;
}
@@ -331,6 +331,22 @@ public Image getHotImage () {
}
/**
+ * Returns the receiver's enabled image if it has one, or null
+ * if it does not.
+ *
+ * @return the receiver's enabled image
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+@Override
+public Image getImage () {
+ return super.getImage();
+}
+
+/**
* Returns the receiver's parent, which must be a <code>ToolBar</code>.
*
* @return the receiver's parent
@@ -365,8 +381,8 @@ public ToolBar getParent () {
public boolean getSelection () {
checkWidget();
if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;
- long /*int*/ hwnd = parent.handle;
- long /*int*/ fsState = OS.SendMessage (hwnd, OS.TB_GETSTATE, id, 0);
+ long hwnd = parent.handle;
+ long fsState = OS.SendMessage (hwnd, OS.TB_GETSTATE, id, 0);
return (fsState & OS.TBSTATE_CHECKED) != 0;
}
@@ -401,8 +417,8 @@ public int getWidth () {
}
int getWidthInPixels () {
- long /*int*/ hwnd = parent.handle;
- int index = (int)/*64*/OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, id, 0);
+ long hwnd = parent.handle;
+ int index = (int)OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, id, 0);
RECT rect = new RECT ();
OS.SendMessage (hwnd, OS.TB_GETITEMRECT, index, rect);
return rect.right - rect.left;
@@ -431,8 +447,8 @@ public boolean isEnabled () {
boolean isTabGroup () {
ToolItem [] tabList = parent._getTabItemList ();
if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == this) return true;
+ for (ToolItem item : tabList) {
+ if (item == this) return true;
}
}
if ((style & SWT.SEPARATOR) != 0) return true;
@@ -464,7 +480,7 @@ void releaseImages () {
TBBUTTONINFO info = new TBBUTTONINFO ();
info.cbSize = TBBUTTONINFO.sizeof;
info.dwMask = OS.TBIF_IMAGE | OS.TBIF_STYLE;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
OS.SendMessage (hwnd, OS.TB_GETBUTTONINFO, id, info);
/*
* Feature in Windows. For some reason, a tool item that has
@@ -563,6 +579,7 @@ public void setControl (Control control) {
if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
}
if ((style & SWT.SEPARATOR) == 0) return;
+ parent.layout(true);
this.control = control;
/*
* Feature in Windows. When a tool bar wraps, tool items
@@ -580,7 +597,7 @@ public void setControl (Control control) {
*/
if ((parent.style & (SWT.WRAP | SWT.VERTICAL)) != 0) {
boolean changed = false;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TBBUTTONINFO info = new TBBUTTONINFO ();
info.cbSize = TBBUTTONINFO.sizeof;
info.dwMask = OS.TBIF_STYLE | OS.TBIF_STATE;
@@ -643,8 +660,8 @@ public void setControl (Control control) {
*/
public void setEnabled (boolean enabled) {
checkWidget();
- long /*int*/ hwnd = parent.handle;
- int fsState = (int)/*64*/OS.SendMessage (hwnd, OS.TB_GETSTATE, id, 0);
+ long hwnd = parent.handle;
+ int fsState = (int)OS.SendMessage (hwnd, OS.TB_GETSTATE, id, 0);
/*
* Feature in Windows. When TB_SETSTATE is used to set the
* state of a tool item, the item redraws even when the state
@@ -663,6 +680,9 @@ public void setEnabled (boolean enabled) {
if ((style & SWT.SEPARATOR) == 0) {
if (image != null) updateImages (enabled && parent.getEnabled ());
}
+ if (!enabled && parent.lastFocusId == id) {
+ parent.lastFocusId = -1;
+ }
}
/**
@@ -684,8 +704,10 @@ public void setEnabled (boolean enabled) {
*/
public void setDisabledImage (Image image) {
checkWidget();
+ if (this.disabledImage == image) return;
if ((style & SWT.SEPARATOR) != 0) return;
if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ parent.layout(isImageSizeChanged(disabledImage, image));
disabledImage = image;
updateImages (getEnabled () && parent.getEnabled ());
}
@@ -709,8 +731,10 @@ public void setDisabledImage (Image image) {
*/
public void setHotImage (Image image) {
checkWidget();
+ if (this.hotImage == image) return;
if ((style & SWT.SEPARATOR) != 0) return;
if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ parent.layout(isImageSizeChanged(hotImage, image));
hotImage = image;
updateImages (getEnabled () && parent.getEnabled ());
}
@@ -718,12 +742,23 @@ public void setHotImage (Image image) {
@Override
public void setImage (Image image) {
checkWidget();
+ if (this.image == image) return;
if ((style & SWT.SEPARATOR) != 0) return;
if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ parent.layout(isImageSizeChanged(super.image, image));
super.setImage (image);
updateImages (getEnabled () && parent.getEnabled ());
}
+boolean isImageSizeChanged(Image oldImage, Image image) {
+ boolean changed = true;
+ // check if image size really changed for old and new images
+ if (oldImage != null && !oldImage.isDisposed() && image != null && !image.isDisposed()) {
+ changed = !oldImage.getBounds().equals(image.getBounds());
+ }
+ return changed;
+}
+
boolean setRadioSelection (boolean value) {
if ((style & SWT.RADIO) == 0) return false;
if (getSelection () != value) {
@@ -751,8 +786,8 @@ boolean setRadioSelection (boolean value) {
public void setSelection (boolean selected) {
checkWidget();
if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
- long /*int*/ hwnd = parent.handle;
- int fsState = (int)/*64*/OS.SendMessage (hwnd, OS.TB_GETSTATE, id, 0);
+ long hwnd = parent.handle;
+ int fsState = (int)OS.SendMessage (hwnd, OS.TB_GETSTATE, id, 0);
/*
* Feature in Windows. When TB_SETSTATE is used to set the
* state of a tool item, the item redraws even when the state
@@ -787,8 +822,8 @@ public void setSelection (boolean selected) {
@Override
boolean setTabItemFocus () {
if (parent.setTabItemFocus ()) {
- long /*int*/ hwnd = parent.handle;
- int index = (int)/*64*/OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, id, 0);
+ long hwnd = parent.handle;
+ int index = (int)OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, id, 0);
OS.SendMessage (hwnd, OS.TB_SETHOTITEM, index, 0);
return true;
}
@@ -796,12 +831,12 @@ boolean setTabItemFocus () {
}
void _setText (String string) {
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TBBUTTONINFO info = new TBBUTTONINFO ();
info.cbSize = TBBUTTONINFO.sizeof;
info.dwMask = OS.TBIF_TEXT | OS.TBIF_STYLE;
info.fsStyle = (byte) (widgetStyle () | OS.BTNS_AUTOSIZE);
- long /*int*/ hHeap = OS.GetProcessHeap (), pszText = 0;
+ long hHeap = OS.GetProcessHeap (), pszText = 0;
if (string.length () != 0) {
info.fsStyle |= OS.BTNS_SHOWTEXT;
TCHAR buffer;
@@ -857,6 +892,7 @@ public void setText (String string) {
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if ((style & SWT.SEPARATOR) != 0) return;
if (string.equals (text)) return;
+ parent.layout(true);
super.setText (string);
if ((state & HAS_AUTO_DIRECTION) == 0 || !updateTextDirection (AUTO_TEXT_DIRECTION)) {
_setText (string);
@@ -870,8 +906,8 @@ public void setText (String string) {
* the tool bar to redraw and layout.
*/
parent.setDropDownItems (false);
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
+ long hwnd = parent.handle;
+ long hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
OS.SendMessage (hwnd, OS.WM_SETFONT, hFont, 0);
parent.setDropDownItems (true);
parent.layoutItems ();
@@ -942,7 +978,7 @@ public void setWidth (int width) {
void setWidthInPixels (int width) {
if ((style & SWT.SEPARATOR) == 0) return;
if (width < 0) return;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TBBUTTONINFO info = new TBBUTTONINFO ();
info.cbSize = TBBUTTONINFO.sizeof;
info.dwMask = OS.TBIF_SIZE;
@@ -953,7 +989,7 @@ void setWidthInPixels (int width) {
void updateImages (boolean enabled) {
if ((style & SWT.SEPARATOR) != 0) return;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TBBUTTONINFO info = new TBBUTTONINFO ();
info.cbSize = TBBUTTONINFO.sizeof;
info.dwMask = OS.TBIF_IMAGE;
@@ -1043,7 +1079,7 @@ void updateImages (boolean enabled) {
info.dwMask |= OS.TBIF_SIZE;
info.cx = 0;
OS.SendMessage (hwnd, OS.TB_SETBUTTONINFO, id, info);
- long /*int*/ hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
+ long hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
OS.SendMessage (hwnd, OS.WM_SETFONT, hFont, 0);
parent.layoutItems ();
}
@@ -1063,7 +1099,7 @@ int widgetStyle () {
return OS.BTNS_BUTTON;
}
-LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmCommandChild (long wParam, long lParam) {
if ((style & SWT.RADIO) != 0) {
if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
selectRadio ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolTip.java
index d7aaca1ce5..78c2a55472 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolTip.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolTip.java
@@ -217,7 +217,7 @@ public String getText () {
public boolean getVisible () {
checkWidget();
if (item != null) return visible;
- long /*int*/ hwndToolTip = hwndToolTip ();
+ long hwndToolTip = hwndToolTip ();
if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, 0) != 0) {
TOOLINFO lpti = new TOOLINFO ();
lpti.cbSize = TOOLINFO.sizeof;
@@ -229,8 +229,8 @@ public boolean getVisible () {
}
int getWidth () {
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hmonitor = OS.MonitorFromWindow (hwnd, OS.MONITOR_DEFAULTTONEAREST);
+ long hwnd = parent.handle;
+ long hmonitor = OS.MonitorFromWindow (hwnd, OS.MONITOR_DEFAULTTONEAREST);
MONITORINFO lpmi = new MONITORINFO ();
lpmi.cbSize = MONITORINFO.sizeof;
OS.GetMonitorInfo (hmonitor, lpmi);
@@ -238,7 +238,7 @@ int getWidth () {
return maxWidth / 4;
}
-long /*int*/ hwndToolTip () {
+long hwndToolTip () {
return (style & SWT.BALLOON) != 0 ? parent.balloonTipHandle () : parent.toolTipHandle ();
}
@@ -275,7 +275,7 @@ void releaseWidget () {
super.releaseWidget ();
if (item == null) {
if (autoHide) {
- long /*int*/ hwndToolTip = hwndToolTip ();
+ long hwndToolTip = hwndToolTip ();
if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, 0) != 0) {
TOOLINFO lpti = new TOOLINFO ();
lpti.cbSize = TOOLINFO.sizeof;
@@ -443,13 +443,13 @@ public void setText (String string) {
}
void updateMessage () {
- long /*int*/ hwnd = hwndToolTip();
+ long hwnd = hwndToolTip();
if (OS.SendMessage (hwnd, OS.TTM_GETCURRENTTOOL, 0, 0) != 0) {
TOOLINFO lpti = new TOOLINFO ();
lpti.cbSize = TOOLINFO.sizeof;
if (OS.SendMessage (hwnd, OS.TTM_GETCURRENTTOOL, 0, lpti) != 0) {
if (message != null && message.length() > 0) {
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
TCHAR buffer = new TCHAR (0, message, true);
int byteCount = buffer.length () * TCHAR.sizeof;
lpti.lpszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
@@ -493,12 +493,12 @@ public void setVisible (boolean visible) {
checkWidget ();
if (visible == getVisible ()) return;
if (item == null) {
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TOOLINFO lpti = new TOOLINFO ();
lpti.cbSize = TOOLINFO.sizeof;
lpti.uId = id;
lpti.hwnd = hwnd;
- long /*int*/ hwndToolTip = hwndToolTip ();
+ long hwndToolTip = hwndToolTip ();
Shell shell = parent.getShell ();
if (text.length () != 0) {
int icon = OS.TTI_NONE;
@@ -519,7 +519,7 @@ public void setVisible (boolean visible) {
nY = pt.y;
}
}
- long /*int*/ lParam = OS.MAKELPARAM (nX, nY);
+ long lParam = OS.MAKELPARAM (nX, nY);
OS.SendMessage (hwndToolTip, OS.TTM_TRACKPOSITION, 0, lParam);
/*
@@ -535,7 +535,7 @@ public void setVisible (boolean visible) {
OS.GetClientRect (hwnd, rect);
OS.MapWindowPoints (hwnd, 0, rect, 2);
if (!OS.PtInRect (rect, pt)) {
- long /*int*/ hCursor = OS.GetCursor ();
+ long hCursor = OS.GetCursor ();
OS.SetCursor (0);
OS.SetCursorPos (rect.left, rect.top);
OS.SendMessage (hwndToolTip, OS.TTM_TRACKACTIVATE, 1, lpti);
@@ -545,7 +545,7 @@ public void setVisible (boolean visible) {
OS.SendMessage (hwndToolTip, OS.TTM_TRACKACTIVATE, 1, lpti);
}
- int time = (int)/*64*/OS.SendMessage (hwndToolTip, OS.TTM_GETDELAYTIME, OS.TTDT_AUTOPOP, 0);
+ int time = (int)OS.SendMessage (hwndToolTip, OS.TTM_GETDELAYTIME, OS.TTDT_AUTOPOP, 0);
OS.SetTimer (hwndToolTip, TIMER_ID, time, 0);
updateMessage();
} else {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java
index 49d85ecd1d..c6c88c56c1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java
@@ -48,12 +48,12 @@ public class Tracker extends Widget {
boolean tracking, cancelled, stippled;
Rectangle [] rectangles = new Rectangle [0], proportions = rectangles;
Rectangle bounds;
- long /*int*/ resizeCursor;
+ long resizeCursor;
Cursor clientCursor;
int cursorOrientation = SWT.NONE;
boolean inEvent = false;
boolean drawn;
- long /*int*/ hwndTransparent, hwndOpaque, oldTransparentProc, oldOpaqueProc;
+ long hwndTransparent, hwndOpaque, oldTransparentProc, oldOpaqueProc;
int oldX, oldY;
/*
@@ -207,7 +207,7 @@ Point adjustMoveCursor () {
pt.x = newX; pt.y = newY;
/*
* Convert to screen coordinates iff needed
- */
+ */
if (parent != null) {
OS.ClientToScreen (parent.handle, pt);
}
@@ -250,7 +250,7 @@ Point adjustResizeCursor () {
* the appropriate resize cursor.
*/
if (clientCursor == null) {
- long /*int*/ newCursor = 0;
+ long newCursor = 0;
switch (cursorOrientation) {
case SWT.UP:
newCursor = OS.LoadCursor (0, OS.IDC_SIZENS);
@@ -361,8 +361,7 @@ void drawRectangles (Rectangle [] rects, boolean stippled) {
if (hwndOpaque != 0) {
RECT rect1 = new RECT();
int bandWidth = stippled ? 3 : 1;
- for (int i = 0; i < rects.length; i++) {
- Rectangle rect = rects[i];
+ for (Rectangle rect : rects) {
rect1.left = rect.x - bandWidth;
rect1.top = rect.y - bandWidth;
rect1.right = rect.x + rect.width + bandWidth * 2;
@@ -373,9 +372,9 @@ void drawRectangles (Rectangle [] rects, boolean stippled) {
return;
}
int bandWidth = 1;
- long /*int*/ hwndTrack = parent == null ? OS.GetDesktopWindow () : parent.handle;
- long /*int*/ hDC = OS.GetDCEx (hwndTrack, 0, OS.DCX_CACHE);
- long /*int*/ hBitmap = 0, hBrush = 0, oldBrush = 0;
+ long hwndTrack = parent == null ? OS.GetDesktopWindow () : parent.handle;
+ long hDC = OS.GetDCEx (hwndTrack, 0, OS.DCX_CACHE);
+ long hBitmap = 0, hBrush = 0, oldBrush = 0;
if (stippled) {
bandWidth = 3;
byte [] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
@@ -383,8 +382,7 @@ void drawRectangles (Rectangle [] rects, boolean stippled) {
hBrush = OS.CreatePatternBrush (hBitmap);
oldBrush = OS.SelectObject (hDC, hBrush);
}
- for (int i=0; i<rects.length; i++) {
- Rectangle rect = rects [i];
+ for (Rectangle rect : rects) {
OS.PatBlt (hDC, rect.x, rect.y, rect.width, bandWidth, OS.PATINVERT);
OS.PatBlt (hDC, rect.x, rect.y + bandWidth, bandWidth, rect.height - (bandWidth * 2), OS.PATINVERT);
OS.PatBlt (hDC, rect.x + rect.width - bandWidth, rect.y + bandWidth, bandWidth, rect.height - (bandWidth * 2), OS.PATINVERT);
@@ -451,9 +449,9 @@ void moveRectangles (int xChange, int yChange) {
if (yChange > 0 && ((style & SWT.DOWN) == 0)) yChange = 0;
if (xChange == 0 && yChange == 0) return;
bounds.x += xChange; bounds.y += yChange;
- for (int i = 0; i < rectangles.length; i++) {
- rectangles [i].x += xChange;
- rectangles [i].y += yChange;
+ for (Rectangle rectangle : rectangles) {
+ rectangle.x += xChange;
+ rectangle.y += yChange;
}
}
@@ -524,8 +522,7 @@ public boolean open () {
OS.SetLayeredWindowAttributes (hwndOpaque, 0xFFFFFF, (byte)0, OS.LWA_COLORKEY | OS.LWA_ALPHA);
drawn = false;
newProc = new Callback (this, "transparentProc", 4); //$NON-NLS-1$
- long /*int*/ newProcAddress = newProc.getAddress ();
- if (newProcAddress == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ long newProcAddress = newProc.getAddress ();
oldTransparentProc = OS.GetWindowLongPtr (hwndTransparent, OS.GWLP_WNDPROC);
OS.SetWindowLongPtr (hwndTransparent, OS.GWLP_WNDPROC, newProcAddress);
oldOpaqueProc = OS.GetWindowLongPtr (hwndOpaque, OS.GWLP_WNDPROC);
@@ -553,8 +550,7 @@ public boolean open () {
OS.GetModuleHandle (null),
null);
newProc = new Callback (this, "transparentProc", 4); //$NON-NLS-1$
- long /*int*/ newProcAddress = newProc.getAddress ();
- if (newProcAddress == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ long newProcAddress = newProc.getAddress ();
oldTransparentProc = OS.GetWindowLongPtr (hwndTransparent, OS.GWLP_WNDPROC);
OS.SetWindowLongPtr (hwndTransparent, OS.GWLP_WNDPROC, newProcAddress);
OS.ShowWindow (hwndTransparent, OS.SW_SHOWNOACTIVATE);
@@ -745,8 +741,7 @@ void resizeRectangles (int xChange, int yChange) {
xChange -= bounds.width;
bounds.width = 0;
if (proportions.length > 1) {
- for (int i = 0; i < proportions.length; i++) {
- Rectangle proportion = proportions [i];
+ for (Rectangle proportion : proportions) {
proportion.x = 100 - proportion.x - proportion.width;
}
}
@@ -759,8 +754,7 @@ void resizeRectangles (int xChange, int yChange) {
xChange += bounds.width;
bounds.width = 0;
if (proportions.length > 1) {
- for (int i = 0; i < proportions.length; i++) {
- Rectangle proportion = proportions [i];
+ for (Rectangle proportion : proportions) {
proportion.x = 100 - proportion.x - proportion.width;
}
}
@@ -775,8 +769,7 @@ void resizeRectangles (int xChange, int yChange) {
yChange -= bounds.height;
bounds.height = 0;
if (proportions.length > 1) {
- for (int i = 0; i < proportions.length; i++) {
- Rectangle proportion = proportions [i];
+ for (Rectangle proportion : proportions) {
proportion.y = 100 - proportion.y - proportion.height;
}
}
@@ -789,8 +782,7 @@ void resizeRectangles (int xChange, int yChange) {
yChange += bounds.height;
bounds.height = 0;
if (proportions.length > 1) {
- for (int i = 0; i < proportions.length; i++) {
- Rectangle proportion = proportions [i];
+ for (Rectangle proportion : proportions) {
proportion.y = 100 - proportion.y - proportion.height;
}
}
@@ -891,8 +883,8 @@ public void setStippled (boolean stippled) {
this.stippled = stippled;
}
-long /*int*/ transparentProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/ wParam, long /*int*/ lParam) {
- switch ((int)/*64*/msg) {
+long transparentProc (long hwnd, long msg, long wParam, long lParam) {
+ switch ((int)msg) {
/*
* We typically do not want to answer that the transparent window is
* transparent to hits since doing so negates the effect of having it
@@ -918,9 +910,9 @@ long /*int*/ transparentProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/
case OS.WM_PAINT:
if (hwndOpaque == hwnd) {
PAINTSTRUCT ps = new PAINTSTRUCT();
- long /*int*/ hDC = OS.BeginPaint (hwnd, ps);
- long /*int*/ hBitmap = 0, hBrush = 0, oldBrush = 0;
- long /*int*/ transparentBrush = OS.CreateSolidBrush(0xFFFFFF);
+ long hDC = OS.BeginPaint (hwnd, ps);
+ long hBitmap = 0, hBrush = 0, oldBrush = 0;
+ long transparentBrush = OS.CreateSolidBrush(0xFFFFFF);
oldBrush = OS.SelectObject (hDC, transparentBrush);
OS.PatBlt (hDC, ps.left, ps.top, ps.right - ps.left, ps.bottom - ps.top, OS.PATCOPY);
OS.SelectObject (hDC, oldBrush);
@@ -936,10 +928,8 @@ long /*int*/ transparentProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/
} else {
oldBrush = OS.SelectObject (hDC, OS.GetStockObject(OS.BLACK_BRUSH));
}
- Rectangle[] rects = this.rectangles;
RECT rect1 = new RECT ();
- for (int i=0; i<rects.length; i++) {
- Rectangle rect = rects [i];
+ for (Rectangle rect : this.rectangles) {
rect1.left = rect.x;
rect1.top = rect.y;
rect1.right = rect.x + rect.width;
@@ -965,7 +955,7 @@ long /*int*/ transparentProc (long /*int*/ hwnd, long /*int*/ msg, long /*int*/
return 0;
}
}
- return OS.CallWindowProc (hwnd == hwndTransparent ? oldTransparentProc : oldOpaqueProc, hwnd, (int)/*64*/msg, wParam, lParam);
+ return OS.CallWindowProc (hwnd == hwndTransparent ? oldTransparentProc : oldOpaqueProc, hwnd, (int)msg, wParam, lParam);
}
void update () {
@@ -980,13 +970,13 @@ void update () {
}
@Override
-LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmKeyDown (long hwnd, long wParam, long lParam) {
LRESULT result = super.wmKeyDown (hwnd, wParam, lParam);
if (result != null) return result;
boolean isMirrored = parent != null && (parent.style & SWT.MIRRORED) != 0;
int stepSize = OS.GetKeyState (OS.VK_CONTROL) < 0 ? STEPSIZE_SMALL : STEPSIZE_LARGE;
int xChange = 0, yChange = 0;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_ESCAPE:
cancelled = true;
tracking = false;
@@ -1114,7 +1104,7 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
}
@Override
-LRESULT wmSysKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmSysKeyDown (long hwnd, long wParam, long lParam) {
LRESULT result = super.wmSysKeyDown (hwnd, wParam, lParam);
if (result != null) return result;
cancelled = true;
@@ -1122,7 +1112,7 @@ LRESULT wmSysKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lPara
return result;
}
-LRESULT wmMouse (int message, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmMouse (int message, long wParam, long lParam) {
boolean isMirrored = parent != null && (parent.style & SWT.MIRRORED) != 0;
int newPos = OS.GetMessagePos ();
int newX = OS.GET_X_LPARAM (newPos);
@@ -1139,9 +1129,9 @@ LRESULT wmMouse (int message, long /*int*/ wParam, long /*int*/ lParam) {
event.setLocationInPixels(newX, newY);
if ((style & SWT.RESIZE) != 0) {
if (isMirrored) {
- resizeRectangles (oldX - newX, newY - oldY);
+ resizeRectangles (oldX - newX, newY - oldY);
} else {
- resizeRectangles (newX - oldX, newY - oldY);
+ resizeRectangles (newX - oldX, newY - oldY);
}
inEvent = true;
sendEvent (SWT.Resize, event);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java
index 2126b9ca37..ea39f2614c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java
@@ -262,7 +262,7 @@ public boolean getVisible () {
return visible;
}
-long /*int*/ messageProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long messageProc (long hwnd, int msg, long wParam, long lParam) {
/*
* Feature in Windows. When the user clicks on the tray
* icon, another application may be the foreground window.
@@ -274,7 +274,7 @@ long /*int*/ messageProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long
* menu is not hidden. The fix is to force the tray icon
* message window to the foreground when sending an event.
*/
- switch ((int)/*64*/lParam) {
+ switch ((int)lParam) {
case OS.WM_LBUTTONDOWN:
if (hooks (SWT.Selection)) {
OS.SetForegroundWindow (hwnd);
@@ -459,7 +459,7 @@ public void setImage (Image image) {
super.setImage (image);
if (image2 != null) image2.dispose ();
image2 = null;
- long /*int*/ hIcon = 0;
+ long hIcon = 0;
Image icon = image;
if (icon != null) {
switch (icon.type) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
index 877edcd18d..7334a6698e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -64,7 +64,7 @@ import org.eclipse.swt.internal.win32.*;
* <dt><b>Styles:</b></dt>
* <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, VIRTUAL, NO_SCROLL</dd>
* <dt><b>Events:</b></dt>
- * <dd>Selection, DefaultSelection, Collapse, Expand, SetData, MeasureItem, EraseItem, PaintItem</dd>
+ * <dd>Selection, DefaultSelection, Collapse, Expand, SetData, MeasureItem, EraseItem, PaintItem, EmptinessChanged</dd>
* </dl>
* <p>
* Note: Only one of the styles SINGLE and MULTI may be specified.
@@ -85,9 +85,9 @@ public class Tree extends Composite {
TreeItem currentItem;
TreeColumn sortColumn;
RECT focusRect;
- long /*int*/ hwndParent, hwndHeader, hAnchor, hInsert, hSelect;
+ long hwndParent, hwndHeader, hAnchor, hInsert, hSelect;
int lastID;
- long /*int*/ hFirstIndexOf, hLastIndexOf;
+ long hFirstIndexOf, hLastIndexOf;
int lastIndexOf, itemCount, sortDirection;
boolean dragStarted, gestureCompleted, insertAfter, shrink, ignoreShrink;
boolean ignoreSelect, ignoreExpand, ignoreDeselect, ignoreResize;
@@ -98,8 +98,8 @@ public class Tree extends Composite {
boolean createdAsRTL;
boolean headerItemDragging;
int scrollWidth, selectionForeground;
- long /*int*/ headerToolTipHandle, itemToolTipHandle;
- long /*int*/ lastTimerID = -1;
+ long headerToolTipHandle, itemToolTipHandle;
+ long lastTimerID = -1;
int lastTimerCount;
int headerBackground = -1;
int headerForeground = -1;
@@ -113,9 +113,9 @@ public class Tree extends Composite {
static final int INCREMENT = 5;
static final int EXPLORER_EXTRA = 2;
static final int DRAG_IMAGE_SIZE = 301;
- static final long /*int*/ TreeProc;
+ static final long TreeProc;
static final TCHAR TreeClass = new TCHAR (0, OS.WC_TREEVIEW, true);
- static final long /*int*/ HeaderProc;
+ static final long HeaderProc;
static final TCHAR HeaderClass = new TCHAR (0, OS.WC_HEADER, true);
static {
WNDCLASS lpWndClass = new WNDCLASS ();
@@ -205,14 +205,6 @@ void _addListener (int eventType, Listener listener) {
OS.SendMessage (handle, OS.TVM_SETSCROLLTIME, 0, 0);
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
if (eventType == SWT.MeasureItem) {
- /*
- * This code is intentionally commented.
- */
-// if (explorerTheme) {
-// int bits1 = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETEXTENDEDSTYLE, 0, 0);
-// bits1 &= ~OS.TVS_EX_AUTOHSCROLL;
-// OS.SendMessage (handle, OS.TVM_SETEXTENDEDSTYLE, 0, bits1);
-// }
bits |= OS.TVS_NOHSCROLL;
}
/*
@@ -236,7 +228,7 @@ void _addListener (int eventType, Listener listener) {
* scroll bar. The fix is to check for this case and
* explicitly hide the scroll bar.
*/
- int count = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
if (count != 0 && (bits & OS.TVS_NOHSCROLL) != 0) {
OS.ShowScrollBar (handle, OS.SB_HORZ, false);
}
@@ -246,17 +238,17 @@ void _addListener (int eventType, Listener listener) {
}
}
-TreeItem _getItem (long /*int*/ hItem) {
+TreeItem _getItem (long hItem) {
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
tvItem.hItem = hItem;
if (OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem) != 0) {
- return _getItem (tvItem.hItem, (int)/*64*/tvItem.lParam);
+ return _getItem (tvItem.hItem, (int)tvItem.lParam);
}
return null;
}
-TreeItem _getItem (long /*int*/ hItem, int id) {
+TreeItem _getItem (long hItem, int id) {
if ((style & SWT.VIRTUAL) == 0) return items [id];
return id != -1 ? items [id] : new TreeItem (this, SWT.NONE, -1, -1, hItem);
}
@@ -282,7 +274,7 @@ void _removeListener (int eventType, Listener listener) {
}
void _setBackgroundPixel (int newPixel) {
- int oldPixel = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETBKCOLOR, 0, 0);
+ int oldPixel = (int)OS.SendMessage (handle, OS.TVM_GETBKCOLOR, 0, 0);
if (oldPixel != newPixel) {
/*
* Bug in Windows. When TVM_SETBKCOLOR is used more
@@ -305,7 +297,7 @@ void _setBackgroundPixel (int newPixel) {
* animation draws badly. The fix is to clear the effect.
*/
if (explorerTheme && ENABLE_TVS_EX_FADEINOUTEXPANDOS) {
- int bits2 = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETEXTENDEDSTYLE, 0, 0);
+ int bits2 = (int)OS.SendMessage (handle, OS.TVM_GETEXTENDEDSTYLE, 0, 0);
if (newPixel == -1 && findImageControl () == null) {
bits2 |= OS.TVS_EX_FADEINOUTEXPANDOS;
} else {
@@ -382,14 +374,14 @@ public void addTreeListener(TreeListener listener) {
}
@Override
-long /*int*/ borderHandle () {
+long borderHandle () {
return hwndParent != 0 ? hwndParent : handle;
}
-LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) {
if (ignoreCustomDraw) return null;
if (nmcd.left == nmcd.right) return new LRESULT (OS.CDRF_DODEFAULT);
- long /*int*/ hDC = nmcd.hdc;
+ long hDC = nmcd.hdc;
OS.RestoreDC (hDC, -1);
TreeItem item = getItem (nmcd);
@@ -427,11 +419,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
if (explorerTheme) {
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
if ((bits & OS.TVS_TRACKSELECT) != 0) {
- if ((style & SWT.FULL_SELECTION) != 0 && (selected || hot)) {
- OS.SetTextColor (hDC, OS.GetSysColor (OS.COLOR_WINDOWTEXT));
- } else {
- OS.SetTextColor (hDC, getForegroundPixel ());
- }
+ OS.SetTextColor (hDC, getForegroundPixel ());
}
}
}
@@ -504,7 +492,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
}
}
draw = false;
- long /*int*/ hTheme = OS.OpenThemeData (handle, Display.TREEVIEW);
+ long hTheme = OS.OpenThemeData (handle, Display.TREEVIEW);
int iStateId = selected ? OS.TREIS_SELECTED : OS.TREIS_HOT;
if (OS.GetFocus () != handle && selected && !hot) iStateId = OS.TREIS_SELECTEDNOTFOCUS;
OS.DrawThemeBackground (hTheme, hDC, OS.TVP_TREEITEM, iStateId, pRect, pClipRect);
@@ -574,7 +562,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
backgroundRect = rect;
}
int clrText = -1, clrTextBk = -1;
- long /*int*/ hFont = item.fontHandle (index);
+ long hFont = item.fontHandle (index);
if (selectionForeground != -1) clrText = selectionForeground;
if (OS.IsWindowEnabled (handle)) {
boolean drawForeground = false;
@@ -632,7 +620,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
if (clrTextBk != -1) data.background = clrTextBk;
}
data.font = item.getFont (index);
- data.uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ data.uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
GC gc = GC.win32_new (hDC, data);
Event event = new Event ();
event.item = item;
@@ -647,7 +635,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
//if ((nmcd.uItemState & OS.CDIS_FOCUS) != 0) {
if (OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0) == nmcd.dwItemSpec) {
if (handle == OS.GetFocus ()) {
- int uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ int uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
if ((uiState & OS.UISF_HIDEFOCUS) == 0) event.detail |= SWT.FOCUSED;
}
}
@@ -717,7 +705,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
backgroundRect = selectionRect;
}
}
- long /*int*/ hTheme = OS.OpenThemeData (handle, Display.TREEVIEW);
+ long hTheme = OS.OpenThemeData (handle, Display.TREEVIEW);
int iStateId = selected ? OS.TREIS_SELECTED : OS.TREIS_HOT;
if (OS.GetFocus () != handle && selected && !hot) iStateId = OS.TREIS_SELECTEDNOTFOCUS;
OS.DrawThemeBackground (hTheme, hDC, OS.TVP_TREEITEM, iStateId, pRect, backgroundRect);
@@ -772,7 +760,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
if (size == null) size = DPIUtil.autoScaleDown (getImageSize ()); // To Points
if (!ignoreDrawForeground) {
//int y1 = rect.top + (index == 0 ? (getItemHeight () - size.y) / 2 : 0);
- int y1 = rect.top;
+ int y1 = rect.top + DPIUtil.autoScaleUp((getItemHeight () - size.y) / 2);
int x1 = Math.max (rect.left, rect.left - inset + 1);
GCData data = new GCData();
data.device = display;
@@ -782,7 +770,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
OS.SelectClipRgn (hDC, 0);
gc.dispose ();
}
- OS.SetRect (rect, rect.left + size.x + offset, rect.top, rect.right - inset, rect.bottom);
+ OS.SetRect (rect, rect.left + DPIUtil.autoScaleUp(size.x) + offset, rect.top, rect.right - inset, rect.bottom);
} else {
if (i == 0) {
if (OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0) != 0) {
@@ -848,7 +836,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
if (clrText != -1) data.foreground = clrText;
if (clrTextBk != -1) data.background = clrTextBk;
}
- data.uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ data.uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
GC gc = GC.win32_new (hDC, data);
Event event = new Event ();
event.item = item;
@@ -865,7 +853,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
if (OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0) == nmcd.dwItemSpec) {
if (i == 0 /*nmcd.iSubItem == 0*/ || (style & SWT.FULL_SELECTION) != 0) {
if (handle == OS.GetFocus ()) {
- int uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ int uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
if ((uiState & OS.UISF_HIDEFOCUS) == 0) event.detail |= SWT.FOCUSED;
}
}
@@ -908,9 +896,9 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
} else {
if (!explorerTheme) {
if (handle == OS.GetFocus ()) {
- int uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ int uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
if ((uiState & OS.UISF_HIDEFOCUS) == 0) {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (hItem == item.handle) {
if (!ignoreDrawFocus && findImageControl () != null) {
if ((style & SWT.FULL_SELECTION) != 0) {
@@ -918,7 +906,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
OS.SetRect (focusRect, 0, nmcd.top, clientRect.right + 1, nmcd.bottom);
OS.DrawFocusRect (hDC, focusRect);
} else {
- int index = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
+ int index = (int)OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
RECT focusRect = item.getBounds (index, true, false, false, false, false, hDC);
RECT clipRect = item.getBounds (index, true, false, false, false, true, hDC);
OS.IntersectClipRect (hDC, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
@@ -934,7 +922,7 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int
return new LRESULT (OS.CDRF_DODEFAULT);
}
-LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) {
/*
* Even when custom draw is being ignored, the font needs
* to be selected into the HDC so that the item bounds are
@@ -952,9 +940,9 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
* COMCTL32.DLL,
*/
if (item == null) return null;
- long /*int*/ hDC = nmcd.hdc;
- int index = hwndHeader != 0 ? (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0) : 0;
- long /*int*/ hFont = item.fontHandle (index);
+ long hDC = nmcd.hdc;
+ int index = hwndHeader != 0 ? (int)OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0) : 0;
+ long hFont = item.fontHandle (index);
if (hFont != -1) OS.SelectObject (hDC, hFont);
if (ignoreCustomDraw || nmcd.left == nmcd.right) {
return new LRESULT (hFont == -1 ? OS.CDRF_DODEFAULT : OS.CDRF_NEWFONT);
@@ -1031,7 +1019,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
if (clrText != -1) data.foreground = clrText;
if (clrTextBk != -1) data.background = clrTextBk;
}
- data.uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ data.uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
data.font = item.getFont (index);
GC gc = GC.win32_new (hDC, data);
Event event = new Event ();
@@ -1045,7 +1033,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
//if ((nmcd.uItemState & OS.CDIS_FOCUS) != 0) {
if (OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0) == nmcd.dwItemSpec) {
if (handle == OS.GetFocus ()) {
- int uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ int uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
if ((uiState & OS.UISF_HIDEFOCUS) == 0) {
if (!explorerTheme || !selected) {
focused = true;
@@ -1109,7 +1097,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
}
pRect.left -= EXPLORER_EXTRA;
pClipRect.left -= EXPLORER_EXTRA;
- long /*int*/ hTheme = OS.OpenThemeData (handle, Display.TREEVIEW);
+ long hTheme = OS.OpenThemeData (handle, Display.TREEVIEW);
int iStateId = selected ? OS.TREIS_SELECTED : OS.TREIS_HOT;
if (OS.GetFocus () != handle && selected && !hot) iStateId = OS.TREIS_SELECTEDNOTFOCUS;
OS.DrawThemeBackground (hTheme, hDC, OS.TVP_TREEITEM, iStateId, pRect, pClipRect);
@@ -1324,7 +1312,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
}
OS.SaveDC (hDC);
if (clipRect != null) {
- long /*int*/ hRgn = OS.CreateRectRgn (clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
+ long hRgn = OS.CreateRectRgn (clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
POINT lpPoint = new POINT ();
OS.GetWindowOrgEx (hDC, lpPoint);
OS.OffsetRgn (hRgn, -lpPoint.x, -lpPoint.y);
@@ -1334,7 +1322,7 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*
return result;
}
-LRESULT CDDS_POSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT CDDS_POSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) {
if (ignoreCustomDraw) return null;
if (OS.IsWindowVisible (handle)) {
if (OS.IsAppThemed ()) {
@@ -1359,7 +1347,7 @@ LRESULT CDDS_POSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ l
* NOTE: This problem only happens on Vista during
* WM_NOTIFY with NM_CUSTOMDRAW and CDDS_POSTPAINT.
*/
- long /*int*/ hItem = 0;
+ long hItem = 0;
if (OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
hItem = getBottomItem ();
} else {
@@ -1383,14 +1371,14 @@ LRESULT CDDS_POSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ l
}
}
if (linesVisible) {
- long /*int*/ hDC = nmcd.hdc;
+ long hDC = nmcd.hdc;
if (hwndHeader != 0) {
int x = 0;
RECT rect = new RECT ();
HDITEM hdItem = new HDITEM ();
hdItem.mask = OS.HDI_WIDTH;
for (int i=0; i<columnCount; i++) {
- int index = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, i, 0);
+ int index = (int)OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, i, 0);
OS.SendMessage (hwndHeader, OS.HDM_GETITEM, index, hdItem);
OS.SetRect (rect, x, nmcd.top, x + hdItem.cxy, nmcd.bottom);
OS.DrawEdge (hDC, rect, OS.BDR_SUNKENINNER, OS.BF_RIGHT);
@@ -1415,7 +1403,7 @@ LRESULT CDDS_POSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ l
* NOTE: This problem only happens on Vista during
* WM_NOTIFY with NM_CUSTOMDRAW and CDDS_POSTPAINT.
*/
- long /*int*/ hItem = 0;
+ long hItem = 0;
if (OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
hItem = getBottomItem ();
} else {
@@ -1427,7 +1415,7 @@ LRESULT CDDS_POSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ l
}
}
if (height == 0) {
- height = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMHEIGHT, 0, 0);
+ height = (int)OS.SendMessage (handle, OS.TVM_GETITEMHEIGHT, 0, 0);
OS.GetClientRect (handle, rect);
OS.SetRect (rect, rect.left, rect.top, rect.right, rect.top + height);
OS.DrawEdge (hDC, rect, OS.BDR_SUNKENINNER, OS.BF_BOTTOM);
@@ -1444,7 +1432,7 @@ LRESULT CDDS_POSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ l
return new LRESULT (OS.CDRF_DODEFAULT);
}
-LRESULT CDDS_PREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT CDDS_PREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) {
if (explorerTheme) {
if ((OS.IsWindowEnabled (handle) && hooks (SWT.EraseItem)) || hasCustomBackground() || findImageControl () != null) {
RECT rect = new RECT ();
@@ -1456,7 +1444,7 @@ LRESULT CDDS_PREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lP
}
@Override
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
if (handle == 0) return 0;
if (hwndParent != 0 && hwnd == hwndParent) {
return OS.DefWindowProc (hwnd, msg, wParam, lParam);
@@ -1475,7 +1463,7 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
* only the focus is assigned.
*/
if ((style & SWT.SINGLE) != 0) break;
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (hItem == 0) {
hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
if (hItem != 0) {
@@ -1496,7 +1484,7 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
break;
}
}
- long /*int*/ hItem = 0;
+ long hItem = 0;
boolean redraw = false;
switch (msg) {
/* Keyboard messages */
@@ -1551,7 +1539,7 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
break;
}
}
- long /*int*/ code = OS.CallWindowProc (TreeProc, hwnd, msg, wParam, lParam);
+ long code = OS.CallWindowProc (TreeProc, hwnd, msg, wParam, lParam);
switch (msg) {
/* Keyboard messages */
case OS.WM_KEYDOWN:
@@ -1625,7 +1613,7 @@ void checkBuffered () {
OS.SendMessage (handle, OS.TVM_SETSCROLLTIME, 0, 0);
}
if (OS.IsAppThemed ()) {
- int exStyle = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETEXTENDEDSTYLE, 0, 0);
+ int exStyle = (int)OS.SendMessage (handle, OS.TVM_GETEXTENDEDSTYLE, 0, 0);
if ((exStyle & OS.TVS_EX_DOUBLEBUFFER) != 0) style |= SWT.DOUBLE_BUFFERED;
}
}
@@ -1654,7 +1642,7 @@ boolean checkData (TreeItem item, int index, boolean redraw) {
* is to detect that the top item has changed and redraw
* the entire tree.
*/
- long /*int*/ hTopItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+ long hTopItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
sendEvent (SWT.SetData, event);
//widget could be disposed at this point
currentItem = oldItem;
@@ -1667,12 +1655,7 @@ boolean checkData (TreeItem item, int index, boolean redraw) {
return true;
}
-@Override
-boolean checkHandle (long /*int*/ hwnd) {
- return hwnd == handle || (hwndParent != 0 && hwnd == hwndParent) || (hwndHeader != 0 && hwnd == hwndHeader);
-}
-
-boolean checkScroll (long /*int*/ hItem) {
+boolean checkScroll (long hItem) {
/*
* Feature in Windows. If redraw is turned off using WM_SETREDRAW
* and a tree item that is not a child of the first root is selected or
@@ -1685,8 +1668,8 @@ boolean checkScroll (long /*int*/ hItem) {
* callers of this method.
*/
if (getDrawing ()) return false;
- long /*int*/ hRoot = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
- long /*int*/ hParent = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hItem);
+ long hRoot = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hParent = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hItem);
while (hParent != hRoot && hParent != 0) {
hParent = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hParent);
}
@@ -1723,7 +1706,7 @@ protected void checkSubclass () {
*/
public void clear (int index, boolean all) {
checkWidget ();
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
if (hItem == 0) error (SWT.ERROR_INVALID_RANGE);
hItem = findItem (hItem, index);
if (hItem == 0) error (SWT.ERROR_INVALID_RANGE);
@@ -1736,11 +1719,11 @@ public void clear (int index, boolean all) {
}
}
-void clear (long /*int*/ hItem, TVITEM tvItem) {
+void clear (long hItem, TVITEM tvItem) {
tvItem.hItem = hItem;
TreeItem item = null;
if (OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem) != 0) {
- item = tvItem.lParam != -1 ? items [(int)/*64*/tvItem.lParam] : null;
+ item = tvItem.lParam != -1 ? items [(int)tvItem.lParam] : null;
}
if (item != null) {
if ((style & SWT.VIRTUAL) != 0 && !item.cached) return;
@@ -1770,12 +1753,11 @@ void clear (long /*int*/ hItem, TVITEM tvItem) {
*/
public void clearAll (boolean all) {
checkWidget ();
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
if (hItem == 0) return;
if (all) {
boolean redraw = false;
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
+ for (TreeItem item : items) {
if (item != null && item != currentItem) {
item.clear ();
redraw = true;
@@ -1789,20 +1771,20 @@ public void clearAll (boolean all) {
}
}
-void clearAll (long /*int*/ hItem, TVITEM tvItem, boolean all) {
+void clearAll (long hItem, TVITEM tvItem, boolean all) {
while (hItem != 0) {
clear (hItem, tvItem);
if (all) {
- long /*int*/ hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
+ long hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
clearAll (hFirstItem, tvItem, all);
}
hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);
}
}
-long /*int*/ CompareFunc (long /*int*/ lParam1, long /*int*/ lParam2, long /*int*/ lParamSort) {
- TreeItem item1 = items [(int)/*64*/lParam1], item2 = items [(int)/*64*/lParam2];
- String text1 = item1.getText ((int)/*64*/lParamSort), text2 = item2.getText ((int)/*64*/lParamSort);
+long CompareFunc (long lParam1, long lParam2, long lParamSort) {
+ TreeItem item1 = items [(int)lParam1], item2 = items [(int)lParam2];
+ String text1 = item1.getText ((int)lParamSort), text2 = item2.getText ((int)lParamSort);
return sortDirection == SWT.UP ? text1.compareTo (text2) : text2.compareTo (text1);
}
@@ -1820,7 +1802,7 @@ long /*int*/ CompareFunc (long /*int*/ lParam1, long /*int*/ lParam2, long /*int
height += rect.bottom - rect.top;
}
RECT rect = new RECT ();
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
while (hItem != 0) {
if ((style & SWT.VIRTUAL) == 0 && !painted) {
TVITEM tvItem = new TVITEM ();
@@ -1864,10 +1846,6 @@ void createHandle () {
OS.SetWindowTheme (handle, Display.EXPLORER, null);
int bits = OS.TVS_EX_DOUBLEBUFFER | OS.TVS_EX_RICHTOOLTIP;
if (ENABLE_TVS_EX_FADEINOUTEXPANDOS) bits |= OS.TVS_EX_FADEINOUTEXPANDOS;
- /*
- * This code is intentionally commented.
- */
-// if ((style & SWT.FULL_SELECTION) == 0) bits |= OS.TVS_EX_AUTOHSCROLL;
OS.SendMessage (handle, OS.TVM_SETEXTENDEDSTYLE, 0, bits);
/*
* Bug in Windows. When the tree is using the explorer
@@ -1893,7 +1871,7 @@ void createHandle () {
* The control will not destroy a font that it did not
* create.
*/
- long /*int*/ hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ long hFont = OS.GetStockObject (OS.SYSTEM_FONT);
OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);
/*
@@ -1923,6 +1901,7 @@ void createHeaderToolTips () {
OS.GetModuleHandle (null),
null);
if (headerToolTipHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ maybeEnableDarkSystemTheme(headerToolTipHandle);
/*
* Feature in Windows. Despite the fact that the
* tool tip text contains \r\n, the tooltip will
@@ -1941,8 +1920,7 @@ void createItem (TreeColumn column, int index) {
System.arraycopy (columns, 0, newColumns, 0, columns.length);
columns = newColumns;
}
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
+ for (TreeItem item : items) {
if (item != null) {
String [] strings = item.strings;
if (strings != null) {
@@ -2006,8 +1984,8 @@ void createItem (TreeColumn column, int index) {
* if is not possible to set the text at a later time.
* The fix is to insert the item with an empty string.
*/
- long /*int*/ hHeap = OS.GetProcessHeap ();
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof);
+ long hHeap = OS.GetProcessHeap ();
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof);
HDITEM hdItem = new HDITEM ();
hdItem.mask = OS.HDI_TEXT | OS.HDI_FORMAT;
hdItem.pszText = pszText;
@@ -2031,7 +2009,7 @@ void createItem (TreeColumn column, int index) {
* scroll bar. The fix is to check for this case and
* explicitly hide the scroll bar explicitly.
*/
- int count = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
if (count != 0) {
OS.ShowScrollBar (handle, OS.SB_HORZ, false);
}
@@ -2068,7 +2046,11 @@ void createItem (TreeColumn column, int index) {
}
}
-void createItem (TreeItem item, long /*int*/ hParent, long /*int*/ hInsertAfter, long /*int*/ hItem) {
+/**
+ * The fastest way to insert many items is documented in {@link TreeItem#TreeItem(Tree,int,int)}
+ * and {@link TreeItem#setItemCount}
+ */
+void createItem (TreeItem item, long hParent, long hInsertAfter, long hItem) {
int id = -1;
if (item != null) {
id = lastID < items.length ? lastID : 0;
@@ -2087,14 +2069,13 @@ void createItem (TreeItem item, long /*int*/ hParent, long /*int*/ hInsertAfter,
shrink = true;
length = Math.max (4, items.length * 3 / 2);
}
- TreeItem [] newItems = new TreeItem [length];
- System.arraycopy (items, 0, newItems, 0, items.length);
- items = newItems;
+
+ itemsGrowArray (length);
}
lastID = id + 1;
}
- long /*int*/ hNewItem = 0;
- long /*int*/ hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hParent);
+ long hNewItem = 0;
+ long hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hParent);
boolean fixParent = hFirstItem == 0;
if (hItem == 0) {
TVINSERTSTRUCT tvInsert = new TVINSERTSTRUCT ();
@@ -2113,14 +2094,6 @@ void createItem (TreeItem item, long /*int*/ hParent, long /*int*/ hInsertAfter,
hNewItem = OS.SendMessage (handle, OS.TVM_INSERTITEM, 0, tvInsert);
ignoreCustomDraw = false;
if (hNewItem == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
- /*
- * This code is intentionally commented.
- */
-// if (hParent != 0) {
-// int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
-// bits |= OS.TVS_LINESATROOT;
-// OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
-// }
} else {
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
@@ -2141,13 +2114,14 @@ void createItem (TreeItem item, long /*int*/ hParent, long /*int*/ hInsertAfter,
if (hFirstItem == hFirstIndexOf && itemCount != -1) itemCount++;
if (hItem == 0) {
/*
- * Bug in Windows. When a child item is added to a parent item
- * that has no children outside of WM_NOTIFY with control code
- * TVN_ITEMEXPANDED, the tree widget does not redraw the +/-
- * indicator. The fix is to detect the case when the first
- * child is added to a visible parent item and redraw the parent.
+ * Bug in Windows. When a child item is added to a collapsed
+ * parent item that has no children, Tree does not draw [-]
+ * indicator and the parent item continues to look as if it
+ * has no children. Reportedly this doesn't happen when item
+ * is added during WM_NOTIFY(TVN_ITEMEXPANDED). The workaround
+ * is to force redraw parent item.
*/
- if (fixParent) {
+ if (fixParent && (hParent != OS.TVI_ROOT)) {
if (getDrawing () && OS.IsWindowVisible (handle)) {
RECT rect = new RECT ();
if (OS.TreeView_GetItemRect (handle, hParent, rect, false)) {
@@ -2169,7 +2143,7 @@ void createItem (TreeItem item, long /*int*/ hParent, long /*int*/ hInsertAfter,
RECT damageRect = new RECT ();
boolean damaged = OS.GetUpdateRect (handle, damageRect, true);
if (damaged && damageRect.top < rect.bottom) {
- long /*int*/ rgn = OS.CreateRectRgn (0, 0, 0, 0);
+ long rgn = OS.CreateRectRgn (0, 0, 0, 0);
int result = OS.GetUpdateRgn (handle, rgn, true);
if (result != OS.NULLREGION) {
OS.OffsetRgn (rgn, 0, rect.bottom - rect.top);
@@ -2180,7 +2154,21 @@ void createItem (TreeItem item, long /*int*/ hParent, long /*int*/ hInsertAfter,
}
}
}
- updateScrollBar ();
+
+ /*
+ Note: Don't update scrollbars when drawing is disabled.
+ This gives significant improvement for bulk insert scenarios.
+ Later, setRedraw(true) will update scrollbars once.
+ */
+ if (getDrawing ()) updateScrollBar ();
+ /*
+ If this is the first item added fire an EmptinessChanged event.
+ */
+ if (item != null && id == 0) {
+ Event event = new Event ();
+ event.detail = 0;
+ sendEvent (SWT.EmptinessChanged, event);
+ }
}
}
@@ -2210,6 +2198,7 @@ void createItemToolTips () {
OS.GetModuleHandle (null),
null);
if (itemToolTipHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ maybeEnableDarkSystemTheme(itemToolTipHandle);
OS.SendMessage (itemToolTipHandle, OS.TTM_SETDELAYTIME, OS.TTDT_INITIAL, 0);
/*
* Feature in Windows. Despite the fact that the
@@ -2228,15 +2217,36 @@ void createItemToolTips () {
OS.SendMessage (itemToolTipHandle, OS.TTM_ADDTOOL, 0, lpti);
}
+/**
+ * On Windows, Tree does not support columns. The workaround is to emulate it
+ * by adding a Header control and custom-drawing Tree items.
+ *
+ * Creates Header (for columns) and wraps (Tree+Header) into an intermediate
+ * parent, so that (Tree+Header) behave as one whole. The wrapper is designed
+ * to mimic original Tree as much as possible. For that reason, all sorts of
+ * settings are copied over.
+ */
void createParent () {
forceResize ();
+
+ /* Copy Tree position to hwndParent */
RECT rect = new RECT ();
OS.GetWindowRect (handle, rect);
OS.MapWindowPoints (0, parent.handle, rect, 2);
- int oldStyle = OS.GetWindowLong (handle, OS.GWL_STYLE);
- int newStyle = super.widgetStyle () & ~OS.WS_VISIBLE;
+
+ /* Copy Tree styles to hwndParent */
+ final int oldStyle = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int newStyle = super.widgetStyle ();
+ newStyle &= ~OS.WS_VISIBLE; /* Show control once everything is configured */
if ((oldStyle & OS.WS_DISABLED) != 0) newStyle |= OS.WS_DISABLED;
-// if ((oldStyle & OS.WS_VISIBLE) != 0) newStyle |= OS.WS_VISIBLE;
+
+ /* Get rid of internal borders; hwndParent will have the borders now */
+ if ((oldStyle & OS.WS_BORDER) != 0) {
+ int noBorderStyle = oldStyle & ~OS.WS_BORDER;
+ OS.SetWindowLong (handle, OS.GWL_STYLE, noBorderStyle);
+ }
+
+ /* Create hwndParent */
hwndParent = OS.CreateWindowEx (
super.widgetExtStyle (),
super.windowClass (),
@@ -2251,7 +2261,14 @@ void createParent () {
OS.GetModuleHandle (null),
null);
if (hwndParent == 0) error (SWT.ERROR_NO_HANDLES);
+
+ /* Old code, not sure if needed */
OS.SetWindowLongPtr (hwndParent, OS.GWLP_ID, hwndParent);
+
+ /* Copy dark scrollbar settings to hwndParent */
+ maybeEnableDarkSystemTheme(hwndParent);
+
+ /* Create header */
int bits = OS.WS_EX_NOINHERITLAYOUT;
if ((style & SWT.RIGHT_TO_LEFT) != 0) bits |= OS.WS_EX_LAYOUTRTL;
hwndHeader = OS.CreateWindowEx (
@@ -2265,26 +2282,21 @@ void createParent () {
OS.GetModuleHandle (null),
null);
if (hwndHeader == 0) error (SWT.ERROR_NO_HANDLES);
+
+ /* Old code, not sure if needed */
OS.SetWindowLongPtr (hwndHeader, OS.GWLP_ID, hwndHeader);
- if (OS.IsDBLocale) {
- long /*int*/ hIMC = OS.ImmGetContext (handle);
- OS.ImmAssociateContext (hwndParent, hIMC);
- OS.ImmAssociateContext (hwndHeader, hIMC);
- OS.ImmReleaseContext (handle, hIMC);
- }
- //This code is intentionally commented
-// if (!OS.IsPPC) {
-// if ((style & SWT.BORDER) != 0) {
-// int oldExStyle = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
-// oldExStyle &= ~OS.WS_EX_CLIENTEDGE;
-// OS.SetWindowLong (handle, OS.GWL_EXSTYLE, oldExStyle);
-// }
-// }
- long /*int*/ hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+
+ maybeEnableDarkSystemTheme(hwndHeader);
+ /* Copy Tree's font to header */
+ long hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (hFont != 0) OS.SendMessage (hwndHeader, OS.WM_SETFONT, hFont, 0);
- long /*int*/ hwndInsertAfter = OS.GetWindow (handle, OS.GW_HWNDPREV);
+
+ /* Copy Tree's tab-order to hwndParent */
+ long hwndInsertAfter = OS.GetWindow (handle, OS.GW_HWNDPREV);
int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
OS.SetWindowPos (hwndParent, hwndInsertAfter, 0, 0, 0, 0, flags);
+
+ /* Copy Tree's scrollbar settings to hwndParent */
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
info.fMask = OS.SIF_RANGE | OS.SIF_PAGE;
@@ -2294,12 +2306,16 @@ void createParent () {
OS.GetScrollInfo (hwndParent, OS.SB_VERT, info);
info.nPage = info.nMax + 1;
OS.SetScrollInfo (hwndParent, OS.SB_VERT, info, true);
+
+ /* Columns are emulated by custom drawing items */
customDraw = true;
+
deregister ();
if ((oldStyle & OS.WS_VISIBLE) != 0) {
+ /* All set, show the new hwndParent wrapper */
OS.ShowWindow (hwndParent, OS.SW_SHOW);
}
- long /*int*/ hwndFocus = OS.GetFocus ();
+ long hwndFocus = OS.GetFocus ();
if (hwndFocus == handle) OS.SetFocus (hwndParent);
OS.SetParent (handle, hwndParent);
if (hwndFocus == handle) OS.SetFocus (handle);
@@ -2331,13 +2347,13 @@ void deregister () {
if (hwndHeader != 0) display.removeControl (hwndHeader);
}
-void deselect (long /*int*/ hItem, TVITEM tvItem, long /*int*/ hIgnoreItem) {
+void deselect (long hItem, TVITEM tvItem, long hIgnoreItem) {
while (hItem != 0) {
if (hItem != hIgnoreItem) {
tvItem.hItem = hItem;
OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
}
- long /*int*/ hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
+ long hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
deselect (hFirstItem, tvItem, hIgnoreItem);
hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);
}
@@ -2385,20 +2401,19 @@ public void deselectAll () {
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
tvItem.stateMask = OS.TVIS_SELECTED;
if ((style & SWT.SINGLE) != 0) {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (hItem != 0) {
tvItem.hItem = hItem;
OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
}
} else {
- long /*int*/ oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
+ long oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, TreeProc);
if ((style & SWT.VIRTUAL) != 0) {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
deselect (hItem, tvItem, 0);
} else {
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
+ for (TreeItem item : items) {
if (item != null) {
tvItem.hItem = item.handle;
OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
@@ -2430,8 +2445,7 @@ void destroyItem (TreeColumn column) {
}
System.arraycopy (columns, index + 1, columns, index, --columnCount - index);
columns [columnCount] = null;
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
+ for (TreeItem item : items) {
if (item != null) {
if (columnCount == 0) {
item.strings = null;
@@ -2530,9 +2544,9 @@ void destroyItem (TreeColumn column) {
newColumns [i - orderIndex] = columns [newOrder [i]];
newColumns [i - orderIndex].updateToolTip (newOrder [i]);
}
- for (int i=0; i<newColumns.length; i++) {
- if (!newColumns [i].isDisposed ()) {
- newColumns [i].sendEvent (SWT.Move);
+ for (TreeColumn newColumn : newColumns) {
+ if (!newColumn.isDisposed ()) {
+ newColumn.sendEvent (SWT.Move);
}
}
}
@@ -2547,7 +2561,7 @@ void destroyItem (TreeColumn column) {
}
}
-void destroyItem (TreeItem item, long /*int*/ hItem) {
+void destroyItem (TreeItem item, long hItem) {
hFirstIndexOf = hLastIndexOf = 0;
itemCount = -1;
/*
@@ -2565,7 +2579,7 @@ void destroyItem (TreeItem item, long /*int*/ hItem) {
* allowing application code to add or remove items during
* this remove operation.
*/
- long /*int*/ hParent = 0;
+ long hParent = 0;
boolean fixRedraw = false;
if ((style & SWT.DOUBLE_BUFFERED) == 0) {
if (getDrawing () && OS.IsWindowVisible (handle)) {
@@ -2577,14 +2591,8 @@ void destroyItem (TreeItem item, long /*int*/ hItem) {
hParent = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hItem);
OS.UpdateWindow (handle);
OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
- /*
- * This code is intentionally commented.
- */
-// OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
- }
- if ((style & SWT.MULTI) != 0) {
- ignoreDeselect = ignoreSelect = lockSelection = true;
}
+ ignoreDeselect = ignoreSelect = lockSelection = true;
/*
* Feature in Windows. When an item is deleted and a tool tip
@@ -2596,15 +2604,17 @@ void destroyItem (TreeItem item, long /*int*/ hItem) {
*
* NOTE: This only happens on Vista.
*/
- long /*int*/ hwndToolTip = OS.SendMessage (handle, OS.TVM_GETTOOLTIPS, 0, 0);
+ long hwndToolTip = OS.SendMessage (handle, OS.TVM_GETTOOLTIPS, 0, 0);
if (hwndToolTip != 0) OS.SendMessage (hwndToolTip, OS.TTM_POP, 0 ,0);
shrink = ignoreShrink = true;
OS.SendMessage (handle, OS.TVM_DELETEITEM, 0, hItem);
ignoreShrink = false;
- if ((style & SWT.MULTI) != 0) {
- ignoreDeselect = ignoreSelect = lockSelection = false;
- }
+ /*
+ * Bug 546333: When TVGN_CARET item is deleted, Windows automatically
+ * sets selection to some other item. We do not want that.
+ */
+ ignoreDeselect = ignoreSelect = lockSelection = false;
if (fixRedraw) {
OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
OS.ValidateRect (handle, null);
@@ -2619,7 +2629,7 @@ void destroyItem (TreeItem item, long /*int*/ hItem) {
}
}
}
- int count = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
+ int count = (int)OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
if (count == 0) {
if (imageList != null) {
OS.SendMessage (handle, OS.TVM_SETIMAGELIST, 0, 0);
@@ -2635,7 +2645,22 @@ void destroyItem (TreeItem item, long /*int*/ hItem) {
scrollWidth = 0;
setScrollWidth ();
}
- updateScrollBar ();
+
+ /*
+ Note: Don't update scrollbars when drawing is disabled.
+ This gives significant improvement for bulk remove scenarios.
+ Later, setRedraw(true) will update scrollbars once.
+ */
+ if (getDrawing ()) updateScrollBar ();
+
+ /*
+ If this is the last item removed fire an EmptinessChanged event.
+ */
+ if (count == 0) {
+ Event event = new Event ();
+ event.detail = 1;
+ sendEvent (SWT.EmptinessChanged, event);
+ }
}
@Override
@@ -2703,8 +2728,8 @@ boolean findCell (int x, int y, TreeItem [] item, int [] index, RECT [] cellRect
POINT pt = new POINT ();
pt.x = x;
pt.y = y;
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ oldFont = 0, newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ long hDC = OS.GetDC (handle);
+ long oldFont = 0, newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
RECT rect = new RECT ();
if (hwndParent != 0) {
@@ -2719,7 +2744,7 @@ boolean findCell (int x, int y, TreeItem [] item, int [] index, RECT [] cellRect
index [0] = 0;
boolean quit = false;
while (index [0] < count && !quit) {
- long /*int*/ hFont = item [0].fontHandle (order [index [0]]);
+ long hFont = item [0].fontHandle (order [index [0]]);
if (hFont != -1) hFont = OS.SelectObject (hDC, hFont);
cellRect [0] = item [0].getBounds (order [index [0]], true, false, true, false, true, hDC);
if (cellRect [0].left > rect.right) {
@@ -2728,7 +2753,7 @@ boolean findCell (int x, int y, TreeItem [] item, int [] index, RECT [] cellRect
cellRect [0].right = Math.min (cellRect [0].right, rect.right);
if (OS.PtInRect (cellRect [0], pt)) {
if (isCustomToolTip ()) {
- int state = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMSTATE, lpht.hItem, OS.TVIS_SELECTED);
+ int state = (int)OS.SendMessage (handle, OS.TVM_GETITEMSTATE, lpht.hItem, OS.TVIS_SELECTED);
int detail = (state & OS.TVIS_SELECTED) != 0 ? SWT.SELECTED : 0;
Event event = sendMeasureItemEvent (item [0], order [index [0]], hDC, detail);
if (isDisposed () || item [0].isDisposed ()) break;
@@ -2754,7 +2779,7 @@ boolean findCell (int x, int y, TreeItem [] item, int [] index, RECT [] cellRect
return found;
}
-int findIndex (long /*int*/ hFirstItem, long /*int*/ hItem) {
+int findIndex (long hFirstItem, long hItem) {
if (hFirstItem == 0) return -1;
if (hFirstItem == hFirstIndexOf) {
if (hFirstIndexOf == hItem) {
@@ -2762,12 +2787,12 @@ int findIndex (long /*int*/ hFirstItem, long /*int*/ hItem) {
return lastIndexOf = 0;
}
if (hLastIndexOf == hItem) return lastIndexOf;
- long /*int*/ hPrevItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PREVIOUS, hLastIndexOf);
+ long hPrevItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PREVIOUS, hLastIndexOf);
if (hPrevItem == hItem) {
hLastIndexOf = hPrevItem;
return --lastIndexOf;
}
- long /*int*/ hNextItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hLastIndexOf);
+ long hNextItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hLastIndexOf);
if (hNextItem == hItem) {
hLastIndexOf = hNextItem;
return ++lastIndexOf;
@@ -2793,7 +2818,7 @@ int findIndex (long /*int*/ hFirstItem, long /*int*/ hItem) {
return -1;
}
int index = 0;
- long /*int*/ hNextItem = hFirstItem;
+ long hNextItem = hFirstItem;
while (hNextItem != 0 && hNextItem != hItem) {
hNextItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hNextItem);
index++;
@@ -2808,11 +2833,11 @@ int findIndex (long /*int*/ hFirstItem, long /*int*/ hItem) {
}
@Override
-Widget findItem (long /*int*/ hItem) {
+Widget findItem (long hItem) {
return _getItem (hItem);
}
-long /*int*/ findItem (long /*int*/ hFirstItem, int index) {
+long findItem (long hFirstItem, int index) {
if (hFirstItem == 0) return 0;
if (hFirstItem == hFirstIndexOf) {
if (index == 0) {
@@ -2830,7 +2855,7 @@ long /*int*/ findItem (long /*int*/ hFirstItem, int index) {
}
if (index < lastIndexOf) {
int previousIndex = lastIndexOf - 1;
- long /*int*/ hPrevItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PREVIOUS, hLastIndexOf);
+ long hPrevItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PREVIOUS, hLastIndexOf);
while (hPrevItem != 0 && index < previousIndex) {
hPrevItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PREVIOUS, hPrevItem);
--previousIndex;
@@ -2841,7 +2866,7 @@ long /*int*/ findItem (long /*int*/ hFirstItem, int index) {
}
} else {
int nextIndex = lastIndexOf + 1;
- long /*int*/ hNextItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hLastIndexOf);
+ long hNextItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hLastIndexOf);
while (hNextItem != 0 && nextIndex < index) {
hNextItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hNextItem);
nextIndex++;
@@ -2854,7 +2879,7 @@ long /*int*/ findItem (long /*int*/ hFirstItem, int index) {
return 0;
}
int nextIndex = 0;
- long /*int*/ hNextItem = hFirstItem;
+ long hNextItem = hFirstItem;
while (hNextItem != 0 && nextIndex < index) {
hNextItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hNextItem);
nextIndex++;
@@ -2870,7 +2895,7 @@ long /*int*/ findItem (long /*int*/ hFirstItem, int index) {
TreeItem getFocusItem () {
// checkWidget ();
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
return hItem != 0 ? _getItem (hItem) : null;
}
@@ -2990,12 +3015,12 @@ Point getImageSize () {
return new Point (0, getItemHeightInPixels ());
}
-long /*int*/ getBottomItem () {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+long getBottomItem () {
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
if (hItem == 0) return 0;
- int index = 0, count = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETVISIBLECOUNT, 0, 0);
+ int index = 0, count = (int)OS.SendMessage (handle, OS.TVM_GETVISIBLECOUNT, 0, 0);
while (index <= count) {
- long /*int*/ hNextItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hItem);
+ long hNextItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hItem);
if (hNextItem == 0) return hItem;
hItem = hNextItem;
index++;
@@ -3151,9 +3176,9 @@ public TreeColumn [] getColumns () {
public TreeItem getItem (int index) {
checkWidget ();
if (index < 0) error (SWT.ERROR_INVALID_RANGE);
- long /*int*/ hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
if (hFirstItem == 0) error (SWT.ERROR_INVALID_RANGE);
- long /*int*/ hItem = findItem (hFirstItem, index);
+ long hItem = findItem (hFirstItem, index);
if (hItem == 0) error (SWT.ERROR_INVALID_RANGE);
return _getItem (hItem);
}
@@ -3167,14 +3192,14 @@ TreeItem getItem (NMTVCUSTOMDRAW nmcd) {
* fix is to query the field from the item instead
* of using the struct.
*/
- int id = (int)/*64*/nmcd.lItemlParam;
+ int id = (int)nmcd.lItemlParam;
if ((style & SWT.VIRTUAL) != 0) {
if (id == -1) {
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
tvItem.hItem = nmcd.dwItemSpec;
OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- id = (int)/*64*/tvItem.lParam;
+ id = (int)tvItem.lParam;
}
}
return _getItem (nmcd.dwItemSpec, id);
@@ -3246,14 +3271,14 @@ TreeItem getItemInPixels (Point point) {
*/
public int getItemCount () {
checkWidget ();
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
if (hItem == 0) return 0;
return getItemCount (hItem);
}
-int getItemCount (long /*int*/ hItem) {
+int getItemCount (long hItem) {
int count = 0;
- long /*int*/ hFirstItem = hItem;
+ long hFirstItem = hItem;
if (hItem == hFirstIndexOf) {
if (itemCount != -1) return itemCount;
hFirstItem = hLastIndexOf;
@@ -3284,7 +3309,7 @@ public int getItemHeight () {
}
int getItemHeightInPixels () {
- return (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMHEIGHT, 0, 0);
+ return (int)OS.SendMessage (handle, OS.TVM_GETITEMHEIGHT, 0, 0);
}
/**
@@ -3306,14 +3331,14 @@ int getItemHeightInPixels () {
*/
public TreeItem [] getItems () {
checkWidget ();
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
if (hItem == 0) return new TreeItem [0];
return getItems (hItem);
}
-TreeItem [] getItems (long /*int*/ hTreeItem) {
+TreeItem [] getItems (long hTreeItem) {
int count = 0;
- long /*int*/ hItem = hTreeItem;
+ long hItem = hTreeItem;
while (hItem != 0) {
hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);
count++;
@@ -3332,7 +3357,7 @@ TreeItem [] getItems (long /*int*/ hTreeItem) {
*/
while (tvItem.hItem != 0) {
OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- TreeItem item = _getItem (tvItem.hItem, (int)/*64*/tvItem.lParam);
+ TreeItem item = _getItem (tvItem.hItem, (int)tvItem.lParam);
if (item != null) result [index++] = item;
tvItem.hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, tvItem.hItem);
}
@@ -3369,12 +3394,12 @@ public boolean getLinesVisible () {
return linesVisible;
}
-long /*int*/ getNextSelection (long /*int*/ hItem) {
+long getNextSelection (long hItem) {
while (hItem != 0) {
- int state = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
+ int state = (int)OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
if ((state & OS.TVIS_SELECTED) != 0) return hItem;
- long /*int*/ hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
- long /*int*/ hSelected = getNextSelection (hFirstItem);
+ long hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
+ long hSelected = getNextSelection (hFirstItem);
if (hSelected != 0) return hSelected;
hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);
}
@@ -3398,7 +3423,7 @@ public TreeItem getParentItem () {
return null;
}
-int getSelection (long /*int*/ hItem, TVITEM tvItem, TreeItem [] selection, int index, int count, boolean bigSelection, boolean all) {
+int getSelection (long hItem, TVITEM tvItem, TreeItem [] selection, int index, int count, boolean bigSelection, boolean all) {
while (hItem != 0) {
boolean expanded = true;
if (bigSelection) {
@@ -3406,7 +3431,7 @@ int getSelection (long /*int*/ hItem, TVITEM tvItem, TreeItem [] selection, int
OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
if ((tvItem.state & OS.TVIS_SELECTED) != 0) {
if (selection != null && index < selection.length) {
- TreeItem item = _getItem (hItem, (int)/*64*/tvItem.lParam);
+ TreeItem item = _getItem (hItem, (int)tvItem.lParam);
if (item != null) {
selection [index] = item;
} else {
@@ -3417,12 +3442,12 @@ int getSelection (long /*int*/ hItem, TVITEM tvItem, TreeItem [] selection, int
}
expanded = (tvItem.state & OS.TVIS_EXPANDED) != 0;
} else {
- int state = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED | OS.TVIS_EXPANDED);
+ int state = (int)OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED | OS.TVIS_EXPANDED);
if ((state & OS.TVIS_SELECTED) != 0) {
if (tvItem != null && selection != null && index < selection.length) {
tvItem.hItem = hItem;
OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- TreeItem item = _getItem (hItem, (int)/*64*/tvItem.lParam);
+ TreeItem item = _getItem (hItem, (int)tvItem.lParam);
if (item != null) {
selection [index] = item;
} else {
@@ -3436,7 +3461,7 @@ int getSelection (long /*int*/ hItem, TVITEM tvItem, TreeItem [] selection, int
if (index == count) break;
if (all) {
if (expanded) {
- long /*int*/ hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
+ long hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
if ((index = getSelection (hFirstItem, tvItem, selection, index, count, bigSelection, all)) == count) {
break;
}
@@ -3468,32 +3493,31 @@ int getSelection (long /*int*/ hItem, TVITEM tvItem, TreeItem [] selection, int
public TreeItem [] getSelection () {
checkWidget ();
if ((style & SWT.SINGLE) != 0) {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (hItem == 0) return new TreeItem [0];
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM | OS.TVIF_STATE;
tvItem.hItem = hItem;
OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
if ((tvItem.state & OS.TVIS_SELECTED) == 0) return new TreeItem [0];
- TreeItem item = _getItem (tvItem.hItem, (int)/*64*/tvItem.lParam);
+ TreeItem item = _getItem (tvItem.hItem, (int)tvItem.lParam);
if (item == null) return new TreeItem [0];
return new TreeItem [] {item};
}
int count = 0;
TreeItem [] guess = new TreeItem [(style & SWT.VIRTUAL) != 0 ? 8 : 1];
- long /*int*/ oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
+ long oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, TreeProc);
if ((style & SWT.VIRTUAL) != 0) {
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM | OS.TVIF_STATE;
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
count = getSelection (hItem, tvItem, guess, 0, -1, false, true);
} else {
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
+ for (TreeItem item : items) {
if (item != null) {
- long /*int*/ hItem = item.handle;
- int state = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
+ long hItem = item.handle;
+ int state = (int)OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
if ((state & OS.TVIS_SELECTED) != 0) {
if (count < guess.length) guess [count] = item;
count++;
@@ -3512,8 +3536,8 @@ public TreeItem [] getSelection () {
OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, TreeProc);
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM | OS.TVIF_STATE;
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
- int itemCount = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ int itemCount = (int)OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
boolean bigSelection = result.length > itemCount / 2;
if (count != getSelection (hItem, tvItem, result, 0, count, bigSelection, false)) {
count = getSelection (hItem, tvItem, result, 0, count, bigSelection, true);
@@ -3540,23 +3564,22 @@ public TreeItem [] getSelection () {
public int getSelectionCount () {
checkWidget ();
if ((style & SWT.SINGLE) != 0) {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (hItem == 0) return 0;
- int state = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
+ int state = (int)OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
return (state & OS.TVIS_SELECTED) == 0 ? 0 : 1;
}
int count = 0;
- long /*int*/ oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
+ long oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, TreeProc);
if ((style & SWT.VIRTUAL) != 0) {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
count = getSelection (hItem, null, null, 0, -1, false, true);
} else {
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
+ for (TreeItem item : items) {
if (item != null) {
- long /*int*/ hItem = item.handle;
- int state = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
+ long hItem = item.handle;
+ int state = (int)OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
if ((state & OS.TVIS_SELECTED) != 0) count++;
}
}
@@ -3628,11 +3651,11 @@ public int getSortDirection () {
*/
public TreeItem getTopItem () {
checkWidget ();
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
return hItem != 0 ? _getItem (hItem) : null;
}
-boolean hitTestSelection (long /*int*/ hItem, int x, int y) {
+boolean hitTestSelection (long hItem, int x, int y) {
if (hItem == 0) return false;
TreeItem item = _getItem (hItem);
if (item == null) return false;
@@ -3643,12 +3666,12 @@ boolean hitTestSelection (long /*int*/ hItem, int x, int y) {
//BUG? - check drag detect
int [] order = new int [1], index = new int [1];
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ oldFont = 0, newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ long hDC = OS.GetDC (handle);
+ long oldFont = 0, newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
- long /*int*/ hFont = item.fontHandle (order [index [0]]);
+ long hFont = item.fontHandle (order [index [0]]);
if (hFont != -1) hFont = OS.SelectObject (hDC, hFont);
- int state = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
+ int state = (int)OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
int detail = (state & OS.TVIS_SELECTED) != 0 ? SWT.SELECTED : 0;
Event event = sendMeasureItemEvent (item, order [index [0]], hDC, detail);
if (event.getBoundsInPixels ().contains (x, y)) result = true;
@@ -3672,8 +3695,8 @@ int imageIndex (Image image, int index) {
* times, Windows does work making this operation slow. The fix
* is to test for the same image list before setting the new one.
*/
- long /*int*/ hImageList = imageList.getHandle ();
- long /*int*/ hOldImageList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0);
+ long hImageList = imageList.getHandle ();
+ long hOldImageList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0);
if (hOldImageList != hImageList) {
OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList);
updateScrollBar ();
@@ -3689,7 +3712,7 @@ int imageIndexHeader (Image image) {
headerImageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, bounds.width, bounds.height);
int index = headerImageList.indexOf (image);
if (index == -1) index = headerImageList.add (image);
- long /*int*/ hImageList = headerImageList.getHandle ();
+ long hImageList = headerImageList.getHandle ();
if (hwndHeader != 0) {
OS.SendMessage (hwndHeader, OS.HDM_SETIMAGELIST, 0, hImageList);
}
@@ -3754,7 +3777,7 @@ public int indexOf (TreeItem item) {
checkWidget ();
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
return hItem == 0 ? -1 : findIndex (hItem, item.handle);
}
@@ -3826,9 +3849,30 @@ boolean isItemSelected (NMTVCUSTOMDRAW nmcd) {
return selected;
}
+@Override
+boolean isUseWsBorder () {
+ return true;
+}
+
+int itemsGetFreeCapacity() {
+ int count = 0;
+ for (TreeItem item : items) {
+ if (item == null)
+ count++;
+ }
+
+ return count;
+}
+
+void itemsGrowArray (int newCapacity) {
+ TreeItem [] newItems = new TreeItem [newCapacity];
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+}
+
void redrawSelection () {
if ((style & SWT.SINGLE) != 0) {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (hItem != 0) {
RECT rect = new RECT ();
if (OS.TreeView_GetItemRect (handle, hItem, rect, false)) {
@@ -3836,12 +3880,12 @@ void redrawSelection () {
}
}
} else {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
if (hItem != 0) {
RECT rect = new RECT ();
- int index = 0, count = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETVISIBLECOUNT, 0, 0);
+ int index = 0, count = (int)OS.SendMessage (handle, OS.TVM_GETVISIBLECOUNT, 0, 0);
while (index <= count && hItem != 0) {
- int state = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
+ int state = (int)OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
if ((state & OS.TVIS_SELECTED) != 0) {
if (OS.TreeView_GetItemRect (handle, hItem, rect, false)) {
OS.InvalidateRect (handle, rect, true);
@@ -3861,23 +3905,23 @@ void register () {
if (hwndHeader != 0) display.addControl (hwndHeader, this);
}
-void releaseItem (long /*int*/ hItem, TVITEM tvItem, boolean release) {
+void releaseItem (long hItem, TVITEM tvItem, boolean release) {
if (hItem == hAnchor) hAnchor = 0;
if (hItem == hInsert) hInsert = 0;
tvItem.hItem = hItem;
if (OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem) != 0) {
if (tvItem.lParam != -1) {
- if (tvItem.lParam < lastID) lastID = (int)/*64*/tvItem.lParam;
+ if (tvItem.lParam < lastID) lastID = (int)tvItem.lParam;
if (release) {
- TreeItem item = items [(int)/*64*/tvItem.lParam];
+ TreeItem item = items [(int)tvItem.lParam];
if (item != null) item.release (false);
}
- items [(int)/*64*/tvItem.lParam] = null;
+ items [(int)tvItem.lParam] = null;
}
}
}
-void releaseItems (long /*int*/ hItem, TVITEM tvItem) {
+void releaseItems (long hItem, TVITEM tvItem) {
hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
while (hItem != 0) {
releaseItems (hItem, tvItem);
@@ -3895,8 +3939,7 @@ void releaseHandle () {
@Override
void releaseChildren (boolean destroy) {
if (items != null) {
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
+ for (TreeItem item : items) {
if (item != null && !item.isDisposed ()) {
item.release (false);
}
@@ -3904,8 +3947,7 @@ void releaseChildren (boolean destroy) {
items = null;
}
if (columns != null) {
- for (int i=0; i<columns.length; i++) {
- TreeColumn column = columns [i];
+ for (TreeColumn column : columns) {
if (column != null && !column.isDisposed ()) {
column.release (false);
}
@@ -3939,7 +3981,7 @@ void releaseWidget () {
display.releaseImageList (headerImageList);
}
imageList = headerImageList = null;
- long /*int*/ hStateList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_STATE, 0);
+ long hStateList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_STATE, 0);
OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_STATE, 0);
if (hStateList != 0) OS.ImageList_Destroy (hStateList);
if (itemToolTipHandle != 0) OS.DestroyWindow (itemToolTipHandle);
@@ -3959,8 +4001,7 @@ public void removeAll () {
checkWidget ();
hFirstIndexOf = hLastIndexOf = 0;
itemCount = -1;
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
+ for (TreeItem item : items) {
if (item != null && !item.isDisposed ()) {
item.release (false);
}
@@ -3969,7 +4010,7 @@ public void removeAll () {
boolean redraw = getDrawing () && OS.IsWindowVisible (handle);
if (redraw) OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
shrink = ignoreShrink = true;
- long /*int*/ result = OS.SendMessage (handle, OS.TVM_DELETEITEM, 0, OS.TVI_ROOT);
+ long result = OS.SendMessage (handle, OS.TVM_DELETEITEM, 0, OS.TVI_ROOT);
ignoreShrink = false;
if (redraw) {
OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
@@ -4047,14 +4088,12 @@ public void removeTreeListener(TreeListener listener) {
@Override
void reskinChildren (int flags) {
if (items != null) {
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
+ for (TreeItem item : items) {
if (item != null) item.reskinChildren (flags);
}
}
if (columns != null) {
- for (int i=0; i<columns.length; i++) {
- TreeColumn column = columns [i];
+ for (TreeColumn column : columns) {
if (column != null) column.reskinChildren (flags);
}
}
@@ -4081,7 +4120,7 @@ void reskinChildren (int flags) {
*/
public void setInsertMark (TreeItem item, boolean before) {
checkWidget ();
- long /*int*/ hItem = 0;
+ long hItem = 0;
if (item != null) {
if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
hItem = item.handle;
@@ -4093,6 +4132,9 @@ public void setInsertMark (TreeItem item, boolean before) {
/**
* Sets the number of root-level items contained in the receiver.
+ * <p>
+ * The fastest way to insert many items is documented in {@link TreeItem#TreeItem(Tree,int,int)}
+ * and {@link TreeItem#setItemCount}
*
* @param count the number of items
*
@@ -4106,60 +4148,101 @@ public void setInsertMark (TreeItem item, boolean before) {
public void setItemCount (int count) {
checkWidget ();
count = Math.max (0, count);
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
- setItemCount (count, OS.TVGN_ROOT, hItem);
-}
+ setItemCount (count, OS.TVI_ROOT);
+}
+
+void setItemCount (int count, long hParent) {
+ // Investigate existing items and decide what to do
+ long itemInsertAfter = 0;
+ int numInserted = 0;
+ long itemDeleteFrom = 0;
+ {
+ // Iterate to position #count and find prev/next items at this position
+ int itemCount = 0;
+ long itemPrev = OS.TVI_FIRST;
+ long itemNext = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hParent);
+ while (itemNext != 0 && itemCount < count)
+ {
+ itemPrev = itemNext;
+ itemNext = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, itemNext);
+ itemCount++;
+ }
+
+ if ((itemCount == count) && (itemNext == 0)) {
+ // Exactly 'count' items, no need to do anything.
+ return;
+ } else if (itemCount == count) {
+ // Too many items, going to delete some
+ itemDeleteFrom = itemNext;
+ } else if (itemNext == 0) {
+ // Counted all items, and there is not enough, going to insert some.
+ itemInsertAfter = itemPrev;
+ numInserted = count - itemCount;
+ }
+ }
-void setItemCount (int count, long /*int*/ hParent, long /*int*/ hItem) {
boolean redraw = false;
if (OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0) == 0) {
redraw = getDrawing () && OS.IsWindowVisible (handle);
if (redraw) OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
}
- int itemCount = 0;
- while (hItem != 0 && itemCount < count) {
- hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);
- itemCount++;
- }
+
boolean expanded = false;
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
- if (!redraw && (style & SWT.VIRTUAL) != 0) {
+ if (!redraw && (style & SWT.VIRTUAL) != 0 && (hParent != OS.TVI_ROOT)) {
/*
* Bug in Windows. Despite the fact that TVM_GETITEMSTATE claims
* to return only the bits specified by the stateMask, when called
* with TVIS_EXPANDED, the entire state is returned. The fix is
* to explicitly check for the TVIS_EXPANDED bit.
*/
- int state = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hParent, OS.TVIS_EXPANDED);
+ int state = (int)OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hParent, OS.TVIS_EXPANDED);
expanded = (state & OS.TVIS_EXPANDED) != 0;
}
- while (hItem != 0) {
- tvItem.hItem = hItem;
- OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);
- TreeItem item = tvItem.lParam != -1 ? items [(int)/*64*/tvItem.lParam] : null;
- if (item != null && !item.isDisposed ()) {
- item.dispose ();
- } else {
- releaseItem (tvItem.hItem, tvItem, false);
- destroyItem (null, tvItem.hItem);
- }
- }
- if ((style & SWT.VIRTUAL) != 0) {
- for (int i=itemCount; i<count; i++) {
- if (expanded) ignoreShrink = true;
- createItem (null, hParent, OS.TVI_LAST, 0);
- if (expanded) ignoreShrink = false;
+
+ if (itemDeleteFrom != 0) {
+ while (itemDeleteFrom != 0) {
+ tvItem.hItem = itemDeleteFrom;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ itemDeleteFrom = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, itemDeleteFrom);
+ TreeItem item = tvItem.lParam != -1 ? items [(int)tvItem.lParam] : null;
+ if (item != null && !item.isDisposed ()) {
+ item.dispose ();
+ } else {
+ releaseItem (tvItem.hItem, tvItem, false);
+ destroyItem (null, tvItem.hItem);
+ }
}
} else {
- shrink = true;
- int extra = Math.max (4, (count + 3) / 4 * 4);
- TreeItem [] newItems = new TreeItem [items.length + extra];
- System.arraycopy (items, 0, newItems, 0, items.length);
- items = newItems;
- for (int i=itemCount; i<count; i++) {
- new TreeItem (this, SWT.NONE, hParent, OS.TVI_LAST, 0);
+ // For performance reasons, reserve the necessary space in items[]
+ int freeCapacity = itemsGetFreeCapacity();
+ if (numInserted > freeCapacity)
+ itemsGrowArray (items.length + numInserted - freeCapacity);
+
+ // Note: on Windows, insert complexity is O(pos), so for performance
+ // reasons, all items are inserted at minimum possible position, that
+ // is, all at the same position.
+
+ if ((style & SWT.VIRTUAL) != 0) {
+ for (int i = 0; i < numInserted; i++) {
+ /*
+ * Bug 206806: Windows sends 'TVN_GETDISPINFO' when item is
+ * being inserted. This causes 'SWT.SetData' to be sent to
+ * user code. If it happens to query 'getItemCount()', it will
+ * get wrong number of items because we're still inserting. The
+ * workaround is to temporarily suppress 'SWT.SetData'. Note
+ * that the boolean flag is misleadingly used for multiple
+ * purposes.
+ */
+ if (expanded) ignoreShrink = true;
+ createItem (null, hParent, itemInsertAfter, 0);
+ if (expanded) ignoreShrink = false;
+ }
+ } else {
+ for (int i = 0; i < numInserted; i++) {
+ new TreeItem (this, SWT.NONE, hParent, itemInsertAfter, 0);
+ }
}
}
if (redraw) {
@@ -4216,18 +4299,18 @@ public void setLinesVisible (boolean show) {
}
@Override
-long /*int*/ scrolledHandle () {
+long scrolledHandle () {
if (hwndHeader == 0) return handle;
return columnCount == 0 && scrollWidth == 0 ? handle : hwndParent;
}
-void select (long /*int*/ hItem, TVITEM tvItem) {
+void select (long hItem, TVITEM tvItem) {
while (hItem != 0) {
tvItem.hItem = hItem;
OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
- int state = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_EXPANDED);
+ int state = (int)OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_EXPANDED);
if ((state & OS.TVIS_EXPANDED) != 0) {
- long /*int*/ hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
+ long hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
select (hFirstItem, tvItem);
}
@@ -4257,8 +4340,8 @@ public void select (TreeItem item) {
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
if ((style & SWT.SINGLE) != 0) {
- long /*int*/ hItem = item.handle;
- int state = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
+ long hItem = item.handle;
+ int state = (int)OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
if ((state & OS.TVIS_SELECTED) != 0) return;
/*
* Feature in Windows. When an item is selected with
@@ -4289,7 +4372,7 @@ public void select (TreeItem item) {
}
setSelection (item);
if (hInfo != null) {
- long /*int*/ hThumb = OS.MAKELPARAM (OS.SB_THUMBPOSITION, hInfo.nPos);
+ long hThumb = OS.MAKELPARAM (OS.SB_THUMBPOSITION, hInfo.nPos);
OS.SendMessage (handle, OS.WM_HSCROLL, hThumb, 0);
}
/*
@@ -4302,7 +4385,7 @@ public void select (TreeItem item) {
* NOTE: This code is only necessary on Windows Vista.
*/
OS.SetScrollInfo (handle, OS.SB_VERT, vInfo, true);
- long /*int*/ vThumb = OS.MAKELPARAM (OS.SB_THUMBPOSITION, vInfo.nPos);
+ long vThumb = OS.MAKELPARAM (OS.SB_THUMBPOSITION, vInfo.nPos);
OS.SendMessage (handle, OS.WM_VSCROLL, vThumb, 0);
if (redraw) {
OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
@@ -4343,9 +4426,9 @@ public void selectAll () {
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
tvItem.state = OS.TVIS_SELECTED;
tvItem.stateMask = OS.TVIS_SELECTED;
- long /*int*/ oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
+ long oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, TreeProc);
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
select (hItem, tvItem);
OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, oldProc);
}
@@ -4359,7 +4442,7 @@ Event sendEraseItemEvent (TreeItem item, NMTTCUSTOMDRAW nmcd, int column, RECT c
data.foreground = OS.GetTextColor (nmcd.hdc);
data.background = OS.GetBkColor (nmcd.hdc);
data.font = item.getFont (column);
- data.uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ data.uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
GC gc = GC.win32_new (nmcd.hdc, data);
Event event = new Event ();
event.item = item;
@@ -4376,7 +4459,7 @@ Event sendEraseItemEvent (TreeItem item, NMTTCUSTOMDRAW nmcd, int column, RECT c
return event;
}
-Event sendMeasureItemEvent (TreeItem item, int index, long /*int*/ hDC, int detail) {
+Event sendMeasureItemEvent (TreeItem item, int index, long hDC, int detail) {
RECT itemRect = item.getBounds (index, true, true, false, false, false, hDC);
int nSavedDC = OS.SaveDC (hDC);
GCData data = new GCData ();
@@ -4415,7 +4498,7 @@ Event sendPaintItemEvent (TreeItem item, NMTTCUSTOMDRAW nmcd, int column, RECT i
data.font = item.getFont (column);
data.foreground = OS.GetTextColor (nmcd.hdc);
data.background = OS.GetBkColor (nmcd.hdc);
- data.uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ data.uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
GC gc = GC.win32_new (nmcd.hdc, data);
Event event = new Event ();
event.item = item;
@@ -4432,7 +4515,7 @@ Event sendPaintItemEvent (TreeItem item, NMTTCUSTOMDRAW nmcd, int column, RECT i
}
@Override
-void setBackgroundImage (long /*int*/ hBitmap) {
+void setBackgroundImage (long hBitmap) {
super.setBackgroundImage (hBitmap);
if (hBitmap != 0) {
/*
@@ -4499,7 +4582,7 @@ void setCursor () {
* is IDC_ARROW.
*/
Cursor cursor = findCursor ();
- long /*int*/ hCursor = cursor == null ? OS.LoadCursor (0, OS.IDC_ARROW) : cursor.handle;
+ long hCursor = cursor == null ? OS.LoadCursor (0, OS.IDC_ARROW) : cursor.handle;
OS.SetCursor (hCursor);
}
@@ -4576,12 +4659,12 @@ void setCheckboxImageList () {
int count = 5, flags = OS.ILC_COLOR32;
if ((style & SWT.RIGHT_TO_LEFT) != 0) flags |= OS.ILC_MIRROR;
if (!OS.IsAppThemed ()) flags |= OS.ILC_MASK;
- int height = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMHEIGHT, 0, 0), width = height;
- long /*int*/ hStateList = OS.ImageList_Create (width, height, flags, count, count);
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ memDC = OS.CreateCompatibleDC (hDC);
- long /*int*/ hBitmap = OS.CreateCompatibleBitmap (hDC, width * count, height);
- long /*int*/ hOldBitmap = OS.SelectObject (memDC, hBitmap);
+ int height = (int)OS.SendMessage (handle, OS.TVM_GETITEMHEIGHT, 0, 0), width = height;
+ long hStateList = OS.ImageList_Create (width, height, flags, count, count);
+ long hDC = OS.GetDC (handle);
+ long memDC = OS.CreateCompatibleDC (hDC);
+ long hBitmap = OS.CreateCompatibleBitmap (hDC, width * count, height);
+ long hOldBitmap = OS.SelectObject (memDC, hBitmap);
RECT rect = new RECT ();
OS.SetRect (rect, 0, 0, width * count, height);
/*
@@ -4601,10 +4684,10 @@ void setCheckboxImageList () {
clrBackground = 0x0200FF00;
}
}
- long /*int*/ hBrush = OS.CreateSolidBrush (clrBackground);
+ long hBrush = OS.CreateSolidBrush (clrBackground);
OS.FillRect (memDC, rect, hBrush);
OS.DeleteObject (hBrush);
- long /*int*/ oldFont = OS.SelectObject (hDC, defaultFont ());
+ long oldFont = OS.SelectObject (hDC, defaultFont ());
TEXTMETRIC tm = new TEXTMETRIC ();
OS.GetTextMetrics (hDC, tm);
OS.SelectObject (hDC, oldFont);
@@ -4624,7 +4707,7 @@ void setCheckboxImageList () {
int left = (width - itemWidth) / 2, top = (height - itemHeight) / 2 + 1;
OS.SetRect (rect, left + width, top, left + width + itemWidth, top + itemHeight);
if (OS.IsAppThemed ()) {
- long /*int*/ hTheme = display.hButtonTheme ();
+ long hTheme = display.hButtonTheme ();
OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, rect, null);
rect.left += width; rect.right += width;
OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_CHECKEDNORMAL, rect, null);
@@ -4650,7 +4733,7 @@ void setCheckboxImageList () {
OS.ImageList_AddMasked (hStateList, hBitmap, clrBackground);
}
OS.DeleteObject (hBitmap);
- long /*int*/ hOldStateList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_STATE, 0);
+ long hOldStateList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_STATE, 0);
OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_STATE, hStateList);
if (hOldStateList != 0) OS.ImageList_Destroy (hOldStateList);
}
@@ -4804,22 +4887,24 @@ public void setRedraw (boolean redraw) {
* when redraw is turned on and there are no items in
* the tree.
*/
- long /*int*/ hItem = 0;
- if (redraw) {
- if (drawCount == 1) {
- int count = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
- if (count == 0) {
- TVINSERTSTRUCT tvInsert = new TVINSERTSTRUCT ();
- tvInsert.hInsertAfter = OS.TVI_FIRST;
- hItem = OS.SendMessage (handle, OS.TVM_INSERTITEM, 0, tvInsert);
- }
- OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
- updateScrollBar ();
+ long hItem = 0;
+ boolean willEnableDraw = redraw && (drawCount == 1);
+ if (willEnableDraw) {
+ int count = (int)OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
+ if (count == 0) {
+ TVINSERTSTRUCT tvInsert = new TVINSERTSTRUCT ();
+ tvInsert.hInsertAfter = OS.TVI_FIRST;
+ hItem = OS.SendMessage (handle, OS.TVM_INSERTITEM, 0, tvInsert);
}
+ OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
+ updateScrollBar ();
}
+
super.setRedraw (redraw);
- if (!redraw) {
- if (drawCount == 1) OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
+
+ boolean haveDisabledDraw = !redraw && (drawCount == 1);
+ if (haveDisabledDraw) {
+ OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
}
if (hItem != 0) {
ignoreShrink = true;
@@ -4873,7 +4958,7 @@ void setScrollWidth (int width) {
horizontalBar.setPageIncrement (info.nPage);
}
OS.GetClientRect (hwndParent, rect);
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
HDLAYOUT playout = new HDLAYOUT ();
playout.prc = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, RECT.sizeof);
playout.pwpos = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, WINDOWPOS.sizeof);
@@ -4884,17 +4969,15 @@ void setScrollWidth (int width) {
if (playout.prc != 0) OS.HeapFree (hHeap, 0, playout.prc);
if (playout.pwpos != 0) OS.HeapFree (hHeap, 0, playout.pwpos);
OS.SetWindowPos (hwndHeader, OS.HWND_TOP, pos.x - left, pos.y, pos.cx + left, pos.cy, OS.SWP_NOACTIVATE);
- int bits = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
- int b = (bits & OS.WS_EX_CLIENTEDGE) != 0 ? OS.GetSystemMetrics (OS.SM_CXEDGE) : 0;
int w = pos.cx + (columnCount == 0 && width == 0 ? 0 : OS.GetSystemMetrics (OS.SM_CXVSCROLL));
int h = rect.bottom - rect.top - pos.cy;
boolean oldIgnore = ignoreResize;
ignoreResize = true;
- OS.SetWindowPos (handle, 0, pos.x - left - b, pos.y + pos.cy - b, w + left + b * 2, h + b * 2, OS.SWP_NOACTIVATE | OS.SWP_NOZORDER);
+ OS.SetWindowPos (handle, 0, pos.x - left, pos.y + pos.cy, w + left, h, OS.SWP_NOACTIVATE | OS.SWP_NOZORDER);
ignoreResize = oldIgnore;
}
-void setSelection (long /*int*/ hItem, TVITEM tvItem, TreeItem [] selection) {
+void setSelection (long hItem, TVITEM tvItem, TreeItem [] selection) {
while (hItem != 0) {
int index = 0;
while (index < selection.length) {
@@ -4916,7 +4999,7 @@ void setSelection (long /*int*/ hItem, TVITEM tvItem, TreeItem [] selection) {
OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
}
}
- long /*int*/ hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
+ long hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
setSelection (hFirstItem, tvItem, selection);
hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);
}
@@ -4985,8 +5068,8 @@ public void setSelection (TreeItem [] items) {
TreeItem item = items [0];
if (item != null) {
if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- long /*int*/ hOldItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
- long /*int*/ hNewItem = hAnchor = item.handle;
+ long hOldItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hNewItem = hAnchor = item.handle;
/*
* Bug in Windows. When TVM_SELECTITEM is used to select and
@@ -5010,7 +5093,7 @@ public void setSelection (TreeItem [] items) {
ignoreSelect = false;
if (OS.SendMessage (handle, OS.TVM_GETVISIBLECOUNT, 0, 0) == 0) {
OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_FIRSTVISIBLE, hNewItem);
- long /*int*/ hParent = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hNewItem);
+ long hParent = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hNewItem);
if (hParent == 0) OS.SendMessage (handle, OS.WM_HSCROLL, OS.SB_TOP, 0);
}
if (fixScroll) {
@@ -5041,14 +5124,14 @@ public void setSelection (TreeItem [] items) {
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
tvItem.stateMask = OS.TVIS_SELECTED;
- long /*int*/ oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
+ long oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, TreeProc);
if ((style & SWT.VIRTUAL) != 0) {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
setSelection (hItem, tvItem, items);
} else {
- for (int i=0; i<this.items.length; i++) {
- item = this.items [i];
+ for (TreeItem item2 : this.items) {
+ item = item2;
if (item != null) {
int index = 0;
while (index < length) {
@@ -5161,8 +5244,8 @@ public void setTopItem (TreeItem item) {
checkWidget ();
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- long /*int*/ hItem = item.handle;
- long /*int*/ hTopItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+ long hItem = item.handle;
+ long hTopItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
if (hItem == hTopItem) return;
boolean fixScroll = checkScroll (hItem), redraw = false;
if (fixScroll) {
@@ -5174,7 +5257,7 @@ public void setTopItem (TreeItem item) {
}
SCROLLINFO hInfo = null;
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- long /*int*/ hParent = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hItem);
+ long hParent = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hItem);
if (hParent != 0 && (bits & (OS.TVS_NOHSCROLL | OS.TVS_NOSCROLL)) == 0) {
hInfo = new SCROLLINFO ();
hInfo.cbSize = SCROLLINFO.sizeof;
@@ -5184,7 +5267,7 @@ public void setTopItem (TreeItem item) {
OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_FIRSTVISIBLE, hItem);
if (hParent != 0) {
if (hInfo != null) {
- long /*int*/ hThumb = OS.MAKELPARAM (OS.SB_THUMBPOSITION, hInfo.nPos);
+ long hThumb = OS.MAKELPARAM (OS.SB_THUMBPOSITION, hInfo.nPos);
OS.SendMessage (handle, OS.WM_HSCROLL, hThumb, 0);
}
} else {
@@ -5202,7 +5285,7 @@ public void setTopItem (TreeItem item) {
updateScrollBar ();
}
-void showItem (long /*int*/ hItem) {
+void showItem (long hItem) {
/*
* Bug in Windows. When TVM_ENSUREVISIBLE is used to ensure
* that an item is visible and the client area of the tree is
@@ -5219,9 +5302,6 @@ void showItem (long /*int*/ hItem) {
OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
}
OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_FIRSTVISIBLE, hItem);
- /* This code is intentionally commented */
- //int hParent = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hItem);
- //if (hParent == 0) OS.SendMessage (handle, OS.WM_HSCROLL, OS.SB_TOP, 0);
OS.SendMessage (handle, OS.WM_HSCROLL, OS.SB_TOP, 0);
if (fixScroll) {
OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
@@ -5255,29 +5335,6 @@ void showItem (long /*int*/ hItem) {
}
}
}
- if (hwndParent != 0) {
- RECT itemRect = new RECT ();
- if (OS.TreeView_GetItemRect (handle, hItem, itemRect, true)) {
- forceResize ();
- RECT rect = new RECT ();
- OS.GetClientRect (hwndParent, rect);
- OS.MapWindowPoints (hwndParent, handle, rect, 2);
- POINT pt = new POINT ();
- pt.x = itemRect.left;
- pt.y = itemRect.top;
- if (!OS.PtInRect (rect, pt)) {
- pt.y = itemRect.bottom;
- if (!OS.PtInRect (rect, pt)) {
- SCROLLINFO info = new SCROLLINFO ();
- info.cbSize = SCROLLINFO.sizeof;
- info.fMask = OS.SIF_POS;
- info.nPos = Math.max (0, pt.x - Tree.INSET / 2);
- OS.SetScrollInfo (hwndParent, OS.SB_HORZ, info, true);
- setScrollWidth ();
- }
- }
- }
- }
updateScrollBar ();
}
@@ -5313,18 +5370,49 @@ public void showColumn (TreeColumn column) {
OS.MapWindowPoints (hwndParent, handle, rect, 2);
RECT headerRect = new RECT ();
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect);
- boolean scroll = headerRect.left < rect.left;
- if (!scroll) {
- int width = Math.min (rect.right - rect.left, headerRect.right - headerRect.left);
- scroll = headerRect.left + width > rect.right;
- }
- if (scroll) {
- SCROLLINFO info = new SCROLLINFO ();
+ /* bugfix for bug 566936: before this change, scroll to the right end was not implemented.
+ * Now it will be distinguished between
+ * (i) the left header is not in the client area
+ * (ii) the right header is not in the client area
+ * (iii) the client area is smaller than the header
+ *
+ * in case of (i),(iii) the scrollbar should be scrolled, so that the left side of the header is set to the begin of the client area
+ * in case of (ii) the scrollbar will be set, so that the right side of the header is set to the end of the client area.
+ *
+ * With this behaviour the header will only be moved so much, that it will be visible in the client area and not more than necessary.
+ * This is the same behaviour like in linux and on mac.*/
+ boolean scrollBecauseLeft = headerRect.left < rect.left;
+ boolean scrollBecauseRight = false;
+ if (!scrollBecauseLeft) {
+ int width = Math.min(rect.right - rect.left,
+ headerRect.right - headerRect.left);
+ scrollBecauseRight = headerRect.left + width > rect.right;
+ }
+ // in case header is wider than visual area, scroll to left position
+ if (scrollBecauseLeft || (headerRect.right
+ - headerRect.left > rect.right - rect.left)) {
+ SCROLLINFO info = new SCROLLINFO();
info.cbSize = SCROLLINFO.sizeof;
info.fMask = OS.SIF_POS;
- info.nPos = Math.max (0, headerRect.left - Tree.INSET / 2);
- OS.SetScrollInfo (hwndParent, OS.SB_HORZ, info, true);
- setScrollWidth ();
+ info.nPos = Math.max(0, headerRect.left - Tree.INSET / 2);
+ OS.SetScrollInfo(hwndParent, OS.SB_HORZ, info, true);
+ setScrollWidth();
+ } else if (scrollBecauseRight) {
+ SCROLLINFO info = new SCROLLINFO();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_POS;
+ int wideRect = rect.right - rect.left;
+ int wideHeader = headerRect.right - headerRect.left;
+ // calculation to scroll to the right
+ // info.nPos + wideRect = headerRect.right
+ // info.nPos + wideRect = headerRect.left + wideHeader
+ // info.nPos = headerRect.left + wideHeader - wideRect
+ info.nPos = Math.max(0, wideHeader + headerRect.left - wideRect
+ - Tree.INSET / 2);
+ info.nPos = Math.min(rect.right - Tree.INSET / 2, info.nPos);
+
+ OS.SetScrollInfo(hwndParent, OS.SB_HORZ, info, true);
+ setScrollWidth();
}
}
}
@@ -5368,17 +5456,17 @@ public void showItem (TreeItem item) {
*/
public void showSelection () {
checkWidget ();
- long /*int*/ hItem = 0;
+ long hItem = 0;
if ((style & SWT.SINGLE) != 0) {
hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (hItem == 0) return;
- int state = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
+ int state = (int)OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
if ((state & OS.TVIS_SELECTED) == 0) return;
} else {
- long /*int*/ oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
+ long oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, TreeProc);
if ((style & SWT.VIRTUAL) != 0) {
- long /*int*/ hRoot = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hRoot = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
hItem = getNextSelection (hRoot);
} else {
//FIXME - this code expands first selected item it finds
@@ -5386,7 +5474,7 @@ public void showSelection () {
while (index <items.length) {
TreeItem item = items [index];
if (item != null) {
- int state = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETITEMSTATE, item.handle, OS.TVIS_SELECTED);
+ int state = (int)OS.SendMessage (handle, OS.TVM_GETITEMSTATE, item.handle, OS.TVIS_SELECTED);
if ((state & OS.TVIS_SELECTED) != 0) {
hItem = item.handle;
break;
@@ -5406,8 +5494,8 @@ public void showSelection () {
sort (OS.TVI_ROOT, false);
}
-void sort (long /*int*/ hParent, boolean all) {
- int itemCount = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
+void sort (long hParent, boolean all) {
+ int itemCount = (int)OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
if (itemCount == 0 || itemCount == 1) return;
hFirstIndexOf = hLastIndexOf = 0;
itemCount = -1;
@@ -5415,7 +5503,7 @@ void sort (long /*int*/ hParent, boolean all) {
OS.SendMessage (handle, OS.TVM_SORTCHILDREN, all ? 1 : 0, hParent);
} else {
Callback compareCallback = new Callback (this, "CompareFunc", 3);
- long /*int*/ lpfnCompare = compareCallback.getAddress ();
+ long lpfnCompare = compareCallback.getAddress ();
TVSORTCB psort = new TVSORTCB ();
psort.hParent = hParent;
psort.lpfnCompare = lpfnCompare;
@@ -5447,7 +5535,7 @@ RECT toolTipRect (RECT rect) {
@Override
String toolTipText (NMTTDISPINFO hdr) {
- long /*int*/ hwndToolTip = OS.SendMessage (handle, OS.TVM_GETTOOLTIPS, 0, 0);
+ long hwndToolTip = OS.SendMessage (handle, OS.TVM_GETTOOLTIPS, 0, 0);
if (hwndToolTip == hdr.hwndFrom && toolTipText != null) return ""; //$NON-NLS-1$
if (headerToolTipHandle == hdr.hwndFrom) {
for (int i=0; i<columnCount; i++) {
@@ -5482,7 +5570,7 @@ String toolTipText (NMTTDISPINFO hdr) {
}
@Override
-long /*int*/ topHandle () {
+long topHandle () {
return hwndParent != 0 ? hwndParent : handle;
}
@@ -5531,7 +5619,7 @@ void updateHeaderToolTips () {
void updateImageList () {
if (imageList == null) return;
if (hwndHeader == 0) return;
- int i = 0, index = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
+ int i = 0, index = (int)OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
while (i < items.length) {
TreeItem item = items [i];
if (item != null) {
@@ -5551,8 +5639,8 @@ void updateImageList () {
* times, Windows does work making this operation slow. The fix
* is to test for the same image list before setting the new one.
*/
- long /*int*/ hImageList = i == items.length ? 0 : imageList.getHandle ();
- long /*int*/ hOldImageList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0);
+ long hImageList = i == items.length ? 0 : imageList.getHandle ();
+ long hOldImageList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0);
if (hImageList != hOldImageList) {
OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList);
}
@@ -5615,8 +5703,7 @@ void updateOrientation () {
Point size = imageList.getImageSize ();
display.releaseImageList (imageList);
imageList = display.getImageList (style & SWT.RIGHT_TO_LEFT, size.x, size.y);
- for (int i = 0; i < items.length; i++) {
- TreeItem item = items[i];
+ for (TreeItem item : items) {
if (item != null) {
Image image = item.image;
if (image != null) {
@@ -5625,7 +5712,7 @@ void updateOrientation () {
}
}
}
- long /*int*/ hImageList = imageList.getHandle ();
+ long hImageList = imageList.getHandle ();
OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList);
}
if (hwndHeader != 0) {
@@ -5653,19 +5740,29 @@ void updateOrientation () {
}
}
}
- long /*int*/ hImageListHeader = headerImageList.getHandle ();
+ long hImageListHeader = headerImageList.getHandle ();
OS.SendMessage (hwndHeader, OS.HDM_SETIMAGELIST, 0, hImageListHeader);
}
}
}
+/**
+ * Copies Tree's scrollbar state to intermediate parent.
+ *
+ * If Tree has a header, then (Tree+header) get wrapped into intermediate
+ * parent. This parent also has scrollbar, and it is configured to
+ * obscure the Tree's scrollbar - I think this is due to aesthetic
+ * reasons where the new scrollbar also extends over header. Since it
+ * obscures the true scrollbar, it always needs to be in sync with the
+ * true scrollbar.
+ */
void updateScrollBar () {
if (hwndParent != 0) {
if (columnCount != 0 || scrollWidth != 0) {
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
info.fMask = OS.SIF_ALL;
- int itemCount = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
+ int itemCount = (int)OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
if (itemCount == 0) {
OS.GetScrollInfo (hwndParent, OS.SB_VERT, info);
info.nPage = info.nMax + 1;
@@ -5726,12 +5823,12 @@ TCHAR windowClass () {
}
@Override
-long /*int*/ windowProc () {
+long windowProc () {
return TreeProc;
}
@Override
-long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long windowProc (long hwnd, int msg, long wParam, long lParam) {
if (hwndHeader != 0 && hwnd == hwndHeader) {
switch (msg) {
case OS.WM_CONTEXTMENU: {
@@ -5773,7 +5870,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
OS.ScreenToClient (hwnd, pt);
pinfo.x = pt.x;
pinfo.y = pt.y;
- int index = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_HITTEST, 0, pinfo);
+ int index = (int)OS.SendMessage (hwndHeader, OS.HDM_HITTEST, 0, pinfo);
if (0 <= index && index < columnCount && !columns [index].resizable) {
if ((pinfo.flags & (OS.HHT_ONDIVIDER | OS.HHT_ONDIVOPEN)) != 0) {
OS.SetCursor (OS.LoadCursor (0, OS.IDC_ARROW));
@@ -5797,7 +5894,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
setScrollWidth ();
if (ignoreResize) return 0;
setResizeChildren (false);
- long /*int*/ code = callWindowProc (hwnd, OS.WM_SIZE, wParam, lParam);
+ long code = callWindowProc (hwnd, OS.WM_SIZE, wParam, lParam);
sendEvent (SWT.Resize);
if (isDisposed ()) return 0;
if (layout != null) {
@@ -5854,7 +5951,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
info.nPos = info.nTrackPos;
}
OS.SetScrollInfo (handle, OS.SB_VERT, info, true);
- long /*int*/ code = OS.SendMessage (handle, OS.WM_VSCROLL, wParam, lParam);
+ long code = OS.SendMessage (handle, OS.WM_VSCROLL, wParam, lParam);
OS.GetScrollInfo (handle, OS.SB_VERT, info);
OS.SetScrollInfo (hwndParent, OS.SB_VERT, info, true);
return code;
@@ -5871,7 +5968,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
* selected.
*/
if ((style & SWT.MULTI) != 0 || hooks (SWT.EraseItem) || hooks (SWT.PaintItem)) {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
TreeItem [] items = new TreeItem [10];
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM | OS.TVIF_STATE;
@@ -5896,7 +5993,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
rect.left = Math.max (rect.left, clientRect.left);
rect.right = Math.min (rect.right, clientRect.right);
}
- long /*int*/ hRgn = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom);
+ long hRgn = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom);
for (int i = 1; i < count; i++) {
if (rect.bottom - rect.top > DRAG_IMAGE_SIZE) break;
if (rect.bottom > clientRect.bottom) break;
@@ -5908,7 +6005,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
itemRect.left = Math.max (itemRect.left, clientRect.left);
itemRect.right = Math.min (itemRect.right, clientRect.right);
}
- long /*int*/ rectRgn = OS.CreateRectRgn (itemRect.left, itemRect.top, itemRect.right, itemRect.bottom);
+ long rectRgn = OS.CreateRectRgn (itemRect.left, itemRect.top, itemRect.right, itemRect.bottom);
OS.CombineRgn (hRgn, hRgn, rectRgn, OS.RGN_OR);
OS.DeleteObject (rectRgn);
rect.bottom = itemRect.bottom;
@@ -5917,8 +6014,8 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
OS.GetRgnBox (hRgn, rect);
/* Create resources */
- long /*int*/ hdc = OS.GetDC (handle);
- long /*int*/ memHdc = OS.CreateCompatibleDC (hdc);
+ long hdc = OS.GetDC (handle);
+ long memHdc = OS.CreateCompatibleDC (hdc);
BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER ();
bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
bmiHeader.biWidth = rect.right - rect.left;
@@ -5928,10 +6025,10 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
bmiHeader.biCompression = OS.BI_RGB;
byte [] bmi = new byte [BITMAPINFOHEADER.sizeof];
OS.MoveMemory (bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
- long /*int*/ [] pBits = new long /*int*/ [1];
- long /*int*/ memDib = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
+ long [] pBits = new long [1];
+ long memDib = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
if (memDib == 0) error (SWT.ERROR_NO_HANDLES);
- long /*int*/ oldMemBitmap = OS.SelectObject (memHdc, memDib);
+ long oldMemBitmap = OS.SelectObject (memHdc, memDib);
int colorKey = 0x0000FD;
POINT pt = new POINT ();
OS.SetWindowOrgEx (memHdc, rect.left, rect.top, pt);
@@ -5963,7 +6060,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
}
@Override
-LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_CHAR (long wParam, long lParam) {
LRESULT result = super.WM_CHAR (wParam, lParam);
if (result != null) return result;
/*
@@ -5975,9 +6072,9 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
* The fix is to avoid calling the tree window
* proc in these cases.
*/
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case ' ': {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (hItem != 0) {
hAnchor = hItem;
OS.SendMessage (handle, OS.TVM_ENSUREVISIBLE, 0, hItem);
@@ -5995,8 +6092,8 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
}
tvItem.state = state << 12;
OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
- long /*int*/ id = OS.SendMessage (handle, OS.TVM_MAPHTREEITEMTOACCID, hItem, 0);
- OS.NotifyWinEvent (OS.EVENT_OBJECT_FOCUS, handle, OS.OBJID_CLIENT, (int)/*64*/id);
+ long id = OS.SendMessage (handle, OS.TVM_MAPHTREEITEMTOACCID, hItem, 0);
+ OS.NotifyWinEvent (OS.EVENT_OBJECT_FOCUS, handle, OS.OBJID_CLIENT, (int)id);
}
tvItem.stateMask = OS.TVIS_SELECTED;
OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
@@ -6010,7 +6107,7 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
tvItem.state |= OS.TVIS_SELECTED;
}
OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
- TreeItem item = _getItem (hItem, (int)/*64*/tvItem.lParam);
+ TreeItem item = _getItem (hItem, (int)tvItem.lParam);
Event event = new Event ();
event.item = item;
sendSelectionEvent (SWT.Selection, event, false);
@@ -6033,7 +6130,7 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
* using NM_RETURN.
*/
Event event = new Event ();
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (hItem != 0) event.item = _getItem (hItem);
sendSelectionEvent (SWT.DefaultSelection, event, false);
return LRESULT.ZERO;
@@ -6045,7 +6142,7 @@ LRESULT WM_CHAR (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_ERASEBKGND (long wParam, long lParam) {
LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
if ((style & SWT.DOUBLE_BUFFERED) != 0) return LRESULT.ONE;
if (findImageControl () != null) return LRESULT.ONE;
@@ -6053,7 +6150,7 @@ LRESULT WM_ERASEBKGND (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_GETOBJECT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_GETOBJECT (long wParam, long lParam) {
/*
* Ensure that there is an accessible object created for this
* control because support for checked item and tree column
@@ -6067,7 +6164,7 @@ LRESULT WM_GETOBJECT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_HSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_HSCROLL (long wParam, long lParam) {
boolean fixScroll = false;
if ((style & SWT.DOUBLE_BUFFERED) != 0) {
fixScroll = (style & SWT.VIRTUAL) != 0 || hooks (SWT.EraseItem) || hooks (SWT.PaintItem);
@@ -6090,10 +6187,10 @@ LRESULT WM_HSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KEYDOWN (long wParam, long lParam) {
LRESULT result = super.WM_KEYDOWN (wParam, lParam);
if (result != null) return result;
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_LEFT:
case OS.VK_RIGHT:
/*
@@ -6102,13 +6199,13 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
* The fix is to replace VK_LEFT by VK_RIGHT and VK_RIGHT by VK_LEFT
* when the current orientation differs from the orientation used to
* create the control.
- */
- boolean isRTL = (style & SWT.RIGHT_TO_LEFT) != 0;
- if (isRTL != createdAsRTL) {
- long /*int*/ code = callWindowProc (handle, OS.WM_KEYDOWN, wParam == OS.VK_RIGHT ? OS.VK_LEFT : OS.VK_RIGHT, lParam);
- return new LRESULT (code);
- }
- break;
+ */
+ boolean isRTL = (style & SWT.RIGHT_TO_LEFT) != 0;
+ if (isRTL != createdAsRTL) {
+ long code = callWindowProc (handle, OS.WM_KEYDOWN, wParam == OS.VK_RIGHT ? OS.VK_LEFT : OS.VK_RIGHT, lParam);
+ return new LRESULT (code);
+ }
+ break;
case OS.VK_SPACE:
/*
* Ensure that the window proc does not process VK_SPACE
@@ -6141,17 +6238,17 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
if (itemToolTipHandle != 0) OS.ShowWindow (itemToolTipHandle, OS.SW_HIDE);
if ((style & SWT.SINGLE) != 0) break;
if (OS.GetKeyState (OS.VK_SHIFT) < 0) {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (hItem != 0) {
if (hAnchor == 0) hAnchor = hItem;
ignoreSelect = ignoreDeselect = true;
- long /*int*/ code = callWindowProc (handle, OS.WM_KEYDOWN, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_KEYDOWN, wParam, lParam);
ignoreSelect = ignoreDeselect = false;
- long /*int*/ hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
tvItem.stateMask = OS.TVIS_SELECTED;
- long /*int*/ hDeselectItem = hItem;
+ long hDeselectItem = hItem;
RECT rect1 = new RECT ();
if (!OS.TreeView_GetItemRect (handle, hAnchor, rect1, false)) {
hAnchor = hItem;
@@ -6165,7 +6262,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
hDeselectItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, flags, hDeselectItem);
}
- long /*int*/ hSelectItem = hAnchor;
+ long hSelectItem = hAnchor;
OS.TreeView_GetItemRect (handle, hNewItem, rect1, false);
OS.TreeView_GetItemRect (handle, hSelectItem, rect2, false);
tvItem.state = OS.TVIS_SELECTED;
@@ -6181,13 +6278,13 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
tvItem.hItem = hNewItem;
OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
Event event = new Event ();
- event.item = _getItem (hNewItem, (int)/*64*/tvItem.lParam);
+ event.item = _getItem (hNewItem, (int)tvItem.lParam);
sendSelectionEvent (SWT.Selection, event, false);
return new LRESULT (code);
}
}
if (OS.GetKeyState (OS.VK_CONTROL) < 0) {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (hItem != 0) {
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
@@ -6195,8 +6292,8 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
tvItem.hItem = hItem;
OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
boolean oldSelected = (tvItem.state & OS.TVIS_SELECTED) != 0;
- long /*int*/ hNewItem = 0;
- switch ((int)/*64*/wParam) {
+ long hNewItem = 0;
+ switch ((int)wParam) {
case OS.VK_UP:
hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PREVIOUSVISIBLE, hItem);
break;
@@ -6218,7 +6315,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
OS.GetClientRect (handle, clientRect);
hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
do {
- long /*int*/ hVisible = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hNewItem);
+ long hVisible = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hNewItem);
if (hVisible == 0) break;
if (!OS.TreeView_GetItemRect (handle, hVisible, rect, false)) break;
if (rect.bottom > clientRect.bottom) break;
@@ -6269,7 +6366,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
}
}
- long /*int*/ code = callWindowProc (handle, OS.WM_KEYDOWN, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_KEYDOWN, wParam, lParam);
hAnchor = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
return new LRESULT (code);
}
@@ -6278,7 +6375,7 @@ LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_KILLFOCUS (long wParam, long lParam) {
/*
* Bug in Windows. When a tree item that has an image
* with alpha is expanded or collapsed, the area where
@@ -6305,7 +6402,7 @@ LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDBLCLK (long wParam, long lParam) {
TVHITTESTINFO lpht = new TVHITTESTINFO ();
lpht.x = OS.GET_X_LPARAM (lParam);
lpht.y = OS.GET_Y_LPARAM (lParam);
@@ -6315,8 +6412,8 @@ LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
if ((lpht.flags & OS.TVHT_ONITEMSTATEICON) != 0) {
Display display = this.display;
display.captureChanged = false;
- sendMouseEvent (SWT.MouseDown, 1, handle, OS.WM_LBUTTONDOWN, wParam, lParam);
- if (!sendMouseEvent (SWT.MouseDoubleClick, 1, handle, OS.WM_LBUTTONDBLCLK, wParam, lParam)) {
+ sendMouseEvent (SWT.MouseDown, 1, handle, lParam);
+ if (!sendMouseEvent (SWT.MouseDoubleClick, 1, handle, lParam)) {
if (!display.captureChanged && !isDisposed ()) {
if (OS.GetCapture () != handle) OS.SetCapture (handle);
}
@@ -6339,10 +6436,10 @@ LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
}
tvItem.state = state << 12;
OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
- long /*int*/ id = OS.SendMessage (handle, OS.TVM_MAPHTREEITEMTOACCID, tvItem.hItem, 0);
- OS.NotifyWinEvent (OS.EVENT_OBJECT_FOCUS, handle, OS.OBJID_CLIENT, (int)/*64*/id);
+ long id = OS.SendMessage (handle, OS.TVM_MAPHTREEITEMTOACCID, tvItem.hItem, 0);
+ OS.NotifyWinEvent (OS.EVENT_OBJECT_FOCUS, handle, OS.OBJID_CLIENT, (int)id);
Event event = new Event ();
- event.item = _getItem (tvItem.hItem, (int)/*64*/tvItem.lParam);
+ event.item = _getItem (tvItem.hItem, (int)tvItem.lParam);
event.detail = SWT.CHECK;
sendSelectionEvent (SWT.Selection, event, false);
return LRESULT.ZERO;
@@ -6373,7 +6470,7 @@ LRESULT WM_LBUTTONDBLCLK (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_LBUTTONDOWN (long wParam, long lParam) {
/*
* In a multi-select tree, if the user is collapsing a subtree that
* contains selected items, clear the selection from these items and
@@ -6388,14 +6485,14 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
if (lpht.hItem == 0 || (lpht.flags & OS.TVHT_ONITEMBUTTON) != 0) {
Display display = this.display;
display.captureChanged = false;
- if (!sendMouseEvent (SWT.MouseDown, 1, handle, OS.WM_LBUTTONDOWN, wParam, lParam)) {
+ if (!sendMouseEvent (SWT.MouseDown, 1, handle, lParam)) {
if (!display.captureChanged && !isDisposed ()) {
if (OS.GetCapture () != handle) OS.SetCapture (handle);
}
return LRESULT.ZERO;
}
boolean fixSelection = false, deselected = false;
- long /*int*/ hOldSelection = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hOldSelection = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (lpht.hItem != 0 && (style & SWT.MULTI) != 0) {
if (hOldSelection != 0) {
TVITEM tvItem = new TVITEM ();
@@ -6405,7 +6502,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
if ((tvItem.state & OS.TVIS_EXPANDED) != 0) {
fixSelection = true;
tvItem.stateMask = OS.TVIS_SELECTED;
- long /*int*/ hNext = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, lpht.hItem);
+ long hNext = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, lpht.hItem);
while (hNext != 0) {
if (hNext == hAnchor) hAnchor = 0;
tvItem.hItem = hNext;
@@ -6413,7 +6510,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
if ((tvItem.state & OS.TVIS_SELECTED) != 0) deselected = true;
tvItem.state = 0;
OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
- long /*int*/ hItem = hNext = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hNext);
+ long hItem = hNext = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hNext);
while (hItem != 0 && hItem != lpht.hItem) {
hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hItem);
}
@@ -6427,14 +6524,14 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
hSelect = lpht.hItem;
ignoreDeselect = ignoreSelect = lockSelection = true;
}
- long /*int*/ code = callWindowProc (handle, OS.WM_LBUTTONDOWN, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_LBUTTONDOWN, wParam, lParam);
/* Bug 225404 */
if (OS.GetFocus () != handle) OS.SetFocus (handle);
if (fixSelection) {
hSelect = 0;
ignoreDeselect = ignoreSelect = lockSelection = false;
}
- long /*int*/ hNewSelection = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hNewSelection = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (hOldSelection != hNewSelection) hAnchor = hNewSelection;
if (dragStarted) {
if (!display.captureChanged && !isDisposed ()) {
@@ -6455,7 +6552,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
if ((bits & OS.TVS_FULLROWSELECT) == 0) {
if (OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0) == 0) {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (hItem != 0) {
RECT rect = new RECT ();
if (OS.TreeView_GetItemRect (handle, hItem, rect, false)) {
@@ -6478,7 +6575,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
if ((lpht.flags & OS.TVHT_ONITEMSTATEICON) != 0) {
Display display = this.display;
display.captureChanged = false;
- if (!sendMouseEvent (SWT.MouseDown, 1, handle, OS.WM_LBUTTONDOWN, wParam, lParam)) {
+ if (!sendMouseEvent (SWT.MouseDown, 1, handle, lParam)) {
if (!display.captureChanged && !isDisposed ()) {
if (OS.GetCapture () != handle) OS.SetCapture (handle);
}
@@ -6501,10 +6598,10 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
tvItem.state = state << 12;
OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
- long /*int*/ id = OS.SendMessage (handle, OS.TVM_MAPHTREEITEMTOACCID, tvItem.hItem, 0);
- OS.NotifyWinEvent (OS.EVENT_OBJECT_FOCUS, handle, OS.OBJID_CLIENT, (int)/*64*/id);
+ long id = OS.SendMessage (handle, OS.TVM_MAPHTREEITEMTOACCID, tvItem.hItem, 0);
+ OS.NotifyWinEvent (OS.EVENT_OBJECT_FOCUS, handle, OS.OBJID_CLIENT, (int)id);
Event event = new Event ();
- event.item = _getItem (tvItem.hItem, (int)/*64*/tvItem.lParam);
+ event.item = _getItem (tvItem.hItem, (int)tvItem.lParam);
event.detail = SWT.CHECK;
sendSelectionEvent (SWT.Selection, event, false);
return LRESULT.ZERO;
@@ -6539,13 +6636,13 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
if ((lpht.flags & OS.TVHT_ONITEM) == 0) {
Display display = this.display;
display.captureChanged = false;
- if (!sendMouseEvent (SWT.MouseDown, 1, handle, OS.WM_LBUTTONDOWN, wParam, lParam)) {
+ if (!sendMouseEvent (SWT.MouseDown, 1, handle, lParam)) {
if (!display.captureChanged && !isDisposed ()) {
if (OS.GetCapture () != handle) OS.SetCapture (handle);
}
return LRESULT.ZERO;
}
- long /*int*/ code = callWindowProc (handle, OS.WM_LBUTTONDOWN, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_LBUTTONDOWN, wParam, lParam);
/* Bug 225404 */
if (OS.GetFocus () != handle) OS.SetFocus (handle);
if (!display.captureChanged && !isDisposed ()) {
@@ -6567,7 +6664,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
/* Get the selected state of the last selected item */
- long /*int*/ hOldItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hOldItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if ((style & SWT.MULTI) != 0) {
tvItem.hItem = hOldItem;
OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
@@ -6597,7 +6694,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
* In SWT, the InvalidateRect() that caused the pixel corruption
* is found in Composite.WM_UPDATEUISTATE().
*/
- int uiState = (int)/*64*/OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
+ int uiState = (int)OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
if ((uiState & OS.UISF_HIDEFOCUS) != 0) {
OS.SendMessage (handle, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0);
}
@@ -6611,7 +6708,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
/* Do the selection */
Display display = this.display;
display.captureChanged = false;
- if (!sendMouseEvent (SWT.MouseDown, 1, handle, OS.WM_LBUTTONDOWN, wParam, lParam)) {
+ if (!sendMouseEvent (SWT.MouseDown, 1, handle, lParam)) {
if (!display.captureChanged && !isDisposed ()) {
if (OS.GetCapture () != handle) OS.SetCapture (handle);
}
@@ -6620,10 +6717,10 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
hSelect = lpht.hItem;
dragStarted = gestureCompleted = false;
ignoreDeselect = ignoreSelect = true;
- long /*int*/ code = callWindowProc (handle, OS.WM_LBUTTONDOWN, wParam, lParam);
+ long code = callWindowProc (handle, OS.WM_LBUTTONDOWN, wParam, lParam);
/* Bug 225404 */
if (OS.GetFocus () != handle) OS.SetFocus (handle);
- long /*int*/ hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (fakeSelection) {
if (hOldItem == 0 || (hNewItem == hOldItem && lpht.hItem != hOldItem)) {
OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_CARET, lpht.hItem);
@@ -6696,14 +6793,13 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
if ((wParam & OS.MK_CONTROL) == 0) {
if (!hittestSelected || !dragStarted) {
tvItem.state = 0;
- long /*int*/ oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
+ long oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, TreeProc);
if ((style & SWT.VIRTUAL) != 0) {
- long /*int*/ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
deselect (hItem, tvItem, hNewItem);
} else {
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
+ for (TreeItem item : items) {
if (item != null && item.handle != hNewItem) {
tvItem.hItem = item.handle;
OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
@@ -6722,7 +6818,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
if (OS.TreeView_GetItemRect (handle, hNewItem, rect2, false)) {
int flags = rect1.top < rect2.top ? OS.TVGN_NEXTVISIBLE : OS.TVGN_PREVIOUSVISIBLE;
tvItem.state = OS.TVIS_SELECTED;
- long /*int*/ hItem = tvItem.hItem = hAnchor;
+ long hItem = tvItem.hItem = hAnchor;
OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
while (hItem != hNewItem) {
tvItem.hItem = hItem;
@@ -6743,7 +6839,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
Event event = new Event ();
- event.item = _getItem (tvItem.hItem, (int)/*64*/tvItem.lParam);
+ event.item = _getItem (tvItem.hItem, (int)tvItem.lParam);
sendSelectionEvent (SWT.Selection, event, false);
}
gestureCompleted = false;
@@ -6761,7 +6857,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
} else {
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
if ((bits & OS.TVS_DISABLEDRAGDROP) == 0) {
- sendMouseEvent (SWT.MouseUp, 1, handle, OS.WM_LBUTTONUP, wParam, lParam);
+ sendMouseEvent (SWT.MouseUp, 1, handle, lParam);
}
}
dragStarted = false;
@@ -6769,7 +6865,7 @@ LRESULT WM_LBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSEMOVE (long wParam, long lParam) {
Display display = this.display;
LRESULT result = super.WM_MOUSEMOVE (wParam, lParam);
if (result != null) return result;
@@ -6819,21 +6915,21 @@ LRESULT WM_MOUSEMOVE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_MOUSEWHEEL (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOUSEWHEEL (long wParam, long lParam) {
LRESULT result = super.WM_MOUSEWHEEL (wParam, lParam);
if (itemToolTipHandle != 0) OS.ShowWindow (itemToolTipHandle, OS.SW_HIDE);
return result;
}
@Override
-LRESULT WM_MOVE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_MOVE (long wParam, long lParam) {
if (itemToolTipHandle != 0) OS.ShowWindow (itemToolTipHandle, OS.SW_HIDE);
if (ignoreResize) return null;
return super.WM_MOVE (wParam, lParam);
}
@Override
-LRESULT WM_RBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_RBUTTONDOWN (long wParam, long lParam) {
/*
* Feature in Windows. The receiver uses WM_RBUTTONDOWN
* to initiate a drag/drop operation depending on how the
@@ -6844,7 +6940,7 @@ LRESULT WM_RBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
*/
Display display = this.display;
display.captureChanged = false;
- if (!sendMouseEvent (SWT.MouseDown, 3, handle, OS.WM_RBUTTONDOWN, wParam, lParam)) {
+ if (!sendMouseEvent (SWT.MouseDown, 3, handle, lParam)) {
if (!display.captureChanged && !isDisposed ()) {
if (OS.GetCapture () != handle) OS.SetCapture (handle);
}
@@ -6904,7 +7000,7 @@ LRESULT WM_RBUTTONDOWN (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_PAINT (long wParam, long lParam) {
if ((state & DISPOSE_SENT) != 0) return LRESULT.ZERO;
if (shrink && !ignoreShrink && items != null) {
@@ -6926,12 +7022,12 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
if ((style & SWT.DOUBLE_BUFFERED) != 0 || findImageControl () != null) {
boolean doubleBuffer = true;
if (explorerTheme) {
- int exStyle = (int)/*64*/OS.SendMessage (handle, OS.TVM_GETEXTENDEDSTYLE, 0, 0);
+ int exStyle = (int)OS.SendMessage (handle, OS.TVM_GETEXTENDEDSTYLE, 0, 0);
if ((exStyle & OS.TVS_EX_DOUBLEBUFFER) != 0) doubleBuffer = false;
}
if (doubleBuffer) {
GC gc = null;
- long /*int*/ paintDC = 0;
+ long paintDC = 0;
PAINTSTRUCT ps = new PAINTSTRUCT ();
boolean hooksPaint = hooks (SWT.Paint) || filters (SWT.Paint);
if (hooksPaint) {
@@ -6946,12 +7042,12 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
int width = ps.right - ps.left;
int height = ps.bottom - ps.top;
if (width != 0 && height != 0) {
- long /*int*/ hDC = OS.CreateCompatibleDC (paintDC);
+ long hDC = OS.CreateCompatibleDC (paintDC);
POINT lpPoint1 = new POINT (), lpPoint2 = new POINT ();
OS.SetWindowOrgEx (hDC, ps.left, ps.top, lpPoint1);
OS.SetBrushOrgEx (hDC, ps.left, ps.top, lpPoint2);
- long /*int*/ hBitmap = OS.CreateCompatibleBitmap (paintDC, width, height);
- long /*int*/ hOldBitmap = OS.SelectObject (hDC, hBitmap);
+ long hBitmap = OS.CreateCompatibleBitmap (paintDC, width, height);
+ long hOldBitmap = OS.SelectObject (hDC, hBitmap);
RECT rect = new RECT ();
OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom);
drawBackground (hDC, rect);
@@ -6983,7 +7079,7 @@ LRESULT WM_PAINT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETCURSOR (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETCURSOR (long wParam, long lParam) {
LRESULT result = super.WM_SETCURSOR (wParam, lParam);
if (result != null) return result;
@@ -7006,7 +7102,7 @@ LRESULT WM_SETCURSOR (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFOCUS (long wParam, long lParam) {
/*
* Bug in Windows. When a tree item that has an image
* with alpha is expanded or collapsed, the area where
@@ -7033,7 +7129,7 @@ LRESULT WM_SETFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETFONT (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETFONT (long wParam, long lParam) {
LRESULT result = super.WM_SETFONT (wParam, lParam);
if (result != null) return result;
if (hwndHeader != 0) {
@@ -7059,7 +7155,7 @@ LRESULT WM_SETFONT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SETREDRAW (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SETREDRAW (long wParam, long lParam) {
LRESULT result = super.WM_SETREDRAW (wParam, lParam);
if (result != null) return result;
if (itemToolTipHandle != 0) OS.ShowWindow (itemToolTipHandle, OS.SW_HIDE);
@@ -7074,12 +7170,12 @@ LRESULT WM_SETREDRAW (long /*int*/ wParam, long /*int*/ lParam) {
* NOTE: This problem is intermittent and happens on
* Windows Vista running under the theme manager.
*/
- long /*int*/ code = OS.DefWindowProc (handle, OS.WM_SETREDRAW, wParam, lParam);
+ long code = OS.DefWindowProc (handle, OS.WM_SETREDRAW, wParam, lParam);
return code == 0 ? LRESULT.ZERO : new LRESULT (code);
}
@Override
-LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SIZE (long wParam, long lParam) {
if (itemToolTipHandle != 0) OS.ShowWindow (itemToolTipHandle, OS.SW_HIDE);
/*
* Bug in Windows. When TVS_NOHSCROLL is set when the
@@ -7106,7 +7202,7 @@ LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_SYSCOLORCHANGE (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_SYSCOLORCHANGE (long wParam, long lParam) {
LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
if (result != null) return result;
/*
@@ -7123,7 +7219,7 @@ LRESULT WM_SYSCOLORCHANGE (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_VSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_VSCROLL (long wParam, long lParam) {
boolean fixScroll = false;
if ((style & SWT.DOUBLE_BUFFERED) != 0) {
int code = OS.LOWORD (wParam);
@@ -7156,7 +7252,7 @@ LRESULT WM_VSCROLL (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT WM_TIMER (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT WM_TIMER (long wParam, long lParam) {
LRESULT result = super.WM_TIMER (wParam, lParam);
if (result != null) return result;
@@ -7170,7 +7266,7 @@ LRESULT WM_TIMER (long /*int*/ wParam, long /*int*/ lParam) {
* Note: Just killing the timer could cause some internal clean up task related to the
* animation not to run.
*/
- long /*int*/ bits = OS.SendMessage (handle, OS.TVM_GETEXTENDEDSTYLE, 0, 0);
+ long bits = OS.SendMessage (handle, OS.TVM_GETEXTENDEDSTYLE, 0, 0);
if ((bits & OS.TVS_EX_FADEINOUTEXPANDOS) != 0) {
if (!OS.IsWindowVisible (handle)) {
if (lastTimerID == wParam) {
@@ -7193,7 +7289,7 @@ LRESULT WM_TIMER (long /*int*/ wParam, long /*int*/ lParam) {
};
@Override
-LRESULT wmColorChild (long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmColorChild (long wParam, long lParam) {
if (findImageControl () != null) {
return new LRESULT (OS.GetStockObject (OS.NULL_BRUSH));
}
@@ -7208,12 +7304,12 @@ LRESULT wmColorChild (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmNotify (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
- if (hdr.hwndFrom == itemToolTipHandle) {
+LRESULT wmNotify (NMHDR hdr, long wParam, long lParam) {
+ if (hdr.hwndFrom == itemToolTipHandle && itemToolTipHandle != 0) {
LRESULT result = wmNotifyToolTip (hdr, wParam, lParam);
if (result != null) return result;
}
- if (hdr.hwndFrom == hwndHeader) {
+ if (hdr.hwndFrom == hwndHeader && hwndHeader != 0) {
LRESULT result = wmNotifyHeader (hdr, wParam, lParam);
if (result != null) return result;
}
@@ -7221,7 +7317,7 @@ LRESULT wmNotify (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
-LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) {
switch (hdr.code) {
case OS.TVN_GETDISPINFO: {
NMTVDISPINFO lptvdi = new NMTVDISPINFO ();
@@ -7248,7 +7344,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
*/
if (!ignoreShrink) {
if (items != null && lptvdi.lParam != -1) {
- if (items [(int)/*64*/lptvdi.lParam] != null && items [(int)/*64*/lptvdi.lParam].cached) {
+ if (items [(int)lptvdi.lParam] != null && items [(int)lptvdi.lParam].cached) {
checkVisible = false;
}
}
@@ -7277,14 +7373,14 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
* fix is to query the field from the item instead
* of using the struct.
*/
- int id = (int)/*64*/lptvdi.lParam;
+ int id = (int)lptvdi.lParam;
if ((style & SWT.VIRTUAL) != 0) {
if (id == -1) {
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
tvItem.hItem = lptvdi.hItem;
OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- id = (int)/*64*/tvItem.lParam;
+ id = (int)tvItem.lParam;
}
}
TreeItem item = _getItem (lptvdi.hItem, id);
@@ -7313,7 +7409,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
}
int index = 0;
if (hwndHeader != 0) {
- index = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
+ index = (int)OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
}
if ((lptvdi.mask & OS.TVIF_TEXT) != 0) {
String string = null;
@@ -7475,7 +7571,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
TVITEM tvItem = treeView.itemNew;
hAnchor = tvItem.hItem;
Event event = new Event ();
- event.item = _getItem (tvItem.hItem, (int)/*64*/tvItem.lParam);
+ event.item = _getItem (tvItem.hItem, (int)tvItem.lParam);
sendSelectionEvent (SWT.Selection, event, false);
}
updateScrollBar ();
@@ -7511,7 +7607,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
* items. The fix is to check for null.
*/
if (items == null) break;
- TreeItem item = _getItem (tvItem.hItem, (int)/*64*/tvItem.lParam);
+ TreeItem item = _getItem (tvItem.hItem, (int)tvItem.lParam);
if (item == null) break;
Event event = new Event ();
event.item = item;
@@ -7541,7 +7637,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
* The fix is to detect this case and run the TVN_ITEMEXPANDED
* code in this method.
*/
- long /*int*/ hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, tvItem.hItem);
+ long hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, tvItem.hItem);
runExpanded = hFirstItem == 0;
}
if (!runExpanded) break;
@@ -7609,7 +7705,7 @@ LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
return super.wmNotifyChild (hdr, wParam, lParam);
}
-LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotifyHeader (NMHDR hdr, long wParam, long lParam) {
/*
* Feature in Windows. On NT, the automatically created
* header control is created as a UNICODE window, not an
@@ -7655,10 +7751,16 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
int pixel = getHeaderBackgroundPixel();
if ((nmcd.uItemState & OS.CDIS_SELECTED) != 0) {
pixel = getDifferentColor(pixel);
- } else if (columns[(int) nmcd.dwItemSpec] == sortColumn && sortDirection != SWT.NONE) {
- pixel = getSlightlyDifferentColor(pixel);
}
- long /*int*/ brush = OS.CreateSolidBrush(pixel);
+ /*
+ * Don't change the header background color for set selected column, similar to
+ * Windows 10 which itself does not use any different color for sort header. For
+ * more details refer bug 570468
+ */
+// else if (columns[(int) nmcd.dwItemSpec] == sortColumn && sortDirection != SWT.NONE) {
+// pixel = getSlightlyDifferentColor(pixel);
+// }
+ long brush = OS.CreateSolidBrush(pixel);
OS.FillRect(nmcd.hdc, rect, brush);
OS.DeleteObject(brush);
@@ -7683,8 +7785,8 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
if (columns[i] == sortColumn && sortDirection != SWT.NONE) {
// the display.getSortImage looks terrible after scaling up.
- long /*int*/ pen = OS.CreatePen (OS.PS_SOLID, 1, getHeaderForegroundPixel());
- long /*int*/ oldPen = OS.SelectObject (nmcd.hdc, pen);
+ long pen = OS.CreatePen (OS.PS_SOLID, 1, getHeaderForegroundPixel());
+ long oldPen = OS.SelectObject (nmcd.hdc, pen);
int center = rects[i].left + (rects[i].right - rects[i].left) / 2;
/*
* Sort indicator size needs to scale as per the Native Windows OS DPI level
@@ -7705,8 +7807,8 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
/* Windows 7 and 10 always draw a nearly invisible vertical line between the columns, even if lines are disabled.
This line uses no fixed color constant, but calculates it from the background color.
The method getSlightlyDifferentColor gives us a color, that is near enough to the windows algorithm. */
- long /*int*/ pen = OS.CreatePen (OS.PS_SOLID, getGridLineWidthInPixels(), getSlightlyDifferentColor(getHeaderBackgroundPixel()));
- long /*int*/ oldPen = OS.SelectObject (nmcd.hdc, pen);
+ long pen = OS.CreatePen (OS.PS_SOLID, getGridLineWidthInPixels(), getSlightlyDifferentColor(getHeaderBackgroundPixel()));
+ long oldPen = OS.SelectObject (nmcd.hdc, pen);
OS.Polyline(nmcd.hdc, new int[] {rects[i].right-1, rects[i].top, rects[i].right-1, rects[i].bottom}, 2);
OS.SelectObject (nmcd.hdc, oldPen);
OS.DeleteObject (pen);
@@ -7760,15 +7862,15 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
// draw background of the 'no column' area
RECT rect = new RECT();
OS.SetRect(rect, lastColumnRight, nmcd.top, nmcd.right, nmcd.bottom-1);
- long /*int*/ brush = OS.CreateSolidBrush(getHeaderBackgroundPixel());
+ long brush = OS.CreateSolidBrush(getHeaderBackgroundPixel());
OS.FillRect(nmcd.hdc, rect, brush);
OS.DeleteObject(brush);
}
// always draw the highlighted border at the end, to avoid overdrawing by other borders.
if (highlightedHeaderDividerX != -1) {
- long /*int*/ pen = OS.CreatePen (OS.PS_SOLID, 4, OS.GetSysColor(OS.COLOR_HIGHLIGHT));
- long /*int*/ oldPen = OS.SelectObject (nmcd.hdc, pen);
+ long pen = OS.CreatePen (OS.PS_SOLID, 4, OS.GetSysColor(OS.COLOR_HIGHLIGHT));
+ long oldPen = OS.SelectObject (nmcd.hdc, pen);
OS.Polyline(nmcd.hdc, new int[] {highlightedHeaderDividerX, nmcd.top, highlightedHeaderDividerX, nmcd.bottom}, 2);
OS.SelectObject (nmcd.hdc, oldPen);
OS.DeleteObject (pen);
@@ -7816,7 +7918,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
OS.SendMessage (hwndHeader, OS.HDM_GETORDERARRAY, columnCount, order);
int index = 0;
while (index < order.length) {
- if (order [index] == phdn.iItem) break;
+ if (order [index] == phdn.iItem) break;
index++;
}
if (index == order.length) index = 0;
@@ -7936,7 +8038,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT wmNotifyToolTip (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNotifyToolTip (NMHDR hdr, long wParam, long lParam) {
switch (hdr.code) {
case OS.NM_CUSTOMDRAW: {
NMTTCUSTOMDRAW nmcd = new NMTTCUSTOMDRAW ();
@@ -7969,7 +8071,7 @@ LRESULT wmNotifyToolTip (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long /*int*/ lParam) {
+LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) {
switch (nmcd.dwDrawStage) {
case OS.CDDS_PREPAINT: {
if (isCustomToolTip ()) {
@@ -7993,10 +8095,10 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long /*int*/ lParam) {
OS.POINTSTOPOINT (pt, pos);
OS.ScreenToClient (handle, pt);
if (findCell (pt.x, pt.y, item, index, cellRect, itemRect)) {
- long /*int*/ hDC = OS.GetDC (handle);
- long /*int*/ hFont = item [0].fontHandle (index [0]);
+ long hDC = OS.GetDC (handle);
+ long hFont = item [0].fontHandle (index [0]);
if (hFont == -1) hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
- long /*int*/ oldFont = OS.SelectObject (hDC, hFont);
+ long oldFont = OS.SelectObject (hDC, hFont);
boolean drawForeground = true;
cellRect [0] = item [0].getBounds (index [0], true, true, false, false, false, hDC);
if (hooks (SWT.EraseItem)) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java
index 1cd30929ad..495b10a756 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java
@@ -321,7 +321,7 @@ public int getWidth () {
int getWidthInPixels () {
int index = parent.indexOf (this);
if (index == -1) return 0;
- long /*int*/ hwndHeader = parent.hwndHeader;
+ long hwndHeader = parent.hwndHeader;
if (hwndHeader == 0) return 0;
HDITEM hdItem = new HDITEM ();
hdItem.mask = OS.HDI_WIDTH;
@@ -345,18 +345,18 @@ public void pack () {
int index = parent.indexOf (this);
if (index == -1) return;
int columnWidth = 0;
- long /*int*/ hwnd = parent.handle, hwndHeader = parent.hwndHeader;
+ long hwnd = parent.handle, hwndHeader = parent.hwndHeader;
RECT headerRect = new RECT ();
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect);
- long /*int*/ hDC = OS.GetDC (hwnd);
- long /*int*/ oldFont = 0, newFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
+ long hDC = OS.GetDC (hwnd);
+ long oldFont = 0, newFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM | OS.TVIF_STATE;
tvItem.hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
while (tvItem.hItem != 0) {
OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
- TreeItem item = tvItem.lParam != -1 ? parent.items [(int)/*64*/tvItem.lParam] : null;
+ TreeItem item = tvItem.lParam != -1 ? parent.items [(int)tvItem.lParam] : null;
if (item != null) {
int itemRight = 0;
if (parent.hooks (SWT.MeasureItem)) {
@@ -366,7 +366,7 @@ public void pack () {
Rectangle bounds = event.getBoundsInPixels();
itemRight = bounds.x + bounds.width;
} else {
- long /*int*/ hFont = item.fontHandle (index);
+ long hFont = item.fontHandle (index);
if (hFont != -1) hFont = OS.SelectObject (hDC, hFont);
RECT itemRect = item.getBounds (index, true, true, false, false, false, hDC);
if (hFont != -1) OS.SelectObject (hDC, hFont);
@@ -395,7 +395,7 @@ public void pack () {
}
int margin = 0;
if (hwndHeader != 0) {
- margin = (int)/*64*/OS.SendMessage (hwndHeader, OS.HDM_GETBITMAPMARGIN, 0, 0);
+ margin = (int)OS.SendMessage (hwndHeader, OS.HDM_GETBITMAPMARGIN, 0, 0);
} else {
margin = OS.GetSystemMetrics (OS.SM_CXEDGE) * 3;
}
@@ -493,7 +493,7 @@ public void setAlignment (int alignment) {
if (index == -1 || index == 0) return;
style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
- long /*int*/ hwndHeader = parent.hwndHeader;
+ long hwndHeader = parent.hwndHeader;
if (hwndHeader == 0) return;
HDITEM hdItem = new HDITEM ();
hdItem.mask = OS.HDI_FORMAT;
@@ -504,7 +504,7 @@ public void setAlignment (int alignment) {
if ((style & SWT.RIGHT) == SWT.RIGHT) hdItem.fmt |= OS.HDF_RIGHT;
OS.SendMessage (hwndHeader, OS.HDM_SETITEM, index, hdItem);
if (index != 0) {
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
parent.forceResize ();
RECT rect = new RECT (), headerRect = new RECT ();
OS.GetClientRect (hwnd, rect);
@@ -530,7 +530,7 @@ public void setImage (Image image) {
void setImage (Image image, boolean sort, boolean right) {
int index = parent.indexOf (this);
if (index == -1) return;
- long /*int*/ hwndHeader = parent.hwndHeader;
+ long hwndHeader = parent.hwndHeader;
if (hwndHeader == 0) return;
HDITEM hdItem = new HDITEM ();
hdItem.mask = OS.HDI_FORMAT | OS.HDI_IMAGE | OS.HDI_BITMAP;
@@ -600,7 +600,7 @@ public void setResizable (boolean resizable) {
}
void setSortDirection (int direction) {
- long /*int*/ hwndHeader = parent.hwndHeader;
+ long hwndHeader = parent.hwndHeader;
if (hwndHeader != 0) {
int index = parent.indexOf (this);
if (index == -1) return;
@@ -631,7 +631,7 @@ void setSortDirection (int direction) {
}
OS.SendMessage (hwndHeader, OS.HDM_SETITEM, index, hdItem);
if (OS.IsAppThemed ()) {
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
parent.forceResize ();
RECT rect = new RECT (), headerRect = new RECT ();
OS.GetClientRect (hwnd, rect);
@@ -658,17 +658,17 @@ public void setText (String string) {
* at the end of the text. The fix is to remove
* mnemonic characters.
*/
- long /*int*/ hHeap = OS.GetProcessHeap ();
+ long hHeap = OS.GetProcessHeap ();
char [] buffer = fixMnemonic (string);
int byteCount = buffer.length * TCHAR.sizeof;
- long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ long pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
OS.MoveMemory (pszText, buffer, byteCount);
- long /*int*/ hwndHeader = parent.hwndHeader;
+ long hwndHeader = parent.hwndHeader;
if (hwndHeader == 0) return;
HDITEM hdItem = new HDITEM ();
hdItem.mask = OS.HDI_TEXT;
hdItem.pszText = pszText;
- long /*int*/ result = OS.SendMessage (hwndHeader, OS.HDM_SETITEM, index, hdItem);
+ long result = OS.SendMessage (hwndHeader, OS.HDM_SETITEM, index, hdItem);
if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
if (result == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
}
@@ -703,7 +703,7 @@ public void setText (String string) {
public void setToolTipText (String string) {
checkWidget();
toolTipText = string;
- long /*int*/ hwndHeaderToolTip = parent.headerToolTipHandle;
+ long hwndHeaderToolTip = parent.headerToolTipHandle;
if (hwndHeaderToolTip == 0) {
parent.createHeaderToolTips ();
parent.updateHeaderToolTips ();
@@ -729,7 +729,7 @@ void setWidthInPixels (int width) {
if (width < 0) return;
int index = parent.indexOf (this);
if (index == -1) return;
- long /*int*/ hwndHeader = parent.hwndHeader;
+ long hwndHeader = parent.hwndHeader;
if (hwndHeader == 0) return;
HDITEM hdItem = new HDITEM ();
hdItem.mask = OS.HDI_WIDTH;
@@ -738,7 +738,7 @@ void setWidthInPixels (int width) {
RECT headerRect = new RECT ();
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect);
parent.forceResize ();
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
RECT rect = new RECT ();
OS.GetClientRect (hwnd, rect);
rect.left = headerRect.left;
@@ -747,9 +747,9 @@ void setWidthInPixels (int width) {
}
void updateToolTip (int index) {
- long /*int*/ hwndHeaderToolTip = parent.headerToolTipHandle;
+ long hwndHeaderToolTip = parent.headerToolTipHandle;
if (hwndHeaderToolTip != 0) {
- long /*int*/ hwndHeader = parent.hwndHeader;
+ long hwndHeader = parent.hwndHeader;
RECT rect = new RECT ();
if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, rect) != 0) {
TOOLINFO lpti = new TOOLINFO ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
index 1dd27b6dd0..308ab3297f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -50,7 +50,7 @@ public class TreeItem extends Item {
*
* @noreference This field is not intended to be referenced by clients.
*/
- public long /*int*/ handle;
+ public long handle;
Tree parent;
String [] strings;
Image [] images;
@@ -61,22 +61,14 @@ public class TreeItem extends Item {
int [] cellBackground, cellForeground;
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as last direct child of the tree.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * The fastest way to insert many items is documented in {@link TreeItem#TreeItem(Tree,int,int)}
+ * and {@link TreeItem#setItemCount}
*
* @param parent a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
@@ -91,26 +83,22 @@ public class TreeItem extends Item {
* @see Widget#getStyle
*/
public TreeItem (Tree parent, int style) {
- this (parent, style, OS.TVGN_ROOT, OS.TVI_LAST, 0);
+ this (parent, style, OS.TVI_ROOT, OS.TVI_LAST, 0);
}
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as <code>index</code> direct child of the tree.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * The fastest way to insert many items is:
+ * <ol>
+ * <li>Use {@link Tree#setRedraw} to disable drawing during bulk insert</li>
+ * <li>Insert every item at index 0 (insert them in reverse to get the same result)</li>
+ * <li>Collapse the parent item before inserting (gives massive improvement on Windows)</li>
+ * </ol>
*
* @param parent a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
* @param index the zero-relative index to store the receiver in its parent
*
* @exception IllegalArgumentException <ul>
@@ -125,28 +113,21 @@ public TreeItem (Tree parent, int style) {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
+ * @see Tree#setRedraw
*/
public TreeItem (Tree parent, int style, int index) {
- this (parent, style, OS.TVGN_ROOT, findPrevious (parent, index), 0);
+ this (parent, style, OS.TVI_ROOT, findPrevious (parent, index), 0);
}
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as last direct child of the specified <code>TreeItem</code>.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * The fastest way to insert many items is documented in {@link TreeItem#TreeItem(Tree,int,int)}
+ * and {@link TreeItem#setItemCount}
*
* @param parentItem a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
@@ -165,22 +146,14 @@ public TreeItem (TreeItem parentItem, int style) {
}
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as <code>index</code> direct child of the specified <code>TreeItem</code>.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * The fastest way to insert many items is documented in {@link TreeItem#TreeItem(Tree,int,int)}
+ * and {@link TreeItem#setItemCount}
*
* @param parentItem a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
* @param index the zero-relative index to store the receiver in its parent
*
* @exception IllegalArgumentException <ul>
@@ -195,12 +168,13 @@ public TreeItem (TreeItem parentItem, int style) {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
+ * @see Tree#setRedraw
*/
public TreeItem (TreeItem parentItem, int style, int index) {
this (checkNull (parentItem).parent, style, parentItem.handle, findPrevious (parentItem, index), 0);
}
-TreeItem (Tree parent, int style, long /*int*/ hParent, long /*int*/ hInsertAfter, long /*int*/ hItem) {
+TreeItem (Tree parent, int style, long hParent, long hInsertAfter, long hItem) {
super (parent, style);
this.parent = parent;
parent.createItem (this, hParent, hInsertAfter, hItem);
@@ -211,25 +185,25 @@ static TreeItem checkNull (TreeItem item) {
return item;
}
-static long /*int*/ findPrevious (Tree parent, int index) {
+static long findPrevious (Tree parent, int index) {
if (parent == null) return 0;
if (index < 0) SWT.error (SWT.ERROR_INVALID_RANGE);
if (index == 0) return OS.TVI_FIRST;
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hFirstItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
- long /*int*/ hItem = parent.findItem (hFirstItem, index - 1);
+ long hwnd = parent.handle;
+ long hFirstItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ long hItem = parent.findItem (hFirstItem, index - 1);
if (hItem == 0) SWT.error (SWT.ERROR_INVALID_RANGE);
return hItem;
}
-static long /*int*/ findPrevious (TreeItem parentItem, int index) {
+static long findPrevious (TreeItem parentItem, int index) {
if (parentItem == null) return 0;
if (index < 0) SWT.error (SWT.ERROR_INVALID_RANGE);
if (index == 0) return OS.TVI_FIRST;
Tree parent = parentItem.parent;
- long /*int*/ hwnd = parent.handle, hParent = parentItem.handle;
- long /*int*/ hFirstItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hParent);
- long /*int*/ hItem = parent.findItem (hFirstItem, index - 1);
+ long hwnd = parent.handle, hParent = parentItem.handle;
+ long hFirstItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hParent);
+ long hItem = parent.findItem (hFirstItem, index - 1);
if (hItem == 0) SWT.error (SWT.ERROR_INVALID_RANGE);
return hItem;
}
@@ -245,7 +219,7 @@ void clear () {
strings = null;
images = null;
if ((parent.style & SWT.CHECK) != 0) {
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
@@ -285,8 +259,8 @@ void clear () {
*/
public void clear (int index, boolean all) {
checkWidget ();
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+ long hwnd = parent.handle;
+ long hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
if (hItem == 0) error (SWT.ERROR_INVALID_RANGE);
hItem = parent.findItem (hItem, index);
if (hItem == 0) error (SWT.ERROR_INVALID_RANGE);
@@ -320,8 +294,8 @@ public void clear (int index, boolean all) {
*/
public void clearAll (boolean all) {
checkWidget ();
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+ long hwnd = parent.handle;
+ long hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
if (hItem == 0) return;
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
@@ -337,7 +311,7 @@ void destroyWidget () {
releaseHandle ();
}
-long /*int*/ fontHandle (int index) {
+long fontHandle (int index) {
if (cellFont != null && cellFont [index] != null) return cellFont [index].handle;
if (font != null) return font.handle;
return -1;
@@ -439,9 +413,9 @@ RECT getBounds (int index, boolean getText, boolean getImage, boolean fullText)
}
//TODO - take into account grid (add boolean arg) to damage less during redraw
-RECT getBounds (int index, boolean getText, boolean getImage, boolean fullText, boolean fullImage, boolean clip, long /*int*/ hDC) {
+RECT getBounds (int index, boolean getText, boolean getImage, boolean fullText, boolean fullImage, boolean clip, long hDC) {
if (!getText && !getImage) return new RECT ();
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
if ((parent.style & SWT.VIRTUAL) == 0 && !cached && !parent.painted) {
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
@@ -453,7 +427,7 @@ RECT getBounds (int index, boolean getText, boolean getImage, boolean fullText,
}
boolean firstColumn = index == 0;
int columnCount = 0;
- long /*int*/ hwndHeader = parent.hwndHeader;
+ long hwndHeader = parent.hwndHeader;
if (hwndHeader != 0) {
columnCount = parent.columnCount;
firstColumn = index == OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
@@ -525,7 +499,7 @@ RECT getBounds (int index, boolean getText, boolean getImage, boolean fullText,
RECT textRect = new RECT ();
char [] buffer = string.toCharArray ();
int flags = OS.DT_NOPREFIX | OS.DT_SINGLELINE | OS.DT_CALCRECT;
- long /*int*/ hNewDC = hDC, hFont = 0;
+ long hNewDC = hDC, hFont = 0;
if (hDC == 0) {
hNewDC = OS.GetDC (hwnd);
hFont = fontHandle (index);
@@ -575,12 +549,12 @@ public boolean getChecked () {
checkWidget ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
if ((parent.style & SWT.CHECK) == 0) return false;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
tvItem.hItem = handle;
- long /*int*/ result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+ long result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
return (result != 0) && (((tvItem.state >> 12) & 1) == 0);
}
@@ -598,14 +572,14 @@ public boolean getChecked () {
*/
public boolean getExpanded () {
checkWidget ();
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
/*
* Bug in Windows. Despite the fact that TVM_GETITEMSTATE claims
* to return only the bits specified by the stateMask, when called
* with TVIS_EXPANDED, the entire state is returned. The fix is
* to explicitly check for the TVIS_EXPANDED bit.
*/
- int state = (int)/*64*/OS.SendMessage (hwnd, OS.TVM_GETITEMSTATE, handle, OS.TVIS_EXPANDED);
+ int state = (int)OS.SendMessage (hwnd, OS.TVM_GETITEMSTATE, handle, OS.TVIS_EXPANDED);
return (state & OS.TVIS_EXPANDED) != 0;
}
@@ -709,12 +683,12 @@ public boolean getGrayed () {
checkWidget ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
if ((parent.style & SWT.CHECK) == 0) return false;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
tvItem.hItem = handle;
- long /*int*/ result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+ long result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
return (result != 0) && ((tvItem.state >> 12) > 2);
}
@@ -739,10 +713,10 @@ public TreeItem getItem (int index) {
checkWidget ();
if (index < 0) error (SWT.ERROR_INVALID_RANGE);
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hFirstItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+ long hwnd = parent.handle;
+ long hFirstItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
if (hFirstItem == 0) error (SWT.ERROR_INVALID_RANGE);
- long /*int*/ hItem = parent.findItem (hFirstItem, index);
+ long hItem = parent.findItem (hFirstItem, index);
if (hItem == 0) error (SWT.ERROR_INVALID_RANGE);
return parent._getItem (hItem);
}
@@ -761,8 +735,8 @@ public TreeItem getItem (int index) {
public int getItemCount () {
checkWidget ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+ long hwnd = parent.handle;
+ long hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
if (hItem == 0) return 0;
return parent.getItemCount (hItem);
}
@@ -786,8 +760,8 @@ public int getItemCount () {
public TreeItem [] getItems () {
checkWidget ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+ long hwnd = parent.handle;
+ long hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
if (hItem == 0) return new TreeItem [0];
return parent.getItems (hItem);
}
@@ -879,8 +853,8 @@ public Tree getParent () {
*/
public TreeItem getParentItem () {
checkWidget ();
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, handle);
+ long hwnd = parent.handle;
+ long hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, handle);
return hItem != 0 ? parent._getItem (hItem) : null;
}
@@ -943,7 +917,7 @@ Rectangle getTextBoundsInPixels (int index) {
RECT rect = getBounds (index, true, false, true);
if (index == 0) rect.left += Tree.INSET - 1;
rect.left = Math.min (rect.left, rect.right);
- rect.right = rect.right - Tree.INSET;
+ rect.right = rect.right - Tree.INSET + 1; // Add 1 px margin to avoid truncation of text seen with "Segoe UI" font
int width = Math.max (0, rect.right - rect.left);
int height = Math.max (0, rect.bottom - rect.top);
return new Rectangle (rect.left, rect.top, width, height);
@@ -973,14 +947,14 @@ public int indexOf (TreeItem item) {
checkWidget ();
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+ long hwnd = parent.handle;
+ long hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
return hItem == 0 ? -1 : parent.findIndex (hItem, item.handle);
}
void redraw () {
if (parent.currentItem == this || !parent.getDrawing ()) return;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
if (!OS.IsWindowVisible (hwnd)) return;
/*
* When there are no columns and the tree is not
@@ -1004,7 +978,7 @@ void redraw () {
void redraw (int column, boolean drawText, boolean drawImage) {
if (parent.currentItem == this || !parent.getDrawing ()) return;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
if (!OS.IsWindowVisible (hwnd)) return;
boolean fullImage = column == 0 && drawText && drawImage;
RECT rect = getBounds (column, drawText, drawImage, true, fullImage, true, 0);
@@ -1049,20 +1023,33 @@ void releaseWidget () {
*/
public void removeAll () {
checkWidget ();
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
tvItem.hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
- while (tvItem.hItem != 0) {
- OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
- TreeItem item = tvItem.lParam != -1 ? parent.items [(int)/*64*/tvItem.lParam] : null;
- if (item != null && !item.isDisposed ()) {
- item.dispose ();
- } else {
- parent.releaseItem (tvItem.hItem, tvItem, false);
- parent.destroyItem (null, tvItem.hItem);
+ /**
+ * Performance optimization, switch off redraw for high amount of elements
+ */
+ boolean disableRedraw = parent.itemCount > 30;
+ if (disableRedraw) {
+ parent.setRedraw(false);
+ }
+ try {
+ while (tvItem.hItem != 0) {
+ OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+ TreeItem item = tvItem.lParam != -1 ? parent.items [(int)tvItem.lParam] : null;
+ if (item != null && !item.isDisposed ()) {
+ item.dispose ();
+ } else {
+ parent.releaseItem (tvItem.hItem, tvItem, false);
+ parent.destroyItem (null, tvItem.hItem);
+ }
+ tvItem.hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+ }
+ } finally {
+ if (disableRedraw) {
+ parent.setRedraw(true);
}
- tvItem.hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
}
}
@@ -1157,7 +1144,7 @@ public void setBackground (int index, Color color) {
public void setChecked (boolean checked) {
checkWidget ();
if ((parent.style & SWT.CHECK) == 0) return;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
@@ -1205,7 +1192,7 @@ public void setExpanded (boolean expanded) {
checkWidget ();
/* Do nothing when the item is a leaf or already expanded */
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
if (OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle) == 0) {
return;
}
@@ -1215,7 +1202,7 @@ public void setExpanded (boolean expanded) {
* with TVIS_EXPANDED, the entire state is returned. The fix is
* to explicitly check for the TVIS_EXPANDED bit.
*/
- int state = (int)/*64*/OS.SendMessage (hwnd, OS.TVM_GETITEMSTATE, handle, OS.TVIS_EXPANDED);
+ int state = (int)OS.SendMessage (hwnd, OS.TVM_GETITEMSTATE, handle, OS.TVIS_EXPANDED);
if (((state & OS.TVIS_EXPANDED) != 0) == expanded) return;
/*
@@ -1235,9 +1222,9 @@ public void setExpanded (boolean expanded) {
RECT [] rects = null;
SCROLLINFO oldInfo = null;
int count = 0;
- long /*int*/ hBottomItem = 0;
+ long hBottomItem = 0;
boolean redraw = false, noScroll = true;
- long /*int*/ hTopItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+ long hTopItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
if (noScroll && hTopItem != 0) {
oldInfo = new SCROLLINFO ();
oldInfo.cbSize = SCROLLINFO.sizeof;
@@ -1247,9 +1234,9 @@ public void setExpanded (boolean expanded) {
}
if (parent.getDrawing () && OS.IsWindowVisible (hwnd)) {
boolean noAnimate = true;
- count = (int)/*64*/OS.SendMessage (hwnd, OS.TVM_GETVISIBLECOUNT, 0, 0);
+ count = (int)OS.SendMessage (hwnd, OS.TVM_GETVISIBLECOUNT, 0, 0);
rects = new RECT [count + 1];
- long /*int*/ hItem = hTopItem;
+ long hItem = hTopItem;
int index = 0;
while (hItem != 0 && (noAnimate || hItem != handle) && index < count) {
RECT rect = new RECT ();
@@ -1264,17 +1251,13 @@ public void setExpanded (boolean expanded) {
hBottomItem = hItem;
oldRect = new RECT ();
OS.GetClientRect (hwnd, oldRect);
- long /*int*/ topHandle = parent.topHandle ();
+ long topHandle = parent.topHandle ();
OS.UpdateWindow (topHandle);
OS.DefWindowProc (topHandle, OS.WM_SETREDRAW, 0, 0);
if (hwnd != topHandle) {
OS.UpdateWindow (hwnd);
OS.DefWindowProc (hwnd, OS.WM_SETREDRAW, 0, 0);
}
- /*
- * This code is intentionally commented.
- */
-// OS.SendMessage (hwnd, OS.WM_SETREDRAW, 0, 0);
}
}
}
@@ -1291,7 +1274,7 @@ public void setExpanded (boolean expanded) {
* check whether the selection has changed and issue
* the event.
*/
- long /*int*/ hOldItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hOldItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
/* Expand or collapse the item */
parent.ignoreExpand = true;
@@ -1319,7 +1302,7 @@ public void setExpanded (boolean expanded) {
newInfo.fMask = OS.SIF_ALL;
if (OS.GetScrollInfo (hwnd, OS.SB_HORZ, newInfo)) {
if (oldInfo.nPos != newInfo.nPos) {
- long /*int*/ lParam = OS.MAKELPARAM (OS.SB_THUMBPOSITION, oldInfo.nPos);
+ long lParam = OS.MAKELPARAM (OS.SB_THUMBPOSITION, oldInfo.nPos);
OS.SendMessage (hwnd, OS.WM_HSCROLL, lParam, 0);
}
}
@@ -1330,7 +1313,7 @@ public void setExpanded (boolean expanded) {
RECT newRect = new RECT ();
OS.GetClientRect (hwnd, newRect);
if (OS.EqualRect (oldRect, newRect)) {
- long /*int*/ hItem = hTopItem;
+ long hItem = hTopItem;
int index = 0;
while (hItem != 0 && index < count) {
RECT rect = new RECT ();
@@ -1345,15 +1328,11 @@ public void setExpanded (boolean expanded) {
fixScroll = index == count && hItem == hBottomItem;
}
}
- long /*int*/ topHandle = parent.topHandle ();
+ long topHandle = parent.topHandle ();
OS.DefWindowProc (topHandle, OS.WM_SETREDRAW, 1, 0);
if (hwnd != topHandle) {
OS.DefWindowProc (hwnd, OS.WM_SETREDRAW, 1, 0);
}
- /*
- * This code is intentionally commented.
- */
-// OS.SendMessage (hwnd, OS.WM_SETREDRAW, 1, 0);
if (fixScroll) {
parent.updateScrollBar ();
SCROLLINFO info = new SCROLLINFO ();
@@ -1376,7 +1355,7 @@ public void setExpanded (boolean expanded) {
}
/* Check for a selection event */
- long /*int*/ hNewItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ long hNewItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
if (hNewItem != hOldItem) {
Event event = new Event ();
if (hNewItem != 0) {
@@ -1424,7 +1403,7 @@ public void setFont (Font font){
if ((parent.style & SWT.VIRTUAL) == 0 && !cached && !parent.painted) {
return;
}
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
tvItem.hItem = handle;
@@ -1479,7 +1458,7 @@ public void setFont (int index, Font font) {
if ((parent.style & SWT.VIRTUAL) == 0 && !cached && !parent.painted) {
return;
}
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
tvItem.hItem = handle;
@@ -1581,7 +1560,7 @@ public void setForeground (int index, Color color){
public void setGrayed (boolean grayed) {
checkWidget ();
if ((parent.style & SWT.CHECK) == 0) return;
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
@@ -1690,7 +1669,7 @@ public void setImage (int index, Image image) {
if ((parent.style & SWT.VIRTUAL) == 0 &&!cached && !parent.painted) {
return;
}
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_IMAGE | OS.TVIF_SELECTEDIMAGE;
tvItem.hItem = handle;
@@ -1718,6 +1697,12 @@ public void setImage (Image image) {
/**
* Sets the number of child items contained in the receiver.
+ * <p>
+ * The fastest way to insert many items is:
+ * <ol>
+ * <li>Use {@link Tree#setRedraw} to disable drawing during bulk insert</li>
+ * <li>Collapse the parent item before inserting (gives massive improvement on Windows)</li>
+ * </ol>
*
* @param count the number of items
*
@@ -1731,9 +1716,7 @@ public void setImage (Image image) {
public void setItemCount (int count) {
checkWidget ();
count = Math.max (0, count);
- long /*int*/ hwnd = parent.handle;
- long /*int*/ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
- parent.setItemCount (count, handle, hItem);
+ parent.setItemCount (count, handle);
}
/**
@@ -1804,7 +1787,7 @@ public void setText (int index, String string) {
if ((parent.style & SWT.VIRTUAL) == 0 && !cached && !parent.painted) {
return;
}
- long /*int*/ hwnd = parent.handle;
+ long hwnd = parent.handle;
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
tvItem.hItem = handle;
@@ -1827,4 +1810,12 @@ public void setText (String string) {
parent.sort (handle, false);
}
+@Override
+String getNameText () {
+ if ((parent.style & SWT.VIRTUAL) != 0) {
+ if (!cached) return "*virtual*"; //$NON-NLS-1$
+ }
+ return super.getNameText ();
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
index d8b2584dcb..488cf58683 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Pierre-Yves B., pyvesdev@gmail.com - Bug 219750: [styled text] Typing ~~ inserts é~~
*******************************************************************************/
package org.eclipse.swt.widgets;
@@ -98,6 +99,9 @@ public abstract class Widget {
/* Bidi "auto" text direction */
static final int HAS_AUTO_DIRECTION = 1<<22;
+ /* Mouse cursor is over the widget flag */
+ static final int MOUSE_OVER = 1<<23;
+
/* Default size for widgets */
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
@@ -111,13 +115,17 @@ public abstract class Widget {
/* Initialize the Common Controls DLL */
static {
- OS.InitCommonControls ();
+ INITCOMMONCONTROLSEX icce = new INITCOMMONCONTROLSEX ();
+ icce.dwSize = INITCOMMONCONTROLSEX.sizeof;
+ icce.dwICC = 0xffff;
+ OS.InitCommonControlsEx (icce);
}
/**
* Prevents uninitialized instances from being created outside the package.
*/
Widget () {
+ notifyCreationTracker();
}
/**
@@ -155,6 +163,7 @@ public Widget (Widget parent, int style) {
this.style = style;
display = parent.display;
reskinWidget ();
+ notifyCreationTracker();
}
void _addListener (int eventType, Listener listener) {
@@ -223,7 +232,7 @@ public void addDisposeListener (DisposeListener listener) {
addListener (SWT.Dispose, typedListener);
}
-long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
return 0;
}
@@ -290,6 +299,13 @@ void checkParent (Widget parent) {
parent.checkOpened ();
}
+void maybeEnableDarkSystemTheme(long handle) {
+ if (display.useDarkModeExplorerTheme) {
+ OS.AllowDarkModeForWindow(handle, true);
+ OS.SetWindowTheme(handle, Display.EXPLORER, null);
+ }
+}
+
/**
* Checks that this class can be subclassed.
* <p>
@@ -348,27 +364,7 @@ protected void checkSubclass () {
protected void checkWidget () {
Display display = this.display;
if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
- if (display.thread != Thread.currentThread ()) {
- /*
- * Bug in IBM JVM 1.6. For some reason, under
- * conditions that are yet to be full understood,
- * Thread.currentThread() is either returning null
- * or a different instance from the one that was
- * saved when the Display was created. This is
- * possibly a JIT problem because modifying this
- * method to print logging information when the
- * error happens seems to fix the problem. The
- * fix is to use operating system calls to verify
- * that the current thread is not the Display thread.
- *
- * NOTE: Despite the fact that Thread.currentThread()
- * is used in other places, the failure has not been
- * observed in all places where it is called.
- */
- if (display.threadId != OS.GetCurrentThreadId ()) {
- error (SWT.ERROR_THREAD_INVALID_ACCESS);
- }
- }
+ if (display.thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if ((state & DISPOSED) != 0) error (SWT.ERROR_WIDGET_DISPOSED);
}
@@ -429,7 +425,7 @@ public void dispose () {
release (true);
}
-boolean dragDetect (long /*int*/ hwnd, int x, int y, boolean filter, boolean [] detect, boolean [] consume) {
+boolean dragDetect (long hwnd, int x, int y, boolean filter, boolean [] detect, boolean [] consume) {
if (consume != null) consume [0] = false;
if (detect != null) detect [0] = true;
POINT pt = new POINT ();
@@ -455,7 +451,7 @@ boolean filters (int eventType) {
return display.filters (eventType);
}
-Widget findItem (long /*int*/ id) {
+Widget findItem (long id) {
return null;
}
@@ -746,7 +742,7 @@ boolean isValidThread () {
return getDisplay ().isValidThread ();
}
-void mapEvent (long /*int*/ hwnd, Event event) {
+void mapEvent (long hwnd, Event event) {
}
GC new_GC (GCData data) {
@@ -808,23 +804,34 @@ void postEvent (int eventType, Event event) {
* @see #releaseWidget
*/
void release (boolean destroy) {
- if ((state & DISPOSE_SENT) == 0) {
- state |= DISPOSE_SENT;
- sendEvent (SWT.Dispose);
- }
- if ((state & DISPOSED) == 0) {
- releaseChildren (destroy);
- }
- if ((state & RELEASED) == 0) {
- state |= RELEASED;
- if (destroy) {
- releaseParent ();
- releaseWidget ();
- destroyWidget ();
- } else {
- releaseWidget ();
- releaseHandle ();
+ try (ExceptionStash exceptions = new ExceptionStash ()) {
+ if ((state & DISPOSE_SENT) == 0) {
+ state |= DISPOSE_SENT;
+ try {
+ sendEvent (SWT.Dispose);
+ } catch (Error | RuntimeException ex) {
+ exceptions.stash (ex);
+ }
+ }
+ if ((state & DISPOSED) == 0) {
+ try {
+ releaseChildren (destroy);
+ } catch (Error | RuntimeException ex) {
+ exceptions.stash (ex);
+ }
}
+ if ((state & RELEASED) == 0) {
+ state |= RELEASED;
+ if (destroy) {
+ releaseParent ();
+ releaseWidget ();
+ destroyWidget ();
+ } else {
+ releaseWidget ();
+ releaseHandle ();
+ }
+ }
+ notifyDisposalTracker();
}
}
@@ -1097,23 +1104,23 @@ void sendSelectionEvent (int type, Event event, boolean send) {
sendEvent (type, event, send);
}
-boolean sendKeyEvent (int type, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+boolean sendKeyEvent (int type, int msg, long wParam, long lParam) {
Event event = new Event ();
if (!setKeyState (event, type, wParam, lParam)) return true;
return sendKeyEvent (type, msg, wParam, lParam, event);
}
-boolean sendKeyEvent (int type, int msg, long /*int*/ wParam, long /*int*/ lParam, Event event) {
+boolean sendKeyEvent (int type, int msg, long wParam, long lParam, Event event) {
sendEvent (type, event);
if (isDisposed ()) return false;
return event.doit;
}
-boolean sendMouseEvent (int type, int button, long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
- return sendMouseEvent (type, button, display.getClickCount (type, button, hwnd, lParam), 0, false, hwnd, msg, wParam, lParam);
+boolean sendMouseEvent (int type, int button, long hwnd, long lParam) {
+ return sendMouseEvent (type, button, display.getClickCount (type, button, hwnd, lParam), 0, false, hwnd, lParam);
}
-boolean sendMouseEvent (int type, int button, int count, int detail, boolean send, long /*int*/ hwnd, int msg, long /*int*/ wParam, long /*int*/ lParam) {
+boolean sendMouseEvent (int type, int button, int count, int detail, boolean send, long hwnd, long lParam) {
if (!hooks (type) && !filters (type)) return true;
Event event = new Event ();
event.button = button;
@@ -1131,36 +1138,78 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen
return event.doit;
}
-boolean sendMouseWheelEvent (int type, long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
- int delta = OS.GET_WHEEL_DELTA_WPARAM (wParam);
- int detail = 0;
- if (type == SWT.MouseWheel) {
- int [] linesToScroll = new int [1];
- OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, linesToScroll, 0);
- if (linesToScroll [0] == OS.WHEEL_PAGESCROLL) {
- detail = SWT.SCROLL_PAGE;
+class MouseWheelData {
+ MouseWheelData (boolean isVertical, ScrollBar scrollBar, long wParam, Point remainder) {
+ /* WHEEL_DELTA is expressed in precision units, see OS.WHEEL_DELTA */
+ int delta = OS.GET_WHEEL_DELTA_WPARAM (wParam);
+
+ /* Wheel speed can be configured in Windows mouse settings */
+ if (isVertical) {
+ int [] wheelSpeed = new int [1];
+ OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, wheelSpeed, 0);
+ if (wheelSpeed [0] == OS.WHEEL_PAGESCROLL) {
+ detail = SWT.SCROLL_PAGE;
+ } else {
+ delta *= wheelSpeed [0];
+ detail = SWT.SCROLL_LINE;
+ }
} else {
- detail = SWT.SCROLL_LINE;
- delta *= linesToScroll [0];
+ int [] wheelSpeed = new int [1];
+ OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLCHARS, 0, wheelSpeed, 0);
+ delta *= wheelSpeed [0];
+
+ /* For legacy compatibility reasons, detail is set to 0 here */
+ detail = 0;
}
- /* Check if the delta and the remainder have the same direction (sign) */
- if ((delta ^ display.scrollRemainder) >= 0) delta += display.scrollRemainder;
- display.scrollRemainder = delta % OS.WHEEL_DELTA;
- } else {
- /* Check if the delta and the remainder have the same direction (sign) */
- if ((delta ^ display.scrollHRemainder) >= 0) delta += display.scrollHRemainder;
- display.scrollHRemainder = delta % OS.WHEEL_DELTA;
- delta = -delta;
+ /* Take scrollbar scrolling speed into account */
+ if (scrollBar != null) {
+ if (detail == SWT.SCROLL_PAGE) {
+ delta *= scrollBar.getPageIncrement ();
+ } else {
+ delta *= scrollBar.getIncrement ();
+ }
+ }
+
+ /*
+ * Accumulate remainder to deal with fractional scrolls. This is only seen
+ * on some devices which support "smooth scrolling". MSDN also says:
+ * The remainder must be zeroed when the wheel rotation switches
+ * directions or when window focus changes.
+ */
+ if (isVertical) {
+ if ((delta ^ remainder.y) >= 0) delta += remainder.y;
+ remainder.y = delta % OS.WHEEL_DELTA;
+ } else {
+ if ((delta ^ remainder.x) >= 0) delta += remainder.x;
+ remainder.x = delta % OS.WHEEL_DELTA;
+ }
+
+ /* Finally, divide by WHEEL_DELTA */
+ count = delta / OS.WHEEL_DELTA;
}
+ int count; // lines or pages scrolled
+ int detail; // {0, SWT.SCROLL_PAGE, SWT.SCROLL_LINE}
+}
+
+boolean sendMouseWheelEvent (int type, long hwnd, long wParam, long lParam) {
if (!hooks (type) && !filters (type)) return true;
- int count = delta / OS.WHEEL_DELTA;
+
+ boolean vertical = (type == SWT.MouseWheel);
+ MouseWheelData wheelData = new MouseWheelData (vertical, null, wParam, display.scrollRemainderEvt);
+
+ if (wheelData.count == 0) return true;
+
+ /* Legacy code. I wonder if any SWT application actually cares? */
+ if (!vertical)
+ wheelData.count = -wheelData.count;
+
POINT pt = new POINT ();
OS.POINTSTOPOINT (pt, lParam);
OS.ScreenToClient (hwnd, pt);
lParam = OS.MAKELPARAM (pt.x, pt.y);
- return sendMouseEvent (type, 0, count, detail, true, hwnd, OS.WM_MOUSEWHEEL, wParam, lParam);
+ return sendMouseEvent (type, 0, wheelData.count, wheelData.detail, true, hwnd, lParam);
}
/**
@@ -1318,7 +1367,7 @@ boolean setInputState (Event event, int type) {
return true;
}
-boolean setKeyState (Event event, int type, long /*int*/ wParam, long /*int*/ lParam) {
+boolean setKeyState (Event event, int type, long wParam, long lParam) {
/*
* Feature in Windows. When the user presses Ctrl+Backspace
@@ -1382,7 +1431,7 @@ boolean setKeyState (Event event, int type, long /*int*/ wParam, long /*int*/ lP
return setInputState (event, type);
}
-int setLocationMask (Event event, int type, long /*int*/ wParam, long /*int*/ lParam) {
+int setLocationMask (Event event, int type, long wParam, long lParam) {
int location = SWT.NONE;
if (display.lastVirtual) {
switch (display.lastKey) {
@@ -1479,13 +1528,13 @@ void updateMenuLocation (Event event) {
/* Do nothing */
}
-LRESULT wmCaptureChanged (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmCaptureChanged (long hwnd, long wParam, long lParam) {
display.captureChanged = true;
return null;
}
-LRESULT wmChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
- display.lastAscii = (int)/*64*/wParam;
+LRESULT wmChar (long hwnd, long wParam, long lParam) {
+ display.lastAscii = (int)wParam;
display.lastNull = wParam == 0;
if (!sendKeyEvent (SWT.KeyDown, OS.WM_CHAR, wParam, lParam)) {
return LRESULT.ONE;
@@ -1494,7 +1543,7 @@ LRESULT wmChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT wmContextMenu (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmContextMenu (long hwnd, long wParam, long lParam) {
if (wParam != hwnd) return null;
/*
@@ -1530,10 +1579,10 @@ LRESULT wmContextMenu (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lPar
return showMenu (x, y, detail) ? LRESULT.ZERO : null;
}
-LRESULT wmIMEChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmIMEChar (long hwnd, long wParam, long lParam) {
Display display = this.display;
display.lastKey = 0;
- display.lastAscii = (int)/*64*/wParam;
+ display.lastAscii = (int)wParam;
display.lastVirtual = display.lastNull = display.lastDead = false;
if (!sendKeyEvent (SWT.KeyDown, OS.WM_IME_CHAR, wParam, lParam)) {
return LRESULT.ONE;
@@ -1544,10 +1593,10 @@ LRESULT wmIMEChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
return LRESULT.ONE;
}
-LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmKeyDown (long hwnd, long wParam, long lParam) {
/* Ignore repeating modifier keys by testing key down state */
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_SHIFT:
case OS.VK_MENU:
case OS.VK_CONTROL:
@@ -1562,7 +1611,7 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
display.lastVirtual = display.lastNull = display.lastDead = false;
/* Map the virtual key */
- int mapKey = OS.MapVirtualKey ((int)/*64*/wParam, 2);
+ int mapKey = OS.MapVirtualKey ((int)wParam, 2);
/*
* Feature in Windows. For Devanagari and Bengali numbers,
* MapVirtualKey() returns the localized number instead of
@@ -1575,7 +1624,7 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
* NOTE: VK_0 to VK_9 are the same as ASCII.
*/
if (('\u09e6' <= mapKey && mapKey <= '\u09ef') || ('\u0966' <= mapKey && mapKey <= '\u096f')) {
- mapKey = (int)/*64*/wParam;
+ mapKey = (int)wParam;
}
/*
@@ -1596,11 +1645,11 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
if ((mapKey & 0x80000000) != 0) return null;
MSG msg = new MSG ();
- int flags = OS.PM_NOREMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE;
+ int flags = OS.PM_NOREMOVE | OS.PM_NOYIELD;
if (OS.PeekMessage (msg, hwnd, OS.WM_DEADCHAR, OS.WM_DEADCHAR, flags)) {
display.lastDead = true;
display.lastVirtual = mapKey == 0;
- display.lastKey = display.lastVirtual ? (int)/*64*/wParam : mapKey;
+ display.lastKey = display.lastVirtual ? (int)wParam : mapKey;
return null;
}
@@ -1637,9 +1686,9 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
* they are not virtual. Therefore it is necessary to force
* numeric keypad keys to be virtual.
*/
- display.lastVirtual = mapKey == 0 || display.numpadKey ((int)/*64*/wParam) != 0;
+ display.lastVirtual = mapKey == 0 || display.numpadKey ((int)wParam) != 0;
if (display.lastVirtual) {
- display.lastKey = (int)/*64*/wParam;
+ display.lastKey = (int)wParam;
/*
* Feature in Windows. The virtual key VK_DELETE is not
* treated as both a virtual key and an ASCII key by Windows.
@@ -1677,7 +1726,7 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
* upper case values in WM_KEYDOWN despite the fact that the
* Shift was not pressed.
*/
- display.lastKey = (int)/*64*/OS.CharLower ((short) mapKey);
+ display.lastKey = (int)OS.CharLower ((short) mapKey);
/*
* Feature in Windows. The virtual key VK_CANCEL is treated
@@ -1696,7 +1745,7 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
* WM_CHAR. If this is the case, issue the key down event from
* inside WM_CHAR.
*/
- int asciiKey = display.asciiKey ((int)/*64*/wParam);
+ int asciiKey = display.asciiKey ((int)wParam);
if (asciiKey != 0) {
/*
* When the user types Ctrl+Space, ToAscii () maps this to
@@ -1706,7 +1755,7 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
* issue the event from WM_CHAR.
*/
if (asciiKey == ' ') return null;
- if (asciiKey != (int)/*64*/wParam) return null;
+ if (asciiKey != (int)wParam) return null;
/*
* Feature in Windows. The virtual key VK_CANCEL is treated
* as both a virtual key and ASCII key by Windows. This
@@ -1732,12 +1781,12 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
* If the user types Ctrl+Shift+6, the value of LastAscii will
* depend on the international keyboard.
*/
- if (OS.GetKeyState (OS.VK_SHIFT) < 0) {
- display.lastAscii = display.shiftedKey ((int)/*64*/wParam);
+ if (OS.GetKeyState (OS.VK_SHIFT) < 0) {
+ display.lastAscii = display.shiftedKey ((int)wParam);
if (display.lastAscii == 0) display.lastAscii = mapKey;
- } else {
- display.lastAscii = (int)/*64*/OS.CharLower ((short) mapKey);
- }
+ } else {
+ display.lastAscii = (int)OS.CharLower ((short) mapKey);
+ }
/* Note that Ctrl+'@' is ASCII NUL and is delivered in WM_CHAR */
if (display.lastAscii == '@') return null;
@@ -1750,7 +1799,7 @@ LRESULT wmKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
return null;
}
-LRESULT wmKeyUp (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmKeyUp (long hwnd, long wParam, long lParam) {
Display display = this.display;
/*
@@ -1764,7 +1813,7 @@ LRESULT wmKeyUp (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
}
/* Map the virtual key. */
- int mapKey = OS.MapVirtualKey ((int)/*64*/wParam, 2);
+ int mapKey = OS.MapVirtualKey ((int)wParam, 2);
/*
* Bug in Windows 95 and NT. When the user types an accent key such
@@ -1784,9 +1833,9 @@ LRESULT wmKeyUp (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
* they are not virtual. Therefore it is necessary to force
* numeric keypad keys to be virtual.
*/
- display.lastVirtual = mapKey == 0 || display.numpadKey ((int)/*64*/wParam) != 0;
+ display.lastVirtual = mapKey == 0 || display.numpadKey ((int)wParam) != 0;
if (display.lastVirtual) {
- display.lastKey = (int)/*64*/wParam;
+ display.lastKey = (int)wParam;
} else {
/*
* Feature in Windows. The virtual key VK_CANCEL is treated
@@ -1812,9 +1861,17 @@ LRESULT wmKeyUp (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
return result;
}
-LRESULT wmKillFocus (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
- display.scrollRemainder = display.scrollHRemainder = 0;
- long /*int*/ code = callWindowProc (hwnd, OS.WM_KILLFOCUS, wParam, lParam);
+LRESULT wmKillFocus (long hwnd, long wParam, long lParam) {
+ /*
+ * MSDN says: The remainder must be zeroed when the wheel rotation switches
+ * directions or when window focus changes.
+ */
+ display.scrollRemainderEvt.x = 0;
+ display.scrollRemainderEvt.y = 0;
+ display.scrollRemainderBar.x = 0;
+ display.scrollRemainderBar.y = 0;
+
+ long code = callWindowProc (hwnd, OS.WM_KILLFOCUS, wParam, lParam);
sendFocusEvent (SWT.FocusOut);
// widget could be disposed at this point
@@ -1830,7 +1887,7 @@ LRESULT wmKillFocus (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam
return new LRESULT (code);
}
-LRESULT wmLButtonDblClk (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmLButtonDblClk (long hwnd, long wParam, long lParam) {
/*
* Feature in Windows. Windows sends the following
* messages when the user double clicks the mouse:
@@ -1847,8 +1904,8 @@ LRESULT wmLButtonDblClk (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lP
LRESULT result = null;
Display display = this.display;
display.captureChanged = false;
- sendMouseEvent (SWT.MouseDown, 1, hwnd, OS.WM_LBUTTONDOWN, wParam, lParam);
- if (sendMouseEvent (SWT.MouseDoubleClick, 1, hwnd, OS.WM_LBUTTONDBLCLK, wParam, lParam)) {
+ sendMouseEvent (SWT.MouseDown, 1, hwnd, lParam);
+ if (sendMouseEvent (SWT.MouseDoubleClick, 1, hwnd, lParam)) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_LBUTTONDBLCLK, wParam, lParam));
} else {
result = LRESULT.ZERO;
@@ -1859,7 +1916,7 @@ LRESULT wmLButtonDblClk (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lP
return result;
}
-LRESULT wmLButtonDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmLButtonDown (long hwnd, long wParam, long lParam) {
Display display = this.display;
LRESULT result = null;
int x = OS.GET_X_LPARAM (lParam);
@@ -1883,7 +1940,7 @@ LRESULT wmLButtonDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lPar
mouseDown = OS.GetKeyState (OS.VK_LBUTTON) < 0;
}
display.captureChanged = false;
- boolean dispatch = sendMouseEvent (SWT.MouseDown, 1, count, 0, false, hwnd, OS.WM_LBUTTONDOWN, wParam, lParam);
+ boolean dispatch = sendMouseEvent (SWT.MouseDown, 1, count, 0, false, hwnd, lParam);
if (dispatch && (consume == null || !consume [0])) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_LBUTTONDOWN, wParam, lParam));
} else {
@@ -1926,10 +1983,10 @@ LRESULT wmLButtonDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lPar
return result;
}
-LRESULT wmLButtonUp (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmLButtonUp (long hwnd, long wParam, long lParam) {
Display display = this.display;
LRESULT result = null;
- if (sendMouseEvent (SWT.MouseUp, 1, hwnd, OS.WM_LBUTTONUP, wParam, lParam)) {
+ if (sendMouseEvent (SWT.MouseUp, 1, hwnd, lParam)) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_LBUTTONUP, wParam, lParam));
} else {
result = LRESULT.ZERO;
@@ -1948,7 +2005,7 @@ LRESULT wmLButtonUp (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam
return result;
}
-LRESULT wmMButtonDblClk (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmMButtonDblClk (long hwnd, long wParam, long lParam) {
/*
* Feature in Windows. Windows sends the following
* messages when the user double clicks the mouse:
@@ -1965,8 +2022,8 @@ LRESULT wmMButtonDblClk (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lP
LRESULT result = null;
Display display = this.display;
display.captureChanged = false;
- sendMouseEvent (SWT.MouseDown, 2, hwnd, OS.WM_MBUTTONDOWN, wParam, lParam);
- if (sendMouseEvent (SWT.MouseDoubleClick, 2, hwnd, OS.WM_MBUTTONDBLCLK, wParam, lParam)) {
+ sendMouseEvent (SWT.MouseDown, 2, hwnd, lParam);
+ if (sendMouseEvent (SWT.MouseDoubleClick, 2, hwnd, lParam)) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_MBUTTONDBLCLK, wParam, lParam));
} else {
result = LRESULT.ZERO;
@@ -1977,11 +2034,11 @@ LRESULT wmMButtonDblClk (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lP
return result;
}
-LRESULT wmMButtonDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmMButtonDown (long hwnd, long wParam, long lParam) {
LRESULT result = null;
Display display = this.display;
display.captureChanged = false;
- if (sendMouseEvent (SWT.MouseDown, 2, hwnd, OS.WM_MBUTTONDOWN, wParam, lParam)) {
+ if (sendMouseEvent (SWT.MouseDown, 2, hwnd, lParam)) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_MBUTTONDOWN, wParam, lParam));
} else {
result = LRESULT.ZERO;
@@ -1992,10 +2049,10 @@ LRESULT wmMButtonDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lPar
return result;
}
-LRESULT wmMButtonUp (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmMButtonUp (long hwnd, long wParam, long lParam) {
Display display = this.display;
LRESULT result = null;
- if (sendMouseEvent (SWT.MouseUp, 2, hwnd, OS.WM_MBUTTONUP, wParam, lParam)) {
+ if (sendMouseEvent (SWT.MouseUp, 2, hwnd, lParam)) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_MBUTTONUP, wParam, lParam));
} else {
result = LRESULT.ZERO;
@@ -2014,27 +2071,28 @@ LRESULT wmMButtonUp (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam
return result;
}
-LRESULT wmMouseHover (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
- if (!sendMouseEvent (SWT.MouseHover, 0, hwnd, OS.WM_MOUSEHOVER, wParam, lParam)) {
+LRESULT wmMouseHover (long hwnd, long wParam, long lParam) {
+ if (!sendMouseEvent (SWT.MouseHover, 0, hwnd, lParam)) {
return LRESULT.ZERO;
}
return null;
}
-LRESULT wmMouseLeave (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmMouseLeave (long hwnd, long wParam, long lParam) {
+ state &= ~MOUSE_OVER;
if (!hooks (SWT.MouseExit) && !filters (SWT.MouseExit)) return null;
int pos = OS.GetMessagePos ();
POINT pt = new POINT ();
OS.POINTSTOPOINT (pt, pos);
OS.ScreenToClient (hwnd, pt);
lParam = OS.MAKELPARAM (pt.x, pt.y);
- if (!sendMouseEvent (SWT.MouseExit, 0, hwnd, OS.WM_MOUSELEAVE, wParam, lParam)) {
+ if (!sendMouseEvent (SWT.MouseExit, 0, hwnd, lParam)) {
return LRESULT.ZERO;
}
return null;
}
-LRESULT wmMouseMove (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmMouseMove (long hwnd, long wParam, long lParam) {
LRESULT result = null;
Display display = this.display;
int pos = OS.GetMessagePos ();
@@ -2046,36 +2104,29 @@ LRESULT wmMouseMove (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam
if (trackMouse || mouseEnter || mouseExit || mouseHover) {
TRACKMOUSEEVENT lpEventTrack = new TRACKMOUSEEVENT ();
lpEventTrack.cbSize = TRACKMOUSEEVENT.sizeof;
- lpEventTrack.dwFlags = OS.TME_QUERY;
+ lpEventTrack.dwFlags = OS.TME_LEAVE | OS.TME_HOVER;
lpEventTrack.hwndTrack = hwnd;
OS.TrackMouseEvent (lpEventTrack);
- if (lpEventTrack.dwFlags == 0) {
- lpEventTrack.dwFlags = OS.TME_LEAVE | OS.TME_HOVER;
- lpEventTrack.hwndTrack = hwnd;
- OS.TrackMouseEvent (lpEventTrack);
- if (mouseEnter) {
- /*
- * Force all outstanding WM_MOUSELEAVE messages to be dispatched before
- * issuing a mouse enter. This causes mouse exit events to be processed
- * before mouse enter events. Note that WM_MOUSELEAVE is posted to the
- * event queue by TrackMouseEvent().
- */
- MSG msg = new MSG ();
- int flags = OS.PM_REMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE;
- while (OS.PeekMessage (msg, 0, OS.WM_MOUSELEAVE, OS.WM_MOUSELEAVE, flags)) {
- OS.TranslateMessage (msg);
- OS.DispatchMessage (msg);
- }
- sendMouseEvent (SWT.MouseEnter, 0, hwnd, OS.WM_MOUSEMOVE, wParam, lParam);
+ if (mouseEnter && (state & MOUSE_OVER) == 0) {
+ /*
+ * Force all outstanding WM_MOUSELEAVE messages to be dispatched before
+ * issuing a mouse enter. This causes mouse exit events to be processed
+ * before mouse enter events. Note that WM_MOUSELEAVE is posted to the
+ * event queue by TrackMouseEvent().
+ */
+ MSG msg = new MSG ();
+ int flags = OS.PM_REMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE;
+ while (OS.PeekMessage (msg, 0, OS.WM_MOUSELEAVE, OS.WM_MOUSELEAVE, flags)) {
+ OS.TranslateMessage (msg);
+ OS.DispatchMessage (msg);
}
- } else {
- lpEventTrack.dwFlags = OS.TME_HOVER;
- OS.TrackMouseEvent (lpEventTrack);
+ sendMouseEvent (SWT.MouseEnter, 0, hwnd, lParam);
}
+ state |= MOUSE_OVER;
}
if (pos != display.lastMouse) {
display.lastMouse = pos;
- if (!sendMouseEvent (SWT.MouseMove, 0, hwnd, OS.WM_MOUSEMOVE, wParam, lParam)) {
+ if (!sendMouseEvent (SWT.MouseMove, 0, hwnd, lParam)) {
result = LRESULT.ZERO;
}
}
@@ -2084,19 +2135,19 @@ LRESULT wmMouseMove (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam
return result;
}
-LRESULT wmMouseWheel (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmMouseWheel (long hwnd, long wParam, long lParam) {
return sendMouseWheelEvent(SWT.MouseWheel, hwnd, wParam, lParam) ? null : LRESULT.ZERO;
}
-LRESULT wmMouseHWheel (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmMouseHWheel (long hwnd, long wParam, long lParam) {
return sendMouseWheelEvent(SWT.MouseHorizontalWheel, hwnd, wParam, lParam) ? null : LRESULT.ZERO;
}
-LRESULT wmNCPaint (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmNCPaint (long hwnd, long wParam, long lParam) {
return null;
}
-LRESULT wmPaint (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmPaint (long hwnd, long wParam, long lParam) {
/* Exit early - don't draw the background */
if (!hooks (SWT.Paint) && !filters (SWT.Paint)) {
@@ -2104,9 +2155,9 @@ LRESULT wmPaint (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
}
/* Issue a paint event */
- long /*int*/ rgn = OS.CreateRectRgn (0, 0, 0, 0);
+ long rgn = OS.CreateRectRgn (0, 0, 0, 0);
OS.GetUpdateRgn (hwnd, rgn, false);
- long /*int*/ result = callWindowProc (hwnd, OS.WM_PAINT, wParam, lParam);
+ long result = callWindowProc (hwnd, OS.WM_PAINT, wParam, lParam);
GCData data = new GCData ();
data.hwnd = hwnd;
GC gc = new_GC (data);
@@ -2117,7 +2168,7 @@ LRESULT wmPaint (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
if (width != 0 && height != 0) {
- long /*int*/ hDC = gc.handle;
+ long hDC = gc.handle;
OS.SelectClipRgn (hDC, rgn);
OS.SetMetaRgn (hDC);
Event event = new Event ();
@@ -2135,7 +2186,7 @@ LRESULT wmPaint (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
return new LRESULT (result);
}
-LRESULT wmPrint (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmPrint (long hwnd, long wParam, long lParam) {
/*
* Bug in Windows. When WM_PRINT is used to print the contents
* of a control that has WS_EX_CLIENTEDGE, the old 3D border is
@@ -2146,7 +2197,7 @@ LRESULT wmPrint (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
if (OS.IsAppThemed ()) {
int bits = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE);
if ((bits & OS.WS_EX_CLIENTEDGE) != 0) {
- long /*int*/ code = callWindowProc (hwnd, OS.WM_PRINT, wParam, lParam);
+ long code = callWindowProc (hwnd, OS.WM_PRINT, wParam, lParam);
RECT rect = new RECT ();
OS.GetWindowRect (hwnd, rect);
rect.right -= rect.left;
@@ -2162,7 +2213,7 @@ LRESULT wmPrint (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
return null;
}
-LRESULT wmRButtonDblClk (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmRButtonDblClk (long hwnd, long wParam, long lParam) {
/*
* Feature in Windows. Windows sends the following
* messages when the user double clicks the mouse:
@@ -2179,8 +2230,8 @@ LRESULT wmRButtonDblClk (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lP
LRESULT result = null;
Display display = this.display;
display.captureChanged = false;
- sendMouseEvent (SWT.MouseDown, 3, hwnd, OS.WM_RBUTTONDOWN, wParam, lParam);
- if (sendMouseEvent (SWT.MouseDoubleClick, 3, hwnd, OS.WM_RBUTTONDBLCLK, wParam, lParam)) {
+ sendMouseEvent (SWT.MouseDown, 3, hwnd, lParam);
+ if (sendMouseEvent (SWT.MouseDoubleClick, 3, hwnd, lParam)) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_RBUTTONDBLCLK, wParam, lParam));
} else {
result = LRESULT.ZERO;
@@ -2191,11 +2242,11 @@ LRESULT wmRButtonDblClk (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lP
return result;
}
-LRESULT wmRButtonDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmRButtonDown (long hwnd, long wParam, long lParam) {
LRESULT result = null;
Display display = this.display;
display.captureChanged = false;
- if (sendMouseEvent (SWT.MouseDown, 3, hwnd, OS.WM_RBUTTONDOWN, wParam, lParam)) {
+ if (sendMouseEvent (SWT.MouseDown, 3, hwnd, lParam)) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_RBUTTONDOWN, wParam, lParam));
} else {
result = LRESULT.ZERO;
@@ -2206,10 +2257,10 @@ LRESULT wmRButtonDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lPar
return result;
}
-LRESULT wmRButtonUp (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmRButtonUp (long hwnd, long wParam, long lParam) {
Display display = this.display;
LRESULT result = null;
- if (sendMouseEvent (SWT.MouseUp, 3, hwnd, OS.WM_RBUTTONUP, wParam, lParam)) {
+ if (sendMouseEvent (SWT.MouseUp, 3, hwnd, lParam)) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_RBUTTONUP, wParam, lParam));
} else {
/* Call the DefWindowProc() to support WM_CONTEXTMENU */
@@ -2230,8 +2281,8 @@ LRESULT wmRButtonUp (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam
return result;
}
-LRESULT wmSetFocus (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
- long /*int*/ code = callWindowProc (hwnd, OS.WM_SETFOCUS, wParam, lParam);
+LRESULT wmSetFocus (long hwnd, long wParam, long lParam) {
+ long code = callWindowProc (hwnd, OS.WM_SETFOCUS, wParam, lParam);
sendFocusEvent (SWT.FocusIn);
// widget could be disposed at this point
@@ -2247,9 +2298,9 @@ LRESULT wmSetFocus (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
return new LRESULT (code);
}
-LRESULT wmSysChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmSysChar (long hwnd, long wParam, long lParam) {
Display display = this.display;
- display.lastAscii = (int)/*64*/wParam;
+ display.lastAscii = (int)wParam;
display.lastNull = wParam == 0;
/* Do not issue a key down if a menu bar mnemonic was invoked */
@@ -2260,7 +2311,7 @@ LRESULT wmSysChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
/* Call the window proc to determine whether it is a system key or mnemonic */
boolean oldKeyHit = display.mnemonicKeyHit;
display.mnemonicKeyHit = true;
- long /*int*/ result = callWindowProc (hwnd, OS.WM_SYSCHAR, wParam, lParam);
+ long result = callWindowProc (hwnd, OS.WM_SYSCHAR, wParam, lParam);
boolean consumed = false;
if (!display.mnemonicKeyHit) {
consumed = !sendKeyEvent (SWT.KeyDown, OS.WM_SYSCHAR, wParam, lParam);
@@ -2271,7 +2322,7 @@ LRESULT wmSysChar (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam)
return consumed ? LRESULT.ONE : new LRESULT (result);
}
-LRESULT wmSysKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmSysKeyDown (long hwnd, long wParam, long lParam) {
/*
* Feature in Windows. When WM_SYSKEYDOWN is sent,
* the user pressed ALT+<key> or F10 to get to the
@@ -2286,9 +2337,9 @@ LRESULT wmSysKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lPara
}
/* Ignore well known system keys */
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_F4: {
- long /*int*/ hwndShell = hwnd;
+ long hwndShell = hwnd;
while (OS.GetParent (hwndShell) != 0) {
if (OS.GetWindow (hwndShell, OS.GW_OWNER) != 0) break;
hwndShell = OS.GetParent (hwndShell);
@@ -2299,7 +2350,7 @@ LRESULT wmSysKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lPara
}
/* Ignore repeating modifier keys by testing key down state */
- switch ((int)/*64*/wParam) {
+ switch ((int)wParam) {
case OS.VK_SHIFT:
case OS.VK_MENU:
case OS.VK_CONTROL:
@@ -2314,11 +2365,11 @@ LRESULT wmSysKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lPara
display.lastVirtual = display.lastNull = display.lastDead = false;
/* If are going to get a WM_SYSCHAR, ignore this message. */
- int mapKey = OS.MapVirtualKey ((int)/*64*/wParam, 2);
+ int mapKey = OS.MapVirtualKey ((int)wParam, 2);
- display.lastVirtual = mapKey == 0 || display.numpadKey ((int)/*64*/wParam) != 0;
+ display.lastVirtual = mapKey == 0 || display.numpadKey ((int)wParam) != 0;
if (display.lastVirtual) {
- display.lastKey = (int)/*64*/wParam;
+ display.lastKey = (int)wParam;
/*
* Feature in Windows. The virtual key VK_DELETE is not
* treated as both a virtual key and an ASCII key by Windows.
@@ -2355,7 +2406,7 @@ LRESULT wmSysKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lPara
* upper case values in WM_SYSKEYDOWN despite the fact that the
* Shift was not pressed.
*/
- display.lastKey = (int)/*64*/OS.CharLower ((short) mapKey);
+ display.lastKey = (int)OS.CharLower ((short) mapKey);
return null;
}
@@ -2366,11 +2417,11 @@ LRESULT wmSysKeyDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lPara
return null;
}
-LRESULT wmSysKeyUp (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmSysKeyUp (long hwnd, long wParam, long lParam) {
return wmKeyUp (hwnd, wParam, lParam);
}
-LRESULT wmXButtonDblClk (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmXButtonDblClk (long hwnd, long wParam, long lParam) {
/*
* Feature in Windows. Windows sends the following
* messages when the user double clicks the mouse:
@@ -2388,8 +2439,8 @@ LRESULT wmXButtonDblClk (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lP
Display display = this.display;
display.captureChanged = false;
int button = OS.HIWORD (wParam) == OS.XBUTTON1 ? 4 : 5;
- sendMouseEvent (SWT.MouseDown, button, hwnd, OS.WM_XBUTTONDOWN, wParam, lParam);
- if (sendMouseEvent (SWT.MouseDoubleClick, button, hwnd, OS.WM_XBUTTONDBLCLK, wParam, lParam)) {
+ sendMouseEvent (SWT.MouseDown, button, hwnd, lParam);
+ if (sendMouseEvent (SWT.MouseDoubleClick, button, hwnd, lParam)) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_XBUTTONDBLCLK, wParam, lParam));
} else {
result = LRESULT.ZERO;
@@ -2400,13 +2451,13 @@ LRESULT wmXButtonDblClk (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lP
return result;
}
-LRESULT wmXButtonDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmXButtonDown (long hwnd, long wParam, long lParam) {
LRESULT result = null;
Display display = this.display;
display.captureChanged = false;
display.xMouse = true;
int button = OS.HIWORD (wParam) == OS.XBUTTON1 ? 4 : 5;
- if (sendMouseEvent (SWT.MouseDown, button, hwnd, OS.WM_XBUTTONDOWN, wParam, lParam)) {
+ if (sendMouseEvent (SWT.MouseDown, button, hwnd, lParam)) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_XBUTTONDOWN, wParam, lParam));
} else {
result = LRESULT.ZERO;
@@ -2417,11 +2468,11 @@ LRESULT wmXButtonDown (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lPar
return result;
}
-LRESULT wmXButtonUp (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam) {
+LRESULT wmXButtonUp (long hwnd, long wParam, long lParam) {
Display display = this.display;
LRESULT result = null;
int button = OS.HIWORD (wParam) == OS.XBUTTON1 ? 4 : 5;
- if (sendMouseEvent (SWT.MouseUp, button, hwnd, OS.WM_XBUTTONUP, wParam, lParam)) {
+ if (sendMouseEvent (SWT.MouseUp, button, hwnd, lParam)) {
result = new LRESULT (callWindowProc (hwnd, OS.WM_XBUTTONUP, wParam, lParam));
} else {
result = LRESULT.ZERO;
@@ -2439,4 +2490,17 @@ LRESULT wmXButtonUp (long /*int*/ hwnd, long /*int*/ wParam, long /*int*/ lParam
}
return result;
}
+
+void notifyCreationTracker() {
+ if (WidgetSpy.isEnabled) {
+ WidgetSpy.getInstance().widgetCreated(this);
+ }
+}
+
+void notifyDisposalTracker() {
+ if (WidgetSpy.isEnabled) {
+ WidgetSpy.getInstance().widgetDisposed(this);
+ }
+}
+
}

Back to the top