Commit graph

21195 commits

Author SHA1 Message Date
Maarten Bent
fa26c8724d
Don't use internal check state for generic virtual wxListCtrl
Just like the MSW virtual wxListCtrl, the checkbox state is determined by OnGetItemIsChecked.

See #23869
2023-09-30 17:32:54 +02:00
ali kettab
3c6869605e Make wxTopLevelWindow::SetSizeHints() work in wxQt
Override Set{Min,Max}Size and DoSetSizeHints() to pass size information
to Qt: setting min/max widget size at the wxWidgets level is not enough
to take effect unless the information is also set at the Qt level.

Closes #23917.
2023-09-30 15:23:25 +02:00
Vadim Zeitlin
7e9d06f584 Ensure that the currently shown wxSimplebook page has focus
When calling wxSimplebook::ChangeSelection(), the focus remained on the
previous, now hidden, page, unless it was explicitly set to one of the
controls on the new page.

This was completely unexpected as it could result in the user
(inadvertently) changing the values of the already "accepted" controls
on the last page, so don't let this happen and always set the focus to
the new page explicitly, even if this hasn't been done by
ShowWithEffect() which doesn't do it at least under wxMSW.

Closes #23914.
2023-09-30 15:21:50 +02:00
Vadim Zeitlin
aaabb840b5 Merge branch 'egl-wl-swap-interval'
Fix setting EGL swap interval under native Wayland too.

See #23909, #23512.
2023-09-30 15:17:39 +02:00
Vadim Zeitlin
4883e185bc Merge branch 'qt-popup' of https://github.com/AliKet/wxWidgets
Fix wxPopupWindow implementation under wxQt.

See #23904.
2023-09-30 15:15:41 +02:00
Vadim Zeitlin
d57e175a7c Merge branch 'qt-bmp-premult' of https://github.com/AliKet/wxWidgets
Use premultiplied ARGB32 format for wxBitmap under wxQt: this makes
bitmap-related unit tests pass with wxQt too.

See #23872.
2023-09-30 15:07:13 +02:00
PB
6caaf589f1 Use more modern appearance for wxMSW wxTreeCtrl by default
Change wxTreeCtrl default style under wxMSW to make it look more
up-to-date by default: use twisting buttons and full-row highlight and
don't display connector lines.

Using wxTR_LINES_AT_ROOT together with wxTR_NO_LINES may look odd but it
is needed because without wxTR_LINES_AT_ROOT, the buttons would not be
displayed.

Also update wxTreeCtrl screenshot in the docs.

Closes #23844.
2023-09-30 15:00:48 +02:00
ali kettab
4036a555bf wxPopupWindow implementation under wxQt completed 2023-09-28 14:09:59 +01:00
Vadim Zeitlin
647564126b Call eglSwapInterval() when it can succeed
Postpone calling this function until we get the (first) frame callback
as by this time the EGL context is fully valid and can be used inside it
and it doesn't fail any longer.
2023-09-27 14:43:58 +02:00
Vadim Zeitlin
6e8fc23705 Make Wayland frame callback a wxGLCanvasEGL member function
This allows to make m_readyToDraw private.

No real changes otherwise.
2023-09-27 14:38:12 +02:00
ali kettab
be75c73880 Add missing guard before using wxImage in wxBitmap code 2023-09-24 11:39:58 +01:00
ali kettab
b12cdc6739 Minor fixes to constructors
Make wxMask constructor taking QBitmap explicit

And wxBitmapRefData already has a constructor taking a QPixmap
2023-09-24 11:11:02 +01:00
ali kettab
1e43b375bc Added QtBlendMaskWithAlpha() to wxBitmap under wxQt
Blend mask with alpha channel and remove the mask.

We need this function for performance reasons. e.g. the wxImageList (used by
wxTreeCtrl and wxListCtrl) calls this function to convert the mask (if any)
to alpha. Because the controls (under wxQt) using the image list ignore the
mask on the bitmaps and expect alpha instead.

This is similar to MSWBlendMaskWithAlpha() found in wxMSW port.
2023-09-23 21:53:26 +01:00
Artur Wieczorek
2cdca2d744 Deprecate wxPGPropertyFlags that are intended for internal use 2023-09-22 23:39:53 +02:00
Artur Wieczorek
763ed589f5 Prevent from using wxPropertyGrid private header in the user code 2023-09-22 23:39:53 +02:00
Artur Wieczorek
11582b4082 Refactor wxFlagsProperty to simplify initialization 2023-09-22 23:39:53 +02:00
Artur Wieczorek
5a87cbdf3d Use enum class to represent wxPGKeyboardActions 2023-09-22 23:39:53 +02:00
Artur Wieczorek
9cb4d8fbbe Save keyboard actions as std::pair in wxPropertyGrid
Store two possible action codes in std::pair instead of packing them
into one int value with bitmasks. This reduces level of indirection
in accessing keyboard actions and make the code more maintainable.
2023-09-22 23:39:52 +02:00
Artur Wieczorek
87e86dee86 Fix wxPG_PROP_ACTIVE_BTN flag definition
wxPG_PROP_ACTIVE_BTN used in wxStringProperty is misinterpreted
as wxPG_PROP_PASSWORD so these flags they can't share the same value
(wxPG_PROP_CLASS_SPECIFIC_2).

