From 626af8005cb5e562af6dd53547111020a68e78e8 Mon Sep 17 00:00:00 2001 From: David Webster Date: Wed, 30 Jan 2002 04:59:05 +0000 Subject: [PATCH] Finish basic dialog support and some scrolling fixes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13923 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/os2/toplevel.cpp | 16 ++++++ src/os2/window.cpp | 125 ++++++++++++++++++++++++++----------------- 2 files changed, 92 insertions(+), 49 deletions(-) diff --git a/src/os2/toplevel.cpp b/src/os2/toplevel.cpp index 0d30d62171..888f0ccf68 100644 --- a/src/os2/toplevel.cpp +++ b/src/os2/toplevel.cpp @@ -269,6 +269,18 @@ bool wxTopLevelWindowOS2::CreateDialog( nX = (vSizeDpy.x - nWidth) / 2; nY = (vSizeDpy.y - nHeight) / 2; } + m_backgroundColour.Set(wxString("LIGHT GREY")); + + LONG lColor = (LONG)m_backgroundColour.GetPixel(); + + if (!::WinSetPresParam( m_hWnd + ,PP_BACKGROUNDCOLOR + ,sizeof(LONG) + ,(PVOID)&lColor + )) + { + return FALSE; + } ::WinSetWindowPos( GetHwnd() ,HWND_TOP ,nX @@ -277,6 +289,10 @@ bool wxTopLevelWindowOS2::CreateDialog( ,nHeight ,SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_SHOW ); + // + // Set the m_hFrame to m_hWnd for Dialogs + // + m_hFrame = m_hWnd; SubclassWin(m_hWnd); return TRUE; } // end of wxTopLevelWindowOS2::CreateDialog diff --git a/src/os2/window.cpp b/src/os2/window.cpp index e9f26646b4..681b0b3451 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -764,7 +764,7 @@ void wxWindowOS2::SetScrollbar( int nPageSize = nThumbVisible; SBCDATA vInfo; HWND hWnd = GetHwnd(); - ULONG ulStyle = WS_VISIBLE | WS_SYNCPAINT; + ULONG ulStyle = WS_VISIBLE; RECTL vRect; ::WinQueryWindowRect(hWnd, &vRect); @@ -798,7 +798,7 @@ void wxWindowOS2::SetScrollbar( ,20 ,hWnd ,HWND_TOP - ,FID_HORZSCROLL + ,60000 ,&vInfo ,NULL ); @@ -848,7 +848,7 @@ void wxWindowOS2::SetScrollbar( ,vRect.yTop - (vRect.yBottom + 20) ,hWnd ,HWND_TOP - ,FID_VERTSCROLL + ,60001 ,&vInfo ,NULL ); @@ -892,10 +892,13 @@ void wxWindowOS2::ScrollWindow( , const wxRect* pRect ) { + nDy *= -1; // flip the sign of Dy as OS/2 is opposite Windows. RECTL vRect; RECTL vRect2; + RECTL vRectHorz; + RECTL vRectVert; + RECTL vRectChild; - nDy *= -1; // flip the sign of Dy as OS/2 is opposite wxWin. if (pRect) { vRect2.xLeft = pRect->x; @@ -905,36 +908,28 @@ void wxWindowOS2::ScrollWindow( } else { - ::WinQueryWindowRect(GetHwnd(), &vRect2); - ::WinQueryWindowRect(m_hWndScrollBarHorz, &vRect); + ::WinQueryWindowRect(GetHwnd(), &vRect); + ::WinQueryWindowRect(m_hWndScrollBarHorz, &vRectHorz); vRect2.yBottom += vRect.yTop - vRect.yBottom; - ::WinQueryWindowRect(m_hWndScrollBarVert, &vRect); + ::WinQueryWindowRect(m_hWndScrollBarVert, &vRectVert); vRect2.xRight -= vRect.xRight - vRect.xLeft; } - if (pRect) - ::WinScrollWindow( GetHwnd() - ,(LONG)nDx - ,(LONG)nDy - ,&vRect2 - ,NULL - ,NULLHANDLE - ,NULL - ,SW_INVALIDATERGN - ); - else - ::WinScrollWindow( GetHwnd() - ,nDx - ,nDy - ,NULL - ,NULL - ,NULLHANDLE - ,NULL - ,SW_INVALIDATERGN - ); + ::WinScrollWindow( GetHwnd() + ,(LONG)nDx + ,(LONG)nDy + ,&vRect + ,NULL + ,NULLHANDLE + ,NULL + ,SW_INVALIDATERGN + ); + ::WinInvalidateRect(m_hWndScrollBarHorz, &vRectHorz, FALSE); + ::WinInvalidateRect(m_hWndScrollBarVert, &vRectVert, FALSE); // // Move the children + // wxWindowList::Node* pCurrent = GetChildren().GetFirst(); SWP vSwp; @@ -945,31 +940,53 @@ void wxWindowOS2::ScrollWindow( if (pChildWin->GetHWND() != NULLHANDLE) { ::WinQueryWindowPos(pChildWin->GetHWND(), &vSwp); - ::WinQueryWindowRect(pChildWin->GetHWND(), &vRect); - if (pChildWin->GetHWND() == m_hWndScrollBarVert || - pChildWin->GetHWND() == m_hWndScrollBarHorz) + ::WinQueryWindowRect(pChildWin->GetHWND(), &vRectChild); + if (pChildWin->IsKindOf(CLASSINFO(wxControl))) { - ::WinSetWindowPos( pChildWin->GetHWND() - ,HWND_TOP - ,vSwp.x + nDx - ,vSwp.y + nDy - ,0 - ,0 - ,SWP_MOVE | SWP_SHOW | SWP_ZORDER - ); + wxControl* pCtrl; + + // + // Must deal with controls that have margins like ENTRYFIELD. The SWP + // struct of such a control will have and origin offset from its intended + // position by the width of the margins. + // + pCtrl = wxDynamicCast(pChildWin, wxControl); + vSwp.y -= pCtrl->GetYComp(); + vSwp.x -= pCtrl->GetXComp(); } - else + ::WinSetWindowPos( pChildWin->GetHWND() + ,HWND_BOTTOM + ,vSwp.x + nDx + ,vSwp.y + nDy + ,0 + ,0 + ,SWP_MOVE | SWP_ZORDER + ); + if (pChildWin->IsKindOf(CLASSINFO(wxRadioBox))) { - ::WinSetWindowPos( pChildWin->GetHWND() - ,HWND_BOTTOM - ,vSwp.x + nDx - ,vSwp.y + nDy - ,0 - ,0 - ,SWP_MOVE | SWP_ZORDER - ); - ::WinInvalidateRect(pChildWin->GetHWND(), &vRect, FALSE); + wxRadioBox* pRadioBox; + + pRadioBox = wxDynamicCast(pChildWin, wxRadioBox); + pRadioBox->AdjustButtons( (int)vSwp.x + nDx + ,(int)vSwp.y + nDy + ,(int)vSwp.cx + ,(int)vSwp.cy + ,pRadioBox->GetSizeFlags() + ); + } + if (pChildWin->IsKindOf(CLASSINFO(wxSlider))) + { + wxSlider* pSlider; + + pSlider = wxDynamicCast(pChildWin, wxSlider); + pSlider->AdjustSubControls( (int)vSwp.x + nDx + ,(int)vSwp.y + nDy + ,(int)vSwp.cx + ,(int)vSwp.cy + ,pSlider->GetSizeFlags() + ); } + ::WinInvalidateRect(pChildWin->GetHWND(), &vRectChild, FALSE); } pCurrent = pCurrent->GetNext(); } @@ -2421,7 +2438,7 @@ MRESULT wxWindowOS2::OS2WindowProc( // child controls, so we need to already be sized // in order to get the child controls positoned properly. // - if (IsKindOf(CLASSINFO(wxDialog))) + if (IsKindOf(CLASSINFO(wxDialog)) || IsKindOf(CLASSINFO(wxFrame))) { PSWP pSwp = (PSWP)PVOIDFROMMP(wParam); PSWP pSwp2 = pSwp++; @@ -2432,6 +2449,16 @@ MRESULT wxWindowOS2::OS2WindowProc( ,pSwp->cy ,(WXUINT)lParam ); + if (IsKindOf(CLASSINFO(wxFrame))) + { + wxFrame* pFrame = wxDynamicCast(this, wxFrame); + + if (pFrame) + { + if (pFrame->GetStatusBar()) + pFrame->PositionStatusBar(); + } + } } break; -- 2.45.2