Commit Graph

72213 Commits

Author SHA1 Message Date
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
Paul Cornett
c3b232dcfd Fix a scrolling issue with GTK3
With overlay scrollbars disabled, it was not possible to move the scrollbar
slider all the way to the end, and there would be some flickering when trying
to do so. Fixed by always setting the preferred size to the virtual size, and
returning the proper value for GtkScrollable policy. GtkScrolledWindow uses
the child's preferred size as the virtual size, so the preferred size must
be set for the scrollbars to be managed correctly. Additionally, there was
some confusion during the initial GTK3 port over the difference between
GtkScrolledWindow policy and GtkScrollable policy, resulting in using the
minimum size rather than the natural size.
See #22093
2022-02-21 21:18:37 -08:00
Vadim Zeitlin
ce8bf736fa Allow using wxImage::Scale() for zooming in image sample
By default, continue to use wxDC::SetUserScale(), but allow also using
wxImage::Scale() with various parameters to compare how the results look
like.
2022-02-22 02:26:06 +00:00
Vadim Zeitlin
c227d10728 Add "Double zoom" command to the image sample image view window
Just a convenient way to go to 200% zoom instead of having to use "Zoom
in" command several times to get close to it.
2022-02-22 02:18:33 +00:00
Vadim Zeitlin
5d3a544db1 Decrease the margin used for wxBU_EXACTFIT in wxMSW
This should achieve the same result as de10f054c4 (Improve calculating
wxButton best size under wxMSW, 2021-04-08) but in a much simpler way.
2022-02-21 23:34:36 +00:00
Vadim Zeitlin
73e23a4fd2 Revert "Improve calculating wxButton best size under wxMSW"
This reverts commit de10f054c4 and a bunch
of commits improving it done since then:

6f888df474 (Restore button size calculation when not using manifest in wxMSW, 2021-04-24)
de10f054c4 (Improve calculating wxButton best size under wxMSW, 2021-04-08)
6f888df474 (Restore button size calculation when not using manifest in wxMSW, 2021-04-24)
75d508b6e6 (Fix regression in sizes of buttons with bitmaps in wxMSW, 2021-07-08)
051418ac00 (Fix recent wxMSW buttons with bitmaps appearance regression, 2021-08-26)
fbc6462375 (Fix a gcc warning introduced by the previous commit, 2021-08-26)

The reason for reverting is that using BCM_GETIDEALSIZE doesn't seem to
have any advantages compared to using our old code, as it doesn't take
the margins into account neither and we still have to add them ourselves
and so it's simpler to just always do it without using this message.
2022-02-21 23:28:30 +00:00
Vadim Zeitlin
4fbd0d650f Merge branch 'xrc-use-bmpbundle'
Use wxBitmapBundle in more XRC handlers and other minor XRC-related
improvements.

See #22144.
2022-02-21 23:09:57 +00:00
Vadim Zeitlin
45e43b4527 Stop using deprecated libtiff uintNN types
They are deprecated by libtiff in favour of C99 standard types, but
replace them with wxUintNN for now, as those are definitely available on
all platforms, while we support some platforms without C99 stdint.h
(notably ancient MSVC versions).
2022-02-20 18:09:18 +01:00
Vadim Zeitlin
652d37ea61 Add "pressed" and "current" wxBitmapButton XRC properties
New names are consistent with the names of the preferred SetBitmapXXX()
functions.

Document them and show using one of them in the sample.
2022-02-20 18:06:09 +01:00
Vadim Zeitlin
f4e3b69dd2 Use wxBitmapBundle in wxBitmapButtonXmlHandler
Allow specifying bundles and not just individual bitmaps in XRC for this
control.
2022-02-20 18:06:09 +01:00
Vadim Zeitlin
34facd225a Add wxXmlResourceHandler::GetBitmapBundle(wxXmlNode) overload
Do it for consistency with the existing GetBitmap() overload and also
because this can be useful when we need to test for the bitmap bundle
presence before using it.

