Commit Graph

70182 Commits

Author SHA1 Message Date
Vadim Zeitlin
d03f193719 Recognize "ll_LL" as at language "ll" in GetSystemLanguage()
If we can't find an exact match for the system locale in the database,
try to at least find the corresponding language.

This is almost certainly what the intention of the original code was, as
otherwise the entire loop was useless because it couldn't find anything
that wouldn't have been found in the loop just above.

This allows to correctly load German translations when using unsupported
locale such as "de_IT", for example.

See #19082.
2021-02-28 23:39:20 +01:00
Vadim Zeitlin
73b41dda91 Remove redundant #if/#endif in Unix locale code
Put both Unix-only functions inside the same #ifdef __UNIX__.

No real changes.
2021-02-28 22:50:35 +01:00
Vadim Zeitlin
2e8e0197d7 Add wxSetlocaleTryAll() helper to simplify Unix locale code
Define the function calling setlocale("xx_YY") first and then just
setlocale("xx") if the former failed, instead of doing the same thing
manually in 3 different places.

Also avoid attempting the second setlocale() call completely if there is
no "_YY" part in the first place.

No real changes.
2021-02-28 22:48:52 +01:00
Vadim Zeitlin
91ec900034 Explicitly disallow wxLANGUAGE_UNKNOWN in wxLocale::Init()
This value doesn't make here, so be upfront about it.
2021-02-28 20:04:33 +01:00
Vadim Zeitlin
18bf718f60 Support wxLANGUAGE_DEFAULT in wxLocale even when it is unknown
Don't give an error if we can't recognize the current system language,
as we may still be able to use it even in this case.

Closes #19082.
2021-02-28 20:00:27 +01:00
Vadim Zeitlin
3e395f9b5f Micro optimization for wxLANGUAGE_UNKNOWN in GetLanguageInfo()
Don't bother iterating over all the languages if we can be sure we're
not going to find anything anyhow.
2021-02-28 01:12:57 +01:00
Vadim Zeitlin
d029279227 Rename local variable to a more consistent name
Call the info->CanonicalName "shortName", as it's done in many other
places in the code instead of using "locale" for it here, even though we
do use it as a name of locale.

No real changes.
2021-02-28 01:11:34 +01:00
Vadim Zeitlin
5fd85d422f Add a trivial test for setting default locale
Initializing wxLocale using wxLANGUAGE_DEFAULT should work, unless
LC_ALL is explicitly set to an invalid value.
2021-02-28 01:07:47 +01:00
Vadim Zeitlin
7b6894ea41 Reuse Unix branch of wxLocale::Init() for macOS too
There doesn't seem to be any reason to partially duplicate Unix-specific
code in a separate Mac branch when we can just use the same code. Parts
of it which are not necessary under Mac, such as trying ".UTF-8" locales
in wxSetlocaleTryUTF8(), can be separately disabled there (even though
they are harmless), but other parts are probably needed, e.g. setting
Norwegian locale failed under macOS before because we didn't translate
nb_NO that we use to no_NO actually supported under macOS.
2021-02-28 01:02:59 +01:00
Vadim Zeitlin
0aba9fe112 Remove useless fallback from wxLocale::Init()
There is no need to try setting "loc.UTF-8" and "loc.UTF8" when we had
just called wxSetlocaleTryUTF8() which tried these variants and also
their lower-case equivalents already.
2021-02-27 17:52:08 +01:00
Artur Wieczorek
04ea7b552a Fix wxBitmapButon used as wxPG editor button under wxGTK2
wxBitmapButton without inner border should work better with themes
if we reduce inner border in a more GTK-compliant way by applying
a dedicated GTK style to the button.
2021-02-27 17:15:39 +01:00
Artur Wieczorek
9a29ea6e63 Fix setting wxBU_EXACTFIT style for wxButton under wxGTK2
The way wxBU_EXACTFIT is implemented in commit c1bb80987f
("Improve implementation of wxBU_EXACTFIT style for wxButton under wxGTK2",
2020-04-12) is too intrusive and disrupts button's appearance in some
themes. It should work better with themes if we reduce inner border in
a more GTK-compliant way by applying a dedicated GTK style to the button.

