These functions return the colour components as unsigned int and so
promote to this type in arithmetic expressions, unlike unsigned char
returned by the existing accessors without the "Get" prefix, which
promotes to (signed) int and results in gcc 12 -Warith-conversion
warnings when the result is then converted to unsigned, as it happened
in our own wxColour::GetRGB() and GetRGBA() functions and would probably
happen in a lot of code outside wx, which could also be updated to use
the new functions instead of inserting casts.
Allow creating wxBitmapBitmap from SVG image stored in an application
resource on the platforms where wxHAS_IMAGE_RESOURCES is defined.
On Windows, load the bundle from a resource with RT_RCDATA type and on
MacOS from a file with an extension "svg" placed in the "Resources"
subdirectory of the application bundle.
Closes#22061.
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.
Add an event which can be handled by the application to determine the
splitter position when the splitter window itself is resized.
This can be used to e.g. preserve the splitter at the given proportion
of the window (and not just in the middle, as it would be already
possible by using gravity 0.5).
Closes#22035.
Extend the existing use of wxIcon in wxDataViewIconText,
wxDataViewCheckIconText, the corresponding renderers and
wxDataViewTreeCtrl to wxBitmapBundle.
As with the other classes, the existing setters have been preserved as
they remain almost entirely compatible with the existing code and the
return type of the existing getters was preserved, with new getters
being introduced for returning wxBitmapBundle only where they're really
required.
Update the sample to use wxBitmapBundle with its wxDataViewTreeCtrl.
This is just a convenient wrapper for GetBitmap() that will be useful in
the classes using wxIcon in their public API to preserve compatibility
after switching to using wxBitmapBundle instead of wxIcon internally.
Embed SVG data of the wx logo into the library itself to make it
available to all wx programs, including the samples. This is a bit
wasteful, but <12KiB is not really noticeable compared to the library
size.
This makes them available in wxIcon (and, less importantly, wxCursor)
too which is needed in order to use icons correctly in high DPI.
This is also more consistent with the other platforms, where wxIcon does
have these methods.
Document these methods in wxIcon now that they're available there under
all platforms and also document wxIcon::GetSize() which had been
available even before, but wasn't documented.
The new function has a more clear name than CreateScaled() it replaces
and uses a more useful parameter order, with the scale factor, which
must always be specified when using it, coming before, and not after,
the depth, which almost never needs to be specified and so can be left
at its default value in 99% of cases.
It seems better to round, rather than truncate, in ToPhys(), for the
same reasons as in wxBitmap::CreateScaled() (see parent commit), and
then ceil() mustn't be used in FromPhys() neither, as this would break
round-tripping via both functions.
So, finally, keep the behaviour simple and, hopefully, the least
surprising, by just rounding the result in both functions.
These functions have better names than the existing GetScaledXXX() ones,
so add them to be able to use them in the new code, even if we still
keep the old ones for compatibility.
This allows to retrieve the native CPU architecture name regardless of
the current process CPU architecture.
Common examples for CPU architecture differences are the following:
- Win32 process in x64 Windows (WoW)
- Win32 or x64 process on ARM64 Windows (WoW64)
- x86_64 process on ARM64 macOS (Rosetta 2)
Closes#22036.
Contrary to what the documentation stated, it was possible for the item
to be invalid, so update it to explain this and give an example of a
case in which this happens.
See #19182.
Provide these functions for consistency with the existing FromDIP() and
ToDIP().
We also can use ceil() (rather than round() used by wxSize operators) in
FromPhys() to ensure that we never truncate contents of a physical
bitmap, which allows to replace the existing wxStaticBitmap code with
just a call to this function.
This fixes the problem with wrong standard bitmaps size when using high
DPI for the main monitor with wxMSW, as GetScaledSize() used here since
31f2892200 (Avoid bitmap scaling in wxArtProvider::GetBitmapBundle(),
2021-12-17) was not the right function to use there.
Closes#19331.
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.
wxBitmap::GetScaledXXX() functions are useful for obtaining the
coordinates in logical pixels, so they should only divide by the scaling
factor on the platforms where logical pixels are actually different from
the physical ones, i.e. those using DPI-independent pixels.
This ensures that their behaviour under MSW remains unchanged even after
a1e4dca067 (Store scale factor in wxMSW bitmaps too, 2021-12-16), which
is the correct way to avoid breaking wxAUI (and other) drawing.
Using wxHAS_ prefix is more consistent with all the other similar
symbols, using wxHAVE_ was a mistake, that we have to pay for by
preserving the old name now (as it is actually already used in some code
outside of the library).
The fact that it's used also shows that it's better to document this
symbol, even if just to explain that it normally shouldn't be used, as
we can't really hide it anyhow.
Instead of immediately constructing the bitmap with the requested size,
possibly by downscaling a higher-resolution bitmap, and then potentially
having to upscale it if we actually need a bitmap of a bigger size, just
retrieve the bitmap in the actually needed size from wxArtProvider when
needed.
This makes bitmaps obtained from wxArtProvider::GetBitmapBundle() look
good, rather than fuzzy and ugly, in high DPI if they're actually
available in the appropriate size.
It is more convenient to be able to retrieve the request object (which
is needed at least for authentication) from the event than to have to
store it separately.
Closes https://github.com/wxWidgets/wxWidgets/pull/2644Closes#19360.
It didn't do anything since wxBitmapBundle-related changes, as could be
seen by toggling the bitmap size in the toolbar sample -- the bitmaps
size didn't actually change.
Make it work again by only using the best bitmap size if it's greater
than the currently set bitmap size, but not shrinking the bitmaps to it
if it's smaller. This doesn't seem especially useful, but this is how
the code behaved with single bitmaps before and there doesn't seem to be
any good reason to change this.
At least document that calling SetToolBitmapSize() is unnecessary and
normally shouldn't be done.
Fix wxGenericColourButton after recent bitmap changes and, more
generally, always skip wxDPIChangedEvent and document that this should
be done.
See https://github.com/wxWidgets/wxWidgets/pull/2637
Documentation of the other overloads was removed in 6a442d2 and there is
nothing special about the wxCoord variant in wxSVGFileDC, so remove it so
all the overloads are consistently documented in just wxDC.
Closes https://github.com/wxWidgets/wxWidgets/pull/2627