Commit Graph

71885 Commits

Author SHA1 Message Date
Vadim Zeitlin
3c7b40e999 Merge branch 'clang-13-no-depr-copy'
Fix clang 13 -Wdeprecated-copy warnings and ensure that we test for them
in the allheaders test.

See https://github.com/wxWidgets/wxWidgets/pull/2619
2021-12-16 21:13:55 +01: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
9aaadab7d6 Check for most clang warnings in our headers in the test suite
Make allheaders unit test also enable -Wall, -Wextra and -Wpedantic for
clang to detect any warnings it might give in wx headers.

Don't use -Weverything because there are just too many warnings we'd
need to disable then.
2021-12-15 17:50:55 +01:00
Vadim Zeitlin
6f8bc1018b Avoid -Wdeprecated-copy for many event classes from clang 13
Add new macros wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY() and
wxDECLARE_NO_ASSIGN_DEF_COPY() and use them instead of
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN() and wxDECLARE_NO_ASSIGN_CLASS()
respectively to ensure that we declare a (default, if possible) copy
ctor in the classes declaring an assignment operator to avoid clang
warnings about not doing it.
2021-12-15 17:50:55 +01:00
Vadim Zeitlin
e2d13c2d94 Show build environment and compiler version for Mac CI builds
This is similar to 6e96c6dda0 (Add "Show build environment" step,
2021-10-27) done for the Unix CI builds.
2021-12-15 17:50:55 +01:00
Vadim Zeitlin
28c3605f6b Factor out 3 copies of identical code into wxInputStreamPeeker
Resolve the long standing "NOTE" comments about having the same code in
wxAnimationDecoder::CanRead(), wxImage::CanRead() and GetImageCount() by
extracting the common logic into a helper wxInputStreamPeeker class and
using it from all places.

This loses the possibility to log a debug message if rewinding the
stream fails, but this is probably not very valuable and the actual
error should be already logged by SeekI() itself when it fails on a
seekable stream.

No real changes.
2021-12-15 17:50:20 +01: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
c834c0b8b7 Add GetUpdatedAscendingSortIndicator() helper function
It seems like this function will need to be used in every implementation
of EVT_LIST_COL_CLICK handler when using sorting, so it makes sense to
provide it in the library itself.
2021-12-14 14:22:08 +00:00
Vadim Zeitlin
0a8e82b010 Rename formal parameter of ShowSortIndicator() to "col"
No real changes, just use a more appropriate parameter name, as it's a
column index and not just "index".
2021-12-14 14:19:10 +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
2679f99f51 Revert apparently unrelated changes to wxCocoaDataViewControl
This reverts some changes of 7129d2b11c (Accept multiple data formats
via drag-and-drop in wxDataViewCtrl, 2021-08-22) that don't seem to be
related to its actual purpose and were probably done accidentally.
2021-12-10 20:42:18 +01:00
Vadim Zeitlin
5ed5803deb Undo the now unnecessary change to the sample
The previously working code should continue to work, so keep the
original version now that it does work after the changes of the previous
commit.

Just mention in the comment that te data object can also be retrieved
directly.
2021-12-10 20:42:18 +01:00
Vadim Zeitlin
33018ea7a9 Copy dropped data to wxDataViewEvent
Existing code relies on GetDataBuffer() returning a valid pointer, so we
need to ensure that this is the case, even if this means copying the
data into an internal buffer.
2021-12-10 20:42:18 +01:00
Vadim Zeitlin
7797ffc730 Add wxDataViewEvent::InitData() helper
Reuse it from both the generic and macOS versions to avoid doing the
same thing in both of them.
2021-12-10 20:42:18 +01:00
Vadim Zeitlin
31bdfd6523 Make CreateDataObject() return wxDataObjectComposite
This function must return a composite data object and not just any
wxDataObject because its callers cast the returned object to this class,
so make it a bit more type-safe.
2021-12-10 20:06:30 +01:00
Vadim Zeitlin
352923dc8d Make wxDataViewCtrlBase::CreateDataObject() static
This function doesn't need to be virtual as it's not meant to be
overridden in, but just called from the derived classes. In fact, it
doesn't even have to be a member function at all, but leave it in the
class for now to avoid having to create a new header just for it, but
make it static.

Also add a comment explaining what is it for and what it does.
2021-12-10 20:00:15 +01:00
Vadim Zeitlin
cd555f9ff5 Use vector instead of array of wxDataFormats
Also rename EnableDropTarget() to EnableDropTargets(), as calling
EnableDropTarget(wxDF_XXX) would be ambiguous due to the existence of a
non-explicit wxVector ctor taking size_t (which is a mistake on its own,
but is probably not worth changing any more).
2021-12-10 19:57:41 +01:00
Vadim Zeitlin
1499d7d45b Handle wxDF_PNG in wxDataViewCtrlBase::CreateDataObject() too
If nothing else, this avoids warnings about missing enum element in the
switch.
2021-12-10 19:57:41 +01:00
Vadim Zeitlin
a0e32cadd9 Slightly improve wording in EnableDropTarget() documentation
No real changes.
2021-12-10 19:57:39 +01:00
Vadim Zeitlin
a279c7b607 Update the version in which EnableDropTarget() overload was added 2021-12-10 19:56:52 +01:00
valid-ptr
7129d2b11c Accept multiple data formats via drag-and-drop in wxDataViewCtrl
Allow specifying multiple formats to be accepted when dragging data to
wxDataViewCtrl in the generic and Cocoa implementations.

