Commit Graph

41143 Commits

Author SHA1 Message Date
Vadim Zeitlin
7c7ff3cd42 Add wxBitmap::GetDIPSize() and use it in wxBitmapBundleImplArt
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.
2022-01-13 17:34:49 +00:00
Vadim Zeitlin
f6fbc97c7b Only return really scaled bitmap size under platforms using DIPs
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.
2022-01-13 17:34:49 +00:00
Vadim Zeitlin
2945278334 Rename wxHAVE_DPI_INDEPENDENT_PIXELS to wxHAS_XXX and document it
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.
2022-01-13 17:34:49 +00:00
Vadim Zeitlin
f78db92462 Avoid bitmap scaling in wxArtProvider::GetBitmapBundle()
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.
2022-01-13 17:34:49 +00:00
Vadim Zeitlin
603c45fbe9 Make sure the icon fits into the AUI pane title bar vertically
With scaled bitmaps, the preferred bitmap version might be too big for
the pane.

Perhaps it's the title bar height which is too small, but it seems to
have been hardcoded to 17 pixels since the very first version in
50acee04cd (Initial commit of wxAUI, 2006-06-06), so don't change it.
2022-01-13 17:34:49 +00:00
Vadim Zeitlin
b35ffa5e41 Use per-window DPI scale factor in wxAuiGenericTabArt
8dcedf56d7 (Add wxWindow parameter to wxAuiTabArt::SetSizingInfo(),
2021-11-13) added "wnd" argument to SetSizingInfo(), so use it instead
of always using the DPI of the main monitor.
2022-01-13 17:34:48 +00:00
Vadim Zeitlin
d78696243b Set scale factor correctly for icons loaded from resources
::LoadIcon() selects the icon of scaled size in the DPI-aware programs,
which is nice, but only works right if we actually set the scale factor
for the icon correctly.
2021-12-16 01:17:35 +00:00
Vadim Zeitlin
a1e4dca067 Store scale factor in wxMSW bitmaps too
Even though it's not really used by MSW code itself, the scale factor is
still needed to determine the correct default bitmap bundle size, for
example: it should be possible to create a bundle with just a single
64x64 bitmap and use it unscaled in 200% DPI, for example, rather than
scaling it up to 128x128 bitmap.
2021-12-16 01:15:17 +00:00
Vadim Zeitlin
0a8f7233cc Merge branch 'virtual-list-sort-indicator'
Simplify recently added wxListCtrl sort indicators support and allow
using it with virtual list controls too.

See https://github.com/wxWidgets/wxWidgets/pull/2618
2021-12-14 19:28:20 +00:00
Vadim Zeitlin
e3ec9fb124 Fix using wxMemoryDC without a GUI wxApp instance
This used to work, at least in wxMSW, but stopped working after the
(perfectly valid, on their own) changes of 2508efdd6e (Initialize
wxMemoryDC with a default font, 2019-08-13), as this resulted in calling
wxApp::GetTopWindow() that can only be called from the GUI code.

Fix this by adding wxApp::GetGUIInstance() and using it in
GetMainTopWindow(), so that we only call GetTopWindow() if we actually
have a GUI wxApp object on which to call it.

Implement this in terms of a new virtual IsGUI() which seems slightly
better than, although roughly equivalent to, using wxDynamicCast().

Closes https://github.com/wxWidgets/wxWidgets/pull/2617

Closes #19343.
2021-12-14 19:28:02 +00:00
Vadim Zeitlin
52649cc566 Remove wxListCtrl::EnableSortIndicator()
The old API seems unnecessarily complex, it is simpler to just let the
application call ShowSortIndicator() itself from its
wxEVT_LIST_COL_CLICK handler, which needs to be defined anyhow in order
to actually sort the items, rather than require it to enable sort
indicator, explicitly set it initially and then remember to not set it
any longer in response to the column clicks.

Also make RemoveSortIndicator() non-virtual and implement it simply as
ShowSortIndicator(-1) because this actually simplifies the code too.
2021-12-14 14:09:23 +00:00
Vadim Zeitlin
30ce892ed5 Let wxListCtrl::ShowSortIndicator() implicitly enable indicators
It doesn't seem right for ShowSortIndicator() to silently do nothing if
EnableSortIndicator() hadn't been called before, so make it enable the
sort indicators if they hadn't been enabled yet.

The alternative would be to assert in this function, but this seems less
useful.

