Commit Graph

71396 Commits

Author SHA1 Message Date
Vadim Zeitlin
e438f9a496 Use wxNumberFormatter in wxGrid number renderer and editor
This ensures that the correct, i.e. matching the users default, decimal
point separator is used even if setlocale() is not called.

Also simplify the code a bit by removing checks for wxUSE_INTL already
present in wxNumberFormatter itself.
2021-08-20 23:37:28 +02:00
Vadim Zeitlin
3fc031e75b Add wxNumberFormatter::Format() for floating point numbers
The existing ToString() is not flexible enough to be used in wxGrid,
which supports specifying the width (and not just the precision) as well
as using formats other than "%g" and "%f" which are the only ones
supported by the existing function.

Note that currently the implementation simply calls wxString::Format()
and then adjusts the decimal separator, but it could, in principle, use
wxUILocale methods for formatting the floating point numbers using
native platform functions for doing this, e.g. CFNumberFormatter under
macOS.
2021-08-20 23:37:28 +02:00
Vadim Zeitlin
85d379913d Use wxUILocale in wxSpinCtrlDouble
This ensures that we use the decimal separator corresponding to the UI
locale of the application, rather than C locale, so that e.g. comma is
used under macOS even if setlocale() is not used.
2021-08-20 23:37:28 +02:00
Vadim Zeitlin
b3cab73680 Use wxUILocale in wxNumberFormatter
Always use the UI locale conventions for floating point numbers in
wxNumberFormatter, making it different from wxString::{To,From}Double()
functions that use C locale, which may, or not, correspond to the UI
locale.
2021-08-20 23:37:28 +02:00
Vadim Zeitlin
37a23e1ab1 Move platform-specific parts of wxLocale::Init() to wxUILocale
This is tidier than using #ifdefs in the same common file and also
ensures that initializing wxLocale affects wxUILocale too, which will be
important for compatibility when the code elsewhere is modified to use
wxUILocale::GetInfo() instead of wxLocale::GetInfo() in the upcoming
commits.

This commit is best viewed with --color-moved git option.
2021-08-20 23:37:28 +02:00
Vadim Zeitlin
d3a1abaab2 Untangle Mac and POSIX code in wxLocale::GetSystemLanguage()
Most of the code in this function was Unix-specific and didn't make
sense for Mac, where we never have to apply the workarounds in it nor
deal with languages specified without the territory etc, so separate Mac
branch using CoreFouundation API from the rest of the Unix code to make
things more understandable.

No real changes.
2021-08-20 23:37:28 +02:00
Vadim Zeitlin
8ccfd32d04 Fix using wxDC::Blit() when using RTL layout under MSW
Work around what seems like a bug in StretchBlt() implementation by
applying an extra offset to it when using RTL layout and revert an
earlier attempt to fix this problem for wxMemoryDC used in wxNotebook
code from 6614aa496d (fix for tabs drawing in RTL (patch 1552881),
2006-10-21).

Closes #19190.
2021-08-20 22:09:32 +01:00
Vadim Zeitlin
6689feb648 Merge branch 'osx-text-undo'
Implement undo/redo for (multiline) wxTextCtrl in wxOSX.

See https://github.com/wxWidgets/wxWidgets/pull/2474
2021-08-20 22:10:48 +02:00
Vadim Zeitlin
405bb3ecf7 Move wxLanguageInfo declaration to wx/localedefs.h too
No real changes, just allow wxUILocale code to use this struct without
including the full wx/intl.h.

