Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiraj Modi2019-06-12 09:31:21 +0000
committerNiraj Modi2019-06-12 09:31:33 +0000
commitbf374552cac5b50f6b86727909611fb3d0aafce9 (patch)
treee71b825eb7187354bed04e9ed19f560dd181a403
parent32d26f5d91674135681f8cf2e02d525c28d23d0d (diff)
downloadeclipse.platform.swt-bf374552cac5b50f6b86727909611fb3d0aafce9.tar.gz
eclipse.platform.swt-bf374552cac5b50f6b86727909611fb3d0aafce9.tar.xz
eclipse.platform.swt-bf374552cac5b50f6b86727909611fb3d0aafce9.zip
Revert "Revert "Bug 293230 - [Win32] Support SWT.ICON_SEARCH/CANCEL Text styles""
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/cancel.icobin0 -> 16398 bytes
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/search.icobin0 -> 16398 bytes
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.rc4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java166
10 files changed, 226 insertions, 22 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/cancel.ico b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/cancel.ico
new file mode 100644
index 0000000000..d113216165
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/cancel.ico
Binary files differ
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
index ed1dad625c..d02174121c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
@@ -601,6 +601,22 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(CharUpper)
}
#endif
+#ifndef NO_ChildWindowFromPointEx
+JNIEXPORT jintLong JNICALL OS_NATIVE(ChildWindowFromPointEx)
+ (JNIEnv *env, jclass that, jintLong arg0, jobject arg1, jint arg2)
+{
+ POINT _arg1, *lparg1=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, ChildWindowFromPointEx_FUNC);
+ if (arg1) if ((lparg1 = getPOINTFields(env, arg1, &_arg1)) == NULL) goto fail;
+ rc = (jintLong)ChildWindowFromPointEx((HWND)arg0, *lparg1, (UINT)arg2);
+fail:
+ if (arg1 && lparg1) setPOINTFields(env, arg1, lparg1);
+ OS_NATIVE_EXIT(env, that, ChildWindowFromPointEx_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_ChooseColor
JNIEXPORT jboolean JNICALL OS_NATIVE(ChooseColor)
(JNIEnv *env, jclass that, jobject arg0)
@@ -5164,6 +5180,22 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(LoadIcon)
}
#endif
+#ifndef NO_LoadIconMetric
+JNIEXPORT jint JNICALL OS_NATIVE(LoadIconMetric)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jint arg2, jintLongArray arg3)
+{
+ jintLong *lparg3=NULL;
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, LoadIconMetric_FUNC);
+ if (arg3) if ((lparg3 = (*env)->GetIntLongArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ rc = (jint)LoadIconMetric((HINSTANCE)arg0, (PCWSTR)arg1, arg2, (HICON *)lparg3);
+fail:
+ if (arg3 && lparg3) (*env)->ReleaseIntLongArrayElements(env, arg3, lparg3, 0);
+ OS_NATIVE_EXIT(env, that, LoadIconMetric_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_LoadImage
JNIEXPORT jintLong JNICALL OS_NATIVE(LoadImage)
(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jint arg2, jint arg3, jint arg4, jint arg5)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
index 94546b87c3..451f7bb9cc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
@@ -65,6 +65,7 @@ char * OS_nativeFunctionNames[] = {
"CertNameToStr",
"CharLower",
"CharUpper",
+ "ChildWindowFromPointEx",
"ChooseColor",
"ChooseFont",
"ClientToScreen",
@@ -427,6 +428,7 @@ char * OS_nativeFunctionNames[] = {
"LoadBitmap",
"LoadCursor",
"LoadIcon",
+ "LoadIconMetric",
"LoadImage",
"LocalFree",
"MAKELPARAM",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
index c5df36e115..4f0ff7b2f9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
@@ -75,6 +75,7 @@ typedef enum {
CertNameToStr_FUNC,
CharLower_FUNC,
CharUpper_FUNC,
+ ChildWindowFromPointEx_FUNC,
ChooseColor_FUNC,
ChooseFont_FUNC,
ClientToScreen_FUNC,
@@ -437,6 +438,7 @@ typedef enum {
LoadBitmap_FUNC,
LoadCursor_FUNC,
LoadIcon_FUNC,
+ LoadIconMetric_FUNC,
LoadImage_FUNC,
LocalFree_FUNC,
MAKELPARAM_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/search.ico b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/search.ico
new file mode 100644
index 0000000000..5eaf35c21e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/search.ico
Binary files differ
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.rc b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.rc
index 651f8dc0cf..3057b6dd33 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.rc
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.rc
@@ -50,3 +50,7 @@ BEGIN
VALUE "Translation", 0x409, 1200
END
END
+
+/* Icons for Text widget */
+101 ICON "search.ico"
+102 ICON "cancel.ico"
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
index 19de3759b3..0a20afaeb7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
@@ -347,6 +347,7 @@ public class OS extends C {
public static final int CS_VREDRAW = 0x1;
public static final int CS_OWNDC = 0x20;
public static final int CW_USEDEFAULT = 0x80000000;
+ public static final int CWP_SKIPINVISIBLE = 0x0001;
public static final String DATETIMEPICK_CLASS = "SysDateTimePick32"; //$NON-NLS-1$
public static final int DCX_CACHE = 0x2;
public static final int DCX_CLIPCHILDREN = 0x8;
@@ -770,6 +771,7 @@ public class OS extends C {
public static final int LGRPID_INSTALLED = 1;
public static final int LIF_ITEMINDEX = 0x1;
public static final int LIF_STATE = 0x2;
+ public static final int LIM_SMALL = 0;
public static final int LIS_FOCUSED = 0x1;
public static final int LIS_ENABLED = 0x2;
public static final int LISS_HOT = 0x2;
@@ -2413,6 +2415,12 @@ public static final native int CertNameToStr (int dwCertEncodingType, CERT_NAME_
public static final native long /*int*/ CharLower (long /*int*/ ch);
/** @param ch cast=(LPWSTR) */
public static final native long /*int*/ CharUpper (long /*int*/ ch);
+/**
+ * @param hWndParent cast=(HWND)
+ * @param pt flags=struct
+ * @param flags cast=(UINT)
+ */
+public static final native long /*int*/ ChildWindowFromPointEx (long /*int*/ hWndParent, POINT pt, int flags);
/** @param lpcc cast=(LPCHOOSECOLORW) */
public static final native boolean ChooseColor (CHOOSECOLOR lpcc);
/** @param chooseFont cast=(LPCHOOSEFONTW) */
@@ -3291,6 +3299,12 @@ public static final native long /*int*/ LoadCursor (long /*int*/ hInstance, long
public static final native long /*int*/ LoadIcon (long /*int*/ hInstance, long /*int*/ lpIconName);
/**
* @param hinst cast=(HINSTANCE)
+ * @param pszName cast=(PCWSTR)
+ * @param phico cast=(HICON *)
+ */
+public static final native int LoadIconMetric (long /*int*/ hinst, long /*int*/ pszName, int lims, long /*int*/ [] phico);
+/**
+ * @param hinst cast=(HINSTANCE)
* @param lpszName cast=(LPWSTR)
*/
public static final native long /*int*/ LoadImage (long /*int*/ hinst, long /*int*/ lpszName, int uType, int cxDesired, int cyDesired, int fuLoad);
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..0aad7e5b74 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
@@ -161,6 +161,10 @@ public class Display extends Device {
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};
+ /* Custom icons */
+ long /*int*/ hIconSearch;
+ long /*int*/ hIconCancel;
+
/* Focus */
int focusEvent;
Control focusControl;
@@ -3628,6 +3632,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);
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..81a335f82d 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
@@ -152,8 +152,14 @@ ScrollBar createScrollBar (int type) {
@Override
void createWidget () {
super.createWidget ();
- if ((style & SWT.H_SCROLL) != 0) horizontalBar = createScrollBar (SWT.H_SCROLL);
- if ((style & SWT.V_SCROLL) != 0) verticalBar = createScrollBar (SWT.V_SCROLL);
+ /*
+ * 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) {
+ if ((style & SWT.H_SCROLL) != 0) horizontalBar = createScrollBar (SWT.H_SCROLL);
+ if ((style & SWT.V_SCROLL) != 0) verticalBar = createScrollBar (SWT.V_SCROLL);
+ }
}
@Override
@@ -328,8 +334,14 @@ int widgetExtStyle () {
@Override
int widgetStyle () {
int bits = super.widgetStyle () | OS.WS_TABSTOP;
- if ((style & SWT.H_SCROLL) != 0) bits |= OS.WS_HSCROLL;
- if ((style & SWT.V_SCROLL) != 0) bits |= OS.WS_VSCROLL;
+ /*
+ * 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) {
+ if ((style & SWT.H_SCROLL) != 0) bits |= OS.WS_HSCROLL;
+ if ((style & SWT.V_SCROLL) != 0) bits |= OS.WS_VSCROLL;
+ }
return bits;
}
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..336ded9566 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 /*int*/ hwndSearch, hwndCancel, hwndActive;
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.
@@ -262,6 +267,49 @@ long /*int*/ callWindowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, lo
break;
}
}
+ if ((style & SWT.SEARCH) != 0) {
+ switch (msg) {
+ case OS.WM_MOUSEMOVE: {
+ POINT pt = new POINT ();
+ OS.POINTSTOPOINT(pt, lParam);
+ long /*int*/ prevActive = hwndActive;
+ hwndActive = OS.ChildWindowFromPointEx (handle, pt, OS.CWP_SKIPINVISIBLE);
+ if (hwndActive == handle) hwndActive = 0;
+ if (prevActive != hwndActive) {
+ if (prevActive != 0) OS.InvalidateRect (prevActive, null, false);
+ if (hwndActive != 0) OS.InvalidateRect (hwndActive, null, false);
+ }
+ break;
+ }
+ case OS.WM_MOUSELEAVE:
+ if (hwndActive != 0) {
+ OS.InvalidateRect (hwndActive, null, false);
+ hwndActive = 0;
+ }
+ break;
+ case OS.WM_LBUTTONDOWN:
+ if (hwndActive != 0) {
+ OS.InvalidateRect (hwndActive, null, false);
+ return 0; // prevent mouse selection
+ }
+ break;
+ case OS.WM_LBUTTONUP: {
+ if (hwndActive != 0) {
+ Event e = new Event();
+ if (hwndActive == hwndSearch) {
+ e.detail = SWT.ICON_SEARCH;
+ } else {
+ e.detail = SWT.ICON_CANCEL;
+ setText ("");
+ }
+ setFocus ();
+ selectAll ();
+ sendSelectionEvent (SWT.DefaultSelection, e, false);
+ }
+ break;
+ }
+ }
+ }
long /*int*/ code = OS.CallWindowProc (EditProc, hwnd, msg, wParam, lParam);
switch (msg) {
case OS.WM_HSCROLL:
@@ -285,6 +333,30 @@ void createHandle () {
state |= THEME_BACKGROUND;
}
}
+ if ((style & SWT.SEARCH) != 0) {
+ if (display.hIconSearch == 0) {
+ long /*int*/ [] phicon = new long /*int*/ [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) {
+ hwndSearch = OS.CreateWindowEx (0, Label.LabelClass, null,
+ OS.WS_CHILD | OS.WS_VISIBLE | OS.WS_CLIPSIBLINGS | OS.SS_OWNERDRAW,
+ 0, 0, 0, 0, handle, 0, OS.GetModuleHandle (null), null);
+ if (hwndSearch == 0) error (SWT.ERROR_NO_HANDLES);
+ }
+ if ((style & SWT.ICON_CANCEL) != 0) {
+ state |= TRACK_MOUSE;
+ hwndCancel = OS.CreateWindowEx (0, Label.LabelClass, null,
+ OS.WS_CHILD | OS.WS_CLIPSIBLINGS | OS.SS_OWNERDRAW,
+ 0, 0, 0, 0, handle, 0, OS.GetModuleHandle (null), null);
+ if (hwndCancel == 0) error (SWT.ERROR_NO_HANDLES);
+ }
+ }
}
@Override
@@ -559,20 +631,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;
@@ -751,7 +823,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) {
@@ -1792,6 +1867,18 @@ boolean sendKeyEvent (int type, int msg, long /*int*/ wParam, long /*int*/ lPara
}
@Override
+void setBackgroundImage (long /*int*/ hBitmap) {
+ int flags = OS.RDW_ERASE | OS.RDW_ALLCHILDREN | OS.RDW_INVALIDATE;
+ OS.RedrawWindow (handle, null, 0, flags);
+}
+
+@Override
+void setBackgroundPixel (int pixel) {
+ 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,
@@ -1947,14 +2034,16 @@ public void setFont (Font font) {
}
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);
+ int flags = 0;
+ int fLeading = (style & SWT.LEFT_TO_RIGHT) != 0 ? OS.EC_LEFTMARGIN : OS.EC_RIGHTMARGIN;
+ int fTrailing = (style & SWT.LEFT_TO_RIGHT) != 0 ? OS.EC_RIGHTMARGIN : OS.EC_LEFTMARGIN;
+ 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));
+ }
}
}
@@ -2428,6 +2517,7 @@ int widgetStyle () {
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,
@@ -2614,6 +2704,25 @@ LRESULT WM_CUT (long /*int*/ wParam, long /*int*/ lParam) {
}
@Override
+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.hwndItem == hwndCancel && struct.hwndItem == hwndActive && 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 /*int*/ hIcon = (struct.hwndItem == hwndSearch) ? 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 /*int*/ wParam, long /*int*/ lParam) {
LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
if ((style & SWT.READ_ONLY) != 0) {
@@ -2757,6 +2866,24 @@ LRESULT WM_PASTE (long /*int*/ wParam, long /*int*/ lParam) {
}
@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. */
+ long /*int*/ hwndLeading = (style & SWT.LEFT_TO_RIGHT) != 0 ? hwndSearch : hwndCancel;
+ long /*int*/ hwndTrailing = (style & SWT.LEFT_TO_RIGHT) != 0 ? hwndCancel : hwndSearch;
+ 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 /*int*/ wParam, long /*int*/ lParam) {
LRESULT result = super.WM_UNDO (wParam, lParam);
if (result != null) return result;
@@ -2873,6 +3000,9 @@ LRESULT wmCommandChild (long /*int*/ wParam, long /*int*/ lParam) {
if (findImageControl () != null) {
OS.InvalidateRect (handle, null, true);
}
+ if ((style & SWT.SEARCH) != 0 && hwndCancel != 0) {
+ OS.ShowWindow (hwndCancel, OS.GetWindowTextLength (handle) != 0 ? OS.SW_SHOW : OS.SW_HIDE);
+ }
if (ignoreModify) break;
/*
* It is possible (but unlikely), that application

Back to the top