Commit Graph

11055 Commits

Author SHA1 Message Date
Vadim Zeitlin
495e9b99cd Don't update wxBitmapComboBox bitmaps size if there are none
Correct the changes of 212d59cd80 (Fix determining the size of
wxBitmapComboBox bitmaps, 2022-05-25) and avoid changing m_usedImgSize
if we have no bitmaps at all, as it happens when adding the very first
bitmap: in this case, we set m_usedImgSize in our OnAddBitmap() before
actually adding the bitmap to m_bitmapbundles in DoInsertItems() called
from the base class Append() or Insert(), and wxMSW implementation calls
RecreateControl() from its overridden OnAddBitmap() which results in a
call to UpdateInternals() in between them.

All this is rather confusing and it would arguably be better to avoid
setting m_usedImgSize until the bitmap is actually added to
m_bitmapbundles, but this would require further changes, so for now just
avoid setting m_usedImgSize to (0, 0).
2022-06-01 15:40:17 +02:00
Vadim Zeitlin
731d29bace Move wxBitmapBundle::Clear() out of line
Ensure that wxBitmapBundleImpl full declaration is available when it is
compiled, at least OpenVMS compiler has trouble with compiling the call
to reset(), which involves using wxBitmapBundleImpl dtor, if it comes
before this class declaration.
2022-05-31 14:46:44 +02:00
Vadim Zeitlin
a25824bc91 Fix wxIPV6address initialization
Use DoInitImpl() which, somehow, was never used before, meaning that,
apparently, wxIPV6address never worked at all, as objects of this type
were still initialized to use FAMILY_INET (i.e. IPv4 address family).

Closes #22463.
2022-05-27 15:26:26 +02:00
Vadim Zeitlin
212d59cd80 Fix determining the size of wxBitmapComboBox bitmaps
Instead of using the size of the first item bitmap, use the size best
suited for all the bitmaps, which may result in better appearance if the
different bitmaps are not all available in the same sizes.

This also fixes the unit test after 80a736250e (Fix margin between
wxBitmapComboBox images and text in high DPI, 2022-05-25) and should
have been part of it.
2022-05-25 22:18:43 +02:00
Maarten Bent
80a736250e Fix margin between wxBitmapComboBox images and text in high DPI
Don't use FromDIP() with m_usedImgSize which is expressed in logical,
and not DPI-independent, pixels already and also update the image size
when the DPI changes.

Closes #22436.
2022-05-25 15:22:15 +02:00
Vadim Zeitlin
411c150bba Merge branch 'print-preview-layout'
Print preview layout and appearance fixes.

See #22441.
2022-05-23 22:25:16 +01:00
Vadim Zeitlin
9042b529fa Merge branch 'dvc-bitmap-renderer-bundle'
Allow using wxBitmapBundle with wxDataViewBitmapRenderer.

See #22411.
2022-05-23 22:22:53 +01:00
Vadim Zeitlin
663fa1c77b Still use wxPreviewFrame size if it was explicitly specified
Even though it's better to not specify the preview frame size at all,
the size should still be used if it was explicitly specified, but this
didn't happen any more after the addition of the call to Fit().

Fix this now by only doing the equivalent of Fit() if no size was
explicitly given.

Also add advice about not setting the size explicitly to the
documentation.
2022-05-23 15:07:06 +01:00
Vadim Zeitlin
fc0a4d4e62 Correct client/window confusing in wxPreviewFrame code
Pass the window size to SetSizeHints() to make sure the window minimum
size is set as expected.
2022-05-23 15:07:06 +01:00
taler21
1e483f9510 Improve the appearance of "Close" button in wxPreviewFrame
Ensure that there is a border at least as wide as between the other
button groups before this button.
2022-05-21 00:11:06 +01:00
Vadim Zeitlin
4d3bb036f9 Use GetDefaultBorderFractional() for borders in wxPreviewFrame
This is slightly more precise when using non-integral scaling factor
than using GetDefaultBorder().
2022-05-21 00:08:11 +01:00
Vadim Zeitlin
5be09037d0 Disallow shrinking wxPreviewFrame too much horizontally
Make it at least as wide as the controls bar to ensure all the buttons
are always shown.
2022-05-21 00:04:03 +01:00
Vadim Zeitlin
f43efa6b46 Fix drawing of corners in wxGraphicsContext::DrawLines()
Close the path corresponding to the polygon to ensure that the starting
and finishing edges are joined correctly, which wasn't the case before
as could be easily seen when using thicker pens.

