[Git][wxwidgets/wxwidgets][master] 19 commits: Remove unneeded winundef.h includes

3 views
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
Nov 16, 2025, 12:57:41 PM (11 days ago) Nov 16
to wx-commi...@googlegroups.com


Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets


Commits:
8593de07 by Maarten Bent at 2025-11-09T17:53:07+01:00
Remove unneeded winundef.h includes

And remove some probably unneeded undefs.

- - - - -
5228892b by Maarten Bent at 2025-11-09T18:02:12+01:00
White-space and style cleanup in winundef.h

- - - - -
b7705f83 by Maarten Bent at 2025-11-10T23:10:25+01:00
Add option to restore ANSI win32 functions

Define wxNO_WIN32_W before including wxWidgets headers to inline
ANSI win32 API functions instead of WIDE win32 API functions.

Fixes #25803

- - - - -
940b850b by Maarten Bent at 2025-11-10T23:10:52+01:00
Use WIDE variant of win32 API functions

wxWidgets uses the WIDE variant of the win32 API. But when the ANSI version of
Windows.h is included before wxWidgets headers and wxNO_WIN32_W is defined,
the ANSI variant of the functions will be used.

This can cause build errors in headers that are (indirectly) included by the user.
Because the class/string types do not match the function type.

So use the WIDE variant explicitly to prevent these errors.

- - - - -
a92af9e2 by ali kettab at 2025-11-10T23:13:27+01:00
wxQt: Fix the destruction of the wxMDIParentFrame's client window

This fixes a double deletion problem which can be seen in the mdi sample.

- - - - -
b7c367f9 by ali kettab at 2025-11-10T23:24:13+01:00
wxQt: Fix setting a new menu bar for an active wxMDIChildFrame

- - - - -
205425c6 by ali kettab at 2025-11-11T00:29:20+01:00
Revert commit b4d80a7e23

This commit added in 2025-04-24 (Use wxUIActionSimulator to test event
propagation order DocView test) is no longer needed under wxQt because
the problem preventing wxMenu::SendEvent() from working correctly under
wxQt is fixed in the parent commit.

- - - - -
06a4a1d5 by ali kettab at 2025-11-11T22:38:34+01:00
wxQt: Rename wxMDIParentFrame::Layout enum type to wxMDIParentFrame::Kind

Fixes #25742

- - - - -
5ea25b01 by ali kettab at 2025-11-11T22:39:55+01:00
wxQt: Remove duplicate comment in wxMDIParentFrame::AddWindowMenu()

- - - - -
2af382d9 by ali kettab at 2025-11-11T22:56:44+01:00
wxQt: Rewrite wxDC::DrawText() in terms of wxDC::DrawRotatedText()

This just eliminates code duplication between the two functions. And
also fix calculating the bounding box of a rotated text.

- - - - -
c0637607 by ali kettab at 2025-11-12T10:50:05+01:00
wxQt: Fix a memory leak when setting maxlen for a multiline textctrl

- - - - -
dc60fd3b by Vadim Zeitlin at 2025-11-15T13:47:53+01:00
Remove mention of "client area" from wxEVT_LEAVE_WINDOW docs

This message is generated when the mouse leaves the window, not its
client area (i.e. it is not generated if the mouse moves over the window
scrollbars).

- - - - -
bfd436b3 by Maarten Bent at 2025-11-15T18:55:06+01:00
CMake: Make _UNICODE/UNICODE defines private

Applications/libraries linking to wxWidgets libraries will not automatically inherit them anymore.

- - - - -
b25f44a7 by Maarten Bent at 2025-11-16T14:49:47+01:00
Add test for including Windows headers before wx headers

Test both ANSI and WIDE (with/without UNICODE) builds.

- - - - -
3842352b by Maarten Bent at 2025-11-16T18:25:40+01:00
Use correct column attributes when drawing wxListCtrl

When a column is custom drawn, it wrongly used the wxItemAttr of the
column being updated to redraw all columns.

Fix this by requesting the column attributes of each column that is
drawn.

See #25633.

Closes #25962.

- - - - -
f2cb2c75 by Vadim Zeitlin at 2025-11-16T18:28:58+01:00
Merge branch 'win32-ansi-restore' of github.com:MaartenBent/wxWidgets

Allow predefining wxNO_WIN32_W to prevent wxWidgets from redefining
Win32 symbols as their wide versions.

See #25965.

Closes #25803.

- - - - -
1578e735 by Vadim Zeitlin at 2025-11-16T18:34:57+01:00
Fix wrong origin offset when using wxRenderer with wxGCDC

ConvertToRECT() in wxRenderer code accounted for the origin shift twice
when using wxGCDC since the changes of 4f9186f1a1 (Increase usable
scrolling range in wxMSW by a factor of 10,000, 2022-04-30) which added
Offset(dc.GetDeviceOrigin()) call to it as for wxGCDC this offset is
already accounted for by MSWApplyGDIPlusTransform().

Fix this by replacing MSWApplyGDIPlusTransform() with a more generic
MSWApplyWXTransform() which does the same thing as before for wxGCDC but
applies the origin offset for other wxDCs. This ensures that this offset
is properly accounted for in both cases.

See #25966, #25967.

- - - - -
69215160 by Vadim Zeitlin at 2025-11-16T18:36:00+01:00
Merge branch 'qt-fixes' of github.com:AliKet/wxWidgets

Miscellaneous wxQt fixes.

See #25968.

- - - - -
f3da561f by Avery King at 2025-11-16T18:36:41+01:00
Fix wxQt build with Qt 6.9

Add the required cast to fix compilation.

Closes #25970.

Closes #25484.

- - - - -


30 changed files:

- build/cmake/functions.cmake
- build/cmake/tests/CMakeLists.txt
- + build/cmake/tests/win32/CMakeLists.txt
- docs/doxygen/mainpages/const_cpp.h
- include/wx/dc.h
- include/wx/dcgraph.h
- include/wx/image.h
- include/wx/msw/dc.h
- include/wx/msw/listctrl.h
- include/wx/msw/ole/automtn.h
- include/wx/msw/private.h
- include/wx/msw/winundef.h
- include/wx/qt/mdi.h
- interface/wx/event.h
- src/common/dcgraph.cpp
- src/common/fmapbase.cpp
- src/common/fontcmn.cpp
- src/common/fontmap.cpp
- src/generic/helpext.cpp
- src/generic/scrlwing.cpp
- src/msw/dc.cpp
- src/msw/listctrl.cpp
- src/msw/renderer.cpp
- src/qt/dc.cpp
- src/qt/frame.cpp
- src/qt/mdi.cpp
- src/qt/textctrl.cpp
- src/qt/uiaction.cpp
- tests/events/propagation.cpp
- + tests/testwin32.cpp


Changes:

=====================================
build/cmake/functions.cmake
=====================================
@@ -382,9 +382,10 @@ function(wx_set_target_properties target_name)
endif()