Also document both the new overload and the original one, which was
mistakenly left undocumented when it was added.
2022-02-20 18:06:09 +01:00
Vadim Zeitlin
f077169c86 Refactor wxBitmapButtonXmlHandler before using wxBitmapBundle
This replaces 4 calls to GetBitmap() with a single one.

Note that we now use SetBitmapPressed() and SetBitmapCurrent(), which
take wxBitmapBundle, instead of deprecated SetBitmapSelected() and
SetBitmapFocus(), which do not.

We also search for the parameter node only once instead of doing it
twice in a row if it was found, so the new code is slightly more
efficient.
2022-02-20 18:06:09 +01:00
Vadim Zeitlin
38ad817163 Use GetBitmapBundle() whenever possible in XRC handlers
This allows specifying multiple bitmaps and/or SVG in the XRC for the
controls which support them.
2022-02-20 18:06:09 +01:00
Vadim Zeitlin
5fcea04d71 Take wxBitmapBundle in wxMenuItem::SetBitmap() in all ports
Update the remaining ports to take wxBitmapBundle rather than wxBitmap
as well to make their API consistent with the tier 1 ports -- even if
there is no actual support for choosing the resolution-appropriate
bitmap in them yet.
2022-02-20 18:06:09 +01:00
Lauri Nurmi
8b3e0acf75 Fix compilation on 64-bit OpenIndiana (SunOS)
src/unix/mediactrl.cpp failed to compile due to a precision-losing cast
(from 'gpointer' {aka 'void*'} to 'window_id_type' {aka 'unsigned int'}).

Tell pkg-config to use 64-bit configs if building for 64-bit on SunOS.

PKG_CONFIG_PATH is set to /usr/lib/64/pkgconfig in that case.

Documented at:
https://docs.oracle.com/cd/E37838_01/html/E66175/gplhi.html

