Add wxMapWindowPoints() private helper function
This allows to avoid having to use casts from RECT to POINT in the rest of the code by encapsulating this cast, and the comment explaining it, in this function only. No real changes.
This commit is contained in:
parent
002b97101e
commit
252551fd26
5 changed files with 22 additions and 9 deletions
|
|
@ -386,6 +386,21 @@ inline RECT wxGetClientRect(HWND hwnd)
|
|||
return rect;
|
||||
}
|
||||
|
||||
// Call MapWindowPoints() on a RECT: because a RECT is (intentionally) laid out
|
||||
// as 2 consecutive POINTs, the cast below is valid but we still prefer to hide
|
||||
// it in this function instead of writing it out in the rest of the code.
|
||||
inline void wxMapWindowPoints(HWND hwndFrom, HWND hwndTo, RECT* rc)
|
||||
{
|
||||
::MapWindowPoints(hwndFrom, hwndTo, reinterpret_cast<POINT *>(rc), 2);
|
||||
}
|
||||
|
||||
// For consistency also provide an overload taking a POINT, even if this one is
|
||||
// even more trivial.
|
||||
inline void wxMapWindowPoints(HWND hwndFrom, HWND hwndTo, POINT* pt)
|
||||
{
|
||||
::MapWindowPoints(hwndFrom, hwndTo, pt, 1);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// small helper classes
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -87,10 +87,7 @@ wxMessageDialogMap& HookMap()
|
|||
void ScreenRectToClient(HWND hwnd, RECT& rc)
|
||||
{
|
||||
// map from desktop (i.e. screen) coordinates to ones of this window
|
||||
//
|
||||
// notice that a RECT is laid out as 2 consecutive POINTs so the cast is
|
||||
// valid
|
||||
::MapWindowPoints(HWND_DESKTOP, hwnd, reinterpret_cast<POINT *>(&rc), 2);
|
||||
wxMapWindowPoints(HWND_DESKTOP, hwnd, &rc);
|
||||
}
|
||||
|
||||
// set window position to the given rect
|
||||
|
|
|
|||
|
|
@ -1195,7 +1195,7 @@ bool wxNotebook::MSWPrintChild(WXHDC hDC, wxWindow *child)
|
|||
|
||||
// map rect to the coords of the window we're drawing in
|
||||
if ( child )
|
||||
::MapWindowPoints(GetHwnd(), GetHwndOf(child), (POINT *)&rc, 2);
|
||||
wxMapWindowPoints(GetHwnd(), GetHwndOf(child), &rc);
|
||||
|
||||
// If we're using a solid colour (for example if we've switched off
|
||||
// theming for this notebook), paint it
|
||||
|
|
|
|||
|
|
@ -3660,7 +3660,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||
POINT point;
|
||||
point.x = GET_X_LPARAM(pos);
|
||||
point.y = GET_Y_LPARAM(pos);
|
||||
::MapWindowPoints(HWND_DESKTOP, GetHwnd(), &point, 1);
|
||||
wxMapWindowPoints(HWND_DESKTOP, GetHwnd(), &point);
|
||||
int htFlags = 0;
|
||||
wxTreeItemId item = HitTest(wxPoint(point.x, point.y), htFlags);
|
||||
|
||||
|
|
|
|||
|
|
@ -1950,8 +1950,9 @@ void wxWindowMSW::DoGetPosition(int *x, int *y) const
|
|||
{
|
||||
// In RTL mode, we want the logical left x-coordinate,
|
||||
// which would be the physical right x-coordinate.
|
||||
::MapWindowPoints(nullptr, parent ? GetHwndOf(parent) : HWND_DESKTOP,
|
||||
(LPPOINT)&rect, 2);
|
||||
wxMapWindowPoints(HWND_DESKTOP,
|
||||
parent ? GetHwndOf(parent) : HWND_DESKTOP,
|
||||
&rect);
|
||||
}
|
||||
|
||||
pos.x = rect.left;
|
||||
|
|
@ -5456,7 +5457,7 @@ wxWindowMSW::MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child)
|
|||
// uses RTL layout, which is exactly what we need here as the child
|
||||
// window origin is its _right_ top corner in this case and not the
|
||||
// left one.
|
||||
::MapWindowPoints(nullptr, GetHwnd(), (POINT *)&rc, 2);
|
||||
wxMapWindowPoints(HWND_DESKTOP, GetHwnd(), &rc);
|
||||
|
||||
int x = rc.left,
|
||||
y = rc.top;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue