Commit Graph

2803 Commits

Author SHA1 Message Date
Vadim Zeitlin
9a3d3156ab Merge branch 'better-bitmap-resize'
Use "nearest" algorithm for resizing bitmaps.

See #22152.
2022-02-27 22:44:50 +00:00
Jouk
6c9d1291f6 Fix build under OpenVMS where mkdtemp() is unavailable
Just skip the part of the test using this function under OpenVMS.

Closes #22158.
2022-02-25 18:23:32 +01:00
Vadim Zeitlin
4e05ee9c5a Benchmark wxIMAGE_QUALITY_BOX_AVERAGE too for completeness
Check the speed of wxImage::Scale() using this algorithm too.

As expected, it's between normal and high quality when upscaling and
exactly the same as high quality when shrinking (because it is actually
the algorithm used for shrinking for wxIMAGE_QUALITY_HIGH).
2022-02-23 00:01:52 +00:00
Vadim Zeitlin
e25b47ee32 Allow tweaking parameters of wxImage::Scale() benchmarks
Use the string parameter as the name of the file containing the image to
resize and the numeric parameter as the scale factor in percents (so
that fractional factors could also be specified using this integer
parameter).
2022-02-22 23:59:36 +00:00
Vadim Zeitlin
a8ec7eec0b Allow passing default value to Bench::GetXXXParameter()
Just an extra convenience for the benchmark functions.
2022-02-22 23:58:38 +00:00
Vadim Zeitlin
5847b302be Make it possible to run a benchmark for the given amount of time
This is more practical than running it a given number of times, which
may result in very long running times for slow functions, such as
wxImage resizing tests using wxIMAGE_QUALITY_HIGH.

Also show the standard deviation in addition to the average and min/max
values.
2022-02-22 23:58:19 +00:00
Vadim Zeitlin
4ff445af4d Check that we parsed something in wxBitmapBundle::FromSVG()
Don't always return success from this function, NanoSVG just skips
everything until the start of the XML prologue and doesn't return an
error even if it doesn't find it at all, so check that it could parse at
least something to avoid returning a "valid" bundle not containing
anything at all.

Add a unit test checking that we actually can't create an SVG from a
.bmp file (which is something that "worked" before).
2022-02-15 19:37:22 +00:00
Vadim Zeitlin
f0e6a8b15a Merge branch 'bitmap-scale-fixes'
Really fix setting wxBitmap scale factor in wxMSW and rename
wxBitmap::CreateWithLogicalSize() to CreateWithDIPSize().

See #22118.
2022-02-13 00:27:24 +01:00
Vadim Zeitlin
74424cbeb2 Rename wxBitmap::CreateWithLogicalSize() to CreateWithDIPSize()
The new name, recently introduced in 94716fd801 (Add
wxBitmap::CreateWithLogicalSize(), 2022-01-22), was perhaps more clear,
but also misleading and confusing because the postcondition

	CreateWithLogicalSize(size, 2).GetLogicalSize() == size

was not satisfied under MSW, so rename it once again, and hopefully
finally, because the new name is consistent with GetDIPSize() returning
the same size.

Also try to improve the documentation a bit more.
2022-02-11 17:30:57 +00:00
Vadim Zeitlin
20f82e2ccb Fix CreateWithLogicalSize() to set correct scale in wxMSW too
Unlike under Mac (see previous commit), this never worked correctly in
wxMSW at all, only SetScaleFactor() could be used to change the scale
factor of the bitmaps there.

Fix this and make CreateWithLogicalSize(..., scale) result in
GetScaleFactor() returning the same scale for the resulting bitmap, as
expected, under MSW too.

Also add a unit test verifying that this holds.
2022-02-11 17:15:51 +00:00
Vadim Zeitlin
d130323a4c Fix default size of wxBitmapBundle created from scaled bitmap
We need to use GetDIPSize(), not GetLogicalSize(), for this to work
correctly under MSW too.

Also add a unit test checking for this.
2022-02-10 14:01:09 +00:00
Vadim Zeitlin
20d1188e82 Really fix setting wxBitmap scale factor
Optimization of 2ae80673ff (Avoid unnecessarily unsharing bitmaps in
wxMSW, 2022-02-02) broke setting the scale factor because we didn't
update the right bitmap data in case bitmap hadn't had exclusive
ownership of its data before. Fix this by not using a reference which
may refer to another object after AllocExclusive() call.

