Commit Graph

72550 Commits

Author SHA1 Message Date
Vadim Zeitlin
6feeed9fe9 Handle transparency to the best of our ability in wxImageList
Don't take the value of "mask" parameter of wxImageList constructor too
prescriptively, it predates support for alpha in wxWidgets by many years
and was never meant to actually suppress using it.

Instead, do the best thing we can in all cases, i.e. use alpha if it's
specified and supported and use mask otherwise. But only create the mask
from light grey colour if we have nothing else if "mask" is true in
wxImageList constructor, as this is a potentially destructive action
that must not be performed if the user has explicitly decided to set
this parameter to false.

Incidentally fix handling of alpha with comctl32.dll v5 (which is used
in the absence of any manifest) by converting it to a mask in this case:
this is not ideal, but better than just using black background as it
happened before, and restores pre-3.1.5 behaviour.

Also simplify the generic version which just has to create the default
mask if necessary and doesn't have to do anything at all in all the
other cases.

Note that these changes required relaxing some of the existing unit
tests as wxMSW implementation now can add alpha channel to the bitmaps
that didn't have it -- but this is a more useful behaviour, and so it
makes more sense to adapt the tests to it rather than doing a less
useful thing just to conform to the tests.

This commit is best viewed with git --color-moved
--color-moved-ws=ignore-all-spac options.

Closes #22349.
2022-05-06 02:12:54 +01:00
Vadim Zeitlin
0e21b52d57 Extract mask creation from wxImage in a separate function
Allow reusing the code for creating a mask from wxImage mask from
elsewhere.

No real changes yet, this is a just a refactoring.

This commit is best viewed with git --color-moved
--color-moved-ws=ignore-all-space options.
2022-05-06 02:12:54 +01:00
Vadim Zeitlin
416ebf79e0 Use wxScopedArray<> in wxBitmap::CreateFromImage()
Don't manage memory manually.

No real changes.
2022-05-06 02:12:54 +01:00
Vadim Zeitlin
e75f100841 Make GetImageListBitmap() member of wxGenericImageList too
Just simplify the code a little by avoiding having to pass m_useMask and
m_size to all calls of this function.

No real changes.
2022-05-06 02:12:54 +01:00
Vadim Zeitlin
dcc39d942f Make GetImageListBitmaps() member function of wxImageList
No real changes, just simplify the code a bit by using a member function
as this avoids having to pass m_useMask to it separately.
2022-05-05 19:06:18 +01:00
PB
68dee47694 Explain how to best use wxFrame as input form
Add information about the recommended way of using wxFrame
as a form, i.e., to not create the input controls as its
direct children but use wxPanel for this instead.

Closes #22395.
2022-05-05 17:32:43 +02:00
Vadim Zeitlin
84e15a8fd2 Merge branch 'wxsvg-mac' of https://github.com/MaartenBent/wxWidgets
Improve wxSVGFileDC on macOS: use correct scaling.

See #22390.
2022-05-05 17:29:20 +02:00
Vadim Zeitlin
bf0f9cf55b Merge branch 'msw-scroll-beyond-2_27'
Increase usable scrolling range in wxMSW by a factor of 10,000 by
switching to handling the device origin in wxWidgets itself instead of
letting GDI handle it.

See #22382.
2022-05-05 17:24:58 +02:00
DietmarSchwertberger
ec737396d8 Unify wxGrid code for processing row and column mouse events
Reuse the same code for handling mouse events for both rows and columns
instead of duplicating almost (but not quite) the same code for both of
them.

As part of resolving the inconsistencies between the two versions, add
wxEVT_GRID_ROW_AUTO_SIZE corresponding to the existing event with the
same name for the columns.

Closes #22380.
2022-05-05 17:23:45 +02:00
Joonas Kuusela
1660584a45 Fix using wx/tipwin.h as the first include wx header
Include wx/defs.h from wx/tipwin.h to ensure wxUSE_TIPWINDOW is defined
before testing its value.

Closes #22392.
2022-05-05 16:10:46 +02:00
Vadim Zeitlin
84eb6bfa41 Consistently use 1992 as the start of the copyright period
Use 1992 as the initial date for all non-Mac files, instead of using
slightly later years for some of them without any good reason (or at
least without any good reason still remembered by anybody).

