Mercurial > projects > dynamin
comparison dynamin/gui/windows_window.d @ 106:acdbb30fee7e
Port to D2.
Most of the effort was dealing with immutable and const.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Mon, 17 Dec 2012 23:41:50 -0600 |
parents | 97997a544ac0 |
children |
comparison
equal
deleted
inserted
replaced
105:97997a544ac0 | 106:acdbb30fee7e |
---|---|
47 // Windows NT is 4.0 | 47 // Windows NT is 4.0 |
48 OSVERSIONINFO info; | 48 OSVERSIONINFO info; |
49 info.dwOSVersionInfoSize = OSVERSIONINFO.sizeof; | 49 info.dwOSVersionInfoSize = OSVERSIONINFO.sizeof; |
50 GetVersionEx(&info); | 50 GetVersionEx(&info); |
51 DWORD major, minor; | 51 DWORD major, minor; |
52 switch(ver) { | 52 final switch(ver) { |
53 case WindowsVersion.Windows95: major = 4; minor = 0; break; | 53 case WindowsVersion.Windows95: major = 4; minor = 0; break; |
54 case WindowsVersion.Windows98: major = 4; minor = 10; break; | 54 case WindowsVersion.Windows98: major = 4; minor = 10; break; |
55 case WindowsVersion.WindowsMe: major = 4; minor = 90; break; | 55 case WindowsVersion.WindowsMe: major = 4; minor = 90; break; |
56 case WindowsVersion.Windows2000: major = 5; minor = 0; break; | 56 case WindowsVersion.Windows2000: major = 5; minor = 0; break; |
57 case WindowsVersion.WindowsXP: major = 5; minor = 1; break; | 57 case WindowsVersion.WindowsXP: major = 5; minor = 1; break; |
336 GetProcAddress(uxLib, "CloseThemeData"); | 336 GetProcAddress(uxLib, "CloseThemeData"); |
337 _DrawThemeBackground = cast(typeof(_DrawThemeBackground)) | 337 _DrawThemeBackground = cast(typeof(_DrawThemeBackground)) |
338 GetProcAddress(uxLib, "DrawThemeBackground"); | 338 GetProcAddress(uxLib, "DrawThemeBackground"); |
339 } | 339 } |
340 } | 340 } |
341 HTHEME[string] cache; | 341 HTHEME[mstring] cache; |
342 // opens an HTHEME for the specified controlName and caches it | 342 // opens an HTHEME for the specified controlName and caches it |
343 // next time, just returns the HTHEME from the cache | 343 // next time, just returns the HTHEME from the cache |
344 HTHEME getHTHEME(string controlName) { | 344 HTHEME getHTHEME(string controlName) { |
345 HTHEME* hthemePtr = controlName in cache; | 345 HTHEME* hthemePtr = controlName in cache; |
346 HTHEME htheme = controlName in cache; | 346 HTHEME htheme = controlName in cache; |
513 scope args = new MouseEventArgs( | 513 scope args = new MouseEventArgs( |
514 cast(short)LOWORD(lParam)+c.borderSize.left, | 514 cast(short)LOWORD(lParam)+c.borderSize.left, |
515 cast(short)HIWORD(lParam)+c.borderSize.top, button); | 515 cast(short)HIWORD(lParam)+c.borderSize.top, button); |
516 func(args); | 516 func(args); |
517 } | 517 } |
518 void snapSide(inout int sideToSnap, float side1, float side2) { | 518 void snapSide(ref int sideToSnap, float side1, float side2) { |
519 if(sideToSnap >= side1-c.snapDistance && sideToSnap <= side1+c.snapDistance) | 519 if(sideToSnap >= side1-c.snapDistance && sideToSnap <= side1+c.snapDistance) |
520 sideToSnap = cast(int)side1; | 520 sideToSnap = cast(int)side1; |
521 if(sideToSnap >= side2-c.snapDistance && sideToSnap <= side2+c.snapDistance) | 521 if(sideToSnap >= side2-c.snapDistance && sideToSnap <= side2+c.snapDistance) |
522 sideToSnap = cast(int)side2; | 522 sideToSnap = cast(int)side2; |
523 } | 523 } |
524 auto emptyFunc = (Rect snapRect) {}; | 524 void delegate(Rect snapRect) emptyFunc = (Rect snapRect) { }; |
525 // used to snap vertical sides, left and right | 525 // used to snap vertical sides, left and right |
526 void snapVSide(inout int side, RECT* rect, void delegate(Rect snapRect) func = emptyFunc) { | 526 void snapVSide(ref int side, RECT* rect, void delegate(Rect snapRect) func = emptyFunc) { |
527 if(c.snapRects is null) | 527 if(c.snapRects is null) |
528 return; | 528 return; |
529 foreach(snapRect; c.snapRects) { | 529 foreach(snapRect; c.snapRects) { |
530 if(rect.bottom >= snapRect.y && rect.top <= snapRect.bottom) { | 530 if(rect.bottom >= snapRect.y && rect.top <= snapRect.bottom) { |
531 snapSide(side, snapRect.x, snapRect.right); | 531 snapSide(side, snapRect.x, snapRect.right); |
532 func(snapRect); | 532 func(snapRect); |
533 } | 533 } |
534 } | 534 } |
535 } | 535 } |
536 // used to snap horizontal sides, top and bottom | 536 // used to snap horizontal sides, top and bottom |
537 void snapHSide(inout int side, RECT* rect, void delegate(Rect snapRect) func = emptyFunc) { | 537 void snapHSide(ref int side, RECT* rect, void delegate(Rect snapRect) func = emptyFunc) { |
538 if(c.snapRects is null) | 538 if(c.snapRects is null) |
539 return; | 539 return; |
540 foreach(snapRect; c.snapRects) { | 540 foreach(snapRect; c.snapRects) { |
541 if(rect.right >= snapRect.x && rect.left <= snapRect.right) { | 541 if(rect.right >= snapRect.x && rect.left <= snapRect.right) { |
542 snapSide(side, snapRect.y, snapRect.bottom); | 542 snapSide(side, snapRect.y, snapRect.bottom); |