Add wxDataViewCtrlBase::EnableDropTarget() overload taking an array of
wxDataFormats to support this at the API level.

Add new DoEnableDropTarget() used by both EnableDropTarget() overloads
and implement it in the generic and Cocoa ports. GTK implementation
still uses only a single format, as before.

Also refactor the Cocoa implementation: all operations using dragged
data are now handled by wxDropTarget and unnecessary DataViewPboardType
as removed.

Update the dataview sample to show the new functionality.
2021-12-10 19:55:44 +01:00
Vadim Zeitlin
d30986be78 Merge branch 'ci-cmake-msvc'
Add CMake build using MSVC with ninja to GitHub Action CI workflow.

See https://github.com/wxWidgets/wxWidgets/pull/2613
2021-12-10 19:04:11 +01:00
Vadim Zeitlin
ddde0f1eea Reenable cmake install step for Windows builds
Just skip using sudo under this OS, but still run "cmake install" as
this is required for the final test, checking the installation success,
to work.
2021-12-10 18:00:38 +01:00
Vadim Zeitlin
d1b5fd27aa Enable long path normalization test by default
It seems that the default value of NtfsDisable8dot3NameCreation registry
value is 2, and not 0, since a very long time (at least Windows 7), so
the wxPATH_NORM_LONG test was never actually executed.

Change the check guarding it to check if the value of the key is
different from 1 instead of checking that it is 0, as the test can still
succeed on the systems where this is the case.

Of course, it can also fail, if short names are disabled for the current
volume, but let's see if this is a problem in practice before doing
something more complicated to deal with this case.
2021-12-10 17:27:06 +01:00
Vadim Zeitlin
b247a1ee70 Use testdata.conf for the wxPATH_NORM_LONG test
This file already exists in the test directory, as it's used by another
test, so just use it instead of relying on the existing of mkinstalldirs
in the parent directory, which is not guaranteed as CMake build runs the
tests from a different directory, which is not the immediate child of
the top source directory.
2021-12-10 17:27:02 +01:00
Vadim Zeitlin
1e683c1401 Rename testdata.fc to testdata.conf
No real changes, just use a more clear and longer (which will be
important for the next commit) name for a test file.

Remove the non-existing samples/console/testdata.gc from make_dist.mk
(there are other non-existing files still referenced there).
2021-12-10 17:26:49 +01:00
Vadim Zeitlin
65b9b1047f Avoid adjusting columns unnecessary on thaw
Remember if we actually need to do this and avoid doing anything if we
don't, this could be expensive with the controls containing a lot of
data.
2021-12-09 23:30:44 +01:00
Vadim Zeitlin
5545e35f42 Get rid of "bool force" AdjustAutosizedColumns() parameter
It is better and more clear to use a separate functions rather than a
"bool force" parameter.

Also add OnThaw() instead to let wxOSXDataViewModelNotifier itself
decide what it needs to do when the control is thawed.

No real changes.
2021-12-09 23:30:11 +01:00
Vadim Zeitlin
8cc7d6d993 Remove unnecessary test for IsFrozen()
wxOSXDataViewModelNotifier::AdjustAutosizedColumns() does nothing if the
control is frozen, so there is no need to test for it before calling it
and this just made this call inconsistent with all the other ones.
2021-12-09 23:19:33 +01:00
Daniel Kulp
7557b8fa49 Don't adjust column sizes when wxDataViewCtrl is frozen in wxOSX
Only do it after thawing it.
2021-12-09 23:15:40 +01:00
Vadim Zeitlin
c39c119707 Try to force compiler choice to MSVC
Otherwise clang compiler is being chosen, even if MSVC should be
available.
2021-12-09 23:09:18 +01: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
17e307ae67 Skip install step under MSW
This wouldn't work anyhow as "sudo" doesn't exist under this platform.
2021-12-09 20:23:44 +01:00
Vadim Zeitlin
25ede89983 Use bash for all build steps for MSW CMake build
Otherwise references to the variables don't work as expected.
2021-12-09 20:22:48 +01:00
Be
4ab869543f Add CMake build with MSVC to GitHub Action CI workflow 2021-12-09 20:09:21 +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
Maarten Bent
248927a090 CMake: Never add static runtime flags on macOS
This option is disabled in the GUI, but users can still specify it on the
command-line. Never add the linker flags to prevent errors (unsupported option
'-static-libgcc') or warnings (argument unused during compilation:
'-static-libstdc++').

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

Closes #19330.
2021-12-09 19:59:15 +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
Simon Stone
0fc936ca41 Add wxIntegerValidatorctor ctor taking minimum and maximum value
Using this ctor is more convenient than using the default ctor and then
calling SetMin() and SetMax().

Document the new ctor and add tests showing that minimum and maximum
values are actually respected.

Closes https://github.com/wxWidgets/wxWidgets/pull/2610
2021-12-09 19:55:44 +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
Scott Talbert
a0eb355e12 Add wxDF_UNICODETEXT to wxDataFormat standard format docs
Closes https://github.com/wxWidgets/wxWidgets/pull/2608
2021-12-09 19:51:07 +01:00
Maarten Bent
4cb8539f72 Add missing wxOVERRIDE to MSWWindowProc of wxListCtrl 2021-12-09 18:18:28 +01:00