From b720b24da89b6b60dbabde36f2a995357e3b1497 Mon Sep 17 00:00:00 2001 From: David Webster Date: Tue, 6 Aug 2002 03:35:32 +0000 Subject: [PATCH] Lots of OS/2 updates git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16378 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/os2/gauge.cpp | 56 +++++++++---- src/os2/statbox.cpp | 8 +- src/os2/stattext.cpp | 23 +++--- src/os2/window.cpp | 189 ++++++++++++++++++++++++++++--------------- src/os2/wx23.def | 21 ++--- 5 files changed, 195 insertions(+), 102 deletions(-) diff --git a/src/os2/gauge.cpp b/src/os2/gauge.cpp index e12f172304..05685686b1 100644 --- a/src/os2/gauge.cpp +++ b/src/os2/gauge.cpp @@ -43,6 +43,7 @@ MRESULT EXPENTRY wxGaugeWndProc( HPS hPS; RECTL vRect; RECTL vRect2; + RECTL vRect3; double dPixelToRange = 0.0; double dRange = 0.0; @@ -70,28 +71,55 @@ MRESULT EXPENTRY wxGaugeWndProc( ,0L ,NULL ); + // + // Draw the guage box + // + LONG lColor = 0x00FFFFFF; // White + POINTL vPoint = {vRect.xLeft + 1, vRect.yBottom + 1}; + + ::GpiSetColor(hPS, lColor); + ::GpiMove(hPS, &vPoint); + vPoint.x = vRect.xRight - 1; + ::GpiLine(hPS, &vPoint); + vPoint.y = vRect.yTop - 1; + ::GpiLine(hPS, &vPoint); + lColor = 0x000C0C0C; // Darkish Grey to give depth feel + ::GpiSetColor(hPS, lColor); + vPoint.x = vRect.xLeft + 1; + ::GpiLine(hPS, &vPoint); + vPoint.y = vRect.yBottom + 1; + ::GpiLine(hPS, &vPoint); + vRect3.xLeft = vRect.xLeft + 2; + vRect3.xRight = vRect.xRight - 2; + vRect3.yTop = vRect.yTop - 2; + vRect3.yBottom = vRect.yBottom + 2; + if (pGauge->GetWindowStyleFlag() & wxGA_VERTICAL) { - dRange = (double)(vRect.yTop - vRect.yBottom); + dRange = (double)(vRect3.yTop - vRect3.yBottom); dPixelToRange = dRange/(double)pGauge->GetRange(); vRect2.yTop = (int)(pGauge->GetValue() * dPixelToRange); - vRect2.yBottom = vRect.yBottom; - vRect2.xLeft = vRect.xLeft; - vRect2.xRight = vRect.xRight; - vRect.yBottom = vRect2.yTop; - ::WinFillRect(hPS, &vRect, pGauge->GetBackgroundColour().GetPixel()); + vRect2.yBottom = vRect3.yBottom; + vRect2.xLeft = vRect3.xLeft; + vRect2.xRight = vRect3.xRight; + vRect3.yBottom = vRect2.yTop; + if (vRect3.yBottom <= 1) + vRect3.yBottom = 2; + ::WinFillRect(hPS, &vRect3, pGauge->GetBackgroundColour().GetPixel()); ::WinFillRect(hPS, &vRect2, pGauge->GetForegroundColour().GetPixel()); } else { - dRange = (double)(vRect.xRight - vRect.xLeft); + dRange = (double)(vRect3.xRight - vRect3.xLeft); dPixelToRange = dRange/(double)pGauge->GetRange(); - vRect2.yTop = vRect.yTop; - vRect2.yBottom = vRect.yBottom; - vRect2.xLeft = vRect.xLeft; + vRect2.yTop = vRect3.yTop; + vRect2.yBottom = vRect3.yBottom; + vRect2.xLeft = vRect3.xLeft; vRect2.xRight = (int)(pGauge->GetValue() * dPixelToRange); - vRect.xLeft = vRect2.xRight; - ::WinFillRect(hPS, &vRect, pGauge->GetBackgroundColour().GetPixel()); + vRect3.xLeft = vRect2.xRight; + if (vRect3.xLeft <= 1) + vRect3.xLeft = 2; + ::WinFillRect(hPS, &vRect3, pGauge->GetBackgroundColour().GetPixel()); ::WinFillRect(hPS, &vRect2, pGauge->GetForegroundColour().GetPixel()); } ::WinEndPaint(hPS); @@ -131,8 +159,8 @@ bool wxGauge::Create( #endif if (pParent) pParent->AddChild(this); - SetBackgroundColour(pParent->GetBackgroundColour()) ; - SetForegroundColour(pParent->GetForegroundColour()) ; + m_backgroundColour.Set(wxString("LIGHT GREY")); + m_foregroundColour.Set(wxString("NAVY")); m_nRangeMax = nRange; m_nGaugePos = 0; diff --git a/src/os2/statbox.cpp b/src/os2/statbox.cpp index 571107c39b..998c4d9dd3 100644 --- a/src/os2/statbox.cpp +++ b/src/os2/statbox.cpp @@ -84,18 +84,12 @@ bool wxStaticBox::Create( ,sizeof(LONG) ,(PVOID)&lColor ); - wxFont* pTextFont = new wxFont( 10 - ,wxMODERN - ,wxNORMAL - ,wxNORMAL - ); - SetFont(*pTextFont); + SetFont(*wxSMALL_FONT); SetSize( rPos.x ,rPos.y ,rSize.x ,rSize.y ); - delete pTextFont; return TRUE; } // end of wxStaticBox::Create diff --git a/src/os2/stattext.cpp b/src/os2/stattext.cpp index 56e44dca0e..167caa3e86 100644 --- a/src/os2/stattext.cpp +++ b/src/os2/stattext.cpp @@ -101,18 +101,14 @@ bool wxStaticText::Create( ); SubclassWin(m_hWnd); - wxFont* pTextFont = new wxFont( 10 - ,wxMODERN - ,wxNORMAL - ,wxNORMAL - ); - wxControl::SetFont(*pTextFont); + SetFont(*wxSMALL_FONT); + SetXComp(0); + SetYComp(0); SetSize( nX ,nY ,nWidth ,nHeight ); - delete pTextFont; return TRUE; } // end of wxStaticText::Create @@ -223,9 +219,18 @@ void wxStaticText::SetLabel( // if (!(GetWindowStyle() & wxST_NO_AUTORESIZE)) { - DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT); + wxCoord vX; + wxCoord vY; + wxCoord vWidth; + wxCoord vHeight; + + GetPosition(&vX, &vY); + GetSize(&vWidth, &vHeight); + if (!(vX == -1 && vY == -1 && vWidth == -1 && vHeight == -1)) + DoSetSize(vX, vY, vWidth, vHeight, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT); + else + DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT); } - DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT); } // end of wxStaticText::SetLabel MRESULT wxStaticText::OS2WindowProc( diff --git a/src/os2/window.cpp b/src/os2/window.cpp index c9ad0104c2..f7fcfaead5 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -1753,19 +1753,6 @@ void wxWindowOS2::DoSetSize( 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) { @@ -1824,34 +1811,61 @@ void wxWindowOS2::DoSetClientSize( , int nHeight ) { - wxWindow* pParent = GetParent(); - HWND hWnd = GetHwnd(); - HWND hParentWnd = (HWND)0; POINTL vPoint; - RECTL vRect; - RECTL vRect2; - RECTL vRect3; - HWND hClientWnd = (HWND)0; + int nActualWidth; + int nActualHeight; + wxWindow* pParent = (wxWindow*)GetParent(); + HWND hParentWnd = (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) + hParentWnd = (HWND)pParent->GetHWND(); + + if (IsKindOf(CLASSINFO(wxFrame))) { - vPoint.x -= vRect3.xLeft; - vPoint.y -= vRect3.yBottom; + wxFrame* pFrame = wxDynamicCast(this, wxFrame); + HWND hFrame = pFrame->GetFrame(); + RECTL vRect; + RECTL vRect2; + RECTL vRect3; + + ::WinQueryWindowRect(GetHwnd(), &vRect2); + ::WinQueryWindowRect(hFrame, &vRect); + ::WinQueryWindowRect(hParentWnd, &vRect3); + nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth; + 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; + } } + else + { + int nX; + int nY; - DoMoveWindow(vPoint.x, vPoint.y, nActualWidth, nActualHeight); + GetPosition(&nX, &nY); + nActualWidth = nWidth; + nActualHeight = nHeight; + + vPoint.x = nX; + vPoint.y = nY; + } + DoMoveWindow( vPoint.x + ,vPoint.y + ,nActualWidth + ,nActualHeight + ); + + wxSizeEvent vEvent( wxSize( nWidth + ,nHeight + ) + ,m_windowId + ); - wxSizeEvent vEvent(wxSize(nWidth, nHeight), m_windowId); vEvent.SetEventObject(this); GetEventHandler()->ProcessEvent(vEvent); } // end of wxWindowOS2::DoSetClientSize @@ -5148,50 +5162,99 @@ wxWindowOS2* FindWindowForMouseEvent( , short* pnY ) { - wxCHECK_MSG( pnX && pnY, pWin, _T("NULL pointer in FindWindowForMouseEvent") ); - POINTL vPoint = { *pnX, *pnY }; HWND hWnd = GetHwndOf(pWin); HWND hWndUnderMouse; + POINTL vPoint; + BOOL rcEnabled = FALSE; + BOOL rcVisible = FALSE; + HWND hWndDesktop = HWND_DESKTOP; - // - // First try to find a non transparent child: this allows us to send events - // to a static text which is inside a static box, for example - // - - hWndUnderMouse = ::WinWindowFromPoint( hWnd - ,&vPoint - ,TRUE - ); - if (!hWndUnderMouse || hWndUnderMouse == hWnd) + ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); + hWndUnderMouse = ::WinWindowFromPoint(HWND_DESKTOP, &vPoint, TRUE); + if (hWndUnderMouse != HWND_DESKTOP) { - // - // Now try any child window at all - // - hWndUnderMouse = ::WinWindowFromPoint( HWND_DESKTOP - ,&vPoint - ,TRUE - ); + wxWindow* pWinUnderMouse = wxFindWinFromHandle((WXHWND)hWndUnderMouse); + if (pWinUnderMouse) + { + wxWindowList::Node* pCurrent = pWinUnderMouse->GetChildren().GetFirst(); + wxWindow* pChild = NULL; + wxWindow* pGrandChild = NULL; + RECTL vRect; + POINTL vPoint2; + + ::WinMapWindowPoints(HWND_DESKTOP, hWndUnderMouse, &vPoint, 1); + // + // Find a child window mouse might be under + // + while (pCurrent) + { + wxWindow* pChild = pCurrent->GetData(); + + vPoint2.x = vPoint.x; + vPoint2.y = vPoint.y; + ::WinMapWindowPoints(hWndUnderMouse, pChild->GetHWND(), &vPoint2, 1); + ::WinQueryWindowRect(pChild->GetHWND(), &vRect); + if (::WinPtInRect(vHabmain, &vRect, &vPoint2)) + { + if (pChild->IsTopLevel()) + { + POINTL vPoint3; + wxWindowList::Node* pCurrent2 =pChild->GetChildren().GetFirst(); + + while (pCurrent2) + { + wxWindow* pGrandChild = pCurrent2->GetData(); + + vPoint3.x = vPoint2.x; + vPoint3.y = vPoint2.y; + ::WinMapWindowPoints( pChild->GetHWND() + ,pGrandChild->GetHWND() + ,&vPoint3 + ,1 + ); + ::WinQueryWindowRect(pGrandChild->GetHWND(), &vRect); + if (::WinPtInRect(vHabmain, &vRect, &vPoint3)) + { + hWndUnderMouse = GetHwndOf(pGrandChild); + pWinUnderMouse = pGrandChild; + break; + } + pCurrent2 = pCurrent2->GetNext(); + } + if (pGrandChild) + break; + } + hWndUnderMouse = GetHwndOf(pChild); + pWinUnderMouse = pChild; + rcVisible = ::WinIsWindowVisible(hWndUnderMouse); + rcEnabled = ::WinIsWindowEnabled(hWndUnderMouse); + if (rcVisible && rcEnabled) + break; + } + pCurrent = pCurrent->GetNext(); + } + } } + rcVisible = ::WinIsWindowVisible(hWndUnderMouse); + rcEnabled = ::WinIsWindowEnabled(hWndUnderMouse); + // // Check that we have a child window which is susceptible to receive mouse // events: for this it must be shown and enabled + // if ( hWndUnderMouse && hWndUnderMouse != hWnd && - ::WinIsWindowVisible(hWndUnderMouse) && - ::WinIsWindowEnabled(hWndUnderMouse)) + rcVisible && rcEnabled) { - wxWindow* pWinUnderMouse = wxFindWinFromHandle((WXHWND)hWndUnderMouse); + wxWindow* pWinUnderMouse = wxFindWinFromHandle((WXHWND)hWndUnderMouse); + if (pWinUnderMouse) { - // translate the mouse coords to the other window coords - pWin->ClientToScreen( (int*)pnX - ,(int*)pnY - ); - pWinUnderMouse->ScreenToClient( (int*)pnX - ,(int*)pnY - ); + // + // Translate the mouse coords to the other window coords + // pWin = pWinUnderMouse; } } diff --git a/src/os2/wx23.def b/src/os2/wx23.def index c43bc29af5..8ef798c78e 100644 --- a/src/os2/wx23.def +++ b/src/os2/wx23.def @@ -4,7 +4,7 @@ DATA MULTIPLE NONSHARED READWRITE LOADONCALL CODE LOADONCALL EXPORTS -;From library: F:\Dev\Wx2\WxWindows\LIB\wx.lib +;From library: H:\DEV\WX2\WXWINDOWS\LIB\wx.lib ;From object file: dummy.cpp ;PUBDEFs (Symbols available from object file): wxDummyChar @@ -1955,7 +1955,7 @@ EXPORTS wxEVT_NC_LEFT_DCLICK wxEVT_INIT_DIALOG wxEVT_COMMAND_SET_FOCUS - ;From object file: F:\DEV\WX2\WXWINDOWS\src\common\extended.c + ;From object file: H:\DEV\WX2\WXWINDOWS\src\common\extended.c ;PUBDEFs (Symbols available from object file): ConvertToIeeeExtended ConvertFromIeeeExtended @@ -4337,10 +4337,13 @@ EXPORTS Get__15wxMessageOutputFv ;wxMessageOutput::ms_msgOut ms_msgOut__15wxMessageOutput + ;wxMessageOutputLog::Printf(const char*,...) + Printf__18wxMessageOutputLogFPCce ;wxMessageOutput::Set(wxMessageOutput*) Set__15wxMessageOutputFP15wxMessageOutput __vft25wxMessageOutputMessageBox15wxMessageOutput __vft21wxMessageOutputStderr15wxMessageOutput + __vft18wxMessageOutputLog15wxMessageOutput ;wxMessageOutputStderr::Printf(const char*,...) Printf__21wxMessageOutputStderrFPCce ;From object file: ..\common\mstream.cpp @@ -6175,7 +6178,7 @@ EXPORTS Read32__17wxTextInputStreamFv ;wxTextInputStream::SkipIfEndOfLine(char) SkipIfEndOfLine__17wxTextInputStreamFc - ;From object file: F:\DEV\WX2\WXWINDOWS\src\common\unzip.c + ;From object file: H:\DEV\WX2\WXWINDOWS\src\common\unzip.c ;PUBDEFs (Symbols available from object file): unzReadCurrentFile unzGetCurrentFileInfo @@ -9135,6 +9138,8 @@ EXPORTS SetItem__17wxGenericListCtrlFR10wxListItem ;wxListLineData::SetItem(int,const wxListItem&) SetItem__14wxListLineDataFiRC10wxListItem + ;wxGenericListCtrl::SetImageList(wxGenericImageList*,int) + SetImageList__17wxGenericListCtrlFP18wxGenericImageListi ;wxGenericListCtrl::SetColumnWidth(int,int) SetColumnWidth__17wxGenericListCtrlFiT1 ;wxGenericListCtrl::ScrollList(int,int) @@ -9227,8 +9232,8 @@ EXPORTS SetItem__16wxListHeaderDataFRC10wxListItem ;wxListMainWindow::SetItemState(long,long,long) SetItemState__16wxListMainWindowFlN21 - ;wxListMainWindow::SetImageList(wxImageList*,int) - SetImageList__16wxListMainWindowFP11wxImageListi + ;wxListMainWindow::SetImageList(wxGenericImageList*,int) + SetImageList__16wxListMainWindowFP18wxGenericImageListi ;wxGenericListCtrl::SetColumn(int,wxListItem&) SetColumn__17wxGenericListCtrlFiR10wxListItem ;wxListMainWindow::SetColumnWidth(int,int) @@ -9257,8 +9262,6 @@ EXPORTS DeleteColumn__17wxGenericListCtrlFi ;wxListMainWindow::CacheLineData(unsigned int) CacheLineData__16wxListMainWindowFUi - ;wxGenericListCtrl::AssignImageList(wxImageList*,int) - AssignImageList__17wxGenericListCtrlFP11wxImageListi ;wxGenericListCtrl::GetNextItem(long,int,int) const GetNextItem__17wxGenericListCtrlCFliT2 ;wxConstructorForwxListCtrl() @@ -9380,6 +9383,8 @@ EXPORTS DrawImage__16wxListMainWindowFiP4wxDCN21 ;wxListMainWindow::ChangeCurrent(unsigned int) ChangeCurrent__16wxListMainWindowFUi + ;wxGenericListCtrl::AssignImageList(wxGenericImageList*,int) + AssignImageList__17wxGenericListCtrlFP18wxGenericImageListi ;wxGenericListCtrl::~wxGenericListCtrl() __dt__17wxGenericListCtrlFv wxEVT_COMMAND_LIST_KEY_DOWN @@ -9594,8 +9599,6 @@ EXPORTS SetItem__16wxListMainWindowFR10wxListItem ;wxListItemData::SetItem(const wxListItem&) SetItem__14wxListItemDataFRC10wxListItem - ;wxGenericListCtrl::SetImageList(wxImageList*,int) - SetImageList__17wxGenericListCtrlFP11wxImageListi ;wxListMainWindow::SetColumn(int,wxListItem&) SetColumn__16wxListMainWindowFiR10wxListItem ;wxListLineDataArray::RemoveAt(unsigned int,unsigned int)