Closes #22143.
2022-02-20 18:04:38 +01:00
Vadim Zeitlin
dec0c1b5b6 Don't return wxNullBitmap from XRC GetBitmapBundle()
Return an empty bundle directly instead of relying on conversion from
invalid bitmap.
2022-02-20 17:55:59 +01:00
Vadim Zeitlin
cc54b767d3 Define NIIF_USER if it's not defined too
This fixes compilation after the changes of 148f56085f (Define
NIIF_LARGE_ICON ourselves if it's not defined, 2022-02-19) for the
compilers using headers so old that they don't even define NIIF_USER
which exists since XP SP2 -- which includes MinGW 5.3 used for our
AppVeyor CI builds.
2022-02-20 17:06:43 +01:00
Vadim Zeitlin
5cc8e34dfb Fix completely broken code in the parent commit
This was accidentally committed without being tested, correct it now.

See #22138.
2022-02-19 23:13:40 +01:00
Vadim Zeitlin
6168e1625d Get the icon of requested size directly in X11 wxTaskBarIcon code
Instead of getting the bitmap of the default size and then possibly
rescaling it, get the icon of the correct size directly from the bitmap
bundle, which could yield better results (and at worst would do the same
thing as before, but with less code).

See #22138.
2022-02-19 21:50:57 +00:00
Vadim Zeitlin
148f56085f Define NIIF_LARGE_ICON ourselves if it's not defined
It should actually always be defined when using any of the currently
supported compilers, but define it ourselves just in case it isn't.

At least get rid of #ifdef checking for it in the code.

See #22138.
2022-02-19 21:47:16 +00:00
Alexander Koshelev
1278aae752 Use wxBitmapBundle in wxTaskBarIcon
Update the sample to use wxBitmapBundle too.

Closes #22138.
2022-02-19 21:44:27 +00:00
Vadim Zeitlin
66723b671f Ask whether X11 or Wayland is used in the bug report template
This is rather important, as many wxGTK bugs only manifest themselves
under one or the other, so ask to specify which one is used.
2022-02-19 22:36:50 +01:00
Vadim Zeitlin
66e8d7d1af Really fix fallback logic in wxArtProvider::GetBitmapBundle()
The code added to this function in ae7fa19ae3 (Improve fallback logic in
wxArtProvider::GetBitmap{,Bundle}(), 2022-01-31) didn't do anything at
all because of forgotten "break" after creating the bundle.

Also tweak this code slightly because it was not optimal: consider a
situation with 3 providers, the first one not having neither the bitmap
nor the bundle with the given ID, the second one having the bundle and
the third one having only the bitmap. With the old logic here (if it
were fixed to actually work), we would return wxBitmapBundleImplArt,
i.e. use wxArtProvider::GetBitmap() that would end up getting the bitmap
from the provider 2 bundle, i.e. do the right thing, but in a rather
indirect way.

With the new version we just return the bundle of the provider 2
directly. And we also avoid calling GetBitmap() more than once, which is
unnecessary as its return value doesn't change anyhow.
2022-02-19 17:12:33 +00:00
Paul Cornett
d1e59441a5 Support auto-scrolling when rubberbanding with generic wxOverlay
The backing bitmap needs to be updated when the window scrolls.
This works well on MSW and GTK2, but GTK3 with X11 still has
artifacts, because GtkScrolledWindow draws onto the client area.
2022-02-18 10:18:53 -08:00
Vadim Zeitlin
6efd3b4438 Fix -Wnoexcept from gcc 10.3 in STL build
Add more wxNOEXCEPT to hash-related classes to avoid warnings like

.../c++/bits/hashtable_policy.h: In instantiation of ‘std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = wxStringHash]’:
include/wx/clntdata.h:33:22:   recursively required from ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = wxString; _Tp = int (*)(void*, void*); _Hash = wxStringHash; _Pred = wxStringEqual; _Alloc = std::allocator<std::pair<const wxString, int (*)(void*, void*)> >]’
include/wx/clntdata.h:33:22:   required from here
.../c++/bits/hashtable_policy.h:1112:40: error: noexcept-expression evaluates to ‘false’ because of a call to ‘wxStringHash::wxStringHash()’ [-Werror=noexcept]
 1112 |       _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
      |                                        ^~~~~~~~~~~~~~~
In file included from include/wx/clntdata.h:16,
                 from include/wx/event.h:17,
                 from include/wx/evtloop.h:14,
                 from tests/testprec.h:5,
                 from tests/allheaders.cpp:410:
include/wx/hashmap.h:568:5: note: but ‘wxStringHash::wxStringHash()’ does not throw; perhaps it should be declared ‘noexcept’
  568 |     wxStringHash() {}
      |     ^~~~~~~~~~~~

that started to be given my MinGW x86-64 10.3.9 (although they were not
given by 10.2.1 version of the same compiler).

But adding wxNOEXCEPT here is more consistent with the changes of
7d74df9a03 (Add wxNOEXCEPT to the hash structs operator() declarations,
2020-08-30) and makes sense anyhow.
2022-02-18 17:02:10 +01:00
Mehmet Soyturk
8aa5c55f61 Change wxRichTextParagraph::m_cachedLines data type to vector
Now wxRichTextParagraph::m_cachedLines is stored as a wxVector instead
of a wxList.

See #2523, closes #2577.
2022-02-17 01:20:01 +01:00
Maarten Bent
151a9c5a63 Fix determining DPI info for wxDialog creation
WM_NCCREATE is not received for dialogs, so use a different message.
There seem to be no other messages that are always and only send on
creation, so use WM_NCCALCSIZE which seems always generated but not too
often.

Use m_activeDPI to determine if the DPI variables have been initialized
or not, instead of adding another variable for this.

Closes #22133.
2022-02-16 22:49:54 +00:00
Blake-Madden
4c5f39426e Add example of using wxString::ToCDouble() to the documentation
Add an example showing the meaning of the return value.

