Fix link errors with older MinGW due to use of GetLayout()

This function is not present in older MinGW import libraries, up to at least
MinGW 4.8.1, so we can't use it directly as it was done in
22f0801378 and we need to load it dynamically.

This was already done in wxDC code, so just reuse the same wrapper function
after extracting it (and a few others, for consistency) into a new header.
This commit is contained in:
Vadim Zeitlin
2016-05-26 23:34:58 +02:00
parent 5e500de7e8
commit 78bfde8ac0
3 changed files with 41 additions and 12 deletions

View File

@@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/dcdynwrap.h
// Purpose: Private dynamically loaded HDC-related functions
// Author: Vadim Zeitlin
// Created: 2016-05-26 (extracted from src/msw/dc.cpp)
// Copyright: (c) 2016 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_DCDYNWRAP_H_
#define _WX_MSW_PRIVATE_DCDYNWRAP_H_
#include "wx/msw/wrapwin.h"
// Namespace for the wrapper functions, hopefully one day we'll be able to get
// rid of all of them and then it will be easy to find all occurrences of their
// use by just searching for this namespace name.
//
// All of the functions in this namespace must work *exactly* like the standard
// functions with the same name and just return an error if dynamically loading
// them failed.
//
// And they're all implemented in src/msw/dc.cpp.
namespace wxDynLoadWrappers
{
DWORD GetLayout(HDC hdc);
DWORD SetLayout(HDC hdc, DWORD dwLayout);
BOOL AlphaBlend(HDC hdcDest, int xDest, int yDest, int wDest, int hDest,
HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc,
BLENDFUNCTION bf);
BOOL GradientFill(HDC hdc, PTRIVERTEX pVert, ULONG numVert,
PVOID pMesh, ULONG numMesh, ULONG mode);
} // namespace wxDynLoadWrappers
#endif // _WX_MSW_PRIVATE_DCDYNWRAP_H_

View File

@@ -47,6 +47,7 @@
#include "wx/renderer.h" #include "wx/renderer.h"
#include "wx/msw/private.h" #include "wx/msw/private.h"
#include "wx/msw/dc.h" #include "wx/msw/dc.h"
#include "wx/msw/private/dcdynwrap.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// private functions // private functions
@@ -159,7 +160,7 @@ bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc,
UINT uState = stat & wxOwnerDrawn::wxODSelected ? wxDSB_SELECTED : wxDSB_NORMAL; UINT uState = stat & wxOwnerDrawn::wxODSelected ? wxDSB_SELECTED : wxDSB_NORMAL;
// checkmarks should not be mirrored in RTL layout // checkmarks should not be mirrored in RTL layout
DWORD oldLayout = ::GetLayout(hdc); DWORD oldLayout = wxDynLoadWrappers::GetLayout(hdc);
if ( oldLayout & LAYOUT_RTL ) if ( oldLayout & LAYOUT_RTL )
::SetLayout(hdc, oldLayout | LAYOUT_BITMAPORIENTATIONPRESERVED); ::SetLayout(hdc, oldLayout | LAYOUT_BITMAPORIENTATIONPRESERVED);
wxDrawStateBitmap(hdc, hBmpCheck, x, y, uState); wxDrawStateBitmap(hdc, hBmpCheck, x, y, uState);

View File

@@ -240,13 +240,6 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxGDIDLLsCleanupModule, wxModule);
#endif // USE_DYNAMIC_GDI_FUNCS #endif // USE_DYNAMIC_GDI_FUNCS
// Namespace for the wrapper functions, hopefully one day we'll be able to get
// rid of all of them and then it will be easy to find all occurrences of their
// use by just searching for this namespace name.
//
// All of the functions in this namespace must work *exactly* like the standard
// functions with the same name and just return an error if dynamically loading
// them failed.
namespace wxDynLoadWrappers namespace wxDynLoadWrappers
{ {
@@ -317,19 +310,16 @@ BOOL GradientFill(HDC hdc, PTRIVERTEX pVert, ULONG numVert,
#elif defined(USE_STATIC_GDI_FUNCS) #elif defined(USE_STATIC_GDI_FUNCS)
inline
DWORD GetLayout(HDC hdc) DWORD GetLayout(HDC hdc)
{ {
return ::GetLayout(hdc); return ::GetLayout(hdc);
} }
inline
DWORD SetLayout(HDC hdc, DWORD dwLayout) DWORD SetLayout(HDC hdc, DWORD dwLayout)
{ {
return ::SetLayout(hdc, dwLayout); return ::SetLayout(hdc, dwLayout);
} }
inline
BOOL AlphaBlend(HDC hdcDest, int xDest, int yDest, int wDest, int hDest, BOOL AlphaBlend(HDC hdcDest, int xDest, int yDest, int wDest, int hDest,
HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc,
BLENDFUNCTION bf) BLENDFUNCTION bf)
@@ -339,7 +329,6 @@ BOOL AlphaBlend(HDC hdcDest, int xDest, int yDest, int wDest, int hDest,
bf); bf);
} }
inline
BOOL GradientFill(HDC hdc, PTRIVERTEX pVert, ULONG numVert, BOOL GradientFill(HDC hdc, PTRIVERTEX pVert, ULONG numVert,
PVOID pMesh, ULONG numMesh, ULONG mode) PVOID pMesh, ULONG numMesh, ULONG mode)
{ {