Commit graph

3874 commits

Author SHA1 Message Date
Vadim Zeitlin
35c35c235e Remove wxUSE_STL which is not really used any longer
wxString is always based on std::[w]string since 2c0c727f49 (Remove wx
own wxStringImpl implementation, 2022-11-16) and all containers use
standard containers by default too now -- and there is a separate
wxUSE_STD_CONTAINERS for this anyhow.

The only remaining use of wxUSE_STL was as the default value for
wxUSE_STD_STRING_CONV_IN_WXSTRING option, but it's not really needed
for this neither, and this option can just be set to 0 by default.

Also add wxUSE_CHAR_CONV_IN_WXSTRING which can now be set to 0 too to
disable all unwanted implicit conversions (even "safe" ones, to wide
strings, in addition to the unsafe ones to narrow strings that could be
already disabled with wxUSE_UNSAFE_WXSTRING_CONV) to allow people who
don't want to have any implicit conversions at all to do it.

Keep --enable-stl configure option for compatibility, but warn if it is
used to tell people that it is not needed any longer.
2023-04-15 17:22:09 +02:00
Vadim Zeitlin
e273d45c9b Enable use of the standard container classes by default
This is mostly, even if not completely, compatible with the previous
default build using wxUSE_STD_CONTAINERS=0, so try enabling this by
default again. Hopefully it should work better now than the last time we
tried it, see 01871bf642 (Add wxUSE_STD_CONTAINERS and turn it on by
default., 2011-03-30) and the subsequent 7311debd0d (Don't use the
standard containers by default., 2011-05-13).

See #22718.
2023-04-10 17:00:32 +01:00
Vadim Zeitlin
82729cb93a Don't assert if HWND is invalid in wxWindow::DissociateHandle()
There was no safe way to prevent wxWindow from trying to destroy the
HWND again if it had been already destroyed, for whatever reason, as
UnsubclassWin() asserted if it was called and calling SetHWND(0) before
calling it as some (but not all) existing code did, resulted in not
removing the association using the old HWND as key.

Allow to use DissociateHandle() for safely detaching HWND from the
window, without assuming that it is valid.
2023-03-31 16:46:45 +01:00
Vadim Zeitlin
0677d493df Add wxUSE_UNICODE_UTF8 to wx/setup.h
This option can also be used under MSW, so move it to the common setup.h
instead of having it in setup.h.in only.

Also do the same thing for wxUSE_UTF8_LOCALE_ONLY, even if it's less
clear if this one is really useful in non-Unix environment.
2023-03-24 19:18:30 +01:00
Tobias Taschner
e15a1ac18e
Add wxWebViewWindowFeatures and event
This replaces the previously implemented wxWebViewWindowInfo.

It explicitly breaks the previous API to enable WebKitGTK
integration and to make the usage in application code less error prone.

A new event wxEVT_WEBVIEW_NEWWINDOW_FEATURES is added to allow
access to the window features and the child web view.
2023-03-24 15:10:21 +01:00
Tobias Taschner
235e71ef28
Edge: Hold environment in configuration 2023-03-17 11:58:35 +01:00
Tobias Taschner
05c77757e2
Edge: Send an error event for various API errors
These errors are rare, but can happen. This way user code can react to
Previously they where just logged.
2023-03-17 09:29:46 +01:00
Tobias Taschner
dd4d5c75af
Add wxWebViewConfiguration
In 40ff38b63b wxWebView::GetNativeConfiguration() was
added which isn't suitable if multiple wxWebViewEdge instances are created with
different options (as they must share the same options). To prevent such errors
the previous method is replaced by the new class wxWebViewConfiguration which
can be shared between various wxWebView instances.

This explicitly breaks API to improve usage.

In the future the new class could also enable a good way to wrap various
common options/configurations available via native API.
2023-03-17 09:29:46 +01:00
Vadim Zeitlin
1c0e4dbf8e Merge branch 'webview_window_handling'
Add wxWebView child window handling.