Also add some comments to wxMSW version.
2021-12-13 14:31:49 +00:00
Vadim Zeitlin
c287840faa Optimize changing sort indicator in wxGenericListCtrl
Don't do anything at all if nothing changes and if the indicator does
change, refresh only the header window and not the whole list control,
which seems unnecessary.
2021-12-13 14:29:59 +00:00
Vadim Zeitlin
58290168e5 Remove top level "const" from {Enable,Show}SortIndicator()
Don't use "const int" or "const bool" for parameter types, the "const"
here is ignored and using it is inconsistent with all the rest of the
library.

No real changes.
2021-12-13 14:18:18 +00:00
Vadim Zeitlin
dbe8e30b56 Allow using column sort indicators in virtual wxListCtrl too
There doesn't seem to be any reason to not show sort indicators in the
columns of virtual list controls, so simply remove the test for
IsVirtual() in DrawSortArrow().

This allows d8ec0aa001 (Support sort indicators in wxListCtrl header,
2021-11-28) to work for wxListCtrl with wxLC_VIRTUAL too.
2021-12-13 14:15:25 +00:00
Vadim Zeitlin
b9a1931394 Fix using MSW wxStaticBitmap with custom wxBitmapBundles
wxBitmapBundle-related changes introduced a bug when wxStaticBitmap
could be using an invalid handle (which manifested itself in not showing
any image on screen) if it was using wxBitmapBundle whose GetBitmap()
returned a wxBitmap that wasn't cached inside wxBitmapBundle itself.

In this case, this wxBitmap wasn't referenced anywhere after being
associated with wxStaticBitmap and so was destroyed, invalidating the
HBITMAP used by the native static control.

Fix this by keeping a copy of the bitmap in wxStaticBitmap itself. This
is not the most efficient, but is the simplest, solution.
2021-12-12 23:39:48 +00:00
Vadim Zeitlin
e211a451fe Re-realize wxAuiToolBar on DPI change to fix its layout
The layout of the toolbar depends on the size of its bitmaps, which
changes when the DPI does, so call Realize() again when this happens.

This fixes the layout of the toolbars in the aui sample when moving it
between screens using different DPI.
2021-12-12 23:16:28 +00:00
Vadim Zeitlin
6156bb1b84 Merge branch 'wxlistctrl-sort' of https://github.com/MaartenBent/wxWidgets
Add sort indicators support to wxListCtrl.

See https://github.com/wxWidgets/wxWidgets/pull/2598
2021-12-09 21:29:39 +01:00
Vadim Zeitlin
933ac7afbb Merge branch 'dvc-null-values'
Improve handling of null values in wxDataViewCtrl to be more compatible
with the earlier versions.

See https://github.com/wxWidgets/wxWidgets/pull/2602

See #18934.

Closes #19333.
2021-12-09 20:00:50 +01:00
Richard Gibson
c3d5853faa Fix handling symlinks in wxOSX wxFileSystemWatcher
Set the correct file path for symlink creation/deletion events.

Closes https://github.com/wxWidgets/wxWidgets/pull/2611
2021-12-09 19:57:00 +01:00
Marco DeFreitas
a2389fc512 Add wxApp::GTKSuppressDiagnostics()
This allows to avoid GTK messages that are often more annoying and
confusing than useful.

Closes https://github.com/wxWidgets/wxWidgets/pull/2609

Closes #19347.
2021-12-09 19:52:07 +01:00
Maarten Bent
d8ec0aa001 Support sort indicators in wxListCtrl header 2021-12-09 17:32:05 +01:00
Jouk
f9b1d71dab add bmpsvg.cpp for compilation on OpenVMS 2021-12-06 13:31:54 +01:00
Artur Wieczorek
67752c3870 Validate the value in the first and last property of wxPropertyGrid
wxPGProperty value edited in the first or last property of wxPropertyGrid
should be validated while attempting to navigate to the previous/next
property.

Closes #19315.
2021-12-04 12:18:20 +01:00
Vadim Zeitlin
552c9dd4ff Fix wxMSW wxDateTimePickerCtrl build with wxUSE_UNICODE_UTF8
Don't use the ternary operator as t_str() doesn't return a pointer in
this build configuration.

Also remove outdated (and maybe even wrong) comment about MinGW headers,
as it's better to use a temporary variable just to avoid writing the
cast explicitly anyhow.

Closes #19338.
2021-12-03 15:49:30 +01:00
novak
cb3f8f3a5c Fix printing framework compilation with wxUSE_VALIDATORS=0
Include wx/textctrl.h, required here because wxTextCtrl is used as the
base class of wxPrintPageTextCtrl, explicitly instead of relying on it
being implicitly included by something else, as it happens in the
default build but not when validators are disabled.

