Commit Graph

71885 Commits

Author SHA1 Message Date
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
Tobias Taschner
1ae0037330 Add wxGetNativeCpuArchitectureName()
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.
2022-01-22 19:32:56 +01:00
Tobias Taschner
512f40d614 Silence unused parameter warning 2022-01-22 19:32:40 +01:00
PB
72e1de6d73 Do not use Direct2D Debug Layer if wx debug features are disabled
Create wxD2D1Factory with D2D1_DEBUG_LEVEL_WARNING only when debug
features, such as asserts, are enabled at wx level.

This is not the exact equivalent of the "Debug" build commonly used
under MSW with MSVC, but seems to be the closest equivalent, see the
discussion in #22034.

Closes #22039.
2022-01-21 21:17:33 +01:00
Vadim Zeitlin
2af0b12d26 Avoid assert on text sample startup under MSW
Use wxTE_RICH2 for a control that we call EnableProofCheck() on, as
using this function without this style asserts in wxMSW.

This should have been done in 5ba2461fd1 (Switch to using GSpell for
wxTextCtrl proof checker in wxGTK, 2021-09-08).
2022-01-20 00:13:16 +01:00
Vadim Zeitlin
ab94485efa Really fix example of creating wxBitmapBundle in hight DPI docs
Co-Authored-By: PB <PBfordev@gmail.com>
2022-01-19 16:45:41 +01:00
Vadim Zeitlin
4a43ea8827 Fix wrong example and wording in high DPI docs
Co-Authored-By: PB <PBfordev@gmail.com>
2022-01-18 19:08:50 +01:00
Vadim Zeitlin
bf2c2b6343 Merge branch 'arrstr_stl_fromend_fix' of https://github.com/pavel-t/wxWidgets
Fix wxArrayString::Index(bFromEnd = true) in STL build.

See #22024.
2022-01-18 18:57:43 +01:00
Pavel Tyunin
f1607c9521 Fix search from end in wxArrayString in STL build 2022-01-17 19:20:19 +02:00
Paul Cornett
32eb4af061 Avoid using wxClientDC to redraw grid lines
This only happens when changing whether/how the lines are drawn, so
there should be no performance issue with just repainting the window.
2022-01-17 08:55:48 -08:00
Paul Cornett
8cfdabd50d Avoid a use of wxClientDC for drawing
Just refresh the cell if the highlight color is changed
2022-01-17 08:55:48 -08:00
Vadim Zeitlin
94b4f738d4 Merge branch 'dpi-docs-improve'
Improve high DPI support documentation.

Closes #18889, #22011.
2022-01-17 17:44:06 +01:00
Vadim Zeitlin
ead3e95bf4 Add a note about rounding the logical pixels up when converting
This might be unexpected, so explicitly warn about possibly not getting
back exactly the same value after a round-trip.
2022-01-17 17:43:51 +01:00
Vadim Zeitlin
74e1404a5a Document using wxWindow::{From,To}Phys() for LP<->PP conversions
This is simpler and more clear than dividing or multiplying by
GetContentScaleFactor().
2022-01-17 17:43:51 +01:00
Vadim Zeitlin
b4f0ddd81e Add wxBitmapBundle section to high DPI overview
Explain how it can be created and used.
2022-01-17 17:43:51 +01:00
Vadim Zeitlin
c1532c8d3c Fix table of contents generation for high DPI overview
Add the required anchors, just the headers are not taken into account
for TOC generation.
2022-01-17 17:42:32 +01:00
Vadim Zeitlin
caec339bc1 Improve documentation of various pixel types
Also add a diagram showing the functions to use to convert between them,
perhaps this can be more clear than textual description.

Co-Authored-By: Stefan Csomor <csomor@advancedconcepts.ch>
2022-01-17 17:42:01 +01:00
Paul Cornett
4217573a3f Fix wxGrid::SetCurrentCell() with Wayland
Avoid wxClientDC with GTK3 as well as OSX. Additionally, refresh
only the cells that need it, rather than the entire window.
See #18448
2022-01-16 21:35:20 -08:00
PB
ccb6b10c1f Use SVG-based toolbar bitmaps in webview sample
In webview sample toolbar use wxBitmapBundles created from SVG files
instead of XPM bitmaps, as this results in much better appearance in
high DPI.

Closes #2642.
2022-01-17 01:07:57 +01:00
Vadim Zeitlin
2064526e3d Revert "Merge branch 'ak_high_dpi' of https://github.com/kosh543/wxWidgets"
This reverts commit a34ab31453, reversing
changes made to 783df59e66.

Undo the addition of wxBitmapBundle support to XRC, as it is finally
going to be done in a different way soon -- but for now just remove it
to ensure that nobody starts using it before it's finalized.

See #2633.

Closes #22014.
2022-01-16 23:40:31 +01:00
Vadim Zeitlin
68e2684d2b Merge branch 'phys-pixels-convert'
Add function for converting between logical and physical pixels too.

See #22013.
2022-01-16 23:39:50 +01:00
Vadim Zeitlin
f2c5973f61 Fix cancel editing on Esc in wxOSX wxDataViewCtrl again
Handle selectors corresponding to key presses, such as cancelOperation:,
ourselves because we never get the keyDown events that are supposed to
take care of generating it from the native code somehow.

This fixes cancelling editing with Escape which stopped working since
26d6f82a81 (Implement EVT_CHAR generation for wxDataViewCtrl under Mac,
2021-04-13).

Closes #17835, #2639.

Co-Authored-By: Stefan Csomor <csomor@advancedconcepts.ch>
2022-01-15 23:41:13 +01:00
Vadim Zeitlin
7e3059dee0 Merge branch 'dvc-multi-format-dnd'
Accept multiple data formats via drag-and-drop in wxDataViewCtrl.

See #2478, #2616.
2022-01-15 23:39:03 +01:00
Pavel Tyunin
d7fe9667fc Add tests for direction of search in arrays 2022-01-15 21:02:22 +02:00
Vadim Zeitlin
1195b901bd Change issue reporting URL to point to template selection page
This seems more useful than pointing directly to the blank issue
creation page.
2022-01-15 15:46:07 +01:00
Vadim Zeitlin
771e527f30 Merge branch 'issue-templates'
Add some templates for GitHub issues.

These templates notably allow associating labels with the new issues,
which would be impossible otherwise.

See #22016.
2022-01-15 15:44:38 +01:00
QuentinC
622a2f9d60 Improve dark mode detection in wxMSW
Use the registry key corresponding to the selection of "Light" or "Dark"
for the "Colors" in the "Settings" applet, see

https://stackoverflow.com/questions/51334674/how-to-detect-windows-10-light-dark-mode-in-win32-application/

Closes #22020.
2022-01-15 14:35:27 +00:00