Make using non-live resize work in wxAUI work in more cases

Use wxClientDC instead of wxScreenDC, which only works in wxMSW, and use
wxINVERT instead of wxXOR, to make DrawResizeHint() actually draw
something in wxGTK3 too.

And not using wxScreenDC might even help with some problems under MSW
too, see #23982.

Note that "rectangle hint" code still uses wxScreenDC, but this hint
kind should probably be just removed as it doesn't seem useful for
anything.
This commit is contained in:
Vadim Zeitlin 2023-12-26 19:23:40 +01:00
parent 1d328aa4e1
commit fffe7f7170

View file

@ -279,16 +279,21 @@ static wxBitmap wxPaneCreateStippleBitmap()
static void DrawResizeHint(wxDC& dc, const wxRect& rect)
{
#ifdef __WXMSW__
wxBitmap stipple = wxPaneCreateStippleBitmap();
wxBrush brush(stipple);
dc.SetBrush(brush);
#ifdef __WXMSW__
wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
PatBlt(GetHdcOf(*impl), rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight(), PATINVERT);
#else
dc.SetPen(*wxTRANSPARENT_PEN);
// Note that we have to use white colour for wxINVERT to work with
// wxGraphicsContext-based wxDC implementations, such as used by wxGTK3
// (and wxOSX, but this code is never used for the latter because it always
// uses live resize).
dc.SetPen(*wxWHITE_PEN);
dc.SetBrush(*wxWHITE_BRUSH);
dc.SetLogicalFunction(wxXOR);
dc.SetLogicalFunction(wxINVERT);
dc.DrawRectangle(rect);
#endif
}
@ -4469,7 +4474,7 @@ void wxAuiManager::OnLeftUp(wxMouseEvent& event)
if (!HasLiveResize())
{
// get rid of the hint rectangle
wxScreenDC dc;
wxClientDC dc{m_frame};
DrawResizeHint(dc, m_actionHintRect);
}
if (m_currentDragItem != -1 && HasLiveResize())
@ -4584,9 +4589,8 @@ void wxAuiManager::OnMotion(wxMouseEvent& event)
}
else
{
wxRect rect(m_frame->ClientToScreen(pos),
m_actionPart->rect.GetSize());
wxScreenDC dc;
wxRect rect(pos, m_actionPart->rect.GetSize());
wxClientDC dc{m_frame};
if (!m_actionHintRect.IsEmpty())
{
@ -4595,13 +4599,9 @@ void wxAuiManager::OnMotion(wxMouseEvent& event)
m_actionHintRect = wxRect();
}
// draw new resize hint, if it's inside the managed frame
wxRect frameScreenRect = m_frame->GetScreenRect();
if (frameScreenRect.Contains(rect))
{
DrawResizeHint(dc, rect);
m_actionHintRect = rect;
}
// draw new resize hint
DrawResizeHint(dc, rect);
m_actionHintRect = rect;
}
}
}