Extending the selection with Ctrl-arrows is different from all the other
cases, as we need to combine both the selection anchor and the current
cell coordinates when doing it.
This means that we can't reuse the same PrepareForSelectionExpansion()
helper for this case, so this function is not useful finally and this
commit removes it entirely. It also replaces GetCurrentBlockCornerRow()
and GetCurrentBlockCornerCol() functions with GetExtensionAnchor() which
combines both of them.
Finally, it adds wxGridDirectionOperations::TryToAdvance() helper to
avoid repeating the IsAtBoundary() check which was previously part of
PrepareForSelectionExpansion() in multiple places.
And because the "extending" and normal parts of DoMoveCursorByBlock()
are so different now, it also factors out AdvanceByBlock() helper which
can be used to keep these parts well separate from each other instead of
intermixing them together.
With all these preparatory changes, it's finally possible to implement
the "extending selection by block" logic relatively easily, with the
bulk of this branch actually taken by comments explaining why do we have
to do what we do.
Add unit tests verifying that the functions used by Shift-Ctrl-arrow
work as expected.
This seems to be more consistent with the existing functions and doesn't
create ambiguity with a grid range.
Also rename wxGridSelectionRange to just wxGridBlocks as, in principle,
this class could be used for iterating over any blocks, not just the
selected ones.
No changes in functionality, this is just a renaming.
Don't try to extend the existing selected blocks to rows/columns, this
contradicts the documented behaviour which is to discard the selected
blocks that become invalid in the new mode.
Do handle switching to wxGridSelectRowsOrColumns mode, as there doesn't
seem to be any reason not to.
Update the tests to check for the expected selection update behaviour.
Change the return type of this function to a simple and clear bool
instead of 3-valued int requiring a special explanation. This is simpler
and not any less efficient as checking for whether one block contains
another or the other one contains this one are separate operations
anyhow.
Rename the function to a more grammatically correct name.
Also move it inline as it's now trivial enough for this to be worth it.
This class was a strange hybrid of a container/view/range and iterator,
as it both provided begin()/end() container-like methods and
iterator-like methods for dereferencing/advancing.
Simplify this by removing the latter part and making this class really
just a range, with its own iterator class in order to avoid leaking the
exact type of the iterator used in the API.
Note that while it's now completely trivial, it is still useful as it
isolates the application code from the vector used to store the selected
blocks currently and will allow to change internal representation in the
future without breaking the existing code.
Check that creating a wxTextCtrl doesn't generate any events to verify
that this problem doesn't exist in other ports, after fixing it in
wxGTK in 3e7e7dd24c (Avoid generating wxEVT_TEXT when wxTextCtrl initial
value is not empty, 2020-04-01).
Since the changes in a40acbb28e (Add CanOverflow function to
wxGridCellAttr, 2020-02-06), cells with non-default vertical alignment
didn't overflow any more, even if their horizontal alignment was
unchanged and still defaulted to left-aligned.
This was due to assuming that if the alignment of wxGridCellAttr itself
was different from wxALIGN_LEFT, it meant that it wasn't left-aligned,
which seems logical but is in fact false, as the alignment can also be
wxALIGN_INVALID, in which case the real alignment is taken from the
default grid attribute.
Fix this by using GetNonDefaultAlignment() to get the alignment value
effectively used and add a unit test, as well as an example in the
sample, showing that this now works correctly.
Somehow emulating the column resizing doesn't work there, even though it
works perfectly reliably locally. This might be due to some display
optimization options used in this environment, but it's difficult to
debug what's going on there, so just disable the test when running under
AppVeyor for now.
Update the column width immediately, as it's being dragged, instead of
drawing a temporary line showing the new column boundary using wxINVERT.
This results in better user experience, as it the effect of changing the
column width can be immediately seen (especially important for non-left
aligned columns or columns using ellipsizition) and, equally if not more
importantly, fixes wxGrid drag-resize not showing any visible UI at all
with wxGTK3 and wxOSX where wxINVERT is not implemented.
Instead of using a single test case, with multiple sections, generated
by CppUnit compatibility macros, use multiple independent test cases.
This makes it more convenient to run individual tests, simplifies the
code and allows to get rid of ugly "pseudo tests".
This file is never compiled with wxUSE_GUI==1, so having these tests
here is not really useful.
It's unfortunately that the absence of warnings from wxLogStatus() is
not checked currently, but it doesn't seem worth recompiling the entire
test case or adding a new one just for this.
This variable doesn't exist any more, but now it's possible to use
CPPFLAGS directly and get rid of the hack which required it to be used
in the first place.
CPPFLAGS, CFLAGS, CXXFLAGS and LDFLAGS are supposed to be under
user-control and putting configure-determined options in them broke
something as simple as running "make CXXFLAGS=-Wno-some-extra-warning"
because this overrode the CXXFLAGS set by configure and required for
build.
Improve this by using WX_*FLAGS in the generated makefile and leaving
the user-controlled FLAGS alone. This is still not ideal as running
"configure CFLAGS=-DFOO" and then "make CFLAGS=-DBAR" will define both
FOO and BAR, as configure copies CFLAGS to WX_CFLAGS, and so setting it
on make command line won't override it, as it should, but this should be
a much more rare and also much less severe problem, so we should be able
to live with it for now.
Normally this commit shouldn't result in any user-visible changes, i.e.
it shouldn't break any previously working scenarios and only make some
previously broken ones work.
This doesn't work anyhow, so it's better to prevent the code doing this
from compiling instead of getting run-time asserts or worse.
Also simplify construction of these events inside wxWidgets by passing
the window itself to the ctor instead of passing just its ID and calling
SetEventObject() separately later.
For consistency, do the same thing for wxNcPaintEvent too.
This escape character doesn't seem to be handled by IE in the default
emulation mode and it's not worth complicating the test code just to
test for it, so simply remove it from the test.
Instead of specializing wxStrtoxCharType and then testing whether endptr
is null, just define separate, and simpler, overloads of wxStrtox()
functions taking nullptr_t -- we can avoid the unnecessary test
completely in this case, as nullptr is, by definition, always null
anyhow.
Also add a test of using wxStrtol() with nullptr too.
This should fix the build with older gcc and MSVS versions.
Remove the check that the size representation was the same as float and
as double, which was supposed to catch various edge cases (NaNs, huge
numbers etc) but actually caught plenty of perfectly valid font sizes
such as 13.8 that simply lost precision when converting from double to
float.
Just check that the size is positive and less than FLT_MAX to avoid
using values that really don't make sense as font sizes.
Also add a unit test checking that using fractional font sizes in
description string works as expected.
Closes#18590.
Closes https://github.com/wxWidgets/wxWidgets/pull/1707
This script used to live in oss-fuzz repository itself (under
projects/wxwidgets), but it seems better to have it in the main
repository, as this will make modifying it, e.g. to add new fuzzers,
simpler.