< prev index next >

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

Print this page




  43 #include "awt_MouseEvent.h"
  44 #include "awt_Palette.h"
  45 #include "awt_Toolkit.h"
  46 #include "awt_Window.h"
  47 #include "awt_Win32GraphicsDevice.h"
  48 #include "Hashtable.h"
  49 #include "ComCtl32Util.h"
  50 
  51 #include <Region.h>
  52 
  53 #include <jawt.h>
  54 
  55 #include <java_awt_Toolkit.h>
  56 #include <java_awt_FontMetrics.h>
  57 #include <java_awt_Color.h>
  58 #include <java_awt_Event.h>
  59 #include <java_awt_event_KeyEvent.h>
  60 #include <java_awt_Insets.h>
  61 #include <sun_awt_windows_WPanelPeer.h>
  62 #include <java_awt_event_InputEvent.h>

  63 #include <java_awt_event_InputMethodEvent.h>
  64 #include <sun_awt_windows_WInputMethod.h>
  65 #include <java_awt_event_MouseEvent.h>
  66 #include <java_awt_event_MouseWheelEvent.h>
  67 
  68 // Begin -- Win32 SDK include files
  69 #include <imm.h>
  70 #include <ime.h>
  71 // End -- Win32 SDK include files
  72 
  73 #include <awt_DnDDT.h>
  74 
  75 LPCTSTR szAwtComponentClassName = TEXT("SunAwtComponent");
  76 // register a message that no other window in the process (even in a plugin
  77 // scenario) will be using
  78 const UINT AwtComponent::WmAwtIsComponent =
  79     ::RegisterWindowMessage(szAwtComponentClassName);
  80 
  81 static HWND g_hwndDown = NULL;
  82 static DCList activeDCList;


2568 
2569     DTRACE_PRINTLN3(
2570       "AwtComponent::GetShiftKeyLocation  vkey = %d = 0x%x  scan = %d",
2571       vkey, vkey, keyScanCode);
2572 
2573     leftShiftScancode = ::MapVirtualKey(VK_LSHIFT, 0);
2574     rightShiftScancode = ::MapVirtualKey(VK_RSHIFT, 0);
2575 
2576     if (keyScanCode == leftShiftScancode) {
2577         return java_awt_event_KeyEvent_KEY_LOCATION_LEFT;
2578     }
2579     if (keyScanCode == rightShiftScancode) {
2580         return java_awt_event_KeyEvent_KEY_LOCATION_RIGHT;
2581     }
2582 
2583     DASSERT(false);
2584     // Note: the above should not fail on NT (or 2000)
2585 
2586     // default value
2587     return java_awt_event_KeyEvent_KEY_LOCATION_LEFT;





