Also, a couple other small edits.

Closes #22129.
2022-02-16 22:42:58 +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
Paul Cornett
3aad506c5b Avoid some -Wfloat-conversion warnings 2022-02-13 18:11:55 -08:00
Paul Cornett
511c537362 Avoid -Wsign-compare warnings 2022-02-13 13:52:52 -08:00
Paul Cornett
eafa248117 Avoid mirroring text when wxDC axes are inverted with GTK3
This was already done for RTL, just extend it to inversion of either axis,
as this is the behavior of MSW and GTK2.
See #22113
2022-02-13 10:22:48 -08:00
Paul Cornett
a2076a3dd7 Build fix
This was supposed to be part of b62a1f8f1a (wxOverlay implementation for Wayland, 2022-02-13)
2022-02-13 09:13:57 -08:00
Paul Cornett
b62a1f8f1a wxOverlay implementation for Wayland 2022-02-13 09:03:36 -08:00
Vadim Zeitlin
574548e559 Fix -Wundef in wxAUI in PCH builds after the last change
We need to include wx/dcbuffer.h even when using PCH, it's not included
by wx/wx.h.
2022-02-13 02:10:59 +01:00
Vadim Zeitlin
d00aeb5813 Avoid using double buffering unnecessarily in wxAuiNotebook
We don't need to do double buffering on our own if the underlying
platform always does it anyhow, as macOS and GTK 3 do.
2022-02-13 01:43:18 +01:00
Vadim Zeitlin
0401fe21f7 Inherit scaling factor in wxBitmap ctor taking wxDC in wxGTK
This is the documented behaviour and not doing it breaks wxAuiTabCtrl
redrawing in high DPI, as it uses this ctor for double buffering.
2022-02-13 01:10:19 +01:00
Vadim Zeitlin
cd7b6f5507 Fix build after a merge conflict in parent commit
Rename CreateWithLogicalSize() to its new name.
2022-02-13 00:41:17 +01:00
Vadim Zeitlin
c08c539d18 Merge branch 'ak_wizard' of https://github.com/kosh543/wxWidgets
Use wxBitmapBundle in wxWizard.

See #22124.
2022-02-13 00:30:26 +01:00
Vadim Zeitlin
9dc34611c7 Merge branch 'ak_htmllistbox' of https://github.com/kosh543/wxWidgets
Use wxBitmapBundle in wxHtmlWindow.

See #22123.
2022-02-13 00:29:39 +01: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
Blake-Madden
ddf90dc3e0 Fix comment in example for banner window
Should say top edge, not left.

Closes #22122.
2022-02-11 18:48:03 +01:00
Vadim Zeitlin
9ab6a5244f Merge branch 'fsw-tests'
Try to do something about recurrent failures in wxFSW unit tests.

See #22119.
2022-02-11 18:47:23 +01:00
Vadim Zeitlin
4436a126dc Merge branch 'tbar-hidpi'
Fix toolbar resizing when moving to a lower DPI screen.

See #22117.
2022-02-11 18:46:49 +01:00
Vadim Zeitlin
00bd8c5576 Fix high DPI support for MDI windows
High DPI support didn't work for wxMDIParentFrame (and everything
inside it) because it was only enabled when InheritAttributes() from
wxNonOwnedWindow was called and this was only done in wxTopLevelWindow
but not in this class.

Fix this by removing the need to call InheritAttributes() at all and
just initializing m_perMonitorDPIaware when the window is created
automatically, to ensure that it can't be forgotten.

Co-Authored-By: Maarten Bent <MaartenBent@users.noreply.github.com>

Closes #22116.
2022-02-11 18:45:48 +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
6f5ac3c594 Fix CreateWithLogicalScale() to set correct scale in wxOSX
This got unfortunately broken by the changes of 94716fd801 (Add
wxBitmap::CreateWithLogicalSize(), 2022-01-22).
2022-02-11 17:15:51 +00:00