if(WIN32)
- target_compile_definitions(${target_name} PUBLIC UNICODE)
+ # not needed for wxWidgets anymore (it is always built with unicode)
+ # but keep it here so IDEs like Visual Studio know what character set is used
+ target_compile_definitions(${target_name} PRIVATE UNICODE _UNICODE)
endif()
- target_compile_definitions(${target_name} PUBLIC _UNICODE)

wx_get_install_dir(library)
file(RELATIVE_PATH wxSETUP_HEADER_REL ${wxOUTPUT_DIR} ${wxSETUP_HEADER_PATH})
@@ -688,9 +689,7 @@ function(wx_set_builtin_target_properties target_name)
endif()

if(WIN32)
- # not needed for wxWidgets anymore (it is always built with unicode)
- # but keep it here so applications linking to wxWidgets will inherit it
- target_compile_definitions(${target_name} PUBLIC UNICODE _UNICODE)
+ target_compile_definitions(${target_name} PRIVATE UNICODE _UNICODE)
endif()

target_include_directories(${target_name} BEFORE PRIVATE ${wxSETUP_HEADER_PATH})


=====================================
build/cmake/tests/CMakeLists.txt
=====================================
@@ -11,3 +11,6 @@ add_subdirectory(base)
add_subdirectory(drawing)
add_subdirectory(gui)
add_subdirectory(headers)
+if(WIN32)
+ add_subdirectory(win32)
+endif()


=====================================
build/cmake/tests/win32/CMakeLists.txt
=====================================
@@ -0,0 +1,22 @@
+#############################################################################
+# Name: build/cmake/tests/win32/CMakeLists.txt
+# Purpose: CMake file for win32 test
+# Author: Maarten Bent
+# Created: 2025-11-15
+# Copyright: (c) 2025 wxWidgets development team
+# Licence: wxWindows licence
+#############################################################################
+
+set(TEST_SRC
+ testwin32.cpp
+)
+
+wx_add_test(test_win32_wide ${TEST_SRC})
+if(TARGET test_win32_wide)
+ target_compile_definitions(test_win32_wide PRIVATE UNICODE _UNICODE)
+endif()
+
+wx_add_test(test_win32_ansi ${TEST_SRC})
+if(TARGET test_win32_ansi)
+ target_compile_definitions(test_win32_ansi PRIVATE _SBCS)
+endif()


=====================================
docs/doxygen/mainpages/const_cpp.h
=====================================
@@ -439,6 +439,11 @@ more details.
developers, but can also be used by the applications if they want to
opt in into getting more help from compiler. Support for this symbol
appeared in wxWidgets 3.3.0.}
+@itemdef{wxNO_WIN32_W,
+ this symbol is not defined by wxWidgets itself, but can be defined by
+ the applications using the library to not inline the WIDE win32 API
+ functions in wx/msw/winundef.h, but inline the ANSI functions instead.
+ This constant is available since wxWidgets 3.3.2.}
@endDefList

*/


=====================================
include/wx/dc.h
=====================================
@@ -483,14 +483,11 @@ public:

#ifdef __WXMSW__
// Native Windows functions using the underlying HDC don't honour GDI+
- // transformations which may be applied to it. Using this function we can
- // transform the coordinates manually before passing them to such functions
- // (as in e.g. wxRendererMSW code). It doesn't do anything if this is not a
- // wxGCDC.
- virtual wxRect MSWApplyGDIPlusTransform(const wxRect& r) const
- {
- return r;
- }
+ // transformations which may be applied to it and also don't know anything
+ // about wxDC origin as it handles it on its own to avoid limitations
+ // imposed by Windows. Use this function to transform the coordinates
+ // before passing them to such functions (as in e.g. wxRendererMSW code).
+ virtual wxRect MSWApplyWXTransform(const wxRect& r) const { return r; }
#endif // __WXMSW__




=====================================
include/wx/dcgraph.h
=====================================
@@ -223,7 +223,7 @@ public:
virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const override;

#ifdef __WXMSW__
- virtual wxRect MSWApplyGDIPlusTransform(const wxRect& r) const override;
+ virtual wxRect MSWApplyWXTransform(const wxRect& r) const override;
#endif // __WXMSW__

// update the internal clip box variables


=====================================
include/wx/image.h
=====================================
@@ -24,10 +24,6 @@
# include "wx/stream.h"
#endif

-// on some systems (Unixware 7.x) index is defined as a macro in the headers
-// which breaks the compilation below
-#undef index
-
#define wxIMAGE_OPTION_QUALITY wxString(wxS("quality"))
#define wxIMAGE_OPTION_FILENAME wxString(wxS("FileName"))



=====================================
include/wx/msw/dc.h
=====================================
@@ -96,6 +96,8 @@ public:
virtual void ResetTransformMatrix() override;
#endif // wxUSE_DC_TRANSFORM_MATRIX

+ virtual wxRect MSWApplyWXTransform(const wxRect& r) const override;
+
virtual void SetLogicalFunction(wxRasterOperationMode function) override;

// implementation from now on


=====================================
include/wx/msw/listctrl.h
=====================================
@@ -379,6 +379,11 @@ public:
WXWPARAM wParam,
WXLPARAM lParam) override;

+ // This function is only used by the implementation and is not part of the
+ // public API.
+ wxItemAttr* MSWGetItemColumnAttr(long item, long column) const
+ { return DoGetItemColumnAttr(item, column); }
+
protected:
// common part of all ctors
void Init();


=====================================
include/wx/msw/ole/automtn.h
=====================================
@@ -21,10 +21,6 @@ typedef void WXIDISPATCH;
typedef unsigned short* WXBSTR;
typedef unsigned long WXLCID;

