Commit Graph

69199 Commits

Author SHA1 Message Date
Václav Slavík
9c5abea266 Don’t add non-default focus ring to NSTextView
NSTextView does not natively show a focus ring by default, and it is
extremely rare thing to do in native applications.

Don't do it in wxTextCtrl either.
2020-08-31 10:38:59 +02:00
Václav Slavík
9f66b03c5c Allow configuring visible focus on Mac
Add wxWindow::EnableVisibleFocus() for changing focus ring behavior on
macOS (currently not implemented elsewhere, although GTK+ has a
discouraged option to do it).
2020-08-31 10:38:59 +02:00
Vadim Zeitlin
24914ec7df Suppress unavoidable -Wformat-literal in wx[F]printf()
Disable gcc format string checks inside these functions.
2020-08-31 01:26:04 +02:00
Vadim Zeitlin
36c5884acb Generalize WX_ATTRIBUTE_PRINTF to WX_ATTRIBUTE_FORMAT
Allow applying gcc "format" attribute to other functions and do apply it
to wxStrftime().

Also suppress -Wformat-nonliteral inside wxStrftime() itself, as it's
now supposed to be checked when calling it.
2020-08-31 01:25:45 +02:00
Vadim Zeitlin
7352a2879c Rename Qt-specific GetEventType() to start with "Qt" prefix
This avoids conflicts with another method with the same name defined in
generic wxGenericFileDirButton, which must neither override nor hide
this method of wxButton.
2020-08-31 01:25:45 +02:00
Vadim Zeitlin
9f63592eba Remove unnecessary wxBitmap copy ctor from wxQt
This ctor is not needed as the inherited wxObject ctor is sufficient and
defining it but not operator=() explicitly results in -Wdeprecated-copy
from gcc 10.
2020-08-31 01:25:45 +02:00
Vadim Zeitlin
19bc293086 Remove extraneous semicolon in wx/qt/menuitem.h
Avoid -Wpedantic from gcc.
2020-08-31 01:25:45 +02:00
Vadim Zeitlin
3bbefcdd74 Don't trigger warnings in standard headers when building wxQt
Pre-include QFont header in wxQt to avoid warnings for the other headers
included from it.
2020-08-31 01:25:45 +02:00
Vadim Zeitlin
9c2cf91223 Don't remove const-ness using C-style cast
Avoid another -Wcast-qual from gcc.
2020-08-31 01:25:45 +02:00
Vadim Zeitlin
9c48b0e8e7 Remove redundant wxSetCursor() declarations
Avoid -Wredundant-decls from gcc by not duplicating the declaration from
wx/gdicmn.h in wx/*/cursor.h.
2020-08-31 01:25:45 +02:00
Vadim Zeitlin
9206a9de00 Remove trailing semicolon from wxDFB_DECLARE_INTERFACE()
This avoids -Wpedantic warnings when a semicolon is used after it.
2020-08-31 01:25:45 +02:00
Vadim Zeitlin
dca6f310bb Replace C-style cast with const_cast<> in wxUniv
Don't use C casts to remove const-ness (avoids gcc -Wcast-qual).
2020-08-31 01:25:45 +02:00
Vadim Zeitlin
ca7fcfe9c3 Add wxGCC_ONLY_WARNING_{SUPPRESS,RESTORE} macros
When the original wxGCC_WARNING_SUPPRESS was added, clang understood all
gcc warnings, so it made sense to also apply it when building with
clang, but recent gcc versions have added warnings not available in
clang any more, so we now need a macro for disabling warning the
warnings for gcc only.

Perhaps we should rename the existing wxGCC_XXX macros to use
wxGCC_OR_CLANG prefix.
2020-08-31 01:25:45 +02:00
Vadim Zeitlin
266c3a962f Disable -Winline as we can't ensure all functions are inlined
It doesn't really make sense to enable this for C++ code, with a lot of
implicitly inline functions.
2020-08-31 01:25:07 +02:00
Vadim Zeitlin
1861065ef2 Disable -Wformat in system headers
This is given for the use of %zu by gcc 5.4.
2020-08-31 01:25:07 +02:00
Vadim Zeitlin
3c628138f5 Suppress bogus -Wnoexcept from gcc9 in wx/graphics.h
Due to what looks like a bug, gcc 9.3.0 gives the following incomplete
error message without it:

include/wx/graphics.h:278:7: error: but
‘wxGraphicsGradientStop::wxGraphicsGradientStop(wxGraphicsGradientStop&&)’
does not throw; perhaps it should be declared ‘noexcept’
[-Werror=noexcept]

(without any other diagnostics).
2020-08-31 01:25:07 +02:00
Vadim Zeitlin
7d74df9a03 Add wxNOEXCEPT to the hash structs operator() declarations
gcc 9 gives -Wnoexcept for these operators and, apparently, not making
them noexcept prevents some optimizations in the standard library
implementation of unordered_foo<>, so do add it.
2020-08-31 01:25:07 +02:00
Vadim Zeitlin
831979ead1 Suppress gcc -Wctor-dtor-privacy in wx/strvararg.h
Helper structs declared in this header intentionally define their ctor
as private, avoid gcc complaints about it.
2020-08-31 01:25:07 +02:00
Vadim Zeitlin
2f605badf3 Fix g++ 4.8 -Wshadow for parameter/function conflicts
Unlike the later versions, g++ 4.8 produces a -Wshadow when the name of
a parameter is the same of the name of a method, so rename the (private)
parameters to avoid this.
2020-08-31 01:25:07 +02:00
Vadim Zeitlin
23334af81b Test headers compilation with maximum warnings options with gcc
As wx headers are included from user applications which may compile with
higher warning level than wx itself, try to check headers compilation
with almost all of gcc warning flags turned on.

This notably should prevent the headers from becoming uncompilable with
-pedantic again in the future.
2020-08-31 01:24:57 +02:00
Václav Slavík
58c94d9ec0 Draw wxTextCtrl focus ring natively on Mac
NSTextView doesn't display focus ring by default, which is why wxOSX
did draw it manually, but this behavior can be overriden since OS X
10.3 with NSView.focusRingType property.

The HITheme-based rendering suffered from a number of non-nativeness
issues:
- didn't respect macOS 10.14+ accent colors
- not animated as the native focus ring
- subtly different shape of the outline
- noticeably different outline shape on macOS 11

Remove NeedsFocusRect() and associated workaround for manually drawing
focus ring inside NSTextView (i.e. multiline text controls). This
private interface was only used for wxTextCtrl and nothing else, so
this shouldn't have any impact elsewhere.
2020-08-30 18:32:07 +02:00
Václav Slavík
587190c95c Size preferences pages correctly on macOS 11
Preferences windows traditionally changed their size on macOS when going
between tabs (pages): the window would resize, with animation, to fit the
current tab’s content and avoid wasted space. This worked well, because the
icons toolbar was left-aligned and so changing window size by growing/shrinking
it to the right or down felt natural.

This changes in macOS 11 where preferences toolbar icons are centered and would
shift around if the window resized horizontally. Indeed, the new standard is to
keep the width and only change window height when switching between pages.

Implement this behavior in wxPreferencesEditor too. This requires us to
instantiate all pages early (as is done on other platforms), so this on Big Sur
or newer only.
2020-08-29 19:53:33 +02:00
Václav Slavík
b6bc50d16e Use macOS 11 icons in wxStockPreferencesPage
Ase the appropriate SF Symbols for General and Advanced preferences pages on
macOS 11, while still using the old templates on older systems.
2020-08-27 19:11:07 +02:00
Václav Slavík
acf02be808 Support SF Symbols images on macOS 11
Extend wxOSXGetSystemImage() and thus wxArtProvider with support for directly
loading the new symbolic images in addition to existing support for named
bundle resources.

This enables usage such as wxArtProvider::GetBitmap("gearshape").
2020-08-27 19:11:07 +02:00
Václav Slavík
ab29743097 Use correct toolbar style for preferences on macOS 11
Code compiled against macOS 11 SDK must explicitly specify that the window
should use preferences-style toolbar, otherwise the tabs would be moved to the
right alongside window title, as is done with the standard toolbar now.
2020-08-27 19:11:07 +02:00
Václav Slavík
b03fa9c37f Fix UI font serialization on macOS 11
e86154fc is insufficient, because there's still one situation when
PostScript names can't be avoided: when storing them using
wxNativeFontInfo::ToString().

Co-authored-by: Stefan Csomor <csomor@advancedconcepts.ch>
2020-08-27 13:10:45 +02:00
Václav Slavík
9e68df224f Fix colored markup drawing in Mac wxDataViewCtrl
50ba73c accidentally omitted an if (colText) check, causing calls to
setTextColor:nil - which in turn caused markup text (but curiously, not
plain) rendering to stick with a previously set color even on cells
where the default color should be used.

Restoring the original logic to prevent setTextColor:nil fixes it.
2020-08-26 19:28:32 +02:00
Václav Slavík
e86154fcd2 Fix system UI font handling on macOS 11
PostScript name for the system SF font, starting with a dot, was always
considered private, but it was possible to round-trip it. Starting with
macOS 11, font descriptors can't be created from such names and result
in a Times font fallback.

To complicate matters further, the way PostScript name of the system
font is created changed too: it is no longer universal for entire
family, but specifies the weight too.

This combined together makes it impossible to store or modify system
fonts.

Fix by not relying on PostScript names internally. Only use them when
serializing font description or where needed, and in such cases obtain
it from CTFontDescriptor on demand.

Still preserve m_postScriptName as a user-provided detail, and treat it
as such: if provided, it is sacred and used to create font descriptors;
if not provided, never fill it in from other data.
2020-08-26 19:08:32 +02:00
Andreas Falkenhahn
a59901f8f1 Fix bug in CanUndo() returning true after wxTextCtrl creation
For wxMSW text controls with wxTE_RICH2 style, calling SetFont() counts
as an undoable operation, resulting in CanUndo() returning true even if
no "real" changes have been made yet.

Fix this by resetting the undo stack after creating the control using
ITextDocument::Undo().

Unfortunately this interface is not available in MinGW-32, so this fix
can't be used with it.

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

Closes #17524.
2020-08-25 18:10:20 +02:00
Vadim Zeitlin
1ec571fb64 Avoid -Wshadow warnings when using multiple wxCHECK()s
If the same function used any of macros from wxCHECK() family more than
once, wxDummyCheckStruct was redeclared, resulting in -Wshadow warnings
from gcc.

Fix this by using unique names for the dummy macro.
2020-08-25 17:37:25 +02:00
Vadim Zeitlin
054d98b1df Fix -Wpedantic in wxDECLARE_ABSTRACT_CLASS()
Fix a regression introduced in c924ecb10a (Suppress -Wsuggest-override
warnings in user code for gcc too, 2020-07-27) and rearrange the macro
to make sure a semicolon is necessary after it.

Closes #18901.
2020-08-25 17:36:02 +02:00
Vadim Zeitlin
30fc873626 Remove useless hdrstop pragma from allheaders test
It shouldn't be necessary for a test not using PCH at all and Borland
compiler is almost certainly not supported anyhow any longer.
2020-08-25 16:54:23 +02:00
Vadim Zeitlin
29a2b481a5 Fix documented type of wxART_XXX constants
They're (now, and had always been before the recent changes) string
literals, i.e. of type "const char *", rather than "wxString".
2020-08-25 16:49:24 +02:00
Vadim Zeitlin
873e028ffa Document wxASCII_STR() macro
Also improve wxString::FromAscii() documentation slightly.
2020-08-25 16:49:05 +02:00
Vadim Zeitlin
79c98b31a4 Don't use wxASCII_STR() inside wxART_MAKE_XXX_ID macros
This changed the type of the art and client ID values, which broke
compatibility with existing code, notably in wxPython (see
https://github.com/wxWidgets/wxWidgets/pull/1996), and the attempts to
fix this compatibility broke it with all the existing code using
wxART_MAKE_ART_ID() or wxART_MAKE_CLIENT_ID() for their own IDs.

Keep things simple and just define the macros as they were defined
before 4552009805 (Merge branch 'pr1312-no-unsafe-wxstring-conv',
2020-07-20), except for wxART_MAKE_CLIENT_ID_FROM_STR() whose argument
and produced value was already of wxString type, and use wxASCII_STR()
at the place of use of wxART_XXX constants in wx code.

This is obviously not ideal as it will require using wxASCII_STR() in
the application code as well, but seems to be the least evil.
2020-08-24 16:47:37 +02:00
Vadim Zeitlin
30b37b610d Revert "Merge branch 'string-art-ids'"
This reverts commit 8c9ba23eae, reversing
changes made to 5192feb38e.

Upcoming commits will try to work around the issues with art IDs related
to wxNO_IMPLICIT_WXSTRING_ENCODING in a different way.
2020-08-24 16:47:37 +02:00
Vadim Zeitlin
825fd01beb Test XRC headers compilation without implicit wxString conversion
Add wx/xrc/xmlres.h to the list of headers compiled with
wxNO_IMPLICIT_WXSTRING_ENCODING to test that they can be used even when
the implicit conversions from "char*" to wxString are disabled.
2020-08-24 16:47:37 +02:00
Ilya Sinitsyn
0e8ca0c8f9 Fix the cursor mode switching in wxGrid mouse move event handler
Allow switching between row and column resizing modes in mouse move event
handler.
2020-08-24 02:09:01 +02:00
Ilya Sinitsyn
5d3d376766 Remove unused wxGrid function 2020-08-24 02:09:01 +02:00
Ilya Sinitsyn
d6aec06150 Process the wxGrid mouse click depending on the current mode
Simplify the code of wxGrid::DoGridCellLeftDown() and make it more
correct by using m_cursorMode instead of duplicating (not 100%
correctly) the logic used to set it in DoGridMouseMoveEvent().

If the assumption that m_cursorMode is already set by the time
DoGridCellLeftDown() is called turns out to be wrong, e.g. when wxGrid
is used on touch screens, we would need to refactor these functions to
extract the code determining m_cursorMode from the mouse location into a
separate function that would be called from both.

Note that this commit is best viewed with "git diff -w" to see how little
has really changed.
2020-08-24 02:08:54 +02:00
Vadim Zeitlin
c1d3e65ac4 Merge branch 'wine-heap-fix'
Wine heap fix and other global memory-related cleanup.

See https://github.com/wxWidgets/wxWidgets/pull/2030
2020-08-24 00:18:57 +02:00
Vadim Zeitlin
3df9d772a4 Merge branch 'display-ppi-from-scaling-factor'
Determine display DPI from scaling factor instead of trying to compute
it from the physical display dimensions.

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

Closes #18855.
2020-08-24 00:14:27 +02:00
Vadim Zeitlin
1bf76ee594 Add a safety check for the buffer size in wxIDataObject
Avoid size overflow if the offset value is greater than it.
2020-08-22 23:48:58 +02:00
Paul Cornett
3f9884817d Allow wxButton to show explicitly set bitmaps regardless of theme setting with GTK3
See #18874
2020-08-22 11:18:48 -07:00
Vadim Zeitlin
75ad798d8b Use GlobalPtrLock instead of manual GlobalUnlock() calls
Make the code safer and shorter by using RAII wrapper instead of manual
Global{Lock,Unlock}() calls.

No real changes.
2020-08-22 19:45:19 +02:00
Vadim Zeitlin
0d7be7c189 Use GlobalPtrLock instead of manual Global{Lock,Unlock}() calls
Also add GlobalPtrLock::GetSize() and use it instead of calling
GetSizeFromBuffer() as it's more direct and doesn't require the use of
::GlobalHandle().
2020-08-22 19:45:19 +02:00
Vadim Zeitlin
aadfaada7a Fix crash when using custom DnD formats under Wine
Using ::HeapSize() on a global pointer is wrong, and even though it
somehow still works under "genuine" MSW, it crashes under Wine.

Fix this by using ::GlobalSize() instead, which is the right function to
use with this kind of pointer.

Thanks to Damjan Jovanovic for the analysis of the problem in Wine
bugzilla (see https://bugs.winehq.org/show_bug.cgi?id=38924#c10).

Closes #18887.
2020-08-22 19:45:19 +02:00
Vadim Zeitlin
93c580ccaf Don't mangle ampersands in wxToolBar tooltips under MSW
Preserve the ampersands in the string, which is consistent with wxGTK
behaviour and less surprising than the default behaviour, which creates
mnemonics in the tooltips that are, of course, perfectly useless, as
they can't be activated from keyboard anyhow.

Turn on TTS_NOPREFIX, which is already used by wxToolTip, to fix this.

Closes #18899.
2020-08-22 18:49:25 +02:00
Václav Slavík
adb7c8a53d cfstring.h compilation fix for ARC builds 2020-08-22 16:46:27 +02:00
Vadim Zeitlin
ff3cb34d18 Add a unit test for using bitmaps with image and empty label
This used to be broken, see #18898, and now that it is fixed by
5a70051c7e (Avoid assertion failure in wxButton with bitmap and empty
label, see #18898, 2020-08-21) add a unit test so that it stays fixed.
2020-08-21 20:21:17 -07:00