This also allows to simplify the script for updating the year.
2022-05-04 17:24:53 +02:00
Jouk
9ad589ce1d Corrections for different syntax of uname command on OpenVMS 2022-05-04 15:58:13 +02:00
Maarten Bent
17e6fe5b4f Improve wxSVGFileDC on macOS
On macOS everything is based on 72DPI, while the SVG is based on 96DPI.
As a result, fonts in point-size are too big and squeezed together (due too
textLength).

Fix this by taking the standard screen DPI into account in FromDIP and ToDIP,
so all coordinates and sizes will be in SVG DPI.

wxSVGFileDC should be created with a DIP size, so use FromDIP to get the
correct viewBox size and clear-rectangle size.
2022-05-03 22:56:55 +02:00
Maarten Bent
1d6c366f14 Make all pages in the drawing sample DPI aware 2022-05-03 22:56:07 +02:00
Vadim Zeitlin
e503cbe212 Merge branch 'fix-empty-grid'
Fix asserts when redrawing empty wxGrid.

See #22385.
2022-05-03 18:11:09 +02:00
Lauri Nurmi
cb527f5b1f Do not assemble OSX menu item translations from pieces
Just spell out "Quit Application" and "Hide Application" as is,
without string concatenation.

Translating individual words can be complicated with some languages.

This change affects the case when wxTheApp is NULL, which presumably
is quite rare.

Closes #22384.
2022-05-03 18:10:16 +02:00
wangpengli.qwerty
f93b4f9c90 Fix assert checking size in wxBitmapBundleImplRC::AddBitmap()
Add the missing "name" argument to wxString::Format().

Closes #22387.
2022-05-03 18:04:26 +02:00
Vadim Zeitlin
10b49c9084 Avoid using invalid column/row indices when repainting empty grid
Even the normally safe internalYToRow() and internalXToCol() functions
can still return an invalid index when the grid is empty, i.e. when
there are no valid indices at all, so check for their return value
before using it as an argument to Get{Row,Col}Pos() that would
(correctly) assert when passed an invalid value.

This fixes a regression inadvertently introduced by 3719ab3725 (Add
support for rearranging wxGrid rows order interactively, 2022-04-02)
which added non-trivial GetRowPos().
2022-05-02 21:56:49 +01:00
Vadim Zeitlin
b585ef67af Consistently write loops over wxRegionIterator in the same way
Standardize on a single loop for all versions of it and prefer to use
"for" loops with the iterator increment directly in the loop statement
instead of using "while" loops with the increment somewhere inside the
loop, where it could be possibly skipped by a "continue" statement.

No real changes.
2022-05-02 21:52:25 +01:00
Vadim Zeitlin
bdfa9359ae Move wxGrid::Get{Row,Col}Pos() out of line
Don't define these functions in the header file, this is unnecessary.

No real changes.
2022-05-02 21:43:42 +01:00
Vadim Zeitlin
3cc55d5b66 Add a workaround for failing test under Wine
Debugging confirms that DPtoLP() simply returns wrong (i.e. different
from that returned under actual MSW) result when using Wine, so just
account for it in the test as it seems to be better than just skipping
the test entirely under Wine and there doesn't seem to be anything else
to do.
2022-05-02 22:42:42 +02:00
Vadim Zeitlin
c0b7240dfb Fix wxDC::DeviceToLogical() in presence of transform matrix
It's not enough to just shift the result by the origin shift if there is
a transform matrix, we need to apply the reverse shift transformed by
this matrix in general.

This is not very efficient as we redo the same matrix operations on
every call, but using both device origin shift and transform matrix
together should be quite rare, so it's not clear if it's worth
optimizing this.
2022-05-02 20:02:04 +01:00
Vadim Zeitlin
7eb5e99cac Don't use array of a single POINT in wxMSW wxDC code
No real changes, just use a simple POINT rather than POINT[1].
2022-05-02 19:52:27 +01:00
utelle
0e435c1c45 Simplify check for translated labels in wxMSW message boxes
Only translate the labels in the native message box if there is a valid
current wxTranslations instance: this is simpler and more robust than
checking if the current language is different from the system language.