-#ifdef GetObject
-#undef GetObject
-#endif
-
// Flags used with wxAutomationObject::GetInstance()
enum wxAutomationInstanceFlags
{


=====================================
include/wx/msw/private.h
=====================================
@@ -847,13 +847,13 @@ public:
bool IsRegistered() const { return m_registered == 1; }

// try to register the class if not done yet, return true on success
- bool Register(const WNDCLASS& wc)
+ bool Register(const WNDCLASSW& wc)
{
// we should only be called if we hadn't been initialized yet
wxASSERT_MSG( m_registered == -1,
wxT("calling ClassRegistrar::Register() twice?") );

- m_registered = ::RegisterClass(&wc) ? 1 : 0;
+ m_registered = ::RegisterClassW(&wc) ? 1 : 0;
if ( !IsRegistered() )
{
wxLogLastError(wxT("RegisterClassEx()"));
@@ -875,7 +875,7 @@ public:
{
if ( IsRegistered() )
{
- if ( !::UnregisterClass(m_clsname.t_str(), wxGetInstance()) )
+ if ( !::UnregisterClassW(m_clsname.wc_str(), wxGetInstance()) )
{
wxLogLastError(wxT("UnregisterClass"));
}
@@ -949,7 +949,7 @@ private:
inline wxString wxGetFullModuleName(HMODULE hmod)
{
wxString fullname;
- if ( !::GetModuleFileName
+ if ( !::GetModuleFileNameW
(
hmod,
wxStringBuffer(fullname, MAX_PATH),


=====================================
include/wx/msw/winundef.h
=====================================
@@ -15,30 +15,48 @@
*/

// ----------------------------------------------------------------------------
-// windows.h #defines the following identifiers which are also used in wxWin so
-// we replace these symbols with the corresponding inline functions and
-// undefine the macro.
+// windows.h and other win32 headers can #define the following identifiers
+// which are also used by wxWidgets so we replace these symbols with the
+// corresponding inline functions and undefine the macro.
//
// This looks quite ugly here but allows us to write clear (and correct!) code
// elsewhere because the functions, unlike the macros, respect the scope.
+//
+// wxWidgets is built using the WIDE win32 API, and the inline functions in
+// this file will use the W variant by default.
+// Applications that include and use ANSI Windows.h can override this by
+// defining wxNO_WIN32_W before including any wxWidgets headers. The inline
+// function will then use the A variant.
// ----------------------------------------------------------------------------

-// CreateDialog
+#if defined(WXBUILDING) || !defined(wxNO_WIN32_W)
+ #define wxFUNC_AW(fn) fn ## W
+ #define wxLPCSTR LPCWSTR
+ #define wxLPSTR LPWSTR
+ #define wxLPWNDCLASS LPWNDCLASSW
+ #define wxDOCINFO DOCINFOW
+ #define wxLPFINDREPLACE LPFINDREPLACEW
+#else
+ #define wxFUNC_AW(fn) fn ## A
+ #define wxLPCSTR LPCSTR
+ #define wxLPSTR LPSTR
+ #define wxLPWNDCLASS LPWNDCLASSA
+ #define wxDOCINFO DOCINFOA
+ #define wxLPFINDREPLACE LPFINDREPLACEA
+#endif

-#if defined(CreateDialog)
+#ifdef CreateDialog
#undef CreateDialog

inline HWND CreateDialog(HINSTANCE hInstance,
- LPCTSTR pTemplate,
+ wxLPCSTR pTemplate,
HWND hwndParent,
DLGPROC pDlgProc)
{
- return CreateDialogW(hInstance, pTemplate, hwndParent, pDlgProc);
+ return wxFUNC_AW(CreateDialog)(hInstance, pTemplate, hwndParent, pDlgProc);
}
#endif

-// CreateFont
-
#ifdef CreateFont
#undef CreateFont

@@ -55,22 +73,20 @@
DWORD clipprecision,
DWORD quality,
DWORD family,
- LPCTSTR facename)
+ wxLPCSTR facename)
{
- return CreateFontW(height, width, escapement, orientation,
- weight, italic, underline, strikeout, charset,
- outprecision, clipprecision, quality,
- family, facename);
+ return wxFUNC_AW(CreateFont)(height, width, escapement, orientation,
+ weight, italic, underline, strikeout,
+ charset, outprecision, clipprecision,
+ quality, family, facename);
}
-#endif // CreateFont
-
-// CreateWindow
+#endif

-#if defined(CreateWindow)
+#ifdef CreateWindow
#undef CreateWindow

- inline HWND CreateWindow(LPCTSTR lpClassName,
- LPCTSTR lpWndClass,
+ inline HWND CreateWindow(wxLPCSTR lpClassName,
+ wxLPCSTR lpWndClass,
DWORD dwStyle,
int x, int y, int w, int h,
HWND hWndParent,
@@ -78,261 +94,217 @@
HINSTANCE hInstance,
LPVOID lpParam)
{
- return CreateWindowW(lpClassName, lpWndClass, dwStyle, x, y, w, h,
- hWndParent, hMenu, hInstance, lpParam);
+ return wxFUNC_AW(CreateWindow)(lpClassName, lpWndClass, dwStyle, x, y, w, h,
+ hWndParent, hMenu, hInstance, lpParam);
}
#endif

-// LoadMenu
-
#ifdef LoadMenu
#undef LoadMenu

- inline HMENU LoadMenu(HINSTANCE instance, LPCTSTR name)
+ inline HMENU LoadMenu(HINSTANCE instance, wxLPCSTR name)
{
- return LoadMenuW(instance, name);
+ return wxFUNC_AW(LoadMenu)(instance, name);
}
#endif

-// FindText
-
#ifdef FindText
#undef FindText

- inline HWND APIENTRY FindText(LPFINDREPLACE lpfindreplace)
+ inline HWND APIENTRY FindText(wxLPFINDREPLACE lpfindreplace)
{
- return FindTextW(lpfindreplace);
+ return wxFUNC_AW(FindText)(lpfindreplace);
}
#endif

-// GetCharWidth
-
#ifdef GetCharWidth
- #undef GetCharWidth
+ #undef GetCharWidth

- inline BOOL GetCharWidth(HDC dc, UINT first, UINT last, LPINT buffer)
- {
- return GetCharWidthW(dc, first, last, buffer);
- }
+ inline BOOL GetCharWidth(HDC dc, UINT first, UINT last, LPINT buffer)
+ {
+ return wxFUNC_AW(GetCharWidth)(dc, first, last, buffer);
+ }
#endif

-// FindWindow
-
#ifdef FindWindow
- #undef FindWindow
+ #undef FindWindow

- inline HWND FindWindow(LPCWSTR classname, LPCWSTR windowname)
- {
- return FindWindowW(classname, windowname);
- }
+ inline HWND FindWindow(wxLPCSTR classname, wxLPCSTR windowname)
+ {
+ return wxFUNC_AW(FindWindow)(classname, windowname);
+ }
#endif

-// PlaySound
-
#ifdef PlaySound
- #undef PlaySound
+ #undef PlaySound

- inline BOOL PlaySound(LPCWSTR pszSound, HMODULE hMod, DWORD fdwSound)
- {
- return PlaySoundW(pszSound, hMod, fdwSound);
- }
+ inline BOOL PlaySound(wxLPCSTR pszSound, HMODULE hMod, DWORD fdwSound)
+ {
+ return wxFUNC_AW(PlaySound)(pszSound, hMod, fdwSound);
+ }
#endif

-// GetClassName
-
#ifdef GetClassName
- #undef GetClassName
+ #undef GetClassName

- inline int GetClassName(HWND h, LPWSTR classname, int maxcount)
- {
- return GetClassNameW(h, classname, maxcount);
- }
+ inline int GetClassName(HWND h, wxLPSTR classname, int maxcount)
+ {
+ return wxFUNC_AW(GetClassName)(h, classname, maxcount);
+ }
#endif

-// GetClassInfo
-
#ifdef GetClassInfo
- #undef GetClassInfo
+ #undef GetClassInfo

- inline BOOL GetClassInfo(HINSTANCE h, LPCWSTR name, LPWNDCLASSW winclass)
- {
- return GetClassInfoW(h, name, winclass);
- }
+ inline BOOL GetClassInfo(HINSTANCE h, wxLPCSTR name, wxLPWNDCLASS winclass)
+ {
+ return wxFUNC_AW(GetClassInfo)(h, name, winclass);
+ }
#endif

-// LoadAccelerators
-
#ifdef LoadAccelerators
- #undef LoadAccelerators
+ #undef LoadAccelerators

- inline HACCEL LoadAccelerators(HINSTANCE h, LPCWSTR name)
- {
- return LoadAcceleratorsW(h, name);
- }
+ inline HACCEL LoadAccelerators(HINSTANCE h, wxLPCSTR name)
+ {
+ return wxFUNC_AW(LoadAccelerators)(h, name);
+ }
#endif

-// DrawText
-
#ifdef DrawText
- #undef DrawText
+ #undef DrawText

- inline int DrawText(HDC h, LPCWSTR str, int count, LPRECT rect, UINT format)
- {
- return DrawTextW(h, str, count, rect, format);
- }
+ inline int DrawText(HDC h, wxLPCSTR str, int count, LPRECT rect, UINT format)
+ {
+ return wxFUNC_AW(DrawText)(h, str, count, rect, format);
+ }
#endif

-
-// StartDoc
-
#ifdef StartDoc
- #undef StartDoc
+ #undef StartDoc

- inline int StartDoc(HDC h, CONST DOCINFOW* info)
- {
- return StartDocW(h, const_cast<DOCINFOW*>(info));
- }
+ inline int StartDoc(HDC h, CONST wxDOCINFO* info)
+ {
+ return wxFUNC_AW(StartDoc)(h, info);
+ }
#endif

-// GetObject
-
#ifdef GetObject
- #undef GetObject
- inline int GetObject(HGDIOBJ h, int i, LPVOID buffer)
- {
- return GetObjectW(h, i, buffer);
- }
-#endif
+ #undef GetObject

-// GetMessage
+ inline int GetObject(HGDIOBJ h, int i, LPVOID buffer)
+ {
+ return wxFUNC_AW(GetObject)(h, i, buffer);
+ }
+#endif

#ifdef GetMessage
- #undef GetMessage
- inline int GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax)
- {
- return GetMessageW(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
- }
+ #undef GetMessage
+
+ inline int GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax)
+ {
+ return wxFUNC_AW(GetMessage)(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
+ }
#endif

-// LoadIcon
#ifdef LoadIcon
#undef LoadIcon
- inline HICON LoadIcon(HINSTANCE hInstance, LPCTSTR lpIconName)
+
+ inline HICON LoadIcon(HINSTANCE hInstance, wxLPCSTR lpIconName)
{
- return LoadIconW(hInstance, lpIconName);
+ return wxFUNC_AW(LoadIcon)(hInstance, lpIconName);
}
-#endif // LoadIcon
+#endif

-// LoadBitmap
#ifdef LoadBitmap
#undef LoadBitmap
- inline HBITMAP LoadBitmap(HINSTANCE hInstance, LPCTSTR lpBitmapName)
+
+ inline HBITMAP LoadBitmap(HINSTANCE hInstance, wxLPCSTR lpBitmapName)
{
- return LoadBitmapW(hInstance, lpBitmapName);
+ return wxFUNC_AW(LoadBitmap)(hInstance, lpBitmapName);
}
-#endif // LoadBitmap
-
-// LoadLibrary
+#endif

#ifdef LoadLibrary
#undef LoadLibrary

- inline HINSTANCE LoadLibrary(LPCWSTR lpLibFileName)
+ inline HINSTANCE LoadLibrary(wxLPCSTR lpLibFileName)
{
- return LoadLibraryW(lpLibFileName);
+ return wxFUNC_AW(LoadLibrary)(lpLibFileName);
}
#endif

-// FindResource
#ifdef FindResource
#undef FindResource

- inline HRSRC FindResource(HMODULE hModule, LPCWSTR lpName, LPCWSTR lpType)
+ inline HRSRC FindResource(HMODULE hModule, wxLPCSTR lpName, wxLPCSTR lpType)
{
- return FindResourceW(hModule, lpName, lpType);
+ return wxFUNC_AW(FindResource)(hModule, lpName, lpType);
}
#endif

-// IsMaximized
-
#ifdef IsMaximized
#undef IsMaximized
+
inline BOOL IsMaximized(HWND hwnd)
{
return IsZoomed(hwnd);
}
#endif

-// GetFirstChild
-
#ifdef GetFirstChild
#undef GetFirstChild
+
inline HWND GetFirstChild(HWND hwnd)
{
return GetTopWindow(hwnd);
}
#endif

-// GetFirstSibling
-
#ifdef GetFirstSibling
#undef GetFirstSibling
+
inline HWND GetFirstSibling(HWND hwnd)
{
- return GetWindow(hwnd,GW_HWNDFIRST);
+ return GetWindow(hwnd, GW_HWNDFIRST);
}
#endif

-// GetLastSibling
-
#ifdef GetLastSibling
#undef GetLastSibling
+
inline HWND GetLastSibling(HWND hwnd)
{
- return GetWindow(hwnd,GW_HWNDLAST);
+ return GetWindow(hwnd, GW_HWNDLAST);
}
#endif

-// GetPrevSibling
-
#ifdef GetPrevSibling
#undef GetPrevSibling
+
inline HWND GetPrevSibling(HWND hwnd)
{
- return GetWindow(hwnd,GW_HWNDPREV);
+ return GetWindow(hwnd, GW_HWNDPREV);
}
#endif

-// GetNextSibling
-
#ifdef GetNextSibling
#undef GetNextSibling
+
inline HWND GetNextSibling(HWND hwnd)
{
- return GetWindow(hwnd,GW_HWNDNEXT);
+ return GetWindow(hwnd, GW_HWNDNEXT);
}
#endif

-// For WINE
-
-#if defined(GetWindowStyle)
- #undef GetWindowStyle
-#endif
-
-// For ming and cygwin
-
#ifdef Yield
#undef Yield
#endif

+// For WINE

-// GetWindowProc
-//ifdef GetWindowProc
-// #undef GetWindowProc
-//endif
-//ifdef GetNextChild
-// #undef GetNextChild
-//endif
+#ifdef GetWindowStyle
+ #undef GetWindowStyle
+#endif

// #endif // _WX_WINUNDEF_H_
-


=====================================
include/wx/qt/mdi.h
=====================================
@@ -36,13 +36,13 @@ public:

QMdiArea* GetQtMdiArea() const;

- enum class Layout
+ enum class Kind
{
MDI,
Tabbed
};

- void QtSetPreferredDILayout(Layout layout);
+ void QtSetPreferredDILayout(Kind layout);

// override/implement base class [pure] virtual methods
// ----------------------------------------------------
@@ -50,7 +50,7 @@ public:
// The default is to return what wxMDIParentFrame::IsTDI() is supposed to
// return under the target platform. i.e. wxMSW and wxOSX return false,
// while wxGTK returns true. Use QtSetPreferredDILayout() to change that.
- static bool IsTDI() { return ms_layout == Layout::Tabbed; }
+ static bool IsTDI() { return ms_layout == Kind::Tabbed; }

virtual void Cascade() override;
virtual void Tile(wxOrientation orient = wxHORIZONTAL) override;
@@ -86,7 +86,7 @@ private:

// TDI=true, MDI=false
// Default to false under Windows, true otherwise.
- static Layout ms_layout;
+ static Kind ms_layout;

wxDECLARE_DYNAMIC_CLASS(wxMDIParentFrame);
};
@@ -154,6 +154,7 @@ class WXDLLIMPEXP_CORE wxMDIClientWindow : public wxMDIClientWindowBase
{
public:
wxMDIClientWindow() = default;
+ ~wxMDIClientWindow();

virtual bool CreateClient(wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL) override;



=====================================
interface/wx/event.h
=====================================
@@ -2767,8 +2767,8 @@ enum wxMouseWheelAxis
under Mac platforms with a single button mouse).

For the @c wxEVT_ENTER_WINDOW and @c wxEVT_LEAVE_WINDOW events
- purposes, the mouse is considered to be inside the window if it is in the
- window client area and not inside one of its children. In other words, the
+ purposes, the mouse is considered to be inside the window if it is over the
+ window and not inside one of its children. In other words, the
parent window receives @c wxEVT_LEAVE_WINDOW event not only when the
mouse leaves the window entirely but also when it enters one of its children.



=====================================
src/common/dcgraph.cpp
=====================================
@@ -1440,7 +1440,7 @@ void wxGCDCImpl::DoDrawCheckMark(wxCoord x, wxCoord y,
}

#ifdef __WXMSW__
-wxRect wxGCDCImpl::MSWApplyGDIPlusTransform(const wxRect& r) const
+wxRect wxGCDCImpl::MSWApplyWXTransform(const wxRect& r) const
{
wxCHECK_MSG( IsOk(), r, wxS("Invalid wxGCDC") );



=====================================
src/common/fmapbase.cpp
=====================================
@@ -29,10 +29,6 @@
#include "wx/wxcrtvararg.h"
#endif //WX_PRECOMP

-#if defined(__WINDOWS__)
- #include "wx/msw/private.h" // includes windows.h for LOGFONT
- #include "wx/msw/winundef.h"
-#endif

#include "wx/fontmap.h"
#include "wx/fmappriv.h"


=====================================
src/common/fontcmn.cpp
=====================================
@@ -29,11 +29,6 @@
#include "wx/gdicmn.h"
#endif // WX_PRECOMP

-#if defined(__WXMSW__)
- #include "wx/msw/private.h" // includes windows.h for LOGFONT
- #include "wx/msw/winundef.h"
-#endif
-
#include "wx/fontutil.h" // for wxNativeFontInfo
#include "wx/fontmap.h"
#include "wx/fontenum.h"


=====================================
src/common/fontmap.cpp
=====================================
@@ -35,11 +35,6 @@
#include "wx/config.h"
#endif // wxUSE_CONFIG

-#if defined(__WXMSW__)
- #include "wx/msw/private.h" // includes windows.h for LOGFONT
- #include "wx/msw/winundef.h"
-#endif
-
#include "wx/fmappriv.h"
#include "wx/fontutil.h"
#include "wx/fontdlg.h"


=====================================
src/generic/helpext.cpp
=====================================
@@ -35,11 +35,6 @@
#include <unistd.h>
#endif

-#ifdef __WXMSW__
-#include <windows.h>
-#include "wx/msw/winundef.h"
-#endif
-
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------


=====================================
src/generic/scrlwing.cpp
=====================================
@@ -37,7 +37,7 @@
#endif

#ifdef __WXMSW__
- #include <windows.h> // for DLGC_WANTARROWS
+ #include <windows.h>
#include "wx/msw/winundef.h"
#endif



=====================================
src/msw/dc.cpp
=====================================
@@ -1933,6 +1933,16 @@ void wxMSWDCImpl::SetLogicalScale(double x, double y)
RealizeScaleAndOrigin();
}

+wxRect wxMSWDCImpl::MSWApplyWXTransform(const wxRect& r) const
+{
+ // We need to handle the origin offset here as we don't use Windows support
+ // for this, see SetDeviceOrigin() below.
+ wxRect rect = r;
+ rect.x += m_deviceOriginX;
+ rect.y += m_deviceOriginY;
+ return rect;
+}
+
void wxMSWDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y)
{
if ( x == m_deviceOriginX && y == m_deviceOriginY )


=====================================
src/msw/listctrl.cpp
=====================================
@@ -3258,9 +3258,7 @@ void HandleItemPostpaint(NMCUSTOMDRAW nmcd)
// also called when using dark mode as we have to draw the selected item
// ourselves when using it, and if we do this, we have to paint all the items
// for consistency.
-//
-// pLVCD->clrText and clrTextBk should contain the colours to use
-void HandleItemPaint(wxListCtrl* listctrl, LPNMLVCUSTOMDRAW pLVCD, HFONT hfont)
+void HandleItemPaint(wxListCtrl* listctrl, LPNMLVCUSTOMDRAW pLVCD)
{
NMCUSTOMDRAW& nmcd = pLVCD->nmcd; // just a shortcut

@@ -3301,21 +3299,9 @@ void HandleItemPaint(wxListCtrl* listctrl, LPNMLVCUSTOMDRAW pLVCD, HFONT hfont)

HDC hdc = nmcd.hdc;
RECT rc = GetCustomDrawnItemRect(nmcd);
-
- COLORREF clrFullBG;
- if ( nmcd.uItemState & CDIS_SELECTED )
- {
- pLVCD->clrText = wxColourToRGB(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
- pLVCD->clrTextBk = wxColourToRGB(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
-
- clrFullBG = pLVCD->clrTextBk;
- }
- else
- {
- clrFullBG = wxColourToRGB(listctrl->GetBackgroundColour());
- }
-
- COLORREF colTextOld = ::SetTextColor(hdc, pLVCD->clrText);
+ COLORREF clrFullBG = wxColourToRGB((nmcd.uItemState & CDIS_SELECTED)
+ ? wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)
+ : listctrl->GetBackgroundColour());

// clear the entire row with the listctrl's bg colour
// otherwise, it'd keep the hover color but only for the regions
@@ -3340,57 +3326,55 @@ void HandleItemPaint(wxListCtrl* listctrl, LPNMLVCUSTOMDRAW pLVCD, HFONT hfont)
RECT rcSubItem;
wxCopyRectToRECT(rectSubItem, rcSubItem);

+ wxItemAttr* attr = listctrl->MSWGetItemColumnAttr(item, col);
+ wxFont font;
+ if ( attr && attr->HasFont() )
+ {
+ font = attr->GetFont();
+ font.WXAdjustToPPI(listctrl->GetDPI());
+ }
+ HFONT hfont = font.IsOk() ? GetHfontOf(font) : nullptr;
+
+ if ( nmcd.uItemState & CDIS_SELECTED )
+ {
+ pLVCD->clrText = wxColourToRGB(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
+ pLVCD->clrTextBk = wxColourToRGB(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
+ }
+ else
+ {
+ pLVCD->clrText = attr && attr->HasTextColour()
+ ? wxColourToRGB(attr->GetTextColour())
+ : wxColourToRGB(listctrl->GetTextColour());
+ pLVCD->clrTextBk = attr && attr->HasBackgroundColour()
+ ? wxColourToRGB(attr->GetBackgroundColour())
+ : wxColourToRGB(listctrl->GetBackgroundColour());
+ }
+
+ COLORREF colTextOld = ::SetTextColor(hdc, pLVCD->clrText);
+
HandleSubItemPrepaint(listctrl, pLVCD, hfont, rcSubItem);
- }

- ::SetTextColor(hdc, colTextOld);
+ ::SetTextColor(hdc, colTextOld);
+ }

HandleItemPostpaint(nmcd);
}

-WXLPARAM HandleItemPrepaint(wxListCtrl *listctrl,
- LPNMLVCUSTOMDRAW pLVCD,
- wxItemAttr *attr)
+WXLPARAM HandleItemPrepaint(wxListCtrl* listctrl, LPNMLVCUSTOMDRAW pLVCD)
{
if ( wxMSWDarkMode::IsActive() )
{
- // We need to always paint selected items ourselves as they come
- // out completely wrong in DarkMode_Explorer theme, see the comment
- // before MSWGetDarkModeSupport().
- wxFont font;
-
- if ( attr && attr->HasFont() )
- {
- font = attr->GetFont();
- font.WXAdjustToPPI(listctrl->GetDPI());
- }
-
- pLVCD->clrText = attr && attr->HasTextColour()
- ? wxColourToRGB(attr->GetTextColour())
- : wxColourToRGB(listctrl->GetTextColour());
- pLVCD->clrTextBk = attr && attr->HasBackgroundColour()
- ? wxColourToRGB(attr->GetBackgroundColour())
- : wxColourToRGB(listctrl->GetBackgroundColour());
-
- HandleItemPaint(listctrl, pLVCD, font.IsOk() ? GetHfontOf(font) : nullptr);
+ HandleItemPaint(listctrl, pLVCD);
return CDRF_SKIPDEFAULT;
}

+ wxItemAttr* attr = listctrl->MSWGetItemColumnAttr(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem);
if ( !attr )
{
// nothing to do for this item
return CDRF_DODEFAULT;
}

-
- // set the colours to use for text drawing
- pLVCD->clrText = attr->HasTextColour()
- ? wxColourToRGB(attr->GetTextColour())
- : wxColourToRGB(listctrl->GetTextColour());
- pLVCD->clrTextBk = attr->HasBackgroundColour()
- ? wxColourToRGB(attr->GetBackgroundColour())
- : wxColourToRGB(listctrl->GetBackgroundColour());
-
// select the font if non default one is specified
if ( attr->HasFont() )
{
@@ -3402,7 +3386,7 @@ WXLPARAM HandleItemPrepaint(wxListCtrl *listctrl,
// with recent comctl32.dll versions (5 and 6, it uses to work with
// 4.something) so we have to draw the item entirely ourselves in
// this case
- HandleItemPaint(listctrl, pLVCD, GetHfontOf(font));
+ HandleItemPaint(listctrl, pLVCD);
return CDRF_SKIPDEFAULT;
}

@@ -3420,11 +3404,17 @@ WXLPARAM HandleItemPrepaint(wxListCtrl *listctrl,
// lucky as HandleItemPaint() doesn't result in the same appearance as with
// the system theme, so we should avoid using it in this case to ensure
// that all items appear consistently.
- if ( listctrl->IsSystemThemeDisabled() &&
- pLVCD->clrTextBk == ::GetSysColor(COLOR_BTNFACE) )
+ if ( listctrl->IsSystemThemeDisabled() )
{
- HandleItemPaint(listctrl, pLVCD, nullptr);
- return CDRF_SKIPDEFAULT;
+ COLORREF bgCol = attr->HasBackgroundColour()
+ ? wxColourToRGB(attr->GetBackgroundColour())
+ : wxColourToRGB(listctrl->GetBackgroundColour());
+
+ if ( bgCol == ::GetSysColor(COLOR_BTNFACE) )
+ {
+ HandleItemPaint(listctrl, pLVCD);
+ return CDRF_SKIPDEFAULT;
+ }
}

return CDRF_DODEFAULT;
@@ -3464,7 +3454,7 @@ WXLPARAM wxListCtrl::OnCustomDraw(WXLPARAM lParam)
if ( column < 0 || column >= GetColumnCount() )
break;

- return HandleItemPrepaint(this, pLVCD, DoGetItemColumnAttr(item, column));
+ return HandleItemPrepaint(this, pLVCD);
}

return CDRF_DODEFAULT;


=====================================
src/msw/renderer.cpp
=====================================
@@ -78,16 +78,8 @@ protected:
// adjusted for the given wxDC.
static RECT ConvertToRECT(wxDC& dc, const wxRect& rect)
{
- // Theme API doesn't know anything about GDI+ transforms, so apply them
- // manually.
- wxRect rectDevice = dc.GetImpl()->MSWApplyGDIPlusTransform(rect);
-
- // We also need to handle the origin offset manually as we don't use
- // Windows support for this, see wxDC code.
- rectDevice.Offset(dc.GetDeviceOrigin());
-
RECT rc;
- wxCopyRectToRECT(rectDevice, rc);
+ wxCopyRectToRECT(dc.GetImpl()->MSWApplyWXTransform(rect), rc);
return rc;
}
};


=====================================
src/qt/dc.cpp
=====================================
@@ -865,8 +865,17 @@ void wxQtDCImpl::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
}

void wxQtDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
+{
+ DoDrawRotatedText(text, x, y, 0.0);
+}
+
+void wxQtDCImpl::DoDrawRotatedText(const wxString& text,
+ wxCoord x, wxCoord y, double angle)
{
m_qtPainter->save();
+ // Move and rotate (reverse angle direction in Qt and wx)
+ m_qtPainter->translate(x, y);
+ m_qtPainter->rotate(-angle);

m_qtPainter->setPen(QPen(m_textForegroundColour.GetQColor()));

@@ -884,57 +893,49 @@ void wxQtDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
{
// text is not mirrored
m_qtPainter->scale(-1, 1);
- x = -x;
}

+ QRect boundingRect; // Bounding rectangle for non rotated text.
+ QRect* boundingRectPtr = AreAutomaticBoundingBoxUpdatesEnabled()
+ ? &boundingRect : nullptr;
+
QFontMetrics metrics = m_qtPainter->fontMetrics();

+ int lineSpacing = 0;
wxStringTokenizer tokenizer(text, "\n");
while ( tokenizer.HasMoreTokens() )
{
const wxString line = tokenizer.GetNextToken();
- m_qtPainter->drawText(x, y, 1, 1, Qt::TextDontClip, wxQtConvertString(line));
- y += metrics.lineSpacing();
+ m_qtPainter->drawText(0, lineSpacing, 1, 1, Qt::TextDontClip,
+ wxQtConvertString(line), boundingRectPtr);
+ lineSpacing += metrics.lineSpacing();
+
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() && wxIsNullDouble(angle) )
+ {
+ CalcBoundingBox(wxQtConvertRect(boundingRect));
+ }
}

m_qtPainter->restore();
-}
-
-void wxQtDCImpl::DoDrawRotatedText(const wxString& text,
- wxCoord x, wxCoord y, double angle)
-{
- m_qtPainter->save();
-
- if (m_backgroundMode == wxBRUSHSTYLE_SOLID)
- m_qtPainter->setBackgroundMode(Qt::OpaqueMode);

- if ( GetLayoutDirection() == wxLayout_RightToLeft )
+ // Calculate bounding rectangle for rotated text.
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() && !wxIsNullDouble(angle) )
{
- m_qtPainter->scale(-1, 1);
-
- x = -x;
- angle = -angle;
- }
-
- //Move and rotate (reverse angle direction in Qt and wx)
- m_qtPainter->translate(x, y);
- m_qtPainter->rotate(-angle);
-
- m_qtPainter->setPen(QPen(m_textForegroundColour.GetQColor()));
+ const double rad = wxDegToRad(angle);

- // Disable logical function
- m_qtPainter->setCompositionMode( QPainter::CompositionMode_SourceOver );
+ const QFontMetrics metrics = m_qtPainter->fontMetrics();
+ const QRect rect = metrics.boundingRect(wxQtConvertString(text));
+ const int w = rect.width();
+ const int h = rect.height();

- if (m_backgroundMode == wxBRUSHSTYLE_SOLID)
- {
- m_qtPainter->setBackgroundMode(Qt::OpaqueMode);
+ // "upper left" and "upper right"
+ CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));

- m_qtPainter->setBackground(QBrush(m_textBackgroundColour.GetQColor()));
+ // "bottom left" and "bottom right"
+ x += (wxCoord)(h*sin(rad));
+ y += (wxCoord)(h*cos(rad));
+ CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
}
-
- m_qtPainter->drawText(0, 0, 1, 1, Qt::TextDontClip, wxQtConvertString(text));
-
- m_qtPainter->restore();
}

bool wxQtDCImpl::DoBlit(wxCoord xdest, wxCoord ydest,


=====================================
src/qt/frame.cpp
=====================================
@@ -62,9 +62,13 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString& title,
{
m_qtWindow = new wxQtMainWindow( parent, this );

- // QMainWindow takes ownership of the central widget pointer.
// Not using QScrollArea or wxPanel is intentional here as it makes the
// implementation simpler and more manageable.
+ //
+ // Quoting the Qt docs [QMainWindow::setCentralWidget()]:
+ // QMainWindow takes ownership of the widget pointer and deletes it at
+ // the appropriate time.
+ //
GetQMainWindow()->setCentralWidget( new wxQtCentralWidget( this, this ) );

if ( !wxFrameBase::Create( parent, id, title, pos, size, style, name ) )


=====================================
src/qt/mdi.cpp
=====================================
@@ -27,11 +27,11 @@ static QMdiSubWindow* gs_qtActiveSubWindow = nullptr;
}

/*static*/
-wxMDIParentFrame::Layout wxMDIParentFrame::ms_layout =
+wxMDIParentFrame::Kind wxMDIParentFrame::ms_layout =
#if defined(__WINDOWS__)
- Layout::MDI;
+ Kind::MDI;
#else // !__WINDOWS__
- Layout::Tabbed;
+ Kind::Tabbed;
#endif // __WINDOWS__

// Central widget helper (provides an area in which MDI windows are displayed):
@@ -89,7 +89,7 @@ bool wxMDIParentFrame::Create(wxWindow *parent,
return true;
}

-void wxMDIParentFrame::QtSetPreferredDILayout(Layout layout)
+void wxMDIParentFrame::QtSetPreferredDILayout(Kind layout)
{
ms_layout = layout;

@@ -97,11 +97,11 @@ void wxMDIParentFrame::QtSetPreferredDILayout(Layout layout)

switch ( layout )
{
- case Layout::MDI:
+ case Kind::MDI:
viewMode = QMdiArea::SubWindowView;
break;

- case Layout::Tabbed:
+ case Kind::Tabbed:
viewMode = QMdiArea::TabbedView;
break;

@@ -242,10 +242,7 @@ void wxMDIParentFrame::AddWindowMenu()
{
m_windowMenu = new wxMenu;

- // Qt offers only "Tile" without specifying any direction, so just
- // reuse one of the predifined ids.
-
- if ( ms_layout == Layout::MDI )
+ if ( ms_layout == Kind::MDI )
{
// Qt offers only "Tile" without specifying any direction, so just
// reuse one of the predifined ids.
@@ -428,6 +425,13 @@ void wxMDIChildFrame::SetMenuBar(wxMenuBar* menuBar)

m_menuBar = menuBar;

+ if ( m_mdiParent->GetActiveChild() == this )
+ {
+ // Attach the menu bar to m_mdiParent immediately if this child
+ // window is active.
+ InternalSetMenuBar();
+ }
+
// Don't call wxFrameBase::SetMenuBar() here because m_menuBar will be
// attached to m_mdiParent later when this child frame becomes active.
}
@@ -496,6 +500,15 @@ bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long WXUNUSED(sty
return true;
}

+wxMDIClientWindow::~wxMDIClientWindow()
+{
+ DestroyChildren();
+
+ // Prevent the base class dtor from destroying the underlying qt window, as
+ // it is owned by QMainWindow.
+ m_qtWindow = nullptr;
+}
+
// Helper implementation:

wxQtMdiArea::wxQtMdiArea(wxWindow *parent, wxMDIClientWindow *handler )


=====================================
src/qt/textctrl.cpp
=====================================
@@ -126,6 +126,7 @@ class wxQtTextEdit : public wxQtEventSignalHandler< QTextEdit, wxTextCtrl >
{
public:
wxQtTextEdit( wxWindow *parent, wxTextCtrl *handler );
+ ~wxQtTextEdit();

virtual wxString GetValueForProcessEnter() override
{
@@ -778,6 +779,11 @@ wxQtTextEdit::wxQtTextEdit( wxWindow *parent, wxTextCtrl *handler )
});
}

+wxQtTextEdit::~wxQtTextEdit()
+{
+ delete m_textLimiter;
+}
+
void wxQtTextEdit::SetMaxLength(unsigned long len)
{
const unsigned long maxlen = std::numeric_limits<int>::max();


=====================================
src/qt/uiaction.cpp
=====================================
@@ -177,7 +177,7 @@ static bool SimulateKeyboardKey( KeyAction keyAction, Key key, int modifiers )
// always produces a lowercase of that char! (which must be in uppercase)
if ( modifiers == wxMOD_SHIFT && key < 256 )
{
- const QChar qChar(key);
+ const QChar qChar(static_cast<int>(key));
if ( qChar.isLetter() )
{
widget->windowHandle() != nullptr ?


=====================================
tests/events/propagation.cpp
=====================================
@@ -33,7 +33,9 @@

#include <memory>

-#include "waitfor.h"
+#if defined(__WXGTK__) || defined(__WXQT__)
+ #include "waitfor.h"
+#endif

// FIXME: Currently under OS X testing paint event doesn't work because neither
// calling Refresh()+Update() nor even sending wxPaintEvent directly to
@@ -668,6 +670,7 @@ void EventPropagationTestCase::DocViewCommon(wxFrame* (*newParent)(wxDocManager

wxMenu* const menuChild = CreateTestMenu(child.get());

+#ifdef __WXGTK__
// There are a lot of hacks related to child frame menu bar handling in
// wxGTK and, in particular, the code in src/gtk/mdi.cpp relies on getting
// idle events to really put everything in place. Moreover, as wxGTK uses
@@ -679,8 +682,8 @@ void EventPropagationTestCase::DocViewCommon(wxFrame* (*newParent)(wxDocManager
// make things work "as usual".
child->Show();
parent->Show();
- child->SetFocus(); // Without this, the test would fail on wxGTK2
- YieldForAWhile();
+ wxYield();
+#endif // __WXGTK__

TestEvtSink sinkDoc('d');
doc->Connect(wxEVT_MENU,
@@ -696,25 +699,7 @@ void EventPropagationTestCase::DocViewCommon(wxFrame* (*newParent)(wxDocManager

// Check that wxDocument, wxView, wxDocManager, child frame and the parent
// get the event in order.
-#if wxUSE_UIACTIONSIMULATOR
- // We use wxUIActionSimulator instead of ASSERT_MENU_EVENT_RESULT because
- // using the latter fails with wxQt on Linux.
- wxUnusedVar(menuChild);
- g_str.clear();
-
- wxUIActionSimulator sim;
- sim.Char('m', wxMOD_ALT);
- // N.B.: Don't call wxYield() here, as this will cause the menu to appear
- // immediately (and enter its internal message loop) and the next line will
- // never be executed under wxMSW. In other words, the execution would block
- // indefinitely.
- sim.Char('a');
- wxYield();
-
- CHECK( g_str == "advmcpA" );
-#else // !wxUSE_UIACTIONSIMULATOR
ASSERT_MENU_EVENT_RESULT( menuChild, "advmcpA" );
-#endif // wxUSE_UIACTIONSIMULATOR

#if wxUSE_TOOLBAR
// Also check that toolbar events get forwarded to the active child.


=====================================
tests/testwin32.cpp
=====================================
@@ -0,0 +1,118 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: tests/testwin32.cpp
+// Purpose: Test including Windows headers before wxWidgets headers
+// Author: Maarten Bent
+// Created: 2025-11-15
+// Copyright: (c) 2025 wxWidgets development team
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WIN32
+ #error This is a Windows/win32 specific test
+#endif
+
+// When including Windows headers before wx headers, the functions declared
+// in wx/msw/winundef.h need to match the ANSI/WIDE variant in the Windows
+// headers. By default the WIDE variant is declared, but if ANSI Windows is
+// used, define wxNO_WIN32_W.
+#define _WINSOCK_DEPRECATED_NO_WARNINGS
+#define _CRT_SECURE_NO_WARNINGS
+#include <winsock2.h>
+#include <Windows.h>
+#ifndef UNICODE
+ #define wxNO_WIN32_W
+#endif
+
+#include "wx/wxprec.h"
+
+// include all headers, so incorrect usage of ANSI/WIDE win32 API in public
+// headers is detected
+#include "allheaders.h"
+
+#ifdef wxHAS_NATIVE_WINDOW
+
+class NativeWindow : public wxNativeWindow
+{
+public:
+ explicit NativeWindow(wxWindow* parent)
+ : wxNativeWindow()
+ {
+ const wxSize size = FromDIP(wxSize(140, 30));
+
+ HWND hwnd = ::CreateWindow
+ (
+ TEXT("BUTTON"),
+ TEXT("Press me to do it"),
+ WS_CHILD | WS_VISIBLE | BS_SPLITBUTTON,
+ 0, 0, size.x, size.y,
+ (HWND)parent->GetHWND(), 0, nullptr, nullptr
+ );
+ if ( !hwnd )
+ {
+ wxLogError("Creating split button failed.");
+ return;
+ }
+
+ (void)Create(parent, wxID_ANY, hwnd);
+ }
+
+ virtual ~NativeWindow()
+ {
+ Disown();
+ }
+
+protected:
+ virtual bool
+ MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) override
+ {
+ const NMHDR* hdr = reinterpret_cast<NMHDR*>(lParam);
+ if ( hdr->code != BCN_DROPDOWN )
+ return wxNativeWindow::MSWOnNotify(idCtrl, lParam, result);
+
+ const NMBCDROPDOWN* dd = reinterpret_cast<NMBCDROPDOWN*>(lParam);
+
+ wxMenu menu;
+ menu.Append(wxID_NEW);
+ menu.AppendSeparator();
+ menu.Append(wxID_ABOUT);
+ PopupMenu(&menu, wxPoint(dd->rcButton.right, dd->rcButton.bottom));
+
+ return true;
+ }
+};
+
+#endif // wxHAS_NATIVE_WINDOW
+
+class MyFrame : public wxFrame
+{
+public:
+ MyFrame(const wxString& title)
+ : wxFrame(nullptr, wxID_ANY, title)
+ {
+ wxSizer* m_sizerCtrl = new wxBoxSizer(wxHORIZONTAL);
+#ifdef wxHAS_NATIVE_WINDOW
+ wxNativeWindow* m_nativeWindow = new NativeWindow(this);
+ m_sizerCtrl->Add(m_nativeWindow, wxSizerFlags(1).Expand().Border());
+#endif
+ SetSizer(m_sizerCtrl);
+
+ CallAfter([&]() { Close(true); });
+ }
+
+};
+
+class MyApp : public wxApp
+{
+public:
+ virtual bool OnInit() override
+ {
+ if (!wxApp::OnInit())
+ return false;
+
+ MyFrame* frame = new MyFrame("win32 test");
+ frame->Show(true);
+ return true;
+ }
+};
+
+wxIMPLEMENT_APP(MyApp);



View it on GitLab: https://gitlab.com/wxwidgets/wxwidgets/-/compare/08b10e373e8de34ec3f7439615e16a2288df0b35...f3da561f78ff54befeb98e7a10c3e583aef51882

--
View it on GitLab: https://gitlab.com/wxwidgets/wxwidgets/-/compare/08b10e373e8de34ec3f7439615e16a2288df0b35...f3da561f78ff54befeb98e7a10c3e583aef51882
You're receiving this email because of your account on gitlab.com.


Reply all
Reply to author
Forward
0 new messages