Closes #19081.
2021-02-27 17:08:37 +01:00
Vadim Zeitlin
94812c9e06 Merge branch 'sorted-array-str-search'
Fix searching in wxSortedArrayString with custom compare function.

Also improve array unit tests.

See https://github.com/wxWidgets/wxWidgets/pull/2251/
2021-02-26 16:51:11 +01:00
Ian McInerney
063dd3e852 Remove hardcoded max width from STC autocomplete listbox
The Scintilla engine will automatically truncate lines in the
autocomplete listbox based on the call to AutoCompSetMaxWidth().
It is not good to do it in the wx implementation code as well,
since then the meaning of AutoCompSetMaxWidth(0) (e.g. no truncation)
is not valid and the list items will be truncated anyway.

Closes https://github.com/wxWidgets/wxWidgets/pull/2250
2021-02-26 16:49:35 +01:00
Vadim Zeitlin
b113635111 Use CHECK() instead of CPPUNIT_ASSERT_XXX in arrays tests
This could be further improved by defining array matchers instead of
using the macros, but for now just get rid of the last traces of CppUnit
in this file.

No real changes.
2021-02-26 16:36:10 +01:00
Vadim Zeitlin
eb3fdfe82f Get rid of ArraysTestCase class in the dyn arrays unit tests
Just remove more CppUnit boilerplate, no real changes.
2021-02-26 16:32:45 +01:00
Vadim Zeitlin
6819b5512b Make BinarySearch() interface slightly more readable
Replace "equal" parameter with the (opposite) "lowerBound" one with a
more descriptive name, add a comment describing it and also remove the
default value to force explaining how it is used in the caller.

No real changes.
2021-02-26 16:25:28 +01:00
Pavel Tyunin
00fec01308
Fex search in wxSortedArrayString with custom compare function in STL build 2021-02-26 11:52:44 +02:00
Pavel Tyunin
2451f8085b
Fix search in wxSortedArrayString with custom compare function 2021-02-25 21:28:32 +02:00
Vadim Zeitlin
752ba82041 Fix format specifier used for wParam in wxMSW WM_POWER handler
wParam is 64 bits in 64 bit builds and can't be used with "%d", we need
"%zd" for it.

Closes #19080.
2021-02-24 13:29:27 +01:00
Paul Cornett
f25d48fbd5 Use a more accurate size for wxTimePickerCtrlGeneric
See #19078
2021-02-23 23:12:43 -08:00
ali kettab
2689040769 Remove unnecessary hack from ListBaseTestCase under wxGTK
The tests pass without it now, so simplify the test code added in
fedc80eee3 (Improve selection and focus events generation in
wxGenericLisCtrl, 2020-09-06).

Closes https://github.com/wxWidgets/wxWidgets/pull/2249
2021-02-23 21:54:15 +01:00
Vadim Zeitlin
0728262640 Provide descriptions for WinHTTP error messages
Just the error code is not very useful as it doesn't say anything about
what exactly failed, e.g. seeing "The buffers supplied to a function was
too small." doesn't help understanding which function was passed a too
small buffer, so add an extra parameter to SetFailed[WithLastError]() to
log this information too.

Also log the error code itself, because SEC_E_BUFFER_TOO_SMALL is
arguably more clear than its ungrammatical error message.

No real changes.

Closes https://github.com/wxWidgets/wxWidgets/pull/2247
2021-02-23 21:53:11 +01:00
Vadim Zeitlin
2c9f6770a5 Merge branch 'valnum-unsigned'
Fix handling of unsigned types in numeric validators: don't accept
negative numbers as unsigned, allow using the full 64-bit range.

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

Closes #12967.
2021-02-23 21:52:27 +01:00
Vadim Zeitlin
4cd2cb0acd Merge branch 'win-val-self' of https://github.com/AliKet/wxWidgets
Make wxWindow::TransferData{To,From}Window and Validate work on the
window itself too.