Closes #22383.
2022-05-02 03:57:49 +02:00
Vadim Zeitlin
4f9186f1a1 Increase usable scrolling range in wxMSW by a factor of 10,000
Using GDI functions for the device origin translation limits the
scrolling range to 2^27 size of the device space in the controls using
PrepareDC(), as it works by adjusting the device origin, and this may be
too small when having many (millions) of rows, which is perfectly
possible with wxDataViewCtrl or wxGrid, for example.

So handle DC device origin translations ourselves in wxMSW, i.e. offset
the coordinates by device origin before passing them to the native
functions as this allows to use the full 32-bit range.

Closes #17550.
2022-05-02 02:51:42 +01:00
Vadim Zeitlin
c6e45280d7 Increase maximum allowed size of test virtual grid in the sample
This allows to see that the grid is currently not redrawn correctly
under MSW when it has more than ~6,000,000 rows due to overflowing the
device space span of 2^27.
2022-05-01 02:12:50 +01:00
Vadim Zeitlin
d64ba81378 Merge branch 'dc-cleanup'
Some cleanup in wxDC code: remove unnecessary casts, use RAII helpers
instead of manual memory and other resources management.

No real changes.

See #22378.
2022-05-01 03:11:06 +02:00
Vadim Zeitlin
4fcf3ba465 Merge branch 'fix-build-without-base64' of https://github.com/PBfordev/wxWidgets
Fix build when wxUSE_BASE64==0.

See #22377.
2022-05-01 03:07:35 +02:00
PB
ed3b1c6ca3 Simplify MSVC pragma for embedding application manifest
Instead of defining a manifest for each individual CPU architecture, use
a single manifest with an asterisk for the architecture.

Should have been part of 77d8926126 (Simplify Windows application
manifests, 2021-12-17).

Closes #22376.
2022-05-01 03:03:20 +02:00
utelle
1c65e88221 Replace references to wxLocale by wxUILocale
Use newer wxUILocale class directly instead of using wxLocale functions
that forward to it anyhow.

No real changes.

Closes #22375.
2022-05-01 03:02:26 +02:00
Vadim Zeitlin
a7791781d9 Merge branch 'listbook-images'
Show images added to its wxImageList later in wxListbook again and also
improve determining the size of the list control under MSW.

See #22372.
2022-05-01 02:57:24 +02:00
Vadim Zeitlin
eb5ad7255c Merge branch 'shared-client-data'
Allow sharing client data in wxGrid-related classes.

See #22369.
2022-05-01 02:55:36 +02:00
Vadim Zeitlin
9a36e26d4a Merge remote-tracking branch 'MaartenBent/wxdc-dpi'
Make wxDC and wxGraphicsContext DPI aware, i.e. add {From,To}DIP() to
them too and make the values returned from Get{DPI,PPI}() consistent
with wxWindow.

Also improve CMake build: add support for finding Cairo when not using
GTK, fix a warning when creating the inplace-config, and mark some
variables as advanced.

See #22346.
2022-05-01 02:53:12 +02:00
Vadim Zeitlin
e09a01068d Remove more unnecessary casts to int in wxMSW wxDC code
There is no need to cast wxCoord to int, they're one and the same.
2022-04-30 21:31:34 +01:00
Vadim Zeitlin
4a56747e8d Use helper PolyFillModeSetter in wxMSW wxDC code
No real changes, just use RAII helper instead of manually setting and
restoring the polygon fill mode.
2022-04-30 21:15:09 +01:00
Vadim Zeitlin
5157a8a62c Hide private StretchBltModeChanger class in unnamed namespace
No real changes, just put this non-wx-prefixed class in an unnamed
namespace to avoid any clashes with user-defined classes (which would be
possible when using wx as a static library).
2022-04-30 21:15:09 +01:00
Vadim Zeitlin
481b73d14c Use wxScopedArray<> instead of manual memory management in wxDC
Update similar code in all ports to use wxScopedArray for arrays of
points, dashes etc in various wxDC implementations instead of using
new[] and delete[] manually.

No real changes, just make the code safer and shorter.
2022-04-30 21:14:58 +01:00
Vadim Zeitlin
6383bc39ff Add convenient wxDCImpl::CalcBoundingBox() overloads and use them
No real changes, just make the code updating the bounding box slightly
shorter by providing convenient and slightly higher-level overloads.

