+ if (m_hWnd)
+ {
+// m_hWnd = 0;
+
+ wxCHECK_RET( ::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in UnsubclassWin") );
+
+ PFNWP fnProc = (PFNWP)::WinQueryWindowPtr(hwnd, QWP_PFNWP);
+ if ( (m_fnOldWndProc != 0) && (fnProc != (PFNWP) m_fnOldWndProc))
+ {
+ WinSubclassWindow(hwnd, (PFNWP)m_fnOldWndProc);
+ m_fnOldWndProc = 0;
+ }
+ }
+} // end of wxWindow::UnsubclassWin
+
+//
+// Make a Windows extended style from the given wxWindows window style
+//
+WXDWORD wxWindow::MakeExtendedStyle(
+ long lStyle
+, bool bEliminateBorders
+)
+{
+ //
+ // PM does not support extended style
+ //
+ WXDWORD exStyle = 0;
+ return exStyle;
+} // end of wxWindow::MakeExtendedStyle
+
+//
+// Determines whether native 3D effects or CTL3D should be used,
+// applying a default border style if required, and returning an extended
+// style to pass to CreateWindowEx.
+//
+WXDWORD wxWindow::Determine3DEffects(
+ WXDWORD dwDefaultBorderStyle
+, bool* pbWant3D
+) const
+{
+ WXDWORD dwStyle = 0L;
+
+ //
+ // Native PM does not have any specialize 3D effects like WIN32 does
+ //
+ *pbWant3D = FALSE;
+ return dwStyle;
+} // end of wxWindow::Determine3DEffects
+
+#if WXWIN_COMPATIBILITY
+void wxWindow::OnCommand(
+ wxWindow& rWin
+, wxCommandEvent& rEvent
+)
+{
+ if (GetEventHandler()->ProcessEvent(rEvent))
+ return;
+ if (m_parent)
+ m_parent->GetEventHandler()->OnCommand( rWin
+ ,rEvent
+ );
+} // end of wxWindow::OnCommand
+
+wxObject* wxWindow::GetChild(
+ int nNumber
+) const
+{
+ //
+ // Return a pointer to the Nth object in the Panel
+ //
+ wxNode* pNode = GetChildren().First();
+ int n = nNumber;
+
+ while (pNode && n--)
+ pNode = pNode->Next();
+ if (pNode)
+ {
+ wxObject* pObj = (wxObject*)pNode->Data();
+ return(pObj);
+ }
+ else
+ return NULL;
+} // end of wxWindow::GetChild
+
+#endif // WXWIN_COMPATIBILITY
+
+//
+// Setup background and foreground colours correctly
+//
+void wxWindow::SetupColours()
+{
+ if ( GetParent() )
+ SetBackgroundColour(GetParent()->GetBackgroundColour());
+} // end of wxWindow::SetupColours
+
+void wxWindow::OnIdle(
+ wxIdleEvent& rEvent
+)
+{
+ //
+ // 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 wxWindow::OnIdle
+
+//
+// Set this window to be the child of 'parent'.
+//
+bool wxWindow::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 wxWindow::Reparent
+
+void wxWindow::Clear()
+{
+ wxClientDC vDc(this);
+ wxBrush vBrush( GetBackgroundColour()
+ ,wxSOLID
+ );
+
+ vDc.SetBackground(vBrush);
+ vDc.Clear();
+} // end of wxWindow::Clear
+
+void wxWindow::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 wxWindow::Refresh
+
+// ---------------------------------------------------------------------------
+// drag and drop
+// ---------------------------------------------------------------------------
+
+#if wxUSE_DRAG_AND_DROP
+void wxWindow::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 wxWindow::SetDropTarget
+#endif
+
+//
+// old style file-manager drag&drop support: we retain the old-style
+// DragAcceptFiles in parallel with SetDropTarget.
+//
+void wxWindow::DragAcceptFiles(
+ bool bAccept
+)
+{
+ HWND hWnd = GetHwnd();
+
+ if (hWnd && bAccept)
+ ::DrgAcceptDroppedFiles(hWnd, NULL, NULL, DO_COPY, 0L);
+} // end of wxWindow::DragAcceptFiles
+
+// ----------------------------------------------------------------------------
+// tooltips
+// ----------------------------------------------------------------------------
+
+#if wxUSE_TOOLTIPS
+
+void wxWindow::DoSetToolTip(
+ wxToolTip* pTooltip
+)
+{
+ wxWindowBase::DoSetToolTip(pTooltip);
+
+ if (m_tooltip)
+ m_tooltip->SetWindow(this);
+} // end of wxWindow::DoSetToolTip
+
+#endif // wxUSE_TOOLTIPS
+
+// ---------------------------------------------------------------------------
+// moving and resizing
+// ---------------------------------------------------------------------------
+
+// Get total size
+void wxWindow::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 wxWindow::DoGetSize
+
+void wxWindow::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 wxWindow::DoGetPosition
+
+void wxWindow::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 wxWindow::DoScreenToClient
+
+void wxWindow::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 wxWindow::DoClientToScreen
+
+//
+// Get size *available for subwindows* i.e. excluding menu bar etc.
+// Must be a frame type window
+//
+void wxWindow::DoGetClientSize(
+ int* pWidth
+, int* pHeight
+) const
+{
+ HWND hWnd = GetHwnd();
+ HWND hWndClient;
+ RECTL vRect;
+
+ hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
+ ::WinQueryWindowRect(hWndClient, &vRect);
+
+ if (pWidth)
+ *pWidth = vRect.xRight;
+ if (pHeight)
+ *pHeight = vRect.yTop;
+} // end of wxWindow::DoGetClientSize
+
+void wxWindow::DoMoveWindow(
+ int nX
+, int nY
+, int nWidth
+, int nHeight
+)
+{
+ if ( !::WinSetWindowPos( GetHwnd()
+ ,HWND_TOP
+ ,(LONG)nX
+ ,(LONG)nY
+ ,(LONG)nWidth
+ ,(LONG)nHeight
+ ,SWP_SIZE | SWP_MOVE
+ ))
+ {
+ wxLogLastError("MoveWindow");
+ }
+} // end of wxWindow::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 wxWindow::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 wxWindow::DoSetSize
+
+void wxWindow::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 wxWindow::DoSetClientSize
+
+wxPoint wxWindow::GetClientAreaOrigin() const
+{
+ return wxPoint(0, 0);
+} // end of wxWindow::GetClientAreaOrigin
+
+void wxWindow::AdjustForParentClientOrigin(
+ int& rX
+, int& rY
+, int nSizeFlags
+)
+{
+ //
+ // Don't do it for the dialogs/frames - they float independently of their
+ // parent
+ //
+ if (!IsTopLevel())
+ {
+ wxWindow* pParent = GetParent();
+
+ if (!(nSizeFlags & wxSIZE_NO_ADJUSTMENTS) && pParent)
+ {
+ wxPoint vPoint(pParent->GetClientAreaOrigin());
+ rX += vPoint.x;
+ rY += vPoint.y;
+ }
+ }
+} // end of wxWindow::AdjustForParentClientOrigin
+
+// ---------------------------------------------------------------------------
+// text metrics
+// ---------------------------------------------------------------------------
+
+int wxWindow::GetCharHeight() const
+{
+ HPS hPs;
+ FONTMETRICS vFontMetrics;
+ BOOL bRc;
+
+ hPs = ::WinGetPS(GetHwnd());
+
+ if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics))
+ return (0);
+ else
+ return(vFontMetrics.lMaxAscender + vFontMetrics.lMaxDescender);
+ ::WinReleasePS(hPs);
+} // end of wxWindow::GetCharHeight
+
+int wxWindow::GetCharWidth() const
+{
+ HPS hPs;
+ FONTMETRICS vFontMetrics;
+
+ hPs = ::WinGetPS(GetHwnd());
+
+ if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics))
+ return (0);
+ else
+ return(vFontMetrics.lAveCharWidth);
+ ::WinReleasePS(hPs);
+} // end of wxWindow::GetCharWidth
+
+void wxWindow::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 wxWindow::CreateCaret(
+ int nWidth
+, int nHeight
+)
+{
+ SetCaret(new wxCaret( this
+ ,nWidth
+ ,nHeight
+ ));
+} // end of wxWindow::CreateCaret
+
+void wxWindow::CreateCaret(
+ const wxBitmap* pBitmap
+)
+{
+ wxFAIL_MSG("not implemented");
+} // end of wxWindow::CreateCaret
+
+void wxWindow::ShowCaret(
+ bool bShow
+)
+{
+ wxCHECK_RET( m_caret, "no caret to show" );
+
+ m_caret->Show(bShow);
+} // end of wxWindow::ShowCaret
+
+void wxWindow::DestroyCaret()
+{
+ SetCaret(NULL);
+} // end of wxWindow::DestroyCaret
+
+void wxWindow::SetCaretPos(
+ int nX
+, int nY)
+{
+ wxCHECK_RET( m_caret, "no caret to move" );
+
+ m_caret->Move( nX
+ ,nY
+ );
+} // end of wxWindow::SetCaretPos
+
+void wxWindow::GetCaretPos(
+ int* pX
+, int* pY
+) const
+{
+ wxCHECK_RET( m_caret, "no caret to get position of" );
+
+ m_caret->GetPosition( pX
+ ,pY
+ );
+} // end of wxWindow::GetCaretPos
+
+#endif //wxUSE_CARET
+
+// ---------------------------------------------------------------------------
+// popup menu
+// ---------------------------------------------------------------------------
+
+bool wxWindow::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
+ );
+ wxYield();
+ wxCurrentPopupMenu = NULL;
+
+ pMenu->SetInvokingWindow(NULL);
+ return TRUE;
+} // end of wxWindow::DoPopupMenu
+
+// ===========================================================================
+// pre/post message processing
+// ===========================================================================
+
+MRESULT wxWindow::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 wxWindow::OS2DefWindowProc
+
+bool wxWindow::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
+ {
+ wxPanel* pPanel = wxDynamicCast(this, wxPanel);
+ wxButton* pBtn = NULL;
+
+ if (pPanel)
+ {
+ //
+ // Panel may have a default button which should
+ // be activated by Enter
+ //
+ pBtn = pPanel->GetDefaultItem();
+ }
+
+ 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 wxWindow::OS2ProcessMessage
+
+bool wxWindow::OS2TranslateMessage(
+ WXMSG* pMsg
+)
+{
+ return m_acceleratorTable.Translate(m_hWnd, pMsg);
+} // end of wxWindow::OS2TranslateMessage
+
+// ---------------------------------------------------------------------------
+// message params unpackers
+// ---------------------------------------------------------------------------
+
+void wxWindow::UnpackCommand(
+ WXWPARAM wParam
+, WXLPARAM lParam
+, WORD* pId
+, WXHWND* phWnd
+, 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(
+ WXWPARAM wParam
+, WXLPARAM lParam
+, WXWORD* pState
+, WXHWND* phWnd
+)
+{
+ *pState = LOWORD(wParam);
+ *phWnd = (WXHWND)lParam;
+} // end of wxWindow::UnpackActivate
+
+void wxWindow::UnpackScroll(
+ WXWPARAM wParam
+, WXLPARAM lParam
+, WXWORD* pCode
+, WXWORD* pPos
+, WXHWND* phWnd
+)
+{
+ *pCode = LOWORD(wParam);
+ *pPos = HIWORD(wParam);
+ *phWnd = (WXHWND)lParam;
+} // end of wxWindow::UnpackScroll
+
+void wxWindow::UnpackMenuSelect(
+ WXWPARAM wParam
+, WXLPARAM lParam
+, WXWORD* pItem
+, WXWORD* pFlags
+, WXHMENU* phMenu
+)
+{
+ *pItem = (WXWORD)LOWORD(wParam);
+ *pFlags = HIWORD(wParam);
+ *phMenu = (WXHMENU)lParam;
+} // end of wxWindow::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 wxWindow::OS2WindowProc(
+ WXUINT uMsg
+, WXWPARAM wParam
+, WXLPARAM lParam
+)
+{
+ //
+ // Did we process the uMsg?
+ //
+ bool bProcessed = FALSE;
+ bool bAllow;
+ MRESULT mResult;
+ WXHICON hIcon;
+ WXHBRUSH hBrush;
+
+ //
+ // The return value
+ //
+// union
+// {
+// bool bAllow;
+// MRESULT mResult;
+// WXHICON hIcon;
+// WXHBRUSH hBrush;
+// } vRc;
+
+ //
+ // 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 idCtrl = (UINT)wParam;
+ if ( uMsg == WM_DRAWITEM )
+ {
+ bProcessed = OS2OnDrawItem(idCtrl,
+ (WXDRAWITEMSTRUCT *)lParam);
+ }
+ else
+ {
+ bProcessed = OS2OnMeasureItem(idCtrl,
+ (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
+ //
+ // 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 this to wxFrame
+ case WM_ERASEBACKGROUND:
+ bProcessed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
+ if (bProcessed)
+ {
+ //
+ // We processed the message, i.e. erased the background
+ //
+ mResult = (MRESULT)TRUE;
+ }
+ 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__
+ mResult = OS2DefWindowProc(uMsg, wParam, lParam);
+ }
+ return mResult;
+} // end of wxWindow::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 wxWindow::OS2DestroyWindow()
+{
+}
+
+void wxWindow::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 wxWindow::OS2DetachWindowMenu
+
+bool wxWindow::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
+)
+{
+ ERRORID vError;
+ wxString sError;
+ long lX1 = 0L;
+ long lY1 = 0L;
+ long lWidth1 = 20L;
+ long lHeight1 = 20L;
+ int nControlId = 0;
+
+ //
+ // 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;
+
+ if (lX > -1L)
+ lX1 = lX;
+ if (lY > -1L)
+ 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;
+ }
+
+ //
+ // 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
+ ,NULLHANDLE
+ ,HWND_TOP
+ ,(ULONG)ulId
+ ,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;
+ }
+ ::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.
+ //
+
+ SubclassWin(GetHWND());
+
+ return TRUE;
+} // end of wxWindow::OS2Create
+
+// ===========================================================================
+// OS2 PM message handlers
+// ===========================================================================
+
+// ---------------------------------------------------------------------------
+// window creation/destruction
+// ---------------------------------------------------------------------------
+
+bool wxWindow::HandleCreate(
+ WXLPCREATESTRUCT vCs
+, bool* pbMayCreate
+)
+{
+ wxWindowCreateEvent vEvent(this);
+
+ (void)GetEventHandler()->ProcessEvent(vEvent);
+ *pbMayCreate = TRUE;
+ return TRUE;
+} // end of wxWindow::HandleCreate
+
+bool wxWindow::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 wxWindow::HandleDestroy
+
+// ---------------------------------------------------------------------------
+// activation/focus
+// ---------------------------------------------------------------------------
+void wxWindow::OnSetFocus(
+ wxFocusEvent& rEvent
+)
+{
+ //
+ // Panel wants to track the window which was the last to have focus in it,
+ // so we want to set ourselves as the window which last had focus
+ //
+ // Notice that it's also important to do it upwards the tree becaus
+ // otherwise when the top level panel gets focus, it won't set it back to
+ // us, but to some other sibling
+ //
+ wxWindow* pWin = this;
+
+ while (pWin)
+ {
+ wxWindow* pParent = pWin->GetParent();
+ wxPanel* pPanel = wxDynamicCast( pParent
+ ,wxPanel
+ );
+ if (pPanel)
+ {
+ pPanel->SetLastFocus(pWin);
+ }
+ pWin = pParent;
+ }
+
+ wxLogTrace(_T("focus"), _T("%s (0x%08x) gets focus"),
+ GetClassInfo()->GetClassName(), GetHandle());
+
+ rEvent.Skip();
+} // end of wxWindow::OnSetFocus
+
+bool wxWindow::HandleActivate(
+ int nState
+, WXHWND WXUNUSED(hActivate)
+)
+{
+ wxActivateEvent vEvent( wxEVT_ACTIVATE
+ ,(bool)nState
+ ,m_windowId
+ );
+ vEvent.SetEventObject(this);
+ return GetEventHandler()->ProcessEvent(vEvent);
+} // end of wxWindow::HandleActivate
+
+bool wxWindow::HandleSetFocus(
+ WXHWND WXUNUSED(hWnd)
+)
+{
+#if wxUSE_CARET
+ //
+ // Deal with caret
+ //
+ if (m_caret)
+ {
+ m_caret->OnSetFocus();
+ }
+#endif // wxUSE_CARET
+
+ //
+ // Panel wants to track the window which was the last to have focus in it
+ //
+ wxPanel* pPanel = wxDynamicCast( GetParent()
+ ,wxPanel
+ );
+ if (pPanel)
+ {
+ pPanel->SetLastFocus(this);
+ }
+
+ wxFocusEvent vEvent(wxEVT_SET_FOCUS, m_windowId);
+
+ vEvent.SetEventObject(this);
+ return GetEventHandler()->ProcessEvent(vEvent);
+} // end of wxWindow::HandleSetFocus
+
+bool wxWindow::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 wxWindow::HandleKillFocus
+
+// ---------------------------------------------------------------------------
+// miscellaneous
+// ---------------------------------------------------------------------------
+
+bool wxWindow::HandleShow(
+ bool bShow
+, int nStatus
+)
+{
+ wxShowEvent vEvent( GetId()
+ ,bShow
+ );
+
+ vEvent.m_eventObject = this;
+ return GetEventHandler()->ProcessEvent(vEvent);
+} // end of wxWindow::HandleShow
+
+bool wxWindow::HandleInitDialog(
+ WXHWND WXUNUSED(hWndFocus)
+)
+{
+ wxInitDialogEvent vEvent(GetId());
+
+ vEvent.m_eventObject = this;
+ return GetEventHandler()->ProcessEvent(vEvent);
+} // end of wxWindow::HandleInitDialog
+
+bool wxWindow::HandleEndDrag(WXWPARAM wParam)
+{
+ // TODO: We'll handle drag and drop later
+ return FALSE;
+}
+
+bool wxWindow::HandleSetCursor(
+ USHORT vId
+, WXHWND hPointer
+)
+{
+ //
+ // Under OS/2 PM this allows the pointer to be changed
+ // as it passes over a control
+ //
+ ::WinSetPointer(HWND_DESKTOP, (HPOINTER)hPointer);
+ return TRUE;
+} // end of wxWindow::HandleSetCursor
+
+// ---------------------------------------------------------------------------
+// owner drawn stuff
+// ---------------------------------------------------------------------------
+bool wxWindow::OS2OnDrawItem(
+ int vId
+, WXDRAWITEMSTRUCT* pItemStruct
+)
+{
+ //
+ // I'll get to owner drawn stuff later
+ //
+
+ //
+ // is it a menu item or control?
+ //
+ wxWindow* pItem = FindItem(vId);
+
+#if wxUSE_OWNER_DRAWN
+ if (pItem && pItem->IsKindOf(CLASSINFO(wxControl)))
+ {
+ return ((wxControl *)pItem)->OS2OnDraw(pItemStruct);
+ }
+ else if (pItem && pItem->IsKindOf(CLASSINFO(wxMenu)))
+ {
+ /*
+ // TODO: draw a menu item
+ //
+ POWNERITEM pDrawStruct = (OWNERITEM *)pItemStruct;
+ wxMenuItem* pMenuItem = (wxMenuItem *)(pDrawStruct->pItemData);
+
+ wxCHECK(pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE);
+
+ //
+ // Prepare to call OnDrawItem()
+ //
+ HPSdc;
+ dc.SetHDC((WXHDC)pDrawStruct->hDC, FALSE);
+ wxRect rect(pDrawStruct->rcItem.left, pDrawStruct->rcItem.top,
+ pDrawStruct->rcItem.right - pDrawStruct->rcItem.left,
+ pDrawStruct->rcItem.bottom - pDrawStruct->rcItem.top);
+
+ return pMenuItem->OnDrawItem
+ (
+ dc, rect,
+ (wxOwnerDrawn::wxODAction)pDrawStruct->itemAction,
+ (wxOwnerDrawn::wxODStatus)pDrawStruct->itemState
+ );
+ */
+ }
+
+ else
+ return FALSE;
+#endif
+ return TRUE;
+} // end of wxWindow::OS2OnDrawItem
+
+bool wxWindow::OS2OnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct)
+{
+ // TODO: more owner drawn menu related stuff, get to it later
+/*
+#if wxUSE_OWNER_DRAWN
+ // is it a menu item?
+ if ( id == 0 )
+ {
+ MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct;
+ wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData);
+
+ wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
+
+ return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth,
+ &pMeasureStruct->itemHeight);
+ }
+
+ wxWindow *item = FindItem(id);
+ if ( item && item->IsKindOf(CLASSINFO(wxControl)) )
+ {
+ return ((wxControl *)item)->MSWOnMeasure(itemStruct);
+ }
+#endif // owner-drawn menus
+*/
+ return FALSE;
+}
+
+// ---------------------------------------------------------------------------
+// colours and palettes
+// ---------------------------------------------------------------------------
+
+bool wxWindow::HandleSysColorChange()
+{
+ wxSysColourChangedEvent vEvent;
+
+ vEvent.SetEventObject(this);
+ return GetEventHandler()->ProcessEvent(vEvent);
+} // end of wxWindow::HandleSysColorChange
+
+bool wxWindow::HandleCtlColor(
+ WXHBRUSH* phBrush
+)
+{
+ //
+ // Not much provided with message. So not sure I can do anything with it
+ //
+ return TRUE;
+} // end of wxWindow::HandleCtlColor
+
+bool wxWindow::HandleWindowParams(
+ PWNDPARAMS pWndParams
+, WXLPARAM lParam
+)
+{
+// TODO: I'll do something here, just not sure what yet
+ return TRUE;
+}
+
+// Define for each class of dialog and control
+WXHBRUSH wxWindow::OnCtlColor(WXHDC hDC,
+ WXHWND hWnd,
+ WXUINT nCtlColor,
+ WXUINT message,
+ WXWPARAM wParam,
+ WXLPARAM lParam)
+{
+ return (WXHBRUSH)0;
+}
+
+bool wxWindow::HandlePaletteChanged()
+{
+ // need to set this to something first
+ WXHWND hWndPalChange = NULLHANDLE;
+
+ wxPaletteChangedEvent vEvent(GetId());
+
+ vEvent.SetEventObject(this);
+ vEvent.SetChangedWindow(wxFindWinFromHandle(hWndPalChange));
+
+ return GetEventHandler()->ProcessEvent(vEvent);
+} // end of wxWindow::HandlePaletteChanged
+
+bool wxWindow::HandlePresParamChanged(
+ WXWPARAM wParam
+)
+{
+ //
+ // TODO: Once again I'll do something here when I need it
+ //
+ //wxQueryNewPaletteEvent event(GetId());
+ //event.SetEventObject(this);
+ // if the background is erased
+// bProcessed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
+
+ return FALSE; //GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized();