Commit Graph

71396 Commits

Author SHA1 Message Date
Vadim Zeitlin
6c9c0ba02b Determine number of digits correctly when increment > 1
Using increment greater than 1 but with a fractional part should still
work, i.e. should use enough digits to fully show the fractional part of
the numbers that can be obtained by using this increment.
2021-04-25 20:00:31 +01:00
Vadim Zeitlin
0153a6673e Don't decrease the number of digits implicitly
wxSpinCtrlDouble::SetIncrement() should increase the number of digits if
necessary because not doing it would be inconsistent with the initial
determination of the number of digits in the ctor and would actually
lose the digits displayed, but it seems unnecessary to decrease the
number of digits and it might be surprising, so don't do it.

Add a test for this behaviour and document it.
2021-04-25 19:54:27 +01:00
Vadim Zeitlin
6938d91942 Update number of digits in wxSpinCtrlDouble::SetIncrement()
This is consistent with using the value of the increment specified in
the ctor for setting the initial number of digits, it was surprising
that creating the control with some value of the increment (e.g. 0.1)
and calling SetIncrement(0.1) later resulted in very different outcomes,
as in the former case the value was shown with a digit after the period
while in the latter case only the integer part was shown.

This also makes the behaviour compatible with that of the previous
versions of the generic wxSpinCtrlDouble, which used "%g" to format the
number before the changes of edc553870f (Fix displaying wxSpinCtrlDouble
values with default precision, 2020-05-18), as they did show the
fractional part even in the latter case.

Add a test checking that this works as expected: before this commit, the
test failed with "1 == 1.2" and "1 == 1.23" errors.
2021-04-25 19:45:34 +01:00
Vadim Zeitlin
eecc62ba65 Factor out wxSpinCtrlDouble::DoSetDigits()
Make this part of SetDigits() reusable in order to be able to also use
it in DetermineDigits() now and in SetIncrement() in the upcoming
commit.

No real changes yet.
2021-04-25 19:44:24 +01:00
Vadim Zeitlin
e2d2b367af Always initialize m_format in DetermineDigits()
It doesn't seem right to leave it unchanged when increment is outside of
[0, 1] interval, we should still set it to something in this case.

And doing this makes it unnecessary and redundant to initialize m_format
in Init(), as it will be always done when DetermineDigits() is called
from Create() anyhow.
2021-04-25 19:13:22 +01:00
Vadim Zeitlin
e748c2b56c Make wxSpinCtrlDouble::DetermineDigits() private
There is no need to allow calling this function from derived classes.

No real changes.
2021-04-25 19:11:38 +01:00
Vadim Zeitlin
51cb0e53b1 Use wxMEMBER_DELETE instead of "Disabled" comment
No real changes, but this is more clear and should result in better
error messages.
2021-04-25 18:59:20 +02:00
Vadim Zeitlin
7f246330de Remove wrong template arguments from wxArgNormalized ctors
Ctor of a template class specialization shouldn't actually repeat the
specialized template arguments, as it was done in 65cbf40b7e (Add
wxNO_UNSAFE_WXSTRING_CONV2 macro, 2019-10-21), so remove them because
this doesn't compile with g++ 11, even though it (wrongly?) did with the
previous gcc versions.
2021-04-25 18:59:20 +02:00
Vadim Zeitlin
3d278ee75f Avoid warnings about operations on different enums in C++20 mode
Arithmetic operations on the elements of different enums are deprecated
in C++20 and the latest compiler versions warn about them.

While individual warnings could be fixed in wxWidgets itself (although
it would be quite an effort to do it for all ~500 of them), it wouldn't
help with the same warnings in the applications using wx, so prefer to
do it by explicitly defining the operations on the enums that can be
combined with each other by using wxALLOW_COMBINING_ENUMS() macro,
except for a single warning in wxTar code where it's easier to just not
use an anum at all.
2021-04-25 18:59:20 +02:00
Vadim Zeitlin
c177e006fc Use wxScopedPtr instead of manual delete in wxSpinCtrlDouble test
No real changes.
2021-04-25 16:45:39 +01:00
Vadim Zeitlin
5ab5172930 Avoid warnings about mixing different enums with C++20
C++20 deprecates arithmetic operations with the elements of different
enums and at least clang 10 and MSVS 2019 already warn about this when
compiling in C++20 mode, so avoid such operations at least in the public
headers to avoid warnings in the applications using wxWidgets and C++20.
2021-04-24 19:06:49 +01:00
Vadim Zeitlin
bf5090bcf3 Enable Winsock 2 and IPv6 build options by default
In addition to linking with Winsock 2, also use winsock2.h.

