71592 Commits

Author SHA1 Message Date
Vadim Zeitlin
9326aa3b6c Add wxBitmapBundle::GetBitmapFor() helper
This can be used to get the bitmap of the size appropriate for the DPI
scaling used for the given window.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
e5a7e9ccbd Take const wxWindow in wxBitmapBundle::GetPreferredSizeFor()
This function should be usable in const methods of wxWindow-derived
classes too.
2021-10-25 12:21:15 +01:00
Vadim Zeitlin
c119e84370 Merge branch 'bundle-scaled-bitmaps'
Make wxBitmapBundle compatible with bitmap scale factor > 1, both when
converting the latter to the former and when retrieving bitmaps from the
bundle.

See https://github.com/wxWidgets/wxWidgets/pull/2564
2021-10-25 13:18:47 +02:00
Vadim Zeitlin
33a56f74d5 Merge branch 'check-sizer-window-parent'
Check that all windows in a sizer use associated window as parent.

See https://github.com/wxWidgets/wxWidgets/pull/2559
2021-10-25 13:18:07 +02:00
Vadim Zeitlin
3d5664cabe Merge branch 'samples-dpi-v2-aware'
Build all samples, not just one of them, as per-monitor DPI v2 programs
under MSW and minor cleanup of the samples .rc files.

See https://github.com/wxWidgets/wxWidgets/pull/2557
2021-10-25 13:16:55 +02:00
Vadim Zeitlin
7b4257b9cd Respect the scale of the bitmap converted to wxBitmapBundle
Use the scaled size, different from the default size, when constructing
wxBitmapBundle from an existing wxBitmap to keep the existing code using
scaled bitmaps working.

Add a unit test checking that this now works as expected under the
platforms where scale factor is used.
2021-10-24 23:15:04 +02:00
Vadim Zeitlin
30aad30a0a Don't create unnecessary vector in wxBitmapBundle::FromBitmap()
Just use wxBitmapBundle ctor instead, this is both simpler and more
efficient.

No real changes.
2021-10-24 23:09:31 +02:00
Vadim Zeitlin
8f74ac7def Adjust scale of bitmaps returned by wxBitmapBundle::GetBitmap()
Bitmaps returned from this function must have the appropriate scale
factor, e.g. 2 in standard high DPI case, in order to be drawn at
correct size in the ports where logical pixels are different from the
physical ones, such as wxOSX and wxGTK3.

Notably, this allows wxGenericStaticBitmap to work correctly in high DPI
in these ports too.

This also allows to undo some of the changes done in 399b0ff9ae (Use
wxBitmapBundle instead of bitmap scale factor in wxGtkImage, 2021-10-16)
to wxGtkImage code and keep using the same code that had been used
before.
2021-10-24 23:04:45 +02:00
Vadim Zeitlin
1056ba19af Move scale factor-related wxBitmap functions out of line
This will make it possible to change them later without breaking ABI,
which is probably worth paying the price of a function call (assuming
the compiler could de-virtualize this call and inline it before).

No real changes.
2021-10-24 23:04:45 +02:00
Vadim Zeitlin
2c1f4c002d Add wxBitmap::SetScaleFactor()
We need to be able to change the scale factor of the bitmaps returned by
wxBitmapBundle::GetBitmap(), so add a function allowing to do this.

Also add wxHAS_BITMAP_SCALE_FACTOR allowing to check whether this
function actually does something non-trivial and explain in the docs
that GetScaleFactor() always returns 1 on the platforms where this
symbol is not defined.
2021-10-24 19:04:51 +02:00
Vadim Zeitlin
c8f76dea8e Simplify wxBitmap::GetScaledXXX() in wxMSW
The scale factor is always 1 in this port, so don't bother dividing or
rounding by it.
2021-10-23 21:38:32 +02:00
Vadim Zeitlin
b258d02be3 Document wxBitmap::GetScaleFactor() and related methods
These methods were added 8+ years ago but never documented for some
reason, finally do it now.
2021-10-23 21:38:32 +02:00
Vadim Zeitlin
691a11989e Move wxBitmap::ConvertToDisabled() to respect alphabetic order
No real changes, just keep the functions sorted as they're clearly
intended to be here.

This commit is best viewed with --color-moved git option.
2021-10-23 21:38:32 +02:00
Vadim Zeitlin
1fb7b13812 Fix typo in "class" in wxUSE_STOPWATCH comment
Closes https://github.com/wxWidgets/wxWidgets/pull/2556
2021-10-22 01:42:53 +02:00
Vadim Zeitlin
fb93d7f101 Fix wrong class name in wxAuiTabContainer comment
No real changes, just fix a typo in a comment.