For now these functions are only in wxDCImpl, it's not clear if we
really need them in wxDC, so don't add them to the public API.
2022-04-30 20:51:53 +01:00
Vadim Zeitlin
2fbb40ab61 Remove RealizeScaleAndOrigin() call from wxMSWDCImpl::Clear()
It seems unnecessary here as this function doesn't change neither scale
nor the origin, so there should be no need to realize them neither.
2022-04-30 20:51:53 +01:00
Vadim Zeitlin
03b9be08de Remove useless casts to int from wxMSW wxDC::SetDeviceOrigin()
The variables are already of type int (== wxCoord).

No real changes.
2022-04-30 20:51:53 +01:00
Stefan Csomor
dc2ff0d6b4 wxOSX: Rewiring GetBestSize for single line text control again
see #22374
2022-04-30 20:34:28 +02:00
PB
97e126624e Show error message wxSVGBitmapEmbedHandler::ProcessBitmap()
Do not just silently fail in wxSVGBitmapEmbedHandler::ProcessBitmap()
when wxUSE_BASE64=0, use wxFAIL_MEG() to show why it failed.
2022-04-30 17:46:25 +02:00
PB
3f32bac284 Fix building wxSVGBitmapEmbedHandler when wxUSE_BASE64=0
Use guards for wxUSE_BASE64 in wxSVGBitmapEmbedHandler::ProcessBitmap()
and just return false there when wxUSE_BASE64=0.
2022-04-30 16:33:28 +02:00
PB
4ddaa9c0ce Fix building wxIniConfig when wxUSE_BASE64=0
Use guards for wxUSE_BASE64 just as wxConfigBase does.
2022-04-30 16:29:13 +02:00
Vadim Zeitlin
e0f7dca2b8 Improve best height of horizontally laid out wxListCtrl in wxMSW
It seems that ListView_ApproximateViewRect() always reserves space for
the horizontal scrollbar vertically, even when it isn't needed,
resulting in a lot of blank space remaining in horizontal wxListbook
(e.g. using "top" orientation) in the notebook sample.

So instead of adding extra space when the scrollbar is shown, remove it
when it is not shown.
2022-04-28 23:47:51 +01:00
Maarten Bent
dc5fe63cb2 Don't implement FromDIP and ToDIP in headers 2022-04-29 00:38:46 +02:00
Vadim Zeitlin
25e46d0a4d Improve wxListCtrl::MSWGetBestViewRect() fit
It looks like ListView_ApproximateViewRect() doesn't actually take the
borders into account and doesn't even take margins into account
correctly.

With this change, vertical wxListbook in the notebook sample doesn't
show any horizontal scrollbar and has symmetric margins around its
contents (whether it shows a vertical scrollbar or not) under both
Windows 7 and 10.
2022-04-28 23:38:40 +01:00
Stefan Csomor
74c0fe6dcc Serialize font style correctly in Mac wxNativeFontInfo
The style needs to be explicitly included in the serialized
representation as it's not necessarily part of the native font
description itself, but can be emulated using a transform matrix.

Also fix the font family handling by recreating the native font info
from the newly generated font.

Closes #22373.
2022-04-28 23:37:43 +02:00
Vadim Zeitlin
ebf5e8813e Show images added to its wxImageList later in wxListbook again
Fix a regression in 3.1.6 which resulted in not showing any images if
the associated image list was empty when it was associated with the
control, as HasImages() returned false in this case and so wxLC_ICON
style was not set.

The fix is to return true from HasImages() if we have image list even if
it is currently empty, as we can't know when (or if) it will become
non-empty and it's better to assume that it will be used (as nothing
really catastrophic should happen if it is not used, finally) rather
than not taking into account the images added to it later.

Closes #22364.
2022-04-28 17:24:58 +01:00
Stefan Csomor
5f7d4a70c2 Use "Courier New" and "Times New Roman" in wxOSX
macOS 12 doesn't provide "Courier" and "Times" fonts any longer, so use
their closest replacements "Courier New" and "Times New Roman" instead.

In addition to using them for our own default fonts, also map
user-provided fonts with the old names to the new ones, as in practice
quite a few applications specify these face names rather than relying on
wxFontFamily and it seems better to allow them to keep working correctly
under macOS 12+ rather than using a completely different default system
font when e.g. "Courier" is specified.

Co-Authored-By: Vadim Zeitlin <vadim@wxwidgets.org>

Closes #22355.
2022-04-28 00:53:05 +02:00