Commit graph

75345 commits

Author SHA1 Message Date
Vadim Zeitlin
0d4792cc2d Refactor wxImageList classes to use wxImageListBase
This ensures that the native MSW and generic implementations provide the
same API by forcing them to implement the same pure virtual functions.
2023-11-03 01:53:36 +01:00
Vadim Zeitlin
3f971f52c1 Add using declaration for ctors to generic wxImageList
Instead of explicitly forwarding the ctors to the base class manually,
just use them.
2023-11-03 01:38:59 +01:00
Vadim Zeitlin
0003ac6873 Replace wxImageList::Init() with member initializers in wxMSW
No real change, just initialize members in their declarations and get
rid of now unnecessary Init().
2023-11-03 01:36:00 +01:00
Vadim Zeitlin
260a109db6 Remove outdated comment about making wxImageList ref counting
This hasn't happened since 26 years, so don't pretend it's going to
happen now that this class is semi-deprecated.
2023-11-03 01:27:57 +01:00
Blake-Madden
9bae94022c Fixes for wxTextProofOptions documentation
Fix missing semicolons causing help parsing to break.

Document Language().

Fix typo.

Closes #24026.
2023-11-03 00:52:12 +01:00
Vadim Zeitlin
31fefa7ba2 Merge branch 'cxx17-string-toculong'
Fixes for C++17 version of wxString::ToCULong().

See #24022.
2023-11-03 00:51:04 +01:00
Vadim Zeitlin
71c25b4de7 Merge branch 'getsubbitmap-fixes'
Assorted fixes to wxBitmap::GetSubBitmap().

See #24010.
2023-11-03 00:49:50 +01:00
Vadim Zeitlin
ae2b05be5c Fix more compatibility problems in C++17 wxString::ToLong()
Unlike the traditional C functions, std::from_chars() doesn't skip
leading whitespace and doesn't accept the leading "+" sign, so we need
to skip them explicitly to preserve the behaviour of ToLong() in the
previous wxWidgets versions.
2023-10-31 00:44:10 +01:00
Vadim Zeitlin
8d6a722ed8 Fix C++17 implementation of wxString::ToCULong()
Do use std::from_chars<unsigned long>() in it as otherwise values
greater than LONG_MAX failed to parse.

Handle negative numbers explicitly to still parse them in this function
as well, as needs to be done for compatibility.

Add a test case for the previously failing numbers.

Closes #23957.
2023-10-31 00:44:10 +01:00
Vadim Zeitlin
9a620bf920 Refactor: extract SetBaseAndSkipPrefix() from wxString::ToCLong()
No real changes, just extract part of the function into a separate
helper to allow reusing it in the next commit.
2023-10-30 23:56:11 +01:00
Joan Bruguera Micó
abfdd186ff Undo wxGLCanvas::SwapBuffers() Wayland frame sync.
This reverts the frame synchronization logic that was recently added
with the purpose of avoiding performance issues due to `eglSwapBuffers`
blocking when the canvas is hidden or occluded.

This logic should be unnecessary after `eglSwapInterval(display, 0)`
is called, since `eglSwapBuffers` should never block anymore.
Furthermore, as it stands now, it causes the canvas to continuously
repaint itself at the refresh rate of the display, which is wasteful
for applications which do not need to continuously refresh.

Fixes #24012.

Closes #24017.
2023-10-30 00:26:11 +01:00
Joan Bruguera Micó
133f7731b2 Ignore spurious map-events on Wayland's wxGLCanvasEGL
In the recent changes for handling map/unmap events on Wayland's
wxGLCanvasEGL, we use the following GTK widget signals:
* The "map-event" signal to create the canvas's subsurface.
  The earlier "map" signal can not be used, as the associated toplevel
  window's Wayland surface may not yet exist by the time we receive it.
* The "unmap" signal to destroy the canvas's subsurface.
  Using the later "unmap-event" signal is problematic, due to other
  resources we build upon being already destroyed by then.

Usually, the "map-event" signal comes before "unmap" and resources are
created and destroyed appropriately. However, there's an edge case:
If a canvas is shown and then immediately hidden (before wxWidgets can
pump from the event loop), "unmap" will come before "map-event".
This happens because signals like "map" and "unmap" are delivered
immediately (when calling e.g. `gtk_widget_hide`), while signals like
"map-event" and "unmap-event" are delivered later on the event loop.