Closes #23856.
2023-09-22 23:39:52 +02:00
Vadim Zeitlin
a0a28a7973 Fix recent wxGTK regression when using wide string entry point
The changes of 5f17915e63 (Store original command line options passed to
main(), 2023-09-02) didn't account for the possibility of the
application using an entry point such as wxEntry(), wxEntryStart() or
wxInitialize() with wide character argv under Unix -- where this is
typically not the case but still possible and if any of the wide string
overloads of these functions were called, wxInitData::arg[cv] remained
uninitialized resulting in a crash in gtk_init_check() later.

Fix this by ensuring we do initialize them in this case too and also
reconstruct the original narrow string argvA from wide string arguments
in this case, which is a bit wasteful but unavoidable if we're not
provided access to the original main() arguments.

See #23877.
2023-09-21 22:03:11 +02:00
Vadim Zeitlin
ae8619b6dd Don't build separate webview_chromium library
Just include wxWebViewChromium in the webview library if it's enabled
during the build.

There doesn't seem to be any reason to build a separate library for it,
it's not really different from the other disabled by default wxWebView
backend (Edge).

And now that we don't need to link with an extra library, there is also
no need to have a separate webview_chromium sample, so just add a
possibility to run webview sample itself using Chromium backend by
setting WX_WEBVIEW_BACKEND environment variable.
2023-09-15 01:56:08 +02:00
Vadim Zeitlin
b788711ca1 Move wxWebViewFactoryChromium to the source file from the header
There doesn't seem to be any need for this class to be public.

No real changes.
2023-09-14 19:18:32 +02:00
ali kettab
c1f91177df Enable raw bitmap data access for monochrome bitmaps in wxQt 2023-09-13 19:44:14 +01:00
ali kettab
74a1d69084 Fix wxMask creation when converting wxImage to wxBitmap in wxQt
Also GetSubBitmap() should return the sub-mask too if the bitmap has a mask

Notice that masked/unmasked areas are reversed to be in accordance with wx
2023-09-13 19:24:00 +01:00
Vadim Zeitlin
eb8a57760e Merge branch 'qt-fixes' of https://github.com/AliKet/wxWidgets
Make wxQt wxPen and wxBrush classes behave more consistently with the
other ports.

See #23863.
2023-09-10 17:35:42 +02:00
ali kettab
a38774206d Added ctor taking a wxPenInfo to wxPen in wxQt 2023-09-09 23:00:43 +01:00
Vadim Zeitlin
c109f7f593 Implement SetProxy() in wxWebViewChromium too
Update the documentation to mention that it supports it and add an
example showing how to call this function.
2023-09-08 01:34:59 +02:00
Vadim Zeitlin
80ce14910c Initialize wxWebViewChromium members in their declarations
No real changes, but ensure that all of them are always initialized.
2023-09-08 01:34:59 +02:00
Vadim Zeitlin
81283f84dd Merge branch 'master' into webview-chromium-new
This pulls in wxWebView::SetProxy() addition.
2023-09-08 01:34:21 +02:00
Vadim Zeitlin
4844d37df1 Make recently added GTK-specific wxTextCtrl accessors public
Make GTKGetTextBuffer() and GTKGetEditable() functions added in
e4388d4f87 (Add accessors for underling wxTextCtrl GTK widgets,
2023-08-27) public instead of protected as it doesn't make sense to
force people to derive from wxTextCtrl just to call them.

See #23829.

Closes #23843.
2023-09-08 01:32:36 +02:00
Vadim Zeitlin
0fd6cf99a3 Implement wxWebView::SetProxy() for Edge backend
Currently it can only be called before Create() because it has to be
passed via the additional browser arguments and can't be changed later.
2023-09-07 15:33:39 +02:00
Vadim Zeitlin
7c5d30fb32 Add wxWebView::SetProxy() and implement it for WebKit2 backend
Update the sample to allow specifying the proxy in it.
2023-09-07 15:33:39 +02:00
Vadim Zeitlin
92f6f164b3 Add wxEVT_WEBVIEW_CREATED for wxWebViewChromium async creation
wxWebViewChromium creation is asynchronous and the object can't be
really used until OnAfterCreated() is called, so expose this in the
public API via a new event sent when the object becomes actually usable.

