+ //
+ // Check if we need to send a LEAVE event
+ //
+ if (m_bMouseInWindow)
+ {
+ POINTL vPoint;
+
+ ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
+ if (::WinWindowFromPoint(HWND_DESKTOP, &vPoint, FALSE) != (HWND)GetHwnd())
+ {
+ //
+ // Generate a LEAVE event
+ //
+ m_bMouseInWindow = FALSE;
+
+ //
+ // Unfortunately the mouse button and keyboard state may have changed
+ // by the time the OnIdle function is called, so 'state' may be
+ // meaningless.
+ //
+ int nState = 0;
+
+ if (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) != 0)
+ nState |= VK_SHIFT;
+ if (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) != 0);
+ nState |= VK_CTRL;
+
+ wxMouseEvent rEvent(wxEVT_LEAVE_WINDOW);
+
+ InitMouseEvent( rEvent
+ ,vPoint.x
+ ,vPoint.y
+ ,nState
+ );
+ (void)GetEventHandler()->ProcessEvent(rEvent);
+ }
+ }
+ UpdateWindowUI();
+} // end of wxWindowOS2::OnIdle
+
+//
+// Set this window to be the child of 'parent'.
+//
+bool wxWindowOS2::Reparent(
+ wxWindow* pParent
+)
+{
+ if (!wxWindowBase::Reparent(pParent))
+ return FALSE;
+
+ HWND hWndChild = GetHwnd();
+ HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0;
+
+ ::WinSetParent(hWndChild, hWndParent, TRUE);
+ return TRUE;
+} // end of wxWindowOS2::Reparent
+
+void wxWindowOS2::Clear()
+{
+ wxClientDC vDc(this);
+ wxBrush vBrush( GetBackgroundColour()
+ ,wxSOLID
+ );
+
+ vDc.SetBackground(vBrush);
+ vDc.Clear();
+} // end of wxWindowOS2::Clear
+
+void wxWindowOS2::Refresh(
+ bool bEraseBack
+, const wxRect* pRect
+)
+{
+ HWND hWnd = GetHwnd();
+
+ if (hWnd)
+ {
+ if (pRect)
+ {
+ RECTL vOs2Rect;
+
+ vOs2Rect.xLeft = pRect->x;
+ vOs2Rect.yTop = pRect->y;
+ vOs2Rect.xRight = pRect->x + pRect->width;
+ vOs2Rect.yBottom = pRect->y + pRect->height;
+
+ ::WinInvalidateRect(hWnd, &vOs2Rect, bEraseBack);
+ }
+ else
+ ::WinInvalidateRect(hWnd, NULL, bEraseBack);
+ }
+} // end of wxWindowOS2::Refresh
+
+// ---------------------------------------------------------------------------
+// drag and drop
+// ---------------------------------------------------------------------------
+
+#if wxUSE_DRAG_AND_DROP
+void wxWindowOS2::SetDropTarget(
+ wxDropTarget* pDropTarget
+)
+{
+ if (m_dropTarget != 0)
+ {
+ m_dropTarget->Revoke(m_hWnd);
+ delete m_dropTarget;
+ }
+ m_dropTarget = pDropTarget;
+ if (m_dropTarget != 0)
+ m_dropTarget->Register(m_hWnd);
+} // end of wxWindowOS2::SetDropTarget
+#endif
+
+//
+// old style file-manager drag&drop support: we retain the old-style
+// DragAcceptFiles in parallel with SetDropTarget.
+//
+void wxWindowOS2::DragAcceptFiles(
+ bool bAccept
+)
+{
+ HWND hWnd = GetHwnd();
+
+ if (hWnd && bAccept)
+ ::DrgAcceptDroppedFiles(hWnd, NULL, NULL, DO_COPY, 0L);
+} // end of wxWindowOS2::DragAcceptFiles
+
+// ----------------------------------------------------------------------------
+// tooltips
+// ----------------------------------------------------------------------------
+
+#if wxUSE_TOOLTIPS
+
+void wxWindowOS2::DoSetToolTip(
+ wxToolTip* pTooltip
+)
+{
+ wxWindowBase::DoSetToolTip(pTooltip);
+
+ if (m_tooltip)
+ m_tooltip->SetWindow(this);
+} // end of wxWindowOS2::DoSetToolTip
+
+#endif // wxUSE_TOOLTIPS
+
+// ---------------------------------------------------------------------------
+// moving and resizing
+// ---------------------------------------------------------------------------
+
+// Get total size
+void wxWindowOS2::DoGetSize(
+ int* pWidth
+, int* pHeight
+) const
+{
+ HWND hWnd = GetHwnd();
+ RECTL vRect;
+
+ ::WinQueryWindowRect(hWnd, &vRect);
+
+ if (pWidth)
+ *pWidth = vRect.xRight - vRect.xLeft;
+ if (pHeight )
+ // OS/2 PM is backwards from windows
+ *pHeight = vRect.yTop - vRect.yBottom;
+} // end of wxWindowOS2::DoGetSize
+
+void wxWindowOS2::DoGetPosition(
+ int* pX
+, int* pY
+) const
+{
+ HWND hWnd = GetHwnd();
+ RECT vRect;
+ POINTL vPoint;
+
+ ::WinQueryWindowRect(hWnd, &vRect);
+
+ vPoint.x = vRect.xLeft;
+ vPoint.y = vRect.yBottom;
+
+ //
+ // We do the adjustments with respect to the parent only for the "real"
+ // children, not for the dialogs/frames
+ //
+ if (!IsTopLevel())
+ {
+ HWND hParentWnd = 0;
+ wxWindow* pParent = GetParent();
+
+ if (pParent)
+ hParentWnd = GetWinHwnd(pParent);
+
+ //
+ // Since we now have the absolute screen coords, if there's a parent we
+ // must subtract its bottom left corner
+ //
+ if (hParentWnd)
+ {
+ RECTL vRect2;
+
+ ::WinQueryWindowRect(hParentWnd, &vRect2);
+ vPoint.x -= vRect.xLeft;
+ vPoint.y -= vRect.yBottom;
+ }
+
+ //
+ // We may be faking the client origin. So a window that's really at (0,
+ // 30) may appear (to wxWin apps) to be at (0, 0).
+ //
+ wxPoint vPt(pParent->GetClientAreaOrigin());
+
+ vPoint.x -= vPt.x;
+ vPoint.y -= vPt.y;
+ }
+
+ if (pX)
+ *pX = vPoint.x;
+ if (pY)
+ *pY = vPoint.y;
+} // end of wxWindowOS2::DoGetPosition
+
+void wxWindowOS2::DoScreenToClient(
+ int* pX
+, int* pY
+) const
+{
+ HWND hWnd = GetHwnd();
+ SWP vSwp;
+
+ ::WinQueryWindowPos(hWnd, &vSwp);
+
+ if (pX)
+ *pX -= vSwp.x;
+ if (pY)
+ *pY -= vSwp.y;
+} // end of wxWindowOS2::DoScreenToClient
+
+void wxWindowOS2::DoClientToScreen(
+ int* pX
+, int* pY
+) const
+{
+ HWND hWnd = GetHwnd();
+ SWP vSwp;
+
+ ::WinQueryWindowPos(hWnd, &vSwp);
+
+ if (pX)
+ *pX += vSwp.x;
+ if (pY)
+ *pY += vSwp.y;
+} // end of wxWindowOS2::DoClientToScreen
+
+//
+// Get size *available for subwindows* i.e. excluding menu bar etc.
+// Must be a frame type window
+//
+void wxWindowOS2::DoGetClientSize(
+ int* pWidth
+, int* pHeight
+) const
+{
+ HWND hWnd = GetHwnd();
+ HWND hWndClient;
+ RECTL vRect;
+
+ if (IsKindOf(CLASSINFO(wxFrame)))
+ hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
+ else
+ hWndClient = NULLHANDLE;
+ if( hWndClient == NULLHANDLE)
+ ::WinQueryWindowRect(GetHwnd(), &vRect);
+ else
+ ::WinQueryWindowRect(hWndClient, &vRect);
+
+ if (pWidth)
+ *pWidth = vRect.xRight;
+ if (pHeight)
+ *pHeight = vRect.yTop;
+} // end of wxWindowOS2::DoGetClientSize
+
+void wxWindowOS2::DoMoveWindow(
+ int nX
+, int nY
+, int nWidth
+, int nHeight
+)
+{
+#if 0 // x and y coords should already be in os2 coordinates
+ RECTL vRect;
+ HWND hParent;
+ wxWindow* pParent = GetParent();
+
+ if (pParent)
+ hParent = GetWinHwnd(pParent);
+ else
+ hParent = HWND_DESKTOP;
+ ::WinQueryWindowRect(hParent, &vRect);
+ nY = vRect.yTop - (nY + nHeight);
+#endif
+ if ( !::WinSetWindowPos( GetHwnd()
+ ,HWND_TOP
+ ,(LONG)nX
+ ,(LONG)nY
+ ,(LONG)nWidth
+ ,(LONG)nHeight
+ ,SWP_SIZE | SWP_MOVE
+ ))
+ {
+ wxLogLastError("MoveWindow");
+ }
+} // end of wxWindowOS2::DoMoveWindow
+
+//
+// Set the size of the window: if the dimensions are positive, just use them,
+// but if any of them is equal to -1, it means that we must find the value for
+// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
+// which case -1 is a valid value for x and y)
+//
+// If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
+// the width/height to best suit our contents, otherwise we reuse the current
+// width/height
+//
+void wxWindowOS2::DoSetSize(
+ int nX
+, int nY
+, int nWidth
+, int nHeight
+, int nSizeFlags
+)
+{
+ //
+ // Get the current size and position...
+ //
+ int nCurrentX;
+ int nCurrentY;
+ int nCurrentWidth;
+ int nCurrentHeight;
+ wxSize vSize(-1, -1);
+
+ GetPosition( &nCurrentX
+ ,&nCurrentY
+ );
+ GetSize( &nCurrentWidth
+ ,&nCurrentHeight
+ );
+
+ //
+ // ... and don't do anything (avoiding flicker) if it's already ok
+ //
+ if ( nX == nCurrentX &&
+ nY == nCurrentY &&
+ nWidth == nCurrentWidth &&
+ nHeight == nCurrentHeight
+ )
+ {
+ return;
+ }
+
+ if (nX == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ nX = nCurrentX;
+ if (nY == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ nY = nCurrentY;
+
+ AdjustForParentClientOrigin( nX
+ ,nY
+ ,nSizeFlags
+ );
+
+ if (nWidth == -1)
+ {
+ if (nSizeFlags & wxSIZE_AUTO_WIDTH)
+ {
+ vSize = DoGetBestSize();
+ nWidth = vSize.x;
+ }
+ else
+ {
+ //
+ // Just take the current one
+ //
+ nWidth = nCurrentWidth;
+ }
+ }
+
+ if (nHeight == -1)
+ {
+ if (nSizeFlags & wxSIZE_AUTO_HEIGHT)
+ {
+ if (vSize.x == -1)
+ {
+ vSize = DoGetBestSize();
+ }
+ nHeight = vSize.y;
+ }
+ else
+ {
+ // just take the current one
+ nHeight = nCurrentHeight;
+ }
+ }
+
+ DoMoveWindow( nX
+ ,nY
+ ,nWidth
+ ,nHeight
+ );
+} // end of wxWindowOS2::DoSetSize
+
+void wxWindowOS2::DoSetClientSize(
+ int nWidth
+, int nHeight
+)
+{
+ wxWindow* pParent = GetParent();
+ HWND hWnd = GetHwnd();
+ HWND hParentWnd = (HWND)0;
+ HWND hClientWnd = (HWND)0;
+ RECTL vRect;
+ RECT vRect2;
+ RECT vRect3;
+
+ hClientWnd = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
+ ::WinQueryWindowRect(hClientWnd, &vRect2);
+
+ if (pParent)
+ hParentWnd = (HWND) pParent->GetHWND();
+
+ ::WinQueryWindowRect(hWnd, &vRect);
+ ::WinQueryWindowRect(hParentWnd, &vRect3);
+ //
+ // Find the difference between the entire window (title bar and all)
+ // and the client area; add this to the new client size to move the
+ // window. OS/2 is backward from windows on height
+ //
+ int nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth;
+ int nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight;
+
+ //
+ // If there's a parent, must subtract the parent's bottom left corner
+ // since MoveWindow moves relative to the parent
+ //
+ POINTL vPoint;
+
+ vPoint.x = vRect2.xLeft;
+ vPoint.y = vRect2.yBottom;
+ if (pParent)
+ {
+ vPoint.x -= vRect3.xLeft;
+ vPoint.y -= vRect3.yBottom;
+ }
+
+ DoMoveWindow( vPoint.x
+ ,vPoint.y
+ ,nActualWidth
+ ,nActualHeight
+ );
+
+ wxSizeEvent vEvent( wxSize( nWidth
+ ,nHeight
+ )
+ ,m_windowId
+ );
+
+ vEvent.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(vEvent);
+} // end of wxWindowOS2::DoSetClientSize
+
+wxPoint wxWindowOS2::GetClientAreaOrigin() const
+{
+ return wxPoint(0, 0);
+} // end of wxWindowOS2::GetClientAreaOrigin
+
+// ---------------------------------------------------------------------------
+// text metrics
+// ---------------------------------------------------------------------------
+
+int wxWindowOS2::GetCharHeight() const
+{
+ HPS hPs;
+ FONTMETRICS vFontMetrics;
+ BOOL bRc;
+
+ hPs = ::WinGetPS(GetHwnd());
+
+ if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics))
+ {
+ ::WinReleasePS(hPs);
+ return (0);
+ }
+ ::WinReleasePS(hPs);
+ return(vFontMetrics.lMaxAscender + vFontMetrics.lMaxDescender);
+} // end of wxWindowOS2::GetCharHeight
+
+int wxWindowOS2::GetCharWidth() const
+{
+ HPS hPs;
+ FONTMETRICS vFontMetrics;
+
+ hPs = ::WinGetPS(GetHwnd());
+
+ if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics))
+ {
+ ::WinReleasePS(hPs);
+ return (0);
+ }
+ ::WinReleasePS(hPs);
+ return(vFontMetrics.lAveCharWidth);
+} // end of wxWindowOS2::GetCharWidth
+
+void wxWindowOS2::GetTextExtent(
+ const wxString& rString
+, int* pX
+, int* pY
+, int* pDescent
+, int* pExternalLeading
+, const wxFont* pTheFont
+) const
+{
+ const wxFont* pFontToUse = pTheFont;
+ HPS hPs;
+
+ hPs = ::WinGetPS(GetHwnd());
+/*
+// TODO: Will have to play with fonts later
+
+ if (!pFontToUse)
+ pFontToUse = &m_font;
+
+ HFONT hFnt = 0;
+ HFONT hFfontOld = 0;
+
+ if (pFontToUse && pFontToUse->Ok())
+ {
+ ::GpiCreateLog
+ hFnt = (HFONT)((wxFont *)pFontToUse)->GetResourceHandle(); // const_cast
+ if (hFnt)
+ hFontOld = (HFONT)SelectObject(dc,fnt);
+ }
+
+ SIZE sizeRect;
+ TEXTMETRIC tm;
+ GetTextExtentPoint(dc, string, (int)string.Length(), &sizeRect);
+ GetTextMetrics(dc, &tm);
+
+ if ( fontToUse && fnt && hfontOld )
+ SelectObject(dc, hfontOld);
+
+ ReleaseDC(hWnd, dc);
+
+ if ( x )
+ *x = sizeRect.cx;
+ if ( y )
+ *y = sizeRect.cy;
+ if ( descent )
+ *descent = tm.tmDescent;
+ if ( externalLeading )
+ *externalLeading = tm.tmExternalLeading;
+*/
+ ::WinReleasePS(hPs);
+}
+
+#if wxUSE_CARET && WXWIN_COMPATIBILITY
+// ---------------------------------------------------------------------------
+// Caret manipulation
+// ---------------------------------------------------------------------------
+
+void wxWindowOS2::CreateCaret(
+ int nWidth
+, int nHeight
+)
+{
+ SetCaret(new wxCaret( this
+ ,nWidth
+ ,nHeight
+ ));
+} // end of wxWindowOS2::CreateCaret
+
+void wxWindowOS2::CreateCaret(
+ const wxBitmap* pBitmap
+)
+{
+ wxFAIL_MSG("not implemented");
+} // end of wxWindowOS2::CreateCaret
+
+void wxWindowOS2::ShowCaret(
+ bool bShow
+)
+{
+ wxCHECK_RET( m_caret, "no caret to show" );
+
+ m_caret->Show(bShow);
+} // end of wxWindowOS2::ShowCaret
+
+void wxWindowOS2::DestroyCaret()
+{
+ SetCaret(NULL);
+} // end of wxWindowOS2::DestroyCaret
+
+void wxWindowOS2::SetCaretPos(
+ int nX
+, int nY)
+{
+ wxCHECK_RET( m_caret, "no caret to move" );
+
+ m_caret->Move( nX
+ ,nY
+ );
+} // end of wxWindowOS2::SetCaretPos
+
+void wxWindowOS2::GetCaretPos(
+ int* pX
+, int* pY
+) const
+{
+ wxCHECK_RET( m_caret, "no caret to get position of" );
+
+ m_caret->GetPosition( pX
+ ,pY
+ );
+} // end of wxWindowOS2::GetCaretPos
+
+#endif //wxUSE_CARET
+
+// ---------------------------------------------------------------------------
+// popup menu
+// ---------------------------------------------------------------------------
+
+static void wxYieldForCommandsOnly()
+{
+ //
+ // Peek all WM_COMMANDs (it will always return WM_QUIT too but we don't
+ // want to process it here)
+ //
+ QMSG vMsg;
+
+ while (::WinPeekMsg( vHabmain
+ ,&vMsg
+ ,(HWND)0
+ ,WM_COMMAND
+ ,WM_COMMAND
+ ,PM_REMOVE
+ ) && vMsg.msg != WM_QUIT)
+ {
+ wxTheApp->DoMessage((WXMSG*)&vMsg);
+ }
+}
+
+bool wxWindowOS2::DoPopupMenu(
+ wxMenu* pMenu
+, int nX
+, int nY
+)
+{
+ HWND hWnd = GetHwnd();
+ HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0;
+ HWND hMenu = GetHmenuOf(pMenu);
+
+ pMenu->SetInvokingWindow(this);
+ pMenu->UpdateUI();
+
+ DoClientToScreen( &nX
+ ,&nY
+ );
+ wxCurrentPopupMenu = pMenu;
+
+ ::WinPopupMenu( hWndParent
+ ,hWnd
+ ,hMenu
+ ,nX
+ ,nY
+ ,0L
+ ,PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2 | PU_KEYBOARD
+ );
+ // we need to do it righ now as otherwise the events are never going to be
+ // sent to wxCurrentPopupMenu from HandleCommand()
+ //
+ // note that even eliminating (ugly) wxCurrentPopupMenu global wouldn't
+ // help and we'd still need wxYieldForCommandsOnly() as the menu may be
+ // destroyed as soon as we return (it can be a local variable in the caller
+ // for example) and so we do need to process the event immediately
+ wxYieldForCommandsOnly();
+ wxCurrentPopupMenu = NULL;
+
+ pMenu->SetInvokingWindow(NULL);
+ return TRUE;
+} // end of wxWindowOS2::DoPopupMenu
+
+// ===========================================================================
+// pre/post message processing
+// ===========================================================================
+
+MRESULT wxWindowOS2::OS2DefWindowProc(
+ WXUINT uMsg
+, WXWPARAM wParam
+, WXLPARAM lParam
+)
+{
+ if (m_fnOldWndProc)
+ return (MRESULT)m_fnOldWndProc(GetHWND(), (ULONG)uMsg, (MPARAM)wParam, (MPARAM)lParam);
+ else
+ return ::WinDefWindowProc(GetHWND(), (ULONG)uMsg, (MPARAM)wParam, (MPARAM)lParam);
+} // end of wxWindowOS2::OS2DefWindowProc
+
+bool wxWindowOS2::OS2ProcessMessage(
+ WXMSG* pMsg
+)
+{
+ QMSG* pQMsg = (QMSG*)pMsg;
+
+ if (m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL))
+ {
+ //
+ // Intercept dialog navigation keys
+ //
+ bool bProcess = TRUE;
+ USHORT uKeyFlags = SHORT1FROMMP(pQMsg->mp1);
+
+ if (uKeyFlags & KC_KEYUP)
+ bProcess = FALSE;
+
+ if (uKeyFlags & KC_ALT)
+ bProcess = FALSE;
+
+ if (!(uKeyFlags & KC_VIRTUALKEY))
+ bProcess = FALSE;
+
+ if (bProcess)
+ {
+ bool bCtrlDown = IsCtrlDown();
+ bool bShiftDown = IsShiftDown();
+
+ //
+ // WM_QUERYDLGCODE: ask the control if it wants the key for itself,
+ // don't process it if it's the case (except for Ctrl-Tab/Enter
+ // combinations which are always processed)
+ //
+ ULONG ulDlgCode = 0;
+
+ if (!bCtrlDown)
+ {
+ ulDlgCode = (ULONG)::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0);
+ }
+
+ bool bForward = TRUE;
+ bool bWindowChange = FALSE;
+
+ switch (SHORT2FROMMP(pQMsg->mp2))
+ {
+ //
+ // Going to make certain assumptions about specific types of controls
+ // here, so we may have to alter some things later if they prove invalid
+ //
+ case VK_TAB:
+ //
+ // Shift tabl will always be a nav-key but tabs may be wanted
+ //
+ if (!bShiftDown)
+ {
+ bProcess = FALSE;
+ }
+ else
+ {
+ //
+ // Entry Fields want tabs for themselve usually
+ //
+ switch (ulDlgCode)
+ {
+ case DLGC_ENTRYFIELD:
+ case DLGC_MLE:
+ bProcess = TRUE;
+ break;
+
+ default:
+ bProcess = FALSE;
+ }
+
+ //
+ // Ctrl-Tab cycles thru notebook pages
+ //
+ bWindowChange = bCtrlDown;
+ bForward = !bShiftDown;
+ }
+ break;
+
+ case VK_UP:
+ case VK_LEFT:
+ if (bCtrlDown)
+ bProcess = FALSE;
+ else
+ bForward = FALSE;
+ break;
+
+ case VK_DOWN:
+ case VK_RIGHT:
+ if (bCtrlDown)
+ bProcess = FALSE;
+ break;
+
+ case VK_ENTER:
+ {
+ if (bCtrlDown)
+ {
+ //
+ // ctrl-enter is not processed
+ //
+ return FALSE;
+ }
+ else if (ulDlgCode & DLGC_BUTTON)
+ {
+ //
+ // buttons want process Enter themselevs
+ //
+ bProcess = FALSE;
+ }
+ else
+ {
+ wxButton* pBtn = wxDynamicCast( GetDefaultItem()
+ ,wxButton
+ );
+
+ if (pBtn && pBtn->IsEnabled())
+ {
+ //
+ // If we do have a default button, do press it
+ //
+ pBtn->OS2Command(BN_CLICKED, 0 /* unused */);
+ return TRUE;
+ }
+ // else: but if it does not it makes sense to make
+ // it work like a TAB - and that's what we do.
+ // Note that Ctrl-Enter always works this way.
+ }
+ }
+ break;
+
+ default:
+ bProcess = FALSE;
+ }
+
+ if (bProcess)
+ {
+ wxNavigationKeyEvent vEvent;
+
+ vEvent.SetDirection(bForward);
+ vEvent.SetWindowChange(bWindowChange);
+ vEvent.SetEventObject(this);
+
+ if (GetEventHandler()->ProcessEvent(vEvent))
+ {
+ wxButton* pBtn = wxDynamicCast(FindFocus(), wxButton);
+
+ if (pBtn)
+ {
+ //
+ // The button which has focus should be default
+ //
+ pBtn->SetDefault();
+ }
+ return TRUE;
+ }
+ }
+ }
+ //
+ // Let Dialogs process
+ //
+ if (::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0));
+ return TRUE;
+ }
+
+#if wxUSE_TOOLTIPS
+ if ( m_tooltip )
+ {
+ // relay mouse move events to the tooltip control
+ QMSG* pQMsg = (QMSG*)pMsg;
+
+ if (pQMsg->msg == WM_MOUSEMOVE )
+ m_tooltip->RelayEvent(pMsg);
+ }
+#endif // wxUSE_TOOLTIPS
+
+ return FALSE;
+} // end of wxWindowOS2::OS2ProcessMessage
+
+bool wxWindowOS2::OS2TranslateMessage(
+ WXMSG* pMsg
+)
+{
+#if wxUSE_ACCEL
+ return m_acceleratorTable.Translate(m_hWnd, pMsg);
+#else
+ return FALSE;
+#endif //wxUSE_ACCEL
+} // end of wxWindowOS2::OS2TranslateMessage
+
+// ---------------------------------------------------------------------------
+// message params unpackers
+// ---------------------------------------------------------------------------
+
+void wxWindowOS2::UnpackCommand(
+ WXWPARAM wParam
+, WXLPARAM lParam
+, WORD* pId
+, WXHWND* phWnd
+, WORD* pCmd
+)
+{
+ *pId = LOWORD(wParam);
+ *phWnd = NULL; // or may be GetHWND() ?
+ *pCmd = LOWORD(lParam);
+} // end of wxWindowOS2::UnpackCommand
+
+void wxWindowOS2::UnpackActivate(
+ WXWPARAM wParam
+, WXLPARAM lParam
+, WXWORD* pState
+, WXHWND* phWnd
+)
+{
+ *pState = LOWORD(wParam);
+ *phWnd = (WXHWND)lParam;
+} // end of wxWindowOS2::UnpackActivate
+
+void wxWindowOS2::UnpackScroll(
+ WXWPARAM wParam
+, WXLPARAM lParam
+, WXWORD* pCode
+, WXWORD* pPos
+, WXHWND* phWnd
+)
+{
+ ULONG ulId;
+ HWND hWnd;
+
+ ulId = (ULONG)LONGFROMMP(wParam);
+ hWnd = ::WinWindowFromID(GetHwnd(), ulId);
+ if (hWnd == m_hWndScrollBarHorz || hWnd == m_hWndScrollBarVert)
+ *phWnd = NULLHANDLE;
+ else
+ *phWnd = hWnd;
+
+ *pPos = SHORT1FROMMP(lParam);
+ *pCode = SHORT2FROMMP(lParam);
+} // end of wxWindowOS2::UnpackScroll
+
+void wxWindowOS2::UnpackMenuSelect(
+ WXWPARAM wParam
+, WXLPARAM lParam
+, WXWORD* pItem
+, WXWORD* pFlags
+, WXHMENU* phMenu
+)
+{
+ *pItem = (WXWORD)LOWORD(wParam);
+ *pFlags = HIWORD(wParam);
+ *phMenu = (WXHMENU)lParam;
+} // end of wxWindowOS2::UnpackMenuSelect
+
+// ---------------------------------------------------------------------------
+// Main wxWindows window proc and the window proc for wxWindow
+// ---------------------------------------------------------------------------
+
+//
+// Hook for new window just as it's being created, when the window isn't yet
+// associated with the handle
+//
+wxWindow* wxWndHook = NULL;
+
+//
+// Main window proc
+//
+MRESULT EXPENTRY wxWndProc(
+ HWND hWnd
+, ULONG ulMsg
+, MPARAM wParam
+, MPARAM lParam
+)
+{
+ //
+ // Trace all ulMsgs - useful for the debugging
+ //
+#ifdef __WXDEBUG__
+ wxLogTrace(wxTraceMessages, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"),
+ wxGetMessageName(ulMsg), wParam, lParam);
+#endif // __WXDEBUG__
+
+ wxWindow* pWnd = wxFindWinFromHandle((WXHWND)hWnd);
+
+ //
+ // When we get the first message for the HWND we just created, we associate
+ // it with wxWindow stored in wxWndHook
+ //
+ if (!pWnd && wxWndHook)
+ {
+ wxAssociateWinWithHandle(hWnd, wxWndHook);
+ pWnd = wxWndHook;
+ wxWndHook = NULL;
+ pWnd->SetHWND((WXHWND)hWnd);
+ }
+
+ MRESULT rc = (MRESULT)0;
+
+
+ //
+ // Stop right here if we don't have a valid handle in our wxWindow object.
+ //
+ if (pWnd && !pWnd->GetHWND())
+ {
+ pWnd->SetHWND((WXHWND) hWnd);
+ rc = pWnd->OS2DefWindowProc(ulMsg, wParam, lParam );
+ pWnd->SetHWND(0);
+ }
+ else
+ {
+ if (pWnd)
+ rc = pWnd->OS2WindowProc(ulMsg, wParam, lParam);
+ else
+ rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam);
+ }
+
+ return rc;
+} // end of wxWndProc
+
+//
+// We will add (or delete) messages we need to handle at this default
+// level as we go
+//
+MRESULT wxWindowOS2::OS2WindowProc(
+ WXUINT uMsg
+, WXWPARAM wParam
+, WXLPARAM lParam
+)
+{
+ //
+ // Did we process the uMsg?
+ //
+ bool bProcessed = FALSE;
+ bool bAllow;
+ MRESULT mResult;
+ WXHICON hIcon;
+ WXHBRUSH hBrush;
+
+ //
+ // For most messages we should return 0 when we do process the message
+ //
+ mResult = (MRESULT)0;
+
+ switch (uMsg)
+ {
+ case WM_CREATE:
+ {
+ bool bMayCreate;
+
+ bProcessed = HandleCreate( (WXLPCREATESTRUCT)lParam
+ ,&bMayCreate
+ );
+ if (bProcessed)
+ {
+ //
+ // Return 0 to bAllow window creation
+ //
+ mResult = (MRESULT)(bMayCreate ? 0 : -1);
+ }
+ }
+ break;
+
+ case WM_DESTROY:
+ HandleDestroy();
+ bProcessed = TRUE;
+ break;
+
+ case WM_MOVE:
+ bProcessed = HandleMove( LOWORD(lParam)
+ ,HIWORD(lParam)
+ );
+ break;
+
+ case WM_SIZE:
+ bProcessed = HandleSize( LOWORD(lParam)
+ ,HIWORD(lParam)
+ ,(WXUINT)wParam
+ );
+ break;
+
+ case WM_ACTIVATE:
+ {
+ WXWORD wState;
+ WXHWND hWnd;
+
+ UnpackActivate( wParam
+ ,lParam
+ ,&wState
+ ,&hWnd
+ );
+
+ bProcessed = HandleActivate( wState
+ ,(WXHWND)hWnd
+ );
+ bProcessed = FALSE;
+ }
+ break;
+
+ case WM_SETFOCUS:
+ if (SHORT1FROMMP((MPARAM)lParam) == TRUE)
+ bProcessed = HandleSetFocus((WXHWND)(HWND)wParam);
+ else
+ bProcessed = HandleKillFocus((WXHWND)(HWND)wParam);
+ break;
+
+ case WM_PAINT:
+ bProcessed = HandlePaint();
+ break;
+
+ case WM_CLOSE:
+ //
+ // Don't let the DefWindowProc() destroy our window - we'll do it
+ // ourselves in ~wxWindow
+ //
+ bProcessed = TRUE;
+ mResult = (MRESULT)TRUE;
+ break;
+
+ case WM_SHOW:
+ bProcessed = HandleShow(wParam != 0, (int)lParam);
+ break;
+
+ //
+ // Under OS2 PM Joysticks are treated just like mouse events
+ // The "Motion" events will be prevelent in joysticks
+ //
+ case WM_MOUSEMOVE:
+ case WM_BUTTON1DOWN:
+ case WM_BUTTON1UP:
+ case WM_BUTTON1DBLCLK:
+ case WM_BUTTON1MOTIONEND:
+ case WM_BUTTON1MOTIONSTART:
+ case WM_BUTTON2DOWN:
+ case WM_BUTTON2UP:
+ case WM_BUTTON2DBLCLK:
+ case WM_BUTTON2MOTIONEND:
+ case WM_BUTTON2MOTIONSTART:
+ case WM_BUTTON3DOWN:
+ case WM_BUTTON3UP:
+ case WM_BUTTON3DBLCLK:
+ case WM_BUTTON3MOTIONEND:
+ case WM_BUTTON3MOTIONSTART:
+ {
+ short x = LOWORD(lParam);
+ short y = HIWORD(lParam);
+
+ bProcessed = HandleMouseEvent(uMsg, x, y, (WXUINT)wParam);
+ }
+ break;
+ case WM_SYSCOMMAND:
+ bProcessed = HandleSysCommand(wParam, lParam);
+ break;
+
+ case WM_COMMAND:
+ {
+ WORD id, cmd;
+ WXHWND hwnd;
+ UnpackCommand(wParam, lParam, &id, &hwnd, &cmd);
+
+ bProcessed = HandleCommand(id, cmd, hwnd);
+ }
+ break;
+
+ //
+ // For these messages we must return TRUE if process the message
+ //
+ case WM_DRAWITEM:
+ case WM_MEASUREITEM:
+ {
+ int nIdCtrl = (UINT)wParam;
+
+ if ( uMsg == WM_DRAWITEM )
+ {
+ bProcessed = OS2OnDrawItem(nIdCtrl,
+ (WXDRAWITEMSTRUCT *)lParam);
+ }
+ else
+ {
+ bProcessed = OS2OnMeasureItem(nIdCtrl,
+ (WXMEASUREITEMSTRUCT *)lParam);
+ }
+
+ if ( bProcessed )
+ mResult = (MRESULT)TRUE;
+ }
+ break;
+
+ case WM_QUERYDLGCODE:
+ if ( m_lDlgCode )
+ {
+ mResult = (MRESULT)m_lDlgCode;
+ bProcessed = TRUE;
+ }
+ //
+ //else: get the dlg code from the DefWindowProc()
+ //
+ break;
+
+ //
+ // In OS/2 PM all keyboard events are of the WM_CHAR type. Virtual key and key-up
+ // and key-down events are obtained from the WM_CHAR params.
+ //
+ case WM_CHAR:
+ {
+ USHORT uKeyFlags = SHORT1FROMMP((MPARAM)wParam);
+
+ if (uKeyFlags & KC_KEYUP)
+ {
+ bProcessed = HandleKeyUp((WXDWORD)wParam, lParam);
+ break;
+ }
+ else // keydown event
+ {
+ //
+ // If this has been processed by an event handler,
+ // return 0 now (we've handled it). DON't RETURN
+ // we still need to process further
+ //
+ HandleKeyDown((WXDWORD)wParam, lParam);
+ if (uKeyFlags & KC_VIRTUALKEY)
+ {
+ USHORT uVk = SHORT2FROMMP((MPARAM)lParam);
+
+ //
+ // We consider these message "not interesting" to OnChar
+ //
+ if (uVk == VK_SHIFT || uVk == VK_CTRL )
+ {
+ bProcessed = TRUE;
+ break;
+ }
+ switch(uVk)
+ {
+ //
+ // Avoid duplicate messages to OnChar for these ASCII keys: they
+ // will be translated by TranslateMessage() and received in WM_CHAR
+ case VK_ESC:
+ case VK_SPACE:
+ case VK_ENTER:
+ case VK_BACKSPACE:
+ case VK_TAB:
+ // But set processed to FALSE, not TRUE to still pass them to
+ // the control's default window proc - otherwise built-in
+ // keyboard handling won't work
+ bProcessed = FALSE;
+ break;
+
+ case VK_LEFT:
+ case VK_RIGHT:
+ case VK_DOWN:
+ case VK_UP:
+ default:
+ bProcessed = HandleChar((WXDWORD)wParam, lParam);
+ }
+ break;
+ }
+ else // WM_CHAR -- Always an ASCII character
+ {
+ bProcessed = HandleChar((WXDWORD)wParam, lParam, TRUE);
+ break;
+ }
+ }
+ }
+
+ case WM_HSCROLL:
+ case WM_VSCROLL:
+ {
+ WXWORD wCode;
+ WXWORD wPos;
+ WXHWND hWnd;
+ UnpackScroll( wParam
+ ,lParam
+ ,&wCode
+ ,&wPos
+ ,&hWnd
+ );
+
+ bProcessed = OS2OnScroll( uMsg == WM_HSCROLL ? wxHORIZONTAL
+ : wxVERTICAL
+ ,wCode
+ ,wPos
+ ,hWnd
+ );
+ }
+ break;
+
+#if defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
+ case WM_CTLCOLORCHANGE:
+ {
+ bProcessed = HandleCtlColor(&hBrush);
+ }
+ break;
+#endif
+ case WM_ERASEBACKGROUND:
+ //
+ // Returning TRUE to requestw PM to paint the window background
+ // in SYSCLR_WINDOW. We don't really want that
+ //
+ bProcessed = HandleEraseBkgnd((WXHDC)(HPS)wParam);
+ mResult = (MRESULT)(FALSE);
+ break;
+
+ //
+ // Instead of CTLCOLOR messages PM sends QUERYWINDOWPARAMS to
+ // things such as colors and fonts and such
+ //
+ case WM_QUERYWINDOWPARAMS:
+ {
+ PWNDPARAMS pWndParams = (PWNDPARAMS)wParam;
+
+ bProcessed = HandleWindowParams( pWndParams
+ ,lParam
+ );
+ }
+ break;
+
+ // the return value for this message is ignored
+ case WM_SYSCOLORCHANGE:
+ bProcessed = HandleSysColorChange();
+ break;
+
+ case WM_REALIZEPALETTE:
+ bProcessed = HandlePaletteChanged();
+ break;
+
+ case WM_PRESPARAMCHANGED:
+ bProcessed = HandlePresParamChanged(wParam);
+ break;
+
+
+ // move all drag and drops to wxDrg
+ case WM_ENDDRAG:
+ bProcessed = HandleEndDrag(wParam);
+ break;
+
+ case WM_INITDLG:
+ bProcessed = HandleInitDialog((WXHWND)(HWND)wParam);
+
+ if ( bProcessed )
+ {
+ // we never set focus from here
+ mResult = FALSE;
+ }
+ break;
+
+ // wxFrame specific message
+ case WM_MINMAXFRAME:
+ bProcessed = HandleGetMinMaxInfo((PSWP)wParam);
+ break;
+
+ case WM_SYSVALUECHANGED:
+ // TODO: do something
+ mResult = (MRESULT)TRUE;
+ break;
+
+ //
+ // Comparable to WM_SETPOINTER for windows, only for just controls
+ //
+ case WM_CONTROLPOINTER:
+ bProcessed = HandleSetCursor( SHORT1FROMMP(wParam) // Control ID
+ ,(HWND)lParam // Cursor Handle
+ );
+ if (bProcessed )
+ {
+ //
+ // Returning TRUE stops the DefWindowProc() from further
+ // processing this message - exactly what we need because we've
+ // just set the cursor.
+ //
+ mResult = (MRESULT)TRUE;
+ }
+ break;
+ }
+ if (!bProcessed)
+ {
+#ifdef __WXDEBUG__
+ wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."),
+ wxGetMessageName(uMsg));
+#endif // __WXDEBUG__
+ if (IsKindOf(CLASSINFO(wxFrame)))
+ mResult = ::WinDefWindowProc(m_hWnd, uMsg, wParam, lParam);
+ else
+ mResult = OS2DefWindowProc(uMsg, wParam, lParam);
+ }
+ return mResult;
+} // end of wxWindowOS2::OS2WindowProc
+
+//
+// Dialog window proc
+//
+MRESULT wxDlgProc(
+ HWND hWnd
+, UINT uMsg
+, MPARAM wParam
+, MPARAM lParam)
+{
+ if (uMsg == WM_INITDLG)
+ {
+ //
+ // For this message, returning TRUE tells system to set focus to the
+ // first control in the dialog box
+ //
+ return (MRESULT)TRUE;
+ }
+ else
+ {
+ //
+ // For all the other ones, FALSE means that we didn't process the
+ // message
+ //
+ return (MRESULT)0;
+ }
+} // end of wxDlgProc
+
+wxWindow* wxFindWinFromHandle(
+ WXHWND hWnd
+)
+{
+ wxNode* pNode = wxWinHandleList->Find((long)hWnd);
+
+ if (!pNode)
+ return NULL;
+ return (wxWindow *)pNode->Data();
+} // end of wxFindWinFromHandle
+
+void wxAssociateWinWithHandle(
+ HWND hWnd
+, wxWindow* pWin
+)
+{
+ //
+ // Adding NULL hWnd is (first) surely a result of an error and
+ // (secondly) breaks menu command processing
+ //
+ wxCHECK_RET( hWnd != (HWND)NULL,
+ wxT("attempt to add a NULL hWnd to window list ignored") );
+
+
+ wxWindow* pOldWin = wxFindWinFromHandle((WXHWND) hWnd);
+
+ if (pOldWin && (pOldWin != pWin))
+ {
+ wxString str(pWin->GetClassInfo()->GetClassName());
+ wxLogError( "Bug! Found existing HWND %X for new window of class %s"
+ ,(int)hWnd
+ ,(const char*)str
+ );
+ }
+ else if (!pOldWin)
+ {
+ wxWinHandleList->Append( (long)hWnd
+ ,pWin
+ );
+ }
+} // end of wxAssociateWinWithHandle
+
+void wxRemoveHandleAssociation(
+ wxWindow* pWin
+)
+{
+ wxWinHandleList->DeleteObject(pWin);
+} // end of wxRemoveHandleAssociation
+
+//
+// Default destroyer - override if you destroy it in some other way
+// (e.g. with MDI child windows)
+//
+void wxWindowOS2::OS2DestroyWindow()
+{
+}
+
+void wxWindowOS2::OS2DetachWindowMenu()
+{
+ if (m_hMenu)
+ {
+ HMENU hMenu = (HMENU)m_hMenu;
+
+ int nN = (int)::WinSendMsg(hMenu, MM_QUERYITEMCOUNT, 0, 0);
+ int i;
+
+ for (i = 0; i < nN; i++)
+ {
+ wxChar zBuf[100];
+ int nChars = (int)::WinSendMsg( hMenu
+ ,MM_QUERYITEMTEXT
+ ,MPFROM2SHORT(i, nN)
+ ,zBuf
+ );
+ if (!nChars)
+ {
+ wxLogLastError(wxT("GetMenuString"));
+ continue;
+ }
+
+ if (wxStrcmp(zBuf, wxT("&Window")) == 0)
+ {
+ ::WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0);
+ break;
+ }
+ }
+ }
+} // end of wxWindowOS2::OS2DetachWindowMenu
+
+bool wxWindowOS2::OS2Create(
+ WXHWND hParent
+, PSZ zClass
+, const wxChar* zTitle
+, WXDWORD dwStyle
+, long lX
+, long lY
+, long lWidth
+, long lHeight
+, WXHWND hOwner
+, WXHWND hZOrder
+, unsigned long ulId
+, void* pCtlData
+, void* pPresParams
+, WXDWORD dwExStyle
+)
+{
+ ERRORID vError;
+ wxString sError;
+ long lX1 = 0L;
+ long lY1 = 0L;
+ long lWidth1 = 20L;
+ long lHeight1 = 20L;
+ int nControlId = 0;
+ int nNeedsubclass = 0;
+ PCSZ pszClass = zClass;
+
+ //
+ // Find parent's size, if it exists, to set up a possible default
+ // panel size the size of the parent window
+ //
+ RECTL vParentRect;
+ HWND hWndClient;
+
+ lX1 = lX;
+ lY1 = lY;
+ if (lWidth > -1L)
+ lWidth1 = lWidth;
+ if (lHeight > -1L)
+ lHeight1 = lHeight;
+
+ wxWndHook = this;
+
+ //
+ // check to see if the new window is a standard control
+ //
+ if ((ULONG)zClass == (ULONG)WC_BUTTON ||
+ (ULONG)zClass == (ULONG)WC_COMBOBOX ||
+ (ULONG)zClass == (ULONG)WC_CONTAINER ||
+ (ULONG)zClass == (ULONG)WC_ENTRYFIELD ||
+ (ULONG)zClass == (ULONG)WC_FRAME ||
+ (ULONG)zClass == (ULONG)WC_LISTBOX ||
+ (ULONG)zClass == (ULONG)WC_MENU ||
+ (ULONG)zClass == (ULONG)WC_NOTEBOOK ||
+ (ULONG)zClass == (ULONG)WC_SCROLLBAR ||
+ (ULONG)zClass == (ULONG)WC_SPINBUTTON ||
+ (ULONG)zClass == (ULONG)WC_STATIC ||
+ (ULONG)zClass == (ULONG)WC_TITLEBAR ||
+ (ULONG)zClass == (ULONG)WC_VALUESET
+ )
+ {
+ nControlId = ulId;
+ }
+ else
+ {
+ // no standard controls
+ if(wxString (wxT("wxFrameClass")) == wxString(zClass) )
+ {
+ pszClass = WC_FRAME;
+ nNeedsubclass = 1;
+ }
+ else
+ {
+ nControlId = ulId;
+ if(nControlId < 0)
+ nControlId = FID_CLIENT;
+ }
+ }
+
+ //
+ // We will either have a registered class via string name or a standard PM Class via a long
+ //
+ m_hWnd = (WXHWND)::WinCreateWindow( (HWND)hParent
+ ,zClass
+ ,(PSZ)zTitle ? zTitle : wxT("")
+ ,(ULONG)dwStyle
+ ,(LONG)lX1
+ ,(LONG)lY1
+ ,(LONG)lWidth
+ ,(LONG)lHeight
+ ,hOwner
+ ,HWND_TOP
+ ,(ULONG)nControlId
+ ,pCtlData
+ ,pPresParams
+ );
+ if (!m_hWnd)
+ {
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ wxLogError("Can't create window of class %s!. Error: %s\n", zClass, sError);
+ return FALSE;
+ }
+ m_dwExStyle = dwExStyle;
+ ::WinSetWindowULong(m_hWnd, QWL_USER, (ULONG) this);
+ wxWndHook = NULL;
+
+#ifdef __WXDEBUG__
+ wxNode* pNode = wxWinHandleList->Member(this);
+
+ if (pNode)
+ {
+ HWND hWnd = (HWND)pNode->GetKeyInteger();
+
+ if (hWnd != (HWND)m_hWnd)
+
+ {
+ wxLogError("A second HWND association is being added for the same window!");
+ }
+ }
+#endif
+ wxAssociateWinWithHandle((HWND)m_hWnd
+ ,this
+ );
+ //
+ // Now need to subclass window.
+ //
+ if(!nNeedsubclass)
+ {
+ wxAssociateWinWithHandle((HWND)m_hWnd,this);
+ }
+ else
+ {
+ SubclassWin(GetHWND());
+ }
+ return TRUE;
+} // end of wxWindowOS2::OS2Create
+
+// ===========================================================================
+// OS2 PM message handlers
+// ===========================================================================
+
+// ---------------------------------------------------------------------------
+// window creation/destruction
+// ---------------------------------------------------------------------------
+
+bool wxWindowOS2::HandleCreate(
+ WXLPCREATESTRUCT vCs
+, bool* pbMayCreate
+)
+{
+ wxWindowCreateEvent vEvent(this);
+
+ (void)GetEventHandler()->ProcessEvent(vEvent);
+ *pbMayCreate = TRUE;
+ return TRUE;
+} // end of wxWindowOS2::HandleCreate
+
+bool wxWindowOS2::HandleDestroy()
+{
+ wxWindowDestroyEvent vEvent(this);
+
+ (void)GetEventHandler()->ProcessEvent(vEvent);
+
+ //
+ // Delete our drop target if we've got one
+ //
+#if wxUSE_DRAG_AND_DROP
+ if (m_dropTarget != NULL)
+ {
+ m_dropTarget->Revoke(m_hWnd);
+ delete m_dropTarget;
+ m_dropTarget = NULL;
+ }
+#endif // wxUSE_DRAG_AND_DROP
+
+ //
+ // WM_DESTROY handled
+ //
+ return TRUE;
+} // end of wxWindowOS2::HandleDestroy
+
+// ---------------------------------------------------------------------------
+// activation/focus
+// ---------------------------------------------------------------------------
+void wxWindowOS2::OnSetFocus(
+ wxFocusEvent& rEvent
+)
+{
+ rEvent.Skip();
+} // end of wxWindowOS2::OnSetFocus
+
+bool wxWindowOS2::HandleActivate(
+ int nState
+, WXHWND WXUNUSED(hActivate)
+)
+{
+ wxActivateEvent vEvent( wxEVT_ACTIVATE
+ ,(bool)nState
+ ,m_windowId
+ );
+ vEvent.SetEventObject(this);
+ return GetEventHandler()->ProcessEvent(vEvent);
+} // end of wxWindowOS2::HandleActivate
+
+bool wxWindowOS2::HandleSetFocus(
+ WXHWND WXUNUSED(hWnd)
+)
+{
+#if wxUSE_CARET
+ //
+ // Deal with caret
+ //
+ if (m_caret)
+ {
+ m_caret->OnSetFocus();
+ }
+#endif // wxUSE_CARET
+
+#if wxUSE_TEXTCTRL
+ // If it's a wxTextCtrl don't send the event as it will be done
+ // after the control gets to process it from EN_FOCUS handler
+ if ( wxDynamicCastThis(wxTextCtrl) )
+ {
+ return FALSE;
+ }
+#endif // wxUSE_TEXTCTRL
+
+ wxFocusEvent vEvent(wxEVT_SET_FOCUS, m_windowId);
+
+ vEvent.SetEventObject(this);
+ return GetEventHandler()->ProcessEvent(vEvent);
+} // end of wxWindowOS2::HandleSetFocus
+
+bool wxWindowOS2::HandleKillFocus(
+ WXHWND WXUNUSED(hWnd)
+)
+{
+#if wxUSE_CARET
+ //
+ // Deal with caret
+ //
+ if (m_caret)
+ {
+ m_caret->OnKillFocus();
+ }
+#endif // wxUSE_CARET
+
+ wxFocusEvent vEvent( wxEVT_KILL_FOCUS
+ ,m_windowId
+ );
+
+ vEvent.SetEventObject(this);
+ return GetEventHandler()->ProcessEvent(vEvent);
+} // end of wxWindowOS2::HandleKillFocus
+
+// ---------------------------------------------------------------------------
+// miscellaneous
+// ---------------------------------------------------------------------------