]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/widgets/Group.java
Remove invalid SHA-256-Digests
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / widgets / Group.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2018 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.widgets;
15
16
17 import org.eclipse.swt.*;
18 import org.eclipse.swt.graphics.*;
19 import org.eclipse.swt.internal.*;
20 import org.eclipse.swt.internal.win32.*;
21
22 /**
23  * Instances of this class provide an etched border
24  * with an optional title.
25  * <p>
26  * Shadow styles are hints and may not be honoured
27  * by the platform.  To create a group with the
28  * default shadow style for the platform, do not
29  * specify a shadow style.
30  * <dl>
31  * <dt><b>Styles:</b></dt>
32  * <dd>SHADOW_ETCHED_IN, SHADOW_ETCHED_OUT, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
33  * <dt><b>Events:</b></dt>
34  * <dd>(none)</dd>
35  * </dl>
36  * <p>
37  * Note: Only one of the above styles may be specified.
38  * </p><p>
39  * IMPORTANT: This class is <em>not</em> intended to be subclassed.
40  * </p>
41  *
42  * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
43  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
44  * @noextend This class is not intended to be subclassed by clients.
45  */
46 public class Group extends Composite {
47         String text = "";
48         static final int CLIENT_INSET = 3;
49         static final long GroupProc;
50         static final TCHAR GroupClass = new TCHAR (0, "SWT_GROUP", true);
51         static {
52                 /*
53                 * Feature in Windows.  The group box window class
54                 * uses the CS_HREDRAW and CS_VREDRAW style bits to
55                 * force a full redraw of the control and all children
56                 * when resized.  This causes flashing.  The fix is to
57                 * register a new window class without these bits and
58                 * implement special code that damages only the control.
59                 */
60                 WNDCLASS lpWndClass = new WNDCLASS ();
61                 TCHAR WC_BUTTON = new TCHAR (0, "BUTTON", true);
62                 OS.GetClassInfo (0, WC_BUTTON, lpWndClass);
63                 GroupProc = lpWndClass.lpfnWndProc;
64                 long hInstance = OS.GetModuleHandle (null);
65                 if (!OS.GetClassInfo (hInstance, GroupClass, lpWndClass)) {
66                         lpWndClass.hInstance = hInstance;
67                         lpWndClass.style &= ~(OS.CS_HREDRAW | OS.CS_VREDRAW);
68                         OS.RegisterClass (GroupClass, lpWndClass);
69                 }
70         }
71
72 /**
73  * Constructs a new instance of this class given its parent
74  * and a style value describing its behavior and appearance.
75  * <p>
76  * The style value is either one of the style constants defined in
77  * class <code>SWT</code> which is applicable to instances of this
78  * class, or must be built by <em>bitwise OR</em>'ing together
79  * (that is, using the <code>int</code> "|" operator) two or more
80  * of those <code>SWT</code> style constants. The class description
81  * lists the style constants that are applicable to the class.
82  * Style bits are also inherited from superclasses.
83  * </p>
84  *
85  * @param parent a composite control which will be the parent of the new instance (cannot be null)
86  * @param style the style of control to construct
87  *
88  * @exception IllegalArgumentException <ul>
89  *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
90  * </ul>
91  * @exception SWTException <ul>
92  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
93  *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
94  * </ul>
95  *
96  * @see SWT#SHADOW_ETCHED_IN
97  * @see SWT#SHADOW_ETCHED_OUT
98  * @see SWT#SHADOW_IN
99  * @see SWT#SHADOW_OUT
100  * @see SWT#SHADOW_NONE
101  * @see Widget#checkSubclass
102  * @see Widget#getStyle
103  */
104 public Group (Composite parent, int style) {
105         super (parent, checkStyle (style));
106 }
107
108 @Override
109 long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
110         if (handle == 0) return 0;
111         /*
112         * Feature in Windows.  When the user clicks on the group
113         * box label, the group box takes focus.  This is unwanted.
114         * The fix is to avoid calling the group box window proc.
115         */
116         switch (msg) {
117                 case OS.WM_LBUTTONDOWN:
118                 case OS.WM_LBUTTONDBLCLK:
119                         return OS.DefWindowProc (hwnd, msg, wParam, lParam);
120         }
121         return OS.CallWindowProc (GroupProc, hwnd, msg, wParam, lParam);
122 }
123
124 static int checkStyle (int style) {
125         style |= SWT.NO_FOCUS;
126         /*
127         * Even though it is legal to create this widget
128         * with scroll bars, they serve no useful purpose
129         * because they do not automatically scroll the
130         * widget's client area.  The fix is to clear
131         * the SWT style.
132         */
133         return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
134 }
135
136 @Override
137 protected void checkSubclass () {
138         if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
139 }
140
141 @Override Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
142         checkWidget ();
143         Point size = super.computeSizeInPixels (wHint, hHint, changed);
144         int length = text.length ();
145         if (length != 0) {
146                 String string = fixText (false);
147
148                 /*
149                 * If the group has text, and the text is wider than the
150                 * client area, pad the width so the text is not clipped.
151                 */
152                 char [] buffer = (string == null ? text : string).toCharArray ();
153                 long newFont, oldFont = 0;
154                 long hDC = OS.GetDC (handle);
155                 newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
156                 if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
157                 RECT rect = new RECT ();
158                 int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE;
159                 OS.DrawText (hDC, buffer, buffer.length, rect, flags);
160                 if (newFont != 0) OS.SelectObject (hDC, oldFont);
161                 OS.ReleaseDC (handle, hDC);
162                 int offsetY = OS.IsAppThemed () ? 0 : 1;
163                 size.x = Math.max (size.x, rect.right - rect.left + CLIENT_INSET * 6 + offsetY);
164         }
165         return size;
166 }
167
168 @Override Rectangle computeTrimInPixels (int x, int y, int width, int height) {
169         checkWidget ();
170         Rectangle trim = super.computeTrimInPixels (x, y, width, height);
171         long newFont, oldFont = 0;
172         long hDC = OS.GetDC (handle);
173         newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
174         if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
175         TEXTMETRIC tm = new TEXTMETRIC ();
176         OS.GetTextMetrics (hDC, tm);
177         if (newFont != 0) OS.SelectObject (hDC, oldFont);
178         OS.ReleaseDC (handle, hDC);
179         int offsetY = OS.IsAppThemed () ? 0 : 1;
180         trim.x -= CLIENT_INSET;
181         trim.y -= tm.tmHeight + offsetY;
182         trim.width += CLIENT_INSET * 2;
183         trim.height += tm.tmHeight + CLIENT_INSET + offsetY;
184         return trim;
185 }
186
187 @Override
188 void createHandle () {
189         /*
190         * Feature in Windows.  When a button is created,
191         * it clears the UI state for all controls in the
192         * shell by sending WM_CHANGEUISTATE with UIS_SET,
193         * UISF_HIDEACCEL and UISF_HIDEFOCUS to the parent.
194         * This is undocumented and unexpected.  The fix
195         * is to ignore the WM_CHANGEUISTATE, when sent
196         * from CreateWindowEx().
197         */
198         parent.state |= IGNORE_WM_CHANGEUISTATE;
199         super.createHandle ();
200         parent.state &= ~IGNORE_WM_CHANGEUISTATE;
201         state |= DRAW_BACKGROUND;
202         state &= ~CANVAS;
203 }
204
205 @Override
206 void enableWidget (boolean enabled) {
207         super.enableWidget (enabled);
208         /*
209         * Bug in Windows.  When a group control is right-to-left and
210         * is disabled, the first pixel of the text is clipped.  The
211         * fix is to add a space to both sides of the text.
212         */
213         String string = fixText (enabled);
214         if (string != null) {
215                 TCHAR buffer = new TCHAR (getCodePage (), string, true);
216                 OS.SetWindowText (handle, buffer);
217         }
218         if (enabled && hasCustomForeground()) {
219                 OS.InvalidateRect (handle, null, true);
220         }
221 }
222
223 String fixText (boolean enabled) {
224         /*
225         * Bug in Windows.  When a group control is right-to-left and
226         * is disabled, the first pixel of the text is clipped.  The
227         * fix is to add a space to both sides of the text.
228         */
229         if (text.length() == 0) return null;
230         if ((style & SWT.RIGHT_TO_LEFT) != 0) {
231                 String string = null;
232                 if (!enabled && !OS.IsAppThemed ()) {
233                         string = " " + text + " ";
234                 }
235                 return (style & SWT.FLIP_TEXT_DIRECTION) == 0 ? string : string != null ? LRE + string : LRE + text;
236         } else if ((style & SWT.FLIP_TEXT_DIRECTION) != 0) {
237                 return RLE + text;
238         }
239         return null;
240 }
241
242 @Override Rectangle getClientAreaInPixels () {
243         checkWidget ();
244         forceResize ();
245         RECT rect = new RECT ();
246         OS.GetClientRect (handle, rect);
247         long newFont, oldFont = 0;
248         long hDC = OS.GetDC (handle);
249         newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
250         if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
251         TEXTMETRIC tm = new TEXTMETRIC ();
252         OS.GetTextMetrics (hDC, tm);
253         if (newFont != 0) OS.SelectObject (hDC, oldFont);
254         OS.ReleaseDC (handle, hDC);
255         int offsetY = OS.IsAppThemed () ? 0 : 1;
256         int x = CLIENT_INSET, y = tm.tmHeight + offsetY;
257         int width = Math.max (0, rect.right - CLIENT_INSET * 2);
258         int height = Math.max (0, rect.bottom - y - CLIENT_INSET);
259         return new Rectangle (x, y, width, height);
260 }
261
262 @Override
263 String getNameText () {
264         return getText ();
265 }
266
267 /**
268  * Returns the receiver's text, which is the string that the
269  * is used as the <em>title</em>. If the text has not previously
270  * been set, returns an empty string.
271  *
272  * @return the text
273  *
274  * @exception SWTException <ul>
275  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
276  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
277  * </ul>
278  */
279 public String getText () {
280         checkWidget ();
281         return text;
282 }
283
284 @Override
285 boolean mnemonicHit (char key) {
286         return setFocus ();
287 }
288
289 @Override
290 boolean mnemonicMatch (char key) {
291         char mnemonic = findMnemonic (getText ());
292         if (mnemonic == '\0') return false;
293         return Character.toUpperCase (key) == Character.toUpperCase (mnemonic);
294 }
295
296 @Override
297 void printWidget (long hwnd, long hdc, GC gc) {
298         /*
299         * Bug in Windows.  For some reason, PrintWindow()
300         * returns success but does nothing when it is called
301         * on a printer.  The fix is to just go directly to
302         * WM_PRINT in this case.
303         */
304         boolean success = false;
305         if (!(OS.GetDeviceCaps(gc.handle, OS.TECHNOLOGY) == OS.DT_RASPRINTER)) {
306                 int bits = OS.GetWindowLong (hwnd, OS.GWL_STYLE);
307                 if ((bits & OS.WS_VISIBLE) == 0) {
308                         OS.ShowWindow (hwnd, OS.SW_SHOW);
309                 }
310                 success = OS.PrintWindow (hwnd, hdc, 0);
311                 if ((bits & OS.WS_VISIBLE) == 0) {
312                         OS.ShowWindow (hwnd, OS.SW_HIDE);
313                 }
314         }
315
316         /*
317         * Bug in Windows.  For some reason, PrintWindow() fails
318         * when it is called on a push button.  The fix is to
319         * detect the failure and use WM_PRINT instead.  Note
320         * that WM_PRINT cannot be used all the time because it
321         * fails for browser controls when the browser has focus.
322         */
323         if (!success) {
324                 /*
325                 * Bug in Windows.  For some reason, WM_PRINT when called
326                 * with PRF_CHILDREN will not draw the tool bar divider
327                 * for tool bar children that do not have CCS_NODIVIDER.
328                 * The fix is to draw the group box and iterate through
329                 * the children, drawing each one.
330                 */
331                 int flags = OS.PRF_CLIENT | OS.PRF_NONCLIENT | OS.PRF_ERASEBKGND;
332                 OS.SendMessage (hwnd, OS.WM_PRINT, hdc, flags);
333                 int nSavedDC = OS.SaveDC (hdc);
334                 Control [] children = _getChildren ();
335                 Rectangle rect = getBoundsInPixels ();
336                 OS.IntersectClipRect (hdc, 0, 0, rect.width, rect.height);
337                 for (int i=children.length - 1; i>=0; --i) {
338                         Point location = children [i].getLocationInPixels ();
339                         int graphicsMode = OS.GetGraphicsMode(hdc);
340                         if (graphicsMode == OS.GM_ADVANCED) {
341                                 float [] lpXform = {1, 0, 0, 1, location.x, location.y};
342                                 OS.ModifyWorldTransform(hdc, lpXform, OS.MWT_LEFTMULTIPLY);
343                         } else {
344                                 OS.SetWindowOrgEx (hdc, -location.x, -location.y, null);
345                         }
346                         long topHandle = children [i].topHandle();
347                         int bits = OS.GetWindowLong (topHandle, OS.GWL_STYLE);
348                         if ((bits & OS.WS_VISIBLE) != 0) {
349                                 children [i].printWidget (topHandle, hdc, gc);
350                         }
351                         if (graphicsMode == OS.GM_ADVANCED) {
352                                 float [] lpXform = {1, 0, 0, 1, -location.x, -location.y};
353                                 OS.ModifyWorldTransform(hdc, lpXform, OS.MWT_LEFTMULTIPLY);
354                         }
355                 }
356                 OS.RestoreDC (hdc, nSavedDC);
357         }
358 }
359
360 @Override
361 void releaseWidget () {
362         super.releaseWidget ();
363         text = null;
364 }
365
366 @Override
367 int resolveTextDirection () {
368         return BidiUtil.resolveTextDirection (text);
369 }
370
371 @Override
372 public void setFont (Font font) {
373         checkWidget ();
374         Rectangle oldRect = getClientAreaInPixels ();
375         super.setFont (font);
376         Rectangle newRect = getClientAreaInPixels ();
377         if (!oldRect.equals (newRect)) sendResize ();
378 }
379
380 /**
381  * Sets the receiver's text, which is the string that will
382  * be displayed as the receiver's <em>title</em>, to the argument,
383  * which may not be null. The string may include the mnemonic character.
384  * <p>
385  * Mnemonics are indicated by an '&amp;' that causes the next
386  * character to be the mnemonic.  When the user presses a
387  * key sequence that matches the mnemonic, focus is assigned
388  * to the first child of the group. On most platforms, the
389  * mnemonic appears underlined but may be emphasised in a
390  * platform specific manner.  The mnemonic indicator character
391  * '&amp;' can be escaped by doubling it in the string, causing
392  * a single '&amp;' to be displayed.
393  * </p><p>
394  * Note: If control characters like '\n', '\t' etc. are used
395  * in the string, then the behavior is platform dependent.
396  * </p>
397  * @param string the new text
398  *
399  * @exception IllegalArgumentException <ul>
400  *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
401  * </ul>
402  * @exception SWTException <ul>
403  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
404  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
405  * </ul>
406  */
407 public void setText (String string) {
408         checkWidget ();
409         if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
410         text = string;
411         if ((state & HAS_AUTO_DIRECTION) == 0 || !updateTextDirection (AUTO_TEXT_DIRECTION)) {
412                 string = fixText (OS.IsWindowEnabled (handle));
413                 TCHAR buffer = new TCHAR (getCodePage (), string == null ? text : string, true);
414                 OS.SetWindowText (handle, buffer);
415         }
416 }
417
418 @Override
419 boolean updateTextDirection(int textDirection) {
420         if (super.updateTextDirection(textDirection)) {
421                 String string = fixText (OS.IsWindowEnabled (handle));
422                 TCHAR buffer = new TCHAR (getCodePage (), string == null ? text : string, true);
423                 OS.SetWindowText (handle, buffer);
424                 return true;
425         }
426         return false;
427 }
428
429 @Override
430 int widgetStyle () {
431         /*
432         * Bug in Windows.  When GetDCEx() is called with DCX_INTERSECTUPDATE,
433         * the HDC that is returned does not include the current update region.
434         * This was confirmed under DEBUG Windows when GetDCEx() complained about
435         * invalid flags.  Therefore, it is not easily possible to get an HDC from
436         * outside of WM_PAINT that includes the current damage and clips children.
437         * Because the receiver has children and draws a frame and label, it is
438         * necessary that the receiver always draw clipped, in the current damaged
439         * area.  The fix is to force the receiver to be fully clipped by including
440         * WS_CLIPCHILDREN and WS_CLIPSIBLINGS in the default style bits.
441         */
442         return super.widgetStyle () | OS.BS_GROUPBOX | OS.WS_CLIPCHILDREN | OS.WS_CLIPSIBLINGS;
443 }
444
445 @Override
446 TCHAR windowClass () {
447         return GroupClass;
448 }
449
450 @Override
451 long windowProc () {
452         return GroupProc;
453 }
454
455 @Override
456 LRESULT WM_ERASEBKGND (long wParam, long lParam) {
457         LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
458         if (result != null) return result;
459         /*
460         * Feature in Windows.  Group boxes do not erase
461         * the background before drawing.  The fix is to
462         * fill the background.
463         */
464         drawBackground (wParam);
465         return LRESULT.ONE;
466 }
467
468 @Override
469 LRESULT WM_NCHITTEST (long wParam, long lParam) {
470         LRESULT result = super.WM_NCHITTEST (wParam, lParam);
471         if (result != null) return result;
472         /*
473         * Feature in Windows.  The window proc for the group box
474         * returns HTTRANSPARENT indicating that mouse messages
475         * should not be delivered to the receiver and any children.
476         * Normally, group boxes in Windows do not have children and
477         * this is the correct behavior for this case.  Because we
478         * allow children, answer HTCLIENT to allow mouse messages
479         * to be delivered to the children.
480         */
481         long code = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
482         if (code == OS.HTTRANSPARENT) code = OS.HTCLIENT;
483         return new LRESULT (code);
484 }
485
486 @Override
487 LRESULT WM_MOUSEMOVE (long wParam, long lParam) {
488         LRESULT result = super.WM_MOUSEMOVE (wParam, lParam);
489         if (result != null) return result;
490         /*
491         * Feature in Windows.  In version 6.00 of COMCTL32.DLL,
492         * every time the mouse moves, the group title redraws.
493         * This only happens when WM_NCHITTEST returns HTCLIENT.
494         * The fix is to avoid calling the group window proc.
495         */
496         return LRESULT.ZERO;
497 }
498
499 @Override
500 LRESULT WM_PAINT (long wParam, long lParam) {
501         LRESULT result = super.WM_PAINT(wParam, lParam);
502
503         if (hasCustomForeground() && text.length () != 0) {
504                 String string = fixText (false);
505                 char [] buffer = (string == null ? text : string).toCharArray ();
506
507                 // We cannot use BeginPaint and EndPaint, because that removes the group border
508                 long hDC = OS.GetDC(handle);
509                 RECT rect = new RECT ();
510                 OS.GetClientRect (handle, rect);
511                 rect.left += 3*CLIENT_INSET;
512
513                 long newFont, oldFont = 0;
514                 newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
515                 if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
516
517                 OS.DrawText(hDC, buffer, buffer.length, rect, OS.DT_SINGLELINE | OS.DT_LEFT | OS.DT_TOP | OS.DT_CALCRECT);
518                 // The calculated rectangle is a little bit too small. Italic fonts would show some small part in the default color.
519                 rect.right += CLIENT_INSET;
520                 drawBackground(hDC, rect);
521                 OS.SetBkMode(hDC, OS.TRANSPARENT);
522                 OS.SetTextColor(hDC, getForegroundPixel());
523                 OS.DrawText(hDC, buffer, buffer.length, rect, OS.DT_SINGLELINE | OS.DT_LEFT | OS.DT_TOP);
524
525                 if (newFont != 0) OS.SelectObject (hDC, oldFont);
526                 OS.ReleaseDC(handle, hDC);
527                 // Without validating the drawn area it would be overdrawn by windows
528                 OS.ValidateRect(handle, rect);
529         }
530         return result;
531 }
532
533 @Override
534 LRESULT WM_PRINTCLIENT (long wParam, long lParam) {
535         LRESULT result = super.WM_PRINTCLIENT (wParam, lParam);
536         if (result != null) return result;
537         /*
538         * Feature in Windows.  In version 6.00 of COMCTL32.DLL,
539         * when WM_PRINTCLIENT is sent from a child BS_GROUP
540         * control to a parent BS_GROUP, the parent BS_GROUP
541         * clears the font from the HDC.  Normally, group boxes
542         * in Windows do not have children so this behavior is
543         * undefined.  When the parent of a BS_GROUP is not a
544         * BS_GROUP, there is no problem.  The fix is to save
545         * and restore the current font.
546         */
547         if (OS.IsAppThemed ()) {
548                 int nSavedDC = OS.SaveDC (wParam);
549                 long code = callWindowProc (handle, OS.WM_PRINTCLIENT, wParam, lParam);
550                 OS.RestoreDC (wParam, nSavedDC);
551                 return new LRESULT (code);
552         }
553         return result;
554 }
555
556 @Override
557 LRESULT WM_UPDATEUISTATE (long wParam, long lParam) {
558         LRESULT result = super.WM_UPDATEUISTATE (wParam, lParam);
559         if (result != null) return result;
560         /*
561         * Feature in Windows.  When WM_UPDATEUISTATE is sent to
562         * a group, it sends WM_CTLCOLORBTN to get the foreground
563         * and background.  If drawing happens in WM_CTLCOLORBTN,
564         * it will overwrite the contents of the control.  The
565         * fix is draw the group without drawing the background
566         * and avoid the group window proc.
567         */
568         boolean redraw = findImageControl () != null;
569         if (!redraw) {
570                 if ((state & THEME_BACKGROUND) != 0) {
571                         if (OS.IsAppThemed ()) {
572                                 redraw = findThemeControl () != null;
573                         }
574                 }
575                 if (!redraw) redraw = findBackgroundControl () != null;
576         }
577         if (redraw) {
578                 OS.InvalidateRect (handle, null, false);
579                 long code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam);
580                 return new LRESULT (code);
581         }
582         return result;
583 }
584
585 @Override
586 LRESULT WM_WINDOWPOSCHANGING (long wParam, long lParam) {
587         LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam);
588         if (result != null) return result;
589         /*
590         * Invalidate the portion of the group widget that needs to
591         * be redrawn.  Note that for some reason, invalidating the
592         * group from inside WM_SIZE causes pixel corruption for
593         * radio button children.
594         */
595         if (!OS.IsWindowVisible (handle)) return result;
596         WINDOWPOS lpwp = new WINDOWPOS ();
597         OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof);
598         if ((lpwp.flags & (OS.SWP_NOSIZE | OS.SWP_NOREDRAW)) != 0) {
599                 return result;
600         }
601         RECT rect = new RECT ();
602         OS.SetRect (rect, 0, 0, lpwp.cx, lpwp.cy);
603         OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, rect);
604         int newWidth = rect.right - rect.left;
605         int newHeight = rect.bottom - rect.top;
606         OS.GetClientRect (handle, rect);
607         int oldWidth = rect.right - rect.left;
608         int oldHeight = rect.bottom - rect.top;
609         if (newWidth == oldWidth && newHeight == oldHeight) {
610                 return result;
611         }
612         if (newWidth != oldWidth) {
613                 int left = oldWidth;
614                 if (newWidth < oldWidth) left = newWidth;
615                 OS.SetRect (rect, left - CLIENT_INSET, 0, newWidth, newHeight);
616                 OS.InvalidateRect (handle, rect, true);
617         }
618         if (newHeight != oldHeight) {
619                 int bottom = oldHeight;
620                 if (newHeight < oldHeight) bottom = newHeight;
621                 if (newWidth < oldWidth) oldWidth -= CLIENT_INSET;
622                 OS.SetRect (rect, 0, bottom - CLIENT_INSET, oldWidth, newHeight);
623                 OS.InvalidateRect (handle, rect, true);
624         }
625         return result;
626 }
627 }