See #23334.
2023-03-12 13:58:01 +01:00
Vadim Zeitlin
0fe6f04bfc Merge branch 'customize-dark-mode'
Allow customizing appearance in dark mode in wxMSW.

See #23275.
2023-03-12 13:42:45 +01:00
Tobias Taschner
3799a80d04
Add missing definition for msys2 build 2023-03-09 16:23:55 +01:00
Tobias Taschner
01ee3942f8
Add wxWebView child window handling
Add new class wxWebViewWindowInfo:
This new class returned by wxWebViewEvent::GetTargetWindowInfo() allows
to get information about the window that is about to be opened and to
set the window that will be used to display the content.
2023-03-09 14:30:19 +01:00
Tobias Taschner
45d5de6a26
Add wxEVT_WEBVIEW_WINDOW_CLOSE_REQUESTED
This event is usually triggered by javascript calling window.close()
2023-03-09 14:29:25 +01:00
Vadim Zeitlin
3d21a14f95 Merge branch 'msw-statbox-compositing'
Many fixes for handling elements not using wxStaticBox as parent inside
wxStaticBoxSizer.

See #23259.

Closes #23182, #23239.
2023-02-23 00:31:02 +00:00
Vadim Zeitlin
6f5703a885 Fix wxStaticBox drawing after disabling composition for parent
We need to switch to custom-drawing the box if we stop using
WS_EX_COMPOSITED as WS_EX_TRANSPARENT doesn't work correctly without it
(the background is not being painted correctly), so do this by
overriding the new MSWOnDisabledComposited() which is now called by
MSWDisableComposited() if/when it actually does disable it.
2023-02-21 18:53:11 +00:00
Vadim Zeitlin
76fffafcd0 Allow customizing menu bar menus colours in MSW dark mode
This allows to customize the hard-coded colours used for drawing the
menu bar too.
2023-02-19 23:20:19 +00:00
Vadim Zeitlin
d051ff0215 Allow customizing wxStaticBox border colour in dark mode
This is useful because there is no really standard value for this colour
and the choice of grey (0x808080) is completely subjective, but also
because it may be useful to disable custom drawing of the border
entirely if it results in any problems with the future Windows versions.

See #23107.
2023-02-19 21:57:05 +00:00
Vadim Zeitlin
d3ab43ae02 Add a possibility to customize dark mode colours in wxMSW
Add MSW-specific wxDarkModeSettings class which can be used to customize
the colours used in the dark mode (and will be also used for other
customizations in the future).

This commit is best viewed using Git --color-moved option.
2023-02-19 21:57:05 +00:00
Vadim Zeitlin
1f9113b40a Add default ctor to wxGLCanvas
It didn't make any sense to have Create() functions in this class
without the default ctor as they could be never used -- calling them
would result in creating the window twice.

Add the default ctor to make this class more similar to all the other
windows.
2023-02-14 16:03:56 +00:00
Tobias Taschner
be10ce0713 Add wxWebViewEvent::IsTargetMainFrame()
Allows to determine if a navigation is happening in the main frame
or an embedded iframe when handling wxEVT_WEBVIEW_NAVIGATING.

Additionally implement previously missing wxEVT_WEBVIEW_NAVIGATING
events for frames with the Edge backend.

See #23238.
2023-02-08 17:42:06 +01:00
Tobias Taschner
b9e776ae43 Allow calling wxWebViewEdge::SetUserAgent() after Create()
Additionally implement wxWebViewEdge::GetUserAgent() via SDK.

This functionality is available with the slightly newer
WebView2 SDK required by previous changes.

See #23225.
2023-02-06 13:55:30 +01:00
Vadim Zeitlin
ef3c8dd408 Explain why including wx/msw/msvcrt.h is a bad idea
This breaks any use of placement new and so the best solution is to
avoid including this header.
2023-01-31 14:48:45 +00:00
David Connet
ed14fd19d2 Fix WXWIN_COMPATIBILITY_3_2 test in wxMSW wxRadioBox declaration
Avoid the warning and actually behave correctly when
WXWIN_COMPATIBILITY_3_2==0 by replacing the wrong "#ifdef" added in
c216744f78 (Deprecate MSW-specific wxRadioBox::Set{Label,Button}Font(),
2022-12-24) with the correct "#if".

