Commit graph

75148 commits

Author SHA1 Message Date
Vadim Zeitlin
e58fdf882e Work around Wine PathMatchSpecEx() bug in the just added test
Skip this test under Wine until the problem is fixed.

See https://bugs.winehq.org/show_bug.cgi?id=55677
2023-09-29 17:01:39 +02:00
Vadim Zeitlin
22c629d667 Fix matching "x*.*" in wxMSW wxDir too
Recent commit corrected handling of "*.*", which previously didn't match
the files without extensions, but still left handling of patterns such
as "x*.*" broken, because they are also supposed to match all files
starting with "x" under Windows, whether they have an extension or not.

Fix this by using PathMatchSpecEx() shell function which should handle
this correctly and update the unit test to check for this case as well.
2023-09-29 16:38:37 +02:00
Vadim Zeitlin
f27688367a Remove ugly macros and useless functions from wxMSW wxDir code
No real changes, just remove trivial functions used to simply return a
member of a struct and also the completely useless PTR_TO_FINDDATA macro
and simply use the variable directly instead.
2023-09-29 16:35:07 +02:00
Vadim Zeitlin
3f70912d74 Remove __WINDOWS__ check from a Windows-only file
No real changes, just remove a redundant __WINDOWS__ check.
2023-09-29 16:28:29 +02:00
Vadim Zeitlin
3181f1988d Fix using *.* in wxDir under MSW
Using "*.*" as a wildcard is supposed to match everything under MSW, but
ever since the changes of 4daceaacbd (Check that files returned from
wxDir::FindXXX() match the filter., 2013-04-08, see #3432) it only
matched the files with extension because we double-checked the match
returned by the native MSW function (which does handle "*.*" correctly)
using our own wxString::Matches() which doesn't handle it specially.

Fix this by skipping the call to Matches() when "*.*" is used: we know
that this wildcard matches everything, so rechecking the match would be
useless at best, even if it were not actively harmful. And also skip
this call for "*" because calling Matches("*") always succeeds anyhow.

This also fixes the same bug in wxFind{First,Next}File() and any other
code using them such as wx{File,Dir}Ctrl.

Closes #23905.
2023-09-27 15:33:32 +02:00
Paul Cornett
df6366ff57 Fix showing popup menu with GTK/Wayland without active event
Since a261c80 (Avoid Gdk-CRITICAL warnings when using PopupMenu() with
Wayland, 2022-04-22) popup menus shown when there is no related current
event did not work when using default positioning. Fix this by always
providing a GdkWindow and a GdkEvent, and using a suitable substitute
when a real event is not available.
See #23892
2023-09-24 14:20:29 -07:00
Artur Wieczorek
3b7d81b7f2 Use C++11 standard library to generate pseudo-random numbers 2023-09-22 23:39:53 +02:00
Artur Wieczorek
5595c1a028 Use range-based loop to iterate over wxPGProperty children 2023-09-22 23:39:53 +02:00
Artur Wieczorek
a3b7839c41 Add wxFlagsProperty demonstration to propgrid sample 2023-09-22 23:39:53 +02: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
e8f7440bbe Get rid of unnecessary casts 2023-09-22 23:39:53 +02:00
Artur Wieczorek
ec6b96c1ed Initialize variables at declaration 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
PB
081b7c430b Document more macOS-only wxTextCtrl methods
Document previously undocumented macOS methods
enabling/disabling automatic character substitutions.

This should have been part of 90e1769 (Add API to control
OS X wxTextCtrl’s smart behavior, 2016-10-16).

Closes #23889.
2023-09-21 22:59:06 +02:00
PB
8efb1bceda Fix crash due to logging bug in the event sample
The gestures frame created its own log target and deleted
the previous one but did not restore it when being closed.

This left the current log target invalid which led to a crash
when calling any wxLog*() function after gestures frame was closed.

Fix this by restoring the previous log target when gestures frame
is closed.

Closes #23767.

See #23881.
2023-09-21 22:56:49 +02:00
Vadim Zeitlin
b126766595 Fix page origin in wxGTK when printing in landscape mode
Using the "left" and "top" margin doesn't work in this case and we would
actually need to use "bottom" and "left" ones to offset the origin
correctly in landscape orientation (and something else for the reverse
landscape, and reverse portrait one, too), but there actually seems to
be a simpler way to put the origin where we want it without translating
it explicitly: we can just tell GTK that we want to use the full page,
rather than just the printable area, by setting "use-full-page" property
to true, so simply do this instead.

Co-authored-by: Alex Shvartzkop <dudesuchamazing@gmail.com>

See #23870.

Closes #23860.
2023-09-21 22:34:24 +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
Paul Cornett
f6c3393741 Avoid dispatching the same event more than once under Wayland when Update() is called
gdk_display_sync() can cause the event loop to run under Wayland, and
gdk_display_flush() seems to work just as well, so use that instead.
See #23760
2023-09-20 11:51:07 -07:00
Cookielau
e570d85164 Ensure current cell remains valid when wxGrid table changes
Replacing the table used by the grid could make the current cell
coordinates invalid, resulting in asserts when trying to use it later.
Fix this by calling the same function which was already called when
changing the existing table.

See #23752.

Closes #23751.

Co-authored-by: Vadim Zeitlin <vadim@wxwidgets.org>
2023-09-15 02:08:36 +02:00
ali kettab
21f9366861 Do not emit wxEVT_CHECKLISTBOX from wxQt wxCheckListBox::Check()
Commit 1d12873751 (wxCheckListBox::Check() should not emit any event
under wxQt, 2022-10-31) was supposed to fix this problem, but didn't:
the event is actually generated from wxQtListWidgetItem::setData() and
not from any other signal.

Really fix this now by checking signals state before generating the
event.

Note that this fixes a crash in wxRearrangeCtrl which doesn't expect
getting any events when calling Check() from its ctor, but did get them
and used a yet uninitialized m_order in their handler.

Closes #23873.
2023-09-15 01:51:57 +02:00
Martin Srebotnjak
6225b58a5b Update Slovenian translations 2023-09-15 01:46:16 +02: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
Maarten Bent
c472e495fa Fix wxBufferedPaintDC scale in wxRichTextCtrl
Use wxBitmap::CreateWithDIPSize() to ensure that the backing store
bitmap uses the scale factor corresponding to wxRichTextCtrl using it.

This fixes layout problems in wxRichTextCtrl when using non-default DPI.

Closes #23828.

Closes #23861.
2023-09-10 17:34:01 +02:00
A. Jiang
5c86933fd3 Skip LIST chunks in WAV files in Unix wxSound implementation
Ignore chunks having informational data instead of failing to load WAV
files containing them.

Closes #23859.
2023-09-10 17:28:56 +02:00
ali kettab
1bdcfd33e6 Fix clearing the dc with invalid brush in wxQt 2023-09-09 23:32:35 +01:00
ali kettab
662b04e673 Fix code indentation for consistency 2023-09-09 23:08:17 +01:00
ali kettab
a248edaf6f Default ctor should create uninitialised wxBrush too in wxQt as documented 2023-09-09 23:07:40 +01:00
ali kettab
c7d51a9394 Fix code indentation for consistency 2023-09-09 23:01:57 +01:00
ali kettab
a38774206d Added ctor taking a wxPenInfo to wxPen in wxQt 2023-09-09 23:00:43 +01:00
ali kettab
c028f61d0f Default ctor should create uninitialised wxPen too in wxQt as documented 2023-09-09 22:53:16 +01: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
49b2f9c809 Merge branch 'webview-proxy'
Add wxWebView::SetProxy().

See #23854.
2023-09-08 01:31:04 +02:00
Hartwig Wiesmann
879cc1e574 Fix file history items formatting when loading them from config
Add DoRefreshLabels() to wxFileHistoryBase::Load() to ensure that the
paths are formatted correctly.

Closes #23799.

See #23857.
2023-09-08 01:24:41 +02:00
Vadim Zeitlin
ff5c972b7f Set proxy to the environment variable value for all backends
Don't do it just for Edge one, as WebKit-based one supports it too and
the example code is nicer without the extra checks.
2023-09-07 15:33:39 +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
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
aec49d9c9d Use dl_iterate_phdr() in wxDynamicLibrary::ListLoaded()
This has the advantage of returning libraries in their load order, which
is more useful than the unspecified order that was used before.

It also means that this function now has a chance of working under other
systems such as FreeBSD, which also provides dl_iterate_phdr().
2023-09-06 00:40:11 +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
Vadim Zeitlin
229b749b34 Merge wxMSWCommandLineInit and wxInitData structs
This is a bit ugly because we need to have some __WINDOWS__ checks in
common code, but less uglier than before, e.g. it allows us to get rid
of wxEntryCleanupReal redefinition hack.
2023-09-02 23:17:49 +02:00