X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e604d44b4b03f1f36998f91311d4e18e8f1b290e..d6c9c1b71e069396bbe3850862de9aa10e6812e0:/src/os2/window.cpp diff --git a/src/os2/window.cpp b/src/os2/window.cpp index 0573448e60..7a31cfbbda 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -37,6 +37,11 @@ #include #endif +#define DEBUG_PRINTF(NAME) { static int raz=0; \ + printf( #NAME " %i\n",raz); fflush(stdout); \ + raz++; \ + } + #if wxUSE_OWNER_DRAWN #include "wx/ownerdrw.h" #endif @@ -244,6 +249,9 @@ bool wxWindow::OS2Command( , WXWORD WXUNUSED(uId) ) { + +DEBUG_PRINTF(wxWindow::OS2Command); + return(FALSE); } @@ -293,6 +301,9 @@ void wxWindow::Init() m_lLastMouseY = -1; m_nLastMouseEvent = -1; #endif // wxUSE_MOUSEEVENT_HACK + +DEBUG_PRINTF(wxWindow::Init-End); + } // wxWindow::Init // @@ -300,6 +311,7 @@ void wxWindow::Init() // wxWindow::~wxWindow() { +DEBUG_PRINTF(wxWindow::~wxWindow-Start); m_isBeingDeleted = TRUE; OS2DetachWindowMenu(); @@ -318,6 +330,7 @@ wxWindow::~wxWindow() // wxRemoveHandleAssociation(this); } +DEBUG_PRINTF(wxWindow::~wxWindow-End); } // end of wxWindow::~wxWindow bool wxWindow::Create( @@ -500,6 +513,7 @@ bool wxWindow::SetFont( const wxFont& rFont ) { +DEBUG_PRINTF(wxWindow::SetFont); if (!wxWindowBase::SetFont(rFont)) { // nothing to do @@ -1505,6 +1519,8 @@ MRESULT wxWindow::OS2DefWindowProc( , WXLPARAM lParam ) { +DEBUG_PRINTF(wxWindow::OS2DefWindowProc); + if (m_fnOldWndProc) return (MRESULT)m_fnOldWndProc(GetHWND(), (ULONG)uMsg, (MPARAM)wParam, (MPARAM)lParam); else @@ -1517,6 +1533,8 @@ bool wxWindow::OS2ProcessMessage( { QMSG* pQMsg = (QMSG*)pMsg; +DEBUG_PRINTF(OS2ProcessMessage); + if (m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL)) { // @@ -1703,7 +1721,11 @@ bool wxWindow::OS2TranslateMessage( WXMSG* pMsg ) { - return m_acceleratorTable.Translate(m_hWnd, pMsg); +#if wxUSE_ACCEL + return m_acceleratorTable.Translate(m_hWnd, pMsg); +#else + return FALSE; +#endif //wxUSE_ACCEL } // end of wxWindow::OS2TranslateMessage // --------------------------------------------------------------------------- @@ -1718,9 +1740,14 @@ void wxWindow::UnpackCommand( , WORD* pCmd ) { +/* *pId = LOWORD(wParam); *phWnd = (WXHWND)lParam; *pCmd = HIWORD(wParam); +*/ + *pId = LOWORD(wParam); + *phWnd = NULL; // or may be GetHWND() ? + *pCmd = LOWORD(lParam); } // end of wxWindow::UnpackCommand void wxWindow::UnpackActivate( @@ -1784,6 +1811,7 @@ MRESULT EXPENTRY wxWndProc( // Trace all ulMsgs - useful for the debugging // #ifdef __WXDEBUG__ +DEBUG_PRINTF(__WXDEBUG__wxWndProc); wxLogTrace(wxTraceMessages, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"), wxGetMessageName(ulMsg), wParam, lParam); #endif // __WXDEBUG__ @@ -1802,7 +1830,7 @@ MRESULT EXPENTRY wxWndProc( pWnd->SetHWND((WXHWND)hWnd); } - MRESULT rc = (MRESULT)FALSE; + MRESULT rc = (MRESULT)0; // @@ -1821,6 +1849,7 @@ MRESULT EXPENTRY wxWndProc( else rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam); } + return rc; } // end of wxWndProc @@ -1881,7 +1910,6 @@ MRESULT wxWindow::OS2WindowProc( case WM_DESTROY: HandleDestroy(); bProcessed = TRUE; - delete this; break; case WM_MOVE: @@ -1923,6 +1951,7 @@ MRESULT wxWindow::OS2WindowProc( break; case WM_PAINT: +DEBUG_PRINTF(WM_PAINT) bProcessed = HandlePaint(); break; @@ -1933,9 +1962,11 @@ MRESULT wxWindow::OS2WindowProc( // bProcessed = TRUE; mResult = (MRESULT)TRUE; +DEBUG_PRINTF(WM_CLOSE) break; case WM_SHOW: +DEBUG_PRINTF(WM_SHOW) bProcessed = HandleShow(wParam != 0, (int)lParam); break; @@ -1974,9 +2005,11 @@ MRESULT wxWindow::OS2WindowProc( { WORD id, cmd; WXHWND hwnd; +DEBUG_PRINTF(WM_COMMAND-in) UnpackCommand(wParam, lParam, &id, &hwnd, &cmd); bProcessed = HandleCommand(id, cmd, hwnd); +DEBUG_PRINTF(WM_COMMAND-out) } break; @@ -2337,10 +2370,10 @@ bool wxWindow::OS2Create( { ERRORID vError; wxString sError; - long lX1 = (long)CW_USEDEFAULT; + long lX1 = 0L; long lY1 = 0L; - long lWidth1 = (long)CW_USEDEFAULT; - long lHeight1 = 100L; + long lWidth1 = 20L; + long lHeight1 = 20L; int nControlId = 0; // @@ -2426,7 +2459,7 @@ bool wxWindow::OS2Create( wxAssociateWinWithHandle((HWND)m_hWnd ,this ); - // + // // Now need to subclass window. // @@ -2823,12 +2856,21 @@ bool wxWindow::HandlePaint() wxLogLastError("CreateRectRgn"); return FALSE; } + // + // Debug code + // +#ifdef __WXDEBUG__ + { + HWND hWnd; + HWND hWnd0 = NULLHANDLE; + + hWnd = GetHwnd(); + if(hWnd != hWnd0) + printf("HandlePaint hWnd=%x ",hWnd); + } +#endif + m_updateRegion = wxRegion(hRgn); -/* - hPS = WinBeginPaint(GetHWND(), 0L, &vRect); - WinFillRect(hPS, &vRect, SYSCLR_WINDOW); - WinEndPaint(hPS); -*/ vEvent.SetEventObject(this); return (GetEventHandler()->ProcessEvent(vEvent)); } // end of wxWindow::HandlePaint @@ -3968,3 +4010,45 @@ static void TranslateKbdEventToMouse( pWin->ScreenToClient(pX, pY); } // end of TranslateKbdEventToMouse +// Find the wxWindow at the current mouse position, returning the mouse +// position. +wxWindow* wxFindWindowAtPointer( + wxPoint& rPt +) +{ + return wxFindWindowAtPoint(wxGetMousePosition()); +} + +wxWindow* wxFindWindowAtPoint( + const wxPoint& rPt +) +{ + POINTL vPt2; + + vPt2.x = rPt.x; + vPt2.y = rPt.y; + + HWND hWndHit = ::WinWindowFromPoint(HWND_DESKTOP, &vPt2, FALSE); + wxWindow* pWin = wxFindWinFromHandle((WXHWND)hWndHit) ; + HWND hWnd = hWndHit; + + // + // Try to find a window with a wxWindow associated with it + // + while (!pWin && (hWnd != 0)) + { + hWnd = ::WinQueryWindow(hWnd, QW_PARENT); + pWin = wxFindWinFromHandle((WXHWND)hWnd) ; + } + return pWin; +} + +// Get the current mouse position. +wxPoint wxGetMousePosition() +{ + POINTL vPt; + + ::WinQueryPointerPos(HWND_DESKTOP, &vPt); + return wxPoint(vPt.x, vPt.y); +} +