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 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.
The recent change of 19844d27ac fixed this
function for valid values of input/output parameters on input, but broke
it if the parameters had invalid value: in this case, we still need to
fill them even if this attribute doesn't have any specific alignment of
its own.
Account for this case too now, explain the logic of this function in the
comments inside it and extend the unit test to check for this case too.
Now the function should really conform to its documented (and expected,
including by the existing code in various grid renderers) behaviour.
Closes https://github.com/wxWidgets/wxWidgets/pull/1665
A just created control shouldn't be considered modified, so reset its
modified state in Create().
And add a unit test checking that IsModified() really behaves as
expected.
Closes https://github.com/wxWidgets/wxWidgets/pull/1652
This function is not supposed to overwrite the given alignment values
unless the alignment is specifically set for the given cell, but it
always overwrote them when called on m_defaultCellAttr, i.e. the
attribute used by the cells that don't have any special attribute.
This meant that custom attributes had to be set (or, more efficiently, a
custom attribute provider returning non-null attributes for all cells
had to be used) previously just to make the right alignment used by
default by number or date renderers work.
Fix this by ignoring the values set in the default attribute in this
function.
Also add a unit test (which required adding a special helper class just
to allow testing wxGrid::GetCellAttr() used by the renderers) that used
to fail but passes now.
Ensure that last wxDataViewCtrl columns is always expanded to fit the
control width and a unit test checking for the scenario in which this
wasn't the case before, but is now.
See https://github.com/wxWidgets/wxWidgets/pull/1313
Fixes to wxUIActionSimulator allowing the tests using it to work for
wxGrid in wxGTK.
And some improvements and bug fixes to wxGrid itself.
Closes https://github.com/wxWidgets/wxWidgets/pull/1609
Fix autosizing broken in 3c72396a36 and
not fully fixed by f7e335c031.
Simplify the code to make it more obviously correct, by separating the
computation of the extent suitable for the label and determining the
size to use taking into account the extents of both the column data and
the its column.
Also add the unit test checking that auto-sizing works correctly in all
the different cases.
Closes https://github.com/wxWidgets/wxWidgets/pull/1600
Co-Authored-By: Ilya Sinitsyn <the_siv@mail.ru>
Restore the checks for the model stamp, reverting the changes of
18594afe76: we still need to ignore the
calls to at least iter_children() and iter_nth_child() model methods
that can be called from inside gtk_tree_view_set_model() when we reset
the model, as running these methods crashes when trying to use the
pointers to already deleted items.
For consistency and robustness, add checks for the model stamp to all
the methods and not just those two, just in case other ones end up being
called later in some way.
Also add a unit test checking that DeleteAllItems() doesn't crash and
does delete all items.
Closes#18533.
This is an ugly workaround for a mysterious problem occurring with the
simulated "Enter" presses under GTK, but it's worth it, as it allows all
grid tests, including the ones using wxUIActionSimulator, to pass now
under wxGTK2 (a couple of tests still fail under wxGTK3).
These tests are still disabled by default during run-time, but at least
allow explicitly enabling them (by setting WX_UI_TESTS=1) even when
using wxGTK where they're known to fail.
gtk_widget_get_preferred_size() return zero size if the GTK widget is
hidden, so show it temporarily in order to find its real preferred size.
Add a unit test checking that the best size of a hidden wxChoice is now
determined correctly.
Closes https://github.com/wxWidgets/wxWidgets/pull/1587
Adjust the length limit before pasting to ensure that all text on
clipboard will be successfully pasted, instead of only pasting the part
of it which fits.
Add a unit test checking that this works.
Closes#4646.
Collapsing a branch shouldn't deselect all the items under it in
multi-selection mode: this doesn't seem to be useful or otherwise make
sense and makes the generic version gratuitously incompatible with the
native MSW one.
Closes#10239.
Closes https://github.com/wxWidgets/wxWidgets/pull/1581
Check that adding a window to either the same, or different, sizer the
second time asserts -- but that it can still be moved to another sizer
if it is detached from the first one first.
Also document that SetContainingSizer() should never be called from
outside the library.
See #17166.