Commit graph

3207 commits

Author SHA1 Message Date
Vadim Zeitlin
53b4f4ddf2 Use physical size in wxImageList
This seems to be the only way to fix using this class, which is
fundamentally incompatible with high DPI support, with bitmaps of
different logical but identical physical sizes.

By using physical size we ensure that the code chopping up the provided
bitmap in multiple images doesn't do it with the bitmap having the same
physical size but a different logical size from all the other bitmaps.
And, conceptually, logical size of the bitmaps in it really shouldn't
matter to the image list as it doesn't have a scaling factor and so
can't do anything useful with the logical size.

Moreover, we can't add wxImageList::SetScaleFactor() neither because
this class is, by design, supposed to be shareable between different
controls which may use different scale factors, so it doesn't make sense
to speak of the scale factor of the image list itself.

This undoes the changes made in the generic implementation back in
c374eefd34 (Fold wxOSX-specific wxImageList into generic version,
2018-10-30) and also eb52e86553 (Take into account scale factor of
images added to wxImageList, 2021-04-03).

Also update a couple of places where wxImageList is still used to use
physical sizes. Unfortunately some others can't be easily fixed, e.g.
global wxFileIconsTable would have to be completely rewritten.

Finally, add a unit test checking that things work as expected now:
previously the size of 24x24 bitmap in the image list containing
(scaled) 32x32 bitmaps would be 21x21 due to sub-bitmap extraction
kicking in.

Closes #23994.
2023-11-06 21:18:34 +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
ali kettab
28cf04036d Enable tests using wxUIActionSimulator under wxQt 2023-11-01 01:06:39 +01:00
ali kettab
aa4a19cb1d Fix or skip other failures in the tests under wxQt 2023-11-01 00:39:19 +01:00
ali kettab
7469f0f5c4 Fix failures in TreeCtrlTestCase tests under wxQt 2023-10-31 22:58:21 +01:00
ali kettab
0e325e6262 Fix failures in ListBoxTestCase tests under wxQt 2023-10-31 22:56:30 +01:00
ali kettab
53c2b7d65b Fix failures in wxGrid tests under wxQt 2023-10-31 22:53:59 +01:00
ali kettab
b5dad92007 Make sure the window is active after SetFocus() under wxQt
Calling wxYield() after SetFocus() ensures that the window is active
and the tests will pass. Otherwise, they would fail.
2023-10-31 22:42:27 +01:00
ali kettab
3a71aeed5e Enable some more tests under wxQt 2023-10-31 22:28:34 +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
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
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
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
ali kettab
b7cf27f2ce Enable HitTestSingleLine test case under wxQt 2023-10-23 21:16:31 +01: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
Vadim Zeitlin
c601bf4279 Merge branch 'qt-fixes'
Fix bugs preventing GUI tests from working with wxQt and provide native
implementations of wx{Date,Time}Ctrl in this port.

See #23925.
2023-10-22 01:18:50 +02:00
Vadim Zeitlin
99febcf9c1 Wait for events in Grid::LabelClick and RangeSelect tests too
Not sure if it really helps, but try to wait for the events in these
tests as well if only for consistency with what was done in 3d07de66b1
(Add a wait to wxGrid UI unit tests too, 2023-10-03).
2023-10-22 01:06:38 +02:00
ali kettab
1f606cd925 Skip test which work locally, but not when run on GitHub CI under wxQt 2023-10-15 00:10:02 +01:00
ali kettab
09c22b080e Fix listboxtest test failing under wxQt
Qt uses QString::localeAwareCompare() for comparison and this is what their
documentation says: "On other Unix-like systems without ICU, the comparison
falls back to the system library's strcoll()". Under MSW, Qt uses CompareStringEx()
IOW, Qt always compares strings by locale-specific sorting criteria and BTW
this is what wxGTK was like before this commit 625ed74 (Make sorting of wxListBox,
wxChoice and wxComboBox identical to the MSW sorting)
2023-10-15 00:10:02 +01:00
ali kettab
155b24daea Fix gridtest test failing under wxQt 2023-10-15 00:10:02 +01:00
ali kettab
942b3bccf4 Fix windowtest test failing under wxQt 2023-10-15 00:10:02 +01:00
ali kettab
ae0d707166 Fix wxListCtrl test failing under wxQt
The wxListCtrl would assert with this message: '../src/qt/listctrl.cpp(452):
assert "col < columnCount()" failed in SetItem(): Invalid col'

Because under wxQt: no columns means no items, and no items means
no selection can be made at all.
2023-10-15 00:10:02 +01:00
ali kettab
f7e7c037c2 Fix wxTextCtrl::GetBestSize test case failing under wxQt 2023-10-15 00:10:02 +01:00
ali kettab
d0bf5fdb8f Use cursor type guaranteed to be supported on all platforms.
The wxCURSOR_CHAR cursor type is not supported under wxQt and using it
causes the test to fail there.
2023-10-15 00:10:02 +01:00
ali kettab
7e360dcf1e Fix testing wxSpinCtrl[Double] unsupported features under wxQt
Backwards ranges are not supported under wxQt and setting empty string
in the control automatically displays minVal.
2023-10-15 00:10:02 +01:00
ali kettab
ff4995ec01 Enable formerly skipped tests under wxQt 2023-10-14 17:58:53 +01:00
ali kettab
14ac76ed36 Make propagation test pass under wxQt
By waiting for the window to be ready before generating wxPaintEvent
2023-10-14 17:58:53 +01:00
Vadim Zeitlin
80e8dc3692 Merge branch 'msw-add-def-catalog'
Fix AddStdCatalog() under MSW and add functions without msg ID fallback.

