Commit Graph

72213 Commits

Author SHA1 Message Date
Artur Wieczorek
3c87cc1e49 Get rid of unused member variable 2022-01-28 23:55:12 +01:00
ousnius
0c6dee2171 Fix XRC environment variable expansion for bitmap bundles 2022-01-28 22:59:03 +01:00
Kvaz1r
b8c457e356 Fix scrolling when m_win != m_targetWindow in wxUniv/MSW
This reverts 3b3169fa15 (Fix refresh problems when scrolling with
mousewheel in wxUniv/MSW, 2021-09-23) (see #2525) and replaces it with a
wxUniv-specific workaround in wxScrollHelperBase::HandleOnScroll().

Closes #2640.
2022-01-27 23:45:52 +01:00
Vadim Zeitlin
4cff1fce29 Merge branch 'unsigned-arith-conv'
Avoid arithmetic conversion warnings from gcc 12.

See #22063, #22057.
2022-01-27 23:40:03 +01:00
Jeinzi
d94dc0cab5 Add missing parenthesis to an example in wxTextCtrl docs
Closes #22062.
2022-01-27 17:07:15 +01:00
Vadim Zeitlin
e0323663b9 Handle font variants added in Pango 1.50
This avoids -Wswitch gcc warning and could be actually useful too if we
ever use a font in one of these variants.

Closes #22064.
2022-01-27 17:05:41 +01:00
Vadim Zeitlin
37a4bf8693 Add wxColour::Get{Red,Green,Blue,Alpha}() to avoid gcc 12 warnings
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.
2022-01-27 15:46:42 +01:00
Vadim Zeitlin
28b84a1e96 Avoid gcc 12 -Warith-conversion in wxImageHistogram::MakeKey()
Explicitly convert the operands to unsigned because we do actually want
the result to be unsigned here.

Co-Authored-By: Scott Talbert <swt@techie.net>
2022-01-27 15:30:22 +01:00
PB
5ba37d867c Support creating wxBitmapBundle from SVG in application resource
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.
2022-01-27 14:39:35 +01:00
Alexander Koshelev
3f3561e2c6 Change inactive bitmap to in wxBitmapBundle wxAnimationCtrl 2022-01-27 14:29:25 +01:00
Alexander Koshelev
2b94729a33 Change wxBitmap to wxBitmapBundle in wxBannerWindow 2022-01-27 14:29:25 +01:00
Alexander Koshelev
85becc9362 Change wxBitmap to wxBitmapBundle in wxBitmapToggleButton 2022-01-27 14:29:25 +01:00
Alexander Koshelev
b2629a97e5 Add wxBitmapBundle::GetPreferredLogicalSizeFor()
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.
2022-01-27 14:29:25 +01:00
Tobias Taschner
dd185a0b27 Fix timing issue with wxWebViewEdge::SetPage()
When SetPage() was called during the webview was still initializing
it would silently fail. This will now load the contents when the
webview is ready. Additionally error handling for the underlying
NavigateToString() has been added so it wont fail silently.

Closes #22052.
2022-01-27 14:11:19 +01:00
Vadim Zeitlin
311aa370de Merge branch 'dvc-bmpbundle'
Use wxBitmapBundle in wxDVC-related classes.

See #22051.
2022-01-27 14:10:29 +01:00
Ger Hobbelt
4902b8137b Improve startup time of the display sample under MSW
Performance tweak for samples/display, resulting in a much faster
application start, particularly when built in debug mode, when Windows
messages are dumped to the system debug channel for
inspection/diagnosis.

Speed up the Append() loop below by foregoing the repeated resizing of
the choice drop-down via repeated calls to GetBestSize() which happens
deep inside the Append() call chain and executes another inner loop
calling SendMessage() to get the control contents. (This exhibits
1/2*O(N^2) behaviour thanks to the linear growth of the length of the
inner loop to the length of the outer loop (= number of items to add),
while it is re-executed for every new added item.)

With the 'display' sample, that's about 500+ rounds and about 500*500/2
SendMessage() calls less now on my dev/test rig, taking noticeable time
to start the display application.

---

Issue was found due to the barrage of '(winmsg)' Windows Message debug
log lines zipping by in the monitor app when the sample was build in
Debug Mode. Only significant difference with the Release Build is those
debug lines being output, hence the performance gain is less, but still
measurable, in a Release build. When the machine is otherwise severely
loaded (UI render core maxing out), "measurable" becomes "obnoxiously
noticeable" again on Win10/64.

Closes #22049.
2022-01-27 14:08:33 +01:00
Vadim Zeitlin
224d8ffdaf Merge branch 'ak_high_dpi' of https://github.com/kosh543/wxWidgets
Add support for wxBitmapBundle to XRC.

See #22040.
2022-01-27 14:04:01 +01:00
Gerhard Gruber
1533026945 Allow better control over splitter position on resize
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.
2022-01-27 14:00:51 +01:00
Vadim Zeitlin
8f58562fea Fix typo in bin2c.py comment
Correct the name of the other script.
2022-01-27 13:55:46 +01:00
Alexander Koshelev
7f5910ad07 XRC: ability to create wxCommandLinkButton with wxBitmapBundle 2022-01-24 17:26:52 +03:00
Alexander Koshelev
4ec849a28c XRC: ability to create wxButton with wxBitmapBundle 2022-01-24 17:26:52 +03:00
Alexander Koshelev
49fd3a227c XRC: ability to create wxStaticBitmap with wxBitmapBundle 2022-01-24 17:26:52 +03:00
Alexander Koshelev
df1504dd8f XRC: add GetBitmapBundle function
The function creates wxBitmapBundle from <bitmaps> xrc tag.

Co-authored-by: VZ <vz-github@zeitlins.org>
2022-01-24 17:26:42 +03:00
Vadim Zeitlin
4073f3b9bf Use wxBitmapBundle in wxDataViewCtrl-related classes
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.
2022-01-23 21:55:30 +01:00
Vadim Zeitlin
90bbde8777 Fix "tall row" height in the dataview sample in high DPI
Add missing FromDIP() to ensure that the rows are really tall.
2022-01-23 17:29:43 +01:00
Vadim Zeitlin
e6addf1128 Take DPI scaling into account for wxDataViewCtrl scroll rate
Use FromDIP() to make scrolling work visually the same in high DPI as in
normal one.
2022-01-23 17:29:43 +01:00
Vadim Zeitlin
906808b8e5 Fix wxDataViewCtrl default row height in high DPI
Use FromDIP() to ensure that it is not too small when using DPI scaling.

Also make the code slightly more clear by using a meaningful variable
name instead of a (duplicated) comment.
2022-01-23 17:29:43 +01:00
Vadim Zeitlin
1a1c02804b Add more FromDIP() calls to generic wxDataViewCtrl renderers
Some of them had been already updated to return the values scaled
appropriately for the current DPI in 56fab0aabb (Improve wxDataView on
DPI change, 2019-01-10), but not all, so add the missing calls to
wxDataView{Progress,IconText}Renderer too.
2022-01-23 17:29:43 +01:00
Vadim Zeitlin
2c18e772c2 Fix wxDataViewCheckIconTextRenderer icon size under Mac too
The change of dcdcbbe078 (Fix wxDataViewCheckIconTextRenderer icon size
with GTK3, 2020-09-17) should really apply to all platforms, especially
those with DPI-independent pixels (a.k.a. really logical pixels), such
as Mac, to have the correct icon sizes in high DPI.
2022-01-23 17:29:43 +01:00
Vadim Zeitlin
e6bf7f5ec5 Remove unnecessary HasImageList() checks in wxDataViewTreeCtrl
These checks don't seem to make any sense at all, even though they were
there ever since this classes was added in a75124d0da (Added
wxDataViewTreeCtrl, 2007-12-01), and, in fact, were clearly harmful
until they were fixed in e6a2aa5ae3 (Show correct icon for branch nodes
in wxDataViewTreeCtrl, 2018-09-12).

But it seems that even this wasn't the right thing to do, as there
doesn't seem to be any reason to not call ItemChanged() even for the
controls not using images, so just remove them completely.
2022-01-23 17:29:43 +01:00
Vadim Zeitlin
3cc4ef5f77 Merge branch 'art-wx-logo'
Add wx logo art ID and use SVG to provide it in any size.

See #22046.
2022-01-23 17:29:22 +01:00
Vadim Zeitlin
22a3b4a8af Merge branch 'msw-icon-scale-factor'
Make scale factor-related functions available in wxIcon in wxMSW too.

See #22045.
2022-01-23 17:27:28 +01:00
Vadim Zeitlin
4cc3c5ee87 Merge branch 'bitmap-bundle-icon'
Add functions for wxIcon interoperability to wxBitmapBundle too.

See #22044.
2022-01-23 17:26:27 +01:00
Vadim Zeitlin
565f812c3d Merge branch 'logical-instead-of-scaled'
Add wxBitmap::CreateWithLogicalSize() and GetLogicalXXX() to be used
instead of CreateScaled() and GetScaledXXX().

See #22042.
2022-01-23 17:25:06 +01:00
Vadim Zeitlin
fc2b7e5266 Add wxBitmapBundle::GetIconFor()
This is to GetBitmapFor() as GetIcon() is to GetBitmap().
2022-01-23 16:04:50 +01:00
Vadim Zeitlin
84b5e4639e Add wxBitmapBundle::IsSameAs()
This is useful if only for compatibility with wxBitmap or wxIcon, that
have the same member function with the same semantics.
2022-01-23 16:04:50 +01:00
Vadim Zeitlin
fe2aba3b99 Add wxBitmapBundle::GetIcon()
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.
2022-01-23 16:04:50 +01:00
Vadim Zeitlin
99445aa64c Document wxBitmapBundle::GetBitmap(wxDefaultSize) behaviour
The size parameter is explicitly allowed to be wxDefaultSize here,
meaning to return the bitmap in the default bundle size.
2022-01-23 16:04:50 +01:00
Vadim Zeitlin
2208f53ba3 Add wxART_WX_LOGO and use it in the webview sample
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.
2022-01-23 15:40:04 +01:00
Vadim Zeitlin
a2ad755b1c Add script for converting arbitrary binary data to C arrays
This is similar to the existing png2c, but works for any binary data,
not just PNG files.

Another small difference is that this script puts 16 bytes per line
instead of 8 -- this still results in reasonably short lines, but twice
shorter files, so seems to be worth it.
2022-01-23 02:07:42 +01:00
Vadim Zeitlin
dcc15ddb71 Don't create invalid wxArtProvider-based wxBitmapBundles
If the art ID is unknown, return an invalid bitmap bundle immediately
rather than returning a non-empty, i.e. apparently valid, bundle which
will be unusable later, as its GetBitmap() will always return an invalid
bitmap.

This allows to just skip using the image if wxArtProvider can't create
it, for whatever reason, rather than asserting when trying to use an
invalid bitmap later, which can often be fatal because it can often have
from wxEVT_PAINT handler and so result in reentering assert handler.
2022-01-23 02:07:42 +01:00
Vadim Zeitlin
38110f1dc1 Preserve bitmap scale factor in wxIcon::CopyFromBitmap()
This doesn't really matter for wxMSW, as scale factor is not used by
wxIcon::GetLogicalXXX() anyhow, but it is used by GetDIPSize(), so it
seems better to still preserve it here.
2022-01-23 02:00:20 +01:00
Vadim Zeitlin
d943d6f6cf Ensure wxBitmap::SetScaleFactor() doesn't change bitmap copies
Call AllocExclusive() to ensure that we're only changing the scale
factor of this object, and not of all the other objects using the same
data.
2022-01-23 02:00:07 +01:00
Vadim Zeitlin
b4946c2fe3 Move scale factor-related functions to wxGDIImage from wxBitmap
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.
2022-01-23 01:59:59 +01:00
Vadim Zeitlin
c1d91d5566 Document functions not using logical pixels in high DPI overview
Any other exceptions to the general rule saying that wx API works with
logical pixels should be added to the list here.
2022-01-22 22:44:00 +00:00
Vadim Zeitlin
94716fd801 Add wxBitmap::CreateWithLogicalSize()
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.
2022-01-22 22:44:00 +00:00
Vadim Zeitlin
dad828da38 Use rounding in both wxWindow::FromPhys() and ToPhys()
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.
2022-01-22 21:40:36 +00:00
Vadim Zeitlin
51dc85c72d Round physical bitmap size in wxGTK wxBitmap::CreateScaled()
Round the result of the multiplication by possibly non-integer scaling
factor rather than truncating it. This is more consistent with wxMSW and
other ports not using DIPs (wxOSX doesn't matter, as the scale factor
can only be an integer there anyhow) and seems to be more useful.

E.g. previously creating a bitmap of logical size 5 at 150% DPI scaling
would create a 7px bitmap, for which GetLogicalWidth() would return 4.66
that would be truncated to 4, and not 5, when assigning it to an int,
while now a 8px bitmap will be created and both rounding or truncating
its GetLogicalWidth() value of 5.33 results in the more expected 5.
2022-01-22 21:26:39 +00:00
Vadim Zeitlin
a81e0d83c1 Use wxBitmap::GetLogicalXXX() instead of GetScaledXXX()
Replace old functions with the new ones in the library code itself.

Note that wxSTC and wxRichText still use GetScaledXXX(), but they're
different functions that might need to be renamed/dealt with separately.
2022-01-22 18:57:31 +00:00
Vadim Zeitlin
65bb454311 Add wxBitmap::GetLogical{Width,Height,Size}()
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.
2022-01-22 18:56:21 +00:00