Changeset 40:3052439af4b5
- Timestamp:
- 02/01/08 14:19:46 (1 year ago)
- Files:
-
- dwt/dwthelper/utils.d (modified) (1 diff)
- dwt/internal/win32/OS.d (modified) (4 diffs)
- dwt/widgets/Canvas.d (modified) (1 diff)
- dwt/widgets/Decorations.d (modified) (1 diff)
- dwt/widgets/Menu.d (modified) (1 diff)
- dwt/widgets/Shell.d (modified) (94 diffs)
- dwt/widgets/ToolTip.d (modified) (3 diffs)
- dwt/widgets/Widget.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/dwthelper/utils.d
r33 r40 138 138 } 139 139 140 struct GCStats { 141 size_t poolsize; // total size of pool 142 size_t usedsize; // bytes allocated 143 size_t freeblocks; // number of blocks marked FREE 144 size_t freelistsize; // total of memory on free lists 145 size_t pageblocks; // number of blocks marked PAGE 146 } 147 148 extern(System) GCStats gc_stats(); 149 150 size_t RuntimeTotalMemory(){ 151 GCStats s = gc_stats(); 152 return s.poolsize; 153 } 140 154 141 155 142 156 143 157 144 dwt/internal/win32/OS.d
r39 r40 72 72 } 73 73 74 public static const BOOL IsPPC_ ;74 public static const BOOL IsPPC_ = false; 75 75 public static const BOOL IsHPC = false; 76 76 … … 120 120 IsWinNT = (info.dwPlatformId is VER_PLATFORM_WIN32_NT); 121 121 //IsSP_ = false; 122 IsPPC_ = false;122 //IsPPC_ = false; 123 123 //IsHPC = false; 124 124 IsDBLocale = false; … … 1000 1000 public static const int LOGPIXELSX = 0x58; 1001 1001 public static const int LOGPIXELSY = 0x5a; 1002 public static const int LPSTR_TEXTCALLBACK =0xffffffff;1002 public static const TCHAR* LPSTR_TEXTCALLBACK = cast(TCHAR*)0xffffffff; 1003 1003 public static const int LR_DEFAULTCOLOR = 0x0; 1004 1004 public static const int LR_SHARED = 0x8000; … … 4195 4195 alias WINAPI.GdiSetBatchLimit GdiSetBatchLimit; 4196 4196 alias WINAPI.GetACP GetACP; 4197 alias STDWIN.GetAsyncKeyState GetAsyncKeyState; 4197 4198 alias WINAPI.GetActiveWindow GetActiveWindow; 4198 4199 alias WINAPI.GetBkColor GetBkColor; dwt/widgets/Canvas.d
r38 r40 51 51 52 52 alias Composite.drawBackground drawBackground; 53 alias Composite.windowProc windowProc; 53 54 54 55 Caret caret; dwt/widgets/Decorations.d
r39 r40 113 113 114 114 public class Decorations : Canvas { 115 116 alias Canvas.windowProc windowProc; 117 115 118 Image image, smallImage, largeImage; 116 119 Image [] images; dwt/widgets/Menu.d
r39 r40 35 35 void fixMenus (Decorations newParent) ; 36 36 public bool isEnabled () ; 37 public bool getEnabled () ; 37 38 } 38 39 /++ dwt/widgets/Shell.d
r39 r40 11 11 module dwt.widgets.Shell; 12 12 13 import dwt.widgets.Decorations;14 import dwt.widgets.Control;15 import dwt.widgets.Menu;16 import dwt.widgets.ToolTip;17 import dwt.internal.win32.OS;18 19 class Shell : Decorations {20 HIMC hIMC;21 HWND hwndMDIClient_;22 //, lpstrTip, toolTipHandle, balloonTipHandle;23 Menu activeMenu;24 void checkWidget ();25 void updateModal () ;26 void fixShell (Shell newShell, Control control) ;27 void setActiveControl (Control control) ;28 void register () ;29 void releaseBrushes () ;30 void releaseChildren (bool destroy) ;31 void setToolTipText (HWND hwnd, char[] text) ;32 void fixToolTip () ;33 ToolTip findToolTip (int id) ;34 void setToolTipTitle (HWND hwndToolTip, char[] text, HICON icon) ;35 HWND hwndMDIClient () ;36 }37 /++38 13 import dwt.DWT; 39 14 import dwt.DWTException; … … 44 19 import dwt.graphics.Region; 45 20 import dwt.internal.win32.OS; 21 22 import dwt.widgets.Composite; 23 import dwt.widgets.Decorations; 24 import dwt.widgets.Control; 25 import dwt.widgets.Menu; 26 import dwt.widgets.ToolTip; 27 import dwt.widgets.Display; 28 import dwt.widgets.TypedListener; 29 30 import dwt.dwthelper.utils; 46 31 47 32 /** … … 141 126 * @see DWT 142 127 */ 143 public class Shell extendsDecorations {128 public class Shell : Decorations { 144 129 Menu activeMenu; 145 130 ToolTip [] toolTips; 146 int hIMC, hwndMDIClient, lpstrTip, toolTipHandle, balloonTipHandle; 131 HIMC hIMC; 132 HWND hwndMDIClient_; 133 TCHAR* lpstrTip; 134 HANDLE toolTipHandle_; 135 HANDLE balloonTipHandle_; 147 136 int minWidth = DWT.DEFAULT, minHeight = DWT.DEFAULT; 148 int[] brushes;137 HBRUSH [] brushes; 149 138 bool showWithParent; 150 String toolTitle, balloonTitle; 151 int toolIcon, balloonIcon; 152 int windowProc; 139 char[] toolTitle, balloonTitle; 140 HICON toolIcon; 141 HICON balloonIcon; 142 alias extern(Windows) int function(HWND, uint, uint, int) TWindowProc; 143 TWindowProc windowProc_; 153 144 Control lastActive, lockToolTipControl; 154 SHACTIVATEINFO psai; 145 static if( OS.IsWinCE ){ 146 SHACTIVATEINFO psai; 147 } 155 148 Region region; 156 static /*final*/ int ToolTipProc; 157 static final int DialogProc; 158 static final TCHAR DialogClass = new TCHAR (0, OS.IsWinCE ? "Dialog" : "#32770", true); 159 final static int [] SYSTEM_COLORS = { 149 static /*final*/ TWindowProc ToolTipProc; 150 static const TWindowProc DialogProc; 151 static if( OS.IsWinCE ){ 152 static const TCHAR[] DialogClass = "Dialog\0"; 153 } 154 else{ 155 static const TCHAR[] DialogClass = "#32770\0"; 156 } 157 const static int [] SYSTEM_COLORS = [ 160 158 OS.COLOR_BTNFACE, 161 159 OS.COLOR_WINDOW, … … 164 162 OS.COLOR_HIGHLIGHT, 165 163 OS.COLOR_SCROLLBAR, 166 };164 ]; 167 165 final static int BRUSHES_SIZE = 32; 168 static {169 WNDCLASS lpWndClass = new WNDCLASS ();170 OS.GetClassInfo ( 0, DialogClass,lpWndClass);166 static this() { 167 WNDCLASS lpWndClass; 168 OS.GetClassInfo (null, DialogClass.ptr, &lpWndClass); 171 169 DialogProc = lpWndClass.lpfnWndProc; 172 170 } … … 181 179 * </ul> 182 180 */ 183 public Shell() {184 this ( (Display) null);181 public this () { 182 this (cast(Display) null); 185 183 } 186 184 … … 220 218 * @see DWT#SYSTEM_MODAL 221 219 */ 222 public Shell(int style) {223 this ( (Display) null, style);220 public this (int style) { 221 this (cast(Display) null, style); 224 222 } 225 223 … … 243 241 * </ul> 244 242 */ 245 public Shell(Display display) {243 public this (Display display) { 246 244 this (display, OS.IsWinCE ? DWT.NONE : DWT.SHELL_TRIM); 247 245 } … … 290 288 * @see DWT#SYSTEM_MODAL 291 289 */ 292 public Shell(Display display, int style) {293 this (display, null, style, 0, false);294 } 295 296 Shell (Display display, Shell parent, int style, inthandle, bool embedded) {290 public this (Display display, int style) { 291 this (display, null, style, null, false); 292 } 293 294 this (Display display, Shell parent, int style, HWND handle, bool embedded) { 297 295 super (); 298 296 checkSubclass (); … … 309 307 this.display = display; 310 308 this.handle = handle; 311 if (handle !is 0&& !embedded) {309 if (handle !is null && !embedded) { 312 310 state |= FOREIGN_HANDLE; 313 311 } … … 337 335 * </ul> 338 336 */ 339 public Shell(Shell parent) {337 public this (Shell parent) { 340 338 this (parent, OS.IsWinCE ? DWT.NONE : DWT.DIALOG_TRIM); 341 339 } … … 388 386 * @see DWT#SYSTEM_MODAL 389 387 */ 390 public Shell(Shell parent, int style) {391 this (parent !is null ? parent.display : null, parent, style, 0, false);388 public this (Shell parent, int style) { 389 this (parent !is null ? parent.display : null, parent, style, null, false); 392 390 } 393 391 … … 406 404 * @return a new shell object containing the specified display and handle 407 405 */ 408 public static Shell win32_new (Display display, inthandle) {406 public static Shell win32_new (Display display, HWND handle) { 409 407 return new Shell (display, null, DWT.NO_TRIM, handle, true); 410 408 } 411 409 412 public static Shell internal_new (Display display, inthandle) {410 public static Shell internal_new (Display display, HWND handle) { 413 411 return new Shell (display, null, DWT.NO_TRIM, handle, false); 414 412 } … … 454 452 } 455 453 456 intballoonTipHandle () {457 if (balloonTipHandle is 0) createBalloonTipHandle ();458 return balloonTipHandle ;459 } 460 461 int callWindowProc (inthwnd, int msg, int wParam, int lParam) {462 if (handle is 0) return 0;463 if (hwnd is toolTipHandle || hwnd is balloonTipHandle) {464 return OS.CallWindowProc (ToolTipProc,hwnd, msg, wParam, lParam);465 } 466 if (hwndMDIClient !is 0) {467 return OS.DefFrameProc (hwnd, hwndMDIClient, msg, wParam, lParam);468 } 469 if (windowProc !is 0) {470 return OS.CallWindowProc (windowProc,hwnd, msg, wParam, lParam);454 HANDLE balloonTipHandle () { 455 if (balloonTipHandle_ is null) createBalloonTipHandle (); 456 return balloonTipHandle_; 457 } 458 459 override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 460 if (handle is null) return LRESULT.ZERO; 461 if (hwnd is toolTipHandle_ || hwnd is balloonTipHandle_) { 462 return cast(LRESULT) ToolTipProc( hwnd, msg, wParam, lParam); 463 } 464 if (hwndMDIClient_ !is null) { 465 return cast(LRESULT) OS.DefFrameProc (hwnd, hwndMDIClient_, msg, wParam, lParam); 466 } 467 if (windowProc_ !is null) { 468 return cast(LRESULT) windowProc_( hwnd, msg, wParam, lParam); 471 469 } 472 470 if ((style & DWT.TOOL) !is 0) { 473 471 int trim = DWT.TITLE | DWT.CLOSE | DWT.MIN | DWT.MAX | DWT.BORDER | DWT.RESIZE; 474 if ((style & trim) is 0) return OS.DefWindowProc (hwnd, msg, wParam, lParam);472 if ((style & trim) is 0) return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); 475 473 } 476 474 if (parent !is null) { … … 478 476 case OS.WM_KILLFOCUS: 479 477 case OS.WM_SETFOCUS: 480 return OS.DefWindowProc (hwnd, msg, wParam, lParam);481 } 482 return OS.CallWindowProc (DialogProc,hwnd, msg, wParam, lParam);483 } 484 return OS.DefWindowProc (hwnd, msg, wParam, lParam);478 return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); 479 } 480 return cast(LRESULT) DialogProc( hwnd, msg, wParam, lParam); 481 } 482 return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); 485 483 } 486 484 … … 506 504 507 505 void createBalloonTipHandle () { 508 balloonTipHandle = OS.CreateWindowEx (506 balloonTipHandle_ = OS.CreateWindowEx ( 509 507 0, 510 new TCHAR (0, OS.TOOLTIPS_CLASS, true),508 StrToTCHARz( OS.TOOLTIPS_CLASS ), 511 509 null, 512 510 OS.TTS_ALWAYSTIP | OS.TTS_BALLOON, 513 511 OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0, 514 512 handle, 515 0,513 null, 516 514 OS.GetModuleHandle (null), 517 515 null); 518 if (balloonTipHandle is 0) error (DWT.ERROR_NO_HANDLES);519 if (ToolTipProc is 0) {520 ToolTipProc = OS.GetWindowLong (balloonTipHandle, OS.GWL_WNDPROC);516 if (balloonTipHandle_ is null) error (DWT.ERROR_NO_HANDLES); 517 if (ToolTipProc is null) { 518 ToolTipProc = cast(TWindowProc) OS.GetWindowLong (balloonTipHandle_, OS.GWL_WNDPROC); 521 519 } 522 520 /* … … 527 525 * a large value. 528 526 */ 529 OS.SendMessage (balloonTipHandle , OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);530 display.addControl (balloonTipHandle , this);531 OS.SetWindowLong (balloonTipHandle , OS.GWL_WNDPROC, display.windowProc);527 OS.SendMessage (balloonTipHandle_, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF); 528 display.addControl (balloonTipHandle_, this); 529 OS.SetWindowLong (balloonTipHandle_, OS.GWL_WNDPROC, display.windowProc); 532 530 } 533 531 534 532 void createHandle () { 535 bool embedded = handle !is 0&& (state & FOREIGN_HANDLE) is 0;533 bool embedded = handle !is null && (state & FOREIGN_HANDLE) is 0; 536 534 537 535 /* … … 547 545 */ 548 546 // if ((style & DWT.ON_TOP) !is 0) display.lockActiveWindow = true; 549 if (handle is 0|| embedded) {547 if (handle is null || embedded) { 550 548 super.createHandle (); 551 549 } else { … … 554 552 state |= THEME_BACKGROUND; 555 553 } 556 windowProc =OS.GetWindowLong (handle, OS.GWL_WNDPROC);554 windowProc_ = cast(TWindowProc) OS.GetWindowLong (handle, OS.GWL_WNDPROC); 557 555 } 558 556 … … 579 577 OS.SetWindowLong (handle, OS.GWL_STYLE, bits); 580 578 int flags = OS.SWP_DRAWFRAME | OS.SWP_NOMOVE | OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE; 581 SetWindowPos (handle, 0, 0, 0, 0, 0, flags);582 if (OS.IsWinCE) _setMaximized (true);583 if (OS.IsPPC) {579 SetWindowPos (handle, null, 0, 0, 0, 0, flags); 580 static if (OS.IsWinCE) _setMaximized (true); 581 static if (OS.IsPPC_) { 584 582 psai = new SHACTIVATEINFO (); 585 583 psai.cbSize = SHACTIVATEINFO.sizeof; … … 588 586 if (OS.IsDBLocale) { 589 587 hIMC = OS.ImmCreateContext (); 590 if (hIMC !is 0) OS.ImmAssociateContext (handle, hIMC);588 if (hIMC !is null) OS.ImmAssociateContext (handle, hIMC); 591 589 } 592 590 } … … 604 602 toolTip.id = id + Display.ID_START; 605 603 if (OS.IsWinCE) return; 606 TOOLINFO lpti = new TOOLINFO ();604 TOOLINFO lpti; 607 605 lpti.cbSize = TOOLINFO.sizeof; 608 606 lpti.hwnd = handle; … … 610 608 lpti.uFlags = OS.TTF_TRACK; 611 609 lpti.lpszText = OS.LPSTR_TEXTCALLBACK; 612 OS.SendMessage (toolTip.hwndToolTip (), OS.TTM_ADDTOOL, 0, lpti);610 OS.SendMessage (toolTip.hwndToolTip (), OS.TTM_ADDTOOL, 0, &lpti); 613 611 } 614 612 615 613 void createToolTipHandle () { 616 toolTipHandle = OS.CreateWindowEx (614 toolTipHandle_ = OS.CreateWindowEx ( 617 615 0, 618 new TCHAR (0, OS.TOOLTIPS_CLASS, true),616 StrToTCHARz( OS.TOOLTIPS_CLASS ), 619 617 null, 620 618 OS.TTS_ALWAYSTIP, 621 619 OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0, 622 620 handle, 623 0,621 null, 624 622 OS.GetModuleHandle (null), 625 623 null); 626 if (toolTipHandle is 0) error (DWT.ERROR_NO_HANDLES);627 if (ToolTipProc is 0) {628 ToolTipProc = OS.GetWindowLong (toolTipHandle, OS.GWL_WNDPROC);624 if (toolTipHandle_ is null) error (DWT.ERROR_NO_HANDLES); 625 if (ToolTipProc is null) { 626 ToolTipProc = cast(TWindowProc) OS.GetWindowLong (toolTipHandle_, OS.GWL_WNDPROC); 629 627 } 630 628 /* … … 635 633 * a large value. 636 634 */ 637 OS.SendMessage (toolTipHandle , OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);638 display.addControl (toolTipHandle , this);639 OS.SetWindowLong (toolTipHandle , OS.GWL_WNDPROC, display.windowProc);635 OS.SendMessage (toolTipHandle_, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF); 636 display.addControl (toolTipHandle_, this); 637 OS.SetWindowLong (toolTipHandle_, OS.GWL_WNDPROC, display.windowProc); 640 638 } 641 639 642 640 void deregister () { 643 641 super.deregister (); 644 if (toolTipHandle !is 0) display.removeControl (toolTipHandle);645 if (balloonTipHandle !is 0) display.removeControl (balloonTipHandle);642 if (toolTipHandle_ !is null) display.removeControl (toolTipHandle_); 643 if (balloonTipHandle_ !is null) display.removeControl (balloonTipHandle_); 646 644 } 647 645 … … 650 648 toolTips [toolTip.id - Display.ID_START] = null; 651 649 if (OS.IsWinCE) return; 652 if (balloonTipHandle !is 0) {653 TOOLINFO lpti = new TOOLINFO ();650 if (balloonTipHandle_ !is null) { 651 TOOLINFO lpti; 654 652 lpti.cbSize = TOOLINFO.sizeof; 655 653 lpti.uId = toolTip.id; 656 654 lpti.hwnd = handle; 657 OS.SendMessage (balloonTipHandle , OS.TTM_DELTOOL, 0,lpti);655 OS.SendMessage (balloonTipHandle_, OS.TTM_DELTOOL, 0, &lpti); 658 656 } 659 657 toolTip.id = -1; … … 697 695 } 698 696 699 intfindBrush (int value, int lbStyle) {697 HBRUSH findBrush (int value, int lbStyle) { 700 698 if (lbStyle is OS.BS_SOLID) { 701 699 for (int i=0; i<SYSTEM_COLORS.length; i++) { … … 705 703 } 706 704 } 707 if (brushes is null) brushes = new int[BRUSHES_SIZE];708 LOGBRUSH logBrush = new LOGBRUSH ();705 if (brushes is null) brushes = new HBRUSH [BRUSHES_SIZE]; 706 LOGBRUSH logBrush; 709 707 for (int i=0; i<brushes.length; i++) { 710 inthBrush = brushes [i];711 if (hBrush is 0) break;712 OS.GetObject (hBrush, LOGBRUSH.sizeof, logBrush);708 HBRUSH hBrush = brushes [i]; 709 if (hBrush is null) break; 710 OS.GetObject (hBrush, LOGBRUSH.sizeof, &logBrush); 713 711 switch (logBrush.lbStyle) { 714 712 case OS.BS_SOLID: … … 724 722 } 725 723 } 726 int length = brushes.length;727 int hBrush = brushes [--length];728 if (hBrush !is 0) OS.DeleteObject (hBrush);729 System.arraycopy (brushes, 0, brushes, 1, length );724 int length_ = brushes.length; 725 HBRUSH hBrush = brushes [--length_]; 726 if (hBrush !is null) OS.DeleteObject (hBrush); 727 System.arraycopy (brushes, 0, brushes, 1, length_); 730 728 switch (lbStyle) { 731 729 case OS.BS_SOLID: … … 733 731 break; 734 732 case OS.BS_PATTERN: 735 hBrush = OS.CreatePatternBrush ( value);733 hBrush = OS.CreatePatternBrush ( cast(HBITMAP) value); 736 734 break; 737 735 } … … 767 765 * shell before disposing or hiding the active shell. 768 766 */ 769 inthwndParent = OS.GetParent (handle);770 if (hwndParent !is 0&& handle is OS.GetActiveWindow ()) {767 auto hwndParent = OS.GetParent (handle); 768 if (hwndParent !is null && handle is OS.GetActiveWindow ()) { 771 769 if (!OS.IsWindowEnabled (hwndParent) && OS.IsWindowVisible (hwndParent)) { 772 770 OS.SetActiveWindow (hwndParent); … … 778 776 if (this is newShell) return; 779 777 if (control is lastActive) setActiveControl (null); 780 String toolTipText = control.toolTipText;778 char[] toolTipText = control.toolTipText_; 781 779 if (toolTipText !is null) { 782 780 control.setToolTipText (this, null); … … 798 796 */ 799 797 if (OS.COMCTL32_MAJOR >= 6) { 800 if (toolTipHandle is 0) return;801 TOOLINFO lpti = new TOOLINFO ();798 if (toolTipHandle_ is null) return; 799 TOOLINFO lpti; 802 800 lpti.cbSize = TOOLINFO.sizeof; 803 if (OS.SendMessage (toolTipHandle , OS.TTM_GETCURRENTTOOL, 0,lpti) !is 0) {801 if (OS.SendMessage (toolTipHandle_, OS.TTM_GETCURRENTTOOL, 0, &lpti) !is 0) { 804 802 if ((lpti.uFlags & OS.TTF_IDISHWND) !is 0) { 805 OS.SendMessage (toolTipHandle , OS.TTM_DELTOOL, 0,lpti);806 OS.SendMessage (toolTipHandle , OS.TTM_ADDTOOL, 0,lpti);803 OS.SendMessage (toolTipHandle_, OS.TTM_DELTOOL, 0, &lpti); 804 OS.SendMessage (toolTipHandle_, OS.TTM_ADDTOOL, 0, &lpti); 807 805 } 808 806 } … … 846 844 if (OS.IsIconic (handle)) return super.getBounds (); 847 845 } 848 RECT rect = new RECT ();849 OS.GetWindowRect (handle, rect);846 RECT rect; 847 OS.GetWindowRect (handle, &rect); 850 848 int width = rect.right - rect.left; 851 849 int height = rect.bottom - rect.top; … … 854 852 855 853 ToolTip getCurrentToolTip () { 856 if (toolTipHandle !is 0) {857 ToolTip tip = getCurrentToolTip (toolTipHandle );854 if (toolTipHandle_ !is null) { 855 ToolTip tip = getCurrentToolTip (toolTipHandle_); 858 856 if (tip !is null) return tip; 859 857 } 860 if (balloonTipHandle !is 0) {861 ToolTip tip = getCurrentToolTip (balloonTipHandle );858 if (balloonTipHandle_ !is null) { 859 ToolTip tip = getCurrentToolTip (balloonTipHandle_); 862 860 if (tip !is null) return tip; 863 861 } … … 865 863 } 866 864 867 ToolTip getCurrentToolTip ( inthwndToolTip) {868 if (hwndToolTip is 0) return null;865 ToolTip getCurrentToolTip (HWND hwndToolTip) { 866 if (hwndToolTip is null) return null; 869 867 if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, 0) !is 0) { 870 TOOLINFO lpti = new TOOLINFO ();868 TOOLINFO lpti; 871 869 lpti.cbSize = TOOLINFO.sizeof; 872 if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, lpti) !is 0) {870 if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, &lpti) !is 0) { 873 871 if ((lpti.uFlags & OS.TTF_IDISHWND) is 0) return findToolTip (lpti.uId); 874 872 } … … 902 900 checkWidget (); 903 901 if (!OS.IsDBLocale) return 0; 904 inthIMC = OS.ImmGetContext (handle);905 int [] lpfdwConversion = new int [1], lpfdwSentence = new int [1];906 bool open = OS.ImmGetOpenStatus (hIMC);907 if (open) open = OS.ImmGetConversionStatus (hIMC, lpfdwConversion,lpfdwSentence);902 auto hIMC = OS.ImmGetContext (handle); 903 uint lpfdwConversion, lpfdwSentence; 904 bool open = cast(bool) OS.ImmGetOpenStatus (hIMC); 905 if (open) open = cast(bool) OS.ImmGetConversionStatus (hIMC, &lpfdwConversion, &lpfdwSentence); 908 906 OS.ImmReleaseContext (handle, hIMC); 909 907 if (!open) return DWT.NONE; 910 908 int result = 0; 911 if ((lpfdwConversion [0]& OS.IME_CMODE_ROMAN) !is 0) result |= DWT.ROMAN;912 if ((lpfdwConversion [0]& OS.IME_CMODE_FULLSHAPE) !is 0) result |= DWT.DBCS;913 if ((lpfdwConversion [0]& OS.IME_CMODE_KATAKANA) !is 0) return result | DWT.PHONETIC;914 if ((lpfdwConversion [0]& OS.IME_CMODE_NATIVE) !is 0) return result | DWT.NATIVE;909 if ((lpfdwConversion & OS.IME_CMODE_ROMAN) !is 0) result |= DWT.ROMAN; 910 if ((lpfdwConversion & OS.IME_CMODE_FULLSHAPE) !is 0) result |= DWT.DBCS; 911 if ((lpfdwConversion & OS.IME_CMODE_KATAKANA) !is 0) return result | DWT.PHONETIC; 912 if ((lpfdwConversion & OS.IME_CMODE_NATIVE) !is 0) return result | DWT.NATIVE; 915 913 return result | DWT.ALPHA; 916 914 } … … 918 916 public Point getLocation () { 919 917 checkWidget (); 920 if (!OS.IsWinCE) {918 static if (!OS.IsWinCE) { 921 919 if (OS.IsIconic (handle)) { 922 920 return super.getLocation (); 923 921 } 924 922 } 925 RECT rect = new RECT ();926 OS.GetWindowRect (handle, rect);923 RECT rect; 924 OS.GetWindowRect (handle, &rect); 927 925 return new Point (rect.left, rect.top); 928 926 } … … 955 953 height = Math.max (height, OS.GetSystemMetrics (OS.SM_CYMINTRACK)); 956 954 } else { 957 RECT rect = new RECT ();955 RECT rect; 958 956 int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE); 959 957 int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE); 960 OS.AdjustWindowRectEx ( rect, bits1, false, bits2);958 OS.AdjustWindowRectEx (&rect, bits1, false, bits2); 961 959 height = Math.max (height, rect.bottom - rect.top); 962 960 } … … 994 992 if (OS.IsIconic (handle)) return super.getSize (); 995 993 } 996 RECT rect = new RECT ();997 OS.GetWindowRect (handle, rect);994 RECT rect; 995 OS.GetWindowRect (handle, &rect); 998 996 int width = rect.right - rect.left; 999 997 int height = rect.bottom - rect.top; … … 1051 1049 } 1052 1050 1053 inthwndMDIClient () {1054 if (hwndMDIClient is 0) {1051 HWND hwndMDIClient () { 1052 if (hwndMDIClient_ is null) { 1055 1053 int widgetStyle = OS.MDIS_ALLCHILDSTYLES | OS.WS_CHILD | OS.WS_CLIPCHILDREN | OS.WS_CLIPSIBLINGS; 1056 hwndMDIClient = OS.CreateWindowEx (1054 hwndMDIClient_ = OS.CreateWindowEx ( 1057 1055 0, 1058 new TCHAR (0, "MDICLIENT", true),1056 StrToTCHARz("MDICLIENT"), 1059 1057 null, 1060 1058 widgetStyle, 1061 1059 0, 0, 0, 0, 1062 1060 handle, 1063 0,1061 null, 1064 1062 OS.GetModuleHandle (null), 1065 1063 new CREATESTRUCT ()); 1066 // OS.ShowWindow (hwndMDIClient , OS.SW_SHOW);1067 } 1068 return hwndMDIClient ;1064 // OS.ShowWindow (hwndMDIClient_, OS.SW_SHOW); 1065 } 1066 return hwndMDIClient_; 1069 1067 } 1070 1068 … … 1092 1090 public void open () { 1093 1091 checkWidget (); 1094 STARTUPINFO lpStartUpInfo = Display.lpStartupInfo;1092 STARTUPINFO* lpStartUpInfo = Display.lpStartupInfo; 1095 1093 if (lpStartUpInfo is null || (lpStartUpInfo.dwFlags & OS.STARTF_USESHOWWINDOW) is 0) { 1096 1094 bringToTop (); … … 1122 1120 * most notably WM_ACTIVATE. 1123 1121 */ 1124 MSG msg = new MSG ();1122 MSG msg; 1125 1123 int flags = OS.PM_NOREMOVE | OS.PM_NOYIELD | OS.PM_QS_SENDMESSAGE; 1126 OS.PeekMessage ( msg, 0, 0, 0, flags);1124 OS.PeekMessage (&msg, null, 0, 0, flags); 1127 1125 if (!restoreFocus () && !traverseGroup (true)) setFocus (); 1128 1126 } … … 1130 1128 void register () { 1131 1129 super.register (); 1132 if (toolTipHandle !is 0) display.addControl (toolTipHandle, this);1133 if (balloonTipHandle !is 0) display.addControl (balloonTipHandle, this);1130 if (toolTipHandle_ !is null) display.addControl (toolTipHandle_, this); 1131 if (balloonTipHandle_ !is null) display.addControl (balloonTipHandle_, this); 1134 1132 } 1135 1133 … … 1137 1135 if (brushes !is null) { 1138 1136 for (int i=0; i<brushes.length; i++) { 1139 if (brushes [i] !is 0) OS.DeleteObject (brushes [i]);1137 if (brushes [i] !is null) OS.DeleteObject (brushes [i]); 1140 1138 } 1141 1139 } … … 1165 1163 void releaseHandle () { 1166 1164 super.releaseHandle (); 1167 hwndMDIClient = 0;1165 hwndMDIClient_ = null; 1168 1166 } 1169 1167 … … 1177 1175 activeMenu = null; 1178 1176 display.clearModal (this); 1179 if (lpstrTip !is 0) {1180 inthHeap = OS.GetProcessHeap ();1177 if (lpstrTip !is null) { 1178 auto hHeap = OS.GetProcessHeap (); 1181 1179 OS.HeapFree (hHeap, 0, lpstrTip); 1182 1180 } 1183 lpstrTip = 0;1184 toolTipHandle = balloonTipHandle = 0;1181 lpstrTip = null; 1182 toolTipHandle_ = balloonTipHandle_ = null; 1185 1183 if (OS.IsDBLocale) { 1186 if (hIMC !is 0) OS.ImmDestroyContext (hIMC);1184 if (hIMC !is null) OS.ImmDestroyContext (hIMC); 1187 1185 } 1188 1186 lastActive = null; … … 1225 1223 } 1226 1224 1227 LRESULT selectPalette ( inthPalette) {1228 inthDC = OS.GetDC (handle);1229 inthOld = OS.SelectPalette (hDC, hPalette, false);1225 LRESULT selectPalette (HPALETTE hPalette) { 1226 auto hDC = OS.GetDC (handle); 1227 auto hOld = OS.SelectPalette (hDC, hPalette, false); 1230 1228 int result = OS.RealizePalette (hDC); 1231 1229 if (result > 0) { … … 1337 1335 if (!OS.IsDBLocale) return; 1338 1336 bool imeOn = mode !is DWT.NONE && mode !is DWT.ROMAN; 1339 inthIMC = OS.ImmGetContext (handle);1337 auto hIMC = OS.ImmGetContext (handle); 1340 1338 OS.ImmSetOpenStatus (hIMC, imeOn); 1341 1339 if (imeOn) { 1342 int [] lpfdwConversion = new int [1], lpfdwSentence = new int [1];1343 if (OS.ImmGetConversionStatus (hIMC, lpfdwConversion,lpfdwSentence)) {1340 uint lpfdwConversion, lpfdwSentence; 1341 if (OS.ImmGetConversionStatus (hIMC, &lpfdwConversion, &lpfdwSentence)) { 1344 1342 int newBits = 0; 1345 1343 int oldBits = OS.IME_CMODE_NATIVE | OS.IME_CMODE_KATAKANA; … … 1363 1361 oldBits |= OS.IME_CMODE_ROMAN; 1364 1362 } 1365 lpfdwConversion [0] |= newBits; lpfdwConversion [0]&= ~oldBits;1366 OS.ImmSetConversionStatus (hIMC, lpfdwConversion [0], lpfdwSentence [0]);1363 lpfdwConversion |= newBits; lpfdwConversion &= ~oldBits; 1364 OS.ImmSetConversionStatus (hIMC, lpfdwConversion, lpfdwSentence); 1367 1365 } 1368 1366 } … … 1394 1392 heightLimit = OS.GetSystemMetrics (OS.SM_CYMINTRACK); 1395 1393 } else { 1396 RECT rect = new RECT ();1394 RECT rect; 1397 1395 int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE); 1398 1396 int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE); 1399 OS.AdjustWindowRectEx ( rect, bits1, false, bits2);1397 OS.AdjustWindowRectEx (&rect, bits1, false, bits2); 1400 1398 heightLimit = rect.bottom - rect.top; 1401 1399 } … … 1435 1433 1436 1434 void setItemEnabled (int cmd, bool enabled) { 1437 inthMenu = OS.GetSystemMenu (handle, false);1438 if (hMenu is 0) return;1435 auto hMenu = OS.GetSystemMenu (handle, false); 1436 if (hMenu is null) return; 1439 1437 int flags = OS.MF_ENABLED; 1440 1438 if (!enabled) flags = OS.MF_DISABLED | OS.MF_GRAYED; … … 1470 1468 if ((style & DWT.NO_TRIM) is 0) return; 1471 1469 if (region !is null && region.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); 1472 int hRegion = 0;1470 HRGN hRegion; 1473 1471 if (region !is null) { 1474 1472 hRegion = OS.CreateRectRgn (0, 0, 0, 0); … … 1479 1477 } 1480 1478 1481 void setToolTipText ( int hwnd, Stringtext) {1479 void setToolTipText (HWND hwnd, char[] text) { 1482 1480 if (OS.IsWinCE) return; 1483 TOOLINFO lpti = new TOOLINFO ();1481 TOOLINFO lpti; 1484 1482 lpti.cbSize = TOOLINFO.sizeof; 1485 1483 lpti.hwnd = handle; 1486 lpti.uId = hwnd;1487 inthwndToolTip = toolTipHandle ();1484 lpti.uId = cast(uint) hwnd; 1485 auto hwndToolTip = toolTipHandle (); 1488 1486 if (text is null) { 1489 OS.SendMessage (hwndToolTip, OS.TTM_DELTOOL, 0, lpti);1487 OS.SendMessage (hwndToolTip, OS.TTM_DELTOOL, 0, cast(int)&lpti); 1490 1488 } else { 1491 if (OS.SendMessage (hwndToolTip, OS.TTM_GETTOOLINFO, 0, lpti) !is 0) {1489 if (OS.SendMessage (hwndToolTip, OS.TTM_GETTOOLINFO, 0, cast(int)&lpti) !is 0) { 1492 1490 OS.SendMessage (hwndToolTip, OS.TTM_UPDATE, 0, 0); 1493 1491 } else { 1494 1492 lpti.uFlags = OS.TTF_IDISHWND | OS.TTF_SUBCLASS; 1495 1493 lpti.lpszText = OS.LPSTR_TEXTCALLBACK; 1496 OS.SendMessage (hwndToolTip, OS.TTM_ADDTOOL, 0, lpti);1497 } 1498 } 1499 } 1500 1501 void setToolTipText (NMTTDISPINFO lpnmtdi, byte [] buffer) {1494 OS.SendMessage (hwndToolTip, OS.TTM_ADDTOOL, 0, cast(int)&lpti); 1495 } 1496 } 1497 } 1498 1499 void setToolTipText (NMTTDISPINFO* lpnmtdi, byte [] buffer) { 1502 1500 /* 1503 1501 * Ensure that the current position of the mouse … … 1507 1505 */ 1508 1506 if (!hasCursor ()) return; 1509 inthHeap = OS.GetProcessHeap ();1510 if (lpstrTip !is 0) OS.HeapFree (hHeap, 0, lpstrTip);1507 auto hHeap = OS.GetProcessHeap (); 1508 if (lpstrTip !is null) OS.HeapFree (hHeap, 0, lpstrTip); 1511 1509 int byteCount = buffer.length; 1512 lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 1513 OS.MoveMemory (lpstrTip, buffer, byteCount); 1510 lpstrTip = cast(TCHAR*)OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 1511 (cast(byte*)lpstrTip)[ 0 .. byteCount ] = buffer; 1512 //OS.MoveMemory (lpstrTip, buffer, byteCount); 1514 1513 lpnmtdi.lpszText = lpstrTip; 1515 1514 } … … 1523 1522 */ 1524 1523 if (!hasCursor ()) return; 1525 inthHeap = OS.GetProcessHeap ();1526 if (lpstrTip !is 0) OS.HeapFree (hHeap, 0, lpstrTip);1524 auto hHeap = OS.GetProcessHeap (); 1525 if (lpstrTip !is null) OS.HeapFree (hHeap, 0, lpstrTip); 1527 1526 int byteCount = buffer.length * 2; 1528 lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 1529 OS.MoveMemory (lpstrTip, buffer, byteCount); 1527 lpstrTip = cast(TCHAR*)OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 1528 (cast(char*)lpstrTip)[ 0 .. byteCount ] = buffer; 1529 //OS.MoveMemory (lpstrTip, buffer, byteCount); 1530 1530 lpnmtdi.lpszText = lpstrTip; 1531 1531 } 1532 1532 1533 void setToolTipTitle ( int hwndToolTip, String text, inticon) {1533 void setToolTipTitle (HWND hwndToolTip, char[] text, HICON icon) { 1534 1534 /* 1535 1535 * Bug in Windows. For some reason, when TTM_SETTITLE … … 1548 1548 * NOTE: This only happens on Vista. 1549 1549 */ 1550 if (hwndToolTip !is toolTipHandle && hwndToolTip !is balloonTipHandle) {1550 if (hwndToolTip !is toolTipHandle_ && hwndToolTip !is balloonTipHandle_) { 1551 1551 return; 1552 1552 } 1553 if (hwndToolTip is toolTipHandle ) {1554 if (text is toolTitle || (toolTitle !is null && toolTitle .equals (text))) {1553 if (hwndToolTip is toolTipHandle_) { 1554 if (text is toolTitle || (toolTitle !is null && toolTitle ==/*eq*/text )) { 1555 1555 if (icon is toolIcon) return; 1556 1556 } … … 1558 1558 toolIcon = icon; 1559 1559 } else { 1560 if (hwndToolTip is balloonTipHandle ) {1561 if (text is balloonTitle || (balloonTitle !is null && balloonTitle .equals (text))) {1560 if (hwndToolTip is balloonTipHandle_) { 1561 if (text is balloonTitle || (balloonTitle !is null && balloonTitle==/*eq*/text)) { 1562 1562 if (icon is toolIcon) return; 1563 1563 } … … 1567 1567 } 1568 1568 if (text !is null) { 1569 TCHAR pszTitle = new TCHAR (getCodePage (), text, true); 1570 OS.SendMessage (hwndToolTip, OS.TTM_SETTITLE, icon, pszTitle); 1569 static if( OS.IsUnicode ){ 1570 TCHAR* pszTitle = StrToTCHARz( text); 1571 } 1572 else { 1573 TCHAR* pszTitle = StrToTCHARz( text, getCodePage ()); 1574 } 1575 OS.SendMessage (hwndToolTip, OS.TTM_SETTITLE, icon, cast(int)pszTitle); 1571 1576 } else { 1572 1577 OS.SendMessage (hwndToolTip, OS.TTM_SETTITLE, 0, 0); … … 1600 1605 if (isDisposed ()) return; 1601 1606 } 1602 inthwndShell = OS.GetActiveWindow ();1603 if (hwndShell is 0) {1607 auto hwndShell = OS.GetActiveWindow (); 1608 if (hwndShell is null) { 1604 1609 if (parent !is null) hwndShell = parent.handle; 1605 1610 } 1606 if (hwndShell !is 0) {1611 if (hwndShell !is null) { 1607 1612 OS.SendMessage (hwndShell, OS.WM_CANCELMODE, 0, 0); 1608 1613 } … … 1636 1641 void subclass () { 1637 1642 super.subclass (); 1638 if (ToolTipProc !is 0) {1643 if (ToolTipProc !is null) { 1639 1644 int newProc = display.windowProc; 1640 if (toolTipHandle !is 0) {1641 OS.SetWindowLong (toolTipHandle , OS.GWL_WNDPROC, newProc);1642 } 1643 if (balloonTipHandle !is 0) {1644 OS.SetWindowLong (balloonTipHandle , OS.GWL_WNDPROC, newProc);1645 } 1646 } 1647 } 1648 1649 inttoolTipHandle () {1650 if (toolTipHandle is 0) createToolTipHandle ();1651 return toolTipHandle ;1652 } 1653 1654 bool translateAccelerator (MSG msg) {1645 if (toolTipHandle_ !is null) { 1646 OS.SetWindowLong (toolTipHandle_, OS.GWL_WNDPROC, newProc); 1647 } 1648 if (balloonTipHandle_ !is null) { 1649 OS.SetWindowLong (balloonTipHandle_, OS.GWL_WNDPROC, newProc); 1650 } 1651 } 1652 } 1653 1654 HANDLE toolTipHandle () { 1655 if (toolTipHandle_ is null) createToolTipHandle (); 1656 return toolTipHandle_; 1657 } 1658 1659 bool translateAccelerator (MSG* msg) { 1655 1660 if (!isEnabled () || !isActive ()) return false; 1656 1661