2588 }
2589 
2590 /* Returns Java extended InputEvent modifieres.
2591  * Since ::GetKeyState returns current state and Java modifiers represent
2592  * state before event, modifier on changed key are inverted.
2593  */
2594 jint
2595 AwtComponent::GetJavaModifiers()
2596 {
2597     jint modifiers = 0;
2598 
2599     if (HIBYTE(::GetKeyState(VK_CONTROL)) != 0) {
2600         modifiers |= java_awt_event_InputEvent_CTRL_DOWN_MASK;
2601     }
2602     if (HIBYTE(::GetKeyState(VK_SHIFT)) != 0) {
2603         modifiers |= java_awt_event_InputEvent_SHIFT_DOWN_MASK;
2604     }
2605     if (HIBYTE(::GetKeyState(VK_MENU)) != 0) {
2606         modifiers |= java_awt_event_InputEvent_ALT_DOWN_MASK;
2607     }




  43 #include "awt_MouseEvent.h"
  44 #include "awt_Palette.h"
  45 #include "awt_Toolkit.h"
  46 #include "awt_Window.h"
  47 #include "awt_Win32GraphicsDevice.h"
  48 #include "Hashtable.h"
  49 #include "ComCtl32Util.h"
  50 
  51 #include <Region.h>
  52 
  53 #include <jawt.h>
  54 
  55 #include <java_awt_Toolkit.h>
  56 #include <java_awt_FontMetrics.h>
  57 #include <java_awt_Color.h>
  58 #include <java_awt_Event.h>
  59 #include <java_awt_event_KeyEvent.h>
  60 #include <java_awt_Insets.h>
  61 #include <sun_awt_windows_WPanelPeer.h>
  62 #include <java_awt_event_InputEvent.h>
  63 #include <java_awt_event_ActionEvent.h>
  64 #include <java_awt_event_InputMethodEvent.h>
  65 #include <sun_awt_windows_WInputMethod.h>
  66 #include <java_awt_event_MouseEvent.h>
  67 #include <java_awt_event_MouseWheelEvent.h>
  68 
  69 // Begin -- Win32 SDK include files
  70 #include <imm.h>
  71 #include <ime.h>
  72 // End -- Win32 SDK include files
  73 
  74 #include <awt_DnDDT.h>
  75 
  76 LPCTSTR szAwtComponentClassName = TEXT("SunAwtComponent");
  77 // register a message that no other window in the process (even in a plugin
  78 // scenario) will be using
  79 const UINT AwtComponent::WmAwtIsComponent =
  80     ::RegisterWindowMessage(szAwtComponentClassName);
  81 
  82 static HWND g_hwndDown = NULL;
  83 static DCList activeDCList;


2569 
2570     DTRACE_PRINTLN3(
2571       "AwtComponent::GetShiftKeyLocation  vkey = %d = 0x%x  scan = %d",
2572       vkey, vkey, keyScanCode);
2573 
2574     leftShiftScancode = ::MapVirtualKey(VK_LSHIFT, 0);
2575     rightShiftScancode = ::MapVirtualKey(VK_RSHIFT, 0);
2576 
2577     if (keyScanCode == leftShiftScancode) {
2578         return java_awt_event_KeyEvent_KEY_LOCATION_LEFT;
2579     }
2580     if (keyScanCode == rightShiftScancode) {
2581         return java_awt_event_KeyEvent_KEY_LOCATION_RIGHT;
2582     }
2583 
2584     DASSERT(false);
2585     // Note: the above should not fail on NT (or 2000)
2586 
2587     // default value
2588     return java_awt_event_KeyEvent_KEY_LOCATION_LEFT;
2589 }
2590 
2591 /* Returns Java ActionEvent modifieres.
2592  * When creating ActionEvent, modifiers provided by ActionEvent
2593  * class should be set.
2594  */
2595 jint
2596 AwtComponent::GetActionModifiers()
2597 {
2598     jint modifiers = GetJavaModifiers();
2599 
2600     if (modifiers & java_awt_event_InputEvent_CTRL_DOWN_MASK) {
2601         modifiers |= java_awt_event_ActionEvent_CTRL_MASK;
2602     }
2603     if (modifiers & java_awt_event_InputEvent_SHIFT_DOWN_MASK) {
2604         modifiers |= java_awt_event_ActionEvent_SHIFT_MASK;
2605     }
2606     if (modifiers & java_awt_event_InputEvent_ALT_DOWN_MASK) {
2607         modifiers |= java_awt_event_ActionEvent_ALT_MASK;
2608     }
2609     return modifiers;
2610 }
2611 
2612 /* Returns Java extended InputEvent modifieres.
2613  * Since ::GetKeyState returns current state and Java modifiers represent
2614  * state before event, modifier on changed key are inverted.
2615  */
2616 jint
2617 AwtComponent::GetJavaModifiers()
2618 {
2619     jint modifiers = 0;
2620 
2621     if (HIBYTE(::GetKeyState(VK_CONTROL)) != 0) {
2622         modifiers |= java_awt_event_InputEvent_CTRL_DOWN_MASK;
2623     }
2624     if (HIBYTE(::GetKeyState(VK_SHIFT)) != 0) {
2625         modifiers |= java_awt_event_InputEvent_SHIFT_DOWN_MASK;
2626     }
2627     if (HIBYTE(::GetKeyState(VK_MENU)) != 0) {
2628         modifiers |= java_awt_event_InputEvent_ALT_DOWN_MASK;
2629     }


< prev index next >