Fixed (?) problem in region handling which caused major redraw problems.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40497 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -170,10 +170,9 @@ public:
|
|||||||
// Tests
|
// Tests
|
||||||
// Does the region contain the point (x,y)?
|
// Does the region contain the point (x,y)?
|
||||||
//
|
//
|
||||||
wxRegionContain Contains( wxCoord lX
|
inline wxRegionContain Contains( wxCoord lX, wxCoord lY ) const{
|
||||||
,wxCoord lY
|
return Contains( wxPoint( lX, lY ) );
|
||||||
) const;
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Convert the region to a B&W bitmap with the black pixels being inside
|
// Convert the region to a B&W bitmap with the black pixels being inside
|
||||||
// the region.
|
// the region.
|
||||||
@@ -206,7 +205,10 @@ public:
|
|||||||
//
|
//
|
||||||
// Does the region contain the rectangle rect?
|
// Does the region contain the rectangle rect?
|
||||||
//
|
//
|
||||||
wxRegionContain Contains(const wxRect& rRect) const;
|
inline wxRegionContain Contains(const wxRect& rRect) const{
|
||||||
|
return Contains( rRect.x, rRect.y,
|
||||||
|
rRect.GetWidth(), rRect.GetHeight());
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Internal
|
// Internal
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
// Modified by:
|
// Modified by:
|
||||||
// Created: 10/15/99
|
// Created: 10/15/99
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Davdi Webster
|
// Copyright: (c) David Webster
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -86,6 +86,13 @@ public:
|
|||||||
// wxRegion
|
// wxRegion
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// General remark:
|
||||||
|
// wxRegion is always basically stored in wx coordinates. However, since
|
||||||
|
// OS/2's internal functions rely on "top > bottom", the values of top and
|
||||||
|
// bottom values of a region need to be interchanged, as compared to wx.
|
||||||
|
// This needs to be taken into account when feeding any rectangle to wx _or_
|
||||||
|
// when accessing the region data via GetBox, wxRegionIterator or otherwise.
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Create an empty region.
|
* Create an empty region.
|
||||||
*/
|
*/
|
||||||
@@ -162,8 +169,8 @@ wxRegion::wxRegion(
|
|||||||
|
|
||||||
vRect.xLeft = rTopLeft.x;
|
vRect.xLeft = rTopLeft.x;
|
||||||
vRect.xRight = rBottomRight.x;
|
vRect.xRight = rBottomRight.x;
|
||||||
vRect.yBottom = rBottomRight.y;
|
vRect.yBottom = rTopLeft.y;
|
||||||
vRect.yTop = rTopLeft.y;
|
vRect.yTop = rBottomRight.y;
|
||||||
|
|
||||||
m_refData = new wxRegionRefData;
|
m_refData = new wxRegionRefData;
|
||||||
|
|
||||||
@@ -428,47 +435,20 @@ bool wxRegion::Empty() const
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Tests
|
// Tests
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
//
|
|
||||||
// Does the region contain the point (x,y)?
|
|
||||||
wxRegionContain wxRegion::Contains(
|
|
||||||
wxCoord x
|
|
||||||
, wxCoord y
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
POINTL vPoint;
|
|
||||||
|
|
||||||
vPoint.x = x;
|
|
||||||
vPoint.y = y;
|
|
||||||
|
|
||||||
if (!m_refData)
|
|
||||||
return wxOutRegion;
|
|
||||||
|
|
||||||
LONG lInside = ::GpiPtInRegion( ((wxRegionRefData*)m_refData)->m_hPS
|
|
||||||
,M_REGION
|
|
||||||
,&vPoint
|
|
||||||
);
|
|
||||||
if (lInside == PRGN_INSIDE)
|
|
||||||
return wxInRegion;
|
|
||||||
return wxOutRegion;
|
|
||||||
} // end of wxRegion::Contains
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Does the region contain the point pt?
|
// Does the region contain the point pt?
|
||||||
//
|
//
|
||||||
wxRegionContain wxRegion::Contains(
|
wxRegionContain wxRegion::Contains( const wxPoint& rPoint ) const
|
||||||
const wxPoint& rPoint
|
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
POINTL vPoint = { rPoint.x, rPoint.y };
|
POINTL vPoint = { rPoint.x, rPoint.y };
|
||||||
|
|
||||||
if (!m_refData)
|
if (!m_refData)
|
||||||
return wxOutRegion;
|
return wxOutRegion;
|
||||||
|
|
||||||
LONG lInside = ::GpiPtInRegion( ((wxRegionRefData*)m_refData)->m_hPS
|
LONG lInside = ::GpiPtInRegion( ((wxRegionRefData*)m_refData)->m_hPS,
|
||||||
,M_REGION
|
M_REGION,
|
||||||
,&vPoint
|
&vPoint
|
||||||
);
|
);
|
||||||
if (lInside == PRGN_INSIDE)
|
if (lInside == PRGN_INSIDE)
|
||||||
return wxInRegion;
|
return wxInRegion;
|
||||||
else
|
else
|
||||||
@@ -478,56 +458,31 @@ wxRegionContain wxRegion::Contains(
|
|||||||
//
|
//
|
||||||
// Does the region contain the rectangle (x, y, w, h)?
|
// Does the region contain the rectangle (x, y, w, h)?
|
||||||
//
|
//
|
||||||
wxRegionContain wxRegion::Contains(
|
wxRegionContain wxRegion::Contains( wxCoord x,
|
||||||
wxCoord x
|
wxCoord y,
|
||||||
, wxCoord y
|
wxCoord vWidth,
|
||||||
, wxCoord vWidth
|
wxCoord vHeight ) const
|
||||||
, wxCoord vHeight
|
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
RECTL vRect;
|
|
||||||
|
|
||||||
if (!m_refData)
|
if (!m_refData)
|
||||||
return wxOutRegion;
|
return wxOutRegion;
|
||||||
|
|
||||||
|
RECTL vRect;
|
||||||
vRect.xLeft = x;
|
vRect.xLeft = x;
|
||||||
vRect.yTop = y;
|
|
||||||
vRect.xRight = x + vWidth;
|
vRect.xRight = x + vWidth;
|
||||||
vRect.yBottom = y + vHeight;
|
vRect.yTop = y + vHeight;
|
||||||
|
vRect.yBottom = y;
|
||||||
|
|
||||||
if (PRGN_INSIDE == ::GpiRectInRegion( ((wxRegionRefData*)m_refData)->m_hPS
|
LONG lInside = ::GpiRectInRegion( ((wxRegionRefData*)m_refData)->m_hPS,
|
||||||
,M_REGION
|
M_REGION,
|
||||||
,&vRect
|
&vRect
|
||||||
))
|
);
|
||||||
return wxInRegion;
|
switch (lInside)
|
||||||
else
|
{
|
||||||
return wxOutRegion;
|
case RRGN_INSIDE : return wxInRegion;
|
||||||
} // end of wxRegion::Contains
|
case RRGN_PARTIAL : return wxPartRegion;
|
||||||
|
case RRGN_ERROR :
|
||||||
//
|
default : return wxOutRegion;
|
||||||
// Does the region contain the rectangle rect
|
}
|
||||||
//
|
|
||||||
wxRegionContain wxRegion::Contains(
|
|
||||||
const wxRect& rRect
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
if (!m_refData)
|
|
||||||
return wxOutRegion;
|
|
||||||
|
|
||||||
wxCoord x;
|
|
||||||
wxCoord y;
|
|
||||||
wxCoord vWidth;
|
|
||||||
wxCoord vHeight;
|
|
||||||
|
|
||||||
x = rRect.x;
|
|
||||||
y = rRect.y;
|
|
||||||
vWidth = rRect.GetWidth();
|
|
||||||
vHeight = rRect.GetHeight();
|
|
||||||
return Contains( x
|
|
||||||
,y
|
|
||||||
,vWidth
|
|
||||||
,vHeight
|
|
||||||
);
|
|
||||||
} // end of wxRegion::Contains
|
} // end of wxRegion::Contains
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@@ -2641,6 +2641,7 @@ MRESULT wxWindowOS2::OS2WindowProc( WXUINT uMsg,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CBN_LBSELECT:
|
||||||
case BN_CLICKED: // Dups as LN_SELECT and CBN_LBSELECT
|
case BN_CLICKED: // Dups as LN_SELECT and CBN_LBSELECT
|
||||||
{
|
{
|
||||||
HWND hWnd = ::WinWindowFromID((HWND)GetHwnd(), SHORT1FROMMP(wParam));
|
HWND hWnd = ::WinWindowFromID((HWND)GetHwnd(), SHORT1FROMMP(wParam));
|
||||||
@@ -2697,11 +2698,19 @@ MRESULT wxWindowOS2::OS2WindowProc( WXUINT uMsg,
|
|||||||
,(WXWORD)SHORT1FROMMP(wParam)
|
,(WXWORD)SHORT1FROMMP(wParam)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (pWin->IsKindOf(CLASSINFO(wxChoice)))
|
||||||
|
{
|
||||||
|
wxChoice* pChoice = wxDynamicCast(pWin, wxChoice);
|
||||||
|
|
||||||
|
pChoice->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
|
||||||
|
,(WXWORD)SHORT1FROMMP(wParam)
|
||||||
|
);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
case LN_ENTER: /* dups as CBN_EFCHANGE */
|
case LN_ENTER:
|
||||||
{
|
{
|
||||||
HWND hWnd = HWNDFROMMP(lParam);
|
HWND hWnd = HWNDFROMMP(lParam);
|
||||||
wxWindowOS2* pWin = wxFindWinFromHandle(hWnd);
|
wxWindowOS2* pWin = wxFindWinFromHandle(hWnd);
|
||||||
@@ -3568,15 +3577,10 @@ bool wxWindowOS2::HandlePaint()
|
|||||||
wxLogLastError(wxT("CreateRectRgn"));
|
wxLogLastError(wxT("CreateRectRgn"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all the rectangles from the region, convert the individual
|
// Get all the rectangles from the region, convert the individual
|
||||||
// rectangles to "the other" coordinate system and reassemble a
|
// rectangles to "the other" coordinate system and reassemble a
|
||||||
// region from the rectangles, to be feed into m_updateRegion.
|
// region from the rectangles, to be feed into m_updateRegion.
|
||||||
//
|
//
|
||||||
// FIXME: This is a bad hack since OS/2 API specifies that rectangles
|
|
||||||
// passed into GpiSetRegion must not have Bottom > Top,
|
|
||||||
// however, at first sight, it _seems_ to work nonetheless.
|
|
||||||
//
|
|
||||||
RGNRECT vRgnData;
|
RGNRECT vRgnData;
|
||||||
PRECTL pUpdateRects = NULL;
|
PRECTL pUpdateRects = NULL;
|
||||||
vRgnData.ulDirection = RECTDIR_LFRT_TOPBOT;
|
vRgnData.ulDirection = RECTDIR_LFRT_TOPBOT;
|
||||||
@@ -3606,14 +3610,13 @@ bool wxWindowOS2::HandlePaint()
|
|||||||
{
|
{
|
||||||
int rectHeight;
|
int rectHeight;
|
||||||
rectHeight = pUpdateRects[i].yTop - pUpdateRects[i].yBottom;
|
rectHeight = pUpdateRects[i].yTop - pUpdateRects[i].yBottom;
|
||||||
pUpdateRects[i].yTop = height - pUpdateRects[i].yTop;
|
pUpdateRects[i].yBottom = height - pUpdateRects[i].yTop;
|
||||||
pUpdateRects[i].yBottom = pUpdateRects[i].yTop + rectHeight;
|
pUpdateRects[i].yTop = pUpdateRects[i].yBottom + rectHeight;
|
||||||
}
|
}
|
||||||
::GpiSetRegion(hPS, hRgn, vRgnData.crc, pUpdateRects);
|
::GpiSetRegion(hPS, hRgn, vRgnData.crc, pUpdateRects);
|
||||||
delete [] pUpdateRects;
|
delete [] pUpdateRects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_updateRegion = wxRegion(hRgn, hPS);
|
m_updateRegion = wxRegion(hRgn, hPS);
|
||||||
|
|
||||||
vEvent.SetEventObject(this);
|
vEvent.SetEventObject(this);
|
||||||
|
Reference in New Issue
Block a user