SetValidator() had no effect if it was called after creating the editor,
but in some situations it is convenient to call it from BeginEdit(), as
we don't have the cell coordinates before it is called, so ensure that
the validator set using this function is actually used even if it's
called after creating the text control.
Current way of converting wxSpinCtrl value to integer does not work
for negative values. We can just use here integer value returned
by GetValue().
Closes#18802.
Even when wxEVT_GRID_CELL_CHANGED is really vetoed, it's still possible
that m_currentCellCoords was changed by the handler, so use the row/col
coordinates of the cell that was really changed instead of the possibly
different m_currentCellCoords value to avoid a bug similar to the one
fixed by the previous commit.
The changes of e6e6dbe077 (Fix problems due to deleting grid cells in
the event handlers, 2020-05-02) fixed the bug (see #18731), but
introduced another one in place: if wxEVT_GRID_CELL_CHANGED handler
deleted any cells, wxGrid code could mistakenly restore the "old" cell
value (actually it restored the value for a different cell, as the
current cell coordinates necessarily changed too in this case).
This bug became more visible after the addition of activatable editors
as the new code asserts, instead of trying to restore the old value, if
wxEVT_GRID_CELL_CHANGED is vetoed, which also resulted in asserts if the
handler deleted the current cell instead.
Fix this by separating the cases of event being really vetoed and of the
event handler deleting the cell for which the event was generated and
handle the latter separately from the former where it matters.
This commit is best viewed ignoring whitespace changes.
This is more verbose, but also much more clear (and so allows to remove
some previously necessary comments).
No real changes, even keep the same values for the enum elements as were
previously used: this is probably unnecessary but do it just to minimize
changes.
Avoid warnings about truncating double literals to float introduced by
the recent 895424ecc0 (Add wxWebView::SetZoomFactor(float) and
GetZoomFactor(), 2020-06-13) by using float literals in the first place.
See https://github.com/wxWidgets/wxWidgets/pull/1894
See #18769.
This makes it much more convenient to use interactively, as the cell
value is toggled immediately and, even more importantly, the UI doesn't
enter the confusing editing mode which doesn't look any different from
the normal grid appearance except for the current cell border absence.
Note that we still keep support for classic in-place editing to preserve
compatibility with the code which calls EnableCellEditControl()
explicitly and expects an editor to be shown, but perhaps we could
switch to using only activation in the future.
Add a helper class making it easier to define activation-only editors
and use it to implement MyGridStarEditor in the sample, showing a
typical example of using such editor.
This is useful for editors which don't really need to show any control
as they can change their value directly and will be used to reimplement
wxGridCellBoolEditor in the upcoming commits.
The changes of the commit 393f5c8e2b (Use less arbitrary column/row
sizes in the grid sample, 2020-03-31) accidentally made this column
narrower than default instead of making it wider due to a typo in the
name of wxGrid method: it should be the default column size, not the
default column label size.
Do it even when the cell value is not one of the recognized boolean
representations, as we later use m_value as an index into a 2 element
array and leaving it uninitialized could result in an out of bound
access, so make sure this doesn't happen.
No real changes, just factor out code for getting and setting the grid
cell value as bool from {Begin,Apply}Edit() to {Get,Set}GridValue() to
make it possible to reuse these functions in the upcoming commits.
This commit is best viewed with the --color-moved option.
Since 8189ce89ed (Improve wxTextCtrl::DoGetSizeFromTextSize() in wxOSX, 2020-05-28) GetSizeFromTextSize() is fully functional under wxOSX
so we can revert 39d586421b (Don't call GetSizeFromText() under wxOSX, 2020-05-21) and use GetSizeFromText() in calculating text box size.
Closes#18766.
It was unexpected that pressing Shift-Enter while an editor was active
didn't close it, but just selected the cell below (and then the one
below it if pressed again and so on), so now always finish editing when
it's pressed.
It could be argued that it's still unexpected for Shift-Enter to select
the cell below after closing the editor, but this is consistent with how
Tab works, and so shouldn't be as confusing as the old behaviour.
Although this variable, and a check for it in OnKeyDown(), was present
since the first version of this code added back in f85afd4e46 (Added new
wxGrid classes[...], 1999-10-06), there doesn't seem to be any
indication that it has ever been needed, so remove it to simplify the
code and make it possible to add early returns to this function easily.
No real changes yet.
Since the changes done in 8b2237cd2d (Make row/column drag-resizing in
wxGrid "live", 2020-03-01) the grid editor was dismissed whenever the
mouse crossed any row/column separator, which was, of course, wrong, as
it was only supposed to be hidden when row/column was actually resized,
i.e. when the separator was dragged by the mouse.
Fix this by moving calls to DoStartResizeRowOrCol() to more appropriate
places and do it only when the button is pressed now.
Note that it might actually be better to just disable column/row
resizing while a cell is being edited, but for now keep things working
as they did before and at least fix the latest regression which is
definitely unwanted.
It ended up returning the result of the base class method anyhow, just
after doing a lot of unnecessary work, so this commit shouldn't change
anything, but should significantly speed up this function.
We may want to explore the possibility of implementing this method
natively using GetPeer()->IsVisible() later, as it could be faster than
our own implementation, but we need to ensure that this always returns
the same result as before, which might not be the case when the TLW is
in the process of being shown or hidden, so don't do this for now.
Closes https://github.com/wxWidgets/wxWidgets/pull/1911Closes#18645.
Don't use NSLayoutManager lineFragmentRectForGlyphAtIndex:effectiveRange
when NSTextView is empty, as this result in debug error messages.
Fall back to using the font height in this case instead, as this seems
to be the only thing to do in this case.
Closes#18793.
No real changes, just use the value returned by the function to
determine if the cell is inside a multi-cell, instead of comparing
rows/columns with 0 to make code slightly more readable and self
explanatory.
Checking the new function return value is simpler than checking the
value of m_cellEditCtrlEnabled after calling EnableCellEditControl().
Do this now also when starting editing using the mouse, as it was simply
forgotten before and so StartingClick() was still called even if editing
was vetoed.
Also add DoDisableCellEditControl(), but this one exists purely for the
symmetry.
This also allows to reset m_cellEditCtrlEnabled earlier, as we don't
have to keep it true for the duration of HideCellEditControl()
execution.
No real changes, as with the previous commit, this one is best viewed
ignoring whitespace changes.
It doesn't make sense to perform the checks in ShowCellEditControl()
when it's called from EnableCellEditControl() and this makes the code
unnecessarily fragile as m_cellEditCtrlEnabled needs to be set at just
the right moment for it to work correctly.
Call the new DoShowCellEditControl() instead and perform the checks only
in the public function, for compatibility.
Also note in a comment and the documentation that ShowCellEditControl()
is not very useful anyhow and that EnableCellEditControl() should most
often be used instead.
No real changes (the commit is best viewed ignoring whitespace changes).