Closes #23161.
2023-01-19 21:27:24 +01:00
Vadim Zeitlin
e89f05faba Remove memory debugging/tracing support and all related options
Drop disabled by default and pretty useless memory tracing code and all
the overlapping and poorly documented build options related to it.

Remove memory.cpp entirely and update all the make/project files, but
preserve the now completely trivial wx/memory.h for compatibility and
also keep including wx/string.h from wx/object.h as it seems like a lot
of existing code actually depends on this, even if it should not.

Replace the options in the propgrid sample with a couple of other
debug-related options that were not used before to avoid leaving the
"Debugging Section" completely empty.
2023-01-05 21:41:38 +01:00
Vadim Zeitlin
52750c2ee9 Factor our wxMSWDarkMode::InvertBitmap() function
Extract it from PaintIfNecessary() to allow reusing it elsewhere.

No real changes yet.
2022-12-29 00:37:25 +00:00
Vadim Zeitlin
5dbe9828db Export wxMSWDarkMode::IsActive() from the core DLL
This is required now that it's used from the aui library too.
2022-12-28 01:01:05 +00:00
Vadim Zeitlin
208142c14a Merge branch 'msw-dark-mode'
Add experimental support for dark mode for wxMSW.

See #23028.
2022-12-27 22:20:34 +01:00
Vadim Zeitlin
1f939fabec Allow using wxMSWDarkMode::PaintIfNecessary() with any HWND
We don't always have a wxWindow to pass to this function, so make it
more general at the cost of being slightly more inconvenient to use.

No real changes yet.
2022-12-25 19:45:53 +00:00
Vadim Zeitlin
61805ef7eb Improve wxToolBar appearance in dark mode
Fix labels and highlight colour and get rid of the white line on top of
the toolbar.

Unfortunately drop-down items are still not drawn correctly as I
couldn't find any way to customize the colour used for their arrow.
2022-12-25 19:45:53 +00:00
Vadim Zeitlin
16727d1714 Start implementing our own wxNotebook drawing in dark mode
So far only tabs on the top are supported, but this will be generalized
later.
2022-12-25 19:45:53 +00:00
Vadim Zeitlin
cbe5e3fcc1 Use proper theme for dark mode support in wxChoice and wxComboBox
The right theme to use is apparently "CFD".
2022-12-25 19:45:53 +00:00
Vadim Zeitlin
2e45ddc2d2 Fix static box and check/radio buttons text colour in dark mode
The labels of these controls were unreadable because they used the same
text colour as in normal, light mode even after enabling dark mode
support for them, so fix this by explicitly setting the default (for
dark mode, i.e. light) text colour for them.

Add a new "setForeground" field to MSWDarkModeSupport struct to allow
doing this easily and in a single place in wxControl code, so that it
could be customized, or even skipped, if these controls support for the
dark mode is improved, in the future.
2022-12-25 19:45:53 +00:00
Vadim Zeitlin
881e21663a Replace a pair of functions with single MSWGetDarkModeSupport()
Overriding either MSWGetDarkThemeName() or MSWGetDarkThemeId() was a bit
confusing as doing the latter changed the theme name used by default too
and not flexible enough, so remove these two functions and add a single
MSWGetDarkModeSupport() one that returns both the theme name and ID and
can also be extended to do more things in the future.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
1bfdd5819b Use custom draw for the menu bar in dark mode
This requires using a couple of undocumented messages/structs, which is
not ideal, but seems to be the only way to get dark menu bar and so
seems to be worth it, as white menu bar looks really out of place in
dark mode.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
252551fd26 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.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
002b97101e Add WindowHDC RAII helper class
After the renaming in the parent commit, this name is now free to be
used for the class creating a window HDC.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
446f4c6afb Rename WindowHDC private helper class to ClientHDC
It was pretty confusing that WindowHDC actually used client HDC and not
the (full) window one.

Also add a helper AutoHDC class releasing the DC automatically in its
dtor and use it as the common base for ScreenHDC and ClientHDC.

