+ ::WinSendMsg(GetHwnd(), WM_VRNENABLED, (MPARAM)TRUE, (MPARAM)0);
+
+ //
+ // We need to refresh everything or otherwise he invalidated area is not
+ // repainted.
+ //
+ Refresh();
+} // end of wxWindowOS2::Thaw
+
+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;
+ RECTL vRect;
+
+ if (IsKindOf(CLASSINFO(wxFrame)))
+ {
+ wxFrame* pFrame = wxDynamicCast(this, wxFrame);
+ hWnd = pFrame->GetFrame();
+ }
+ else
+ hWnd = GetHwnd();
+
+ ::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();
+ SWP vSwp;
+ POINTL vPoint;
+ wxWindow* pParent = GetParent();
+
+ //
+ // It would seem that WinQueryWindowRect would be the correlary to
+ // the WIN32 WinGetRect, but unlike WinGetRect which returns the window
+ // origin position in screen coordinates, WinQueryWindowRect returns it
+ // relative to itself, i.e. (0,0). To get the same under PM we must
+ // us WinQueryWindowPos. This call, unlike the WIN32 call, however,
+ // returns a position relative to it's parent, so no parent adujstments
+ // are needed under OS/2. Also, windows should be created using
+ // wxWindow coordinates, i.e 0,0 is the TOP left so vSwp will already
+ // reflect that.
+ //
+ ::WinQueryWindowPos(hWnd, &vSwp);
+
+ vPoint.x = vSwp.x;
+ vPoint.y = vSwp.y;
+
+ //
+ // 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).
+ //
+ if (pParent)
+ {
+ 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();
+ RECTL vRect;
+
+ ::WinQueryWindowRect(hWnd, &vRect);
+ if (IsKindOf(CLASSINFO(wxDialog)))
+ {
+ RECTL vTitle;
+ HWND hWndTitle;
+ //
+ // For a Dialog we have to explicitly request the client portion.
+ // For a Frame the hWnd IS the client window
+ //
+ hWndTitle = ::WinWindowFromID(hWnd, FID_TITLEBAR);
+ if (::WinQueryWindowRect(hWndTitle, &vTitle))
+ {
+ if (vTitle.yTop - vTitle.yBottom == 0)
+ {
+ //
+ // Dialog has not been created yet, use a default
+ //
+ vTitle.yTop = 20;
+ }
+ vRect.yTop -= (vTitle.yTop - vTitle.yBottom);
+ }
+
+ ULONG uStyle = ::WinQueryWindowULong(hWnd, QWL_STYLE);
+
+ //
+ // Deal with borders
+ //
+ if (uStyle & FCF_DLGBORDER)
+ {
+ vRect.xLeft += 4;
+ vRect.xRight -= 4;
+ vRect.yTop -= 4;
+ vRect.yBottom += 4;
+ }
+ else if (uStyle & FCF_SIZEBORDER)
+ {
+ vRect.xLeft += 4;
+ vRect.xRight -= 4;
+ vRect.yTop -= 4;
+ vRect.yBottom += 4;
+ }
+ else if (uStyle & FCF_BORDER)
+ {
+ vRect.xLeft += 2;
+ vRect.xRight -= 2;
+ vRect.yTop -= 2;
+ vRect.yBottom += 2;
+ }
+ else // make some kind of adjustment or top sizers ram into the titlebar!
+ {
+ vRect.xLeft += 3;
+ vRect.xRight -= 3;
+ vRect.yTop -= 3;
+ vRect.yBottom += 3;
+ }
+ }
+ if (pWidth)
+ *pWidth = vRect.xRight - vRect.xLeft;
+ if (pHeight)
+ *pHeight = vRect.yTop - vRect.yBottom;
+} // end of wxWindowOS2::DoGetClientSize
+
+void wxWindowOS2::DoMoveWindow(
+ int nX
+, int nY
+, int nWidth
+, int nHeight
+)
+{
+ RECTL vRect;
+ HWND hParent;
+ wxWindow* pParent = GetParent();
+
+ if (pParent && !IsKindOf(CLASSINFO(wxDialog)))
+ {
+ int nOS2Height = GetOS2ParentHeight(pParent);
+
+ nY = nOS2Height - (nY + nHeight);
+ }
+ else
+ {
+ RECTL vRect;
+
+ ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
+ nY = vRect.yTop - (nY + nHeight);
+ }
+ ::WinSetWindowPos( GetHwnd()
+ ,HWND_TOP
+ ,(LONG)nX
+ ,(LONG)nY
+ ,(LONG)nWidth
+ ,(LONG)nHeight
+ ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
+ );
+} // 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
+ //
+ //
+ // Must convert Y coords to test for equality under OS/2
+ //
+ int nY2 = nY;
+ wxWindow* pParent = (wxWindow*)GetParent();
+
+ if (pParent && !IsKindOf(CLASSINFO(wxDialog)))
+ {
+ int nOS2Height = GetOS2ParentHeight(pParent);
+
+ nY2 = nOS2Height - (nY2 + nHeight);
+ }
+ else
+ {
+ RECTL vRect;
+
+ ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
+ nY2 = vRect.yTop - (nY2 + nHeight);
+ }
+ if (nX == nCurrentX && nY2 == 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;
+ POINTL vPoint;
+ RECTL vRect;
+ RECTL vRect2;
+ RECTL vRect3;
+ HWND hClientWnd = (HWND)0;
+
+ hClientWnd = ::WinWindowFromID(hWnd, FID_CLIENT);
+ ::WinQueryWindowRect(hClientWnd, &vRect2);
+ ::WinQueryWindowRect(hWnd, &vRect);
+ ::WinQueryWindowRect(hParentWnd, &vRect3);
+
+ int nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth;
+ int nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight;
+
+ 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;
+
+ 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
+{
+ POINTL avPoint[TXTBOX_COUNT];
+ POINTL vPtMin;
+ POINTL vPtMax;
+ int i;
+ int l;
+ FONTMETRICS vFM; // metrics structure
+ BOOL bRc;
+ char* pStr;
+ ERRORID vErrorCode; // last error id code
+ HPS hPS;
+
+
+ hPS = ::WinGetPS(GetHwnd());
+
+ l = rString.Length();
+ if (l > 0L)
+ {
+ pStr = (PCH)rString.c_str();
+
+ //
+ // In world coordinates.
+ //
+ bRc = ::GpiQueryTextBox( hPS
+ ,l
+ ,pStr
+ ,TXTBOX_COUNT // return maximum information
+ ,avPoint // array of coordinates points
+ );
+ if (bRc)
+ {
+ vPtMin.x = avPoint[0].x;
+ vPtMax.x = avPoint[0].x;
+ vPtMin.y = avPoint[0].y;
+ vPtMax.y = avPoint[0].y;
+ for (i = 1; i < 4; i++)
+ {
+ if(vPtMin.x > avPoint[i].x) vPtMin.x = avPoint[i].x;
+ if(vPtMin.y > avPoint[i].y) vPtMin.y = avPoint[i].y;
+ if(vPtMax.x < avPoint[i].x) vPtMax.x = avPoint[i].x;
+ if(vPtMax.y < avPoint[i].y) vPtMax.y = avPoint[i].y;
+ }
+ bRc = ::GpiQueryFontMetrics( hPS
+ ,sizeof(FONTMETRICS)
+ ,&vFM
+ );
+ if (!bRc)
+ {
+ vPtMin.x = 0;
+ vPtMin.y = 0;
+ vPtMax.x = 0;
+ vPtMax.y = 0;
+ }
+ }
+ else
+ {
+ vPtMin.x = 0;
+ vPtMin.y = 0;
+ vPtMax.x = 0;
+ vPtMax.y = 0;
+ }
+ }
+ else
+ {
+ vPtMin.x = 0;
+ vPtMin.y = 0;
+ vPtMax.x = 0;
+ vPtMax.y = 0;
+ }
+ if (pX)
+ *pX = (vPtMax.x - vPtMin.x + 1);
+ if (pY)
+ *pY = (vPtMax.y - vPtMin.y + 1);
+ if (pDescent)
+ {
+ if (bRc)
+ *pDescent = vFM.lMaxDescender;
+ else
+ *pDescent = 0;
+ }
+ if (pExternalLeading)
+ {
+ if (bRc)
+ *pExternalLeading = vFM.lExternalLeading;
+ else
+ *pExternalLeading = 0;
+ }
+ ::WinReleasePS(hPS);
+} // end of wxWindow::GetTextExtent
+
+bool wxWindowOS2::IsMouseInWindow() const
+{
+ //
+ // Get the mouse position
+ POINTL vPt;
+
+ ::WinQueryPointerPos(HWND_DESKTOP, &vPt);
+
+ //
+ // Find the window which currently has the cursor and go up the window
+ // chain until we find this window - or exhaust it
+ //
+ HWND hWnd = ::WinWindowFromPoint(HWND_DESKTOP, &vPt, TRUE);
+
+ while (hWnd && (hWnd != GetHwnd()))
+ hWnd = ::WinQueryWindow(hWnd, QW_PARENT);
+
+ return hWnd != NULL;
+} // end of wxWindowOS2::IsMouseInWindow
+
+#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
+// ---------------------------------------------------------------------------
+//
+#if wxUSE_MENUS_NATIVE
+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);
+ }
+}
+#endif // wxUSE_MENUS_NATIVE
+
+#if wxUSE_MENUS_NATIVE
+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 ;()
+ //
+ // 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
+#endif // wxUSE_MENUS_NATIVE
+
+// ===========================================================================
+// pre/post message processing
+// ===========================================================================
+
+MRESULT wxWindowOS2::OS2DefWindowProc(
+ WXUINT uMsg
+, WXWPARAM wParam
+, WXLPARAM lParam
+)
+{
+ if (m_fnOldWndProc)
+ return (MRESULT)m_fnOldWndProc(GetHWND(), uMsg, (MPARAM)wParam, (MPARAM)lParam);
+ else
+ return ::WinDefWindowProc(GetHWND(), uMsg, (MPARAM)wParam, (MPARAM)lParam);
+} // end of wxWindowOS2::OS2DefWindowProc
+
+bool wxWindowOS2::OS2ProcessMessage(
+ WXMSG* pMsg
+)
+{
+// wxUniversal implements tab traversal itself
+#ifndef __WXUNIVERSAL__
+ 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;
+ }
+#else
+ pMsg = pMsg; // just shut up the compiler
+#endif // __WXUNIVERSAL__
+
+#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 && !defined(__WXUNIVERSAL__)
+ return m_acceleratorTable.Translate(m_hWnd, pMsg);
+#else
+ pMsg = pMsg;
+ return FALSE;
+#endif //wxUSE_ACCEL
+} // end of wxWindowOS2::OS2TranslateMessage
+
+bool wxWindowOS2::OS2ShouldPreProcessMessage(
+ WXMSG* pMsg
+)
+{
+ // preprocess all messages by default
+ return TRUE;
+} // end of wxWindowOS2::OS2ShouldPreProcessMessage
+
+// ---------------------------------------------------------------------------
+// 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
+//
+wxWindowOS2* 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__
+
+ wxWindowOS2* 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;
+ MRESULT mResult;
+
+ //
+ // 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_WINDOWPOSCHANGED:
+
+ //
+ // Dialogs under OS/2 do not get WM_SIZE events at all.
+ // Instead they get this, which can function much like WM_SIZE
+ // PSWP contains the new sizes and positioning, PSWP+1 the old
+ // We use this because ADJUSTWINDOWPOS comes BEFORE the new
+ // position is added and our auto layout does a WinQueryWindowRect
+ // to get the CURRENT client size. That is the size used to position
+ // child controls, so we need to already be sized
+ // in order to get the child controls positoned properly.
+ //
+ if (IsKindOf(CLASSINFO(wxDialog)))
+ {
+ PSWP pSwp = (PSWP)PVOIDFROMMP(wParam);
+ PSWP pSwp2 = pSwp++;
+
+ if (!(pSwp->cx == pSwp2->cx &&
+ pSwp->cy == pSwp2->cy))
+ bProcessed = HandleSize( pSwp->cx
+ ,pSwp->cy
+ ,(WXUINT)lParam
+ );
+ }
+ 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)
+ {
+ //TODO: check if the cast to WXWORD isn't causing trouble
+ 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;
+
+ case WM_CONTROL:
+ switch(SHORT2FROMMP(wParam))
+ {
+ case SPBN_UPARROW:
+ case SPBN_DOWNARROW:
+ case SPBN_CHANGE:
+ {
+ char zVal[10];
+ long lVal;
+
+ ::WinSendMsg( HWNDFROMMP(lParam)
+ ,SPBM_QUERYVALUE
+ ,&zVal
+ ,MPFROM2SHORT( (USHORT)10
+ ,(USHORT)SPBQ_UPDATEIFVALID
+ )
+ );
+ lVal = atol(zVal);
+ bProcessed = OS2OnScroll( wxVERTICAL
+ ,(int)SHORT2FROMMP(wParam)
+ ,(int)lVal
+ ,HWNDFROMMP(lParam)
+ );
+ }
+ break;
+
+ case SLN_SLIDERTRACK:
+ {
+ HWND hWnd = ::WinWindowFromID(GetHWND(), SHORT1FROMMP(wParam));
+ wxWindowOS2* pChild = wxFindWinFromHandle(hWnd);
+
+ if (pChild->IsKindOf(CLASSINFO(wxSlider)))
+ bProcessed = OS2OnScroll( wxVERTICAL
+ ,(int)SHORT2FROMMP(wParam)
+ ,(int)LONGFROMMP(lParam)
+ ,hWnd
+ );
+ }
+ break;
+ }
+ 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;
+
+ // the return value for this message is ignored
+ case WM_SYSCOLORCHANGE:
+ bProcessed = HandleSysColorChange();
+ break;
+
+ case WM_REALIZEPALETTE:
+ bProcessed = HandlePaletteChanged();
+ 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 if (IsKindOf(CLASSINFO(wxDialog)))
+ mResult = ::WinDefDlgProc( m_hWnd, uMsg, wParam, lParam);
+ else
+ mResult = OS2DefWindowProc(uMsg, wParam, lParam);
+ }
+ return mResult;
+} // end of wxWindowOS2::OS2WindowProc
+
+#ifndef __EMX__
+// clashes with wxDlgProc in toplevel.cpp?
+//
+// Dialog window proc
+//
+MRESULT wxDlgProc(
+ HWND WXUNUSED(hWnd)
+, UINT uMsg
+, MPARAM WXUNUSED(wParam)
+, MPARAM WXUNUSED(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
+#endif
+
+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
+, wxWindowOS2* 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(
+ wxWindowOS2* 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()
+{
+}
+
+bool wxWindowOS2::OS2GetCreateWindowCoords(
+ const wxPoint& rPos
+, const wxSize& rSize
+, int& rnX
+, int& rnY
+, int& rnWidth
+, int& rnHeight
+) const
+{
+ bool bNonDefault = FALSE;
+
+ if (rPos.x == -1)
+ {
+ //
+ // If set x to CW_USEDEFAULT, y parameter is ignored anyhow so we can
+ // just as well set it to CW_USEDEFAULT as well
+ rnX = rnY = CW_USEDEFAULT;
+ }
+ else
+ {
+ rnX = rPos.x;
+ rnY = rPos.y == -1 ? CW_USEDEFAULT : rPos.y;
+ bNonDefault = TRUE;
+ }
+ if (rSize.x == -1)
+ {
+ //
+ // As abobe, h is not used at all in this case anyhow
+ //
+ rnWidth = rnHeight = CW_USEDEFAULT;
+ }
+ else
+ {
+ rnWidth = rSize.x;
+ rnHeight = rSize.y == -1 ? CW_USEDEFAULT : rSize.y;
+ bNonDefault = TRUE;
+ }
+ return bNonDefault;
+} // end of wxWindowOS2::OS2GetCreateWindowCoords
+
+bool wxWindowOS2::OS2Create(
+ PSZ zClass
+, const char* zTitle
+, WXDWORD dwStyle
+, const wxPoint& rPos
+, const wxSize& rSize
+, void* pCtlData
+, WXDWORD dwExStyle
+, bool bIsChild
+)
+{
+ ERRORID vError;
+ wxString sError;
+ int nX = 0L;
+ int nY = 0L;
+ int nWidth = 0L;
+ int nHeight = 0L;
+ wxWindow* pParent = GetParent();
+ HWND hWnd = NULLHANDLE;
+ HWND hParent;
+ long lControlId = 0L;
+ wxWindowCreationHook vHook(this);
+ wxString sClassName((wxChar*)zClass);
+
+ OS2GetCreateWindowCoords( rPos
+ ,rSize
+ ,nX
+ ,nY
+ ,nWidth
+ ,nHeight
+ );
+
+ if (GetWindowStyleFlag() & wxPOPUP_WINDOW)
+ hParent = HWND_DESKTOP;
+ else
+ {
+ if ((bIsChild || HasFlag(wxFRAME_TOOL_WINDOW)) && pParent )
+ {
+ //
+ // This is either a normal child window or a top level window with
+ // wxFRAME_TOOL_WINDOW style (see below)
+ //
+ hParent = GetHwndOf(pParent);
+ }
+ else
+ {
+ //
+ // This is either a window for which no parent was specified (not
+ // much we can do then) or a frame without wxFRAME_TOOL_WINDOW
+ // style: we should use NULL parent HWND for it or it would be
+ // always on top of its parent which is not what we usually want
+ // (in fact, we only want it for frames with the special
+ // wxFRAME_TOOL_WINDOW as above)
+ //
+ hParent = NULL;
+ }
+ }
+ if (bIsChild)
+ {
+ lControlId = GetId();
+ if (GetWindowStyleFlag() & wxCLIP_SIBLINGS)
+ {
+ dwStyle |= WS_CLIPSIBLINGS;
+ }
+ }
+ //
+ // For each class "Foo" we have we also have "FooNR" ("no repaint") class
+ // which is the same but without CS_[HV]REDRAW class styles so using it
+ // ensures that the window is not fully repainted on each resize
+ //
+ if (GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE)
+ {
+ sClassName += wxT("NR");
+ }
+
+ //
+ // If the window being created is a Frame's Statusbar we need to use
+ // the actual Frame's size, not its client
+ //
+ if (pParent)
+ {
+ if ( pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)) ||
+ pParent->IsKindOf(CLASSINFO(wxScrolledWindow))
+ )
+ {
+ if (IsKindOf(CLASSINFO(wxStatusBar)) &&
+ pParent->IsKindOf(CLASSINFO(wxFrame)))
+ {
+ RECTL vRect;
+ wxFrame* pFrame = wxDynamicCast(pParent, wxFrame);
+
+ ::WinQueryWindowRect((HWND)pFrame->GetFrame(), &vRect);
+ nY = vRect.yTop - (nY + nHeight);
+ }
+ else
+ nY = pParent->GetSize().y - (nY + nHeight);
+ }
+ }
+ else
+ {
+ RECTL vRect;
+
+ ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
+ nY = vRect.yTop - (nY + nHeight);
+ }
+ m_hWnd = (WXHWND)::WinCreateWindow( (HWND)hParent
+ ,(PSZ)sClassName.c_str()
+ ,(PSZ)zTitle ? zTitle : ""
+ ,(ULONG)dwStyle
+ ,(LONG)0L
+ ,(LONG)0L
+ ,(LONG)0L
+ ,(LONG)0L
+ ,NULLHANDLE
+ ,HWND_TOP
+ ,(ULONG)lControlId
+ ,pCtlData
+ ,NULL
+ );
+ if (!m_hWnd)
+ {
+ vError = ::WinGetLastError(wxGetInstance());
+ sError = wxPMErrorToStr(vError);
+ return FALSE;
+ }
+ SubclassWin(m_hWnd);
+ SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
+ SetSize( nX
+ ,nY
+ ,nWidth
+ ,nHeight
+ );
+ return TRUE;
+} // end of WinGuiBase_Window::OS2Create
+
+// ===========================================================================
+// OS2 PM message handlers
+// ===========================================================================
+
+// ---------------------------------------------------------------------------
+// window creation/destruction
+// ---------------------------------------------------------------------------
+
+bool wxWindowOS2::HandleCreate(
+ WXLPCREATESTRUCT WXUNUSED(vCs)
+, bool* pbMayCreate
+)
+{
+ wxWindowCreateEvent vEvent((wxWindow*)this);
+
+ (void)GetEventHandler()->ProcessEvent(vEvent);
+ *pbMayCreate = TRUE;
+ return TRUE;
+} // end of wxWindowOS2::HandleCreate
+
+bool wxWindowOS2::HandleDestroy()
+{
+ wxWindowDestroyEvent vEvent((wxWindow*)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)
+)
+{
+ //
+ // Notify the parent keeping track of focus for the kbd navigation
+ // purposes that we got it
+ //
+ wxChildFocusEvent vEventFocus((wxWindow *)this);
+ (void)GetEventHandler()->ProcessEvent(vEventFocus);
+
+#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
+// ---------------------------------------------------------------------------
+
+bool wxWindowOS2::HandleShow(
+ bool bShow
+, int WXUNUSED(nStatus)
+)
+{
+ wxShowEvent vEvent(GetId(), bShow);
+
+ vEvent.m_eventObject = this;
+ return GetEventHandler()->ProcessEvent(vEvent);
+} // end of wxWindowOS2::HandleShow