This allows to turn on IPv6 support on by default under MSW, so turn it
on under Unix too for consistency.

Predefine _WINSOCK_DEPRECATED_NO_WARNINGS to avoid warnings about
deprecated (but still available and very unlikely to be ever removed)
Winsock 1 functions that we still use.
2021-04-24 18:06:43 +01:00
Vadim Zeitlin
53eff92ea7 Call AdjustForBitmapMargins() only once in wxAnyButton
No real changes, just a tiny refactoring to avoid duplicating exactly
the same function call.
2021-04-24 14:59:05 +01:00
Vadim Zeitlin
6f888df474 Restore button size calculation when not using manifest in wxMSW
This fixes regression introduced in de10f054c4 (Improve calculating
wxButton best size under wxMSW, 2021-04-08) which didn't check whether
BCM_GETIDEALSIZE succeeded -- as we must do, because in some situations
(when using very old systems or not using a manifest even under newer
ones), it does indeed fail.
2021-04-24 14:58:56 +01:00
PB
31b983bad1 Make menu sample build when using precompiled headers
Headers wx/filehistory.h and wx/filename.h were included only
when WX_PRECOMP was not defined.

However, these two files are not included in wx/wxprec.h,
so they must be always included directly.

Closes https://github.com/wxWidgets/wxWidgets/pull/2344
2021-04-24 13:34:54 +02:00
Vadim Zeitlin
343d24ec32 Merge branch 'spinctrl-value'
Consistently return minimum value from wxSpinCtrl with invalid text
value.

See https://github.com/wxWidgets/wxWidgets/pull/2345
2021-04-24 11:20:31 +02:00
Manuel Garcia
4b41daab13 Replace su with sudo in docs/gtk/install.md
Closes https://github.com/wxWidgets/wxWidgets/pull/2343
2021-04-24 00:41:22 +02:00
Vadim Zeitlin
db22d12a47 Merge branch 'osx-dataview-native-key'
Implement wxEVT_CHAR generation for wxDataViewCtrl under Mac.

Closes https://github.com/wxWidgets/wxWidgets/pull/2324
2021-04-24 00:40:15 +02:00
Vadim Zeitlin
16ba1daebf Use wxOVERRIDE in wx/osx/cocoa/dataview.h
No real changes, just add wxOVERRIDE.
2021-04-24 00:38:29 +02:00
Vadim Zeitlin
e46b6d7758 Also remove useless wxDataViewCtrl::OnMouse() from Mac version
This empty event handler doesn't do anything useful.
2021-04-24 00:32:14 +02:00
Vadim Zeitlin
ccdfd28b48 Remove empty wxDataViewCtrl::OnChar() added in the parent commit
This is not really useful to have, so just remove it.
2021-04-24 00:31:17 +02:00
Stefan Csomor
26d6f82a81 Implement EVT_CHAR generation for wxDataViewCtrl under Mac
This requires manually sending the original key event back to the native
control because NSOutlineView doesn't implement the NSTextInputClient
protocol and so doesn't allow handling the keys in the usual way.
2021-04-24 00:30:30 +02:00
Stefan Csomor
18c45321f4 Return bool from wxWidgetCocoaImpl::doCommandBySelector()
This allows to determine whether the event was handled by wx code and
perform further processing by feeding things back to native code if not.
2021-04-24 00:27:26 +02:00
Vadim Zeitlin
fb88a3f3eb Don't use last valid value in wxGTK wxSpinCtrl with text override
This partially undoes the recent changes to wxGTK wxSpinCtrl and reverts
to the previous behaviour, which was actually compatible with wxMSW, and
returns the minimum value when the text of the control is set to an
invalid string.
2021-04-23 23:43:49 +02:00
Vadim Zeitlin
06f368be54 Use wxON_BLOCK_EXIT_SET() in wxMSW wxSpinCtrl code
Ensure that m_blockEvent flag is always reset on the scope exit.

