Commit Graph

22 Commits

Author SHA1 Message Date
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
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
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
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
Vadim Zeitlin
f2d5ff0121 Make wxNumValidator::m_value protected rather than private
This is useful for writing overridden TransferXXX() methods in the
derived validator classes, give a motivating example in the docs.

See https://github.com/wxWidgets/wxWidgets/pull/2222
2021-02-08 22:43:48 +01:00
Paul Cornett
de7ab5527b Avoid -Wdouble-promotion warnings in headers 2020-07-20 08:12:02 -07:00
Vsevolod V Gromov
20c7421a67 Add Get{Min,Max,Range}() to numeric validator classes
Just provide accessors matching the existing setters.

Closes https://github.com/wxWidgets/wxWidgets/pull/1287,
https://github.com/wxWidgets/wxWidgets/pull/1288
2019-04-18 16:47:02 +02:00
Vadim Zeitlin
f7514dc79d Suppress harmless gcc -Wfloat-equal in wxNumValidator code
Exact comparison with 0 here is fine, so just disable the warning for
this code.

Closes #18271.
2018-11-20 14:11:53 +01:00
Vadim Zeitlin
b1e59a6d60 Add wxFloatingPointValidator::SetFactor()
This allows displaying values in percents (or also currency units and
subunits, for example) without changing the actually stored value.
2018-01-26 14:39:57 +01:00
Vadim Zeitlin
a6d677a0fe Check for correct window in wxNumValidatorBase::SetWindow()
Override SetWindow() to check that the validator is being associated
with the window of the correct type, this allows to trigger an assert
immediately if this is not the case, making it simpler to find the error
as the call to SetValitator() on the wrong window will be in the call
stack when this happens, unlike before when the assert would happen only
at some later time.
2018-01-07 01:26:53 +01:00
Vadim Zeitlin
48faeb65b3 Fix copy ctor in numeric validators classes
wxFloatingPointValidator and wxIntegerValidator copy ctor didn't copy
the associated window, so it was lost when the validator was Clone()'d.

Fix this by correctly using wxValidator copy ctor, instead of the
default one, in the copy ctor of the common wxNumValidatorBase base
class.
2018-01-04 21:39:57 +01:00
Vadim Zeitlin
f83d16aa46 Undefine min and max before using them in wx/valnum.h
Avoid problems when using this header in code also include <windows.h>
(and not doing it via wx/msw/wrapwin.h) by ensuring that min and max
used here are not defined as macros.
2017-12-26 04:29:42 +01:00
Vadim Zeitlin
9db6f6ca1a Make wx/valnum.h self-contained by including wx/textentry.h
This header uses (i.e. forward declaration wouldn't be sufficient)
wxTextEntry, so it must include the header declaring it.
2016-12-09 01:58:14 +01:00
Maarten
977a826639 use more wxOVERRIDE (#329) 2016-09-25 13:21:28 -07:00
Paul Cornett
27a8d28029 more use of wxOVERRIDE 2015-09-06 17:20:42 -07:00
Vadim Zeitlin
f4b80e5337 Remove MSVC6 support.
Don't support this compiler any more, this allows to get rid of tons of
MSVC6-specific workarounds, in particular we can now use Bind() and natural
template functions calls in the library code.

Also remove MSVC6 project and solution files and don't generate them when
bakefile_gen is ran any more (removing the remaining occurrences of msvc6prj
from the bakefiles results in weird bake-time errors, so it's simpler to just
leave them there).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76532 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-05-15 22:32:17 +00:00
Stefan Csomor
e71baaa811 calling explicit base class constructor from copy constructor
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67215 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-03-16 10:55:30 +00:00
Stefan Csomor
f5f3d4ec5c clang fix
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66791 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-01-27 17:15:40 +00:00
Stefan Csomor
df04f800b8 supporting clang 2.0 under xcode, see #12332
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66780 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-01-27 11:00:26 +00:00
Vadim Zeitlin
6496afbab8 Work around wxNumValidator compilation problems with MSVC 6.
Surprisingly, MSVC 6 seems to be able to compile most of the code but chokes
on a wxCOMPILE_TIME_ASSERT involving an inherited typedef. As this assert is
not critical, simply disable it for this compiler.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66722 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-01-19 23:47:09 +00:00
Vadim Zeitlin
a54cf37118 Add wxIntegerValidator and wxFloatingPointValidator classes.
Add validators for integer and floating point numbers.

Add an example of their use to the validate sample as well as a new unit test
and documentation for them.

Use the new classes instead of wxTextValidator in wxGrid code.

Closes #12166.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66714 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-01-19 10:48:28 +00:00