Closes #22440.
2022-05-20 01:32:07 +02:00
Vadim Zeitlin
dcf24f5311 Remove unnecessary and ugly borders from wxPreviewFrame
Having borders around the controls toolbar and preview canvas not only
wasted space, but also let the frame background show through, which
looked just ugly under MSW, where it is dark grey and so clashes with
the control bar background.

Simply remove them to save space and improve appearance too.
2022-05-19 17:08:17 +01:00
Vadim Zeitlin
f0de5a93f8 Use reasonable size for wxPreviewFrame by default
Give a reasonable default size to wxPreviewCanvas and fit wxPreviewFrame
to its contents.

Remove the useless call to Fit() from SizerWithButtons: the size set
inside it was just ignored anyhow.

This also allows to stop hardcoding the size in the sample, so don't do
this any more.

See #22439.
2022-05-19 17:04:32 +01:00
Vadim Zeitlin
93a6784c5f Remove unnecessary wxPreviewFrame::Layout() call
No real changes, just remove the useless call which was left over the
very first version of this code added in 7bcb11d307 (Many changes to the
printing classes., 1999-03-25).
2022-05-19 17:21:49 +02:00
taler21
91a0dc3197 Fix insufficient width of zoom combobox in print preview
Don't hardcode 70px size for the combobox, but let it determine its own
size instead, as 70 may well not be enough, depending on the theme and
the font size.

Closes #22439.
2022-05-19 16:42:31 +02:00
Antti Nietosvaara
7f32d9b752 Fix layout of wxFlexGridSizer containing wxWrapSizer
Fix a layout issue when wxFlexGridSizer contains items that return true
from InformFirstDirection(), such as wxWrapSizer.

If didAdjustMinSize == true, the minimum width has probably changed, and
we should recalculate it. Otherwise we end up using incorrect delta in
DoAdjustForGrowables, which might push items too far to the right.

Closes #22421.
2022-05-11 15:21:16 +01:00
Vadim Zeitlin
a7eee933c6 Merge branch 'tsan-warnings'
Fix a harmless warning from thread sanitizer and make wxAtomicInc() more
useful.

See #22417.
2022-05-11 02:37:26 +02:00
Vadim Zeitlin
cf841aa286 Fix build with WXWIN_COMPATIBILITY_2_8==1
This was broken by the changes of 6383bc39ff (Add convenient
wxDCImpl::CalcBoundingBox() overloads and use them, 2022-04-30), fix it
by calling the overloaded wxDCImpl::CalcBoundingBox() instead of the
wxDC version for which the overloads were not added.

Closes #22418.
2022-05-11 02:29:02 +02:00
Vadim Zeitlin
fbeccb3954 Use wxAtomicInt for the global initialization counter
This is slightly more efficient and simpler than using a separate
critical section and can easily be done now that wxAtomicInc() returns
the new value.

No real changes.
2022-05-11 00:18:02 +02:00
Vadim Zeitlin
f4fb91b56e Don't keep critical section locked during wxEntryStart() call
Use gs_initData.csInit only to ensure that we call wxEntryStart() once
even if there are multiple calls to wxInitialize() from multiple
threads, but don't keep it locked for the duration of that function as
this is unnecessary and results in -- probably benign in practice, but
still annoying -- warnings from the thread sanitizer about lock order
inversions due to locking csInit first before locking gs_mutexGui in
wxThreadModule::OnInit() and then acquiring csInit again while
gs_mutexGui is still locked in wxUninitialize().

This shouldn't result in any observable changes in behaviour.
2022-05-10 23:26:45 +02:00
Vadim Zeitlin
5556ea8429 Add support for storing wxBitmapBundle in a wxVariant
Define wxBitmapBundleVariantData without using the standard macros that
only work for wxObject-derived classes, but using more or less what they
expand into.