As a side effect, add a convenient wxWebViewEvent ctor taking wxWebView
as argument and calling SetEventObject() itself, instead of forcing all
code creating wxWebViewEvents to do it.
2023-09-06 03:50:34 +02:00
Vadim Zeitlin
f1734a29b6 Use compiler-generated wxWebViewEvent default ctor
No real changes, just let the compiler do what it does best and generate
the code for us instead of writing "{}" explicitly.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
7aec5a7e62 Implement browser window resizing correctly under Mac too
While the window was somehow resized on its own under Mac (and only
there) after the initial creation, it didn't have the correct size
initially if we didn't give it to it, so provide a Mac-specific
implementation of wxEVT_SIZE handler too, which fixes this and allows to
remove an ugly Mac-specific workaround from the sample.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
0dffac1829 Add private header for wxWebViewChromium Mac-specific functions
Instead of just declaring the function inline in the common code, do it
in a header included from both common C++ and Mac Objective C++ sources.

No real changes.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
4395a47d40 Remove redundant wxWebViewChromium forward declaration
There is no need to do it just before the full class declaration.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
013940da8f Move ClientHandler to wxCEF namespace
Use "wxCEF" prefix for this class to avoid any conflicts by using
non-wx-prefixed name.

Also replace wxWebViewChromiumImplData with wxCEF::ImplData as this is
shorter and more consistent with ClientHandler.

Finally stop using anonymous namespace for wxBrowserProcessHandler and
wxCefApp, as we can now put them into the same wxCEF namespace.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
efe58535d1 Hide private wxWebViewChromium data into a private struct
No real changes, just a refactoring to make further changes simpler.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
f5e2af9a28 Make wxWebViewChromium work with wxGTK3 and X11
Make browser creation actually work by postponing it until the host
window is realized and so has a valid X11 Window.

Remove unnecessary code manually creating GTK widget and just use the
standard wxGTK wxWindow instead.

Add code for setting the visual compatible with CEF to avoid X11 errors,
see https://github.com/chromiumembedded/cef/issues/3564, with many
thanks to Jiří Janoušek for finding and solving this problem originally.

Adjust the sample to handle wxWebView::Create() failure (not very
gracefully, but still better than just crashing) and to avoid using it
until it is fully created.

Update documentation to mention GTK limitations.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
d3cc4678d5 Add entry hook mechanism and use it for Chromium helper processes
At least when using wxGTK Chromium helper process can't be executed once
GTK is initialized because doing this creates background threads and
Chromium code aborts if there are any threads running.

As we don't want to initialize CEF unconditionally before initializing
GTK in all applications (even those not using CEF), the only solution is
to detect if we need to run a Chromium helper process ourselves before
GTK initialization, i.e. before wxApp creation, which means that it
can't be done via the existing wxModule mechanism because modules are
initialized after creating the global application instance.

So add a way to hijack wxWidgets initialization entirely if some special
command line option (such as Chromium "--type=xxx") is specified and use
it in wxWebViewChromium to call CefExecuteProcess() before initializing
GTK or even wxWidgets itself -- as it won't be needed in a CEF helper
process anyhow.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
6762d5eaa5 Merge branch 'master' into webview-chromium
Merge the changes required by wxWebViewChromium, notably support for the
entry hooks and new wxDynamicLibrary::ListLoaded() Unix implementation.
2023-09-06 03:49:49 +02:00
Vadim Zeitlin
3861ad6b6d Merge branch 'init-data-refactor'
Refactor and improve command line arguments handling during
initialization.

See #23847.
2023-09-06 02:46:51 +02:00
Joan Bruguera Micó
952de605f6 Handle map/unmap events on Wayland's wxGLCanvasEGL
Fixes hiding a wxGLCanvas on Wayland, either directly (`->Show(false)`)
or indirectly (e.g. when it is contained in a wxNotebook).

On Wayland, unlike on X11, to show the canvas on the screen, we need to
create a Wayland subsurface. This subsurface is detached from the GTK
widget associated to the canvas, thus it is not automatically mapped or
unmapped when the associated GTK widget is.
Rather, we need to manually keep it in sync with the widget's state.

Knowing what has to be done to map and unmap the canvas, while dealing
with edge cases properly, is not easy to someone not used to Wayland.
When the canvas is mapped, we have this graph of resources:

  EGL Surface (m_surface)
             |
             |
             v
  wl_egl window (m_wlEGLWindow)
             |
             |
             v
     Canvas wl_surface         GDK's toplevel window wl_surface
       (m_wlSurface)        (gdk_wayland_window_get_wl_surface(w))
              \                   which is shown to the user
               \                         ^
                \                       /
                 \                     /
                  v                   /
          Subsurface (m_wlSubsurface) to overlay
          the canvas onto the toplevel window