This commit is best viewed with --color-moved git option.
2021-08-20 22:02:46 +02:00
Vadim Zeitlin
59a4505a5f Use Core Foundation for testing locale availability under Mac
Using setlocale() is not the right way to do it there, try checking if
the locale is supported by Core Foundation instead of whether it's
supported by the Unix layer which is neglected and not used under Mac.
2021-08-20 22:02:46 +02:00
Vadim Zeitlin
8f20dd3490 Remove obsolete AIX workaround from wxLocale code
This code, added back in 420de418ea (workaround for buggy setlocale()
under AIX (without this wxLocale didn't work at all), 2005-09-18), is
probably irrelevant anyhow because AIX 5.2 must not be used any more,
but also seems to have lost its purpose at some time during the
intervening years, as we don't use "retloc" as argument to setlocale()
anyhow, so it is doubly safe to simply remove it.
2021-08-20 22:02:46 +02:00
Vadim Zeitlin
b9cbe6770f Add wxUILocale with minimal functionality
Use it in the sample to show what (little) it can do right now.
2021-08-20 22:02:46 +02:00
Tobias Taschner
26c9bc0807 wxWebViewEdgeImpl: Add missing MinGW definitions
In a756ed93c2 (wxWebViewEdge: Improve wxEVT_WEBVIEW_LOADED, 2021-08-17)
usage of additional interfaces was added. This adds their interface IDs
for non VISUALC compilers.

Also sorted the definitions alphabetically, use "--color-moved" git
option to see the actual changes.

Closes https://github.com/wxWidgets/wxWidgets/pull/2472
2021-08-20 21:36:21 +02:00
Vadim Zeitlin
ca9a48598d Avoid copying the font object unnecessarily in wxTextMeasureBase
This change slightly modifies the parent commit by avoiding an
unnecessary copy of wxFont which, while cheap, is not quite free and
can be easily avoided here.

See https://github.com/wxWidgets/wxWidgets/pull/2471
2021-08-20 21:32:55 +02:00
Dimitri Schoolwerth
eb76f400d2 Fix potential wxTextMeasureBase::DoGetPartialTextExtents() crashes
If wxTextMeasure is constructed without a font and the base version of
DoGetPartialTextExtents() gets used then there's a crash due to
dereferencing a null pointer. To fix, simply use GetFont() like
elsewhere to get the effective font used.

To fix another null pointer dereference crash don't call
wxTextMeasure::DoGetTextExtent() with null height pointer, as it
requires that both width and height pointers are non-null since
8cd79b7af0 (Factor out text measurement from wxDC and wxWindow into
wxTextMeasure., 2012-10-18), but not for all back-ends any longer since
d76774b444 (Don't dereference NULL output pointer in wxTextMeasure.,
2012-11-25).

There currently appears to be no code in wx that would result in either
crash. For Windows both crashes can be artificially reproduced with
the render sample (requiring static linking with wx due to using private
wxTextMeasure) when using the GDI+ renderer along with the patch:

diff --git a/samples/render/render.cpp b/samples/render/render.cpp
index 6bae34781b..bc4f8d405b 100644
--- a/samples/render/render.cpp
+++ b/samples/render/render.cpp
@@ -34,6 +34,7 @@
     #include "wx/image.h"
 #endif

+#include "wx/private/textmeasure.h"
 #include "wx/apptrait.h"
 #include "wx/artprov.h"
 #include "wx/renderer.h"
@@ -209,6 +210,10 @@ private:
             wxGraphicsContext* ctx = m_renderer->CreateContext(pdc);
             gdc.SetBackground(GetBackgroundColour());
             gdc.SetGraphicsContext(ctx);
+
+            wxTextMeasure txm(&gdc);
+            wxArrayInt widths;
+            txm.GetPartialTextExtents("a", widths, 1.0);
         }

         wxDC& dc = m_renderer ? static_cast<wxDC&>(gdc) : pdc;

Closes https://github.com/wxWidgets/wxWidgets/pull/2471
2021-08-20 21:32:02 +02:00
Dimitri Schoolwerth
a7b9dc121b Fix recent regression with drawing themed multi-line text
Remove conditions from MSW themed text drawing that prevent multi-lines
from being rendered properly and instead always use DT_TOP alignment
for multi-lines.

This fixes a regression occurring since 90ba137f20 (Work around text
extent differences resulting in clipped text, 2021-07-26) with themed
Vista+ :

Non-top aligned multi-line text gets rendered as a single line because
of DT_SINGLELINE being used if the height of the drawing rect and
multi-line text happen to be equal. This occurs on the "Variable line
height" page of the dataview sample, which calculates its cell height
by multiplying the text extent by the number of lines in the text (a
requirement with wxMSW, not wxGTK).

Removing the conditions also exposes top aligned multi-line themed text
to drawing beyond the drawing rect, which actually makes it behave more
like wxGTK and wxOSX as well as wxMSW non-themed drawing as they try to
render text fully without regard for the bounds of the drawing rect.

Closes https://github.com/wxWidgets/wxWidgets/pull/2470
2021-08-20 21:29:57 +02:00
Vadim Zeitlin
1f7cd9c7a4 Merge branch 'generic-initial-state-fixes'
Fixes for the initial state of generic wx{List,Spin}Ctrl.

See https://github.com/wxWidgets/wxWidgets/pull/2469
2021-08-20 21:28:35 +02:00
Vadim Zeitlin
e51971e86c Skip wxTextCtrl::EmptyUndoBuffer() test when using Wine
Wine doesn't provide the OLE interface used by this function, so the
test would always fail when running under it, just skip it instead.
2021-08-20 20:16:11 +01:00
Stefan Csomor
b3b24e962e Expand self-hosted Mac M1 CI build workflow
See https://github.com/wxWidgets/wxWidgets/pull/2336
2021-08-20 19:42:35 +02:00
Vadim Zeitlin
8fe4ba8ff4 Add wxIsRunningUnderWine() helper function
This is mostly useful in the testing code to avoid failures when testing
for functionality not implemented by Wine.
2021-08-20 18:22:26 +01:00
Vadim Zeitlin
64f7c23272 Add unit test for wxTextCtrl::EmptyUndoBuffer()
Check that calling it results in CanUndo() returning false and really
prevents Undo() from working.
2021-08-20 17:00:12 +01:00
Vadim Zeitlin
adacb5c07e Move EmptyUndoBuffer() from wxTextEntry to wxTextCtrl
It seems unlikely that we're ever going to need this function in any
other classes inheriting from wxTextEntry (i.e. wxComboBox) and both
existing implementations are for wxTextCtrl only, so define this
function there.

If really necessary, we can always lower it to wxTextEntry later, while
moving it in the other direction wouldn't be easily possible due to
compatibility concerns.

This commit is best viewed with git --color-moved option.
2021-08-20 17:00:01 +01:00
Vadim Zeitlin
1799922d0e Implement EmptyUndoBuffer() for wxTextCtrl in wxMSW too
The relevant code was already present in MSWCreateText(), so just
extract it into its own function.
2021-08-20 16:58:38 +01:00
Dan Korn
3c9bb69d6e Add wxTextCtrl::EmptyUndoBuffer()
This is implemented for multi-line controls under macOS only currently.
2021-08-20 17:27:51 +02:00
Dan Korn
9b27eaad43 Handle standard Cmd-{Y,Z} key combinations in Mac wxTextCtrl
Use them to undo and redo, as expected.
2021-08-20 16:59:41 +02:00
Stefan Csomor
4fcd18e6ea Use a private undo manager for wxTextCtrl
This allows each control have its own undo history, independent of the
other ones, as expected by the wx API, rather than using an undo manager
shared by all controls in the same TLW.
2021-08-20 16:59:41 +02:00
Dan Korn
6c292d264c Implement undo and redo for wxTextCtrl under Mac
Use the parent undo manager to implement these functions.
2021-08-20 16:58:22 +02:00
Jouk
6d00ab47db Add support for PCRE2 for OpenVMS 2021-08-20 10:00:17 +02:00
Stefan Csomor
28a5fc0e4c Update MacS-M1-make.yml
deactivating triggers
2021-08-19 20:45:32 +02:00
Stefan Csomor
f704e7504e Update MacS-M1-make.yml
try manual runs
2021-08-19 20:43:12 +02:00
Vadim Zeitlin
214381c0cd Fix bug with having multiple default buttons in wxMSW dialogs
We need to reset the default button using DM_SETDEFID too, otherwise
calling DM_SETDEFID later, when setting the new default button, seems to
restore BS_DEFPUSHBUTTON on the previous default button (but only if its
ID is positive, which probably explains why this bug went unnoticed for
so long), resulting in having 2 buttons with BS_DEFPUSHBUTTON in the
dialog.

Closes #19245.

This commit is best viewed ignoring whitespace-only changes.
2021-08-19 18:10:36 +01:00
Stefan Csomor
7501deb5fe removing erroneously readded plist files in last commit
841bc00f0c contained inadvertently the state before the harmonize plist PR was merged
2021-08-18 07:43:54 +02:00
Stefan Csomor
841bc00f0c setting font name when using SetFamily on macOS
fixes https://trac.wxwidgets.org/ticket/19210
2021-08-18 07:23:04 +02:00
Tobias Taschner
a756ed93c2 wxWebViewEdge: Improve wxEVT_WEBVIEW_LOADED
Previously the edge event ContentLoading was used which was
triggered earlier than DOMContentLoaded. This event wasn't
available in earlier SDK versions.

Minimum required SDK version is now:
1.0.705.50 (Released 2021-01-25)

Fixes #19202

See https://github.com/wxWidgets/wxWidgets/pull/2468
2021-08-17 23:50:13 +02:00
Vadim Zeitlin
6f372ad18a Merge branch 'harmonize-info-plist'
Modernize and make consistent all the different Info.plist files in the
repository.

See https://github.com/wxWidgets/wxWidgets/pull/2466
2021-08-17 23:48:14 +02:00
Vadim Zeitlin
6448a29e25 Always define old names for grid event constants and macros
It doesn't cost us anything to define the compatible names, and there is
no real advantage for the existing application code in using the new
names, so define them without WXWIN_COMPATIBILITY_X_Y checks around
them, to avoid forcing unnecessary changes in the application code when
upgrading to wx 3.2.0.

This commit is best viewed ignoring whitespace-only changes.
2021-08-17 23:47:43 +02:00
Vadim Zeitlin
5d0b3c1129 Merge branch 'univ_textctrl_fixtest' of https://github.com/Kvaz1r/wxWidgets
Fix multiple problems in wxUniv wxTextCtrl, allowing it to pass more
unit tests.

See https://github.com/wxWidgets/wxWidgets/pull/2447
2021-08-17 23:47:03 +02:00
Vadim Zeitlin
96d36383bd Use sensible default column width in generic wxListCtrl too
Set width of the new columns to wxLIST_DEFAULT_COL_WIDTH and not 0 in
the generic version: this is more compatible with the MSW version and
more useful.

Document that omitting list column width in XRC results in columns of
default, rather than null, as previously, width.
2021-08-17 23:41:07 +02:00
Vadim Zeitlin
2727926608 Add wxLIST_DEFAULT_COL_WIDTH constant
The same value of 80px was used in both the generic and MSW versions of
wxListCtrl, so introduce a symbolic name for it and define it only once,
similarly to how it's already done for wxDVC_DEFAULT_WIDTH and
WXGRID_DEFAULT_COL_WIDTH.

No real changes.
2021-08-17 23:26:17 +02:00
Vadim Zeitlin
ac1fa83c20 Ensure initial value of generic wxSpinCtrl is always valid
Under MSW creating a wxSpinCtrl with a range of, say, 1..10 and the
default initial value of 0 sets its initial value to 1 (i.e. the closest
valid value) as expected, but the generic version still set it to the
invalid value of 0, which was unexpected, inconsistent and not useful.

Fix the generic version to follow MSW behaviour now and add a test
checking for this.
2021-08-17 23:15:49 +02:00
Maarten Bent
2e12779a21 CMake: update Info.plist variables
Use the same values as in build/bakefiles/mac_bundles.bkl.
Use the correct copyright year for in the Info.plist files.
2021-08-17 22:33:45 +02:00
Maarten Bent
4862cbd4c6 CMake: Allow to specify specific Info.plist.in file for samples 2021-08-17 21:50:48 +02:00
Vadim Zeitlin
b66656fbec Merge branch 'dvd-revert-performance-breaking-commits' of https://github.com/vslavik/wxWidgets
Revert recent changes to wxDataViewCtrl which resulted in unacceptable
performance regressions.

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

See #14939, #19003.
2021-08-15 19:00:45 +02:00
Vadim Zeitlin
14d8548349 Merge branch 'misc-render-fixes' of https://github.com/discnl/wxWidgets
Fixes for rendering text with bottom/right alignment for wxMSW and not
only.

See https://github.com/wxWidgets/wxWidgets/pull/2446
2021-08-15 18:57:04 +02:00
Vadim Zeitlin
1fbda84306 Exclude Info.plist files from whitespace checks
These files use TABs for indentation, so the standard check doesn't work
for them (and it doesn't seem worth having a special check just for
them neither, so simply don't check them at all).
2021-08-15 18:39:34 +02:00
Vadim Zeitlin
d7e102f766 Reuse Info.plist used by configure for CMake too
The CMake-specific file is almost identical to the file used by
configure now, so don't keep both of them when just one could do.
2021-08-15 18:39:34 +02:00
Vadim Zeitlin
a69af310ad Use CFBundleLocalizations in internant sample Info.plist only
Remove this bundle key from the generic Info.plist files as it's not
really useful there because none of our samples except "internat" is
localized.

So just add a special Info.plist for this sample and add values
corresponding to all the languages for which we have translations to its
CFBundleLocalizations.
2021-08-15 18:39:34 +02:00
Vadim Zeitlin
81c4fa449b Use CMake-compatible variable names in configure Info.plist files
This will allow reusing them for CMake as well, and is required in order
to be able to do it as CMake variables names are fixed.
2021-08-15 18:39:34 +02:00
Vadim Zeitlin
518c04cd55 Add "Copyright" to CMake copyright variable
This is used for NSHumanReadableCopyright Info.plist field and should
have "Copyright" for consistency with the other Info.plist files.
2021-08-15 16:56:24 +02:00
Vadim Zeitlin
b7f2e4d423 Fix apparent typo in MACOSX_BUNDLE_BUNDLE_VERSION variable name
The documented name of the bundle version variable has BUNDLE twice, see

https://cmake.org/cmake/help/latest/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.html

and samples/Info.plist.in uses this variable, but we set
MACOSX_BUNDLE_VERSION instead, which seems wrong, so use the apparently
correct variable name instead.
2021-08-15 16:56:24 +02:00