For the same reason, showing a canvas, then immediately hiding it, then
immediately showing it again, will cause two "map-event"s to get
delivered enqueued without a "unmap" in between.

This condition can be hit quite easily when setting up a complex UIs,
and in particular it is triggered by Aegisub during startup, leading to
a crash (Wayland protocol error) when opening a video later, or when
specifying a video directly on the startup command line.

To avoid this breaking our resource management, add some checks to detect
those "map-event"s we shouldn't handle - either the ones that happen
after "unmap", or the duplicate ones without an "unmap" in between.

Fixes #23961.

Closes #23968.
2023-10-30 00:24:51 +01:00
Joan Bruguera Micó
22ae7a58b5 Clean up Wayland resources on wxGLCanvas destructor
If the wxGLCanvas is destroyed immediately (without hiding it first),
the GTKs widget's `unmap` signal which usually destroys the Wayland
resources is not emitted. Thus, we need to ensure they are destroyed
on the destructor instead.

This fixes an use-after-free issue, sometimes causing a crash, because
one of the leaked resources is the canvas's Wayland frame callback.

Fixes #24013.

Closes #24016.
2023-10-30 00:20:30 +01:00
Vadim Zeitlin
64afa9d963 Ensure that we call eglSwapInterval() for the correct context
Calling it from the frame callback might change the swap interval for
the wrong context if the active context got changed in the meanwhile,
but by the time SwapBuffers() is called the correct context must be set.

Doing it there also allows to unify X11 and Wayland code branches.
2023-10-29 19:37:28 +01:00
Martin Corino
8fc73d45ce Document wxPGSelectPropertyFlags enum
This enum is used in the public API and so needs to be documented.

Closes #23980.
2023-10-29 02:54:03 +02:00
ali kettab
8b66609f16 Fix wxTLW::SetSizeHints() implementation under wxQt
As documented, the value -1 is special which means no constraints will
be used.

In other words, we should use the Qt defaults if -1 was specified.

Closes #24008.
2023-10-29 02:49:17 +02:00
PB
220031c0da Fix buttons missing in widgets sample after recent changes
The Clear log and Exit buttons were not shown after the changes
in a69fabe (Fix using wxStaticBoxSizer in samples, 2023-10-22).

Fix this by creating them with the proper parent.

Closes #24005.

