1 11 package org.eclipse.swt.widgets; 12 13 14 import org.eclipse.swt.internal.win32.*; 15 import org.eclipse.swt.graphics.*; 16 import org.eclipse.swt.*; 17 import org.eclipse.swt.events.*; 18 import org.eclipse.swt.accessibility.*; 19 20 38 39 public abstract class Control extends Widget implements Drawable { 40 50 public int handle; 51 Composite parent; 52 Cursor cursor; 53 Menu menu; 54 String toolTipText; 55 Object layoutData; 56 Accessible accessible; 57 Image backgroundImage; 58 int drawCount, foreground, background; 59 60 63 Control () { 64 } 65 66 94 public Control (Composite parent, int style) { 95 super (parent, style); 96 this.parent = parent; 97 createWidget (); 98 } 99 100 119 public void addControlListener(ControlListener listener) { 120 checkWidget (); 121 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 122 TypedListener typedListener = new TypedListener (listener); 123 addListener (SWT.Resize,typedListener); 124 addListener (SWT.Move,typedListener); 125 } 126 127 148 public void addDragDetectListener (DragDetectListener listener) { 149 checkWidget (); 150 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 151 TypedListener typedListener = new TypedListener (listener); 152 addListener (SWT.DragDetect,typedListener); 153 } 154 155 174 public void addFocusListener (FocusListener listener) { 175 checkWidget (); 176 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 177 TypedListener typedListener = new TypedListener (listener); 178 addListener (SWT.FocusIn,typedListener); 179 addListener (SWT.FocusOut,typedListener); 180 } 181 182 201 public void addHelpListener (HelpListener listener) { 202 checkWidget (); 203 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 204 TypedListener typedListener = new TypedListener (listener); 205 addListener (SWT.Help, typedListener); 206 } 207 208 238 public void addKeyListener (KeyListener listener) { 239 checkWidget (); 240 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 241 TypedListener typedListener = new TypedListener (listener); 242 addListener (SWT.KeyUp,typedListener); 243 addListener (SWT.KeyDown,typedListener); 244 } 245 246 267 public void addMenuDetectListener (MenuDetectListener listener) { 268 checkWidget (); 269 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 270 TypedListener typedListener = new TypedListener (listener); 271 addListener (SWT.MenuDetect, typedListener); 272 } 273 274 293 public void addMouseListener (MouseListener listener) { 294 checkWidget (); 295 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 296 TypedListener typedListener = new TypedListener (listener); 297 addListener (SWT.MouseDown,typedListener); 298 addListener (SWT.MouseUp,typedListener); 299 addListener (SWT.MouseDoubleClick,typedListener); 300 } 301 302 321 public void addMouseTrackListener (MouseTrackListener listener) { 322 checkWidget (); 323 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 324 TypedListener typedListener = new TypedListener (listener); 325 addListener (SWT.MouseEnter,typedListener); 326 addListener (SWT.MouseExit,typedListener); 327 addListener (SWT.MouseHover,typedListener); 328 } 329 330 349 public void addMouseMoveListener (MouseMoveListener listener) { 350 checkWidget (); 351 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 352 TypedListener typedListener = new TypedListener (listener); 353 addListener (SWT.MouseMove,typedListener); 354 } 355 356 377 public void addMouseWheelListener (MouseWheelListener listener) { 378 checkWidget (); 379 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 380 TypedListener typedListener = new TypedListener (listener); 381 addListener (SWT.MouseWheel, typedListener); 382 } 383 384 403 public void addPaintListener (PaintListener listener) { 404 checkWidget (); 405 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 406 TypedListener typedListener = new TypedListener (listener); 407 addListener (SWT.Paint,typedListener); 408 } 409 410 429 public void addTraverseListener (TraverseListener listener) { 430 checkWidget (); 431 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 432 TypedListener typedListener = new TypedListener (listener); 433 addListener (SWT.Traverse,typedListener); 434 } 435 436 int borderHandle () { 437 return handle; 438 } 439 440 void checkBackground () { 441 Shell shell = getShell (); 442 if (this == shell) return; 443 state &= ~PARENT_BACKGROUND; 444 Composite composite = parent; 445 do { 446 int mode = composite.backgroundMode; 447 if (mode != 0) { 448 if (mode == SWT.INHERIT_DEFAULT) { 449 Control control = this; 450 do { 451 if ((control.state & THEME_BACKGROUND) == 0) { 452 return; 453 } 454 control = control.parent; 455 } while (control != composite); 456 } 457 state |= PARENT_BACKGROUND; 458 return; 459 } 460 if (composite == shell) break; 461 composite = composite.parent; 462 } while (true); 463 } 464 465 void checkBorder () { 466 if (getBorderWidth () == 0) style &= ~SWT.BORDER; 467 } 468 469 void checkBuffered () { 470 style &= ~SWT.DOUBLE_BUFFERED; 471 } 472 473 boolean checkHandle (int hwnd) { 474 return hwnd == handle; 475 } 476 477 void checkMirrored () { 478 if ((style & SWT.RIGHT_TO_LEFT) != 0) { 479 int bits = OS.GetWindowLong (handle, OS.GWL_EXSTYLE); 480 if ((bits & OS.WS_EX_LAYOUTRTL) != 0) style |= SWT.MIRRORED; 481 } 482 } 483 484 511 public Point computeSize (int wHint, int hHint) { 512 return computeSize (wHint, hHint, true); 513 } 514 515 549 public Point computeSize (int wHint, int hHint, boolean changed) { 550 checkWidget (); 551 int width = DEFAULT_WIDTH; 552 int height = DEFAULT_HEIGHT; 553 if (wHint != SWT.DEFAULT) width = wHint; 554 if (hHint != SWT.DEFAULT) height = hHint; 555 int border = getBorderWidth (); 556 width += border * 2; 557 height += border * 2; 558 return new Point (width, height); 559 } 560 561 Control computeTabGroup () { 562 if (isTabGroup ()) return this; 563 return parent.computeTabGroup (); 564 } 565 566 Control computeTabRoot () { 567 Control [] tabList = parent._getTabList (); 568 if (tabList != null) { 569 int index = 0; 570 while (index < tabList.length) { 571 if (tabList [index] == this) break; 572 index++; 573 } 574 if (index == tabList.length) { 575 if (isTabGroup ()) return this; 576 } 577 } 578 return parent.computeTabRoot (); 579 } 580 581 Control [] computeTabList () { 582 if (isTabGroup ()) { 583 if (getVisible () && getEnabled ()) { 584 return new Control [] {this}; 585 } 586 } 587 return new Control [0]; 588 } 589 590 void createHandle () { 591 int hwndParent = widgetParent (); 592 handle = OS.CreateWindowEx ( 593 widgetExtStyle (), 594 windowClass (), 595 null, 596 widgetStyle (), 597 OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0, 598 hwndParent, 599 0, 600 OS.GetModuleHandle (null), 601 widgetCreateStruct ()); 602 if (handle == 0) error (SWT.ERROR_NO_HANDLES); 603 int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); 604 if ((bits & OS.WS_CHILD) != 0) { 605 OS.SetWindowLong (handle, OS.GWL_ID, handle); 606 } 607 if (OS.IsDBLocale && hwndParent != 0) { 608 int hIMC = OS.ImmGetContext (hwndParent); 609 OS.ImmAssociateContext (handle, hIMC); 610 OS.ImmReleaseContext (hwndParent, hIMC); 611 } 612 } 613 614 void createWidget () { 615 state |= DRAG_DETECT; 616 foreground = background = -1; 617 checkOrientation (parent); 618 createHandle (); 619 checkBackground (); 620 checkBuffered (); 621 register (); 622 subclass (); 623 setDefaultFont (); 624 checkMirrored (); 625 checkBorder (); 626 if ((state & PARENT_BACKGROUND) != 0) { 627 setBackground (); 628 } 629 } 630 631 int defaultBackground () { 632 if (OS.IsWinCE) return OS.GetSysColor (OS.COLOR_WINDOW); 633 return OS.GetSysColor (OS.COLOR_BTNFACE); 634 } 635 636 int defaultFont () { 637 return display.getSystemFont ().handle; 638 } 639 640 int defaultForeground () { 641 return OS.GetSysColor (OS.COLOR_WINDOWTEXT); 642 } 643 644 void deregister () { 645 display.removeControl (handle); 646 } 647 648 void destroyWidget () { 649 int hwnd = topHandle (); 650 releaseHandle (); 651 if (hwnd != 0) { 652 OS.DestroyWindow (hwnd); 653 } 654 } 655 656 692 public boolean dragDetect (Event event) { 693 checkWidget (); 694 if (event == null) error (SWT.ERROR_NULL_ARGUMENT); 695 return dragDetect (event.button, event.count, event.stateMask, event.x, event.y); 696 } 697 698 734 public boolean dragDetect (MouseEvent event) { 735 checkWidget (); 736 if (event == null) error (SWT.ERROR_NULL_ARGUMENT); 737 return dragDetect (event.button, event.count, event.stateMask, event.x, event.y); 738 } 739 740 boolean dragDetect (int button, int count, int stateMask, int x, int y) { 741 if (button != 1 || count != 1) return false; 742 boolean dragging = dragDetect (handle, x, y, false, null, null); 743 if (OS.GetKeyState (OS.VK_LBUTTON) < 0) { 744 if (OS.GetCapture () != handle) OS.SetCapture (handle); 745 } 746 if (!dragging) { 747 767 if (button == 1 && OS.GetKeyState (OS.VK_ESCAPE) >= 0) { 768 int wParam = 0; 769 if ((stateMask & SWT.CTRL) != 0) wParam |= OS.MK_CONTROL; 770 if ((stateMask & SWT.SHIFT) != 0) wParam |= OS.MK_SHIFT; 771 if ((stateMask & SWT.ALT) != 0) wParam |= OS.MK_ALT; 772 if ((stateMask & SWT.BUTTON1) != 0) wParam |= OS.MK_LBUTTON; 773 if ((stateMask & SWT.BUTTON2) != 0) wParam |= OS.MK_MBUTTON; 774 if ((stateMask & SWT.BUTTON3) != 0) wParam |= OS.MK_RBUTTON; 775 if ((stateMask & SWT.BUTTON4) != 0) wParam |= OS.MK_XBUTTON1; 776 if ((stateMask & SWT.BUTTON5) != 0) wParam |= OS.MK_XBUTTON2; 777 int lParam = (x & 0xFFFF) | ((y << 16) & 0xFFFF0000); 778 OS.SendMessage (handle, OS.WM_LBUTTONUP, wParam, lParam); 779 } 780 return false; 781 } 782 return sendDragEvent (button, stateMask, x, y); 783 } 784 785 void drawBackground (int hDC) { 786 RECT rect = new RECT (); 787 OS.GetClientRect (handle, rect); 788 drawBackground (hDC, rect); 789 } 790 791 void drawBackground (int hDC, RECT rect) { 792 drawBackground (hDC, rect, -1); 793 } 794 795 void drawBackground (int hDC, RECT rect, int pixel) { 796 Control control = findBackgroundControl (); 797 if (control != null) { 798 if (control.backgroundImage != null) { 799 fillImageBackground (hDC, control, rect); 800 return; 801 } 802 pixel = control.getBackgroundPixel (); 803 } 804 if (pixel == -1) { 805 if ((state & THEME_BACKGROUND) != 0) { 806 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { 807 control = findThemeControl (); 808 if (control != null) { 809 fillThemeBackground (hDC, control, rect); 810 return; 811 } 812 } 813 } 814 } 815 if (pixel == -1) pixel = getBackgroundPixel (); 816 fillBackground (hDC, pixel, rect); 817 } 818 819 void drawImageBackground (int hDC, int hwnd, int hBitmap, RECT rect) { 820 RECT rect2 = new RECT (); 821 OS.GetClientRect (hwnd, rect2); 822 OS.MapWindowPoints (hwnd, handle, rect2, 2); 823 int hBrush = findBrush (hBitmap, OS.BS_PATTERN); 824 POINT lpPoint = new POINT (); 825 OS.GetWindowOrgEx (hDC, lpPoint); 826 OS.SetBrushOrgEx (hDC, -rect2.left - lpPoint.x, -rect2.top - lpPoint.y, lpPoint); 827 int hOldBrush = OS.SelectObject (hDC, hBrush); 828 OS.PatBlt (hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY); 829 OS.SetBrushOrgEx (hDC, lpPoint.x, lpPoint.y, null); 830 OS.SelectObject (hDC, hOldBrush); 831 } 832 833 void drawThemeBackground (int hDC, int hwnd, RECT rect) { 834 835 } 836 837 void enableDrag (boolean enabled) { 838 839 } 840 841 void enableWidget (boolean enabled) { 842 OS.EnableWindow (handle, enabled); 843 } 844 845 void fillBackground (int hDC, int pixel, RECT rect) { 846 if (rect.left > rect.right || rect.top > rect.bottom) return; 847 int hPalette = display.hPalette; 848 if (hPalette != 0) { 849 OS.SelectPalette (hDC, hPalette, false); 850 OS.RealizePalette (hDC); 851 } 852 OS.FillRect (hDC, rect, findBrush (pixel, OS.BS_SOLID)); 853 } 854 855 void fillImageBackground (int hDC, Control control, RECT rect) { 856 if (rect.left > rect.right || rect.top > rect.bottom) return; 857 if (control != null) { 858 Image image = control.backgroundImage; 859 if (image != null) { 860 control.drawImageBackground (hDC, handle, image.handle, rect); 861 } 862 } 863 } 864 865 void fillThemeBackground (int hDC, Control control, RECT rect) { 866 if (rect.left > rect.right || rect.top > rect.bottom) return; 867 if (control != null) { 868 control.drawThemeBackground (hDC, handle, rect); 869 } 870 } 871 872 Control findBackgroundControl () { 873 if (background != -1 || backgroundImage != null) return this; 874 return (state & PARENT_BACKGROUND) != 0 ? parent.findBackgroundControl () : null; 875 } 876 877 int findBrush (int value, int lbStyle) { 878 return parent.findBrush (value, lbStyle); 879 } 880 881 Cursor findCursor () { 882 if (cursor != null) return cursor; 883 return parent.findCursor (); 884 } 885 886 Control findImageControl () { 887 Control control = findBackgroundControl (); 888 return control != null && control.backgroundImage != null ? control : null; 889 } 890 891 Control findThemeControl () { 892 return background == -1 && backgroundImage == null ? parent.findThemeControl () : null; 893 } 894 895 Menu [] findMenus (Control control) { 896 if (menu != null && this != control) return new Menu [] {menu}; 897 return new Menu [0]; 898 } 899 900 char findMnemonic (String string) { 901 int index = 0; 902 int length = string.length (); 903 do { 904 while (index < length && string.charAt (index) != '&') index++; 905 if (++index >= length) return '\0'; 906 if (string.charAt (index) != '&') return string.charAt (index); 907 index++; 908 } while (index < length); 909 return '\0'; 910 } 911 912 void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) { 913 oldShell.fixShell (newShell, this); 914 oldDecorations.fixDecorations (newDecorations, this, menus); 915 } 916 917 void fixFocus (Control focusControl) { 918 Shell shell = getShell (); 919 Control control = this; 920 while (control != shell && (control = control.parent) != null) { 921 if (control.setFixedFocus ()) return; 922 } 923 shell.setSavedFocus (focusControl); 924 OS.SetFocus (0); 925 } 926 927 940 public boolean forceFocus () { 941 checkWidget (); 942 if (display.focusEvent == SWT.FocusOut) return false; 943 Decorations shell = menuShell (); 944 shell.setSavedFocus (this); 945 if (!isEnabled () || !isVisible () || !isActive ()) return false; 946 if (isFocusControl ()) return true; 947 shell.setSavedFocus (null); 948 962 OS.SetFocus (handle); 964 if (isDisposed ()) return false; 965 shell.setSavedFocus (this); 966 return isFocusControl (); 967 } 968 969 void forceResize () { 970 if (parent == null) return; 971 WINDOWPOS [] lpwp = parent.lpwp; 972 if (lpwp == null) return; 973 for (int i=0; i<lpwp.length; i++) { 974 WINDOWPOS wp = lpwp [i]; 975 if (wp != null && wp.hwnd == handle) { 976 981 SetWindowPos (wp.hwnd, 0, wp.x, wp.y, wp.cx, wp.cy, wp.flags); 987 lpwp [i] = null; 988 return; 989 } 990 } 991 } 992 993 1010public Accessible getAccessible () { 1011 checkWidget (); 1012 if (accessible == null) accessible = new_Accessible (this); 1013 return accessible; 1014} 1015 1016 1026public Color getBackground () { 1027 checkWidget (); 1028 Control control = findBackgroundControl (); 1029 if (control == null) control = this; 1030 return Color.win32_new (display, control.getBackgroundPixel ()); 1031} 1032 1033 1045public Image getBackgroundImage () { 1046 checkWidget (); 1047 Control control = findBackgroundControl (); 1048 if (control == null) control = this; 1049 return control.backgroundImage; 1050} 1051 1052int getBackgroundPixel () { 1053 return background != -1 ? background : defaultBackground (); 1054} 1055 1056 1066public int getBorderWidth () { 1067 checkWidget (); 1068 int borderHandle = borderHandle (); 1069 int bits1 = OS.GetWindowLong (borderHandle, OS.GWL_EXSTYLE); 1070 if ((bits1 & OS.WS_EX_CLIENTEDGE) != 0) return OS.GetSystemMetrics (OS.SM_CXEDGE); 1071 if ((bits1 & OS.WS_EX_STATICEDGE) != 0) return OS.GetSystemMetrics (OS.SM_CXBORDER); 1072 int bits2 = OS.GetWindowLong (borderHandle, OS.GWL_STYLE); 1073 if ((bits2 & OS.WS_BORDER) != 0) return OS.GetSystemMetrics (OS.SM_CXBORDER); 1074 return 0; 1075} 1076 1077 1090public Rectangle getBounds () { 1091 checkWidget (); 1092 forceResize (); 1093 RECT rect = new RECT (); 1094 OS.GetWindowRect (topHandle (), rect); 1095 int hwndParent = parent == null ? 0 : parent.handle; 1096 OS.MapWindowPoints (0, hwndParent, rect, 2); 1097 int width = rect.right - rect.left; 1098 int height = rect.bottom - rect.top; 1099 return new Rectangle (rect.left, rect.top, width, height); 1100} 1101 1102int getCodePage () { 1103 if (OS.IsUnicode) return OS.CP_ACP; 1104 int hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 1105 LOGFONT logFont = OS.IsUnicode ? (LOGFONT) new LOGFONTW () : new LOGFONTA (); 1106 OS.GetObject (hFont, LOGFONT.sizeof, logFont); 1107 int cs = logFont.lfCharSet & 0xFF; 1108 int [] lpCs = new int [8]; 1109 if (OS.TranslateCharsetInfo (cs, lpCs, OS.TCI_SRCCHARSET)) { 1110 return lpCs [1]; 1111 } 1112 return OS.GetACP (); 1113} 1114 1115String getClipboardText () { 1116 String string = ""; 1117 if (OS.OpenClipboard (0)) { 1118 int hMem = OS.GetClipboardData (OS.IsUnicode ? OS.CF_UNICODETEXT : OS.CF_TEXT); 1119 if (hMem != 0) { 1120 1121 int byteCount = OS.GlobalSize (hMem) / TCHAR.sizeof * TCHAR.sizeof; 1122 int ptr = OS.GlobalLock (hMem); 1123 if (ptr != 0) { 1124 1125 TCHAR buffer = new TCHAR (0, byteCount / TCHAR.sizeof); 1126 OS.MoveMemory (buffer, ptr, byteCount); 1127 string = buffer.toString (0, buffer.strlen ()); 1128 OS.GlobalUnlock (hMem); 1129 } 1130 } 1131 OS.CloseClipboard (); 1132 } 1133 return string; 1134} 1135 1136 1150public Cursor getCursor () { 1151 checkWidget (); 1152 return cursor; 1153} 1154 1155 1168public boolean getDragDetect () { 1169 checkWidget (); 1170 return (state & DRAG_DETECT) != 0; 1171} 1172 1173 1188public boolean getEnabled () { 1189 checkWidget (); 1190 return OS.IsWindowEnabled (handle); 1191} 1192 1193 1203public Font getFont () { 1204 checkWidget (); 1205 int hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 1206 if (hFont == 0) hFont = defaultFont (); 1207 return Font.win32_new (display, hFont); 1208} 1209 1210 1220public Color getForeground () { 1221 checkWidget (); 1222 return Color.win32_new (display, getForegroundPixel ()); 1223} 1224 1225int getForegroundPixel () { 1226 return foreground != -1 ? foreground : defaultForeground (); 1227} 1228 1229 1239public Object getLayoutData () { 1240 checkWidget (); 1241 return layoutData; 1242} 1243 1244 1257public Point getLocation () { 1258 checkWidget (); 1259 forceResize (); 1260 RECT rect = new RECT (); 1261 OS.GetWindowRect (topHandle (), rect); 1262 int hwndParent = parent == null ? 0 : parent.handle; 1263 OS.MapWindowPoints (0, hwndParent, rect, 2); 1264 return new Point (rect.left, rect.top); 1265} 1266 1267 1282public Menu getMenu () { 1283 checkWidget (); 1284 return menu; 1285} 1286 1287 1294public Monitor getMonitor () { 1295 checkWidget (); 1296 if (OS.IsWinCE || OS.WIN32_VERSION < OS.VERSION (4, 10)) { 1297 return display.getPrimaryMonitor (); 1298 } 1299 int hmonitor = OS.MonitorFromWindow (handle, OS.MONITOR_DEFAULTTONEAREST); 1300 MONITORINFO lpmi = new MONITORINFO (); 1301 lpmi.cbSize = MONITORINFO.sizeof; 1302 OS.GetMonitorInfo (hmonitor, lpmi); 1303 Monitor monitor = new Monitor (); 1304 monitor.handle = hmonitor; 1305 monitor.x = lpmi.rcMonitor_left; 1306 monitor.y = lpmi.rcMonitor_top; 1307 monitor.width = lpmi.rcMonitor_right - lpmi.rcMonitor_left; 1308 monitor.height = lpmi.rcMonitor_bottom - lpmi.rcMonitor_top; 1309 monitor.clientX = lpmi.rcWork_left; 1310 monitor.clientY = lpmi.rcWork_top; 1311 monitor.clientWidth = lpmi.rcWork_right - lpmi.rcWork_left; 1312 monitor.clientHeight = lpmi.rcWork_bottom - lpmi.rcWork_top; 1313 return monitor; 1314} 1315 1316 1328public Composite getParent () { 1329 checkWidget (); 1330 return parent; 1331} 1332 1333Control [] getPath () { 1334 int count = 0; 1335 Shell shell = getShell (); 1336 Control control = this; 1337 while (control != shell) { 1338 count++; 1339 control = control.parent; 1340 } 1341 control = this; 1342 Control [] result = new Control [count]; 1343 while (control != shell) { 1344 result [--count] = control; 1345 control = control.parent; 1346 } 1347 return result; 1348} 1349 1350 1365public Shell getShell () { 1366 checkWidget (); 1367 return parent.getShell (); 1368} 1369 1370 1383public Point getSize () { 1384 checkWidget (); 1385 forceResize (); 1386 RECT rect = new RECT (); 1387 OS.GetWindowRect (topHandle (), rect); 1388 int width = rect.right - rect.left; 1389 int height = rect.bottom - rect.top; 1390 return new Point (width, height); 1391} 1392 1393 1404public String getToolTipText () { 1405 checkWidget (); 1406 return toolTipText; 1407} 1408 1409 1426public boolean getVisible () { 1427 checkWidget (); 1428 if (drawCount != 0) return (state & HIDDEN) == 0; 1429 int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); 1430 return (bits & OS.WS_VISIBLE) != 0; 1431} 1432 1433boolean hasCursor () { 1434 RECT rect = new RECT (); 1435 if (!OS.GetClientRect (handle, rect)) return false; 1436 OS.MapWindowPoints (handle, 0, rect, 2); 1437 POINT pt = new POINT (); 1438 return OS.GetCursorPos (pt) && OS.PtInRect (rect, pt); 1439} 1440 1441boolean hasFocus () { 1442 1447 int hwndFocus = OS.GetFocus (); 1448 while (hwndFocus != 0) { 1449 if (hwndFocus == handle) return true; 1450 if (display.getControl (hwndFocus) != null) { 1451 return false; 1452 } 1453 hwndFocus = OS.GetParent (hwndFocus); 1454 } 1455 return false; 1456} 1457 1458 1471public int internal_new_GC (GCData data) { 1472 checkWidget(); 1473 int hwnd = handle; 1474 if (data != null && data.hwnd != 0) hwnd = data.hwnd; 1475 if (data != null) data.hwnd = hwnd; 1476 int hDC = 0; 1477 if (data == null || data.ps == null) { 1478 hDC = OS.GetDC (hwnd); 1479 } else { 1480 hDC = OS.BeginPaint (hwnd, data.ps); 1481 } 1482 if (hDC == 0) SWT.error(SWT.ERROR_NO_HANDLES); 1483 if (data != null) { 1484 if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (4, 10)) { 1485 int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; 1486 if ((data.style & mask) != 0) { 1487 data.layout = (data.style & SWT.RIGHT_TO_LEFT) != 0 ? OS.LAYOUT_RTL : 0; 1488 } else { 1489 int flags = OS.GetLayout (hDC); 1490 if ((flags & OS.LAYOUT_RTL) != 0) { 1491 data.style |= SWT.RIGHT_TO_LEFT | SWT.MIRRORED; 1492 } else { 1493 data.style |= SWT.LEFT_TO_RIGHT; 1494 } 1495 } 1496 } else { 1497 data.style |= SWT.LEFT_TO_RIGHT; 1498 } 1499 data.device = display; 1500 int foreground = getForegroundPixel (); 1501 if (foreground != OS.GetTextColor (hDC)) data.foreground = foreground; 1502 Control control = findBackgroundControl (); 1503 if (control == null) control = this; 1504 int background = control.getBackgroundPixel (); 1505 if (background != OS.GetBkColor (hDC)) data.background = background; 1506 data.hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0); 1507 data.uiState = OS.SendMessage (hwnd, OS.WM_QUERYUISTATE, 0, 0); 1508 } 1509 return hDC; 1510} 1511 1512 1525public void internal_dispose_GC (int hDC, GCData data) { 1526 checkWidget (); 1527 int hwnd = handle; 1528 if (data != null && data.hwnd != 0) { 1529 hwnd = data.hwnd; 1530 } 1531 if (data == null || data.ps == null) { 1532 OS.ReleaseDC (hwnd, hDC); 1533 } else { 1534 OS.EndPaint (hwnd, data.ps); 1535 } 1536} 1537 1538boolean isActive () { 1539 Shell dialogShell = display.getModalDialogShell (); 1540 if (dialogShell != null && dialogShell != getShell ()) { 1541 return false; 1542 } 1543 Shell shell = null; 1544 Shell [] modalShells = display.modalShells; 1545 if (modalShells != null) { 1546 int bits = SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL; 1547 int index = modalShells.length; 1548 while (--index >= 0) { 1549 Shell modal = modalShells [index]; 1550 if (modal != null) { 1551 if ((modal.style & bits) != 0) { 1552 Control control = this; 1553 while (control != null) { 1554 if (control == modal) break; 1555 control = control.parent; 1556 } 1557 if (control != modal) return false; 1558 break; 1559 } 1560 if ((modal.style & SWT.PRIMARY_MODAL) != 0) { 1561 if (shell == null) shell = getShell (); 1562 if (modal.parent == shell) return false; 1563 } 1564 } 1565 } 1566 } 1567 if (shell == null) shell = getShell (); 1568 return shell.getEnabled (); 1569} 1570 1571 1587public boolean isEnabled () { 1588 checkWidget (); 1589 return getEnabled () && parent.isEnabled (); 1590} 1591 1592 1603public boolean isFocusControl () { 1604 checkWidget (); 1605 Control focusControl = display.focusControl; 1606 if (focusControl != null && !focusControl.isDisposed ()) { 1607 return this == focusControl; 1608 } 1609 return hasFocus (); 1610} 1611 1612boolean isFocusAncestor (Control control) { 1613 while (control != null && control != this && !(control instanceof Shell)) { 1614 control = control.parent; 1615 } 1616 return control == this; 1617} 1618 1619 1630public boolean isReparentable () { 1631 checkWidget (); 1632 return true; 1633} 1634 1635boolean isShowing () { 1636 1640 if (!isVisible ()) return false; 1641 Control control = this; 1642 while (control != null) { 1643 Point size = control.getSize (); 1644 if (size.x == 0 || size.y == 0) { 1645 return false; 1646 } 1647 control = control.parent; 1648 } 1649 return true; 1650 1653} 1660 1661boolean isTabGroup () { 1662 Control [] tabList = parent._getTabList (); 1663 if (tabList != null) { 1664 for (int i=0; i<tabList.length; i++) { 1665 if (tabList [i] == this) return true; 1666 } 1667 } 1668 int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); 1669 return (bits & OS.WS_TABSTOP) != 0; 1670} 1671 1672boolean isTabItem () { 1673 Control [] tabList = parent._getTabList (); 1674 if (tabList != null) { 1675 for (int i=0; i<tabList.length; i++) { 1676 if (tabList [i] == this) return false; 1677 } 1678 } 1679 int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); 1680 if ((bits & OS.WS_TABSTOP) != 0) return false; 1681 int code = OS.SendMessage (handle, OS.WM_GETDLGCODE, 0, 0); 1682 if ((code & OS.DLGC_STATIC) != 0) return false; 1683 if ((code & OS.DLGC_WANTALLKEYS) != 0) return false; 1684 if ((code & OS.DLGC_WANTARROWS) != 0) return false; 1685 if ((code & OS.DLGC_WANTTAB) != 0) return false; 1686 return true; 1687} 1688 1689 1703public boolean isVisible () { 1704 checkWidget (); 1705 if (OS.IsWindowVisible (handle)) return true; 1706 return getVisible () && parent.isVisible (); 1707} 1708 1709void mapEvent (int hwnd, Event event) { 1710 if (hwnd != handle) { 1711 POINT point = new POINT (); 1712 point.x = event.x; 1713 point.y = event.y; 1714 OS.MapWindowPoints (hwnd, handle, point, 1); 1715 event.x = point.x; 1716 event.y = point.y; 1717 } 1718} 1719 1720void markLayout (boolean changed, boolean all) { 1721 1722} 1723 1724Decorations menuShell () { 1725 return parent.menuShell (); 1726} 1727 1728boolean mnemonicHit (char key) { 1729 return false; 1730} 1731 1732boolean mnemonicMatch (char key) { 1733 return false; 1734} 1735 1736 1756public void moveAbove (Control control) { 1757 checkWidget (); 1758 int topHandle = topHandle (), hwndAbove = OS.HWND_TOP; 1759 if (control != null) { 1760 if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT); 1761 if (parent != control.parent) return; 1762 int hwnd = control.topHandle (); 1763 if (hwnd == 0 || hwnd == topHandle) return; 1764 hwndAbove = OS.GetWindow (hwnd, OS.GW_HWNDPREV); 1765 1772 if (hwndAbove == 0 || hwndAbove == hwnd) { 1773 hwndAbove = OS.HWND_TOP; 1774 } 1775 } 1776 int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE; 1777 SetWindowPos (topHandle, hwndAbove, 0, 0, 0, 0, flags); 1778} 1779 1780 1800public void moveBelow (Control control) { 1801 checkWidget (); 1802 int topHandle = topHandle (), hwndAbove = OS.HWND_BOTTOM; 1803 if (control != null) { 1804 if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT); 1805 if (parent != control.parent) return; 1806 hwndAbove = control.topHandle (); 1807 } else { 1808 1816 Shell shell = getShell (); 1817 if (this == shell && parent != null) { 1818 1826 int hwndParent = parent.handle, hwnd = hwndParent; 1827 hwndAbove = OS.GetWindow (hwnd, OS.GW_HWNDPREV); 1828 while (hwndAbove != 0 && hwndAbove != hwnd) { 1829 if (OS.GetWindow (hwndAbove, OS.GW_OWNER) == hwndParent) break; 1830 hwndAbove = OS.GetWindow (hwnd = hwndAbove, OS.GW_HWNDPREV); 1831 } 1832 if (hwndAbove == hwnd) return; 1833 } 1834 } 1835 if (hwndAbove == 0 || hwndAbove == topHandle) return; 1836 int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE; 1837 SetWindowPos (topHandle, hwndAbove, 0, 0, 0, 0, flags); 1838} 1839 1840Accessible new_Accessible (Control control) { 1841 return Accessible.internal_new_Accessible (this); 1842} 1843 1844GC new_GC (GCData data) { 1845 return GC.win32_new (this, data); 1846} 1847 1848 1860public void pack () { 1861 checkWidget (); 1862 pack (true); 1863} 1864 1865 1886public void pack (boolean changed) { 1887 checkWidget (); 1888 setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed)); 1889} 1890 1891 1910public void redraw () { 1911 checkWidget (); 1912 redraw (false); 1913} 1914 1915void redraw (boolean all) { 1916 if (!OS.IsWindowVisible (handle)) return; 1918 if (OS.IsWinCE) { 1919 OS.InvalidateRect (handle, null, true); 1920 } else { 1921 int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE; 1922 if (all) flags |= OS.RDW_ALLCHILDREN; 1923 OS.RedrawWindow (handle, null, 0, flags); 1924 } 1925} 1926 1956public void redraw (int x, int y, int width, int height, boolean all) { 1957 checkWidget (); 1958 if (width <= 0 || height <= 0) return; 1959 if (!OS.IsWindowVisible (handle)) return; 1960 RECT rect = new RECT (); 1961 OS.SetRect (rect, x, y, x + width, y + height); 1962 if (OS.IsWinCE) { 1963 OS.InvalidateRect (handle, rect, true); 1964 } else { 1965 int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE; 1966 if (all) flags |= OS.RDW_ALLCHILDREN; 1967 OS.RedrawWindow (handle, rect, 0, flags); 1968 } 1969} 1970 1971boolean redrawChildren () { 1972 if (!OS.IsWindowVisible (handle)) return false; 1973 Control control = findBackgroundControl (); 1974 if (control == null) { 1975 if ((state & THEME_BACKGROUND) != 0) { 1976 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { 1977 OS.InvalidateRect (handle, null, true); 1978 return true; 1979 } 1980 } 1981 } else { 1982 if (control.backgroundImage != null) { 1983 OS.InvalidateRect (handle, null, true); 1984 return true; 1985 } 1986 } 1987 return false; 1988} 1989 1990void register () { 1991 display.addControl (handle, this); 1992} 1993 1994void releaseHandle () { 1995 super.releaseHandle (); 1996 handle = 0; 1997 parent = null; 1998} 1999 2000void releaseParent () { 2001 parent.removeControl (this); 2002} 2003 2004void releaseWidget () { 2005 super.releaseWidget (); 2006 if (OS.IsDBLocale) { 2007 OS.ImmAssociateContext (handle, 0); 2008 } 2009 if (toolTipText != null) { 2010 setToolTipText (getShell (), null); 2011 } 2012 toolTipText = null; 2013 if (menu != null && !menu.isDisposed ()) { 2014 menu.dispose (); 2015 } 2016 backgroundImage = null; 2017 menu = null; 2018 cursor = null; 2019 unsubclass (); 2020 deregister (); 2021 layoutData = null; 2022 if (accessible != null) { 2023 accessible.internal_dispose_Accessible (); 2024 } 2025 accessible = null; 2026} 2027 2028 2045public void removeControlListener (ControlListener listener) { 2046 checkWidget (); 2047 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 2048 if (eventTable == null) return; 2049 eventTable.unhook (SWT.Move, listener); 2050 eventTable.unhook (SWT.Resize, listener); 2051} 2052 2053 2072public void removeDragDetectListener(DragDetectListener listener) { 2073 checkWidget (); 2074 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 2075 if (eventTable == null) return; 2076 eventTable.unhook (SWT.DragDetect, listener); 2077} 2078 2079 2096public void removeFocusListener(FocusListener listener) { 2097 checkWidget (); 2098 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 2099 if (eventTable == null) return; 2100 eventTable.unhook (SWT.FocusIn, listener); 2101 eventTable.unhook (SWT.FocusOut, listener); 2102} 2103 2104 2121public void removeHelpListener (HelpListener listener) { 2122 checkWidget (); 2123 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 2124 if (eventTable == null) return; 2125 eventTable.unhook (SWT.Help, listener); 2126} 2127 2128 2145public void removeKeyListener(KeyListener listener) { 2146 checkWidget (); 2147 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 2148 if (eventTable == null) return; 2149 eventTable.unhook (SWT.KeyUp, listener); 2150 eventTable.unhook (SWT.KeyDown, listener); 2151} 2152 2153 2173public void removeMenuDetectListener (MenuDetectListener listener) { 2174 checkWidget (); 2175 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 2176 if (eventTable == null) return; 2177 eventTable.unhook (SWT.MenuDetect, listener); 2178} 2179 2180 2197public void removeMouseTrackListener(MouseTrackListener listener) { 2198 checkWidget (); 2199 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 2200 if (eventTable == null) return; 2201 eventTable.unhook (SWT.MouseEnter, listener); 2202 eventTable.unhook (SWT.MouseExit, listener); 2203 eventTable.unhook (SWT.MouseHover, listener); 2204} 2205 2206 2223public void removeMouseListener (MouseListener listener) { 2224 checkWidget (); 2225 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 2226 if (eventTable == null) return; 2227 eventTable.unhook (SWT.MouseDown, listener); 2228 eventTable.unhook (SWT.MouseUp, listener); 2229 eventTable.unhook (SWT.MouseDoubleClick, listener); 2230} 2231 2232 2249public void removeMouseMoveListener(MouseMoveListener listener) { 2250 checkWidget (); 2251 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 2252 if (eventTable == null) return; 2253 eventTable.unhook (SWT.MouseMove, listener); 2254} 2255 2256 2275public void removeMouseWheelListener (MouseWheelListener listener) { 2276 checkWidget (); 2277 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 2278 if (eventTable == null) return; 2279 eventTable.unhook (SWT.MouseWheel, listener); 2280} 2281 2282 2299public void removePaintListener(PaintListener listener) { 2300 checkWidget (); 2301 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 2302 if (eventTable == null) return; 2303 eventTable.unhook(SWT.Paint, listener); 2304} 2305 2306 2323public void removeTraverseListener(TraverseListener listener) { 2324 checkWidget (); 2325 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 2326 if (eventTable == null) return; 2327 eventTable.unhook (SWT.Traverse, listener); 2328} 2329 2330void showWidget (boolean visible) { 2331 int topHandle = topHandle (); 2332 OS.ShowWindow (topHandle, visible ? OS.SW_SHOW : OS.SW_HIDE); 2333 if (handle != topHandle) OS.ShowWindow (handle, visible ? OS.SW_SHOW : OS.SW_HIDE); 2334} 2335 2336boolean sendFocusEvent (int type) { 2337 Shell shell = getShell (); 2338 2339 2349 Display display = this.display; 2350 display.focusEvent = type; 2351 display.focusControl = this; 2352 sendEvent (type); 2353 display.focusEvent = SWT.None; 2355 display.focusControl = null; 2356 2357 2363 if (!shell.isDisposed ()) { 2364 switch (type) { 2365 case SWT.FocusIn: 2366 shell.setActiveControl (this); 2367 break; 2368 case SWT.FocusOut: 2369 if (shell != display.getActiveShell ()) { 2370 shell.setActiveControl (null); 2371 } 2372 break; 2373 } 2374 } 2375 return true; 2376} 2377 2378void setBackground () { 2379 Control control = findBackgroundControl (); 2380 if (control == null) control = this; 2381 if (control.backgroundImage != null) { 2382 Shell shell = getShell (); 2383 shell.releaseBrushes (); 2384 setBackgroundImage (control.backgroundImage.handle); 2385 } else { 2386 setBackgroundPixel (control.background == -1 ? control.defaultBackground() : control.background); 2387 } 2388} 2389 2390 2408public void setBackground (Color color) { 2409 checkWidget (); 2410 int pixel = -1; 2411 if (color != null) { 2412 if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); 2413 pixel = color.handle; 2414 } 2415 if (pixel == background) return; 2416 background = pixel; 2417 updateBackgroundColor (); 2418} 2419 2420 2442public void setBackgroundImage (Image image) { 2443 checkWidget (); 2444 if (image != null) { 2445 if (image.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); 2446 if (image.type != SWT.BITMAP) error (SWT.ERROR_INVALID_ARGUMENT); 2447 } 2448 if (backgroundImage == image) return; 2449 backgroundImage = image; 2450 Shell shell = getShell (); 2451 shell.releaseBrushes (); 2452 updateBackgroundImage (); 2453} 2454 2455void setBackgroundImage (int hBitmap) { 2456 if (OS.IsWinCE) { 2457 OS.InvalidateRect (handle, null, true); 2458 } else { 2459 int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE; 2460 OS.RedrawWindow (handle, null, 0, flags); 2461 } 2462} 2463 2464void setBackgroundPixel (int pixel) { 2465 if (OS.IsWinCE) { 2466 OS.InvalidateRect (handle, null, true); 2467 } else { 2468 int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE; 2469 OS.RedrawWindow (handle, null, 0, flags); 2470 } 2471} 2472 2473 2496public void setBounds (int x, int y, int width, int height) { 2497 checkWidget (); 2498 int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE; 2499 setBounds (x, y, Math.max (0, width), Math.max (0, height), flags); 2500} 2501 2502void setBounds (int x, int y, int width, int height, int flags) { 2503 setBounds (x, y, width, height, flags, true); 2504} 2505 2506void setBounds (int x, int y, int width, int height, int flags, boolean defer) { 2507 int topHandle = topHandle (); 2508 if (defer && parent != null) { 2509 forceResize (); 2510 if (OS.GetWindow (handle, OS.GW_CHILD) == 0) { 2511 if (findImageControl () != null) { 2512 flags |= OS.SWP_NOCOPYBITS; 2513 } else { 2514 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { 2515 if (findThemeControl () != null) flags |= OS.SWP_NOCOPYBITS; 2516 } 2517 } 2518 } 2519 WINDOWPOS [] lpwp = parent.lpwp; 2520 if (lpwp == null) { 2521 SetWindowPos (topHandle, 0, x, y, width, height, flags); 2522 } else { 2523 int index = 0; 2524 while (index < lpwp.length) { 2525 if (lpwp [index] == null) break; 2526 index ++; 2527 } 2528 if (index == lpwp.length) { 2529 WINDOWPOS [] newLpwp = new WINDOWPOS [lpwp.length + 4]; 2530 System.arraycopy (lpwp, 0, newLpwp, 0, lpwp.length); 2531 parent.lpwp = lpwp = newLpwp; 2532 } 2533 WINDOWPOS wp = new WINDOWPOS (); 2534 wp.hwnd = topHandle; 2535 wp.x = x; 2536 wp.y = y; 2537 wp.cx = width; 2538 wp.cy = height; 2539 wp.flags = flags; 2540 lpwp [index] = wp; 2541 } 2542 } else { 2543 SetWindowPos (topHandle, 0, x, y, width, height, flags); 2544 } 2545} 2546 2547 2565public void setBounds (Rectangle rect) { 2566 checkWidget (); 2567 if (rect == null) error (SWT.ERROR_NULL_ARGUMENT); 2568 setBounds (rect.x, rect.y, rect.width, rect.height); 2569} 2570 2571 2583public void setCapture (boolean capture) { 2584 checkWidget (); 2585 if (capture) { 2586 OS.SetCapture (handle); 2587 } else { 2588 if (OS.GetCapture () == handle) { 2589 OS.ReleaseCapture (); 2590 } 2591 } 2592} 2593 2594void setCursor () { 2595 int lParam = OS.HTCLIENT | (OS.WM_MOUSEMOVE << 16); 2596 OS.SendMessage (handle, OS.WM_SETCURSOR, handle, lParam); 2597} 2598 2599 2618public void setCursor (Cursor cursor) { 2619 checkWidget (); 2620 if (cursor != null && cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); 2621 this.cursor = cursor; 2622 if (OS.IsWinCE) { 2623 int hCursor = cursor != null ? cursor.handle : 0; 2624 OS.SetCursor (hCursor); 2625 return; 2626 } 2627 int hwndCursor = OS.GetCapture (); 2628 if (hwndCursor == 0) { 2629 POINT pt = new POINT (); 2630 if (!OS.GetCursorPos (pt)) return; 2631 int hwnd = hwndCursor = OS.WindowFromPoint (pt); 2632 while (hwnd != 0 && hwnd != handle) { 2633 hwnd = OS.GetParent (hwnd); 2634 } 2635 if (hwnd == 0) return; 2636 } 2637 Control control = display.getControl (hwndCursor); 2638 if (control == null) control = this; 2639 control.setCursor (); 2640} 2641 2642void setDefaultFont () { 2643 int hFont = display.getSystemFont ().handle; 2644 OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0); 2645} 2646 2647 2661public void setDragDetect (boolean dragDetect) { 2662 checkWidget (); 2663 if (dragDetect) { 2664 state |= DRAG_DETECT; 2665 } else { 2666 state &= ~DRAG_DETECT; 2667 } 2668 enableDrag (dragDetect); 2669} 2670 2671 2684public void setEnabled (boolean enabled) { 2685 checkWidget (); 2686 2693 Control control = null; 2694 boolean fixFocus = false; 2695 if (!enabled) { 2696 if (display.focusEvent != SWT.FocusOut) { 2697 control = display.getFocusControl (); 2698 fixFocus = isFocusAncestor (control); 2699 } 2700 } 2701 enableWidget (enabled); 2702 if (fixFocus) fixFocus (control); 2703} 2704 2705boolean setFixedFocus () { 2706 if ((style & SWT.NO_FOCUS) != 0) return false; 2707 return forceFocus (); 2708} 2709 2710 2724public boolean setFocus () { 2725 checkWidget (); 2726 if ((style & SWT.NO_FOCUS) != 0) return false; 2727 return forceFocus (); 2728} 2729 2730 2745public void setFont (Font font) { 2746 checkWidget (); 2747 int hFont = 0; 2748 if (font != null) { 2749 if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); 2750 hFont = font.handle; 2751 } 2752 if (hFont == 0) hFont = defaultFont (); 2753 OS.SendMessage (handle, OS.WM_SETFONT, hFont, 1); 2754} 2755 2756 2773public void setForeground (Color color) { 2774 checkWidget (); 2775 int pixel = -1; 2776 if (color != null) { 2777 if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); 2778 pixel = color.handle; 2779 } 2780 if (pixel == foreground) return; 2781 foreground = pixel; 2782 setForegroundPixel (pixel); 2783} 2784 2785void setForegroundPixel (int pixel) { 2786 OS.InvalidateRect (handle, null, true); 2787} 2788 2789 2799public void setLayoutData (Object layoutData) { 2800 checkWidget (); 2801 this.layoutData = layoutData; 2802} 2803 2804 2819public void setLocation (int x, int y) { 2820 checkWidget (); 2821 int flags = OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE; 2822 2828 if (!OS.IsWinCE) flags |= OS.SWP_DRAWFRAME; 2829 setBounds (x, y, 0, 0, flags); 2830} 2831 2832 2846public void setLocation (Point location) { 2847 checkWidget (); 2848 if (location == null) error (SWT.ERROR_NULL_ARGUMENT); 2849 setLocation (location.x, location.y); 2850} 2851 2852 2877public void setMenu (Menu menu) { 2878 checkWidget (); 2879 if (menu != null) { 2880 if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); 2881 if ((menu.style & SWT.POP_UP) == 0) { 2882 error (SWT.ERROR_MENU_NOT_POP_UP); 2883 } 2884 if (menu.parent != menuShell ()) { 2885 error (SWT.ERROR_INVALID_PARENT); 2886 } 2887 } 2888 this.menu = menu; 2889} 2890 2891boolean setRadioFocus () { 2892 return false; 2893} 2894 2895boolean setRadioSelection (boolean value) { 2896 return false; 2897} 2898 2899 2922public void setRedraw (boolean redraw) { 2923 checkWidget (); 2924 2933 if (drawCount == 0) { 2934 int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); 2935 if ((bits & OS.WS_VISIBLE) == 0) state |= HIDDEN; 2936 } 2937 if (redraw) { 2938 if (--drawCount == 0) { 2939 int topHandle = topHandle (); 2940 OS.SendMessage (topHandle, OS.WM_SETREDRAW, 1, 0); 2941 if (handle != topHandle) OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0); 2942 if ((state & HIDDEN) != 0) { 2943 state &= ~HIDDEN; 2944 OS.ShowWindow (topHandle, OS.SW_HIDE); 2945 if (handle != topHandle) OS.ShowWindow (handle, OS.SW_HIDE); 2946 } else { 2947 if (OS.IsWinCE) { 2948 OS.InvalidateRect (topHandle, null, true); 2949 if (handle != topHandle) OS.InvalidateRect (handle, null, true); 2950 } else { 2951 int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN; 2952 OS.RedrawWindow (topHandle, null, 0, flags); 2953 } 2954 } 2955 } 2956 } else { 2957 if (drawCount++ == 0) { 2958 int topHandle = topHandle (); 2959 OS.SendMessage (topHandle, OS.WM_SETREDRAW, 0, 0); 2960 if (handle != topHandle) OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0); 2961 } 2962 } 2963} 2964 2965boolean setSavedFocus () { 2966 return forceFocus (); 2967} 2968 2969 2985public void setSize (int width, int height) { 2986 checkWidget (); 2987 int flags = OS.SWP_NOMOVE | OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE; 2988 setBounds (0, 0, Math.max (0, width), Math.max (0, height), flags); 2989} 2990 2991 3009public void setSize (Point size) { 3010 checkWidget (); 3011 if (size == null) error (SWT.ERROR_NULL_ARGUMENT); 3012 setSize (size.x, size.y); 3013} 3014 3015boolean setTabGroupFocus () { 3016 return setTabItemFocus (); 3017} 3018 3019boolean setTabItemFocus () { 3020 if (!isShowing ()) return false; 3021 return forceFocus (); 3022} 3023 3024 3035public void setToolTipText (String string) { 3036 checkWidget (); 3037 toolTipText = string; 3038 setToolTipText (getShell (), string); 3039} 3040 3041void setToolTipText (Shell shell, String string) { 3042 shell.setToolTipText (handle, string); 3043} 3044 3045 3061public void setVisible (boolean visible) { 3062 checkWidget (); 3063 if (drawCount != 0) { 3064 if (((state & HIDDEN) == 0) == visible) return; 3065 } else { 3066 int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); 3067 if (((bits & OS.WS_VISIBLE) != 0) == visible) return; 3068 } 3069 if (visible) { 3070 sendEvent (SWT.Show); 3071 if (isDisposed ()) return; 3072 } 3073 3074 3081 Control control = null; 3082 boolean fixFocus = false; 3083 if (!visible) { 3084 if (display.focusEvent != SWT.FocusOut) { 3085 control = display.getFocusControl (); 3086 fixFocus = isFocusAncestor (control); 3087 } 3088 } 3089 if (drawCount != 0) { 3090 state = visible ? state & ~HIDDEN : state | HIDDEN; 3091 } else { 3092 showWidget (visible); 3093 if (isDisposed ()) return; 3094 } 3095 if (!visible) { 3096 sendEvent (SWT.Hide); 3097 if (isDisposed ()) return; 3098 } 3099 if (fixFocus) fixFocus (control); 3100} 3101 3102void sort (int [] items) { 3103 3104 int length = items.length; 3105 for (int gap=length/2; gap>0; gap/=2) { 3106 for (int i=gap; i<length; i++) { 3107 for (int j=i-gap; j>=0; j-=gap) { 3108 if (items [j] <= items [j + gap]) { 3109 int swap = items [j]; 3110 items [j] = items [j + gap]; 3111 items [j + gap] = swap; 3112 } 3113 } 3114 } 3115 } 3116} 3117 3118void subclass () { 3119 int oldProc = windowProc (); 3120 int newProc = display.windowProc; 3121 if (oldProc == newProc) return; 3122 OS.SetWindowLong (handle, OS.GWL_WNDPROC, newProc); 3123} 3124 3125 3141public Point toControl (int x, int y) { 3142 checkWidget (); 3143 POINT pt = new POINT (); 3144 pt.x = x; pt.y = y; 3145 OS.ScreenToClient (handle, pt); 3146 return new Point (pt.x, pt.y); 3147} 3148 3149 3165public Point toControl (Point point) { 3166 checkWidget (); 3167 if (point == null) error (SWT.ERROR_NULL_ARGUMENT); 3168 return toControl (point.x, point.y); 3169} 3170 3171 3187public Point toDisplay (int x, int y) { 3188 checkWidget (); 3189 POINT pt = new POINT (); 3190 pt.x = x; pt.y = y; 3191 OS.ClientToScreen (handle, pt); 3192 return new Point (pt.x, pt.y); 3193} 3194 3195 3211public Point toDisplay (Point point) { 3212 checkWidget (); 3213 if (point == null) error (SWT.ERROR_NULL_ARGUMENT); 3214 return toDisplay (point.x, point.y); 3215} 3216 3217int topHandle () { 3218 return handle; 3219} 3220 3221boolean translateAccelerator (MSG msg) { 3222 return menuShell ().translateAccelerator (msg); 3223} 3224 3225boolean translateMnemonic (Event event, Control control) { 3226 if (control == this) return false; 3227 if (!isVisible () || !isEnabled ()) return false; 3228 event.doit = mnemonicMatch (event.character); 3229 return traverse (event); 3230} 3231 3232boolean translateMnemonic (MSG msg) { 3233 if (msg.wParam < 0x20) return false; 3234 int hwnd = msg.hwnd; 3235 if (OS.GetKeyState (OS.VK_MENU) >= 0) { 3236 int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0); 3237 if ((code & OS.DLGC_WANTALLKEYS) != 0) return false; 3238 if ((code & OS.DLGC_BUTTON) == 0) return false; 3239 } 3240 Decorations shell = menuShell (); 3241 if (shell.isVisible () && shell.isEnabled ()) { 3242 display.lastAscii = msg.wParam; 3243 display.lastNull = display.lastDead = false; 3244 Event event = new Event (); 3245 event.detail = SWT.TRAVERSE_MNEMONIC; 3246 if (setKeyState (event, SWT.Traverse, msg.wParam, msg.lParam)) { 3247 return translateMnemonic (event, null) || shell.translateMnemonic (event, this); 3248 } 3249 } 3250 return false; 3251} 3252 3253boolean translateTraversal (MSG msg) { 3254 int hwnd = msg.hwnd; 3255 int key = msg.wParam; 3256 if (key == OS.VK_MENU) { 3257 OS.SendMessage (hwnd, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0); 3258 return false; 3259 } 3260 int detail = SWT.TRAVERSE_NONE; 3261 boolean doit = true, all = false; 3262 boolean lastVirtual = false; 3263 int lastKey = key, lastAscii = 0; 3264 switch (key) { 3265 case OS.VK_ESCAPE: { 3266 all = true; 3267 lastAscii = 27; 3268 int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0); 3269 if ((code & OS.DLGC_WANTALLKEYS) != 0) { 3270 3277 if ((code & OS.DLGC_HASSETSEL) == 0) doit = false; 3278 } 3279 detail = SWT.TRAVERSE_ESCAPE; 3280 break; 3281 } 3282 case OS.VK_RETURN: { 3283 all = true; 3284 lastAscii = '\r'; 3285 int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0); 3286 if ((code & OS.DLGC_WANTALLKEYS) != 0) doit = false; 3287 detail = SWT.TRAVERSE_RETURN; 3288 break; 3289 } 3290 case OS.VK_TAB: { 3291 lastAscii = '\t'; 3292 boolean next = OS.GetKeyState (OS.VK_SHIFT) >= 0; 3293 int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0); 3294 if ((code & (OS.DLGC_WANTTAB | OS.DLGC_WANTALLKEYS)) != 0) { 3295 3303 if ((code & OS.DLGC_HASSETSEL) != 0) { 3304 if (next && OS.GetKeyState (OS.VK_CONTROL) >= 0) { 3305 doit = false; 3306 } 3307 } else { 3308 doit = false; 3309 } 3310 } 3311 if (parent != null && (parent.style & SWT.MIRRORED) != 0) { 3312 if (key == OS.VK_LEFT || key == OS.VK_RIGHT) next = !next; 3313 } 3314 detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS; 3315 break; 3316 } 3317 case OS.VK_UP: 3318 case OS.VK_LEFT: 3319 case OS.VK_DOWN: 3320 case OS.VK_RIGHT: { 3321 3326 if (OS.IsSP) { 3327 if (key == OS.VK_LEFT || key == OS.VK_RIGHT) return false; 3328 } 3329 lastVirtual = true; 3330 int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0); 3331 if ((code & (OS.DLGC_WANTARROWS )) != 0) doit = false; 3332 boolean next = key == OS.VK_DOWN || key == OS.VK_RIGHT; 3333 detail = next ? SWT.TRAVERSE_ARROW_NEXT : SWT.TRAVERSE_ARROW_PREVIOUS; 3334 break; 3335 } 3336 case OS.VK_PRIOR: 3337 case OS.VK_NEXT: { 3338 all = true; 3339 lastVirtual = true; 3340 if (OS.GetKeyState (OS.VK_CONTROL) >= 0) return false; 3341 int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0); 3342 if ((code & OS.DLGC_WANTALLKEYS) != 0) { 3343 3348 if ((code & OS.DLGC_HASSETSEL) == 0) doit = false; 3349 } 3350 detail = key == OS.VK_PRIOR ? SWT.TRAVERSE_PAGE_PREVIOUS : SWT.TRAVERSE_PAGE_NEXT; 3351 break; 3352 } 3353 default: 3354 return false; 3355 } 3356 Event event = new Event (); 3357 event.doit = doit; 3358 event.detail = detail; 3359 display.lastKey = lastKey; 3360 display.lastAscii = lastAscii; 3361 display.lastVirtual = lastVirtual; 3362 display.lastNull = display.lastDead = false; 3363 if (!setKeyState (event, SWT.Traverse, msg.wParam, msg.lParam)) return false; 3364 Shell shell = getShell (); 3365 Control control = this; 3366 do { 3367 if (control.traverse (event)) { 3368 OS.SendMessage (hwnd, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0); 3369 return true; 3370 } 3371 if (!event.doit && control.hooks (SWT.Traverse)) return false; 3372 if (control == shell) return false; 3373 control = control.parent; 3374 } while (all && control != null); 3375 return false; 3376} 3377 3378boolean traverse (Event event) { 3379 3385 sendEvent (SWT.Traverse, event); 3386 if (isDisposed ()) return true; 3387 if (!event.doit) return false; 3388 switch (event.detail) { 3389 case SWT.TRAVERSE_NONE: return true; 3390 case SWT.TRAVERSE_ESCAPE: return traverseEscape (); 3391 case SWT.TRAVERSE_RETURN: return traverseReturn (); 3392 case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true); 3393 case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false); 3394 case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true); 3395 case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false); 3396 case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event.character); 3397 case SWT.TRAVERSE_PAGE_NEXT: return traversePage (true); 3398 case SWT.TRAVERSE_PAGE_PREVIOUS: return traversePage (false); 3399 } 3400 return false; 3401} 3402 3403 3418public boolean traverse (int traversal) { 3419 checkWidget (); 3420 Event event = new Event (); 3421 event.doit = true; 3422 event.detail = traversal; 3423 return traverse (event); 3424} 3425 3426boolean traverseEscape () { 3427 return false; 3428} 3429 3430boolean traverseGroup (boolean next) { 3431 Control root = computeTabRoot (); 3432 Control group = computeTabGroup (); 3433 Control [] list = root.computeTabList (); 3434 int length = list.length; 3435 int index = 0; 3436 while (index < length) { 3437 if (list [index] == group) break; 3438 index++; 3439 } 3440 3446 if (index == length) return false; 3447 int start = index, offset = (next) ? 1 : -1; 3448 while ((index = ((index + offset + length) % length)) != start) { 3449 Control control = list [index]; 3450 if (!control.isDisposed () && control.setTabGroupFocus ()) { 3451 return true; 3452 } 3453 } 3454 if (group.isDisposed ()) return false; 3455 return group.setTabGroupFocus (); 3456} 3457 3458boolean traverseItem (boolean next) { 3459 Control [] children = parent._getChildren (); 3460 int length = children.length; 3461 int index = 0; 3462 while (index < length) { 3463 if (children [index] == this) break; 3464 index++; 3465 } 3466 3472 if (index == length) return false; 3473 int start = index, offset = (next) ? 1 : -1; 3474 while ((index = (index + offset + length) % length) != start) { 3475 Control child = children [index]; 3476 if (!child.isDisposed () && child.isTabItem ()) { 3477 if (child.setTabItemFocus ()) return true; 3478 } 3479 } 3480 return false; 3481} 3482 3483boolean traverseMnemonic (char key) { 3484 if (mnemonicHit (key)) { 3485 OS.SendMessage (handle, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0); 3486 return true; 3487 } 3488 return false; 3489} 3490 3491boolean traversePage (boolean next) { 3492 return false; 3493} 3494 3495boolean traverseReturn () { 3496 return false; 3497} 3498 3499void unsubclass () { 3500 int newProc = windowProc (); 3501 int oldProc = display.windowProc; 3502 if (oldProc == newProc) return; 3503 OS.SetWindowLong (handle, OS.GWL_WNDPROC, newProc); 3504} 3505 3506 3525public void update () { 3526 checkWidget (); 3527 update (false); 3528} 3529 3530void update (boolean all) { 3531 if (OS.IsWinCE) { 3533 OS.UpdateWindow (handle); 3534 } else { 3535 int flags = OS.RDW_UPDATENOW; 3536 if (all) flags |= OS.RDW_ALLCHILDREN; 3537 OS.RedrawWindow (handle, null, 0, flags); 3538 } 3539} 3540 3541void updateBackgroundColor () { 3542 Control control = findBackgroundControl (); 3543 if (control == null) control = this; 3544 setBackgroundPixel (control.background); 3545} 3546 3547void updateBackgroundImage () { 3548 Control control = findBackgroundControl (); 3549 Image image = control != null ? control.backgroundImage : backgroundImage; 3550 setBackgroundImage (image != null ? image.handle : 0); 3551} 3552 3553void updateBackgroundMode () { 3554 int oldState = state & PARENT_BACKGROUND; 3555 checkBackground (); 3556 if (oldState != (state & PARENT_BACKGROUND)) { 3557 setBackground (); 3558 } 3559} 3560 3561void updateFont (Font oldFont, Font newFont) { 3562 if (getFont ().equals (oldFont)) setFont (newFont); 3563} 3564 3565void updateImages () { 3566 3567} 3568 3569void updateLayout (boolean resize, boolean all) { 3570 3571} 3572 3573CREATESTRUCT widgetCreateStruct () { 3574 return null; 3575} 3576 3577int widgetExtStyle () { 3578 int bits = 0; 3579 if (!OS.IsPPC) { 3580 if ((style & SWT.BORDER) != 0) bits |= OS.WS_EX_CLIENTEDGE; 3581 } 3582 3590 if (OS.WIN32_VERSION < OS.VERSION (4, 10)) { 3591 return bits; 3592 } 3593 bits |= OS.WS_EX_NOINHERITLAYOUT; 3594 if ((style & SWT.RIGHT_TO_LEFT) != 0) bits |= OS.WS_EX_LAYOUTRTL; 3595 return bits; 3596} 3597 3598int widgetParent () { 3599 return parent.handle; 3600} 3601 3602int widgetStyle () { 3603 3604 int bits = OS.WS_CHILD | OS.WS_VISIBLE | OS.WS_CLIPSIBLINGS; 3605 if (OS.IsPPC) { 3609 if ((style & SWT.BORDER) != 0) bits |= OS.WS_BORDER; 3610 } 3611 return bits; 3612 3613 3619} 3624 3625 3642public boolean setParent (Composite parent) { 3643 checkWidget (); 3644 if (parent == null) error (SWT.ERROR_NULL_ARGUMENT); 3645 if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); 3646 if (this.parent == parent) return true; 3647 if (!isReparentable ()) return false; 3648 releaseParent (); 3649 Shell newShell = parent.getShell (), oldShell = getShell (); 3650 Decorations newDecorations = parent.menuShell (), oldDecorations = menuShell (); 3651 if (oldShell != newShell || oldDecorations != newDecorations) { 3652 Menu [] menus = oldShell.findMenus (this); 3653 fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus); 3654 } 3655 int topHandle = topHandle (); 3656 if (OS.SetParent (topHandle, parent.handle) == 0) return false; 3657 this.parent = parent; 3658 int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE; 3659 SetWindowPos (topHandle, OS.HWND_BOTTOM, 0, 0, 0, 0, flags); 3660 return true; 3661} 3662 3663abstract TCHAR windowClass (); 3664 3665abstract int windowProc (); 3666 3667int windowProc (int hwnd, int msg, int wParam, int lParam) { 3668 LRESULT result = null; 3669 switch (msg) { 3670 case OS.WM_ACTIVATE: result = WM_ACTIVATE (wParam, lParam); break; 3671 case OS.WM_CAPTURECHANGED: result = WM_CAPTURECHANGED (wParam, lParam); break; 3672 case OS.WM_CHAR: result = WM_CHAR (wParam, lParam); break; 3673 case OS.WM_CLEAR: result = WM_CLEAR (wParam, lParam); break; 3674 case OS.WM_CLOSE: result = WM_CLOSE (wParam, lParam); break; 3675 case OS.WM_COMMAND: result = WM_COMMAND (wParam, lParam); break; 3676 case OS.WM_CONTEXTMENU: result = WM_CONTEXTMENU (wParam, lParam); break; 3677 case OS.WM_CTLCOLORBTN: 3678 case OS.WM_CTLCOLORDLG: 3679 case OS.WM_CTLCOLOREDIT: 3680 case OS.WM_CTLCOLORLISTBOX: 3681 case OS.WM_CTLCOLORMSGBOX: 3682 case OS.WM_CTLCOLORSCROLLBAR: 3683 case OS.WM_CTLCOLORSTATIC: result = WM_CTLCOLOR (wParam, lParam); break; 3684 case OS.WM_CUT: result = WM_CUT (wParam, lParam); break; 3685 case OS.WM_DESTROY: result = WM_DESTROY (wParam, lParam); break; 3686 case OS.WM_DRAWITEM: result = WM_DRAWITEM (wParam, lParam); break; 3687 case OS.WM_ENDSESSION: result = WM_ENDSESSION (wParam, lParam); break; 3688 case OS.WM_ENTERIDLE: result = WM_ENTERIDLE (wParam, lParam); break; 3689 case OS.WM_ERASEBKGND: result = WM_ERASEBKGND (wParam, lParam); break; 3690 case OS.WM_GETDLGCODE: result = WM_GETDLGCODE (wParam, lParam); break; 3691 case OS.WM_GETFONT: result = WM_GETFONT (wParam, lParam); break; 3692 case OS.WM_GETOBJECT: result = WM_GETOBJECT (wParam, lParam); break; 3693 case OS.WM_GETMINMAXINFO: result = WM_GETMINMAXINFO (wParam, lParam); break; 3694 case OS.WM_HELP: result = WM_HELP (wParam, lParam); break; 3695 case OS.WM_HSCROLL: result = WM_HSCROLL (wParam, lParam); break; 3696 case OS.WM_IME_CHAR: result = WM_IME_CHAR (wParam, lParam); break; 3697 case OS.WM_IME_COMPOSITION: result = WM_IME_COMPOSITION (wParam, lParam); break; 3698 case OS.WM_INITMENUPOPUP: result = WM_INITMENUPOPUP (wParam, lParam); break; 3699 case OS.WM_INPUTLANGCHANGE: result = WM_INPUTLANGCHANGE (wParam, lParam); break; 3700 case OS.WM_HOTKEY: result = WM_HOTKEY (wParam, lParam); break; 3701 case OS.WM_KEYDOWN: result = WM_KEYDOWN (wParam, lParam); break; 3702 case OS.WM_KEYUP: result = WM_KEYUP (wParam, lParam); break; 3703 case OS.WM_KILLFOCUS: result = WM_KILLFOCUS (wParam, lParam); break; 3704 case OS.WM_LBUTTONDBLCLK: result = WM_LBUTTONDBLCLK (wParam, lParam); break; 3705 case OS.WM_LBUTTONDOWN: result = WM_LBUTTONDOWN (wParam, lParam); break; 3706 case OS.WM_LBUTTONUP: result = WM_LBUTTONUP (wParam, lParam); break; 3707 case OS.WM_MBUTTONDBLCLK: result = WM_MBUTTONDBLCLK (wParam, lParam); break; 3708 case OS.WM_MBUTTONDOWN: result = WM_MBUTTONDOWN (wParam, lParam); break; 3709 case OS.WM_MBUTTONUP: result = WM_MBUTTONUP (wParam, lParam); break; 3710 case OS.WM_MEASUREITEM: result = WM_MEASUREITEM (wParam, lParam); break; 3711 case OS.WM_MENUCHAR: result = WM_MENUCHAR (wParam, lParam); break; 3712 case OS.WM_MENUSELECT: result = WM_MENUSELECT (wParam, lParam); break; 3713 case OS.WM_MOUSEACTIVATE: result = WM_MOUSEACTIVATE (wParam, lParam); break; 3714 case OS.WM_MOUSEHOVER: result = WM_MOUSEHOVER (wParam, lParam); break; 3715 case OS.WM_MOUSELEAVE: result = WM_MOUSELEAVE (wParam, lParam); break; 3716 case OS.WM_MOUSEMOVE: result = WM_MOUSEMOVE (wParam, lParam); break; 3717 case OS.WM_MOUSEWHEEL: result = WM_MOUSEWHEEL (wParam, lParam); break; 3718 case OS.WM_MOVE: result = WM_MOVE (wParam, lParam); break; 3719 case OS.WM_NCACTIVATE: result = WM_NCACTIVATE (wParam, lParam); break; 3720 case OS.WM_NCCALCSIZE: result = WM_NCCALCSIZE (wParam, lParam); break; 3721 case OS.WM_NCHITTEST: result = WM_NCHITTEST (wParam, lParam); break; 3722 case OS.WM_NCLBUTTONDOWN: result = WM_NCLBUTTONDOWN (wParam, lParam); break; 3723 case OS.WM_NCPAINT: result = WM_NCPAINT (wParam, lParam); break; 3724 case OS.WM_NOTIFY: result = WM_NOTIFY (wParam, lParam); break; 3725 case OS.WM_PAINT: result = WM_PAINT (wParam, lParam); break; 3726 case OS.WM_PALETTECHANGED: result = WM_PALETTECHANGED (wParam, lParam); break; 3727 case OS.WM_PARENTNOTIFY: result = WM_PARENTNOTIFY (wParam, lParam); break; 3728 case OS.WM_PASTE: result = WM_PASTE (wParam, lParam); break; 3729 case OS.WM_PRINT: result = WM_PRINT (wParam, lParam); break; 3730 case OS.WM_PRINTCLIENT: result = WM_PRINTCLIENT (wParam, lParam); break; 3731 case OS.WM_QUERYENDSESSION: result = WM_QUERYENDSESSION (wParam, lParam); break; 3732 case OS.WM_QUERYNEWPALETTE: result = WM_QUERYNEWPALETTE (wParam, lParam); break; 3733 case OS.WM_QUERYOPEN: result = WM_QUERYOPEN (wParam, lParam); break; 3734 case OS.WM_RBUTTONDBLCLK: result = WM_RBUTTONDBLCLK (wParam, lParam); break; 3735 case OS.WM_RBUTTONDOWN: result = WM_RBUTTONDOWN (wParam, lParam); break; 3736 case OS.WM_RBUTTONUP: result = WM_RBUTTONUP (wParam, lParam); break; 3737 case OS.WM_SETCURSOR: result = WM_SETCURSOR (wParam, lParam); break; 3738 case OS.WM_SETFOCUS: result = WM_SETFOCUS (wParam, lParam); break; 3739 case OS.WM_SETFONT: result = WM_SETFONT (wParam, lParam); break; 3740 case OS.WM_SETTINGCHANGE: result = WM_SETTINGCHANGE (wParam, lParam); break; 3741 case OS.WM_SETREDRAW: result = WM_SETREDRAW (wParam, lParam); break; 3742 case OS.WM_SHOWWINDOW: result = WM_SHOWWINDOW (wParam, lParam); break; 3743 case OS.WM_SIZE: result = WM_SIZE (wParam, lParam); break; 3744 case OS.WM_SYSCHAR: result = WM_SYSCHAR (wParam, lParam); break; 3745 case OS.WM_SYSCOLORCHANGE: result = WM_SYSCOLORCHANGE (wParam, lParam); break; 3746 case OS.WM_SYSCOMMAND: result = WM_SYSCOMMAND (wParam, lParam); break; 3747 case OS.WM_SYSKEYDOWN: result = WM_SYSKEYDOWN (wParam, lParam); break; 3748 case OS.WM_SYSKEYUP: result = WM_SYSKEYUP (wParam, lParam); break; 3749 case OS.WM_TIMER: result = WM_TIMER (wParam, lParam); break; 3750 case OS.WM_UNDO: result = WM_UNDO (wParam, lParam); break; 3751 case OS.WM_UPDATEUISTATE: result = WM_UPDATEUISTATE (wParam, lParam); break; 3752 case OS.WM_VSCROLL: result = WM_VSCROLL (wParam, lParam); break; 3753 case OS.WM_WINDOWPOSCHANGED: result = WM_WINDOWPOSCHANGED (wParam, lParam); break; 3754 case OS.WM_WINDOWPOSCHANGING: result = WM_WINDOWPOSCHANGING (wParam, lParam); break; 3755 case OS.WM_XBUTTONDBLCLK: result = WM_XBUTTONDBLCLK (wParam, lParam); break; 3756 case OS.WM_XBUTTONDOWN: result = WM_XBUTTONDOWN (wParam, lParam); break; 3757 case OS.WM_XBUTTONUP: result = WM_XBUTTONUP (wParam, lParam); break; 3758 } 3759 if (result != null) return result.value; 3760 return callWindowProc (hwnd, msg, wParam, lParam); 3761} 3762 3763LRESULT WM_ACTIVATE (int wParam, int lParam) { 3764 return null; 3765} 3766 3767LRESULT WM_CAPTURECHANGED (int wParam, int lParam) { 3768 return wmCaptureChanged (handle, wParam, lParam); 3769} 3770 3771LRESULT WM_CHAR (int wParam, int lParam) { 3772 return wmChar (handle, wParam, lParam); 3773} 3774 3775LRESULT WM_CLEAR (int wParam, int lParam) { 3776 return null; 3777} 3778 3779LRESULT WM_CLOSE (int wParam, int lParam) { 3780 return null; 3781} 3782 3783LRESULT WM_COMMAND (int wParam, int lParam) { 3784 3788 if (lParam == 0) { 3789 Decorations shell = menuShell (); 3790 if (shell.isEnabled ()) { 3791 int id = wParam & 0xFFFF; 3792 MenuItem item = display.getMenuItem (id); 3793 if (item != null && item.isEnabled ()) { 3794 return item.wmCommandChild (wParam, lParam); 3795 } 3796 } 3797 return null; 3798 } 3799 Control control = display.getControl (lParam); 3800 if (control == null) return null; 3801 return control.wmCommandChild (wParam, lParam); 3802} 3803 3804LRESULT WM_CONTEXTMENU (int wParam, int lParam) { 3805 return wmContextMenu (handle, wParam, lParam); 3806} 3807 3808LRESULT WM_CTLCOLOR (int wParam, int lParam) { 3809 int hPalette = display.hPalette; 3810 if (hPalette != 0) { 3811 OS.SelectPalette (wParam, hPalette, false); 3812 OS.RealizePalette (wParam); 3813 } 3814 Control control = display.getControl (lParam); 3815 if (control == null) return null; 3816 return control.wmColorChild (wParam, lParam); 3817} 3818 3819LRESULT WM_CUT (int wParam, int lParam) { 3820 return null; 3821} 3822 3823LRESULT WM_DESTROY (int wParam, int lParam) { 3824 return null; 3825} 3826 3827LRESULT WM_DRAWITEM (int wParam, int lParam) { 3828 DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT (); 3829 OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof); 3830 if (struct.CtlType == OS.ODT_MENU) { 3831 MenuItem item = display.getMenuItem (struct.itemID); 3832 if (item == null) return null; 3833 return item.wmDrawChild (wParam, lParam); 3834 } 3835 Control control = display.getControl (struct.hwndItem); 3836 if (control == null) return null; 3837 return control.wmDrawChild (wParam, lParam); 3838} 3839 3840LRESULT WM_ENDSESSION (int wParam, int lParam) { 3841 return null; 3842} 3843 3844LRESULT WM_ENTERIDLE (int wParam, int lParam) { 3845 return null; 3846} 3847 3848LRESULT WM_ERASEBKGND (int wParam, int lParam) { 3849 if ((state & DRAW_BACKGROUND) != 0) { 3850 if (findImageControl () != null) return LRESULT.ONE; 3851 } 3852 if ((state & THEME_BACKGROUND) != 0) { 3853 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { 3854 if (findThemeControl () != null) return LRESULT.ONE; 3855 } 3856 } 3857 return null; 3858} 3859 3860LRESULT WM_GETDLGCODE (int wParam, int lParam) { 3861 return null; 3862} 3863 3864LRESULT WM_GETFONT (int wParam, int lParam) { 3865 return null; 3866} 3867 3868LRESULT WM_GETOBJECT (int wParam, int lParam) { 3869 if (accessible != null) { 3870 int result = accessible.internal_WM_GETOBJECT (wParam, lParam); 3871 if (result != 0) return new LRESULT (result); 3872 } 3873 return null; 3874} 3875 3876LRESULT WM_GETMINMAXINFO (int wParam, int lParam) { 3877 return null; 3878} 3879 3880LRESULT WM_HOTKEY (int wParam, int lParam) { 3881 return null; 3882} 3883 3884LRESULT WM_HELP (int wParam, int lParam) { 3885 if (OS.IsWinCE) return null; 3886 HELPINFO lphi = new HELPINFO (); 3887 OS.MoveMemory (lphi, lParam, HELPINFO.sizeof); 3888 Decorations shell = menuShell (); 3889 if (!shell.isEnabled ()) return null; 3890 if (lphi.iContextType == OS.HELPINFO_MENUITEM) { 3891 MenuItem item = display.getMenuItem (lphi.iCtrlId); 3892 if (item != null && item.isEnabled ()) { 3893 Widget widget = null; 3894 if (item.hooks (SWT.Help)) { 3895 widget = item; 3896 } else { 3897 Menu menu = item.parent; 3898 if (menu.hooks (SWT.Help)) widget = menu; 3899 } 3900 if (widget != null) { 3901 int hwndShell = shell.handle; 3902 OS.SendMessage (hwndShell, OS.WM_CANCELMODE, 0, 0); 3903 widget.postEvent (SWT.Help); 3904 return LRESULT.ONE; 3905 } 3906 } 3907 return null; 3908 } 3909 if (hooks (SWT.Help)) { 3910 postEvent (SWT.Help); 3911 return LRESULT.ONE; 3912 } 3913 return null; 3914} 3915 3916LRESULT WM_HSCROLL (int wParam, int lParam) { 3917 Control control = display.getControl (lParam); 3918 if (control == null) return null; 3919 return control.wmScrollChild (wParam, lParam); 3920} 3921 3922LRESULT WM_IME_CHAR (int wParam, int lParam) { 3923 return wmIMEChar (handle, wParam, lParam); 3924} 3925 3926LRESULT WM_IME_COMPOSITION (int wParam, int lParam) { 3927 return null; 3928} 3929 3930LRESULT WM_INITMENUPOPUP (int wParam, int lParam) { 3931 3932 3933 if (display.accelKeyHit) return null; 3934 3935 3940 Shell shell = getShell (); 3941 Menu oldMenu = shell.activeMenu, newMenu = null; 3942 if ((lParam >> 16) == 0) { 3943 newMenu = menuShell ().findMenu (wParam); 3944 if (newMenu != null) newMenu.update (); 3945 } 3946 Menu menu = newMenu; 3947 while (menu != null && menu != oldMenu) { 3948 menu = menu.getParentMenu (); 3949 } 3950 if (menu == null) { 3951 menu = shell.activeMenu; 3952 while (menu != null) { 3953 3960 menu.sendEvent (SWT.Hide); 3961 if (menu.isDisposed ()) break; 3962 menu = menu.getParentMenu (); 3963 Menu ancestor = newMenu; 3964 while (ancestor != null && ancestor != menu) { 3965 ancestor = ancestor.getParentMenu (); 3966 } 3967 if (ancestor != null) break; 3968 } 3969 } 3970 3971 3976 if (newMenu != null && newMenu.isDisposed ()) newMenu = null; 3977 shell.activeMenu = newMenu; 3978 3979 3980 if (newMenu != null && newMenu != oldMenu) { 3981 newMenu.sendEvent (SWT.Show); 3982 } 3984 return null; 3985} 3986 3987LRESULT WM_INPUTLANGCHANGE (int wParam, int lParam) { 3988 return null; 3989} 3990 3991LRESULT WM_KEYDOWN (int wParam, int lParam) { 3992 return wmKeyDown (handle, wParam, lParam); 3993} 3994 3995LRESULT WM_KEYUP (int wParam, int lParam) { 3996 return wmKeyUp (handle, wParam, lParam); 3997} 3998 3999LRESULT WM_KILLFOCUS (int wParam, int lParam) { 4000 return wmKillFocus (handle, wParam, lParam); 4001} 4002 4003LRESULT WM_LBUTTONDBLCLK (int wParam, int lParam) { 4004 return wmLButtonDblClk (handle, wParam, lParam); 4005} 4006 4007LRESULT WM_LBUTTONDOWN (int wParam, int lParam) { 4008 return wmLButtonDown (handle, wParam, lParam); 4009} 4010 4011LRESULT WM_LBUTTONUP (int wParam, int lParam) { 4012 return wmLButtonUp (handle, wParam, lParam); 4013} 4014 4015LRESULT WM_MBUTTONDBLCLK (int wParam, int lParam) { 4016 return wmMButtonDblClk (handle, wParam, lParam); 4017} 4018 4019LRESULT WM_MBUTTONDOWN (int wParam, int lParam) { 4020 return wmMButtonDown (handle, wParam, lParam); 4021} 4022 4023LRESULT WM_MBUTTONUP (int wParam, int lParam) { 4024 return wmMButtonUp (handle, wParam, lParam); 4025} 4026 4027LRESULT WM_MEASUREITEM (int wParam, int lParam) { 4028 MEASUREITEMSTRUCT struct = new MEASUREITEMSTRUCT (); 4029 OS.MoveMemory (struct, lParam, MEASUREITEMSTRUCT.sizeof); 4030 if (struct.CtlType == OS.ODT_MENU) { 4031 MenuItem item = display.getMenuItem (struct.itemID); 4032 if (item == null) return null; 4033 return item.wmMeasureChild (wParam, lParam); 4034 } 4035 int hwnd = OS.GetDlgItem (handle, struct.CtlID); 4036 Control control = display.getControl (hwnd); 4037 if (control == null) return null; 4038 return control.wmMeasureChild (wParam, lParam); 4039} 4040 4041LRESULT WM_MENUCHAR (int wParam, int lParam) { 4042 4050 int type = wParam >> 16; 4051 if (type == 0 || type == OS.MF_SYSMENU) { 4052 display.mnemonicKeyHit = false; 4053 return new LRESULT (OS.MNC_CLOSE << 16); 4054 } 4055 return null; 4056} 4057 4058LRESULT WM_MENUSELECT (int wParam, int lParam) { 4059 int code = wParam >> 16; 4060 Shell shell = getShell (); 4061 if (code == -1 && lParam == 0) { 4062 Menu menu = shell.activeMenu; 4063 while (menu != null) { 4064 4073 display.mnemonicKeyHit = true; 4074 4081 menu.sendEvent (SWT.Hide); 4082 if (menu.isDisposed ()) break; 4083 menu = menu.getParentMenu (); 4084 } 4085 4090 shell.activeMenu = null; 4091 return null; 4092 } 4093 if ((code & OS.MF_SYSMENU) != 0) return null; 4094 if ((code & OS.MF_HILITE) != 0) { 4095 MenuItem item = null; 4096 Decorations menuShell = menuShell (); 4097 if ((code & OS.MF_POPUP) != 0) { 4098 int index = wParam & 0xFFFF; 4099 MENUITEMINFO info = new MENUITEMINFO (); 4100 info.cbSize = MENUITEMINFO.sizeof; 4101 info.fMask = OS.MIIM_SUBMENU; 4102 if (OS.GetMenuItemInfo (lParam, index, true, info)) { 4103 Menu newMenu = menuShell.findMenu (info.hSubMenu); 4104 if (newMenu != null) item = newMenu.cascade; 4105 } 4106 } else { 4107 Menu newMenu = menuShell.findMenu (lParam); 4108 if (newMenu != null) { 4109 int id = wParam & 0xFFFF; 4110 item = display.getMenuItem (id); 4111 } 4112 Menu oldMenu = shell.activeMenu; 4113 if (oldMenu != null) { 4114 Menu ancestor = oldMenu; 4115 while (ancestor != null && ancestor != newMenu) { 4116 ancestor = ancestor.getParentMenu (); 4117 } 4118 if (ancestor == newMenu) { 4119 ancestor = oldMenu; 4120 while (ancestor != newMenu) { 4121 4128 ancestor.sendEvent (SWT.Hide); 4129 if (ancestor.isDisposed ()) break; 4130 ancestor = ancestor.getParentMenu (); 4131 } 4132 4138 if (!shell.isDisposed ()) { 4139 if (newMenu != null && newMenu.isDisposed ()) { 4140 newMenu = null; 4141 } 4142 shell.activeMenu = newMenu; 4143 } 4144 if (item != null && item.isDisposed ()) item = null; 4145 } 4146 } 4147 } 4148 if (item != null) item.sendEvent (SWT.Arm); 4149 } 4150 return null; 4151} 4152 4153LRESULT WM_MOUSEACTIVATE (int wParam, int lParam) { 4154 return null; 4155} 4156 4157LRESULT WM_MOUSEHOVER (int wParam, int lParam) { 4158 return wmMouseHover (handle, wParam, lParam); 4159} 4160 4161LRESULT WM_MOUSELEAVE (int wParam, int lParam) { 4162 if (OS.COMCTL32_MAJOR >= 6) getShell ().fixToolTip (); 4163 return wmMouseLeave (handle, wParam, lParam); 4164} 4165 4166LRESULT WM_MOUSEMOVE (int wParam, int lParam) { 4167 return wmMouseMove (handle, wParam, lParam); 4168} 4169 4170LRESULT WM_MOUSEWHEEL (int wParam, int lParam) { 4171 return wmMouseWheel (handle, wParam, lParam); 4172} 4173 4174LRESULT WM_MOVE (int wParam, int lParam) { 4175 if (findImageControl () != null) { 4176 if (this != getShell ()) redrawChildren (); 4177 } else { 4178 if ((state & THEME_BACKGROUND) != 0) { 4179 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { 4180 if (OS.IsWindowVisible (handle)) { 4181 if (findThemeControl () != null) redrawChildren (); 4182 } 4183 } 4184 } 4185 } 4186 sendEvent (SWT.Move); 4187 return null; 4189} 4190 4191LRESULT WM_NCACTIVATE (int wParam, int lParam) { 4192 return null; 4193} 4194 4195LRESULT WM_NCCALCSIZE (int wParam, int lParam) { 4196 return null; 4197} 4198 4199LRESULT WM_NCHITTEST (int wParam, int lParam) { 4200 if (!OS.IsWindowEnabled (handle)) return null; 4201 if (!isActive ()) return new LRESULT (OS.HTTRANSPARENT); 4202 return null; 4203} 4204 4205LRESULT WM_NCLBUTTONDOWN (int wParam, int lParam) { 4206 return null; 4207} 4208 4209LRESULT WM_NCPAINT (int wParam, int lParam) { 4210 return null; 4211} 4212 4213LRESULT WM_NOTIFY (int wParam, int lParam) { 4214 NMHDR hdr = new NMHDR (); 4215 OS.MoveMemory (hdr, lParam, NMHDR.sizeof); 4216 return wmNotify (hdr, wParam, lParam); 4217} 4218 4219LRESULT WM_PAINT (int wParam, int lParam) { 4220 return super.wmPaint (handle, wParam, lParam); 4221} 4222 4223LRESULT WM_PALETTECHANGED (int wParam, int lParam) { 4224 return null; 4225} 4226 4227LRESULT WM_PARENTNOTIFY (int wParam, int lParam) { 4228 return null; 4229} 4230 4231LRESULT WM_PASTE (int wParam, int lParam) { 4232 return null; 4233} 4234 4235LRESULT WM_PRINT (int wParam, int lParam) { 4236 return wmPrint (handle, wParam, lParam); 4237} 4238 4239LRESULT WM_PRINTCLIENT (int wParam, int lParam) { 4240 return null; 4241} 4242 4243LRESULT WM_QUERYENDSESSION (int wParam, int lParam) { 4244 return null; 4245} 4246 4247LRESULT WM_QUERYNEWPALETTE (int wParam, int lParam) { 4248 return null; 4249} 4250 4251LRESULT WM_QUERYOPEN (int wParam, int lParam) { 4252 return null; 4253} 4254 4255LRESULT WM_RBUTTONDBLCLK (int wParam, int lParam) { 4256 return wmRButtonDblClk (handle, wParam, lParam); 4257} 4258 4259LRESULT WM_RBUTTONDOWN (int wParam, int lParam) { 4260 return wmRButtonDown (handle, wParam, lParam); 4261} 4262 4263LRESULT WM_RBUTTONUP (int wParam, int lParam) { 4264 return wmRButtonUp (handle, wParam, lParam); 4265} 4266 4267LRESULT WM_SETCURSOR (int wParam, int lParam) { 4268 int hitTest = (short) (lParam & 0xFFFF); 4269 if (hitTest == OS.HTCLIENT) { 4270 Control control = display.getControl (wParam); 4271 if (control == null) return null; 4272 Cursor cursor = control.findCursor (); 4273 if (cursor != null) { 4274 OS.SetCursor (cursor.handle); 4275 return LRESULT.ONE; 4276 } 4277 } 4278 return null; 4279} 4280 4281LRESULT WM_SETFOCUS (int wParam, int lParam) { 4282 return wmSetFocus (handle, wParam, lParam); 4283} 4284 4285LRESULT WM_SETTINGCHANGE (int wParam, int lParam) { 4286 return null; 4287} 4288 4289LRESULT WM_SETFONT (int wParam, int lParam) { 4290 return null; 4291} 4292 4293LRESULT WM_SETREDRAW (int wParam, int lParam) { 4294 return null; 4295} 4296 4297LRESULT WM_SHOWWINDOW (int wParam, int lParam) { 4298 return null; 4299} 4300 4301LRESULT WM_SIZE (int wParam, int lParam) { 4302 sendEvent (SWT.Resize); 4303 return null; 4305} 4306 4307LRESULT WM_SYSCHAR (int wParam, int lParam) { 4308 return wmSysChar (handle, wParam, lParam); 4309} 4310 4311LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) { 4312 return null; 4313} 4314 4315LRESULT WM_SYSCOMMAND (int wParam, int lParam) { 4316 4322 if ((wParam & 0xF000) == 0) { 4323 Decorations shell = menuShell (); 4324 if (shell.isEnabled ()) { 4325 MenuItem item = display.getMenuItem (wParam & 0xFFFF); 4326 if (item != null) item.wmCommandChild (wParam, lParam); 4327 } 4328 return LRESULT.ZERO; 4329 } 4330 4331 4332 int cmd = wParam & 0xFFF0; 4333 switch (cmd) { 4334 case OS.SC_CLOSE: 4335 int hwndShell = menuShell ().handle; 4336 int bits = OS.GetWindowLong (hwndShell, OS.GWL_STYLE); 4337 if ((bits & OS.WS_SYSMENU) == 0) return LRESULT.ZERO; 4338 break; 4339 case OS.SC_KEYMENU: 4340 4353 if (lParam == 0) { 4354 Decorations shell = menuShell (); 4355 Menu menu = shell.getMenuBar (); 4356 if (menu == null) { 4357 Control control = display._getFocusControl (); 4358 if (control != null) { 4359 if (control.hooks (SWT.KeyDown) || control.hooks (SWT.KeyUp)) { 4360 display.mnemonicKeyHit = false; 4361 return LRESULT.ZERO; 4362 } 4363 } 4364 } 4365 } else { 4366 4380 if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) { 4381 if (lParam != ' ') { 4382 Decorations shell = menuShell (); 4383 Menu menu = shell.getMenuBar (); 4384 if (menu != null) { 4385 char key = Display.mbcsToWcs (lParam); 4386 if (key != 0) { 4387 key = Character.toUpperCase (key); 4388 MenuItem [] items = menu.getItems (); 4389 for (int i=0; i<items.length; i++) { 4390 MenuItem item = items [i]; 4391 String text = item.getText (); 4392 char mnemonic = findMnemonic (text); 4393 if (text.length () > 0 && mnemonic == 0) { 4394 char ch = text.charAt (0); 4395 if (Character.toUpperCase (ch) == key) { 4396 display.mnemonicKeyHit = false; 4397 return LRESULT.ZERO; 4398 } 4399 } 4400 } 4401 } 4402 } else { 4403 display.mnemonicKeyHit = false; 4404 } 4405 } 4406 } 4407 } 4408 case OS.SC_HSCROLL: 4410 case OS.SC_VSCROLL: 4411 4415 Decorations shell = menuShell (); 4416 if (!shell.isEnabled () || !shell.isActive ()) { 4417 return LRESULT.ZERO; 4418 } 4419 break; 4420 case OS.SC_MINIMIZE: 4421 4422 menuShell ().saveFocus (); 4423 break; 4424 } 4425 return null; 4426} 4427 4428LRESULT WM_SYSKEYDOWN (int wParam, int lParam) { 4429 return wmSysKeyDown (handle, wParam, lParam); 4430} 4431 4432LRESULT WM_SYSKEYUP (int wParam, int lParam) { 4433 return wmSysKeyUp (handle, wParam, lParam); 4434} 4435 4436LRESULT WM_TIMER (int wParam, int lParam) { 4437 return null; 4438} 4439 4440LRESULT WM_UNDO (int wParam, int lParam) { 4441 return null; 4442} 4443 4444LRESULT WM_UPDATEUISTATE (int wParam, int lParam) { 4445 return null; 4446} 4447 4448LRESULT WM_VSCROLL (int wParam, int lParam) { 4449 Control control = display.getControl (lParam); 4450 if (control == null) return null; 4451 return control.wmScrollChild (wParam, lParam); 4452} 4453 4454LRESULT WM_WINDOWPOSCHANGED (int wParam, int lParam) { 4455 return null; 4456} 4457 4458LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) { 4459 4465 if (drawCount != 0) { 4466 Shell shell = getShell (); 4467 if (shell != this) { 4468 WINDOWPOS lpwp = new WINDOWPOS (); 4469 OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof); 4470 if ((lpwp.flags & OS.SWP_NOMOVE) == 0 || (lpwp.flags & OS.SWP_NOSIZE) == 0) { 4471 RECT rect = new RECT (); 4472 OS.GetWindowRect (topHandle (), rect); 4473 int hwndParent = parent == null ? 0 : parent.handle; 4474 OS.MapWindowPoints (0, hwndParent, rect, 2); 4475 OS.InvalidateRect (hwndParent, rect, true); 4476 } 4477 } 4478 } 4479 return null; 4480} 4481 4482LRESULT WM_XBUTTONDBLCLK (int wParam, int lParam) { 4483 return wmXButtonDblClk (handle, wParam, lParam); 4484} 4485 4486LRESULT WM_XBUTTONDOWN (int wParam, int lParam) { 4487 return wmXButtonDown (handle, wParam, lParam); 4488} 4489 4490LRESULT WM_XBUTTONUP (int wParam, int lParam) { 4491 return wmXButtonUp (handle, wParam, lParam); 4492} 4493 4494LRESULT wmColorChild (int wParam, int lParam) { 4495 Control control = findBackgroundControl (); 4496 if (control == null) { 4497 if ((state & THEME_BACKGROUND) != 0) { 4498 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { 4499 control = findThemeControl (); 4500 if (control != null) { 4501 RECT rect = new RECT (); 4502 OS.GetClientRect (handle, rect); 4503 OS.SetTextColor (wParam, getForegroundPixel ()); 4504 OS.SetBkColor (wParam, getBackgroundPixel ()); 4505 fillThemeBackground (wParam, control, rect); 4506 OS.SetBkMode (wParam, OS.TRANSPARENT); 4507 return new LRESULT (OS.GetStockObject (OS.NULL_BRUSH)); 4508 } 4509 } 4510 } 4511 if (foreground == -1) return null; 4512 } 4513 if (control == null) control = this; 4514 int forePixel = getForegroundPixel (); 4515 int backPixel = control.getBackgroundPixel (); 4516 OS.SetTextColor (wParam, forePixel); 4517 OS.SetBkColor (wParam, backPixel); 4518 if (control.backgroundImage != null) { 4519 RECT rect = new RECT (); 4520 OS.GetClientRect (handle, rect); 4521 int hwnd = control.handle; 4522 int hBitmap = control.backgroundImage.handle; 4523 OS.MapWindowPoints (handle, hwnd, rect, 2); 4524 POINT lpPoint = new POINT (); 4525 OS.GetWindowOrgEx (wParam, lpPoint); 4526 OS.SetBrushOrgEx (wParam, -rect.left - lpPoint.x, -rect.top - lpPoint.y, lpPoint); 4527 int hBrush = findBrush (hBitmap, OS.BS_PATTERN); 4528 if ((state & DRAW_BACKGROUND) != 0) { 4529 int hOldBrush = OS.SelectObject (wParam, hBrush); 4530 OS.MapWindowPoints (hwnd, handle, rect, 2); 4531 OS.PatBlt (wParam, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY); 4532 OS.SelectObject (wParam, hOldBrush); 4533 } 4534 OS.SetBkMode (wParam, OS.TRANSPARENT); 4535 return new LRESULT (hBrush); 4536 } 4537 int hBrush = findBrush (backPixel, OS.BS_SOLID); 4538 if ((state & DRAW_BACKGROUND) != 0) { 4539 RECT rect = new RECT (); 4540 OS.GetClientRect (handle, rect); 4541 int hOldBrush = OS.SelectObject (wParam, hBrush); 4542 OS.PatBlt (wParam, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY); 4543 OS.SelectObject (wParam, hOldBrush); 4544 } 4545 return new LRESULT (hBrush); 4546} 4547 4548LRESULT wmCommandChild (int wParam, int lParam) { 4549 return null; 4550} 4551 4552LRESULT wmDrawChild (int wParam, int lParam) { 4553 return null; 4554} 4555 4556LRESULT wmMeasureChild (int wParam, int lParam) { 4557 return null; 4558} 4559 4560LRESULT wmNotify (NMHDR hdr, int wParam, int lParam) { 4561 Control control = display.getControl (hdr.hwndFrom); 4562 if (control == null) return null; 4563 return control.wmNotifyChild (hdr, wParam, lParam); 4564} 4565 4566LRESULT wmNotifyChild (NMHDR hdr, int wParam, int lParam) { 4567 return null; 4568} 4569 4570LRESULT wmScrollChild (int wParam, int lParam) { 4571 return null; 4572} 4573 4574} 4575 4576 | Popular Tags |