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.
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).
This check was introduced back in 283b7808d8 (added support for readonly
cells and 3d border drawing, 2000-02-16), but was wrong even then and
remained wrong ever since: we must not set m_cellEditCtrlEnabled to true
when the current cell is read-only, so there is no need to check for the
latter condition if m_cellEditCtrlEnabled is indeed true.
Ensure that we really never erroneously set m_cellEditCtrlEnabled for
the read-only cells by replacing an wxASSERT_MSG checking for this in
EnableCellEditControl() with wxCHECK_RET().
Also explicitly document this function precondition, also added back in
b54ba67107 ([...] added CanEnableCellControl() and use it before calling
EnableEC, 2000-02-17) but never documented so far.
This code seems to have been there ever since da6af900f1 (Added
drag-shrinking, 2000-02-04), but while it probably made sense back then,
it lost its purpose a long time ago as the cell editor is now not only
hidden, but also disabled when drag-resizing starts, so it doesn't make
sense to attempt showing it back when the mouse button is released: it's
never going to do anything (and didn't).
Just remove this code, as hiding the editor while drag-resizing is not
the behaviour we want from the UI point of view anyhow. And, again,
removing it doesn't actually change anything in the current version of
the code.
Apply the utility from https://github.com/codespell-project/codespell/
to fix spelling issues in the headers under both include and interface
directories and add a file with a couple of exceptions.
The exact command line used was:
$ codespell -w -I misc/scripts/codespell.ignore -i 3 in*
This allows to fold the last DoSaveEditControlValue() call into this
function, so that it's only called from DoAcceptCellEditControl() or
from SaveEditControlValue() (which is public, and hence can't be
changed, even if its behaviour doesn't make much sense).
This commit means that m_cellEditCtrlEnabled is now reset to false when
AcceptCellEditControlIfShown() is called, which was not the case before,
but this seems to make sense, as we shouldn't be just hiding the editor
while leaving it enabled, and, also, doesn't really seem to change
anything as hiding the editor indirectly results in a call to
DisableCellEditControl(), via wxGrid::OnHideEditor(), and so it was
actually already reset before -- but now this happens slightly earlier
and more explicitly.
This is just another refactoring in order to avoid duplicating calls to
HideCellEditControl() and SaveEditControlValue() in several different
places.
Also call DoSaveEditControlValue() because if the editor is shown, it is
also necessarily enabled and there is no need to check for this.
We can't make wxClientDC work on the platforms not supporting drawing
outside of wxEVT_PAINT handler, but at least document that this doesn't
work.
Also add an example of using this class for the purpose for which it
still works (measuring) and remove references to it and wxWindowDC from
wxPaintDC documentation as we don't want to encourage people using it.
See #17820.
No real changes, just simplify the code by using a single function to
retrieve the editor to use for the current cell.
This also allows to get rid of a few temporary variables, further
amplifying the simplification.
Pressing Esc while double clicking on the column separator in the native
header in wxGrid could result in a crash due to using invalid index when
calling GetColLeft(m_dragRowOrCol) in GetPositionForResizeEvent() called
from DoHeaderEndDragResizeCol() because m_dragRowOrCol had been already
reset to -1.
Guard against the crash with a check in GetPositionForResizeEvent()
itself and also add a check to DoHeaderDragResizeCol() to avoid calling
the former function in this case.
Reproducing the original problem is relatively simple as it's enough to
just keep double clicking a column separator while also pressing Esc,
but catching it under debugger is much more complicated and so it's not
really clear how exactly does this happen, but tracing shows that the
native control just decides to generate two HDN_ENDTRACK messages
without any intervening HDN_BEGINTRACK, so it doesn't seem like we can
do anything else than just silently ignore the unwanted HDN_ENDTRACK, as
it's done in this commit.