No real changes.
2021-04-23 22:37:15 +01:00
Vadim Zeitlin
8fc2d44004 Don't generate events from wxMSW wxSpinCtrl::SetValue(wxString)
The function was documented to not generate the events, but actually
did generate wxEVT_TEXT ones, even if it didn't generate wxEVT_SPINCTRL.

This was inconsistent with wxGTK and generic wxSpinCtrlDouble used under
MSW, so change this to avoid the unwanted events.
2021-04-23 22:30:59 +01:00
Vadim Zeitlin
35fa1f93bc Reset wxSpinCtrl value to GetMin() if text string is invalid
Previously, wxSpinCtrl (using native control) and wxSpinCtrlDouble
(using the generic implementation) behaved differently in this case,
with the former changing its value but the latter keeping the last valid
value instead.

Make them behave the same by resetting the value in both cases and
document this behaviour.
2021-04-23 22:27:28 +01:00
Vadim Zeitlin
2973d75f25 Explain in more details how to build applications using wx
We didn't document using wxwin.m4 at all anywhere, so do it at least
minimally now (we still need a separate page documenting its full
functionality) and also show a simple makefile using wx-config.

Closes https://github.com/wxWidgets/wxWidgets/pull/2338
2021-04-23 21:48:11 +02:00
Vadim Zeitlin
c67e689bb5 Fix left over control in wxSpinCtrlDouble unit tests
Fix the bug introduced in the recent 34ab87ce4d (Get rid of CppUnit
boilerplate in wxSpinCtrlDouble unit test, 2021-04-19) which resulted in
failures in the subsequent unit tests and ensure that the spin control
is destroyed at the end of the test.
2021-04-23 21:45:35 +02:00
Vadim Zeitlin
3fc404372f Temporarily disable failing wxSpinCtrl unit test
wxSpinCtrl::GetValue() behaviour after calling SetValue("") is currently
inconsistent between wxMSW and wxGTK, or even between wxSpinCtrl and
wxSpinCtrlDouble in wxMSW.

Disable the recently added test checking it for now.
2021-04-23 17:28:34 +02:00
Vadim Zeitlin
c89a8f973c Merge branch 'im/stdheaders' of https://github.com/imciner2/wxWidgets
Don't enable warnings in the system headers during all headers test.

See https://github.com/wxWidgets/wxWidgets/pull/2342
2021-04-23 00:04:21 +02:00
PB
b7b4e1a530 Document that wxMatchWild() is always case-sensitive
Closes https://github.com/wxWidgets/wxWidgets/pull/2337
2021-04-22 23:57:02 +02:00
Vadim Zeitlin
87fddbdbdb Merge branch 'spinctrl-gettextvalue'
Add wxSpinCtrl::GetTextValue() and allow clearing the text value in
wxGTK version for compatibility with MSW.

See https://github.com/wxWidgets/wxWidgets/pull/2334
2021-04-22 23:55:30 +02:00
Ian McInerney
e0005c1d93 No longer include the system headers first
With the Wsystem-headers warning removed, these are no longer needed
and can instead be included on first-use again.
2021-04-22 19:23:48 +01:00
Ian McInerney
b47189b945 Don't enable warnings in the system headers during all headers test
This warning flag is really only used for stdlib debugging/writing,
and is off by default so that normal users of the library don't see
any warnings generated by the library (since they have no control
over it).
2021-04-22 19:22:32 +01:00
Scott Talbert
858248d055 Fix declaration shadow warning in wxHtmlHelpFrame
Fixes this warning:
In file included from ../../include/wx/html/helpctrl.h:19,
                 from ../../include/wx/help.h:27,
                 from ../../include/wx/cshelp.h:18,
                 from ../../tests/allheaders.h:85,
                 from ../../tests/allheaders.cpp:435:
../../include/wx/html/helpfrm.h:74:50: error: declaration of 'wxWindowID' shadows a global declaration [-Werror=shadow]
   74 |     wxHtmlHelpFrame(wxWindow* parent, wxWindowID wxWindowID,
      |                                       ~~~~~~~~~~~^~~~~~~~~~
In file included from ../../include/wx/wxprec.h:12,
                 from ../../tests/testprec.h:4,
                 from ../../tests/allheaders.cpp:433:
../../include/wx/defs.h:1965:13: note: shadowed declaration is here
 1965 | typedef int wxWindowID;
      |             ^~~~~~~~~~

See https://trac.wxwidgets.org/ticket/19153
2021-04-22 07:33:03 -07:00
Vadim Zeitlin
c356f83da2 Fix resetting text override when manually entering the text
The entered text wasn't taken into account, as the override was still
used when its numeric value was retrieved by GtkSpinButton using our
"input" handler, so reset the override now as soon as we get "changed"
signal.
2021-04-21 09:24:02 +02:00
Vadim Zeitlin
86c0394383 Reset text override if the text is manually modified
Otherwise the newly entered text wouldn't be taken into account, as it
would still be overridden.
2021-04-21 09:02:59 +02:00
Vadim Zeitlin
32258bd10a Move wxEVT_TEXT generation to wxSpinCtrlGTKBase::GTKTextChanged()
This is more consistent with GTKValueChanged() and allows making the
change in the upcoming commit.

No real changes yet, this is just a refactoring.
2021-04-21 09:02:51 +02:00
Vadim Zeitlin
e7c9bd32fd Fix return type of GtkSpinButton "output" signal handler
This doesn't seem to change anything in practice, but still use the
correct return type.

Co-Authored-By: Paul Cornett <paulcor@users.noreply.github.com>
2021-04-21 08:32:37 +02:00
Vadim Zeitlin
496aefbf88 Document wxSpinCtrl::SetValue("") behaviour
Mention that this is explicitly allowed now that it works.

Co-Authored-By: Dummy <dummy@trac.wxwidgets.org>
2021-04-20 22:23:14 +02:00
Vadim Zeitlin
ca0cf3ea59 Allow using a different text value in wxGTK wxSpinCtrl
Make it possible to use a string value different from the numeric value,
as wxMSW version allows this and some existing code depends on it.

Closes #19140.
2021-04-20 22:23:14 +02:00
PB
46867f591c Mark deprecated methods as such in wxIcon documentation
wxIcon::Set{Depth|Height|Width}() are deprecated (in wxGDIImage, see 26ee45e),
mark them as such in the documentation (should probably be a part of a5aa044a).

Also fix a typo.

Closes https://github.com/wxWidgets/wxWidgets/pull/2331
2021-04-20 00:21:51 +01:00
Vadim Zeitlin
bf5235e01c Merge branch 'explicit-image-from-xpm'
Make wxImage ctor from XPM data explicit to avoid surprising behaviour.

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

Closes #19149.
2021-04-20 00:21:16 +01:00
Vadim Zeitlin
e73a0c23ef Replace dynamic cast with a virtual GTKValueChanged() function
No real changes, but using a virtual function is simpler and safer than
using wxIsKindOf().
2021-04-20 01:13:15 +02:00
Vadim Zeitlin
3ac3763705 Always handle "input" and "output" signals in wxGTK wxSpinCtrl
No real changes yet, just refactor the code to always connect these
signals handlers and not just when using non-decimal base.

Add wxSpinCtrl::GTKInput() and GTKOutput() virtual methods to handle
these signals appropriately depending on the type of the control.

This will allow further customizing conversion to/from string in the
upcoming commit and will also make it possible to handle UI locale
different from the C locale in the future.
2021-04-20 01:13:15 +02:00
Vadim Zeitlin
8194f05553 Simplify event sending code by using GetTextValue()
Just use this function now that it's available rather than calling
gtk_entry_get_text() (and sometimes forgetting to specify UTF-8 encoding
explicitly).
2021-04-20 01:13:15 +02:00
Vadim Zeitlin
4b263ff10a Explicitly convert from UTF-8 in wxSpinCtrl::GetTextValue()
Use UTF-8 encoding explicitly rather than relying on it being the
default.
2021-04-20 01:06:24 +02:00
Dummy
f64da1eb36 Allow clearing spin controls in the widgets sample
Calling wxSpinCtrl::SetValue("") is always valid.

See #19140.
2021-04-20 00:59:22 +02:00
Vadim Zeitlin
34ab87ce4d Get rid of CppUnit boilerplate in wxSpinCtrlDouble unit test
This was already done for wxSpinCtrl unit tests in a4928c0fde (Use Catch
in wxSpinCtrl unit tests, 2020-07-12), do it for wxSpinCtrlDouble too
now.
2021-04-20 00:59:22 +02:00