A simple way would be to destroy everything (m_surface, m_wlEGLWindow,
m_wlSurface, m_wlSubsurface) on unmap, and re-create it again on map.
Inefficiencies aside, this mostly works. However, it can mess with the
current OpenGL context. For example, suppose we have a (fragile)
program that places a canvas inside one of wxNotebook's tabs, and makes
the OpenGL context current only once at startup (e.g. on wxEVT_SHOW).
Switching between tabs will destroy and re-create the EGL Surface, so
the canvas will not be properly rendered when going back to its tab.

So we need to be smarter, and find some way to hide the subsurface
instead. The obvious way would be to unmap the canvas wl_surface
(m_wlSurface), as according to the Wayland spec., "a sub-surface is
hidden [...] if a NULL wl_buffer is applied [to the canvas surface]."
(https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_subsurface)
However, as far as I can tell, this can't be done. There's no API to
hide an wl_egl window, and directly applying a NULL wl_buffer to the
canvas surface initially hides it, but seems to breaks the associated
window so that it crashes when one attempts to show it again.

So what remains, is destroying the overlay subsurface (m_wlSubsurface).
When doing it, to the spec, "the wl_surface is unmapped immediately.".

And not only does this work, but it also deals with the annoying fact
that on current GTK3 versions, when the GDK's toplevel window is
unmapped, its wl_surface is not just unmapped, but entirely destroyed.
(Side note: This may not have been intended, and has been changed for
GTK4, see: 5d3cec5441)
So we'd have to re-create the subsurface because of this anyway.

So, this works nicely, and as far as I can tell (documentation is a bit
scarce), there's no problem to leaving m_wlSurface (and its associated
m_wlEGLWindow and m_surface) unmapped in this way.

Fixes #22580.

Closes #23835.
2023-09-06 02:45:03 +02:00
Joan Bruguera Micó
19936c2176 Don't clobber std::string_view equality with char *
Make the wxString(std::string_view) constructor explicit.

Otherwise, when comparing a std::string_view with a const char *, the
cast to wxString will be considered as a candidate for the comparison,
ultimately causing an "ambiguous overload for 'operator=='" error.

For example, this sample only builds if the constructor is explicit:

  #include <wx/string.h>
  #include <string_view>

  int main() {
    std::string_view view = "abc";
    const char *str = "abc";
    return view == str;
  }

However, making the constructor explicit will break assignment:

    std::string_view view = "abc";
    wxString s;
    s = view; // Error: no match for "operator="

That we can fix by implementing operator=(std::string_view)

That, however, introduces another ambiguity:

    std::string str = "abc";
    wxString s;
    s = str; // Ambiguous between s = wxString(str)
                              and s = std::string_view(str)

That we can fix by implementing operator=(std::string)

Finally, note that some rather obscure ambiguities remain, such as:

    wxString s;
    s = {"abc", 2}; // Ambiguous between s = wxString("abc", 2)
                                     and s = std::string_view("abc", 2)

Avoiding them is not simple (https://cplusplus.github.io/LWG/issue2946)
and doesn't add much value.

Closes #23834.
2023-09-06 02:44:11 +02:00
Vadim Zeitlin
b3cfab1433 Merge branch 'msw-dont-preprocess-unknown'
Don't preprocess messages for unknown windows in wxMSW.

See #23824.
2023-09-06 02:41:08 +02:00
Vadim Zeitlin
d5d8c1ad28 Add a hack to fix link problem with wxScrolledCanvas in wx DLL
When using MSVC, wxScrolledCanvas could be instantiated multiple times
when including wx/scrolwin.h directly and when including wx/grid.h,
which declares a class deriving from wxScrolledCanvas, later.

Fix this by defining a dummy class deriving from wxScrolledCanvas in the
same header, as this is enough to convince MSVC to generate the
definition of wxScrolledCanvas itself in the DLL instead of doing it
inline.

Closes #23774.

Closes #23803.
2023-09-06 02:40:01 +02:00
Vadim Zeitlin
497f6f993b Describe ownership rules for wxInitData pointers in comments
No real changes, just add some comments.
2023-09-02 23:17:49 +02:00
Vadim Zeitlin
ad7f5805bf Remove wxInitData::argvOrig which is not needed, finally
We never really used the "original" version of the command line, i.e.
before it was (possibly) modified by gtk_init_check(), so don't bother
keeping it and just free the pointers corresponding to the arguments
consumed by GTK in wxGTK code.

There should be no real changes, this is just a simplification.
2023-09-02 23:17:49 +02:00
Vadim Zeitlin
5f17915e63 Store original command line options passed to main()
This allows to avoid converting them back from Unicode to UTF-8 when we
need them in wxGTK initialization code and can also be useful elsewhere.
2023-09-02 23:17:49 +02:00