From 47bd5c068556f174a921ae184234e823b4b8e6eb Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Sat, 28 Mar 2015 04:09:34 -0700 Subject: [PATCH] MGR: When erasing controls in Simple Preferences dialog, align background image correctly for controls that are descendants of the dialog deeper than one level (grandchild, great-grandchild, etc.) --- clientgui/sg_CustomControls.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/clientgui/sg_CustomControls.cpp b/clientgui/sg_CustomControls.cpp index 356efb6968..93054d2e1a 100644 --- a/clientgui/sg_CustomControls.cpp +++ b/clientgui/sg_CustomControls.cpp @@ -180,8 +180,14 @@ void CTransparentHyperlinkCtrl::OnEraseBackground(wxEraseEvent& event) wxMemoryDC memDC(**m_pParentsBgBmp); wxSize sz = GetClientSize(); wxDC *dc = event.GetDC(); - wxCoord x, y; - GetPosition(&x, &y); + wxCoord x=0, y=0, xx, yy; + wxWindow* win = this; + do { + win->GetPosition(&xx, &yy); + x += xx; + y += yy; + win = win->GetParent(); + } while (!win->IsTopLevel()); dc->Blit(0, 0, sz.GetWidth(), sz.GetHeight(), &memDC, x, y, wxCOPY); } else { event.Skip(); @@ -365,8 +371,14 @@ void CTransparentCheckBox::OnEraseBackground(wxEraseEvent& event) wxMemoryDC memDC(**m_pParentsBgBmp); wxSize sz = GetClientSize(); wxDC *dc = event.GetDC(); - wxCoord x, y; - GetPosition(&x, &y); + wxCoord x=0, y=0, xx, yy; + wxWindow* win = this; + do { + win->GetPosition(&xx, &yy); + x += xx; + y += yy; + win = win->GetParent(); + } while (!win->IsTopLevel()); dc->Blit(0, 0, sz.GetWidth(), sz.GetHeight(), &memDC, x, y, wxCOPY); } else { event.Skip();