Commit Graph

71487 Commits

Author SHA1 Message Date
David Costanzo
07670667d9 Fix gcc 11 -Wzero-as-null-pointer-constant in wxMSW wxImageList
This warning was introduced by the recent 999340f288 (Check that
wxImageList::Create() is not called more than once, 2021-10-17), fix it
by using NULL for HIMAGELIST which is a pointer internally.

Closes #19298.
2021-10-20 15:23:52 +02:00
Vadim Zeitlin
ae5bc69d9f Use preferred bundle bitmaps size in wxMSW wxToolBar
This avoids resizing the bitmaps in some common use cases and is similar
to the previous commit doing the same thing for wxButton.

Notice that this introduces a slight change of behaviour, as
AdjustToolBitmapSize() now can reduce, as well as increase, the size of
bitmaps used, which is necessary in order to shrink the bitmaps when
moving from a higher DPI resolution display to a lower-resolution one.
This is not 100% backwards-compatible, but should only have not very bad
cosmetic effects.
2021-10-19 02:20:26 +01:00
Vadim Zeitlin
1f8af4d5a2 Use preferred size for the button bitmaps in wxMSW
Avoid scaling the bitmaps by using the preferred size for them.

This results in significantly better appearance without any real
drawbacks in practice at 125% and 175% DPI scaling in the common case
when just a single and double-sized bitmaps are available, and still
seems to be acceptable at 150% scaling in this case.
2021-10-19 02:20:26 +01:00
Vadim Zeitlin
b20552116c Allow wxBitmapBundle to specify its preferred bitmap size
Using bitmaps of preferred size avoids scaling and results in much
better appearance, so add methods allowing querying the bundle about the
bitmaps it supports and implement them in the various implementations.

This is not actually used anywhere yet, but will be soon.
2021-10-19 02:20:26 +01:00
Vadim Zeitlin
1cda648206 Merge branch 'button-bmp-bundle'
Add support for wxBitmapBundle to wxButton and related classes to make
it possible to use high resolution images in them in high DPI.

See https://github.com/wxWidgets/wxWidgets/pull/2552
2021-10-19 03:09:03 +02:00
Vadim Zeitlin
7dbbe60d82 Give better error message if Nano SVG is unavailable, if possible
Getting errors due to "missing" Nano SVG headers can be confusing, as
it's not immediately clear why are they missing, so try to make things
more explicit by using __has_include(), if available, to test for the
header before including it and giving a better error message if it
fails.

It still won't help people not using C++17 or those not reading error
messages, but should be better than nothing.
2021-10-19 02:33:39 +02:00
Vadim Zeitlin
5bb6046ca9 Document remaining problems when changing DPI of wxMSW toolbar
Unfortunately even using CallAfter() doesn't allow to completely repair
the toolbar display after moving it to a display with a different
fractional scaling, e.g. from 125% to 175%. There are still some minor
but visible display artefacts in this case that we can't get rid of even
by resizing the window containing the toolbar programmatically -- even
though doing it interactively does help.
2021-10-18 11:50:10 +02:00
Vadim Zeitlin
04a8e0e5bd Use bitmap bundle rather than scaled bitmap size in wxToolBar
Get the minimum size needed for the bitmaps from wxBitmapBundle.
2021-10-18 11:50:10 +02:00
Vadim Zeitlin
62b6539eea Select the button size appropriate for the current DPI initially
Don't just update the bitmaps size when we receive the DPI changed
event, but also use size appropriate for the current DPI initially.
2021-10-18 11:50:10 +02:00
Vadim Zeitlin
2a0719818a Update bitmap shown by the buttons in wxMSW on DPI change
Recreate wxImageList used for the bitmaps internally with the bitmaps of
the size corresponding to the new DPI.

This commit is best viewed with --color-moved git option.
2021-10-18 11:50:10 +02:00
Vadim Zeitlin
4e5d2d97e2 Allow using wxBitmapBundle for wxButton bitmaps
Take wxBitmapBundle in wxButton::SetBitmapLabel() and related functions
in order to be able to associate several bitmaps to be used in different
resolutions with the button, instead of just a single bitmap.
2021-10-18 11:50:10 +02:00
Vadim Zeitlin
2910327ef3 Don't crash in wxOSXGetImageFromBundle() if the bundle is invalid
Just return a null image instead, as this function can be called when we
don't have any bitmaps too -- as it happens in the Button::Bitmap unit
test, for example.
2021-10-18 11:50:10 +02:00
Vadim Zeitlin
5965bc1910 Remove unused parts of wxMSW wxBitmapButton implementation
Nothing here, including the event table for this class using
non-existing wxBitmapButton::OnSysColourChanged (which is just the same
as wxWindow::OnSysColourChanged, in fact), was needed any longer ever
since the changes of a6fd73d33a (implement wxBitmapButton as just a
wrapper for wxButton under MSW, 2009-06-15), so simply remove all the
unused stuff.
2021-10-18 11:50:10 +02:00
Vadim Zeitlin
630e6b898f Add conversion ctor from wxIcon to wxBitmapBundle too
Existing code may call functions taking wxBitmap with wxIcon, due to an
existing conversion from wxIcon to wxBitmap, so we need to provide a
similar conversion to wxBitmapBundle for compatibility.
2021-10-18 11:50:10 +02:00
Vadim Zeitlin
d4bc1daf19 Revert "Remove unused code in wxGTK wxAnyButton"
This reverts commit 4e366b2cfb as it the
code removed by it is still needed and removing it results in unit test
failures in wxBitmapToggleButton unit tests with both GTK 2 and 3.

