< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_Component.cpp

Print this page




 565             env->SetObjectField(peer, AwtObject::createErrorID, createError);
 566             env->DeleteLocalRef(createError);
 567         }
 568         env->DeleteLocalRef(target);
 569         return;
 570     }
 571 
 572     m_hwnd = hwnd;
 573 
 574     ::ImmAssociateContext(m_hwnd, NULL);
 575 
 576     SetDrawState((jint)JAWT_LOCK_SURFACE_CHANGED |
 577         (jint)JAWT_LOCK_BOUNDS_CHANGED |
 578         (jint)JAWT_LOCK_CLIP_CHANGED);
 579 
 580     LinkObjects(env, peer);
 581 
 582     /* Subclass the window now so that we can snoop on its messages */
 583     SubclassHWND();
 584 





 585     /*
 586       * Fix for 4046446.
 587       */
 588     SetWindowPos(GetHWnd(), 0, x, y, w, h, SWP_NOZORDER | SWP_NOCOPYBITS | SWP_NOACTIVATE);
 589 
 590     /* Set default colors. */
 591     m_colorForeground = colorForeground;
 592     m_colorBackground = colorBackground;
 593 
 594     /*
 595      * Only set background color if the color is actually set on the
 596      * target -- this avoids inheriting a parent's color unnecessarily,
 597      * and has to be done here because there isn't an API to get the
 598      * real background color from outside the AWT package.
 599      */
 600     jobject bkgrd = env->GetObjectField(target, AwtComponent::backgroundID) ;
 601     if (bkgrd != NULL) {
 602         JNU_CallMethodByName(env, NULL, peer, "setBackground",
 603                              "(Ljava/awt/Color;)V", bkgrd);
 604         DASSERT(!safe_ExceptionOccurred(env));


1696           case WM_RBUTTONUP:
1697               mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
1698                              RIGHT_BUTTON);
1699               break;
1700           case WM_MBUTTONUP:
1701               mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
1702                              MIDDLE_BUTTON);
1703               break;
1704           case WM_AWT_MOUSEEXIT:
1705               mr = WmMouseExit(static_cast<UINT>(wParam), myPos.x, myPos.y);
1706               break;
1707           case WM_MOUSEWHEEL:
1708           case WM_MOUSEHWHEEL:
1709               mr = WmMouseWheel(GET_KEYSTATE_WPARAM(wParam),
1710                                 GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
1711                                 GET_WHEEL_DELTA_WPARAM(wParam),
1712                                 switchMessage == WM_MOUSEHWHEEL);
1713               break;
1714           }
1715           break;






































































