X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a917d2149e1d1dadbb01ac5ceca10d9f32ba2964..cd05bf23f6aec29f60a793f3ca4dfe336661fca1:/src/os2/window.cpp diff --git a/src/os2/window.cpp b/src/os2/window.cpp index 24d5f26679..61dd62db31 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -14,13 +14,13 @@ // #include "wx/wxprec.h" +#include "wx/window.h" + #ifndef WX_PRECOMP #define INCL_DOS #define INCL_PM #include - #include "wx/window.h" #include "wx/accel.h" - #include "wx/setup.h" #include "wx/menu.h" #include "wx/dc.h" #include "wx/dcclient.h" @@ -44,6 +44,10 @@ #include "wx/statusbr.h" #include "wx/toolbar.h" #include "wx/settings.h" + #include "wx/intl.h" + #include "wx/log.h" + #include "wx/textctrl.h" + #include "wx/menuitem.h" #include #endif @@ -55,9 +59,6 @@ #include "wx/dnd.h" #endif -#include "wx/menuitem.h" -#include "wx/log.h" - #include "wx/os2/private.h" #if wxUSE_TOOLTIPS @@ -72,12 +73,6 @@ #include "wx/caret.h" #endif // wxUSE_CARET -#include "wx/intl.h" -#include "wx/log.h" - - -#include "wx/textctrl.h" - #include // @@ -159,8 +154,9 @@ wxWindow* wxFindWinFromHandle(WXHWND hWnd); // // get the current state of SHIFT/CTRL keys // -static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) != 0; } -static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) != 0; } +static inline bool IsKeyDown(LONG key) {return (::WinGetKeyState(HWND_DESKTOP, key) & 0x8000) != 0; } +static inline bool IsShiftDown() { return IsKeyDown(VK_SHIFT); } +static inline bool IsCtrlDown() { return IsKeyDown(VK_CTRL); } static wxWindow* gpWinBeingCreated = NULL; @@ -2396,9 +2392,6 @@ MRESULT wxWindowOS2::OS2WindowProc( WXUINT uMsg, case WM_BUTTON3MOTIONEND: case WM_BUTTON3MOTIONSTART: { - if (uMsg == WM_BUTTON1DOWN && AcceptsFocus()) - SetFocus(); - short nX = LOWORD(wParam); short nY = HIWORD(wParam); @@ -3296,7 +3289,7 @@ bool wxWindowOS2::OS2OnDrawItem( int vId, { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); - wxLogError(_T("Unable to set current color table. Error: %s\n"), sError.c_str()); + wxLogError(_T("Unable to set current color table (1). Error: %s\n"), sError.c_str()); } // // Set the color table to RGB mode @@ -3311,7 +3304,7 @@ bool wxWindowOS2::OS2OnDrawItem( int vId, { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); - wxLogError(_T("Unable to set current color table. Error: %s\n"), sError.c_str()); + wxLogError(_T("Unable to set current color table (2). Error: %s\n"), sError.c_str()); } wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); @@ -3738,7 +3731,6 @@ bool wxWindowOS2::HandleEraseBkgnd( WXHDC hDC ) vDC.m_hPS = (HPS)hDC; // this is really a PS vDC.SetWindow((wxWindow*)this); - vDC.BeginDrawing(); wxEraseEvent vEvent(m_windowId, &vDC); @@ -3746,7 +3738,6 @@ bool wxWindowOS2::HandleEraseBkgnd( WXHDC hDC ) rc = GetEventHandler()->ProcessEvent(vEvent); - vDC.EndDrawing(); vDC.m_hPS = NULLHANDLE; return true; } // end of wxWindowOS2::HandleEraseBkgnd @@ -3892,12 +3883,9 @@ void wxWindowOS2::InitMouseEvent( rEvent.m_shiftDown = ((uFlags & KC_SHIFT) != 0); rEvent.m_controlDown = ((uFlags & KC_CTRL) != 0); rEvent.m_altDown = ((uFlags & KC_ALT) != 0); - rEvent.m_leftDown = (::WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & - 0x8000) != 0; - rEvent.m_middleDown = (::WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & - 0x8000) != 0; - rEvent.m_rightDown = (::WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & - 0x8000) != 0; + rEvent.m_leftDown = IsKeyDown(VK_BUTTON1); + rEvent.m_middleDown = IsKeyDown(VK_BUTTON3); + rEvent.m_rightDown = IsKeyDown(VK_BUTTON2); rEvent.SetTimestamp(s_currentMsg.time); rEvent.SetEventObject(this); rEvent.SetId(GetId()); @@ -4382,8 +4370,8 @@ int wxCharCodeOS2ToWX( case VK_CTRL: nId = WXK_CONTROL; break; case VK_PAUSE: nId = WXK_PAUSE; break; case VK_SPACE: nId = WXK_SPACE; break; - case VK_PAGEUP: nId = WXK_PRIOR; break; - case VK_PAGEDOWN: nId = WXK_NEXT; break; + case VK_PAGEUP: nId = WXK_PAGEUP; break; + case VK_PAGEDOWN: nId = WXK_PAGEDOWN; break; case VK_ESC: nId = WXK_ESCAPE; break; case VK_END: nId = WXK_END; break; case VK_HOME : nId = WXK_HOME; break; @@ -4445,15 +4433,16 @@ int wxCharCodeWXToOS2( int nId, { int nKeySym = 0; - *bIsVirtual = true; + if ( bIsVirtual ) + *bIsVirtual = true; switch (nId) { case WXK_CLEAR: nKeySym = VK_CLEAR; break; case WXK_SHIFT: nKeySym = VK_SHIFT; break; case WXK_CONTROL: nKeySym = VK_CTRL; break; case WXK_PAUSE: nKeySym = VK_PAUSE; break; - case WXK_PRIOR: nKeySym = VK_PAGEUP; break; - case WXK_NEXT : nKeySym = VK_PAGEDOWN; break; + case WXK_PAGEUP: nKeySym = VK_PAGEUP; break; + case WXK_PAGEDOWN: nKeySym = VK_PAGEDOWN; break; case WXK_END: nKeySym = VK_END; break; case WXK_HOME : nKeySym = VK_HOME; break; case WXK_LEFT : nKeySym = VK_LEFT; break; @@ -4491,7 +4480,8 @@ int wxCharCodeWXToOS2( int nId, case WXK_SCROLL: nKeySym = VK_SCRLLOCK; break; default: { - *bIsVirtual = false; + if ( bIsVirtual ) + *bIsVirtual = false; nKeySym = nId; break; } @@ -4499,6 +4489,29 @@ int wxCharCodeWXToOS2( int nId, return nKeySym; } // end of wxCharCodeWXToOS2 + +bool wxGetKeyState(wxKeyCode key) +{ + wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != + WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons")); + + const LONG vk = wxCharCodeWXToOS2(key); + // if the requested key is a LED key, return true if the led is pressed + if ( key == WXK_NUMLOCK || key == WXK_CAPITAL || key == WXK_SCROLL ) + { + // low order bit means LED is highlighted and high order one means the + // key is down; for compatibility with the other ports return true if + // either one is set + return ::WinGetKeyState(HWND_DESKTOP, vk) != 0; + + } + else // normal key + { + return IsKeyDown(vk); + } +} + + wxWindow* wxGetActiveWindow() { HWND hWnd = ::WinQueryActiveWindow(HWND_DESKTOP); @@ -5038,12 +5051,29 @@ wxWindow* wxFindWindowAtPoint(const wxPoint& rPt) // Get the current mouse position. wxPoint wxGetMousePosition() { - POINTL vPt; + POINTL vPt; ::WinQueryPointerPos(HWND_DESKTOP, &vPt); return wxPoint(vPt.x, vPt.y); } +wxMouseState wxGetMouseState() +{ + wxMouseState ms; + wxPoint pt = wxGetMousePosition(); + ms.SetX(pt.x); + ms.SetY(pt.y); + ms.SetLeftDown(IsKeyDown(VK_BUTTON1)); + ms.SetMiddleDown(IsKeyDown(VK_BUTTON3)); + ms.SetRightDown(IsKeyDown(VK_BUTTON2)); + ms.SetControlDown(IsCtrlDown()); + ms.SetShiftDown(IsShiftDown()); + ms.SetAltDown(IsKeyDown(VK_ALT)|IsKeyDown(VK_ALTGRAF)); + ms.SetMetaDown(IsKeyDown(VK_ALTGRAF)); + return ms; +} + + wxWindowOS2* FindWindowForMouseEvent( wxWindow* pWin, short* WXUNUSED(pnX), short* WXUNUSED(pnY) )