This will allow using wxBitmapBundle with wxDataViewCustomRenderer
subclasses in the upcoming commit.
2022-05-08 21:26:04 +02:00
Vadim Zeitlin
23e815bcf6 Allow relaxing the check for variant type in wxDataViewRenderer
Instead of checking for the exact variant type match, call the new
IsCompatibleVariantType() virtual function, which still does the same
check by default, but can be overridden to allow other types as well if
they're accepted by the renderer.

This will be soon used to allow accepting both wxBitmap (which must
still be accepted for compatibility) and wxBitmapBundle (which is the
simplest way to support high DPI) in wxDataViewBitmapRenderer at once.
2022-05-08 18:39:15 +01: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
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
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
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
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
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
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
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
Maarten Bent
dc5fe63cb2 Don't implement FromDIP and ToDIP in headers 2022-04-29 00:38:46 +02:00
Vadim Zeitlin
35a3bac439 Use wxObjectDataPtr in wxSharedClientDataContainer
This is slightly more economical, both at run-time and, maybe more
importantly, at compile-time than using wxSharedPtr that we don't really
need here, simple intrusive ref counting smart pointer is enough.
2022-04-28 00:47:19 +02:00
Vadim Zeitlin
e2a5c1ffc8 Don't provide wxSharedClientDataContainer::m_data accessors
This is not really necessary and breaks encapsulation of this private
method. It is enough to provide just a way to copy the data from another
object as this is all that the derived classes really need.
2022-04-28 00:36:40 +02:00
Frode Roxrud Gill
f646e8b11c Allow cloning client data stored in wxGrid attributes etc
Add wxSharedClientDataContainer class storing ref-counted client data
and use it instead of plain wxClientDataContainer in wxGridCellAttr,
wxGridCellEditor and wxGridCellRenderer classes.

This allows to keep the same client data associated with many grid cells
without having to make many copies of it.
2022-04-28 00:28:58 +02:00
Vadim Zeitlin
6935b831bd Merge branch 'messages-with-context' of https://github.com/lanurmi/wxWidgets
Add wxTRANSLATE_IN_CONTEXT() and use it in a few places, notably for the
key names.

See #22354.
2022-04-27 19:17:12 +02:00
Maarten Bent
d2366b2eb0 Fix printing at high DPI on GTK3 and when saving as postscript 2022-04-26 21:25:55 +02:00
Vadim Zeitlin
8245ba96ee Don't crash if invalid index is used with wxDataViewListCtrl
Use wxCHECK, not wxASSERT, for checking a critical precondition to
ensure that we don't crash if it's violated.

This fixes crashes in various wxDataViewListCtrl methods if they're
passed an invalid index different from wxNOT_FOUND.

Closes #22358.
2022-04-26 02:02:29 +02:00
Lauri Nurmi
3396a40015 Mark keyboard key names translatable in a specific context
Many key names are short and commonly used words; e.g. "Delete", "Left",
"Right", "Pause", "Menu", "End".

It is not at all unlikely that such words could be used in a completely
different meaning elsewhere in the code. That is why this list of
keys should be assigned a context.

The context fulfills also the same purpose as TRANSLATORS: comments --
removing comments as redundant.
2022-04-24 11:30:31 +03:00
Uwe Runtemund
28f62b2e59 Add support for creating wxBitmapBundle from wxIconBundle
This is useful for converting existing code using wxIconBundle for
similar purposes to switch to using wxBitmapBundle instead.

Closes #22347.
2022-04-23 17:31:46 +02:00
Maarten Bent
e8cf1f989b Add ToDIP to wxDC and wxGraphicsContext 2022-04-21 22:04:10 +02:00
Maarten Bent
7cd4e343a2 Let wxGCDC inherit wxWindow from wxGraphicsContext 2022-04-21 22:04:09 +02:00
Maarten Bent
1a1d19e93b Improve print preview and printing with high DPI
All print related scaling is based on 96DPI, so always let the printing contexts return this,
and also adjust the font to this DPI.
2022-04-21 22:04:06 +02:00
Maarten Bent
cb05935f52 Check if GetDPI parameters are not NULL
And combine the same code for assigning the variables.
2022-04-21 21:55:53 +02:00
Maarten Bent
15a37b91fb Add FromDIP to wxDC and wxGraphicsContext
Using the same implementation as wxWindow has.
2022-04-20 20:37:53 +02:00