See https://github.com/wxWidgets/wxWidgets/pull/2548
2021-10-17 23:56:28 +02:00
Vadim Zeitlin
411cad6cd9 Merge branch 'gtk-always-use-wxgtkimage'
Ensure all buttons with images have associated wxGtkImage as this is
required for showing high resolution bitmaps in them in high DPI.

See https://github.com/wxWidgets/wxWidgets/pull/2548
2021-10-17 23:27:49 +02:00
Vadim Zeitlin
4e366b2cfb Remove unused code in wxGTK wxAnyButton
The GtkImage can always be retrieved using the appropriate GTK function,
there is no need to get the button child directly any longer.
2021-10-17 23:25:45 +02:00
Vadim Zeitlin
def2691fd2 Merge branch 'gtk-image-bundle'
Use wxBitmapBundle in wxGtkImage and select the appropriately-sized
bitmaps depending on DPI in wxGTK wxToolBar.

See https://github.com/wxWidgets/wxWidgets/pull/2547
2021-10-17 23:19:00 +02:00
Vadim Zeitlin
efb82320c6 Merge branch 'imaglist-destroy'
Add wxImageList::Destroy() and other minor improvements to this class.

See https://github.com/wxWidgets/wxWidgets/pull/2551
2021-10-17 19:38:54 +02:00
Vadim Zeitlin
271926fde0 Fix description of wxUSE_SPELLCHECK option in configure and CMake
Don't say that it's only for MSW and GTK 3, as it's also available under
Mac. Also don't use "spellchecking" non-word in the description of a
spell-checking option.

No real changes.
2021-10-17 19:36:56 +02:00
Vadim Zeitlin
da79145101 Merge branch 'cmake-spellcheck' of https://github.com/MaartenBent/wxWidgets
Add wxUSE_SPELLCHECK option to CMake build too.

See https://github.com/wxWidgets/wxWidgets/pull/2550
2021-10-17 19:35:08 +02:00
Vadim Zeitlin
999340f288 Check that wxImageList::Create() is not called more than once
Or at least not until Destroy() is called.
2021-10-17 16:19:19 +02:00
Vadim Zeitlin
a66e5cdb38 Add wxImageList::Destroy()
This will be useful in wxMSW implementation and seems to make sense to
have as a public function, as long as we have Create().
2021-10-17 16:19:19 +02:00
Vadim Zeitlin
6b3fd04e24 Initialize wxGenericImageList members in default ctor
Don't leave m_useMask and m_scaleFactor uninitialized -- even if this
probably doesn't matter, call Create() to make sure they have
well-defined values for the default-constructed objects.
2021-10-17 16:19:19 +02:00
Maarten Bent
d2642b4c07 CMake: Enable wxUSE_SPELLCHECK
Find gspell-1 when using GTK3. Also need to find enchant.h.
2021-10-17 14:55:46 +02:00
Maarten Bent
fef2d7d05b Fix wxListCtrl checkbox style when reapplying extended styles
Fixes #19263
2021-10-17 13:41:56 +02:00
Maarten Bent
b102afc316 CMake: Don't include generator expression in wxPLATFORM_LIB_DIR
So wxPLATFORM_LIB_DIR can be used in locations where generator expressions are not supported.
2021-10-17 11:52:30 +02:00
Maarten Bent
6d6567d41c CMake: remove duplicate install for builtin libraries 2021-10-17 11:50:34 +02:00
Vadim Zeitlin
10b7659acd Ensure all buttons with images have associated wxGtkImage
Replace GtkImage with wxGtkImage if necessary, to ensure that we can
always use our own class, to profit from its support for high DPI
images, even for the buttons using stock IDs and so creating GtkImage by
default.

See #19288.
2021-10-17 00:58:26 +02:00
Vadim Zeitlin
3333356624 Really support wxBitmapBundle in wxGTK wxToolBar
Use the appropriately sized bitmap instead of always using the (scaled
version of the) default one, as was the case since 97f6c85d9b (Add first
version of wxBitmapBundle and use it in wxToolBar, 2021-09-24).

With this change, toolbar bitmaps work correctly in 100% and 200% DPI
scaling.
2021-10-16 20:05:51 +02:00
Vadim Zeitlin
0f5c2851f4 Add wxToolBarTool::Get{Normal,Disabled}BitmapBundle() accessors
The existing variants returning wxBitmap are insufficient for non-MSW
ports where the toolbar bitmap size is unavailable otherwise, as
GetToolBitmapSize() value doesn't really correspond to it (which is a
problem on its own, but there is not much that can be done about it by
now).