See #23930.
2023-10-06 01:03:25 +02:00
Vadim Zeitlin
3d07de66b1 Add a wait to wxGrid UI unit tests too
Wait for a bit before checking for the expected event as a single
wxYield() call might apparently not be enough under load, as this test
sporadically fails in AppVeyor CI builds even though it passes locally.
2023-10-03 16:05:31 +02:00
Vadim Zeitlin
0741b09a92 Merge branch 'msw-uitests'
Attempt to fix wxMSW UI tests under AppVeyor and other improvements.

See #23926.
2023-10-02 19:33:12 +02:00
Vadim Zeitlin
a4d2e36cec Merge branch 'msw-fnmatch-all'
Fix using *.* and similar patterns in wxDir under MSW: they're supposed
to match all files and not only files with extensions.

See #23910.
2023-10-02 19:29:31 +02:00
Vadim Zeitlin
94b1a17aeb Add AddAvailableCatalog() and use it in AddStdCatalog()
The new function only returns true if the catalog could be really
loaded and not if it is considered not to be needed because the message
ID language (which is typically "en-US") happens to be present in the
preferred UI languages list (which seems to always include "en-US" in at
least Western European MSW).

This allows to distinguish, albeit in a rather awkward (but
backwards-compatible) way between having a translation for the given
language and not needed such translation.

It is still not clear if it is really correct to return "en-US" from the
list of preferred languages even if the user has never intentionally
configured the OS to indicate that English is acceptable, but at least
now we can work around this issue and use AddAvailableCatalog() in
AddStdCatalog() to make sure we only skip loading unversioned wxstd.mo
if the versioned wxstd-x.y.mo file is really found instead of never
doing it, as was the case until now (see #23886).

Also add GetBestAvailableTranslation() helper which seems more useful
than the existing GetBestTranslation() one and is similarly related to
it.

See #18227.
2023-10-02 19:21:48 +02:00
Vadim Zeitlin
fa5964c100 Use WaitFor() and new YieldForAWhile() helpers in the tests
Reuse the existing function (and another new one, which is even simpler)
instead of duplicating its code in many places in the tests.

No real changes.
2023-10-02 15:10:36 +02:00
Vadim Zeitlin
dc6085a808 Use WaitFor() in WaitForPaint::YieldUntilPainted()
No real changes, just refactor the existing code to call the new
function instead of duplicating it.
2023-10-01 21:32:09 +02:00
Vadim Zeitlin
1237322404 Add WaitFor() helper and use it in Button::Click unit test
This test also sporadically happens under AppVeyor, check if it happens
because we need to wait for some time before the event is processed.
2023-10-01 21:30:00 +02:00
Vadim Zeitlin
55e074f5bc Rename tests/waitforpaint.h into just waitfor.h
No changes yet, just prepare for adding more "waiting" helpers.
2023-10-01 21:25:46 +02:00
Vadim Zeitlin
3f2b7f6bdb Try changing BitmapToggleButtonTestCase to avoid wxMSW failures
This test sporadically fails under AppVeyor, perhaps due to a hard-coded
sleep in it which may somehow misbehave there -- try changing it not to
rely on this sleep.

This has a nice side effect of making the test run faster, too.
2023-10-01 21:14:00 +02:00
Vadim Zeitlin
5406a8f0c2 Don't use newer PathMatchSpecEx() unnecessarily
Use older and so hopefully compatible with all MinGW versions
PathMatchSpec() instead as we don't use any of the newer function flags
and it seems to behave identically with the default flag.
2023-09-30 23:22:16 +02:00
Vadim Zeitlin
d18a16c401 Add an interactive test for PathMatchSpecEx()
This test allows to compare the results of wxString::Matches(),
wxMatchWild() and MSW native function for the same filter.
2023-09-30 16:45:26 +02:00
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
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
ali kettab
d986aed5cd Fixup! get rid of unnecessary hacks
The discrepancy with the other ports was fixed by the previous two commits.
2023-09-19 00:58:47 +01:00
ali kettab
160d171077 Fix wxGraphicsBitmap creation after recent changes to wxBitmap under wxQt 2023-09-13 21:11:26 +01:00
ali kettab
d9e3efcf20 Update bitmap tests for wxQt 2023-09-13 20:40:39 +01: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
00366cbaae Merge branch 'animation-hidpi'
Add support for specifying multiple animations to allow automatically
showing a higher resolution version when using high DPI, just as it was
already possible with the bitmaps.

See #23817.
2023-08-29 01:53:36 +02:00