Fix client coordinates mapping for wxSpinCtrl in wxMSW

Add MSWDoClientToScreen() and MSWDoScreenToClient() helpers and use them
with the correct HWND in DoClientToScreen() and DoScreenToClient()
overridden in wxSpinCtrl, i.e. the HWND of the "buddy" text control and
not the spin button, which is the main HWND of this control.

This notably fixes wxSpinCtrl::GetScreenPosition() which returned the
position of the spin button.

Closes https://github.com/wxWidgets/wxWidgets/pull/1454

Closes #18455.
This commit is contained in:
Kvaz1r
2019-07-31 18:17:25 +03:00
committed by Vadim Zeitlin
parent 2a2fa8c5af
commit a2f37a9ed5
4 changed files with 30 additions and 4 deletions

View File

@@ -120,6 +120,8 @@ protected:
virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const wxOVERRIDE;
virtual void DoGetSize(int *width, int *height) const wxOVERRIDE;
virtual void DoGetClientSize(int *x, int *y) const wxOVERRIDE;
virtual void DoClientToScreen(int *x, int *y) const wxOVERRIDE;
virtual void DoScreenToClient(int *x, int *y) const wxOVERRIDE;
#if wxUSE_TOOLTIPS
virtual void DoSetToolTip( wxToolTip *tip ) wxOVERRIDE;
#endif // wxUSE_TOOLTIPS

View File

@@ -621,6 +621,8 @@ protected:
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *font = NULL) const wxOVERRIDE;
static void MSWDoClientToScreen( WXHWND hWnd, int *x, int *y );
static void MSWDoScreenToClient( WXHWND hWnd, int *x, int *y );
virtual void DoClientToScreen( int *x, int *y ) const wxOVERRIDE;
virtual void DoScreenToClient( int *x, int *y ) const wxOVERRIDE;
virtual void DoGetPosition( int *x, int *y ) const wxOVERRIDE;

View File

@@ -846,4 +846,14 @@ void wxSpinCtrl::DoGetPosition(int *x, int *y) const
*x = wxMin(xBuddy, xText);
}
void wxSpinCtrl::DoScreenToClient(int *x, int *y) const
{
wxWindow::MSWDoScreenToClient(GetBuddyHwnd(), x, y);
}
void wxSpinCtrl::DoClientToScreen(int *x, int *y) const
{
wxWindow::MSWDoClientToScreen(GetBuddyHwnd(), x, y);
}
#endif // wxUSE_SPINCTRL

View File

@@ -1951,7 +1951,8 @@ void wxWindowMSW::DoGetPosition(int *x, int *y) const
*y = pos.y;
}
void wxWindowMSW::DoScreenToClient(int *x, int *y) const
/* static */
void wxWindowMSW::MSWDoScreenToClient(WXHWND hWnd, int *x, int *y)
{
POINT pt;
if ( x )
@@ -1959,7 +1960,7 @@ void wxWindowMSW::DoScreenToClient(int *x, int *y) const
if ( y )
pt.y = *y;
::ScreenToClient(GetHwnd(), &pt);
::ScreenToClient(hWnd, &pt);
if ( x )
*x = pt.x;
@@ -1967,7 +1968,8 @@ void wxWindowMSW::DoScreenToClient(int *x, int *y) const
*y = pt.y;
}
void wxWindowMSW::DoClientToScreen(int *x, int *y) const
/* static */
void wxWindowMSW::MSWDoClientToScreen(WXHWND hWnd, int *x, int *y)
{
POINT pt;
if ( x )
@@ -1975,7 +1977,7 @@ void wxWindowMSW::DoClientToScreen(int *x, int *y) const
if ( y )
pt.y = *y;
::ClientToScreen(GetHwnd(), &pt);
::ClientToScreen(hWnd, &pt);
if ( x )
*x = pt.x;
@@ -1983,6 +1985,16 @@ void wxWindowMSW::DoClientToScreen(int *x, int *y) const
*y = pt.y;
}
void wxWindowMSW::DoScreenToClient(int *x, int *y) const
{
MSWDoScreenToClient(GetHwnd(), x, y);
}
void wxWindowMSW::DoClientToScreen(int *x, int *y) const
{
MSWDoClientToScreen(GetHwnd(), x, y);
}
bool
wxWindowMSW::DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height)
{