comparison dwt/widgets/Tracker.d @ 213:36f5cb12e1a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Sat, 17 May 2008 17:34:28 +0200
parents 6f75fdfa1bcd
children 8efa9bb96c53
comparison
equal deleted inserted replaced
212:ab60f3309436 213:36f5cb12e1a2
53 public class Tracker : Widget { 53 public class Tracker : Widget {
54 Control parent; 54 Control parent;
55 bool tracking, cancelled, stippled; 55 bool tracking, cancelled, stippled;
56 Rectangle [] rectangles, proportions; 56 Rectangle [] rectangles, proportions;
57 Rectangle bounds; 57 Rectangle bounds;
58 HCURSOR resizeCursor, clientCursor; 58 HCURSOR resizeCursor;
59 Cursor clientCursor;
59 int cursorOrientation = DWT.NONE; 60 int cursorOrientation = DWT.NONE;
60 bool inEvent = false; 61 bool inEvent = false;
61 HWND hwndTransparent; 62 HWND hwndTransparent;
62 WNDPROC oldProc; 63 WNDPROC oldProc;
63 int oldX, oldY; 64 int oldX, oldY;
505 width, height, 506 width, height,
506 null, 507 null,
507 null, 508 null,
508 OS.GetModuleHandle (null), 509 OS.GetModuleHandle (null),
509 null); 510 null);
510 oldProc = cast(WNDPROC) OS.GetWindowLong (hwndTransparent, OS.GWL_WNDPROC); 511 oldProc = cast(WNDPROC) OS.GetWindowLongPtr (hwndTransparent, OS.GWLP_WNDPROC);
511 //newProc = new Callback (this, "transparentProc", 4); //$NON-NLS-1$ 512 //newProc = new Callback (this, "transparentProc", 4); //$NON-NLS-1$
512 //int newProcAddress = newProc.getAddress (); 513 //int newProcAddress = newProc.getAddress ();
513 //if (newProcAddress is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS); 514 //if (newProcAddress is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
514 OS.SetWindowLong (hwndTransparent, OS.GWL_WNDPROC, cast(int) &transparentFunc ); 515 OS.SetWindowLongPtr (hwndTransparent, OS.GWLP_WNDPROC, cast(LONG_PTR) &transparentFunc );
515 516
516 //PORTING_FIXME: Vista version 517 //PORTING_FIXME: Vista version
517 version( VISTA ) if (isVista) { 518 version( VISTA ) if (isVista) {
518 OS.SetLayeredWindowAttributes (hwndTransparent, 0xFFFFFF, cast(byte)0xFF, OS.LWA_COLORKEY | OS.LWA_ALPHA); 519 OS.SetLayeredWindowAttributes (hwndTransparent, 0xFFFFFF, cast(byte)0xFF, OS.LWA_COLORKEY | OS.LWA_ALPHA);
519 } 520 }
786 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 787 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
787 * </ul> 788 * </ul>
788 */ 789 */
789 public void setCursor(Cursor newCursor) { 790 public void setCursor(Cursor newCursor) {
790 checkWidget(); 791 checkWidget();
791 clientCursor = null; 792 clientCursor = newCursor;
792 if (newCursor !is null) { 793 if (newCursor !is null) {
793 clientCursor = newCursor.handle; 794 if (inEvent) OS.SetCursor (clientCursor.handle);
794 if (inEvent) OS.SetCursor (clientCursor);
795 } 795 }
796 } 796 }
797 797
798 /** 798 /**
799 * Specifies the rectangles that should be drawn, expressed relative to the parent 799 * Specifies the rectangles that should be drawn, expressed relative to the parent
856 case OS.WM_NCHITTEST: 856 case OS.WM_NCHITTEST:
857 if (inEvent) return OS.HTTRANSPARENT; 857 if (inEvent) return OS.HTTRANSPARENT;
858 break; 858 break;
859 case OS.WM_SETCURSOR: 859 case OS.WM_SETCURSOR:
860 if (clientCursor !is null) { 860 if (clientCursor !is null) {
861 OS.SetCursor (clientCursor); 861 OS.SetCursor (clientCursor.handle);
862 return 1; 862 return 1;
863 } 863 }
864 if (resizeCursor !is null) { 864 if (resizeCursor !is null) {
865 OS.SetCursor (resizeCursor); 865 OS.SetCursor (resizeCursor);
866 return 1; 866 return 1;
904 OS.EndPaint (hwnd, &ps); 904 OS.EndPaint (hwnd, &ps);
905 return 0; 905 return 0;
906 } 906 }
907 default: 907 default:
908 } 908 }
909 return OS.CallWindowProc (oldProc, hwnd, msg, wParam, lParam); 909 return oldProc( hwnd, msg, wParam, lParam);
910 } 910 }
911 911
912 void update () { 912 void update () {
913 if (parent is null && !OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) return; 913 if (parent is null && !OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) return;
914 if (parent !is null) { 914 if (parent !is null) {
1061 cancelled = true; 1061 cancelled = true;
1062 tracking = false; 1062 tracking = false;
1063 return result; 1063 return result;
1064 } 1064 }
1065 1065
1066 LRESULT wmMouse (int message, int wParam, int lParam) { 1066 LRESULT wmMouse (int message, int /*long*/ wParam, int /*long*/ lParam) {
1067 bool isMirrored = parent !is null && (parent.style & DWT.MIRRORED) !is 0; 1067 bool isMirrored = parent !is null && (parent.style & DWT.MIRRORED) !is 0;
1068 int newPos = OS.GetMessagePos (); 1068 int newPos = OS.GetMessagePos ();
1069 int newX = cast(short) (newPos & 0xFFFF); 1069 int newX = OS.GET_X_LPARAM (newPos);
1070 int newY = cast(short) (newPos >> 16); 1070 int newY = OS.GET_Y_LPARAM (newPos);
1071 if (newX !is oldX || newY !is oldY) { 1071 if (newX !is oldX || newY !is oldY) {
1072 Rectangle [] oldRectangles = rectangles; 1072 Rectangle [] oldRectangles = rectangles;
1073 bool oldStippled = stippled; 1073 bool oldStippled = stippled;
1074 Rectangle [] rectsToErase = new Rectangle [rectangles.length]; 1074 Rectangle [] rectsToErase = new Rectangle [rectangles.length];
1075 for (int i = 0; i < rectangles.length; i++) { 1075 for (int i = 0; i < rectangles.length; i++) {