1716       case WM_SETCURSOR:
1717           mr = mrDoDefault;
1718           if (LOWORD(lParam) == HTCLIENT) {
1719               if (AwtComponent* comp =
1720                                     AwtComponent::GetComponent((HWND)wParam)) {
1721                   AwtCursor::UpdateCursor(comp);
1722                   mr = mrConsume;
1723               }
1724           }
1725           break;
1726 
1727       case WM_KEYDOWN:
1728           mr = WmKeyDown(static_cast<UINT>(wParam),
1729                          LOWORD(lParam), HIWORD(lParam), FALSE);
1730           break;
1731       case WM_KEYUP:
1732           mr = WmKeyUp(static_cast<UINT>(wParam),
1733                        LOWORD(lParam), HIWORD(lParam), FALSE);
1734           break;
1735       case WM_SYSKEYDOWN:




 565             env->SetObjectField(peer, AwtObject::createErrorID, createError);
 566             env->DeleteLocalRef(createError);
 567         }
 568         env->DeleteLocalRef(target);
 569         return;
 570     }
 571 
 572     m_hwnd = hwnd;
 573 
 574     ::ImmAssociateContext(m_hwnd, NULL);
 575 
 576     SetDrawState((jint)JAWT_LOCK_SURFACE_CHANGED |
 577         (jint)JAWT_LOCK_BOUNDS_CHANGED |
 578         (jint)JAWT_LOCK_CLIP_CHANGED);
 579 
 580     LinkObjects(env, peer);
 581 
 582     /* Subclass the window now so that we can snoop on its messages */
 583     SubclassHWND();
 584 
 585     AwtToolkit& tk = AwtToolkit::GetInstance();
 586     if (tk.IsWin8OrLater()) {
 587         tk.TIEnableMouseInPointer(true);
 588     }
 589 
 590     /*
 591       * Fix for 4046446.
 592       */
 593     SetWindowPos(GetHWnd(), 0, x, y, w, h, SWP_NOZORDER | SWP_NOCOPYBITS | SWP_NOACTIVATE);
 594 
 595     /* Set default colors. */
 596     m_colorForeground = colorForeground;
 597     m_colorBackground = colorBackground;
 598 
 599     /*
 600      * Only set background color if the color is actually set on the
 601      * target -- this avoids inheriting a parent's color unnecessarily,
 602      * and has to be done here because there isn't an API to get the
 603      * real background color from outside the AWT package.
 604      */
 605     jobject bkgrd = env->GetObjectField(target, AwtComponent::backgroundID) ;
 606     if (bkgrd != NULL) {
 607         JNU_CallMethodByName(env, NULL, peer, "setBackground",
 608                              "(Ljava/awt/Color;)V", bkgrd);
 609         DASSERT(!safe_ExceptionOccurred(env));


1701           case WM_RBUTTONUP:
1702               mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
1703                              RIGHT_BUTTON);
1704               break;
1705           case WM_MBUTTONUP:
1706               mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
1707                              MIDDLE_BUTTON);
1708               break;
1709           case WM_AWT_MOUSEEXIT:
1710               mr = WmMouseExit(static_cast<UINT>(wParam), myPos.x, myPos.y);
1711               break;
1712           case WM_MOUSEWHEEL:
1713           case WM_MOUSEHWHEEL:
1714               mr = WmMouseWheel(GET_KEYSTATE_WPARAM(wParam),
1715                                 GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
1716                                 GET_WHEEL_DELTA_WPARAM(wParam),
1717                                 switchMessage == WM_MOUSEHWHEEL);
1718               break;
1719           }
1720           break;
1721 
1722       /* WM_POINTER is enabled for the TOUCH type 'pointer' input
1723          This touch typed 'pointer' would map to the mouse functionality */
1724       case WM_POINTERENTER:
1725           {
1726               AwtToolkit& tk = AwtToolkit::GetInstance();
1727               UINT32 pointerId = GET_POINTERID_WPARAM(wParam);
1728               POINTER_INFO pinfo;
1729 
1730               if(tk.TIGetPointerInfo(pointerId, &pinfo)) {
1731                   if (pinfo.pointerType == PT_TOUCH) {
1732                       POINT pdDnPoint = pinfo.ptPixelLocation;
1733                       if(::ScreenToClient(GetHWnd(), &pdDnPoint)) {
1734                         mr = WmMouseEnter(static_cast<UINT>(wParam), pdDnPoint.x, pdDnPoint.y);
1735                       }
1736                   }
1737               }
1738           }
1739         break;
1740       case WM_POINTERLEAVE:
1741           {
1742               AwtToolkit& tk = AwtToolkit::GetInstance();
1743               UINT32 pointerId = GET_POINTERID_WPARAM(wParam);
1744               POINTER_INFO pinfo;
1745 
1746               if(tk.TIGetPointerInfo(pointerId, &pinfo)) {
1747                   if (pinfo.pointerType == PT_TOUCH) {
1748                       POINT pdDnPoint = pinfo.ptPixelLocation;
1749                       if(::ScreenToClient(GetHWnd(), &pdDnPoint)) {
1750                         mr = WmMouseExit(static_cast<UINT>(wParam), pdDnPoint.x, pdDnPoint.y);
1751                       }
1752                   }
1753               }
1754           }
1755         break;
1756       case WM_POINTERDOWN:
1757           {
1758               AwtToolkit& tk = AwtToolkit::GetInstance();
1759               UINT32 pointerId = GET_POINTERID_WPARAM(wParam);
1760               POINTER_INFO pinfo;
1761 
1762               if(tk.TIGetPointerInfo(pointerId, &pinfo)) {
1763                   if (pinfo.pointerType == PT_TOUCH) {
1764                       POINT pdDnPoint = pinfo.ptPixelLocation;
1765                       if(::ScreenToClient(GetHWnd(), &pdDnPoint)) {
1766                         mr = WmMouseDown(static_cast<UINT>(wParam), pdDnPoint.x, pdDnPoint.y,
1767                                        LEFT_BUTTON);
1768                       }
1769                   }
1770               }
1771           }
1772           break;
1773       case WM_POINTERUP:
1774           {
1775               AwtToolkit& tk = AwtToolkit::GetInstance();
1776               UINT32 pointerId = GET_POINTERID_WPARAM(wParam);
1777               POINTER_INFO pinfo;
1778 
1779               if(tk.TIGetPointerInfo(pointerId, &pinfo)) {
1780                   if (pinfo.pointerType == PT_TOUCH) {
1781                       POINT pdUpPoint = pinfo.ptPixelLocation;
1782                       if(::ScreenToClient(GetHWnd(), &pdUpPoint)) {
1783                         mr = WmMouseUp(static_cast<UINT>(wParam), pdUpPoint.x, pdUpPoint.y,
1784                                      LEFT_BUTTON);
1785                       }
1786                   }
1787               }
1788           }
1789           break;
1790 
1791       case WM_SETCURSOR:
1792           mr = mrDoDefault;
1793           if (LOWORD(lParam) == HTCLIENT) {
1794               if (AwtComponent* comp =
1795                                     AwtComponent::GetComponent((HWND)wParam)) {
1796                   AwtCursor::UpdateCursor(comp);
1797                   mr = mrConsume;
1798               }
1799           }
1800           break;
1801 
1802       case WM_KEYDOWN:
1803           mr = WmKeyDown(static_cast<UINT>(wParam),
1804                          LOWORD(lParam), HIWORD(lParam), FALSE);
1805           break;
1806       case WM_KEYUP:
1807           mr = WmKeyUp(static_cast<UINT>(wParam),
1808                        LOWORD(lParam), HIWORD(lParam), FALSE);
1809           break;
1810       case WM_SYSKEYDOWN:


< prev index next >