Closes #19337.
2021-12-03 15:46:43 +01:00
novak
c498d6d090 Fix wxBusyInfo compilation when wxUSE_MARKUP=0
Just use SetLabelText() instead of SetLabelMarkup() in this case, as
it's already done elsewhere.

Closes #19336.
2021-12-03 15:44:52 +01:00
Vadim Zeitlin
8311951f03 Don't use wxVector<T>::clear() when T is an incomplete type
At least the OpenVMS compiler doesn't like it and we can easily avoid
doing this by simply moving ClearExtraAccels() definition to the source
file.
2021-12-03 15:37:11 +01:00
Vadim Zeitlin
149db36bc8 Fix memset_s() compilation errors under macOS with some SDKs
Define __STDC_WANT_LIB_EXT1__ as early as possible to ensure that it's
defined before string.h is included by some other header without it.

Closes #19334.
2021-12-03 15:23:26 +01:00
Vadim Zeitlin
30fceb1d92 Merge branch 'define-use-svg-in-features.h'
Move wxUSE_SVG definition to wx/defs.h and work around OpenVMS
compilation problems.

See https://github.com/wxWidgets/wxWidgets/pull/2606
2021-12-03 15:20:51 +01:00
Vadim Zeitlin
35e97d9d50 Use wxDPIChangedEvent::ScaleX() for a horizontal coordinate
This doesn't really change anything as the scaling factor is always the
same in both directions currently, but is more consistent with the other
places where Scale[XY]() are used.

This slightly amends the changes of 3787f55a6b (Add
wxDPIChangedEvent::Scale() and use it in this event handlers,
2021-07-11).
2021-12-03 15:20:31 +01:00
Vadim Zeitlin
9e050fb1c5 Include NanoSVG headers before including (almost) any wx headers
OpenVMS C++ compiler can't compile NanoSVG headers after including
wx/unichar.h, so include them as soon as possible, i.e. right after
wx/wxprec.h but before anything else.

This commit is best viewed with --color-moved git option.
2021-12-02 15:31:04 +01:00
Vadim Zeitlin
882a339a48 Move wxHAS_SVG definition to wx/features.h
This is more consistent with the other wxHAS_XXXs and makes it possible
to only include wx/bmpbndl.h in bmpsvg.cpp if SVG support is indeed
available.
2021-12-02 15:25:06 +01:00
Tobias Taschner
bbca67df67 Implement wxFSVolume for macOS
Implement with NSFileManager and NSURL to provide basic functionality
like on MSW. Icons are not implemented for macOS.
2021-12-01 23:35:19 +01:00
Vadim Zeitlin
419a97a791 Merge branch 'svg-file'
Add wxBitmapBundle::FromSVGFile() helper.

See https://github.com/wxWidgets/wxWidgets/pull/2600
2021-12-01 23:27:33 +01:00
Scott Talbert
82735e8612 Use wxSpinCtrl best size in wxGenericCalendarCtrl::DoGetBestSize
This fixes the wxGenericCalendarCtrl on wxGTK3 where the SpinCtrl is
much wider than on other platforms and should also ensure that the
control is always big enough in all locales under Mac.

Closes https://github.com/wxWidgets/wxWidgets/pull/2604

