Changeset 193 for trunk/src


Ignore:
Timestamp:
Oct 10, 2009, 6:56:48 PM (16 years ago)
Author:
lpino
Message:
  • More mouse events and other small changes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/Control.java

    r190 r193  
    555555        hps = this.hps;
    556556    }
    557 //     System.out.println("Control::drawBackground -> xLeft = " + rcl.xLeft);
    558 //     System.out.println("Control::drawBackground -> xRight = " + rcl.xRight);
    559 //     System.out.println("Control::drawBackground -> yBottom = " + rcl.yBottom);
    560 //     System.out.println("Control::drawBackground -> yTop = " + rcl.yTop);
    561557    OS.WinFillRect (hps, rcl, getBackgroundPixel ());
    562558}
     
    863859 */
    864860//@@TODO(dmik)
    865 //public Menu getMenu () {
    866 //      checkWidget ();
    867 //      return menu;
    868 //}
     861public Menu getMenu () {
     862      checkWidget ();
     863      return menu;
     864}
    869865
    870866/**
     
    29532949    switch (msg) {
    29542950//        case OS.WM_ADJUSTWINDOWPOS: result = WM_ADJUSTWINDOWPOS (mp1, mp2); break;
    2955 //        case OS.WM_BUTTON2DBLCLK: result = WM_BUTTON2DBLCLK (mp1, mp2); break;
    29562951        case OS.WM_BUTTON1DOWN: result = WM_BUTTON1DOWN (mp1, mp2); break;
    29572952        case OS.WM_BUTTON1UP: result = WM_BUTTON1UP (mp1, mp2); break;
     2953        case OS.WM_BUTTON2DBLCLK: result = WM_BUTTON2DBLCLK (mp1, mp2); break;
     2954        case OS.WM_BUTTON2DOWN: result = WM_BUTTON2DOWN (mp1, mp2); break;
     2955        case OS.WM_BUTTON2UP: result = WM_BUTTON2UP (mp1, mp2); break;
     2956        case OS.WM_BUTTON3DBLCLK: result = WM_BUTTON3DBLCLK (mp1, mp2); break;
     2957        case OS.WM_BUTTON3DOWN: result = WM_BUTTON3DOWN (mp1, mp2); break;
     2958        case OS.WM_BUTTON3UP: result = WM_BUTTON3UP (mp1, mp2); break;
    29582959//        case OS.WM_BUTTON1CLICK: result = WM_BUTTON1CLICK (mp1, mp2); break;
    29592960        case OS.WM_CALCVALIDRECTS: result = WM_CALCVALIDRECTS (mp1, mp2); break;
     
    29912992//        case OS.WM_KEYUP: result = WM_KEYUP (wParam, lParam); break;
    29922993        case OS.WM_BUTTON1DBLCLK: result = WM_BUTTON1DBLCLK (mp1, mp2); break;
    2993 //        case OS.WM_LBUTTONDOWN: result = WM_LBUTTONDOWN (wParam, lParam); break;
    2994 //        case OS.WM_LBUTTONUP: result = WM_LBUTTONUP (wParam, lParam); break;
    2995 //        case OS.WM_MBUTTONDBLCLK: result = WM_MBUTTONDBLCLK (wParam, lParam); break;
    2996 //        case OS.WM_MBUTTONDOWN: result = WM_MBUTTONDOWN (wParam, lParam); break;
    2997 //        case OS.WM_MBUTTONUP: result = WM_MBUTTONUP (wParam, lParam); break;
    29982994        case OS.WM_MEASUREITEM: result = WM_MEASUREITEM (mp1, mp2); break;
    29992995//        case OS.WM_MENUCHAR: result = WM_MENUCHAR (wParam, lParam); break;
     
    30143010//        case OS.WM_PRINTCLIENT: result = WM_PRINTCLIENT (wParam, lParam); break;
    30153011//        case OS.WM_QUERYENDSESSION: result = WM_QUERYENDSESSION (wParam, lParam); break;
    3016 //        case OS.WM_RBUTTONDBLCLK: result = WM_RBUTTONDBLCLK (wParam, lParam); break;
    3017 //        case OS.WM_RBUTTONDOWN: result = WM_RBUTTONDOWN (wParam, lParam); break;
    3018 //        case OS.WM_RBUTTONUP: result = WM_RBUTTONUP (wParam, lParam); break;
    30193012//        case OS.WM_SETCURSOR: result = WM_SETCURSOR (wParam, lParam); break;
    30203013        case OS.WM_SETFOCUS: result = WM_SETFOCUS (mp1, mp2); break;
     
    33343327MRESULT WM_BUTTON1DBLCLK (int mp1, int mp2) {
    33353328      /*
    3336       * Feature in Windows. Windows sends the following
     3329      * Feature in OS/2. OS/2 sends the following
    33373330      * messages when the user double clicks the mouse:
    33383331      *
    3339       *       WM_LBUTTONDOWN          - mouse down
    3340       *       WM_LBUTTONUP            - mouse up
    3341       *       WM_LBUTTONDBLCLK        - double click
    3342       *       WM_LBUTTONUP            - mouse up
     3332      *       WM_BUTTON1DOWN          - mouse down
     3333      *       WM_BUTTON1UP            - mouse up
     3334      *       WM_BUTTON1DBLCLK        - double click
     3335      *       WM_BUTTON1UP            - mouse up
    33433336      *
    33443337      * Applications that expect matching mouse down/up
     
    33463339      * fix is to send a mouse down event.
    33473340      */
     3341      sendMouseEvent (SWT.MouseDown, 1, OS.WM_BUTTON1DOWN, mp1, mp2);
    33483342      sendMouseEvent (SWT.MouseDoubleClick, 1, OS.WM_BUTTON1DBLCLK, mp1, mp2);
    33493343      int result = callWindowProc (OS.WM_BUTTON1DBLCLK, mp1, mp2);
     3344      if (OS.WinQueryCapture (OS.HWND_DESKTOP) != handle) OS.WinSetCapture (OS.HWND_DESKTOP, handle);
     3345      return new MRESULT (result);
     3346}
     3347//
     3348MRESULT WM_BUTTON2DBLCLK (int mp1, int mp2) {
     3349      /*
     3350      * Feature in OS/2. OS/2 sends the following
     3351      * messages when the user double clicks the mouse:
     3352      *
     3353      *       WM_BUTTON2DOWN          - mouse down
     3354      *       WM_BUTTON2UP            - mouse up
     3355      *       WM_BUTTON2DBLCLK        - double click
     3356      *       WM_BUTTON2UP            - mouse up
     3357      *
     3358      * Applications that expect matching mouse down/up
     3359      * pairs will not see the second mouse down.  The
     3360      * fix is to send a mouse down event.
     3361      */
     3362      sendMouseEvent (SWT.MouseDown, 3, OS.WM_BUTTON2DOWN, mp1, mp2);
     3363      sendMouseEvent (SWT.MouseDoubleClick, 3, OS.WM_BUTTON2DBLCLK, mp1, mp2);
     3364      int result = callWindowProc (OS.WM_BUTTON2DBLCLK, mp1, mp2);
     3365      if (OS.WinQueryCapture (OS.HWND_DESKTOP) != handle) OS.WinSetCapture (OS.HWND_DESKTOP, handle);
     3366      return new MRESULT (result);
     3367}
     3368
     3369MRESULT WM_BUTTON3DBLCLK (int mp1, int mp2) {
     3370      /*
     3371      * Feature in OS/2. OS/2 sends the following
     3372      * messages when the user double clicks the mouse:
     3373      *
     3374      *       WM_BUTTON3DOWN          - mouse down
     3375      *       WM_BUTTON3UP            - mouse up
     3376      *       WM_BUTTON3DBLCLK        - double click
     3377      *       WM_BUTTON3UP            - mouse up
     3378      *
     3379      * Applications that expect matching mouse down/up
     3380      * pairs will not see the second mouse down.  The
     3381      * fix is to send a mouse down event.
     3382      */
     3383      sendMouseEvent (SWT.MouseDown, 2, OS.WM_BUTTON3DOWN, mp1, mp2);
     3384      sendMouseEvent (SWT.MouseDoubleClick, 2, OS.WM_BUTTON3DBLCLK, mp1, mp2);
     3385      int result = callWindowProc (OS.WM_BUTTON3DBLCLK, mp1, mp2);
    33503386      if (OS.WinQueryCapture (OS.HWND_DESKTOP) != handle) OS.WinSetCapture (OS.HWND_DESKTOP, handle);
    33513387      return new MRESULT (result);
     
    33753411//      int result = 0;
    33763412      if (mouseDown) {
    3377           int hwnd = OS.WinQueryCapture (OS.HWND_DESKTOP);
    3378           int hwnd2 = OS.WinQueryWindow(handle, OS.QW_PARENT);
    3379           int hwnd3 = OS.WinQueryActiveWindow(OS.HWND_DESKTOP);
     3413//          int hwnd = OS.WinQueryCapture (OS.HWND_DESKTOP);
     3414//          int hwnd2 = OS.WinQueryWindow(handle, OS.QW_PARENT);
     3415//          int hwnd3 = OS.WinQueryActiveWindow(OS.HWND_DESKTOP);
    33803416//          System.out.println("Control::WM_BUTTON1DOWN -> Window = " + Integer.toHexString(handle) + " Window Activa = " + Integer.toHexString(hwnd) + " Padre = " + Integer.toHexString(hwnd2));
    3381               if (OS.WinQueryCapture (OS.HWND_DESKTOP) != handle){
     3417              if (OS.WinQueryCapture (OS.HWND_DESKTOP) != handle)
    33823418                  OS.WinSetCapture (OS.HWND_DESKTOP, handle);
    3383               }
    3384               if(OS.WinQueryWindow(handle, OS.QW_PARENT) == OS.WinQueryActiveWindow(OS.HWND_DESKTOP)){
     3419//              if(OS.WinQueryWindow(handle, OS.QW_PARENT) == OS.WinQueryActiveWindow(OS.HWND_DESKTOP)){
    33853420//                  System.out.println("Control::WM_BUTTON1DOWN");
    3386               }
    3387               OS.WinSetActiveWindow (OS.HWND_DESKTOP, handle);
     3421//              }
     3422//              OS.WinSetActiveWindow (OS.HWND_DESKTOP, handle);
    33883423      }
    33893424//      if (dragging) {
     
    34193454}
    34203455
     3456MRESULT WM_BUTTON2DOWN (int mp1, int mp2) {
     3457      sendMouseEvent (SWT.MouseDown, 3, OS.WM_BUTTON2DOWN, mp1, mp2);
     3458      int result = callWindowProc (OS.WM_BUTTON2DOWN, mp1, mp2);
     3459      if (OS.WinQueryCapture (OS.HWND_DESKTOP) != handle) OS.WinSetCapture (OS.HWND_DESKTOP, handle);
     3460      return new MRESULT (result);
     3461}
     3462
     3463MRESULT WM_BUTTON3DOWN (int mp1, int mp2) {
     3464      sendMouseEvent (SWT.MouseDown, 2, OS.WM_BUTTON3DOWN, mp1, mp2);
     3465      int result = callWindowProc (OS.WM_BUTTON3DOWN, mp1, mp2);
     3466      if (OS.WinQueryCapture (OS.HWND_DESKTOP) != handle) OS.WinSetCapture (OS.HWND_DESKTOP, handle);
     3467      return new MRESULT (result);
     3468}
     3469
    34213470MRESULT WM_BUTTON1UP (int mp1, int mp2) {
    34223471      sendMouseEvent (SWT.MouseUp, 1, OS.WM_BUTTON1UP, mp1, mp2);
     
    34283477}
    34293478
    3430 //LRESULT WM_MBUTTONDBLCLK (int wParam, int lParam) {
    3431 //      /*
    3432 //      * Feature in Windows. Windows sends the following
    3433 //      * messages when the user double clicks the mouse:
    3434 //      *
    3435 //      *       WM_MBUTTONDOWN          - mouse down
    3436 //      *       WM_MBUTTONUP            - mouse up
    3437 //      *       WM_MLBUTTONDBLCLK       - double click
    3438 //      *       WM_MBUTTONUP            - mouse up
    3439 //      *
    3440 //      * Applications that expect matching mouse down/up
    3441 //      * pairs will not see the second mouse down.  The
    3442 //      * fix is to send a mouse down event.
    3443 //      */
    3444 //      sendMouseEvent (SWT.MouseDown, 2, OS.WM_MBUTTONDOWN, wParam, lParam);
    3445 //      sendMouseEvent (SWT.MouseDoubleClick, 2, OS.WM_MBUTTONDBLCLK, wParam, lParam);
    3446 //      int result = callWindowProc (OS.WM_MBUTTONDBLCLK, wParam, lParam);
    3447 //      if (OS.GetCapture () != handle) OS.SetCapture (handle);
    3448 //      return new LRESULT (result);
    3449 //}
    3450 //
    3451 //LRESULT WM_MBUTTONDOWN (int wParam, int lParam) {
    3452 //      sendMouseEvent (SWT.MouseDown, 2, OS.WM_MBUTTONDOWN, wParam, lParam);
    3453 //      int result = callWindowProc (OS.WM_MBUTTONDOWN, wParam, lParam);
    3454 //      if (OS.GetCapture () != handle) OS.SetCapture(handle);
    3455 //      return new LRESULT (result);
    3456 //}
    3457 //
    3458 //LRESULT WM_MBUTTONUP (int wParam, int lParam) {
    3459 //      sendMouseEvent (SWT.MouseUp, 2, OS.WM_MBUTTONUP, wParam, lParam);
    3460 //      int result = callWindowProc (OS.WM_MBUTTONUP, wParam, lParam);
     3479MRESULT WM_BUTTON2UP (int mp1, int mp2) {
     3480      sendMouseEvent (SWT.MouseUp, 3, OS.WM_BUTTON2UP, mp1, mp2);
     3481      int result = callWindowProc (OS.WM_BUTTON2UP, mp1, mp2);
    34613482//      if ((wParam & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0) {
    3462 //              if (OS.GetCapture () == handle) OS.ReleaseCapture ();
     3483              if (OS.WinQueryCapture (OS.HWND_DESKTOP) == handle) OS.WinSetCapture (OS.HWND_DESKTOP, OS.NULLHANDLE);
    34633484//      }
    3464 //      return new LRESULT (result);
    3465 //}
     3485      return new MRESULT (result);
     3486}
     3487
     3488MRESULT WM_BUTTON3UP (int mp1, int mp2) {
     3489      sendMouseEvent (SWT.MouseUp, 2, OS.WM_BUTTON3UP, mp1, mp2);
     3490      int result = callWindowProc (OS.WM_BUTTON3UP, mp1, mp2);
     3491      if (OS.WinQueryCapture (OS.HWND_DESKTOP) == handle) OS.WinSetCapture (OS.HWND_DESKTOP, OS.NULLHANDLE);
     3492      return new MRESULT (result);
     3493}
    34663494
    34673495MRESULT WM_MEASUREITEM (int mp1, int mp2) {
    3468     System.out.println("Control:WM_MEASUREITEM");
     3496    System.out.println("Control:WM_MEASUREITEM -> sListBox" + mp1);
    34693497//      MEASUREITEMSTRUCT struct = new MEASUREITEMSTRUCT ();
    34703498//      OS.MoveMemory (struct, lParam, MEASUREITEMSTRUCT.sizeof);
     
    34763504//      }
    34773505//      int hwnd = OS.GetDlgItem (handle, struct.CtlID);
    3478 //      Control control = WidgetTable.get (hwnd);
    3479 //      if (control == null) return null;
    3480 //      return control.wmMeasureChild (wParam, lParam);
    3481     return null;
    3482 }
    3483 //
     3506      Control control = WidgetTable.get (mp1);
     3507      if (control == null) return null;
     3508      return control.wmMeasureChild (mp1, mp2);
     3509//    return null;
     3510}
     3511
    34843512//LRESULT WM_MENUCHAR (int wParam, int lParam) {
    34853513//      Display display = getDisplay ();
     
    34993527//      return null;
    35003528//}
    3501 //
     3529
    35023530MRESULT WM_MENUSELECT (int mp1, int mp2) {
    3503 //    System.out.println("Control:WM_MENUSELECT - MP1 SHORT 1= " + OS.SHORT1FROMMP(mp1));
    3504     if(OS.SHORT2FROMMP(mp1) == 0) return MRESULT.FALSE;
     3531    if(OS.SHORT2FROMMP(mp1) == 0) return MRESULT.TRUE;
    35053532//      int code = wParam >> 16;
    35063533      Shell shell = getShell ();
     
    35273554//              return null;
    35283555//      }
    3529 //      if ((code & OS.MF_SYSMENU) != 0) return null;
     3556      if ((OS.SHORT1FROMMP(mp1) & OS.FID_SYSMENU) != 0) return MRESULT.TRUE;
    35303557      int sState = OS.WinSendMsg(mp2, OS.MM_QUERYITEMATTR, OS.MPFROM2SHORT(OS.SHORT1FROMMP(mp1), (short)OS.TRUE), OS.MIA_HILITED);
    35313558      if ((sState & OS.MIA_HILITED) != 0) {
     
    36193646//      return null;
    36203647//}
    3621 //
    3622 //MRESULT WM_MOUSEMOVE (int mp1, int mp2) {
    3623 //      if (!OS.IsWinCE) {
    3624 //              boolean hooksEnter = hooks (SWT.MouseEnter);
    3625 //              if (hooksEnter || hooks (SWT.MouseExit) || hooks (SWT.MouseHover)) {
    3626 //                      TRACKMOUSEEVENT lpEventTrack = new TRACKMOUSEEVENT ();
    3627 //                      lpEventTrack.cbSize = TRACKMOUSEEVENT.sizeof;
    3628 //                      lpEventTrack.dwFlags = OS.TME_QUERY;
    3629 //                      lpEventTrack.hwndTrack = handle;
    3630 //                      OS.TrackMouseEvent (lpEventTrack);
    3631 //                      if (lpEventTrack.dwFlags == 0) {
    3632 //                              lpEventTrack.dwFlags = OS.TME_LEAVE | OS.TME_HOVER;
    3633 //                              lpEventTrack.hwndTrack = handle;
    3634 //                              OS.TrackMouseEvent (lpEventTrack);
    3635 //                              if (hooksEnter) {
    3636 //                                      Event event = new Event ();
    3637 //                                      event.x = (short) (lParam & 0xFFFF);
    3638 //                                      event.y = (short) (lParam >> 16);
    3639 //                                      postEvent (SWT.MouseEnter, event);
    3640 //                              }
    3641 //                      } else {
    3642 //                              lpEventTrack.dwFlags = OS.TME_HOVER;
    3643 //                              OS.TrackMouseEvent (lpEventTrack);
    3644 //                      }
    3645 //              }
    3646 //      }
    3647 //      Display display = getDisplay ();
    3648 //      int pos = OS.GetMessagePos ();
    3649 //      if (pos != display.lastMouse) {
    3650 //              display.lastMouse = pos;
    3651 //              sendMouseEvent (SWT.MouseMove, 0, OS.WM_MOUSEMOVE, wParam, lParam);
    3652 //      }
    3653 //      return null;
    3654 //}
    3655 //
     3648
     3649MRESULT WM_MOUSEMOVE (int mp1, int mp2) {
     3650      Display display = getDisplay ();
     3651      int[] pnt = new int [] {0, 0};
     3652      OS.WinQueryMsgPos (0, pnt);
     3653      //@@TODO(dmik): Mapping coordinates to use lastMouse variable (x low order, y high order like windows)
     3654      int pos = (pnt[1] << 16) + pnt[0];
     3655      if (pos != display.lastMouse) {
     3656              display.lastMouse = pos;
     3657              sendMouseEvent (SWT.MouseMove, 0, OS.WM_MOUSEMOVE, mp1, mp2);
     3658      }
     3659      return MRESULT.FALSE;
     3660}
     3661
    36563662//LRESULT WM_MOUSEWHEEL (int wParam, int lParam) {
    36573663//      return null;
     
    36873693        return null;
    36883694    }
    3689 //    System.out.println("Control::WM_PAINT -> HANDLE  =  " + Integer.toHexString(handle));
    36903695    /* lazily obtain a long-term cached micro presentation space */
    36913696    GCData data = new GCData ();
     
    37523757//LRESULT WM_QUERYENDSESSION (int wParam, int lParam) {
    37533758//      return null;
    3754 //}
    3755 //
    3756 //LRESULT WM_RBUTTONDBLCLK (int wParam, int lParam) {
    3757 //      /*
    3758 //      * Feature in Windows. Windows sends the following
    3759 //      * messages when the user double clicks the mouse:
    3760 //      *
    3761 //      *       WM_RBUTTONDOWN          - mouse down
    3762 //      *       WM_RBUTTONUP            - mouse up
    3763 //      *       WM_RBUTTONDBLCLK        - double click
    3764 //      *       WM_LBUTTONUP            - mouse up
    3765 //      *
    3766 //      * Applications that expect matching mouse down/up
    3767 //      * pairs will not see the second mouse down.  The
    3768 //      * fix is to send a mouse down event.
    3769 //      */
    3770 //      sendMouseEvent (SWT.MouseDown, 3, OS.WM_RBUTTONDOWN, wParam, lParam);
    3771 //      sendMouseEvent (SWT.MouseDoubleClick, 3, OS.WM_RBUTTONDBLCLK, wParam, lParam);
    3772 //      int result = callWindowProc (OS.WM_RBUTTONDBLCLK, wParam, lParam);
    3773 //      if (OS.GetCapture () != handle) OS.SetCapture (handle);
    3774 //       return new LRESULT (result);
    3775 //}
    3776 //
    3777 //LRESULT WM_RBUTTONDOWN (int wParam, int lParam) {
    3778 //      sendMouseEvent (SWT.MouseDown, 3, OS.WM_RBUTTONDOWN, wParam, lParam);
    3779 //      int result = callWindowProc (OS.WM_RBUTTONDOWN, wParam, lParam);
    3780 //      if (OS.GetCapture () != handle) OS.SetCapture (handle);
    3781 //      return new LRESULT (result);
    3782 //}
    3783 //
    3784 //LRESULT WM_RBUTTONUP (int wParam, int lParam) {
    3785 //      sendMouseEvent (SWT.MouseUp, 3, OS.WM_RBUTTONUP, wParam, lParam);
    3786 //      int result = callWindowProc (OS.WM_RBUTTONUP, wParam, lParam);
    3787 //      if ((wParam & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0) {
    3788 //              if (OS.GetCapture () == handle) OS.ReleaseCapture ();
    3789 //      }
    3790 //      return new LRESULT (result);
    37913759//}
    37923760
     
    40233991      return control.wmScrollChild (mp1, mp2);
    40243992  }
    4025 //
    4026 //LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) {
    4027 //      return null;
    4028 //}
    40293993
    40303994MRESULT WM_WINDOWPOSCHANGED (int mp1, int mp2) {
     
    40964060
    40974061//@@TODO (dmik):
    4098 //LRESULT wmMeasureChild (int wParam, int lParam) {
    4099 //      return null;
    4100 //}
     4062MRESULT wmMeasureChild (int mp1, int mp2) {
     4063        System.out.println("Control:wmMeasureChild");
     4064      return null;
     4065}
    41014066//
    41024067//LRESULT wmNotifyChild (int wParam, int lParam) {
Note: See TracChangeset for help on using the changeset viewer.