Commit Graph

71487 Commits

Author SHA1 Message Date
PB
f8dda6db65 Do not use calendar.rc for calendar sample in CMake
The file was removed in  16f2c7bb89 (Remove unused samples resource
files, 2021-10-20) merged as part of 3d5664cabe (Merge branch
'samples-dpi-v2-aware', 2021-10-25).

Closes https://github.com/wxWidgets/wxWidgets/pull/2565
2021-10-26 19:40:18 +02:00
Vadim Zeitlin
8d14270636 Merge branches 'statbmp-bundle', 'upscale-only-bitmap' and 'bitmap-from-icon'
Fixes for wxBitmapBundle behaviour and use it in wxStaticBitmap too now.

See https://github.com/wxWidgets/wxWidgets/pull/2560,
    https://github.com/wxWidgets/wxWidgets/pull/2566,
    https://github.com/wxWidgets/wxWidgets/pull/2567
2021-10-26 19:38:21 +02:00
Vadim Zeitlin
04828b7225 Update wxStaticBitmap in wxMSW on DPI change
Use the appropriately sized bitmap when the resolution changes.
2021-10-26 00:11:57 +02:00
Vadim Zeitlin
0a91a2f40b Use wxBitmap::Rescale() in wxGenericStaticBitmap code
No real changes, just reuse the existing function instead of redoing it
one more time.
2021-10-26 00:11:57 +02:00
Vadim Zeitlin
3abec9254f Take wxBitmapBundle in wxStaticBitmap::SetBitmap()
This allows using higher resolution bitmaps when using high DPI
automatically in this control too.
2021-10-26 00:11:57 +02:00
Vadim Zeitlin
da73be0d77 Upscale the biggest bitmap in the bundle if it's too small
The changes of b20552116c (Allow wxBitmapBundle to specify its preferred
bitmap size, 2021-10-19) resulted in never rescaling the bitmaps in
standard size in high DPI at all, which isn't the right thing to do: by
default, i.e. if just a single bitmap is specified, we should scale it
up as necessary in order to show the UI elements in the correct sizes.
2021-10-26 00:04:22 +02:00
Vadim Zeitlin
41b1ba3c9e Replace many identical wxBitmap::CopyFromIcon() with a single one
Define CopyFromIcon() directly in wxBitmapBase for the non-MSW ports, as
it was implemented exactly in the same way in all ports using this class
anyhow.

This means this function is not virtual any longer, but this shouldn't
be a problem as it was never supposed to be overridden in application
code and this couldn't be done with wxMSW, where it never was virtual in
the first place, anyhow.

No real changes, just a simplification.
2021-10-25 23:36:45 +02:00
Vadim Zeitlin
568411347b Make wxOSX wxBitmap::CopyFromIcon() work as in the other ports
Just use the same object, as wxIcon is the same thing as wxBitmap
anyhow, instead of re-creating another wxBitmap which can be subtly
different from the original one.

Notably, converting an icon with default scale factor of 1 to bitmap
when using a high DPI display resulted in a bitmap with the same
physical size but scale factor of 2, as wxOSXGetImageScaleFactor()
returned 2 in this case, i.e. changed the logical bitmap size.

This couldn't be anything other than a bug, so fix this and, at the same
time, simplify the code and make it consistent with the other ports.
2021-10-25 23:36:45 +02:00
Vadim Zeitlin
9ffa5cf4f0 Use 16x16 default size for wxStaticBitmap in wxMotif too
Nobody cares about Motif, but still use the same default size there as
under the other platforms.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
0f9cb0fce1 Refresh wxStaticBitmap and update its size in wxUniv SetBitmap()
Make wxUniv behave consistently with the other ports.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
dc1c2c91b3 Fix setting size of wxStaticBitmap in wxOSX too
This is the same change as was done in the previous commit for
wxGenericStaticBitmap, see that commit message for more details.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
eba93fb5e7 Fix setting size of wxGenericStaticBitmap
We must call SetInitialSize() in Create() in order to take the size
argument passed to ctor/Create() into account -- it was completely
ignored previously.

But calling SetBitmap() must not change the initial size, as it can also
be done later, so just change the current size there instead (which is
consistent with wxMSW version and original behaviour, so keep it like
this, even though it's not totally clear if all ports do it).

Remove the now unused wxGenericStaticBitmap::GetBitmapSize().
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
b403624f22 Add common implementations of wxStaticBitmap icon methods
Instead of defining them, slightly differently, in all the non-MSW
ports, define them once in wxStaticBitmapBase.

No real changes, this is just a simplification.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
5773a8736c Define wxICON_IS_BITMAP when this is indeed the case
This symbol is useful for testing if wxIcon can be just converted to
wxBitmap, as is the case in all ports except for wxMSW currently.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
e126ddc11c Use more suitable type for MSWReplaceImageHandle() parameter
It's a handle, so make it a WXHANDLE rather than WXLPARAM and avoid
casting the handle when calling it (there is still a cast when calling
::SendMessage() inside this function, but this is unavoidable and this
cast was already there anyhow).

No real changes.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
c1abbe6473 Refactor wxMSW wxStaticBitmap to separate bitmaps and icons
Use different members for storing wxBitmap and wxIcon instead of using a
single pointer for storing a heap-allocated copy of either of them
because this is simpler, more efficient due to avoiding unnecessary
conversions and RTTI, and will be simpler to generalize to using
wxBitmapBundle instead of wxBitmap in the upcoming commits.

As a side effect, don't assert in GetIcon() or GetBitmap() if there is
no valid icon or bitmap, as this is inconsistent with the other ports
and wasn't even consistent between these functions in wxMSW itself.

There should be no other changes in behaviour.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
373653e4e5 Remove unnecessary wxStaticBitmap::DeleteCurrentHandleIfNeeded()
This function was used exactly once and it's simpler and more clear to
just inline it into Free() where it was called.

No real changes, this is just a small simplification.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
1d6e3e3693 Move wxStaticBitmapBase methods to the appropriate file
For some reason, wxStaticBitmapBase methods were defined in the wrong
ctrlcmn.cpp file rather than statbmpcmn.cpp. Just move them there to
avoid confusion.

No real changes.

This commit is best viewed with --color-moved git option.
2021-10-25 13:40:18 +01:00
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