Also change the other ports to unshared the bitmap when modifying its
scale factor so that the new unit test passes for them too.
2022-02-10 14:01:09 +00:00
Vadim Zeitlin
34ca92d362 Show logs in case of Mkdir or Rmdir failures in wxFSW unit tests
Try to gather more information about the test failures on GitHub Actions
when creating or removing the test directory that isn't reproducible
locally.
2022-02-10 13:55:54 +00:00
Vadim Zeitlin
046f228bb2 Reset watch directory in wxFileSystemWatcher unit test
Share the same variable between GetWatchDir() and RemoveWatchDir() to
make things more clear.

Also check for GetWatchDir() postcondition (i.e. that the directory
exists) in the function itself instead of doing it in the caller.
2022-02-10 13:38:00 +00:00
Vadim Zeitlin
93c86fe5cd Fix harmless signed/unsigned warning in wxRegEx unit test
Cast the expected number of matches to "int" to have the same type as
wxRegEx::Replace() return value -- there is no danger of truncation here
as we're never going to expect billions of matches.
2022-02-10 13:36:49 +00:00
Scott Talbert
f172f53ac4 Create our own socket file for socket file test
/dev/log doesn't exist in certain types of containers (e.g., Fedora's
build system).  Additionally, this enables us to run this test on
platforms other than Linux.

Closes #22090.
2022-02-05 16:18:22 +01:00
oneeyeman1
995c6e6df5 Add wxSpinCtrl::SetIncrement() and implement it for all ports
SetIncrement() was already available in wxSpinCtrlDouble and GTK version
of wxSpinCtrl, now implement support for it in wxMSW and wxOSX as well.

In fact, in wxMSW, implement it at wxSpinButton level, so that both this
class and wxSpinCtrl inheriting from it (in wxMSW only) support setting
custom increment now.

Also add support for it to XRC, show it in the sample and add a unit
test verifying that it works.

Closes #2597.
2022-02-04 02:16:06 +01:00
Vadim Zeitlin
46dce3e160 Merge fix for environment variable expansion in XRC bitmap paths
This is a merge of the branches 'fix-xrc-envvar-bitmapbundle' of
https://github.com/ousnius/wxWidgets & 'ak_fix-xrc-envvar-bitmapbundle'
of https://github.com/kosh543/wxWidgets.

Fix the recently introduced bug in environment variables expansion in
the bitmap paths and add a unit test ensuring it isn't introduced again.

See #22071, #22080.
2022-02-02 14:20:51 +01:00
Alexander Koshelev
c986763a77 Test environment variables in XRC bitmap paths 2022-02-02 10:56:51 +03:00
Vadim Zeitlin
ae7fa19ae3 Improve fallback logic in wxArtProvider::GetBitmap{,Bundle}()
This improves the changes of f78db92462 (Avoid bitmap scaling in
wxArtProvider::GetBitmapBundle(), 2021-12-17) and still uses a custom
bundle to avoid scaling the bitmap if possible, but does it in
GetBitmapBundle() itself rather than CreateBitmapBundle().

This allows to also use CreateBitmapBundle() from GetBitmap(), as there
is no possibility of infinite recursion due to calling each of these
functions from the other one any more, and so allows defining art
providers overriding only CreateBitmapBundle() instead of having to
always override both it and CreateBitmap().

Also add a unit test, even if just a trivial one, for these functions,
to at least check that they don't crash.
2022-01-31 22:53:13 +00:00
Alexander Koshelev
b2629a97e5 Add wxBitmapBundle::GetPreferredLogicalSizeFor()
We often need the logical bitmap size when using it in size computations
involving window size, so add a function returning it directly to
wxBitmapBundle, similarly to wxBitmap::GetLogicalSize(), to avoid using
FromPhys() everywhere.

Also rename the existing wxBitmapBundle::GetPreferredSizeFor() to
GetPreferredBitmapSizeFor() to make it more clear that this is similar
to wxBitmap::GetSize() and so returns the size in physical units.

Closes #22056.
2022-01-27 14:29:25 +01:00
Vadim Zeitlin
a81e0d83c1 Use wxBitmap::GetLogicalXXX() instead of GetScaledXXX()
Replace old functions with the new ones in the library code itself.