No real changes, this is just a renaming/refactoring.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
a37f28bcb6 Add dark mode support to wxHeaderCtrl
Extract the code setting up the header control colours for the dark mode
from src/msw/listctrl.cpp into wxMSWHeaderCtrlCustomDraw and reuse it in
wxHeaderCtrl too.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
ca5f244f15 Add wxUxThemeHandle::GetColour() replacing MSWGetThemeColour()
Add a helper function wrapping ::GetThemeColor() and use it in all
places where this function was used before, as it's more convenient.

Also remove wxWindow::MSWGetThemeColour() as it was only used in a
single place and doesn't seem to present any advantages compared to
using wxUxThemeHandle new method.

There should be no changes in behaviour, this is just a refactoring.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
ddd002501e Reuse wxMSWHeaderCtrlCustomDraw in wxListCtrl too
It doesn't seem to make much sense to have a completely identical
wxMSWListHeaderCustomDraw class used in wxListCtrl when we could simply
reuse wxMSWHeaderCtrlCustomDraw already existing elsewhere, so just do
this now.

No real changes, this is just a refactoring.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
ed02083c7e Apply dark mode to the tooltips of the native controls using them
Override the newly added MSWGetToolTipMessage() in the controls using
tooltips and apply dark mode to the window returned by this message too
to make sure they appear correctly in dark mode.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
b284786cf0 Enable dark mode support for wxListCtrl
Use "ItemsView" theme which draws the items of the control itself in the
same way as Explorer does when using dark mode.

Unfortunately this theme doesn't draw the scrollbars correctly, but this
will hopefully be fixed with another hack later.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
dd0c107d6a Allow customizing both dark theme name and ID
We're going to need to use "ItemsView" theme for the header and list
controls, so replace the previously existing MSWGetDarkThemeClass() with
two functions, allowing to customize the name and the ID independently.

No changes yet.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
4b0c691b09 Allow constructing wxUxThemeHandle from an HWND too
This is not used used yet, but will be soon for getting theme data of
the header control which is part of wxListCtrl but doesn't have any
corresponding wxWindow. It's also useful for using null HWND, which
must be used with the special "ItemsView" theme when using dark mode.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
8d3971ef6b Make wxUxThemeHandle::m_hTheme const
No real changes, just make a member variable which never changes const.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
cb85871831 Add MSWShouldUseAutoDarkMode() and use it for wxSpinButton
This control doesn't seem to support dark mode natively, whichever theme
is used for it, so paint it in dark mode ourselves simply by inverting
its colours -- this is not great, but passable and better than leaving
it with a light background.

As this probably won't be the only control which will need this,
implement it at wxWindow level and allow the derived classes to opt-in
this "automatic dark mode support" by simply overriding the new
MSWShouldUseAutoDarkMode() function.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
810b3abd91 Support dark mode for windows and dialogs backgrounds
Currently the colours used in the dark mode are hard-coded, which
definitely isn't great, but better than nothing and at least allows
using the correct background colour for generic windows, panels and
dialogs.

Also return dark mode-specific colours from wxSystemSettings when it's
active.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
bd281c2cc9 Add support for using custom theme class in dark mode
This is needed for at least wxStatusBar, although the gripper is still
not drawn correctly even when this particular theme class is used -- but
at least the main part of the status bar now uses the correct colours.
2022-12-25 19:45:52 +00:00
Vadim Zeitlin
7a84c0b25d Add wxMSWDarkMode::IsActive()
This is the same as the already existing wxMSWImpl::ShouldUseDarkMode()
but has a better name for the use outside of the file implementing dark
mode support.
2022-12-25 19:45:51 +00:00
Vadim Zeitlin
2c409668e3 Enable using dark mode for native controls
Use undocumented AllowDarkModeForWindow() and set the window theme to
"EXPLORER" even for the windows for which we don't normally do it (i.e.
not those deriving from wxSystemThemedControl), to show (at least some)
controls correctly in dark mode.
2022-12-25 19:45:51 +00:00