See https://github.com/wxWidgets/wxWidgets/pull/2235
2021-02-23 21:48:16 +01:00
Joao Matos
152970a52a Fix missing event objects in WebViewGTK events. 2021-02-23 10:04:50 -08:00
Paul Cornett
1406d3dc03 Simplify wxWebView zoom conversion code
So there is no need to "shut up compilers"
2021-02-23 10:01:18 -08:00
Paul Cornett
1508fa1e4c Use a more accurate width for wxDatePickerCtrlGeneric
See #19078
2021-02-23 10:01:01 -08:00
ali kettab
ec20753685 Add tests showing transferring data (to, from) self (window) works correctly 2021-02-22 14:31:20 +01:00
Vadim Zeitlin
72a24b402b Fix deleting of wxTextCtrl in wxNumValidator test case
This was broken in da973c3caf (Get rid of CppUnit boilerplate in numeric
validator unit tests, 2021-02-21) which replaced DestroyChildren() in
the old CppUnit test case dtor with just "delete m_text", as this didn't
take care of "text2" created in one of the tests.

Using DestroyChildren() still seems overly side, so ensure that "text2"
is destroyed explicitly.
2021-02-22 14:26:23 +01:00
Vadim Zeitlin
bdaca38904 Fix transferring unsigned values to the window too
In addition to not accepting "-1" as a valid unsigned value, we also
must not format unsigned values as signed ones, i.e. we need to use
wxNumberFormatter::ToString() overload taking unsigned for them.

Do it in wxIntegerValidatorBase::ToString(), used by TransferToWindow(),
and add more tests for the latter.

Also reorganize the tests in sections and use REQUIRE() for the checks
that should prevent the rest of the section from running if they fail.
2021-02-22 12:58:14 +01:00
Vadim Zeitlin
483856f3d3 Add wxIntegerValidatorBase::ULongestValueType typedef
Allow just writing ULongestValueType instead of writing #ifdefs in
several places.
2021-02-22 12:58:14 +01:00
Vadim Zeitlin
94289a46b1 Relax check for converting "-" to long long in the unit tests
This somehow succeeds when using gcc 4.8 under Ubuntu 14.04 or MinGW
5.3, so don't fail the tests in this case, but still warn about it
because it seems quite unexpected.
2021-02-22 12:57:58 +01:00
Vadim Zeitlin
a91cb5c344 Use CHECK_FALSE in wxNumberFormatter unit tests
Just replace CHECK(!condition) with CHECK_FALSE(condition), this should
result in slightly more clear error messages.

Also make tests for long and long long more consistent.
2021-02-22 11:55:32 +01:00
Vadim Zeitlin
cddc657505 Use min/max values of correct type in numeric validators
Use the actual type of the value, not LongestValueType, for storing
m_min and m_max as this is necessary for the comparisons between the
value and them to work correctly for unsigned types.

Also check for precision loss when converting from the bigger
LongestValueType to the actual type.

Add new unit tests, that failed before, but pass now.
2021-02-22 11:49:19 +01:00
Vadim Zeitlin
f1e6af089a Fix parsing unsigned numbers in wxIntegerValidatorBase
Use wxNumberFormatter::FromString() overload taking wxULongLong_t to
allow parsing numbers greater than LLONG_MAX.
2021-02-22 11:49:19 +01:00
Vadim Zeitlin
eb64202ad4 Add support for unsigned long long to wxNumberFormatter
This is necessary in order to deal with the numbers greater than
wxINT64_MAX that can't be represented in just long long.

It also allows to implement the intuitive handling of minus sign for the
unsigned numbers, i.e. not to accept it in FromString(), unlike the
standard functions which do (and parse -1 as 0xffff...fff).

Also extend the tests to check for more boundary cases.
2021-02-22 11:49:19 +01:00
Vadim Zeitlin
06bb60f0f8 Merge branch 'curlmultisocket' of https://github.com/NewPagodi/wxWidgets
Rewrite CURL-based wxWebRequest implementation using multi-socket
support for much better efficiency and reliability.

See https://github.com/wxWidgets/wxWidgets/pull/2193
2021-02-22 00:40:53 +01:00
Vadim Zeitlin
d8113b36c3 Merge branch '12764-faster-grid-attr-lookup' of https://github.com/discnl/wxWidgets
Improve responsiveness of a wxGrid with many attributes by using hash
map instead of array for storing them and looking them up.

See https://github.com/wxWidgets/wxWidgets/pull/2229
2021-02-22 00:21:31 +01:00
Vadim Zeitlin
b53f7ac904 Restore support for using faster dotted pens in wxMSW
Changes of d245dc9e1f (Fix drawing of dotted lines with wxDC in wxMSW,
2020-03-27) improved the appearance of dotted and dashed lines in wxMSW
but at the expense of significant (up to a factor of 300) slowdown.