Closes #11444.
2021-12-01 23:23:34 +01:00
Vadim Zeitlin
74e1c444fa Don't show bogus value when there are none in wxGTK wxDVC neither
This is similar to the previous change to the generic version and simply
applies the same logic to the cells for which GetValue() returns null
value as for those for which HasValue() returns false.
2021-12-01 01:43:52 +00:00
Vadim Zeitlin
55420130b5 Don't use items without values in generic wxDVC
In particular, don't draw them, as this would reuse the value of the
previously drawn item, which would be wrong -- just leave them blank if
PrepareForItem() returned false, which happens if GetValue() returned a
null value or a value of a wrong type.
2021-12-01 01:43:52 +00:00
Vadim Zeitlin
9cb360a0aa Don't call SetValue() with null value in wxOSX wxDVC
We can't guarantee that GetValue() returns a valid value, even if
HasValue() returned true, so avoid calling SetValue() if it returned an
invalid one, as this risks triggering an assert failure and because this
function is typically called when repainting the control, there is a
good chance that we're going to reenter it while showing the assert
dialog box, resulting in an abort, which is not the best way to handle
GetValue() not returning a valid value -- especially when the generic
version doesn't do this, so the problem risks only appearing when
porting to Mac.
2021-12-01 02:22:06 +01:00
Vadim Zeitlin
1ef8d1d48f Avoid warning about not supporting setAccessoryViewDisclosed:
We call it inside the check ensuring that it is supported, so suppress
this warning (introduced in the recent e765756555 (OSX file dialog
extensions (#2592), 2021-11-26)) by casting the receiver to the generic
type, just as it's already done elsewhere in wxOSX code.
2021-12-01 00:05:35 +01:00
Vadim Zeitlin
95b7a2f183 Return false from PrepareForItem() if there is no value
This corresponds to the behaviour described in the comment and is more
useful than always returning true.
2021-11-30 23:03:28 +00:00
Vadim Zeitlin
26c6273a70 Fix crash when setting wxGTK wxNotebook image after creation
The bug was introduced in 9d86ba11e2 (Add support for wxBitmapBundle to
wxGTK wxNotebook, 2021-11-07) after which wxGtkNotebookPage::m_image
remained uninitialized if the page didn't have an image initially, so
fix it by simply initializing this pointer to NULL in this case.

It would arguably be better if wxGtkNotebookPage initialized all its
members in the ctor, but for now just fix the critical bug.

Closes #19332.
2021-11-30 18:13:21 +01:00
Paul Cornett
982a030705 Remove some incorrect ifdefs from wxGenericTreeCtrl
It's clear from the change history (relevant commits listed below) that these
are leftovers from code that is long gone.

ccdbdc8936 (Added native selection rectangle drawing., 2006-11-11)
05d9753817 (Just use the already existing wxRenderer::DrawItemSelectionRect(), 2006-11-14)
a4609ab847 (Implement wxRendererMac::DrawItemSelectionRect and move the generic wxTreeCtrl to using it to draw selected items., 2006-11-19)
2021-11-29 08:53:23 -08:00
Vadim Zeitlin
8adfaa37f7 Add wxBitmapBundle::FromSVGFile() helper
This is just a trivial wrapper for wxBitmapBundle::FromSVG(), but it can
still be convenient to have.
2021-11-29 12:55:22 +00:00
Artur Wieczorek
9febbe2b30 Explicitly cast AutoHRGN to HRGN to unify types in the statement
This seems to be required by MinGW compiler.
2021-11-28 19:32:02 +01:00
Artur Wieczorek
288b208a0a Fix setting clipping region for wxDC with RTL enabled (wxMSW)
It turns out that region being added to DC with enabled RTL layout needs
to be defined using mirrored device x-coordinates.
So if we have DC with RTL layout we need to create a temporary mirrored
region and pass it to the DC instead of the original one.

Closes #19325.
2021-11-28 17:04:26 +01:00
Paul Cornett
b04c1ace47 Avoid integer overflow when computing image data size in wxImage::Create()
See #19326

Co-Authored-By: David Costanzo <david_costanzo@yahoo.com>
2021-11-27 17:14:28 -08:00
utelle
deef116a09 Update language database and move support for it to wxUILocale
Update the language database from the canonical sources:

- It now includes most locales supported by Windows 10.
- It now also has the following attributes for each entry:
 - BCP 47-like locale tag.
 - Reference to canonical name for generic language entries.
 - Language name in this language itself.
- Also add data file with list of language script identifiers and
  aliases based on ISO 15924.
- And update genlang.py to handle all the new attributes and data.

Also move database-related methods of wxLocale to wxUILocale and
just redirect wxLocale methods to the new wxUILocale ones (they are
still preserved for compatibility).

Closes https://github.com/wxWidgets/wxWidgets/pull/2594
2021-11-27 17:44:20 +01:00
Stefan Csomor
e765756555 OSX file dialog extensions (#2592)
Re-introduce OpenSavePanelDelegate for filtering when wildcard is provided (Spotlight search field was not working correctly, if extension was not known)
(and on macOS 10.11 allow programmatically showing the extra panel)

see http://www.github.com/wxWidgets/wxWidgets/pull/2592 and https://trac.wxwidgets.org/ticket/19324

co-authered-by: Jeff Young <jeff at rokeby dot ie>
2021-11-26 22:26:49 +01:00
Vadim Zeitlin
c5f023a829 Fix wxGTK1 build after wxBitmapBundle changes in wxStaticBitmap
This should have been done in 3abec9254f (Take wxBitmapBundle in
wxStaticBitmap::SetBitmap(), 2021-10-21) but was forgotten there.
2021-11-26 18:31:19 +01:00