Note that wxSTC and wxRichText still use GetScaledXXX(), but they're
different functions that might need to be renamed/dealt with separately.
2022-01-22 18:57:31 +00:00
Pavel Tyunin
d7fe9667fc Add tests for direction of search in arrays 2022-01-15 21:02:22 +02:00
Vadim Zeitlin
ee330d73a7 Rebake after the year change
The year is now included in the copyright string used in the makefiles
and so they need to be regenerated every time the year changes (which
happens surprisingly frequently).

It would be better to define a single variable with the year number to
avoid having to do this in the future.
2022-01-14 22:51:24 +01:00
Vadim Zeitlin
1f401475f3 Merge branch 'art-scalefactor'
Fix confusion between different kinds of coordinates in wxAUI code,
restoring correct behaviour in high DPI on all platforms.

See #2620.

Closes #19331.
2022-01-13 17:51:00 +00:00
Vadim Zeitlin
03cf1f4359 Remove wxHAS_BITMAP_SCALE_FACTOR
Now wxMSW also stores the scale factor, even if it doesn't use it in its
GetScaledXXX(), so it doesn't seem useful to have this symbol for
distinguishing the platforms with and without bitmap scale factor
support, when we can just use wxHAS_DPI_INDEPENDENT_PIXELS instead in
the only place where this was used.

And as this symbol was added quite recently, in 2c1f4c002d (Add
wxBitmap::SetScaleFactor(), 2021-10-23), we can hopefully just remove it
without breaking any existing code, if we do it right now.
2022-01-13 17:34:49 +00:00
Vadim Zeitlin
2f0bce2979 Replace old Trac links with GitHub ones
Also update a couple of links to SF.
2022-01-13 16:52:58 +01:00
Vadim Zeitlin
b8f69d2167 Enable test for wxEVT_SHOW for non-MSW platforms too
This test does pass with wxGTK, so run it there.
2022-01-11 02:36:46 +01:00
Vadim Zeitlin
b4ff385039 Revert addition of MSW-only test for notebook pages wxEVT_SHOW
This doesn't work in wxGTK and it doesn't seem useful to have a MSW-only
test for this, finally.
2022-01-11 02:10:36 +01:00
Dummy
006fd1a511 Fix sending show events when hiding frozen windows in wxMSW
Send these events ourselves because MSW itself doesn't generate them for
frozen windows. This makes wxMSW more consistent with the other ports.

Add unit tests to verify that the behaviour is really as expected for
both normal and frozen windows, at least under MSW -- under GTK these
events are not sent at all for the notebook pages.

Closes #19216.
2022-01-08 22:14:04 +01:00
PB
0f8ab824a3 Fix using const char* and wxString in ternary operator
Using a const char* and a wxString in the two branches of the ternary
operator resulted in compile-time errors since the result type of the
conditional expression was ambiguous, so add explicit conversions to fix
it.

Closes https://github.com/wxWidgets/wxWidgets/pull/2634

See #19355.
2022-01-03 21:20:23 +01:00
Vadim Zeitlin
559ea66e55 Use DPI aware manifests for MSVS 2022 too 2021-12-18 13:22:59 +01:00
Vadim Zeitlin
e4ff06ebdd Also remove mentions of amd64_dpi_aware_pmv2.manifest from the manually maintained MSVS projects 2021-12-17 22:00:42 +01:00
Vadim Zeitlin
5d6b2f6704 Rebake after parent commit changes 2021-12-17 21:29:49 +01:00
Vadim Zeitlin
9aaadab7d6 Check for most clang warnings in our headers in the test suite
Make allheaders unit test also enable -Wall, -Wextra and -Wpedantic for
clang to detect any warnings it might give in wx headers.

Don't use -Weverything because there are just too many warnings we'd
need to disable then.
2021-12-15 17:50:55 +01:00
Vadim Zeitlin
d1b5fd27aa Enable long path normalization test by default
It seems that the default value of NtfsDisable8dot3NameCreation registry
value is 2, and not 0, since a very long time (at least Windows 7), so
the wxPATH_NORM_LONG test was never actually executed.