See https://github.com/wxWidgets/wxWidgets/pull/2556
2021-10-22 01:41:21 +02:00
Vadim Zeitlin
4d5bdfeb77 Fix shadow warning in wxHtmlHelpDialog ctor declaration
This is similar to 858248d055 (Fix declaration shadow warning in
wxHtmlHelpFrame, 2021-04-21) and fixes another -Wshadow from gcc 11 by
getting rid of the last parameter confusingly named as its type.

See #19153.
2021-10-22 01:37:20 +02:00
Vadim Zeitlin
b88f472291 Relax the sizer parent check to allow for null parent too
Normally non-toplevel windows must have non-null parents, as creating
them with null parent would fail, but our own wxTabFrame used in AUI is
an example of a window which can have null parent because it's actually
never created at all. This does look like a pretty bad hack, but it's
very unlikely to happen accidentally, so relax the assertion check added
in the previous commit to allow for it.
2021-10-21 15:33:49 +01:00
Stefan Csomor
98f056daf5 using GetPreferredSizeAtScale when assembling native NSImage from a bitmap bundle 2021-10-21 15:30:32 +02:00
Stefan Csomor
6f2a1fa55d adding bitmap bundle files to macOS xcodeproj 2021-10-21 15:29:46 +02:00
Jouk
5449136210 Fix inheritance of wxBitmapHelpers::Rescale as is needed on OpenVMS 2021-10-21 11:44:11 +02:00
Jouk
8b9a5c059e Add compilation of bmpbndl.cpp on OpenVMS 2021-10-21 08:07:35 +02:00
Vadim Zeitlin
62c3d921b2 Check that all windows in a sizer use associated window as parent
Using a wrong parent for the window managed by the sizer of the given
window or, alternatively, inserting a window into a wrong sizer, seems
to be a common mistake when creating sizer-based layouts and results in
hard to understand visual problems (as typically the window with the
mismatched parent/sizer just remains stuck at some wrong location).

So try to help detect it sooner and provide more information about the
problem by checking the parent of the window either when it is added to
the sizer -- if we already know which sizer the window is associated
with at that moment -- or when associating the sizer with the window
later.
2021-10-21 00:26:28 +01:00
Vadim Zeitlin
a809b6f058 Merge branch 'add-dump-window'
Add wxDumpWindow() function.

See https://github.com/wxWidgets/wxWidgets/pull/2558
2021-10-21 00:24:47 +01:00
Stefan Csomor
4eb4c1706f Remove NSImage from public API of wxBitmapBundleImpl
Hide wxOSX implementation details by storing NSImage associated with the
bundle in a separate global map instead of making it part of
wxBitmapBundleImpl itself.

See https://github.com/wxWidgets/wxWidgets/pull/2555
2021-10-21 01:21:46 +02:00
Vadim Zeitlin
ae2d8c34f9 Use wxDumpWindow() in trace messages in wxWindow itself
Instead of just showing the class name and the window name, show the
result of wxDumpWindow() which is similar, but more informative.
2021-10-20 23:35:37 +01:00
Vadim Zeitlin
9e5c8eef24 Make wxDumpWindow() public and available in wxMSW too
This function was defined in wxGTK and wxOSX, but not in wxMSW or the
other ports, but it can be useful there too, so make it public and
define it in common code.
2021-10-20 23:35:37 +01:00
Vadim Zeitlin
85503d1dcd Get rid of CppUnit boilerplate in MiscGUIFuncsTestCase
Simplify code by not defining an unnecessary test case class and using
CATCH macros directly.

No real changes.
2021-10-20 23:35:37 +01:00
Vadim Zeitlin
87b394a555 Use wxScopedPtr in MiscGUIFuncsTestCase for automatic cleanup
Replace manual calls to Destroy() to ensure that the objects created in
this test will be destroyed even if a check fails.
2021-10-20 23:35:37 +01:00
Vadim Zeitlin
5341bf5b60 Remove unnecessary win32-res tags from samples bakefiles
Don't specify sample.rc as the resource file for the samples, it is used
by default anyhow, so this is unnecessary.
2021-10-20 17:47:47 +02:00
Vadim Zeitlin
16f2c7bb89 Remove unused samples resource files
These resource files didn't appear in the .bkl ones and so were not used
at all and were not worth being used anyhow, as they didn't differ
significantly from sample.rc.
2021-10-20 16:34:38 +01:00
Vadim Zeitlin
aa2780b472 Set wxUSE_DPI_AWARE_MANIFEST=2 for all samples, not just toolbar
This is required for high resolution bitmaps support and it will be
needed in other samples too, so use it for all of them.

This probably will result in some problems due to remaining bugs with
high DPI support, but it should make them more noticeable and so should
help with finding and fixing them.
2021-10-20 16:19:41 +01:00
Vadim Zeitlin
ec975c70cc Merge branch 'bmp-bundle-pref-size'
Allow wxBitmapBundle specify its preferred size and use it in wxMSW.

See https://github.com/wxWidgets/wxWidgets/pull/2554
2021-10-20 16:17:51 +01:00
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