X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cdf1e7142564c55f5299f1f2d0909090534eb97c..7b9da2077d0975db6c965a85c91d5aca671ab5e3:/src/os2/window.cpp diff --git a/src/os2/window.cpp b/src/os2/window.cpp index 7673bf4463..3ae47914ad 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -96,6 +96,11 @@ MRESULT wxWndProc( HWND hWnd ,MPARAM mp1 ,MPARAM mp2 ); + +#ifdef __WXDEBUG__ + const char *wxGetMessageName(int message); +#endif //__WXDEBUG__ + void wxRemoveHandleAssociation(wxWindow *win); void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win); wxWindow *wxFindWinFromHandle(WXHWND hWnd); @@ -119,71 +124,81 @@ END_EVENT_TABLE() // implementation // =========================================================================== -// Find an item given the MS Windows id -wxWindow *wxWindow::FindItem(long id) const +// Find an item given the PM Window id +wxWindow* wxWindow::FindItem( + long ulId +) const { - wxWindowList::Node *current = GetChildren().GetFirst(); - while (current) + wxWindowList::Node* pCurrent = GetChildren().GetFirst(); + + while (pCurrent) { - wxWindow *childWin = current->GetData(); + wxWindow* pChildWin = pCurrent->GetData(); + wxWindow* pWnd = pChildWin->FindItem(ulId); - wxWindow *wnd = childWin->FindItem(id); - if ( wnd ) - return wnd; + if (pWnd) + return pWnd; - if ( childWin->IsKindOf(CLASSINFO(wxControl)) ) + if (pChildWin->IsKindOf(CLASSINFO(wxControl))) { - wxControl *item = (wxControl *)childWin; - if ( item->GetId() == id ) - return item; + wxControl* pItem = (wxControl *)pChildWin; + + if (pItem->GetId() == ulId) + return(pItem); else { // In case it's a 'virtual' control (e.g. radiobox) - if ( item->GetSubcontrols().Member((wxObject *)id) ) - return item; + if (pItem->GetSubcontrols().Member((wxObject *)ulId)) + return(pItem); } } - - current = current->GetNext(); + pCurrent = pCurrent->GetNext(); } - - return NULL; + return(NULL); } -// Find an item given the MS Windows handle -wxWindow *wxWindow::FindItemByHWND(WXHWND hWnd, bool controlOnly) const +// Find an item given the PM Window handle +wxWindow* wxWindow::FindItemByHWND( + WXHWND hWnd +, bool bControlOnly +) const { - wxWindowList::Node *current = GetChildren().GetFirst(); - while (current) + wxWindowList::Node* pCurrent = GetChildren().GetFirst(); + + while (pCurrent) { - wxWindow *parent = current->GetData(); + wxWindow* pParent = pCurrent->GetData(); // Do a recursive search. - wxWindow *wnd = parent->FindItemByHWND(hWnd); - if ( wnd ) - return wnd; + wxWindow* pWnd = pParent->FindItemByHWND(hWnd); + + if (pWnd) + return(pWnd); - if ( !controlOnly || parent->IsKindOf(CLASSINFO(wxControl)) ) + if (!bControlOnly || pParent->IsKindOf(CLASSINFO(wxControl))) { - wxWindow *item = current->GetData(); - if ( item->GetHWND() == hWnd ) - return item; + wxWindow* pItem = pCurrent->GetData(); + + if (pItem->GetHWND() == hWnd) + return(pItem); else { - if ( item->ContainsHWND(hWnd) ) - return item; + if (pItem->ContainsHWND(hWnd)) + return(pItem); } } - - current = current->GetNext(); + pCurrent = pCurrent->GetNext(); } - return NULL; + return(NULL); } // Default command handler -bool wxWindow::OS2Command(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id)) +bool wxWindow::OS2Command( + WXUINT WXUNUSED(uParam) +, WXWORD WXUNUSED(uId) +) { - return FALSE; + return(FALSE); } // ---------------------------------------------------------------------------- @@ -196,13 +211,13 @@ void wxWindow::Init() InitBase(); // PM specific - m_doubleClickAllowed = 0; - m_winCaptured = FALSE; + m_bDoubleClickAllowed = 0; + m_bWinCaptured = FALSE; m_isBeingDeleted = FALSE; - m_oldWndProc = 0; - m_useCtl3D = FALSE; - m_mouseInWindow = FALSE; + m_fnOldWndProc = 0; + m_bUseCtl3D = FALSE; + m_bMouseInWindow = FALSE; // wxWnd m_hMenu = 0; @@ -212,17 +227,17 @@ void wxWindow::Init() // pass WM_GETDLGCODE to DefWindowProc() m_lDlgCode = 0; - m_xThumbSize = 0; - m_yThumbSize = 0; - m_backgroundTransparent = FALSE; + m_nXThumbSize = 0; + m_nYThumbSize = 0; + m_bBackgroundTransparent = FALSE; // as all windows are created with WS_VISIBLE style... m_isShown = TRUE; #if wxUSE_MOUSEEVENT_HACK - m_lastMouseX = - m_lastMouseY = -1; - m_lastMouseEvent = -1; + m_lLastMouseX = + m_lLastMouseY = -1; + m_nLastMouseEvent = -1; #endif // wxUSE_MOUSEEVENT_HACK } @@ -245,25 +260,47 @@ wxWindow::~wxWindow() } } -bool wxWindow::Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindow without parent") ); - - if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) - return FALSE; - - parent->AddChild(this); - - // TODO: PM Specific initialization - OS2Create(m_windowId, parent, wxCanvasClassName, this, NULL, - pos.x, pos.y, - WidthDefault(size.x), HeightDefault(size.y), - msflags, NULL, exStyle); - return TRUE; +bool wxWindow::Create( + wxWindow* pParent +, wxWindowID vId +, const wxPoint& rPos +, const wxSize& rSize +, long lStyle +, const wxString& rName +) +{ + wxCHECK_MSG(pParent, FALSE, wxT("can't create wxWindow without parent")); + + if ( !CreateBase( pParent + ,vId + ,rPos + ,rSize + ,lStyle + ,wxDefaultValidator + ,rName + )) + return(FALSE); + + pParent->AddChild(this); + + bool bWant3D; + WXDWORD dwExStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &bWant3D); + DWORD ulFlags = 0L; + + OS2Create( m_windowId + ,pParent + ,wxCanvasClassName + ,this + ,NULL + ,rPos.x + ,rPos.y + ,WidthDefault(rSize.x) + ,HeightDefault(rSize.y) + ,ulFlags + ,NULL + ,dwExStyle + ); + return(TRUE); } // --------------------------------------------------------------------------- @@ -272,41 +309,80 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, void wxWindow::SetFocus() { - // TODO: + HWND hWnd = GetHwnd(); + + if (hWnd) + ::WinSetFocus(HWND_DESKTOP, hWnd); } -wxWindow* wxWindow::FindFocus() +wxWindow* wxWindowBase::FindFocus() { - wxWindow* window = NULL; - // TODO: - return(window); + HWND hWnd = ::WinQueryFocus(HWND_DESKTOP); + + if (hWnd) + { + return wxFindWinFromHandle((WXHWND)hWnd); + } + return NULL; } -bool wxWindow::Enable(bool enable) // check if base implementation is OK +bool wxWindow::Enable( + bool bEnable +) { - // TODO: + if (!wxWindowBase::Enable(bEnable)) + return(FALSE); + + HWND hWnd = GetHwnd(); + + if ( hWnd ) + ::WinEnableWindow(hWnd, (BOOL)bEnable); + + wxWindowList::Node* pNode = GetChildren().GetFirst(); + + while (pNode) + { + wxWindow* pChild = pNode->GetData(); + + pChild->Enable(bEnable); + pNode = pNode->GetNext(); + } return(TRUE); } -bool wxWindow::Show(bool show) // check if base implementation is OK +bool wxWindow::Show( + bool bShow +) { - // TODO: + if (!wxWindowBase::Show(bShow)) + return(FALSE); + + HWND hWnd = GetHwnd(); + + ::WinShowWindow(hWnd, bShow); + + if (bShow) + { + ::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE); + } return(TRUE); } void wxWindow::Raise() { - // TODO: + ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ACTIVATE); } void wxWindow::Lower() { - // TODO: + ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_DEACTIVATE); } -void wxWindow::SetTitle( const wxString& title) +void wxWindow::SetTitle( + const wxString& rTitle +) { - SetWindowText(GetHwnd(), title.c_str()); + ::WinSetWindowText(GetHwnd(), title.c_str()); } wxString wxWindow::GetTitle() const @@ -373,6 +449,7 @@ int wxWindow::GetScrollPage(int orient) const // TODO: return(1); } +#endif // WXWIN_COMPATIBILITY int wxWindow::GetScrollPos(int orient) const { @@ -424,7 +501,7 @@ void wxWindow::ScrollWindow( int dx void wxWindow::SubclassWin(WXHWND hWnd) { - wxASSERT_MSG( !m_oldWndProc, wxT("subclassing window twice?") ); + wxASSERT_MSG( !m_fnOldWndProc, wxT("subclassing window twice?") ); HWND hwnd = (HWND)hWnd; /* @@ -831,7 +908,7 @@ void wxWindow::UnpackScroll(WXWPARAM wParam, WXLPARAM lParam, void wxWindow::UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam, WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd) { - *nCtlColor = CTLCOLOR_BTN; + *nCtlColor = 0; // TODO: CTLCOLOR_BTN; *hwnd = (WXHWND)lParam; *hdc = (WXHDC)wParam; } @@ -839,7 +916,7 @@ void wxWindow::UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam, void wxWindow::UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam, WXWORD *item, WXWORD *flags, WXHMENU *hmenu) { - *item = (WXWORD)wParam; + *item = (WXWORD)LOWORD(wParam); *flags = HIWORD(wParam); *hmenu = (WXHMENU)lParam; } @@ -886,7 +963,7 @@ MRESULT wxWndProc(HWND hWnd, UINT message, MPARAM wParam, MPARAM lParam) { // FIXME: why do we do this? wnd->SetHWND((WXHWND) hWnd); - rc = wnd->OS2DefWindowProc(message, wParam, lParam ); + rc = wnd->OS2DefWindowProc(hWnd, message, wParam, lParam ); wnd->SetHWND(0); } else @@ -894,7 +971,7 @@ MRESULT wxWndProc(HWND hWnd, UINT message, MPARAM wParam, MPARAM lParam) if ( wnd ) rc = wnd->OS2WindowProc(hWnd, message, wParam, lParam); else - rc = DefWindowProc( hWnd, message, wParam, lParam ); + rc = 0; //TODO: DefWindowProc( hWnd, message, wParam, lParam ); } return rc; @@ -1249,11 +1326,11 @@ MRESULT wxWindow::OS2WindowProc(HWND hWnd, WXUINT message, WXWPARAM wParam, WXLP rc.result = MSWDefWindowProc(message, wParam, lParam); } */ - return rc.result; + return (MRESULT)0; } // Dialog window proc -MRESULT wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +MRESULT wxDlgProc(HWND hWnd, UINT message, MPARAM wParam, MPARAM lParam) { // TODO: /* @@ -1273,7 +1350,6 @@ MRESULT wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return (MRESULT)0; } -wxList *wxWinHandleList = NULL; wxWindow *wxFindWinFromHandle(WXHWND hWnd) { wxNode *node = wxWinHandleList->Find((long)hWnd); @@ -1551,7 +1627,7 @@ bool wxWindow::HandleDestroy() #if wxUSE_DRAG_AND_DROP if ( m_dropTarget != NULL ) { - m_dropTarget->Revoke(m_hWnd); +// m_dropTarget->Revoke(m_hWnd); delete m_dropTarget; m_dropTarget = NULL; @@ -1570,12 +1646,16 @@ bool wxWindow::HandleActivate(int state, bool WXUNUSED(minimized), WXHWND WXUNUSED(activate)) { + // TODO: + /* wxActivateEvent event(wxEVT_ACTIVATE, (state == WA_ACTIVE) || (state == WA_CLICKACTIVE), m_windowId); event.SetEventObject(this); return GetEventHandler()->ProcessEvent(event); + */ + return FALSE; } bool wxWindow::HandleSetFocus(WXHWND WXUNUSED(hwnd)) @@ -1654,6 +1734,8 @@ bool wxWindow::HandleSetCursor(WXHWND hWnd, if ( GetHWND() == hWnd ) { // don't set cursor when the mouse is not in the client part +// TODO +/* if ( nHitTest == HTCLIENT || nHitTest == HTERROR ) { HCURSOR hcursor = 0; @@ -1692,6 +1774,7 @@ bool wxWindow::HandleSetCursor(WXHWND hWnd, return TRUE; } } +*/ } return FALSE; @@ -1701,7 +1784,7 @@ bool wxWindow::HandleSetCursor(WXHWND hWnd, // owner drawn stuff // --------------------------------------------------------------------------- -bool wxWindow::MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct) +bool wxWindow::OS2OnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct) { // TODO: /* @@ -1789,7 +1872,8 @@ bool wxWindow::HandleCtlColor(WXHBRUSH *brush, WXLPARAM lParam) { WXHBRUSH hBrush = 0; - +// TODO: +/* if ( nCtlColor == CTLCOLOR_DLG ) { hBrush = OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam); @@ -1805,6 +1889,8 @@ bool wxWindow::HandleCtlColor(WXHBRUSH *brush, *brush = hBrush; return hBrush != 0; +*/ + return FALSE; } // Define for each class of dialog and control @@ -1861,14 +1947,14 @@ void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event) bool wxWindow::HandlePaint() { // TODO: - Return FALSE; + return FALSE; } bool wxWindow::HandleEraseBkgnd(WXHDC hdc) { // Prevents flicker when dragging - if ( ::IsIconic(GetHwnd()) ) - return TRUE; +// if ( ::IsIconic(GetHwnd()) ) +// return TRUE; wxDC dc; @@ -1930,6 +2016,8 @@ bool wxWindow::HandleSize(int w, int h, WXUINT WXUNUSED(flag)) bool wxWindow::HandleGetMinMaxInfo(void *mmInfo) { +// TODO: +/* MINMAXINFO *info = (MINMAXINFO *)mmInfo; bool rc = FALSE; @@ -1959,6 +2047,8 @@ bool wxWindow::HandleGetMinMaxInfo(void *mmInfo) } return rc; +*/ + return FALSE; } // --------------------------------------------------------------------------- @@ -1972,7 +2062,7 @@ bool wxWindow::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) wxMenu *popupMenu = wxCurrentPopupMenu; wxCurrentPopupMenu = NULL; - return popupMenu->MSWCommand(cmd, id); + return popupMenu->OS2Command(cmd, id); } wxWindow *win = FindItem(id); @@ -1982,7 +2072,7 @@ bool wxWindow::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) } if ( win ) - return win->MSWCommand(cmd, id); + return win->OS2Command(cmd, id); return FALSE; } @@ -1999,6 +2089,8 @@ bool wxWindow::HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam) void wxWindow::InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags) { +// TODO: +/* event.m_x = x; event.m_y = y; event.m_shiftDown = ((flags & MK_SHIFT) != 0); @@ -2014,7 +2106,7 @@ void wxWindow::InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags) m_lastMouseY = y; m_lastMouseEvent = event.GetEventType(); #endif // wxUSE_MOUSEEVENT_HACK - +*/ } bool wxWindow::HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags) @@ -2045,10 +2137,10 @@ bool wxWindow::HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags) bool wxWindow::HandleMouseMove(int x, int y, WXUINT flags) { - if ( !m_mouseInWindow ) + if ( !m_bMouseInWindow ) { // Generate an ENTER event - m_mouseInWindow = TRUE; + m_bMouseInWindow = TRUE; wxMouseEvent event(wxEVT_ENTER_WINDOW); InitMouseEvent(event, x, y, flags); @@ -2119,7 +2211,7 @@ bool wxWindow::OS2OnScroll(int orientation, WXWORD wParam, { wxWindow *child = wxFindWinFromHandle(control); if ( child ) - return child->MSWOnScroll(orientation, wParam, pos, control); + return child->OS2OnScroll(orientation, wParam, pos, control); } wxScrollWinEvent event; @@ -2311,8 +2403,8 @@ wxWindow *wxGetActiveWindow() // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE // in active frames and dialogs, regardless of where the focus is. -static HHOOK wxTheKeyboardHook = 0; -static FARPROC wxTheKeyboardHookProc = 0; +//static HHOOK wxTheKeyboardHook = 0; +//static FARPROC wxTheKeyboardHookProc = 0; int wxKeyboardHook(int nCode, WORD wParam, DWORD lParam); void wxSetKeyboardHook(bool doIt) @@ -2749,3 +2841,5 @@ const char *wxGetMessageName(int message) return NULL; } +#endif // __WXDEBUG__ +