Change the check guarding it to check if the value of the key is
different from 1 instead of checking that it is 0, as the test can still
succeed on the systems where this is the case.

Of course, it can also fail, if short names are disabled for the current
volume, but let's see if this is a problem in practice before doing
something more complicated to deal with this case.
2021-12-10 17:27:06 +01:00
Vadim Zeitlin
b247a1ee70 Use testdata.conf for the wxPATH_NORM_LONG test
This file already exists in the test directory, as it's used by another
test, so just use it instead of relying on the existing of mkinstalldirs
in the parent directory, which is not guaranteed as CMake build runs the
tests from a different directory, which is not the immediate child of
the top source directory.
2021-12-10 17:27:02 +01:00
Vadim Zeitlin
1e683c1401 Rename testdata.fc to testdata.conf
No real changes, just use a more clear and longer (which will be
important for the next commit) name for a test file.

Remove the non-existing samples/console/testdata.gc from make_dist.mk
(there are other non-existing files still referenced there).
2021-12-10 17:26:49 +01:00
Simon Stone
0fc936ca41 Add wxIntegerValidatorctor ctor taking minimum and maximum value
Using this ctor is more convenient than using the default ctor and then
calling SetMin() and SetMax().

Document the new ctor and add tests showing that minimum and maximum
values are actually respected.

Closes https://github.com/wxWidgets/wxWidgets/pull/2610
2021-12-09 19:55:44 +01:00
Tobias Taschner
bbca67df67 Implement wxFSVolume for macOS
Implement with NSFileManager and NSURL to provide basic functionality
like on MSW. Icons are not implemented for macOS.
2021-12-01 23:35:19 +01:00
Vadim Zeitlin
8adfaa37f7 Add wxBitmapBundle::FromSVGFile() helper
This is just a trivial wrapper for wxBitmapBundle::FromSVG(), but it can
still be convenient to have.
2021-11-29 12:55:22 +00:00
Vadim Zeitlin
5efcaf4e59 Fix copying testdata.fc file to the tests build directory
This file was listed in test.bkl but wasn't actually copied because the
value of <files> was overwritten by another <files> just below ever
since the changes of 21fe35aff7 (add wxImage test units to test loading
from both seekable and non-seekable streams, 2009-06-01).

Fix this by splitting this wx-data into 2 different ones, to avoid this
conflict.
2021-11-28 22:16:12 +01:00
Artur Wieczorek
fc6bfbc0bf Add tests of clipping regions with wxDC with RTL layout enabled 2021-11-28 17:05:34 +01:00
Paul Cornett
b04c1ace47 Avoid integer overflow when computing image data size in wxImage::Create()
See #19326

Co-Authored-By: David Costanzo <david_costanzo@yahoo.com>
2021-11-27 17:14:28 -08:00
Vadim Zeitlin
7ba71ecaa2 Merge branch 'size-div-double'
Add operator/(wxSize, double) and cleanup some wxSize and related tests.

See https://github.com/wxWidgets/wxWidgets/pull/2593
2021-11-25 15:16:53 +01:00
Simon Rozman
e3535d6481 Mark MSVS *.vcxproj.filters files as using CR LF as well
For consistency with *.vcxproj and *.sln and for making
check_mixed_eol.sh happy.

Signed-off-by: Simon Rozman <simon@rozman.si>
2021-11-24 12:13:12 +01:00
Vadim Zeitlin
2bbe126dca Add operator/(wxSize, double)
For some reason, while both operator*(wxSize, double) and
wxSize::operator/=(double) existed, this one did not, which was
unexpected, so add it too.
2021-11-20 22:06:28 +01:00
Vadim Zeitlin
9941531efc Simplify wxSize unit test further by comparing wxSizes directly
This is shorter and more clear than comparing width and height
independently and results in just as informative messages in case of
test failure if asserthelper.h is included.
2021-11-20 22:01:31 +01:00
Vadim Zeitlin
a18e00379e Get rid of CppUnit boilerplate in wxPoint and wxRealPoint tests
Similar to the previous commit, this doesn't really change anything, but
simplifies things.
2021-11-20 21:57:35 +01:00
Vadim Zeitlin
227b5dba0a Get rid of CppUnit boilerplate in wxSize unit test
No real changes.
2021-11-20 21:52:59 +01:00