Allow the applications for which the drawing performance is important to
explicitly request the old behaviour, with uglier, but faster, pens by
choosing to use low quality pens.

Update the graphics benchmark to allow specifying the pen quality and
verify that the performance when using it is the same as before 3.1.4.

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

See #7097.

Closes #18875.
2021-02-22 00:04:07 +01:00
Vadim Zeitlin
959d955a80 Make wxNumberFormatter tests more concise and readable
Define a couple of helper functions to avoid over long lines or having
to break them and also align the tests vertically to allow scanning them
more easily.

No real changes.
2021-02-21 17:13:01 +01:00
Vadim Zeitlin
a015270709 Replace CPPUNIT_ASSERT() macros in wxNumberFormatter unit tests
Just use CHECK() rather than CPPUNIT_ASSERT_EQUAL() etc.
2021-02-21 17:02:55 +01:00
Vadim Zeitlin
5ebce65494 Get rid of CppUnit boilerplate in wxNumberFormatter unit tests
No real changes, just drop CppUnit::TestCase inheritance and the legacy
macros and use TEST_CASE_METHOD() instead.
2021-02-21 16:52:07 +01:00
Vadim Zeitlin
d3f051e328 Document wxNumberFormatter overloads using long long
These overloads were added back in f2a5052baa (Add support for long long
to wxNumberFormatter., 2011-01-19) but never documented.
2021-02-21 16:43:04 +01:00
Vadim Zeitlin
7371131f1e Fix confusion around '-' handling in numeric validators code
Actual implementation of IsCharOk() didn't correspond to the comments in
it or near the function declaration which stated that it's never called
with ch='-' as argument -- it was called with it and called IsMinusOk()
right before a comment saying that it doesn't need to do it, which was
very confusing.

Fix this by making the behaviour really correspond to the comments and
handling '-' at the base class level. This required introducing a new
pure virtual CanBeNegative() function, but it's going to be useful for
other things later too.

Still keep IsMinusOk() helper, but make it private now because it
doesn't need to be called from the derived class IsCharOk() any longer.
2021-02-21 15:13:10 +01:00
Vadim Zeitlin
a5afa85c0a Always use pip for installing httpbin in Travis CI builds
Using Docker just doesn't work: simply running "docker pull" fails due
to the pull rate limits all the time, see e.g.

https://travis-ci.org/github/wxWidgets/wxWidgets/jobs/759810039#L2628

while following Travis own instructions for dealing with this problem at

https://blog.travis-ci.com/docker-rate-limits

results in the build failure due to secret environment variables not
being accessible from the PRs for security reasons, see

https://travis-ci.org/github/wxWidgets/wxWidgets/jobs/759820694

So use pip everywhere, even under Ubuntu 14.04, where it doesn't work
out of the box as it tries to install globally when it doesn't have the
permissions to do it.
2021-02-21 14:57:10 +01:00
Vadim Zeitlin
709b259bbb Don't define copy ctor in numeric validator classes unnecessarily
There is just no need to do it manually, when the compiler can do the
job perfectly well itself.

No real changes, but this will simplify the upcoming refactoring.
2021-02-21 14:55:16 +01:00
Václav Slavík
26826c9bea Fix wxOSX sizing of borderless wxBitmapButton
Don't apply the workaround required for NSRoundedBezelStyle and
NSTexturedRoundedBezelStyle, i.e. enlarging too small buttons, if these
bezel styles are not used. In particular, avoid enlarging buttons with
wxBORDER_NONE or wxBORDER_SIMPLE.

Follow-up to 0941b25.
2021-02-21 09:58:27 +01:00
Vadim Zeitlin
d2b2e0a4ed Replace CPPUNIT_ASSERT() macros in numeric validator unit tests
Simplify code and use CHECK() rather than REQUIRE(), which is what
CPPUNIT_ASSERT() is defined as, to continue running the tests even if
some of them fail.
2021-02-21 00:33:22 +01:00
Vadim Zeitlin
da973c3caf Get rid of CppUnit boilerplate in numeric validator unit tests
No real changes, just drop CppUnit::TestCase inheritance and the legacy
macros and use TEST_CASE_METHOD() instead.
2021-02-21 00:30:46 +01:00