Having these functions allows to retrieve the actually used bitmap size
by using wxBitmapBundle::GetDefaultSize().
2021-10-16 20:01:28 +02:00
Vadim Zeitlin
399b0ff9ae Use wxBitmapBundle instead of bitmap scale factor in wxGtkImage
Minimal changes to the code to allow using bigger bitmaps from
wxBitmapBundle in high DPI instead of having to create individual
bitmaps with scale factor greater than 1.

Notice that this is not actually used anywhere in wxGTK yet, but will be
soon.
2021-10-16 19:58:55 +02:00
Vadim Zeitlin
77e3983091 Create disabled bitmap in BitmapProviderDefault on demand
There is no need to always do it in advance when we might never actually
need it.
2021-10-16 17:46:20 +02:00
Vadim Zeitlin
8f1be368e9 Add some comments to wxGtkImage
Document which pointers can, and can't, be null and when exactly is the
stored bitmap valid, as this is far from being immediately obvious.

No real changes.
2021-10-16 17:01:48 +02:00
Vadim Zeitlin
eb54c65e24 Separate GTK 2/3 version of BitmapProviderDefault
No real changes, just move the trivial GTK 2 stab out of the way.
2021-10-16 16:56:31 +02:00
Vadim Zeitlin
fbb2ec85ef Install 32-bit version of xvfb in 32-bit wxMSW cross-build
libgl1:i386 conflicts with 64-bit version of xvfb in the latest Sid, so
try using 32-bit version of the latter.
2021-10-16 16:44:44 +02:00
Cătălin Răceanu
6fb64da922 Fix selection when wxOwnerDrawnComboBox contains identical items
Ensure that the drop-down selection is correct even if there are
multiple items with the same label in wxOwnerDrawnComboBox.

See https://github.com/wxWidgets/wxWidgets/pull/2544

Closes #19289.
2021-10-16 15:56:40 +02:00
Vadim Zeitlin
e8a15050d2 Add missing references to wxSize parameters in wxBitmapBundle
Pass wxSize by const reference instead of "const" value.

Note that passing wxSize by value might be not such a bad thing,
actually, but we use const reference for it everywhere else, so do it
here as well for consistency (and the original intention was to do it
like this, missing "&" was just a typo subsequently propagated through
copy-pasting).

No real changes.
2021-10-16 15:56:40 +02:00
Paul Cornett
e9bf514976 Fix creating wxButton using stock id with GTK
Broken by 85d63c3150 (Add a class derived from GtkImage to support HiDPI bitmaps, 2020-09-15)
See #19288
2021-10-13 22:37:11 -07:00
Vadim Zeitlin
700dd3e905 Merge branch 'cmake_glu' of https://github.com/swt2c/wxWidgets
Link with GLU when using EGL too in CMake build.

Also build all samples in the CMake CI builds.

See https://github.com/wxWidgets/wxWidgets/pull/2543
2021-10-12 00:39:54 +02:00
Scott Talbert
769e24bae0 cmake: build all samples under Linux CI 2021-10-11 13:03:15 -04:00
Scott Talbert
28f59e8900 cmake: also link with GLU when using EGL
Fixes #19282
2021-10-11 12:43:52 -04:00
Vadim Zeitlin
af1069374e Merge branch 'bitmap-bundle'
Add wxBitmapBundle and use it in wxToolBar.

See https://github.com/wxWidgets/wxWidgets/pull/2535
2021-10-05 18:58:18 +02:00
Vadim Zeitlin
fb4e188cea Add wxHAS_SVG feature test macro
This is more clear and future-proof than using wxHAS_RAW_BITMAP for
checking for SVG availability.
2021-10-05 16:12:01 +01:00
Vadim Zeitlin
0216654272 Make wxBitmapBundleImpl public and show how to use it
Show how a custom implementation of wxBitmapBundleImpl can be defined in
the toolbar sample.
2021-10-05 16:06:43 +01:00
Stefan Csomor
fe3e0c558e wxArtProvider with wxBitmapBundle 2021-10-05 16:06:43 +01:00
Vadim Zeitlin
ab619010bd Add FromSVG() overload taking const data
Passing non-const data is inconvenient and error-prone, as data can't be
used again after it was modified by Nano SVG, which resulted in the
button using SVG bitmap not working any longer in the toolbar sample
after recreating the toolbar.

So make it easier to do the right thing, while still keeping the
overload taking non-const data for the situations when avoiding an extra
copy is worth it.
2021-10-05 16:06:43 +01:00
Vadim Zeitlin
6783df71a7 Cache the last returned bitmap in wxBitmapBundleImplSVG
This seems to be enough to avoid inefficiencies and doesn't consume as
many resources as caching all bitmaps ever generated.
2021-10-05 16:06:43 +01:00
Vadim Zeitlin
ac02ae877f Add simple wxBitmapBundle::FromSVG() implementation using NanoSVG
Add nanosvg submodule and use it in the generic implementation of this
function.

This is incomplete yet and, notably, doesn't cache the rasterized
images, but already shows that using SVG images works (at least in the
toolbar sample).
2021-10-05 16:06:43 +01:00
Stefan Csomor
5ebd76156d adapting buttonbar 2021-10-05 16:06:43 +01:00