X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/17808a759627b03c2acbe7333dd2386557e1b804..3c8b2423bd521e1aca4752b66117dfcf95407866:/src/os2/window.cpp diff --git a/src/os2/window.cpp b/src/os2/window.cpp index f5c84cb939..7a44b19018 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -51,6 +51,8 @@ #include #endif +#include "wx/os2/dcclient.h" + #if wxUSE_OWNER_DRAWN #include "wx/ownerdrw.h" #endif @@ -121,7 +123,7 @@ QMSG s_currentMsg; #if wxUSE_MENUS_NATIVE -wxMenu* wxCurrentPopupMenu = NULL; +extern wxMenu* wxCurrentPopupMenu; #endif // wxUSE_MENUS_NATIVE // --------------------------------------------------------------------------- @@ -332,7 +334,7 @@ void wxWindowOS2::Init() // wxWindowOS2::~wxWindowOS2() { - m_isBeingDeleted = true; + SendDestroyEvent(); for (wxWindow* pWin = GetParent(); pWin; pWin = pWin->GetParent()) { @@ -350,7 +352,9 @@ wxWindowOS2::~wxWindowOS2() if (m_hWnd) { if(!::WinDestroyWindow(GetHWND())) + { wxLogLastError(wxT("DestroyWindow")); + } // // remove hWnd <-> wxWindow association // @@ -382,7 +386,7 @@ bool wxWindowOS2::Create( wxWindow* pParent, // static box // wxASSERT_MSG( !wxDynamicCast(pParent, wxStaticBox), - _T("wxStaticBox can't be used as a window parent!") ); + wxT("wxStaticBox can't be used as a window parent!") ); #endif // wxUSE_STATBOX // Ensure groupbox backgrounds are painted @@ -452,7 +456,7 @@ bool wxWindowOS2::Create( wxWindow* pParent, void wxWindowOS2::SetFocus() { HWND hWnd = GetHwnd(); - wxCHECK_RET( hWnd, _T("can't set focus to invalid window") ); + wxCHECK_RET( hWnd, wxT("can't set focus to invalid window") ); if (hWnd) ::WinSetFocus(HWND_DESKTOP, hWnd); @@ -543,7 +547,7 @@ void wxWindowOS2::DoReleaseMouse() /* static */ wxWindow* wxWindowBase::GetCapture() { HWND hwnd = ::WinQueryCapture(HWND_DESKTOP); - return hwnd ? wxFindWinFromHandle((WXHWND)hwnd) : (wxWindow *)NULL; + return hwnd ? wxFindWinFromHandle((WXHWND)hwnd) : NULL; } // end of wxWindowBase::GetCapture bool wxWindowOS2::SetFont( const wxFont& rFont ) @@ -1092,7 +1096,7 @@ void wxWindowOS2::OnIdle( // // Set this window to be the child of 'parent'. // -bool wxWindowOS2::Reparent( wxWindow* pParent) +bool wxWindowOS2::Reparent( wxWindowBase* pParent) { if (!wxWindowBase::Reparent(pParent)) return false; @@ -1659,12 +1663,12 @@ int wxWindowOS2::GetCharWidth() const return(vFontMetrics.lAveCharWidth); } // end of wxWindowOS2::GetCharWidth -void wxWindowOS2::GetTextExtent( const wxString& rString, - int* pX, - int* pY, - int* pDescent, - int* pExternalLeading, - const wxFont* WXUNUSED(pTheFont) ) const +void wxWindowOS2::DoGetTextExtent( const wxString& rString, + int* pX, + int* pY, + int* pDescent, + int* pExternalLeading, + const wxFont* WXUNUSED(pTheFont) ) const { POINTL avPoint[TXTBOX_COUNT]; POINTL vPtMin; @@ -1748,7 +1752,7 @@ void wxWindowOS2::GetTextExtent( const wxString& rString, *pExternalLeading = 0; } ::WinReleasePS(hPS); -} // end of wxWindow::GetTextExtent +} // end of wxWindow::DoGetTextExtent bool wxWindowOS2::IsMouseInWindow() const { @@ -1784,10 +1788,6 @@ bool wxWindowOS2::DoPopupMenu( wxMenu* pMenu, int nX, int nY ) bool bIsWaiting = true; int nHeight; - // Protect against recursion - if (wxCurrentPopupMenu) - return false; - pMenu->SetInvokingWindow(this); pMenu->UpdateUI(); @@ -2550,7 +2550,7 @@ MRESULT wxWindowOS2::OS2WindowProc( WXUINT uMsg, (pPage->ulPageIdNew > 0L && pPage->ulPageIdCur > 0L)) { wxWindowOS2* pWin = wxFindWinFromHandle(pPage->hwndBook); - wxNotebookEvent vEvent( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED + wxBookCtrlEvent vEvent( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED ,(int)SHORT1FROMMP(wParam) ,(int)pPage->ulPageIdNew ,(int)pPage->ulPageIdCur @@ -2855,7 +2855,7 @@ void wxAssociateWinWithHandle( { wxString Newstr(pWin->GetClassInfo()->GetClassName()); wxString Oldstr(pOldWin->GetClassInfo()->GetClassName()); - wxLogError( _T("Bug! New window of class %s has same HWND %X as old window of class %s"), + wxLogError( wxT("Bug! New window of class %s has same HWND %X as old window of class %s"), Newstr.c_str(), (int)hWnd, Oldstr.c_str() @@ -3001,7 +3001,7 @@ bool wxWindowOS2::OS2Create( PSZ zClass, { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); - wxLogError(_T("Error creating frame. Error: %s\n"), sError.c_str()); + wxLogError(wxT("Error creating frame. Error: %s\n"), sError.c_str()); return false; } SetSize( nX @@ -3204,7 +3204,7 @@ bool wxWindowOS2::OS2OnDrawItem( int vId, WXDRAWITEMSTRUCT* pItemStruct ) { #if wxUSE_OWNER_DRAWN - wxDC vDc; + wxClientDC vDc(this); #if wxUSE_MENUS_NATIVE // @@ -3223,8 +3223,10 @@ bool wxWindowOS2::OS2OnDrawItem( int vId, ,pMeasureStruct->rclItem.xRight - pMeasureStruct->rclItem.xLeft ,pMeasureStruct->rclItem.yTop - pMeasureStruct->rclItem.yBottom ); - vDc.SetHDC( hDC, false ); - vDc.SetHPS( pMeasureStruct->hps ); + + wxPMDCImpl *impl = (wxPMDCImpl*) vDc.GetImpl(); + impl->SetHDC( hDC, false ); + impl->SetHPS( pMeasureStruct->hps ); // // Load the wxWidgets Pallete and set to RGB mode // @@ -3238,7 +3240,7 @@ bool wxWindowOS2::OS2OnDrawItem( int vId, { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); - wxLogError(_T("Unable to set current color table (1). Error: %s\n"), sError.c_str()); + wxLogError(wxT("Unable to set current color table (1). Error: %s\n"), sError.c_str()); } // // Set the color table to RGB mode @@ -3253,7 +3255,7 @@ bool wxWindowOS2::OS2OnDrawItem( int vId, { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); - wxLogError(_T("Unable to set current color table (2). Error: %s\n"), sError.c_str()); + wxLogError(wxT("Unable to set current color table (2). Error: %s\n"), sError.c_str()); } wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); @@ -3485,7 +3487,7 @@ void wxWindow::OnPaint ( wxPaintEvent& rEvent ) { - HDC hDC = (HDC)wxPaintDC::FindDCInCache((wxWindow*) rEvent.GetEventObject()); + HDC hDC = (HDC)wxPaintDCImpl::FindDCInCache((wxWindow*) rEvent.GetEventObject()); if (hDC != 0) { @@ -3670,10 +3672,10 @@ bool wxWindowOS2::HandleEraseBkgnd( WXHDC hDC ) if (vSwp.fl & SWP_MINIMIZE) return true; - wxDC vDC; - - vDC.m_hPS = (HPS)hDC; // this is really a PS - vDC.SetWindow((wxWindow*)this); + wxClientDC vDC(this); + wxPMDCImpl *impl = (wxPMDCImpl*) vDC.GetImpl(); + impl->SetHDC(hDC); + impl->SetHPS((HPS)hDC); // this is really a PS wxEraseEvent vEvent(m_windowId, &vDC); @@ -3681,14 +3683,15 @@ bool wxWindowOS2::HandleEraseBkgnd( WXHDC hDC ) rc = HandleWindowEvent(vEvent); - vDC.m_hPS = NULLHANDLE; + impl->SetHPS(NULLHANDLE); return true; } // end of wxWindowOS2::HandleEraseBkgnd void wxWindowOS2::OnEraseBackground(wxEraseEvent& rEvent) { RECTL vRect; - HPS hPS = rEvent.GetDC()->GetHPS(); + wxPMDCImpl *impl = (wxPMDCImpl*) rEvent.GetDC()->GetImpl(); + HPS hPS = impl->GetHPS(); APIRET rc; LONG lColor = m_backgroundColour.GetPixel();