Closes #24007.
2023-10-29 02:47:46 +02:00
Vadim Zeitlin
3dd977f53a Make using EGL under Wayland from outside wxEVT_PAINT work again
Since the changes of 194a7be33f (Improve wxGLCanvasEGL refresh logic
under Wayland, 2023-05-17, see #23554) drawing on wxGLCanvas from
wxEVT_IDLE handler without refreshing the window first didn't work any
longer because the "ready to draw" flag was always false in this case.

To make this work again, refresh the window ourselves to ensure that it
does get redrawn. This is less efficient than drawing on it from
wxEVT_PAINT because all the code executed by the application prior to
calling SwapBuffers() is just wasted, but better than not updating the
window at all.

The recommended way of doing things remains, just as it always was, to
draw from wxEVT_PAINT and call Refresh() in the application code when
the window needs to be updated.

See #23998.

Closes #23996.
2023-10-29 02:46:31 +02:00
Vadim Zeitlin
8f3331e8c1 Fix assert checking input size in wxOSX GetSubBitmap()
Extend the just added GetSubBitmap() unit test to check for this too.
2023-10-29 01:48:29 +02:00
Vadim Zeitlin
2cf77c2596 Fix GetSubBitmap() returned value size when rounding is required
When using non-integer scale factor, we need to round the result of the
multiplication by it instead of truncating it for consistency with the
behaviour of wxBitmap::CreateWithDIPSize() and the other places where we
do this, including wxOSX version of this function.

Add a simple unit test checking that this works correctly (it would fail
with wxGTK before).
2023-10-29 01:48:27 +02:00
Vadim Zeitlin
4048542d54 Move test not depending on it outside wxHAS_RAW_BITMAP check
No real changes, just don't put the test not using raw bitmap access
inside the section guarded by "#if wxHAS_RAW_BITMAP".

This commit is best viewed with Git --color-moved option.
2023-10-29 01:48:11 +02:00
Vadim Zeitlin
34bce88b23 Improve assert message in wxOSX and wxMSW GetSubBitmap()
Don't test for 2 unrelated conditions inside the single assert as this
makes it unclear which of them failed.

Separate the checks for bitmap and input parameter validity, just as it
was already done in wxGTK.
2023-10-29 01:22:47 +02:00
Vadim Zeitlin
3ac8c2717e Set scale factor of bitmap returned by wxMSW GetSubBitmap()
The bitmap scale factor may not be used in wxMSW, where physical and
logical size are the same, but still set it for consistency with the
other ports.
2023-10-29 01:22:47 +02:00
Stefan Csomor
695ca04289
change implementation to a sonoma supported version (#24003) 2023-10-27 14:18:17 +02:00
PB
4ddea5658d Cover default button in wxDialog::CreateStdDialogButtonSizer docs
Add a note explaining that when creating a button sizer with this
method, one of the buttons will be usually made the default.

See #23992.

Closes #24001.
2023-10-25 23:54:22 +02:00
Randalphwa
b297edbe79 Fix using unique_ptr<> in the builds with wxUSE_INTL==0
Include standard library <memory> header file explicitly in the files
where std::unique_ptr<> is used instead of relying it on getting
implicitly included from the other headers, as this doesn't happen when
wxUSE_INTL==0.

Closes #23999.
2023-10-25 23:50:17 +02:00
Vadim Zeitlin
600049f20c Merge branch 'dfb-cxx17'
Fix wxDirectFB build with C++17.

See #23991.
2023-10-25 23:49:00 +02:00
Vadim Zeitlin
72b4658d5a Merge branch 'gtk-gui-app-console-mode'
Add a test for running wxGTK GUI apps in console mode.

See #23981, #23990.
2023-10-25 23:48:00 +02:00
Vadim Zeitlin
9e8a913e4d Merge branch 'qt-textctrl-hittest' of https://github.com/AliKet/wxWidgets
Implement several previously missing wxTextCtrl functions in wxQt.

See #23984.
2023-10-25 23:46:30 +02:00
Vadim Zeitlin
9d06e4c4a7 Implement wxSearchCtrl::GetEditHWND() correctly in wxMSW
Since the changes of 4d76a87015 (Make wxSearchCtrl inherit from
wxTextEntry in all ports, 2023-07-09, see #23697) GetEditHWND() returned
null for wxSearchCtrl which was considered to be correct because all
wxTextEntry functions were supposed to be forwarded to wxSearchTextCtrl
anyhow.

This wasn't really correct, however, as GetEditHWND() was also called
from SetHint(), resulting in an assert failure and falling back on
generic hint implementation which, while mostly working, suffers from
some problems that the native implementation doesn't have.

So make this function return the actual HWND used by the associated text
entry to fix this and allow SetHint() to work as before and also
forestall any problems due to not having the right HWND in the future.

See #23983.

Closes #23975.
2023-10-25 23:45:23 +02:00
Vadim Zeitlin
93b8819a03 Merge branch 'qt-event-trans' of https://github.com/AliKet/wxWidgets
Some fixes for keyboard event processing in wxQt.

See #23974.
2023-10-25 23:44:10 +02:00
Vadim Zeitlin
c1ed2cf33f Fix compiling calls to CopyBits() in C++17
Template arguments can't be narrowed, so use the correct type for them
instead of "int" which is insufficient to hold UINT_MAX.
2023-10-24 01:22:17 +02:00
Vadim Zeitlin
b389483c58 Work around the use of "register" in DirectDB headers
This keyword results in deprecation warnings since C++11 and errors
since C++17 in which it was completely removed.
2023-10-24 01:21:39 +02:00
Vadim Zeitlin
c07a1ec718 Check running the GUI test without GUI in Unix CI builds
This just checks that launching a GUI program and not initializing GUI
in it works as expected and, notably, does not crash.
2023-10-24 01:21:22 +02:00
Vadim Zeitlin
5af28133a0 Fix crash on shutdown of wxX11 GUI applications not using GUI
This should have been done back in f18b415ee3 (Don't crash on startup of
console programs in monolithic wxX11 build., 2011-05-03) when a related
crash on startup was fixed.
2023-10-24 01:21:22 +02:00
Vadim Zeitlin
ea393d76ad Allow running GUI test in console-like app mode
This allows to test that GUI applications not initializing the GUI can
at least start correctly and work as console ones (at least under Unix).
2023-10-24 01:21:22 +02:00
Vadim Zeitlin
c151c9271f Make GTK wxSystemSettings initialization more robust
Add more checks which should not be really needed, but don't do any harm
neither and ensure that we don't use invalid pointers.
2023-10-24 00:36:13 +02:00
ali kettab
b7cf27f2ce Enable HitTestSingleLine test case under wxQt 2023-10-23 21:16:31 +01:00
Vadim Zeitlin
dc6a0c069b Fix losing the other selection contents in wxClipboard
The memory leak fix in b52728a62a (Fix memory leak of wxClipboard data
on exit, 2023-06-21) was too eager and destroyed not just the currently
used selection (e.g. primary), but also the other one (secondary) when
Clear() was called, which was wrong and resulted in the loss of
clipboard contents when discarding the primary selection in wxSTC, for
example.

Fix this by only deleting the object corresponding to the selection
which we're clearing.

See #23661.

Closes #23988.
2023-10-23 01:52:44 +02:00
ali kettab
d91fd33ffd Implement wxTextCtrl::{Set,Is}Editable() under wxQt 2023-10-22 19:57:48 +01:00
ali kettab
334814bf85 Implement wxTextCtrl::SetMaxLength() function under wxQt
This is currently implemented for single line control only. But unfortunately the
wxEVT_TEXT_MAXLEN event is only emitted when the Qt version used is 5.12 or higher.
2023-10-22 18:54:23 +01:00
ali kettab
9b2e4ff2e5 Implement wxTextCtrl::HitTest() function under wxQt 2023-10-22 18:05:13 +01:00
Vadim Zeitlin
f9caa2d4e3 Ignore another commit only removing wxT() for git-blame purposes
Also tidy up the files with the ignored commits a bit and add a comment
explaining how to produce the entries in this file easily.
2023-10-22 17:39:30 +02:00
ali kettab
e16a2cdbeb Don't generate wxEVT_CHAR event for some special keys under wxQt
For compatibility with wxWidgets, don't generate wxEVT_CHAR event for
the following keys: SHIFT, CONTROL, MENU, CAPITAL, NUMLOCK and SCROLL.
2023-10-22 11:54:30 +01:00
ali kettab
6d7f9342be Fix wxContextMenuEvent event propagation under wxQt
Closes #23973.
2023-10-22 01:32:58 +02:00
Martin Corino
5d30f84125 Document wxItemContainer::IsSorted()
This method is needed to determine the sorted state of a control derived
from wxItemContainer without knowing the actual derived control class.

Closes #23971.
2023-10-22 01:31:38 +02:00
Martin Corino
8f12280af4 Add missing API docs for wxRichTextCtrl-related classes
Document functions used in RichText sample code.

Closes #23970.
2023-10-22 01:29:54 +02:00
PB
a69fabecb1 Fix using wxStaticBoxSizer in samples
If a control is contained in a wxStaticBoxSizer or its child sizer,
wxStaticBoxSizer::GetStaticBox() should be used as the control's parent.

However, widgets and dialogs samples did not do that, which resulted in
flooding the message log in widgets sample with warnings about this; in
dialogs sample the warnings were shown in the debug output.

Fix this by always using the static box as the control's parent when the
control is contained (directly or indirectly) in a wxStaticBoxSizer.

Closes #23967.
2023-10-22 01:27:55 +02:00
PB
cc41fa5458 Improve item sorting in generic wxFileCtrl and wxDirCtrl
To sort its items (files and folders) wxFileCtrl used simple string
compare and wxDirCtrl case-insensitive string compare.

However, the files and folders should be presented to the users in the
way they are used to, i.e., in the natural order. Therefore, use
wxCmpNatural() for file and folder names and wxStricmp() for file
extensions.

Closes #22054.

Closes #23962.
2023-10-22 01:25:56 +02:00
Vadim Zeitlin
e43f913313 Remove all blank "Modified by:" lines from top comment blocks
Having this line is not useful at all as it doesn't contain any
information and shouldn't be filled in the future as git-shortlog can
provide the information about people who changed the given file more
more reliably than consulting the comments in any case.

Keep the non-blank lines for historical purposes.
2023-10-22 01:22:48 +02:00