Changeset 39:f5e70f9aeeda
- Timestamp:
- 02/01/08 11:45:36 (1 year ago)
- Files:
-
- dwt/internal/win32/OS.d (modified) (4 diffs)
- dwt/widgets/Button.d (modified) (1 diff)
- dwt/widgets/Decorations.d (modified) (69 diffs)
- dwt/widgets/Display.d (modified) (2 diffs)
- dwt/widgets/Menu.d (modified) (2 diffs)
- dwt/widgets/MenuItem.d (modified) (3 diffs)
- dwt/widgets/Shell.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/internal/win32/OS.d
r38 r39 73 73 74 74 public static const BOOL IsPPC_; 75 public static const BOOL IsHPC; 76 public static const BOOL IsSP_; 75 public static const BOOL IsHPC = false; 76 77 // PORTING_FIXME, is it Windows WFSP? 78 public static const BOOL IsSP_ = false; 79 77 80 public static const BOOL IsDBLocale; 78 81 … … 116 119 IsWin95 = (info.dwPlatformId is VER_PLATFORM_WIN32_WINDOWS); 117 120 IsWinNT = (info.dwPlatformId is VER_PLATFORM_WIN32_NT); 118 IsSP_ = false;121 //IsSP_ = false; 119 122 IsPPC_ = false; 120 IsHPC = false;123 //IsHPC = false; 121 124 IsDBLocale = false; 122 125 WIN32_MAJOR = info.dwMajorVersion; … … 3877 3880 alias WINAPI.GetCharacterPlacementA GetCharacterPlacement; 3878 3881 alias WINAPI.GetClassInfoA GetClassInfo; 3882 alias STDWIN.GetClassNameA GetClassName; 3879 3883 alias WINAPI.GetClipboardFormatNameA GetClipboardFormatName; 3880 3884 alias WINAPI.GetKeyNameTextA GetKeyNameText; … … 3974 3978 alias WINAPI.GetCharacterPlacementW GetCharacterPlacement; 3975 3979 alias WINAPI.GetClassInfoW GetClassInfo; 3980 alias STDWIN.GetClassNameW GetClassName; 3976 3981 alias WINAPI.GetClipboardFormatNameW GetClipboardFormatName; 3977 3982 alias WINAPI.GetKeyNameTextW GetKeyNameText; dwt/widgets/Button.d
r31 r39 16 16 17 17 class Button : Control{ 18 void setDefault (bool value) ; 19 void click () ; 18 20 } 19 21 dwt/widgets/Decorations.d
r35 r39 13 13 module dwt.widgets.Decorations; 14 14 15 import dwt.widgets.Canvas; 16 import dwt.widgets.Menu; 17 import dwt.widgets.Control; 18 import dwt.internal.win32.OS; 19 20 class Decorations : Canvas { 21 Menu findMenu (HMENU hMenu) ; 22 void bringToTop () ; 23 void fixDecorations (Decorations newDecorations, Control control, Menu [] menus) ; 24 void setSavedFocus (Control control) ; 25 public Menu getMenuBar () ; 26 void saveFocus () ; 27 } 28 /++ 15 29 16 import dwt.DWT; 30 17 import dwt.DWTException; … … 33 20 import dwt.graphics.Point; 34 21 import dwt.graphics.Rectangle; 35 import dwt.internal.win32.ACCEL;36 import dwt.internal.win32.CREATESTRUCT;37 import dwt.internal.win32.LRESULT;38 import dwt.internal.win32.MENUITEMINFO;39 import dwt.internal.win32.MSG;40 22 import dwt.internal.win32.OS; 41 import dwt.internal.win32.RECT; 42 import dwt.internal.win32.STARTUPINFO; 43 import dwt.internal.win32.TCHAR; 44 import dwt.internal.win32.WINDOWPLACEMENT; 45 import dwt.internal.win32.WINDOWPOS; 23 24 import dwt.widgets.Canvas; 25 import dwt.widgets.Menu; 26 import dwt.widgets.Control; 27 import dwt.widgets.Button; 28 import dwt.widgets.Composite; 29 import dwt.widgets.Event; 30 import dwt.widgets.Shell; 31 import dwt.widgets.MenuItem; 32 import dwt.widgets.Display; 33 34 import dwt.dwthelper.utils; 46 35 47 36 /** … … 123 112 */ 124 113 125 public class Decorations extendsCanvas {114 public class Decorations : Canvas { 126 115 Image image, smallImage, largeImage; 127 116 Image [] images; … … 130 119 Control savedFocus; 131 120 Button defaultButton, saveDefault; 132 int swFlags, hAccel, nAccel; 121 int swFlags; 122 HACCEL hAccel; 123 int nAccel; 133 124 bool moved, resized, opened; 134 125 int oldX = OS.CW_USEDEFAULT, oldY = OS.CW_USEDEFAULT; … … 138 129 * Prevents uninitialized instances from being created outside the package. 139 130 */ 140 Decorations () {131 this () { 141 132 } 142 133 … … 179 170 * @see Widget#getStyle 180 171 */ 181 public Decorations (Composite parent, int style) {172 public this (Composite parent, int style) { 182 173 super (parent, checkStyle (style)); 183 174 } … … 191 182 */ 192 183 if (maximized) { 193 RECT rect = new RECT ();194 OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);184 RECT rect; 185 OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, &rect, 0); 195 186 int width = rect.right - rect.left, height = rect.bottom - rect.top; 196 if (OS.IsPPC ) {187 if (OS.IsPPC_) { 197 188 /* Leave space for the menu bar */ 198 189 if (menuBar !is null) { 199 inthwndCB = menuBar.hwndCB;200 RECT rectCB = new RECT ();201 OS.GetWindowRect (hwndCB, rectCB);190 auto hwndCB = menuBar.hwndCB; 191 RECT rectCB; 192 OS.GetWindowRect (hwndCB, &rectCB); 202 193 height -= rectCB.bottom - rectCB.top; 203 194 } 204 195 } 205 196 int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE; 206 SetWindowPos (handle, 0, rect.left, rect.top, width, height, flags);197 SetWindowPos (handle, null, rect.left, rect.top, width, height, flags); 207 198 } 208 199 } else { … … 321 312 } 322 313 323 int callWindowProc (inthwnd, int msg, int wParam, int lParam) {324 if (handle is 0) return 0;325 return OS.DefMDIChildProc (hwnd, msg, wParam, lParam);314 override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 315 if (handle is null) return LRESULT.ZERO; 316 return cast(LRESULT) OS.DefMDIChildProc (hwnd, msg, wParam, lParam); 326 317 } 327 318 … … 366 357 367 358 /* Get the size of the trimmings */ 368 RECT rect = new RECT ();369 OS.SetRect ( rect, x, y, x + width, y + height);359 RECT rect; 360 OS.SetRect (&rect, x, y, x + width, y + height); 370 361 int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE); 371 362 int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE); 372 bool hasMenu = OS.IsWinCE ? false : OS.GetMenu (handle) !is 0;373 OS.AdjustWindowRectEx ( rect, bits1, hasMenu, bits2);363 bool hasMenu = OS.IsWinCE ? false : OS.GetMenu (handle) !is null; 364 OS.AdjustWindowRectEx (&rect, bits1, hasMenu, bits2); 374 365 375 366 /* Get the size of the scroll bars */ … … 379 370 /* Compute the height of the menu bar */ 380 371 if (hasMenu) { 381 RECT testRect = new RECT ();382 OS.SetRect ( testRect, 0, 0, rect.right - rect.left, rect.bottom - rect.top);383 OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, testRect);372 RECT testRect; 373 OS.SetRect (&testRect, 0, 0, rect.right - rect.left, rect.bottom - rect.top); 374 OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, &testRect); 384 375 while ((testRect.bottom - testRect.top) < height) { 385 376 if (testRect.bottom - testRect.top is 0) break; 386 377 rect.top -= OS.GetSystemMetrics (OS.SM_CYMENU) - OS.GetSystemMetrics (OS.SM_CYBORDER); 387 OS.SetRect ( testRect, 0, 0, rect.right - rect.left, rect.bottom - rect.top);388 OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, testRect);378 OS.SetRect (&testRect, 0, 0, rect.right - rect.left, rect.bottom - rect.top); 379 OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, &testRect); 389 380 } 390 381 } … … 393 384 394 385 void createAccelerators () { 395 hAccel = nAccel = 0; 386 hAccel = null; 387 nAccel = 0; 396 388 int maxAccel = 0; 397 389 MenuItem [] items = display.items; 398 390 if (menuBar is null || items is null) { 399 if (!OS.IsPPC ) return;391 if (!OS.IsPPC_) return; 400 392 maxAccel = 1; 401 393 } else { 402 maxAccel = OS.IsPPC ? items.length + 1 : items.length;403 } 404 ACCEL accel = new ACCEL ();394 maxAccel = OS.IsPPC_ ? items.length + 1 : items.length; 395 } 396 ACCEL accel; 405 397 byte [] buffer1 = new byte [ACCEL.sizeof]; 406 398 byte [] buffer2 = new byte [maxAccel * ACCEL.sizeof]; … … 415 407 } 416 408 if (menu is menuBar) { 417 item.fillAccel (accel); 418 OS.MoveMemory (buffer1, accel, ACCEL.sizeof); 409 item.fillAccel (&accel); 410 *cast(ACCEL*)buffer1.ptr = accel; 411 //OS.MoveMemory (buffer1, accel, ACCEL.sizeof); 419 412 System.arraycopy (buffer1, 0, buffer2, nAccel * ACCEL.sizeof, ACCEL.sizeof); 420 413 nAccel++; … … 424 417 } 425 418 } 426 if (OS.IsPPC ) {419 if (OS.IsPPC_) { 427 420 /* 428 421 * Note on WinCE PPC. Close the shell when user taps CTRL-Q. 429 422 * IDOK represents the "Done Button" which also closes the shell. 430 423 */ 431 accel.fVirt = (byte) (OS.FVIRTKEY | OS.FCONTROL); 432 accel.key = (short) 'Q'; 433 accel.cmd = (short) OS.IDOK; 434 OS.MoveMemory (buffer1, accel, ACCEL.sizeof); 424 accel.fVirt = cast(byte) (OS.FVIRTKEY | OS.FCONTROL); 425 accel.key = cast(short) 'Q'; 426 accel.cmd = cast(short) OS.IDOK; 427 *cast(ACCEL*)buffer1.ptr = accel; 428 //OS.MoveMemory (buffer1, accel, ACCEL.sizeof); 435 429 System.arraycopy (buffer1, 0, buffer2, nAccel * ACCEL.sizeof, ACCEL.sizeof); 436 430 nAccel++; 437 431 } 438 if (nAccel !is 0) hAccel = OS.CreateAcceleratorTable ( buffer2, nAccel);432 if (nAccel !is 0) hAccel = OS.CreateAcceleratorTable ( cast(ACCEL*)buffer2.ptr, nAccel); 439 433 } 440 434 … … 457 451 if ((state & FOREIGN_HANDLE) is 0) { 458 452 if (!OS.IsWinCE) { 459 int hIcon = OS.LoadIcon (0,OS.IDI_APPLICATION);453 auto hIcon = OS.LoadIcon (null, cast(wchar*)OS.IDI_APPLICATION); 460 454 OS.SendMessage (handle, OS.WM_SETICON, OS.ICON_SMALL, hIcon); 461 455 } … … 466 460 super.createWidget (); 467 461 swFlags = OS.IsWinCE ? OS.SW_SHOWMAXIMIZED : OS.SW_SHOWNOACTIVATE; 468 hAccel = -1;462 hAccel = cast(HACCEL)-1; 469 463 } 470 464 471 465 void destroyAccelerators () { 472 if (hAccel !is 0 && hAccel !is-1) OS.DestroyAcceleratorTable (hAccel);473 hAccel = -1;466 if (hAccel !is null && hAccel !is cast(HACCEL)-1) OS.DestroyAcceleratorTable (hAccel); 467 hAccel = cast(HACCEL)-1; 474 468 } 475 469 … … 477 471 if (isDisposed()) return; 478 472 if (!isValidThread ()) error (DWT.ERROR_THREAD_INVALID_ACCESS); 479 if (!( this instanceof Shell)) {473 if (!(cast(Shell)this)) { 480 474 if (!traverseDecorations (true)) { 481 475 Shell shell = getShell (); … … 487 481 } 488 482 489 Menu findMenu ( inthMenu) {483 Menu findMenu (HMENU hMenu) { 490 484 if (menus is null) return null; 491 485 for (int i=0; i<menus.length; i++) { … … 522 516 if (!OS.IsWinCE) { 523 517 if (OS.IsIconic (handle)) { 524 WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ();518 WINDOWPLACEMENT lpwndpl; 525 519 lpwndpl.length = WINDOWPLACEMENT.sizeof; 526 OS.GetWindowPlacement (handle, lpwndpl);527 int width = lpwndpl.r ight - lpwndpl.left;528 int height = lpwndpl. bottom - lpwndpl.top;529 return new Rectangle (lpwndpl. left, lpwndpl.top, width, height);520 OS.GetWindowPlacement (handle, &lpwndpl); 521 int width = lpwndpl.rcNormalPosition.right - lpwndpl.rcNormalPosition.left; 522 int height = lpwndpl.rcNormalPosition.bottom - lpwndpl.rcNormalPosition.top; 523 return new Rectangle (lpwndpl.rcNormalPosition.left, lpwndpl.rcNormalPosition.top, width, height); 530 524 } 531 525 } … … 540 534 * subtract the height of the CommandBar. 541 535 */ 542 if (OS.IsHPC) {536 static if (OS.IsHPC) { 543 537 Rectangle rect = super.getClientArea (); 544 538 if (menuBar !is null) { 545 inthwndCB = menuBar.hwndCB;539 auto hwndCB = menuBar.hwndCB; 546 540 int height = OS.CommandBar_Height (hwndCB); 547 541 rect.y += height; … … 550 544 return rect; 551 545 } 552 if (!OS.IsWinCE) {546 static if (!OS.IsWinCE) { 553 547 if (OS.IsIconic (handle)) { 554 WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ();548 WINDOWPLACEMENT lpwndpl; 555 549 lpwndpl.length = WINDOWPLACEMENT.sizeof; 556 OS.GetWindowPlacement (handle, lpwndpl);557 int width = lpwndpl.r ight - lpwndpl.left;558 int height = lpwndpl. bottom - lpwndpl.top;550 OS.GetWindowPlacement (handle, &lpwndpl); 551 int width = lpwndpl.rcNormalPosition.right - lpwndpl.rcNormalPosition.left; 552 int height = lpwndpl.rcNormalPosition.bottom - lpwndpl.rcNormalPosition.top; 559 553 /* 560 554 * Feature in Windows. For some reason WM_NCCALCSIZE does … … 570 564 if (horizontalBar !is null) width -= OS.GetSystemMetrics (OS.SM_CYHSCROLL); 571 565 if (verticalBar !is null) height -= OS.GetSystemMetrics (OS.SM_CXVSCROLL); 572 RECT rect = new RECT ();566 RECT rect; 573 567 int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE); 574 568 int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE); 575 bool hasMenu = OS.IsWinCE ? false : OS.GetMenu (handle) !is 0;576 OS.AdjustWindowRectEx ( rect, bits1, hasMenu, bits2);569 bool hasMenu = OS.IsWinCE ? false : OS.GetMenu (handle) !is null; 570 OS.AdjustWindowRectEx (&rect, bits1, hasMenu, bits2); 577 571 width = Math.max (0, width - (rect.right - rect.left)); 578 572 height = Math.max (0, height - (rect.bottom - rect.top)); … … 666 660 if (!OS.IsWinCE) { 667 661 if (OS.IsIconic (handle)) { 668 WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ();662 WINDOWPLACEMENT lpwndpl; 669 663 lpwndpl.length = WINDOWPLACEMENT.sizeof; 670 OS.GetWindowPlacement (handle, lpwndpl);671 return new Point (lpwndpl. left, lpwndpl.top);664 OS.GetWindowPlacement (handle, &lpwndpl); 665 return new Point (lpwndpl.rcNormalPosition.left, lpwndpl.rcNormalPosition.top); 672 666 } 673 667 } … … 691 685 public bool getMaximized () { 692 686 checkWidget (); 693 if (OS.IsWinCE) return swFlags is OS.SW_SHOWMAXIMIZED;694 if (OS.IsWindowVisible (handle)) return OS.IsZoomed (handle);687 static if (OS.IsWinCE) return swFlags is OS.SW_SHOWMAXIMIZED; 688 if (OS.IsWindowVisible (handle)) return cast(bool) OS.IsZoomed (handle); 695 689 return swFlags is OS.SW_SHOWMAXIMIZED; 696 690 } … … 728 722 public bool getMinimized () { 729 723 checkWidget (); 730 if (OS.IsWinCE) return false;731 if (OS.IsWindowVisible (handle)) return OS.IsIconic (handle);724 static if (OS.IsWinCE) return false; 725 if (OS.IsWindowVisible (handle)) return cast(bool) OS.IsIconic (handle); 732 726 return swFlags is OS.SW_SHOWMINNOACTIVE; 733 727 } 734 728 735 StringgetNameText () {729 char[] getNameText () { 736 730 return getText (); 737 731 } … … 739 733 public Point getSize () { 740 734 checkWidget (); 741 if (!OS.IsWinCE) {735 static if (!OS.IsWinCE) { 742 736 if (OS.IsIconic (handle)) { 743 WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ();737 WINDOWPLACEMENT lpwndpl; 744 738 lpwndpl.length = WINDOWPLACEMENT.sizeof; 745 OS.GetWindowPlacement (handle, lpwndpl);746 int width = lpwndpl.r ight - lpwndpl.left;747 int height = lpwndpl. bottom - lpwndpl.top;739 OS.GetWindowPlacement (handle, &lpwndpl); 740 int width = lpwndpl.rcNormalPosition.right - lpwndpl.rcNormalPosition.left; 741 int height = lpwndpl.rcNormalPosition.bottom - lpwndpl.rcNormalPosition.top; 748 742 return new Point (width, height); 749 743 } … … 765 759 * </ul> 766 760 */ 767 public StringgetText () {761 public char[] getText () { 768 762 checkWidget (); 769 763 int length = OS.GetWindowTextLength (handle); 770 764 if (length is 0) return ""; 771 765 /* Use the character encoding for the default locale */ 772 TCHAR buffer = new TCHAR (0, length + 1); 773 OS.GetWindowText (handle, buffer, length + 1); 774 return buffer.toString (0, length); 766 TCHAR[] buffer; 767 buffer.length = length + 1; 768 OS.GetWindowText (handle, buffer.ptr, length + 1); 769 return TCHARsToStr( buffer ); 775 770 } 776 771 … … 829 824 savedFocus = null; 830 825 defaultButton = saveDefault = null; 831 if (hAccel !is 0 && hAccel !is-1) OS.DestroyAcceleratorTable (hAccel);832 hAccel = -1;826 if (hAccel !is null && hAccel !is cast(HACCEL)-1) OS.DestroyAcceleratorTable (hAccel); 827 hAccel = cast(HACCEL)-1; 833 828 } 834 829 … … 875 870 } 876 871 forceResize (); 877 RECT rect = new RECT ();878 OS.GetWindowRect (handle, rect);872 RECT rect; 873 OS.GetWindowRect (handle, &rect); 879 874 bool sameOrigin = true; 880 875 if ((OS.SWP_NOMOVE & flags) is 0) { … … 887 882 if (!sameExtent) resized = true; 888 883 } 889 if (!OS.IsWinCE) {884 static if (!OS.IsWinCE) { 890 885 if (OS.IsZoomed (handle)) { 891 886 if (sameOrigin && sameExtent) return; … … 991 986 if (largeImage !is null) largeImage.dispose (); 992 987 smallImage = largeImage = null; 993 int hSmallIcon = 0, hLargeIcon = 0;988 HICON hSmallIcon, hLargeIcon; 994 989 Image smallIcon = null, largeIcon = null; 995 990 if (image !is null) { … … 1038 1033 */ 1039 1034 if ((state & FOREIGN_HANDLE) is 0) { 1040 hSmallIcon = OS.LoadIcon ( 0,OS.IDI_APPLICATION);1035 hSmallIcon = OS.LoadIcon (null, cast(wchar*)OS.IDI_APPLICATION); 1041 1036 } 1042 1037 } … … 1063 1058 */ 1064 1059 if (!OS.IsWinCE) { 1065 if (hSmallIcon is 0 && hLargeIcon is 0&& (style & DWT.BORDER) !is 0) {1060 if (hSmallIcon is null && hLargeIcon is null && (style & DWT.BORDER) !is 0) { 1066 1061 int flags = OS.RDW_FRAME | OS.RDW_INVALIDATE; 1067 OS.RedrawWindow (handle, null, 0, flags);1062 OS.RedrawWindow (handle, null, null, flags); 1068 1063 } 1069 1064 } … … 1156 1151 if (menu.parent !is this) error (DWT.ERROR_INVALID_PARENT); 1157 1152 } 1158 if (OS.IsWinCE) {1153 static if (OS.IsWinCE) { 1159 1154 if (OS.IsHPC) { 1160 1155 bool resize = menuBar !is menu; … … 1171 1166 } 1172 1167 } else { 1173 if (OS.IsPPC ) {1168 if (OS.IsPPC_) { 1174 1169 /* 1175 1170 * Note in WinCE PPC. The menu bar is a separate popup window. … … 1192 1187 if (menu !is null) display.removeBar (menu); 1193 1188 menuBar = menu; 1194 int hMenu = menuBar !is null ? menuBar.handle: 0;1189 auto hMenu = menuBar !is null ? menuBar.handle: null; 1195 1190 OS.SetMenu (handle, hMenu); 1196 1191 } … … 1236 1231 * feature. 1237 1232 */ 1238 inthwndParent = parent.handle;1233 auto hwndParent = parent.handle; 1239 1234 display.lockActiveWindow = true; 1240 1235 OS.SetParent (handle, hwndParent); … … 1247 1242 OS.SetWindowLong (handle, OS.GWL_ID, 0); 1248 1243 int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE; 1249 SetWindowPos (handle, OS.HWND_BOTTOM, 0, 0, 0, 0, flags);1244 SetWindowPos (handle, cast(HWND)OS.HWND_BOTTOM, 0, 0, 0, 0, flags); 1250 1245 display.lockActiveWindow = false; 1251 1246 } 1252 1247 1253 1248 void setPlacement (int x, int y, int width, int height, int flags) { 1254 WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ();1249 WINDOWPLACEMENT lpwndpl; 1255 1250 lpwndpl.length = WINDOWPLACEMENT.sizeof; 1256 OS.GetWindowPlacement (handle, lpwndpl);1251 OS.GetWindowPlacement (handle, &lpwndpl); 1257 1252 lpwndpl.showCmd = OS.SW_SHOWNA; 1258 1253 if (OS.IsIconic (handle)) { … … 1265 1260 bool sameOrigin = true; 1266 1261 if ((flags & OS.SWP_NOMOVE) is 0) { 1267 sameOrigin = lpwndpl. left !is x || lpwndpl.top !is y;1268 lpwndpl.r ight = x + (lpwndpl.right - lpwndpl.left);1269 lpwndpl. bottom = y + (lpwndpl.bottom - lpwndpl.top);1270 lpwndpl. left = x;1271 lpwndpl. top = y;1262 sameOrigin = lpwndpl.rcNormalPosition.left !is x || lpwndpl.rcNormalPosition.top !is y; 1263 lpwndpl.rcNormalPosition.right = x + (lpwndpl.rcNormalPosition.right - lpwndpl.rcNormalPosition.left); 1264 lpwndpl.rcNormalPosition.bottom = y + (lpwndpl.rcNormalPosition.bottom - lpwndpl.rcNormalPosition.top); 1265 lpwndpl.rcNormalPosition.left = x; 1266 lpwndpl.rcNormalPosition.top = y; 1272 1267 } 1273 1268 bool sameExtent = true; 1274 1269 if ((flags & OS.SWP_NOSIZE) is 0) { 1275 sameExtent = lpwndpl.r ight - lpwndpl.left !is width || lpwndpl.bottom - lpwndpl.top !is height;1276 lpwndpl.r ight = lpwndpl.left + width;1277 lpwndpl. bottom = lpwndpl.top + height;1278 } 1279 OS.SetWindowPlacement (handle, lpwndpl);1270 sameExtent = lpwndpl.rcNormalPosition.right - lpwndpl.rcNormalPosition.left !is width || lpwndpl.rcNormalPosition.bottom - lpwndpl.rcNormalPosition.top !is height; 1271 lpwndpl.rcNormalPosition.right = lpwndpl.rcNormalPosition.left + width; 1272 lpwndpl.rcNormalPosition.bottom = lpwndpl.rcNormalPosition.top + height; 1273 } 1274 OS.SetWindowPlacement (handle, &lpwndpl); 1280 1275 if (OS.IsIconic (handle)) { 1281 1276 if (sameOrigin) { … … 1294 1289 sendEvent (DWT.Resize); 1295 1290 if (isDisposed ()) return; 1296 if (layout !is null) {1291 if (layout_ !is null) { 1297 1292 markLayout (false, false); 1298 1293 updateLayout (true, false); … … 1307 1302 1308 1303 void setSystemMenu () { 1309 if (OS.IsWinCE) return;1310 inthMenu = OS.GetSystemMenu (handle, false);1311 if (hMenu is 0) return;1304 static if (OS.IsWinCE) return; 1305 auto hMenu = OS.GetSystemMenu (handle, false); 1306 if (hMenu is null) return; 1312 1307 int oldCount = OS.GetMenuItemCount (hMenu); 1313 1308 if ((style & DWT.RESIZE) is 0) { … … 1326 1321 if ((style & DWT.CLOSE) is 0 || newCount !is oldCount) { 1327 1322 OS.DeleteMenu (hMenu, OS.SC_TASKLIST, OS.MF_BYCOMMAND); 1328 MENUITEMINFO info = new MENUITEMINFO ();1323 MENUITEMINFO info; 1329 1324 info.cbSize = MENUITEMINFO.sizeof; 1330 1325 info.fMask = OS.MIIM_ID; 1331 1326 int index = 0; 1332 1327 while (index < newCount) { 1333 if (OS.GetMenuItemInfo (hMenu, index, true, info)) {1328 if (OS.GetMenuItemInfo (hMenu, index, true, &info)) { 1334 1329 if (info.wID is OS.SC_CLOSE) break; 1335 1330 } … … 1360 1355 * </ul> 1361 1356 */ 1362 public void setText ( Stringstring) {1357 public void setText (char[] string) { 1363 1358 checkWidget (); 1364 1359 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 1365 1360 /* Use the character encoding for the default locale */ 1366 TCHAR buffer = new TCHAR (0, string, true); 1367 OS.SetWindowText (handle, buffer); 1361 OS.SetWindowText (handle, StrToTCHARz(string)); 1368 1362 } 1369 1363 … … 1383 1377 sendEvent (DWT.Show); 1384 1378 if (isDisposed ()) return; 1385 if (OS.IsHPC) {1379 static if (OS.IsHPC) { 1386 1380 if (menuBar !is null) { 1387 inthwndCB = menuBar.hwndCB;1381 auto hwndCB = menuBar.hwndCB; 1388 1382 OS.CommandBar_DrawMenuBar (hwndCB, 0); 1389 1383 } … … 1392 1386 state &= ~HIDDEN; 1393 1387 } else { 1394 if (OS.IsWinCE) {1388 static if (OS.IsWinCE) { 1395 1389 OS.ShowWindow (handle, OS.SW_SHOW); 1396 1390 } else { … … 1399 1393 OS.DrawMenuBar (handle); 1400 1394 } 1401 STARTUPINFO lpStartUpInfo = Display.lpStartupInfo;1395 STARTUPINFO* lpStartUpInfo = Display.lpStartupInfo; 1402 1396 if (lpStartUpInfo !is null && (lpStartUpInfo.dwFlags & OS.STARTF_USESHOWWINDOW) !is 0) { 1403 1397 OS.ShowWindow (handle, lpStartUpInfo.wShowWindow); … … 1423 1417 } 1424 1418 } else { 1425 if (!OS.IsWinCE) {1419 static if (!OS.IsWinCE) { 1426 1420 if (OS.IsIconic (handle)) { 1427 1421 swFlags = OS.SW_SHOWMINNOACTIVE; … … 1468 1462 } 1469 1463 1470 bool translateAccelerator (MSG msg) {1464 bool translateAccelerator (MSG* msg) { 1471 1465 if (!isEnabled () || !isActive ()) return false; 1472 1466 if (menuBar !is null && !menuBar.isEnabled ()) return false; … … 1476 1470 } 1477 1471 1478 bool translateMenuAccelerator (MSG msg) {1479 if (hAccel is -1) createAccelerators ();1480 return hAccel !is 0&& OS.TranslateAccelerator (handle, hAccel, msg) !is 0;1481 } 1482 1483 bool translateMDIAccelerator (MSG msg) {1484 if (!( this instanceof Shell)) {1472 bool translateMenuAccelerator (MSG* msg) { 1473 if (hAccel is cast(HACCEL)-1) createAccelerators (); 1474 return hAccel !is null && OS.TranslateAccelerator (handle, hAccel, msg) !is 0; 1475 } 1476 1477 bool translateMDIAccelerator (MSG* msg) { 1478 if (!(cast(Shell)this)) { 1485 1479 Shell shell = getShell (); 1486 int hwndMDIClient = shell.hwndMDIClient;1487 if (hwndMDIClient !is 0&& OS.TranslateMDISysAccel (hwndMDIClient, msg)) {1480 auto hwndMDIClient = shell.hwndMDIClient_; 1481 if (hwndMDIClient !is null && OS.TranslateMDISysAccel (hwndMDIClient, msg)) { 1488 1482 return true; 1489 1483 } … … 1528 1522 while ((index = (index + offset + length) % length) !is start) { 1529 1523 Control child = children [index]; 1530 if (!child.isDisposed () && child instanceof Decorations) {1524 if (!child.isDisposed () && ( null !is cast(Decorations)child)) { 1531 1525 if (child.setFocus ()) return true; 1532 1526 } … … 1546 1540 } 1547 1541 1548 CREATESTRUCT widgetCreateStruct () {1542 CREATESTRUCT* widgetCreateStruct () { 1549 1543 return new CREATESTRUCT (); 1550 1544 } … … 1554 1548 bits &= ~OS.WS_EX_CLIENTEDGE; 1555 1549 if ((style & DWT.NO_TRIM) !is 0) return bits; 1556 if (OS.IsPPC ) {1550 if (OS.IsPPC_) { 1557 1551 if ((style & DWT.CLOSE) !is 0) bits |= OS.WS_EX_CAPTIONOKBTN; 1558 1552 } … … 1562 1556 } 1563 1557 1564 intwidgetParent () {1558 HWND widgetParent () { 1565 1559 Shell shell = getShell (); 1566 1560 return shell.hwndMDIClient (); … … 1591 1585 * It does not set the WS_THICKFRAME style. 1592 1586 */ 1593 if (!OS.IsPPC ) bits |= OS.WS_THICKFRAME;1587 if (!OS.IsPPC_) bits |= OS.WS_THICKFRAME; 1594 1588 } else { 1595 1589 if ((style & DWT.BORDER) is 0) bits |= OS.WS_BORDER; … … 1597 1591 1598 1592 /* Set the system menu and close box bits */ 1599 if (!OS.IsPPC && !OS.IsSP) {1593 if (!OS.IsPPC_ && !OS.IsSP_) { 1600 1594 if ((style & DWT.CLOSE) !is 0) bits |= OS.WS_SYSMENU; 1601 1595 } … … 1604 1598 } 1605 1599 1606 int windowProc (inthwnd, int msg, int wParam, int lParam) {1600 override int windowProc (HWND hwnd, int msg, int wParam, int lParam) { 1607 1601 switch (msg) { 1608 1602 case Display.SWT_GETACCEL: 1609 1603 case Display.SWT_GETACCELCOUNT: 1610 if (hAccel is -1) createAccelerators ();1611 return msg is Display.SWT_GETACCELCOUNT ? nAccel : hAccel;1604 if (hAccel is cast(HACCEL)-1) createAccelerators (); 1605 return msg is Display.SWT_GETACCELCOUNT ? nAccel : cast(int)hAccel; 1612 1606 } 1613 1607 return super.windowProc (hwnd, msg, wParam, lParam); … … 1616 1610 LRESULT WM_ACTIVATE (int wParam, int lParam) { 1617 1611 LRESULT result = super.WM_ACTIVATE (wParam, lParam); 1618 if (result !is null) return result;1612 if (result !is LRESULT.NULL) return result; 1619 1613 /* 1620 1614 * Feature in AWT. When an AWT Window is activated, … … 1629 1623 * WM_ACTIVATE messages that come from AWT Windows. 1630 1624 */ 1631 if (OS.GetParent ( lParam) is handle) {1632 TCHAR buffer = new TCHAR (0, 128);1633 OS.GetClassName ( lParam, buffer, buffer.length ());1634 String className = buffer.toString (0, buffer.strlen ());1635 if (className .equals (Display.AWT_WINDOW_CLASS)) {1625 if (OS.GetParent ( cast(HWND)lParam) is handle) { 1626 TCHAR[128] buffer = 0; 1627 OS.GetClassName (cast(HWND)lParam, buffer.ptr, buffer.length ); 1628 char[] className = TCHARzToStr( buffer.ptr ); 1629 if (className == Display.AWT_WINDOW_CLASS) { 1636 1630 return LRESULT.ZERO; 1637 1631 } … … 1645 1639 */ 1646 1640 if ((wParam >> 16) !is 0) return result; 1647 Control control = display.findControl ( lParam);1648 if (control is null || control instanceof Shell) {1649 if ( this instanceof Shell) {1641 Control control = display.findControl (cast(HWND)lParam); 1642 if (control is null || (null !is cast(Shell)control)) { 1643 if (cast(Shell)this) { 1650 1644 sendEvent (DWT.Activate); 1651 1645 if (isDisposed ()) return LRESULT.ZERO; … … 1657 1651 bool lockWindow = display.isXMouseActive (); 1658 1652 if (lockWindow) display.lockActiveWindow = true; 1659 Control control = display.findControl ( lParam);1660 if (control is null || control instanceof Shell) {1661 if ( this instanceof Shell) {1653 Control control = display.findControl (cast(HWND)lParam); 1654 if (control is null || (null !is cast(Shell)control)) { 1655 if (cast(Shell)this) { 1662 1656 sendEvent (DWT.Deactivate); 1663 1657 if (!isDisposed ()) { … … 1677 1671 LRESULT WM_CLOSE (int wParam, int lParam) { 1678 1672 LRESULT result = super.WM_CLOSE (wParam, lParam); 1679 if (result !is null) return result;1673 if (result !is LRESULT.NULL) return result; 1680 1674 if (isEnabled () && isActive ()) closeWidget (); 1681 1675 return LRESULT.ZERO; … … 1684 1678 LRESULT WM_HOTKEY (int wParam, int lParam) { 1685 1679 LRESULT result = super.WM_HOTKEY (wParam, lParam); 1686 if (result !is null) return result; 1687 if (OS.IsSP) { 1688 /* 1689 * Feature on WinCE SP. The Back key is either used to close 1690 * the foreground Dialog or used as a regular Back key in an EDIT 1691 * control. The article 'Back Key' in MSDN for Smartphone 1692 * describes how an application should handle it. The 1693 * workaround is to override the Back key when creating 1694 * the menubar and handle it based on the style of the Shell. 1695 * If the Shell has the DWT.CLOSE style, close the Shell. 1696 * Otherwise, send the Back key to the window with focus. 1697 */ 1698 if (((lParam >> 16) & 0xFFFF) is OS.VK_ESCAPE) { 1699 if ((style & DWT.CLOSE) !is 0) { 1700 OS.PostMessage (handle, OS.WM_CLOSE, 0, 0); 1701 } else { 1702 OS.SHSendBackToFocusWindow (OS.WM_HOTKEY, wParam, lParam); 1703 } 1704 return LRESULT.ZERO; 1680 if (result !is LRESULT.NULL) return result; 1681 static if( OS.IsWinCE ){ 1682 if (OS.IsSP_) { 1683 /* 1684 * Feature on WinCE SP. The Back key is either used to close 1685 * the foreground Dialog or used as a regular Back key in an EDIT 1686 * control. The article 'Back Key' in MSDN for Smartphone 1687 * describes how an application should handle it. The 1688 * workaround is to override the Back key when creating 1689 * the menubar and handle it based on the style of the Shell. 1690 * If the Shell has the DWT.CLOSE style, close the Shell. 1691 * Otherwise, send the Back key to the window with focus. 1692 */ 1693 if (((lParam >> 16) & 0xFFFF) is OS.VK_ESCAPE) { 1694 if ((style & DWT.CLOSE) !is 0) { 1695 OS.PostMessage (handle, OS.WM_CLOSE, 0, 0); 1696 } else { 1697 OS.SHSendBackToFocusWindow (OS.WM_HOTKEY, wParam, lParam); 1698 } 1699 return LRESULT.ZERO; 1700 } 1705 1701 } 1706 1702 } … … 1718 1714 Point location = getLocation (); 1719 1715 if (location.x is oldX && location.y is oldY) { 1720 return null;1716 return LRESULT.NULL; 1721 1717 } 1722 1718 oldX = location.x; … … 1728 1724 LRESULT WM_NCACTIVATE (int wParam, int lParam) { 1729 1725 LRESULT result = super.WM_NCACTIVATE (wParam, lParam); 1730 if (result !is null) return result;1726 if (result !is LRESULT.NULL) return result; 1731 1727 if (wParam is 0) { 1732 1728 if (display.lockActiveWindow) return LRESULT.ZERO; 1733 Control control = display.findControl ( lParam);1729 Control control = display.findControl (cast(HANDLE)lParam); 1734 1730 if (control !is null) { 1735 1731 Shell shell = getShell (); 1736 1732 Decorations decorations = control.menuShell (); 1737 1733 if (decorations.getShell () is shell) { 1738 if ( this instanceof Shell) return LRESULT.ONE;1734 if (cast(Shell)this) return LRESULT.ONE; 1739 1735 if (display.ignoreRestoreFocus) { 1740 1736 if (display.lastHittest !is OS.HTCLIENT) { … … 1745 1741 } 1746 1742 } 1747 if (!( this instanceof Shell)) {1748 inthwndShell = getShell().handle;1743 if (!(cast(Shell)this)) { 1744 auto hwndShell = getShell().handle; 1749 1745 OS.SendMessage (hwndShell, OS.WM_NCACTIVATE, wParam, lParam); 1750 1746 } … … 1754 1750 LRESULT WM_QUERYOPEN (int wParam, int lParam) { 1755 1751 LRESULT result = super.WM_QUERYOPEN (wParam, lParam); 1756 if (result !is null) return result;1752 if (result !is LRESULT.NULL) return result; 1757 1753 sendEvent (DWT.Deiconify); 1758 1754 // widget could be disposed at this point … … 1767 1763 1768 1764 LRESULT WM_SIZE (int wParam, int lParam) { 1769 LRESULT result = null;1765 LRESULT result = LRESULT.NULL; 1770 1766 bool changed = true; 1771 1767 if (resized) { … … 1802 1798 LRESULT WM_SYSCOMMAND (int wParam, int lParam) { 1803 1799 LRESULT result = super.WM_SYSCOMMAND (wParam, lParam); 1804 if (result !is null) return result;1805 if (!( this instanceof Shell)) {1800 if (result !is LRESULT.NULL) return result; 1801 if (!(cast(Shell)this)) { 1806 1802 int cmd = wParam & 0xFFF0; 1807 1803 switch (cmd) { … … 1821 1817 LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) { 1822 1818 LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam); 1823 if (result !is null) return result;1819 if (result !is LRESULT.NULL) return result; 1824 1820 if (display.lockActiveWindow) { 1825 WINDOWPOS lpwp = new WINDOWPOS ();1826 OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof);1821 WINDOWPOS* lpwp = cast(WINDOWPOS*)lParam; 1822 //OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof); 1827 1823 lpwp.flags |= OS.SWP_NOZORDER; 1828 OS.MoveMemory (lParam,lpwp, WINDOWPOS.sizeof);1824 //OS.MoveMemory (lParam, &lpwp, WINDOWPOS.sizeof); 1829 1825 } 1830 1826 return result; … … 1832 1828 1833 1829 } 1834 ++/dwt/widgets/Display.d
r37 r39 211 211 212 212 /* Startup info */ 213 static STARTUPINFO lpStartupInfo;213 static STARTUPINFO* lpStartupInfo; 214 214 static this() { 215 215 static if (!OS.IsWinCE) { 216 //lpStartupInfo = new STARTUPINFO ();216 lpStartupInfo = new STARTUPINFO (); 217 217 lpStartupInfo.cb = STARTUPINFO.sizeof; 218 OS.GetStartupInfo ( &lpStartupInfo);218 OS.GetStartupInfo (lpStartupInfo); 219 219 } 220 220 } … … 3388 3388 public bool readAndDispatch () { 3389 3389 checkDevice (); 3390 //lpStartupInfo = null;3390 lpStartupInfo = null; 3391 3391 drawMenuBars (); 3392 3392 runPopups (); dwt/widgets/Menu.d
r35 r39 16 16 import dwt.widgets.Decorations; 17 17 import dwt.widgets.MenuItem; 18 import dwt.internal.win32.OS; 18 19 1
